diff options
| author | Ulf Wendel <uw@php.net> | 2010-01-04 14:34:44 +0000 |
|---|---|---|
| committer | Ulf Wendel <uw@php.net> | 2010-01-04 14:34:44 +0000 |
| commit | bf9d5991eaf3a3c015aaa1cac515dd87d72c8825 (patch) | |
| tree | 2b20eaa7ebc0861cd36a8c1cf03a98b3fd4f6214 | |
| parent | 39e27c9030bec5a4a2ba47cabe86435ee10afed8 (diff) | |
| download | php-git-bf9d5991eaf3a3c015aaa1cac515dd87d72c8825.tar.gz | |
Tweaking test. Andrey, you once requested such a test, please have a look if it does exactly what you want it to do.
| -rw-r--r-- | ext/mysqli/tests/mysqli_insert_packet_overflow.phpt | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt b/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt index 777610ee8b..725636e146 100644 --- a/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt +++ b/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt @@ -4,6 +4,18 @@ INSERT and packet overflow <?php require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); + +if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + die(sprintf("SKIP [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error())); + +$max_len = pow(2, 24); +if (!$res = mysqli_query($link, "SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'")) + die(sprintf("SKIP [%d] %s\n", mysqli_errno($link), mysqli_error($link))); + +if (!mysqli_query($link, "SET NAMES 'latin1'")) + die(sprintf("SKIP [%d] %s\n", mysqli_errno($link), mysqli_error($link))); + +mysqli_close($link); ?> --INI-- memory_limit=256M @@ -33,45 +45,48 @@ memory_limit=256M if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[006] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + if (!mysqli_query($link, "SET NAMES 'latin1'")) + printf("[007] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + if (!$res = mysqli_query($link, "SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'")) - printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); if (0 === ($max_allowed_packet = (int)$row['Value'])) - printf("[009] Cannot determine max_allowed_packet size and/or bogus max_allowed_packet setting used.\n"); + printf("[010] Cannot determine max_allowed_packet size and/or bogus max_allowed_packet setting used.\n"); $max_len = pow(2, 24); if ($max_allowed_packet < $max_len) { - printf("[010] Failed to change max_allowed_packet"); + printf("[011] Failed to change max_allowed_packet"); } if (!mysqli_query($link, "CREATE TABLE test(col_blob LONGBLOB) ENGINE=" . $engine)) - printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); $query_prefix = 'INSERT INTO test(col_blob) VALUES ("'; $query_postfix = '")'; $query_len = strlen($query_prefix) + strlen($query_postfix); - $com_query_len = 1; + $com_query_len = 2; $blob = str_repeat('a', $max_len - $com_query_len - $query_len); $query = sprintf("%s%s%s", $query_prefix, $blob, $query_postfix); if (!mysqli_query($link, $query)) - printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + printf("[013] max_allowed_packet = %d, strlen(query) = %d, [%d] %s\n", $max_allowed_packet, strlen($query), mysqli_errno($link), mysqli_error($link)); if (!$res = mysqli_query($link, "SELECT col_blob FROM test")) - printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); if (!$row = mysqli_fetch_assoc($res)) { - printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } else { if ($row['col_blob'] != $blob) { - printf("[015] Blob seems wrong, dumping data\n"); + printf("[016] Blob seems wrong, dumping data\n"); var_dump(strlen($row['col_blob'])); var_dump(strlen($blob)); } @@ -79,7 +94,7 @@ memory_limit=256M } if (!mysqli_query($link, "SET GLOBAL max_allowed_packet = " . $org_max_allowed_packet)) - printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_close($link); |
