From: Matteo Beccati Date: Sun, 9 Mar 2014 11:14:23 +0000 (+0100) Subject: Deprecated PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT X-Git-Tag: php-5.6.0beta1~3^2~105 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d72621ab9e8a6cc89fe1005a83c16249fdc02810;p=php Deprecated PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT --- diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index b1fa4f88f5..0d72d5573e 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -239,8 +239,11 @@ static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, spprintf(&S->cursor_name, 0, "pdo_crsr_%08x", ++H->stmt_counter); emulate = 1; } else if (driver_options) { - if (pdo_attr_lval(driver_options, PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, H->disable_native_prepares TSRMLS_CC) == 1 || - pdo_attr_lval(driver_options, PDO_ATTR_EMULATE_PREPARES, H->emulate_prepares TSRMLS_CC) == 1) { + if (pdo_attr_lval(driver_options, PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, H->disable_native_prepares TSRMLS_CC) == 1) { + php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead"); + emulate = 1; + } + if (pdo_attr_lval(driver_options, PDO_ATTR_EMULATE_PREPARES, H->emulate_prepares TSRMLS_CC) == 1) { emulate = 1; } } else { @@ -1106,6 +1109,7 @@ static int pdo_pgsql_set_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) H->emulate_prepares = Z_LVAL_P(val); return 1; case PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT: + php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead"); H->disable_native_prepares = Z_LVAL_P(val); return 1; default: diff --git a/ext/pdo_pgsql/php_pdo_pgsql_int.h b/ext/pdo_pgsql/php_pdo_pgsql_int.h index 037344ab94..34d89d2078 100644 --- a/ext/pdo_pgsql/php_pdo_pgsql_int.h +++ b/ext/pdo_pgsql/php_pdo_pgsql_int.h @@ -44,10 +44,9 @@ typedef struct { pdo_pgsql_error_info einfo; Oid pgoid; /* The following two variables have the same purpose. Unfortunately we need - to keep track of two different attributes having the same effect. - It might be worth to deprecate the driver specific one soon. */ + to keep track of two different attributes having the same effect. */ int emulate_prepares; - int disable_native_prepares; + int disable_native_prepares; /* deprecated since 5.6 */ unsigned int stmt_counter; } pdo_pgsql_db_handle; diff --git a/ext/pdo_pgsql/tests/bug48764.phpt b/ext/pdo_pgsql/tests/bug48764.phpt index 67e8f3971f..83fa5655d8 100644 --- a/ext/pdo_pgsql/tests/bug48764.phpt +++ b/ext/pdo_pgsql/tests/bug48764.phpt @@ -104,7 +104,7 @@ function bug($db, $options = array()) { } } ---EXPECT-- +--EXPECTF-- Test 1 42P18 Test 2 @@ -112,23 +112,43 @@ Test 2 OK Test 3 42P18 + +Deprecated: PDO::prepare(): PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead in %s on line %d OK Test 4 OK 42P18 Test 5 + +Deprecated: PDO::setAttribute(): PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead in %s on line %d + +Deprecated: PDO::prepare(): PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead in %s on line %d OK + +Deprecated: PDO::setAttribute(): PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead in %s on line %d 42P18 Test 6 OK 42P18 OK + +Deprecated: PDO::__construct(): PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead in %s on line %d Test 7 + +Deprecated: PDO::prepare(): PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead in %s on line %d OK + +Deprecated: PDO::prepare(): PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead in %s on line %d OK 42P18 + +Deprecated: PDO::__construct(): PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead in %s on line %d Test 8 + +Deprecated: PDO::prepare(): PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead in %s on line %d OK + +Deprecated: PDO::prepare(): PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated, use PDO::ATTR_EMULATE_PREPARES instead in %s on line %d OK OK 42P18 diff --git a/ext/pdo_pgsql/tests/bug_33876.phpt b/ext/pdo_pgsql/tests/bug_33876.phpt index 6a93905b43..15c4275d80 100644 --- a/ext/pdo_pgsql/tests/bug_33876.phpt +++ b/ext/pdo_pgsql/tests/bug_33876.phpt @@ -54,7 +54,7 @@ echo "EMUL\n"; $res = $db->prepare('SELECT foo from test where bar = ?', array( - PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => true)); + PDO::ATTR_EMULATE_PREPARES => true)); # this is the portable approach to binding a bool $res->bindValue(1, false, PDO::PARAM_BOOL);