Skip to content

Commit 94dffc5

Browse files
committed
bring tests up-to-date with 5_1 branch
#few are failing and will stop failing when bugfixes are upmerged from 5_1
1 parent 9be53ac commit 94dffc5

20 files changed

+218
-16
lines changed

ext/mysqli/tests/003.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ mysqli connect
77
include "connect.inc";
88

99
/*** test mysqli_connect 127.0.0.1 ***/
10-
$link = mysqli_connect($host, $user, $passwd);
10+
$link = mysqli_connect($host, $user, $passwd, "test");
1111

12-
mysqli_select_db($link, "test");
12+
mysqli_query($link, "SET sql_mode=''");
1313

1414
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
1515
mysqli_query($link,"CREATE TABLE test_bind_result(c1 date, c2 time,

ext/mysqli/tests/004.phpt

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@ mysqli fetch char/text
1414
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
1515
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
1616

17-
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', 'this is a test')");
17+
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', 'this is a test0')");
18+
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567891', 'this is a test1')");
19+
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567892', 'this is a test2')");
20+
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567893', 'this is a test3')");
1821

19-
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
22+
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch ORDER BY c1");
2023
mysqli_bind_result($stmt, $c1, $c2);
2124
mysqli_execute($stmt);
22-
mysqli_fetch($stmt);
25+
$i=4;
26+
while ($i--) {
27+
mysqli_fetch($stmt);
28+
$test = array($c1,$c2);
29+
var_dump($test);
30+
}
2331

24-
$test = array($c1,$c2);
25-
26-
var_dump($test);
2732

2833
mysqli_stmt_close($stmt);
2934
mysqli_close($link);
@@ -33,5 +38,23 @@ array(2) {
3338
[0]=>
3439
string(10) "1234567890"
3540
[1]=>
36-
string(14) "this is a test"
41+
string(15) "this is a test0"
42+
}
43+
array(2) {
44+
[0]=>
45+
string(10) "1234567891"
46+
[1]=>
47+
string(15) "this is a test1"
48+
}
49+
array(2) {
50+
[0]=>
51+
string(10) "1234567892"
52+
[1]=>
53+
string(15) "this is a test2"
54+
}
55+
array(2) {
56+
[0]=>
57+
string(10) "1234567893"
58+
[1]=>
59+
string(15) "this is a test3"
3760
}

ext/mysqli/tests/006.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mysqli fetch long values
1010
$link = mysqli_connect($host, $user, $passwd);
1111

1212
mysqli_select_db($link, "test");
13+
mysqli_query($link, "SET sql_mode=''");
1314

1415
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
1516
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned,

ext/mysqli/tests/007.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mysqli fetch short values
1010
$link = mysqli_connect($host, $user, $passwd);
1111

1212
mysqli_select_db($link, "test");
13+
mysqli_query($link, "SET sql_mode=''");
1314

1415
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
1516
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,

ext/mysqli/tests/008.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mysqli fetch tinyint values
1010
$link = mysqli_connect($host, $user, $passwd);
1111

1212
mysqli_select_db($link, "test");
13+
mysqli_query($link, "SET sql_mode=''");
1314

1415
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
1516
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint,

ext/mysqli/tests/009.phpt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
mysqli fetch bigint values
2+
mysqli fetch bigint values (ok to fail with 4.1.x)
33
--SKIPIF--
44
<?php
55
if (PHP_INT_SIZE == 8) {
@@ -16,6 +16,7 @@ mysqli fetch bigint values
1616
$link = mysqli_connect($host, $user, $passwd);
1717

1818
mysqli_select_db($link, "test");
19+
mysqli_query($link, "SET sql_mode=''");
1920

2021
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
2122
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 bigint default 5,
@@ -38,8 +39,25 @@ mysqli fetch bigint values
3839
var_dump($test);
3940

4041
mysqli_stmt_close($stmt);
42+
43+
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch_uint");
44+
mysqli_query($link,"CREATE TABLE test_bind_fetch_uint(c1 integer unsigned, c2 integer unsigned)");
45+
46+
mysqli_query($link, "INSERT INTO test_bind_fetch_uint (c1,c2) VALUES (20123456, 3123456789)");
47+
48+
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_uint");
49+
mysqli_bind_result($stmt, $c1, $c2);
50+
mysqli_execute($stmt);
51+
$rc = mysqli_fetch($stmt);
52+
53+
echo $c1, "\n", $c2, "\n";
54+
55+
mysqli_stmt_close($stmt);
56+
57+
4158
mysqli_close($link);
4259
?>
60+
4361
--EXPECT--
4462
array(7) {
4563
[0]=>
@@ -53,7 +71,9 @@ array(7) {
5371
[4]=>
5472
int(0)
5573
[5]=>
56-
string(13) "-333333333333"
74+
int(0)
5775
[6]=>
5876
int(100)
5977
}
78+
20123456
79+
3123456789

ext/mysqli/tests/010.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ precision=12
1212
$link = mysqli_connect($host, $user, $passwd);
1313

1414
mysqli_select_db($link, "test");
15+
mysqli_query($link, "SET sql_mode=''");
1516

1617
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
1718

ext/mysqli/tests/013.phpt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mysqli fetch mixed / mysql_query
2525
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
2626

2727
$c = array(0,0,0,0,0,0,0,0);
28-
mysqli_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
28+
$b_res= mysqli_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
2929
mysqli_execute($stmt);
3030
mysqli_fetch($stmt);
3131
mysqli_fetch($stmt);
@@ -38,10 +38,15 @@ mysqli fetch mixed / mysql_query
3838
$test = "";
3939
for ($i=0; $i < count($c); $i++)
4040
$test .= ($c[0] == $d[0]) ? "1" : "0";
41-
42-
var_dump($test);
41+
if ($test == "11111111")
42+
echo "ok";
43+
else if ($b_res == FALSE && mysqli_get_client_version() > 40100 && mysqli_get_client_version() < 50000 &&
44+
mysqli_get_server_version($link) > 50000)
45+
echo "error (4.1 library with 5.x server)";
46+
else
47+
echo "error";
4348

4449
mysqli_close($link);
4550
?>
46-
--EXPECT--
47-
string(8) "11111111"
51+
--EXPECTF--
52+
ok

ext/mysqli/tests/020.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mysqli bind_param/bind_result date
1010
$link = mysqli_connect($host, $user, $passwd);
1111

1212
mysqli_select_db($link, "test");
13+
mysqli_query($link, "SET sql_mode=''");
1314

1415
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
1516
mysqli_query($link,"CREATE TABLE test_bind_result(c1 date, c2 time,

ext/mysqli/tests/023.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mysqli bind_param/bind_prepare fetch long values
1010
$link = mysqli_connect($host, $user, $passwd);
1111

1212
mysqli_select_db($link, "test");
13+
mysqli_query($link, "SET sql_mode=''");
1314

1415
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
1516
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned,

ext/mysqli/tests/024.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mysqli bind_param/bind_result short values
1010
$link = mysqli_connect($host, $user, $passwd);
1111

1212
mysqli_select_db($link, "test");
13+
mysqli_query($link, "SET sql_mode=''");
1314

1415
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
1516
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,

ext/mysqli/tests/025.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mysqli bind_param/bind_result tinyint values
1010
$link = mysqli_connect($host, $user, $passwd);
1111

1212
mysqli_select_db($link, "test");
13+
mysqli_query($link, "SET sql_mode=''");
1314

1415
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
1516
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint,

ext/mysqli/tests/026.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mysqli bind_param/bind_result with send_long_data
1010
$link = mysqli_connect($host, $user, $passwd);
1111

1212
mysqli_select_db($link, "test");
13+
mysqli_query($link, "SET sql_mode=''");
1314

1415
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
1516
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 varchar(10), c2 text)");

ext/mysqli/tests/042.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mysqli_fetch_object
1010
$link = mysqli_connect($host, $user, $passwd);
1111

1212
mysqli_select_db($link, "test");
13+
mysqli_query($link, "SET sql_mode=''");
1314

1415
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
1516
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,

ext/mysqli/tests/060.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ mysqli_fetch_object with classes
1616
$link = mysqli_connect($host, $user, $passwd);
1717

1818
mysqli_select_db($link, "test");
19+
mysqli_query($link, "SET sql_mode=''");
1920

2021
mysqli_query($link,"DROP TABLE IF EXISTS test_fetch");
2122
mysqli_query($link,"CREATE TABLE test_fetch(c1 smallint unsigned,

ext/mysqli/tests/065.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if (!function_exists('mysqli_set_charset')) {
1212
include "connect.inc";
1313

1414
$mysql = new mysqli($host, $user, $passwd);
15+
mysqli_query($mysql, "SET sql_mode=''");
1516

1617
$esc_str = chr(0xbf) . chr(0x5c);
1718

ext/mysqli/tests/bug32405.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Bug #32405
99
/*** test mysqli_connect 127.0.0.1 ***/
1010
$link = mysqli_connect($host, $user, $passwd);
1111
mysqli_select_db($link, "test");
12+
mysqli_query($link, "SET sql_mode=''");
1213

1314
/* two fields are needed. the problem does not occur with 1 field only selected. */
1415
$link->query("CREATE TABLE test_users(user_id int(10) unsigned NOT NULL auto_increment, login varchar(50) default '', PRIMARY KEY (user_id))");

ext/mysqli/tests/bug35103.phpt

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
--TEST--
2+
bug #35103 Bad handling of unsigned bigint
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
$drop = <<<EOSQL
9+
DROP TABLE test_bint;
10+
DROP TABLE test_buint;
11+
EOSQL;
12+
include "connect.inc";
13+
14+
$mysql = new mysqli($host, $user, $passwd, "test");
15+
$mysql->query("DROP TABLE IF EXISTS test_bint");
16+
$mysql->query("CREATE TABLE test_bint (a bigint(20) default NULL) ENGINE=MYISAM");
17+
$mysql->query("INSERT INTO test_bint VALUES (9223372036854775807),(-9223372036854775808),(-2147483648),(-2147483649),(-2147483647),(2147483647),(2147483648),(2147483649)");
18+
19+
$mysql->query("DROP TABLE IF EXISTS test_buint");
20+
$mysql->query("CREATE TABLE test_buint (a bigint(20) unsigned default NULL)");
21+
$mysql->query("INSERT INTO test_buint VALUES (18446744073709551615),(9223372036854775807),(9223372036854775808),(2147483647),(2147483649),(4294967295)");
22+
23+
$stmt = $mysql->prepare("SELECT a FROM test_bint ORDER BY a");
24+
$stmt->bind_result($v);
25+
$stmt->execute();
26+
$i=0;
27+
echo "BIG INT SIGNED, TEST\n";
28+
while ($i++ < 8) {
29+
$stmt->fetch();
30+
echo $v, "\n";
31+
}
32+
$stmt->close();
33+
34+
echo str_repeat("-", 20), "\n";
35+
36+
$stmt = $mysql->prepare("SELECT a FROM test_buint ORDER BY a");
37+
$stmt->bind_result($v2);
38+
$stmt->execute();
39+
$j=0;
40+
echo "BIG INT UNSIGNED TEST\n";
41+
while ($j++ < 6) {
42+
$stmt->fetch();
43+
echo $v2, "\n";
44+
}
45+
$stmt->close();
46+
47+
$mysql->multi_query($drop);
48+
49+
$mysql->close();
50+
?>
51+
--EXPECT--
52+
BIG INT SIGNED, TEST
53+
-9223372036854775808
54+
-2147483649
55+
-2147483648
56+
-2147483647
57+
2147483647
58+
2147483648
59+
2147483649
60+
9223372036854775807
61+
--------------------
62+
BIG INT UNSIGNED TEST
63+
2147483647
64+
2147483649
65+
4294967295
66+
9223372036854775807
67+
9223372036854775808
68+
18446744073709551615

ext/mysqli/tests/bug35517.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #35517 mysqli_stmt_fetch returns NULL
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
include "connect.inc";
8+
9+
$mysql = new mysqli($host, $user, $passwd, "test");
10+
11+
$mysql->query("CREATE TABLE temp (id INT UNSIGNED NOT NULL)");
12+
$mysql->query("INSERT INTO temp (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)");
13+
14+
$stmt = $mysql->prepare("SELECT id FROM temp");
15+
$stmt->execute();
16+
$stmt->bind_result($id);
17+
while ($stmt->fetch()) {
18+
var_dump($id);
19+
}
20+
$stmt->close();
21+
22+
$mysql->query("DROP TABLE temp");
23+
$mysql->close();
24+
?>
25+
--EXPECTF--
26+
string(10) "3000000897"
27+
string(10) "3800001532"
28+
string(10) "3900002281"
29+
string(10) "3100059612"

ext/mysqli/tests/bug35759.phpt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--TEST--
2+
bug #35759 : mysqli_stmt_bind_result() makes huge allocation when column empty
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
$sql=<<<EOSQL
9+
CREATE TABLE blobby (
10+
a1 MEDIUMBLOB NOT NULL,
11+
12+
13+
EOSQL;
14+
include "connect.inc";
15+
$col_num= 1000;
16+
17+
$mysql = new mysqli($host, $user, $passwd, "test");
18+
$mysql->query("DROP TABLE IF EXISTS blobby");
19+
$create = "CREATE TABLE blobby (a0 MEDIUMBLOB NOT NULL DEFAULT ''";
20+
$i= 0;
21+
while (++$i < $col_num) {
22+
$create .= ", a$i MEDIUMBLOB NOT NULL DEFAULT ''";
23+
}
24+
$create .= ")";
25+
26+
$mysql->query($create);
27+
$mysql->query("INSERT INTO blobby (a0) VALUES ('')");
28+
29+
$stmt = $mysql->prepare("SELECT * FROM blobby");
30+
$stmt->execute();
31+
$stmt->store_result();
32+
$params= array_pad(array(), $col_num, "");
33+
call_user_func_array(array($stmt, "bind_result"), $params);
34+
$stmt->fetch();
35+
36+
$stmt->close();
37+
38+
$mysql->query("DROP TABLE blobby");
39+
40+
$mysql->close();
41+
echo "OK\n";
42+
?>
43+
--EXPECT--
44+
OK

0 commit comments

Comments
 (0)