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("STORAGE ENGINE") },
38
{ C_STRING_WITH_LEN("FTPARSER") },
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
{ C_STRING_WITH_LEN("AUDIT") },
44
{ C_STRING_WITH_LEN("LOGGER") },
45
{ C_STRING_WITH_LEN("AUTH") }
41
{ C_STRING_WITH_LEN("AUDIT") }
48
44
extern int initialize_schema_table(st_plugin_int *plugin);
56
52
plugin_type_deinitialize should equal to the number of plugins
59
plugin_type_init plugin_type_initialize[DRIZZLE_MAX_PLUGIN_TYPE_NUM]=
62
ha_initialize_handlerton, /* Storage Engine */
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]=
74
ha_finalize_handlerton, /* Storage Engine */
75
finalize_schema_table, /* Information Schema */
76
finalize_udf, /* UDF */
79
logging_finalizer, /* Logger */
80
authentication_finalizer /* Auth */
55
plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
57
initialize_udf,ha_initialize_handlerton,0,0,initialize_schema_table,
61
plugin_type_init plugin_type_deinitialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
63
finalize_udf,ha_finalize_handlerton,0,0,finalize_schema_table,
67
static const char *plugin_interface_version_sym=
68
"_mysql_plugin_interface_version_";
69
static const char *sizeof_st_plugin_sym=
70
"_mysql_sizeof_struct_st_plugin_";
83
71
static const char *plugin_declarations_sym= "_mysql_plugin_declarations_";
72
static int min_plugin_interface_version= MYSQL_PLUGIN_INTERFACE_VERSION & ~0xFF;
85
74
/* Note that 'int version' must be the first field of every plugin
86
75
sub-structure (plugin->info).
77
static int min_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
79
MYSQL_UDF_INTERFACE_VERSION,
80
MYSQL_HANDLERTON_INTERFACE_VERSION,
81
MYSQL_FTPARSER_INTERFACE_VERSION,
82
MYSQL_DAEMON_INTERFACE_VERSION,
83
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION,
84
MYSQL_AUDIT_INTERFACE_VERSION
86
static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
88
MYSQL_UDF_INTERFACE_VERSION,
89
MYSQL_HANDLERTON_INTERFACE_VERSION,
90
MYSQL_FTPARSER_INTERFACE_VERSION,
91
MYSQL_DAEMON_INTERFACE_VERSION,
92
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION,
93
MYSQL_AUDIT_INTERFACE_VERSION
89
96
static bool initialized= 0;
91
98
static DYNAMIC_ARRAY plugin_dl_array;
92
99
static DYNAMIC_ARRAY plugin_array;
93
static HASH plugin_hash[DRIZZLE_MAX_PLUGIN_TYPE_NUM];
100
static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM];
94
101
static bool reap_needed= false;
95
102
static int plugin_array_version=0;
166
173
{ return !(plugin_var->flags & PLUGIN_VAR_THDLOCAL) && type != OPT_GLOBAL; }
167
174
bool check_update_type(Item_result type);
168
175
SHOW_TYPE show_type();
169
unsigned char* real_value_ptr(THD *thd, enum_var_type type);
176
uchar* real_value_ptr(THD *thd, enum_var_type type);
170
177
TYPELIB* plugin_var_typelib(void);
171
unsigned char* value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
178
uchar* value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
172
179
bool check(THD *thd, set_var *var);
173
bool check_default(enum_var_type type __attribute__((unused)))
180
bool check_default(enum_var_type type __attribute__((__unused__)))
174
181
{ return is_readonly(); }
175
182
void set_default(THD *thd,
176
enum_var_type type __attribute__((unused)));
183
enum_var_type type __attribute__((__unused__)));
177
184
bool update(THD *thd, set_var *var);
336
346
tmp->ref_count++;
339
memset(&plugin_dl, 0, sizeof(plugin_dl));
349
bzero(&plugin_dl, sizeof(plugin_dl));
340
350
/* Compile dll path */
342
strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", dl->str, NULL) -
352
strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", dl->str, NullS) -
344
354
plugin_dl.ref_count= 1;
345
355
/* Open new dll handle */
346
if (!(plugin_dl.handle= dlopen(dlpath, RTLD_LAZY|RTLD_GLOBAL)))
356
if (!(plugin_dl.handle= dlopen(dlpath, RTLD_NOW)))
348
358
const char *errmsg=dlerror();
349
359
if (!strncmp(dlpath, errmsg, dlpathlen))
358
368
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath, errno, errmsg);
371
/* Determine interface version */
372
if (!(sym= dlsym(plugin_dl.handle, plugin_interface_version_sym)))
374
free_plugin_mem(&plugin_dl);
375
if (report & REPORT_TO_USER)
376
my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), plugin_interface_version_sym);
377
if (report & REPORT_TO_LOG)
378
sql_print_error(ER(ER_CANT_FIND_DL_ENTRY), plugin_interface_version_sym);
381
plugin_dl.version= *(int *)sym;
383
if (plugin_dl.version < min_plugin_interface_version ||
384
(plugin_dl.version >> 8) > (MYSQL_PLUGIN_INTERFACE_VERSION >> 8))
386
free_plugin_mem(&plugin_dl);
387
if (report & REPORT_TO_USER)
388
my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dlpath, 0,
389
"plugin interface version mismatch");
390
if (report & REPORT_TO_LOG)
391
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath, 0,
392
"plugin interface version mismatch");
362
395
/* Find plugin declarations */
363
396
if (!(sym= dlsym(plugin_dl.handle, plugin_declarations_sym)))
406
if (plugin_dl.version != MYSQL_PLUGIN_INTERFACE_VERSION)
409
uint sizeof_st_plugin;
410
struct st_mysql_plugin *old, *cur;
411
char *ptr= (char *)sym;
413
if ((sym= dlsym(plugin_dl.handle, sizeof_st_plugin_sym)))
414
sizeof_st_plugin= *(int *)sym;
417
#ifdef ERROR_ON_NO_SIZEOF_PLUGIN_SYMBOL
418
free_plugin_mem(&plugin_dl);
419
if (report & REPORT_TO_USER)
420
my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), sizeof_st_plugin_sym);
421
if (report & REPORT_TO_LOG)
422
sql_print_error(ER(ER_CANT_FIND_DL_ENTRY), sizeof_st_plugin_sym);
426
When the following assert starts failing, we'll have to switch
427
to the upper branch of the #ifdef
429
assert(min_plugin_interface_version == 0);
430
sizeof_st_plugin= (int)offsetof(struct st_mysql_plugin, version);
435
((struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
439
cur= (struct st_mysql_plugin*)
440
my_malloc(i*sizeof(struct st_mysql_plugin), MYF(MY_ZEROFILL|MY_WME));
443
free_plugin_mem(&plugin_dl);
444
if (report & REPORT_TO_USER)
445
my_error(ER_OUTOFMEMORY, MYF(0), plugin_dl.dl.length);
446
if (report & REPORT_TO_LOG)
447
sql_print_error(ER(ER_OUTOFMEMORY), plugin_dl.dl.length);
451
All st_plugin fields not initialized in the plugin explicitly, are
452
set to 0. It matches C standard behaviour for struct initializers that
453
have less values than the struct definition.
456
(old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
458
memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
373
462
plugin_dl.plugins= (struct st_mysql_plugin *)sym;
375
464
/* Duplicate and convert dll name */
411
508
struct st_plugin_dl **);
412
509
if (tmp->ref_count &&
413
510
! my_strnncoll(files_charset_info,
414
(const unsigned char *)dl->str, dl->length,
415
(const unsigned char *)tmp->dl.str, tmp->dl.length))
511
(const uchar *)dl->str, dl->length,
512
(const uchar *)tmp->dl.str, tmp->dl.length))
417
514
/* Do not remove this element, unless no other plugin uses this dll. */
418
515
if (! --tmp->ref_count)
420
517
free_plugin_mem(tmp);
421
memset(tmp, 0, sizeof(struct st_plugin_dl));
518
bzero(tmp, sizeof(struct st_plugin_dl));
430
528
static struct st_plugin_int *plugin_find_internal(const LEX_STRING *name, int type)
433
531
if (! initialized)
436
if (type == DRIZZLE_ANY_PLUGIN)
534
if (type == MYSQL_ANY_PLUGIN)
438
for (i= 0; i < DRIZZLE_MAX_PLUGIN_TYPE_NUM; i++)
536
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
440
538
struct st_plugin_int *plugin= (st_plugin_int *)
441
hash_search(&plugin_hash[i], (const unsigned char *)name->str, name->length);
539
hash_search(&plugin_hash[i], (const uchar *)name->str, name->length);
447
545
return((st_plugin_int *)
448
hash_search(&plugin_hash[type], (const unsigned char *)name->str, name->length));
546
hash_search(&plugin_hash[type], (const uchar *)name->str, name->length));
561
659
struct st_plugin_int tmp;
562
660
struct st_mysql_plugin *plugin;
563
if (plugin_find_internal(name, DRIZZLE_ANY_PLUGIN))
661
if (plugin_find_internal(name, MYSQL_ANY_PLUGIN))
565
663
if (report & REPORT_TO_USER)
566
664
my_error(ER_UDF_EXISTS, MYF(0), name->str);
567
665
if (report & REPORT_TO_LOG)
568
666
sql_print_error(ER(ER_UDF_EXISTS), name->str);
571
669
/* Clear the whole struct to catch future extensions. */
572
memset(&tmp, 0, sizeof(tmp));
670
bzero((char*) &tmp, sizeof(tmp));
573
671
if (! (tmp.plugin_dl= plugin_dl_add(dl, report)))
575
673
/* Find plugin by name */
576
for (plugin= tmp.plugin_dl->plugins; plugin->name; plugin++)
674
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 &&
676
uint name_len= strlen(plugin->name);
677
if (plugin->type >= 0 && plugin->type < MYSQL_MAX_PLUGIN_TYPE_NUM &&
580
678
! my_strnncoll(system_charset_info,
581
(const unsigned char *)name->str, name->length,
582
(const unsigned char *)plugin->name,
679
(const uchar *)name->str, name->length,
680
(const uchar *)plugin->name,
585
683
struct st_plugin_int *tmp_plugin_ptr;
684
if (*(int*)plugin->info <
685
min_plugin_info_interface_version[plugin->type] ||
686
((*(int*)plugin->info) >> 8) >
687
(cur_plugin_info_interface_version[plugin->type] >> 8))
690
strxnmov(buf, sizeof(buf) - 1, "API version for ",
691
plugin_type_names[plugin->type].str,
692
" plugin is too different", NullS);
693
if (report & REPORT_TO_USER)
694
my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dl->str, 0, buf);
695
if (report & REPORT_TO_LOG)
696
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dl->str, 0, buf);
587
699
tmp.plugin= plugin;
588
700
tmp.name.str= (char *)plugin->name;
589
701
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,
954
extern "C" uchar *get_plugin_hash_key(const uchar *, size_t *, bool);
955
extern "C" uchar *get_bookmark_hash_key(const uchar *, size_t *, bool);
958
uchar *get_plugin_hash_key(const uchar *buff, size_t *length,
847
959
bool not_used __attribute__((unused)))
849
961
struct st_plugin_int *plugin= (st_plugin_int *)buff;
850
962
*length= (uint)plugin->name.length;
851
return((unsigned char *)plugin->name.str);
963
return((uchar *)plugin->name.str);
855
unsigned char *get_bookmark_hash_key(const unsigned char *buff, size_t *length,
967
uchar *get_bookmark_hash_key(const uchar *buff, size_t *length,
856
968
bool not_used __attribute__((unused)))
858
970
struct st_bookmark *var= (st_bookmark *)buff;
859
971
*length= var->name_len + 1;
860
return (unsigned char*) var->key;
972
return (uchar*) var->key;
1003
1115
tmp->ref_count= 0;
1004
1116
tmp->plugin_dl= 0;
1006
if (insert_dynamic(&plugin_array, (unsigned char*)&tmp))
1118
if (insert_dynamic(&plugin_array, (uchar*)&tmp))
1009
1121
*ptr= *dynamic_element(&plugin_array, plugin_array.elements - 1,
1010
1122
struct st_plugin_int **)=
1011
(struct st_plugin_int *) memdup_root(&plugin_mem_root, (unsigned char*)tmp,
1123
(struct st_plugin_int *) memdup_root(&plugin_mem_root, (uchar*)tmp,
1012
1124
sizeof(struct st_plugin_int));
1014
if (my_hash_insert(&plugin_hash[plugin->type],(unsigned char*) *ptr))
1126
if (my_hash_insert(&plugin_hash[plugin->type],(uchar*) *ptr))
1227
1338
bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
1228
int type, uint32_t state_mask, void *arg)
1339
int type, uint state_mask, void *arg)
1230
uint32_t idx, total;
1231
1342
struct st_plugin_int *plugin, **plugins;
1232
1343
int version=plugin_array_version;
1234
1345
if (!initialized)
1237
1348
state_mask= ~state_mask; // do it only once
1239
total= type == DRIZZLE_ANY_PLUGIN ? plugin_array.elements
1350
total= type == MYSQL_ANY_PLUGIN ? plugin_array.elements
1240
1351
: plugin_hash[type].records;
1242
1353
Do the alloca out here in case we do have a working alloca:
1243
1354
leaving the nested stack frame invalidates alloca allocation.
1245
1356
plugins=(struct st_plugin_int **)my_alloca(total*sizeof(plugin));
1246
if (type == DRIZZLE_ANY_PLUGIN)
1357
if (type == MYSQL_ANY_PLUGIN)
1248
1359
for (idx= 0; idx < total; idx++)
1286
1397
Internal type declarations for variables support
1287
1398
****************************************************************************/
1289
#undef DRIZZLE_SYSVAR_NAME
1290
#define DRIZZLE_SYSVAR_NAME(name) name
1400
#undef MYSQL_SYSVAR_NAME
1401
#define MYSQL_SYSVAR_NAME(name) name
1291
1402
#define PLUGIN_VAR_TYPEMASK 0x007f
1293
1404
#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);
1319
typedef bool *(*mysql_sys_var_ptr_p)(THD* a_thd, int offset);
1406
typedef DECLARE_MYSQL_SYSVAR_BASIC(sysvar_bool_t, bool);
1407
typedef DECLARE_MYSQL_THDVAR_BASIC(thdvar_bool_t, bool);
1408
typedef DECLARE_MYSQL_SYSVAR_BASIC(sysvar_str_t, char *);
1409
typedef DECLARE_MYSQL_THDVAR_BASIC(thdvar_str_t, char *);
1411
typedef DECLARE_MYSQL_SYSVAR_TYPELIB(sysvar_enum_t, unsigned long);
1412
typedef DECLARE_MYSQL_THDVAR_TYPELIB(thdvar_enum_t, unsigned long);
1413
typedef DECLARE_MYSQL_SYSVAR_TYPELIB(sysvar_set_t, uint64_t);
1414
typedef DECLARE_MYSQL_THDVAR_TYPELIB(thdvar_set_t, uint64_t);
1416
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_int_t, int);
1417
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_long_t, long);
1418
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_int64_t_t, int64_t);
1419
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_uint_t, uint);
1420
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_ulong_t, ulong);
1421
typedef DECLARE_MYSQL_SYSVAR_SIMPLE(sysvar_uint64_t_t, uint64_t);
1423
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_int_t, int);
1424
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_long_t, long);
1425
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_int64_t_t, int64_t);
1426
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_uint_t, uint);
1427
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_ulong_t, ulong);
1428
typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_uint64_t_t, uint64_t);
1430
#define SET_PLUGIN_VAR_RESOLVE(opt)\
1431
*(mysql_sys_var_ptr_p*)&((opt)->resolve)= mysql_sys_var_ptr
1432
typedef uchar *(*mysql_sys_var_ptr_p)(void* a_thd, int offset);
1322
1435
/****************************************************************************
1323
1436
default variable data check and update functions
1324
1437
****************************************************************************/
1326
static int check_func_bool(THD *thd __attribute__((unused)),
1439
static int check_func_bool(THD *thd __attribute__((__unused__)),
1327
1440
struct st_mysql_sys_var *var,
1328
1441
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)),
1652
static void update_func_bool(THD *thd __attribute__((__unused__)),
1653
struct st_mysql_sys_var *var __attribute__((__unused__)),
1541
1654
void *tgt, const void *save)
1543
*(bool *) tgt= *(int *) save ? 1 : 0;
1656
*(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)),
1660
static void update_func_int(THD *thd __attribute__((__unused__)),
1661
struct st_mysql_sys_var *var __attribute__((__unused__)),
1549
1662
void *tgt, const void *save)
1551
1664
*(int *)tgt= *(int *) save;
1555
static void update_func_long(THD *thd __attribute__((unused)),
1556
struct st_mysql_sys_var *var __attribute__((unused)),
1668
static void update_func_long(THD *thd __attribute__((__unused__)),
1669
struct st_mysql_sys_var *var __attribute__((__unused__)),
1557
1670
void *tgt, const void *save)
1559
1672
*(long *)tgt= *(long *) save;
1563
static void update_func_int64_t(THD *thd __attribute__((unused)),
1564
struct st_mysql_sys_var *var __attribute__((unused)),
1676
static void update_func_int64_t(THD *thd __attribute__((__unused__)),
1677
struct st_mysql_sys_var *var __attribute__((__unused__)),
1565
1678
void *tgt, const void *save)
1567
1680
*(int64_t *)tgt= *(uint64_t *) save;
1571
static void update_func_str(THD *thd __attribute__((unused)), struct st_mysql_sys_var *var,
1684
static void update_func_str(THD *thd __attribute__((__unused__)), struct st_mysql_sys_var *var,
1572
1685
void *tgt, const void *save)
1574
1687
char *old= *(char **) tgt;
1735
1848
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);
1851
bzero(global_system_variables.dynamic_variables_ptr +
1852
global_variables_dynamic_size,
1853
new_size - global_variables_dynamic_size);
1854
bzero(max_system_variables.dynamic_variables_ptr +
1855
global_variables_dynamic_size,
1856
new_size - global_variables_dynamic_size);
1744
1857
global_variables_dynamic_size= new_size;
1848
1961
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);
1963
return (uchar*)thd->variables.dynamic_variables_ptr + offset;
1966
static uchar *mysql_sys_var_ptr(void* a_thd, int offset)
1968
return intern_sys_var_ptr((THD *)a_thd, offset, true);
2091
unsigned char* sys_var_pluginvar::value_ptr(THD *thd, enum_var_type type,
2092
LEX_STRING *base __attribute__((unused)))
2174
uchar* sys_var_pluginvar::value_ptr(THD *thd, enum_var_type type,
2175
LEX_STRING *base __attribute__((__unused__)))
2094
unsigned char* result;
2096
2179
result= real_value_ptr(thd, type);
2098
2181
if ((plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_ENUM)
2099
result= (unsigned char*) get_type(plugin_var_typelib(), *(ulong*)result);
2182
result= (uchar*) get_type(plugin_var_typelib(), *(ulong*)result);
2100
2183
else if ((plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_SET)
2102
2185
char buffer[STRING_BUFFER_USUAL_SIZE];
2103
2186
String str(buffer, sizeof(buffer), system_charset_info);
2104
2187
TYPELIB *typelib= plugin_var_typelib();
2105
2188
uint64_t mask= 1, value= *(uint64_t*) result;
2109
2192
for (i= 0; i < typelib->count; i++, mask<<=1)
2411
2494
switch (opt->flags & PLUGIN_VAR_TYPEMASK) {
2412
2495
case PLUGIN_VAR_BOOL:
2413
(((thdvar_bool_t *)opt)->resolve)= mysql_sys_var_ptr_bool;
2496
SET_PLUGIN_VAR_RESOLVE(((thdvar_bool_t *) opt));
2415
2498
case PLUGIN_VAR_INT:
2416
(((thdvar_int_t *)opt)->resolve)= mysql_sys_var_ptr_int;
2499
SET_PLUGIN_VAR_RESOLVE((thdvar_int_t *) opt);
2418
2501
case PLUGIN_VAR_LONG:
2419
(((thdvar_long_t *)opt)->resolve)= mysql_sys_var_ptr_long;
2502
SET_PLUGIN_VAR_RESOLVE((thdvar_long_t *) opt);
2421
2504
case PLUGIN_VAR_LONGLONG:
2422
(((thdvar_int64_t_t *)opt)->resolve)= mysql_sys_var_ptr_int64_t;
2505
SET_PLUGIN_VAR_RESOLVE((thdvar_int64_t_t *) opt);
2424
2507
case PLUGIN_VAR_STR:
2425
(((thdvar_str_t *)opt)->resolve)= mysql_sys_var_ptr_str;
2508
SET_PLUGIN_VAR_RESOLVE((thdvar_str_t *) opt);
2427
2510
case PLUGIN_VAR_ENUM:
2428
(((thdvar_enum_t *)opt)->resolve)= mysql_sys_var_ptr_enum;
2511
SET_PLUGIN_VAR_RESOLVE((thdvar_enum_t *) opt);
2430
2513
case PLUGIN_VAR_SET:
2431
(((thdvar_set_t *)opt)->resolve)= mysql_sys_var_ptr_set;
2514
SET_PLUGIN_VAR_RESOLVE((thdvar_set_t *) opt);
2434
sql_print_error(_("Unknown variable type code 0x%x in plugin '%s'."),
2517
sql_print_error("Unknown variable type code 0x%x in plugin '%s'.",
2435
2518
opt->flags, plugin_name);
2572
2655
st_mysql_sys_var **opt;
2573
2656
my_option *opts;
2574
2657
bool can_disable;
2575
uint32_t count= EXTRA_OPTIONS;
2658
uint count= EXTRA_OPTIONS;
2577
2660
for (opt= p->plugin->system_vars; opt && *opt; opt++, count+= 2) {};
2579
2662
if (!(opts= (my_option*) alloc_root(mem_root, sizeof(my_option) * count)))
2582
memset(opts, 0, sizeof(my_option) * count);
2665
bzero(opts, sizeof(my_option) * count);
2584
if ((my_strcasecmp(&my_charset_utf8_general_ci, p->name.str, "MyISAM") == 0))
2667
if ((my_strcasecmp(&my_charset_latin1, p->name.str, "MyISAM") == 0))
2585
2668
can_disable= false;
2586
else if ((my_strcasecmp(&my_charset_utf8_general_ci, p->name.str, "MEMORY") == 0))
2669
else if ((my_strcasecmp(&my_charset_latin1, p->name.str, "MEMORY") == 0))
2587
2670
can_disable= false;
2589
2672
can_disable= true;
2624
2707
st_mysql_sys_var *o;
2626
2709
struct st_bookmark *var;
2627
uint32_t len, count= EXTRA_OPTIONS;
2710
uint len, count= EXTRA_OPTIONS;
2628
2711
assert(tmp->plugin && tmp->name.str);
2630
2713
for (opt= tmp->plugin->system_vars; opt && *opt; opt++)
2631
2714
count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */
2633
if ((my_strcasecmp(&my_charset_utf8_general_ci, tmp->name.str, "MyISAM") == 0))
2716
if ((my_strcasecmp(&my_charset_latin1, tmp->name.str, "MyISAM") == 0))
2634
2717
can_disable= false;
2635
else if ((my_strcasecmp(&my_charset_utf8_general_ci, tmp->name.str, "MEMORY") == 0))
2718
else if ((my_strcasecmp(&my_charset_latin1, tmp->name.str, "MEMORY") == 0))
2636
2719
can_disable= false;
2638
2721
can_disable= true;
2642
2725
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);
2727
sql_print_error("Out of memory for plugin '%s'.", tmp->name.str);
2647
memset(opts, 0, sizeof(my_option) * count);
2730
bzero(opts, sizeof(my_option) * count);
2649
2732
if (construct_options(tmp_root, tmp, opts, can_disable))
2651
sql_print_error(_("Bad options for plugin '%s'."), tmp->name.str);
2734
sql_print_error("Bad options for plugin '%s'.", tmp->name.str);
2751
2834
/* Only options with a non-NULL comment are displayed in help text */
2752
2835
for (;opt->id; opt++)
2753
2836
if (opt->comment)
2754
insert_dynamic(&all_options, (unsigned char*) opt);
2837
insert_dynamic(&all_options, (uchar*) opt);
2757
2840
for (;main_options->id; main_options++)
2758
insert_dynamic(&all_options, (unsigned char*) main_options);
2841
insert_dynamic(&all_options, (uchar*) main_options);
2760
2843
sort_dynamic(&all_options, (qsort_cmp) option_cmp);
2762
2845
/* main_options now points to the empty option terminator */
2763
insert_dynamic(&all_options, (unsigned char*) main_options);
2846
insert_dynamic(&all_options, (uchar*) main_options);
2765
2848
my_print_help((my_option*) all_options.buffer);
2766
2849
my_print_variables((my_option*) all_options.buffer);