Skip to content

Commit a881ea7

Browse files
committed
Add a test case to test fetching of multiple rows with bit values.
1 parent e15c418 commit a881ea7

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

ext/mysqli/tests/bug_bits.phpt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
--TEST--
2+
Bug (Incorrectly decoding bit values / Malformed server packet. Field length pointing)
3+
--SKIPIF--
4+
<?php
5+
require_once('skipif.inc');
6+
require_once('skipifconnectfailure.inc');
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require_once("connect.inc");
12+
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
13+
printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
14+
}
15+
16+
if (!$link->query("DROP TABLE IF EXISTS bug_bits")) {
17+
printf("[002] [%d] %s\n", $link->errno, $link->error);
18+
}
19+
20+
if (!$link->query("CREATE TABLE `bug_bits` (`inty` bigint(20) unsigned NOT NULL DEFAULT '0', `bitty` bit(64) NOT NULL DEFAULT b'0')")) {
21+
printf("[003] [%d] %s\n", $link->errno, $link->error);
22+
}
23+
24+
$insertQuery = "INSERT INTO `bug_bits` VALUES (18446744073709551615, 18446744073709551615), (18446744073709551614, 18446744073709551614)";
25+
if (!$link->query($insertQuery)) {
26+
printf("[004] [%d] %s\n", $link->errno, $link->error);
27+
}
28+
29+
if (!($res = $link->query("SELECT * FROM `bug_bits`"))) {
30+
printf("[005] [%d] %s\n", $link->errno, $link->error);
31+
}
32+
33+
while ($row = $res->fetch_assoc()) {
34+
var_dump($row);
35+
}
36+
37+
$link->close();
38+
39+
echo "Done\n";
40+
?>
41+
--CLEAN--
42+
<?php
43+
require_once("connect.inc");
44+
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
45+
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
46+
47+
if (!mysqli_query($link, "DROP TABLE IF EXISTS bug72489"))
48+
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
49+
50+
mysqli_close($link);
51+
?>
52+
--EXPECT--
53+
array(2) {
54+
["inty"]=>
55+
string(20) "18446744073709551615"
56+
["bitty"]=>
57+
string(20) "18446744073709551615"
58+
}
59+
array(2) {
60+
["inty"]=>
61+
string(20) "18446744073709551614"
62+
["bitty"]=>
63+
string(20) "18446744073709551614"
64+
}
65+
Done

0 commit comments

Comments
 (0)