diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-10 16:52:17 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-10 16:53:08 +0100 |
| commit | 9e3ba775b7de7d7647c488beb9e302d03690f955 (patch) | |
| tree | 511c1b86b2c6e1e5875be73c085c4a94d714aa43 /ext/pdo_mysql | |
| parent | a5527577e7e80dbaf4e0313c1bfc890b2cc5f3b7 (diff) | |
| download | php-git-9e3ba775b7de7d7647c488beb9e302d03690f955.tar.gz | |
Fixed bug #72368
Generate a param count mismatch error even if the query contains
no placeholders.
Additionally we shouldn't HANDLE errors from pdo_parse_params,
which are always reported via raise_impl_error. Doing so results
in duplicate error messages.
Diffstat (limited to 'ext/pdo_mysql')
5 files changed, 38 insertions, 36 deletions
diff --git a/ext/pdo_mysql/tests/bug41125.phpt b/ext/pdo_mysql/tests/bug41125.phpt index 63ff7df2f3..cc5edba6fa 100644 --- a/ext/pdo_mysql/tests/bug41125.phpt +++ b/ext/pdo_mysql/tests/bug41125.phpt @@ -83,10 +83,12 @@ foreach ($queries as $k => $query) { } ?> ---EXPECT-- +--EXPECTF-- 1 00000 - - ------------------------------------------------------- + +Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in %s on line %d [1] Query: [[SELECT 1 FROM DUAL WHERE 1 = '?\'\'']] 00000 - - @@ -123,18 +125,24 @@ O'\0 1 00000 - - -------- + +Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in %s on line %d [5] Query: [[SELECT 'a', 'b\'' FROM DUAL WHERE '''' LIKE '\'' AND 1]] -a - b' + 00000 - - -------- + +Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in %s on line %d [6] Query: [[SELECT 'a''', '\'b\'' FROM DUAL WHERE '''' LIKE '\'' AND 1]] -a' - 'b' + 00000 - - -------- [7] Query: [[SELECT UPPER(:id) FROM DUAL WHERE '1']] 1 00000 - - -------- + +Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in %s on line %d [8] Query: [[SELECT 1 FROM DUAL WHERE '\'']] 00000 - - @@ -147,13 +155,16 @@ a' - 'b' 00000 - - -------- + +Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in %s on line %d [11] Query: [[SELECT 1 FROM DUAL WHERE '\'' = '''']] -1 + 00000 - - -------- + +Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in %s on line %d [12] Query: [[SELECT '\n' '1 FROM DUAL WHERE '''' and :id']] -1 FROM DUAL WHERE '' and :id 00000 - - -------- [13] Query: [[SELECT 1 'FROM DUAL WHERE :id AND '''' = '''' OR 1 = 1 AND ':id]] diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt index 808baffae3..b23d697efa 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt @@ -326,7 +326,7 @@ require __DIR__ . '/mysql_pdo_test.inc'; $db = MySQLPDOTest::factory(); $db->exec('DROP TABLE IF EXISTS test'); ?> ---EXPECT-- +--EXPECTF-- PDO::prepare(): Argument #1 ($query) cannot be empty array(1) { ["one"]=> @@ -339,12 +339,9 @@ array(1) { string(12) ":placeholder" } } -array(1) { - [0]=> - array(1) { - ["label"]=> - string(12) ":placeholder" - } + +Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in %s on line %d +array(0) { } array(2) { [0]=> @@ -381,12 +378,9 @@ array(1) { string(1) "?" } } -array(1) { - [0]=> - array(1) { - ["label"]=> - string(1) "?" - } + +Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in %s on line %d +array(0) { } array(2) { [0]=> diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt index 5d403c0caa..b652a08ea2 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt @@ -65,14 +65,13 @@ $db = MySQLPDOTest::factory(); $db->exec('DROP TABLE IF EXISTS test'); ?> --EXPECTF-- -array(1) { - [0]=> - array(2) { - ["id"]=> - string(1) "1" - ["label"]=> - string(1) "?" - } +Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in %s on line %d +[003] Execute has failed, 'HY093' array ( + 0 => 'HY093', + 1 => NULL, + 2 => NULL, +) +array(0) { } now the same with native PS diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt index e47b03b999..abd809539b 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt @@ -72,8 +72,6 @@ array(0) { now the same with emulated PS Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in %s on line %d - -Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number in %s on line 33 [005] Execute has failed, 'HY093' array ( 0 => 'HY093', 1 => NULL, diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt index ea4d097809..35658d5529 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt @@ -81,13 +81,13 @@ Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number in % ) array(0) { } -array(1) { - [0]=> - array(2) { - ["id"]=> - string(3) "101" - ["label"]=> - string(12) ":placeholder" - } + +Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in %s on line %d +[005] Execute has failed, 'HY093' array ( + 0 => 'HY093', + 1 => NULL, + 2 => NULL, +) +array(0) { } done! |
