xref: /PHP-8.1/ext/mysqli/tests/gh7837.phpt (revision 49512b6b)
1--TEST--
2Bug GH-7837 (large bigints may be truncated)
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8if (!$IS_MYSQLND) {
9    die("skip requires mysqlnd");
10}
11?>
12--FILE--
13<?php
14require_once "connect.inc";
15
16$mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
17$mysql->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, true);
18$mysql->query("DROP TABLE IF EXISTS test");
19$mysql->query("CREATE TABLE test (`ubigint` bigint unsigned NOT NULL) ENGINE=InnoDB");
20$mysql->query("INSERT INTO test (`ubigint`) VALUES (18446744073709551615)");
21$mysql->query("INSERT INTO test (`ubigint`) VALUES (9223372036854775808)");
22$mysql->query("INSERT INTO test (`ubigint`) VALUES (1)");
23$result = $mysql->query("SELECT ubigint FROM test");
24var_dump($result->fetch_all());
25?>
26--CLEAN--
27<?php
28require_once "clean_table.inc";
29?>
30--EXPECT--
31array(3) {
32  [0]=>
33  array(1) {
34    [0]=>
35    string(20) "18446744073709551615"
36  }
37  [1]=>
38  array(1) {
39    [0]=>
40    string(19) "9223372036854775808"
41  }
42  [2]=>
43  array(1) {
44    [0]=>
45    int(1)
46  }
47}
48