# Copy create_tmp_table_binlog_formats from master to slave
# This is done to get same results aswith older versions of MariaDB.
# The slave will work even if this isnot done. However in mixed
# format on slave temporary tables would not be logged toin the
# slaves binary log
let $format=`select @@create_tmp_table_binlog_formats`;
connection server_2;
--eval set @@global.create_tmp_table_binlog_formats='$format'
# Ensure that the slave threads uses the new values.
--source include/stop_slave.inc
--source include/start_slave.inc
connection server_1;
--echo #
--echo # Create help tables
--echo #
create table t2 (a int) engine=myisam;
insert into t2 values (0),(1),(2),(2);
create temporary table t3 (a_in_temporary int) engine=myisam;
--echo #
--echo # Check how create table and create or replace table are logged
--echo #
connection server_1;
CREATE TABLE t1 AS SELECT 1AS f1;
CREATE OR REPLACE TABLE t1 AS SELECT 2AS f1;
CREATE OR REPLACE table t1 like t2;
CREATE OR REPLACE table t1 like t3;
drop table t1;
--echo binlog from server 1
--source include/show_binlog_events.inc
save_master_pos;
connection server_2;
sync_with_master;
--echo binlog from server 2
--source include/show_binlog_events.inc
connection server_1;
--echo #
--echo # Ensure that also failed create_or_replace are logged
--echo #
create table t1 (a int);
--error ER_TABLE_MUST_HAVE_COLUMNS
create or replace table t1;
drop table if exists t1;
# The following isnot logged as t1 does not exists;
--error ER_DUP_ENTRY
create or replace table t1 (a int primary key) select a from t2;
create table t1 (a int);
# This should as a delete as we will delete t1
--error ER_DUP_ENTRY
create or replace table t1 (a int primary key) select a from t2;
# Same with temporary table
create temporary table t9 (a int);
--error ER_DUP_ENTRY
create or replace temporary table t9 (a int primary key) select a from t2;
--echo binlog from server 1
--source include/show_binlog_events.inc
save_master_pos;
connection server_2;
sync_with_master;
show tables;
connection server_1;
--let $binlog_start=query_get_value(SHOW MASTER STATUS, Position, 1)
create table t1 (a int);
--error ER_DUP_FIELDNAME
create or replace table t1 (a int, a int) select * from t2;
--source include/show_binlog_events.inc
drop table if exists t1,t2;
drop temporary table if exists t9;
--echo #
--echo # Ensure that CREATE are run as CREATE OR REPLACE on slave
--echo #
# Drop the table on the slave
drop table t1;
connection server_1;
drop table t1,t4;
create table t1 (server_2_ver_2 int);
save_master_pos;
connection server_2;
sync_with_master;
show create table t1;
--echo binlog from server 2
--source include/show_binlog_events.inc
connection server_1;
drop table t1;
--echo #
--echo # Ensure that CREATE ... SELECT is recorded as one GTID on the slave
--echo #
set @org_binlog_format=@@binlog_format; set binlog_format="STATEMENT";
create temporary table t5 (a int);
drop temporary table t5; set binlog_format="ROW";
create temporary table t6 (a int);
drop temporary table t6; set binlog_format="STATEMENT";
create temporary table t7 (a int); set binlog_format="ROW";
drop temporary table t7;
create temporary table t8 (a int);
--error ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR set binlog_format="STATEMENT";
drop temporary table t8; set @@binlog_format=@org_binlog_format;
# MDEV-20091:
# 1. No DROP should be logged for non-existing tmp table, nor
# 2. at the connection close when its creation has not been logged. set @@session.binlog_format=default;
drop temporary table if exists t9;
--connect(con1,localhost,root,,)
--let $conid = `SELECT CONNECTION_ID()` set session binlog_format=default;
create temporary table t9 (i int);
--echo *** Must be no DROP logged for t9 when there was no CREATE, at disconnect too ***
--disconnect con1
--connection server_1
# The disconnect runs asynchroneously. Wait for it to complete, otherwise the
# DROP TEMPORARY TABLE may not have been binlogged yet when SHOW BINLOG EVENTS
# is run.
--let $wait_condition= SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE ID=$conid
--source include/wait_condition.inc
--source include/show_binlog_events.inc
# Clean up
drop table t2;
--connection server_2 set @@global.create_tmp_table_binlog_formats=default;
--connection server_1
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.