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