MySQL 8.0.32
Source Code Documentation
s_mysql_mysql_system_variable_update_integer Struct Reference

Service to set the value of integer system variables. More...

#include <mysql_system_variable.h>

Public Attributes

mysql_service_status_t(* set_signed )(MYSQL_THD thd, const char *variable_type, my_h_string variable_base, my_h_string variable_name, long long variable_value)
 Sets the value of a system variable to a new signed integer value. More...
 
mysql_service_status_t(* set_unsigned )(MYSQL_THD thd, const char *variable_type, my_h_string variable_base, my_h_string variable_name, unsigned long long variable_value)
 Sets the value of a system variable to a new unsigned integer value. More...
 

Detailed Description

Service to set the value of integer system variables.

Passing non-NULL THD input to setter methods means that the operation will be executed within the scope of existing transaction, thus any operation side effects impacting transaction itself (for example it may generate an SQL error that it stores into the current THD). If using existing THD, security context of the thread is checked to make sure that required privileges exist. Passing NULL makes a temporary THD created as a execution context (and destroyed afterwards), i.e. no impacts on existing transactions. It doesn't make sense to change SESSION variable on a temporary THD, so this operation will generate error.

This is an example of using the service:

MYSQL_THD thd = nullptr;
if (!make_new_thread &&
mysql_service_mysql_current_thread_reader->get(&thd)) {
*error = 1;
return 0;
}
const char *cs = "latin1";
const char *base_input = "my_component"; //nullptr if not a component variable
const char *name_input = "my_variable";
const char *type = "SESSION";
long long value_signed = 100000;
unsigned long long value_unsigned = 500000;
my_h_string base = nullptr, name = nullptr;
if ((base != nullptr &&
mysql_service_mysql_string_converter->convert_from_buffer(
&base, base_input, strlen(base_input), cs)) ||
mysql_service_mysql_string_converter->convert_from_buffer(
&name, name_input, strlen(name_input), cs)) {
if (base) mysql_service_mysql_string_factory->destroy(base);
if (name) mysql_service_mysql_string_factory->destroy(name);
*error = 1;
return 0;
}
// example call for signed integer system variable type
if (mysql_service_mysql_system_variable_update_integer->set_signed(
thd, type, base, name, value_signed))
*error = 1;
// alternative call for unsigned integer type
if (mysql_service_mysql_system_variable_update_integer->set_unsigned(
thd, type, base, name, value_unsigned))
*error = 1;
if (base) mysql_service_mysql_string_factory->destroy(base);
if (name) mysql_service_mysql_string_factory->destroy(name);
#define MYSQL_THD
Definition: backup_page_tracker.h:37
Definition: commit_order_queue.h:33
required string type
Definition: replication_group_member_actions.proto:33
case opt name
Definition: sslopt-case.h:32
The string functions as a service to the mysql_server component.
Definition: mysql_string_service.cc:45
See also
mysql_system_variable_update_imp

Member Data Documentation

◆ set_signed

mysql_service_status_t(* s_mysql_mysql_system_variable_update_integer::set_signed) (MYSQL_THD thd, const char *variable_type, my_h_string variable_base, my_h_string variable_name, long long variable_value)

Sets the value of a system variable to a new signed integer value.

Uses long long type to store the data, this type size may differ on a different environments (32-bit vs 64-bit builds for example). This means that the user must ensure that component using this API was compiled using the same environment as for the server code.

Parameters
thdthread session handle. if NULL a temp one will be created and then removed.
variable_typeOne of GLOBAL, SESSION, PERSIST, PERSIST_ONLY. If NULL, then assumes GLOBAL. SESSION is not supported for a temporary THD.
variable_basea mysql string of the variable name prefix. NULL if none
variable_nameMySQL string of the variable name
variable_valuelong long to set as value
Return values
FALSEsuccess
TRUEfailure, error set. For error info, see THD if supplied.

◆ set_unsigned

mysql_service_status_t(* s_mysql_mysql_system_variable_update_integer::set_unsigned) (MYSQL_THD thd, const char *variable_type, my_h_string variable_base, my_h_string variable_name, unsigned long long variable_value)

Sets the value of a system variable to a new unsigned integer value.

Uses unsigned long long type to store the data, this type size may differ on a different environments (32-bit vs 64-bit builds for example). This means that the user must ensure that component using this API was compiled using the same environment as for the server code.

Parameters
thdthread session handle. if NULL a temp one will be created and then removed.
variable_typeOne of GLOBAL, SESSION, PERSIST, PERSIST_ONLY. If NULL, then assumes GLOBAL. SESSION is not supported for a temporary THD.
variable_basea mysql string of the variable name prefix. NULL if none
variable_nameMySQL string of the variable name
variable_valueunsigned long long to set as value
Return values
FALSEsuccess
TRUEfailure, error set. For error info, see THD if supplied.

The documentation for this struct was generated from the following file: