mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Remove mysqli_change_user_get_lock.phpt (#15482)
This commit is contained in:
@@ -1,107 +0,0 @@
|
||||
--TEST--
|
||||
mysqli_change_user() - GET_LOCK()
|
||||
--EXTENSIONS--
|
||||
mysqli
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once 'skipifconnectfailure.inc';
|
||||
?>
|
||||
--XFAIL--
|
||||
The server is still buggy
|
||||
--INI--
|
||||
max_execution_time=240
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'connect.inc';
|
||||
require_once 'table.inc';
|
||||
|
||||
// We need this little hack to be able to re-run the test
|
||||
$lock = 'phptest_' . mt_rand(0, 100000);
|
||||
$thread_id = mysqli_thread_id($link);
|
||||
|
||||
printf("Testing GET_LOCK()...\n");
|
||||
|
||||
if (!$res = mysqli_query($link, sprintf('SELECT GET_LOCK("%s", 2) AS _ok', $lock)))
|
||||
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
|
||||
if (!$row = mysqli_fetch_assoc($res))
|
||||
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
|
||||
if ($row['_ok'] != 1)
|
||||
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
else
|
||||
printf("... lock '%s' acquired by thread %d\n", $lock, $thread_id);
|
||||
|
||||
mysqli_free_result($res);
|
||||
|
||||
|
||||
// GET_LOCK("phptest") should be released
|
||||
/* From the mysql_change_user documentation:
|
||||
This command resets the state as if one had done a new connect. (See Section 25.2.13, “Controlling Automatic Reconnect Behavior”.) It always performs a ROLLBACK of any active transactions, closes and drops all temporary tables, and unlocks all locked tables. Session system variables are reset to the values of the corresponding global system variables. Prepared statements are released and HANDLER variables are closed. Locks acquired with GET_LOCK() are released. These effects occur even if the user didn't change.
|
||||
*/
|
||||
mysqli_change_user($link, $user, $passwd, $db);
|
||||
sleep(5);
|
||||
$new_thread_id = mysqli_thread_id($link);
|
||||
|
||||
printf("... calling IS_USED_LOCK() on '%s' using thread '%d'\n", $lock, $new_thread_id);
|
||||
if (!$res = mysqli_query($link, 'SELECT IS_USED_LOCK("phptest") AS _ok'))
|
||||
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
|
||||
if (!$row = mysqli_fetch_assoc($res))
|
||||
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
|
||||
if ($row['_ok'] != NULL)
|
||||
printf("[006] Lock '%s' should have been released, [%d] %s\n",
|
||||
$lock,
|
||||
mysqli_errno($link), mysqli_error($link));
|
||||
|
||||
printf("... calling IS_FREE_LOCK() on '%s' using thread '%d'\n", $lock, $new_thread_id);
|
||||
if (!$res = mysqli_query($link, 'SELECT IS_FREE_LOCK("phptest") AS _ok'))
|
||||
printf("[007] [%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));
|
||||
|
||||
if ($row['_ok'] != 1)
|
||||
printf("[009] Lock '%s' should have been released, [%d] %s\n",
|
||||
$lock,
|
||||
mysqli_errno($link), mysqli_error($link));
|
||||
|
||||
mysqli_free_result($res);
|
||||
|
||||
/* Ok, let's try a NEW connection and a NEW lock! */
|
||||
mysqli_close($link);
|
||||
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
|
||||
printf("[010] Cannot open new connection, [%d] %s\n",
|
||||
mysqli_connect_errno(), mysqli_connect_error());
|
||||
|
||||
do {
|
||||
$newlock = 'phptest_' . mt_rand(0, 100000);
|
||||
} while ($lock == $newlock);
|
||||
|
||||
$new_thread_id = mysqli_thread_id($link);
|
||||
printf("... calling IS_USED_LOCK() on '%s' using new connection with thread '%d'\n", $newlock, $new_thread_id);
|
||||
if (!$res = mysqli_query($link, 'SELECT IS_USED_LOCK("phptest") AS _ok'))
|
||||
printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
|
||||
if (!$row = mysqli_fetch_assoc($res))
|
||||
printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
|
||||
if ($row['_ok'] != NULL)
|
||||
printf("[013] Lock '%s' should have been released, [%d] %s\n",
|
||||
$lock,
|
||||
mysqli_errno($link), mysqli_error($link));
|
||||
|
||||
print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once 'clean_table.inc';
|
||||
?>
|
||||
--EXPECTF--
|
||||
Testing GET_LOCK()...
|
||||
... lock 'phptest_%d' acquired by thread %d
|
||||
... calling IS_USED_LOCK() on 'phptest_%d' using thread '%d'
|
||||
... calling IS_FREE_LOCK() on 'phptest_%d' using thread '%d'
|
||||
... calling IS_USED_LOCK() on 'phptest_%d' using new connection with thread '%d'
|
||||
done!
|
||||
@@ -6,8 +6,6 @@ mysqli
|
||||
<?php
|
||||
require_once 'skipifconnectfailure.inc';
|
||||
?>
|
||||
--XFAIL--
|
||||
The server is still buggy
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'connect.inc';
|
||||
@@ -21,6 +19,7 @@ The server is still buggy
|
||||
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||
|
||||
/*
|
||||
Do not verify that we have aquired a lock, as this would block the test
|
||||
if ($res = mysqli_query($link2, 'SELECT COUNT(*) AS _num FROM test')) {
|
||||
printf("[003] Reading from test should not be possible due to a lock, [%d] %s\n",
|
||||
mysqli_errno($link2), mysqli_error($link2));
|
||||
|
||||
Reference in New Issue
Block a user