Skip to content
Permalink
Browse files

MDEV-16508 spider: sql_mode not maintained between spider node and da…

…ta nodes (#1347)

Add the following parameter.

- spider_sync_sql_mode
  Local sql_mode synchronous existence to remote server.
   0 : It doesn't synchronize.
   1 : It synchronizes.
  The default value is 1
  • Loading branch information...
Kentoku committed Jun 28, 2019
1 parent 5e929ee commit d4bdf1c0b67b19180e461411c9494137456e0e77
Showing with 1,406 additions and 3 deletions.
  1. +13 −0 storage/spider/mysql-test/spider/bugfix/include/sql_mode_deinit.inc
  2. +40 −0 storage/spider/mysql-test/spider/bugfix/include/sql_mode_init.inc
  3. +1 −0 storage/spider/mysql-test/spider/bugfix/include/sql_mode_mariadb_deinit.inc
  4. +3 −0 storage/spider/mysql-test/spider/bugfix/include/sql_mode_mariadb_init.inc
  5. +1 −0 storage/spider/mysql-test/spider/bugfix/include/sql_mode_mysql_deinit.inc
  6. +3 −0 storage/spider/mysql-test/spider/bugfix/include/sql_mode_mysql_init.inc
  7. +1 −1 storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result
  8. +83 −0 storage/spider/mysql-test/spider/bugfix/r/sql_mode_mariadb.result
  9. +83 −0 storage/spider/mysql-test/spider/bugfix/r/sql_mode_mysql.result
  10. +65 −0 storage/spider/mysql-test/spider/bugfix/t/sql_mode.inc
  11. +3 −0 storage/spider/mysql-test/spider/bugfix/t/sql_mode_mariadb.cnf
  12. +5 −0 storage/spider/mysql-test/spider/bugfix/t/sql_mode_mariadb.test
  13. +3 −0 storage/spider/mysql-test/spider/bugfix/t/sql_mode_mysql.cnf
  14. +5 −0 storage/spider/mysql-test/spider/bugfix/t/sql_mode_mysql.test
  15. +1 −1 storage/spider/mysql-test/spider/r/slave_trx_isolation.result
  16. +17 −0 storage/spider/spd_conn.cc
  17. +5 −0 storage/spider/spd_conn.h
  18. +23 −0 storage/spider/spd_db_conn.cc
  19. +27 −0 storage/spider/spd_db_handlersocket.cc
  20. +9 −0 storage/spider/spd_db_handlersocket.h
  21. +9 −0 storage/spider/spd_db_include.h
  22. +906 −0 storage/spider/spd_db_mysql.cc
  23. +17 −0 storage/spider/spd_db_mysql.h
  24. +27 −0 storage/spider/spd_db_oracle.cc
  25. +9 −0 storage/spider/spd_db_oracle.h
  26. +4 −1 storage/spider/spd_include.h
  27. +21 −0 storage/spider/spd_param.cc
  28. +3 −0 storage/spider/spd_param.h
  29. +13 −0 storage/spider/spd_trx.cc
  30. +6 −0 storage/spider/spd_trx.h
@@ -0,0 +1,13 @@
--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP
--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP
--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP
--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP
--connection master_1
set session sql_mode= @old_sql_mode;
--disable_warnings
--disable_query_log
--disable_result_log
--source ../t/test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
@@ -0,0 +1,40 @@
--disable_warnings
--disable_query_log
--disable_result_log
--source ../t/test_init.inc
--enable_result_log
--enable_query_log
--enable_warnings
--let $SQL_MODES= real_as_float,pipes_as_concat,ansi_quotes,ignore_space,ignore_bad_table_options,only_full_group_by,no_unsigned_subtraction,no_dir_in_create,postgresql,oracle,mssql,db2,maxdb,no_key_options,no_table_options,no_field_options,mysql323,mysql40,ansi,no_auto_value_on_zero,no_backslash_escapes,strict_trans_tables,strict_all_tables,no_zero_in_date,no_zero_date,allow_invalid_dates,error_for_division_by_zero,traditional,no_auto_create_user,high_not_precedence,no_engine_substitution,pad_char_to_full_length
if (`SELECT IF(STRCMP('$SERVER_NAME', 'MariaDB') = 0, 1, 0)`)
{
if (`SELECT IF($SERVER_MAJOR_VERSION = 10, 1, 0)`)
{
if (`SELECT IF($SERVER_MINOR_VERSION >= 3, 1, 0)`)
{
--let $SQL_MODES= $SQL_MODES,empty_string_is_null,simultaneous_assignment
}
if (`SELECT IF($SERVER_MINOR_VERSION >= 4, 1, 0)`)
{
--let $SQL_MODES= $SQL_MODES,time_round_fractional
}
}
}
--connection master_1
set @old_sql_mode= @@sql_mode;
eval set session sql_mode= '$SQL_MODES';
--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1
--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES
let $CHILD2_1_DROP_TABLES=
DROP TABLE IF EXISTS tbl_a;
--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES
let $CHILD2_1_CREATE_TABLES=
CREATE TABLE tbl_a (
pkey int NOT NULL,
PRIMARY KEY (pkey)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES
let $CHILD2_1_SELECT_TABLES=
SELECT pkey FROM tbl_a ORDER BY pkey;
let $CHILD2_1_SELECT_ARGUMENT1=
SELECT argument FROM mysql.general_log WHERE argument LIKE '%sql_mode%';
@@ -0,0 +1 @@
--source sql_mode_deinit.inc
@@ -0,0 +1,3 @@
--source sql_mode_init.inc
let $MASTER_1_COMMENT_2_1=
COMMENT='table "tbl_a", srv "s_2_1", wrapper "mariadb"';
@@ -0,0 +1 @@
--source sql_mode_deinit.inc
@@ -0,0 +1,3 @@
--source sql_mode_init.inc
let $MASTER_1_COMMENT_2_1=
COMMENT='table "tbl_a", srv "s_2_1", wrapper "mysql"';
@@ -50,7 +50,7 @@ SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %';
argument
set session time_zone = '+00:00'
SET NAMES utf8
set session transaction isolation level read committed;set session autocommit = 1;set session wait_timeout = 604800;start transaction
set session transaction isolation level read committed;set session autocommit = 1;set session wait_timeout = 604800;set session sql_mode = 'strict_trans_tables,error_for_division_by_zero,no_auto_create_user,no_engine_substitution';start transaction
SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %'
SELECT pkey FROM tbl_a ORDER BY pkey;
pkey
@@ -0,0 +1,83 @@
for master_1
for child2
child2_1
child2_2
child2_3
for child3
connection master_1;
set @old_sql_mode= @@sql_mode;
set session sql_mode= 'real_as_float,pipes_as_concat,ansi_quotes,ignore_space,ignore_bad_table_options,only_full_group_by,no_unsigned_subtraction,no_dir_in_create,postgresql,oracle,mssql,db2,maxdb,no_key_options,no_table_options,no_field_options,mysql323,mysql40,ansi,no_auto_value_on_zero,no_backslash_escapes,strict_trans_tables,strict_all_tables,no_zero_in_date,no_zero_date,allow_invalid_dates,error_for_division_by_zero,traditional,no_auto_create_user,high_not_precedence,no_engine_substitution,pad_char_to_full_length,empty_string_is_null,simultaneous_assignment,time_round_fractional';

this test is for MDEV-16508

drop and create databases
connection master_1;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
SET @old_log_output = @@global.log_output;
SET GLOBAL log_output = 'TABLE,FILE';
CREATE DATABASE auto_test_remote;
USE auto_test_remote;

create table and insert
connection child2_1;
CHILD2_1_CREATE_TABLES
TRUNCATE TABLE mysql.general_log;
connection master_1;
CREATE TABLE tbl_a (
pkey int NOT NULL,
PRIMARY KEY (pkey)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

select test
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
SELECT * FROM tbl_a ORDER BY pkey;
pkey
0
1
2
3
4
5
6
7
8
9
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%sql_mode%';
argument
set session transaction isolation level repeatable read;set session autocommit = 1;set session sql_log_off = 0;set session wait_timeout = 604800;set session sql_mode = 'real_as_float,ignore_bad_table_options,no_unsigned_subtraction,no_dir_in_create,no_auto_value_on_zero,strict_trans_tables,strict_all_tables,no_zero_in_date,no_zero_date,allow_invalid_dates,error_for_division_by_zero,no_auto_create_user,high_not_precedence,no_engine_substitution,pad_char_to_full_length,empty_string_is_null,simultaneous_assignment,time_round_fractional';set session time_zone = '+00:00';start transaction
SELECT argument FROM mysql.general_log WHERE argument LIKE '%sql_mode%'
SELECT pkey FROM tbl_a ORDER BY pkey;
pkey
0
1
2
3
4
5
6
7
8
9

deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
SET GLOBAL log_output = @old_log_output;
connection master_1;
set session sql_mode= @old_sql_mode;
for master_1
for child2
child2_1
child2_2
child2_3
for child3

end of test
@@ -0,0 +1,83 @@
for master_1
for child2
child2_1
child2_2
child2_3
for child3
connection master_1;
set @old_sql_mode= @@sql_mode;
set session sql_mode= 'real_as_float,pipes_as_concat,ansi_quotes,ignore_space,ignore_bad_table_options,only_full_group_by,no_unsigned_subtraction,no_dir_in_create,postgresql,oracle,mssql,db2,maxdb,no_key_options,no_table_options,no_field_options,mysql323,mysql40,ansi,no_auto_value_on_zero,no_backslash_escapes,strict_trans_tables,strict_all_tables,no_zero_in_date,no_zero_date,allow_invalid_dates,error_for_division_by_zero,traditional,no_auto_create_user,high_not_precedence,no_engine_substitution,pad_char_to_full_length,empty_string_is_null,simultaneous_assignment,time_round_fractional';

this test is for MDEV-16508

drop and create databases
connection master_1;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
SET @old_log_output = @@global.log_output;
SET GLOBAL log_output = 'TABLE,FILE';
CREATE DATABASE auto_test_remote;
USE auto_test_remote;

create table and insert
connection child2_1;
CHILD2_1_CREATE_TABLES
TRUNCATE TABLE mysql.general_log;
connection master_1;
CREATE TABLE tbl_a (
pkey int NOT NULL,
PRIMARY KEY (pkey)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

select test
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
SELECT * FROM tbl_a ORDER BY pkey;
pkey
0
1
2
3
4
5
6
7
8
9
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%sql_mode%';
argument
set session transaction isolation level repeatable read;set session autocommit = 1;set session sql_log_off = 0;set session wait_timeout = 604800;set session sql_mode = 'real_as_float,ignore_bad_table_options,no_unsigned_subtraction,no_dir_in_create,no_auto_value_on_zero,strict_trans_tables,strict_all_tables,no_zero_in_date,no_zero_date,allow_invalid_dates,error_for_division_by_zero,no_auto_create_user,high_not_precedence,no_engine_substitution,pad_char_to_full_length';set session time_zone = '+00:00';start transaction
SELECT argument FROM mysql.general_log WHERE argument LIKE '%sql_mode%'
SELECT pkey FROM tbl_a ORDER BY pkey;
pkey
0
1
2
3
4
5
6
7
8
9

deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
SET GLOBAL log_output = @old_log_output;
connection master_1;
set session sql_mode= @old_sql_mode;
for master_1
for child2
child2_1
child2_2
child2_3
for child3

end of test
@@ -0,0 +1,65 @@
--echo
--echo this test is for MDEV-16508
--echo
--echo drop and create databases

--connection master_1
--disable_warnings
CREATE DATABASE auto_test_local;
USE auto_test_local;

--connection child2_1
SET @old_log_output = @@global.log_output;
SET GLOBAL log_output = 'TABLE,FILE';
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
--enable_warnings

--echo
--echo create table and insert

--connection child2_1
--disable_query_log
echo CHILD2_1_CREATE_TABLES;
eval $CHILD2_1_CREATE_TABLES;
--enable_query_log
TRUNCATE TABLE mysql.general_log;

--connection master_1
--disable_query_log
echo CREATE TABLE tbl_a (
pkey int NOT NULL,
PRIMARY KEY (pkey)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
eval CREATE TABLE tbl_a (
pkey int NOT NULL,
PRIMARY KEY (pkey)
) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
--enable_query_log
INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

--echo
--echo select test

--connection child2_1
TRUNCATE TABLE mysql.general_log;

--connection master_1
SELECT * FROM tbl_a ORDER BY pkey;

--connection child2_1
eval $CHILD2_1_SELECT_ARGUMENT1;
eval $CHILD2_1_SELECT_TABLES;

--echo
--echo deinit
--disable_warnings

--connection master_1
DROP DATABASE IF EXISTS auto_test_local;

--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
SET GLOBAL log_output = @old_log_output;

--enable_warnings
@@ -0,0 +1,3 @@
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
@@ -0,0 +1,5 @@
--source ../include/sql_mode_mariadb_init.inc
--source sql_mode.inc
--source ../include/sql_mode_mariadb_deinit.inc
--echo
--echo end of test
@@ -0,0 +1,3 @@
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
@@ -0,0 +1,5 @@
--source ../include/sql_mode_mysql_init.inc
--source sql_mode.inc
--source ../include/sql_mode_mysql_deinit.inc
--echo
--echo end of test
@@ -53,7 +53,7 @@ SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %';
argument
set session time_zone = '+00:00'
SET NAMES utf8
set session transaction isolation level read committed;set session autocommit = 1;set session wait_timeout = 604800;start transaction
set session transaction isolation level read committed;set session autocommit = 1;set session wait_timeout = 604800;set session sql_mode = 'strict_trans_tables,error_for_division_by_zero,no_auto_create_user,no_engine_substitution';start transaction
SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %'
SELECT pkey FROM tbl_a ORDER BY pkey;
pkey
@@ -92,6 +92,9 @@ extern PSI_thread_key spd_key_thd_bg_mon;
/* UTC time zone for timestamp columns */
extern Time_zone *UTC;

extern sql_mode_t full_sql_mode;
extern sql_mode_t pushdown_sql_mode;

HASH spider_open_connections;
uint spider_open_connections_id;
HASH spider_ipport_conns;
@@ -150,6 +153,7 @@ int spider_reset_conn_setted_parameter(
conn->autocommit = spider_param_remote_autocommit();
conn->sql_log_off = spider_param_remote_sql_log_off();
conn->wait_timeout = spider_param_remote_wait_timeout(thd);
conn->sql_mode = full_sql_mode + 1;
if (thd && spider_param_remote_time_zone())
{
int tz_length = strlen(spider_param_remote_time_zone());
@@ -1444,6 +1448,18 @@ void spider_conn_queue_wait_timeout(
DBUG_VOID_RETURN;
}

void spider_conn_queue_sql_mode(
SPIDER_CONN *conn,
sql_mode_t sql_mode
) {
DBUG_ENTER("spider_conn_queue_sql_mode");
DBUG_PRINT("info", ("spider conn=%p", conn));
DBUG_ASSERT(!(sql_mode & ~full_sql_mode));
conn->queued_sql_mode = TRUE;
conn->queued_sql_mode_val = (sql_mode & pushdown_sql_mode);
DBUG_VOID_RETURN;
}

void spider_conn_queue_time_zone(
SPIDER_CONN *conn,
Time_zone *time_zone
@@ -1500,6 +1516,7 @@ void spider_conn_clear_queue(
conn->queued_autocommit = FALSE;
conn->queued_sql_log_off = FALSE;
conn->queued_wait_timeout = FALSE;
conn->queued_sql_mode = FALSE;
conn->queued_time_zone = FALSE;
conn->queued_trx_start = FALSE;
conn->queued_xa_start = FALSE;
@@ -141,6 +141,11 @@ void spider_conn_queue_wait_timeout(
int wait_timeout
);

void spider_conn_queue_sql_mode(
SPIDER_CONN *conn,
sql_mode_t sql_mode
);

void spider_conn_queue_time_zone(
SPIDER_CONN *conn,
Time_zone *time_zone

0 comments on commit d4bdf1c

Please sign in to comment.
You can’t perform that action at this time.