Commit d4bdf1c0 authored by Kentoku SHIBA's avatar Kentoku SHIBA Committed by GitHub

MDEV-16508 spider: sql_mode not maintained between spider node and data 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
parent 5e929ee8
--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
--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%';
--source sql_mode_init.inc
let $MASTER_1_COMMENT_2_1=
COMMENT='table "tbl_a", srv "s_2_1", wrapper "mariadb"';
--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
......
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
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
--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
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
--source ../include/sql_mode_mariadb_init.inc
--source sql_mode.inc
--source ../include/sql_mode_mariadb_deinit.inc
--echo
--echo end of test
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
--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
......
......@@ -388,6 +388,13 @@ int spider_db_conn_queue_action(
(error_num = spider_dbton[conn->dbton_id].db_util->
append_wait_timeout(&sql_str, conn->queued_wait_timeout_val))
) ||
(
conn->queued_sql_mode &&
conn->queued_sql_mode_val != conn->sql_mode &&
conn->db_conn->set_sql_mode_in_bulk_sql() &&
(error_num = spider_dbton[conn->dbton_id].db_util->
append_sql_mode(&sql_str, conn->queued_sql_mode_val))
) ||
(
conn->queued_time_zone &&
conn->queued_time_zone_val != conn->time_zone &&
......@@ -469,6 +476,15 @@ int spider_db_conn_queue_action(
) {
DBUG_RETURN(error_num);
}
if (
conn->queued_sql_mode &&
conn->queued_sql_mode_val != conn->sql_mode &&
!conn->db_conn->set_sql_mode_in_bulk_sql() &&
(error_num = spider_dbton[conn->dbton_id].db_util->
append_sql_mode(&sql_str, conn->queued_sql_mode_val))
) {
DBUG_RETURN(error_num);
}
if (
conn->queued_time_zone &&
conn->queued_time_zone_val != conn->time_zone &&
......@@ -543,6 +559,13 @@ int spider_db_conn_queue_action(
conn->wait_timeout = conn->queued_wait_timeout_val;
}
if (
conn->queued_sql_mode &&
conn->queued_sql_mode_val != conn->sql_mode
) {
conn->sql_mode = conn->queued_sql_mode_val;
}
if (conn->queued_autocommit)
{
if (conn->queued_autocommit_val && conn->autocommit != 1)
......
......@@ -1848,6 +1848,23 @@ int spider_db_handlersocket::set_wait_timeout(
DBUG_RETURN(0);
}
bool spider_db_handlersocket::set_sql_mode_in_bulk_sql()
{
DBUG_ENTER("spider_db_handlersocket::set_sql_mode_in_bulk_sql");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(FALSE);
}
int spider_db_handlersocket::set_sql_mode(
sql_mode_t sql_mode,
int *need_mon
) {
DBUG_ENTER("spider_db_handlersocket::set_sql_mode");
DBUG_PRINT("info",("spider this=%p", this));
/* nothing to do */
DBUG_RETURN(0);
}
bool spider_db_handlersocket::set_time_zone_in_bulk_sql()
{
DBUG_ENTER("spider_db_handlersocket::set_time_zone_in_bulk_sql");
......@@ -2694,6 +2711,16 @@ int spider_db_handlersocket_util::append_wait_timeout(
DBUG_RETURN(0);
}
int spider_db_handlersocket_util::append_sql_mode(
spider_string *str,
sql_mode_t sql_mode
) {
DBUG_ENTER("spider_db_handlersocket_util::append_sql_mode");
DBUG_PRINT("info",("spider this=%p", this));
/* nothing to do */
DBUG_RETURN(0);
}
int spider_db_handlersocket_util::append_time_zone(
spider_string *str,
Time_zone *time_zone
......
......@@ -63,6 +63,10 @@ class spider_db_handlersocket_util: public spider_db_util
spider_string *str,
int wait_timeout
);
int append_sql_mode(
spider_string *str,
sql_mode_t sql_mode
);
int append_time_zone(
spider_string *str,
Time_zone *time_zone
......@@ -381,6 +385,11 @@ class spider_db_handlersocket: public spider_db_conn
int wait_timeout,
int *need_mon
);
bool set_sql_mode_in_bulk_sql();
int set_sql_mode(
sql_mode_t sql_mode,
int *need_mon
);
bool set_time_zone_in_bulk_sql();
int set_time_zone(
Time_zone *time_zone,
......
......@@ -846,6 +846,10 @@ class spider_db_util
spider_string *str,
int wait_timeout
) = 0;
virtual int append_sql_mode(
spider_string *str,
sql_mode_t sql_mode
) = 0;
virtual int append_time_zone(
spider_string *str,
Time_zone *time_zone
......@@ -1147,6 +1151,11 @@ class spider_db_conn
int wait_timeout,
int *need_mon
) = 0;
virtual bool set_sql_mode_in_bulk_sql() = 0;
virtual int set_sql_mode(
sql_mode_t sql_mode,
int *need_mon
) = 0;
virtual bool set_time_zone_in_bulk_sql() = 0;
virtual int set_time_zone(
Time_zone *time_zone,
......
This diff is collapsed.
......@@ -68,6 +68,14 @@ class spider_db_mbase_util: public spider_db_util
spider_string *str,
int wait_timeout
);
virtual int append_sql_mode_internal(
spider_string *str,
sql_mode_t sql_mode
);
int append_sql_mode(
spider_string *str,
sql_mode_t sql_mode
);
int append_time_zone(
spider_string *str,
Time_zone *time_zone
......@@ -190,6 +198,10 @@ class spider_db_mariadb_util: public spider_db_mbase_util
public:
spider_db_mariadb_util();
~spider_db_mariadb_util();
int append_sql_mode_internal(
spider_string *str,
sql_mode_t sql_mode
);
};
class spider_db_mbase_row: public spider_db_row
......@@ -477,6 +489,11 @@ class spider_db_mbase: public spider_db_conn
int wait_timeout,
int *need_mon
);
bool set_sql_mode_in_bulk_sql();
int set_sql_mode(
sql_mode_t sql_mode,
int *need_mon
);
bool set_time_zone_in_bulk_sql();
int set_time_zone(
Time_zone *time_zone,
......
......@@ -2113,6 +2113,23 @@ int spider_db_oracle::set_wait_timeout(
DBUG_RETURN(0);
}
bool spider_db_oracle::set_sql_mode_in_bulk_sql()
{
DBUG_ENTER("spider_db_oracle::set_sql_mode_in_bulk_sql");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_RETURN(FALSE);
}
int spider_db_oracle::set_sql_mode(
sql_mode_t sql_mode,
int *need_mon
) {
DBUG_ENTER("spider_db_oracle::set_sql_mode");
DBUG_PRINT("info",("spider this=%p", this));
/* nothing to do */
DBUG_RETURN(0);
}
bool spider_db_oracle::set_time_zone_in_bulk_sql()
{
DBUG_ENTER("spider_db_oracle::set_time_zone_in_bulk_sql");
......@@ -2829,6 +2846,16 @@ int spider_db_oracle_util::append_wait_timeout(
DBUG_RETURN(0);
}
int spider_db_oracle_util::append_sql_mode(
spider_string *str,
sql_mode_t sql_mode
) {
DBUG_ENTER("spider_db_oracle_util::append_sql_mode");
DBUG_PRINT("info",("spider this=%p", this));
/* nothing to do */
DBUG_RETURN(0);
}
int spider_db_oracle_util::append_time_zone(
spider_string *str,
Time_zone *time_zone
......
......@@ -71,6 +71,10 @@ class spider_db_oracle_util: public spider_db_util
spider_string *str,
int wait_timeout
);
int append_sql_mode(
spider_string *str,
sql_mode_t sql_mode
);
int append_time_zone(
spider_string *str,
Time_zone *time_zone
......@@ -431,6 +435,11 @@ class spider_db_oracle: public spider_db_conn
int wait_timeout,
int *need_mon
);
bool set_sql_mode_in_bulk_sql();
int set_sql_mode(
sql_mode_t sql_mode,
int *need_mon
);
bool set_time_zone_in_bulk_sql();
int set_time_zone(
Time_zone *time_zone,
......
......@@ -260,7 +260,7 @@ const char SPIDER_empty_string = "";
#define SPIDER_TMP_SHARE_LONG_COUNT 19
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
#define SPIDER_MEM_CALC_LIST_NUM 265
#define SPIDER_MEM_CALC_LIST_NUM 266
#define SPIDER_CONN_META_BUF_LEN 64
#define SPIDER_BACKUP_DASTATUS \
......@@ -450,6 +450,7 @@ typedef struct st_spider_conn
int autocommit;
int sql_log_off;
int wait_timeout;
sql_mode_t sql_mode;
THD *thd;
void *another_ha_first;
void *another_ha_last;
......@@ -559,6 +560,7 @@ typedef struct st_spider_conn
bool queued_wait_timeout;
bool queued_autocommit;
bool queued_sql_log_off;
bool queued_sql_mode;
bool queued_time_zone;
bool queued_trx_start;
bool queued_xa_start;
......@@ -572,6 +574,7 @@ typedef struct st_spider_conn
int queued_wait_timeout_val;
bool queued_autocommit_val;
bool queued_sql_log_off_val;
sql_mode_t queued_sql_mode_val;
Time_zone *queued_time_zone_val;
XID *queued_xa_start_xid;
......
......@@ -3405,6 +3405,26 @@ int spider_param_wait_timeout(
DBUG_RETURN(604800);
}
/*
FALSE: no sync
TRUE: sync
*/
static MYSQL_THDVAR_BOOL(
sync_sql_mode, /* name */
PLUGIN_VAR_OPCMDARG, /* opt */
"Sync sql_mode", /* comment */
NULL, /* check */
NULL, /* update */
TRUE /* def */
);
bool spider_param_sync_sql_mode(
THD *thd
) {
DBUG_ENTER("spider_param_sync_sql_mode");
DBUG_RETURN(THDVAR(thd, sync_sql_mode));
}
static struct st_mysql_storage_engine spider_storage_engine =
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
......@@ -3557,6 +3577,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
MYSQL_SYSVAR(slave_trx_isolation),
MYSQL_SYSVAR(remote_wait_timeout),
MYSQL_SYSVAR(wait_timeout),
MYSQL_SYSVAR(sync_sql_mode),
NULL
};
......
......@@ -428,3 +428,6 @@ int spider_param_remote_wait_timeout(
int spider_param_wait_timeout(
THD *thd
);
bool spider_param_sync_sql_mode(
THD *thd
);
......@@ -1684,6 +1684,16 @@ int spider_check_and_set_wait_timeout(
DBUG_RETURN(0);
}
int spider_check_and_set_sql_mode(
THD *thd,
SPIDER_CONN *conn,
int *need_mon
) {
DBUG_ENTER("spider_check_and_set_sql_mode");
spider_conn_queue_sql_mode(conn, thd->variables.sql_mode);
DBUG_RETURN(0);
}
int spider_check_and_set_time_zone(
THD *thd,
SPIDER_CONN *conn,
......@@ -1886,6 +1896,9 @@ int spider_internal_start_trx(
&spider->need_mons[link_idx])) ||
(error_num = spider_check_and_set_wait_timeout(thd, conn,
&spider->need_mons[link_idx])) ||
(spider_param_sync_sql_mode(thd) &&
(error_num = spider_check_and_set_sql_mode(thd, conn,
&spider->need_mons[link_idx]))) ||
(sync_autocommit &&
(error_num = spider_check_and_set_autocommit(thd, conn,
&spider->need_mons[link_idx])))
......
......@@ -106,6 +106,12 @@ int spider_check_and_set_wait_timeout(
int *need_mon
);
int spider_check_and_set_sql_mode(
THD *thd,
SPIDER_CONN *conn,
int *need_mon
);
int spider_check_and_set_time_zone(
THD *thd,
SPIDER_CONN *conn,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment