33
31
When you ad a new plugin type, add both a string and make sure that the
34
32
init and deinit array are correctly updated.
36
const LEX_STRING plugin_type_names[DRIZZLE_MAX_PLUGIN_TYPE_NUM]=
34
const LEX_STRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]=
36
{ C_STRING_WITH_LEN("UDF") },
37
{ C_STRING_WITH_LEN("UDA") },
38
{ C_STRING_WITH_LEN("STORAGE ENGINE") },
38
39
{ C_STRING_WITH_LEN("DAEMON") },
39
{ C_STRING_WITH_LEN("STORAGE ENGINE") },
40
40
{ C_STRING_WITH_LEN("INFORMATION SCHEMA") },
41
{ C_STRING_WITH_LEN("UDF") },
42
{ C_STRING_WITH_LEN("UDA") },
43
41
{ C_STRING_WITH_LEN("AUDIT") },
44
{ C_STRING_WITH_LEN("LOGGER") },
42
{ C_STRING_WITH_LEN("LOG") },
45
43
{ C_STRING_WITH_LEN("AUTH") }
56
54
plugin_type_deinitialize should equal to the number of plugins
59
plugin_type_init plugin_type_initialize[DRIZZLE_MAX_PLUGIN_TYPE_NUM]=
57
plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
59
initialize_udf, /* UDF */
62
61
ha_initialize_handlerton, /* Storage Engine */
63
63
initialize_schema_table, /* Information Schema */
64
initialize_udf, /* UDF */
67
logging_initializer, /* Logger */
68
authentication_initializer /* Auth */
71
plugin_type_init plugin_type_deinitialize[DRIZZLE_MAX_PLUGIN_TYPE_NUM]=
69
plugin_type_init plugin_type_deinitialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
71
finalize_udf, /* UDF */
74
73
ha_finalize_handlerton, /* Storage Engine */
75
75
finalize_schema_table, /* Information Schema */
76
finalize_udf, /* UDF */
79
logging_finalizer, /* Logger */
80
authentication_finalizer /* Auth */
81
static const char *plugin_interface_version_sym=
82
"_mysql_plugin_interface_version_";
83
static const char *sizeof_st_plugin_sym=
84
"_mysql_sizeof_struct_st_plugin_";
83
85
static const char *plugin_declarations_sym= "_mysql_plugin_declarations_";
86
static int min_plugin_interface_version= MYSQL_PLUGIN_INTERFACE_VERSION & ~0xFF;
85
88
/* Note that 'int version' must be the first field of every plugin
86
89
sub-structure (plugin->info).
91
static int min_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
93
MYSQL_UDF_INTERFACE_VERSION,
94
MYSQL_UDA_INTERFACE_VERSION,
95
MYSQL_HANDLERTON_INTERFACE_VERSION,
96
MYSQL_DAEMON_INTERFACE_VERSION,
97
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION,
98
MYSQL_AUDIT_INTERFACE_VERSION,
99
MYSQL_LOG_INTERFACE_VERSION,
100
MYSQL_AUTH_INTERFACE_VERSION
102
static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
104
MYSQL_UDF_INTERFACE_VERSION,
105
MYSQL_UDA_INTERFACE_VERSION,
106
MYSQL_HANDLERTON_INTERFACE_VERSION,
107
MYSQL_DAEMON_INTERFACE_VERSION,
108
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION,
109
MYSQL_AUDIT_INTERFACE_VERSION,
110
MYSQL_LOG_INTERFACE_VERSION,
111
MYSQL_AUTH_INTERFACE_VERSION
89
114
static bool initialized= 0;
91
116
static DYNAMIC_ARRAY plugin_dl_array;
92
117
static DYNAMIC_ARRAY plugin_array;
93
static HASH plugin_hash[DRIZZLE_MAX_PLUGIN_TYPE_NUM];
118
static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM];
94
119
static bool reap_needed= false;
95
120
static int plugin_array_version=0;
154
179
static void *operator new(size_t size, MEM_ROOT *mem_root)
155
180
{ return (void*) alloc_root(mem_root, (uint) size); }
156
static void operator delete(void *ptr_arg __attribute__((unused)),
157
size_t size __attribute__((unused)))
181
static void operator delete(void *ptr_arg __attribute__((__unused__)),
182
size_t size __attribute__((__unused__)))
158
183
{ TRASH(ptr_arg, size); }
160
185
sys_var_pluginvar(const char *name_arg,
166
191
{ return !(plugin_var->flags & PLUGIN_VAR_THDLOCAL) && type != OPT_GLOBAL; }
167
192
bool check_update_type(Item_result type);
168
193
SHOW_TYPE show_type();
169
unsigned char* real_value_ptr(THD *thd, enum_var_type type);
194
uchar* real_value_ptr(THD *thd, enum_var_type type);
170
195
TYPELIB* plugin_var_typelib(void);
171
unsigned char* value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
196
uchar* value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
172
197
bool check(THD *thd, set_var *var);
173
bool check_default(enum_var_type type __attribute__((unused)))
198
bool check_default(enum_var_type type __attribute__((__unused__)))
174
199
{ return is_readonly(); }
175
200
void set_default(THD *thd,
176
enum_var_type type __attribute__((unused)));
201
enum_var_type type __attribute__((__unused__)));
177
202
bool update(THD *thd, set_var *var);
264
289
static struct st_plugin_dl *plugin_dl_find(const LEX_STRING *dl)
267
292
struct st_plugin_dl *tmp;
268
293
for (i= 0; i < plugin_dl_array.elements; i++)
270
295
tmp= *dynamic_element(&plugin_dl_array, i, struct st_plugin_dl **);
271
296
if (tmp->ref_count &&
272
297
! my_strnncoll(files_charset_info,
273
(const unsigned char *)dl->str, dl->length,
274
(const unsigned char *)tmp->dl.str, tmp->dl.length))
298
(const uchar *)dl->str, dl->length,
299
(const uchar *)tmp->dl.str, tmp->dl.length))
305
330
dlclose(p->handle);
331
my_free(p->dl.str, MYF(MY_ALLOW_ZERO_PTR));
332
if (p->version != MYSQL_PLUGIN_INTERFACE_VERSION)
333
my_free((uchar*)p->plugins, MYF(MY_ALLOW_ZERO_PTR));
310
337
static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
312
340
char dlpath[FN_REFLEN];
313
uint32_t plugin_dir_len, dummy_errors, dlpathlen;
341
uint plugin_dir_len, dummy_errors, dlpathlen;
314
342
struct st_plugin_dl *tmp, plugin_dl;
316
344
plugin_dir_len= strlen(opt_plugin_dir);
319
347
This is done to ensure that only approved libraries from the
320
348
plugin directory are used (to make this even remotely secure).
322
if (strchr(dl->str, FN_LIBCHAR) ||
350
if (my_strchr(files_charset_info, dl->str, dl->str + dl->length, FN_LIBCHAR) ||
323
351
check_string_char_length((LEX_STRING *) dl, "", NAME_CHAR_LEN,
324
352
system_charset_info, 1) ||
325
353
plugin_dir_len + dl->length + 1 >= FN_REFLEN)
336
364
tmp->ref_count++;
339
memset(&plugin_dl, 0, sizeof(plugin_dl));
367
bzero(&plugin_dl, sizeof(plugin_dl));
340
368
/* Compile dll path */
342
strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", dl->str, NULL) -
370
strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", dl->str, NullS) -
344
372
plugin_dl.ref_count= 1;
345
373
/* Open new dll handle */
346
if (!(plugin_dl.handle= dlopen(dlpath, RTLD_LAZY|RTLD_GLOBAL)))
374
if (!(plugin_dl.handle= dlopen(dlpath, RTLD_NOW)))
348
376
const char *errmsg=dlerror();
349
377
if (!strncmp(dlpath, errmsg, dlpathlen))
358
386
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath, errno, errmsg);
389
/* Determine interface version */
390
if (!(sym= dlsym(plugin_dl.handle, plugin_interface_version_sym)))
392
free_plugin_mem(&plugin_dl);
393
if (report & REPORT_TO_USER)
394
my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), plugin_interface_version_sym);
395
if (report & REPORT_TO_LOG)
396
sql_print_error(ER(ER_CANT_FIND_DL_ENTRY), plugin_interface_version_sym);
399
plugin_dl.version= *(int *)sym;
401
if (plugin_dl.version < min_plugin_interface_version ||
402
(plugin_dl.version >> 8) > (MYSQL_PLUGIN_INTERFACE_VERSION >> 8))
404
free_plugin_mem(&plugin_dl);
405
if (report & REPORT_TO_USER)
406
my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dlpath, 0,
407
"plugin interface version mismatch");
408
if (report & REPORT_TO_LOG)
409
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath, 0,
410
"plugin interface version mismatch");
362
413
/* Find plugin declarations */
363
414
if (!(sym= dlsym(plugin_dl.handle, plugin_declarations_sym)))
424
if (plugin_dl.version != MYSQL_PLUGIN_INTERFACE_VERSION)
427
uint sizeof_st_plugin;
428
struct st_mysql_plugin *old, *cur;
429
char *ptr= (char *)sym;
431
if ((sym= dlsym(plugin_dl.handle, sizeof_st_plugin_sym)))
432
sizeof_st_plugin= *(int *)sym;
435
#ifdef ERROR_ON_NO_SIZEOF_PLUGIN_SYMBOL
436
free_plugin_mem(&plugin_dl);
437
if (report & REPORT_TO_USER)
438
my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), sizeof_st_plugin_sym);
439
if (report & REPORT_TO_LOG)
440
sql_print_error(ER(ER_CANT_FIND_DL_ENTRY), sizeof_st_plugin_sym);
444
When the following assert starts failing, we'll have to switch
445
to the upper branch of the #ifdef
447
assert(min_plugin_interface_version == 0);
448
sizeof_st_plugin= (int)offsetof(struct st_mysql_plugin, version);
453
((struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
457
cur= (struct st_mysql_plugin*)
458
my_malloc(i*sizeof(struct st_mysql_plugin), MYF(MY_ZEROFILL|MY_WME));
461
free_plugin_mem(&plugin_dl);
462
if (report & REPORT_TO_USER)
463
my_error(ER_OUTOFMEMORY, MYF(0), plugin_dl.dl.length);
464
if (report & REPORT_TO_LOG)
465
sql_print_error(ER(ER_OUTOFMEMORY), plugin_dl.dl.length);
469
All st_plugin fields not initialized in the plugin explicitly, are
470
set to 0. It matches C standard behaviour for struct initializers that
471
have less values than the struct definition.
474
(old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
476
memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
373
480
plugin_dl.plugins= (struct st_mysql_plugin *)sym;
375
482
/* Duplicate and convert dll name */
411
526
struct st_plugin_dl **);
412
527
if (tmp->ref_count &&
413
528
! my_strnncoll(files_charset_info,
414
(const unsigned char *)dl->str, dl->length,
415
(const unsigned char *)tmp->dl.str, tmp->dl.length))
529
(const uchar *)dl->str, dl->length,
530
(const uchar *)tmp->dl.str, tmp->dl.length))
417
532
/* Do not remove this element, unless no other plugin uses this dll. */
418
533
if (! --tmp->ref_count)
420
535
free_plugin_mem(tmp);
421
memset(tmp, 0, sizeof(struct st_plugin_dl));
536
bzero(tmp, sizeof(struct st_plugin_dl));
430
546
static struct st_plugin_int *plugin_find_internal(const LEX_STRING *name, int type)
433
549
if (! initialized)
436
if (type == DRIZZLE_ANY_PLUGIN)
552
if (type == MYSQL_ANY_PLUGIN)
438
for (i= 0; i < DRIZZLE_MAX_PLUGIN_TYPE_NUM; i++)
554
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
440
556
struct st_plugin_int *plugin= (st_plugin_int *)
441
hash_search(&plugin_hash[i], (const unsigned char *)name->str, name->length);
557
hash_search(&plugin_hash[i], (const uchar *)name->str, name->length);
447
563
return((st_plugin_int *)
448
hash_search(&plugin_hash[type], (const unsigned char *)name->str, name->length));
564
hash_search(&plugin_hash[type], (const uchar *)name->str, name->length));
543
if (insert_dynamic(&plugin_array, (unsigned char*)&plugin))
659
if (insert_dynamic(&plugin_array, (uchar*)&plugin))
545
661
tmp= *dynamic_element(&plugin_array, plugin_array.elements - 1,
546
662
struct st_plugin_int **)=
547
(struct st_plugin_int *) memdup_root(&plugin_mem_root, (unsigned char*)plugin,
663
(struct st_plugin_int *) memdup_root(&plugin_mem_root, (uchar*)plugin,
548
664
sizeof(struct st_plugin_int));
571
687
/* Clear the whole struct to catch future extensions. */
572
memset(&tmp, 0, sizeof(tmp));
688
bzero((char*) &tmp, sizeof(tmp));
573
689
if (! (tmp.plugin_dl= plugin_dl_add(dl, report)))
575
691
/* Find plugin by name */
576
for (plugin= tmp.plugin_dl->plugins; plugin->name; plugin++)
692
for (plugin= tmp.plugin_dl->plugins; plugin->info; plugin++)
578
uint32_t name_len= strlen(plugin->name);
579
if (plugin->type >= 0 && plugin->type < DRIZZLE_MAX_PLUGIN_TYPE_NUM &&
694
uint name_len= strlen(plugin->name);
695
if (plugin->type >= 0 && plugin->type < MYSQL_MAX_PLUGIN_TYPE_NUM &&
580
696
! my_strnncoll(system_charset_info,
581
(const unsigned char *)name->str, name->length,
582
(const unsigned char *)plugin->name,
697
(const uchar *)name->str, name->length,
698
(const uchar *)plugin->name,
585
701
struct st_plugin_int *tmp_plugin_ptr;
702
if (*(int*)plugin->info <
703
min_plugin_info_interface_version[plugin->type] ||
704
((*(int*)plugin->info) >> 8) >
705
(cur_plugin_info_interface_version[plugin->type] >> 8))
708
strxnmov(buf, sizeof(buf) - 1, "API version for ",
709
plugin_type_names[plugin->type].str,
710
" plugin is too different", NullS);
711
if (report & REPORT_TO_USER)
712
my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dl->str, 0, buf);
713
if (report & REPORT_TO_LOG)
714
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dl->str, 0, buf);
587
717
tmp.plugin= plugin;
588
718
tmp.name.str= (char *)plugin->name;
589
719
tmp.name.length= name_len;
842
extern "C" unsigned char *get_plugin_hash_key(const unsigned char *, size_t *, bool);
843
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,
972
extern "C" uchar *get_plugin_hash_key(const uchar *, size_t *, bool);
973
extern "C" uchar *get_bookmark_hash_key(const uchar *, size_t *, bool);
976
uchar *get_plugin_hash_key(const uchar *buff, size_t *length,
847
977
bool not_used __attribute__((unused)))
849
979
struct st_plugin_int *plugin= (st_plugin_int *)buff;
850
980
*length= (uint)plugin->name.length;
851
return((unsigned char *)plugin->name.str);
981
return((uchar *)plugin->name.str);
855
unsigned char *get_bookmark_hash_key(const unsigned char *buff, size_t *length,
985
uchar *get_bookmark_hash_key(const uchar *buff, size_t *length,
856
986
bool not_used __attribute__((unused)))
858
988
struct st_bookmark *var= (st_bookmark *)buff;
859
989
*length= var->name_len + 1;
860
return (unsigned char*) var->key;
990
return (uchar*) var->key;
1003
1133
tmp->ref_count= 0;
1004
1134
tmp->plugin_dl= 0;
1006
if (insert_dynamic(&plugin_array, (unsigned char*)&tmp))
1136
if (insert_dynamic(&plugin_array, (uchar*)&tmp))
1009
1139
*ptr= *dynamic_element(&plugin_array, plugin_array.elements - 1,
1010
1140
struct st_plugin_int **)=
1011
(struct st_plugin_int *) memdup_root(&plugin_mem_root, (unsigned char*)tmp,
1141
(struct st_plugin_int *) memdup_root(&plugin_mem_root, (uchar*)tmp,
1012
1142
sizeof(struct st_plugin_int));
1014
if (my_hash_insert(&plugin_hash[plugin->type],(unsigned char*) *ptr))
1144
if (my_hash_insert(&plugin_hash[plugin->type],(uchar*) *ptr))
1286
1415
Internal type declarations for variables support
1287
1416
****************************************************************************/
1289
#undef DRIZZLE_SYSVAR_NAME
1290
#define DRIZZLE_SYSVAR_NAME(name) name
1418
#undef MYSQL_SYSVAR_NAME
1419
#define MYSQL_SYSVAR_NAME(name) name
1291
1420
#define PLUGIN_VAR_TYPEMASK 0x007f
1293
1422
#define EXTRA_OPTIONS 3 /* options for: 'foo', 'plugin-foo' and NULL */
1295
typedef DECLARE_DRIZZLE_SYSVAR_BASIC(sysvar_bool_t, bool);
1296
typedef DECLARE_DRIZZLE_THDVAR_BASIC(thdvar_bool_t, bool);
1297
typedef DECLARE_DRIZZLE_SYSVAR_BASIC(sysvar_str_t, char *);
1298
typedef DECLARE_DRIZZLE_THDVAR_BASIC(thdvar_str_t, char *);
1300
typedef DECLARE_DRIZZLE_SYSVAR_TYPELIB(sysvar_enum_t, unsigned long);
1301
typedef DECLARE_DRIZZLE_THDVAR_TYPELIB(thdvar_enum_t, unsigned long);
1302
typedef DECLARE_DRIZZLE_SYSVAR_TYPELIB(sysvar_set_t, uint64_t);
1303
typedef DECLARE_DRIZZLE_THDVAR_TYPELIB(thdvar_set_t, uint64_t);
1305
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_int_t, int);
1306
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_long_t, long);
1307
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_int64_t_t, int64_t);
1308
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_uint_t, uint);
1309
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_ulong_t, ulong);
1310
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);
1424
typedef DECLARE_MYSQL_SYSVAR_BASIC(sysvar_bool_t, bool);
1425
typedef DECLARE_MYSQL_THDVAR_BASIC(thdvar_bool_t, bool);
1426
typedef DECLARE_MYSQL_SYSVAR_BASIC(sysvar_str_t, char *);
1427
typedef DECLARE_MYSQL_THDVAR_BASIC(thdvar_str_t, char *);
1429
typedef DECLARE_MYSQL_SYSVAR_TYPELIB(sysvar_enum_t, unsigned long);
1430
typedef DECLARE_MYSQL_THDVAR_TYPELIB(thdvar_enum_t, unsigned long);
1431
typedef DECLARE_MYSQL_SYSVAR_TYPELIB(sysvar_set_t, uint64_t);
1432
typedef DECLARE_MYSQL_THDVAR_TYPELIB(thdvar_set_t, uint64_t);
1434
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_int_t, int);
1435
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_long_t, long);
1436
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_int64_t_t, int64_t);
1437
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_uint_t, uint);
1438
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_ulong_t, ulong);
1439
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_uint64_t_t, uint64_t);
1441
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_int_t, int);
1442
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_long_t, long);
1443
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_int64_t_t, int64_t);
1444
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_uint_t, uint);
1445
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_ulong_t, ulong);
1446
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_uint64_t_t, uint64_t);
1319
1448
typedef bool *(*mysql_sys_var_ptr_p)(THD* a_thd, int offset);
1539
static void update_func_bool(THD *thd __attribute__((unused)),
1540
struct st_mysql_sys_var *var __attribute__((unused)),
1668
static void update_func_bool(THD *thd __attribute__((__unused__)),
1669
struct st_mysql_sys_var *var __attribute__((__unused__)),
1541
1670
void *tgt, const void *save)
1543
*(bool *) tgt= *(int *) save ? 1 : 0;
1672
*(my_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)),
1676
static void update_func_int(THD *thd __attribute__((__unused__)),
1677
struct st_mysql_sys_var *var __attribute__((__unused__)),
1549
1678
void *tgt, const void *save)
1551
1680
*(int *)tgt= *(int *) save;
1555
static void update_func_long(THD *thd __attribute__((unused)),
1556
struct st_mysql_sys_var *var __attribute__((unused)),
1684
static void update_func_long(THD *thd __attribute__((__unused__)),
1685
struct st_mysql_sys_var *var __attribute__((__unused__)),
1557
1686
void *tgt, const void *save)
1559
1688
*(long *)tgt= *(long *) save;
1563
static void update_func_int64_t(THD *thd __attribute__((unused)),
1564
struct st_mysql_sys_var *var __attribute__((unused)),
1692
static void update_func_int64_t(THD *thd __attribute__((__unused__)),
1693
struct st_mysql_sys_var *var __attribute__((__unused__)),
1565
1694
void *tgt, const void *save)
1567
1696
*(int64_t *)tgt= *(uint64_t *) save;
1571
static void update_func_str(THD *thd __attribute__((unused)), struct st_mysql_sys_var *var,
1700
static void update_func_str(THD *thd __attribute__((__unused__)), struct st_mysql_sys_var *var,
1572
1701
void *tgt, const void *save)
1574
1703
char *old= *(char **) tgt;
1735
1864
variables. If their value is non-NULL, it must point to a valid
1738
memset(global_system_variables.dynamic_variables_ptr +
1739
global_variables_dynamic_size, 0,
1740
new_size - global_variables_dynamic_size);
1741
memset(max_system_variables.dynamic_variables_ptr +
1742
global_variables_dynamic_size, 0,
1743
new_size - global_variables_dynamic_size);
1867
bzero(global_system_variables.dynamic_variables_ptr +
1868
global_variables_dynamic_size,
1869
new_size - global_variables_dynamic_size);
1870
bzero(max_system_variables.dynamic_variables_ptr +
1871
global_variables_dynamic_size,
1872
new_size - global_variables_dynamic_size);
1744
1873
global_variables_dynamic_size= new_size;
1771
1900
If required, will sync with global variables if the requested variable
1772
1901
has not yet been allocated in the current thread.
1774
static unsigned char *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
1903
static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
1776
1905
assert(offset >= 0);
1777
1906
assert((uint)offset <= global_system_variables.dynamic_variables_head);
1780
return (unsigned char*) global_system_variables.dynamic_variables_ptr + offset;
1909
return (uchar*) global_system_variables.dynamic_variables_ptr + offset;
1783
1912
dynamic_variables_head points to the largest valid offset
2091
unsigned char* sys_var_pluginvar::value_ptr(THD *thd, enum_var_type type,
2092
LEX_STRING *base __attribute__((unused)))
2220
uchar* sys_var_pluginvar::value_ptr(THD *thd, enum_var_type type,
2221
LEX_STRING *base __attribute__((__unused__)))
2094
unsigned char* result;
2096
2225
result= real_value_ptr(thd, type);
2098
2227
if ((plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_ENUM)
2099
result= (unsigned char*) get_type(plugin_var_typelib(), *(ulong*)result);
2228
result= (uchar*) get_type(plugin_var_typelib(), *(ulong*)result);
2100
2229
else if ((plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_SET)
2102
2231
char buffer[STRING_BUFFER_USUAL_SIZE];
2103
2232
String str(buffer, sizeof(buffer), system_charset_info);
2104
2233
TYPELIB *typelib= plugin_var_typelib();
2105
2234
uint64_t mask= 1, value= *(uint64_t*) result;
2109
2238
for (i= 0; i < typelib->count; i++, mask<<=1)
2235
2364
#define OPTION_SET_LIMITS(type, options, opt) \
2236
options->var_type= type; \
2237
options->def_value= (opt)->def_val; \
2238
options->min_value= (opt)->min_val; \
2239
options->max_value= (opt)->max_val; \
2365
options->var_type= type; \
2366
options->def_value= (opt)->def_val; \
2367
options->min_value= (opt)->min_val; \
2368
options->max_value= (opt)->max_val; \
2240
2369
options->block_size= (long) (opt)->blk_sz
2367
2496
/* support --skip-plugin-foo syntax */
2368
2497
memcpy(name, plugin_name, namelen + 1);
2369
my_casedn_str(&my_charset_utf8_general_ci, name);
2370
strxmov(name + namelen + 1, "plugin-", name, NULL);
2498
my_casedn_str(&my_charset_latin1, name);
2499
strxmov(name + namelen + 1, "plugin-", name, NullS);
2371
2500
/* Now we have namelen + 1 + 7 + namelen + 1 == namelen * 2 + 9. */
2373
2502
for (p= name + namelen*2 + 8; p > name; p--)
2572
2701
st_mysql_sys_var **opt;
2573
2702
my_option *opts;
2574
2703
bool can_disable;
2575
uint32_t count= EXTRA_OPTIONS;
2704
uint count= EXTRA_OPTIONS;
2577
2706
for (opt= p->plugin->system_vars; opt && *opt; opt++, count+= 2) {};
2579
2708
if (!(opts= (my_option*) alloc_root(mem_root, sizeof(my_option) * count)))
2582
memset(opts, 0, sizeof(my_option) * count);
2711
bzero(opts, sizeof(my_option) * count);
2584
if ((my_strcasecmp(&my_charset_utf8_general_ci, p->name.str, "MyISAM") == 0))
2713
if ((my_strcasecmp(&my_charset_latin1, p->name.str, "MyISAM") == 0))
2585
2714
can_disable= false;
2586
else if ((my_strcasecmp(&my_charset_utf8_general_ci, p->name.str, "MEMORY") == 0))
2715
else if ((my_strcasecmp(&my_charset_latin1, p->name.str, "MEMORY") == 0))
2587
2716
can_disable= false;
2589
2718
can_disable= true;
2624
2753
st_mysql_sys_var *o;
2626
2755
struct st_bookmark *var;
2627
uint32_t len, count= EXTRA_OPTIONS;
2756
uint len, count= EXTRA_OPTIONS;
2628
2757
assert(tmp->plugin && tmp->name.str);
2630
2759
for (opt= tmp->plugin->system_vars; opt && *opt; opt++)
2631
2760
count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */
2633
if ((my_strcasecmp(&my_charset_utf8_general_ci, tmp->name.str, "MyISAM") == 0))
2762
if ((my_strcasecmp(&my_charset_latin1, tmp->name.str, "MyISAM") == 0))
2634
2763
can_disable= false;
2635
else if ((my_strcasecmp(&my_charset_utf8_general_ci, tmp->name.str, "MEMORY") == 0))
2764
else if ((my_strcasecmp(&my_charset_latin1, tmp->name.str, "MEMORY") == 0))
2636
2765
can_disable= false;
2638
2767
can_disable= true;
2642
2771
if (!(opts= (my_option*) alloc_root(tmp_root, sizeof(my_option) * count)))
2644
sql_print_error(_("Out of memory for plugin '%s'."), tmp->name.str);
2773
sql_print_error("Out of memory for plugin '%s'.", tmp->name.str);
2647
memset(opts, 0, sizeof(my_option) * count);
2776
bzero(opts, sizeof(my_option) * count);
2649
2778
if (construct_options(tmp_root, tmp, opts, can_disable))
2651
sql_print_error(_("Bad options for plugin '%s'."), tmp->name.str);
2780
sql_print_error("Bad options for plugin '%s'.", tmp->name.str);
2678
2807
len= tmp->name.length + strlen(o->name) + 2;
2679
2808
varname= (char*) alloc_root(mem_root, len);
2680
strxmov(varname, tmp->name.str, "-", o->name, NULL);
2681
my_casedn_str(&my_charset_utf8_general_ci, varname);
2809
strxmov(varname, tmp->name.str, "-", o->name, NullS);
2810
my_casedn_str(&my_charset_latin1, varname);
2683
2812
for (p= varname; *p; p++)
2751
2880
/* Only options with a non-NULL comment are displayed in help text */
2752
2881
for (;opt->id; opt++)
2753
2882
if (opt->comment)
2754
insert_dynamic(&all_options, (unsigned char*) opt);
2883
insert_dynamic(&all_options, (uchar*) opt);
2757
2886
for (;main_options->id; main_options++)
2758
insert_dynamic(&all_options, (unsigned char*) main_options);
2887
insert_dynamic(&all_options, (uchar*) main_options);
2760
2889
sort_dynamic(&all_options, (qsort_cmp) option_cmp);
2762
2891
/* main_options now points to the empty option terminator */
2763
insert_dynamic(&all_options, (unsigned char*) main_options);
2892
insert_dynamic(&all_options, (uchar*) main_options);
2765
2894
my_print_help((my_option*) all_options.buffer);
2766
2895
my_print_variables((my_option*) all_options.buffer);