Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
MDEV-16234 CREATE TABLE .. SELECT LASTVAL breaks replication
Fixed by marking NEXTVAL() and LASTVAL() to be replicated row based
- Loading branch information
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| include/master-slave.inc | ||
| [connection master] | ||
| # | ||
| # MDEV-16234 | ||
| # CREATE TABLE .. SELECT LASTVAL is written to binlog as single | ||
| # statement, causes discrepancy between master and slave | ||
| # | ||
| CREATE SEQUENCE s1 ENGINE=InnoDB; | ||
| SELECT NEXTVAL(s1); | ||
| NEXTVAL(s1) | ||
| 1 | ||
| CREATE TABLE t1 ENGINE=InnoDB SELECT LASTVAL(s1) AS a; | ||
| INSERT INTO t1 VALUES (NEXTVAL(s1)); | ||
| INSERT INTO t1 VALUES (LASTVAL(s1)); | ||
| SELECT * FROM t1; | ||
| a | ||
| 1 | ||
| 2 | ||
| 2 | ||
| SELECT * from s1; | ||
| next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count | ||
| 1001 1 9223372036854775806 1 1 1000 0 0 | ||
| connection slave; | ||
| SELECT * FROM t1; | ||
| a | ||
| 1 | ||
| 2 | ||
| 2 | ||
| SELECT * from s1; | ||
| next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count | ||
| 1001 1 9223372036854775806 1 1 1000 0 0 | ||
| connection master; | ||
| DROP TABLE t1; | ||
| DROP SEQUENCE s1; | ||
| include/rpl_end.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --source include/have_innodb.inc | ||
| --source include/have_binlog_format_mixed.inc | ||
| --source include/master-slave.inc | ||
|
|
||
| --echo # | ||
| --echo # MDEV-16234 | ||
| --echo # CREATE TABLE .. SELECT LASTVAL is written to binlog as single | ||
| --echo # statement, causes discrepancy between master and slave | ||
| --echo # | ||
|
|
||
| CREATE SEQUENCE s1 ENGINE=InnoDB; | ||
| SELECT NEXTVAL(s1); | ||
| CREATE TABLE t1 ENGINE=InnoDB SELECT LASTVAL(s1) AS a; | ||
| INSERT INTO t1 VALUES (NEXTVAL(s1)); | ||
| INSERT INTO t1 VALUES (LASTVAL(s1)); | ||
| SELECT * FROM t1; | ||
| SELECT * from s1; | ||
| --sync_slave_with_master | ||
| SELECT * FROM t1; | ||
| SELECT * from s1; | ||
|
|
||
| # Cleanup | ||
| --connection master | ||
| DROP TABLE t1; | ||
| DROP SEQUENCE s1; | ||
|
|
||
| --source include/rpl_end.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters