Skip to content

Commit 73e0385

Browse files
committed
Merge 10.2 into 10.3
2 parents 874f8f3 + 409e210 commit 73e0385

File tree

10 files changed

+150
-9
lines changed

10 files changed

+150
-9
lines changed

mysql-test/main/temp_table.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,3 +572,15 @@ LOCK TABLES t2 WRITE;
572572
TRUNCATE TABLE t1;
573573
UNLOCK TABLES;
574574
DROP TABLE t1, t2;
575+
#
576+
# MDEV-19449 1030: Got error 168 "Unknown (generic) error from engine"
577+
# for valid TRUNCATE (temporary) TABLE
578+
#
579+
CREATE TEMPORARY TABLE t1 (col1 BIGINT) ENGINE = InnoDB;
580+
INSERT INTO t1 (no_such_col) SELECT * FROM t1;
581+
ERROR 42S22: Unknown column 'no_such_col' in 'field list'
582+
TRUNCATE TABLE t1;
583+
ALTER TABLE t1 CHANGE no_such_col1 col1 BIGINT NULL;
584+
ERROR 42S22: Unknown column 'no_such_col1' in 't1'
585+
TRUNCATE TABLE t1;
586+
DROP TEMPORARY TABLE t1;

mysql-test/main/temp_table.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,3 +623,19 @@ TRUNCATE TABLE t1;
623623
UNLOCK TABLES;
624624

625625
DROP TABLE t1, t2;
626+
627+
--echo #
628+
--echo # MDEV-19449 1030: Got error 168 "Unknown (generic) error from engine"
629+
--echo # for valid TRUNCATE (temporary) TABLE
630+
--echo #
631+
632+
CREATE TEMPORARY TABLE t1 (col1 BIGINT) ENGINE = InnoDB;
633+
--error ER_BAD_FIELD_ERROR
634+
INSERT INTO t1 (no_such_col) SELECT * FROM t1;
635+
TRUNCATE TABLE t1;
636+
--error ER_BAD_FIELD_ERROR
637+
ALTER TABLE t1 CHANGE no_such_col1 col1 BIGINT NULL;
638+
# This would wrongly try to re-truncate the old copy of the table that
639+
# was not dropped during the first TRUNCATE due to extra table handles.
640+
TRUNCATE TABLE t1;
641+
DROP TEMPORARY TABLE t1;

mysql-test/suite/rpl/disabled.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ rpl_get_master_version_and_clock : Bug#11766137 Jan 05 2011 joro Valgrind warnin
1515
rpl_partition_archive : MDEV-5077 2013-09-27 svoj Cannot exchange partition with archive table
1616
rpl_row_binlog_max_cache_size : MDEV-11092
1717
rpl_blackhole : MDEV-11094
18-
rpl_row_mysqlbinlog : MDEV-11095
1918
rpl_row_index_choice : MDEV-11666
2019
rpl_parallel2 : fails after MDEV-16172
2120
rpl_semi_sync_after_sync : fails after MDEV-16172
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
include/master-slave.inc
2+
[connection master]
3+
CREATE TABLE t1 (id mediumint(8) unsigned NOT NULL AUTO_INCREMENT, someLabel varchar(30) NOT NULL, flag tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (id)) Engine=MyISAM;
4+
CREATE TABLE t2 (id mediumint(8) unsigned NOT NULL AUTO_INCREMENT, data varchar(30) NOT NULL, status tinyint(1) NOT NULL, PRIMARY KEY (id)) Engine=MyISAM;
5+
CREATE TABLE t3 (id mediumint(8) unsigned NOT NULL AUTO_INCREMENT, t1id mediumint(8) unsigned NOT NULL, flag tinyint(1) NOT NULL DEFAULT 0, status tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (id)) Engine=MyISAM;
6+
INSERT INTO t1 ( id, someLabel, flag ) VALUES ( 1, 'ABC', 0 );
7+
CREATE OR REPLACE TRIGGER doNothing
8+
BEFORE UPDATE ON t1
9+
FOR EACH ROW
10+
BEGIN
11+
IF
12+
new.someLabel != old.someLabel
13+
THEN
14+
UPDATE t3 SET t3.flag = 0;
15+
END IF;
16+
END|
17+
FLUSH LOGS;
18+
LOCK TABLES t1 WRITE, t2 WRITE;
19+
INSERT INTO t2 (data, status) VALUES ('1', 4);
20+
UPDATE t1 SET flag = 1 WHERE id = 1;
21+
INSERT INTO t2 (data, status) VALUES ('2', 4);
22+
UNLOCK TABLES;
23+
connection slave;
24+
include/diff_tables.inc [master:t1, slave:t1]
25+
include/diff_tables.inc [master:t2, slave:t2]
26+
include/diff_tables.inc [master:t3, slave:t3]
27+
connection master;
28+
DROP TABLE t1, t2, t3;
29+
include/rpl_end.inc

mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ use `test`/*!*/;
169169
SET TIMESTAMP=1000000000/*!*/;
170170
SET @@session.pseudo_thread_id=999999999/*!*/;
171171
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
172-
SET @@session.sql_mode=1342177280/*!*/;
172+
SET @@session.sql_mode=1411383296/*!*/;
173173
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
174174
/*!\C latin1 *//*!*/;
175175
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
@@ -192,7 +192,7 @@ use `test`/*!*/;
192192
SET TIMESTAMP=1000000000/*!*/;
193193
SET @@session.pseudo_thread_id=999999999/*!*/;
194194
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
195-
SET @@session.sql_mode=1342177280/*!*/;
195+
SET @@session.sql_mode=1411383296/*!*/;
196196
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
197197
/*!\C latin1 *//*!*/;
198198
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
@@ -307,7 +307,7 @@ use `test`/*!*/;
307307
SET TIMESTAMP=1000000000/*!*/;
308308
SET @@session.pseudo_thread_id=999999999/*!*/;
309309
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
310-
SET @@session.sql_mode=1342177280/*!*/;
310+
SET @@session.sql_mode=1411383296/*!*/;
311311
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
312312
/*!\C latin1 *//*!*/;
313313
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
@@ -336,7 +336,7 @@ use `test`/*!*/;
336336
SET TIMESTAMP=1000000000/*!*/;
337337
SET @@session.pseudo_thread_id=999999999/*!*/;
338338
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
339-
SET @@session.sql_mode=1342177280/*!*/;
339+
SET @@session.sql_mode=1411383296/*!*/;
340340
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
341341
/*!\C latin1 *//*!*/;
342342
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# ==== Purpose ====
2+
#
3+
# Test verifies that there are no duplicate entries in binlog (i.e a safe
4+
# statement which follows an unsafe statement gets logged in both row format
5+
# and statement format resulting in duplicate entry) when binlog-format=MIXED
6+
# and LOCK TABLES are enabled.
7+
#
8+
# ==== Implementation ====
9+
#
10+
# Steps:
11+
# 1 - Create three tables t1,t2 and t3 with AUTO_INCREMENT on.
12+
# 2 - Create a trigger on table t3, so that trigger execution results in
13+
# unsafe statement. Note query that modifies autoinc column in
14+
# sub-statement can make the master and slave inconsistent. Hence they
15+
# are logged in row format.
16+
# 3 - Lock tables t1,t2 and t3.
17+
# 4 - Execute an unsafe update which modifies tables t1 and t3. But since t2
18+
# table is also locked its table map event also gets written into the
19+
# binary log during the execution of update.
20+
# 5 - Execute a safe DML operation using table 't2' and verify that master
21+
# doesn't report any assert.
22+
# 6 - Ensure that slave is in sync with master and data is consistent.
23+
#
24+
# ==== References ====
25+
#
26+
# MDEV-19158: MariaDB 10.2.22 is writing duplicate entries into binary log
27+
28+
--source include/have_binlog_format_mixed.inc
29+
--source include/master-slave.inc
30+
31+
CREATE TABLE t1 (id mediumint(8) unsigned NOT NULL AUTO_INCREMENT, someLabel varchar(30) NOT NULL, flag tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (id)) Engine=MyISAM;
32+
CREATE TABLE t2 (id mediumint(8) unsigned NOT NULL AUTO_INCREMENT, data varchar(30) NOT NULL, status tinyint(1) NOT NULL, PRIMARY KEY (id)) Engine=MyISAM;
33+
CREATE TABLE t3 (id mediumint(8) unsigned NOT NULL AUTO_INCREMENT, t1id mediumint(8) unsigned NOT NULL, flag tinyint(1) NOT NULL DEFAULT 0, status tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (id)) Engine=MyISAM;
34+
35+
INSERT INTO t1 ( id, someLabel, flag ) VALUES ( 1, 'ABC', 0 );
36+
37+
DELIMITER |;
38+
39+
CREATE OR REPLACE TRIGGER doNothing
40+
BEFORE UPDATE ON t1
41+
FOR EACH ROW
42+
BEGIN
43+
IF
44+
new.someLabel != old.someLabel
45+
THEN
46+
UPDATE t3 SET t3.flag = 0;
47+
END IF;
48+
END|
49+
50+
DELIMITER ;|
51+
52+
FLUSH LOGS;
53+
54+
LOCK TABLES t1 WRITE, t2 WRITE;
55+
INSERT INTO t2 (data, status) VALUES ('1', 4);
56+
UPDATE t1 SET flag = 1 WHERE id = 1;
57+
INSERT INTO t2 (data, status) VALUES ('2', 4);
58+
UNLOCK TABLES;
59+
60+
sync_slave_with_master;
61+
62+
let $diff_tables= master:t1, slave:t1;
63+
--source include/diff_tables.inc
64+
let $diff_tables= master:t2, slave:t2;
65+
--source include/diff_tables.inc
66+
let $diff_tables= master:t3, slave:t3;
67+
--source include/diff_tables.inc
68+
69+
--connection master
70+
DROP TABLE t1, t2, t3;
71+
72+
--source include/rpl_end.inc

mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ remove_file $MYSQLTEST_VARDIR/tmp/master.sql;
151151
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=$stop_position --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
152152

153153
--echo --- Test 4 Second Remote test --
154-
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/remote.sql
155-
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 >> $MYSQLTEST_VARDIR/tmp/remote.sql
154+
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --to-last-log master-bin.000001 > $MYSQLTEST_VARDIR/tmp/remote.sql
156155

157156
# Now that we have our file, lets get rid of the current database.
158157
# Cleanup the master and the slave and try to recreate.

sql/handler.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6394,8 +6394,8 @@ int handler::ha_reset()
63946394
table->default_column_bitmaps();
63956395
pushed_cond= NULL;
63966396
tracker= NULL;
6397-
mark_trx_read_write_done= check_table_binlog_row_based_done=
6398-
check_table_binlog_row_based_result= 0;
6397+
mark_trx_read_write_done= 0;
6398+
clear_cached_table_binlog_row_based_flag();
63996399
/* Reset information about pushed engine conditions */
64006400
cancel_pushed_idx_cond();
64016401
/* Reset information about pushed index conditions */

sql/handler.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4372,6 +4372,12 @@ class handler :public Sql_alloc
43724372
public:
43734373
bool check_table_binlog_row_based(bool binlog_row);
43744374

4375+
inline void clear_cached_table_binlog_row_based_flag()
4376+
{
4377+
check_table_binlog_row_based_done= 0;
4378+
check_table_binlog_row_based_result= 0;
4379+
}
4380+
private:
43754381
/* Cache result to avoid extra calls */
43764382
inline void mark_trx_read_write()
43774383
{

sql/sql_base.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,12 @@ bool close_cached_connection_tables(THD *thd, LEX_CSTRING *connection)
586586
Marks all tables in the list which were used by current substatement
587587
(they are marked by its query_id) as free for reuse.
588588
589+
Clear 'check_table_binlog_row_based_done' flag. For tables which were used
590+
by current substatement the flag is cleared as part of 'ha_reset()' call.
591+
For the rest of the open tables not used by current substament if this
592+
flag is enabled as part of current substatement execution, clear the flag
593+
explicitly.
594+
589595
NOTE
590596
The reason we reset query_id is that it's not enough to just test
591597
if table->query_id != thd->query_id to know if a table is in use.
@@ -607,6 +613,8 @@ static void mark_used_tables_as_free_for_reuse(THD *thd, TABLE *table)
607613
table->query_id= 0;
608614
table->file->ha_reset();
609615
}
616+
else if (table->file->check_table_binlog_row_based_done)
617+
table->file->clear_cached_table_binlog_row_based_flag();
610618
}
611619
}
612620

0 commit comments

Comments
 (0)