Skip to content

Commit 0fde9ac

Browse files
author
Ulf Wendel
committed
Test for MySQL version.Variable is deprecated in MySQL 5.6.
1 parent ed98579 commit 0fde9ac

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

ext/mysqli/tests/mysqli_report.phpt

+24-22
Original file line numberDiff line numberDiff line change
@@ -194,37 +194,39 @@ require_once('skipifconnectfailure.inc');
194194
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
195195
printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
196196

197-
// this might cause a warning - no index used
198-
if (!$res = @mysqli_query($link, "SHOW VARIABLES LIKE 'log_slow_queries'"))
199-
printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
197+
if (mysqli_get_server_version($link) <= 50600) {
198+
// this might cause a warning - no index used
199+
if (!$res = @mysqli_query($link, "SHOW VARIABLES LIKE 'log_slow_queries'"))
200+
printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
200201

201-
if (!$row = mysqli_fetch_assoc($res))
202-
printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
202+
if (!$row = mysqli_fetch_assoc($res))
203+
printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
203204

204-
$log_slow_query = ('ON' == $row['Value']);
205+
$log_slow_query = ('ON' == $row['Value']);
205206

206-
if (mysqli_get_server_version($link) >= 51011) {
207-
// this might cause a warning - no index used
208-
if (!$res = @mysqli_query($link, "SHOW VARIABLES LIKE 'log_queries_not_using_indexes'"))
209-
printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
207+
if (mysqli_get_server_version($link) >= 50111) {
208+
// this might cause a warning - no index used
209+
if (!$res = @mysqli_query($link, "SHOW VARIABLES LIKE 'log_queries_not_using_indexes'"))
210+
printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
210211

211-
if (!$row = mysqli_fetch_assoc($res))
212-
printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
212+
if (!$row = mysqli_fetch_assoc($res))
213+
printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
213214

214-
$log_queries_not_using_indexes = ('ON' == $row['Value']);
215+
$log_queries_not_using_indexes = ('ON' == $row['Value']);
215216

216-
if ($log_slow_queries && $log_queries_not_using_indexes) {
217+
if ($log_slow_queries && $log_queries_not_using_indexes) {
217218

218-
for ($i = 100; $i < 20000; $i++) {
219-
if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES ($i, 'z')"))
220-
printf("[022 - %d] [%d] %s\n", $i - 99, mysqli_errno($link), mysqli_error($link));
221-
}
219+
for ($i = 100; $i < 20000; $i++) {
220+
if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES ($i, 'z')"))
221+
printf("[022 - %d] [%d] %s\n", $i - 99, mysqli_errno($link), mysqli_error($link));
222+
}
222223

223-
// this might cause a warning - no index used
224-
if (!$res = @mysqli_query($link, "SELECT id, label FROM test WHERE id = 1323"))
225-
printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
224+
// this might cause a warning - no index used
225+
if (!$res = @mysqli_query($link, "SELECT id, label FROM test WHERE id = 1323"))
226+
printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
226227

227-
mysqli_free_result($res);
228+
mysqli_free_result($res);
229+
}
228230
}
229231
}
230232

0 commit comments

Comments
 (0)