]> granicus.if.org Git - php/commitdiff
Remove PDOStatement::activeQueryString()
authorAdam Baratz <adambaratz@php.net>
Tue, 20 Dec 2016 14:58:50 +0000 (09:58 -0500)
committerAdam Baratz <adambaratz@php.net>
Tue, 20 Dec 2016 16:06:38 +0000 (11:06 -0500)
NEWS
ext/pdo/pdo_stmt.c
ext/pdo/tests/active_query_string.phpt [deleted file]
ext/pdo_dblib/dblib_driver.c

diff --git a/NEWS b/NEWS
index d5712707b98cc00a06382d60bdb3b0b10c9723f4..e4588aa1f22d5f9c486e56d04ef3028298428473 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -58,9 +58,6 @@ PHP                                                                        NEWS
 - Mcrypt:
   . The deprecated mcrypt extension has been moved to PECL. (leigh)
 
-- PDO:
-  . Add PDOStatement::activeQueryString(). (Adam Baratz)
-
 - PDO_DBlib:
   . Fixed bug #73234 (Emulated statements let value dictate parameter type).
     (Adam Baratz)
index 9bd161f8fec68733ea8bca207f239948cf1d1bc5..9f61a052c4fe1ad757f35c094213a6f8307e0f9c 100644 (file)
@@ -486,12 +486,6 @@ static PHP_METHOD(PDOStatement, execute)
                 * quoted.
          */
 
-               /* string is leftover from previous calls so PDOStatement::activeQueryString() can access */
-               if (stmt->active_query_string && stmt->active_query_string != stmt->query_string) {
-                       efree(stmt->active_query_string);
-               }
-               stmt->active_query_string = NULL;
-
                ret = pdo_parse_params(stmt, stmt->query_string, stmt->query_stringlen,
                        &stmt->active_query_string, &stmt->active_query_stringlen);
 
@@ -510,6 +504,10 @@ static PHP_METHOD(PDOStatement, execute)
                RETURN_FALSE;
        }
        if (stmt->methods->executer(stmt)) {
+               if (stmt->active_query_string && stmt->active_query_string != stmt->query_string) {
+                       efree(stmt->active_query_string);
+               }
+               stmt->active_query_string = NULL;
                if (!stmt->executed) {
                        /* this is the first execute */
 
@@ -528,6 +526,10 @@ static PHP_METHOD(PDOStatement, execute)
 
                RETURN_BOOL(ret);
        }
+       if (stmt->active_query_string && stmt->active_query_string != stmt->query_string) {
+               efree(stmt->active_query_string);
+       }
+       stmt->active_query_string = NULL;
        PDO_HANDLE_STMT_ERR();
        RETURN_FALSE;
 }
@@ -2090,22 +2092,6 @@ static PHP_METHOD(PDOStatement, closeCursor)
 }
 /* }}} */
 
-/* {{{ proto string PDOStatement::activeQueryString()
-   Fetch the last executed query string associated with the statement handle */
-static PHP_METHOD(PDOStatement, activeQueryString)
-{
-       PHP_STMT_GET_OBJ;
-
-       if (stmt->active_query_string) {
-               RETURN_STRING(stmt->active_query_string);
-       } else if (stmt->query_string) {
-               RETURN_STRING(stmt->query_string);
-       } else {
-               RETURN_FALSE;
-       }
-}
-/* }}} */
-
 /* {{{ proto void PDOStatement::debugDumpParams()
    A utility for internals hackers to debug parameter internals */
 static PHP_METHOD(PDOStatement, debugDumpParams)
@@ -2184,7 +2170,6 @@ const zend_function_entry pdo_dbstmt_functions[] = {
        PHP_ME(PDOStatement, setFetchMode,      arginfo_pdostatement_setfetchmode,      ZEND_ACC_PUBLIC)
        PHP_ME(PDOStatement, nextRowset,        arginfo_pdostatement__void,                     ZEND_ACC_PUBLIC)
        PHP_ME(PDOStatement, closeCursor,       arginfo_pdostatement__void,                     ZEND_ACC_PUBLIC)
-       PHP_ME(PDOStatement, activeQueryString, arginfo_pdostatement__void,             ZEND_ACC_PUBLIC)
        PHP_ME(PDOStatement, debugDumpParams, arginfo_pdostatement__void,               ZEND_ACC_PUBLIC)
        PHP_ME(PDOStatement, __wakeup,          arginfo_pdostatement__void,                     ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
        PHP_ME(PDOStatement, __sleep,           arginfo_pdostatement__void,                     ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
@@ -2332,9 +2317,6 @@ PDO_API void php_pdo_free_statement(pdo_stmt_t *stmt)
        if (stmt->methods && stmt->methods->dtor) {
                stmt->methods->dtor(stmt);
        }
-       if (stmt->active_query_string && stmt->active_query_string != stmt->query_string) {
-               efree(stmt->active_query_string);
-       }
        if (stmt->query_string) {
                efree(stmt->query_string);
        }
diff --git a/ext/pdo/tests/active_query_string.phpt b/ext/pdo/tests/active_query_string.phpt
deleted file mode 100644 (file)
index a0130e0..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
---TEST--
-PDO Common: PDOStatement::activeQueryString()
---SKIPIF--
-<?php
-if (!extension_loaded('pdo')) die('skip');
-$dir = getenv('REDIR_TEST_DIR');
-if (false == $dir) die('skip no driver');
-require_once $dir . 'pdo_test.inc';
-PDOTest::skip();
-
-$db = PDOTest::factory();
-if (!$db->getAttribute(PDO::ATTR_EMULATE_PREPARES) && !$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true)) die('skip driver cannot emulate prepared statements');
-?>
---FILE--
-<?php
-if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
-require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
-
-$db = PDOTest::factory();
-$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
-
-$quoted_true = $db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql' ? "'t'" : '1';
-
-$stmt = $db->query('SELECT 1');
-var_dump($stmt->activeQueryString()); // works with statements without bound values
-
-$stmt = $db->prepare('SELECT :bool, :int, :string, :null');
-$stmt->bindValue(':bool', true, PDO::PARAM_BOOL);
-$stmt->bindValue(':int', 123, PDO::PARAM_INT);
-$stmt->bindValue(':string', 'foo', PDO::PARAM_STR);
-$stmt->bindValue(':null', null, PDO::PARAM_NULL);
-
-var_dump($stmt->activeQueryString()); // will return unparsed query before execution
-
-$stmt->execute();
-
-// will return parsed query after execution
-var_dump($stmt->activeQueryString() == "SELECT " . $quoted_true . ", 123, 'foo', NULL");
-// can be called repeatedly
-var_dump($stmt->activeQueryString() == "SELECT " . $quoted_true . ", 123, 'foo', NULL");
-
-$stmt->execute();
-
-// works if the statement is executed again
-var_dump($stmt->activeQueryString() == "SELECT " . $quoted_true . ", 123, 'foo', NULL");
-
-$stmt->bindValue(':int', 456, PDO::PARAM_INT);
-$stmt->execute();
-
-// works with altered values
-var_dump($stmt->activeQueryString() == "SELECT " . $quoted_true . ", 456, 'foo', NULL");
-
-?>
---EXPECT--
-string(8) "SELECT 1"
-string(34) "SELECT :bool, :int, :string, :null"
-bool(true)
-bool(true)
-bool(true)
-bool(true)
index dd77169d57868afb04499c88a7396322d8c32ef7..4c53b36b2b90c6832f87ca2d5e9578cdec1a8c0d 100644 (file)
@@ -272,11 +272,6 @@ static int dblib_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val)
 static int dblib_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_value)
 {
        switch (attr) {
-               case PDO_ATTR_EMULATE_PREPARES:
-                       /* this is the only option available, but expose it so common tests and whatever else can introspect */
-                       ZVAL_TRUE(return_value);
-                       break;
-
                case PDO_DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER:
                        ZVAL_BOOL(return_value, ((pdo_dblib_db_handle *)dbh->driver_data)->stringify_uniqueidentifier);
                        break;