| 1 |
--source include/have_ndb.inc |
| 2 |
|
| 3 |
# Select which engine to use(for easy comparison) |
| 4 |
let $engine = NDB; |
| 5 |
#let $engine = InnoDB; |
| 6 |
|
| 7 |
# Choose if table have primary key or not |
| 8 |
# NOTE! Without pk, the table get a hidden primary key |
| 9 |
# which is a "bigint auto increment" when using engine=ndb |
| 10 |
let $table_pk = ; |
| 11 |
#let $table_pk = ,PRIMARY KEY(counter1); |
| 12 |
|
| 13 |
--replace_result $engine engine |
| 14 |
eval CREATE TABLE t1 ( |
| 15 |
counter1 integer, |
| 16 |
counter2 integer, |
| 17 |
counter3 integer, |
| 18 |
counter4 integer |
| 19 |
$table_pk |
| 20 |
) ENGINE=$engine; |
| 21 |
|
| 22 |
# |
| 23 |
# Create a second connection to the same mysqld |
| 24 |
# to use for running the concurrent select queries |
| 25 |
# |
| 26 |
connect (j1,localhost,root,,test); |
| 27 |
connection j1; |
| 28 |
|
| 29 |
# |
| 30 |
# Create procedure performing select queries |
| 31 |
# repeatedly for specified number of seconds |
| 32 |
# |
| 33 |
--disable_query_log |
| 34 |
delimiter %; |
| 35 |
create procedure query_select_repeat (seconds int) |
| 36 |
begin |
| 37 |
set @x=time_to_sec(current_time()) + seconds; |
| 38 |
repeat |
| 39 |
select counter1,counter2,counter3 from t1; |
| 40 |
until @x <= time_to_sec(current_time()) |
| 41 |
end repeat; |
| 42 |
end% |
| 43 |
|
| 44 |
delimiter ;% |
| 45 |
--enable_query_log |
| 46 |
|
| 47 |
# |
| 48 |
# Start the select queries to run repeatedly for a couple of seconds |
| 49 |
# |
| 50 |
send call query_select_repeat(5); |
| 51 |
|
| 52 |
# |
| 53 |
# Switch back to default connection and run the ALTERs |
| 54 |
# and INSERTs which locks up with the repeated SELECTs |
| 55 |
# |
| 56 |
connection default; |
| 57 |
INSERT INTO t1 (counter1, counter2, counter3, counter4) |
| 58 |
VALUES (1,1,1,1); |
| 59 |
INSERT INTO t1 (counter1, counter2, counter3, counter4) |
| 60 |
VALUES (2,2,2,2); |
| 61 |
ALTER TABLE t1 DROP COLUMN counter4; |
| 62 |
INSERT INTO t1 (counter1, counter2, counter3) |
| 63 |
VALUES (3,3,3); |
| 64 |
ALTER TABLE t1 ADD COLUMN counter4 integer; |
| 65 |
INSERT INTO t1 (counter1, counter2, counter3, counter4) |
| 66 |
VALUES (4,4,4,4); |
| 67 |
|
| 68 |
# |
| 69 |
# Wait for the read queries to complete |
| 70 |
# |
| 71 |
connection j1; |
| 72 |
--disable_query_log |
| 73 |
--disable_result_log |
| 74 |
reap; |
| 75 |
--enable_result_log |
| 76 |
--enable_query_log |
| 77 |
|
| 78 |
drop procedure query_select_repeat; |
| 79 |
|
| 80 |
# |
| 81 |
# Switch back to default connection and clean up |
| 82 |
# |
| 83 |
connection default; |
| 84 |
DROP TABLE t1; |