summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2010-01-12 12:46:54 +0000
committerIlia Alshanetsky <iliaa@php.net>2010-01-12 12:46:54 +0000
commitc2ed5e6f9d04c09bbffb3b453bf54a940011126f (patch)
tree3e774eaee6f75e4ecded5a567df18de5b5f5961f /ext
parentcf881fc0f523b00846580481f0cbbf68c326c3e6 (diff)
downloadphp-git-c2ed5e6f9d04c09bbffb3b453bf54a940011126f.tar.gz
Fixed bug #50728 (All PDOExceptions hardcode 'code' property to 0)
Diffstat (limited to 'ext')
-rw-r--r--ext/pdo_dblib/dblib_driver.c2
-rw-r--r--ext/pdo_firebird/firebird_driver.c2
-rwxr-xr-xext/pdo_mysql/mysql_driver.c2
-rwxr-xr-xext/pdo_oci/oci_driver.c2
-rwxr-xr-xext/pdo_odbc/odbc_driver.c8
-rw-r--r--ext/pdo_pgsql/pgsql_driver.c2
-rw-r--r--ext/pdo_sqlite/sqlite_driver.c2
-rw-r--r--ext/pdo_sqlite/tests/bug50728.phpt16
8 files changed, 23 insertions, 13 deletions
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c
index 2f68a9d6a9..dd59769862 100644
--- a/ext/pdo_dblib/dblib_driver.c
+++ b/ext/pdo_dblib/dblib_driver.c
@@ -255,7 +255,7 @@ cleanup:
dbh->driver_data = H;
if (!ret) {
- zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC,
+ zend_throw_exception_ex(php_pdo_get_exception(), DBLIB_G(err).dberr TSRMLS_CC,
"SQLSTATE[%s] %s (severity %d)",
DBLIB_G(err).sqlstate,
DBLIB_G(err).dberrstr,
diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c
index 82bc9920bd..e19efa3cf5 100644
--- a/ext/pdo_firebird/firebird_driver.c
+++ b/ext/pdo_firebird/firebird_driver.c
@@ -686,7 +686,7 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
char errmsg[512];
ISC_STATUS *s = H->isc_status;
isc_interprete(errmsg, &s);
- zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
+ zend_throw_exception_ex(php_pdo_get_exception(), H->isc_status[1] TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
"HY000", H->isc_status[1], errmsg);
}
diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c
index 9774554f37..52d7437d75 100755
--- a/ext/pdo_mysql/mysql_driver.c
+++ b/ext/pdo_mysql/mysql_driver.c
@@ -127,7 +127,7 @@ int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int lin
if (!dbh->methods) {
PDO_DBG_INF("Throwing exception");
- zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
+ zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
*pdo_err, einfo->errcode, einfo->errmsg);
}
diff --git a/ext/pdo_oci/oci_driver.c b/ext/pdo_oci/oci_driver.c
index 0b606eb4c0..aa3671a0f3 100755
--- a/ext/pdo_oci/oci_driver.c
+++ b/ext/pdo_oci/oci_driver.c
@@ -173,7 +173,7 @@ ub4 _oci_error(OCIError *err, pdo_dbh_t *dbh, pdo_stmt_t *stmt, char *what, swor
/* little mini hack so that we can use this code from the dbh ctor */
if (!dbh->methods) {
- zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s]: %s", *pdo_err, einfo->errmsg);
+ zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode TSRMLS_CC, "SQLSTATE[%s]: %s", *pdo_err, einfo->errmsg);
}
return einfo->errcode;
diff --git a/ext/pdo_odbc/odbc_driver.c b/ext/pdo_odbc/odbc_driver.c
index aba37aad23..fb841ef3a0 100755
--- a/ext/pdo_odbc/odbc_driver.c
+++ b/ext/pdo_odbc/odbc_driver.c
@@ -85,15 +85,9 @@ void pdo_odbc_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, PDO_ODBC_HSTMT statement,
einfo->what = what;
strcpy(*pdo_err, einfo->last_state);
-/* printf("@@ SQLSTATE[%s] %s\n", *pdo_err, einfo->last_err_msg); */
if (!dbh->methods) {
-#if PHP_VERSION_ID > 50200
- zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] %s: %d %s",
+ zend_throw_exception_ex(php_pdo_get_exception(), einfo->last_error TSRMLS_CC, "SQLSTATE[%s] %s: %d %s",
*pdo_err, what, einfo->last_error, einfo->last_err_msg);
-#else
- zend_throw_exception_ex(php_pdo_get_exception(TSRMLS_C), 0 TSRMLS_CC, "SQLSTATE[%s] %s: %d %s",
- *pdo_err, what, einfo->last_error, einfo->last_err_msg);
-#endif
}
}
/* }}} */
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c
index 4b6b437b2c..647309e607 100644
--- a/ext/pdo_pgsql/pgsql_driver.c
+++ b/ext/pdo_pgsql/pgsql_driver.c
@@ -87,7 +87,7 @@ 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(), 0 TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
+ zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
*pdo_err, einfo->errcode, einfo->errmsg);
}
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c
index 4a91569d46..f315d0aa9e 100644
--- a/ext/pdo_sqlite/sqlite_driver.c
+++ b/ext/pdo_sqlite/sqlite_driver.c
@@ -102,7 +102,7 @@ int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int li
}
if (!dbh->methods) {
- zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
+ zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
*pdo_err, einfo->errcode, einfo->errmsg);
}
diff --git a/ext/pdo_sqlite/tests/bug50728.phpt b/ext/pdo_sqlite/tests/bug50728.phpt
new file mode 100644
index 0000000000..3dbbb1ffff
--- /dev/null
+++ b/ext/pdo_sqlite/tests/bug50728.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #50728 (All PDOExceptions hardcode 'code' property to 0)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
+?>
+--FILE--
+<?php
+try {
+ $a = new PDO("sqlite:/this/path/should/not/exist.db");
+} catch (PDOException $e) {
+ var_dump($e->getCode());
+}
+?>
+--EXPECTF--
+int(14)