include "connect.inc";
/*** test mysqli_connect 127.0.0.1 ***/
- $link = mysqli_connect($host, $user, $passwd);
+ $link = mysqli_connect($host, $user, $passwd, "test");
- mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
mysqli_query($link,"CREATE TABLE test_bind_result(c1 date, c2 time,
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
- mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', 'this is a test')");
+ mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', 'this is a test0')");
+ mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567891', 'this is a test1')");
+ mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567892', 'this is a test2')");
+ mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567893', 'this is a test3')");
- $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
+ $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch ORDER BY c1");
mysqli_bind_result($stmt, $c1, $c2);
mysqli_execute($stmt);
- mysqli_fetch($stmt);
+ $i=4;
+ while ($i--) {
+ mysqli_fetch($stmt);
+ $test = array($c1,$c2);
+ var_dump($test);
+ }
- $test = array($c1,$c2);
-
- var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
[0]=>
string(10) "1234567890"
[1]=>
- string(14) "this is a test"
+ string(15) "this is a test0"
+}
+array(2) {
+ [0]=>
+ string(10) "1234567891"
+ [1]=>
+ string(15) "this is a test1"
+}
+array(2) {
+ [0]=>
+ string(10) "1234567892"
+ [1]=>
+ string(15) "this is a test2"
+}
+array(2) {
+ [0]=>
+ string(10) "1234567893"
+ [1]=>
+ string(15) "this is a test3"
}
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned,
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint,
--TEST--
-mysqli fetch bigint values
+mysqli fetch bigint values (ok to fail with 4.1.x)
--SKIPIF--
<?php
if (PHP_INT_SIZE == 8) {
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 bigint default 5,
var_dump($test);
mysqli_stmt_close($stmt);
+
+ mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch_uint");
+ mysqli_query($link,"CREATE TABLE test_bind_fetch_uint(c1 integer unsigned, c2 integer unsigned)");
+
+ mysqli_query($link, "INSERT INTO test_bind_fetch_uint (c1,c2) VALUES (20123456, 3123456789)");
+
+ $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_uint");
+ mysqli_bind_result($stmt, $c1, $c2);
+ mysqli_execute($stmt);
+ $rc = mysqli_fetch($stmt);
+
+ echo $c1, "\n", $c2, "\n";
+
+ mysqli_stmt_close($stmt);
+
+
mysqli_close($link);
?>
+
--EXPECT--
array(7) {
[0]=>
[4]=>
int(0)
[5]=>
- string(13) "-333333333333"
+ int(0)
[6]=>
int(100)
}
+20123456
+3123456789
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
$c = array(0,0,0,0,0,0,0,0);
- mysqli_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
+ $b_res= mysqli_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
mysqli_execute($stmt);
mysqli_fetch($stmt);
mysqli_fetch($stmt);
$test = "";
for ($i=0; $i < count($c); $i++)
$test .= ($c[0] == $d[0]) ? "1" : "0";
-
- var_dump($test);
+ if ($test == "11111111")
+ echo "ok";
+ else if ($b_res == FALSE && mysqli_get_client_version() > 40100 && mysqli_get_client_version() < 50000 &&
+ mysqli_get_server_version($link) > 50000)
+ echo "error (4.1 library with 5.x server)";
+ else
+ echo "error";
mysqli_close($link);
?>
---EXPECT--
-string(8) "11111111"
+--EXPECTF--
+ok
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
mysqli_query($link,"CREATE TABLE test_bind_result(c1 date, c2 time,
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned,
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint,
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 varchar(10), c2 text)");
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_fetch");
mysqli_query($link,"CREATE TABLE test_fetch(c1 smallint unsigned,
include "connect.inc";
$mysql = new mysqli($host, $user, $passwd);
+ mysqli_query($mysql, "SET sql_mode=''");
$esc_str = chr(0xbf) . chr(0x5c);
/*** test mysqli_connect 127.0.0.1 ***/
$link = mysqli_connect($host, $user, $passwd);
mysqli_select_db($link, "test");
+ mysqli_query($link, "SET sql_mode=''");
/* two fields are needed. the problem does not occur with 1 field only selected. */
$link->query("CREATE TABLE test_users(user_id int(10) unsigned NOT NULL auto_increment, login varchar(50) default '', PRIMARY KEY (user_id))");
--- /dev/null
+--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
--- /dev/null
+--TEST--
+Bug #35517 mysqli_stmt_fetch returns NULL
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+ include "connect.inc";
+
+ $mysql = new mysqli($host, $user, $passwd, "test");
+
+ $mysql->query("CREATE TABLE temp (id INT UNSIGNED NOT NULL)");
+ $mysql->query("INSERT INTO temp (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)");
+
+ $stmt = $mysql->prepare("SELECT id FROM temp");
+ $stmt->execute();
+ $stmt->bind_result($id);
+ while ($stmt->fetch()) {
+ var_dump($id);
+ }
+ $stmt->close();
+
+ $mysql->query("DROP TABLE temp");
+ $mysql->close();
+?>
+--EXPECTF--
+string(10) "3000000897"
+string(10) "3800001532"
+string(10) "3900002281"
+string(10) "3100059612"
--- /dev/null
+--TEST--
+bug #35759 : mysqli_stmt_bind_result() makes huge allocation when column empty
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$sql=<<<EOSQL
+CREATE TABLE blobby (
+ a1 MEDIUMBLOB NOT NULL,
+
+
+EOSQL;
+ include "connect.inc";
+ $col_num= 1000;
+
+ $mysql = new mysqli($host, $user, $passwd, "test");
+ $mysql->query("DROP TABLE IF EXISTS blobby");
+ $create = "CREATE TABLE blobby (a0 MEDIUMBLOB NOT NULL DEFAULT ''";
+ $i= 0;
+ while (++$i < $col_num) {
+ $create .= ", a$i MEDIUMBLOB NOT NULL DEFAULT ''";
+ }
+ $create .= ")";
+
+ $mysql->query($create);
+ $mysql->query("INSERT INTO blobby (a0) VALUES ('')");
+
+ $stmt = $mysql->prepare("SELECT * FROM blobby");
+ $stmt->execute();
+ $stmt->store_result();
+ $params= array_pad(array(), $col_num, "");
+ call_user_func_array(array($stmt, "bind_result"), $params);
+ $stmt->fetch();
+
+ $stmt->close();
+
+ $mysql->query("DROP TABLE blobby");
+
+ $mysql->close();
+ echo "OK\n";
+?>
+--EXPECT--
+OK