16
16
#include <drizzled/server_includes.h>
17
17
#include <mysys/my_getopt.h>
18
#include <authentication.h>
20
#include <drizzled/drizzled_error_messages.h>
19
#include <drizzled/authentication.h>
20
#include <drizzled/logging.h>
21
#include <drizzled/errmsg.h>
22
#include <drizzled/configvar.h>
23
#include <drizzled/qcache.h>
24
#include <drizzled/parser.h>
25
#include <drizzled/sql_parse.h>
26
#include <drizzled/scheduling.h>
30
#include <drizzled/error.h>
31
#include <drizzled/gettext.h>
21
33
#define REPORT_TO_LOG 1
22
34
#define REPORT_TO_USER 2
24
36
#define plugin_ref_to_int(A) (A ? A[0] : NULL)
25
37
#define plugin_int_to_ref(A) &(A)
27
41
extern struct st_mysql_plugin *mysqld_builtins[];
29
43
char *opt_plugin_load= NULL;
42
56
{ C_STRING_WITH_LEN("UDA") },
43
57
{ C_STRING_WITH_LEN("AUDIT") },
44
58
{ C_STRING_WITH_LEN("LOGGER") },
45
{ C_STRING_WITH_LEN("AUTH") }
59
{ C_STRING_WITH_LEN("ERRMSG") },
60
{ C_STRING_WITH_LEN("AUTH") },
61
{ C_STRING_WITH_LEN("CONFIGVAR") },
62
{ C_STRING_WITH_LEN("QCACHE") },
63
{ C_STRING_WITH_LEN("PARSER") },
64
{ C_STRING_WITH_LEN("SCHEDULING") }
48
67
extern int initialize_schema_table(st_plugin_int *plugin);
163
192
sys_var_pluginvar *cast_pluginvar() { return this; }
164
193
bool is_readonly() const { return plugin_var->flags & PLUGIN_VAR_READONLY; }
165
194
bool check_type(enum_var_type type)
166
{ return !(plugin_var->flags & PLUGIN_VAR_THDLOCAL) && type != OPT_GLOBAL; }
195
{ return !(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) && type != OPT_GLOBAL; }
167
196
bool check_update_type(Item_result type);
168
197
SHOW_TYPE show_type();
169
unsigned char* real_value_ptr(THD *thd, enum_var_type type);
198
unsigned char* real_value_ptr(Session *session, enum_var_type type);
170
199
TYPELIB* plugin_var_typelib(void);
171
unsigned char* value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
172
bool check(THD *thd, set_var *var);
200
unsigned char* value_ptr(Session *session, enum_var_type type, LEX_STRING *base);
201
bool check(Session *session, set_var *var);
173
202
bool check_default(enum_var_type type __attribute__((unused)))
174
203
{ return is_readonly(); }
175
void set_default(THD *thd,
204
void set_default(Session *session,
176
205
enum_var_type type __attribute__((unused)));
177
bool update(THD *thd, set_var *var);
206
bool update(Session *session, set_var *var);
186
215
static bool register_builtin(struct st_mysql_plugin *, struct st_plugin_int *,
187
216
struct st_plugin_int **);
188
static void unlock_variables(THD *thd, struct system_variables *vars);
189
static void cleanup_variables(THD *thd, struct system_variables *vars);
217
static void unlock_variables(Session *session, struct system_variables *vars);
218
static void cleanup_variables(Session *session, struct system_variables *vars);
190
219
static void plugin_vars_free_values(sys_var *vars);
191
220
static void plugin_opt_set_limits(struct my_option *options,
192
221
const struct st_mysql_sys_var *opt);
193
#define my_intern_plugin_lock(A,B) intern_plugin_lock(A,B CALLER_INFO)
194
#define my_intern_plugin_lock_ci(A,B) intern_plugin_lock(A,B ORIG_CALLER_INFO)
195
static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref plugin
222
#define my_intern_plugin_lock(A,B) intern_plugin_lock(A,B)
223
#define my_intern_plugin_lock_ci(A,B) intern_plugin_lock(A,B)
224
static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref plugin);
197
225
static void intern_plugin_unlock(LEX *lex, plugin_ref plugin);
198
226
static void reap_plugins(void);
201
229
/* declared in set_var.cc */
202
230
extern sys_var *intern_find_sys_var(const char *str, uint32_t length, bool no_error);
203
extern bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
231
extern bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
204
232
const char *name, int64_t val);
206
234
/****************************************************************************
339
368
memset(&plugin_dl, 0, sizeof(plugin_dl));
340
369
/* Compile dll path */
342
strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", dl->str, NULL) -
370
dlpath.append(opt_plugin_dir);
372
dlpath.append(dl->str);
344
373
plugin_dl.ref_count= 1;
345
374
/* Open new dll handle */
346
if (!(plugin_dl.handle= dlopen(dlpath, RTLD_LAZY|RTLD_GLOBAL)))
375
if (!(plugin_dl.handle= dlopen(dlpath.c_str(), RTLD_LAZY|RTLD_GLOBAL)))
348
377
const char *errmsg=dlerror();
349
if (!strncmp(dlpath, errmsg, dlpathlen))
378
uint32_t dlpathlen= dlpath.length();
379
if (!dlpath.compare(0, dlpathlen, errmsg))
350
380
{ // if errmsg starts from dlpath, trim this prefix.
351
381
errmsg+=dlpathlen;
352
382
if (*errmsg == ':') errmsg++;
353
383
if (*errmsg == ' ') errmsg++;
355
385
if (report & REPORT_TO_USER)
356
my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dlpath, errno, errmsg);
386
my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dlpath.c_str(), errno, errmsg);
357
387
if (report & REPORT_TO_LOG)
358
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath, errno, errmsg);
388
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath.c_str(), errno, errmsg);
1293
1322
#define EXTRA_OPTIONS 3 /* options for: 'foo', 'plugin-foo' and NULL */
1295
1324
typedef DECLARE_DRIZZLE_SYSVAR_BASIC(sysvar_bool_t, bool);
1296
typedef DECLARE_DRIZZLE_THDVAR_BASIC(thdvar_bool_t, bool);
1325
typedef DECLARE_DRIZZLE_SessionVAR_BASIC(sessionvar_bool_t, bool);
1297
1326
typedef DECLARE_DRIZZLE_SYSVAR_BASIC(sysvar_str_t, char *);
1298
typedef DECLARE_DRIZZLE_THDVAR_BASIC(thdvar_str_t, char *);
1327
typedef DECLARE_DRIZZLE_SessionVAR_BASIC(sessionvar_str_t, char *);
1300
1329
typedef DECLARE_DRIZZLE_SYSVAR_TYPELIB(sysvar_enum_t, unsigned long);
1301
typedef DECLARE_DRIZZLE_THDVAR_TYPELIB(thdvar_enum_t, unsigned long);
1330
typedef DECLARE_DRIZZLE_SessionVAR_TYPELIB(sessionvar_enum_t, unsigned long);
1302
1331
typedef DECLARE_DRIZZLE_SYSVAR_TYPELIB(sysvar_set_t, uint64_t);
1303
typedef DECLARE_DRIZZLE_THDVAR_TYPELIB(thdvar_set_t, uint64_t);
1332
typedef DECLARE_DRIZZLE_SessionVAR_TYPELIB(sessionvar_set_t, uint64_t);
1305
1334
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_int_t, int);
1306
1335
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_long_t, long);
1309
1338
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_ulong_t, ulong);
1310
1339
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_uint64_t_t, uint64_t);
1312
typedef DECLARE_DRIZZLE_THDVAR_SIMPLE(thdvar_int_t, int);
1313
typedef DECLARE_DRIZZLE_THDVAR_SIMPLE(thdvar_long_t, long);
1314
typedef DECLARE_DRIZZLE_THDVAR_SIMPLE(thdvar_int64_t_t, int64_t);
1315
typedef DECLARE_DRIZZLE_THDVAR_SIMPLE(thdvar_uint_t, uint);
1316
typedef DECLARE_DRIZZLE_THDVAR_SIMPLE(thdvar_ulong_t, ulong);
1317
typedef DECLARE_DRIZZLE_THDVAR_SIMPLE(thdvar_uint64_t_t, uint64_t);
1341
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_int_t, int);
1342
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_long_t, long);
1343
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_int64_t_t, int64_t);
1344
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_uint_t, uint);
1345
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_ulong_t, ulong);
1346
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_uint64_t_t, uint64_t);
1319
typedef bool *(*mysql_sys_var_ptr_p)(THD* a_thd, int offset);
1348
typedef bool *(*mysql_sys_var_ptr_p)(Session* a_session, int offset);
1322
1351
/****************************************************************************
1323
1352
default variable data check and update functions
1324
1353
****************************************************************************/
1326
static int check_func_bool(THD *thd __attribute__((unused)),
1355
static int check_func_bool(Session *session __attribute__((unused)),
1327
1356
struct st_mysql_sys_var *var,
1328
1357
void *save, st_mysql_value *value)
1769
returns a pointer to the memory which holds the thd-local variable or
1770
a pointer to the global variable if thd==null.
1798
returns a pointer to the memory which holds the session-local variable or
1799
a pointer to the global variable if session==null.
1771
1800
If required, will sync with global variables if the requested variable
1772
1801
has not yet been allocated in the current thread.
1774
static unsigned char *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
1803
static unsigned char *intern_sys_var_ptr(Session* session, int offset, bool global_lock)
1776
1805
assert(offset >= 0);
1777
1806
assert((uint)offset <= global_system_variables.dynamic_variables_head);
1780
1809
return (unsigned char*) global_system_variables.dynamic_variables_ptr + offset;
1783
1812
dynamic_variables_head points to the largest valid offset
1785
if (!thd->variables.dynamic_variables_ptr ||
1786
(uint)offset > thd->variables.dynamic_variables_head)
1814
if (!session->variables.dynamic_variables_ptr ||
1815
(uint)offset > session->variables.dynamic_variables_head)
1790
1819
rw_rdlock(&LOCK_system_variables_hash);
1792
thd->variables.dynamic_variables_ptr= (char*)
1793
my_realloc(thd->variables.dynamic_variables_ptr,
1821
session->variables.dynamic_variables_ptr= (char*)
1822
my_realloc(session->variables.dynamic_variables_ptr,
1794
1823
global_variables_dynamic_size,
1795
1824
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
1838
1867
if (global_lock)
1839
1868
pthread_mutex_unlock(&LOCK_global_system_variables);
1841
thd->variables.dynamic_variables_version=
1870
session->variables.dynamic_variables_version=
1842
1871
global_system_variables.dynamic_variables_version;
1843
thd->variables.dynamic_variables_head=
1872
session->variables.dynamic_variables_head=
1844
1873
global_system_variables.dynamic_variables_head;
1845
thd->variables.dynamic_variables_size=
1874
session->variables.dynamic_variables_size=
1846
1875
global_system_variables.dynamic_variables_size;
1848
1877
rw_unlock(&LOCK_system_variables_hash);
1850
return (unsigned char*)thd->variables.dynamic_variables_ptr + offset;
1853
static bool *mysql_sys_var_ptr_bool(THD* a_thd, int offset)
1855
return (bool *)intern_sys_var_ptr(a_thd, offset, true);
1858
static int *mysql_sys_var_ptr_int(THD* a_thd, int offset)
1860
return (int *)intern_sys_var_ptr(a_thd, offset, true);
1863
static long *mysql_sys_var_ptr_long(THD* a_thd, int offset)
1865
return (long *)intern_sys_var_ptr(a_thd, offset, true);
1868
static int64_t *mysql_sys_var_ptr_int64_t(THD* a_thd, int offset)
1870
return (int64_t *)intern_sys_var_ptr(a_thd, offset, true);
1873
static char **mysql_sys_var_ptr_str(THD* a_thd, int offset)
1875
return (char **)intern_sys_var_ptr(a_thd, offset, true);
1878
static uint64_t *mysql_sys_var_ptr_set(THD* a_thd, int offset)
1880
return (uint64_t *)intern_sys_var_ptr(a_thd, offset, true);
1883
static unsigned long *mysql_sys_var_ptr_enum(THD* a_thd, int offset)
1885
return (unsigned long *)intern_sys_var_ptr(a_thd, offset, true);
1889
void plugin_thdvar_init(THD *thd)
1891
plugin_ref old_table_plugin= thd->variables.table_plugin;
1893
thd->variables.table_plugin= NULL;
1894
cleanup_variables(thd, &thd->variables);
1896
thd->variables= global_system_variables;
1897
thd->variables.table_plugin= NULL;
1879
return (unsigned char*)session->variables.dynamic_variables_ptr + offset;
1882
static bool *mysql_sys_var_ptr_bool(Session* a_session, int offset)
1884
return (bool *)intern_sys_var_ptr(a_session, offset, true);
1887
static int *mysql_sys_var_ptr_int(Session* a_session, int offset)
1889
return (int *)intern_sys_var_ptr(a_session, offset, true);
1892
static long *mysql_sys_var_ptr_long(Session* a_session, int offset)
1894
return (long *)intern_sys_var_ptr(a_session, offset, true);
1897
static int64_t *mysql_sys_var_ptr_int64_t(Session* a_session, int offset)
1899
return (int64_t *)intern_sys_var_ptr(a_session, offset, true);
1902
static char **mysql_sys_var_ptr_str(Session* a_session, int offset)
1904
return (char **)intern_sys_var_ptr(a_session, offset, true);
1907
static uint64_t *mysql_sys_var_ptr_set(Session* a_session, int offset)
1909
return (uint64_t *)intern_sys_var_ptr(a_session, offset, true);
1912
static unsigned long *mysql_sys_var_ptr_enum(Session* a_session, int offset)
1914
return (unsigned long *)intern_sys_var_ptr(a_session, offset, true);
1918
void plugin_sessionvar_init(Session *session)
1920
plugin_ref old_table_plugin= session->variables.table_plugin;
1922
session->variables.table_plugin= NULL;
1923
cleanup_variables(session, &session->variables);
1925
session->variables= global_system_variables;
1926
session->variables.table_plugin= NULL;
1899
1928
/* we are going to allocate these lazily */
1900
thd->variables.dynamic_variables_version= 0;
1901
thd->variables.dynamic_variables_size= 0;
1902
thd->variables.dynamic_variables_ptr= 0;
1929
session->variables.dynamic_variables_version= 0;
1930
session->variables.dynamic_variables_size= 0;
1931
session->variables.dynamic_variables_ptr= 0;
1904
thd->variables.table_plugin=
1933
session->variables.table_plugin=
1905
1934
my_intern_plugin_lock(NULL, global_system_variables.table_plugin);
1906
1935
intern_plugin_unlock(NULL, old_table_plugin);
1967
void plugin_thdvar_cleanup(THD *thd)
1996
void plugin_sessionvar_cleanup(Session *session)
1970
1999
plugin_ref *list;
1972
unlock_variables(thd, &thd->variables);
1973
cleanup_variables(thd, &thd->variables);
2001
unlock_variables(session, &session->variables);
2002
cleanup_variables(session, &session->variables);
1975
if ((idx= thd->lex->plugins.elements))
2004
if ((idx= session->lex->plugins.elements))
1977
list= ((plugin_ref*) thd->lex->plugins.buffer) + idx - 1;
1978
while ((unsigned char*) list >= thd->lex->plugins.buffer)
2006
list= ((plugin_ref*) session->lex->plugins.buffer) + idx - 1;
2007
while ((unsigned char*) list >= session->lex->plugins.buffer)
1979
2008
intern_plugin_unlock(NULL, *list--);
1982
reset_dynamic(&thd->lex->plugins);
2011
reset_dynamic(&session->lex->plugins);
2151
2180
pthread_mutex_lock(&LOCK_global_system_variables);
2152
tgt= real_value_ptr(thd, type);
2181
tgt= real_value_ptr(session, type);
2153
2182
src= ((void **) (plugin_var + 1) + 1);
2155
if (plugin_var->flags & PLUGIN_VAR_THDLOCAL)
2184
if (plugin_var->flags & PLUGIN_VAR_SessionLOCAL)
2157
2186
if (type != OPT_GLOBAL)
2158
src= real_value_ptr(thd, OPT_GLOBAL);
2187
src= real_value_ptr(session, OPT_GLOBAL);
2160
2189
switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) {
2161
2190
case PLUGIN_VAR_INT:
2162
src= &((thdvar_uint_t*) plugin_var)->def_val;
2191
src= &((sessionvar_uint_t*) plugin_var)->def_val;
2164
2193
case PLUGIN_VAR_LONG:
2165
src= &((thdvar_ulong_t*) plugin_var)->def_val;
2194
src= &((sessionvar_ulong_t*) plugin_var)->def_val;
2167
2196
case PLUGIN_VAR_LONGLONG:
2168
src= &((thdvar_uint64_t_t*) plugin_var)->def_val;
2197
src= &((sessionvar_uint64_t_t*) plugin_var)->def_val;
2170
2199
case PLUGIN_VAR_ENUM:
2171
src= &((thdvar_enum_t*) plugin_var)->def_val;
2200
src= &((sessionvar_enum_t*) plugin_var)->def_val;
2173
2202
case PLUGIN_VAR_SET:
2174
src= &((thdvar_set_t*) plugin_var)->def_val;
2203
src= &((sessionvar_set_t*) plugin_var)->def_val;
2176
2205
case PLUGIN_VAR_BOOL:
2177
src= &((thdvar_bool_t*) plugin_var)->def_val;
2206
src= &((sessionvar_bool_t*) plugin_var)->def_val;
2179
2208
case PLUGIN_VAR_STR:
2180
src= &((thdvar_str_t*) plugin_var)->def_val;
2209
src= &((sessionvar_str_t*) plugin_var)->def_val;
2187
/* thd must equal current_thd if PLUGIN_VAR_THDLOCAL flag is set */
2188
assert(!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) ||
2189
thd == current_thd);
2216
/* session must equal current_session if PLUGIN_VAR_SessionLOCAL flag is set */
2217
assert(!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) ||
2218
session == current_session);
2191
if (!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) || type == OPT_GLOBAL)
2220
if (!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) || type == OPT_GLOBAL)
2193
plugin_var->update(thd, plugin_var, tgt, src);
2222
plugin_var->update(session, plugin_var, tgt, src);
2194
2223
pthread_mutex_unlock(&LOCK_global_system_variables);
2198
2227
pthread_mutex_unlock(&LOCK_global_system_variables);
2199
plugin_var->update(thd, plugin_var, tgt, src);
2228
plugin_var->update(session, plugin_var, tgt, src);
2204
bool sys_var_pluginvar::update(THD *thd, set_var *var)
2233
bool sys_var_pluginvar::update(Session *session, set_var *var)
2208
2237
assert(is_readonly() || plugin_var->update);
2210
/* thd must equal current_thd if PLUGIN_VAR_THDLOCAL flag is set */
2211
assert(!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) ||
2212
thd == current_thd);
2239
/* session must equal current_session if PLUGIN_VAR_SessionLOCAL flag is set */
2240
assert(!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) ||
2241
session == current_session);
2214
2243
if (is_readonly())
2217
2246
pthread_mutex_lock(&LOCK_global_system_variables);
2218
tgt= real_value_ptr(thd, var->type);
2247
tgt= real_value_ptr(session, var->type);
2220
if (!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) || var->type == OPT_GLOBAL)
2249
if (!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) || var->type == OPT_GLOBAL)
2222
2251
/* variable we are updating has global scope, so we unlock after updating */
2223
plugin_var->update(thd, plugin_var, tgt, &var->save_result);
2252
plugin_var->update(session, plugin_var, tgt, &var->save_result);
2224
2253
pthread_mutex_unlock(&LOCK_global_system_variables);
2228
2257
pthread_mutex_unlock(&LOCK_global_system_variables);
2229
plugin_var->update(thd, plugin_var, tgt, &var->save_result);
2258
plugin_var->update(session, plugin_var, tgt, &var->save_result);
2290
2319
options->def_value= (intptr_t) ((sysvar_str_t*) opt)->def_val;
2292
2321
/* threadlocal variables */
2293
case PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL:
2294
OPTION_SET_LIMITS(GET_INT, options, (thdvar_int_t*) opt);
2296
case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL:
2297
OPTION_SET_LIMITS(GET_UINT, options, (thdvar_uint_t*) opt);
2299
case PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL:
2300
OPTION_SET_LIMITS(GET_LONG, options, (thdvar_long_t*) opt);
2302
case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL:
2303
OPTION_SET_LIMITS(GET_ULONG, options, (thdvar_ulong_t*) opt);
2305
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL:
2306
OPTION_SET_LIMITS(GET_LL, options, (thdvar_int64_t_t*) opt);
2308
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_THDLOCAL:
2309
OPTION_SET_LIMITS(GET_ULL, options, (thdvar_uint64_t_t*) opt);
2311
case PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL:
2322
case PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL:
2323
OPTION_SET_LIMITS(GET_INT, options, (sessionvar_int_t*) opt);
2325
case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL:
2326
OPTION_SET_LIMITS(GET_UINT, options, (sessionvar_uint_t*) opt);
2328
case PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL:
2329
OPTION_SET_LIMITS(GET_LONG, options, (sessionvar_long_t*) opt);
2331
case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL:
2332
OPTION_SET_LIMITS(GET_ULONG, options, (sessionvar_ulong_t*) opt);
2334
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL:
2335
OPTION_SET_LIMITS(GET_LL, options, (sessionvar_int64_t_t*) opt);
2337
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL:
2338
OPTION_SET_LIMITS(GET_ULL, options, (sessionvar_uint64_t_t*) opt);
2340
case PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL:
2312
2341
options->var_type= GET_ENUM;
2313
options->typelib= ((thdvar_enum_t*) opt)->typelib;
2314
options->def_value= ((thdvar_enum_t*) opt)->def_val;
2342
options->typelib= ((sessionvar_enum_t*) opt)->typelib;
2343
options->def_value= ((sessionvar_enum_t*) opt)->def_val;
2315
2344
options->min_value= options->block_size= 0;
2316
2345
options->max_value= options->typelib->count - 1;
2318
case PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL:
2347
case PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL:
2319
2348
options->var_type= GET_SET;
2320
options->typelib= ((thdvar_set_t*) opt)->typelib;
2321
options->def_value= ((thdvar_set_t*) opt)->def_val;
2349
options->typelib= ((sessionvar_set_t*) opt)->typelib;
2350
options->def_value= ((sessionvar_set_t*) opt)->def_val;
2322
2351
options->min_value= options->block_size= 0;
2323
2352
options->max_value= (1UL << options->typelib->count) - 1;
2325
case PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL:
2354
case PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL:
2326
2355
options->var_type= GET_BOOL;
2327
options->def_value= ((thdvar_bool_t*) opt)->def_val;
2356
options->def_value= ((sessionvar_bool_t*) opt)->def_val;
2329
case PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL:
2358
case PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL:
2330
2359
options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ?
2331
2360
GET_STR_ALLOC : GET_STR);
2332
options->def_value= (intptr_t) ((thdvar_str_t*) opt)->def_val;
2361
options->def_value= (intptr_t) ((sessionvar_str_t*) opt)->def_val;
2404
2433
plugin_option && *plugin_option; plugin_option++, index++)
2406
2435
opt= *plugin_option;
2407
if (!(opt->flags & PLUGIN_VAR_THDLOCAL))
2436
if (!(opt->flags & PLUGIN_VAR_SessionLOCAL))
2409
2438
if (!(register_var(name, opt->name, opt->flags)))
2411
2440
switch (opt->flags & PLUGIN_VAR_TYPEMASK) {
2412
2441
case PLUGIN_VAR_BOOL:
2413
(((thdvar_bool_t *)opt)->resolve)= mysql_sys_var_ptr_bool;
2442
(((sessionvar_bool_t *)opt)->resolve)= mysql_sys_var_ptr_bool;
2415
2444
case PLUGIN_VAR_INT:
2416
(((thdvar_int_t *)opt)->resolve)= mysql_sys_var_ptr_int;
2445
(((sessionvar_int_t *)opt)->resolve)= mysql_sys_var_ptr_int;
2418
2447
case PLUGIN_VAR_LONG:
2419
(((thdvar_long_t *)opt)->resolve)= mysql_sys_var_ptr_long;
2448
(((sessionvar_long_t *)opt)->resolve)= mysql_sys_var_ptr_long;
2421
2450
case PLUGIN_VAR_LONGLONG:
2422
(((thdvar_int64_t_t *)opt)->resolve)= mysql_sys_var_ptr_int64_t;
2451
(((sessionvar_int64_t_t *)opt)->resolve)= mysql_sys_var_ptr_int64_t;
2424
2453
case PLUGIN_VAR_STR:
2425
(((thdvar_str_t *)opt)->resolve)= mysql_sys_var_ptr_str;
2454
(((sessionvar_str_t *)opt)->resolve)= mysql_sys_var_ptr_str;
2427
2456
case PLUGIN_VAR_ENUM:
2428
(((thdvar_enum_t *)opt)->resolve)= mysql_sys_var_ptr_enum;
2457
(((sessionvar_enum_t *)opt)->resolve)= mysql_sys_var_ptr_enum;
2430
2459
case PLUGIN_VAR_SET:
2431
(((thdvar_set_t *)opt)->resolve)= mysql_sys_var_ptr_set;
2460
(((sessionvar_set_t *)opt)->resolve)= mysql_sys_var_ptr_set;
2434
2463
sql_print_error(_("Unknown variable type code 0x%x in plugin '%s'."),