]> granicus.if.org Git - php/commitdiff
lame implementation of SQLSTATE error codes
authorWez Furlong <wez@php.net>
Fri, 7 Jan 2005 05:25:57 +0000 (05:25 +0000)
committerWez Furlong <wez@php.net>
Fri, 7 Jan 2005 05:25:57 +0000 (05:25 +0000)
ext/pdo_pgsql/pgsql_driver.c

index ca833326964cf298343efc57bad0d90ccc54fed3..c5071e13faf6ff0d7abcaff3a1e61ec6bf42c474 100644 (file)
@@ -55,7 +55,7 @@ static char * _pdo_pgsql_trim_message(const char *message, int persistent)
 int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *file, int line TSRMLS_DC) /* {{{ */
 {
        pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
-       enum pdo_error_type *pdo_err = stmt ? &stmt->error_code : &dbh->error_code;
+       pdo_error_type *pdo_err = stmt ? &stmt->error_code : &dbh->error_code;
        pdo_pgsql_error_info *einfo = &H->einfo;
        char *errmsg = PQerrorMessage(H->server);
 
@@ -69,12 +69,8 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *
        }
 
        switch (errcode) {
-               case PGRES_EMPTY_QUERY:
-                       *pdo_err = PDO_ERR_SYNTAX;
-                       break;
-
                default:
-                       *pdo_err = PDO_ERR_CANT_MAP;
+                       strcpy(*pdo_err, "HY000");
                        break;
        }
 
@@ -83,8 +79,8 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *
        }
 
        if (!dbh->methods) {
-               zend_throw_exception_ex(php_pdo_get_exception(), *pdo_err TSRMLS_CC, "[%d] %s",
-                               einfo->errcode, einfo->errmsg);
+               zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
+                               *pdo_err, einfo->errcode, einfo->errmsg);
        }
        
        return errcode;