From 94dffc55ac062f8bea6a9a045efe2ac6fd2ad09f Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Wed, 4 Jan 2006 23:04:06 +0000 Subject: [PATCH] bring tests up-to-date with 5_1 branch #few are failing and will stop failing when bugfixes are upmerged from 5_1 --- ext/mysqli/tests/003.phpt | 4 +- ext/mysqli/tests/004.phpt | 37 ++++++++++++++---- ext/mysqli/tests/006.phpt | 1 + ext/mysqli/tests/007.phpt | 1 + ext/mysqli/tests/008.phpt | 1 + ext/mysqli/tests/009.phpt | 24 +++++++++++- ext/mysqli/tests/010.phpt | 1 + ext/mysqli/tests/013.phpt | 15 +++++--- ext/mysqli/tests/020.phpt | 1 + ext/mysqli/tests/023.phpt | 1 + ext/mysqli/tests/024.phpt | 1 + ext/mysqli/tests/025.phpt | 1 + ext/mysqli/tests/026.phpt | 1 + ext/mysqli/tests/042.phpt | 1 + ext/mysqli/tests/060.phpt | 1 + ext/mysqli/tests/065.phpt | 1 + ext/mysqli/tests/bug32405.phpt | 1 + ext/mysqli/tests/bug35103.phpt | 68 ++++++++++++++++++++++++++++++++++ ext/mysqli/tests/bug35517.phpt | 29 +++++++++++++++ ext/mysqli/tests/bug35759.phpt | 44 ++++++++++++++++++++++ 20 files changed, 218 insertions(+), 16 deletions(-) create mode 100644 ext/mysqli/tests/bug35103.phpt create mode 100644 ext/mysqli/tests/bug35517.phpt create mode 100644 ext/mysqli/tests/bug35759.phpt diff --git a/ext/mysqli/tests/003.phpt b/ext/mysqli/tests/003.phpt index d043dc7724..28aedb032c 100644 --- a/ext/mysqli/tests/003.phpt +++ b/ext/mysqli/tests/003.phpt @@ -7,9 +7,9 @@ mysqli connect include "connect.inc"; /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); + $link = mysqli_connect($host, $user, $passwd, "test"); - mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result"); mysqli_query($link,"CREATE TABLE test_bind_result(c1 date, c2 time, diff --git a/ext/mysqli/tests/004.phpt b/ext/mysqli/tests/004.phpt index c80c7214e3..fafc30ba0d 100644 --- a/ext/mysqli/tests/004.phpt +++ b/ext/mysqli/tests/004.phpt @@ -14,16 +14,21 @@ mysqli fetch char/text mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)"); - mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', 'this is a test')"); + mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', 'this is a test0')"); + mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567891', 'this is a test1')"); + mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567892', 'this is a test2')"); + mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567893', 'this is a test3')"); - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); + $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch ORDER BY c1"); mysqli_bind_result($stmt, $c1, $c2); mysqli_execute($stmt); - mysqli_fetch($stmt); + $i=4; + while ($i--) { + mysqli_fetch($stmt); + $test = array($c1,$c2); + var_dump($test); + } - $test = array($c1,$c2); - - var_dump($test); mysqli_stmt_close($stmt); mysqli_close($link); @@ -33,5 +38,23 @@ array(2) { [0]=> string(10) "1234567890" [1]=> - string(14) "this is a test" + string(15) "this is a test0" +} +array(2) { + [0]=> + string(10) "1234567891" + [1]=> + string(15) "this is a test1" +} +array(2) { + [0]=> + string(10) "1234567892" + [1]=> + string(15) "this is a test2" +} +array(2) { + [0]=> + string(10) "1234567893" + [1]=> + string(15) "this is a test3" } diff --git a/ext/mysqli/tests/006.phpt b/ext/mysqli/tests/006.phpt index 4b495cc594..a53ad7a547 100644 --- a/ext/mysqli/tests/006.phpt +++ b/ext/mysqli/tests/006.phpt @@ -10,6 +10,7 @@ mysqli fetch long values $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned, diff --git a/ext/mysqli/tests/007.phpt b/ext/mysqli/tests/007.phpt index 503863bdc2..cb32033cca 100644 --- a/ext/mysqli/tests/007.phpt +++ b/ext/mysqli/tests/007.phpt @@ -10,6 +10,7 @@ mysqli fetch short values $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned, diff --git a/ext/mysqli/tests/008.phpt b/ext/mysqli/tests/008.phpt index 12311d621b..9fc01b8adf 100644 --- a/ext/mysqli/tests/008.phpt +++ b/ext/mysqli/tests/008.phpt @@ -10,6 +10,7 @@ mysqli fetch tinyint values $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint, diff --git a/ext/mysqli/tests/009.phpt b/ext/mysqli/tests/009.phpt index 091313870f..32ed3c18f0 100644 --- a/ext/mysqli/tests/009.phpt +++ b/ext/mysqli/tests/009.phpt @@ -1,5 +1,5 @@ --TEST-- -mysqli fetch bigint values +mysqli fetch bigint values (ok to fail with 4.1.x) --SKIPIF-- + --EXPECT-- array(7) { [0]=> @@ -53,7 +71,9 @@ array(7) { [4]=> int(0) [5]=> - string(13) "-333333333333" + int(0) [6]=> int(100) } +20123456 +3123456789 diff --git a/ext/mysqli/tests/010.phpt b/ext/mysqli/tests/010.phpt index 0d74bed501..6b79d62f42 100644 --- a/ext/mysqli/tests/010.phpt +++ b/ext/mysqli/tests/010.phpt @@ -12,6 +12,7 @@ precision=12 $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); diff --git a/ext/mysqli/tests/013.phpt b/ext/mysqli/tests/013.phpt index ff435f94db..983ceba14c 100644 --- a/ext/mysqli/tests/013.phpt +++ b/ext/mysqli/tests/013.phpt @@ -25,7 +25,7 @@ mysqli fetch mixed / mysql_query $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result"); $c = array(0,0,0,0,0,0,0,0); - mysqli_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]); + $b_res= mysqli_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]); mysqli_execute($stmt); mysqli_fetch($stmt); mysqli_fetch($stmt); @@ -38,10 +38,15 @@ mysqli fetch mixed / mysql_query $test = ""; for ($i=0; $i < count($c); $i++) $test .= ($c[0] == $d[0]) ? "1" : "0"; - - var_dump($test); + if ($test == "11111111") + echo "ok"; + else if ($b_res == FALSE && mysqli_get_client_version() > 40100 && mysqli_get_client_version() < 50000 && + mysqli_get_server_version($link) > 50000) + echo "error (4.1 library with 5.x server)"; + else + echo "error"; mysqli_close($link); ?> ---EXPECT-- -string(8) "11111111" +--EXPECTF-- +ok diff --git a/ext/mysqli/tests/020.phpt b/ext/mysqli/tests/020.phpt index 85834c52af..4ae140f620 100644 --- a/ext/mysqli/tests/020.phpt +++ b/ext/mysqli/tests/020.phpt @@ -10,6 +10,7 @@ mysqli bind_param/bind_result date $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result"); mysqli_query($link,"CREATE TABLE test_bind_result(c1 date, c2 time, diff --git a/ext/mysqli/tests/023.phpt b/ext/mysqli/tests/023.phpt index 69e9b20858..24a717a6eb 100644 --- a/ext/mysqli/tests/023.phpt +++ b/ext/mysqli/tests/023.phpt @@ -10,6 +10,7 @@ mysqli bind_param/bind_prepare fetch long values $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned, diff --git a/ext/mysqli/tests/024.phpt b/ext/mysqli/tests/024.phpt index c6d6cd7e70..f0d0a6407a 100644 --- a/ext/mysqli/tests/024.phpt +++ b/ext/mysqli/tests/024.phpt @@ -10,6 +10,7 @@ mysqli bind_param/bind_result short values $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned, diff --git a/ext/mysqli/tests/025.phpt b/ext/mysqli/tests/025.phpt index 85ff0fa29f..f3338cf467 100644 --- a/ext/mysqli/tests/025.phpt +++ b/ext/mysqli/tests/025.phpt @@ -10,6 +10,7 @@ mysqli bind_param/bind_result tinyint values $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint, diff --git a/ext/mysqli/tests/026.phpt b/ext/mysqli/tests/026.phpt index 0f9e882608..d38e3c1807 100644 --- a/ext/mysqli/tests/026.phpt +++ b/ext/mysqli/tests/026.phpt @@ -10,6 +10,7 @@ mysqli bind_param/bind_result with send_long_data $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 varchar(10), c2 text)"); diff --git a/ext/mysqli/tests/042.phpt b/ext/mysqli/tests/042.phpt index fe6d23e172..719e24925d 100644 --- a/ext/mysqli/tests/042.phpt +++ b/ext/mysqli/tests/042.phpt @@ -10,6 +10,7 @@ mysqli_fetch_object $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned, diff --git a/ext/mysqli/tests/060.phpt b/ext/mysqli/tests/060.phpt index 875130dc55..ba6c231c57 100644 --- a/ext/mysqli/tests/060.phpt +++ b/ext/mysqli/tests/060.phpt @@ -16,6 +16,7 @@ mysqli_fetch_object with classes $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); mysqli_query($link,"DROP TABLE IF EXISTS test_fetch"); mysqli_query($link,"CREATE TABLE test_fetch(c1 smallint unsigned, diff --git a/ext/mysqli/tests/065.phpt b/ext/mysqli/tests/065.phpt index d0fa071169..09ee886ec5 100644 --- a/ext/mysqli/tests/065.phpt +++ b/ext/mysqli/tests/065.phpt @@ -12,6 +12,7 @@ if (!function_exists('mysqli_set_charset')) { include "connect.inc"; $mysql = new mysqli($host, $user, $passwd); + mysqli_query($mysql, "SET sql_mode=''"); $esc_str = chr(0xbf) . chr(0x5c); diff --git a/ext/mysqli/tests/bug32405.phpt b/ext/mysqli/tests/bug32405.phpt index 9b58e3611b..f805dc7982 100644 --- a/ext/mysqli/tests/bug32405.phpt +++ b/ext/mysqli/tests/bug32405.phpt @@ -9,6 +9,7 @@ Bug #32405 /*** test mysqli_connect 127.0.0.1 ***/ $link = mysqli_connect($host, $user, $passwd); mysqli_select_db($link, "test"); + mysqli_query($link, "SET sql_mode=''"); /* two fields are needed. the problem does not occur with 1 field only selected. */ $link->query("CREATE TABLE test_users(user_id int(10) unsigned NOT NULL auto_increment, login varchar(50) default '', PRIMARY KEY (user_id))"); diff --git a/ext/mysqli/tests/bug35103.phpt b/ext/mysqli/tests/bug35103.phpt new file mode 100644 index 0000000000..b6118b9b2b --- /dev/null +++ b/ext/mysqli/tests/bug35103.phpt @@ -0,0 +1,68 @@ +--TEST-- +bug #35103 Bad handling of unsigned bigint +--SKIPIF-- + +--FILE-- +query("DROP TABLE IF EXISTS test_bint"); + $mysql->query("CREATE TABLE test_bint (a bigint(20) default NULL) ENGINE=MYISAM"); + $mysql->query("INSERT INTO test_bint VALUES (9223372036854775807),(-9223372036854775808),(-2147483648),(-2147483649),(-2147483647),(2147483647),(2147483648),(2147483649)"); + + $mysql->query("DROP TABLE IF EXISTS test_buint"); + $mysql->query("CREATE TABLE test_buint (a bigint(20) unsigned default NULL)"); + $mysql->query("INSERT INTO test_buint VALUES (18446744073709551615),(9223372036854775807),(9223372036854775808),(2147483647),(2147483649),(4294967295)"); + + $stmt = $mysql->prepare("SELECT a FROM test_bint ORDER BY a"); + $stmt->bind_result($v); + $stmt->execute(); + $i=0; + echo "BIG INT SIGNED, TEST\n"; + while ($i++ < 8) { + $stmt->fetch(); + echo $v, "\n"; + } + $stmt->close(); + + echo str_repeat("-", 20), "\n"; + + $stmt = $mysql->prepare("SELECT a FROM test_buint ORDER BY a"); + $stmt->bind_result($v2); + $stmt->execute(); + $j=0; + echo "BIG INT UNSIGNED TEST\n"; + while ($j++ < 6) { + $stmt->fetch(); + echo $v2, "\n"; + } + $stmt->close(); + + $mysql->multi_query($drop); + + $mysql->close(); +?> +--EXPECT-- +BIG INT SIGNED, TEST +-9223372036854775808 +-2147483649 +-2147483648 +-2147483647 +2147483647 +2147483648 +2147483649 +9223372036854775807 +-------------------- +BIG INT UNSIGNED TEST +2147483647 +2147483649 +4294967295 +9223372036854775807 +9223372036854775808 +18446744073709551615 diff --git a/ext/mysqli/tests/bug35517.phpt b/ext/mysqli/tests/bug35517.phpt new file mode 100644 index 0000000000..eb1b543463 --- /dev/null +++ b/ext/mysqli/tests/bug35517.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #35517 mysqli_stmt_fetch returns NULL +--SKIPIF-- + +--FILE-- +query("CREATE TABLE temp (id INT UNSIGNED NOT NULL)"); + $mysql->query("INSERT INTO temp (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)"); + + $stmt = $mysql->prepare("SELECT id FROM temp"); + $stmt->execute(); + $stmt->bind_result($id); + while ($stmt->fetch()) { + var_dump($id); + } + $stmt->close(); + + $mysql->query("DROP TABLE temp"); + $mysql->close(); +?> +--EXPECTF-- +string(10) "3000000897" +string(10) "3800001532" +string(10) "3900002281" +string(10) "3100059612" diff --git a/ext/mysqli/tests/bug35759.phpt b/ext/mysqli/tests/bug35759.phpt new file mode 100644 index 0000000000..5f67a76247 --- /dev/null +++ b/ext/mysqli/tests/bug35759.phpt @@ -0,0 +1,44 @@ +--TEST-- +bug #35759 : mysqli_stmt_bind_result() makes huge allocation when column empty +--SKIPIF-- + +--FILE-- +query("DROP TABLE IF EXISTS blobby"); + $create = "CREATE TABLE blobby (a0 MEDIUMBLOB NOT NULL DEFAULT ''"; + $i= 0; + while (++$i < $col_num) { + $create .= ", a$i MEDIUMBLOB NOT NULL DEFAULT ''"; + } + $create .= ")"; + + $mysql->query($create); + $mysql->query("INSERT INTO blobby (a0) VALUES ('')"); + + $stmt = $mysql->prepare("SELECT * FROM blobby"); + $stmt->execute(); + $stmt->store_result(); + $params= array_pad(array(), $col_num, ""); + call_user_func_array(array($stmt, "bind_result"), $params); + $stmt->fetch(); + + $stmt->close(); + + $mysql->query("DROP TABLE blobby"); + + $mysql->close(); + echo "OK\n"; +?> +--EXPECT-- +OK -- 2.40.0