MySQL version / commit
trunk (but would exist since forever)
Steps to reproduce
test case below, needs a master.opt:
~/githome/mysql-server/build-debug % cat ../mysql-test/t/plugin_thdvar_reinstall-master.opt
$EXAMPLE_PLUGIN_OPT
The example storage engine declares MYSQL_THDVAR_INT(signed_int_thdvar) with
a registered default of -10. This test distinguishes the two possible reads
after reinstall by moving BOTH the session value AND the global value off the
default to distinct values before uninstall:
registered default : -10
session value set : 42
global value set : 99
After reinstall, a correct server reads @@session = -10 (the registered
default). The bug makes @@session read 42 (the stale pre-uninstall session
value). @@global reads -10 (correctly reset to the registered default, NOT the
99 that was set) -- proving the stale @@session value is the old session value
and not merely an echo of the global.
Mechanism: the per-THD bookmark is permanent (offset reused across
uninstall/reinstall); UNINSTALL clears only the global slot; per-connection
slots in dynamic_variables_ptr are never cleared, and reinstall reuses the
same offset. Reproduces on unmodified MySQL (no SET SESSION crash: INT type).
--source include/have_example_plugin.inc
--echo # Install the example engine (declares example_signed_int_thdvar)
--replace_regex /.dll/.so/
eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN';
--echo # Registered default
SELECT @@session.example_signed_int_thdvar AS first_install_default;
--echo # Set a distinct per-session value on THIS connection
SET SESSION example_signed_int_thdvar = 42;
SELECT @@session.example_signed_int_thdvar AS after_set;
--echo # Move GLOBAL off its registered default (-10) to a distinct value (99),
--echo # so a post-reinstall read can tell "reset to default" (-10) from
--echo # "stale session value survived" (42) from "echo of global" (99).
SET GLOBAL example_signed_int_thdvar = 99;
SELECT @@global.example_signed_int_thdvar AS global_after_set;
UNINSTALL PLUGIN example;
--echo # While uninstalled the variable does not exist
--error ER_UNKNOWN_SYSTEM_VARIABLE
SELECT @@session.example_signed_int_thdvar AS when_uninstalled;
--echo # Reinstall on the SAME connection/server. @@session MUST be the
--echo # registered default (-10). BUG: it reads 42 (the stale session value).
--replace_regex /.dll/.so/
eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN';
SELECT @@session.example_signed_int_thdvar AS after_reinstall;
SELECT @@global.example_signed_int_thdvar AS after_reinstall_global;
UNINSTALL PLUGIN example;
Expected vs actual result
Install the example engine (declares example_signed_int_thdvar)
INSTALL PLUGIN example SONAME 'ha_example.so';
Registered default
SELECT @@session.example_signed_int_thdvar AS first_install_default;
first_install_default
-10
Set a distinct per-session value on THIS connection
SET SESSION example_signed_int_thdvar = 42;
SELECT @@session.example_signed_int_thdvar AS after_set;
after_set
42
Move GLOBAL off its registered default (-10) to a distinct value (99),
so a post-reinstall read can tell "reset to default" (-10) from
"stale session value survived" (42) from "echo of global" (99).
SET GLOBAL example_signed_int_thdvar = 99;
SELECT @@global.example_signed_int_thdvar AS global_after_set;
global_after_set
99
UNINSTALL PLUGIN example;
While uninstalled the variable does not exist
SELECT @@session.example_signed_int_thdvar AS when_uninstalled;
ERROR HY000: Unknown system variable 'example_signed_int_thdvar'
Reinstall on the SAME connection/server. @@session MUST be the
registered default (-10). BUG: it reads 42 (the stale session value).
INSTALL PLUGIN example SONAME 'ha_example.so';
SELECT @@session.example_signed_int_thdvar AS after_reinstall;
after_reinstall
42
----> would expect -10 here
SELECT @@global.example_signed_int_thdvar AS after_reinstall_global;
after_reinstall_global
-10
UNINSTALL PLUGIN example;
Platform / compiler
No response
MySQL version / commit
trunk (but would exist since forever)
Steps to reproduce
test case below, needs a master.opt:
~/githome/mysql-server/build-debug % cat ../mysql-test/t/plugin_thdvar_reinstall-master.opt
$EXAMPLE_PLUGIN_OPT
The example storage engine declares MYSQL_THDVAR_INT(signed_int_thdvar) with
a registered default of -10. This test distinguishes the two possible reads
after reinstall by moving BOTH the session value AND the global value off the
default to distinct values before uninstall:
registered default : -10
session value set : 42
global value set : 99
After reinstall, a correct server reads @@session = -10 (the registered
default). The bug makes @@session read 42 (the stale pre-uninstall session
value). @@global reads -10 (correctly reset to the registered default, NOT the
99 that was set) -- proving the stale @@session value is the old session value
and not merely an echo of the global.
Mechanism: the per-THD bookmark is permanent (offset reused across
uninstall/reinstall); UNINSTALL clears only the global slot; per-connection
slots in dynamic_variables_ptr are never cleared, and reinstall reuses the
same offset. Reproduces on unmodified MySQL (no SET SESSION crash: INT type).
--source include/have_example_plugin.inc
--echo # Install the example engine (declares example_signed_int_thdvar)
--replace_regex /.dll/.so/
eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN';
--echo # Registered default
SELECT @@session.example_signed_int_thdvar AS first_install_default;
--echo # Set a distinct per-session value on THIS connection
SET SESSION example_signed_int_thdvar = 42;
SELECT @@session.example_signed_int_thdvar AS after_set;
--echo # Move GLOBAL off its registered default (-10) to a distinct value (99),
--echo # so a post-reinstall read can tell "reset to default" (-10) from
--echo # "stale session value survived" (42) from "echo of global" (99).
SET GLOBAL example_signed_int_thdvar = 99;
SELECT @@global.example_signed_int_thdvar AS global_after_set;
UNINSTALL PLUGIN example;
--echo # While uninstalled the variable does not exist
--error ER_UNKNOWN_SYSTEM_VARIABLE
SELECT @@session.example_signed_int_thdvar AS when_uninstalled;
--echo # Reinstall on the SAME connection/server. @@session MUST be the
--echo # registered default (-10). BUG: it reads 42 (the stale session value).
--replace_regex /.dll/.so/
eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN';
SELECT @@session.example_signed_int_thdvar AS after_reinstall;
SELECT @@global.example_signed_int_thdvar AS after_reinstall_global;
UNINSTALL PLUGIN example;
Expected vs actual result
Install the example engine (declares example_signed_int_thdvar)
INSTALL PLUGIN example SONAME 'ha_example.so';
Registered default
SELECT @@session.example_signed_int_thdvar AS first_install_default;
first_install_default
-10
Set a distinct per-session value on THIS connection
SET SESSION example_signed_int_thdvar = 42;
SELECT @@session.example_signed_int_thdvar AS after_set;
after_set
42
Move GLOBAL off its registered default (-10) to a distinct value (99),
so a post-reinstall read can tell "reset to default" (-10) from
"stale session value survived" (42) from "echo of global" (99).
SET GLOBAL example_signed_int_thdvar = 99;
SELECT @@global.example_signed_int_thdvar AS global_after_set;
global_after_set
99
UNINSTALL PLUGIN example;
While uninstalled the variable does not exist
SELECT @@session.example_signed_int_thdvar AS when_uninstalled;
ERROR HY000: Unknown system variable 'example_signed_int_thdvar'
Reinstall on the SAME connection/server. @@session MUST be the
registered default (-10). BUG: it reads 42 (the stale session value).
INSTALL PLUGIN example SONAME 'ha_example.so';
SELECT @@session.example_signed_int_thdvar AS after_reinstall;
after_reinstall
42
----> would expect -10 here
SELECT @@global.example_signed_int_thdvar AS after_reinstall_global;
after_reinstall_global
-10
UNINSTALL PLUGIN example;
Platform / compiler
No response