summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Wendel <uw@php.net>2011-08-31 13:50:58 +0000
committerUlf Wendel <uw@php.net>2011-08-31 13:50:58 +0000
commit776d1e5ece64cb844c9011fd22f4e6496df42a88 (patch)
tree5747798667e1506b577cb77f2d5dab83e72659ed
parentad24758ee9024197f4df78a6583846a401f8fad3 (diff)
downloadphp-git-776d1e5ece64cb844c9011fd22f4e6496df42a88.tar.gz
New utility function to check for '[1148] The used command is not allowed with this MySQL version' during SKIPIF
-rw-r--r--ext/mysqli/tests/061.phpt15
-rw-r--r--ext/mysqli/tests/bug49442.phpt22
-rw-r--r--ext/mysqli/tests/local_infile_tools.inc57
-rw-r--r--ext/mysqli/tests/mysqli_query_local_infile_large.phpt10
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_default.phpt10
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler.phpt13
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt13
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt13
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt13
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt13
-rwxr-xr-xext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt13
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt13
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt13
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt13
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt13
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt13
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt10
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt13
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt13
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt13
20 files changed, 125 insertions, 181 deletions
diff --git a/ext/mysqli/tests/061.phpt b/ext/mysqli/tests/061.phpt
index afe1b77d9d..5817d8230d 100644
--- a/ext/mysqli/tests/061.phpt
+++ b/ext/mysqli/tests/061.phpt
@@ -9,18 +9,13 @@ if (!function_exists('mysqli_set_local_infile_handler'))
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!$link)
- die(sprintf("skip Can't connect [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+ die(sprintf("skip Can't connect [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
-if (!mysqli_query($link,"DROP TABLE IF EXISTS t_061"))
- die(sprintf("skip Cannot drop table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)));
-
-if (!mysqli_query($link,"CREATE TABLE t_061 (c1 varchar(10), c2 varchar(10))"))
- die(sprintf("skip Cannot create table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)));
-
-if (!mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE t_061 FIELDS TERMINATED BY ';'", mysqli_real_escape_string($link, $filename))))
- if (1148 == mysqli_errno($link))
- die(sprintf("skip Cannot test LOAD DATA LOCAL INFILE, [%d] %s", mysqli_errno($link), mysqli_error($link)));
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
+mysqli_close($link);
?>
--FILE--
<?php
diff --git a/ext/mysqli/tests/bug49442.phpt b/ext/mysqli/tests/bug49442.phpt
index 5560186080..54267451ee 100644
--- a/ext/mysqli/tests/bug49442.phpt
+++ b/ext/mysqli/tests/bug49442.phpt
@@ -10,25 +10,11 @@ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
die(sprintf("skip Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
}
-if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
- die(sprintf("skip Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)));
-}
-
-if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine)) {
- die(sprintf("skip Failed to create test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)));
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-require_once("local_infile_tools.inc");
-$file = create_standard_csv(4);
-
-if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s'
- INTO TABLE test
- FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\''
- LINES TERMINATED BY '\n'",
- mysqli_real_escape_string($link, $file)))) {
- if (1148 == mysqli_errno($link))
- die(sprintf("skip Cannot test LOAD DATA LOCAL INFILE, [%d] %s\n", mysqli_errno($link), mysqli_error($link)));
-}
+mysqli_close($link);
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/local_infile_tools.inc b/ext/mysqli/tests/local_infile_tools.inc
index 04d6e8a12a..bb9872f1ab 100644
--- a/ext/mysqli/tests/local_infile_tools.inc
+++ b/ext/mysqli/tests/local_infile_tools.inc
@@ -6,11 +6,53 @@
}
}
- function create_standard_csv($offset) {
+ function check_local_infile_support($link, $engine, $table_name = 'test') {
+
+ if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"'))
+ return "Cannot check if Server variable 'local_infile' is set to 'ON'";
+
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+ if ('ON' != $row['Value'])
+ return sprintf("Server variable 'local_infile' seems not set to 'ON', found '%s'", $row['Value']);
+
+ if (!mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name))) {
+ return "Failed to drop old test table";
+ }
+
+ if (!mysqli_query($link, $sql = sprintf('CREATE TABLE %s(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=%s',
+ $table_name, $engine)))
+ return "Failed to create test table: $sql";
+
+ $file = create_standard_csv(1, false);
+ if (!$file) {
+ mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name));
+ return "Cannot create CSV file";
+ }
+
+ if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s'
+ INTO TABLE %s
+ FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\''
+ LINES TERMINATED BY '\n'",
+ mysqli_real_escape_string($link, $file),
+ $table_name))) {
+ if (1148 == mysqli_errno($link)) {
+ mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name));
+ return "Cannot test LOAD DATA LOCAL INFILE, [1148] The used command is not allowed with this MySQL version";
+ } else if ($link->errno) {
+ return $link->error;
+ }
+ }
+ mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name));
+ return "";
+ }
+
+ function create_standard_csv($offset, $verbose = true) {
// create a CVS file
$file = tempnam(sys_get_temp_dir(), 'mysqli_test');
if (!$fp = fopen($file, 'w')) {
- printf("[%03d + 1] Cannot create CVS file '%s'\n", $offset, $file);
+ if ($verbose)
+ printf("[%03d + 1] Cannot create CVS file '%s'\n", $offset, $file);
return NULL;
} else {
/* Looks ugly? No, handy if you have crashes... */
@@ -21,14 +63,16 @@
if (!fwrite($fp, (binary)"'97';'x';\n") ||
!fwrite($fp, (binary)"'98';'y';\n") ||
!fwrite($fp, (binary)"99;'z';\n")) {
- printf("[%03d + 2] Cannot write CVS file '%s'\n", $offset, $file);
+ if ($verbose)
+ printf("[%03d + 2] Cannot write CVS file '%s'\n", $offset, $file);
return NULL;
}
} else {
if (!fwrite($fp, "97;'x';\n") ||
!fwrite($fp, "98;'y';\n") ||
!fwrite($fp, "99;'z';\n")) {
- printf("[%03d + 3] Cannot write CVS file '%s'\n", $offset, $file);
+ if ($verbose)
+ printf("[%03d + 3] Cannot write CVS file '%s'\n", $offset, $file);
return NULL;
}
}
@@ -36,8 +80,9 @@
fclose($fp);
if (!chmod($file, 0644)) {
- printf("[%03d + 4] Cannot change the file perms of '%s' from 0600 to 0644, MySQL might not be able to read it\n",
- $offset, $file);
+ if ($verbose)
+ printf("[%03d + 4] Cannot change the file perms of '%s' from 0600 to 0644, MySQL might not be able to read it\n",
+ $offset, $file);
return NULL;
}
return $file;
diff --git a/ext/mysqli/tests/mysqli_query_local_infile_large.phpt b/ext/mysqli/tests/mysqli_query_local_infile_large.phpt
index 8b115a507d..76bc415d8b 100644
--- a/ext/mysqli/tests/mysqli_query_local_infile_large.phpt
+++ b/ext/mysqli/tests/mysqli_query_local_infile_large.phpt
@@ -4,6 +4,16 @@ mysql_query(LOAD DATA LOCAL INFILE) with large data set (10MB)
<?php
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
+
+$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+if (!$link)
+ die(sprintf("skip Can't connect [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
+
+mysqli_close($link);
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_default.phpt b/ext/mysqli/tests/mysqli_set_local_infile_default.phpt
index dd67bb32a3..0348b01f6a 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_default.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_default.phpt
@@ -9,7 +9,15 @@ require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_set_local_infile_handler'))
die("skip - function not available.");
-require_once('connect.inc');
+$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
+if (!$link)
+ die(sprintf("skip Can't connect [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
+
+mysqli_close($link);
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler.phpt
index c8da0183be..58f4c70351 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler.phpt
@@ -13,18 +13,11 @@ require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt
index ad0a3532f9..b8f51c214f 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt
@@ -16,18 +16,11 @@ if (!$TEST_EXPERIMENTAL)
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt
index e7df96e5a4..a3c8801023 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt
@@ -16,18 +16,11 @@ if (!$TEST_EXPERIMENTAL)
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt
index c2ee87b34a..408bb29ec4 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt
@@ -16,18 +16,11 @@ if (!$TEST_EXPERIMENTAL)
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt
index 4ebf8ded2e..168cbc1358 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt
@@ -16,18 +16,11 @@ if (!$TEST_EXPERIMENTAL)
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt
index 3d94a545d9..ad7ab32c1c 100755
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt
@@ -16,18 +16,11 @@ if (!$TEST_EXPERIMENTAL)
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt
index 09b4f90f6c..b2b42a22e5 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt
@@ -13,18 +13,11 @@ require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt
index ca42705494..16e38c5fa2 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt
@@ -16,18 +16,11 @@ if (!$TEST_EXPERIMENTAL)
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt
index 8b56deafac..4663fe236e 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt
@@ -16,18 +16,11 @@ if (!$TEST_EXPERIMENTAL)
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt
index 1c47292e3b..ca06435c5e 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt
@@ -16,18 +16,11 @@ if (!$TEST_EXPERIMENTAL)
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt
index 6113abae67..601a09e12c 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt
@@ -16,18 +16,11 @@ if (!$TEST_EXPERIMENTAL)
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt
index 423ad834e6..c9e5f19962 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt
@@ -18,13 +18,11 @@ if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
}
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
-mysqli_close($link);
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
+mysqli_close($link);
?>
--INI--
open_basedir="."
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt
index 33dd5164ec..0d4024e528 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt
@@ -16,18 +16,11 @@ if (!$TEST_EXPERIMENTAL)
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt
index 9af9974e71..b3144e430e 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt
@@ -16,18 +16,11 @@ if (!$TEST_EXPERIMENTAL)
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1
diff --git a/ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt b/ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt
index e6dfecb7eb..f287f4d874 100644
--- a/ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt
+++ b/ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt
@@ -13,18 +13,11 @@ require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die("skip Cannot connect to MySQL");
-if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) {
- mysqli_close($link);
- die("skip Cannot check if Server variable 'local_infile' is set to 'ON'");
-}
+include_once("local_infile_tools.inc");
+if ($msg = check_local_infile_support($link, $engine))
+ die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
-$row = mysqli_fetch_assoc($res);
-mysqli_free_result($res);
mysqli_close($link);
-
-if ('ON' != $row['Value'])
- die(sprintf("skip Server variable 'local_infile' seems not set to 'ON', found '%s'",
- $row['Value']));
?>
--INI--
mysqli.allow_local_infile=1