diff options
| author | Ulf Wendel <uw@php.net> | 2010-06-08 10:55:12 +0000 |
|---|---|---|
| committer | Ulf Wendel <uw@php.net> | 2010-06-08 10:55:12 +0000 |
| commit | 949b509299f31aba9a7140e56035cb99033f109d (patch) | |
| tree | d7afce06052c36ba13ab0dd2bb060896e78c2d12 | |
| parent | 99c31b31ec6103358a7f7401a9bc4a7e957637f4 (diff) | |
| download | php-git-949b509299f31aba9a7140e56035cb99033f109d.tar.gz | |
Making tests pass strict sql mode.
| -rw-r--r-- | ext/mysqli/tests/bug35759.phpt | 64 | ||||
| -rw-r--r-- | ext/mysqli/tests/bug51647.phpt | 33 | ||||
| -rw-r--r-- | ext/mysqli/tests/mysqli_fetch_all.phpt | 48 | ||||
| -rw-r--r-- | ext/mysqli/tests/mysqli_fetch_all_oo.phpt | 51 | ||||
| -rw-r--r-- | ext/mysqli/tests/mysqli_fetch_array.phpt | 52 | ||||
| -rw-r--r-- | ext/mysqli/tests/mysqli_fetch_array_oo.phpt | 49 |
6 files changed, 165 insertions, 132 deletions
diff --git a/ext/mysqli/tests/bug35759.phpt b/ext/mysqli/tests/bug35759.phpt index cbceb3b42e..bcf9cb8e67 100644 --- a/ext/mysqli/tests/bug35759.phpt +++ b/ext/mysqli/tests/bug35759.phpt @@ -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 diff --git a/ext/mysqli/tests/bug51647.phpt b/ext/mysqli/tests/bug51647.phpt index b222aa5f01..33aec04d5c 100644 --- a/ext/mysqli/tests/bug51647.phpt +++ b/ext/mysqli/tests/bug51647.phpt @@ -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!"; ?> diff --git a/ext/mysqli/tests/mysqli_fetch_all.phpt b/ext/mysqli/tests/mysqli_fetch_all.phpt index eacecc92d0..6614f1e8d9 100644 --- a/ext/mysqli/tests/mysqli_fetch_all.phpt +++ b/ext/mysqli/tests/mysqli_fetch_all.phpt @@ -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] diff --git a/ext/mysqli/tests/mysqli_fetch_all_oo.phpt b/ext/mysqli/tests/mysqli_fetch_all_oo.phpt index a71eb2bce2..30985a5c3d 100644 --- a/ext/mysqli/tests/mysqli_fetch_all_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_all_oo.phpt @@ -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); diff --git a/ext/mysqli/tests/mysqli_fetch_array.phpt b/ext/mysqli/tests/mysqli_fetch_array.phpt index cff3141661..cad8a1015c 100644 --- a/ext/mysqli/tests/mysqli_fetch_array.phpt +++ b/ext/mysqli/tests/mysqli_fetch_array.phpt @@ -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); diff --git a/ext/mysqli/tests/mysqli_fetch_array_oo.phpt b/ext/mysqli/tests/mysqli_fetch_array_oo.phpt index 78c21308f3..86fdb68026 100644 --- a/ext/mysqli/tests/mysqli_fetch_array_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_array_oo.phpt @@ -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); |
