summaryrefslogtreecommitdiff
path: root/ext/mysqli/tests/bug35103.phpt
blob: b6118b9b2ba56ee8c280b83a3c32b52876fe44bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--TEST--
bug #35103 Bad handling of unsigned bigint
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php

$drop = <<<EOSQL
DROP TABLE test_bint;
DROP TABLE test_buint;
EOSQL;
	include "connect.inc";

	$mysql = new mysqli($host, $user, $passwd, "test");
	$mysql->query("DROP TABLE IF EXISTS test_bint");
	$mysql->query("CREATE TABLE test_bint (a bigint(20) default NULL) ENGINE=MYISAM");
	$mysql->query("INSERT INTO test_bint VALUES (9223372036854775807),(-9223372036854775808),(-2147483648),(-2147483649),(-2147483647),(2147483647),(2147483648),(2147483649)");

	$mysql->query("DROP TABLE IF EXISTS test_buint");
	$mysql->query("CREATE TABLE test_buint (a bigint(20) unsigned default NULL)");
	$mysql->query("INSERT INTO test_buint VALUES (18446744073709551615),(9223372036854775807),(9223372036854775808),(2147483647),(2147483649),(4294967295)");
	
	$stmt = $mysql->prepare("SELECT a FROM test_bint ORDER BY a");
	$stmt->bind_result($v);
	$stmt->execute();
	$i=0;
	echo "BIG INT SIGNED, TEST\n";
	while ($i++ < 8) {
		$stmt->fetch();
		echo $v, "\n";
	}
	$stmt->close();

	echo str_repeat("-", 20), "\n";

	$stmt = $mysql->prepare("SELECT a FROM test_buint ORDER BY a");
	$stmt->bind_result($v2);
	$stmt->execute();
	$j=0;
	echo "BIG INT UNSIGNED TEST\n";
	while ($j++ < 6) {
		$stmt->fetch();
		echo $v2, "\n";
	}
	$stmt->close();

	$mysql->multi_query($drop);

	$mysql->close();
?>
--EXPECT--
BIG INT SIGNED, TEST
-9223372036854775808
-2147483649
-2147483648
-2147483647
2147483647
2147483648
2147483649
9223372036854775807
--------------------
BIG INT UNSIGNED TEST
2147483647
2147483649
4294967295
9223372036854775807
9223372036854775808
18446744073709551615