mirror of
https://github.com/MariaDB/server.git
synced 2025-07-04 01:23:45 +03:00
Problem: Statements that write to tables with auto_increment columns based on the selection from another table, may lead to master and slave going out of sync, as the order in which the rows are retrieved from the table may differ on master and slave. Solution: We mark writing to a table with auto_increment table based on the rows selected from another table as unsafe. This will cause the execution of such statements to throw a warning and forces the statement to be logged in ROW if the logging format is mixed. Changes: 1. All the statements that writes to a table with auto_increment column(s) based on the rows fetched from another table, will now be unsafe. 2. CREATE TABLE with SELECT will now be unsafe. sql/share/errmsg-utf8.txt: Added new warning messages. sql/sql_base.cc: -Created function to check statements that write to tables with auto_increment column and has select. -Marked all the statements that write to a table with auto_increment column based on rows fetched from other table(s) as unsafe. sql/sql_table.cc: mark CREATE TABLE[with auto_increment column] as unsafe.
63 lines
2.0 KiB
Plaintext
63 lines
2.0 KiB
Plaintext
# Test for BUG#1858 "OPTIMIZE TABLE done by a client
|
|
# thread stops the slave SQL thread".
|
|
# You can replace OPTIMIZE by REPAIR.
|
|
#####################################
|
|
# Change Author: JBM
|
|
# Change Date: 2006-02-09
|
|
# Change: NDB does not and will not support
|
|
# OPTIMIZE for memory tables. If and when
|
|
# it does support for Disk Data, a new
|
|
# version of this test will be need.
|
|
# Skipping this test if default engine = ndb
|
|
#####################################
|
|
-- source include/not_ndb_default.inc
|
|
-- source include/master-slave.inc
|
|
|
|
disable_query_log;
|
|
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
|
enable_query_log;
|
|
|
|
create table t1 (a int not null auto_increment primary key, b int, key(b));
|
|
INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
|
|
--disable_warnings
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
INSERT INTO t1 (a) SELECT null FROM t1;
|
|
--enable_warnings
|
|
save_master_pos;
|
|
# a few updates to force OPTIMIZE to do something
|
|
--disable_warnings
|
|
update t1 set b=(a/2*rand());
|
|
delete from t1 order by b limit 10000;
|
|
--enable_warnings
|
|
|
|
connection slave;
|
|
sync_with_master;
|
|
optimize table t1;
|
|
connection master;
|
|
save_master_pos;
|
|
connection slave;
|
|
# Bug was that when the INSERT terminated on slave,
|
|
# the slave SQL thread got killed by OPTIMIZE.
|
|
sync_with_master; # won't work if slave SQL thread stopped
|
|
|
|
connection master; # cleanup
|
|
drop table t1;
|
|
sync_slave_with_master;
|
|
|
|
# If the machine is so fast that slave syncs before OPTIMIZE
|
|
# starts, this test wil demonstrate nothing but will pass.
|
|
|
|
# End of 4.1 tests
|
|
--source include/rpl_end.inc
|