]> granicus.if.org Git - php/commitdiff
Making tests pass strict sql mode.
authorUlf Wendel <uw@php.net>
Tue, 8 Jun 2010 10:55:12 +0000 (10:55 +0000)
committerUlf Wendel <uw@php.net>
Tue, 8 Jun 2010 10:55:12 +0000 (10:55 +0000)
ext/mysqli/tests/bug35759.phpt
ext/mysqli/tests/bug51647.phpt
ext/mysqli/tests/mysqli_fetch_all.phpt
ext/mysqli/tests/mysqli_fetch_all_oo.phpt
ext/mysqli/tests/mysqli_fetch_array.phpt
ext/mysqli/tests/mysqli_fetch_array_oo.phpt

index cbceb3b42e3fa9336143715baa1b27e91be54a91..bcf9cb8e67c543971735f852b1d41ad4d623219a 100644 (file)
@@ -8,53 +8,51 @@ require_once('skipifconnectfailure.inc');
 --FILE--
 <?php
 
-$sql=<<<EOSQL
-CREATE TABLE blobby (
-  a1 MEDIUMBLOB NOT NULL,
-
-
-EOSQL;
        require_once("connect.inc");
        $col_num= 1000;
 
        $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
-       $mysql->query("DROP TABLE IF EXISTS blobby");
-       $create = "CREATE TABLE blobby (a0 MEDIUMBLOB NOT NULL DEFAULT ''";
+       $mysql->query("DROP TABLE IF EXISTS test");
+       $create = "CREATE TABLE test (a0 MEDIUMBLOB NOT NULL DEFAULT ''";
        $i= 0;
        while (++$i < $col_num) {
                $create .= ", a$i MEDIUMBLOB NOT NULL DEFAULT ''";
        }
-        $create .= ")";
+       $create .= ")";
+
+       if (!$mysql->query($create)) {
+               if (1101 == $mysql->errno) {
+                       /* SQL strict mode - [1101] BLOB/TEXT column 'a0' can't have a default value */
+                       print "done!";
+                       exit(0);
+               }
+               printf("[001] [%d] %s\n", $mysql->errno, $mysql->error);
+       }
 
-        $mysql->query($create);
-       $mysql->query("INSERT INTO blobby (a0) VALUES ('')");
+       if (!$mysql->query("INSERT INTO test (a0) VALUES ('')"))
+               printf("[002] [%d] %s\n", $mysql->errno, $mysql->error);
 
-       $stmt = $mysql->prepare("SELECT * FROM blobby");
-       $stmt->execute();
-       $stmt->store_result();
-       for ($i = 0; $i < $col_num; $i++) {
-               $params[] = &$col_num;
-       }
-       call_user_func_array(array($stmt, "bind_result"), $params);
-       $stmt->fetch();
+       $stmt = $mysql->prepare("SELECT * FROM test");
+       if ($stmt) {
 
-       $stmt->close();
+               $stmt->execute();
+               $stmt->store_result();
+               for ($i = 0; $i < $col_num; $i++) {
+                       $params[] = &$col_num;
+               }
+               call_user_func_array(array($stmt, "bind_result"), $params);
+               $stmt->fetch();
 
-       $mysql->query("DROP TABLE blobby");
+               $stmt->close();
+       } else {
+               printf("[003] [%d] %s\n", $mysql->errno, $mysql->error);
+       }
 
        $mysql->close();
-       echo "OK\n";
-?>
---CLEAN--
-<?php
-require_once("connect.inc");
-if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
-   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
 
-if (!mysqli_query($link, "DROP TABLE IF EXISTS blobby"))
-       printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
-
-mysqli_close($link);
+       echo "done!";
 ?>
+--CLEAN--
+<?php require("clean_table.inc"); ?>
 --EXPECT--
-OK
+done!
\ No newline at end of file
index b222aa5f014e58f3e6d45a8938ea189bb79f0b15..33aec04d5ca161a2c9690486cbb54a0d9bdb1eb4 100644 (file)
@@ -9,12 +9,37 @@ require_once('skipifconnectfailure.inc');
 <?php
        include ("connect.inc");
 
-       $link = mysqli_init();
-       $link->ssl_set("client-key.pem", "client-cert.pem", "cacert.pem","","");
+       if (!is_object($link = mysqli_init()))
+               printf("[001] Cannot create link\n");
+
+       if (!$link->ssl_set("client-key.pem", "client-cert.pem", "cacert.pem","",""))
+               printf("[002] [%d] %s\n", $link->errno, $link->error);
+
        if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
-               printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+               printf("[003] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+       }
+
+       if (!$res = $link->query('SHOW STATUS like "Ssl_cipher"')) {
+               if (1064 == $link->errno) {
+                       /* ERROR 1064 (42000): You have an error in your SQL syntax;  = sql strict mode */
+                       if ($res = $link->query("SHOW STATUS")) {
+                               while ($row = $res->fetch_assoc())
+                                       if ($row['Variable_name'] == 'Ssl_cipher')
+                                               break;
+                       } else {
+                               printf("[005] [%d] %s\n", $link->errno, $link->error);
+                       }
+               } else {
+                       printf("[004] [%d] %s\n", $link->errno, $link->error);
+               }
+       } else {
+               if (!$row = $res->fetch_assoc())
+                       printf("[006] [%d] %s\n", $link->errno, $link->error);
        }
-       var_dump($link->query("show status like \"Ssl_cipher\"")->fetch_assoc());
+
+
+
+       var_dump($row);
 
        print "done!";
 ?>
index eacecc92d0d07ebec49ff1230131f06c1b587925..6614f1e8d90ee49e91b7a5f188cee0952f58515e 100644 (file)
@@ -99,24 +99,27 @@ if (!function_exists('mysqli_fetch_all'))
                }
 
                if (!mysqli_query($link, $sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
-                               print $sql;
                                // don't bail, engine might not support the datatype
                                return false;
                }
 
-               if (is_null($php_value) && !mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
+               if (is_null($php_value)) {
+                       if (!mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
                                printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
                                return false;
-               }
-
-               if (!is_null($php_value)) {
-                               if (is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
-                                               printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
-                                               return false;
-                               } else if (!is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $sql_value))) {
-                                               printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
-                                               return false;
+                       }
+               } else {
+                       if (is_string($sql_value)) {
+                               if (!mysqli_query($link, $sql = "INSERT INTO test(id, label) VALUES (1, '" . $sql_value . "')")) {
+                                       printf("[%04ds] [%d] %s - %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link), $sql);
+                                       return false;
                                }
+                       } else {
+                               if (!mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
+                                       printf("[%04di] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
+                                       return false;
+                               }
+                       }
                }
 
                if (!$res = mysqli_query($link, "SELECT id, label FROM test")) {
@@ -193,24 +196,25 @@ if (!function_exists('mysqli_fetch_all'))
        func_mysqli_fetch_all($link, $engine, "INTEGER UNSIGNED", 4294967295, "4294967295", 230);
        func_mysqli_fetch_all($link, $engine, "INTEGER UNSIGNED", NULL, NULL, 240);
 
-       func_mysqli_fetch_all($link, $engine, "BIGINT", -9223372036854775808, "-9223372036854775808", 250);
+       func_mysqli_fetch_all($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250);
+
        func_mysqli_fetch_all($link, $engine, "BIGINT", NULL, NULL, 260);
-       func_mysqli_fetch_all($link, $engine, "BIGINT UNSIGNED", 18446744073709551615, "18446744073709551615", 270);
+       func_mysqli_fetch_all($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270);
        func_mysqli_fetch_all($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280);
 
-       func_mysqli_fetch_all($link, $engine, "FLOAT", -9223372036854775808 - 1.1, "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu");
+       func_mysqli_fetch_all($link, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu");
        func_mysqli_fetch_all($link, $engine, "FLOAT", NULL, NULL, 300);
-       func_mysqli_fetch_all($link, $engine, "FLOAT UNSIGNED", 18446744073709551615 + 1.1, "1.84467e+19", 310, "/1\.84467e\+?[0]?19/iu");
+       func_mysqli_fetch_all($link, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+19", 310, "/1\.84467e\+?[0]?19/iu");
        func_mysqli_fetch_all($link, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320);
 
-       func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2)", -99999999.99, "-99999999.99", 330);
+       func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330);
        func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2)", NULL, NULL, 340);
-       func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2) UNSIGNED", 99999999.99, "99999999.99", 350);
+       func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350);
        func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360);
 
-       func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", -99999999.99, "-99999999.99", 370);
+       func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370);
        func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", NULL, NULL, 380);
-       func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", 99999999.99, "99999999.99", 390);
+       func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390);
        func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400);
 
        // don't care about date() strict TZ warnings...
@@ -238,10 +242,10 @@ if (!function_exists('mysqli_fetch_all'))
        func_mysqli_fetch_all($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560);
        func_mysqli_fetch_all($link, $engine, "CHAR(1)", NULL, NULL, 570);
 
-       $string65k = func_mysqli_fetch_array_make_string(65535);
+       $string65k = func_mysqli_fetch_array_make_string(65400);
        func_mysqli_fetch_all($link, $engine, "VARCHAR(1)", "a", "a", 580);
        func_mysqli_fetch_all($link, $engine, "VARCHAR(255)", $string255, $string255, 590);
-       func_mysqli_fetch_all($link, $engine, "VARCHAR(65635)", $string65k, $string65k, 600);
+       func_mysqli_fetch_all($link, $engine, "VARCHAR(65400)", $string65k, $string65k, 600);
        func_mysqli_fetch_all($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610);
        func_mysqli_fetch_all($link, $engine, "VARCHAR(1)", NULL, NULL, 620);
 
@@ -299,7 +303,7 @@ if (!function_exists('mysqli_fetch_all'))
 ?>
 --CLEAN--
 <?php
-       require_once("clean_table.inc");
+       // require_once("clean_table.inc");
 ?>
 --EXPECTF--
 [005]
index a71eb2bce28beb7c6c56720065839bbcd6d0bc37..30985a5c3de8396d3a28a91d6e2752f460723477 100644 (file)
@@ -100,24 +100,27 @@ if (!function_exists('mysqli_fetch_all'))
                }
 
                if (!$link->query($sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
-                       print $sql;
-                       // don't bail, engine might not support the datatype
-                       return false;
-               }
-
-               if (is_null($php_value) && !$link->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
-                       printf("[%04d] [%d] %s\n", $offset + 1, $link->errno, $link->error);
-                       return false;
+                               // don't bail, engine might not support the datatype
+                               return false;
                }
 
-               if (!is_null($php_value)) {
-                       if (is_int($sql_value) && !$link->query(sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
-                               printf("[%04d] [%d] %s\n", $offset + 1, $link->errno, $link->error);
-                               return false;
-                       } else if (!is_int($sql_value) && !$link->query(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $sql_value))) {
+               if (is_null($php_value)) {
+                       if (!$link->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
                                printf("[%04d] [%d] %s\n", $offset + 1, $link->errno, $link->error);
                                return false;
                        }
+               } else {
+                       if (is_string($sql_value)) {
+                               if (!$link->query($sql = "INSERT INTO test(id, label) VALUES (1, '" . $sql_value . "')")) {
+                                       printf("[%04ds] [%d] %s - %s\n", $offset + 1, $link->errno, $link->error, $sql);
+                                       return false;
+                               }
+                       } else {
+                               if (!$link->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
+                                       printf("[%04di] [%d] %s\n", $offset + 1, $link->errno, $link->error);
+                                       return false;
+                               }
+                       }
                }
 
                if (!$res = $link->query("SELECT id, label FROM test")) {
@@ -178,7 +181,7 @@ if (!function_exists('mysqli_fetch_all'))
        func_mysqli_fetch_all_oo($link, $engine, "SMALLINT", -32768, "-32768", 100);
        func_mysqli_fetch_all_oo($link, $engine, "SMALLINT", 32767, "32767", 110);
        func_mysqli_fetch_all_oo($link, $engine, "SMALLINT", NULL, NULL, 120);
-       func_mysqli_fetch_all_oo($link, $engine, "SMALLINT UNSIGNED", 65535, "65535", 130);
+       func_mysqli_fetch_all_oo($link, $engine, "SMALLINT UNSIGNED", 65400, "65400", 130);
        func_mysqli_fetch_all_oo($link, $engine, "SMALLINT UNSIGNED", NULL, NULL, 140);
 
        func_mysqli_fetch_all_oo($link, $engine, "MEDIUMINT", -8388608, "-8388608", 150);
@@ -193,24 +196,24 @@ if (!function_exists('mysqli_fetch_all'))
        func_mysqli_fetch_all_oo($link, $engine, "INTEGER UNSIGNED", 4294967295, "4294967295", 230);
        func_mysqli_fetch_all_oo($link, $engine, "INTEGER UNSIGNED", NULL, NULL, 240);
 
-       func_mysqli_fetch_all_oo($link, $engine, "BIGINT", -9223372036854775808, "-9223372036854775808", 250);
+       func_mysqli_fetch_all_oo($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250);
        func_mysqli_fetch_all_oo($link, $engine, "BIGINT", NULL, NULL, 260);
-       func_mysqli_fetch_all_oo($link, $engine, "BIGINT UNSIGNED", 18446744073709551615, "18446744073709551615", 270);
+       func_mysqli_fetch_all_oo($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270);
        func_mysqli_fetch_all_oo($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280);
 
-       func_mysqli_fetch_all_oo($link, $engine, "FLOAT", -9223372036854775808 - 1.1, "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu");
+       func_mysqli_fetch_all_oo($link, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu");
        func_mysqli_fetch_all_oo($link, $engine, "FLOAT", NULL, NULL, 300);
-       func_mysqli_fetch_all_oo($link, $engine, "FLOAT UNSIGNED", 18446744073709551615 + 1.1, "1.84467e+?19", 310, "/1\.84467e\+?[0]?19/iu");
+       func_mysqli_fetch_all_oo($link, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+?19", 310, "/1\.84467e\+?[0]?19/iu");
        func_mysqli_fetch_all_oo($link, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320);
 
-       func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2)", -99999999.99, "-99999999.99", 330);
+       func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330);
        func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2)", NULL, NULL, 340);
-       func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2) UNSIGNED", 99999999.99, "99999999.99", 350);
+       func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350);
        func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360);
 
-       func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", -99999999.99, "-99999999.99", 370);
+       func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370);
        func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", NULL, NULL, 380);
-       func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", 99999999.99, "99999999.99", 390);
+       func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390);
        func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400);
 
        // don't care about date() strict TZ warnings...
@@ -241,10 +244,10 @@ if (!function_exists('mysqli_fetch_all'))
        func_mysqli_fetch_all_oo($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560);
        func_mysqli_fetch_all_oo($link, $engine, "CHAR(1)", NULL, NULL, 570);
 
-       $string65k = func_mysqli_fetch_array_oo_make_string(65535);
+       $string65k = func_mysqli_fetch_array_oo_make_string(65400);
        func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(1)", "a", "a", 580);
        func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(255)", $string255, $string255, 590);
-       func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(65635)", $string65k, $string65k, 600);
+       func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(65400)", $string65k, $string65k, 600);
        func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610);
        func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(1)", NULL, NULL, 620);
 
index cff3141661ebed3ed9a74813b9f614a2a163c7cd..cad8a1015cedbf5470c2b040aaf8ae2432dec54f 100644 (file)
@@ -77,26 +77,28 @@ require_once('skipifconnectfailure.inc');
                }
 
                if (!mysqli_query($link, $sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
-                       print $sql;
-                       // don't bail, engine might not support the datatype
-                       return false;
-               }
-
-               if (is_null($php_value) && !mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
-                       printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
-                       return false;
+                               // don't bail, engine might not support the datatype
+                               return false;
                }
 
-               if (!is_null($php_value)) {
-                       if (is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
-                               printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
-                               return false;
-                       } else if (!is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $sql_value))) {
+               if (is_null($php_value)) {
+                       if (!mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
                                printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
                                return false;
                        }
+               } else {
+                       if (is_string($sql_value)) {
+                               if (!mysqli_query($link, $sql = "INSERT INTO test(id, label) VALUES (1, '" . $sql_value . "')")) {
+                                       printf("[%04ds] [%d] %s - %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link), $sql);
+                                       return false;
+                               }
+                       } else {
+                               if (!mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
+                                       printf("[%04di] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
+                                       return false;
+                               }
+                       }
                }
-
                if (!$res = mysqli_query($link, "SELECT id, label FROM test")) {
                        printf("[%04d] [%d] %s\n", $offset + 2, mysqli_errno($link), mysqli_error($link));
                        return false;
@@ -107,8 +109,6 @@ require_once('skipifconnectfailure.inc');
                        return false;
                }
 
-
-
                if ($regexp_comparison) {
                        if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) {
                                printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
@@ -185,25 +185,25 @@ require_once('skipifconnectfailure.inc');
        if ($IS_MYSQLND ||
                ((mysqli_get_server_version($link) >= 51000) &&
                (mysqli_get_client_version($link) >= 51000))) {
-               func_mysqli_fetch_array($link, $engine, "BIGINT", -9223372036854775808, "-9223372036854775808", 250);
+               func_mysqli_fetch_array($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250);
                func_mysqli_fetch_array($link, $engine, "BIGINT", NULL, NULL, 260);
-               func_mysqli_fetch_array($link, $engine, "BIGINT UNSIGNED", 18446744073709551615, "18446744073709551615", 260);
+               func_mysqli_fetch_array($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 260);
                func_mysqli_fetch_array($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280);
        }
 
-       func_mysqli_fetch_array($link, $engine, "FLOAT", -9223372036854775808 - 1.1, "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu");
+       func_mysqli_fetch_array($link, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu");
        func_mysqli_fetch_array($link, $engine, "FLOAT", NULL, NULL, 300);
-       func_mysqli_fetch_array($link, $engine, "FLOAT UNSIGNED", 18446744073709551615 + 1.1, "1.84467e+?19", 310, "/1\.84467e\+?[0]?19/iu");
+       func_mysqli_fetch_array($link, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+?19", 310, "/1\.84467e\+?[0]?19/iu");
        func_mysqli_fetch_array($link, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320);
 
-       func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2)", -99999999.99, "-99999999.99", 330);
+       func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330);
        func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2)", NULL, NULL, 340);
-       func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2) UNSIGNED", 99999999.99, "99999999.99", 350);
+       func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350);
        func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360);
 
-       func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", -99999999.99, "-99999999.99", 370);
+       func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370);
        func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", NULL, NULL, 380);
-       func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", 99999999.99, "99999999.99", 390);
+       func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390);
        func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400);
 
                // don't care about date() strict TZ warnings...
@@ -233,10 +233,10 @@ require_once('skipifconnectfailure.inc');
        func_mysqli_fetch_array($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560);
        func_mysqli_fetch_array($link, $engine, "CHAR(1)", NULL, NULL, 570);
 
-       $string65k = func_mysqli_fetch_array_make_string(65535);
+       $string65k = func_mysqli_fetch_array_make_string(65400);
        func_mysqli_fetch_array($link, $engine, "VARCHAR(1)", "a", "a", 580);
        func_mysqli_fetch_array($link, $engine, "VARCHAR(255)", $string255, $string255, 590);
-       func_mysqli_fetch_array($link, $engine, "VARCHAR(65635)", $string65k, $string65k, 600);
+       func_mysqli_fetch_array($link, $engine, "VARCHAR(65400)", $string65k, $string65k, 600);
        func_mysqli_fetch_array($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610);
        func_mysqli_fetch_array($link, $engine, "VARCHAR(1)", NULL, NULL, 620);
 
index 78c21308f381741b5c2e414b0df908f36cc07987..86fdb680269a112dfe8706c66405c353ee14caf1 100644 (file)
@@ -76,24 +76,27 @@ require_once('skipifconnectfailure.inc');
                }
 
                if (!$mysqli->query($sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
-                       print $sql;
-                       // don't bail, engine might not support the datatype
-                       return false;
-               }
-
-               if (is_null($php_value) && !$mysqli->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
-                       printf("[%04d] [%d] %s\n", $offset + 1, $mysqli->errno, $mysqli->error);
-                       return false;
+                               // don't bail, engine might not support the datatype
+                               return false;
                }
 
-               if (!is_null($php_value)) {
-                       if (is_int($sql_value) && !$mysqli->query(sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
-                               printf("[%04d] [%d] %s\n", $offset + 1, $mysqli->errno, $mysqli->error);
-                               return false;
-                       } else if (!is_int($sql_value) && !$mysqli->query(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $sql_value))) {
+               if (is_null($php_value)) {
+                       if (!$mysqli->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
                                printf("[%04d] [%d] %s\n", $offset + 1, $mysqli->errno, $mysqli->error);
                                return false;
                        }
+               } else {
+                       if (is_string($sql_value)) {
+                               if (!$mysqli->query($sql = "INSERT INTO test(id, label) VALUES (1, '" . $sql_value . "')")) {
+                                       printf("[%04ds] [%d] %s - %s\n", $offset + 1, $mysqli->errno, $mysqli->error, $sql);
+                                       return false;
+                               }
+                       } else {
+                               if (!$mysqli->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
+                                       printf("[%04di] [%d] %s\n", $offset + 1, $mysqli->errno, $mysqli->error);
+                                       return false;
+                               }
+                       }
                }
 
                if (!$res = $mysqli->query("SELECT id, label FROM test")) {
@@ -169,24 +172,24 @@ require_once('skipifconnectfailure.inc');
        if ($IS_MYSQLND ||
                ((mysqli_get_server_version($link) >= 51000) &&
                 (mysqli_get_client_version($link) >= 51000))) {
-               func_mysqli_fetch_array($mysqli, $engine, "BIGINT", -9223372036854775808, "-9223372036854775808", 250);
+               func_mysqli_fetch_array($mysqli, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250);
                func_mysqli_fetch_array($mysqli, $engine, "BIGINT", NULL, NULL, 260);
-               func_mysqli_fetch_array($mysqli, $engine, "BIGINT UNSIGNED", 18446744073709551615, "18446744073709551615", 270);
+               func_mysqli_fetch_array($mysqli, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270);
                func_mysqli_fetch_array($mysqli, $engine, "BIGINT UNSIGNED", NULL, NULL, 280);
        }
 
-       func_mysqli_fetch_array($mysqli, $engine, "FLOAT", -9223372036854775808 - 1.1, "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu");
+       func_mysqli_fetch_array($mysqli, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu");
        func_mysqli_fetch_array($mysqli, $engine, "FLOAT", NULL, NULL, 300);
-       func_mysqli_fetch_array($mysqli, $engine, "FLOAT UNSIGNED", 18446744073709551615 + 1.1, "1.84467e+?19", 310, "/1\.84467e\+?[0]?19/iu");
+       func_mysqli_fetch_array($mysqli, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+?19", 310, "/1\.84467e\+?[0]?19/iu");
        func_mysqli_fetch_array($mysqli, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320);
 
-       func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2)", -99999999.99, "-99999999.99", 330);
+       func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330);
        func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2)", NULL, NULL, 340);
-       func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2) UNSIGNED", 99999999.99, "99999999.99", 350);
+       func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350);
        func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360);
-       func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", -99999999.99, "-99999999.99", 370);
+       func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370);
        func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", NULL, NULL, 380);
-       func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", 99999999.99, "99999999.99", 390);
+       func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390);
        func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", NULL, NULL, 400);
 
        // don't care about date() strict TZ warnings...
@@ -214,10 +217,10 @@ require_once('skipifconnectfailure.inc');
        func_mysqli_fetch_array($mysqli, $engine, "CHAR(1) NOT NULL", "a", "a", 560);
        func_mysqli_fetch_array($mysqli, $engine, "CHAR(1)", NULL, NULL, 570);
 
-       $string65k = func_mysqli_fetch_array_make_string(65535);
+       $string65k = func_mysqli_fetch_array_make_string(65400);
        func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(1)", "a", "a", 580);
        func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(255)", $string255, $string255, 590);
-       func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(65635)", $string65k, $string65k, 600);
+       func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(65400)", $string65k, $string65k, 600);
        func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610);
        func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(1)", NULL, NULL, 620);