From e1d31a10afcca0d8e16f35c8bb4c25c23f94f136 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 13 Jul 2023 13:22:24 +1000 Subject: [PATCH] MDEV-31524 Fixing spider table param / variable overriding The existing (incorrect) overriding mechanism is: Non-minus-one var value overrides table param overrides default value. Before MDEV-27169, unspecified var value is -1. So if the user sets both the var to be a value other than -1 and the table param, the var value will prevail, which is incorrect. After MDEV-27169, unspecified var value is default value. So if the user does not set the var but sets the table param, the default value will prevail, which is even more incorrect. This patch fixes it so that table param, if specified, always overrides var value, and the latter if not specified or set to -1, falls back to the default value We achieve this by replacing all such overriding in spd_param.cc with macros that override in the correct way, and removing all the "overriding -1" lines involving table params in spider_set_connect_info_default() except for those table params not defined as sysvar/thdvar in spd_params.cc We also introduced macros for non-overriding sysvar and thdvar, so that the code is cleaner and less error-prone In server versions where MDEV-27169 has not been applied, we also backport the patch, that is, replacing -1 default values with real default values In server versions where MDEV-28006 has not been applied, we do the same for udf params --- .../spider/bugfix/r/mdev_31524.result | 46 + .../spider/bugfix/t/mdev_31524.test | 73 + storage/spider/spd_copy_tables.cc | 6 - storage/spider/spd_db_conn.cc | 4 +- storage/spider/spd_direct_sql.cc | 15 - storage/spider/spd_param.cc | 1266 +++++------------ storage/spider/spd_table.cc | 146 -- 7 files changed, 449 insertions(+), 1107 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_31524.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_31524.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_31524.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_31524.result new file mode 100644 index 0000000000000..645fc62862d94 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_31524.result @@ -0,0 +1,46 @@ + +MDEV-31524 Spider variables that double as table params overriding mechanism is buggy + +for master_1 +for child2 +for child3 +SET @old_spider_read_only_mode = @@session.spider_read_only_mode; +CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +set session spider_read_only_mode = default; +create table t2 (c int); +create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv_mdev_31524",TABLE "t2"'; +/* 1 */ insert into t1 values (42); +drop table t1, t2; +set session spider_read_only_mode = 1; +create table t2 (c int); +create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv_mdev_31524",TABLE "t2"'; +/* 2 */ insert into t1 values (42); +ERROR HY000: Table 'test.t1' is read only +drop table t1, t2; +set session spider_read_only_mode = -1; +create table t2 (c int); +create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv_mdev_31524",TABLE "t2"'; +/* 3 */ insert into t1 values (42); +drop table t1, t2; +SET session spider_read_only_mode = default; +create table t2 (c int); +create table t1 (c int) ENGINE=Spider COMMENT='read_only_mode "1", WRAPPER "mysql", srv "srv_mdev_31524",TABLE "t2"'; +/* 4 */ insert into t1 values (42); +ERROR HY000: Table 'test.t1' is read only +drop table t1, t2; +set session spider_read_only_mode = 1; +create table t2 (c int); +create table t1 (c int) ENGINE=Spider COMMENT='read_only_mode "0", WRAPPER "mysql", srv "srv_mdev_31524",TABLE "t2"'; +/* 5 */ insert into t1 values (42); +drop table t1, t2; +SET session spider_read_only_mode = -1; +create table t2 (c int); +create table t1 (c int) ENGINE=Spider COMMENT='read_only_mode "1", WRAPPER "mysql", srv "srv_mdev_31524",TABLE "t2"'; +/* 6 */ insert into t1 values (42); +ERROR HY000: Table 'test.t1' is read only +drop table t1, t2; +drop server srv_mdev_31524; +SET session spider_read_only_mode = @old_spider_read_only_mode; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_31524.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_31524.test new file mode 100644 index 0000000000000..64cbf4154aa12 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_31524.test @@ -0,0 +1,73 @@ +--echo +--echo MDEV-31524 Spider variables that double as table params overriding mechanism is buggy +--echo + +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log + +--let $srv=srv_mdev_31524 +SET @old_spider_read_only_mode = @@session.spider_read_only_mode; +evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); + +# when the user does not set var nor the table option, the default +# value (0 in this case) takes effect. +set session spider_read_only_mode = default; +create table t2 (c int); +eval create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "$srv",TABLE "t2"'; +/* 1 */ insert into t1 values (42); +drop table t1, t2; + +# when the user sets var but not the table option, the var should be +# take effect. +set session spider_read_only_mode = 1; +create table t2 (c int); +eval create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "$srv",TABLE "t2"'; +--error 12518 +/* 2 */ insert into t1 values (42); +drop table t1, t2; + +# when the user sets var to -1 and does not set the table option, the +# default value takes effect. +set session spider_read_only_mode = -1; +create table t2 (c int); +eval create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "$srv",TABLE "t2"'; +/* 3 */ insert into t1 values (42); +drop table t1, t2; + +# when the user does not set the var, but sets the table option, the +# table option should take effect +SET session spider_read_only_mode = default; +create table t2 (c int); +eval create table t1 (c int) ENGINE=Spider COMMENT='read_only_mode "1", WRAPPER "mysql", srv "$srv",TABLE "t2"'; +--error 12518 +/* 4 */ insert into t1 values (42); +drop table t1, t2; + +# when the user sets both var and table option, the table option +# should take precedence +set session spider_read_only_mode = 1; +create table t2 (c int); +eval create table t1 (c int) ENGINE=Spider COMMENT='read_only_mode "0", WRAPPER "mysql", srv "$srv",TABLE "t2"'; +/* 5 */ insert into t1 values (42); +drop table t1, t2; + +# when the user sets the var to -1 and sets the table option, the +# table option should take effect +SET session spider_read_only_mode = -1; +create table t2 (c int); +eval create table t1 (c int) ENGINE=Spider COMMENT='read_only_mode "1", WRAPPER "mysql", srv "$srv",TABLE "t2"'; +--error 12518 +/* 6 */ insert into t1 values (42); +drop table t1, t2; + +eval drop server $srv; + +SET session spider_read_only_mode = @old_spider_read_only_mode; +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index 319b02462b192..e00e06087764c 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -64,12 +64,6 @@ int spider_udf_set_copy_tables_param_default( } } - if (copy_tables->bulk_insert_interval == -1) - copy_tables->bulk_insert_interval = 10; - if (copy_tables->bulk_insert_rows == -1) - copy_tables->bulk_insert_rows = 100; - if (copy_tables->use_table_charset == -1) - copy_tables->use_table_charset = 1; if (copy_tables->use_transaction == -1) copy_tables->use_transaction = 1; #ifndef WITHOUT_SPIDER_BG_SEARCH diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 8712dc91a6522..de85e0b99b257 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -11559,7 +11559,7 @@ int spider_db_udf_copy_tables( error_num = result->get_errno(); if (error_num == HA_ERR_END_OF_FILE) { - if (roop_count < copy_tables->bulk_insert_rows) + if (roop_count < bulk_insert_rows) { end_of_file = TRUE; if (roop_count) @@ -11583,8 +11583,6 @@ int spider_db_udf_copy_tables( pthread_mutex_unlock(&tmp_conn->mta_conn_mutex); goto error_db_query; } - bulk_insert_rows = spider_param_udf_ct_bulk_insert_rows( - copy_tables->bulk_insert_rows); if ( select_ct->append_key_order_str(key_info, 0, FALSE) || select_ct->append_limit(0, bulk_insert_rows) || diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 0574c18b07864..6a04488c50f62 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -1451,25 +1451,10 @@ int spider_udf_set_direct_sql_param_default( } } - if (direct_sql->table_loop_mode == -1) - direct_sql->table_loop_mode = 0; if (direct_sql->priority == -1) direct_sql->priority = 1000000; - if (direct_sql->connect_timeout == -1) - direct_sql->connect_timeout = 6; - if (direct_sql->net_read_timeout == -1) - direct_sql->net_read_timeout = 600; - if (direct_sql->net_write_timeout == -1) - direct_sql->net_write_timeout = 600; - if (direct_sql->bulk_insert_rows == -1) - direct_sql->bulk_insert_rows = 3000; if (direct_sql->connection_channel == -1) direct_sql->connection_channel = 0; -#if MYSQL_VERSION_ID < 50500 -#else - if (direct_sql->use_real_table == -1) - direct_sql->use_real_table = 0; -#endif if (direct_sql->error_rw_mode == -1) direct_sql->error_rw_mode = 0; for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++) diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index 81540a1ef91cc..b77acef57fe9c 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -1,4 +1,5 @@ /* Copyright (C) 2008-2018 Kentoku Shiba + Copyright (C) 2023 MariaDB plc This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,6 +14,26 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ +/** + @file + + There are several kinds of spider parameters. + + - sysvar/thdvar that are not table parameters. These variables do + not appear in a `SPIDER_SHARE`. Examples include `support_xa` and + `conn_recycle_mode`. Their values are commonly retrieved by + `SPIDER_SYSVAR_VALUE_FUNC()` and `SPIDER_THDVAR_VALUE_FUNC()` + - sysvar/thdvar that are also table parameters. These variables + commonly appear in a `SPIDER_SHARE`. Examples include + `read_only_mode` and `use_table_charset`. Table parameter values + override variable values, and their values are commonly retrieved + by `SPIDER_SYSVAR_OVERRIDE_VALUE_FUNC()` and + `SPIDER_THDVAR_OVERRIDE_VALUE_FUNC()`. + - table parameters that are not sysvar/thdvar. Examples include + host and username. They are not handled in this file which is only + concerned with global/session variables +*/ + #define MYSQL_SERVER 1 #include #include "mysql_version.h" @@ -42,6 +63,57 @@ extern struct st_maria_plugin spider_i_s_alloc_mem_maria; extern volatile ulonglong spider_mon_table_cache_version; extern volatile ulonglong spider_mon_table_cache_version_req; +/* + Define a function returning the value of a global variable. +*/ +#define SPIDER_SYSVAR_VALUE_FUNC(param_type, param_name) \ + param_type spider_param_ ## param_name() \ + { \ + return SYSVAR(param_name); \ + } + +/* + Define a function returning the value of a session variable. +*/ +#define SPIDER_THDVAR_VALUE_FUNC(param_type, param_name) \ + param_type spider_param_ ## param_name(THD *thd) \ + { \ + return THDVAR(thd, param_name); \ + } + +/* + Define a function returning the value of a table param that is also a + global variable. + + If the table param value is not -1, use the table param value. + Otherwise if the variable value is not -1, use the variable value. + Otherwise use the default variable value. +*/ +#define SPIDER_SYSVAR_OVERRIDE_VALUE_FUNC(param_type, param_name) \ + param_type spider_param_ ## param_name(param_type param_name) \ + { \ + return param_name != -1 ? param_name : \ + SYSVAR(param_name) != -1 ? SYSVAR(param_name) : \ + MYSQL_SYSVAR_NAME(param_name).def_val; \ + } + +/* + Define a function returning the value of a table param that is also a + session variable. + + If the table param value is not -1, use the table param value. + Otherwise if the variable value is not -1, use the variable value. + Otherwise use the default variable value. +*/ +#define SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(param_type, param_name) \ + param_type spider_param_ ## param_name(THD* thd, \ + param_type param_name) \ + { \ + return param_name != -1 ? param_name : \ + THDVAR(thd, param_name) != -1 ? THDVAR(thd, param_name) : \ + MYSQL_SYSVAR_NAME(param_name).def_val; \ + } + #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS static int spider_direct_update(THD *thd, SHOW_VAR *var, char *buff) { @@ -172,11 +244,7 @@ static MYSQL_SYSVAR_BOOL( TRUE ); -my_bool spider_param_support_xa() -{ - DBUG_ENTER("spider_param_support_xa"); - DBUG_RETURN(spider_support_xa); -} +SPIDER_SYSVAR_VALUE_FUNC(my_bool, support_xa) static my_bool spider_connect_mutex; static MYSQL_SYSVAR_BOOL( @@ -189,11 +257,7 @@ static MYSQL_SYSVAR_BOOL( FALSE ); -my_bool spider_param_connect_mutex() -{ - DBUG_ENTER("spider_param_connect_mutex"); - DBUG_RETURN(spider_connect_mutex); -} +SPIDER_SYSVAR_VALUE_FUNC(my_bool, connect_mutex) static uint spider_connect_error_interval; /* @@ -212,11 +276,7 @@ static MYSQL_SYSVAR_UINT( 0 ); -uint spider_param_connect_error_interval() -{ - DBUG_ENTER("spider_param_connect_error_interval"); - DBUG_RETURN(spider_connect_error_interval); -} +SPIDER_SYSVAR_VALUE_FUNC(uint, connect_error_interval) static uint spider_table_init_error_interval; /* @@ -235,15 +295,11 @@ static MYSQL_SYSVAR_UINT( 0 ); -uint spider_param_table_init_error_interval() -{ - DBUG_ENTER("spider_param_table_init_error_interval"); - DBUG_RETURN(spider_table_init_error_interval); -} +SPIDER_SYSVAR_VALUE_FUNC(uint, table_init_error_interval) static int spider_use_table_charset; /* - -1 :use table parameter + -1 :fallback to default 0 :use utf8 1 :use table charset */ @@ -254,19 +310,13 @@ static MYSQL_SYSVAR_INT( "Use table charset for remote access", NULL, NULL, - -1, + 1, -1, 1, 0 ); -int spider_param_use_table_charset( - int use_table_charset -) { - DBUG_ENTER("spider_param_use_table_charset"); - DBUG_RETURN(spider_use_table_charset == -1 ? - use_table_charset : spider_use_table_charset); -} +SPIDER_SYSVAR_OVERRIDE_VALUE_FUNC(int, use_table_charset) /* 0: no recycle @@ -285,12 +335,7 @@ static MYSQL_THDVAR_UINT( 0 /* blk */ ); -uint spider_param_conn_recycle_mode( - THD *thd -) { - DBUG_ENTER("spider_param_conn_recycle_mode"); - DBUG_RETURN(THDVAR(thd, conn_recycle_mode)); -} +SPIDER_THDVAR_VALUE_FUNC(uint, conn_recycle_mode) /* 0: weak @@ -308,12 +353,7 @@ static MYSQL_THDVAR_UINT( 0 /* blk */ ); -uint spider_param_conn_recycle_strict( - THD *thd -) { - DBUG_ENTER("spider_param_conn_recycle_strict"); - DBUG_RETURN(THDVAR(thd, conn_recycle_strict)); -} +SPIDER_THDVAR_VALUE_FUNC(uint, conn_recycle_strict) /* FALSE: no sync @@ -328,12 +368,7 @@ static MYSQL_THDVAR_BOOL( TRUE /* def */ ); -bool spider_param_sync_trx_isolation( - THD *thd -) { - DBUG_ENTER("spider_param_sync_trx_isolation"); - DBUG_RETURN(THDVAR(thd, sync_trx_isolation)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, sync_trx_isolation) /* FALSE: no use @@ -348,12 +383,7 @@ static MYSQL_THDVAR_BOOL( FALSE /* def */ ); -bool spider_param_use_consistent_snapshot( - THD *thd -) { - DBUG_ENTER("spider_param_use_consistent_snapshot"); - DBUG_RETURN(THDVAR(thd, use_consistent_snapshot)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, use_consistent_snapshot) /* FALSE: off @@ -368,12 +398,7 @@ static MYSQL_THDVAR_BOOL( FALSE /* def */ ); -bool spider_param_internal_xa( - THD *thd -) { - DBUG_ENTER("spider_param_internal_xa"); - DBUG_RETURN(THDVAR(thd, internal_xa)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, internal_xa) /* 0 :err when use a spider table @@ -393,12 +418,7 @@ static MYSQL_THDVAR_UINT( 0 /* blk */ ); -uint spider_param_internal_xa_snapshot( - THD *thd -) { - DBUG_ENTER("spider_param_internal_xa_snapshot"); - DBUG_RETURN(THDVAR(thd, internal_xa_snapshot)); -} +SPIDER_THDVAR_VALUE_FUNC(uint, internal_xa_snapshot) /* 0 :off @@ -417,12 +437,7 @@ static MYSQL_THDVAR_UINT( 0 /* blk */ ); -uint spider_param_force_commit( - THD *thd -) { - DBUG_ENTER("spider_param_force_commit"); - DBUG_RETURN(THDVAR(thd, force_commit)); -} +SPIDER_THDVAR_VALUE_FUNC(uint, force_commit) /* 0: register all XA transaction @@ -440,15 +455,10 @@ static MYSQL_THDVAR_UINT( 0 /* blk */ ); -uint spider_param_xa_register_mode( - THD *thd -) { - DBUG_ENTER("spider_param_xa_register_mode"); - DBUG_RETURN(THDVAR(thd, xa_register_mode)); -} +SPIDER_THDVAR_VALUE_FUNC(uint, xa_register_mode) /* - -1 :use table parameter + -1 :fallback to default 0-:offset */ static MYSQL_THDVAR_LONGLONG( @@ -457,23 +467,16 @@ static MYSQL_THDVAR_LONGLONG( "Internal offset", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_internal_offset( - THD *thd, - longlong internal_offset -) { - DBUG_ENTER("spider_param_internal_offset"); - DBUG_RETURN(THDVAR(thd, internal_offset) < 0 ? - internal_offset : THDVAR(thd, internal_offset)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(longlong, internal_offset) /* - -1 :use table parameter + -1 :fallback to default 0-:limit */ static MYSQL_THDVAR_LONGLONG( @@ -482,23 +485,16 @@ static MYSQL_THDVAR_LONGLONG( "Internal limit", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 9223372036854775807LL, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_internal_limit( - THD *thd, - longlong internal_limit -) { - DBUG_ENTER("spider_param_internal_limit"); - DBUG_RETURN(THDVAR(thd, internal_limit) < 0 ? - internal_limit : THDVAR(thd, internal_limit)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(longlong, internal_limit) /* - -1 :use table parameter + -1 :fallback to default 0-:number of rows at a select */ static MYSQL_THDVAR_LONGLONG( @@ -507,23 +503,16 @@ static MYSQL_THDVAR_LONGLONG( "Number of rows at a select", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 9223372036854775807LL, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_split_read( - THD *thd, - longlong split_read -) { - DBUG_ENTER("spider_param_split_read"); - DBUG_RETURN(THDVAR(thd, split_read) < 0 ? - split_read : THDVAR(thd, split_read)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(longlong, split_read) /* - -1 :use table parameter + -1 :fallback to default 0 :doesn't use "offset" and "limit" for "split_read" 1-:magnification */ @@ -533,23 +522,16 @@ static MYSQL_THDVAR_INT( "Use offset and limit parameter in SQL for split_read parameter.", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 2, /* def */ -1, /* min */ 2147483647, /* max */ 0 /* blk */ ); -double spider_param_semi_split_read( - THD *thd, - double semi_split_read -) { - DBUG_ENTER("spider_param_semi_split_read"); - DBUG_RETURN(THDVAR(thd, semi_split_read) < 0 ? - semi_split_read : THDVAR(thd, semi_split_read)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(double, semi_split_read) /* - -1 :use table parameter + -1 :fallback to default 0-:the limit value */ static MYSQL_THDVAR_LONGLONG( @@ -558,23 +540,16 @@ static MYSQL_THDVAR_LONGLONG( "The limit value for semi_split_read", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 9223372036854775807LL, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_semi_split_read_limit( - THD *thd, - longlong semi_split_read_limit -) { - DBUG_ENTER("spider_param_semi_split_read_limit"); - DBUG_RETURN(THDVAR(thd, semi_split_read_limit) < 0 ? - semi_split_read_limit : THDVAR(thd, semi_split_read_limit)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(longlong, semi_split_read_limit) /* - -1 :use table parameter + -1 :fallback to default 0 :no alloc 1-:alloc size */ @@ -584,23 +559,16 @@ static MYSQL_THDVAR_INT( "Initial sql string alloc size", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 1024, /* def */ -1, /* min */ 2147483647, /* max */ 0 /* blk */ ); -int spider_param_init_sql_alloc_size( - THD *thd, - int init_sql_alloc_size -) { - DBUG_ENTER("spider_param_init_sql_alloc_size"); - DBUG_RETURN(THDVAR(thd, init_sql_alloc_size) < 0 ? - init_sql_alloc_size : THDVAR(thd, init_sql_alloc_size)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, init_sql_alloc_size) /* - -1 :use table parameter + -1 :fallback to default 0 :off 1 :on */ @@ -610,24 +578,17 @@ static MYSQL_THDVAR_INT( "Reset sql string alloc after execute", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 1, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_reset_sql_alloc( - THD *thd, - int reset_sql_alloc -) { - DBUG_ENTER("spider_param_reset_sql_alloc"); - DBUG_RETURN(THDVAR(thd, reset_sql_alloc) < 0 ? - reset_sql_alloc : THDVAR(thd, reset_sql_alloc)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, reset_sql_alloc) #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) /* - -1 :use table parameter + -1 :fallback to default 0-:result free size for handlersocket */ static MYSQL_THDVAR_LONGLONG( @@ -636,24 +597,17 @@ static MYSQL_THDVAR_LONGLONG( "Result free size for handlersocket", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 1048576, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_hs_result_free_size( - THD *thd, - longlong hs_result_free_size -) { - DBUG_ENTER("spider_param_hs_result_free_size"); - DBUG_RETURN(THDVAR(thd, hs_result_free_size) < 0 ? - hs_result_free_size : THDVAR(thd, hs_result_free_size)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUN(longlong, hs_result_free_size) #endif /* - -1 :use table parameter + -1 :fallback to default 0 :off 1 :on */ @@ -663,23 +617,16 @@ static MYSQL_THDVAR_INT( "Sprit read mode for multi range", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 100, /* def */ -1, /* min */ 2147483647, /* max */ 0 /* blk */ ); -int spider_param_multi_split_read( - THD *thd, - int multi_split_read -) { - DBUG_ENTER("spider_param_multi_split_read"); - DBUG_RETURN(THDVAR(thd, multi_split_read) < 0 ? - multi_split_read : THDVAR(thd, multi_split_read)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, multi_split_read) /* - -1 :use table parameter + -1 :fallback to default 0-:max order columns */ static MYSQL_THDVAR_INT( @@ -688,20 +635,13 @@ static MYSQL_THDVAR_INT( "Max columns for order by", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 32767, /* def */ -1, /* min */ 32767, /* max */ 0 /* blk */ ); -int spider_param_max_order( - THD *thd, - int max_order -) { - DBUG_ENTER("spider_param_max_order"); - DBUG_RETURN(THDVAR(thd, max_order) < 0 ? - max_order : THDVAR(thd, max_order)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, max_order) /* -1 :off @@ -722,12 +662,7 @@ static MYSQL_THDVAR_INT( 0 /* blk */ ); -int spider_param_semi_trx_isolation( - THD *thd -) { - DBUG_ENTER("spider_param_semi_trx_isolation"); - DBUG_RETURN(THDVAR(thd, semi_trx_isolation)); -} +SPIDER_THDVAR_VALUE_FUNC(int, semi_trx_isolation) static int spider_param_semi_table_lock_check( MYSQL_THD thd, @@ -779,19 +714,13 @@ static MYSQL_THDVAR_INT( "Table lock during execute a sql", /* comment */ &spider_param_semi_table_lock_check, /* check */ NULL, /* update */ - 1, /* def */ + 0, /* def */ 0, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_semi_table_lock( - THD *thd, - int semi_table_lock -) { - DBUG_ENTER("spider_param_semi_table_lock"); - DBUG_RETURN((semi_table_lock & THDVAR(thd, semi_table_lock))); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, semi_table_lock) static int spider_param_semi_table_lock_connection_check( MYSQL_THD thd, @@ -844,20 +773,13 @@ static MYSQL_THDVAR_INT( "Use different connection if semi_table_lock is enabled", /* comment */ &spider_param_semi_table_lock_connection_check, /* check */ NULL, /* update */ - -1, /* def */ + 1, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_semi_table_lock_connection( - THD *thd, - int semi_table_lock_connection -) { - DBUG_ENTER("spider_param_semi_table_lock_connection"); - DBUG_RETURN(THDVAR(thd, semi_table_lock_connection) == -1 ? - semi_table_lock_connection : THDVAR(thd, semi_table_lock_connection)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, semi_table_lock_connection) /* 0-:block_size @@ -874,15 +796,10 @@ static MYSQL_THDVAR_UINT( 0 /* blk */ ); -uint spider_param_block_size( - THD *thd -) { - DBUG_ENTER("spider_param_block_size"); - DBUG_RETURN(THDVAR(thd, block_size)); -} +SPIDER_THDVAR_VALUE_FUNC(uint, block_size) /* - -1 :use table parameter + -1 :fallback to default 0 :off 1 :lock in share mode 2 :for update @@ -893,20 +810,13 @@ static MYSQL_THDVAR_INT( "Lock for select with update", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 1, /* def */ -1, /* min */ 2, /* max */ 0 /* blk */ ); -int spider_param_selupd_lock_mode( - THD *thd, - int selupd_lock_mode -) { - DBUG_ENTER("spider_param_selupd_lock_mode"); - DBUG_RETURN(THDVAR(thd, selupd_lock_mode) == -1 ? - selupd_lock_mode : THDVAR(thd, selupd_lock_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, selupd_lock_mode) /* FALSE: no sync @@ -921,12 +831,7 @@ static MYSQL_THDVAR_BOOL( TRUE /* def */ ); -bool spider_param_sync_autocommit( - THD *thd -) { - DBUG_ENTER("spider_param_sync_autocommit"); - DBUG_RETURN(THDVAR(thd, sync_autocommit)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, sync_autocommit) /* FALSE: not use @@ -941,12 +846,7 @@ static MYSQL_THDVAR_BOOL( TRUE /* def */ ); -bool spider_param_use_default_database( - THD *thd -) { - DBUG_ENTER("spider_param_use_default_database"); - DBUG_RETURN(THDVAR(thd, use_default_database)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, use_default_database) /* -1 :don't know or does not matter; don't send 'SET SQL_LOG_OFF' statement @@ -965,15 +865,10 @@ static MYSQL_THDVAR_INT( 0 /* blk */ ); -int spider_param_internal_sql_log_off( - THD *thd -) { - DBUG_ENTER("spider_param_internal_sql_log_off"); - DBUG_RETURN(THDVAR(thd, internal_sql_log_off)); -} +SPIDER_THDVAR_VALUE_FUNC(int, internal_sql_log_off) /* - -1 :use table parameter + -1 :fallback to default 0-:bulk insert size */ static MYSQL_THDVAR_INT( @@ -982,23 +877,16 @@ static MYSQL_THDVAR_INT( "Bulk insert size", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 16000, /* def */ -1, /* min */ 2147483647, /* max */ 0 /* blk */ ); -int spider_param_bulk_size( - THD *thd, - int bulk_size -) { - DBUG_ENTER("spider_param_bulk_size"); - DBUG_RETURN(THDVAR(thd, bulk_size) < 0 ? - bulk_size : THDVAR(thd, bulk_size)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, bulk_size) /* - -1 :use table parameter + -1 :fallback to default 0 : Send "update" and "delete" statements one by one. 1 : Send collected multiple "update" and "delete" statements. (Collected statements are sent one by one) @@ -1011,23 +899,16 @@ static MYSQL_THDVAR_INT( "The mode of bulk updating and deleting", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 2, /* max */ 0 /* blk */ ); -int spider_param_bulk_update_mode( - THD *thd, - int bulk_update_mode -) { - DBUG_ENTER("spider_param_bulk_update_mode"); - DBUG_RETURN(THDVAR(thd, bulk_update_mode) == -1 ? - bulk_update_mode : THDVAR(thd, bulk_update_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, bulk_update_mode) /* - -1 :use table parameter + -1 :fallback to default 0-:bulk update size */ static MYSQL_THDVAR_INT( @@ -1036,23 +917,24 @@ static MYSQL_THDVAR_INT( "Bulk update size", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 16000, /* def */ -1, /* min */ 2147483647, /* max */ 0 /* blk */ ); -int spider_param_bulk_update_size( - THD *thd, - int bulk_update_size -) { - DBUG_ENTER("spider_param_bulk_update_size"); - DBUG_RETURN(THDVAR(thd, bulk_update_size) == -1 ? - bulk_update_size : THDVAR(thd, bulk_update_size)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, bulk_update_size) /* - -1 :use table parameter + Notes on merge conflicts (remove after merging): + 10.5: 48faa20db848012e2187a09e05aba832078cb82e + 10.6: 51ff9eddf7c0aaf1e022fcb3b48ec36835df7785 + 10.9: 06a61b8e453126c2de1649073f247d34e85f9702 + 10.10: 90cd0c156f5bb53fd058d2bbfb83f850ffae6722 + 10.11+: 124eb662700708f3c4b0fb77968f8b854d6bb4aa +*/ +/* + -1 :fallback to default 0 :off 1 :on */ @@ -1062,23 +944,16 @@ static MYSQL_THDVAR_INT( "Execute optimize to remote server", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_internal_optimize( - THD *thd, - int internal_optimize -) { - DBUG_ENTER("spider_param_internal_optimize"); - DBUG_RETURN(THDVAR(thd, internal_optimize) == -1 ? - internal_optimize : THDVAR(thd, internal_optimize)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, internal_optimize) /* - -1 :use table parameter + -1 :fallback to default 0 :off 1 :on */ @@ -1088,20 +963,13 @@ static MYSQL_THDVAR_INT( "Execute optimize to remote server with local", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_internal_optimize_local( - THD *thd, - int internal_optimize_local -) { - DBUG_ENTER("spider_param_internal_optimize_local"); - DBUG_RETURN(THDVAR(thd, internal_optimize_local) == -1 ? - internal_optimize_local : THDVAR(thd, internal_optimize_local)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, internal_optimize_local) /* FALSE: off @@ -1116,12 +984,7 @@ static MYSQL_THDVAR_BOOL( FALSE /* def */ ); -bool spider_param_use_flash_logs( - THD *thd -) { - DBUG_ENTER("spider_param_use_flash_logs"); - DBUG_RETURN(THDVAR(thd, use_flash_logs)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, use_flash_logs) /* 0 :off @@ -1140,12 +1003,7 @@ static MYSQL_THDVAR_INT( 0 /* blk */ ); -int spider_param_use_snapshot_with_flush_tables( - THD *thd -) { - DBUG_ENTER("spider_param_use_snapshot_with_flush_tables"); - DBUG_RETURN(THDVAR(thd, use_snapshot_with_flush_tables)); -} +SPIDER_THDVAR_VALUE_FUNC(int, use_snapshot_with_flush_tables) /* FALSE: off @@ -1160,12 +1018,7 @@ static MYSQL_THDVAR_BOOL( FALSE /* def */ ); -bool spider_param_use_all_conns_snapshot( - THD *thd -) { - DBUG_ENTER("spider_param_use_all_conns_snapshot"); - DBUG_RETURN(THDVAR(thd, use_all_conns_snapshot)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, use_all_conns_snapshot) /* FALSE: off @@ -1180,12 +1033,7 @@ static MYSQL_THDVAR_BOOL( FALSE /* def */ ); -bool spider_param_lock_exchange( - THD *thd -) { - DBUG_ENTER("spider_param_lock_exchange"); - DBUG_RETURN(THDVAR(thd, lock_exchange)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, lock_exchange) /* FALSE: off @@ -1200,12 +1048,7 @@ static MYSQL_THDVAR_BOOL( FALSE /* def */ ); -bool spider_param_internal_unlock( - THD *thd -) { - DBUG_ENTER("spider_param_internal_unlock"); - DBUG_RETURN(THDVAR(thd, internal_unlock)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, internal_unlock) /* FALSE: off @@ -1220,15 +1063,10 @@ static MYSQL_THDVAR_BOOL( TRUE /* def */ ); -bool spider_param_semi_trx( - THD *thd -) { - DBUG_ENTER("spider_param_semi_trx"); - DBUG_RETURN(THDVAR(thd, semi_trx)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, semi_trx) /* - -1 :use table parameter + -1 :fallback to default 0-:seconds of timeout */ static MYSQL_THDVAR_INT( @@ -1237,25 +1075,16 @@ static MYSQL_THDVAR_INT( "Wait timeout of connecting to remote server", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 6, /* def */ -1, /* min */ 2147483647, /* max */ 0 /* blk */ ); -int spider_param_connect_timeout( - THD *thd, - int connect_timeout -) { - DBUG_ENTER("spider_param_connect_timeout"); - if (thd) - DBUG_RETURN(THDVAR(thd, connect_timeout) == -1 ? - connect_timeout : THDVAR(thd, connect_timeout)); - DBUG_RETURN(connect_timeout); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, connect_timeout) /* - -1 :use table parameter + -1 :fallback to default 0-:seconds of timeout */ static MYSQL_THDVAR_INT( @@ -1264,25 +1093,16 @@ static MYSQL_THDVAR_INT( "Wait timeout of receiving data from remote server", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 600, /* def */ -1, /* min */ 2147483647, /* max */ 0 /* blk */ ); -int spider_param_net_read_timeout( - THD *thd, - int net_read_timeout -) { - DBUG_ENTER("spider_param_net_read_timeout"); - if (thd) - DBUG_RETURN(THDVAR(thd, net_read_timeout) == -1 ? - net_read_timeout : THDVAR(thd, net_read_timeout)); - DBUG_RETURN(net_read_timeout); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, net_read_timeout) /* - -1 :use table parameter + -1 :fallback to default 0-:seconds of timeout */ static MYSQL_THDVAR_INT( @@ -1291,25 +1111,16 @@ static MYSQL_THDVAR_INT( "Wait timeout of sending data to remote server", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 600, /* def */ -1, /* min */ 2147483647, /* max */ 0 /* blk */ ); -int spider_param_net_write_timeout( - THD *thd, - int net_write_timeout -) { - DBUG_ENTER("spider_param_net_write_timeout"); - if (thd) - DBUG_RETURN(THDVAR(thd, net_write_timeout) == -1 ? - net_write_timeout : THDVAR(thd, net_write_timeout)); - DBUG_RETURN(net_write_timeout); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, net_write_timeout) /* - -1 :use table parameter + -1 :fallback to default 0 :It acquires it collectively. 1 :Acquisition one by one.If it discontinues once, and it will need it later, it retrieves it again when there is interrupt on the way. @@ -1322,23 +1133,16 @@ static MYSQL_THDVAR_INT( "The retrieval result from a remote server is acquired by acquisition one by one", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 3, /* def */ -1, /* min */ 3, /* max */ 0 /* blk */ ); -int spider_param_quick_mode( - THD *thd, - int quick_mode -) { - DBUG_ENTER("spider_param_quick_mode"); - DBUG_RETURN(THDVAR(thd, quick_mode) < 0 ? - quick_mode : THDVAR(thd, quick_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, quick_mode) /* - -1 :use table parameter + -1 :fallback to default 0-:number of records */ static MYSQL_THDVAR_LONGLONG( @@ -1347,23 +1151,16 @@ static MYSQL_THDVAR_LONGLONG( "Number of records in a page when acquisition one by one", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 1024, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_quick_page_size( - THD *thd, - longlong quick_page_size -) { - DBUG_ENTER("spider_param_quick_page_size"); - DBUG_RETURN(THDVAR(thd, quick_page_size) < 0 ? - quick_page_size : THDVAR(thd, quick_page_size)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(longlong, quick_page_size) /* - -1 :use table parameter + -1 :fallback to default 0-:the limitation of memory size */ static MYSQL_THDVAR_LONGLONG( @@ -1372,23 +1169,16 @@ static MYSQL_THDVAR_LONGLONG( "The limitation of memory size in a page when acquisition one by one", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 10485760, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_quick_page_byte( - THD *thd, - longlong quick_page_byte -) { - DBUG_ENTER("spider_param_quick_page_byte"); - DBUG_RETURN(THDVAR(thd, quick_page_byte) < 0 ? - quick_page_byte : THDVAR(thd, quick_page_byte)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(longlong, quick_page_byte) /* - -1 :use table parameter + -1 :fallback to default 0 :It doesn't use low memory mode. 1 :It uses low memory mode. */ @@ -1398,23 +1188,16 @@ static MYSQL_THDVAR_INT( "Use low memory mode when SQL(SELECT) internally issued to a remote server is executed and get a result list", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 1, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_low_mem_read( - THD *thd, - int low_mem_read -) { - DBUG_ENTER("spider_param_low_mem_read"); - DBUG_RETURN(THDVAR(thd, low_mem_read) < 0 ? - low_mem_read : THDVAR(thd, low_mem_read)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, low_mem_read) /* - -1 :use table parameter + -1 :fallback to default 0 :Use index columns if select statement can solve by using index, otherwise use all columns. 1 :Use columns that are judged necessary. @@ -1425,24 +1208,17 @@ static MYSQL_THDVAR_INT( "The mode of using columns at select clause", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 1, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_select_column_mode( - THD *thd, - int select_column_mode -) { - DBUG_ENTER("spider_param_select_column_mode"); - DBUG_RETURN(THDVAR(thd, select_column_mode) == -1 ? - select_column_mode : THDVAR(thd, select_column_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, select_column_mode) #ifndef WITHOUT_SPIDER_BG_SEARCH /* - -1 :use table parameter + -1 :fallback to default 0 :background search is disabled 1 :background search is used if search with no lock 2 :background search is used if search with no lock or shared lock @@ -1454,23 +1230,16 @@ static MYSQL_THDVAR_INT( "Mode of background search", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 3, /* max */ 0 /* blk */ ); -int spider_param_bgs_mode( - THD *thd, - int bgs_mode -) { - DBUG_ENTER("spider_param_bgs_mode"); - DBUG_RETURN(THDVAR(thd, bgs_mode) < 0 ? - bgs_mode : THDVAR(thd, bgs_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, bgs_mode) /* - -1 :use table parameter + -1 :fallback to default 0 :records is gotten usually 1-:number of records */ @@ -1480,23 +1249,16 @@ static MYSQL_THDVAR_LONGLONG( "Number of first read records when background search is used", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 2, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_bgs_first_read( - THD *thd, - longlong bgs_first_read -) { - DBUG_ENTER("spider_param_bgs_first_read"); - DBUG_RETURN(THDVAR(thd, bgs_first_read) < 0 ? - bgs_first_read : THDVAR(thd, bgs_first_read)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(longlong, bgs_first_read) /* - -1 :use table parameter + -1 :fallback to default 0 :records is gotten usually 1-:number of records */ @@ -1506,24 +1268,17 @@ static MYSQL_THDVAR_LONGLONG( "Number of second read records when background search is used", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 100, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_bgs_second_read( - THD *thd, - longlong bgs_second_read -) { - DBUG_ENTER("spider_param_bgs_second_read"); - DBUG_RETURN(THDVAR(thd, bgs_second_read) < 0 ? - bgs_second_read : THDVAR(thd, bgs_second_read)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(longlong, bgs_second_read) #endif /* - -1 :use table parameter + -1 :fallback to default 0 :records is gotten usually 1-:number of records */ @@ -1533,23 +1288,16 @@ static MYSQL_THDVAR_LONGLONG( "Number of first read records", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_first_read( - THD *thd, - longlong first_read -) { - DBUG_ENTER("spider_param_first_read"); - DBUG_RETURN(THDVAR(thd, first_read) < 0 ? - first_read : THDVAR(thd, first_read)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(longlong, first_read) /* - -1 :use table parameter + -1 :fallback to default 0 :records is gotten usually 1-:number of records */ @@ -1559,23 +1307,16 @@ static MYSQL_THDVAR_LONGLONG( "Number of second read records", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_second_read( - THD *thd, - longlong second_read -) { - DBUG_ENTER("spider_param_second_read"); - DBUG_RETURN(THDVAR(thd, second_read) < 0 ? - second_read : THDVAR(thd, second_read)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(longlong, second_read) /* - -1 :use table parameter + -1 :fallback to default 0 :always get the newest information 1-:interval */ @@ -1585,23 +1326,16 @@ static MYSQL_THDVAR_INT( "Interval of cardinality confirmation.(second)", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 51, /* def */ -1, /* min */ 2147483647, /* max */ 0 /* blk */ ); -double spider_param_crd_interval( - THD *thd, - double crd_interval -) { - DBUG_ENTER("spider_param_crd_interval"); - DBUG_RETURN(THDVAR(thd, crd_interval) == -1 ? - crd_interval : THDVAR(thd, crd_interval)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(double, crd_interval) /* - -1 :use table parameter + -1 :fallback to default 0 :use table parameter 1 :use show command 2 :use information schema @@ -1613,24 +1347,17 @@ static MYSQL_THDVAR_INT( "Mode of cardinality confirmation.", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 1, /* def */ -1, /* min */ 3, /* max */ 0 /* blk */ ); -int spider_param_crd_mode( - THD *thd, - int crd_mode -) { - DBUG_ENTER("spider_param_crd_mode"); - DBUG_RETURN(THDVAR(thd, crd_mode) <= 0 ? - crd_mode : THDVAR(thd, crd_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, crd_mode) #ifdef WITH_PARTITION_STORAGE_ENGINE /* - -1 :use table parameter + -1 :fallback to default 0 :No synchronization. 1 :Cardinality is synchronized when opening a table. Then no synchronization. @@ -1642,24 +1369,17 @@ static MYSQL_THDVAR_INT( "Cardinality synchronization in partitioned table.", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 2, /* max */ 0 /* blk */ ); -int spider_param_crd_sync( - THD *thd, - int crd_sync -) { - DBUG_ENTER("spider_param_crd_sync"); - DBUG_RETURN(THDVAR(thd, crd_sync) == -1 ? - crd_sync : THDVAR(thd, crd_sync)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, crd_sync) #endif /* - -1 :use table parameter + -1 :fallback to default 0 :The crd_weight is used as a fixed value. 1 :The crd_weight is used as an addition value. 2 :The crd_weight is used as a multiplication value. @@ -1670,23 +1390,16 @@ static MYSQL_THDVAR_INT( "Type of cardinality calculation.", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 2, /* def */ -1, /* min */ 2, /* max */ 0 /* blk */ ); -int spider_param_crd_type( - THD *thd, - int crd_type -) { - DBUG_ENTER("spider_param_crd_type"); - DBUG_RETURN(THDVAR(thd, crd_type) == -1 ? - crd_type : THDVAR(thd, crd_type)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, crd_type) /* - -1 :use table parameter + -1 :fallback to default 0-:weight */ static MYSQL_THDVAR_INT( @@ -1695,24 +1408,17 @@ static MYSQL_THDVAR_INT( "Weight coefficient to calculate effectiveness of index from cardinality of column.", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 2, /* def */ -1, /* min */ 2147483647, /* max */ 0 /* blk */ ); -double spider_param_crd_weight( - THD *thd, - double crd_weight -) { - DBUG_ENTER("spider_param_crd_weight"); - DBUG_RETURN(THDVAR(thd, crd_weight) == -1 ? - crd_weight : THDVAR(thd, crd_weight)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(double, crd_weight) #ifndef WITHOUT_SPIDER_BG_SEARCH /* - -1 :use table parameter + -1 :fallback to default 0 :Background confirmation is disabled 1 :Background confirmation is enabled (create thread per table/partition) 2 :Background confirmation is enabled (use static threads) @@ -1723,24 +1429,17 @@ static MYSQL_THDVAR_INT( "Mode of cardinality confirmation at background.", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 2, /* def */ -1, /* min */ 2, /* max */ 0 /* blk */ ); -int spider_param_crd_bg_mode( - THD *thd, - int crd_bg_mode -) { - DBUG_ENTER("spider_param_crd_bg_mode"); - DBUG_RETURN(THDVAR(thd, crd_bg_mode) == -1 ? - crd_bg_mode : THDVAR(thd, crd_bg_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, crd_bg_mode) #endif /* - -1 :use table parameter + -1 :fallback to default 0 :always get the newest information 1-:interval */ @@ -1750,23 +1449,16 @@ static MYSQL_THDVAR_INT( "Interval of table state confirmation.(second)", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 10, /* def */ -1, /* min */ 2147483647, /* max */ 0 /* blk */ ); -double spider_param_sts_interval( - THD *thd, - double sts_interval -) { - DBUG_ENTER("spider_param_sts_interval"); - DBUG_RETURN(THDVAR(thd, sts_interval) == -1 ? - sts_interval : THDVAR(thd, sts_interval)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(double, sts_interval) /* - -1 :use table parameter + -1 :fallback to default 0 :use table parameter 1 :use show command 2 :use information schema @@ -1777,24 +1469,17 @@ static MYSQL_THDVAR_INT( "Mode of table state confirmation.", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 1, /* def */ -1, /* min */ 2, /* max */ 0 /* blk */ ); -int spider_param_sts_mode( - THD *thd, - int sts_mode -) { - DBUG_ENTER("spider_param_sts_mode"); - DBUG_RETURN(THDVAR(thd, sts_mode) <= 0 ? - sts_mode : THDVAR(thd, sts_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, sts_mode) #ifdef WITH_PARTITION_STORAGE_ENGINE /* - -1 :use table parameter + -1 :fallback to default 0 :No synchronization. 1 :Table state is synchronized when opening a table. Then no synchronization. @@ -1806,25 +1491,18 @@ static MYSQL_THDVAR_INT( "Table state synchronization in partitioned table.", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 2, /* max */ 0 /* blk */ ); -int spider_param_sts_sync( - THD *thd, - int sts_sync -) { - DBUG_ENTER("spider_param_sts_sync"); - DBUG_RETURN(THDVAR(thd, sts_sync) == -1 ? - sts_sync : THDVAR(thd, sts_sync)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, sts_sync) #endif #ifndef WITHOUT_SPIDER_BG_SEARCH /* - -1 :use table parameter + -1 :fallback to default 0 :Background confirmation is disabled 1 :Background confirmation is enabled (create thread per table/partition) 2 :Background confirmation is enabled (use static threads) @@ -1835,20 +1513,13 @@ static MYSQL_THDVAR_INT( "Mode of table state confirmation at background.", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 2, /* def */ -1, /* min */ 2, /* max */ 0 /* blk */ ); -int spider_param_sts_bg_mode( - THD *thd, - int sts_bg_mode -) { - DBUG_ENTER("spider_param_sts_bg_mode"); - DBUG_RETURN(THDVAR(thd, sts_bg_mode) == -1 ? - sts_bg_mode : THDVAR(thd, sts_bg_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, sts_bg_mode) #endif /* @@ -1867,12 +1538,7 @@ static MYSQL_THDVAR_INT( 0 /* blk */ ); -double spider_param_ping_interval_at_trx_start( - THD *thd -) { - DBUG_ENTER("spider_param_ping_interval_at_trx_start"); - DBUG_RETURN(THDVAR(thd, ping_interval_at_trx_start)); -} +SPIDER_THDVAR_VALUE_FUNC(double, ping_interval_at_trx_start) #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) /* @@ -1900,7 +1566,7 @@ double spider_param_hs_ping_interval( #endif /* - -1 :use table parameter + -1 :fallback to default 0 :normal mode 1 :quick mode 2 :set 0 value @@ -1911,20 +1577,13 @@ static MYSQL_THDVAR_INT( "Mode of auto increment.", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 3, /* max */ 0 /* blk */ ); -int spider_param_auto_increment_mode( - THD *thd, - int auto_increment_mode -) { - DBUG_ENTER("spider_param_auto_increment_mode"); - DBUG_RETURN(THDVAR(thd, auto_increment_mode) == -1 ? - auto_increment_mode : THDVAR(thd, auto_increment_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, auto_increment_mode) /* FALSE: off @@ -1939,12 +1598,7 @@ static MYSQL_THDVAR_BOOL( FALSE /* def */ ); -bool spider_param_same_server_link( - THD *thd -) { - DBUG_ENTER("spider_param_same_server_link"); - DBUG_RETURN(THDVAR(thd, same_server_link)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, same_server_link) /* FALSE: transmits @@ -1960,15 +1614,10 @@ static MYSQL_THDVAR_BOOL( FALSE /* def */ ); -bool spider_param_local_lock_table( - THD *thd -) { - DBUG_ENTER("spider_param_local_lock_table"); - DBUG_RETURN(THDVAR(thd, local_lock_table)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, local_lock_table) /* - -1 :use table parameter + -1 :fallback to default 0 :don't transmit 1 :transmits */ @@ -1984,17 +1633,10 @@ static MYSQL_THDVAR_INT( 0 /* blk */ ); -int spider_param_use_pushdown_udf( - THD *thd, - int use_pushdown_udf -) { - DBUG_ENTER("spider_param_use_pushdown_udf"); - DBUG_RETURN(THDVAR(thd, use_pushdown_udf) == -1 ? - use_pushdown_udf : THDVAR(thd, use_pushdown_udf)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, use_pushdown_udf) /* - -1 :use table parameter + -1 :fallback to default 0 :duplicate check on local server 1 :avoid duplicate check on local server */ @@ -2004,20 +1646,13 @@ static MYSQL_THDVAR_INT( "Execute \"REPLACE\" and \"INSERT IGNORE\" on remote server and avoid duplicate check on local server", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_direct_dup_insert( - THD *thd, - int direct_dup_insert -) { - DBUG_ENTER("spider_param_direct_dup_insert"); - DBUG_RETURN(THDVAR(thd, direct_dup_insert) < 0 ? - direct_dup_insert : THDVAR(thd, direct_dup_insert)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, direct_dup_insert) static uint spider_udf_table_lock_mutex_count; /* @@ -2036,11 +1671,7 @@ static MYSQL_SYSVAR_UINT( 0 ); -uint spider_param_udf_table_lock_mutex_count() -{ - DBUG_ENTER("spider_param_udf_table_lock_mutex_count"); - DBUG_RETURN(spider_udf_table_lock_mutex_count); -} +SPIDER_SYSVAR_VALUE_FUNC(uint, udf_table_lock_mutex_count) static uint spider_udf_table_mon_mutex_count; /* @@ -2059,11 +1690,7 @@ static MYSQL_SYSVAR_UINT( 0 ); -uint spider_param_udf_table_mon_mutex_count() -{ - DBUG_ENTER("spider_param_udf_table_mon_mutex_count"); - DBUG_RETURN(spider_udf_table_mon_mutex_count); -} +SPIDER_SYSVAR_VALUE_FUNC(uint, udf_table_mon_mutex_count) /* 1-:number of rows @@ -2074,23 +1701,16 @@ static MYSQL_THDVAR_LONGLONG( "Number of rows for bulk inserting", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 3000, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_udf_ds_bulk_insert_rows( - THD *thd, - longlong udf_ds_bulk_insert_rows -) { - DBUG_ENTER("spider_param_udf_ds_bulk_insert_rows"); - DBUG_RETURN(THDVAR(thd, udf_ds_bulk_insert_rows) <= 0 ? - udf_ds_bulk_insert_rows : THDVAR(thd, udf_ds_bulk_insert_rows)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(longlong, udf_ds_bulk_insert_rows) /* - -1 :use table parameter + -1 :fallback to default 0 :drop records 1 :insert last table 2 :insert first table and loop again @@ -2101,20 +1721,13 @@ static MYSQL_THDVAR_INT( "Table loop mode if the number of tables in table list are less than the number of result sets", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 2, /* max */ 0 /* blk */ ); -int spider_param_udf_ds_table_loop_mode( - THD *thd, - int udf_ds_table_loop_mode -) { - DBUG_ENTER("spider_param_udf_ds_table_loop_mode"); - DBUG_RETURN(THDVAR(thd, udf_ds_table_loop_mode) == -1 ? - udf_ds_table_loop_mode : THDVAR(thd, udf_ds_table_loop_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, udf_ds_table_loop_mode) static char *spider_remote_access_charset; /* @@ -2155,11 +1768,7 @@ static MYSQL_SYSVAR_STR( #endif #endif -char *spider_param_remote_access_charset() -{ - DBUG_ENTER("spider_param_remote_access_charset"); - DBUG_RETURN(spider_remote_access_charset); -} +SPIDER_SYSVAR_VALUE_FUNC(char*, remote_access_charset) static int spider_remote_autocommit; /* @@ -2180,11 +1789,7 @@ static MYSQL_SYSVAR_INT( 0 ); -int spider_param_remote_autocommit() -{ - DBUG_ENTER("spider_param_remote_autocommit"); - DBUG_RETURN(spider_remote_autocommit); -} +SPIDER_SYSVAR_VALUE_FUNC(int, remote_autocommit) static char *spider_remote_time_zone; /* @@ -2225,11 +1830,7 @@ static MYSQL_SYSVAR_STR( #endif #endif -char *spider_param_remote_time_zone() -{ - DBUG_ENTER("spider_param_remote_time_zone"); - DBUG_RETURN(spider_remote_time_zone); -} +SPIDER_SYSVAR_VALUE_FUNC(char *, remote_time_zone) static int spider_remote_sql_log_off; /* @@ -2250,11 +1851,7 @@ static MYSQL_SYSVAR_INT( 0 ); -int spider_param_remote_sql_log_off() -{ - DBUG_ENTER("spider_param_remote_sql_log_off"); - DBUG_RETURN(spider_remote_sql_log_off); -} +SPIDER_SYSVAR_VALUE_FUNC(int, remote_sql_log_off) static int spider_remote_trx_isolation; /* @@ -2277,11 +1874,7 @@ static MYSQL_SYSVAR_INT( 0 ); -int spider_param_remote_trx_isolation() -{ - DBUG_ENTER("spider_param_remote_trx_isolation"); - DBUG_RETURN(spider_remote_trx_isolation); -} +SPIDER_SYSVAR_VALUE_FUNC(int, remote_trx_isolation) static char *spider_remote_default_database; /* @@ -2322,11 +1915,7 @@ static MYSQL_SYSVAR_STR( #endif #endif -char *spider_param_remote_default_database() -{ - DBUG_ENTER("spider_param_remote_default_database"); - DBUG_RETURN(spider_remote_default_database); -} +SPIDER_SYSVAR_VALUE_FUNC(char *, remote_default_database) /* 0-:connect retry interval (micro second) @@ -2416,12 +2005,11 @@ char *spider_param_bka_engine( char *bka_engine ) { DBUG_ENTER("spider_param_bka_engine"); - DBUG_RETURN(THDVAR(thd, bka_engine) ? - THDVAR(thd, bka_engine) : bka_engine); + DBUG_RETURN(bka_engine ? bka_engine : THDVAR(thd, bka_engine)); } /* - -1 :use table parameter + -1 :fallback to default 0 :use union all 1 :use temporary table */ @@ -2431,24 +2019,17 @@ static MYSQL_THDVAR_INT( "Mode of BKA for Spider", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 1, /* def */ -1, /* min */ 2, /* max */ 0 /* blk */ ); -int spider_param_bka_mode( - THD *thd, - int bka_mode -) { - DBUG_ENTER("spider_param_bka_mode"); - DBUG_RETURN(THDVAR(thd, bka_mode) == -1 ? - bka_mode : THDVAR(thd, bka_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, bka_mode) static int spider_udf_ct_bulk_insert_interval; /* - -1 : The UDF parameter is adopted. + -1 : Fallback to default. 0 or more : Milliseconds. */ static MYSQL_SYSVAR_INT( @@ -2458,23 +2039,17 @@ static MYSQL_SYSVAR_INT( "The interval time between bulk insert and next bulk insert at coping", NULL, NULL, - -1, + 10, -1, 2147483647, 0 ); -int spider_param_udf_ct_bulk_insert_interval( - int udf_ct_bulk_insert_interval -) { - DBUG_ENTER("spider_param_udf_ct_bulk_insert_interval"); - DBUG_RETURN(spider_udf_ct_bulk_insert_interval < 0 ? - udf_ct_bulk_insert_interval : spider_udf_ct_bulk_insert_interval); -} +SPIDER_SYSVAR_OVERRIDE_VALUE_FUNC(int, udf_ct_bulk_insert_interval) static longlong spider_udf_ct_bulk_insert_rows; /* - -1,0 : The UDF parameter is adopted. + -1,0 : Fallback to default. 1 or more : Number of rows. */ static MYSQL_SYSVAR_LONGLONG( @@ -2484,19 +2059,13 @@ static MYSQL_SYSVAR_LONGLONG( "The number of rows inserted with bulk insert of one time at coping", NULL, NULL, - -1, + 100, -1, 9223372036854775807LL, 0 ); -longlong spider_param_udf_ct_bulk_insert_rows( - longlong udf_ct_bulk_insert_rows -) { - DBUG_ENTER("spider_param_udf_ct_bulk_insert_rows"); - DBUG_RETURN(spider_udf_ct_bulk_insert_rows <= 0 ? - udf_ct_bulk_insert_rows : spider_udf_ct_bulk_insert_rows); -} +SPIDER_SYSVAR_OVERRIDE_VALUE_FUNC(longlong, udf_ct_bulk_insert_rows) #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) /* @@ -2594,7 +2163,7 @@ uint spider_param_hs_w_conn_recycle_strict( } /* - -1 :use table parameter + -1 :fallback to default 0 :not use 1 :use handlersocket */ @@ -2604,23 +2173,16 @@ static MYSQL_THDVAR_INT( "Use handlersocket for reading", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_use_hs_read( - THD *thd, - int use_hs_read -) { - DBUG_ENTER("spider_param_use_hs_read"); - DBUG_RETURN(THDVAR(thd, use_hs_read) == -1 ? - use_hs_read : THDVAR(thd, use_hs_read)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUN(int, use_hs_read) /* - -1 :use table parameter + -1 :fallback to default 0 :not use 1 :use handlersocket */ @@ -2630,24 +2192,17 @@ static MYSQL_THDVAR_INT( "Use handlersocket for writing", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_use_hs_write( - THD *thd, - int use_hs_write -) { - DBUG_ENTER("spider_param_use_hs_write"); - DBUG_RETURN(THDVAR(thd, use_hs_write) == -1 ? - use_hs_write : THDVAR(thd, use_hs_write)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUN(int, use_hs_write) #endif /* - -1 :use table parameter + -1 :fallback to default 0 :not use 1 :use handler */ @@ -2657,23 +2212,16 @@ static MYSQL_THDVAR_INT( "Use handler for reading", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 3, /* max */ 0 /* blk */ ); -int spider_param_use_handler( - THD *thd, - int use_handler -) { - DBUG_ENTER("spider_param_use_handler"); - DBUG_RETURN(THDVAR(thd, use_handler) == -1 ? - use_handler : THDVAR(thd, use_handler)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, use_handler) /* - -1 :use table parameter + -1 :fallback to default 0 :return error if error 1 :return 0 record if error */ @@ -2683,23 +2231,16 @@ static MYSQL_THDVAR_INT( "Read error mode if error", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_error_read_mode( - THD *thd, - int error_read_mode -) { - DBUG_ENTER("spider_param_error_read_mode"); - DBUG_RETURN(THDVAR(thd, error_read_mode) == -1 ? - error_read_mode : THDVAR(thd, error_read_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, error_read_mode) /* - -1 :use table parameter + -1 :fallback to default 0 :return error if error 1 :return 0 record if error */ @@ -2709,23 +2250,16 @@ static MYSQL_THDVAR_INT( "Write error mode if error", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_error_write_mode( - THD *thd, - int error_write_mode -) { - DBUG_ENTER("spider_param_error_write_mode"); - DBUG_RETURN(THDVAR(thd, error_write_mode) == -1 ? - error_write_mode : THDVAR(thd, error_write_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, error_write_mode) /* - -1 :use table parameter + -1 :fallback to default 0 :not skip 1 :skip */ @@ -2735,23 +2269,16 @@ static MYSQL_THDVAR_INT( "Skip generating internal default condition", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_skip_default_condition( - THD *thd, - int skip_default_condition -) { - DBUG_ENTER("spider_param_skip_default_condition"); - DBUG_RETURN(THDVAR(thd, skip_default_condition) == -1 ? - skip_default_condition : THDVAR(thd, skip_default_condition)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, skip_default_condition) /* - -1 :use table parameter + -1 :fallback to default 0 :not skip 1 :skip parallel search if query is not SELECT statement 2 :skip parallel search if query has SQL_NO_CACHE @@ -2763,23 +2290,16 @@ static MYSQL_THDVAR_INT( "Skip parallel search by specific conditions", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 3, /* max */ 0 /* blk */ ); -int spider_param_skip_parallel_search( - THD *thd, - int skip_parallel_search -) { - DBUG_ENTER("spider_param_skip_parallel_search"); - DBUG_RETURN(THDVAR(thd, skip_parallel_search) == -1 ? - skip_parallel_search : THDVAR(thd, skip_parallel_search)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, skip_parallel_search) /* - -1 :use table parameter + -1 :fallback to default 0 :not send directly 1-:send directly */ @@ -2789,23 +2309,16 @@ static MYSQL_THDVAR_LONGLONG( "Send 'ORDER BY' and 'LIMIT' to remote server directly", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 9223372036854775807LL, /* def */ -1, /* min */ 9223372036854775807LL, /* max */ 0 /* blk */ ); -longlong spider_param_direct_order_limit( - THD *thd, - longlong direct_order_limit -) { - DBUG_ENTER("spider_param_direct_order_limit"); - DBUG_RETURN(THDVAR(thd, direct_order_limit) == -1 ? - direct_order_limit : THDVAR(thd, direct_order_limit)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(longlong, direct_order_limit) /* - -1 :use table parameter + -1 :fallback to default 0 :writable 1 :read only */ @@ -2815,25 +2328,18 @@ static MYSQL_THDVAR_INT( "Read only", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_read_only_mode( - THD *thd, - int read_only_mode -) { - DBUG_ENTER("spider_param_read_only_mode"); - DBUG_RETURN(THDVAR(thd, read_only_mode) == -1 ? - read_only_mode : THDVAR(thd, read_only_mode)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, read_only_mode) #ifdef HA_CAN_BULK_ACCESS static int spider_bulk_access_free; /* - -1 :use table parameter + -1 :fallback to default 0 :in reset 1 :in close */ @@ -2844,25 +2350,19 @@ static MYSQL_SYSVAR_INT( "Free mode of bulk access resources", NULL, NULL, - -1, + 0, -1, 1, 0 ); -int spider_param_bulk_access_free( - int bulk_access_free -) { - DBUG_ENTER("spider_param_bulk_access_free"); - DBUG_RETURN(spider_bulk_access_free == -1 ? - bulk_access_free : spider_bulk_access_free); -} +SPIDER_SYSVAR_OVERRIDE_VALUE_FUN(int, bulk_access_free) #endif #if MYSQL_VERSION_ID < 50500 #else /* - -1 :use UDF parameter + -1 :fallback to default 0 :can not use 1 :can use */ @@ -2872,20 +2372,13 @@ static MYSQL_THDVAR_INT( "Use real table for temporary table list", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_udf_ds_use_real_table( - THD *thd, - int udf_ds_use_real_table -) { - DBUG_ENTER("spider_param_udf_ds_use_real_table"); - DBUG_RETURN(THDVAR(thd, udf_ds_use_real_table) == -1 ? - udf_ds_use_real_table : THDVAR(thd, udf_ds_use_real_table)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, udf_ds_use_real_table) #endif static my_bool spider_general_log; @@ -2899,11 +2392,7 @@ static MYSQL_SYSVAR_BOOL( FALSE ); -my_bool spider_param_general_log() -{ - DBUG_ENTER("spider_param_general_log"); - DBUG_RETURN(spider_general_log); -} +SPIDER_SYSVAR_VALUE_FUNC(my_bool, general_log) /* FALSE: no pushdown hints @@ -2918,12 +2407,7 @@ static MYSQL_THDVAR_BOOL( FALSE /* def */ ); -my_bool spider_param_index_hint_pushdown( - THD *thd -) { - DBUG_ENTER("spider_param_index_hint_pushdown"); - DBUG_RETURN(THDVAR(thd, index_hint_pushdown)); -} +SPIDER_THDVAR_VALUE_FUNC(my_bool, index_hint_pushdown) static uint spider_max_connections; static MYSQL_SYSVAR_UINT( @@ -2939,11 +2423,7 @@ static MYSQL_SYSVAR_UINT( 0 /* blk */ ); -uint spider_param_max_connections() -{ - DBUG_ENTER("spider_param_max_connections"); - DBUG_RETURN(spider_max_connections); -} +SPIDER_SYSVAR_VALUE_FUNC(uint, max_connections) static uint spider_conn_wait_timeout; static MYSQL_SYSVAR_UINT( @@ -2959,11 +2439,7 @@ static MYSQL_SYSVAR_UINT( 0 /* blk */ ); -uint spider_param_conn_wait_timeout() -{ - DBUG_ENTER("spider_param_conn_wait_timeout"); - DBUG_RETURN(spider_conn_wait_timeout); -} +SPIDER_SYSVAR_VALUE_FUNC(uint, conn_wait_timeout) static uint spider_log_result_errors; /* @@ -2986,11 +2462,7 @@ static MYSQL_SYSVAR_UINT( 0 ); -uint spider_param_log_result_errors() -{ - DBUG_ENTER("spider_param_log_result_errors"); - DBUG_RETURN(spider_log_result_errors); -} +SPIDER_SYSVAR_VALUE_FUNC(uint, log_result_errors) static uint spider_log_result_error_with_sql; /* @@ -3012,11 +2484,7 @@ static MYSQL_SYSVAR_UINT( 0 ); -uint spider_param_log_result_error_with_sql() -{ - DBUG_ENTER("spider_param_log_result_error_with_sql"); - DBUG_RETURN(spider_log_result_error_with_sql); -} +SPIDER_SYSVAR_VALUE_FUNC(uint, log_result_error_with_sql) static char *spider_version = (char *) SPIDER_DETAIL_VERSION; static MYSQL_SYSVAR_STR( @@ -3045,15 +2513,10 @@ static MYSQL_THDVAR_UINT( 0 /* blk */ ); -uint spider_param_internal_xa_id_type( - THD *thd -) { - DBUG_ENTER("spider_param_internal_xa_id_type"); - DBUG_RETURN(THDVAR(thd, internal_xa_id_type)); -} +SPIDER_THDVAR_VALUE_FUNC(uint, internal_xa_id_type) /* - -1 :use table parameter + -1 :fallback to default 0 :OFF 1 :automatic channel 2-63 :use custom channel @@ -3064,20 +2527,13 @@ static MYSQL_THDVAR_INT( "Read casually if it is possible", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 63, /* max */ 0 /* blk */ ); -int spider_param_casual_read( - THD *thd, - int casual_read -) { - DBUG_ENTER("spider_param_casual_read"); - DBUG_RETURN(THDVAR(thd, casual_read) == -1 ? - casual_read : THDVAR(thd, casual_read)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, casual_read) static my_bool spider_dry_access; static MYSQL_SYSVAR_BOOL( @@ -3090,14 +2546,10 @@ static MYSQL_SYSVAR_BOOL( FALSE ); -my_bool spider_param_dry_access() -{ - DBUG_ENTER("spider_param_dry_access"); - DBUG_RETURN(spider_dry_access); -} +SPIDER_SYSVAR_VALUE_FUNC(my_bool, dry_access) /* - -1 :use table parameter + -1 :fallback to default 0 :fast 1 :correct delete row number */ @@ -3107,23 +2559,16 @@ static MYSQL_THDVAR_INT( "The type of delete_all_rows", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 1, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_delete_all_rows_type( - THD *thd, - int delete_all_rows_type -) { - DBUG_ENTER("spider_param_delete_all_rows_type"); - DBUG_RETURN(THDVAR(thd, delete_all_rows_type) == -1 ? - delete_all_rows_type : THDVAR(thd, delete_all_rows_type)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, delete_all_rows_type) /* - -1 :use table parameter + -1 :fallback to default 0 :compact 1 :add original table name */ @@ -3133,23 +2578,16 @@ static MYSQL_THDVAR_INT( "The type of temporary table name for bka", /* comment */ NULL, /* check */ NULL, /* update */ - -1, /* def */ + 0, /* def */ -1, /* min */ 1, /* max */ 0 /* blk */ ); -int spider_param_bka_table_name_type( - THD *thd, - int bka_table_name_type -) { - DBUG_ENTER("spider_param_bka_table_name_type"); - DBUG_RETURN(THDVAR(thd, bka_table_name_type) == -1 ? - bka_table_name_type : THDVAR(thd, bka_table_name_type)); -} +SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, bka_table_name_type) /* - -1 :use table parameter + -1 :fallback to default 0 :off 1 :on */ @@ -3165,16 +2603,11 @@ static MYSQL_THDVAR_INT( 0 /* blk */ ); -int spider_param_use_cond_other_than_pk_for_update( - THD *thd -) { - DBUG_ENTER("spider_param_reset_sql_alloc"); - DBUG_RETURN(THDVAR(thd, use_cond_other_than_pk_for_update)); -} +SPIDER_THDVAR_VALUE_FUNC(int, use_cond_other_than_pk_for_update) static int spider_store_last_sts; /* - -1 : use table parameter + -1 : fallback to default 0 : do not store 1 : do store */ @@ -3185,23 +2618,17 @@ static MYSQL_SYSVAR_INT( "Store last sts result into system table", NULL, NULL, - -1, + 1, -1, 1, 0 ); -int spider_param_store_last_sts( - int store_last_sts -) { - DBUG_ENTER("spider_param_store_last_sts"); - DBUG_RETURN(spider_store_last_sts == -1 ? - store_last_sts : spider_store_last_sts); -} +SPIDER_SYSVAR_OVERRIDE_VALUE_FUNC(int, store_last_sts) static int spider_store_last_crd; /* - -1 : use table parameter + -1 : fallback to default 0 : do not store 1 : do store */ @@ -3212,23 +2639,17 @@ static MYSQL_SYSVAR_INT( "Store last crd result into system table", NULL, NULL, - -1, + 1, -1, 1, 0 ); -int spider_param_store_last_crd( - int store_last_crd -) { - DBUG_ENTER("spider_param_store_last_crd"); - DBUG_RETURN(spider_store_last_crd == -1 ? - store_last_crd : spider_store_last_crd); -} +SPIDER_SYSVAR_OVERRIDE_VALUE_FUNC(int, store_last_crd) static int spider_load_sts_at_startup; /* - -1 : use table parameter + -1 : fallback to default 0 : do not load 1 : do load */ @@ -3239,23 +2660,17 @@ static MYSQL_SYSVAR_INT( "Load sts from system table at startup", NULL, NULL, - -1, + 1, -1, 1, 0 ); -int spider_param_load_sts_at_startup( - int load_sts_at_startup -) { - DBUG_ENTER("spider_param_load_sts_at_startup"); - DBUG_RETURN(spider_load_sts_at_startup == -1 ? - load_sts_at_startup : spider_load_sts_at_startup); -} +SPIDER_SYSVAR_OVERRIDE_VALUE_FUNC(int, load_sts_at_startup) static int spider_load_crd_at_startup; /* - -1 : use table parameter + -1 : fallback to default 0 : do not load 1 : do load */ @@ -3266,19 +2681,13 @@ static MYSQL_SYSVAR_INT( "Load crd from system table at startup", NULL, NULL, - -1, + 1, -1, 1, 0 ); -int spider_param_load_crd_at_startup( - int load_crd_at_startup -) { - DBUG_ENTER("spider_param_load_crd_at_startup"); - DBUG_RETURN(spider_load_crd_at_startup == -1 ? - load_crd_at_startup : spider_load_crd_at_startup); -} +SPIDER_SYSVAR_OVERRIDE_VALUE_FUNC(int, load_crd_at_startup) #ifndef WITHOUT_SPIDER_BG_SEARCH static uint spider_table_sts_thread_count; @@ -3298,11 +2707,7 @@ static MYSQL_SYSVAR_UINT( 0 ); -uint spider_param_table_sts_thread_count() -{ - DBUG_ENTER("spider_param_table_sts_thread_count"); - DBUG_RETURN(spider_table_sts_thread_count); -} +SPIDER_SYSVAR_VALUE_FUNC(uint, table_sts_thread_count) static uint spider_table_crd_thread_count; /* @@ -3321,11 +2726,7 @@ static MYSQL_SYSVAR_UINT( 0 ); -uint spider_param_table_crd_thread_count() -{ - DBUG_ENTER("spider_param_table_crd_thread_count"); - DBUG_RETURN(spider_table_crd_thread_count); -} +SPIDER_SYSVAR_VALUE_FUNC(uint, table_crd_thread_count) #endif static int spider_slave_trx_isolation; @@ -3349,11 +2750,7 @@ static MYSQL_SYSVAR_INT( 0 /* blk */ ); -int spider_param_slave_trx_isolation() -{ - DBUG_ENTER("spider_param_slave_trx_isolation"); - DBUG_RETURN(spider_slave_trx_isolation); -} +SPIDER_SYSVAR_VALUE_FUNC(int, slave_trx_isolation) /* -1 :not set @@ -3418,12 +2815,7 @@ static MYSQL_THDVAR_BOOL( TRUE /* def */ ); -bool spider_param_sync_sql_mode( - THD *thd -) { - DBUG_ENTER("spider_param_sync_sql_mode"); - DBUG_RETURN(THDVAR(thd, sync_sql_mode)); -} +SPIDER_THDVAR_VALUE_FUNC(bool, sync_sql_mode) static struct st_mysql_storage_engine spider_storage_engine = { MYSQL_HANDLERTON_INTERFACE_VERSION }; diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 2ff97ce357730..a07df994e4607 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -3700,10 +3700,6 @@ int spider_set_connect_info_default( #endif #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (share->use_hs_reads[roop_count] == -1) - share->use_hs_reads[roop_count] = 0; - if (share->use_hs_writes[roop_count] == -1) - share->use_hs_writes[roop_count] = 0; if (share->hs_read_ports[roop_count] == -1) { share->hs_read_ports[roop_count] = 9998; @@ -3735,154 +3731,24 @@ int spider_set_connect_info_default( share->hs_write_to_reads[roop_count] = 1; } #endif - if (share->use_handlers[roop_count] == -1) - share->use_handlers[roop_count] = 0; - if (share->connect_timeouts[roop_count] == -1) - share->connect_timeouts[roop_count] = 6; - if (share->net_read_timeouts[roop_count] == -1) - share->net_read_timeouts[roop_count] = 600; - if (share->net_write_timeouts[roop_count] == -1) - share->net_write_timeouts[roop_count] = 600; if (share->access_balances[roop_count] == -1) share->access_balances[roop_count] = 100; - if (share->bka_table_name_types[roop_count] == -1) - share->bka_table_name_types[roop_count] = 0; } -#ifndef WITHOUT_SPIDER_BG_SEARCH - if (share->sts_bg_mode == -1) - share->sts_bg_mode = 2; -#endif - if (share->sts_interval == -1) - share->sts_interval = 10; - if (share->sts_mode == -1) - share->sts_mode = 1; -#ifdef WITH_PARTITION_STORAGE_ENGINE - if (share->sts_sync == -1) - share->sts_sync = 0; -#endif - if (share->store_last_sts == -1) - share->store_last_sts = 1; - if (share->load_sts_at_startup == -1) - share->load_sts_at_startup = 1; -#ifndef WITHOUT_SPIDER_BG_SEARCH - if (share->crd_bg_mode == -1) - share->crd_bg_mode = 2; -#endif - if (share->crd_interval == -1) - share->crd_interval = 51; - if (share->crd_mode == -1) - share->crd_mode = 1; -#ifdef WITH_PARTITION_STORAGE_ENGINE - if (share->crd_sync == -1) - share->crd_sync = 0; -#endif - if (share->store_last_crd == -1) - share->store_last_crd = 1; - if (share->load_crd_at_startup == -1) - share->load_crd_at_startup = 1; - if (share->crd_type == -1) - share->crd_type = 2; - if (share->crd_weight == -1) - share->crd_weight = 2; - if (share->internal_offset == -1) - share->internal_offset = 0; - if (share->internal_limit == -1) - share->internal_limit = 9223372036854775807LL; - if (share->split_read == -1) - share->split_read = 9223372036854775807LL; - if (share->semi_split_read == -1) - share->semi_split_read = 2; - if (share->semi_split_read_limit == -1) - share->semi_split_read_limit = 9223372036854775807LL; - if (share->init_sql_alloc_size == -1) - share->init_sql_alloc_size = 1024; - if (share->reset_sql_alloc == -1) - share->reset_sql_alloc = 1; - if (share->multi_split_read == -1) - share->multi_split_read = 100; - if (share->max_order == -1) - share->max_order = 32767; - if (share->semi_table_lock == -1) - share->semi_table_lock = 0; - if (share->semi_table_lock_conn == -1) - share->semi_table_lock_conn = 1; - if (share->selupd_lock_mode == -1) - share->selupd_lock_mode = 1; if (share->query_cache == -1) share->query_cache = 0; if (share->query_cache_sync == -1) share->query_cache_sync = 0; - if (share->bulk_size == -1) - share->bulk_size = 16000; - if (share->bulk_update_mode == -1) - share->bulk_update_mode = 0; - if (share->bulk_update_size == -1) - share->bulk_update_size = 16000; - if (share->internal_optimize == -1) - share->internal_optimize = 0; - if (share->internal_optimize_local == -1) - share->internal_optimize_local = 0; if (share->scan_rate == -1) share->scan_rate = 1; if (share->read_rate == -1) share->read_rate = 0.0002; if (share->priority == -1) share->priority = 1000000; - if (share->quick_mode == -1) - share->quick_mode = 3; - if (share->quick_page_size == -1) - share->quick_page_size = 1024; - if (share->quick_page_byte == -1) - share->quick_page_byte = 10485760; - if (share->low_mem_read == -1) - share->low_mem_read = 1; if (share->table_count_mode == -1) share->table_count_mode = 0; - if (share->select_column_mode == -1) - share->select_column_mode = 1; -#ifndef WITHOUT_SPIDER_BG_SEARCH - if (share->bgs_mode == -1) - share->bgs_mode = 0; - if (share->bgs_first_read == -1) - share->bgs_first_read = 2; - if (share->bgs_second_read == -1) - share->bgs_second_read = 100; -#endif - if (share->first_read == -1) - share->first_read = 0; - if (share->second_read == -1) - share->second_read = 0; - if (share->auto_increment_mode == -1) - share->auto_increment_mode = 0; - if (share->use_table_charset == -1) - share->use_table_charset = 1; - if (share->use_pushdown_udf == -1) - share->use_pushdown_udf = 1; - if (share->skip_default_condition == -1) - share->skip_default_condition = 0; - if (share->skip_parallel_search == -1) - share->skip_parallel_search = 0; - if (share->direct_dup_insert == -1) - share->direct_dup_insert = 0; - if (share->direct_order_limit == -1) - share->direct_order_limit = 9223372036854775807LL; - if (share->read_only_mode == -1) - share->read_only_mode = 0; - if (share->error_read_mode == -1) - share->error_read_mode = 0; - if (share->error_write_mode == -1) - share->error_write_mode = 0; if (share->active_link_count == -1) share->active_link_count = share->all_link_count; -#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) - if (share->hs_result_free_size == -1) - share->hs_result_free_size = 1048576; -#endif -#ifdef HA_CAN_BULK_ACCESS - if (share->bulk_access_free == -1) - share->bulk_access_free = 0; -#endif #ifdef HA_CAN_FORCE_BULK_UPDATE if (share->force_bulk_update == -1) share->force_bulk_update = 0; @@ -3891,18 +3757,6 @@ int spider_set_connect_info_default( if (share->force_bulk_delete == -1) share->force_bulk_delete = 0; #endif - if (share->casual_read == -1) - share->casual_read = 0; - if (share->delete_all_rows_type == -1) - { -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS - share->delete_all_rows_type = 1; -#else - share->delete_all_rows_type = 0; -#endif - } - if (share->bka_mode == -1) - share->bka_mode = 1; if (!share->bka_engine) { DBUG_PRINT("info",("spider create default bka_engine"));