| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Verify that INSERT DELAYED in mixed or row mode writes events to the |
| 4 |
# binlog, and that AUTO_INCREMENT works correctly. |
| 5 |
# |
| 6 |
# ==== Method ==== |
| 7 |
# |
| 8 |
# Insert both single and multiple rows into an autoincrement column, |
| 9 |
# both with specified value and with NULL. |
| 10 |
# |
| 11 |
# With INSERT DELAYED, the rows do not show up in the table |
| 12 |
# immediately, so we must do source include/wait_until_rows_count.inc |
| 13 |
# between any two INSERT DELAYED statements. Moreover, if mixed or |
| 14 |
# row-based logging is used, there is also a delay between when rows |
| 15 |
# show up in the table and when they show up in the binlog. To ensure |
| 16 |
# that the rows show up in the binlog, we call FLUSH TABLES, which |
| 17 |
# waits until the delayed_insert thread has finished. |
| 18 |
# |
| 19 |
# We cannot read the binlog after executing INSERT DELAYED statements |
| 20 |
# that insert multiple rows, because that is nondeterministic. More |
| 21 |
# precisely, rows may be written in batches to the binlog, where each |
| 22 |
# batch has one Table_map_log_event and one or more |
| 23 |
# Write_rows_log_event. The number of rows included in each batch is |
| 24 |
# nondeterministic. |
| 25 |
# |
| 26 |
# ==== Related bugs ==== |
| 27 |
# |
| 28 |
# BUG#20627: INSERT DELAYED does not honour auto_increment_* variables |
| 29 |
# Bug in this test: BUG#38068: binlog_stm_binlog fails sporadically in pushbuild |
| 30 |
|
| 31 |
reset master; |
| 32 |
|
| 33 |
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; |
| 34 |
|
| 35 |
let $table=t1; |
| 36 |
let $count=0; |
| 37 |
|
| 38 |
insert /* before delayed */ delayed /* after delayed */ into t1 values (207); |
| 39 |
inc $count; |
| 40 |
--source include/wait_until_rows_count.inc |
| 41 |
|
| 42 |
insert /*! delayed */ into t1 values (null); |
| 43 |
inc $count; |
| 44 |
--source include/wait_until_rows_count.inc |
| 45 |
|
| 46 |
insert delayed into t1 values (300); |
| 47 |
inc $count; |
| 48 |
--source include/wait_until_rows_count.inc |
| 49 |
|
| 50 |
# It is not enough to wait until all rows have been inserted into the |
| 51 |
# table. FLUSH TABLES ensures that they are in the binlog too. See |
| 52 |
# comment above. |
| 53 |
FLUSH TABLES; |
| 54 |
source include/show_binlog_events.inc; |
| 55 |
|
| 56 |
RESET MASTER; |
| 57 |
insert /* before delayed */ delayed /* after delayed */ into t1 values (null),(null),(null),(null); |
| 58 |
inc $count; inc $count; inc $count; inc $count; |
| 59 |
--source include/wait_until_rows_count.inc |
| 60 |
|
| 61 |
insert /*! delayed */ into t1 values (null),(null),(400),(null); |
| 62 |
inc $count; inc $count; inc $count; inc $count; |
| 63 |
--source include/wait_until_rows_count.inc |
| 64 |
|
| 65 |
if (`SELECT @@SESSION.BINLOG_FORMAT = 'STATEMENT'`) { |
| 66 |
FLUSH TABLES; |
| 67 |
source include/show_binlog_events.inc; |
| 68 |
} |
| 69 |
|
| 70 |
select * from t1; |
| 71 |
drop table t1; |