~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_plugin.cc

  • Committer: Jay Pipes
  • Date: 2008-07-17 17:54:00 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: jay@mysql.com-20080717175400-xm2aazihjra8mdzq
Removal of DBUG from libdrizzle/ - Round 2

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include <drizzled/server_includes.h>
17
 
#include <mysys/my_getopt.h>
18
 
#include <authentication.h>
19
 
#include <logging.h>
20
 
#include <drizzled/drizzled_error_messages.h>
 
16
#include "mysql_priv.h"
 
17
#include <my_pthread.h>
 
18
#include <my_getopt.h>
21
19
#define REPORT_TO_LOG  1
22
20
#define REPORT_TO_USER 2
23
21
 
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.
35
33
*/
36
 
const LEX_STRING plugin_type_names[DRIZZLE_MAX_PLUGIN_TYPE_NUM]=
 
34
const LEX_STRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]=
37
35
{
 
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") }
46
44
};
47
45
 
56
54
  plugin_type_deinitialize should equal to the number of plugins
57
55
  defined.
58
56
*/
59
 
plugin_type_init plugin_type_initialize[DRIZZLE_MAX_PLUGIN_TYPE_NUM]=
 
57
plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
60
58
{
61
 
  0,  /* Daemon */
 
59
  initialize_udf,  /* UDF */
 
60
  0,  /* UDA */
62
61
  ha_initialize_handlerton,  /* Storage Engine */
 
62
  0,  /* Daemon */
63
63
  initialize_schema_table,  /* Information Schema */
64
 
  initialize_udf,  /* UDF */
65
 
  0,  /* UDA */
66
64
  0,  /* Audit */
67
 
  logging_initializer,  /* Logger */
68
 
  authentication_initializer  /* Auth */
 
65
  0,  /* Log */
 
66
  0  /* Auth */
69
67
};
70
68
 
71
 
plugin_type_init plugin_type_deinitialize[DRIZZLE_MAX_PLUGIN_TYPE_NUM]=
 
69
plugin_type_init plugin_type_deinitialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
72
70
{
73
 
  0,  /* Daemon */
 
71
  finalize_udf,  /* UDF */
 
72
  0,  /* UDA */
74
73
  ha_finalize_handlerton,  /* Storage Engine */
 
74
  0,  /* Daemon */
75
75
  finalize_schema_table,  /* Information Schema */
76
 
  finalize_udf,  /* UDF */
77
 
  0,  /* UDA */
78
76
  0,  /* Audit */
79
 
  logging_finalizer,  /* Logger */
80
 
  authentication_finalizer  /* Auth */
 
77
  0,  /* Log */
 
78
  0  /* Auth */
81
79
};
82
80
 
 
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;
84
87
 
85
88
/* Note that 'int version' must be the first field of every plugin
86
89
   sub-structure (plugin->info).
87
90
*/
 
91
static int min_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
 
92
{
 
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
 
101
};
 
102
static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
 
103
{
 
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
 
112
};
88
113
 
89
114
static bool initialized= 0;
90
115
 
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;
96
121
 
99
124
  the following variables/structures
100
125
*/
101
126
static MEM_ROOT plugin_mem_root;
102
 
static uint32_t global_variables_dynamic_size= 0;
 
127
static uint global_variables_dynamic_size= 0;
103
128
static HASH bookmark_hash;
104
129
 
105
130
 
126
151
*/
127
152
struct st_bookmark
128
153
{
129
 
  uint32_t name_len;
 
154
  uint name_len;
130
155
  int offset;
131
 
  uint32_t version;
 
156
  uint version;
132
157
  char key[1];
133
158
};
134
159
 
138
163
*/
139
164
struct st_mysql_sys_var
140
165
{
141
 
  DRIZZLE_PLUGIN_VAR_HEADER;
 
166
  MYSQL_PLUGIN_VAR_HEADER;
142
167
};
143
168
 
144
169
 
153
178
 
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); }
159
184
 
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);
178
203
};
179
204
 
199
224
 
200
225
 
201
226
/* declared in set_var.cc */
202
 
extern sys_var *intern_find_sys_var(const char *str, uint32_t length, bool no_error);
 
227
extern sys_var *intern_find_sys_var(const char *str, uint length, bool no_error);
203
228
extern bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
204
229
                                 const char *name, int64_t val);
205
230
 
211
236
{
212
237
  switch (((st_item_value_holder*)value)->item->result_type()) {
213
238
  case INT_RESULT:
214
 
    return DRIZZLE_VALUE_TYPE_INT;
 
239
    return MYSQL_VALUE_TYPE_INT;
215
240
  case REAL_RESULT:
216
 
    return DRIZZLE_VALUE_TYPE_REAL;
 
241
    return MYSQL_VALUE_TYPE_REAL;
217
242
  default:
218
 
    return DRIZZLE_VALUE_TYPE_STRING;
 
243
    return MYSQL_VALUE_TYPE_STRING;
219
244
  }
220
245
}
221
246
 
263
288
 
264
289
static struct st_plugin_dl *plugin_dl_find(const LEX_STRING *dl)
265
290
{
266
 
  uint32_t i;
 
291
  uint i;
267
292
  struct st_plugin_dl *tmp;
268
293
  for (i= 0; i < plugin_dl_array.elements; i++)
269
294
  {
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))
275
300
      return(tmp);
276
301
  }
277
302
  return(0);
279
304
 
280
305
static st_plugin_dl *plugin_dl_insert_or_reuse(struct st_plugin_dl *plugin_dl)
281
306
{
282
 
  uint32_t i;
 
307
  uint i;
283
308
  struct st_plugin_dl *tmp;
284
309
  for (i= 0; i < plugin_dl_array.elements; i++)
285
310
  {
290
315
      return(tmp);
291
316
    }
292
317
  }
293
 
  if (insert_dynamic(&plugin_dl_array, (unsigned char*)&plugin_dl))
 
318
  if (insert_dynamic(&plugin_dl_array, (uchar*)&plugin_dl))
294
319
    return(0);
295
320
  tmp= *dynamic_element(&plugin_dl_array, plugin_dl_array.elements - 1,
296
321
                        struct st_plugin_dl **)=
297
 
      (struct st_plugin_dl *) memdup_root(&plugin_mem_root, (unsigned char*)plugin_dl,
 
322
      (struct st_plugin_dl *) memdup_root(&plugin_mem_root, (uchar*)plugin_dl,
298
323
                                           sizeof(struct st_plugin_dl));
299
324
  return(tmp);
300
325
}
303
328
{
304
329
  if (p->handle)
305
330
    dlclose(p->handle);
306
 
  free(p->dl.str);
 
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));
307
334
}
308
335
 
309
336
 
310
337
static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
311
338
{
 
339
#ifdef HAVE_DLOPEN
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;
315
343
  void *sym;
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).
321
349
  */
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++;
337
365
    return(tmp);
338
366
  }
339
 
  memset(&plugin_dl, 0, sizeof(plugin_dl));
 
367
  bzero(&plugin_dl, sizeof(plugin_dl));
340
368
  /* Compile dll path */
341
369
  dlpathlen=
342
 
    strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", dl->str, NULL) -
 
370
    strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", dl->str, NullS) -
343
371
    dlpath;
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)))
347
375
  {
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);
359
387
    return(0);
360
388
  }
361
 
 
 
389
  /* Determine interface version */
 
390
  if (!(sym= dlsym(plugin_dl.handle, plugin_interface_version_sym)))
 
391
  {
 
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);
 
397
    return(0);
 
398
  }
 
399
  plugin_dl.version= *(int *)sym;
 
400
  /* Versioning */
 
401
  if (plugin_dl.version < min_plugin_interface_version ||
 
402
      (plugin_dl.version >> 8) > (MYSQL_PLUGIN_INTERFACE_VERSION >> 8))
 
403
  {
 
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");
 
411
    return(0);
 
412
  }
362
413
  /* Find plugin declarations */
363
414
  if (!(sym= dlsym(plugin_dl.handle, plugin_declarations_sym)))
364
415
  {
370
421
    return(0);
371
422
  }
372
423
 
 
424
  if (plugin_dl.version != MYSQL_PLUGIN_INTERFACE_VERSION)
 
425
  {
 
426
    int i;
 
427
    uint sizeof_st_plugin;
 
428
    struct st_mysql_plugin *old, *cur;
 
429
    char *ptr= (char *)sym;
 
430
 
 
431
    if ((sym= dlsym(plugin_dl.handle, sizeof_st_plugin_sym)))
 
432
      sizeof_st_plugin= *(int *)sym;
 
433
    else
 
434
    {
 
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);
 
441
      return(0);
 
442
#else
 
443
      /*
 
444
        When the following assert starts failing, we'll have to switch
 
445
        to the upper branch of the #ifdef
 
446
      */
 
447
      assert(min_plugin_interface_version == 0);
 
448
      sizeof_st_plugin= (int)offsetof(struct st_mysql_plugin, version);
 
449
#endif
 
450
    }
 
451
 
 
452
    for (i= 0;
 
453
         ((struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
 
454
         i++)
 
455
      /* no op */;
 
456
 
 
457
    cur= (struct st_mysql_plugin*)
 
458
          my_malloc(i*sizeof(struct st_mysql_plugin), MYF(MY_ZEROFILL|MY_WME));
 
459
    if (!cur)
 
460
    {
 
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);
 
466
      return(0);
 
467
    }
 
468
    /*
 
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.
 
472
    */
 
473
    for (i=0;
 
474
         (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
 
475
         i++)
 
476
      memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
 
477
 
 
478
    sym= cur;
 
479
  }
373
480
  plugin_dl.plugins= (struct st_mysql_plugin *)sym;
374
481
 
375
482
  /* Duplicate and convert dll name */
398
505
    return(0);
399
506
  }
400
507
  return(tmp);
 
508
#else
 
509
  if (report & REPORT_TO_USER)
 
510
    my_error(ER_FEATURE_DISABLED, MYF(0), "plugin", "HAVE_DLOPEN");
 
511
  if (report & REPORT_TO_LOG)
 
512
    sql_print_error(ER(ER_FEATURE_DISABLED), "plugin", "HAVE_DLOPEN");
 
513
  return(0);
 
514
#endif
401
515
}
402
516
 
403
517
 
404
518
static void plugin_dl_del(const LEX_STRING *dl)
405
519
{
406
 
  uint32_t i;
 
520
#ifdef HAVE_DLOPEN
 
521
  uint i;
407
522
 
408
523
  for (i= 0; i < plugin_dl_array.elements; i++)
409
524
  {
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))
416
531
    {
417
532
      /* Do not remove this element, unless no other plugin uses this dll. */
418
533
      if (! --tmp->ref_count)
419
534
      {
420
535
        free_plugin_mem(tmp);
421
 
        memset(tmp, 0, sizeof(struct st_plugin_dl));
 
536
        bzero(tmp, sizeof(struct st_plugin_dl));
422
537
      }
423
538
      break;
424
539
    }
425
540
  }
426
541
  return;
 
542
#endif
427
543
}
428
544
 
429
545
 
430
546
static struct st_plugin_int *plugin_find_internal(const LEX_STRING *name, int type)
431
547
{
432
 
  uint32_t i;
 
548
  uint i;
433
549
  if (! initialized)
434
550
    return(0);
435
551
 
436
 
  if (type == DRIZZLE_ANY_PLUGIN)
 
552
  if (type == MYSQL_ANY_PLUGIN)
437
553
  {
438
 
    for (i= 0; i < DRIZZLE_MAX_PLUGIN_TYPE_NUM; i++)
 
554
    for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
439
555
    {
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);
442
558
      if (plugin)
443
559
        return(plugin);
444
560
    }
445
561
  }
446
562
  else
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));
449
565
  return(0);
450
566
}
451
567
 
499
615
    pi->ref_count++;
500
616
 
501
617
    if (lex)
502
 
      insert_dynamic(&lex->plugins, (unsigned char*)&plugin);
 
618
      insert_dynamic(&lex->plugins, (uchar*)&plugin);
503
619
    return(plugin);
504
620
  }
505
621
  return(NULL);
529
645
 
530
646
static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin)
531
647
{
532
 
  uint32_t i;
 
648
  uint i;
533
649
  struct st_plugin_int *tmp;
534
650
  for (i= 0; i < plugin_array.elements; i++)
535
651
  {
540
656
      return(tmp);
541
657
    }
542
658
  }
543
 
  if (insert_dynamic(&plugin_array, (unsigned char*)&plugin))
 
659
  if (insert_dynamic(&plugin_array, (uchar*)&plugin))
544
660
    return(0);
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));
549
665
  return(tmp);
550
666
}
560
676
{
561
677
  struct st_plugin_int tmp;
562
678
  struct st_mysql_plugin *plugin;
563
 
  if (plugin_find_internal(name, DRIZZLE_ANY_PLUGIN))
 
679
  if (plugin_find_internal(name, MYSQL_ANY_PLUGIN))
564
680
  {
565
681
    if (report & REPORT_TO_USER)
566
682
      my_error(ER_UDF_EXISTS, MYF(0), name->str);
569
685
    return(true);
570
686
  }
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)))
574
690
    return(true);
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++)
577
693
  {
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,
583
699
                       name_len))
584
700
    {
585
701
      struct st_plugin_int *tmp_plugin_ptr;
586
 
 
 
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))
 
706
      {
 
707
        char buf[256];
 
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);
 
715
        goto err;
 
716
      }
587
717
      tmp.plugin= plugin;
588
718
      tmp.name.str= (char *)plugin->name;
589
719
      tmp.name.length= name_len;
594
724
        if ((tmp_plugin_ptr= plugin_insert_or_reuse(&tmp)))
595
725
        {
596
726
          plugin_array_version++;
597
 
          if (!my_hash_insert(&plugin_hash[plugin->type], (unsigned char*)tmp_plugin_ptr))
 
727
          if (!my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr))
598
728
          {
599
729
            init_alloc_root(&tmp_plugin_ptr->mem_root, 4096, 4096);
600
730
            return(false);
645
775
  {
646
776
    if ((*plugin_type_deinitialize[plugin->plugin->type])(plugin))
647
777
    {
648
 
      sql_print_error(_("Plugin '%s' of type %s failed deinitialization"),
 
778
      sql_print_error("Plugin '%s' of type %s failed deinitialization",
649
779
                      plugin->name.str, plugin_type_names[plugin->plugin->type].str);
650
780
    }
651
781
  }
659
789
    exit until NDB is shut down.
660
790
  */
661
791
  if (ref_check && plugin->ref_count)
662
 
    sql_print_error(_("Plugin '%s' has ref_count=%d after deinitialization."),
 
792
    sql_print_error("Plugin '%s' has ref_count=%d after deinitialization.",
663
793
                    plugin->name.str, plugin->ref_count);
664
794
}
665
795
 
668
798
{
669
799
  /* Free allocated strings before deleting the plugin. */
670
800
  plugin_vars_free_values(plugin->system_vars);
671
 
  hash_delete(&plugin_hash[plugin->plugin->type], (unsigned char*)plugin);
 
801
  hash_delete(&plugin_hash[plugin->plugin->type], (uchar*)plugin);
672
802
  if (plugin->plugin_dl)
673
803
    plugin_dl_del(&plugin->plugin_dl->dl);
674
804
  plugin->state= PLUGIN_IS_FREED;
682
812
 
683
813
static void reap_plugins(void)
684
814
{
685
 
  uint32_t count, idx;
 
815
  uint count, idx;
686
816
  struct st_plugin_int *plugin, **reap, **list;
687
817
 
688
818
  if (!reap_needed)
724
854
 
725
855
  pi= plugin_ref_to_int(plugin);
726
856
 
727
 
  free((unsigned char*) plugin);
 
857
  my_free((uchar*) plugin, MYF(MY_WME));
728
858
 
729
859
  if (lex)
730
860
  {
762
892
}
763
893
 
764
894
 
765
 
void plugin_unlock_list(THD *thd, plugin_ref *list, uint32_t count)
 
895
void plugin_unlock_list(THD *thd, plugin_ref *list, uint count)
766
896
{
767
897
  LEX *lex= thd ? thd->lex : 0;
768
898
  assert(list);
779
909
  {
780
910
    if ((*plugin_type_initialize[plugin->plugin->type])(plugin))
781
911
    {
782
 
      sql_print_error(_("Plugin '%s' registration as a %s failed."),
 
912
      sql_print_error("Plugin '%s' registration as a %s failed.",
783
913
                      plugin->name.str, plugin_type_names[plugin->plugin->type].str);
784
914
      goto err;
785
915
    }
788
918
  {
789
919
    if (plugin->plugin->init(plugin))
790
920
    {
791
 
      sql_print_error(_("Plugin '%s' init function returned error."),
 
921
      sql_print_error("Plugin '%s' init function returned error.",
792
922
                      plugin->name.str);
793
923
      goto err;
794
924
    }
839
969
}
840
970
 
841
971
 
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);
844
 
 
845
 
 
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);
 
974
 
 
975
 
 
976
uchar *get_plugin_hash_key(const uchar *buff, size_t *length,
847
977
                           bool not_used __attribute__((unused)))
848
978
{
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);
852
982
}
853
983
 
854
984
 
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)))
857
987
{
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;
861
991
}
862
992
 
863
993
 
870
1000
*/
871
1001
int plugin_init(int *argc, char **argv, int flags)
872
1002
{
873
 
  uint32_t i;
 
1003
  uint i;
874
1004
  struct st_mysql_plugin **builtins;
875
1005
  struct st_mysql_plugin *plugin;
876
1006
  struct st_plugin_int tmp, *plugin_ptr, **reap;
893
1023
                            sizeof(struct st_plugin_int *),16,16))
894
1024
    goto err;
895
1025
 
896
 
  for (i= 0; i < DRIZZLE_MAX_PLUGIN_TYPE_NUM; i++)
 
1026
  for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
897
1027
  {
898
1028
    if (hash_init(&plugin_hash[i], system_charset_info, 16, 0, 0,
899
1029
                  get_plugin_hash_key, NULL, HASH_UNIQUE))
907
1037
  */
908
1038
  for (builtins= mysqld_builtins; *builtins; builtins++)
909
1039
  {
910
 
    for (plugin= *builtins; plugin->name; plugin++)
 
1040
    for (plugin= *builtins; plugin->info; plugin++)
911
1041
    {
912
 
      memset(&tmp, 0, sizeof(tmp));
 
1042
      bzero(&tmp, sizeof(tmp));
913
1043
      tmp.plugin= plugin;
914
1044
      tmp.name.str= (char *)plugin->name;
915
1045
      tmp.name.length= strlen(plugin->name);
928
1058
        initialize the global default storage engine so that it may
929
1059
        not be null in any child thread.
930
1060
      */
931
 
      if (my_strcasecmp(&my_charset_utf8_general_ci, plugin->name, "MyISAM") == 0)
 
1061
      if (my_strcasecmp(&my_charset_latin1, plugin->name, "MyISAM") == 0)
932
1062
      {
933
1063
        assert(!global_system_variables.table_plugin);
934
1064
        global_system_variables.table_plugin=
1003
1133
  tmp->ref_count= 0;
1004
1134
  tmp->plugin_dl= 0;
1005
1135
 
1006
 
  if (insert_dynamic(&plugin_array, (unsigned char*)&tmp))
 
1136
  if (insert_dynamic(&plugin_array, (uchar*)&tmp))
1007
1137
    return(1);
1008
1138
 
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));
1013
1143
 
1014
 
  if (my_hash_insert(&plugin_hash[plugin->type],(unsigned char*) *ptr))
 
1144
  if (my_hash_insert(&plugin_hash[plugin->type],(uchar*) *ptr))
1015
1145
    return(1);
1016
1146
 
1017
1147
  return(0);
1033
1163
  {
1034
1164
    if (p == buffer + sizeof(buffer) - 1)
1035
1165
    {
1036
 
      sql_print_error(_("plugin-load parameter too long"));
 
1166
      sql_print_error("plugin-load parameter too long");
1037
1167
      return(true);
1038
1168
    }
1039
1169
 
1055
1185
        dl= name;
1056
1186
        if ((plugin_dl= plugin_dl_add(&dl, REPORT_TO_LOG)))
1057
1187
        {
1058
 
          for (plugin= plugin_dl->plugins; plugin->name; plugin++)
 
1188
          for (plugin= plugin_dl->plugins; plugin->info; plugin++)
1059
1189
          {
1060
1190
            name.str= (char *) plugin->name;
1061
1191
            name.length= strlen(name.str);
1093
1223
  }
1094
1224
  return(false);
1095
1225
error:
1096
 
  sql_print_error(_("Couldn't load plugin named '%s' with soname '%s'."),
 
1226
  sql_print_error("Couldn't load plugin named '%s' with soname '%s'.",
1097
1227
                  name.str, dl.str);
1098
1228
  return(true);
1099
1229
}
1101
1231
 
1102
1232
void plugin_shutdown(void)
1103
1233
{
1104
 
  uint32_t i, count= plugin_array.elements, free_slots= 0;
 
1234
  uint i, count= plugin_array.elements, free_slots= 0;
1105
1235
  struct st_plugin_int **plugins, *plugin;
1106
1236
  struct st_plugin_dl **dl;
1107
1237
 
1144
1274
    }
1145
1275
 
1146
1276
    if (count > free_slots)
1147
 
      sql_print_warning(_("Forcing shutdown of %d plugins"),
1148
 
                        count - free_slots);
 
1277
      sql_print_warning("Forcing shutdown of %d plugins", count - free_slots);
1149
1278
 
1150
1279
    plugins= (struct st_plugin_int **) my_alloca(sizeof(void*) * (count+1));
1151
1280
 
1166
1295
    for (i= 0; i < count; i++)
1167
1296
      if (!(plugins[i]->state & (PLUGIN_IS_UNINITIALIZED | PLUGIN_IS_FREED)))
1168
1297
      {
1169
 
        sql_print_information(_("Plugin '%s' will be forced to shutdown"),
 
1298
        sql_print_information("Plugin '%s' will be forced to shutdown",
1170
1299
                              plugins[i]->name.str);
1171
1300
        /*
1172
1301
          We are forcing deinit on plugins so we don't want to do a ref_count
1182
1311
    for (i= 0; i < count; i++)
1183
1312
    {
1184
1313
      if (plugins[i]->ref_count)
1185
 
        sql_print_error(_("Plugin '%s' has ref_count=%d after shutdown."),
 
1314
        sql_print_error("Plugin '%s' has ref_count=%d after shutdown.",
1186
1315
                        plugins[i]->name.str, plugins[i]->ref_count);
1187
1316
      if (plugins[i]->state & PLUGIN_IS_UNINITIALIZED)
1188
1317
        plugin_del(plugins[i]);
1202
1331
 
1203
1332
  /* Dispose of the memory */
1204
1333
 
1205
 
  for (i= 0; i < DRIZZLE_MAX_PLUGIN_TYPE_NUM; i++)
 
1334
  for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
1206
1335
    hash_free(&plugin_hash[i]);
1207
1336
  delete_dynamic(&plugin_array);
1208
1337
 
1225
1354
 
1226
1355
 
1227
1356
bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
1228
 
                       int type, uint32_t state_mask, void *arg)
 
1357
                       int type, uint state_mask, void *arg)
1229
1358
{
1230
 
  uint32_t idx, total;
 
1359
  uint idx, total;
1231
1360
  struct st_plugin_int *plugin, **plugins;
1232
1361
  int version=plugin_array_version;
1233
1362
 
1236
1365
 
1237
1366
  state_mask= ~state_mask; // do it only once
1238
1367
 
1239
 
  total= type == DRIZZLE_ANY_PLUGIN ? plugin_array.elements
 
1368
  total= type == MYSQL_ANY_PLUGIN ? plugin_array.elements
1240
1369
                                  : plugin_hash[type].records;
1241
1370
  /*
1242
1371
    Do the alloca out here in case we do have a working alloca:
1243
1372
        leaving the nested stack frame invalidates alloca allocation.
1244
1373
  */
1245
1374
  plugins=(struct st_plugin_int **)my_alloca(total*sizeof(plugin));
1246
 
  if (type == DRIZZLE_ANY_PLUGIN)
 
1375
  if (type == MYSQL_ANY_PLUGIN)
1247
1376
  {
1248
1377
    for (idx= 0; idx < total; idx++)
1249
1378
    {
1264
1393
  {
1265
1394
    if (unlikely(version != plugin_array_version))
1266
1395
    {
1267
 
      for (uint32_t i=idx; i < total; i++)
 
1396
      for (uint i=idx; i < total; i++)
1268
1397
        if (plugins[i] && plugins[i]->state & state_mask)
1269
1398
          plugins[i]=0;
1270
1399
    }
1286
1415
  Internal type declarations for variables support
1287
1416
****************************************************************************/
1288
1417
 
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
1292
1421
 
1293
1422
#define EXTRA_OPTIONS 3 /* options for: 'foo', 'plugin-foo' and NULL */
1294
1423
 
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 *);
1299
 
 
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);
1304
 
 
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);
1311
 
 
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 *);
 
1428
 
 
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);
 
1433
 
 
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);
 
1440
 
 
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);
1318
1447
 
1319
1448
typedef bool *(*mysql_sys_var_ptr_p)(THD* a_thd, int offset);
1320
1449
 
1323
1452
  default variable data check and update functions
1324
1453
****************************************************************************/
1325
1454
 
1326
 
static int check_func_bool(THD *thd __attribute__((unused)),
 
1455
static int check_func_bool(THD *thd __attribute__((__unused__)),
1327
1456
                           struct st_mysql_sys_var *var,
1328
1457
                           void *save, st_mysql_value *value)
1329
1458
{
1332
1461
  int result, length;
1333
1462
  int64_t tmp;
1334
1463
 
1335
 
  if (value->value_type(value) == DRIZZLE_VALUE_TYPE_STRING)
 
1464
  if (value->value_type(value) == MYSQL_VALUE_TYPE_STRING)
1336
1465
  {
1337
1466
    length= sizeof(buff);
1338
1467
    if (!(str= value->val_str(value, buff, &length)) ||
1373
1502
  plugin_opt_set_limits(&options, var);
1374
1503
 
1375
1504
  if (var->flags & PLUGIN_VAR_UNSIGNED)
1376
 
    *(uint32_t *)save= (uint) getopt_ull_limit_value((uint64_t) tmp, &options,
 
1505
    *(uint *)save= (uint) getopt_ull_limit_value((uint64_t) tmp, &options,
1377
1506
                                                   &fixed);
1378
1507
  else
1379
1508
    *(int *)save= (int) getopt_ll_limit_value(tmp, &options, &fixed);
1423
1552
}
1424
1553
 
1425
1554
static int check_func_str(THD *thd,
1426
 
                          struct st_mysql_sys_var *var __attribute__((unused)),
 
1555
                          struct st_mysql_sys_var *var __attribute__((__unused__)),
1427
1556
                          void *save, st_mysql_value *value)
1428
1557
{
1429
1558
  char buff[STRING_BUFFER_USUAL_SIZE];
1438
1567
}
1439
1568
 
1440
1569
 
1441
 
static int check_func_enum(THD *thd __attribute__((unused)),
 
1570
static int check_func_enum(THD *thd __attribute__((__unused__)),
1442
1571
                           struct st_mysql_sys_var *var,
1443
1572
                           void *save, st_mysql_value *value)
1444
1573
{
1454
1583
  else
1455
1584
    typelib= ((sysvar_enum_t*) var)->typelib;
1456
1585
 
1457
 
  if (value->value_type(value) == DRIZZLE_VALUE_TYPE_STRING)
 
1586
  if (value->value_type(value) == MYSQL_VALUE_TYPE_STRING)
1458
1587
  {
1459
1588
    length= sizeof(buff);
1460
1589
    if (!(str= value->val_str(value, buff, &length)))
1485
1614
}
1486
1615
 
1487
1616
 
1488
 
static int check_func_set(THD *thd __attribute__((unused)),
 
1617
static int check_func_set(THD *thd __attribute__((__unused__)),
1489
1618
                          struct st_mysql_sys_var *var,
1490
1619
                          void *save, st_mysql_value *value)
1491
1620
{
1493
1622
  const char *strvalue= "NULL", *str;
1494
1623
  TYPELIB *typelib;
1495
1624
  uint64_t result;
1496
 
  uint32_t error_len;
 
1625
  uint error_len;
1497
1626
  bool not_used;
1498
1627
  int length;
1499
1628
 
1502
1631
  else
1503
1632
    typelib= ((sysvar_set_t*)var)->typelib;
1504
1633
 
1505
 
  if (value->value_type(value) == DRIZZLE_VALUE_TYPE_STRING)
 
1634
  if (value->value_type(value) == MYSQL_VALUE_TYPE_STRING)
1506
1635
  {
1507
1636
    length= sizeof(buff);
1508
1637
    if (!(str= value->val_str(value, buff, &length)))
1511
1640
                     &error, &error_len, &not_used);
1512
1641
    if (error_len)
1513
1642
    {
1514
 
      strmake(buff, error, cmin(sizeof(buff), (unsigned long)error_len));
 
1643
      strmake(buff, error, min(sizeof(buff), error_len));
1515
1644
      strvalue= buff;
1516
1645
      goto err;
1517
1646
    }
1520
1649
  {
1521
1650
    if (value->val_int(value, (int64_t *)&result))
1522
1651
      goto err;
1523
 
    if (unlikely((result >= (1UL << typelib->count)) &&
 
1652
    if (unlikely((result >= (1ULL << typelib->count)) &&
1524
1653
                 (typelib->count < sizeof(long)*8)))
1525
1654
    {
1526
1655
      llstr(result, buff);
1536
1665
}
1537
1666
 
1538
1667
 
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)
1542
1671
{
1543
 
  *(bool *) tgt= *(int *) save ? 1 : 0;
 
1672
  *(my_bool *) tgt= *(int *) save ? 1 : 0;
1544
1673
}
1545
1674
 
1546
1675
 
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)
1550
1679
{
1551
1680
  *(int *)tgt= *(int *) save;
1552
1681
}
1553
1682
 
1554
1683
 
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)
1558
1687
{
1559
1688
  *(long *)tgt= *(long *) save;
1560
1689
}
1561
1690
 
1562
1691
 
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)
1566
1695
{
1567
1696
  *(int64_t *)tgt= *(uint64_t *) save;
1568
1697
}
1569
1698
 
1570
1699
 
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)
1573
1702
{
1574
1703
  char *old= *(char **) tgt;
1576
1705
  if (var->flags & PLUGIN_VAR_MEMALLOC)
1577
1706
  {
1578
1707
    *(char **)tgt= my_strdup(*(char **) save, MYF(0));
1579
 
    free(old);
 
1708
    my_free(old, MYF(0));
1580
1709
  }
1581
1710
}
1582
1711
 
1586
1715
****************************************************************************/
1587
1716
 
1588
1717
 
1589
 
sys_var *find_sys_var(THD *thd, const char *str, uint32_t length)
 
1718
sys_var *find_sys_var(THD *thd, const char *str, uint length)
1590
1719
{
1591
1720
  sys_var *var;
1592
1721
  sys_var_pluginvar *pi= NULL;
1629
1758
static st_bookmark *find_bookmark(const char *plugin, const char *name, int flags)
1630
1759
{
1631
1760
  st_bookmark *result= NULL;
1632
 
  uint32_t namelen, length, pluginlen= 0;
 
1761
  uint namelen, length, pluginlen= 0;
1633
1762
  char *varname, *p;
1634
1763
 
1635
1764
  if (!(flags & PLUGIN_VAR_THDLOCAL))
1643
1772
 
1644
1773
  if (plugin)
1645
1774
  {
1646
 
    strxmov(varname + 1, plugin, "_", name, NULL);
 
1775
    strxmov(varname + 1, plugin, "_", name, NullS);
1647
1776
    for (p= varname + 1; *p; p++)
1648
1777
      if (*p == '-')
1649
1778
        *p= '_';
1654
1783
  varname[0]= flags & PLUGIN_VAR_TYPEMASK;
1655
1784
 
1656
1785
  result= (st_bookmark*) hash_search(&bookmark_hash,
1657
 
                                     (const unsigned char*) varname, length - 1);
 
1786
                                     (const uchar*) varname, length - 1);
1658
1787
 
1659
1788
  my_afree(varname);
1660
1789
  return result;
1669
1798
static st_bookmark *register_var(const char *plugin, const char *name,
1670
1799
                                 int flags)
1671
1800
{
1672
 
  uint32_t length= strlen(plugin) + strlen(name) + 3, size= 0, offset, new_size;
 
1801
  uint length= strlen(plugin) + strlen(name) + 3, size= 0, offset, new_size;
1673
1802
  st_bookmark *result;
1674
1803
  char *varname, *p;
1675
1804
 
1678
1807
 
1679
1808
  switch (flags & PLUGIN_VAR_TYPEMASK) {
1680
1809
  case PLUGIN_VAR_BOOL:
1681
 
    size= sizeof(bool);
 
1810
    size= sizeof(my_bool);
1682
1811
    break;
1683
1812
  case PLUGIN_VAR_INT:
1684
1813
    size= sizeof(int);
1700
1829
  };
1701
1830
 
1702
1831
  varname= ((char*) my_alloca(length));
1703
 
  strxmov(varname + 1, plugin, "_", name, NULL);
 
1832
  strxmov(varname + 1, plugin, "_", name, NullS);
1704
1833
  for (p= varname + 1; *p; p++)
1705
1834
    if (*p == '-')
1706
1835
      *p= '_';
1735
1864
        variables. If their value is non-NULL, it must point to a valid
1736
1865
        string.
1737
1866
      */
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;
1745
1874
    }
1746
1875
 
1754
1883
    result->version= global_system_variables.dynamic_variables_version;
1755
1884
 
1756
1885
    /* this should succeed because we have already checked if a dup exists */
1757
 
    if (my_hash_insert(&bookmark_hash, (unsigned char*) result))
 
1886
    if (my_hash_insert(&bookmark_hash, (uchar*) result))
1758
1887
    {
1759
1888
      fprintf(stderr, "failed to add placeholder to hash");
1760
1889
      assert(0);
1771
1900
  If required, will sync with global variables if the requested variable
1772
1901
  has not yet been allocated in the current thread.
1773
1902
*/
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)
1775
1904
{
1776
1905
  assert(offset >= 0);
1777
1906
  assert((uint)offset <= global_system_variables.dynamic_variables_head);
1778
1907
 
1779
1908
  if (!thd)
1780
 
    return (unsigned char*) global_system_variables.dynamic_variables_ptr + offset;
 
1909
    return (uchar*) global_system_variables.dynamic_variables_ptr + offset;
1781
1910
 
1782
1911
  /*
1783
1912
    dynamic_variables_head points to the largest valid offset
1785
1914
  if (!thd->variables.dynamic_variables_ptr ||
1786
1915
      (uint)offset > thd->variables.dynamic_variables_head)
1787
1916
  {
1788
 
    uint32_t idx;
 
1917
    uint idx;
1789
1918
 
1790
1919
    rw_rdlock(&LOCK_system_variables_hash);
1791
1920
 
1847
1976
 
1848
1977
    rw_unlock(&LOCK_system_variables_hash);
1849
1978
  }
1850
 
  return (unsigned char*)thd->variables.dynamic_variables_ptr + offset;
 
1979
  return (uchar*)thd->variables.dynamic_variables_ptr + offset;
1851
1980
}
1852
1981
 
1853
1982
static bool *mysql_sys_var_ptr_bool(THD* a_thd, int offset)
1911
2040
/*
1912
2041
  Unlocks all system variables which hold a reference
1913
2042
*/
1914
 
static void unlock_variables(THD *thd __attribute__((unused)),
 
2043
static void unlock_variables(THD *thd __attribute__((__unused__)),
1915
2044
                             struct system_variables *vars)
1916
2045
{
1917
2046
  intern_plugin_unlock(NULL, vars->table_plugin);
1931
2060
  sys_var_pluginvar *pivar;
1932
2061
  sys_var *var;
1933
2062
  int flags;
1934
 
  uint32_t idx;
 
2063
  uint idx;
1935
2064
 
1936
2065
  rw_rdlock(&LOCK_system_variables_hash);
1937
2066
  for (idx= 0; idx < bookmark_hash.records; idx++)
1949
2078
        flags & PLUGIN_VAR_THDLOCAL && flags & PLUGIN_VAR_MEMALLOC)
1950
2079
    {
1951
2080
      char **ptr= (char**) pivar->real_value_ptr(thd, OPT_SESSION);
1952
 
      free(*ptr);
 
2081
      my_free(*ptr, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
1953
2082
      *ptr= NULL;
1954
2083
    }
1955
2084
  }
1957
2086
 
1958
2087
  assert(vars->table_plugin == NULL);
1959
2088
 
1960
 
  free(vars->dynamic_variables_ptr);
 
2089
  my_free(vars->dynamic_variables_ptr, MYF(MY_ALLOW_ZERO_PTR));
1961
2090
  vars->dynamic_variables_ptr= NULL;
1962
2091
  vars->dynamic_variables_size= 0;
1963
2092
  vars->dynamic_variables_version= 0;
1966
2095
 
1967
2096
void plugin_thdvar_cleanup(THD *thd)
1968
2097
{
1969
 
  uint32_t idx;
 
2098
  uint idx;
1970
2099
  plugin_ref *list;
1971
2100
 
1972
2101
  unlock_variables(thd, &thd->variables);
1975
2104
  if ((idx= thd->lex->plugins.elements))
1976
2105
  {
1977
2106
    list= ((plugin_ref*) thd->lex->plugins.buffer) + idx - 1;
1978
 
    while ((unsigned char*) list >= thd->lex->plugins.buffer)
 
2107
    while ((uchar*) list >= thd->lex->plugins.buffer)
1979
2108
      intern_plugin_unlock(NULL, *list--);
1980
2109
  }
1981
2110
 
2008
2137
    {
2009
2138
      /* Free the string from global_system_variables. */
2010
2139
      char **valptr= (char**) piv->real_value_ptr(NULL, OPT_GLOBAL);
2011
 
      free(*valptr);
 
2140
      my_free(*valptr, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
2012
2141
      *valptr= NULL;
2013
2142
    }
2014
2143
  }
2056
2185
}
2057
2186
 
2058
2187
 
2059
 
unsigned char* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type)
 
2188
uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type)
2060
2189
{
2061
2190
  assert(thd || (type == OPT_GLOBAL));
2062
2191
  if (plugin_var->flags & PLUGIN_VAR_THDLOCAL)
2066
2195
 
2067
2196
    return intern_sys_var_ptr(thd, *(int*) (plugin_var+1), false);
2068
2197
  }
2069
 
  return *(unsigned char**) (plugin_var+1);
 
2198
  return *(uchar**) (plugin_var+1);
2070
2199
}
2071
2200
 
2072
2201
 
2088
2217
}
2089
2218
 
2090
2219
 
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__)))
2093
2222
{
2094
 
  unsigned char* result;
 
2223
  uchar* result;
2095
2224
 
2096
2225
  result= real_value_ptr(thd, type);
2097
2226
 
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)
2101
2230
  {
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;
2106
 
    uint32_t i;
 
2235
    uint i;
2107
2236
 
2108
2237
    str.length(0);
2109
2238
    for (i= 0; i < typelib->count; i++, mask<<=1)
2114
2243
      str.append(',');
2115
2244
    }
2116
2245
 
2117
 
    result= (unsigned char*) "";
 
2246
    result= (uchar*) "";
2118
2247
    if (str.length())
2119
 
      result= (unsigned char*) thd->strmake(str.ptr(), str.length()-1);
 
2248
      result= (uchar*) thd->strmake(str.ptr(), str.length()-1);
2120
2249
  }
2121
2250
  return result;
2122
2251
}
2233
2362
 
2234
2363
 
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
2241
2370
 
2242
2371
 
2278
2407
    options->typelib= ((sysvar_set_t*) opt)->typelib;
2279
2408
    options->def_value= ((sysvar_set_t*) opt)->def_val;
2280
2409
    options->min_value= options->block_size= 0;
2281
 
    options->max_value= (1UL << options->typelib->count) - 1;
 
2410
    options->max_value= (1ULL << options->typelib->count) - 1;
2282
2411
    break;
2283
2412
  case PLUGIN_VAR_BOOL:
2284
2413
    options->var_type= GET_BOOL;
2320
2449
    options->typelib= ((thdvar_set_t*) opt)->typelib;
2321
2450
    options->def_value= ((thdvar_set_t*) opt)->def_val;
2322
2451
    options->min_value= options->block_size= 0;
2323
 
    options->max_value= (1UL << options->typelib->count) - 1;
 
2452
    options->max_value= (1ULL << options->typelib->count) - 1;
2324
2453
    break;
2325
2454
  case PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL:
2326
2455
    options->var_type= GET_BOOL;
2345
2474
                                         char *);
2346
2475
 
2347
2476
bool get_one_plugin_option(int optid __attribute__((unused)),
2348
 
                              const struct my_option *opt __attribute__((unused)),
2349
 
                              char *argument __attribute__((unused)))
 
2477
                              const struct my_option *opt __attribute__((__unused__)),
 
2478
                              char *argument __attribute__((__unused__)))
2350
2479
{
2351
2480
  return 0;
2352
2481
}
2356
2485
                             my_option *options, bool can_disable)
2357
2486
{
2358
2487
  const char *plugin_name= tmp->plugin->name;
2359
 
  uint32_t namelen= strlen(plugin_name), optnamelen;
2360
 
  uint32_t buffer_length= namelen * 4 + (can_disable ? 75 : 10);
 
2488
  uint namelen= strlen(plugin_name), optnamelen;
 
2489
  uint buffer_length= namelen * 4 + (can_disable ? 75 : 10);
2361
2490
  char *name= (char*) alloc_root(mem_root, buffer_length) + 1;
2362
2491
  char *optname, *p;
2363
2492
  int index= 0, offset= 0;
2366
2495
 
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. */
2372
2501
 
2373
2502
  for (p= name + namelen*2 + 8; p > name; p--)
2377
2506
  if (can_disable)
2378
2507
  {
2379
2508
    strxmov(name + namelen*2 + 10, "Enable ", plugin_name, " plugin. "
2380
 
            "Disable with --skip-", name," (will save memory).", NULL);
 
2509
            "Disable with --skip-", name," (will save memory).", NullS);
2381
2510
    /*
2382
2511
      Now we have namelen * 2 + 10 (one char unused) + 7 + namelen + 9 +
2383
2512
      20 + namelen + 20 + 1 == namelen * 4 + 67.
2431
2560
      (((thdvar_set_t *)opt)->resolve)= mysql_sys_var_ptr_set;
2432
2561
      break;
2433
2562
    default:
2434
 
      sql_print_error(_("Unknown variable type code 0x%x in plugin '%s'."),
 
2563
      sql_print_error("Unknown variable type code 0x%x in plugin '%s'.",
2435
2564
                      opt->flags, plugin_name);
2436
2565
      return(-1);
2437
2566
    };
2474
2603
        if ((opt->flags & (PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY)) == false)
2475
2604
        {
2476
2605
          opt->flags|= PLUGIN_VAR_READONLY;
2477
 
          sql_print_warning(_("Server variable %s of plugin %s was forced "
 
2606
          sql_print_warning("Server variable %s of plugin %s was forced "
2478
2607
                            "to be read-only: string variable without "
2479
 
                            "update_func and PLUGIN_VAR_MEMALLOC flag"),
 
2608
                            "update_func and PLUGIN_VAR_MEMALLOC flag",
2480
2609
                            opt->name, plugin_name);
2481
2610
        }
2482
2611
      }
2494
2623
        opt->update= update_func_int64_t;
2495
2624
      break;
2496
2625
    default:
2497
 
      sql_print_error(_("Unknown variable type code 0x%x in plugin '%s'."),
 
2626
      sql_print_error("Unknown variable type code 0x%x in plugin '%s'.",
2498
2627
                      opt->flags, plugin_name);
2499
2628
      return(-1);
2500
2629
    }
2505
2634
 
2506
2635
    if (!opt->name)
2507
2636
    {
2508
 
      sql_print_error(_("Missing variable name in plugin '%s'."),
 
2637
      sql_print_error("Missing variable name in plugin '%s'.",
2509
2638
                      plugin_name);
2510
2639
      return(-1);
2511
2640
    }
2514
2643
    {
2515
2644
      optnamelen= strlen(opt->name);
2516
2645
      optname= (char*) alloc_root(mem_root, namelen + optnamelen + 2);
2517
 
      strxmov(optname, name, "-", opt->name, NULL);
 
2646
      strxmov(optname, name, "-", opt->name, NullS);
2518
2647
      optnamelen= namelen + optnamelen + 1;
2519
2648
    }
2520
2649
    else
2522
2651
      /* this should not fail because register_var should create entry */
2523
2652
      if (!(v= find_bookmark(name, opt->name, opt->flags)))
2524
2653
      {
2525
 
        sql_print_error(_("Thread local variable '%s' not allocated "
2526
 
                        "in plugin '%s'."), opt->name, plugin_name);
 
2654
        sql_print_error("Thread local variable '%s' not allocated "
 
2655
                        "in plugin '%s'.", opt->name, plugin_name);
2527
2656
        return(-1);
2528
2657
      }
2529
2658
 
2557
2686
    options[1]= options[0];
2558
2687
    options[1].name= p= (char*) alloc_root(mem_root, optnamelen + 8);
2559
2688
    options[1].comment= 0; // hidden
2560
 
    strxmov(p, "plugin-", optname, NULL);
 
2689
    strxmov(p, "plugin-", optname, NullS);
2561
2690
 
2562
2691
    options+= 2;
2563
2692
  }
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;
2576
2705
 
2577
2706
  for (opt= p->plugin->system_vars; opt && *opt; opt++, count+= 2) {};
2578
2707
 
2579
2708
  if (!(opts= (my_option*) alloc_root(mem_root, sizeof(my_option) * count)))
2580
2709
    return(NULL);
2581
2710
 
2582
 
  memset(opts, 0, sizeof(my_option) * count);
 
2711
  bzero(opts, sizeof(my_option) * count);
2583
2712
 
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;
2588
2717
  else
2589
2718
    can_disable= true;
2624
2753
  st_mysql_sys_var *o;
2625
2754
  sys_var *v;
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);
2629
2758
 
2630
2759
  for (opt= tmp->plugin->system_vars; opt && *opt; opt++)
2631
2760
    count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */
2632
2761
 
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;
2637
2766
  else
2638
2767
    can_disable= true;
2641
2770
  {
2642
2771
    if (!(opts= (my_option*) alloc_root(tmp_root, sizeof(my_option) * count)))
2643
2772
    {
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);
2645
2774
      return(-1);
2646
2775
    }
2647
 
    memset(opts, 0, sizeof(my_option) * count);
 
2776
    bzero(opts, sizeof(my_option) * count);
2648
2777
 
2649
2778
    if (construct_options(tmp_root, tmp, opts, can_disable))
2650
2779
    {
2651
 
      sql_print_error(_("Bad options for plugin '%s'."), tmp->name.str);
 
2780
      sql_print_error("Bad options for plugin '%s'.", tmp->name.str);
2652
2781
      return(-1);
2653
2782
    }
2654
2783
 
2657
2786
 
2658
2787
    if (error)
2659
2788
    {
2660
 
       sql_print_error(_("Parsing options for plugin '%s' failed."),
 
2789
       sql_print_error("Parsing options for plugin '%s' failed.",
2661
2790
                       tmp->name.str);
2662
2791
       goto err;
2663
2792
    }
2677
2806
      {
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);
2682
2811
 
2683
2812
        for (p= varname; *p; p++)
2684
2813
          if (*p == '-')
2700
2829
      chain.last->next = NULL;
2701
2830
      if (mysql_add_sys_var_chain(chain.first, NULL))
2702
2831
      {
2703
 
        sql_print_error(_("Plugin '%s' has conflicting system variables"),
 
2832
        sql_print_error("Plugin '%s' has conflicting system variables",
2704
2833
                        tmp->name.str);
2705
2834
        goto err;
2706
2835
      }
2710
2839
  }
2711
2840
 
2712
2841
  if (enabled_saved && global_system_variables.log_warnings)
2713
 
    sql_print_information(_("Plugin '%s' disabled by command line option"),
 
2842
    sql_print_information("Plugin '%s' disabled by command line option",
2714
2843
                          tmp->name.str);
2715
2844
err:
2716
2845
  if (opts)
2725
2854
 
2726
2855
static int option_cmp(my_option *a, my_option *b)
2727
2856
{
2728
 
  return my_strcasecmp(&my_charset_utf8_general_ci, a->name, b->name);
 
2857
  return my_strcasecmp(&my_charset_latin1, a->name, b->name);
2729
2858
}
2730
2859
 
2731
2860
 
2732
 
void my_print_help_inc_plugins(my_option *main_options, uint32_t size)
 
2861
void my_print_help_inc_plugins(my_option *main_options, uint size)
2733
2862
{
2734
2863
  DYNAMIC_ARRAY all_options;
2735
2864
  struct st_plugin_int *p;
2740
2869
  my_init_dynamic_array(&all_options, sizeof(my_option), size, size/4);
2741
2870
 
2742
2871
  if (initialized)
2743
 
    for (uint32_t idx= 0; idx < plugin_array.elements; idx++)
 
2872
    for (uint idx= 0; idx < plugin_array.elements; idx++)
2744
2873
    {
2745
2874
      p= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);
2746
2875
 
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);
2755
2884
    }
2756
2885
 
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);
2759
2888
 
2760
2889
  sort_dynamic(&all_options, (qsort_cmp) option_cmp);
2761
2890
 
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);
2764
2893
 
2765
2894
  my_print_help((my_option*) all_options.buffer);
2766
2895
  my_print_variables((my_option*) all_options.buffer);