| 1 |
# |
| 2 |
# SELECT .. FOR UPDATE |
| 3 |
# |
| 4 |
# If the engine has its own lock timeouts, |
| 5 |
# it makes sense to set them to minimum to decrease |
| 6 |
# the duration of the test. |
| 7 |
|
| 8 |
--source ../have_engine.inc |
| 9 |
--source support_transactions.inc |
| 10 |
|
| 11 |
--disable_warnings |
| 12 |
DROP TABLE IF EXISTS t1; |
| 13 |
--enable_warnings |
| 14 |
|
| 15 |
--source include/count_sessions.inc |
| 16 |
|
| 17 |
--source ../create_table.inc |
| 18 |
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a'); |
| 19 |
|
| 20 |
--connect (con1,localhost,root,,) |
| 21 |
BEGIN; |
| 22 |
--sorted_result |
| 23 |
SELECT a,b FROM t1 WHERE b='a' FOR UPDATE; |
| 24 |
if ($mysql_errname) |
| 25 |
{ |
| 26 |
--let $functionality = SELECT .. FOR UPDATE |
| 27 |
--source ../unexpected_result.inc |
| 28 |
} |
| 29 |
|
| 30 |
--connection default |
| 31 |
SET lock_wait_timeout = 1; |
| 32 |
|
| 33 |
# Should still be able to select |
| 34 |
|
| 35 |
--sorted_result |
| 36 |
SELECT a,b FROM t1 WHERE b='a'; |
| 37 |
if ($mysql_errname) |
| 38 |
{ |
| 39 |
--let $functionality = SELECT .. FOR UPDATE or locking |
| 40 |
--source ../unexpected_result.inc |
| 41 |
} |
| 42 |
|
| 43 |
# ... but not with LOCK IN SHARE MODE |
| 44 |
|
| 45 |
--sorted_result |
| 46 |
--let $error_codes = ER_LOCK_WAIT_TIMEOUT |
| 47 |
SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE; |
| 48 |
--source ../check_errors.inc |
| 49 |
if ($mysql_errname != ER_LOCK_WAIT_TIMEOUT) |
| 50 |
{ |
| 51 |
--let $functionality = SELECT .. FOR UPDATE or LOCK IN SHARE MODE |
| 52 |
--source ../unexpected_result.inc |
| 53 |
} |
| 54 |
|
| 55 |
--let $error_codes = ER_LOCK_WAIT_TIMEOUT |
| 56 |
UPDATE t1 SET b='c' WHERE b='a'; |
| 57 |
--source ../check_errors.inc |
| 58 |
if ($mysql_errname != ER_LOCK_WAIT_TIMEOUT) |
| 59 |
{ |
| 60 |
--let $functionality = UPDATE or SELECT .. FOR UPDATE |
| 61 |
--source ../unexpected_result.inc |
| 62 |
} |
| 63 |
|
| 64 |
--connection con1 |
| 65 |
COMMIT; |
| 66 |
--sorted_result |
| 67 |
SELECT a,b FROM t1; |
| 68 |
|
| 69 |
--disconnect con1 |
| 70 |
--connection default |
| 71 |
# Now it can be updated all right |
| 72 |
UPDATE t1 SET b='c' WHERE b='a'; |
| 73 |
if ($mysql_errname) |
| 74 |
{ |
| 75 |
--let $functionality = UPDATE |
| 76 |
--source ../unexpected_result.inc |
| 77 |
} |
| 78 |
--sorted_result |
| 79 |
SELECT a,b FROM t1; |
| 80 |
|
| 81 |
DROP TABLE t1; |
| 82 |
|
| 83 |
--source include/wait_until_count_sessions.inc |
| 84 |
--source ../cleanup_engine.inc |
| 85 |
|