mariadb/mysql-test/suite/rpl/r/rpl_variables_stm.result

527 lines
22 KiB
Text
Raw Normal View History

BUG#31168: @@hostname does not replicate Problem: in mixed and statement mode, a query that refers to a system variable will use the slave's value when replayed on slave. So if the value of a system variable is inserted into a table, the slave will differ from the master. Fix: mark statements that refer to a system variable as "unsafe", meaning they will be replicated by row in mixed mode and produce a warning in statement mode. There are some exceptions: some variables are actually replicated. Those should *not* be marked as unsafe. BUG#34732: mysqlbinlog does not print default values for auto_increment variables Problem: mysqlbinlog does not print default values for some variables, including auto_increment_increment and others. So if a client executing the output of mysqlbinlog has different default values, replication will be wrong. Fix: Always print default values for all variables that are replicated. I need to fix the two bugs at the same time, because the test cases would fail if I only fixed one of them. include/m_ctype.h: Added definition of ILLEGAL_CHARSET_INFO_NUMBER. We just need a symbol for a number that will never be used by any charset. ~0U should be safe since charset numbers are sequential, starting from 0. mysql-test/include/commit.inc: Upated test to avoid making statements unsafe. mysql-test/r/commit_1innodb.result: Updated test needs updated result file. mysql-test/r/mysqlbinlog.result: Updated result file. mysql-test/r/mysqlbinlog2.result: Updated result file. mysql-test/r/user_var-binlog.result: Updated result file. mysql-test/suite/binlog/r/binlog_base64_flag.result: Updated result file. mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result: Updated result file. mysql-test/suite/binlog/r/binlog_unsafe.result: Modified test file needs modified result file. mysql-test/suite/binlog/t/binlog_base64_flag.test: Need to filter out pseudo_thread_id from result since it is nondeterministic. mysql-test/suite/binlog/t/binlog_unsafe.test: Add tests that using variables is unsafe. The 'CREATE VIEW' tests didn't make sense, so I removed them. SHOW WARNINGS is not necessary either, because we get warnings for each statement in the result file. mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result: Updated result file. mysql-test/suite/rpl/r/rpl_skip_error.result: Updated result file. mysql-test/suite/rpl/t/rpl_skip_error.test: The test used @@server_id, which is not safe to replicate, so it would have given a warning. The way it used @@server_id was hackish (issue a query on master that removes rows only on master), so I replaced it by a more robust way to do the same thing (connect to slave and insert the rows only there). Also clarified what the test case does. mysql-test/t/mysqlbinlog2.test: Use --short-form instead of manually filtering out nondeterministic stuff from mysqlbinlog (because we added the nondeterministic @@pseudo_thread_id to the output). sql/item_func.cc: Added method of Item_func_get_system_var that indicates whether the given system variable will be written to the binlog or not. sql/item_func.h: Added method of Item_func_get_system_var that indicates whether the given system variable will be written to the binlog or not. sql/log_event.cc: - auto_increment_offset was not written to the binlog if auto_increment_increment=1 - mysqlbinlog did not output default values for some variables (BUG#34732). In st_print_event_info, we remember for each variable whether it has been printed or not. This is achieved in different ways for different variables: - For auto_increment_*, lc_time_names, charset_database_number, we set the default values in st_print_event_info to something illegal, so that it will look like they have changed the first time they are seen. - For charset, sql_mode, pseudo_thread_id, we add a flag to st_print_event_info which indicates whether the variable has been printed. - Since pseudo_thread_id is now printed more often, and its value is not guaranteed to be constant across different runs of the same test script, I replaced it by a constant if --short-form is used. - Moved st_print_event_info constructor from log_event.h to log_event.cc, since it now depends on ILLEGAL_CHARSET_NUMBER, which is defined in m_ctype.h, which is better to include from a .cc file than from a header file. sql/log_event.h: Added fields to st_print_event_info that indicate whether some of the variables have been written or not. Since the initialization of charset_database_number now depends on ILLEGAL_CHARSET_INFO_NUMBER, which is defined in a header file, which we'd better not include from this header file -- I moved the constructor from here to log_event.cc. sql/set_var.cc: System variables now have a flag binlog_status, which indicates if they are written to the binlog. If nothing is specified, all variables are marked as not written to the binlog (NOT_IN_BINLOG) when created. In this file, the variables that are written to the binlog are marked with SESSION_VARIABLE_IN_BINLOG. sql/set_var.h: Added flag binlog_status to class sys_var. Added a getter and a constructor parameter that sets it. Since I had to change sys_var_thd_enum constructor anyways, I simplified it to use default values of arguments instead of three copies of the constructor. sql/sql_yacc.yy: Mark statements that refer to a system variable as "unsafe", meaning they will be replicated by row in mixed mode. Added comment to explain strange piece of code just above. mysql-test/include/diff_tables.inc: New auxiliary test file that tests whether two tables (possibly one on master and one on slave) differ. mysql-test/suite/rpl/r/rpl_variables.result: New test case needs new result file. mysql-test/suite/rpl/r/rpl_variables_stm.result: New test file needs new result file. mysql-test/suite/rpl/t/rpl_variables.test: Test that INSERT of @@variables is replicated correctly (by switching to row-based mode). mysql-test/suite/rpl/t/rpl_variables_stm.test: Test that replication of @@variables which are replicated explicitly works as expected in statement mode (without giving warnings).
2008-03-07 13:59:36 +01:00
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
==== Initialization ====
[on master]
SET @m_pseudo_thread_id= @@global.pseudo_thread_id;
SET @m_auto_increment_increment= @@global.auto_increment_increment;
SET @m_auto_increment_offset= @@global.auto_increment_offset;
SET @m_character_set_client= @@global.character_set_client;
SET @m_collation_connection= @@global.collation_connection;
SET @m_collation_server= @@global.collation_server;
SET @m_time_zone= @@global.time_zone;
SET @m_lc_time_names= @@global.lc_time_names;
SET @m_collation_database= @@global.collation_database;
[on slave]
SET @s_pseudo_thread_id= @@global.pseudo_thread_id;
SET @s_auto_increment_increment= @@global.auto_increment_increment;
SET @s_auto_increment_offset= @@global.auto_increment_offset;
SET @s_character_set_client= @@global.character_set_client;
SET @s_collation_connection= @@global.collation_connection;
SET @s_collation_server= @@global.collation_server;
SET @s_time_zone= @@global.time_zone;
SET @s_lc_time_names= @@global.lc_time_names;
SET @s_collation_database= @@global.collation_database;
SET @@global.pseudo_thread_id= 4711;
SET @@global.auto_increment_increment=19;
SET @@global.auto_increment_offset=4;
SET @@global.character_set_client='latin2';
SET @@global.collation_connection='latin2_bin';
BUG#31168: @@hostname does not replicate Problem: in mixed and statement mode, a query that refers to a system variable will use the slave's value when replayed on slave. So if the value of a system variable is inserted into a table, the slave will differ from the master. Fix: mark statements that refer to a system variable as "unsafe", meaning they will be replicated by row in mixed mode and produce a warning in statement mode. There are some exceptions: some variables are actually replicated. Those should *not* be marked as unsafe. BUG#34732: mysqlbinlog does not print default values for auto_increment variables Problem: mysqlbinlog does not print default values for some variables, including auto_increment_increment and others. So if a client executing the output of mysqlbinlog has different default values, replication will be wrong. Fix: Always print default values for all variables that are replicated. I need to fix the two bugs at the same time, because the test cases would fail if I only fixed one of them. include/m_ctype.h: Added definition of ILLEGAL_CHARSET_INFO_NUMBER. We just need a symbol for a number that will never be used by any charset. ~0U should be safe since charset numbers are sequential, starting from 0. mysql-test/include/commit.inc: Upated test to avoid making statements unsafe. mysql-test/r/commit_1innodb.result: Updated test needs updated result file. mysql-test/r/mysqlbinlog.result: Updated result file. mysql-test/r/mysqlbinlog2.result: Updated result file. mysql-test/r/user_var-binlog.result: Updated result file. mysql-test/suite/binlog/r/binlog_base64_flag.result: Updated result file. mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result: Updated result file. mysql-test/suite/binlog/r/binlog_unsafe.result: Modified test file needs modified result file. mysql-test/suite/binlog/t/binlog_base64_flag.test: Need to filter out pseudo_thread_id from result since it is nondeterministic. mysql-test/suite/binlog/t/binlog_unsafe.test: Add tests that using variables is unsafe. The 'CREATE VIEW' tests didn't make sense, so I removed them. SHOW WARNINGS is not necessary either, because we get warnings for each statement in the result file. mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result: Updated result file. mysql-test/suite/rpl/r/rpl_skip_error.result: Updated result file. mysql-test/suite/rpl/t/rpl_skip_error.test: The test used @@server_id, which is not safe to replicate, so it would have given a warning. The way it used @@server_id was hackish (issue a query on master that removes rows only on master), so I replaced it by a more robust way to do the same thing (connect to slave and insert the rows only there). Also clarified what the test case does. mysql-test/t/mysqlbinlog2.test: Use --short-form instead of manually filtering out nondeterministic stuff from mysqlbinlog (because we added the nondeterministic @@pseudo_thread_id to the output). sql/item_func.cc: Added method of Item_func_get_system_var that indicates whether the given system variable will be written to the binlog or not. sql/item_func.h: Added method of Item_func_get_system_var that indicates whether the given system variable will be written to the binlog or not. sql/log_event.cc: - auto_increment_offset was not written to the binlog if auto_increment_increment=1 - mysqlbinlog did not output default values for some variables (BUG#34732). In st_print_event_info, we remember for each variable whether it has been printed or not. This is achieved in different ways for different variables: - For auto_increment_*, lc_time_names, charset_database_number, we set the default values in st_print_event_info to something illegal, so that it will look like they have changed the first time they are seen. - For charset, sql_mode, pseudo_thread_id, we add a flag to st_print_event_info which indicates whether the variable has been printed. - Since pseudo_thread_id is now printed more often, and its value is not guaranteed to be constant across different runs of the same test script, I replaced it by a constant if --short-form is used. - Moved st_print_event_info constructor from log_event.h to log_event.cc, since it now depends on ILLEGAL_CHARSET_NUMBER, which is defined in m_ctype.h, which is better to include from a .cc file than from a header file. sql/log_event.h: Added fields to st_print_event_info that indicate whether some of the variables have been written or not. Since the initialization of charset_database_number now depends on ILLEGAL_CHARSET_INFO_NUMBER, which is defined in a header file, which we'd better not include from this header file -- I moved the constructor from here to log_event.cc. sql/set_var.cc: System variables now have a flag binlog_status, which indicates if they are written to the binlog. If nothing is specified, all variables are marked as not written to the binlog (NOT_IN_BINLOG) when created. In this file, the variables that are written to the binlog are marked with SESSION_VARIABLE_IN_BINLOG. sql/set_var.h: Added flag binlog_status to class sys_var. Added a getter and a constructor parameter that sets it. Since I had to change sys_var_thd_enum constructor anyways, I simplified it to use default values of arguments instead of three copies of the constructor. sql/sql_yacc.yy: Mark statements that refer to a system variable as "unsafe", meaning they will be replicated by row in mixed mode. Added comment to explain strange piece of code just above. mysql-test/include/diff_tables.inc: New auxiliary test file that tests whether two tables (possibly one on master and one on slave) differ. mysql-test/suite/rpl/r/rpl_variables.result: New test case needs new result file. mysql-test/suite/rpl/r/rpl_variables_stm.result: New test file needs new result file. mysql-test/suite/rpl/t/rpl_variables.test: Test that INSERT of @@variables is replicated correctly (by switching to row-based mode). mysql-test/suite/rpl/t/rpl_variables_stm.test: Test that replication of @@variables which are replicated explicitly works as expected in statement mode (without giving warnings).
2008-03-07 13:59:36 +01:00
SET @@global.collation_server='geostd8_general_ci';
SET @@global.time_zone='Japan';
SET @@global.lc_time_names='sv_SE';
SET @@global.collation_database='geostd8_bin';
[on master]
CREATE TABLE tstmt (id INT AUTO_INCREMENT PRIMARY KEY,
num INT,
text VARCHAR(100));
CREATE TABLE tproc LIKE tstmt;
CREATE TABLE tfunc LIKE tstmt;
CREATE TABLE ttrig LIKE tstmt;
CREATE TABLE tprep LIKE tstmt;
CREATE TABLE trigger_table (text CHAR(4));
==== Insert variables directly ====
SET @@pseudo_thread_id= 4712;
INSERT INTO tstmt(num) VALUES (@@session.pseudo_thread_id);
SET @@pseudo_thread_id= 4713;
INSERT INTO tstmt(num) VALUES (@@session.pseudo_thread_id);
SET @@foreign_key_checks= 0;
INSERT INTO tstmt(num) VALUES (@@session.foreign_key_checks);
SET @@foreign_key_checks= 1;
INSERT INTO tstmt(num) VALUES (@@session.foreign_key_checks);
SET @@sql_auto_is_null= 0;
INSERT INTO tstmt(num) VALUES (@@session.sql_auto_is_null);
SET @@sql_auto_is_null= 1;
INSERT INTO tstmt(num) VALUES (@@session.sql_auto_is_null);
SET @@unique_checks= 0;
INSERT INTO tstmt(num) VALUES (@@session.unique_checks);
SET @@unique_checks= 1;
INSERT INTO tstmt(num) VALUES (@@session.unique_checks);
SET @@auto_increment_increment= 11;
INSERT INTO tstmt(num) VALUES (@@session.auto_increment_increment);
SET @@auto_increment_increment= 19;
INSERT INTO tstmt(num) VALUES (@@session.auto_increment_increment);
SET @@auto_increment_offset= 13;
INSERT INTO tstmt(num) VALUES (@@session.auto_increment_offset);
SET @@auto_increment_offset= 17;
INSERT INTO tstmt(num) VALUES (@@session.auto_increment_offset);
SET @@auto_increment_increment= 1;
SET @@auto_increment_offset= 1;
SET @@character_set_client= 'cp1257';
INSERT INTO tstmt(text) VALUES (@@session.character_set_client);
SET @@character_set_client= 'cp1256';
INSERT INTO tstmt(text) VALUES (@@session.character_set_client);
SET @@collation_connection= 'cp1251_ukrainian_ci';
INSERT INTO tstmt(text) VALUES (@@session.collation_connection);
INSERT INTO tstmt(text) VALUES (@@session.character_set_connection);
SET @@collation_connection= 'cp1251_bulgarian_ci';
INSERT INTO tstmt(text) VALUES (@@session.collation_connection);
INSERT INTO tstmt(text) VALUES (@@session.character_set_connection);
SET @@collation_server= 'latin7_bin';
INSERT INTO tstmt(text) VALUES (@@session.collation_server);
INSERT INTO tstmt(text) VALUES (@@session.character_set_server);
SET @@collation_server= 'latin7_general_cs';
INSERT INTO tstmt(text) VALUES (@@session.collation_server);
INSERT INTO tstmt(text) VALUES (@@session.character_set_server);
SET @@time_zone= 'Europe/Moscow';
INSERT INTO tstmt(text) VALUES (@@session.time_zone);
SET @@time_zone= 'Universal';
INSERT INTO tstmt(text) VALUES (@@session.time_zone);
SET @@lc_time_names= 'sv_FI';
INSERT INTO tstmt(text) VALUES (@@session.lc_time_names);
SET @@lc_time_names= 'no_NO';
INSERT INTO tstmt(text) VALUES (@@session.lc_time_names);
SET @@collation_database= 'latin7_general_ci';
INSERT INTO tstmt(text) VALUES (@@session.collation_database);
INSERT INTO tstmt(text) VALUES (@@session.character_set_database);
SET @@collation_database= 'latin7_estonian_cs';
INSERT INTO tstmt(text) VALUES (@@session.collation_database);
INSERT INTO tstmt(text) VALUES (@@session.character_set_database);
SET @@timestamp= 47114711;
INSERT INTO tstmt(text) VALUES (@@session.timestamp);
SET @@timestamp= 47124712;
INSERT INTO tstmt(text) VALUES (@@session.timestamp);
SET @@last_insert_id= 1616;
INSERT INTO tstmt(text) VALUES (@@session.last_insert_id);
SET @@last_insert_id= 1717;
INSERT INTO tstmt(text) VALUES (@@session.last_insert_id);
==== Insert variables from a stored procedure ====
CREATE PROCEDURE proc()
BEGIN
SET @@pseudo_thread_id= 4712;
INSERT INTO tproc(num) VALUES (@@session.pseudo_thread_id);
SET @@pseudo_thread_id= 4713;
INSERT INTO tproc(num) VALUES (@@session.pseudo_thread_id);
SET @@foreign_key_checks= 0;
INSERT INTO tproc(num) VALUES (@@session.foreign_key_checks);
SET @@foreign_key_checks= 1;
INSERT INTO tproc(num) VALUES (@@session.foreign_key_checks);
SET @@sql_auto_is_null= 0;
INSERT INTO tproc(num) VALUES (@@session.sql_auto_is_null);
SET @@sql_auto_is_null= 1;
INSERT INTO tproc(num) VALUES (@@session.sql_auto_is_null);
SET @@unique_checks= 0;
INSERT INTO tproc(num) VALUES (@@session.unique_checks);
SET @@unique_checks= 1;
INSERT INTO tproc(num) VALUES (@@session.unique_checks);
SET @@auto_increment_increment= 11;
INSERT INTO tproc(num) VALUES (@@session.auto_increment_increment);
SET @@auto_increment_increment= 19;
INSERT INTO tproc(num) VALUES (@@session.auto_increment_increment);
SET @@auto_increment_offset= 13;
INSERT INTO tproc(num) VALUES (@@session.auto_increment_offset);
SET @@auto_increment_offset= 17;
INSERT INTO tproc(num) VALUES (@@session.auto_increment_offset);
# reset these as they affect the index column
SET @@auto_increment_increment= 1;
SET @@auto_increment_offset= 1;
SET @@character_set_client= 'cp1257';
INSERT INTO tproc(text) VALUES (@@session.character_set_client);
SET @@character_set_client= 'cp1256';
INSERT INTO tproc(text) VALUES (@@session.character_set_client);
SET @@collation_connection= 'cp1251_ukrainian_ci';
INSERT INTO tproc(text) VALUES (@@session.collation_connection);
INSERT INTO tproc(text) VALUES (@@session.character_set_connection);
SET @@collation_connection= 'cp1251_bulgarian_ci';
INSERT INTO tproc(text) VALUES (@@session.collation_connection);
INSERT INTO tproc(text) VALUES (@@session.character_set_connection);
SET @@collation_server= 'latin7_bin';
INSERT INTO tproc(text) VALUES (@@session.collation_server);
INSERT INTO tproc(text) VALUES (@@session.character_set_server);
SET @@collation_server= 'latin7_general_cs';
INSERT INTO tproc(text) VALUES (@@session.collation_server);
INSERT INTO tproc(text) VALUES (@@session.character_set_server);
SET @@time_zone= 'Europe/Moscow';
INSERT INTO tproc(text) VALUES (@@session.time_zone);
SET @@time_zone= 'Universal';
INSERT INTO tproc(text) VALUES (@@session.time_zone);
SET @@lc_time_names= 'sv_FI';
INSERT INTO tproc(text) VALUES (@@session.lc_time_names);
SET @@lc_time_names= 'no_NO';
INSERT INTO tproc(text) VALUES (@@session.lc_time_names);
SET @@collation_database= 'latin7_general_ci';
INSERT INTO tproc(text) VALUES (@@session.collation_database);
INSERT INTO tproc(text) VALUES (@@session.character_set_database);
SET @@collation_database= 'latin7_estonian_cs';
INSERT INTO tproc(text) VALUES (@@session.collation_database);
INSERT INTO tproc(text) VALUES (@@session.character_set_database);
SET @@timestamp= 47114711;
INSERT INTO tproc(text) VALUES (@@session.timestamp);
SET @@timestamp= 47124712;
INSERT INTO tproc(text) VALUES (@@session.timestamp);
SET @@last_insert_id= 1616;
INSERT INTO tproc(text) VALUES (@@session.last_insert_id);
SET @@last_insert_id= 1717;
INSERT INTO tproc(text) VALUES (@@session.last_insert_id);
END|
CALL proc();
==== Insert variables from a stored function ====
CREATE FUNCTION func()
RETURNS INT
BEGIN
SET @@pseudo_thread_id= 4712;
INSERT INTO tfunc(num) VALUES (@@session.pseudo_thread_id);
SET @@pseudo_thread_id= 4713;
INSERT INTO tfunc(num) VALUES (@@session.pseudo_thread_id);
SET @@foreign_key_checks= 0;
INSERT INTO tfunc(num) VALUES (@@session.foreign_key_checks);
SET @@foreign_key_checks= 1;
INSERT INTO tfunc(num) VALUES (@@session.foreign_key_checks);
SET @@sql_auto_is_null= 0;
INSERT INTO tfunc(num) VALUES (@@session.sql_auto_is_null);
SET @@sql_auto_is_null= 1;
INSERT INTO tfunc(num) VALUES (@@session.sql_auto_is_null);
SET @@unique_checks= 0;
INSERT INTO tfunc(num) VALUES (@@session.unique_checks);
SET @@unique_checks= 1;
INSERT INTO tfunc(num) VALUES (@@session.unique_checks);
SET @@auto_increment_increment= 11;
INSERT INTO tfunc(num) VALUES (@@session.auto_increment_increment);
SET @@auto_increment_increment= 19;
INSERT INTO tfunc(num) VALUES (@@session.auto_increment_increment);
SET @@auto_increment_offset= 13;
INSERT INTO tfunc(num) VALUES (@@session.auto_increment_offset);
SET @@auto_increment_offset= 17;
INSERT INTO tfunc(num) VALUES (@@session.auto_increment_offset);
# reset these as they affect the index column
SET @@auto_increment_increment= 1;
SET @@auto_increment_offset= 1;
SET @@character_set_client= 'cp1257';
INSERT INTO tfunc(text) VALUES (@@session.character_set_client);
SET @@character_set_client= 'cp1256';
INSERT INTO tfunc(text) VALUES (@@session.character_set_client);
SET @@collation_connection= 'cp1251_ukrainian_ci';
INSERT INTO tfunc(text) VALUES (@@session.collation_connection);
INSERT INTO tfunc(text) VALUES (@@session.character_set_connection);
SET @@collation_connection= 'cp1251_bulgarian_ci';
INSERT INTO tfunc(text) VALUES (@@session.collation_connection);
INSERT INTO tfunc(text) VALUES (@@session.character_set_connection);
SET @@collation_server= 'latin7_bin';
INSERT INTO tfunc(text) VALUES (@@session.collation_server);
INSERT INTO tfunc(text) VALUES (@@session.character_set_server);
SET @@collation_server= 'latin7_general_cs';
INSERT INTO tfunc(text) VALUES (@@session.collation_server);
INSERT INTO tfunc(text) VALUES (@@session.character_set_server);
SET @@time_zone= 'Europe/Moscow';
INSERT INTO tfunc(text) VALUES (@@session.time_zone);
SET @@time_zone= 'Universal';
INSERT INTO tfunc(text) VALUES (@@session.time_zone);
SET @@lc_time_names= 'sv_FI';
INSERT INTO tfunc(text) VALUES (@@session.lc_time_names);
SET @@lc_time_names= 'no_NO';
INSERT INTO tfunc(text) VALUES (@@session.lc_time_names);
SET @@collation_database= 'latin7_general_ci';
INSERT INTO tfunc(text) VALUES (@@session.collation_database);
INSERT INTO tfunc(text) VALUES (@@session.character_set_database);
SET @@collation_database= 'latin7_estonian_cs';
INSERT INTO tfunc(text) VALUES (@@session.collation_database);
INSERT INTO tfunc(text) VALUES (@@session.character_set_database);
SET @@timestamp= 47114711;
INSERT INTO tfunc(text) VALUES (@@session.timestamp);
SET @@timestamp= 47124712;
INSERT INTO tfunc(text) VALUES (@@session.timestamp);
SET @@last_insert_id= 1616;
INSERT INTO tfunc(text) VALUES (@@session.last_insert_id);
SET @@last_insert_id= 1717;
INSERT INTO tfunc(text) VALUES (@@session.last_insert_id);
RETURN 0;
END|
SELECT func();
func()
0
==== Insert variables from a trigger ====
CREATE TRIGGER trig
BEFORE INSERT ON trigger_table
FOR EACH ROW
BEGIN
SET @@pseudo_thread_id= 4712;
INSERT INTO ttrig(num) VALUES (@@session.pseudo_thread_id);
SET @@pseudo_thread_id= 4713;
INSERT INTO ttrig(num) VALUES (@@session.pseudo_thread_id);
SET @@foreign_key_checks= 0;
INSERT INTO ttrig(num) VALUES (@@session.foreign_key_checks);
SET @@foreign_key_checks= 1;
INSERT INTO ttrig(num) VALUES (@@session.foreign_key_checks);
SET @@sql_auto_is_null= 0;
INSERT INTO ttrig(num) VALUES (@@session.sql_auto_is_null);
SET @@sql_auto_is_null= 1;
INSERT INTO ttrig(num) VALUES (@@session.sql_auto_is_null);
SET @@unique_checks= 0;
INSERT INTO ttrig(num) VALUES (@@session.unique_checks);
SET @@unique_checks= 1;
INSERT INTO ttrig(num) VALUES (@@session.unique_checks);
SET @@auto_increment_increment= 11;
INSERT INTO ttrig(num) VALUES (@@session.auto_increment_increment);
SET @@auto_increment_increment= 19;
INSERT INTO ttrig(num) VALUES (@@session.auto_increment_increment);
SET @@auto_increment_offset= 13;
INSERT INTO ttrig(num) VALUES (@@session.auto_increment_offset);
SET @@auto_increment_offset= 17;
INSERT INTO ttrig(num) VALUES (@@session.auto_increment_offset);
# reset these as they affect the index column
SET @@auto_increment_increment= 1;
SET @@auto_increment_offset= 1;
SET @@character_set_client= 'cp1257';
INSERT INTO ttrig(text) VALUES (@@session.character_set_client);
SET @@character_set_client= 'cp1256';
INSERT INTO ttrig(text) VALUES (@@session.character_set_client);
SET @@collation_connection= 'cp1251_ukrainian_ci';
INSERT INTO ttrig(text) VALUES (@@session.collation_connection);
INSERT INTO ttrig(text) VALUES (@@session.character_set_connection);
SET @@collation_connection= 'cp1251_bulgarian_ci';
INSERT INTO ttrig(text) VALUES (@@session.collation_connection);
INSERT INTO ttrig(text) VALUES (@@session.character_set_connection);
SET @@collation_server= 'latin7_bin';
INSERT INTO ttrig(text) VALUES (@@session.collation_server);
INSERT INTO ttrig(text) VALUES (@@session.character_set_server);
SET @@collation_server= 'latin7_general_cs';
INSERT INTO ttrig(text) VALUES (@@session.collation_server);
INSERT INTO ttrig(text) VALUES (@@session.character_set_server);
SET @@time_zone= 'Europe/Moscow';
INSERT INTO ttrig(text) VALUES (@@session.time_zone);
SET @@time_zone= 'Universal';
INSERT INTO ttrig(text) VALUES (@@session.time_zone);
SET @@lc_time_names= 'sv_FI';
INSERT INTO ttrig(text) VALUES (@@session.lc_time_names);
SET @@lc_time_names= 'no_NO';
INSERT INTO ttrig(text) VALUES (@@session.lc_time_names);
SET @@collation_database= 'latin7_general_ci';
INSERT INTO ttrig(text) VALUES (@@session.collation_database);
INSERT INTO ttrig(text) VALUES (@@session.character_set_database);
SET @@collation_database= 'latin7_estonian_cs';
INSERT INTO ttrig(text) VALUES (@@session.collation_database);
INSERT INTO ttrig(text) VALUES (@@session.character_set_database);
SET @@timestamp= 47114711;
INSERT INTO ttrig(text) VALUES (@@session.timestamp);
SET @@timestamp= 47124712;
INSERT INTO ttrig(text) VALUES (@@session.timestamp);
SET @@last_insert_id= 1616;
INSERT INTO ttrig(text) VALUES (@@session.last_insert_id);
SET @@last_insert_id= 1717;
INSERT INTO ttrig(text) VALUES (@@session.last_insert_id);
END|
INSERT INTO trigger_table VALUES ('bye.');
==== Insert variables from a prepared statement ====
PREPARE p1 FROM 'SET @@pseudo_thread_id= 4712';
PREPARE p2 FROM 'INSERT INTO tprep(num) VALUES (@@session.pseudo_thread_id)';
PREPARE p3 FROM 'SET @@pseudo_thread_id= 4713';
PREPARE p4 FROM 'INSERT INTO tprep(num) VALUES (@@session.pseudo_thread_id)';
PREPARE p5 FROM 'SET @@foreign_key_checks= 0';
PREPARE p6 FROM 'INSERT INTO tprep(num) VALUES (@@session.foreign_key_checks)';
PREPARE p7 FROM 'SET @@foreign_key_checks= 1';
PREPARE p8 FROM 'INSERT INTO tprep(num) VALUES (@@session.foreign_key_checks)';
PREPARE p9 FROM 'SET @@sql_auto_is_null= 0';
PREPARE p10 FROM 'INSERT INTO tprep(num) VALUES (@@session.sql_auto_is_null)';
PREPARE p11 FROM 'SET @@sql_auto_is_null= 1';
PREPARE p12 FROM 'INSERT INTO tprep(num) VALUES (@@session.sql_auto_is_null)';
PREPARE p13 FROM 'SET @@unique_checks= 0';
PREPARE p14 FROM 'INSERT INTO tprep(num) VALUES (@@session.unique_checks)';
PREPARE p15 FROM 'SET @@unique_checks= 1';
PREPARE p16 FROM 'INSERT INTO tprep(num) VALUES (@@session.unique_checks)';
PREPARE p17 FROM 'SET @@auto_increment_increment= 11';
PREPARE p18 FROM 'INSERT INTO tprep(num) VALUES (@@session.auto_increment_increment)';
PREPARE p19 FROM 'SET @@auto_increment_increment= 19';
PREPARE p20 FROM 'INSERT INTO tprep(num) VALUES (@@session.auto_increment_increment)';
PREPARE p21 FROM 'SET @@auto_increment_offset= 13';
PREPARE p22 FROM 'INSERT INTO tprep(num) VALUES (@@session.auto_increment_offset)';
PREPARE p23 FROM 'SET @@auto_increment_offset= 17';
PREPARE p24 FROM 'INSERT INTO tprep(num) VALUES (@@session.auto_increment_offset)';
PREPARE p25 FROM 'SET @@auto_increment_increment= 1';
PREPARE p26 FROM 'SET @@auto_increment_offset= 1';
PREPARE p27 FROM 'SET @@character_set_client= \'cp1257\'';
PREPARE p28 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_client)';
PREPARE p29 FROM 'SET @@character_set_client= \'cp1256\'';
PREPARE p30 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_client)';
PREPARE p31 FROM 'SET @@collation_connection= \'cp1251_ukrainian_ci\'';
PREPARE p32 FROM 'INSERT INTO tprep(text) VALUES (@@session.collation_connection)';
PREPARE p33 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_connection)';
PREPARE p34 FROM 'SET @@collation_connection= \'cp1251_bulgarian_ci\'';
PREPARE p35 FROM 'INSERT INTO tprep(text) VALUES (@@session.collation_connection)';
PREPARE p36 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_connection)';
PREPARE p37 FROM 'SET @@collation_server= \'latin7_bin\'';
PREPARE p38 FROM 'INSERT INTO tprep(text) VALUES (@@session.collation_server)';
PREPARE p39 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_server)';
PREPARE p40 FROM 'SET @@collation_server= \'latin7_general_cs\'';
PREPARE p41 FROM 'INSERT INTO tprep(text) VALUES (@@session.collation_server)';
PREPARE p42 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_server)';
PREPARE p43 FROM 'SET @@time_zone= \'Europe/Moscow\'';
PREPARE p44 FROM 'INSERT INTO tprep(text) VALUES (@@session.time_zone)';
PREPARE p45 FROM 'SET @@time_zone= \'Universal\'';
PREPARE p46 FROM 'INSERT INTO tprep(text) VALUES (@@session.time_zone)';
PREPARE p47 FROM 'SET @@lc_time_names= \'sv_FI\'';
PREPARE p48 FROM 'INSERT INTO tprep(text) VALUES (@@session.lc_time_names)';
PREPARE p49 FROM 'SET @@lc_time_names= \'no_NO\'';
PREPARE p50 FROM 'INSERT INTO tprep(text) VALUES (@@session.lc_time_names)';
PREPARE p51 FROM 'SET @@collation_database= \'latin7_general_ci\'';
PREPARE p52 FROM 'INSERT INTO tprep(text) VALUES (@@session.collation_database)';
PREPARE p53 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_database)';
PREPARE p54 FROM 'SET @@collation_database= \'latin7_estonian_cs\'';
PREPARE p55 FROM 'INSERT INTO tprep(text) VALUES (@@session.collation_database)';
PREPARE p56 FROM 'INSERT INTO tprep(text) VALUES (@@session.character_set_database)';
PREPARE p57 FROM 'SET @@timestamp= 47114711';
PREPARE p58 FROM 'INSERT INTO tprep(text) VALUES (@@session.timestamp)';
PREPARE p59 FROM 'SET @@timestamp= 47124712';
PREPARE p60 FROM 'INSERT INTO tprep(text) VALUES (@@session.timestamp)';
PREPARE p61 FROM 'SET @@last_insert_id= 1616';
PREPARE p62 FROM 'INSERT INTO tprep(text) VALUES (@@session.last_insert_id)';
PREPARE p63 FROM 'SET @@last_insert_id= 1717';
PREPARE p64 FROM 'INSERT INTO tprep(text) VALUES (@@session.last_insert_id)';
EXECUTE p1;
EXECUTE p2;
EXECUTE p3;
EXECUTE p4;
EXECUTE p5;
EXECUTE p6;
EXECUTE p7;
EXECUTE p8;
EXECUTE p9;
EXECUTE p10;
EXECUTE p11;
EXECUTE p12;
EXECUTE p13;
EXECUTE p14;
EXECUTE p15;
EXECUTE p16;
EXECUTE p17;
EXECUTE p18;
EXECUTE p19;
EXECUTE p20;
EXECUTE p21;
EXECUTE p22;
EXECUTE p23;
EXECUTE p24;
EXECUTE p25;
EXECUTE p26;
EXECUTE p27;
EXECUTE p28;
EXECUTE p29;
EXECUTE p30;
EXECUTE p31;
EXECUTE p32;
EXECUTE p33;
EXECUTE p34;
EXECUTE p35;
EXECUTE p36;
EXECUTE p37;
EXECUTE p38;
EXECUTE p39;
EXECUTE p40;
EXECUTE p41;
EXECUTE p42;
EXECUTE p43;
EXECUTE p44;
EXECUTE p45;
EXECUTE p46;
EXECUTE p47;
EXECUTE p48;
EXECUTE p49;
EXECUTE p50;
EXECUTE p51;
EXECUTE p52;
EXECUTE p53;
EXECUTE p54;
EXECUTE p55;
EXECUTE p56;
EXECUTE p57;
EXECUTE p58;
EXECUTE p59;
EXECUTE p60;
EXECUTE p61;
EXECUTE p62;
EXECUTE p63;
EXECUTE p64;
==== Results ====
SELECT * FROM tstmt ORDER BY id;
id num text
1 4712 NULL
2 4713 NULL
3 0 NULL
4 1 NULL
5 0 NULL
6 1 NULL
7 0 NULL
8 1 NULL
12 11 NULL
20 19 NULL
32 13 NULL
36 17 NULL
37 NULL cp1257
38 NULL cp1256
39 NULL cp1251_ukrainian_ci
40 NULL cp1251
41 NULL cp1251_bulgarian_ci
42 NULL cp1251
43 NULL latin7_bin
44 NULL latin7
45 NULL latin7_general_cs
46 NULL latin7
47 NULL Europe/Moscow
48 NULL Universal
49 NULL sv_FI
50 NULL no_NO
51 NULL latin7_general_ci
52 NULL latin7
53 NULL latin7_estonian_cs
54 NULL latin7
55 NULL 47114711
56 NULL 47124712
57 NULL 1616
58 NULL 1717
Comparing tables master:test.tstmt and master:test.tproc
Comparing tables master:test.tstmt and master:test.tfunc
Comparing tables master:test.tstmt and master:test.ttrig
Comparing tables master:test.tstmt and master:test.tprep
Comparing tables master:test.tstmt and slave:test.tstmt
Comparing tables master:test.tstmt and slave:test.tproc
Comparing tables master:test.tstmt and slave:test.tfunc
Comparing tables master:test.tstmt and slave:test.ttrig
Comparing tables master:test.tstmt and slave:test.tprep
==== Clean up ====
[on master]
DROP PROCEDURE proc;
DROP FUNCTION func;
DROP TRIGGER trig;
DROP TABLE tstmt, tproc, tfunc, ttrig, tprep, trigger_table;
SET @@global.pseudo_thread_id= @m_pseudo_thread_id;
SET @@global.auto_increment_increment= @m_auto_increment_increment;
SET @@global.auto_increment_offset= @m_auto_increment_offset;
SET @@global.character_set_client= @m_character_set_client;
SET @@global.collation_connection= @m_collation_connection;
SET @@global.collation_server= @m_collation_server;
SET @@global.time_zone= @m_time_zone;
SET @@global.lc_time_names= @m_lc_time_names;
SET @@global.collation_database= @m_collation_database;
[on slave]
SET @@global.pseudo_thread_id= @s_pseudo_thread_id;
SET @@global.auto_increment_increment= @s_auto_increment_increment;
SET @@global.auto_increment_offset= @s_auto_increment_offset;
SET @@global.character_set_client= @s_character_set_client;
SET @@global.collation_connection= @s_collation_connection;
SET @@global.collation_server= @s_collation_server;
SET @@global.time_zone= @s_time_zone;
SET @@global.lc_time_names= @s_lc_time_names;
SET @@global.collation_database= @s_collation_database;