]> granicus.if.org Git - php/commitdiff
Deprecated PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT
authorMatteo Beccati <mbeccati@php.net>
Sun, 9 Mar 2014 11:14:23 +0000 (12:14 +0100)
committerMatteo Beccati <mbeccati@php.net>
Tue, 11 Mar 2014 22:10:48 +0000 (23:10 +0100)
ext/pdo_pgsql/pgsql_driver.c
ext/pdo_pgsql/php_pdo_pgsql_int.h
ext/pdo_pgsql/tests/bug48764.phpt
ext/pdo_pgsql/tests/bug_33876.phpt

index b1fa4f88f58530a806f953938d616e1b0941dfaa..0d72d5573e305ea771e8079675e9f3298ce91359 100644 (file)
@@ -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:
index 037344ab943398d47dc77487304c671ac29d4abc..34d89d20783b808084ee4029e2cb0ab05cd99e92 100644 (file)
@@ -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;
 
index 67e8f3971fb0ef029a4a9395fbb480ee0b9376c3..83fa5655d8ef89097043c1f97dfcba6c05c83718 100644 (file)
@@ -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
index 6a93905b439f323d2149b456d9f23beca5953945..15c4275d80c33dff5404158e44d5fe374b322cdf 100644 (file)
@@ -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);