[Maria-developers] MYSQL_THDVAR and SET GLOBAL
![](https://secure.gravatar.com/avatar/d1fa154903ca7ed342c36888aab05236.jpg?s=120&d=mm&r=g)
Is there an easy way to prevent SET GLOBAL ... from being done for plugin variables declared via MYSQL_THDVAR_...? For the following variable I can do SET GLOBAL innodb_fake_changes=1 and that sets a global variable. static MYSQL_THDVAR_BOOL(fake_changes, PLUGIN_VAR_OPCMDARG, "In the transaction after enabled, UPDATE, INSERT and DELETE only move the cursor to the records " "and do nothing other operations (no changes, no ibuf, no undo, no transaction log) in the transaction. " "This is to cause replication prefetch IO. ATTENTION: the transaction started after enabled is affected.", check_fake_changes, NULL, FALSE); -- Mark Callaghan mdcallag@gmail.com
![](https://secure.gravatar.com/avatar/06b8a7f236cf59aa9a83cab1a0551ca8.jpg?s=120&d=mm&r=g)
Hi!
"MARK" == MARK CALLAGHAN
writes:
MARK> Is there an easy way to prevent SET GLOBAL ... from being done for MARK> plugin variables declared via MYSQL_THDVAR_...? For the following MARK> variable I can do SET GLOBAL innodb_fake_changes=1 and that sets a MARK> global variable. MARK> static MYSQL_THDVAR_BOOL(fake_changes, PLUGIN_VAR_OPCMDARG, MARK> "In the transaction after enabled, UPDATE, INSERT and DELETE only MARK> move the cursor to the records " MARK> "and do nothing other operations (no changes, no ibuf, no undo, no MARK> transaction log) in the transaction. " MARK> "This is to cause replication prefetch IO. ATTENTION: the MARK> transaction started after enabled is affected.", MARK> check_fake_changes, NULL, FALSE); You can only do SET GLOBAL if you have SUPER privilege. Isn't that enough to ensure no one does it by mistake? Don't think there is an easy way to disable global for non super user. Sergei should know (as he implemented this) and he should also be able to add an option that variables should not be settable by SET GLOBAL. Regards, Monty
![](https://secure.gravatar.com/avatar/3c2329333dd5898f2e72818af773243d.jpg?s=120&d=mm&r=g)
Hi, MARK! On Nov 29, MARK CALLAGHAN wrote:
Is there an easy way to prevent SET GLOBAL ... from being done for plugin variables declared via MYSQL_THDVAR_...? For the following variable I can do SET GLOBAL innodb_fake_changes=1 and that sets a global variable.
static MYSQL_THDVAR_BOOL(fake_changes, PLUGIN_VAR_OPCMDARG, "In the transaction after enabled, UPDATE, INSERT and DELETE only move the cursor to the records " "and do nothing other operations (no changes, no ibuf, no undo, no transaction log) in the transaction. " "This is to cause replication prefetch IO. ATTENTION: the transaction started after enabled is affected.", check_fake_changes, NULL, FALSE);
I couldn't find a proper solution, but here's a workaround. Provide an update function for your variable: - check_fake_changes, NULL, FALSE); + check_fake_changes, update_fake_changes, FALSE); + + void update_fake_changes(MYSQL_THD thd, struct st_mysql_sys_var *var, + void *var_ptr, const void *save) + { + if (var_ptr != THDVAR(0, fake_changes)) + *(my_bool *) var_ptr= *(my_bool *) save ? TRUE : FALSE; + } it isn't very cool, because one is supposed to do all the checks in the check function, not in the update. but it'll work. Regards, Sergei
participants (3)
-
MARK CALLAGHAN
-
Michael Widenius
-
Sergei Golubchik