wez             Mon Mar 27 20:51:01 2006 UTC

  Modified files:              (Branch: PHP_5_1)
    /php-src/ext/pdo    pdo_stmt.c php_pdo_driver.h 
    /php-src/ext/pdo_pgsql      pgsql_statement.c 
  Log:
  The fix for #35332 caused #35671 (and thus PECL #6504).
  
  Partially back out that fix and introduce an extra optional step for drivers 
to
  canonicalize the "name" that is used for registering parameters.
  
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pdo/pdo_stmt.c?r1=1.118.2.34&r2=1.118.2.35&diff_format=u
Index: php-src/ext/pdo/pdo_stmt.c
diff -u php-src/ext/pdo/pdo_stmt.c:1.118.2.34 
php-src/ext/pdo/pdo_stmt.c:1.118.2.35
--- php-src/ext/pdo/pdo_stmt.c:1.118.2.34       Sun Mar 19 17:35:36 2006
+++ php-src/ext/pdo/pdo_stmt.c  Mon Mar 27 20:51:01 2006
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_stmt.c,v 1.118.2.34 2006/03/19 17:35:36 iliaa Exp $ */
+/* $Id: pdo_stmt.c,v 1.118.2.35 2006/03/27 20:51:01 wez Exp $ */
 
 /* The PDO Statement Handle Class */
 
@@ -323,10 +323,14 @@
                }
                return 0;
        }
-       
-       /* tell the driver we just created a parameter */
+
+       /* ask the driver to perform any normalization it needs on the
+        * parameter name.  Note that it is illegal for the driver to take
+        * a reference to param, as it resides in transient storage only
+        * at this time. */
        if (stmt->methods->param_hook) {
-               if (!stmt->methods->param_hook(stmt, param, PDO_PARAM_EVT_ALLOC 
TSRMLS_CC)) {
+               if (!stmt->methods->param_hook(stmt, param, 
PDO_PARAM_EVT_NORMALIZE
+                               TSRMLS_CC)) {
                        if (param->name) {
                                efree(param->name);
                                param->name = NULL;
@@ -335,16 +339,36 @@
                }
        }
 
+       /* delete any other parameter registered with this number.
+        * If the parameter is named, it will be removed and correctly
+        * disposed of by the hash_update call that follows */
        if (param->paramno >= 0) {
                zend_hash_index_del(hash, param->paramno);
        }
-       
+
+       /* allocate storage for the parameter, keyed by its "canonical" name */
        if (param->name) {
-               zend_hash_update(hash, param->name, param->namelen, param, 
sizeof(*param), (void**)&pparam);
+               zend_hash_update(hash, param->name, param->namelen, param,
+                       sizeof(*param), (void**)&pparam);
        } else {
-               zend_hash_index_update(hash, param->paramno, param, 
sizeof(*param), (void**)&pparam);
+               zend_hash_index_update(hash, param->paramno, param, 
sizeof(*param),
+                       (void**)&pparam);
        }
 
+       /* tell the driver we just created a parameter */
+       if (stmt->methods->param_hook) {
+               if (!stmt->methods->param_hook(stmt, pparam, PDO_PARAM_EVT_ALLOC
+                                       TSRMLS_CC)) {
+                       /* undo storage allocation; the hash will free the 
parameter
+                        * name if required */
+                       if (pparam->name) {
+                               zend_hash_del(hash, pparam->name, 
pparam->namelen);
+                       } else {
+                               zend_hash_index_del(hash, pparam->paramno);
+                       }
+                       return 0;
+               }
+       }
        return 1;
 }
 /* }}} */
http://cvs.php.net/viewcvs.cgi/php-src/ext/pdo/php_pdo_driver.h?r1=1.66.2.9&r2=1.66.2.10&diff_format=u
Index: php-src/ext/pdo/php_pdo_driver.h
diff -u php-src/ext/pdo/php_pdo_driver.h:1.66.2.9 
php-src/ext/pdo/php_pdo_driver.h:1.66.2.10
--- php-src/ext/pdo/php_pdo_driver.h:1.66.2.9   Sun Jan  1 12:50:11 2006
+++ php-src/ext/pdo/php_pdo_driver.h    Mon Mar 27 20:51:01 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_driver.h,v 1.66.2.9 2006/01/01 12:50:11 sniper Exp $ */
+/* $Id: php_pdo_driver.h,v 1.66.2.10 2006/03/27 20:51:01 wez Exp $ */
 
 #ifndef PHP_PDO_DRIVER_H
 #define PHP_PDO_DRIVER_H
@@ -44,7 +44,7 @@
 # define FALSE 0
 #endif
 
-#define PDO_DRIVER_API 20051128
+#define PDO_DRIVER_API 20060327
 
 enum pdo_param_type {
        PDO_PARAM_NULL,
@@ -338,7 +338,8 @@
        PDO_PARAM_EVT_EXEC_PRE,
        PDO_PARAM_EVT_EXEC_POST,
        PDO_PARAM_EVT_FETCH_PRE,
-       PDO_PARAM_EVT_FETCH_POST
+       PDO_PARAM_EVT_FETCH_POST,
+       PDO_PARAM_EVT_NORMALIZE
 };
 
 typedef int (*pdo_stmt_param_hook_func)(pdo_stmt_t *stmt, struct 
pdo_bound_param_data *param, enum pdo_param_event event_type TSRMLS_DC);
http://cvs.php.net/viewcvs.cgi/php-src/ext/pdo_pgsql/pgsql_statement.c?r1=1.31.2.11&r2=1.31.2.12&diff_format=u
Index: php-src/ext/pdo_pgsql/pgsql_statement.c
diff -u php-src/ext/pdo_pgsql/pgsql_statement.c:1.31.2.11 
php-src/ext/pdo_pgsql/pgsql_statement.c:1.31.2.12
--- php-src/ext/pdo_pgsql/pgsql_statement.c:1.31.2.11   Fri Mar 17 22:15:57 2006
+++ php-src/ext/pdo_pgsql/pgsql_statement.c     Mon Mar 27 20:51:01 2006
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pgsql_statement.c,v 1.31.2.11 2006/03/17 22:15:57 tony2001 Exp $ */
+/* $Id: pgsql_statement.c,v 1.31.2.12 2006/03/27 20:51:01 wez Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -221,7 +221,7 @@
                                }
                                break;
 
-                       case PDO_PARAM_EVT_ALLOC:
+                       case PDO_PARAM_EVT_NORMALIZE:
                                /* decode name from $1, $2 into 0, 1 etc. */
                                if (param->name) {
                                        if (param->name[0] == '$') {
@@ -240,6 +240,10 @@
                                }
                                break;
 
+                       case PDO_PARAM_EVT_ALLOC:
+                               /* work is handled by EVT_NORMALIZE */
+                               return 1;
+
                        case PDO_PARAM_EVT_EXEC_PRE:
                                if (!S->param_values) {
                                        S->param_values = ecalloc(

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to