MySQL 9.1.0
Source Code Documentation
|
A helper class to fascilitate executing SET on system variables. More...
#include <set_variables_helper.h>
Public Member Functions | |
Set_variables_helper (THD *existing_thd) | |
Initializes the helper and switches to the canned temp LEX. More... | |
~Set_variables_helper () | |
bool | add_variable (const char *prefix, size_t prefix_length, const char *suffix, size_t suffix_length, Item *variable_value, enum_var_type var_type) |
Adds setting one variable instruction. More... | |
bool | execute () |
Executes the SET command for all variables added. More... | |
THD * | get_thd () |
bool | is_auto_thd () |
bool | check_variable_update_type (const char *prefix, size_t prefix_length, const char *suffix, size_t suffix_length, Item *variable_value) |
Checks the update type for the system variable and throws error if any found. More... | |
Private Attributes | |
List< set_var_base > | m_sysvar_list |
THD * | m_thd |
LEX * | m_lex_save |
LEX | m_lex_tmp |
Storing_auto_THD * | m_thd_auto |
A helper class to fascilitate executing SET on system variables.
Runs in the current THD, but in a temp LEX to avoid polluting the THD::lex with the changes.
Useful for service implementations looking to set values to system variables.
Should be used in a single THD.
A proper usage is something of the sort:
THD *curr_thd = ...; Item *value1 = Item_int(20), *val2= Item_int(30);
Set_variables_helper hlp(curr_thd);
if (hlp.add_variable(nullptr, 0, "foo", 3, enum_var_type::PERSIST_ONLY, value1)) return true;
if (hlp.add_variable("bar", 3, "baz", 3, enum_var_type::PERSIST, val2)) return true;
...
if (hlp->execute()) return true;
The above executes the following command SET PERSIST_ONLY foo = 20, PERSIST bar.baz = 30;
Set_variables_helper::Set_variables_helper | ( | THD * | existing_thd | ) |
Initializes the helper and switches to the canned temp LEX.
existing_thd | the THD to execute on. |
Set_variables_helper::~Set_variables_helper | ( | ) |
bool Set_variables_helper::add_variable | ( | const char * | prefix, |
size_t | prefix_length, | ||
const char * | suffix, | ||
size_t | suffix_length, | ||
Item * | variable_value, | ||
enum_var_type | var_type | ||
) |
Adds setting one variable instruction.
Adds a:
to the SET command being constructed.
prefix | the prefix for the variable name or nullptr if none |
prefix_length | length of prefix, 0 if empty |
suffix | the name of the variable to set. Must be nonnull |
suffix_length | the length of suffix |
variable_value | the value to set |
var_type | how to set: PERSIST, PERSIST_ONLY etc |
true | failure |
false | success |
bool Set_variables_helper::check_variable_update_type | ( | const char * | prefix, |
size_t | prefix_length, | ||
const char * | suffix, | ||
size_t | suffix_length, | ||
Item * | variable_value | ||
) |
Checks the update type for the system variable and throws error if any found.
prefix | the prefix for the variable name or nullptr if none |
prefix_length | length of prefix, 0 if empty |
suffix | the name of the variable to set. Must be nonnull |
suffix_length | the length of suffix |
variable_value | the value to set |
true | failure |
false | success |
bool Set_variables_helper::execute | ( | ) |
Executes the SET command for all variables added.
true | failure |
false | success |
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |