mirror of
https://github.com/MariaDB/server.git
synced 2025-04-18 21:44:20 +03:00
MDEV-31660 : Assertion `client_state.transaction().active() in wsrep_append_key
At the moment we cannot support wsrep_forced_binlog_format=[MIXED|STATEMENT] during CREATE TABLE AS SELECT. Statement will use ROW instead and give a warning. Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
This commit is contained in:
parent
04b7b3a0ca
commit
f57deb314f
@ -18,6 +18,8 @@ USE test;
|
||||
CREATE TABLE t1(i INT) ENGINE=INNODB;
|
||||
INSERT INTO t1 VALUES(1);
|
||||
CREATE TEMPORARY TABLE `t1_temp` AS SELECT * FROM `t1` WHERE i = 1;
|
||||
Warnings:
|
||||
Warning 1105 Galera does not support wsrep_forced_binlog_format = STMT in CREATE TABLE AS SELECT
|
||||
SELECT * FROM t1;
|
||||
i
|
||||
1
|
||||
|
@ -0,0 +1,273 @@
|
||||
connection node_2;
|
||||
connection node_1;
|
||||
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since.*");
|
||||
SET GLOBAL wsrep_forced_binlog_format=ROW;
|
||||
connection node_1;
|
||||
CREATE TABLE t1(a int not null primary key auto_increment, b int) ENGINE=InnoDB;
|
||||
CREATE TABLE t2(a int not null primary key, b int) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (NULL,1),(NULL,2);
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
CREATE TABLE t3 AS SELECT * FROM t1;
|
||||
CREATE TABLE t4 AS SELECT * FROM t2;
|
||||
CREATE TABLE t5 (a INT UNIQUE) AS SELECT 1 AS a;
|
||||
CREATE TABLE t6 (a INT UNIQUE) REPLACE SELECT 1 AS a;
|
||||
CREATE TABLE t7 (a INT UNIQUE) REPLACE SELECT 1 AS a,2 AS b UNION SELECT 1 AS a,
|
||||
3 AS c;
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t1;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT COUNT(*) AS EXPECT_0 FROM t2;
|
||||
EXPECT_0
|
||||
0
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t3;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT * FROM t4;
|
||||
a b
|
||||
SELECT * FROM t5;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t6;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t7;
|
||||
a b
|
||||
1 3
|
||||
connection node_2;
|
||||
# Veryfy CTAS replication
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t1;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT COUNT(*) AS EXPECT_0 FROM t2;
|
||||
EXPECT_0
|
||||
0
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t3;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT * FROM t4;
|
||||
a b
|
||||
SELECT * FROM t5;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t6;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t7;
|
||||
a b
|
||||
1 3
|
||||
connection node_1;
|
||||
DROP TABLE t1,t2,t3,t4,t5,t6,t7;
|
||||
SET GLOBAL wsrep_forced_binlog_format=STATEMENT;
|
||||
connection node_1;
|
||||
CREATE TABLE t1(a int not null primary key auto_increment, b int) ENGINE=InnoDB;
|
||||
CREATE TABLE t2(a int not null primary key, b int) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (NULL,1),(NULL,2);
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave
|
||||
CREATE TABLE t3 AS SELECT * FROM t1;
|
||||
Warnings:
|
||||
Warning 1105 Galera does not support wsrep_forced_binlog_format = STMT in CREATE TABLE AS SELECT
|
||||
CREATE TABLE t4 AS SELECT * FROM t2;
|
||||
Warnings:
|
||||
Warning 1105 Galera does not support wsrep_forced_binlog_format = STMT in CREATE TABLE AS SELECT
|
||||
CREATE TABLE t5 (a INT UNIQUE) AS SELECT 1 AS a;
|
||||
Warnings:
|
||||
Warning 1105 Galera does not support wsrep_forced_binlog_format = STMT in CREATE TABLE AS SELECT
|
||||
CREATE TABLE t6 (a INT UNIQUE) REPLACE SELECT 1 AS a;
|
||||
Warnings:
|
||||
Warning 1105 Galera does not support wsrep_forced_binlog_format = STMT in CREATE TABLE AS SELECT
|
||||
CREATE TABLE t7 (a INT UNIQUE) REPLACE SELECT 1 AS a,2 AS b UNION SELECT 1 AS a,
|
||||
3 AS c;
|
||||
Warnings:
|
||||
Warning 1105 Galera does not support wsrep_forced_binlog_format = STMT in CREATE TABLE AS SELECT
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t1;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT COUNT(*) AS EXPECT_0 FROM t2;
|
||||
EXPECT_0
|
||||
0
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t3;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT * FROM t4;
|
||||
a b
|
||||
SELECT * FROM t5;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t6;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t7;
|
||||
a b
|
||||
1 3
|
||||
connection node_2;
|
||||
# Veryfy CTAS replication
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t1;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT COUNT(*) AS EXPECT_0 FROM t2;
|
||||
EXPECT_0
|
||||
0
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t3;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT * FROM t4;
|
||||
a b
|
||||
SELECT * FROM t5;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t6;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t7;
|
||||
a b
|
||||
1 3
|
||||
connection node_1;
|
||||
DROP TABLE t1,t2,t3,t4,t5,t6,t7;
|
||||
SET GLOBAL wsrep_forced_binlog_format=MIXED;
|
||||
connection node_1;
|
||||
CREATE TABLE t1(a int not null primary key auto_increment, b int) ENGINE=InnoDB;
|
||||
CREATE TABLE t2(a int not null primary key, b int) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (NULL,1),(NULL,2);
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
CREATE TABLE t3 AS SELECT * FROM t1;
|
||||
Warnings:
|
||||
Warning 1105 Galera does not support wsrep_forced_binlog_format = MIXED in CREATE TABLE AS SELECT
|
||||
CREATE TABLE t4 AS SELECT * FROM t2;
|
||||
Warnings:
|
||||
Warning 1105 Galera does not support wsrep_forced_binlog_format = MIXED in CREATE TABLE AS SELECT
|
||||
CREATE TABLE t5 (a INT UNIQUE) AS SELECT 1 AS a;
|
||||
Warnings:
|
||||
Warning 1105 Galera does not support wsrep_forced_binlog_format = MIXED in CREATE TABLE AS SELECT
|
||||
CREATE TABLE t6 (a INT UNIQUE) REPLACE SELECT 1 AS a;
|
||||
Warnings:
|
||||
Warning 1105 Galera does not support wsrep_forced_binlog_format = MIXED in CREATE TABLE AS SELECT
|
||||
CREATE TABLE t7 (a INT UNIQUE) REPLACE SELECT 1 AS a,2 AS b UNION SELECT 1 AS a,
|
||||
3 AS c;
|
||||
Warnings:
|
||||
Warning 1105 Galera does not support wsrep_forced_binlog_format = MIXED in CREATE TABLE AS SELECT
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t1;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT COUNT(*) AS EXPECT_0 FROM t2;
|
||||
EXPECT_0
|
||||
0
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t3;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT * FROM t4;
|
||||
a b
|
||||
SELECT * FROM t5;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t6;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t7;
|
||||
a b
|
||||
1 3
|
||||
connection node_2;
|
||||
# Veryfy CTAS replication
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t1;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT COUNT(*) AS EXPECT_0 FROM t2;
|
||||
EXPECT_0
|
||||
0
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t3;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT * FROM t4;
|
||||
a b
|
||||
SELECT * FROM t5;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t6;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t7;
|
||||
a b
|
||||
1 3
|
||||
connection node_1;
|
||||
DROP TABLE t1,t2,t3,t4,t5,t6,t7;
|
||||
SET GLOBAL wsrep_forced_binlog_format=NONE;
|
||||
connection node_1;
|
||||
CREATE TABLE t1(a int not null primary key auto_increment, b int) ENGINE=InnoDB;
|
||||
CREATE TABLE t2(a int not null primary key, b int) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (NULL,1),(NULL,2);
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
CREATE TABLE t3 AS SELECT * FROM t1;
|
||||
CREATE TABLE t4 AS SELECT * FROM t2;
|
||||
CREATE TABLE t5 (a INT UNIQUE) AS SELECT 1 AS a;
|
||||
CREATE TABLE t6 (a INT UNIQUE) REPLACE SELECT 1 AS a;
|
||||
CREATE TABLE t7 (a INT UNIQUE) REPLACE SELECT 1 AS a,2 AS b UNION SELECT 1 AS a,
|
||||
3 AS c;
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t1;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT COUNT(*) AS EXPECT_0 FROM t2;
|
||||
EXPECT_0
|
||||
0
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t3;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT * FROM t4;
|
||||
a b
|
||||
SELECT * FROM t5;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t6;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t7;
|
||||
a b
|
||||
1 3
|
||||
connection node_2;
|
||||
# Veryfy CTAS replication
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t1;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT COUNT(*) AS EXPECT_0 FROM t2;
|
||||
EXPECT_0
|
||||
0
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t3;
|
||||
EXPECT_32
|
||||
32
|
||||
SELECT * FROM t4;
|
||||
a b
|
||||
SELECT * FROM t5;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t6;
|
||||
a
|
||||
1
|
||||
SELECT * FROM t7;
|
||||
a b
|
||||
1 3
|
||||
connection node_1;
|
||||
DROP TABLE t1,t2,t3,t4,t5,t6,t7;
|
50
mysql-test/suite/galera/t/galera_forced_binlog_ctas_test.inc
Normal file
50
mysql-test/suite/galera/t/galera_forced_binlog_ctas_test.inc
Normal file
@ -0,0 +1,50 @@
|
||||
--connection node_1
|
||||
CREATE TABLE t1(a int not null primary key auto_increment, b int) ENGINE=InnoDB;
|
||||
CREATE TABLE t2(a int not null primary key, b int) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (NULL,1),(NULL,2);
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
INSERT INTO t1(b) SELECT b+1 from t1;
|
||||
CREATE TABLE t3 AS SELECT * FROM t1;
|
||||
CREATE TABLE t4 AS SELECT * FROM t2;
|
||||
CREATE TABLE t5 (a INT UNIQUE) AS SELECT 1 AS a;
|
||||
CREATE TABLE t6 (a INT UNIQUE) REPLACE SELECT 1 AS a;
|
||||
CREATE TABLE t7 (a INT UNIQUE) REPLACE SELECT 1 AS a,2 AS b UNION SELECT 1 AS a,
|
||||
3 AS c;
|
||||
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t1;
|
||||
SELECT COUNT(*) AS EXPECT_0 FROM t2;
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t3;
|
||||
SELECT * FROM t4;
|
||||
SELECT * FROM t5;
|
||||
SELECT * FROM t6;
|
||||
SELECT * FROM t7;
|
||||
|
||||
--connection node_2
|
||||
--echo # Veryfy CTAS replication
|
||||
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'
|
||||
--source include/wait_condition.inc
|
||||
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2'
|
||||
--source include/wait_condition.inc
|
||||
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't3'
|
||||
--source include/wait_condition.inc
|
||||
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't4'
|
||||
--source include/wait_condition.inc
|
||||
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't5'
|
||||
--source include/wait_condition.inc
|
||||
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't6'
|
||||
--source include/wait_condition.inc
|
||||
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't7'
|
||||
--source include/wait_condition.inc
|
||||
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t1;
|
||||
SELECT COUNT(*) AS EXPECT_0 FROM t2;
|
||||
SELECT COUNT(*) AS EXPECT_32 FROM t3;
|
||||
SELECT * FROM t4;
|
||||
SELECT * FROM t5;
|
||||
SELECT * FROM t6;
|
||||
SELECT * FROM t7;
|
||||
|
||||
--connection node_1
|
||||
DROP TABLE t1,t2,t3,t4,t5,t6,t7;
|
@ -0,0 +1,19 @@
|
||||
--source include/galera_cluster.inc
|
||||
|
||||
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since.*");
|
||||
|
||||
SET GLOBAL wsrep_forced_binlog_format=ROW;
|
||||
|
||||
--source suite/galera/t/galera_forced_binlog_ctas_test.inc
|
||||
|
||||
SET GLOBAL wsrep_forced_binlog_format=STATEMENT;
|
||||
|
||||
--source suite/galera/t/galera_forced_binlog_ctas_test.inc
|
||||
|
||||
SET GLOBAL wsrep_forced_binlog_format=MIXED;
|
||||
|
||||
--source suite/galera/t/galera_forced_binlog_ctas_test.inc
|
||||
|
||||
SET GLOBAL wsrep_forced_binlog_format=NONE;
|
||||
|
||||
--source suite/galera/t/galera_forced_binlog_ctas_test.inc
|
12
sql/log.cc
12
sql/log.cc
@ -1960,15 +1960,16 @@ static int binlog_prepare(handlerton *hton, THD *thd, bool all)
|
||||
static bool trans_cannot_safely_rollback(THD *thd, bool all)
|
||||
{
|
||||
DBUG_ASSERT(ending_trans(thd, all));
|
||||
ulong binlog_format= thd->wsrep_binlog_format(thd->variables.binlog_format);
|
||||
|
||||
return ((thd->variables.option_bits & OPTION_KEEP_LOG) ||
|
||||
(trans_has_updated_non_trans_table(thd) &&
|
||||
thd->wsrep_binlog_format() == BINLOG_FORMAT_STMT) ||
|
||||
binlog_format == BINLOG_FORMAT_STMT) ||
|
||||
(thd->transaction.all.has_modified_non_trans_temp_table() &&
|
||||
thd->wsrep_binlog_format() == BINLOG_FORMAT_MIXED) ||
|
||||
binlog_format == BINLOG_FORMAT_MIXED) ||
|
||||
(trans_has_updated_non_trans_table(thd) &&
|
||||
ending_single_stmt_trans(thd,all) &&
|
||||
thd->wsrep_binlog_format() == BINLOG_FORMAT_MIXED));
|
||||
binlog_format == BINLOG_FORMAT_MIXED));
|
||||
}
|
||||
|
||||
|
||||
@ -2117,6 +2118,7 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
|
||||
}
|
||||
else if (likely(!error))
|
||||
{
|
||||
ulong binlog_format= thd->wsrep_binlog_format(thd->variables.binlog_format);
|
||||
if (ending_trans(thd, all) && trans_cannot_safely_rollback(thd, all))
|
||||
error= binlog_rollback_flush_trx_cache(thd, all, cache_mngr);
|
||||
/*
|
||||
@ -2133,9 +2135,9 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
|
||||
(!(thd->transaction.stmt.has_created_dropped_temp_table() &&
|
||||
!thd->is_current_stmt_binlog_format_row()) &&
|
||||
(!stmt_has_updated_non_trans_table(thd) ||
|
||||
thd->wsrep_binlog_format() != BINLOG_FORMAT_STMT) &&
|
||||
binlog_format != BINLOG_FORMAT_STMT) &&
|
||||
(!thd->transaction.stmt.has_modified_non_trans_temp_table() ||
|
||||
thd->wsrep_binlog_format() != BINLOG_FORMAT_MIXED)))
|
||||
binlog_format != BINLOG_FORMAT_MIXED)))
|
||||
error= binlog_truncate_trx_cache(thd, cache_mngr, all);
|
||||
}
|
||||
|
||||
|
@ -3433,7 +3433,8 @@ thr_lock_type read_lock_type_for_table(THD *thd,
|
||||
at THD::variables::sql_log_bin member.
|
||||
*/
|
||||
bool log_on= mysql_bin_log.is_open() && thd->variables.sql_log_bin;
|
||||
if ((log_on == FALSE) || (thd->wsrep_binlog_format() == BINLOG_FORMAT_ROW) ||
|
||||
if ((log_on == FALSE) ||
|
||||
(thd->wsrep_binlog_format(thd->variables.binlog_format) == BINLOG_FORMAT_ROW) ||
|
||||
(table_list->table->s->table_category == TABLE_CATEGORY_LOG) ||
|
||||
(table_list->table->s->table_category == TABLE_CATEGORY_PERFORMANCE) ||
|
||||
!(is_update_query(prelocking_ctx->sql_command) ||
|
||||
|
@ -667,6 +667,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
|
||||
wsrep_ignore_table(false),
|
||||
wsrep_aborter(0),
|
||||
wsrep_delayed_BF_abort(false),
|
||||
wsrep_ctas(false),
|
||||
|
||||
/* wsrep-lib */
|
||||
m_wsrep_next_trx_id(WSREP_UNDEFINED_TRX_ID),
|
||||
@ -5323,7 +5324,7 @@ extern "C" int thd_binlog_format(const MYSQL_THD thd)
|
||||
if (WSREP(thd))
|
||||
{
|
||||
/* for wsrep binlog format is meaningful also when binlogging is off */
|
||||
return (int) WSREP_BINLOG_FORMAT(thd->variables.binlog_format);
|
||||
return (int) thd->wsrep_binlog_format(thd->variables.binlog_format);
|
||||
}
|
||||
|
||||
if (mysql_bin_log.is_open() && (thd->variables.option_bits & OPTION_BIN_LOG))
|
||||
@ -5997,6 +5998,8 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
|
||||
reset_binlog_local_stmt_filter();
|
||||
|
||||
// Used binlog format
|
||||
ulong binlog_format= wsrep_binlog_format(variables.binlog_format);
|
||||
/*
|
||||
We should not decide logging format if the binlog is closed or
|
||||
binlogging is off, or if the statement is filtered out from the
|
||||
@ -6017,20 +6020,41 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
If user has configured wsrep_forced_binlog_format to
|
||||
STMT OR MIXED and used binlog_format would be same
|
||||
and this is CREATE TABLE AS SELECT we will fall back
|
||||
to ROW.
|
||||
*/
|
||||
if (wsrep_forced_binlog_format < BINLOG_FORMAT_ROW &&
|
||||
wsrep_ctas)
|
||||
{
|
||||
if (!get_stmt_da()->has_sql_condition(ER_UNKNOWN_ERROR))
|
||||
{
|
||||
push_warning_printf(this, Sql_condition::WARN_LEVEL_WARN,
|
||||
ER_UNKNOWN_ERROR,
|
||||
"Galera does not support wsrep_forced_binlog_format = %s "
|
||||
"in CREATE TABLE AS SELECT",
|
||||
wsrep_forced_binlog_format == BINLOG_FORMAT_STMT ?
|
||||
"STMT" : "MIXED");
|
||||
}
|
||||
set_current_stmt_binlog_format_row();
|
||||
}
|
||||
|
||||
if ((WSREP_EMULATE_BINLOG_NNULL(this) ||
|
||||
(mysql_bin_log.is_open() && (variables.option_bits & OPTION_BIN_LOG))) &&
|
||||
!(wsrep_binlog_format() == BINLOG_FORMAT_STMT &&
|
||||
!(binlog_format == BINLOG_FORMAT_STMT &&
|
||||
!binlog_filter->db_ok(db.str)))
|
||||
#else
|
||||
if (mysql_bin_log.is_open() && (variables.option_bits & OPTION_BIN_LOG) &&
|
||||
!(wsrep_binlog_format() == BINLOG_FORMAT_STMT &&
|
||||
!(binlog_format == BINLOG_FORMAT_STMT &&
|
||||
!binlog_filter->db_ok(db.str)))
|
||||
#endif /* WITH_WSREP */
|
||||
{
|
||||
|
||||
if (is_bulk_op())
|
||||
{
|
||||
if (wsrep_binlog_format() == BINLOG_FORMAT_STMT)
|
||||
if (binlog_format == BINLOG_FORMAT_STMT)
|
||||
{
|
||||
my_error(ER_BINLOG_NON_SUPPORTED_BULK, MYF(0));
|
||||
DBUG_PRINT("info",
|
||||
@ -6243,7 +6267,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
prev_access_table= table;
|
||||
}
|
||||
|
||||
if (wsrep_binlog_format() != BINLOG_FORMAT_ROW)
|
||||
if (binlog_format != BINLOG_FORMAT_ROW)
|
||||
{
|
||||
/*
|
||||
DML statements that modify a table with an auto_increment
|
||||
@ -6327,7 +6351,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
*/
|
||||
my_error((error= ER_BINLOG_ROW_INJECTION_AND_STMT_ENGINE), MYF(0));
|
||||
}
|
||||
else if ((wsrep_binlog_format() == BINLOG_FORMAT_ROW || is_bulk_op()) &&
|
||||
else if ((binlog_format == BINLOG_FORMAT_ROW || is_bulk_op()) &&
|
||||
sqlcom_can_generate_row_events(this))
|
||||
{
|
||||
/*
|
||||
@ -6357,7 +6381,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
else
|
||||
{
|
||||
/* binlog_format = STATEMENT */
|
||||
if (wsrep_binlog_format() == BINLOG_FORMAT_STMT)
|
||||
if (binlog_format == BINLOG_FORMAT_STMT)
|
||||
{
|
||||
if (lex->is_stmt_row_injection())
|
||||
{
|
||||
@ -6497,7 +6521,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
"and binlog_filter->db_ok(db) = %d",
|
||||
mysql_bin_log.is_open(),
|
||||
(variables.option_bits & OPTION_BIN_LOG),
|
||||
(uint) wsrep_binlog_format(),
|
||||
(uint) binlog_format,
|
||||
binlog_filter->db_ok(db.str)));
|
||||
#endif
|
||||
|
||||
@ -6533,7 +6557,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
void THD::reconsider_logging_format_for_iodup(TABLE *table)
|
||||
{
|
||||
DBUG_ENTER("reconsider_logging_format_for_iodup");
|
||||
enum_binlog_format bf= (enum_binlog_format) wsrep_binlog_format();
|
||||
enum_binlog_format bf= (enum_binlog_format) wsrep_binlog_format(variables.binlog_format);
|
||||
|
||||
DBUG_ASSERT(lex->duplicates == DUP_UPDATE);
|
||||
|
||||
|
@ -4255,7 +4255,7 @@ public:
|
||||
tests fail and so force them to propagate the
|
||||
lex->binlog_row_based_if_mixed upwards to the caller.
|
||||
*/
|
||||
if ((wsrep_binlog_format() == BINLOG_FORMAT_MIXED) && (in_sub_stmt == 0))
|
||||
if ((wsrep_binlog_format(variables.binlog_format) == BINLOG_FORMAT_MIXED) && (in_sub_stmt == 0))
|
||||
set_current_stmt_binlog_format_row();
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
@ -4311,7 +4311,7 @@ public:
|
||||
show_system_thread(system_thread)));
|
||||
if (in_sub_stmt == 0)
|
||||
{
|
||||
if (wsrep_binlog_format() == BINLOG_FORMAT_ROW)
|
||||
if (wsrep_binlog_format(variables.binlog_format) == BINLOG_FORMAT_ROW)
|
||||
set_current_stmt_binlog_format_row();
|
||||
else if (!has_temporary_tables())
|
||||
set_current_stmt_binlog_format_stmt();
|
||||
@ -4958,9 +4958,18 @@ public:
|
||||
*/
|
||||
bool is_awaiting_semisync_ack;
|
||||
|
||||
inline ulong wsrep_binlog_format() const
|
||||
inline ulong wsrep_binlog_format(ulong binlog_format) const
|
||||
{
|
||||
return WSREP_BINLOG_FORMAT(variables.binlog_format);
|
||||
#ifdef WITH_WSREP
|
||||
// During CTAS we force ROW format
|
||||
if (wsrep_ctas)
|
||||
return BINLOG_FORMAT_ROW;
|
||||
else
|
||||
return ((wsrep_forced_binlog_format != BINLOG_FORMAT_UNSPEC) ?
|
||||
wsrep_forced_binlog_format : binlog_format);
|
||||
#else
|
||||
return (binlog_format);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
@ -5003,11 +5012,9 @@ public:
|
||||
void *wsrep_apply_format;
|
||||
uchar* wsrep_rbr_buf;
|
||||
wsrep_gtid_t wsrep_sync_wait_gtid;
|
||||
// wsrep_gtid_t wsrep_last_written_gtid;
|
||||
ulong wsrep_affected_rows;
|
||||
bool wsrep_has_ignored_error;
|
||||
bool wsrep_replicate_GTID;
|
||||
|
||||
/*
|
||||
When enabled, do not replicate/binlog updates from the current table that's
|
||||
being processed. At the moment, it is used to keep mysql.gtid_slave_pos
|
||||
@ -5027,7 +5034,8 @@ public:
|
||||
/* true if BF abort is observed in do_command() right after reading
|
||||
client's packet, and if the client has sent PS execute command. */
|
||||
bool wsrep_delayed_BF_abort;
|
||||
|
||||
// true if this transaction is CREATE TABLE AS SELECT (CTAS)
|
||||
bool wsrep_ctas;
|
||||
/*
|
||||
Transaction id:
|
||||
* m_wsrep_next_trx_id is assigned on the first query after
|
||||
|
@ -537,6 +537,18 @@ bool Warning_info::has_sql_condition(const char *message_str, size_t message_len
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Warning_info::has_sql_condition(uint sql_errno) const
|
||||
{
|
||||
Diagnostics_area::Sql_condition_iterator it(m_warn_list);
|
||||
const Sql_condition *err;
|
||||
|
||||
while ((err = it++))
|
||||
{
|
||||
if (err->get_sql_errno() == sql_errno)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Warning_info::clear(ulonglong new_id)
|
||||
{
|
||||
|
@ -591,6 +591,16 @@ private:
|
||||
*/
|
||||
bool has_sql_condition(const char *message_str, size_t message_length) const;
|
||||
|
||||
/**
|
||||
Checks if Warning_info contains SQL-condition with the given error id
|
||||
|
||||
@param sql_errno SQL-condition error number
|
||||
|
||||
@return true if the Warning_info contains an SQL-condition with the given
|
||||
error id.
|
||||
*/
|
||||
bool has_sql_condition(uint sql_errno) const;
|
||||
|
||||
/**
|
||||
Reset the warning information. Clear all warnings,
|
||||
the number of warnings, reset current row counter
|
||||
@ -1126,6 +1136,9 @@ public:
|
||||
bool has_sql_condition(const char *message_str, size_t message_length) const
|
||||
{ return get_warning_info()->has_sql_condition(message_str, message_length); }
|
||||
|
||||
bool has_sql_condition(uint sql_errno) const
|
||||
{ return get_warning_info()->has_sql_condition(sql_errno); }
|
||||
|
||||
void reset_for_next_command()
|
||||
{ get_warning_info()->reset_for_next_command(); }
|
||||
|
||||
|
@ -475,7 +475,7 @@ void upgrade_lock_type(THD *thd, thr_lock_type *lock_type,
|
||||
}
|
||||
|
||||
bool log_on= (thd->variables.option_bits & OPTION_BIN_LOG);
|
||||
if (WSREP_BINLOG_FORMAT(global_system_variables.binlog_format) == BINLOG_FORMAT_STMT &&
|
||||
if (thd->wsrep_binlog_format(global_system_variables.binlog_format) == BINLOG_FORMAT_STMT &&
|
||||
log_on && mysql_bin_log.is_open())
|
||||
{
|
||||
/*
|
||||
|
@ -57,7 +57,33 @@
|
||||
#include <algorithm>
|
||||
#ifdef WITH_WSREP
|
||||
#include "wsrep_mysqld.h"
|
||||
#endif
|
||||
|
||||
/** RAII class for temporarily enabling wsrep_ctas in the connection. */
|
||||
class Enable_wsrep_ctas_guard
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@param thd - pointer to the context of connection in which
|
||||
wsrep_ctas mode needs to be enabled.
|
||||
@param ctas - true if this is CREATE TABLE AS SELECT and
|
||||
wsrep_on
|
||||
*/
|
||||
explicit Enable_wsrep_ctas_guard(THD *thd, const bool ctas)
|
||||
: m_thd(thd)
|
||||
{
|
||||
if (ctas)
|
||||
thd->wsrep_ctas= true;
|
||||
}
|
||||
|
||||
~Enable_wsrep_ctas_guard()
|
||||
{
|
||||
m_thd->wsrep_ctas= false;
|
||||
}
|
||||
private:
|
||||
THD* m_thd;
|
||||
};
|
||||
|
||||
#endif /* WITH_WSREP */
|
||||
#include "sql_debug.h"
|
||||
|
||||
#ifdef __WIN__
|
||||
@ -11519,6 +11545,7 @@ bool Sql_cmd_create_table_like::execute(THD *thd)
|
||||
int res= 0;
|
||||
|
||||
const bool used_engine= lex->create_info.used_fields & HA_CREATE_USED_ENGINE;
|
||||
ulong binlog_format= thd->wsrep_binlog_format(thd->variables.binlog_format);
|
||||
DBUG_ASSERT((m_storage_engine_name.str != NULL) == used_engine);
|
||||
if (used_engine)
|
||||
{
|
||||
@ -11558,6 +11585,14 @@ bool Sql_cmd_create_table_like::execute(THD *thd)
|
||||
*/
|
||||
Alter_info alter_info(lex->alter_info, thd->mem_root);
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
// If CREATE TABLE AS SELECT and wsrep_on
|
||||
const bool wsrep_ctas= (select_lex->item_list.elements && WSREP(thd));
|
||||
|
||||
// This will be used in THD::decide_logging_format if CTAS
|
||||
Enable_wsrep_ctas_guard wsrep_ctas_guard(thd, wsrep_ctas);
|
||||
#endif
|
||||
|
||||
if (unlikely(thd->is_fatal_error))
|
||||
{
|
||||
/* If out of memory when creating a copy of alter_info. */
|
||||
@ -11627,15 +11662,17 @@ bool Sql_cmd_create_table_like::execute(THD *thd)
|
||||
#endif
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
if (select_lex->item_list.elements && // With SELECT
|
||||
WSREP(thd) && thd->variables.wsrep_trx_fragment_size > 0)
|
||||
if (wsrep_ctas)
|
||||
{
|
||||
my_message(
|
||||
if (thd->variables.wsrep_trx_fragment_size > 0)
|
||||
{
|
||||
my_message(
|
||||
ER_NOT_ALLOWED_COMMAND,
|
||||
"CREATE TABLE AS SELECT is not supported with streaming replication",
|
||||
MYF(0));
|
||||
res= 1;
|
||||
goto end_with_restore_list;
|
||||
res= 1;
|
||||
goto end_with_restore_list;
|
||||
}
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
@ -11665,7 +11702,7 @@ bool Sql_cmd_create_table_like::execute(THD *thd)
|
||||
(see 'NAME_CONST issues' in 'Binary Logging of Stored Programs')
|
||||
*/
|
||||
if (thd->query_name_consts && mysql_bin_log.is_open() &&
|
||||
thd->wsrep_binlog_format() == BINLOG_FORMAT_STMT &&
|
||||
binlog_format == BINLOG_FORMAT_STMT &&
|
||||
!mysql_bin_log.is_query_in_union(thd, thd->query_id))
|
||||
{
|
||||
List_iterator_fast<Item> it(select_lex->item_list);
|
||||
@ -11802,10 +11839,11 @@ bool Sql_cmd_create_table_like::execute(THD *thd)
|
||||
#ifdef WITH_WSREP
|
||||
WSREP_TO_ISOLATION_BEGIN_ALTER(create_table->db.str, create_table->table_name.str,
|
||||
first_table, &alter_info, NULL)
|
||||
{
|
||||
WSREP_WARN("CREATE TABLE isolation failure");
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
{
|
||||
WSREP_WARN("CREATE TABLE isolation failure");
|
||||
res= true;
|
||||
goto end_with_restore_list;
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
}
|
||||
// check_engine will set db_type to NULL if e.g. TEMPORARY is
|
||||
|
@ -46,10 +46,6 @@ extern ulong wsrep_forced_binlog_format;
|
||||
#define WSREP_EMULATE_BINLOG(thd) \
|
||||
(WSREP(thd) && wsrep_emulate_bin_log)
|
||||
|
||||
#define WSREP_BINLOG_FORMAT(my_format) \
|
||||
((wsrep_forced_binlog_format != BINLOG_FORMAT_UNSPEC) ? \
|
||||
wsrep_forced_binlog_format : my_format)
|
||||
|
||||
#else
|
||||
|
||||
#define WSREP_ON false
|
||||
@ -57,7 +53,6 @@ extern ulong wsrep_forced_binlog_format;
|
||||
#define WSREP_NNULL(T) (0)
|
||||
#define WSREP_EMULATE_BINLOG(thd) (0)
|
||||
#define WSREP_EMULATE_BINLOG_NNULL(thd) (0)
|
||||
#define WSREP_BINLOG_FORMAT(my_format) ((ulong)my_format)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user