Debian Codegraph @

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

raw
1 ####################################################################################
2 # WL#13784 - Create auto_increment PK on table creation when no PK is specified #
3 # #
4 # Test case verifies following FR #
5 # In GIPK mode if primary key is generated for a non-PK table then query string #
6 # CREATE TABLE ... SELECT must be re-written to include generated primary key #
7 # definition in the binlog event to replicate table correctly in the RBR mode. #
8 # #
9 # - In SBR mode, CREATE TABLE ... SELECT with GIPK can *not* be replicated #
10 # safely so an error is reported in this case. #
11 # #
12 # Case : Verify CREATE TABLE ... SELECT without primary key. An error is reported #
13 # in this case. #
14 # Source: @sql_generate_invisible_primary_key = ON. #
15 # Create table using CREATE TABLE ... SELECT without explicit #
16 # primary key. #
17 # Error should be reported in this case. #
18 # #
19 ####################################################################################
20 --source include/have_binlog_format_statement.inc
21 --source include/master-slave.inc
22
23 SET @saved_session_sql_generate_invisible_primary_key = @@session.sql_generate_invisible_primary_key;
24 SET SESSION sql_generate_invisible_primary_key = ON;
25
26 --echo # Verify CREATE TABLE ... SELECT without an explicit primary key.
27 --echo # An error is generated in this case.
28 CREATE TABLE t1(f1 INT, f2 INT);
29 INSERT INTO t1 VALUES (1, 10), (2, 20);
30
31 --error ER_CREATE_SELECT_WITH_GIPK_DISALLOWED_IN_SBR
32 CREATE TABLE t2 AS SELECT * FROM t1;
33 --error ER_CREATE_SELECT_WITH_GIPK_DISALLOWED_IN_SBR
34 CREATE TEMPORARY TABLE t2 AS SELECT * FROM t1;
35
36 --source include/rpl_connection_master.inc
37 DROP TABLE t1;
38
39 SET SESSION sql_generate_invisible_primary_key =
40 @saved_session_sql_generate_invisible_primary_key;
41 --source include/rpl_end.inc