diff options
author | Michael Wallner <mike@php.net> | 2013-08-20 19:21:53 +0200 |
---|---|---|
committer | Michael Wallner <mike@php.net> | 2013-08-20 19:21:53 +0200 |
commit | 7f3e7eb95812649fd421b405990a96091010b8e9 (patch) | |
tree | 1b45286a23879d7622870f122506224b7a391a95 /ext/pdo_pgsql | |
parent | 4cd9796be78bfb1cc88b5ed71cbd61e56937b8e7 (diff) | |
parent | 27c803aaed259f76a66db1278eea05f30a8ec956 (diff) | |
download | php-git-7f3e7eb95812649fd421b405990a96091010b8e9.tar.gz |
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
Fix bug #64953 (Postgres prepared statement positional parameter casting)
Conflicts:
ext/pdo/pdo_sql_parser.c
Diffstat (limited to 'ext/pdo_pgsql')
-rw-r--r-- | ext/pdo_pgsql/tests/bug64953.phpt | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/ext/pdo_pgsql/tests/bug64953.phpt b/ext/pdo_pgsql/tests/bug64953.phpt new file mode 100644 index 0000000000..6e72bcab68 --- /dev/null +++ b/ext/pdo_pgsql/tests/bug64953.phpt @@ -0,0 +1,71 @@ +--TEST-- +PDO PgSQL Bug #64953 (Postgres prepared statement positional parameter casting) +--SKIPIF-- +<?php +if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded'); +require dirname(__FILE__) . '/config.inc'; +require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; +PDOTest::skip(); +?> +--FILE-- +<?php +echo "Test\n"; + +require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; +$pdo = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); +$pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + +echo "Taken from the bug report:\n"; + +$st = $pdo->prepare('SELECT ?::char as i'); +$st->bindValue(1, '1'); +$st->execute(); +var_dump($st->fetch()); // return false + + +$st = $pdo->prepare('SELECT (?)::char as i'); +$st->bindValue(1, '1'); +$st->execute(); +var_dump($st->fetch()); // return array(1) { ["i"]=> string(1) "1" } + +echo "Something more nasty:\n"; + +$st = $pdo->prepare("SELECT :int::int as i"); +$st->execute(array(":int" => 123)); +var_dump($st->fetch()); + +$st = $pdo->prepare("SELECT '''?'''::text as \":text\""); +$st->execute(); +var_dump($st->fetch()); + +?> +Done +--EXPECT-- +Test +Taken from the bug report: +array(2) { + ["i"]=> + string(1) "1" + [0]=> + string(1) "1" +} +array(2) { + ["i"]=> + string(1) "1" + [0]=> + string(1) "1" +} +Something more nasty: +array(2) { + ["i"]=> + string(3) "123" + [0]=> + string(3) "123" +} +array(2) { + [":text"]=> + string(3) "'?'" + [0]=> + string(3) "'?'" +} +Done |