xref: /PHP-7.0/ext/mysqli/tests/bug_bits.phpt (revision 13fc1b92)
1--TEST--
2Bug (Incorrectly decoding bit values / Malformed server packet. Field length pointing)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10
11require_once("connect.inc");
12if (!$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
16if (!$link->query("DROP TABLE IF EXISTS bug_bits")) {
17    printf("[002] [%d] %s\n", $link->errno, $link->error);
18}
19
20if (!$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)".
25			   ",(18446744073709551614, 18446744073709551614)".
26			   ",(4294967296, 4294967296)".
27			   ",(4294967295, 4294967295)".
28			   ",(2147483648, 2147483648)".
29			   ",(2147483647, 2147483647)".
30			   ",(1, 1)";
31if (!$link->query($insertQuery)) {
32    printf("[004] [%d] %s\n", $link->errno, $link->error);
33}
34
35if (!($res = $link->query("SELECT * FROM `bug_bits`"))) {
36    printf("[005] [%d] %s\n", $link->errno, $link->error);
37}
38
39while ($row = $res->fetch_assoc()) {
40	var_dump($row);
41}
42
43$link->close();
44
45echo "Done\n";
46?>
47--CLEAN--
48<?php
49require_once("connect.inc");
50if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
51    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
52
53if (!mysqli_query($link, "DROP TABLE IF EXISTS bug_bits"))
54    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
55
56mysqli_close($link);
57?>
58--EXPECT--
59array(2) {
60  ["inty"]=>
61  string(20) "18446744073709551615"
62  ["bitty"]=>
63  string(20) "18446744073709551615"
64}
65array(2) {
66  ["inty"]=>
67  string(20) "18446744073709551614"
68  ["bitty"]=>
69  string(20) "18446744073709551614"
70}
71array(2) {
72  ["inty"]=>
73  string(10) "4294967296"
74  ["bitty"]=>
75  string(10) "4294967296"
76}
77array(2) {
78  ["inty"]=>
79  string(10) "4294967295"
80  ["bitty"]=>
81  string(10) "4294967295"
82}
83array(2) {
84  ["inty"]=>
85  string(10) "2147483648"
86  ["bitty"]=>
87  string(10) "2147483648"
88}
89array(2) {
90  ["inty"]=>
91  string(10) "2147483647"
92  ["bitty"]=>
93  string(10) "2147483647"
94}
95array(2) {
96  ["inty"]=>
97  string(1) "1"
98  ["bitty"]=>
99  string(1) "1"
100}
101Done
102