iliaa Sun Dec 3 23:27:44 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/pdo pdo_sql_parser.re pdo_sql_parser.c
Log:
Added missing check for mismatching number of tokens & bound params in
prepared statement emulation.
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_sql_parser.re?r1=1.28.2.4.2.2&r2=1.28.2.4.2.3&diff_format=u
Index: php-src/ext/pdo/pdo_sql_parser.re
diff -u php-src/ext/pdo/pdo_sql_parser.re:1.28.2.4.2.2
php-src/ext/pdo/pdo_sql_parser.re:1.28.2.4.2.3
--- php-src/ext/pdo/pdo_sql_parser.re:1.28.2.4.2.2 Thu Nov 23 14:41:35 2006
+++ php-src/ext/pdo/pdo_sql_parser.re Sun Dec 3 23:27:44 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_sql_parser.re,v 1.28.2.4.2.2 2006/11/23 14:41:35 iliaa Exp $ */
+/* $Id: pdo_sql_parser.re,v 1.28.2.4.2.3 2006/12/03 23:27:44 iliaa Exp $ */
#include "php.h"
#include "php_pdo_driver.h"
@@ -132,7 +132,6 @@
goto clean_up;
}
-
if (stmt->supports_placeholders == query_type &&
!stmt->named_rewrite_template) {
/* query matches native syntax */
ret = 0;
@@ -156,7 +155,13 @@
ret = -1;
goto clean_up;
}
-
+
+ if (params && bindno != zend_hash_num_elements(params) &&
stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
+ pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "number of bound
variables does not match number of tokens" TSRMLS_CC);
+ ret = -1;
+ goto clean_up;
+ }
+
/* what are we going to do ? */
if (stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_sql_parser.c?r1=1.35.2.6.2.3&r2=1.35.2.6.2.4&diff_format=u
Index: php-src/ext/pdo/pdo_sql_parser.c
diff -u php-src/ext/pdo/pdo_sql_parser.c:1.35.2.6.2.3
php-src/ext/pdo/pdo_sql_parser.c:1.35.2.6.2.4
--- php-src/ext/pdo/pdo_sql_parser.c:1.35.2.6.2.3 Thu Nov 23 14:41:35 2006
+++ php-src/ext/pdo/pdo_sql_parser.c Sun Dec 3 23:27:44 2006
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.10.6 on Thu Nov 23 09:39:04 2006 */
+/* Generated by re2c 0.10.6 on Sun Dec 3 18:24:46 2006 */
#line 1 "ext/pdo/pdo_sql_parser.re"
/*
+----------------------------------------------------------------------+
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_sql_parser.c,v 1.35.2.6.2.3 2006/11/23 14:41:35 iliaa Exp $ */
+/* $Id: pdo_sql_parser.c,v 1.35.2.6.2.4 2006/12/03 23:27:44 iliaa Exp $ */
#include "php.h"
#include "php_pdo_driver.h"
@@ -352,7 +352,6 @@
goto clean_up;
}
-
if (stmt->supports_placeholders == query_type &&
!stmt->named_rewrite_template) {
/* query matches native syntax */
ret = 0;
@@ -376,7 +375,13 @@
ret = -1;
goto clean_up;
}
-
+
+ if (params && bindno != zend_hash_num_elements(params) &&
stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
+ pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "number of bound
variables does not match number of tokens" TSRMLS_CC);
+ ret = -1;
+ goto clean_up;
+ }
+
/* what are we going to do ? */
if (stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php