]> granicus.if.org Git - php/commitdiff
bring tests up-to-date with 5_1 branch
authorAndrey Hristov <andrey@php.net>
Wed, 4 Jan 2006 23:04:06 +0000 (23:04 +0000)
committerAndrey Hristov <andrey@php.net>
Wed, 4 Jan 2006 23:04:06 +0000 (23:04 +0000)
#few are failing and will stop failing when bugfixes are upmerged from 5_1

20 files changed:
ext/mysqli/tests/003.phpt
ext/mysqli/tests/004.phpt
ext/mysqli/tests/006.phpt
ext/mysqli/tests/007.phpt
ext/mysqli/tests/008.phpt
ext/mysqli/tests/009.phpt
ext/mysqli/tests/010.phpt
ext/mysqli/tests/013.phpt
ext/mysqli/tests/020.phpt
ext/mysqli/tests/023.phpt
ext/mysqli/tests/024.phpt
ext/mysqli/tests/025.phpt
ext/mysqli/tests/026.phpt
ext/mysqli/tests/042.phpt
ext/mysqli/tests/060.phpt
ext/mysqli/tests/065.phpt
ext/mysqli/tests/bug32405.phpt
ext/mysqli/tests/bug35103.phpt [new file with mode: 0644]
ext/mysqli/tests/bug35517.phpt [new file with mode: 0644]
ext/mysqli/tests/bug35759.phpt [new file with mode: 0644]

index d043dc7724f61d1487ea562f9a42fe21696c8de1..28aedb032cf872a201efaeb12014b2532a2fc3c0 100644 (file)
@@ -7,9 +7,9 @@ mysqli connect
        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, 
index c80c7214e3262cfbb80c296c11da1fa813e58a95..fafc30ba0d7166d759d6bd1c8911b560a1c2b14d 100644 (file)
@@ -14,16 +14,21 @@ mysqli fetch char/text
        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);
@@ -33,5 +38,23 @@ array(2) {
   [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"
 }
index 4b495cc5945129b0a5396d0594a8480444e0a219..a53ad7a54723d4dca7d9391eaebe07cf7a865138 100644 (file)
@@ -10,6 +10,7 @@ mysqli fetch long values
        $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,
index 503863bdc2c05580851200f999e5cbf0481ce593..cb32033ccaecb0f6a52209dcfdfea949644eb306 100644 (file)
@@ -10,6 +10,7 @@ mysqli fetch short values
        $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,
index 12311d621b977644075300eeed05fd438d859b9d..9fc01b8adf0889ea656a6d2748af1bca6df8fe75 100644 (file)
@@ -10,6 +10,7 @@ mysqli fetch tinyint values
        $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,
index 091313870fd3e982e683a454255432646f1dcaa6..32ed3c18f07cb832de4fd63e7cc2b04fc76b793b 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-mysqli fetch bigint values
+mysqli fetch bigint values (ok to fail with 4.1.x)
 --SKIPIF--
 <?php
        if (PHP_INT_SIZE == 8) {
@@ -16,6 +16,7 @@ mysqli fetch bigint values
        $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,
@@ -38,8 +39,25 @@ mysqli fetch bigint values
        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]=>
@@ -53,7 +71,9 @@ array(7) {
   [4]=>
   int(0)
   [5]=>
-  string(13) "-333333333333"
+  int(0)
   [6]=>
   int(100)
 }
+20123456
+3123456789
index 0d74bed501c7c9e5d6c1e41bc6cd10f42ae5dba5..6b79d62f42289d8d6a8bef476596d10e2558d73f 100644 (file)
@@ -12,6 +12,7 @@ precision=12
        $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");
 
index ff435f94db99b11abb644b2d0841e10e94d1d100..983ceba14ceff58d453a5100aa0a28b2afdd4639 100644 (file)
@@ -25,7 +25,7 @@ mysqli fetch mixed / mysql_query
        $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);  
@@ -38,10 +38,15 @@ mysqli fetch mixed / mysql_query
        $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
index 85834c52afc03a2b78a96bf0c9cc069b2cc2637b..4ae140f620ad6c0f6825e7ab9e8e113a8590caa1 100644 (file)
@@ -10,6 +10,7 @@ mysqli bind_param/bind_result date
        $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, 
index 69e9b20858c3bcd5bf15045fe2571b5b6f641775..24a717a6eb4d5666bd6d3dde6105c1f88a3669f0 100644 (file)
@@ -10,6 +10,7 @@ mysqli bind_param/bind_prepare fetch long values
        $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,
index c6d6cd7e70247e987371a340b09cb82b05cc85b9..f0d0a6407acccad04361017cca838498f15273b1 100644 (file)
@@ -10,6 +10,7 @@ mysqli bind_param/bind_result short values
        $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,
index 85ff0fa29fe1c3a7b546b7ccb7d9e073f2de0b15..f3338cf4671197164b38503cf732a218ff420939 100644 (file)
@@ -10,6 +10,7 @@ mysqli bind_param/bind_result tinyint values
        $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,
index 0f9e882608860ee7d96a3c59b4c3f1b886a4c91a..d38e3c1807591829c4fef71fbe1e964db996524b 100644 (file)
@@ -10,6 +10,7 @@ mysqli bind_param/bind_result with send_long_data
        $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)");
index fe6d23e172afe0441ba44f146effa6be13724262..719e24925d0114f99dd1b6c5167672ec53f609f1 100644 (file)
@@ -10,6 +10,7 @@ mysqli_fetch_object
        $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,
index 875130dc55507f53210844153e39b7d99f35758c..ba6c231c57e656bb483857dabebc0ffca764ca17 100644 (file)
@@ -16,6 +16,7 @@ mysqli_fetch_object with classes
        $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,
index d0fa071169eaaba62baabb5a28b1445d4a55b12b..09ee886ec5701ed616dd7d6367a2554eb8cbd963 100644 (file)
@@ -12,6 +12,7 @@ if (!function_exists('mysqli_set_charset')) {
        include "connect.inc";
 
        $mysql = new mysqli($host, $user, $passwd);
+       mysqli_query($mysql, "SET sql_mode=''");
 
        $esc_str = chr(0xbf) . chr(0x5c);
 
index 9b58e3611bfc2d7398f15388e109da2803457d5f..f805dc79825a719f92e4a51e3a58196266e2057c 100644 (file)
@@ -9,6 +9,7 @@ Bug #32405
        /*** 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))");
diff --git a/ext/mysqli/tests/bug35103.phpt b/ext/mysqli/tests/bug35103.phpt
new file mode 100644 (file)
index 0000000..b6118b9
--- /dev/null
@@ -0,0 +1,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
diff --git a/ext/mysqli/tests/bug35517.phpt b/ext/mysqli/tests/bug35517.phpt
new file mode 100644 (file)
index 0000000..eb1b543
--- /dev/null
@@ -0,0 +1,29 @@
+--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"
diff --git a/ext/mysqli/tests/bug35759.phpt b/ext/mysqli/tests/bug35759.phpt
new file mode 100644 (file)
index 0000000..5f67a76
--- /dev/null
@@ -0,0 +1,44 @@
+--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