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>
18
#include <mysys/hash.h>
20
#include <drizzled/authentication.h>
21
#include <drizzled/logging.h>
22
#include <drizzled/errmsg.h>
23
#include <drizzled/configvar.h>
24
#include <drizzled/qcache.h>
25
#include <drizzled/parser.h>
26
#include <drizzled/sql_parse.h>
27
#include <drizzled/scheduling.h>
28
#include <drizzled/replicator.h>
29
#include <drizzled/show.h>
30
#include <drizzled/handler.h>
31
#include <drizzled/set_var.h>
32
#include <drizzled/session.h>
33
#include <drizzled/item/null.h>
34
#include <drizzled/plugin_registry.h>
40
#include <drizzled/error.h>
41
#include <drizzled/gettext.h>
21
43
#define REPORT_TO_LOG 1
22
44
#define REPORT_TO_USER 2
24
46
#define plugin_ref_to_int(A) (A ? A[0] : NULL)
25
47
#define plugin_int_to_ref(A) &(A)
27
51
extern struct st_mysql_plugin *mysqld_builtins[];
29
53
char *opt_plugin_load= NULL;
163
204
sys_var_pluginvar *cast_pluginvar() { return this; }
164
205
bool is_readonly() const { return plugin_var->flags & PLUGIN_VAR_READONLY; }
165
206
bool check_type(enum_var_type type)
166
{ return !(plugin_var->flags & PLUGIN_VAR_THDLOCAL) && type != OPT_GLOBAL; }
207
{ return !(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) && type != OPT_GLOBAL; }
167
208
bool check_update_type(Item_result type);
168
209
SHOW_TYPE show_type();
169
unsigned char* real_value_ptr(THD *thd, enum_var_type type);
210
unsigned char* real_value_ptr(Session *session, enum_var_type type);
170
211
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);
173
bool check_default(enum_var_type type __attribute__((unused)))
212
unsigned char* value_ptr(Session *session, enum_var_type type,
213
const LEX_STRING *base);
214
bool check(Session *session, set_var *var);
215
bool check_default(enum_var_type)
174
216
{ return is_readonly(); }
175
void set_default(THD *thd,
176
enum_var_type type __attribute__((unused)));
177
bool update(THD *thd, set_var *var);
217
void set_default(Session *session, enum_var_type);
218
bool update(Session *session, set_var *var);
186
227
static bool register_builtin(struct st_mysql_plugin *, struct st_plugin_int *,
187
228
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);
229
static void unlock_variables(Session *session, struct system_variables *vars);
230
static void cleanup_variables(Session *session, struct system_variables *vars);
190
231
static void plugin_vars_free_values(sys_var *vars);
191
232
static void plugin_opt_set_limits(struct my_option *options,
192
233
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
234
#define my_intern_plugin_lock(A,B) intern_plugin_lock(A,B)
235
#define my_intern_plugin_lock_ci(A,B) intern_plugin_lock(A,B)
236
static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref plugin);
197
237
static void intern_plugin_unlock(LEX *lex, plugin_ref plugin);
198
238
static void reap_plugins(void);
201
241
/* declared in set_var.cc */
202
242
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,
243
extern bool throw_bounds_warning(Session *session, bool fixed, bool unsignd,
204
244
const char *name, int64_t val);
206
246
/****************************************************************************
339
382
memset(&plugin_dl, 0, sizeof(plugin_dl));
340
383
/* Compile dll path */
342
strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", dl->str, NULL) -
384
dlpath.append(opt_plugin_dir);
386
dlpath.append(dl->str);
344
387
plugin_dl.ref_count= 1;
345
388
/* Open new dll handle */
346
if (!(plugin_dl.handle= dlopen(dlpath, RTLD_LAZY|RTLD_GLOBAL)))
389
if (!(plugin_dl.handle= dlopen(dlpath.c_str(), RTLD_LAZY|RTLD_GLOBAL)))
348
391
const char *errmsg=dlerror();
349
if (!strncmp(dlpath, errmsg, dlpathlen))
392
uint32_t dlpathlen= dlpath.length();
393
if (!dlpath.compare(0, dlpathlen, errmsg))
350
394
{ // if errmsg starts from dlpath, trim this prefix.
351
395
errmsg+=dlpathlen;
352
396
if (*errmsg == ':') errmsg++;
353
397
if (*errmsg == ' ') errmsg++;
355
399
if (report & REPORT_TO_USER)
356
my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dlpath, errno, errmsg);
400
my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dlpath.c_str(), errno, errmsg);
357
401
if (report & REPORT_TO_LOG)
358
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath, errno, errmsg);
402
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_CANT_OPEN_LIBRARY), dlpath.c_str(), errno, errmsg);
430
static struct st_plugin_int *plugin_find_internal(const LEX_STRING *name, int type)
436
if (type == DRIZZLE_ANY_PLUGIN)
438
for (i= 0; i < DRIZZLE_MAX_PLUGIN_TYPE_NUM; i++)
440
struct st_plugin_int *plugin= (st_plugin_int *)
441
hash_search(&plugin_hash[i], (const unsigned char *)name->str, name->length);
447
return((st_plugin_int *)
448
hash_search(&plugin_hash[type], (const unsigned char *)name->str, name->length));
453
475
static SHOW_COMP_OPTION plugin_status(const LEX_STRING *name, int type)
477
Plugin_registry registry= Plugin_registry::get_plugin_registry();
455
479
SHOW_COMP_OPTION rc= SHOW_OPTION_NO;
456
480
struct st_plugin_int *plugin;
457
if ((plugin= plugin_find_internal(name, type)))
485
if ((plugin= registry.find(name, type)))
459
487
rc= SHOW_OPTION_DISABLED;
460
488
if (plugin->state == PLUGIN_IS_READY)
492
520
memory manager and/or valgrind to track locked references and
493
521
double unlocks to aid resolving reference counting.problems.
495
if (!(plugin= (plugin_ref) my_malloc_ci(sizeof(pi), MYF(MY_WME))))
523
if (!(plugin= (plugin_ref) malloc(sizeof(pi))))
502
insert_dynamic(&lex->plugins, (unsigned char*)&plugin);
509
plugin_ref plugin_lock(THD *thd, plugin_ref *ptr CALLER_INFO_PROTO)
535
plugin_ref plugin_lock(Session *session, plugin_ref *ptr)
511
LEX *lex= thd ? thd->lex : 0;
537
LEX *lex= session ? session->lex : 0;
513
539
rc= my_intern_plugin_lock_ci(lex, *ptr);
518
plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name, int type
544
plugin_ref plugin_lock_by_name(Session *session, const LEX_STRING *name, int type)
521
LEX *lex= thd ? thd->lex : 0;
546
Plugin_registry registry= Plugin_registry::get_plugin_registry();
548
LEX *lex= session ? session->lex : 0;
522
549
plugin_ref rc= NULL;
523
550
st_plugin_int *plugin;
524
if ((plugin= plugin_find_internal(name, type)))
554
if ((plugin= registry.find(name, type)))
525
555
rc= my_intern_plugin_lock_ci(lex, plugin_int_to_ref(plugin));
558
588
const LEX_STRING *name, const LEX_STRING *dl,
559
589
int *argc, char **argv, int report)
591
Plugin_registry registry= Plugin_registry::get_plugin_registry();
561
593
struct st_plugin_int tmp;
562
594
struct st_mysql_plugin *plugin;
563
if (plugin_find_internal(name, DRIZZLE_ANY_PLUGIN))
598
if (registry.find(name, DRIZZLE_ANY_PLUGIN))
565
600
if (report & REPORT_TO_USER)
566
601
my_error(ER_UDF_EXISTS, MYF(0), name->str);
567
602
if (report & REPORT_TO_LOG)
568
sql_print_error(ER(ER_UDF_EXISTS), name->str);
603
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_UDF_EXISTS), name->str);
571
606
/* Clear the whole struct to catch future extensions. */
669
701
/* Free allocated strings before deleting the plugin. */
670
702
plugin_vars_free_values(plugin->system_vars);
671
hash_delete(&plugin_hash[plugin->plugin->type], (unsigned char*)plugin);
672
703
if (plugin->plugin_dl)
673
704
plugin_dl_del(&plugin->plugin_dl->dl);
674
705
plugin->state= PLUGIN_IS_FREED;
675
706
plugin_array_version++;
676
rw_wrlock(&LOCK_system_variables_hash);
707
pthread_rwlock_wrlock(&LOCK_system_variables_hash);
677
708
mysql_del_sys_var_chain(plugin->system_vars);
678
rw_unlock(&LOCK_system_variables_hash);
709
pthread_rwlock_unlock(&LOCK_system_variables_hash);
679
710
free_root(&plugin->mem_root, MYF(0));
683
714
static void reap_plugins(void)
686
struct st_plugin_int *plugin, **reap, **list;
718
struct st_plugin_int *plugin;
691
720
reap_needed= false;
692
721
count= plugin_array.elements;
693
reap= (struct st_plugin_int **)my_alloca(sizeof(plugin)*(count+1));
696
723
for (idx= 0; idx < count; idx++)
698
725
plugin= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);
699
if (plugin->state == PLUGIN_IS_DELETED && !plugin->ref_count)
701
/* change the status flag to prevent reaping by another thread */
702
plugin->state= PLUGIN_IS_DYING;
708
while ((plugin= *(--list)))
726
plugin->state= PLUGIN_IS_DYING;
709
727
plugin_deinitialize(plugin, true);
711
while ((plugin= *(--reap)))
712
728
plugin_del(plugin);
717
static void intern_plugin_unlock(LEX *lex, plugin_ref plugin)
732
static void intern_plugin_unlock(LEX *, plugin_ref plugin)
720
734
st_plugin_int *pi;
842
extern "C" unsigned char *get_plugin_hash_key(const unsigned char *, size_t *, bool);
843
841
extern "C" unsigned char *get_bookmark_hash_key(const unsigned char *, size_t *, bool);
846
unsigned char *get_plugin_hash_key(const unsigned char *buff, size_t *length,
847
bool not_used __attribute__((unused)))
849
struct st_plugin_int *plugin= (st_plugin_int *)buff;
850
*length= (uint)plugin->name.length;
851
return((unsigned char *)plugin->name.str);
855
unsigned char *get_bookmark_hash_key(const unsigned char *buff, size_t *length,
856
bool not_used __attribute__((unused)))
844
unsigned char *get_bookmark_hash_key(const unsigned char *buff, size_t *length, bool)
858
846
struct st_bookmark *var= (st_bookmark *)buff;
859
847
*length= var->name_len + 1;
955
936
Now we initialize all remaining plugins
958
reap= (st_plugin_int **) my_alloca((plugin_array.elements+1) * sizeof(void*));
961
for (i= 0; i < plugin_array.elements; i++)
938
for (idx= 0; idx < plugin_array.elements; idx++)
963
plugin_ptr= *dynamic_element(&plugin_array, i, struct st_plugin_int **);
940
plugin_ptr= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);
964
941
if (plugin_ptr->state == PLUGIN_IS_UNINITIALIZED)
966
943
if (plugin_initialize(plugin_ptr))
968
945
plugin_ptr->state= PLUGIN_IS_DYING;
969
*(reap++)= plugin_ptr;
946
plugin_deinitialize(plugin_ptr, true);
947
plugin_del(plugin_ptr);
975
Check if any plugins have to be reaped
977
while ((plugin_ptr= *(--reap)))
979
plugin_deinitialize(plugin_ptr, true);
980
plugin_del(plugin_ptr);
986
954
free_root(&tmp_root, MYF(0));
1146
1117
if (count > free_slots)
1147
sql_print_warning(_("Forcing shutdown of %d plugins"),
1148
count - free_slots);
1118
errmsg_printf(ERRMSG_LVL_WARN, _("Forcing shutdown of %"PRIu64" plugins"),
1119
(uint64_t)count - free_slots);
1150
plugins= (struct st_plugin_int **) my_alloca(sizeof(void*) * (count+1));
1121
plugins.reserve(count);
1153
1124
If we have any plugins which did not die cleanly, we force shutdown
1155
for (i= 0; i < count; i++)
1126
for (idx= 0; idx < count; idx++)
1157
plugins[i]= *dynamic_element(&plugin_array, i, struct st_plugin_int **);
1128
plugins.push_back(*dynamic_element(&plugin_array, idx,
1129
struct st_plugin_int **));
1158
1130
/* change the state to ensure no reaping races */
1159
if (plugins[i]->state == PLUGIN_IS_DELETED)
1160
plugins[i]->state= PLUGIN_IS_DYING;
1131
if (plugins[idx]->state == PLUGIN_IS_DELETED)
1132
plugins[idx]->state= PLUGIN_IS_DYING;
1164
1136
We loop through all plugins and call deinit() if they have one.
1166
for (i= 0; i < count; i++)
1167
if (!(plugins[i]->state & (PLUGIN_IS_UNINITIALIZED | PLUGIN_IS_FREED)))
1138
for (idx= 0; idx < count; idx++)
1139
if (!(plugins[idx]->state & (PLUGIN_IS_UNINITIALIZED | PLUGIN_IS_FREED)))
1169
sql_print_information(_("Plugin '%s' will be forced to shutdown"),
1170
plugins[i]->name.str);
1141
errmsg_printf(ERRMSG_LVL_INFO, _("Plugin '%s' will be forced to shutdown"),
1142
plugins[idx]->name.str);
1172
1144
We are forcing deinit on plugins so we don't want to do a ref_count
1173
1145
check until we have processed all the plugins.
1175
plugin_deinitialize(plugins[i], false);
1147
plugin_deinitialize(plugins[idx], false);
1179
1151
We defer checking ref_counts until after all plugins are deinitialized
1180
1152
as some may have worker threads holding on to plugin references.
1182
for (i= 0; i < count; i++)
1154
for (idx= 0; idx < count; idx++)
1184
if (plugins[i]->ref_count)
1185
sql_print_error(_("Plugin '%s' has ref_count=%d after shutdown."),
1186
plugins[i]->name.str, plugins[i]->ref_count);
1187
if (plugins[i]->state & PLUGIN_IS_UNINITIALIZED)
1188
plugin_del(plugins[i]);
1156
if (plugins[idx]->ref_count)
1157
errmsg_printf(ERRMSG_LVL_ERROR, _("Plugin '%s' has ref_count=%d after shutdown."),
1158
plugins[idx]->name.str, plugins[idx]->ref_count);
1159
if (plugins[idx]->state & PLUGIN_IS_UNINITIALIZED)
1160
plugin_del(plugins[idx]);
1198
1170
initialized= 0;
1203
1174
/* Dispose of the memory */
1205
for (i= 0; i < DRIZZLE_MAX_PLUGIN_TYPE_NUM; i++)
1206
hash_free(&plugin_hash[i]);
1207
1176
delete_dynamic(&plugin_array);
1209
1178
count= plugin_dl_array.elements;
1210
dl= (struct st_plugin_dl **)my_alloca(sizeof(void*) * count);
1211
for (i= 0; i < count; i++)
1212
dl[i]= *dynamic_element(&plugin_dl_array, i, struct st_plugin_dl **);
1213
for (i= 0; i < plugin_dl_array.elements; i++)
1214
free_plugin_mem(dl[i]);
1180
for (idx= 0; idx < count; idx++)
1181
dl.push_back(*dynamic_element(&plugin_dl_array, idx,
1182
struct st_plugin_dl **));
1183
for (idx= 0; idx < count; idx++)
1184
free_plugin_mem(dl[idx]);
1216
1185
delete_dynamic(&plugin_dl_array);
1218
1187
hash_free(&bookmark_hash);
1237
1211
state_mask= ~state_mask; // do it only once
1239
total= type == DRIZZLE_ANY_PLUGIN ? plugin_array.elements
1240
: plugin_hash[type].records;
1242
Do the alloca out here in case we do have a working alloca:
1243
leaving the nested stack frame invalidates alloca allocation.
1245
plugins=(struct st_plugin_int **)my_alloca(total*sizeof(plugin));
1246
1214
if (type == DRIZZLE_ANY_PLUGIN)
1248
for (idx= 0; idx < total; idx++)
1216
plugins.reserve(plugin_array.elements);
1217
for (idx= 0; idx < plugin_array.elements; idx++)
1250
1219
plugin= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);
1251
plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL;
1220
plugins.push_back(!(plugin->state & state_mask) ? plugin : NULL);
1256
HASH *hash= plugin_hash + type;
1257
for (idx= 0; idx < total; idx++)
1259
plugin= (struct st_plugin_int *) hash_element(hash, idx);
1260
plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL;
1225
Plugin_registry registry= Plugin_registry::get_plugin_registry();
1226
registry.get_mask_list(type, plugins, state_mask);
1263
for (idx= 0; idx < total; idx++)
1229
vector<st_plugin_int *>::iterator plugin_iter;
1230
for (plugin_iter= plugins.begin();
1231
plugin_iter != plugins.end();
1265
1234
if (unlikely(version != plugin_array_version))
1267
for (uint32_t i=idx; i < total; i++)
1268
if (plugins[i] && plugins[i]->state & state_mask)
1236
vector<st_plugin_int *>::iterator reset_iter;
1237
for (reset_iter= plugin_iter;
1238
reset_iter != plugins.end();
1240
if (*reset_iter && (*reset_iter)->state & state_mask)
1271
plugin= plugins[idx];
1243
plugin= *plugin_iter;
1272
1244
/* It will stop iterating on first engine error when "func" returns true */
1273
if (plugin && func(thd, plugin_int_to_ref(plugin), arg))
1245
if (plugin && func(session, plugin_int_to_ref(plugin), arg))
1293
1263
#define EXTRA_OPTIONS 3 /* options for: 'foo', 'plugin-foo' and NULL */
1295
1265
typedef DECLARE_DRIZZLE_SYSVAR_BASIC(sysvar_bool_t, bool);
1296
typedef DECLARE_DRIZZLE_THDVAR_BASIC(thdvar_bool_t, bool);
1266
typedef DECLARE_DRIZZLE_SessionVAR_BASIC(sessionvar_bool_t, bool);
1297
1267
typedef DECLARE_DRIZZLE_SYSVAR_BASIC(sysvar_str_t, char *);
1298
typedef DECLARE_DRIZZLE_THDVAR_BASIC(thdvar_str_t, char *);
1268
typedef DECLARE_DRIZZLE_SessionVAR_BASIC(sessionvar_str_t, char *);
1300
1270
typedef DECLARE_DRIZZLE_SYSVAR_TYPELIB(sysvar_enum_t, unsigned long);
1301
typedef DECLARE_DRIZZLE_THDVAR_TYPELIB(thdvar_enum_t, unsigned long);
1271
typedef DECLARE_DRIZZLE_SessionVAR_TYPELIB(sessionvar_enum_t, unsigned long);
1302
1272
typedef DECLARE_DRIZZLE_SYSVAR_TYPELIB(sysvar_set_t, uint64_t);
1303
typedef DECLARE_DRIZZLE_THDVAR_TYPELIB(thdvar_set_t, uint64_t);
1273
typedef DECLARE_DRIZZLE_SessionVAR_TYPELIB(sessionvar_set_t, uint64_t);
1305
1275
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_int_t, int);
1306
1276
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_long_t, long);
1309
1279
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_ulong_t, ulong);
1310
1280
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);
1282
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_int_t, int);
1283
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_long_t, long);
1284
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_int64_t_t, int64_t);
1285
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_uint_t, uint);
1286
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_ulong_t, ulong);
1287
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_uint64_t_t, uint64_t);
1319
typedef bool *(*mysql_sys_var_ptr_p)(THD* a_thd, int offset);
1289
typedef bool *(*mysql_sys_var_ptr_p)(Session* a_session, int offset);
1322
1292
/****************************************************************************
1323
1293
default variable data check and update functions
1324
1294
****************************************************************************/
1326
static int check_func_bool(THD *thd __attribute__((unused)),
1327
struct st_mysql_sys_var *var,
1296
static int check_func_bool(Session *, struct st_mysql_sys_var *var,
1328
1297
void *save, st_mysql_value *value)
1330
1299
char buff[STRING_BUFFER_USUAL_SIZE];
1373
1342
plugin_opt_set_limits(&options, var);
1375
1344
if (var->flags & PLUGIN_VAR_UNSIGNED)
1376
*(uint32_t *)save= (uint) getopt_ull_limit_value((uint64_t) tmp, &options,
1345
*(uint32_t *)save= (uint32_t) getopt_ull_limit_value((uint64_t) tmp, &options,
1379
1348
*(int *)save= (int) getopt_ll_limit_value(tmp, &options, &fixed);
1381
return throw_bounds_warning(thd, fixed, var->flags & PLUGIN_VAR_UNSIGNED,
1350
return throw_bounds_warning(session, fixed, var->flags & PLUGIN_VAR_UNSIGNED,
1382
1351
var->name, (int64_t) tmp);
1386
static int check_func_long(THD *thd, struct st_mysql_sys_var *var,
1355
static int check_func_long(Session *session, struct st_mysql_sys_var *var,
1387
1356
void *save, st_mysql_value *value)
1539
static void update_func_bool(THD *thd __attribute__((unused)),
1540
struct st_mysql_sys_var *var __attribute__((unused)),
1507
static void update_func_bool(Session *, struct st_mysql_sys_var *,
1541
1508
void *tgt, const void *save)
1543
1510
*(bool *) tgt= *(int *) save ? 1 : 0;
1547
static void update_func_int(THD *thd __attribute__((unused)),
1548
struct st_mysql_sys_var *var __attribute__((unused)),
1514
static void update_func_int(Session *, struct st_mysql_sys_var *,
1549
1515
void *tgt, const void *save)
1551
1517
*(int *)tgt= *(int *) save;
1555
static void update_func_long(THD *thd __attribute__((unused)),
1556
struct st_mysql_sys_var *var __attribute__((unused)),
1521
static void update_func_long(Session *, struct st_mysql_sys_var *,
1557
1522
void *tgt, const void *save)
1559
1524
*(long *)tgt= *(long *) save;
1563
static void update_func_int64_t(THD *thd __attribute__((unused)),
1564
struct st_mysql_sys_var *var __attribute__((unused)),
1528
static void update_func_int64_t(Session *, struct st_mysql_sys_var *,
1565
1529
void *tgt, const void *save)
1567
1531
*(int64_t *)tgt= *(uint64_t *) save;
1571
static void update_func_str(THD *thd __attribute__((unused)), struct st_mysql_sys_var *var,
1535
static void update_func_str(Session *, struct st_mysql_sys_var *var,
1572
1536
void *tgt, const void *save)
1574
1538
char *old= *(char **) tgt;
1575
1539
*(char **)tgt= *(char **) save;
1576
1540
if (var->flags & PLUGIN_VAR_MEMALLOC)
1578
*(char **)tgt= my_strdup(*(char **) save, MYF(0));
1542
*(char **)tgt= strdup(*(char **) save);
1545
* There isn't a _really_ good thing to do here until this whole set_var
1546
* mess gets redesigned
1549
errmsg_printf(ERRMSG_LVL_ERROR, _("Out of memory."));
1586
1557
****************************************************************************/
1589
sys_var *find_sys_var(THD *thd, const char *str, uint32_t length)
1560
sys_var *find_sys_var(Session *session, const char *str, uint32_t length)
1592
1563
sys_var_pluginvar *pi= NULL;
1593
1564
plugin_ref plugin;
1595
rw_rdlock(&LOCK_system_variables_hash);
1566
pthread_rwlock_rdlock(&LOCK_system_variables_hash);
1596
1567
if ((var= intern_find_sys_var(str, length, false)) &&
1597
1568
(pi= var->cast_pluginvar()))
1599
rw_unlock(&LOCK_system_variables_hash);
1600
LEX *lex= thd ? thd->lex : 0;
1570
pthread_rwlock_unlock(&LOCK_system_variables_hash);
1571
LEX *lex= session ? session->lex : 0;
1601
1572
if (!(plugin= my_intern_plugin_lock(lex, plugin_int_to_ref(pi->plugin))))
1602
1573
var= NULL; /* failed to lock it, it must be uninstalling */
1673
1644
st_bookmark *result;
1674
1645
char *varname, *p;
1676
if (!(flags & PLUGIN_VAR_THDLOCAL))
1647
if (!(flags & PLUGIN_VAR_SessionLOCAL))
1679
1650
switch (flags & PLUGIN_VAR_TYPEMASK) {
1680
1651
case PLUGIN_VAR_BOOL:
1652
size= ALIGN_SIZE(sizeof(bool));
1683
1654
case PLUGIN_VAR_INT:
1655
size= ALIGN_SIZE(sizeof(int));
1686
1657
case PLUGIN_VAR_LONG:
1687
1658
case PLUGIN_VAR_ENUM:
1659
size= ALIGN_SIZE(sizeof(long));
1690
1661
case PLUGIN_VAR_LONGLONG:
1691
1662
case PLUGIN_VAR_SET:
1692
size= sizeof(uint64_t);
1663
size= ALIGN_SIZE(sizeof(uint64_t));
1694
1665
case PLUGIN_VAR_STR:
1695
size= sizeof(char*);
1666
size= ALIGN_SIZE(sizeof(char*));
1702
varname= ((char*) my_alloca(length));
1703
strxmov(varname + 1, plugin, "_", name, NULL);
1673
varname= ((char*) malloc(length));
1674
sprintf(varname+1, "%s_%s", plugin, name);
1704
1675
for (p= varname + 1; *p; p++)
1725
1696
if (new_size > global_variables_dynamic_size)
1727
global_system_variables.dynamic_variables_ptr= (char*)
1728
my_realloc(global_system_variables.dynamic_variables_ptr, new_size,
1729
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
1730
max_system_variables.dynamic_variables_ptr= (char*)
1731
my_realloc(max_system_variables.dynamic_variables_ptr, new_size,
1732
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
1700
(char *)realloc(global_system_variables.dynamic_variables_ptr,
1703
global_system_variables.dynamic_variables_ptr= tmpptr;
1706
(char *)realloc(max_system_variables.dynamic_variables_ptr,
1709
max_system_variables.dynamic_variables_ptr= tmpptr;
1734
1712
Clear the new variable value space. This is required for string
1735
1713
variables. If their value is non-NULL, it must point to a valid
1769
returns a pointer to the memory which holds the thd-local variable or
1770
a pointer to the global variable if thd==null.
1747
returns a pointer to the memory which holds the session-local variable or
1748
a pointer to the global variable if session==null.
1771
1749
If required, will sync with global variables if the requested variable
1772
1750
has not yet been allocated in the current thread.
1774
static unsigned char *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
1752
static unsigned char *intern_sys_var_ptr(Session* session, int offset, bool global_lock)
1776
1754
assert(offset >= 0);
1777
assert((uint)offset <= global_system_variables.dynamic_variables_head);
1755
assert((uint32_t)offset <= global_system_variables.dynamic_variables_head);
1780
1758
return (unsigned char*) global_system_variables.dynamic_variables_ptr + offset;
1783
1761
dynamic_variables_head points to the largest valid offset
1785
if (!thd->variables.dynamic_variables_ptr ||
1786
(uint)offset > thd->variables.dynamic_variables_head)
1763
if (!session->variables.dynamic_variables_ptr ||
1764
(uint32_t)offset > session->variables.dynamic_variables_head)
1790
rw_rdlock(&LOCK_system_variables_hash);
1768
pthread_rwlock_rdlock(&LOCK_system_variables_hash);
1792
thd->variables.dynamic_variables_ptr= (char*)
1793
my_realloc(thd->variables.dynamic_variables_ptr,
1794
global_variables_dynamic_size,
1795
MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
1771
if (!(tmpptr= (char *)realloc(session->variables.dynamic_variables_ptr,
1772
global_variables_dynamic_size)))
1774
session->variables.dynamic_variables_ptr= tmpptr;
1797
1776
if (global_lock)
1798
1777
pthread_mutex_lock(&LOCK_global_system_variables);
1800
1779
safe_mutex_assert_owner(&LOCK_global_system_variables);
1802
memcpy(thd->variables.dynamic_variables_ptr +
1803
thd->variables.dynamic_variables_size,
1781
memcpy(session->variables.dynamic_variables_ptr +
1782
session->variables.dynamic_variables_size,
1804
1783
global_system_variables.dynamic_variables_ptr +
1805
thd->variables.dynamic_variables_size,
1784
session->variables.dynamic_variables_size,
1806
1785
global_system_variables.dynamic_variables_size -
1807
thd->variables.dynamic_variables_size);
1786
session->variables.dynamic_variables_size);
1810
1789
now we need to iterate through any newly copied 'defaults'
1827
1806
if ((pi->plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR &&
1828
1807
pi->plugin_var->flags & PLUGIN_VAR_MEMALLOC)
1830
char **pp= (char**) (thd->variables.dynamic_variables_ptr +
1809
char **pp= (char**) (session->variables.dynamic_variables_ptr +
1831
1810
*(int*)(pi->plugin_var + 1));
1832
1811
if ((*pp= *(char**) (global_system_variables.dynamic_variables_ptr +
1833
1812
*(int*)(pi->plugin_var + 1))))
1834
*pp= my_strdup(*pp, MYF(MY_WME|MY_FAE));
1838
1819
if (global_lock)
1839
1820
pthread_mutex_unlock(&LOCK_global_system_variables);
1841
thd->variables.dynamic_variables_version=
1822
session->variables.dynamic_variables_version=
1842
1823
global_system_variables.dynamic_variables_version;
1843
thd->variables.dynamic_variables_head=
1824
session->variables.dynamic_variables_head=
1844
1825
global_system_variables.dynamic_variables_head;
1845
thd->variables.dynamic_variables_size=
1826
session->variables.dynamic_variables_size=
1846
1827
global_system_variables.dynamic_variables_size;
1848
rw_unlock(&LOCK_system_variables_hash);
1829
pthread_rwlock_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;
1831
return (unsigned char*)session->variables.dynamic_variables_ptr + offset;
1834
static bool *mysql_sys_var_ptr_bool(Session* a_session, int offset)
1836
return (bool *)intern_sys_var_ptr(a_session, offset, true);
1839
static int *mysql_sys_var_ptr_int(Session* a_session, int offset)
1841
return (int *)intern_sys_var_ptr(a_session, offset, true);
1844
static long *mysql_sys_var_ptr_long(Session* a_session, int offset)
1846
return (long *)intern_sys_var_ptr(a_session, offset, true);
1849
static int64_t *mysql_sys_var_ptr_int64_t(Session* a_session, int offset)
1851
return (int64_t *)intern_sys_var_ptr(a_session, offset, true);
1854
static char **mysql_sys_var_ptr_str(Session* a_session, int offset)
1856
return (char **)intern_sys_var_ptr(a_session, offset, true);
1859
static uint64_t *mysql_sys_var_ptr_set(Session* a_session, int offset)
1861
return (uint64_t *)intern_sys_var_ptr(a_session, offset, true);
1864
static unsigned long *mysql_sys_var_ptr_enum(Session* a_session, int offset)
1866
return (unsigned long *)intern_sys_var_ptr(a_session, offset, true);
1870
void plugin_sessionvar_init(Session *session)
1872
plugin_ref old_table_plugin= session->variables.table_plugin;
1874
session->variables.table_plugin= NULL;
1875
cleanup_variables(session, &session->variables);
1877
session->variables= global_system_variables;
1878
session->variables.table_plugin= NULL;
1899
1880
/* 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;
1881
session->variables.dynamic_variables_version= 0;
1882
session->variables.dynamic_variables_size= 0;
1883
session->variables.dynamic_variables_ptr= 0;
1904
thd->variables.table_plugin=
1885
session->variables.table_plugin=
1905
1886
my_intern_plugin_lock(NULL, global_system_variables.table_plugin);
1906
1887
intern_plugin_unlock(NULL, old_table_plugin);
2151
2116
pthread_mutex_lock(&LOCK_global_system_variables);
2152
tgt= real_value_ptr(thd, type);
2117
tgt= real_value_ptr(session, type);
2153
2118
src= ((void **) (plugin_var + 1) + 1);
2155
if (plugin_var->flags & PLUGIN_VAR_THDLOCAL)
2120
if (plugin_var->flags & PLUGIN_VAR_SessionLOCAL)
2157
2122
if (type != OPT_GLOBAL)
2158
src= real_value_ptr(thd, OPT_GLOBAL);
2123
src= real_value_ptr(session, OPT_GLOBAL);
2160
2125
switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) {
2161
2126
case PLUGIN_VAR_INT:
2162
src= &((thdvar_uint_t*) plugin_var)->def_val;
2127
src= &((sessionvar_uint_t*) plugin_var)->def_val;
2164
2129
case PLUGIN_VAR_LONG:
2165
src= &((thdvar_ulong_t*) plugin_var)->def_val;
2130
src= &((sessionvar_ulong_t*) plugin_var)->def_val;
2167
2132
case PLUGIN_VAR_LONGLONG:
2168
src= &((thdvar_uint64_t_t*) plugin_var)->def_val;
2133
src= &((sessionvar_uint64_t_t*) plugin_var)->def_val;
2170
2135
case PLUGIN_VAR_ENUM:
2171
src= &((thdvar_enum_t*) plugin_var)->def_val;
2136
src= &((sessionvar_enum_t*) plugin_var)->def_val;
2173
2138
case PLUGIN_VAR_SET:
2174
src= &((thdvar_set_t*) plugin_var)->def_val;
2139
src= &((sessionvar_set_t*) plugin_var)->def_val;
2176
2141
case PLUGIN_VAR_BOOL:
2177
src= &((thdvar_bool_t*) plugin_var)->def_val;
2142
src= &((sessionvar_bool_t*) plugin_var)->def_val;
2179
2144
case PLUGIN_VAR_STR:
2180
src= &((thdvar_str_t*) plugin_var)->def_val;
2145
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);
2152
/* session must equal current_session if PLUGIN_VAR_SessionLOCAL flag is set */
2153
assert(!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) ||
2154
session == current_session);
2191
if (!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) || type == OPT_GLOBAL)
2156
if (!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) || type == OPT_GLOBAL)
2193
plugin_var->update(thd, plugin_var, tgt, src);
2158
plugin_var->update(session, plugin_var, tgt, src);
2194
2159
pthread_mutex_unlock(&LOCK_global_system_variables);
2198
2163
pthread_mutex_unlock(&LOCK_global_system_variables);
2199
plugin_var->update(thd, plugin_var, tgt, src);
2164
plugin_var->update(session, plugin_var, tgt, src);
2204
bool sys_var_pluginvar::update(THD *thd, set_var *var)
2169
bool sys_var_pluginvar::update(Session *session, set_var *var)
2208
2173
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);
2175
/* session must equal current_session if PLUGIN_VAR_SessionLOCAL flag is set */
2176
assert(!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) ||
2177
session == current_session);
2214
2179
if (is_readonly())
2217
2182
pthread_mutex_lock(&LOCK_global_system_variables);
2218
tgt= real_value_ptr(thd, var->type);
2183
tgt= real_value_ptr(session, var->type);
2220
if (!(plugin_var->flags & PLUGIN_VAR_THDLOCAL) || var->type == OPT_GLOBAL)
2185
if (!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) || var->type == OPT_GLOBAL)
2222
2187
/* variable we are updating has global scope, so we unlock after updating */
2223
plugin_var->update(thd, plugin_var, tgt, &var->save_result);
2188
plugin_var->update(session, plugin_var, tgt, &var->save_result);
2224
2189
pthread_mutex_unlock(&LOCK_global_system_variables);
2228
2193
pthread_mutex_unlock(&LOCK_global_system_variables);
2229
plugin_var->update(thd, plugin_var, tgt, &var->save_result);
2194
plugin_var->update(session, plugin_var, tgt, &var->save_result);
2290
2255
options->def_value= (intptr_t) ((sysvar_str_t*) opt)->def_val;
2292
2257
/* 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:
2258
case PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL:
2259
OPTION_SET_LIMITS(GET_INT, options, (sessionvar_int_t*) opt);
2261
case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL:
2262
OPTION_SET_LIMITS(GET_UINT, options, (sessionvar_uint_t*) opt);
2264
case PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL:
2265
OPTION_SET_LIMITS(GET_LONG, options, (sessionvar_long_t*) opt);
2267
case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL:
2268
OPTION_SET_LIMITS(GET_ULONG_IS_FAIL, options, (sessionvar_ulong_t*) opt);
2270
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL:
2271
OPTION_SET_LIMITS(GET_LL, options, (sessionvar_int64_t_t*) opt);
2273
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL:
2274
OPTION_SET_LIMITS(GET_ULL, options, (sessionvar_uint64_t_t*) opt);
2276
case PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL:
2312
2277
options->var_type= GET_ENUM;
2313
options->typelib= ((thdvar_enum_t*) opt)->typelib;
2314
options->def_value= ((thdvar_enum_t*) opt)->def_val;
2278
options->typelib= ((sessionvar_enum_t*) opt)->typelib;
2279
options->def_value= ((sessionvar_enum_t*) opt)->def_val;
2315
2280
options->min_value= options->block_size= 0;
2316
2281
options->max_value= options->typelib->count - 1;
2318
case PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL:
2283
case PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL:
2319
2284
options->var_type= GET_SET;
2320
options->typelib= ((thdvar_set_t*) opt)->typelib;
2321
options->def_value= ((thdvar_set_t*) opt)->def_val;
2285
options->typelib= ((sessionvar_set_t*) opt)->typelib;
2286
options->def_value= ((sessionvar_set_t*) opt)->def_val;
2322
2287
options->min_value= options->block_size= 0;
2323
2288
options->max_value= (1UL << options->typelib->count) - 1;
2325
case PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL:
2290
case PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL:
2326
2291
options->var_type= GET_BOOL;
2327
options->def_value= ((thdvar_bool_t*) opt)->def_val;
2292
options->def_value= ((sessionvar_bool_t*) opt)->def_val;
2329
case PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL:
2294
case PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL:
2330
2295
options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ?
2331
2296
GET_STR_ALLOC : GET_STR);
2332
options->def_value= (intptr_t) ((thdvar_str_t*) opt)->def_val;
2297
options->def_value= (intptr_t) ((sessionvar_str_t*) opt)->def_val;
2404
2368
plugin_option && *plugin_option; plugin_option++, index++)
2406
2370
opt= *plugin_option;
2407
if (!(opt->flags & PLUGIN_VAR_THDLOCAL))
2371
if (!(opt->flags & PLUGIN_VAR_SessionLOCAL))
2409
2373
if (!(register_var(name, opt->name, opt->flags)))
2411
2375
switch (opt->flags & PLUGIN_VAR_TYPEMASK) {
2412
2376
case PLUGIN_VAR_BOOL:
2413
(((thdvar_bool_t *)opt)->resolve)= mysql_sys_var_ptr_bool;
2377
(((sessionvar_bool_t *)opt)->resolve)= mysql_sys_var_ptr_bool;
2415
2379
case PLUGIN_VAR_INT:
2416
(((thdvar_int_t *)opt)->resolve)= mysql_sys_var_ptr_int;
2380
(((sessionvar_int_t *)opt)->resolve)= mysql_sys_var_ptr_int;
2418
2382
case PLUGIN_VAR_LONG:
2419
(((thdvar_long_t *)opt)->resolve)= mysql_sys_var_ptr_long;
2383
(((sessionvar_long_t *)opt)->resolve)= mysql_sys_var_ptr_long;
2421
2385
case PLUGIN_VAR_LONGLONG:
2422
(((thdvar_int64_t_t *)opt)->resolve)= mysql_sys_var_ptr_int64_t;
2386
(((sessionvar_int64_t_t *)opt)->resolve)= mysql_sys_var_ptr_int64_t;
2424
2388
case PLUGIN_VAR_STR:
2425
(((thdvar_str_t *)opt)->resolve)= mysql_sys_var_ptr_str;
2389
(((sessionvar_str_t *)opt)->resolve)= mysql_sys_var_ptr_str;
2427
2391
case PLUGIN_VAR_ENUM:
2428
(((thdvar_enum_t *)opt)->resolve)= mysql_sys_var_ptr_enum;
2392
(((sessionvar_enum_t *)opt)->resolve)= mysql_sys_var_ptr_enum;
2430
2394
case PLUGIN_VAR_SET:
2431
(((thdvar_set_t *)opt)->resolve)= mysql_sys_var_ptr_set;
2395
(((sessionvar_set_t *)opt)->resolve)= mysql_sys_var_ptr_set;
2434
sql_print_error(_("Unknown variable type code 0x%x in plugin '%s'."),
2398
errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown variable type code 0x%x in plugin '%s'."),
2435
2399
opt->flags, plugin_name);
2494
2458
opt->update= update_func_int64_t;
2497
sql_print_error(_("Unknown variable type code 0x%x in plugin '%s'."),
2461
errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown variable type code 0x%x in plugin '%s'."),
2498
2462
opt->flags, plugin_name);
2502
if ((opt->flags & (PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_THDLOCAL))
2466
if ((opt->flags & (PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_SessionLOCAL))
2503
2467
== PLUGIN_VAR_NOCMDOPT)
2506
2470
if (!opt->name)
2508
sql_print_error(_("Missing variable name in plugin '%s'."),
2472
errmsg_printf(ERRMSG_LVL_ERROR, _("Missing variable name in plugin '%s'."),
2513
if (!(opt->flags & PLUGIN_VAR_THDLOCAL))
2477
if (!(opt->flags & PLUGIN_VAR_SessionLOCAL))
2515
2479
optnamelen= strlen(opt->name);
2516
2480
optname= (char*) alloc_root(mem_root, namelen + optnamelen + 2);
2517
strxmov(optname, name, "-", opt->name, NULL);
2481
sprintf(optname, "%s-%s", name, opt->name);
2518
2482
optnamelen= namelen + optnamelen + 1;