Commit 82f3ceed authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-16470: switch off user variables (and fixes of its support)

parent 8ec21afc
...@@ -7711,6 +7711,28 @@ void append_info(DYNAMIC_STRING *ds, ulonglong affected_rows, ...@@ -7711,6 +7711,28 @@ void append_info(DYNAMIC_STRING *ds, ulonglong affected_rows,
} }
#ifndef EMBEDDED_LIBRARY
static const char *trking_info_desc[SESSION_TRACK_END + 1]=
{
"Tracker : SESSION_TRACK_SYSTEM_VARIABLES\n",
"Tracker : SESSION_TRACK_SCHEMA\n",
"Tracker : SESSION_TRACK_STATE_CHANGE\n",
"Tracker : SESSION_TRACK_GTIDS\n",
"Tracker : SESSION_TRACK_TRANSACTION_CHARACTERISTICS\n",
"Tracker : SESSION_TRACK_TRANSACTION_TYPE\n"
#ifdef USER_VAR_TRACKING
,
"Tracker : SESSION_TRACK_MYSQL_RESERVED1\n",
"Tracker : SESSION_TRACK_MYSQL_RESERVED2\n",
"Tracker : SESSION_TRACK_MYSQL_RESERVED3\n",
"Tracker : SESSION_TRACK_MYSQL_RESERVED4\n",
"Tracker : SESSION_TRACK_MYSQL_RESERVED5\n",
"Tracker : SESSION_TRACK_MYSQL_RESERVED6\n",
"Tracker : SESSION_TRACK_USER_VARIABLES\n"
#endif // USER_VAR_TRACKING
};
#endif // EMBEDDED_LIBRARY
/** /**
@brief Append state change information (received through Ok packet) to the output. @brief Append state change information (received through Ok packet) to the output.
...@@ -7731,31 +7753,15 @@ static void append_session_track_info(DYNAMIC_STRING *ds, MYSQL *mysql) ...@@ -7731,31 +7753,15 @@ static void append_session_track_info(DYNAMIC_STRING *ds, MYSQL *mysql)
&data, &data_length)) &data, &data_length))
{ {
dynstr_append(ds, "-- "); dynstr_append(ds, "-- ");
switch (type) if (type <= SESSION_TRACK_END)
{ {
case SESSION_TRACK_SYSTEM_VARIABLES: dynstr_append(ds, trking_info_desc[type]);
dynstr_append(ds, "Tracker : SESSION_TRACK_SYSTEM_VARIABLES\n"); }
break; else
case SESSION_TRACK_SCHEMA: {
dynstr_append(ds, "Tracker : SESSION_TRACK_SCHEMA\n"); DBUG_ASSERT(0);
break; dynstr_append(ds, "Tracker???\n");
case SESSION_TRACK_STATE_CHANGE:
dynstr_append(ds, "Tracker : SESSION_TRACK_STATE_CHANGE\n");
break;
case SESSION_TRACK_GTIDS:
dynstr_append(ds, "Tracker : SESSION_TRACK_GTIDS\n");
break;
case SESSION_TRACK_TRANSACTION_CHARACTERISTICS:
dynstr_append(ds, "Tracker : SESSION_TRACK_TRANSACTION_CHARACTERISTICS\n");
break;
case SESSION_TRACK_TRANSACTION_TYPE:
dynstr_append(ds, "Tracker : SESSION_TRACK_TRANSACTION_TYPE\n");
break;
default:
DBUG_ASSERT(0);
dynstr_append(ds, "\n");
} }
dynstr_append(ds, "-- "); dynstr_append(ds, "-- ");
dynstr_append_mem(ds, data, data_length); dynstr_append_mem(ds, data, data_length);
...@@ -7767,7 +7773,13 @@ static void append_session_track_info(DYNAMIC_STRING *ds, MYSQL *mysql) ...@@ -7767,7 +7773,13 @@ static void append_session_track_info(DYNAMIC_STRING *ds, MYSQL *mysql)
&data, &data_length)) &data, &data_length))
{ {
dynstr_append(ds, "\n-- "); dynstr_append(ds, "\n-- ");
dynstr_append_mem(ds, data, data_length); if (data == NULL)
{
DBUG_ASSERT(data_length == 0);
dynstr_append_mem(ds, "<NULL>", sizeof("<NULL>") - 1);
}
else
dynstr_append_mem(ds, data, data_length);
} }
dynstr_append(ds, "\n\n"); dynstr_append(ds, "\n\n");
} }
......
...@@ -113,7 +113,6 @@ enum enum_session_state_type ...@@ -113,7 +113,6 @@ enum enum_session_state_type
SESSION_TRACK_GTIDS, SESSION_TRACK_GTIDS,
SESSION_TRACK_TRANSACTION_CHARACTERISTICS, SESSION_TRACK_TRANSACTION_CHARACTERISTICS,
SESSION_TRACK_TRANSACTION_STATE, SESSION_TRACK_TRANSACTION_STATE,
SESSION_TRACK_USER_VARIABLES,
SESSION_TRACK_always_at_the_end SESSION_TRACK_always_at_the_end
}; };
extern "C" { extern "C" {
......
...@@ -617,7 +617,15 @@ enum enum_session_state_type ...@@ -617,7 +617,15 @@ enum enum_session_state_type
SESSION_TRACK_GTIDS, SESSION_TRACK_GTIDS,
SESSION_TRACK_TRANSACTION_CHARACTERISTICS, /* Transaction chistics */ SESSION_TRACK_TRANSACTION_CHARACTERISTICS, /* Transaction chistics */
SESSION_TRACK_TRANSACTION_STATE, /* Transaction state */ SESSION_TRACK_TRANSACTION_STATE, /* Transaction state */
#ifdef USER_VAR_TRACKING
SESSION_TRACK_MYSQL_RESERVED1,
SESSION_TRACK_MYSQL_RESERVED2,
SESSION_TRACK_MYSQL_RESERVED3,
SESSION_TRACK_MYSQL_RESERVED4,
SESSION_TRACK_MYSQL_RESERVED5,
SESSION_TRACK_MYSQL_RESERVED6,
SESSION_TRACK_USER_VARIABLES, SESSION_TRACK_USER_VARIABLES,
#endif // USER_VAR_TRACKING
SESSION_TRACK_always_at_the_end /* must be last */ SESSION_TRACK_always_at_the_end /* must be last */
}; };
......
...@@ -1151,8 +1151,6 @@ The following specify which files/extra groups are read (specified before remain ...@@ -1151,8 +1151,6 @@ The following specify which files/extra groups are read (specified before remain
characteristics (isolation level, read only/read characteristics (isolation level, read only/read
write,snapshot - but not any work done / data modified write,snapshot - but not any work done / data modified
within the transaction). within the transaction).
--session-track-user-variables
Track changes to user variables.
--show-slave-auth-info --show-slave-auth-info
Show user and password in SHOW SLAVE HOSTS on this Show user and password in SHOW SLAVE HOSTS on this
master. master.
...@@ -1758,7 +1756,6 @@ session-track-schema TRUE ...@@ -1758,7 +1756,6 @@ session-track-schema TRUE
session-track-state-change FALSE session-track-state-change FALSE
session-track-system-variables autocommit,character_set_client,character_set_connection,character_set_results,time_zone session-track-system-variables autocommit,character_set_client,character_set_connection,character_set_results,time_zone
session-track-transaction-info OFF session-track-transaction-info OFF
session-track-user-variables FALSE
show-slave-auth-info FALSE show-slave-auth-info FALSE
silent-startup FALSE silent-startup FALSE
skip-grant-tables TRUE skip-grant-tables TRUE
......
...@@ -48,20 +48,4 @@ SET @@session.session_track_system_variables= @save_session_track_system_variabl ...@@ -48,20 +48,4 @@ SET @@session.session_track_system_variables= @save_session_track_system_variabl
# #
# MDEV-16470 - Session user variables tracker # MDEV-16470 - Session user variables tracker
# #
SET @@session.session_track_user_variables=1;
SET @a=1;
SET @b=NULL;
SELECT @c:=10;
@c:=10
10
SET @@session.session_track_user_variables=0;
#
# mdev-22337 Assertion `Alloced_length >= (str_length + length +
net_length_size(length))' failed in Binary_string::q_net_store_data
on long MULTIPOLYGON query with session_track_user_variables=1
(optimized builds)
#
set @@session.session_track_user_variables=1;
set @a=repeat('X', 1029);
set @@session.session_track_user_variables=0;
# End of 10.5 tests # End of 10.5 tests
...@@ -49,24 +49,24 @@ SET @@session.session_track_system_variables= @save_session_track_system_variabl ...@@ -49,24 +49,24 @@ SET @@session.session_track_system_variables= @save_session_track_system_variabl
--echo # --echo #
--echo # MDEV-16470 - Session user variables tracker --echo # MDEV-16470 - Session user variables tracker
--echo # --echo #
SET @@session.session_track_user_variables=1; #SET @@session.session_track_user_variables=1;
--enable_session_track_info #--enable_session_track_info
SET @a=1; #SET @a=1;
SET @b=NULL; #SET @b=NULL;
SELECT @c:=10; #SELECT @c:=10;
--disable_session_track_info #--disable_session_track_info
SET @@session.session_track_user_variables=0; #SET @@session.session_track_user_variables=0;
--echo # #--echo #
--echo # mdev-22337 Assertion `Alloced_length >= (str_length + length + #--echo # mdev-22337 Assertion `Alloced_length >= (str_length + length +
--echo net_length_size(length))' failed in Binary_string::q_net_store_data #--echo net_length_size(length))' failed in Binary_string::q_net_store_data
--echo on long MULTIPOLYGON query with session_track_user_variables=1 #--echo on long MULTIPOLYGON query with session_track_user_variables=1
--echo (optimized builds) #--echo (optimized builds)
--echo # #--echo #
set @@session.session_track_user_variables=1; #set @@session.session_track_user_variables=1;
--enable_session_track_info #--enable_session_track_info
set @a=repeat('X', 1029); #set @a=repeat('X', 1029);
--disable_session_track_info #--disable_session_track_info
set @@session.session_track_user_variables=0; #set @@session.session_track_user_variables=0;
--echo # End of 10.5 tests --echo # End of 10.5 tests
...@@ -3543,16 +3543,6 @@ NUMERIC_BLOCK_SIZE NULL ...@@ -3543,16 +3543,6 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,STATE,CHARACTERISTICS ENUM_VALUE_LIST OFF,STATE,CHARACTERISTICS
READ_ONLY NO READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME SESSION_TRACK_USER_VARIABLES
VARIABLE_SCOPE SESSION
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Track changes to user variables.
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME SKIP_EXTERNAL_LOCKING VARIABLE_NAME SKIP_EXTERNAL_LOCKING
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN VARIABLE_TYPE BOOLEAN
......
...@@ -4787,10 +4787,12 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, size_t length, ...@@ -4787,10 +4787,12 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, size_t length,
entry->unsigned_flag= unsigned_arg; entry->unsigned_flag= unsigned_arg;
} }
entry->type=type; entry->type=type;
#ifdef USER_VAR_TRACKING
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
THD *thd= current_thd; THD *thd= current_thd;
thd->session_tracker.user_variables.mark_as_changed(thd, entry); thd->session_tracker.user_variables.mark_as_changed(thd, entry);
#endif #endif
#endif // USER_VAR_TRACKING
return 0; return 0;
} }
......
...@@ -1183,6 +1183,7 @@ bool Session_state_change_tracker::store(THD *thd, String *buf) ...@@ -1183,6 +1183,7 @@ bool Session_state_change_tracker::store(THD *thd, String *buf)
return false; return false;
} }
#ifdef USER_VAR_TRACKING
bool User_variables_tracker::update(THD *thd, set_var *) bool User_variables_tracker::update(THD *thd, set_var *)
{ {
...@@ -1204,10 +1205,13 @@ bool User_variables_tracker::store(THD *thd, String *buf) ...@@ -1204,10 +1205,13 @@ bool User_variables_tracker::store(THD *thd, String *buf)
length= net_length_size(var->name.length) + var->name.length; length= net_length_size(var->name.length) + var->name.length;
if (!null_value) if (!null_value)
length+= net_length_size(value_str.length()) + value_str.length(); length+= net_length_size(value_str.length()) + value_str.length();
else
length+= 1;
if (buf->reserve(sizeof(char) + length + net_length_size(length))) if (buf->reserve(sizeof(char) + length + net_length_size(length)))
return true; return true;
// TODO: check max packet length MDEV-22709
buf->q_append(static_cast<char>(SESSION_TRACK_USER_VARIABLES)); buf->q_append(static_cast<char>(SESSION_TRACK_USER_VARIABLES));
buf->q_net_store_length(length); buf->q_net_store_length(length);
buf->q_net_store_data(reinterpret_cast<const uchar*>(var->name.str), buf->q_net_store_data(reinterpret_cast<const uchar*>(var->name.str),
...@@ -1215,10 +1219,16 @@ bool User_variables_tracker::store(THD *thd, String *buf) ...@@ -1215,10 +1219,16 @@ bool User_variables_tracker::store(THD *thd, String *buf)
if (!null_value) if (!null_value)
buf->q_net_store_data(reinterpret_cast<const uchar*>(value_str.ptr()), buf->q_net_store_data(reinterpret_cast<const uchar*>(value_str.ptr()),
value_str.length()); value_str.length());
else
{
char nullbuff[1]= { (char)251 };
buf->q_append(nullbuff, sizeof(nullbuff));
}
} }
m_changed_user_variables.clear(); m_changed_user_variables.clear();
return false; return false;
} }
#endif // USER_VAR_TRACKING
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
......
...@@ -35,7 +35,9 @@ enum enum_session_tracker ...@@ -35,7 +35,9 @@ enum enum_session_tracker
CURRENT_SCHEMA_TRACKER, /* Current schema */ CURRENT_SCHEMA_TRACKER, /* Current schema */
SESSION_STATE_CHANGE_TRACKER, SESSION_STATE_CHANGE_TRACKER,
TRANSACTION_INFO_TRACKER, /* Transaction state */ TRANSACTION_INFO_TRACKER, /* Transaction state */
#ifdef USER_VAR_TRACKING
USER_VARIABLES_TRACKER, USER_VARIABLES_TRACKER,
#endif // USER_VAR_TRACKING
SESSION_TRACKER_END /* must be the last */ SESSION_TRACKER_END /* must be the last */
}; };
...@@ -395,6 +397,7 @@ class Transaction_state_tracker : public State_tracker ...@@ -395,6 +397,7 @@ class Transaction_state_tracker : public State_tracker
This is a tracker class that enables & manages the tracking of user variables. This is a tracker class that enables & manages the tracking of user variables.
*/ */
#ifdef USER_VAR_TRACKING
class User_variables_tracker: public State_tracker class User_variables_tracker: public State_tracker
{ {
Hash_set<const user_var_entry> m_changed_user_variables; Hash_set<const user_var_entry> m_changed_user_variables;
...@@ -415,6 +418,7 @@ class User_variables_tracker: public State_tracker ...@@ -415,6 +418,7 @@ class User_variables_tracker: public State_tracker
} }
void deinit() { m_changed_user_variables.~Hash_set(); } void deinit() { m_changed_user_variables.~Hash_set(); }
}; };
#endif // USER_VAR_TRACKING
/** /**
...@@ -445,7 +449,9 @@ class Session_tracker ...@@ -445,7 +449,9 @@ class Session_tracker
Session_state_change_tracker state_change; Session_state_change_tracker state_change;
Transaction_state_tracker transaction_info; Transaction_state_tracker transaction_info;
Session_sysvars_tracker sysvars; Session_sysvars_tracker sysvars;
#ifdef USER_VAR_TRACKING
User_variables_tracker user_variables; User_variables_tracker user_variables;
#endif // USER_VAR_TRACKING
Session_tracker() Session_tracker()
{ {
...@@ -453,7 +459,9 @@ class Session_tracker ...@@ -453,7 +459,9 @@ class Session_tracker
m_trackers[CURRENT_SCHEMA_TRACKER]= &current_schema; m_trackers[CURRENT_SCHEMA_TRACKER]= &current_schema;
m_trackers[SESSION_STATE_CHANGE_TRACKER]= &state_change; m_trackers[SESSION_STATE_CHANGE_TRACKER]= &state_change;
m_trackers[TRANSACTION_INFO_TRACKER]= &transaction_info; m_trackers[TRANSACTION_INFO_TRACKER]= &transaction_info;
#ifdef USER_VAR_TRACKING
m_trackers[USER_VARIABLES_TRACKER]= &user_variables; m_trackers[USER_VARIABLES_TRACKER]= &user_variables;
#endif // USER_VAR_TRACKING
} }
void enable(THD *thd) void enable(THD *thd)
......
...@@ -1739,7 +1739,9 @@ THD::~THD() ...@@ -1739,7 +1739,9 @@ THD::~THD()
/* trick to make happy memory accounting system */ /* trick to make happy memory accounting system */
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
session_tracker.sysvars.deinit(); session_tracker.sysvars.deinit();
#ifdef USER_VAR_TRACKING
session_tracker.user_variables.deinit(); session_tracker.user_variables.deinit();
#endif // USER_VAR_TRACKING
#endif //EMBEDDED_LIBRARY #endif //EMBEDDED_LIBRARY
if (status_var.local_memory_used != 0) if (status_var.local_memory_used != 0)
......
...@@ -793,7 +793,9 @@ typedef struct system_variables ...@@ -793,7 +793,9 @@ typedef struct system_variables
ulong session_track_transaction_info; ulong session_track_transaction_info;
my_bool session_track_schema; my_bool session_track_schema;
my_bool session_track_state_change; my_bool session_track_state_change;
#ifdef USER_VAR_TRACKING
my_bool session_track_user_variables; my_bool session_track_user_variables;
#endif // USER_VAR_TRACKING
my_bool tcp_nodelay; my_bool tcp_nodelay;
ulong threadpool_priority; ulong threadpool_priority;
......
...@@ -6647,6 +6647,7 @@ static Sys_var_mybool Sys_session_track_state_change( ...@@ -6647,6 +6647,7 @@ static Sys_var_mybool Sys_session_track_state_change(
ON_UPDATE(update_session_track_state_change)); ON_UPDATE(update_session_track_state_change));
#ifdef USER_VAR_TRACKING
static bool update_session_track_user_variables(sys_var *self, THD *thd, static bool update_session_track_user_variables(sys_var *self, THD *thd,
enum_var_type type) enum_var_type type)
{ {
...@@ -6661,6 +6662,7 @@ static Sys_var_mybool Sys_session_track_user_variables( ...@@ -6661,6 +6662,7 @@ static Sys_var_mybool Sys_session_track_user_variables(
NO_MUTEX_GUARD, NOT_IN_BINLOG, NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(0), ON_CHECK(0),
ON_UPDATE(update_session_track_user_variables)); ON_UPDATE(update_session_track_user_variables));
#endif // USER_VAR_TRACKING
#endif //EMBEDDED_LIBRARY #endif //EMBEDDED_LIBRARY
......
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