| 1 |
# |
| 2 |
# SELECT HIGH_PRIOIRITY |
| 3 |
# |
| 4 |
--source have_engine.inc |
| 5 |
|
| 6 |
--source include/count_sessions.inc |
| 7 |
|
| 8 |
--disable_warnings |
| 9 |
DROP TABLE IF EXISTS t1; |
| 10 |
--enable_warnings |
| 11 |
|
| 12 |
# We will have 3 connections: |
| 13 |
# con1 will lock a table in READ mode |
| 14 |
# con0 will run UPDATE (and will wait on the lock) |
| 15 |
# con2 will start another SELECT |
| 16 |
# con1 will then unlock the table |
| 17 |
# |
| 18 |
# With standard SELECT we should see updated rows in the 2nd result set, |
| 19 |
# while with SELECT HIGH_PRIORITY we should still see only old rows in con2 resultset |
| 20 |
# (and it shouldn't wait till the table is unlocked and UPDATE is executed). |
| 21 |
|
| 22 |
--connect (con0,localhost,root,,) |
| 23 |
SET lock_wait_timeout = 4; |
| 24 |
--connect (con1,localhost,root,,) |
| 25 |
SET lock_wait_timeout = 4; |
| 26 |
--connect (con2,localhost,root,,) |
| 27 |
SET lock_wait_timeout = 4; |
| 28 |
|
| 29 |
|
| 30 |
# Part 1: Standard SELECT |
| 31 |
# should be executed after the UPDATE |
| 32 |
|
| 33 |
--source create_table.inc |
| 34 |
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b'); |
| 35 |
|
| 36 |
--connection con1 |
| 37 |
LOCK TABLE t1 READ; |
| 38 |
|
| 39 |
--connection con0 |
| 40 |
--send |
| 41 |
UPDATE t1 SET b = CONCAT(b,b); |
| 42 |
|
| 43 |
--connection con2 |
| 44 |
let $show_statement = SHOW PROCESSLIST; |
| 45 |
let $field = State; |
| 46 |
let $condition = LIKE 'Waiting for table%'; |
| 47 |
let $wait_timeout = 2; |
| 48 |
--source include/wait_show_condition.inc |
| 49 |
--send |
| 50 |
SELECT a,b FROM t1; |
| 51 |
|
| 52 |
--connection con1 |
| 53 |
let $show_statement = SHOW PROCESSLIST; |
| 54 |
let $field = Info; |
| 55 |
let $condition = = 'SELECT a,b FROM t1'; |
| 56 |
let $wait_timeout = 2; |
| 57 |
--source include/wait_show_condition.inc |
| 58 |
if (!$found) |
| 59 |
{ |
| 60 |
--let $mysql_errname = timeout in wait_show_condition.inc |
| 61 |
--let $functionality = Table locking or UPDATE |
| 62 |
--source unexpected_result.inc |
| 63 |
} |
| 64 |
|
| 65 |
UNLOCK TABLES; |
| 66 |
|
| 67 |
--connection con0 |
| 68 |
--reap |
| 69 |
if ($mysql_errname) |
| 70 |
{ |
| 71 |
--let $my_last_stmt = UPDATE t1 SET b = CONCAT(b,b) |
| 72 |
--let $functionality = UPDATE |
| 73 |
--source unexpected_result.inc |
| 74 |
} |
| 75 |
|
| 76 |
--connection con2 |
| 77 |
--echo # Should return the new data |
| 78 |
--sorted_result |
| 79 |
--reap |
| 80 |
|
| 81 |
DROP TABLE t1; |
| 82 |
|
| 83 |
|
| 84 |
# Part 2: SELECT HIGH_PRIORITY |
| 85 |
# should be executed before the UPDATE |
| 86 |
|
| 87 |
--source create_table.inc |
| 88 |
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b'); |
| 89 |
|
| 90 |
--connection con1 |
| 91 |
LOCK TABLE t1 READ; |
| 92 |
|
| 93 |
--connection con0 |
| 94 |
--send |
| 95 |
UPDATE t1 SET b = CONCAT(b,b,b); |
| 96 |
|
| 97 |
--connection con2 |
| 98 |
let $condition = LIKE 'Waiting for table%'; |
| 99 |
let $field = State; |
| 100 |
let $wait_timeout = 2; |
| 101 |
--source include/wait_show_condition.inc |
| 102 |
SET lock_wait_timeout = 1; |
| 103 |
--echo # Should return old data |
| 104 |
--sorted_result |
| 105 |
SELECT HIGH_PRIORITY * FROM t1; |
| 106 |
if ($mysql_errname) |
| 107 |
{ |
| 108 |
--let $functionality = SELECT HIGH_PRIORITY |
| 109 |
--source unexpected_result.inc |
| 110 |
} |
| 111 |
|
| 112 |
--connection con1 |
| 113 |
UNLOCK TABLES; |
| 114 |
|
| 115 |
--connection con0 |
| 116 |
--reap |
| 117 |
if ($mysql_errname) |
| 118 |
{ |
| 119 |
--let $my_last_stmt = UPDATE t1 SET b = CONCAT(b,b,b) |
| 120 |
--let $functionality = UPDATE |
| 121 |
--source unexpected_result.inc |
| 122 |
} |
| 123 |
|
| 124 |
--disconnect con1 |
| 125 |
--disconnect con2 |
| 126 |
--disconnect con0 |
| 127 |
let $wait_timeout = 30; |
| 128 |
|
| 129 |
--connection default |
| 130 |
|
| 131 |
# Cleanup |
| 132 |
DROP TABLE t1; |
| 133 |
|
| 134 |
--source include/wait_until_count_sessions.inc |
| 135 |
|
| 136 |
--source cleanup_engine.inc |
| 137 |
|