mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-36563 Assertion `!mysql_bin_log.is_open()' failed in THD::mark_tmp_table_as_free_for_reuse The purpose of this commit is to ensure that creation and changes of temporary tables are properly and predicable logged to the binary log. It also fixes some bugs where ROW logging was used in MIXED mode, when STATEMENT would be a better (and expected) choice. In this comment STATEMENT stands for logging to binary log in STATEMENT format, MIXED stands for MIXED binlog format and ROW for ROW binlog format. New rules for logging of temporary tables - CREATE of temporary tables are now by default binlogged only if STATEMENT binlog format is used. If it is binlogged, 1 is stored in TABLE_SHARE->table_creation_was_logged. The user can change this behavior by setting create_temporary_table_binlog_formats to MIXED,STATEMENT in which case the create is logged in statement format also in MIXED mode (as before). - Changes to temporary tables are only binlogged if and only if the CREATE was logged. The logging happens under STATEMENT or MIXED. If binlog_format=ROW, temporary table changes are not binlogged. A temporary table that are changed under ROW are marked as 'not up to date in binlog' and no future row changes are logged. Any usage of this temporary table will force row logging of other tables in any future statements using the temporary table to be row logged. - DROP TEMPORARY is binlogged only of the CREATE was binlogged. Changes done: - Row logging is forced for any statement using temporary tables that are not up to date in the binary log. (Before the row logging was forced if the user has a temporary table) - If there is any changes to the temporary table that is not binlogged, the table is marked as not up to date. - TABLE_SHARE->table_creation_was_logged has a new definition for temporary tables: 0 Table creating was not logged to binary log 1 Table creating was logged to binary log and table is up to date. 2 Table creating was logged to binary log but some changes where not logged to binary log. Table is not up to date in binary log is defined as value 0 or 2. - If a multi-table-update or multi-table-delete fails then all updated temporary tables are marked as not up to date. - Enforce row logging if the query is using temporary tables that are not up to date. Before row logging was enforced if the user had any temporary tables. - When dropping temporary tables use IF EXISTS. This ensures that slave will not stop if it had crashed and lost the temporary tables. - Remove comment and version from DROP /*!4000 TEMPORARY.. generated when a connection closes that has open temporary tables. Added 'generated by server' at the end of the DROP. Bugs fixed: - When using temporary tables with commands that forced row based, like INSERT INTO temporary_table VALUES (UUID()), this was never logged which causes the temporary table to be inconsistent on master and slave. - Used binlog format is now clearly defined. It is now only depending on the current binlog_format and the tables used. Before it was depending on the user had ANY temporary tables and the state of 'current_stmt_binlog_format' set by previous queries. This also caused temporary tables to be logged to binary log in some cases. - CREATE TABLE t1 LIKE not_logged_temporary_table caused replication to stop. - Rename of not binlogged temporary tables where binlogged to binary log which caused replication to stop. Changes in behavior: - By default create_temporary_table_binlog_formats=STATEMENT, which means that CREATE TEMPORARY is not logged to binary log under MIXED binary logging. This can be changed by setting create_temporary_table_binlog_formats to MIXED,STATEMENT. - Using temporary tables that was not logged to the binary log will cause any query using them for updating other tables to be logged in ROW format. Before all queries was logged in ROW format if the user had any temporary tables, even if they were not used by the query. - Generated DROP TEMPORARY TABLE is now always using IF EXISTS and has a "generated by server" comment in the binary log. The consequences of the above is that manipulations of a lot of rows through temporary tables will by default be be slower in mixed mode. For example: BEGIN; CREATE TEMPORARY TABLE tmp AS SELECT a, b, c FROM large_table1 JOIN large_table2 ON ...; INSERT INTO other_table SELECT b, c FROM tmp WHERE a <100; DROP TEMPORARY TABLE tmp; COMMIT; By default this will create a huge entry in the binary log, compared to just a few hundred bytes in statement mode. However the change in this commit will make usage of temporary tables more reliable and predicable and is thus worth it. Using statement mode or create_temporary_table_binlog_formats can be used to avoid this issue.
1064 lines
30 KiB
PHP
1064 lines
30 KiB
PHP
--source include/have_innodb.inc
|
|
--disable_abort_on_error
|
|
|
|
if (`SELECT HEX(@commands) = HEX('configure')`)
|
|
{
|
|
connection master;
|
|
|
|
#
|
|
# Index that is used as an Id to tables that trigger errors.
|
|
#
|
|
--let $tt_error_counter=0
|
|
--let $nt_error_counter=0
|
|
|
|
#
|
|
# Creates a T-table that is never dropped.
|
|
#
|
|
--eval CREATE TABLE tt_xx_1 ( id INT ) ENGINE = Innodb
|
|
|
|
#
|
|
# Creates a N-table that is never dropped.
|
|
#
|
|
--eval CREATE TABLE nt_xx_1 ( id INT ) ENGINE = MyIsam
|
|
|
|
#
|
|
# Creates a T-table that is never dropped.
|
|
#
|
|
--eval CREATE TABLE tt_error_1 ( id INT, PRIMARY KEY (id) ) ENGINE = Innodb
|
|
|
|
#
|
|
# Creates a N-table that is never dropped.
|
|
#
|
|
--eval CREATE TABLE nt_error_1 ( id INT, PRIMARY KEY (id) ) ENGINE = MyIsam
|
|
|
|
#
|
|
# Creates a T-table that is never dropped.
|
|
#
|
|
--eval CREATE TABLE tt_error_2 ( id INT, PRIMARY KEY (id) ) ENGINE = Innodb
|
|
|
|
#
|
|
# Creates a N-table that is never dropped.
|
|
#
|
|
--eval CREATE TABLE nt_error_2 ( id INT, PRIMARY KEY (id) ) ENGINE = MyIsam
|
|
|
|
#
|
|
# Create a trigger nt_error_2 --> tt_error_2
|
|
#
|
|
DELIMITER |;
|
|
CREATE TRIGGER tr_i_nt_2_to_tt_2 AFTER INSERT ON nt_error_2 FOR EACH ROW
|
|
BEGIN
|
|
DECLARE in_stmt_id INTEGER;
|
|
INSERT INTO tt_error_2(id) VALUES (NEW.id);
|
|
END|
|
|
DELIMITER ;|
|
|
|
|
#
|
|
# Creates a Temporary N-table that is never dropped.
|
|
#
|
|
--eval CREATE TEMPORARY TABLE nt_tmp_xx_1 ( id INT ) ENGINE = MyIsam
|
|
|
|
#
|
|
# Creates a Temporary T-table that is never dropped.
|
|
#
|
|
--eval CREATE TEMPORARY TABLE tt_tmp_xx_1 ( id INT ) ENGINE = Innodb
|
|
|
|
#
|
|
# In what follows, we create a set of tables that are used
|
|
# throughout this test case. The number of tables to be
|
|
# created is give by the variable $tot_table.
|
|
#
|
|
#
|
|
# Creates Temporay N-tables that are automatically dropped and recreated
|
|
# when a command ends.
|
|
#
|
|
--let $n= $tot_table
|
|
while ($n)
|
|
{
|
|
--eval DROP TEMPORARY TABLE IF EXISTS nt_tmp_$n
|
|
--eval CREATE TEMPORARY TABLE nt_tmp_$n ( id INT ) ENGINE = MyIsam
|
|
--disable_query_log
|
|
--eval SET @check_temp='$available_n_temp'
|
|
--enable_query_log
|
|
#
|
|
# Updates the $available_n_temp that keeps track of the created
|
|
# temporary N-tables.
|
|
#
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $available_n_temp= $available_n_temp,nt_tmp_$n
|
|
}
|
|
if (`SELECT HEX(@check_temp) = HEX('')`)
|
|
{
|
|
--let $available_n_temp= nt_tmp_$n
|
|
}
|
|
--dec $n
|
|
}
|
|
|
|
#
|
|
# Creates Temporay T-tables that are automatically dropped and recreated
|
|
# when a command ends.
|
|
#
|
|
--let $n= $tot_table
|
|
while ($n)
|
|
{
|
|
--eval DROP TEMPORARY TABLE IF EXISTS tt_tmp_$n
|
|
--eval CREATE TEMPORARY TABLE tt_tmp_$n ( id INT ) ENGINE = Innodb
|
|
--disable_query_log
|
|
--eval SET @check_temp='$available_t_temp'
|
|
--enable_query_log
|
|
#
|
|
# Updates the $available_t_temp that keeps track of the created
|
|
# temporary T-tables.
|
|
#
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $available_t_temp= $available_t_temp,tt_tmp_$n
|
|
}
|
|
if (`SELECT HEX(@check_temp) = HEX('')`)
|
|
{
|
|
--let $available_t_temp= tt_tmp_$n
|
|
}
|
|
--dec $n
|
|
}
|
|
|
|
#
|
|
# Creates N-tables that are automatically dropped and recreated
|
|
# when a command ends.
|
|
#
|
|
--let $n= $tot_table
|
|
while ($n)
|
|
{
|
|
--eval DROP TABLE IF EXISTS nt_$n
|
|
--eval CREATE TABLE nt_$n ( id INT ) ENGINE = MyIsam
|
|
--disable_query_log
|
|
--eval SET @check_temp='$available_n'
|
|
--enable_query_log
|
|
#
|
|
# Updates the $available_n that keeps track of the created
|
|
# N-tables.
|
|
#
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $available_n= $available_n,nt_$n
|
|
}
|
|
if (`SELECT HEX(@check_temp) = HEX('')`)
|
|
{
|
|
--let $available_n= nt_$n
|
|
}
|
|
--dec $n
|
|
}
|
|
|
|
#
|
|
# Creates T-tables that are automatically dropped and recreated
|
|
# when a command ends.
|
|
#
|
|
--let $n= $tot_table
|
|
while ($n)
|
|
{
|
|
--eval DROP TABLE IF EXISTS tt_$n
|
|
--eval CREATE TABLE tt_$n ( id INT ) ENGINE = Innodb
|
|
--disable_query_log
|
|
--eval SET @check_temp='$available_t'
|
|
--enable_query_log
|
|
#
|
|
# Updates the $available_t that keeps track of the created
|
|
# T-tables.
|
|
#
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $available_t= $available_t,tt_$n
|
|
}
|
|
if (`SELECT HEX(@check_temp) = HEX('')`)
|
|
{
|
|
--let $available_t= tt_$n
|
|
}
|
|
--dec $n
|
|
}
|
|
|
|
--let $dropped_t_temp=
|
|
--let $dropped_n_temp=
|
|
|
|
--let $dropped_t=
|
|
--let $dropped_n=
|
|
|
|
let $pos_trans_command= query_get_value("SHOW MASTER STATUS", Position, 1);
|
|
|
|
SET @commands= '';
|
|
}
|
|
|
|
#
|
|
# Drops tables and synchronizes master and slave.
|
|
#
|
|
|
|
if (`SELECT HEX(@commands) = HEX('clean')`)
|
|
{
|
|
connection master;
|
|
|
|
DROP TABLE IF EXISTS tt_xx_1;
|
|
|
|
DROP TABLE IF EXISTS nt_xx_1;
|
|
|
|
DROP TABLE IF EXISTS tt_error_1;
|
|
|
|
DROP TABLE IF EXISTS nt_error_1;
|
|
|
|
DROP TABLE IF EXISTS tt_error_2;
|
|
|
|
DROP TABLE IF EXISTS nt_error_2;
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tt_tmp_xx_1;
|
|
DROP TEMPORARY TABLE IF EXISTS nt_tmp_xx_1;
|
|
|
|
--let $n= $tot_table
|
|
while ($n)
|
|
{
|
|
--eval DROP TABLE IF EXISTS nt_$n
|
|
--eval DROP TEMPORARY TABLE IF EXISTS tt_tmp_$n
|
|
--eval DROP TEMPORARY TABLE IF EXISTS nt_tmp_$n
|
|
--dec $n
|
|
}
|
|
|
|
--let $n= $tot_table
|
|
while ($n)
|
|
{
|
|
--eval DROP TABLE IF EXISTS tt_$n
|
|
--dec $n
|
|
}
|
|
|
|
sync_slave_with_master;
|
|
|
|
SET @commands= '';
|
|
}
|
|
|
|
#
|
|
# This is the core of the test is responsible for processing
|
|
# the following commands:
|
|
#
|
|
# B - Begin
|
|
# C - Commit
|
|
# R - Rollback
|
|
#
|
|
#
|
|
# T - Inserts a row into a T-table
|
|
# N-Temp - Inserts a row into a temporary N-table.
|
|
#
|
|
#
|
|
# T-SELECT-N-Temp - Selects from a temporary N-table and inserts
|
|
# into a T-table.
|
|
# N-SELECT-N-Temp - Selects from a temporary N-table and inserts
|
|
# into a N-table.
|
|
# T-SELECT-T-Temp - Selects from a temporary T-table and inserts
|
|
# into a T-table.
|
|
# N-SELECT-T-Temp - Selects from a temporary T-table and inserts
|
|
# into a N-table.
|
|
#
|
|
#
|
|
# Create-N-Temp - Creates a temporary N-table if a temporary N-table
|
|
# was dropped before
|
|
# Create-T-Temp - Creates a temporary T-table if a temporary T-table
|
|
# was dropped before
|
|
#
|
|
#
|
|
# Drop-Temp-T-Temp - Drops a temporary T-table if there is any
|
|
# Drop-Temp-N-Temp - Drops a temporary N-table if there is any
|
|
# Drop-Temp-TN-Temp - Drops both a temporary T-table and N-table if there
|
|
# is any
|
|
# Drop-Temp-TT-Temp - Drops two temporary T-tables if there is any
|
|
# Drop-Temp-NN-Temp - Drops two temporary N-tables if there is any
|
|
# Drop-Temp-Xe-Temp - Tries to drop a temporary table that does not exist
|
|
# Drop-Temp-NXe-Temp - Drops a temporary N-table if there is any and
|
|
# a temporary table that does not exist
|
|
# Drop-Temp-TXe-Temp - Drops a temporary T-table if there is any and
|
|
# a temporary table that does not exist
|
|
#
|
|
#
|
|
# Drop-Temp-If-Xe-Temp - Tries to drop a temporary table that does not exist
|
|
# Drop-Temp-If-TXe-Temp - Drops a temporary T-table if there is any and
|
|
# a temporary table that does not exist
|
|
#
|
|
#
|
|
# Drop-T - Drops a T-table if there is any
|
|
# Drop-N - Drops a N-table if there is any
|
|
# Drop-Xe - Tries to drop a table that does not exist
|
|
# Drop-TXe - Drops a T-table if there is any and a table that does
|
|
# not exist
|
|
# Drop-NXe - Drops a N-table if there is any and a table that does
|
|
# not exist
|
|
# Drop-TN - Drops both a T-table and N-table if there is any
|
|
# Drop-TT - Drops two T-tables if there is any
|
|
# Drop-NN - Drops two N-tables if there is any
|
|
# Drop-N-TN-Temp - Drops a N-table and both a temporary T-table and
|
|
# N-table if there is any
|
|
#
|
|
#
|
|
# Drop-If-Xe - Tries to drop a table that does not exist
|
|
# Drop-If-TXe - Drops a T-table if there is any and a table that does
|
|
# not exist
|
|
# Drop-If-NXe - Drops a N-table if there is any and a table that does
|
|
# not exist
|
|
#
|
|
while (`SELECT HEX(@commands) != HEX('')`)
|
|
{
|
|
--disable_query_log
|
|
SET @command= SUBSTRING_INDEX(@commands, ' ', 1);
|
|
let $command= `SELECT @command`;
|
|
--eval SET @check_commands= '$commands'
|
|
if (`SELECT HEX(@check_commands) = HEX('''')`)
|
|
{
|
|
let $commands= `SELECT @commands`;
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('B')`)
|
|
{
|
|
--enable_query_log
|
|
eval BEGIN;
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('T')`)
|
|
{
|
|
--enable_query_log
|
|
eval INSERT INTO tt_xx_1() VALUES (1);
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('N')`)
|
|
{
|
|
--enable_query_log
|
|
eval INSERT INTO nt_xx_1() VALUES (1);
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Te')`)
|
|
{
|
|
--enable_query_log
|
|
--inc $tt_error_counter
|
|
eval INSERT INTO tt_error_1() VALUES ($tt_error_counter), ($tt_error_counter);
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Ne')`)
|
|
{
|
|
--enable_query_log
|
|
--inc $nt_error_counter
|
|
eval INSERT INTO nt_error_1() VALUES ($nt_error_counter), ($nt_error_counter);
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('NeT-trig')`)
|
|
{
|
|
--enable_query_log
|
|
--inc $nt_error_counter
|
|
eval INSERT INTO nt_error_1() VALUES ($nt_error_counter), ($nt_error_counter);
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('N-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
eval INSERT INTO nt_tmp_xx_1() VALUES (1);
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('N-SELECT-N-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
eval INSERT INTO nt_xx_1 SELECT * FROM nt_tmp_xx_1;
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('N-SELECT-T-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
eval INSERT INTO nt_xx_1 SELECT * FROM tt_tmp_xx_1;
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('T-SELECT-N-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
eval INSERT INTO tt_xx_1 SELECT * FROM nt_tmp_xx_1;
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('T-SELECT-T-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
eval INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Create-N-Temp') || HEX(@command) = HEX('Create-T-Temp')`)
|
|
{
|
|
if (`SELECT HEX(@command) = HEX('Create-N-Temp')`)
|
|
{
|
|
--let $dropped_temp=$dropped_n_temp
|
|
--let $available_temp=$available_n_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Create-T-Temp')`)
|
|
{
|
|
--let $dropped_temp=$dropped_t_temp
|
|
--let $available_temp=$available_t_temp
|
|
}
|
|
|
|
--eval SET @check_temp='$dropped_temp'
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
SET @temp= SUBSTRING_INDEX(@check_temp, ',', 1);
|
|
let $table=`SELECT @temp`;
|
|
--eval SET @check_temp='$available_temp'
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $available_temp= $available_temp,$table
|
|
}
|
|
if (`SELECT HEX(@check_temp) = HEX('')`)
|
|
{
|
|
--let $available_temp= $table
|
|
}
|
|
--eval SET @check_temp='$dropped_temp'
|
|
--eval SET @table_temp='$table'
|
|
SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
|
|
--let $dropped_temp= `SELECT @check_temp`
|
|
|
|
if (`SELECT HEX(@command) = HEX('Create-N-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
--eval CREATE TEMPORARY TABLE $table ( id INT ) engine= MyIsam
|
|
--disable_query_log
|
|
|
|
--let $available_n_temp= $available_temp
|
|
--let $dropped_n_temp= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Create-T-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
--eval CREATE TEMPORARY TABLE $table ( id INT ) engine= Innodb
|
|
--disable_query_log
|
|
|
|
--let $available_t_temp= $available_temp
|
|
--let $dropped_t_temp= $dropped_temp
|
|
}
|
|
}
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-N-Temp') || HEX(@command) = HEX('Drop-Temp-T-Temp') || HEX(@command) = HEX('Drop-T') || HEX(@command) = HEX('Drop-N')`)
|
|
{
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-N-Temp')`)
|
|
{
|
|
--let $dropped_temp=$dropped_n_temp
|
|
--let $available_temp=$available_n_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-T-Temp')`)
|
|
{
|
|
--let $dropped_temp=$dropped_t_temp
|
|
--let $available_temp=$available_t_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-N')`)
|
|
{
|
|
--let $dropped_temp=$dropped_n
|
|
--let $available_temp=$available_n
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-T')`)
|
|
{
|
|
--let $dropped_temp=$dropped_t
|
|
--let $available_temp=$available_t
|
|
}
|
|
|
|
--eval SET @check_temp='$available_temp'
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
SET @temp= SUBSTRING_INDEX(@check_temp, ',', 1);
|
|
let $table=`SELECT @temp`;
|
|
--eval SET @check_temp='$dropped_temp'
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $dropped_temp= $dropped_temp,$table
|
|
}
|
|
if (`SELECT HEX(@check_temp) = HEX('')`)
|
|
{
|
|
--let $dropped_temp= $table
|
|
}
|
|
--eval SET @check_temp='$available_temp'
|
|
--eval SET @table_temp='$table'
|
|
SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
|
|
--let $available_temp= `SELECT @check_temp`
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-N-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TEMPORARY TABLE $table
|
|
--disable_query_log
|
|
|
|
--let $available_n_temp= $available_temp
|
|
--let $dropped_n_temp= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-T-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TEMPORARY TABLE $table
|
|
--disable_query_log
|
|
|
|
--let $available_t_temp= $available_temp
|
|
--let $dropped_t_temp= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-N')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TABLE $table
|
|
--disable_query_log
|
|
|
|
--let $available_n= $available_temp
|
|
--let $dropped_n= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-T')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TABLE $table
|
|
--disable_query_log
|
|
|
|
--let $available_t= $available_temp
|
|
--let $dropped_t= $dropped_temp
|
|
}
|
|
}
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-Xe-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TEMPORARY TABLE tt_xx_1
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-If-Xe-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TEMPORARY TABLE IF EXISTS tt_xx_1
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-Xe')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TABLE xx_1
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-If-Xe')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TABLE IF EXISTS xx_1
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-NXe-Temp') || HEX(@command) = HEX('Drop-Temp-TXe-Temp') || HEX(@command) = HEX('Drop-NXe') || HEX(@command) = HEX('Drop-TXe') || HEX(@command) = HEX('Drop-Temp-If-NXe-Temp') || HEX(@command) = HEX('Drop-Temp-If-TXe-Temp') || HEX(@command) = HEX('Drop-If-NXe') || HEX(@command) = HEX('Drop-If-TXe')`)
|
|
{
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-NXe-Temp') || HEX(@command) = HEX('Drop-Temp-If-NXe-Temp')`)
|
|
{
|
|
--let $dropped_temp=$dropped_n_temp
|
|
--let $available_temp=$available_n_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-TXe-Temp') || HEX(@command) = HEX('Drop-Temp-If-TXe-Temp')`)
|
|
{
|
|
--let $dropped_temp=$dropped_t_temp
|
|
--let $available_temp=$available_t_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-NXe') || HEX(@command) = HEX('Drop-If-NXe')`)
|
|
{
|
|
--let $dropped_temp=$dropped_n
|
|
--let $available_temp=$available_n
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-TXe') || HEX(@command) = HEX('Drop-If-TXe')`)
|
|
{
|
|
--let $dropped_temp=$dropped_t
|
|
--let $available_temp=$available_t
|
|
}
|
|
|
|
--eval SET @check_temp='$available_temp'
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
SET @temp= SUBSTRING_INDEX(@check_temp, ',', 1);
|
|
let $table=`SELECT @temp`;
|
|
--eval SET @check_temp='$dropped_temp'
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $dropped_temp= $dropped_temp,$table
|
|
}
|
|
if (`SELECT HEX(@check_temp) = HEX('')`)
|
|
{
|
|
--let $dropped_n_temp= $table
|
|
}
|
|
--eval SET @check_temp='$available_temp'
|
|
--eval SET @table_temp='$table'
|
|
SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
|
|
--let $available_temp= `SELECT @check_temp`
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-NXe-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TEMPORARY TABLE $table, tt_1
|
|
--disable_query_log
|
|
|
|
--let $available_n_temp= $available_temp
|
|
--let $dropped_n_temp= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-If-NXe-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TEMPORARY TABLE IF EXISTS $table, tt_1
|
|
--disable_query_log
|
|
|
|
--let $available_n_temp= $available_temp
|
|
--let $dropped_n_temp= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-TXe-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TEMPORARY TABLE $table, tt_1
|
|
--disable_query_log
|
|
|
|
--let $available_t_temp= $available_temp
|
|
--let $dropped_t_temp= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-If-TXe-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TEMPORARY TABLE IF EXISTS $table, tt_1
|
|
--disable_query_log
|
|
|
|
--let $available_t_temp= $available_temp
|
|
--let $dropped_t_temp= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-NXe')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TABLE $table, xx_1
|
|
--disable_query_log
|
|
|
|
--let $available_n= $available_temp
|
|
--let $dropped_n= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-If-NXe')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TABLE IF EXISTS $table, xx_1
|
|
--disable_query_log
|
|
|
|
--let $available_n= $available_temp
|
|
--let $dropped_n= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-TXe')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TABLE $table, xx_1
|
|
--disable_query_log
|
|
|
|
--let $available_t= $available_temp
|
|
--let $dropped_t= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-If-TXe')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TABLE IF EXISTS $table, xx_1
|
|
--disable_query_log
|
|
|
|
--let $available_t= $available_temp
|
|
--let $dropped_t= $dropped_temp
|
|
}
|
|
}
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-NN-Temp') || HEX(@command) = HEX('Drop-Temp-TT-Temp') || HEX(@command) = HEX('Drop-NN') || HEX(@command) = HEX('Drop-TT')`)
|
|
{
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-NN-Temp')`)
|
|
{
|
|
--let $dropped_temp=$dropped_n_temp
|
|
--let $available_temp=$available_n_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-TT-Temp')`)
|
|
{
|
|
--let $dropped_temp=$dropped_t_temp
|
|
--let $available_temp=$available_t_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-NN')`)
|
|
{
|
|
--let $dropped_temp=$dropped_n
|
|
--let $available_temp=$available_n
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-TT')`)
|
|
{
|
|
--let $dropped_temp=$dropped_t
|
|
--let $available_temp=$available_t
|
|
}
|
|
|
|
--eval SET @check_temp='$available_temp'
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $n= 2
|
|
while (`SELECT HEX(@check_temp) != HEX('') && $n != 0`)
|
|
{
|
|
SET @temp= SUBSTRING_INDEX(@check_temp, ',', 1);
|
|
let $table=`SELECT @temp`;
|
|
--eval SET @check_temp='$dropped_temp'
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $dropped_temp= $dropped_temp,$table
|
|
}
|
|
if (`SELECT HEX(@check_temp) = HEX('')`)
|
|
{
|
|
--let $dropped_temp= $table
|
|
}
|
|
if ($n == 1)
|
|
{
|
|
--let $table_1= $table
|
|
}
|
|
if ($n == 2)
|
|
{
|
|
--let $table_2= $table
|
|
}
|
|
|
|
--dec $n
|
|
--eval SET @check_temp='$available_temp'
|
|
--eval SET @table_temp='$table'
|
|
SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
|
|
--let $available_temp= `SELECT @check_temp`
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-NN-Temp') && $n = 0`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TEMPORARY TABLE $table_1, $table_2
|
|
--disable_query_log
|
|
|
|
--let $available_n_temp= $available_temp
|
|
--let $dropped_n_temp= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-TT-Temp') && $n= 0`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TEMPORARY TABLE $table_1, $table_2
|
|
--disable_query_log
|
|
|
|
--let $available_t_temp= $available_temp
|
|
--let $dropped_t_temp= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-NN') && $n = 0`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TABLE $table_1, $table_2
|
|
--disable_query_log
|
|
|
|
--let $available_n= $available_temp
|
|
--let $dropped_n= $dropped_temp
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-TT') && $n= 0`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TABLE $table_1, $table_2
|
|
--disable_query_log
|
|
|
|
--let $available_t= $available_temp
|
|
--let $dropped_t= $dropped_temp
|
|
}
|
|
}
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-Temp-TN-Temp')`)
|
|
{
|
|
--eval SET @check_temp_t='$available_t_temp'
|
|
--eval SET @check_temp_n='$available_n_temp'
|
|
if (`SELECT HEX(@check_temp_t) != HEX('') && HEX(@check_temp_n) != HEX('')`)
|
|
{
|
|
SET @temp_t= SUBSTRING_INDEX(@check_temp_t, ',', 1);
|
|
let $table_t=`SELECT @temp_t`;
|
|
--eval SET @check_temp_t='$dropped_t_temp'
|
|
if (`SELECT HEX(@check_temp_t) != HEX('')`)
|
|
{
|
|
--let $dropped_t_temp= $dropped_t_temp,$table_t
|
|
}
|
|
if (`SELECT HEX(@check_temp_t) = HEX('')`)
|
|
{
|
|
--let $dropped_t_temp= $table_t
|
|
}
|
|
--eval SET @check_temp='$available_t_temp'
|
|
--eval SET @table_temp='$table_t'
|
|
SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
|
|
--let $available_t_temp= `SELECT @check_temp`
|
|
|
|
SET @temp_n= SUBSTRING_INDEX(@check_temp_n, ',', 1);
|
|
let $table_n=`SELECT @temp_n`;
|
|
--eval SET @check_temp_n='$dropped_n_temp'
|
|
if (`SELECT HEX(@check_temp_n) != HEX('')`)
|
|
{
|
|
--let $dropped_n_temp= $dropped_n_temp,$table_n
|
|
}
|
|
if (`SELECT HEX(@check_temp_n) = HEX('')`)
|
|
{
|
|
--let $dropped_n_temp= $table_n
|
|
}
|
|
--eval SET @check_temp='$available_n_temp'
|
|
--eval SET @table_temp='$table_n'
|
|
SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
|
|
--let $available_n_temp= `SELECT @check_temp`
|
|
|
|
--enable_query_log
|
|
--eval DROP TEMPORARY TABLE $table_t, $table_n
|
|
--disable_query_log
|
|
}
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-TN')`)
|
|
{
|
|
--eval SET @check_temp_t='$available_t'
|
|
--eval SET @check_temp_n='$available_n'
|
|
if (`SELECT HEX(@check_temp_t) != HEX('') && HEX(@check_temp_n) != HEX('')`)
|
|
{
|
|
SET @temp_t= SUBSTRING_INDEX(@check_temp_t, ',', 1);
|
|
let $table_t=`SELECT @temp_t`;
|
|
--eval SET @check_temp_t='$dropped_t'
|
|
if (`SELECT HEX(@check_temp_t) != HEX('')`)
|
|
{
|
|
--let $dropped_t= $dropped_t,$table_t
|
|
}
|
|
if (`SELECT HEX(@check_temp_t) = HEX('')`)
|
|
{
|
|
--let $dropped_t= $table_t
|
|
}
|
|
--eval SET @check_temp='$available_t'
|
|
--eval SET @table_temp='$table_t'
|
|
SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
|
|
--let $available_t= `SELECT @check_temp`
|
|
|
|
SET @temp_n= SUBSTRING_INDEX(@check_temp_n, ',', 1);
|
|
let $table_n=`SELECT @temp_n`;
|
|
--eval SET @check_temp_n='$dropped_n'
|
|
if (`SELECT HEX(@check_temp_n) != HEX('')`)
|
|
{
|
|
--let $dropped_n= $dropped_n,$table_n
|
|
}
|
|
if (`SELECT HEX(@check_temp_n) = HEX('')`)
|
|
{
|
|
--let $dropped_n= $table_n
|
|
}
|
|
--eval SET @check_temp='$available_n'
|
|
--eval SET @table_temp='$table_n'
|
|
SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
|
|
--let $available_t= `SELECT @check_temp`
|
|
|
|
--enable_query_log
|
|
--eval DROP TABLE $table_t, $table_n
|
|
--disable_query_log
|
|
}
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-N-TN-Temp') || HEX(@command) = HEX('Drop-TN-Temp')`)
|
|
{
|
|
--eval SET @check_temp_t='$available_t_temp'
|
|
--eval SET @check_temp_n='$available_n_temp'
|
|
if (`SELECT HEX(@command) = HEX('Drop-N-TN-Temp')`)
|
|
{
|
|
--eval SET @check_n='$available_n'
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-TN-Temp')`)
|
|
{
|
|
#
|
|
# Just to be possible to go through the next if...
|
|
#
|
|
--eval SET @check_n='...'
|
|
}
|
|
if (`SELECT HEX(@check_temp_t) != HEX('') && HEX(@check_temp_n) != HEX('') && HEX(@check_n) != HEX('')`)
|
|
{
|
|
SET @temp_t= SUBSTRING_INDEX(@check_temp_t, ',', 1);
|
|
let $table_temp_t=`SELECT @temp_t`;
|
|
--eval SET @check_temp_t='$dropped_t_temp'
|
|
if (`SELECT HEX(@check_temp_t) != HEX('')`)
|
|
{
|
|
--let $dropped_t_temp= $dropped_t_temp,$table_temp_t
|
|
}
|
|
if (`SELECT HEX(@check_temp_t) = HEX('')`)
|
|
{
|
|
--let $dropped_t_temp= $table_temp_t
|
|
}
|
|
--eval SET @check_temp='$available_t_temp'
|
|
--eval SET @table_temp='$table_temp_t'
|
|
SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
|
|
--let $available_t_temp= `SELECT @check_temp`
|
|
|
|
SET @temp_n= SUBSTRING_INDEX(@check_temp_n, ',', 1);
|
|
let $table_temp_n=`SELECT @temp_n`;
|
|
--eval SET @check_temp_n='$dropped_n_temp'
|
|
if (`SELECT HEX(@check_temp_n) != HEX('')`)
|
|
{
|
|
--let $dropped_n_temp= $dropped_n_temp,$table_temp_n
|
|
}
|
|
if (`SELECT HEX(@check_temp_n) = HEX('')`)
|
|
{
|
|
--let $dropped_n_temp= $table_temp_n
|
|
}
|
|
--eval SET @check_temp='$available_n_temp'
|
|
--eval SET @table_temp='$table_temp_n'
|
|
SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
|
|
--let $available_n_temp= `SELECT @check_temp`
|
|
|
|
if (`SELECT HEX(@command) = HEX('Drop-N-TN-Temp')`)
|
|
{
|
|
SET @temp_n= SUBSTRING_INDEX(@check_n, ',', 1);
|
|
let $table_n=`SELECT @temp_n`;
|
|
--eval SET @check_n='$dropped_n'
|
|
if (`SELECT HEX(@check_n) != HEX('')`)
|
|
{
|
|
--let $dropped_n= $dropped_n,$table_n
|
|
}
|
|
if (`SELECT HEX(@check_n) = HEX('')`)
|
|
{
|
|
--let $dropped_n= $table_n
|
|
}
|
|
--eval SET @check_temp='$available_n'
|
|
--eval SET @table_temp='$table_n'
|
|
SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
|
|
--let $available_n= `SELECT @check_temp`
|
|
|
|
--enable_query_log
|
|
--eval DROP TABLE $table_temp_t, $table_temp_n, $table_n
|
|
--disable_query_log
|
|
}
|
|
if (`SELECT HEX(@command) = HEX('Drop-TN-Temp')`)
|
|
{
|
|
--enable_query_log
|
|
--eval DROP TABLE $table_temp_t, $table_temp_n
|
|
--disable_query_log
|
|
}
|
|
}
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('C')`)
|
|
{
|
|
--enable_query_log
|
|
--error 0, ER_GET_ERRMSG
|
|
eval COMMIT;
|
|
--disable_query_log
|
|
}
|
|
|
|
if (`SELECT HEX(@command) = HEX('R')`)
|
|
{
|
|
--enable_query_log
|
|
--error 0, ER_GET_ERRMSG
|
|
--replace_column 2 #
|
|
eval ROLLBACK;
|
|
--disable_query_log
|
|
}
|
|
|
|
SET @commands= LTRIM(SUBSTRING(@commands, LENGTH(@command) + 1));
|
|
if (`SELECT HEX(@commands) = HEX('')`)
|
|
{
|
|
let $binlog_start= $pos_trans_command;
|
|
--echo -b-b-b-b-b-b-b-b-b-b-b- >> $commands << -b-b-b-b-b-b-b-b-b-b-b-
|
|
# Use other connection because include/show_binlog_events.inc
|
|
# executes SELECT UUID(), which switches to row-logging when
|
|
# binlog_format=mixed, if there are open temporary tables. This is
|
|
# due to BUG#13692513.
|
|
--connection server_1
|
|
--source include/show_binlog_events.inc
|
|
connection master;
|
|
let $master_tt_xx_count=`select count(*) from tt_xx_1`;
|
|
let $master_nt_xx_count=`select count(*) from nt_xx_1`;
|
|
sync_slave_with_master;
|
|
let $slave_tt_xx_count=`select count(*) from tt_xx_1`;
|
|
let $slave_nt_xx_count=`select count(*) from nt_xx_1`;
|
|
if ($slave_tt_xx_count != $master_tt_xx_count)
|
|
{
|
|
--echo # Error: Data mismatch in tt_xx_1: Master: $master_tt_xx_count rows Slave: $slave_tt_xx_count rows
|
|
}
|
|
if ($slave_nt_xx_count != $master_nt_xx_count)
|
|
{
|
|
--echo # Error: Data mismatch in nt_xx_1: Master: $master_nt_xx_count rows Slave: $slave_nt_xx_count rows
|
|
}
|
|
--connection master
|
|
--echo -e-e-e-e-e-e-e-e-e-e-e- >> $commands << -e-e-e-e-e-e-e-e-e-e-e-
|
|
--echo
|
|
|
|
--disable_warnings
|
|
--let $available_n_temp=
|
|
--let $dropped_n_temp=
|
|
--let $n= $tot_table
|
|
while ($n)
|
|
{
|
|
--eval DROP TEMPORARY TABLE IF EXISTS nt_tmp_$n
|
|
--eval CREATE TEMPORARY TABLE nt_tmp_$n ( id INT ) ENGINE = MyIsam
|
|
--eval SET @check_temp='$available_n_temp'
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $available_n_temp= $available_n_temp,nt_tmp_$n
|
|
}
|
|
if (`SELECT HEX(@check_temp) = HEX('')`)
|
|
{
|
|
--let $available_n_temp= nt_tmp_$n
|
|
}
|
|
--dec $n
|
|
}
|
|
|
|
--let $available_t_temp=
|
|
--let $dropped_t_temp=
|
|
--let $n= $tot_table
|
|
while ($n)
|
|
{
|
|
--eval DROP TEMPORARY TABLE IF EXISTS tt_tmp_$n
|
|
--eval CREATE TEMPORARY TABLE tt_tmp_$n ( id INT ) ENGINE = Innodb
|
|
--eval SET @check_temp='$available_t_temp'
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $available_t_temp= $available_t_temp,tt_tmp_$n
|
|
}
|
|
if (`SELECT HEX(@check_temp) = HEX('')`)
|
|
{
|
|
--let $available_t_temp= tt_tmp_$n
|
|
}
|
|
--dec $n
|
|
}
|
|
|
|
--let $available_t=
|
|
--let $dropped_t=
|
|
--let $n= $tot_table
|
|
while ($n)
|
|
{
|
|
--eval DROP TABLE IF EXISTS tt_$n
|
|
--eval CREATE TABLE tt_$n ( id INT ) ENGINE = Innodb
|
|
--eval SET @check_temp='$available_t'
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $available_t= $available_t,tt_$n
|
|
}
|
|
if (`SELECT HEX(@check_temp) = HEX('')`)
|
|
{
|
|
--let $available_t= tt_$n
|
|
}
|
|
--dec $n
|
|
}
|
|
|
|
--let $available_n=
|
|
--let $dropped_n=
|
|
--let $n= $tot_table
|
|
while ($n)
|
|
{
|
|
--eval DROP TABLE IF EXISTS nt_$n
|
|
--eval CREATE TABLE nt_$n ( id INT ) ENGINE = MyIsam
|
|
--eval SET @check_temp='$available_n'
|
|
if (`SELECT HEX(@check_temp) != HEX('')`)
|
|
{
|
|
--let $available_n= $available_n,nt_$n
|
|
}
|
|
if (`SELECT HEX(@check_temp) = HEX('')`)
|
|
{
|
|
--let $available_n= nt_$n
|
|
}
|
|
--dec $n
|
|
}
|
|
truncate table tt_xx_1;
|
|
truncate table nt_xx_1;
|
|
--enable_warnings
|
|
|
|
let $pos_trans_command= query_get_value("SHOW MASTER STATUS", Position, 1);
|
|
let $commands= '';
|
|
}
|
|
--enable_query_log
|
|
}
|