Skip to content

Commit a9c3cc8

Browse files
MDEV-39207 Fix plugin name passed to find_bookmark in test_plugin_options
Should be lowercase, just like in construct_options(). Without this fix all plugin session vars have test_load always false (static_unloaded).
1 parent 9f00ff0 commit a9c3cc8

File tree

4 files changed

+74
-2
lines changed

4 files changed

+74
-2
lines changed

mysql-test/suite/sys_vars/r/session_track_system_variables_basic.result

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,38 @@ SET SESSION session_track_system_variables="sql_slave_skip_counter", sql_slave_s
152152
# Restoring the original values.
153153
SET @@global.session_track_system_variables = @global_saved_tmp;
154154
# End of tests.
155+
#
156+
# MDEV-39207 plugin variables disappear from session_track_system_variables list
157+
#
158+
install soname 'ha_example.so';
159+
# Plugin global vars are not included
160+
set global session_track_system_variables='myisam_block_size';
161+
select @@global.session_track_system_variables;
162+
@@global.session_track_system_variables
163+
164+
set global session_track_system_variables='example_int_var';
165+
select @@global.session_track_system_variables;
166+
@@global.session_track_system_variables
167+
example_int_var
168+
set global session_track_system_variables='myisam_sort_buffer_size,example_int_var';
169+
select @@global.session_track_system_variables;
170+
@@global.session_track_system_variables
171+
example_int_var,myisam_sort_buffer_size
172+
set global session_track_system_variables='myisam_block_size,myisam_sort_buffer_size,character_set_client,example_int_var';
173+
select @@global.session_track_system_variables;
174+
@@global.session_track_system_variables
175+
character_set_client,example_int_var,myisam_sort_buffer_size
176+
# Session tracking works as expected for plugin session var
177+
connect foo,localhost,root;
178+
select @@session.session_track_system_variables;
179+
@@session.session_track_system_variables
180+
character_set_client,example_int_var,myisam_sort_buffer_size
181+
set session example_int_var = -1;
182+
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
183+
-- example_int_var: -1
184+
185+
connection default;
186+
disconnect foo;
187+
uninstall soname 'ha_example.so';
188+
SET @@global.session_track_system_variables = @global_saved_tmp;
189+
# End of 10.11 tests

mysql-test/suite/sys_vars/t/session_track_system_variables_basic.test

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,33 @@ SET SESSION session_track_system_variables="sql_slave_skip_counter", sql_slave_s
126126
SET @@global.session_track_system_variables = @global_saved_tmp;
127127

128128
--echo # End of tests.
129+
130+
--echo #
131+
--echo # MDEV-39207 plugin variables disappear from session_track_system_variables list
132+
--echo #
133+
134+
install soname 'ha_example.so';
135+
136+
--echo # Plugin global vars are not included
137+
set global session_track_system_variables='myisam_block_size';
138+
select @@global.session_track_system_variables;
139+
set global session_track_system_variables='example_int_var';
140+
select @@global.session_track_system_variables;
141+
set global session_track_system_variables='myisam_sort_buffer_size,example_int_var';
142+
select @@global.session_track_system_variables;
143+
set global session_track_system_variables='myisam_block_size,myisam_sort_buffer_size,character_set_client,example_int_var';
144+
select @@global.session_track_system_variables;
145+
146+
--echo # Session tracking works as expected for plugin session var
147+
connect foo,localhost,root;
148+
enable_session_track_info;
149+
select @@session.session_track_system_variables;
150+
set session example_int_var = -1;
151+
disable_session_track_info;
152+
153+
connection default;
154+
disconnect foo;
155+
uninstall soname 'ha_example.so';
156+
SET @@global.session_track_system_variables = @global_saved_tmp;
157+
158+
--echo # End of 10.11 tests

sql/session_tracker.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,9 @@ bool Session_sysvars_tracker::vars_list::construct_var_list(char *buf,
329329
}
330330
mysql_mutex_unlock(&LOCK_plugin);
331331

332-
buf--; buf[0]= '\0';
332+
if (idx > 0)
333+
buf--;
334+
buf[0]= '\0';
333335
my_safe_afree(names, names_size);
334336

335337
return false;

sql/sql_plugin.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4212,9 +4212,14 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp,
42124212
struct st_bookmark *var;
42134213
size_t len=0, count= EXTRA_OPTIONS;
42144214
st_ptr_backup *tmp_backup= 0;
4215+
const char *plugin_name= tmp->plugin->name;
4216+
size_t plugin_name_len= strlen(plugin_name);
42154217
DBUG_ENTER("test_plugin_options");
42164218
DBUG_ASSERT(tmp->plugin && tmp->name.str);
42174219

4220+
char *plugin_name_ptr= static_cast<char*>(alloc_root(mem_root, plugin_name_len + 1));
4221+
safe_strcpy(plugin_name_ptr, plugin_name_len + 1, plugin_name);
4222+
my_casedn_str(&my_charset_latin1, plugin_name_ptr);
42184223
if (tmp->plugin->system_vars || (*argc > 1))
42194224
{
42204225
for (opt= tmp->plugin->system_vars; opt && *opt; opt++)
@@ -4250,7 +4255,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp,
42504255
sys_var *v;
42514256

42524257
tmp_backup[tmp->nbackups++].save(&o->name);
4253-
if ((var= find_bookmark(tmp->name.str, o->name, o->flags)))
4258+
if ((var= find_bookmark(plugin_name_ptr, o->name, o->flags)))
42544259
{
42554260
varname= var->key + 1;
42564261
var->loaded= TRUE;

0 commit comments

Comments
 (0)