~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/set_var.cc

  • Committer: Brian Aker
  • Date: 2008-07-14 16:24:25 UTC
  • Revision ID: brian@tangent.org-20080714162425-juw3vw221gs9kysh
Cleanup around intptr_t

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    them you must first assign a value to them (in specific ::check() for
47
47
    example).
48
48
*/
49
 
#include <drizzled/server_includes.h>
 
49
 
 
50
#ifdef USE_PRAGMA_IMPLEMENTATION
 
51
#pragma implementation                          // gcc: Class implementation
 
52
#endif
 
53
 
 
54
#include "mysql_priv.h"
 
55
#include "slave.h"
50
56
#include "rpl_mi.h"
51
 
#include <mysys/my_getopt.h>
52
 
#include <mysys/thr_alarm.h>
53
 
#include <storage/myisam/myisam.h>
54
 
#include <drizzled/drizzled_error_messages.h>
55
 
#include <libdrizzle/gettext.h>
 
57
#include <my_getopt.h>
 
58
#include <thr_alarm.h>
 
59
#include <myisam.h>
 
60
#include <my_dir.h>
56
61
 
57
 
extern const CHARSET_INFO *character_set_filesystem;
 
62
extern CHARSET_INFO *character_set_filesystem;
58
63
 
59
64
 
60
65
static DYNAMIC_ARRAY fixed_show_vars;
61
66
static HASH system_variable_hash;
62
67
 
63
 
const char *bool_type_names[]= { "OFF", "ON", NULL };
 
68
const char *bool_type_names[]= { "OFF", "ON", NullS };
64
69
TYPELIB bool_typelib=
65
70
{
66
71
  array_elements(bool_type_names)-1, "", bool_type_names, NULL
67
72
};
68
73
 
69
 
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NULL };
 
74
const char *delay_key_write_type_names[]= { "OFF", "ON", "ALL", NullS };
70
75
TYPELIB delay_key_write_typelib=
71
76
{
72
77
  array_elements(delay_key_write_type_names)-1, "",
74
79
};
75
80
 
76
81
const char *slave_exec_mode_names[]=
77
 
{ "STRICT", "IDEMPOTENT", NULL };
 
82
{ "STRICT", "IDEMPOTENT", NullS };
78
83
static const unsigned int slave_exec_mode_names_len[]=
79
84
{ sizeof("STRICT") - 1, sizeof("IDEMPOTENT") - 1, 0 };
80
85
TYPELIB slave_exec_mode_typelib=
90
95
static bool set_option_bit(THD *thd, set_var *var);
91
96
static bool set_option_autocommit(THD *thd, set_var *var);
92
97
static int  check_log_update(THD *thd, set_var *var);
 
98
static bool set_log_update(THD *thd, set_var *var);
93
99
static int  check_pseudo_thread_id(THD *thd, set_var *var);
94
100
static void fix_low_priority_updates(THD *thd, enum_var_type type);
95
101
static int check_tx_isolation(THD *thd, set_var *var);
111
117
static bool get_unsigned(THD *thd, set_var *var);
112
118
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
113
119
                          const char *name, int64_t val);
114
 
static KEY_CACHE *create_key_cache(const char *name, uint32_t length);
115
 
static unsigned char *get_error_count(THD *thd);
116
 
static unsigned char *get_warning_count(THD *thd);
117
 
static unsigned char *get_tmpdir(THD *thd);
 
120
static KEY_CACHE *create_key_cache(const char *name, uint length);
 
121
static uchar *get_error_count(THD *thd);
 
122
static uchar *get_warning_count(THD *thd);
 
123
static uchar *get_tmpdir(THD *thd);
 
124
static int  sys_check_log_path(THD *thd,  set_var *var);
 
125
static bool sys_update_general_log_path(THD *thd, set_var * var);
 
126
static void sys_default_general_log_path(THD *thd, enum_var_type type);
 
127
static bool sys_update_slow_log_path(THD *thd, set_var * var);
 
128
static void sys_default_slow_log_path(THD *thd, enum_var_type type);
118
129
 
119
130
/*
120
131
  Variable definition list
185
196
sys_collation_server(&vars, "collation_server", &SV::collation_server,
186
197
                     &default_charset_info,
187
198
                     sys_var::SESSION_VARIABLE_IN_BINLOG);
 
199
static sys_var_long_ptr sys_concurrent_insert(&vars, "concurrent_insert",
 
200
                                              &myisam_concurrent_insert);
188
201
static sys_var_long_ptr sys_connect_timeout(&vars, "connect_timeout",
189
202
                                            &connect_timeout);
190
203
static sys_var_const_str       sys_datadir(&vars, "datadir", mysql_real_data_home);
196
209
static sys_var_long_ptr sys_expire_logs_days(&vars, "expire_logs_days",
197
210
                                             &expire_logs_days);
198
211
static sys_var_bool_ptr sys_flush(&vars, "flush", &myisam_flush);
 
212
static sys_var_long_ptr sys_flush_time(&vars, "flush_time", &flush_time);
199
213
sys_var_str             sys_init_connect(&vars, "init_connect", 0,
200
214
                                         sys_update_init_connect,
201
215
                                         sys_default_init_connect,0);
218
232
                                                              param_age_threshold));
219
233
static sys_var_bool_ptr sys_local_infile(&vars, "local_infile",
220
234
                                         &opt_local_infile);
 
235
static sys_var_bool_ptr
 
236
  sys_log_queries_not_using_indexes(&vars, "log_queries_not_using_indexes",
 
237
                                    &opt_log_queries_not_using_indexes);
 
238
static sys_var_thd_ulong        sys_log_warnings(&vars, "log_warnings", &SV::log_warnings);
 
239
static sys_var_microseconds     sys_var_long_query_time(&vars, "long_query_time",
 
240
                                                        &SV::long_query_time);
221
241
static sys_var_thd_bool sys_low_priority_updates(&vars, "low_priority_updates",
222
242
                                                 &SV::low_priority_updates,
223
243
                                                 fix_low_priority_updates);
253
273
                                              &SV::max_seeks_for_key);
254
274
static sys_var_thd_ulong   sys_max_length_for_sort_data(&vars, "max_length_for_sort_data",
255
275
                                                 &SV::max_length_for_sort_data);
 
276
#ifndef TO_BE_DELETED   /* Alias for max_join_size */
 
277
static sys_var_thd_ha_rows      sys_sql_max_join_size(&vars, "sql_max_join_size",
 
278
                                              &SV::max_join_size,
 
279
                                              fix_max_join_size);
 
280
#endif
256
281
static sys_var_long_ptr sys_max_relay_log_size(&vars, "max_relay_log_size",
257
282
                                               &max_relay_log_size,
258
283
                                               fix_max_relay_log_size);
265
290
                                                 &max_write_lock_count);
266
291
static sys_var_thd_ulong       sys_min_examined_row_limit(&vars, "min_examined_row_limit",
267
292
                                                          &SV::min_examined_row_limit);
 
293
static sys_var_long_ptr sys_myisam_data_pointer_size(&vars, "myisam_data_pointer_size",
 
294
                                                    &myisam_data_pointer_size);
268
295
static sys_var_thd_uint64_t     sys_myisam_max_sort_file_size(&vars, "myisam_max_sort_file_size", &SV::myisam_max_sort_file_size, fix_myisam_max_sort_file_size, 1);
269
296
static sys_var_thd_ulong       sys_myisam_repair_threads(&vars, "myisam_repair_threads", &SV::myisam_repair_threads);
270
297
static sys_var_thd_ulong        sys_myisam_sort_buffer_size(&vars, "myisam_sort_buffer_size", &SV::myisam_sort_buff_size);
295
322
static sys_var_thd_ulong        sys_optimizer_search_depth(&vars, "optimizer_search_depth",
296
323
                                                   &SV::optimizer_search_depth);
297
324
 
298
 
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NULL};
 
325
const char *optimizer_use_mrr_names[] = {"auto", "force", "disable", NullS};
299
326
TYPELIB optimizer_use_mrr_typelib= {
300
327
  array_elements(optimizer_use_mrr_names) - 1, "",
301
328
  optimizer_use_mrr_names, NULL
340
367
static sys_var_long_ptr sys_server_id(&vars, "server_id", &server_id, fix_server_id);
341
368
static sys_var_bool_ptr sys_slave_compressed_protocol(&vars, "slave_compressed_protocol",
342
369
                                                      &opt_slave_compressed_protocol);
 
370
#ifdef HAVE_REPLICATION
343
371
static sys_var_bool_ptr         sys_slave_allow_batching(&vars, "slave_allow_batching",
344
372
                                                         &slave_allow_batching);
345
373
static sys_var_set_slave_mode slave_exec_mode(&vars,
347
375
                                              &slave_exec_mode_options,
348
376
                                              &slave_exec_mode_typelib,
349
377
                                              0);
 
378
#endif
350
379
static sys_var_long_ptr sys_slow_launch_time(&vars, "slow_launch_time",
351
380
                                             &slow_launch_time);
352
381
static sys_var_thd_ulong        sys_sort_buffer(&vars, "sort_buffer_size",
359
388
*/
360
389
static sys_var_thd_optimizer_switch   sys_optimizer_switch(&vars, "optimizer_switch",
361
390
                                     &SV::optimizer_switch);
 
391
static sys_var_const_str        sys_ssl_ca(&vars, "ssl_ca", NULL);
 
392
static sys_var_const_str        sys_ssl_capath(&vars, "ssl_capath", NULL);
 
393
static sys_var_const_str        sys_ssl_cert(&vars, "ssl_cert", NULL);
 
394
static sys_var_const_str        sys_ssl_cipher(&vars, "ssl_cipher", NULL);
 
395
static sys_var_const_str        sys_ssl_key(&vars, "ssl_key", NULL);
362
396
 
363
397
static sys_var_thd_storage_engine sys_storage_engine(&vars, "storage_engine",
364
398
                                       &SV::table_plugin);
 
399
static sys_var_bool_ptr sys_sync_frm(&vars, "sync_frm", &opt_sync_frm);
365
400
static sys_var_const_str        sys_system_time_zone(&vars, "system_time_zone",
366
401
                                             system_time_zone);
367
402
static sys_var_long_ptr sys_table_def_size(&vars, "table_definition_cache",
384
419
static sys_var_bool_ptr  sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
385
420
static sys_var_const_str        sys_version(&vars, "version", server_version);
386
421
static sys_var_const_str        sys_version_comment(&vars, "version_comment",
387
 
                                            DRIZZLE_COMPILATION_COMMENT);
 
422
                                            MYSQL_COMPILATION_COMMENT);
388
423
static sys_var_const_str        sys_version_compile_machine(&vars, "version_compile_machine",
389
424
                                                    MACHINE_TYPE);
390
425
static sys_var_const_str        sys_version_compile_os(&vars, "version_compile_os",
401
436
 
402
437
static sys_var_thd_date_time_format sys_time_format(&vars, "time_format",
403
438
                                             &SV::time_format,
404
 
                                             DRIZZLE_TIMESTAMP_TIME);
 
439
                                             MYSQL_TIMESTAMP_TIME);
405
440
static sys_var_thd_date_time_format sys_date_format(&vars, "date_format",
406
441
                                             &SV::date_format,
407
 
                                             DRIZZLE_TIMESTAMP_DATE);
 
442
                                             MYSQL_TIMESTAMP_DATE);
408
443
static sys_var_thd_date_time_format sys_datetime_format(&vars, "datetime_format",
409
444
                                                 &SV::datetime_format,
410
 
                                                 DRIZZLE_TIMESTAMP_DATETIME);
 
445
                                                 MYSQL_TIMESTAMP_DATETIME);
411
446
 
412
447
/* Variables that are bits in THD */
413
448
 
426
461
static sys_var_thd_bit  sys_big_selects(&vars, "sql_big_selects", 0,
427
462
                                        set_option_bit,
428
463
                                        OPTION_BIG_SELECTS);
 
464
static sys_var_thd_bit  sys_log_off(&vars, "sql_log_off",
 
465
                                    check_log_update,
 
466
                                    set_option_bit,
 
467
                                    OPTION_LOG_OFF);
 
468
static sys_var_thd_bit  sys_log_update(&vars, "sql_log_update",
 
469
                                       check_log_update,
 
470
                                       set_log_update,
 
471
                                       OPTION_BIN_LOG);
429
472
static sys_var_thd_bit  sys_log_binlog(&vars, "sql_log_bin",
430
473
                                       check_log_update,
431
474
                                       set_option_bit,
436
479
static sys_var_thd_bit  sys_sql_notes(&vars, "sql_notes", 0,
437
480
                                         set_option_bit,
438
481
                                         OPTION_SQL_NOTES);
 
482
static sys_var_thd_bit  sys_auto_is_null(&vars, "sql_auto_is_null", 0,
 
483
                                         set_option_bit,
 
484
                                         OPTION_AUTO_IS_NULL, 0,
 
485
                                         sys_var::SESSION_VARIABLE_IN_BINLOG);
439
486
static sys_var_thd_bit  sys_safe_updates(&vars, "sql_safe_updates", 0,
440
487
                                         set_option_bit,
441
488
                                         OPTION_SAFE_UPDATES);
523
570
static sys_var_const_str_ptr    sys_repl_report_user(&vars, "report_user", &report_user);
524
571
static sys_var_const_str_ptr    sys_repl_report_password(&vars, "report_password", &report_password);
525
572
 
526
 
static unsigned char *slave_get_report_port(THD *thd)
 
573
static uchar *slave_get_report_port(THD *thd)
527
574
{
528
575
  thd->sys_var_tmp.long_value= report_port;
529
 
  return (unsigned char*) &thd->sys_var_tmp.long_value;
 
576
  return (uchar*) &thd->sys_var_tmp.long_value;
530
577
}
531
578
 
532
579
static sys_var_readonly    sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
536
583
/* Read only variables */
537
584
 
538
585
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
 
586
static sys_var_have_variable sys_have_crypt(&vars, "have_crypt", &have_crypt);
 
587
static sys_var_have_plugin sys_have_csv(&vars, "have_csv", C_STRING_WITH_LEN("csv"), MYSQL_STORAGE_ENGINE_PLUGIN);
 
588
static sys_var_have_variable sys_have_dlopen(&vars, "have_dynamic_loading", &have_dlopen);
 
589
static sys_var_have_plugin sys_have_innodb(&vars, "have_innodb", C_STRING_WITH_LEN("innodb"), MYSQL_STORAGE_ENGINE_PLUGIN);
539
590
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
 
591
/* Global read-only variable describing server license */
 
592
static sys_var_const_str        sys_license(&vars, "license", STRINGIFY_ARG(LICENSE));
 
593
/* Global variables which enable|disable logging */
 
594
static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log,
 
595
                                      QUERY_LOG_GENERAL);
 
596
/* Synonym of "general_log" for consistency with SHOW VARIABLES output */
 
597
static sys_var_log_state sys_var_log(&vars, "log", &opt_log, QUERY_LOG_GENERAL);
 
598
static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
 
599
                                         QUERY_LOG_SLOW);
 
600
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
 
601
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
 
602
                                          &opt_slow_log, QUERY_LOG_SLOW);
 
603
sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path,
 
604
                                     sys_update_general_log_path,
 
605
                                     sys_default_general_log_path,
 
606
                                     opt_logname);
 
607
sys_var_str sys_var_slow_log_path(&vars, "slow_query_log_file", sys_check_log_path,
 
608
                                  sys_update_slow_log_path, 
 
609
                                  sys_default_slow_log_path,
 
610
                                  opt_slow_logname);
 
611
static sys_var_log_output sys_var_log_output_state(&vars, "log_output", &log_output_options,
 
612
                                            &log_output_typelib, 0);
 
613
 
 
614
 
540
615
/*
541
616
  Additional variables (not derived from sys_var class, not accessible as
542
617
  @@varname in SELECT or SET). Sorted in alphabetical order to facilitate
547
622
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
548
623
static SHOW_VAR fixed_vars[]= {
549
624
  {"back_log",                (char*) &back_log,                    SHOW_LONG},
 
625
  {"character_sets_dir",      mysql_charsets_dir,                   SHOW_CHAR},
550
626
  {"init_file",               (char*) &opt_init_file,               SHOW_CHAR_PTR},
551
627
  {"language",                language,                             SHOW_CHAR},
552
628
#ifdef HAVE_MLOCKALL
554
630
#endif
555
631
  {"log_bin",                 (char*) &opt_bin_log,                 SHOW_BOOL},
556
632
  {"log_error",               (char*) log_error_file,               SHOW_CHAR},
 
633
  {"lower_case_file_system",  (char*) &lower_case_file_system,      SHOW_MY_BOOL},
 
634
  {"lower_case_table_names",  (char*) &lower_case_table_names,      SHOW_INT},
557
635
  {"myisam_recover_options",  (char*) &myisam_recover_options_str,  SHOW_CHAR_PTR},
558
636
  {"open_files_limit",        (char*) &open_files_limit,            SHOW_LONG},
559
637
  {"pid_file",                (char*) pidfile_name,                 SHOW_CHAR},
560
638
  {"plugin_dir",              (char*) opt_plugin_dir,               SHOW_CHAR},
561
639
  {"port",                    (char*) &mysqld_port,                 SHOW_INT},
562
640
  {"protocol_version",        (char*) &protocol_version,            SHOW_INT},
 
641
  {"skip_external_locking",   (char*) &my_disable_locking,          SHOW_MY_BOOL},
 
642
  {"skip_networking",         (char*) &opt_disable_networking,      SHOW_BOOL},
 
643
  {"skip_show_database",      (char*) &opt_skip_show_db,            SHOW_BOOL},
563
644
  {"thread_stack",            (char*) &my_thread_stack_size,        SHOW_LONG},
564
645
};
565
646
 
566
647
 
567
 
bool sys_var::check(THD *thd __attribute__((unused)), set_var *var)
 
648
bool sys_var::check(THD *thd __attribute__((__unused__)), set_var *var)
568
649
{
569
650
  var->save_result.uint64_t_value= var->value->val_int();
570
651
  return 0;
599
680
                        set_var *var)
600
681
{
601
682
  char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
602
 
  uint32_t new_length= (var ? var->value->str_value.length() : 0);
 
683
  uint new_length= (var ? var->value->str_value.length() : 0);
603
684
  if (!old_value)
604
685
    old_value= (char*) "";
605
686
  if (!(res= my_strndup(old_value, new_length, MYF(0))))
613
694
  var_str->value= res;
614
695
  var_str->value_length= new_length;
615
696
  rw_unlock(var_mutex);
616
 
  free(old_value);
 
697
  my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
617
698
  return 0;
618
699
}
619
700
 
620
701
 
621
 
static bool sys_update_init_connect(THD *thd __attribute__((unused)), set_var *var)
 
702
static bool sys_update_init_connect(THD *thd __attribute__((__unused__)), set_var *var)
622
703
{
623
704
  return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var);
624
705
}
625
706
 
626
707
 
627
 
static void sys_default_init_connect(THD* thd __attribute__((unused)),
628
 
                                     enum_var_type type __attribute__((unused)))
 
708
static void sys_default_init_connect(THD* thd __attribute__((__unused__)),
 
709
                                     enum_var_type type __attribute__((__unused__)))
629
710
{
630
711
  update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0);
631
712
}
632
713
 
633
714
 
634
 
static bool sys_update_init_slave(THD *thd __attribute__((unused)),
 
715
static bool sys_update_init_slave(THD *thd __attribute__((__unused__)),
635
716
                                  set_var *var)
636
717
{
637
718
  return update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, var);
638
719
}
639
720
 
640
721
 
641
 
static void sys_default_init_slave(THD* thd __attribute__((unused)),
642
 
                                   enum_var_type type __attribute__((unused)))
 
722
static void sys_default_init_slave(THD* thd __attribute__((__unused__)),
 
723
                                   enum_var_type type __attribute__((__unused__)))
643
724
{
644
725
  update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0);
645
726
}
663
744
 
664
745
 
665
746
static void
666
 
fix_myisam_max_sort_file_size(THD *thd __attribute__((unused)),
667
 
                              enum_var_type type __attribute__((unused)))
 
747
fix_myisam_max_sort_file_size(THD *thd __attribute__((__unused__)),
 
748
                              enum_var_type type __attribute__((__unused__)))
668
749
{
669
750
  myisam_max_temp_length=
670
751
    (my_off_t) global_system_variables.myisam_max_sort_file_size;
714
795
static void fix_completion_type(THD *thd __attribute__((unused)),
715
796
                                enum_var_type type __attribute__((unused))) {}
716
797
 
717
 
static int check_completion_type(THD *thd __attribute__((unused)),
 
798
static int check_completion_type(THD *thd __attribute__((__unused__)),
718
799
                                 set_var *var)
719
800
{
720
801
  int64_t val= var->value->val_int();
732
813
  If we are changing the thread variable, we have to copy it to NET too
733
814
*/
734
815
 
 
816
#ifdef HAVE_REPLICATION
735
817
static void fix_net_read_timeout(THD *thd, enum_var_type type)
736
818
{
737
819
  if (type != OPT_GLOBAL)
750
832
  if (type != OPT_GLOBAL)
751
833
    thd->net.retry_count=thd->variables.net_retry_count;
752
834
}
753
 
 
754
 
 
755
 
extern void fix_delay_key_write(THD *thd __attribute__((unused)),
756
 
                                enum_var_type type __attribute__((unused)))
 
835
#else /* HAVE_REPLICATION */
 
836
static void fix_net_read_timeout(THD *thd __attribute__((unused)),
 
837
                                 enum_var_type type __attribute__((unused)))
 
838
{}
 
839
static void fix_net_write_timeout(THD *thd __attribute__((unused)),
 
840
                                  enum_var_type type __attribute__((unused)))
 
841
{}
 
842
static void fix_net_retry_count(THD *thd __attribute__((unused)),
 
843
                                enum_var_type type __attribute__((unused)))
 
844
{}
 
845
#endif /* HAVE_REPLICATION */
 
846
 
 
847
 
 
848
extern void fix_delay_key_write(THD *thd __attribute__((__unused__)),
 
849
                                enum_var_type type __attribute__((__unused__)))
757
850
{
758
851
  switch ((enum_delay_key_write) delay_key_write_options) {
759
852
  case DELAY_KEY_WRITE_NONE:
769
862
  }
770
863
}
771
864
 
772
 
bool sys_var_set::update(THD *thd __attribute__((unused)),
 
865
bool sys_var_set::update(THD *thd __attribute__((__unused__)),
773
866
                         set_var *var)
774
867
{
775
868
  *value= var->save_result.ulong_value;
776
869
  return 0;
777
870
}
778
871
 
779
 
unsigned char *sys_var_set::value_ptr(THD *thd,
780
 
                              enum_var_type type __attribute__((unused)),
781
 
                              LEX_STRING *base __attribute__((unused)))
 
872
uchar *sys_var_set::value_ptr(THD *thd,
 
873
                              enum_var_type type __attribute__((__unused__)),
 
874
                              LEX_STRING *base __attribute__((__unused__)))
782
875
{
783
876
  char buff[256];
784
 
  String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
877
  String tmp(buff, sizeof(buff), &my_charset_latin1);
785
878
  ulong length;
786
879
  ulong val= *value;
787
880
 
788
881
  tmp.length(0);
789
 
  for (uint32_t i= 0; val; val>>= 1, i++)
 
882
  for (uint i= 0; val; val>>= 1, i++)
790
883
  {
791
884
    if (val & 1)
792
885
    {
798
891
 
799
892
  if ((length= tmp.length()))
800
893
    length--;
801
 
  return (unsigned char*) thd->strmake(tmp.ptr(), length);
 
894
  return (uchar*) thd->strmake(tmp.ptr(), length);
802
895
}
803
896
 
804
 
void sys_var_set_slave_mode::set_default(THD *thd __attribute__((unused)),
805
 
                                         enum_var_type type __attribute__((unused)))
 
897
void sys_var_set_slave_mode::set_default(THD *thd __attribute__((__unused__)),
 
898
                                         enum_var_type type __attribute__((__unused__)))
806
899
{
807
900
  slave_exec_mode_options= 0;
808
901
  bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
830
923
  return rc;
831
924
}
832
925
 
833
 
void fix_slave_exec_mode(enum_var_type type __attribute__((unused)))
 
926
void fix_slave_exec_mode(enum_var_type type __attribute__((__unused__)))
834
927
{
835
928
  if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
836
929
      bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
837
930
  {
838
 
    sql_print_error(_("Ambiguous slave modes combination."
839
 
                    " STRICT will be used"));
 
931
    sql_print_error("Ambiguous slave modes combination."
 
932
                    " STRICT will be used");
840
933
    bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
841
934
  }
842
935
  if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
879
972
 
880
973
 
881
974
void fix_binlog_format_after_update(THD *thd,
882
 
                                    enum_var_type type __attribute__((unused)))
 
975
                                    enum_var_type type __attribute__((__unused__)))
883
976
{
884
977
  thd->reset_current_stmt_binlog_row_based();
885
978
}
886
979
 
887
980
 
888
 
static void fix_max_binlog_size(THD *thd __attribute__((unused)),
889
 
                                enum_var_type type __attribute__((unused)))
 
981
static void fix_max_binlog_size(THD *thd __attribute__((__unused__)),
 
982
                                enum_var_type type __attribute__((__unused__)))
890
983
{
891
984
  mysql_bin_log.set_max_size(max_binlog_size);
 
985
#ifdef HAVE_REPLICATION
892
986
  if (!max_relay_log_size)
893
987
    active_mi->rli.relay_log.set_max_size(max_binlog_size);
 
988
#endif
894
989
  return;
895
990
}
896
991
 
897
 
static void fix_max_relay_log_size(THD *thd __attribute__((unused)),
898
 
                                   enum_var_type type __attribute__((unused)))
 
992
static void fix_max_relay_log_size(THD *thd __attribute__((__unused__)),
 
993
                                   enum_var_type type __attribute__((__unused__)))
899
994
{
 
995
#ifdef HAVE_REPLICATION
900
996
  active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
901
997
                                        max_relay_log_size: max_binlog_size);
 
998
#endif
902
999
  return;
903
1000
}
904
1001
 
905
 
static void fix_max_connections(THD *thd __attribute__((unused)),
906
 
                                enum_var_type type __attribute__((unused)))
 
1002
static void fix_max_connections(THD *thd __attribute__((__unused__)),
 
1003
                                enum_var_type type __attribute__((__unused__)))
907
1004
{
908
1005
  resize_thr_alarm(max_connections +  10);
909
1006
}
927
1024
}
928
1025
 
929
1026
 
930
 
static void fix_server_id(THD *thd __attribute__((unused)),
931
 
                          enum_var_type type __attribute__((unused)))
 
1027
static void fix_server_id(THD *thd __attribute__((__unused__)),
 
1028
                          enum_var_type type __attribute__((__unused__)))
932
1029
{
933
1030
  server_id_supplied = 1;
934
1031
  thd->server_id= server_id;
947
1044
    else
948
1045
      llstr(val, buf);
949
1046
 
950
 
    push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1047
    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
951
1048
                        ER_TRUNCATED_WRONG_VALUE,
952
1049
                        ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
953
1050
  }
964
1061
  return out;
965
1062
}
966
1063
 
967
 
static bool get_unsigned(THD *thd __attribute__((unused)), set_var *var)
 
1064
static bool get_unsigned(THD *thd __attribute__((__unused__)), set_var *var)
968
1065
{
969
1066
  if (var->value->unsigned_flag)
970
1067
    var->save_result.uint64_t_value= (uint64_t) var->value->val_int();
1015
1112
}
1016
1113
 
1017
1114
 
1018
 
void sys_var_long_ptr_global::set_default(THD *thd __attribute__((unused)), enum_var_type type __attribute__((unused)))
 
1115
void sys_var_long_ptr_global::set_default(THD *thd __attribute__((__unused__)), enum_var_type type __attribute__((__unused__)))
1019
1116
{
1020
1117
  bool not_used;
1021
1118
  pthread_mutex_lock(guard);
1038
1135
}
1039
1136
 
1040
1137
 
1041
 
void sys_var_uint64_t_ptr::set_default(THD *thd __attribute__((unused)),
1042
 
                                        enum_var_type type __attribute__((unused)))
 
1138
void sys_var_uint64_t_ptr::set_default(THD *thd __attribute__((__unused__)),
 
1139
                                        enum_var_type type __attribute__((__unused__)))
1043
1140
{
1044
1141
  bool not_used;
1045
1142
  pthread_mutex_lock(&LOCK_global_system_variables);
1049
1146
}
1050
1147
 
1051
1148
 
1052
 
bool sys_var_bool_ptr::update(THD *thd __attribute__((unused)), set_var *var)
 
1149
bool sys_var_bool_ptr::update(THD *thd __attribute__((__unused__)), set_var *var)
1053
1150
{
1054
1151
  *value= (bool) var->save_result.ulong_value;
1055
1152
  return 0;
1056
1153
}
1057
1154
 
1058
1155
 
1059
 
void sys_var_bool_ptr::set_default(THD *thd __attribute__((unused)), enum_var_type type __attribute__((unused)))
 
1156
void sys_var_bool_ptr::set_default(THD *thd __attribute__((__unused__)), enum_var_type type __attribute__((__unused__)))
1060
1157
{
1061
1158
  *value= (bool) option_limits->def_value;
1062
1159
}
1063
1160
 
1064
1161
 
1065
 
bool sys_var_enum::update(THD *thd __attribute__((unused)), set_var *var)
 
1162
bool sys_var_enum::update(THD *thd __attribute__((__unused__)), set_var *var)
1066
1163
{
1067
1164
  *value= (uint) var->save_result.ulong_value;
1068
1165
  return 0;
1069
1166
}
1070
1167
 
1071
1168
 
1072
 
unsigned char *sys_var_enum::value_ptr(THD *thd __attribute__((unused)),
1073
 
                               enum_var_type type __attribute__((unused)),
1074
 
                               LEX_STRING *base __attribute__((unused)))
 
1169
uchar *sys_var_enum::value_ptr(THD *thd __attribute__((__unused__)),
 
1170
                               enum_var_type type __attribute__((__unused__)),
 
1171
                               LEX_STRING *base __attribute__((__unused__)))
1075
1172
{
1076
 
  return (unsigned char*) enum_names->type_names[*value];
 
1173
  return (uchar*) enum_names->type_names[*value];
1077
1174
}
1078
1175
 
1079
1176
 
1080
 
unsigned char *sys_var_enum_const::value_ptr(THD *thd __attribute__((unused)),
1081
 
                                     enum_var_type type __attribute__((unused)),
1082
 
                                     LEX_STRING *base __attribute__((unused)))
 
1177
uchar *sys_var_enum_const::value_ptr(THD *thd __attribute__((__unused__)),
 
1178
                                     enum_var_type type __attribute__((__unused__)),
 
1179
                                     LEX_STRING *base __attribute__((__unused__)))
1083
1180
{
1084
 
  return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
 
1181
  return (uchar*) enum_names->type_names[global_system_variables.*offset];
1085
1182
}
1086
1183
 
1087
1184
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1135
1232
 }
1136
1233
 
1137
1234
 
1138
 
unsigned char *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1139
 
                                    LEX_STRING *base __attribute__((unused)))
 
1235
uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
 
1236
                                    LEX_STRING *base __attribute__((__unused__)))
1140
1237
{
1141
1238
  if (type == OPT_GLOBAL)
1142
 
    return (unsigned char*) &(global_system_variables.*offset);
1143
 
  return (unsigned char*) &(thd->variables.*offset);
 
1239
    return (uchar*) &(global_system_variables.*offset);
 
1240
  return (uchar*) &(thd->variables.*offset);
1144
1241
}
1145
1242
 
1146
1243
 
1184
1281
}
1185
1282
 
1186
1283
 
1187
 
unsigned char *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1188
 
                                      LEX_STRING *base __attribute__((unused)))
 
1284
uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
 
1285
                                      LEX_STRING *base __attribute__((__unused__)))
1189
1286
{
1190
1287
  if (type == OPT_GLOBAL)
1191
 
    return (unsigned char*) &(global_system_variables.*offset);
1192
 
  return (unsigned char*) &(thd->variables.*offset);
 
1288
    return (uchar*) &(global_system_variables.*offset);
 
1289
  return (uchar*) &(thd->variables.*offset);
1193
1290
}
1194
1291
 
1195
1292
bool sys_var_thd_uint64_t::check(THD *thd, set_var *var)
1235
1332
}
1236
1333
 
1237
1334
 
1238
 
unsigned char *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
1239
 
                                        LEX_STRING *base __attribute__((unused)))
 
1335
uchar *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
 
1336
                                        LEX_STRING *base __attribute__((__unused__)))
1240
1337
{
1241
1338
  if (type == OPT_GLOBAL)
1242
 
    return (unsigned char*) &(global_system_variables.*offset);
1243
 
  return (unsigned char*) &(thd->variables.*offset);
 
1339
    return (uchar*) &(global_system_variables.*offset);
 
1340
  return (uchar*) &(thd->variables.*offset);
1244
1341
}
1245
1342
 
1246
1343
 
1247
1344
bool sys_var_thd_bool::update(THD *thd,  set_var *var)
1248
1345
{
1249
1346
  if (var->type == OPT_GLOBAL)
1250
 
    global_system_variables.*offset= (bool) var->save_result.ulong_value;
 
1347
    global_system_variables.*offset= (my_bool) var->save_result.ulong_value;
1251
1348
  else
1252
 
    thd->variables.*offset= (bool) var->save_result.ulong_value;
 
1349
    thd->variables.*offset= (my_bool) var->save_result.ulong_value;
1253
1350
  return 0;
1254
1351
}
1255
1352
 
1257
1354
void sys_var_thd_bool::set_default(THD *thd,  enum_var_type type)
1258
1355
{
1259
1356
  if (type == OPT_GLOBAL)
1260
 
    global_system_variables.*offset= (bool) option_limits->def_value;
 
1357
    global_system_variables.*offset= (my_bool) option_limits->def_value;
1261
1358
  else
1262
1359
    thd->variables.*offset= global_system_variables.*offset;
1263
1360
}
1264
1361
 
1265
1362
 
1266
 
unsigned char *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1267
 
                                   LEX_STRING *base __attribute__((unused)))
 
1363
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
 
1364
                                   LEX_STRING *base __attribute__((__unused__)))
1268
1365
{
1269
1366
  if (type == OPT_GLOBAL)
1270
 
    return (unsigned char*) &(global_system_variables.*offset);
1271
 
  return (unsigned char*) &(thd->variables.*offset);
 
1367
    return (uchar*) &(global_system_variables.*offset);
 
1368
  return (uchar*) &(thd->variables.*offset);
1272
1369
}
1273
1370
 
1274
1371
 
1275
 
bool sys_var::check_enum(THD *thd __attribute__((unused)),
 
1372
bool sys_var::check_enum(THD *thd __attribute__((__unused__)),
1276
1373
                         set_var *var, const TYPELIB *enum_names)
1277
1374
{
1278
1375
  char buff[STRING_BUFFER_USUAL_SIZE];
1309
1406
}
1310
1407
 
1311
1408
 
1312
 
bool sys_var::check_set(THD *thd __attribute__((unused)),
 
1409
bool sys_var::check_set(THD *thd __attribute__((__unused__)),
1313
1410
                        set_var *var, TYPELIB *enum_names)
1314
1411
{
1315
1412
  bool not_used;
1316
1413
  char buff[STRING_BUFFER_USUAL_SIZE], *error= 0;
1317
 
  uint32_t error_len= 0;
 
1414
  uint error_len= 0;
1318
1415
  String str(buff, sizeof(buff), system_charset_info), *res;
1319
1416
 
1320
1417
  if (var->value->result_type() == STRING_RESULT)
1321
1418
  {
1322
1419
    if (!(res= var->value->val_str(&str)))
1323
1420
    {
1324
 
      my_stpcpy(buff, "NULL");
 
1421
      strmov(buff, "NULL");
1325
1422
      goto err;
1326
1423
    }
1327
1424
 
1340
1437
                                            &not_used));
1341
1438
    if (error_len)
1342
1439
    {
1343
 
      strmake(buff, error, cmin(sizeof(buff) - 1, (ulong)error_len));
 
1440
      strmake(buff, error, min(sizeof(buff) - 1, error_len));
1344
1441
      goto err;
1345
1442
    }
1346
1443
  }
1360
1457
      For when the enum is made to contain 64 elements, as 1ULL<<64 is
1361
1458
      undefined, we guard with a "count<64" test.
1362
1459
    */
1363
 
    if (unlikely((tmp >= ((1UL) << enum_names->count)) &&
 
1460
    if (unlikely((tmp >= ((1ULL) << enum_names->count)) &&
1364
1461
                 (enum_names->count < 64)))
1365
1462
    {
1366
1463
      llstr(tmp, buff);
1400
1497
  switch (show_type()) {
1401
1498
  case SHOW_INT:
1402
1499
  {
1403
 
    uint32_t value;
 
1500
    uint value;
1404
1501
    pthread_mutex_lock(&LOCK_global_system_variables);
1405
1502
    value= *(uint*) value_ptr(thd, var_type, base);
1406
1503
    pthread_mutex_unlock(&LOCK_global_system_variables);
1441
1538
  }
1442
1539
  case SHOW_MY_BOOL:
1443
1540
  {
1444
 
    int32_t value;
 
1541
    int32 value;
1445
1542
    pthread_mutex_lock(&LOCK_global_system_variables);
1446
 
    value= *(bool*) value_ptr(thd, var_type, base);
 
1543
    value= *(my_bool*) value_ptr(thd, var_type, base);
1447
1544
    pthread_mutex_unlock(&LOCK_global_system_variables);
1448
1545
    return new Item_int(value,1);
1449
1546
  }
1454
1551
    char *str= *(char**) value_ptr(thd, var_type, base);
1455
1552
    if (str)
1456
1553
    {
1457
 
      uint32_t length= strlen(str);
 
1554
      uint length= strlen(str);
1458
1555
      tmp= new Item_string(thd->strmake(str, length), length,
1459
1556
                           system_charset_info, DERIVATION_SYSCONST);
1460
1557
    }
1508
1605
}
1509
1606
 
1510
1607
 
1511
 
unsigned char *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1512
 
                                   LEX_STRING *base __attribute__((unused)))
 
1608
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
 
1609
                                   LEX_STRING *base __attribute__((__unused__)))
1513
1610
{
1514
1611
  ulong tmp= ((type == OPT_GLOBAL) ?
1515
1612
              global_system_variables.*offset :
1516
1613
              thd->variables.*offset);
1517
 
  return (unsigned char*) enum_names->type_names[tmp];
 
1614
  return (uchar*) enum_names->type_names[tmp];
1518
1615
}
1519
1616
 
1520
1617
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1530
1627
}
1531
1628
 
1532
1629
 
1533
 
unsigned char *sys_var_thd_bit::value_ptr(THD *thd,
1534
 
                                  enum_var_type type __attribute__((unused)),
1535
 
                                  LEX_STRING *base __attribute__((unused)))
 
1630
uchar *sys_var_thd_bit::value_ptr(THD *thd,
 
1631
                                  enum_var_type type __attribute__((__unused__)),
 
1632
                                  LEX_STRING *base __attribute__((__unused__)))
1536
1633
{
1537
1634
  /*
1538
1635
    If reverse is 0 (default) return 1 if bit is set.
1539
1636
    If reverse is 1, return 0 if bit is set
1540
1637
  */
1541
 
  thd->sys_var_tmp.bool_value= ((thd->options & bit_flag) ?
 
1638
  thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ?
1542
1639
                                   !reverse : reverse);
1543
 
  return (unsigned char*) &thd->sys_var_tmp.bool_value;
 
1640
  return (uchar*) &thd->sys_var_tmp.my_bool_value;
1544
1641
}
1545
1642
 
1546
1643
 
1563
1660
    old= (thd->variables.*offset);
1564
1661
    (thd->variables.*offset)= new_value;
1565
1662
  }
1566
 
  free((char*) old);
 
1663
  my_free((char*) old, MYF(MY_ALLOW_ZERO_PTR));
1567
1664
  return;
1568
1665
}
1569
1666
 
1602
1699
    update is aborted
1603
1700
  */
1604
1701
  var->save_result.date_time_format= date_time_format_copy(thd, format);
1605
 
  free((char*) format);
 
1702
  my_free((char*) format, MYF(0));
1606
1703
  return var->save_result.date_time_format == 0;
1607
1704
}
1608
1705
 
1628
1725
}
1629
1726
 
1630
1727
 
1631
 
unsigned char *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
1632
 
                                               LEX_STRING *base __attribute__((unused)))
 
1728
uchar *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
 
1729
                                               LEX_STRING *base __attribute__((__unused__)))
1633
1730
{
1634
1731
  if (type == OPT_GLOBAL)
1635
1732
  {
1641
1738
    */
1642
1739
    res= thd->strmake((global_system_variables.*offset)->format.str,
1643
1740
                      (global_system_variables.*offset)->format.length);
1644
 
    return (unsigned char*) res;
 
1741
    return (uchar*) res;
1645
1742
  }
1646
 
  return (unsigned char*) (thd->variables.*offset)->format.str;
 
1743
  return (uchar*) (thd->variables.*offset)->format.str;
1647
1744
}
1648
1745
 
1649
1746
 
1653
1750
  const char *new_name;
1654
1751
} my_old_conv;
1655
1752
 
1656
 
bool sys_var_collation::check(THD *thd __attribute__((unused)),
 
1753
static my_old_conv old_conv[]= 
 
1754
{
 
1755
  {     "cp1251_koi8"           ,       "cp1251"        },
 
1756
  {     "cp1250_latin2"         ,       "cp1250"        },
 
1757
  {     "kam_latin2"            ,       "keybcs2"       },
 
1758
  {     "mac_latin2"            ,       "MacRoman"      },
 
1759
  {     "macce_latin2"          ,       "MacCE"         },
 
1760
  {     "pc2_latin2"            ,       "pclatin2"      },
 
1761
  {     "vga_latin2"            ,       "pclatin1"      },
 
1762
  {     "koi8_cp1251"           ,       "koi8r"         },
 
1763
  {     "win1251ukr_koi8_ukr"   ,       "win1251ukr"    },
 
1764
  {     "koi8_ukr_win1251ukr"   ,       "koi8u"         },
 
1765
  {     NULL                    ,       NULL            }
 
1766
};
 
1767
 
 
1768
CHARSET_INFO *get_old_charset_by_name(const char *name)
 
1769
{
 
1770
  my_old_conv *conv;
 
1771
 
 
1772
  for (conv= old_conv; conv->old_name; conv++)
 
1773
  {
 
1774
    if (!my_strcasecmp(&my_charset_latin1, name, conv->old_name))
 
1775
      return get_charset_by_csname(conv->new_name, MY_CS_PRIMARY, MYF(0));
 
1776
  }
 
1777
  return NULL;
 
1778
}
 
1779
 
 
1780
 
 
1781
bool sys_var_collation::check(THD *thd __attribute__((__unused__)),
1657
1782
                              set_var *var)
1658
1783
{
1659
 
  const CHARSET_INFO *tmp;
 
1784
  CHARSET_INFO *tmp;
1660
1785
 
1661
1786
  if (var->value->result_type() == STRING_RESULT)
1662
1787
  {
1688
1813
}
1689
1814
 
1690
1815
 
1691
 
bool sys_var_character_set::check(THD *thd __attribute__((unused)),
 
1816
bool sys_var_character_set::check(THD *thd __attribute__((__unused__)),
1692
1817
                                  set_var *var)
1693
1818
{
1694
 
  const CHARSET_INFO *tmp;
 
1819
  CHARSET_INFO *tmp;
1695
1820
 
1696
1821
  if (var->value->result_type() == STRING_RESULT)
1697
1822
  {
1706
1831
      }
1707
1832
      tmp= NULL;
1708
1833
    }
1709
 
    else if (!(tmp= get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))))
 
1834
    else if (!(tmp=get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))) &&
 
1835
             !(tmp=get_old_charset_by_name(res->c_ptr())))
1710
1836
    {
1711
1837
      my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
1712
1838
      return 1;
1735
1861
}
1736
1862
 
1737
1863
 
1738
 
unsigned char *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1739
 
                                        LEX_STRING *base __attribute__((unused)))
 
1864
uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
 
1865
                                        LEX_STRING *base __attribute__((__unused__)))
1740
1866
{
1741
 
  const CHARSET_INFO * const cs= ci_ptr(thd,type)[0];
1742
 
  return cs ? (unsigned char*) cs->csname : (unsigned char*) NULL;
 
1867
  CHARSET_INFO *cs= ci_ptr(thd,type)[0];
 
1868
  return cs ? (uchar*) cs->csname : (uchar*) NULL;
1743
1869
}
1744
1870
 
1745
1871
 
1753
1879
    thd->update_charset();
1754
1880
  }
1755
1881
}
1756
 
const CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
 
1882
CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
1757
1883
{
1758
1884
  if (type == OPT_GLOBAL)
1759
1885
    return &(global_system_variables.*offset);
1777
1903
}
1778
1904
 
1779
1905
 
1780
 
const CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
 
1906
CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
1781
1907
                                                       enum_var_type type)
1782
1908
{
1783
1909
  if (type == OPT_GLOBAL)
1824
1950
}
1825
1951
 
1826
1952
 
1827
 
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1828
 
                                       LEX_STRING *base __attribute__((unused)))
 
1953
uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
 
1954
                                       LEX_STRING *base __attribute__((__unused__)))
1829
1955
{
1830
 
  const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
 
1956
  CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1831
1957
                     global_system_variables.*offset : thd->variables.*offset);
1832
 
  return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
 
1958
  return cs ? (uchar*) cs->name : (uchar*) "NULL";
1833
1959
}
1834
1960
 
1835
1961
 
1847
1973
}
1848
1974
 
1849
1975
 
1850
 
unsigned char *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((unused)),
1851
 
                                          enum_var_type type __attribute__((unused)),
1852
 
                                          LEX_STRING *base __attribute__((unused)))
 
1976
uchar *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((__unused__)),
 
1977
                                          enum_var_type type __attribute__((__unused__)),
 
1978
                                          LEX_STRING *base __attribute__((__unused__)))
1853
1979
{
1854
1980
  KEY_CACHE *key_cache= get_key_cache(base);
1855
1981
  if (!key_cache)
1856
1982
    key_cache= &zero_key_cache;
1857
 
  return (unsigned char*) key_cache + offset ;
 
1983
  return (uchar*) key_cache + offset ;
1858
1984
}
1859
1985
 
1860
1986
 
1896
2022
  {
1897
2023
    if (key_cache == dflt_key_cache)
1898
2024
    {
1899
 
      push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
2025
      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1900
2026
                          ER_WARN_CANT_DROP_DEFAULT_KEYCACHE,
1901
2027
                          ER(ER_WARN_CANT_DROP_DEFAULT_KEYCACHE));
1902
2028
      goto end;                                 // Ignore default key cache
2000
2126
}
2001
2127
 
2002
2128
 
2003
 
bool sys_var_log_state::update(THD *thd __attribute__((unused)), set_var *var)
 
2129
bool sys_var_log_state::update(THD *thd, set_var *var)
2004
2130
{
2005
2131
  bool res;
2006
2132
  pthread_mutex_lock(&LOCK_global_system_variables);
2007
2133
  if (!var->save_result.ulong_value)
 
2134
  {
 
2135
    logger.deactivate_log_handler(thd, log_type);
2008
2136
    res= false;
 
2137
  }
2009
2138
  else
2010
 
    res= true;
 
2139
    res= logger.activate_log_handler(thd, log_type);
2011
2140
  pthread_mutex_unlock(&LOCK_global_system_variables);
2012
2141
  return res;
2013
2142
}
2014
2143
 
2015
 
void sys_var_log_state::set_default(THD *thd __attribute__((unused)),
2016
 
                                    enum_var_type type __attribute__((unused)))
2017
 
{
2018
 
}
2019
 
 
2020
 
 
2021
 
bool update_sys_var_str_path(THD *thd __attribute__((unused)),
 
2144
void sys_var_log_state::set_default(THD *thd,
 
2145
                                    enum_var_type type __attribute__((__unused__)))
 
2146
{
 
2147
  pthread_mutex_lock(&LOCK_global_system_variables);
 
2148
  logger.deactivate_log_handler(thd, log_type);
 
2149
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
2150
}
 
2151
 
 
2152
 
 
2153
static int  sys_check_log_path(THD *thd __attribute__((__unused__)),
 
2154
                               set_var *var)
 
2155
{
 
2156
  char path[FN_REFLEN], buff[FN_REFLEN];
 
2157
  struct stat f_stat;
 
2158
  String str(buff, sizeof(buff), system_charset_info), *res;
 
2159
  const char *log_file_str;
 
2160
  size_t path_length;
 
2161
 
 
2162
  if (!(res= var->value->val_str(&str)))
 
2163
    goto err;
 
2164
 
 
2165
  log_file_str= res->c_ptr();
 
2166
  bzero(&f_stat, sizeof(struct stat));
 
2167
 
 
2168
  path_length= unpack_filename(path, log_file_str);
 
2169
 
 
2170
  if (!path_length)
 
2171
  {
 
2172
    /* File name is empty. */
 
2173
 
 
2174
    goto err;
 
2175
  }
 
2176
 
 
2177
  if (!stat(path, &f_stat))
 
2178
  {
 
2179
    /*
 
2180
      A file system object exists. Check if argument is a file and we have
 
2181
      'write' permission.
 
2182
    */
 
2183
 
 
2184
    if (!MY_S_ISREG(f_stat.st_mode) ||
 
2185
        !(f_stat.st_mode & MY_S_IWRITE))
 
2186
      goto err;
 
2187
 
 
2188
    return 0;
 
2189
  }
 
2190
 
 
2191
  /* Get dirname of the file path. */
 
2192
  (void) dirname_part(path, log_file_str, &path_length);
 
2193
 
 
2194
  /* Dirname is empty if file path is relative. */
 
2195
  if (!path_length)
 
2196
    return 0;
 
2197
 
 
2198
  /*
 
2199
    Check if directory exists and we have permission to create file and
 
2200
    write to file.
 
2201
  */
 
2202
  if (my_access(path, (F_OK|W_OK)))
 
2203
    goto err;
 
2204
 
 
2205
  return 0;
 
2206
 
 
2207
err:
 
2208
  my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name, 
 
2209
           res ? log_file_str : "NULL");
 
2210
  return 1;
 
2211
}
 
2212
 
 
2213
 
 
2214
bool update_sys_var_str_path(THD *thd __attribute__((__unused__)),
2022
2215
                             sys_var_str *var_str,
2023
2216
                             set_var *var, const char *log_ext,
2024
 
                             bool log_state, uint32_t log_type)
 
2217
                             bool log_state, uint log_type)
2025
2218
{
 
2219
  MYSQL_QUERY_LOG *file_log;
2026
2220
  char buff[FN_REFLEN];
2027
2221
  char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
2028
2222
  bool result= 0;
2029
 
  uint32_t str_length= (var ? var->value->str_value.length() : 0);
 
2223
  uint str_length= (var ? var->value->str_value.length() : 0);
2030
2224
 
2031
2225
  switch (log_type) {
 
2226
  case QUERY_LOG_SLOW:
 
2227
    file_log= logger.get_slow_log_file_handler();
 
2228
    break;
 
2229
  case QUERY_LOG_GENERAL:
 
2230
    file_log= logger.get_log_file_handler();
 
2231
    break;
2032
2232
  default:
2033
2233
    assert(0);                                  // Impossible
2034
2234
  }
2047
2247
  pthread_mutex_lock(&LOCK_global_system_variables);
2048
2248
  logger.lock_exclusive();
2049
2249
 
 
2250
  if (file_log && log_state)
 
2251
    file_log->close(0);
2050
2252
  old_value= var_str->value;
2051
2253
  var_str->value= res;
2052
2254
  var_str->value_length= str_length;
2053
 
  free(old_value);
2054
 
  if (log_state)
 
2255
  my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
 
2256
  if (file_log && log_state)
2055
2257
  {
2056
2258
    switch (log_type) {
 
2259
    case QUERY_LOG_SLOW:
 
2260
      file_log->open_slow_log(sys_var_slow_log_path.value);
 
2261
      break;
 
2262
    case QUERY_LOG_GENERAL:
 
2263
      file_log->open_query_log(sys_var_general_log_path.value);
 
2264
      break;
2057
2265
    default:
2058
2266
      assert(0);
2059
2267
    }
2067
2275
}
2068
2276
 
2069
2277
 
2070
 
bool sys_var_log_output::update(THD *thd __attribute__((unused)),
 
2278
static bool sys_update_general_log_path(THD *thd, set_var * var)
 
2279
{
 
2280
  return update_sys_var_str_path(thd, &sys_var_general_log_path,
 
2281
                                 var, ".log", opt_log, QUERY_LOG_GENERAL);
 
2282
}
 
2283
 
 
2284
 
 
2285
static void sys_default_general_log_path(THD *thd,
 
2286
                                         enum_var_type type __attribute__((__unused__)))
 
2287
{
 
2288
  (void) update_sys_var_str_path(thd, &sys_var_general_log_path,
 
2289
                                 0, ".log", opt_log, QUERY_LOG_GENERAL);
 
2290
}
 
2291
 
 
2292
 
 
2293
static bool sys_update_slow_log_path(THD *thd, set_var * var)
 
2294
{
 
2295
  return update_sys_var_str_path(thd, &sys_var_slow_log_path,
 
2296
                                 var, "-slow.log", opt_slow_log,
 
2297
                                 QUERY_LOG_SLOW);
 
2298
}
 
2299
 
 
2300
 
 
2301
static void sys_default_slow_log_path(THD *thd,
 
2302
                                      enum_var_type type __attribute__((__unused__)))
 
2303
{
 
2304
  (void) update_sys_var_str_path(thd, &sys_var_slow_log_path,
 
2305
                                 0, "-slow.log", opt_slow_log,
 
2306
                                 QUERY_LOG_SLOW);
 
2307
}
 
2308
 
 
2309
 
 
2310
bool sys_var_log_output::update(THD *thd __attribute__((__unused__)),
2071
2311
                                set_var *var)
2072
2312
{
2073
2313
  pthread_mutex_lock(&LOCK_global_system_variables);
2074
2314
  logger.lock_exclusive();
 
2315
  logger.init_slow_log(var->save_result.ulong_value);
 
2316
  logger.init_general_log(var->save_result.ulong_value);
2075
2317
  *value= var->save_result.ulong_value;
2076
2318
  logger.unlock();
2077
2319
  pthread_mutex_unlock(&LOCK_global_system_variables);
2079
2321
}
2080
2322
 
2081
2323
 
2082
 
void sys_var_log_output::set_default(THD *thd __attribute__((unused)),
2083
 
                                     enum_var_type type __attribute__((unused)))
 
2324
void sys_var_log_output::set_default(THD *thd __attribute__((__unused__)),
 
2325
                                     enum_var_type type __attribute__((__unused__)))
2084
2326
{
2085
2327
  pthread_mutex_lock(&LOCK_global_system_variables);
2086
2328
  logger.lock_exclusive();
 
2329
  logger.init_slow_log(LOG_FILE);
 
2330
  logger.init_general_log(LOG_FILE);
2087
2331
  *value= LOG_FILE;
2088
2332
  logger.unlock();
2089
2333
  pthread_mutex_unlock(&LOCK_global_system_variables);
2090
2334
}
2091
2335
 
2092
2336
 
2093
 
unsigned char *sys_var_log_output::value_ptr(THD *thd,
2094
 
                                     enum_var_type type __attribute__((unused)),
2095
 
                                     LEX_STRING *base __attribute__((unused)))
 
2337
uchar *sys_var_log_output::value_ptr(THD *thd,
 
2338
                                     enum_var_type type __attribute__((__unused__)),
 
2339
                                     LEX_STRING *base __attribute__((__unused__)))
2096
2340
{
2097
2341
  char buff[256];
2098
 
  String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
2342
  String tmp(buff, sizeof(buff), &my_charset_latin1);
2099
2343
  ulong length;
2100
2344
  ulong val= *value;
2101
2345
 
2102
2346
  tmp.length(0);
2103
 
  for (uint32_t i= 0; val; val>>= 1, i++)
 
2347
  for (uint i= 0; val; val>>= 1, i++)
2104
2348
  {
2105
2349
    if (val & 1)
2106
2350
    {
2112
2356
 
2113
2357
  if ((length= tmp.length()))
2114
2358
    length--;
2115
 
  return (unsigned char*) thd->strmake(tmp.ptr(), length);
 
2359
  return (uchar*) thd->strmake(tmp.ptr(), length);
2116
2360
}
2117
2361
 
2118
2362
 
2120
2364
  Functions to handle SET NAMES and SET CHARACTER SET
2121
2365
*****************************************************************************/
2122
2366
 
2123
 
int set_var_collation_client::check(THD *thd __attribute__((unused)))
 
2367
int set_var_collation_client::check(THD *thd __attribute__((__unused__)))
2124
2368
{
2125
2369
  /* Currently, UCS-2 cannot be used as a client character set */
2126
2370
  if (character_set_client->mbminlen > 1)
2152
2396
 
2153
2397
 
2154
2398
void sys_var_timestamp::set_default(THD *thd,
2155
 
                                    enum_var_type type __attribute__((unused)))
 
2399
                                    enum_var_type type __attribute__((__unused__)))
2156
2400
{
2157
2401
  thd->user_time=0;
2158
2402
}
2159
2403
 
2160
2404
 
2161
 
unsigned char *sys_var_timestamp::value_ptr(THD *thd,
2162
 
                                    enum_var_type type __attribute__((unused)),
2163
 
                                    LEX_STRING *base __attribute__((unused)))
 
2405
uchar *sys_var_timestamp::value_ptr(THD *thd,
 
2406
                                    enum_var_type type __attribute__((__unused__)),
 
2407
                                    LEX_STRING *base __attribute__((__unused__)))
2164
2408
{
2165
2409
  thd->sys_var_tmp.long_value= (long) thd->start_time;
2166
 
  return (unsigned char*) &thd->sys_var_tmp.long_value;
 
2410
  return (uchar*) &thd->sys_var_tmp.long_value;
2167
2411
}
2168
2412
 
2169
2413
 
2175
2419
}
2176
2420
 
2177
2421
 
2178
 
unsigned char *sys_var_last_insert_id::value_ptr(THD *thd,
2179
 
                                         enum_var_type type __attribute__((unused)),
2180
 
                                         LEX_STRING *base __attribute__((unused)))
 
2422
uchar *sys_var_last_insert_id::value_ptr(THD *thd,
 
2423
                                         enum_var_type type __attribute__((__unused__)),
 
2424
                                         LEX_STRING *base __attribute__((__unused__)))
2181
2425
{
2182
2426
  /*
2183
2427
    this tmp var makes it robust againt change of type of
2185
2429
  */
2186
2430
  thd->sys_var_tmp.uint64_t_value= 
2187
2431
    thd->read_first_successful_insert_id_in_prev_stmt();
2188
 
  return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
 
2432
  return (uchar*) &thd->sys_var_tmp.uint64_t_value;
2189
2433
}
2190
2434
 
2191
2435
 
2196
2440
}
2197
2441
 
2198
2442
 
2199
 
unsigned char *sys_var_insert_id::value_ptr(THD *thd,
2200
 
                                    enum_var_type type __attribute__((unused)),
2201
 
                                    LEX_STRING *base __attribute__((unused)))
 
2443
uchar *sys_var_insert_id::value_ptr(THD *thd,
 
2444
                                    enum_var_type type __attribute__((__unused__)),
 
2445
                                    LEX_STRING *base __attribute__((__unused__)))
2202
2446
{
2203
2447
  thd->sys_var_tmp.uint64_t_value=
2204
2448
    thd->auto_inc_intervals_forced.minimum();
2205
 
  return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
 
2449
  return (uchar*) &thd->sys_var_tmp.uint64_t_value;
2206
2450
}
2207
2451
 
2208
2452
 
2222
2466
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
2223
2467
{
2224
2468
  char buff[MAX_TIME_ZONE_NAME_LENGTH];
2225
 
  String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
2469
  String str(buff, sizeof(buff), &my_charset_latin1);
2226
2470
  String *res= var->value->val_str(&str);
2227
2471
 
2228
2472
  if (!(var->save_result.time_zone= my_tz_find(thd, res)))
2249
2493
}
2250
2494
 
2251
2495
 
2252
 
unsigned char *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
2253
 
                                        LEX_STRING *base __attribute__((unused)))
 
2496
uchar *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
 
2497
                                        LEX_STRING *base __attribute__((__unused__)))
2254
2498
{
2255
2499
  /* 
2256
2500
    We can use ptr() instead of c_ptr() here because String contaning
2257
2501
    time zone name is guaranteed to be zero ended.
2258
2502
  */
2259
2503
  if (type == OPT_GLOBAL)
2260
 
    return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr());
 
2504
    return (uchar *)(global_system_variables.time_zone->get_name()->ptr());
2261
2505
  else
2262
2506
  {
2263
2507
    /*
2269
2513
      (binlog code stores session value only).
2270
2514
    */
2271
2515
    thd->time_zone_used= 1;
2272
 
    return (unsigned char *)(thd->variables.time_zone->get_name()->ptr());
 
2516
    return (uchar *)(thd->variables.time_zone->get_name()->ptr());
2273
2517
  }
2274
2518
}
2275
2519
 
2281
2525
 {
2282
2526
   if (default_tz_name)
2283
2527
   {
2284
 
     String str(default_tz_name, &my_charset_utf8_general_ci);
 
2528
     String str(default_tz_name, &my_charset_latin1);
2285
2529
     /*
2286
2530
       We are guaranteed to find this time zone since its existence
2287
2531
       is checked during start-up.
2312
2556
  }
2313
2557
}
2314
2558
 
2315
 
bool sys_var_max_user_conn::update(THD *thd __attribute__((unused)),
 
2559
bool sys_var_max_user_conn::update(THD *thd __attribute__((__unused__)),
2316
2560
                                   set_var *var)
2317
2561
{
2318
2562
  assert(var->type == OPT_GLOBAL);
2323
2567
}
2324
2568
 
2325
2569
 
2326
 
void sys_var_max_user_conn::set_default(THD *thd __attribute__((unused)),
2327
 
                                        enum_var_type type __attribute__((unused)))
 
2570
void sys_var_max_user_conn::set_default(THD *thd __attribute__((__unused__)),
 
2571
                                        enum_var_type type __attribute__((__unused__)))
2328
2572
{
2329
2573
  assert(type == OPT_GLOBAL);
2330
2574
  pthread_mutex_lock(&LOCK_global_system_variables);
2333
2577
}
2334
2578
 
2335
2579
 
2336
 
unsigned char *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2337
 
                                        LEX_STRING *base __attribute__((unused)))
 
2580
uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
 
2581
                                        LEX_STRING *base __attribute__((__unused__)))
2338
2582
{
2339
2583
  if (type != OPT_GLOBAL &&
2340
2584
      thd->user_connect && thd->user_connect->user_resources.user_conn)
2341
 
    return (unsigned char*) &(thd->user_connect->user_resources.user_conn);
2342
 
  return (unsigned char*) &(max_user_connections);
 
2585
    return (uchar*) &(thd->user_connect->user_resources.user_conn);
 
2586
  return (uchar*) &(max_user_connections);
2343
2587
}
2344
2588
 
2345
2589
 
2346
 
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((unused)),
 
2590
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((__unused__)),
2347
2591
                                      set_var *var)
2348
2592
{
2349
2593
  MY_LOCALE *locale_match;
2361
2605
  else // STRING_RESULT
2362
2606
  {
2363
2607
    char buff[6]; 
2364
 
    String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res;
 
2608
    String str(buff, sizeof(buff), &my_charset_latin1), *res;
2365
2609
    if (!(res=var->value->val_str(&str)))
2366
2610
    {
2367
2611
      my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
2391
2635
}
2392
2636
 
2393
2637
 
2394
 
unsigned char *sys_var_thd_lc_time_names::value_ptr(THD *thd,
 
2638
uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2395
2639
                                            enum_var_type type,
2396
 
                                            LEX_STRING *base __attribute__((unused)))
 
2640
                                            LEX_STRING *base __attribute__((__unused__)))
2397
2641
{
2398
2642
  return type == OPT_GLOBAL ?
2399
 
                 (unsigned char *) global_system_variables.lc_time_names->name :
2400
 
                 (unsigned char *) thd->variables.lc_time_names->name;
 
2643
                 (uchar *) global_system_variables.lc_time_names->name :
 
2644
                 (uchar *) thd->variables.lc_time_names->name;
2401
2645
}
2402
2646
 
2403
2647
 
2453
2697
}
2454
2698
 
2455
2699
 
2456
 
unsigned char *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2457
 
                                          LEX_STRING *base __attribute__((unused)))
 
2700
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
 
2701
                                          LEX_STRING *base __attribute__((__unused__)))
2458
2702
{
2459
2703
  thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2460
2704
                                   global_system_variables.*offset :
2461
2705
                                   thd->variables.*offset) / 1000000.0;
2462
 
  return (unsigned char*) &thd->tmp_double_value;
 
2706
  return (uchar*) &thd->tmp_double_value;
2463
2707
}
2464
2708
 
2465
2709
 
2509
2753
  return 0;
2510
2754
}
2511
2755
 
2512
 
static int check_log_update(THD *thd __attribute__((unused)),
2513
 
                            set_var *var __attribute__((unused)))
2514
 
{
2515
 
  return 0;
2516
 
}
2517
 
 
2518
 
 
2519
 
static int check_pseudo_thread_id(THD *thd __attribute__((unused)),
 
2756
static int check_log_update(THD *thd __attribute__((__unused__)),
 
2757
                            set_var *var __attribute__((__unused__)))
 
2758
{
 
2759
  return 0;
 
2760
}
 
2761
 
 
2762
static bool set_log_update(THD *thd __attribute__((__unused__)),
 
2763
                           set_var *var __attribute__((__unused__)))
 
2764
{
 
2765
  /*
 
2766
    The update log is not supported anymore since 5.0.
 
2767
    See sql/mysqld.cc/, comments in function init_server_components() for an
 
2768
    explaination of the different warnings we send below
 
2769
  */
 
2770
 
 
2771
  if (opt_sql_bin_update)
 
2772
  {
 
2773
    push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
 
2774
                 ER_UPDATE_LOG_DEPRECATED_TRANSLATED,
 
2775
                 ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED));
 
2776
  }
 
2777
  else
 
2778
    push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
 
2779
                 ER_UPDATE_LOG_DEPRECATED_IGNORED,
 
2780
                 ER(ER_UPDATE_LOG_DEPRECATED_IGNORED));
 
2781
  set_option_bit(thd, var);
 
2782
  return 0;
 
2783
}
 
2784
 
 
2785
 
 
2786
static int check_pseudo_thread_id(THD *thd __attribute__((__unused__)),
2520
2787
                                  set_var *var)
2521
2788
{
2522
2789
  var->save_result.uint64_t_value= var->value->val_int();
2523
2790
  return 0;
2524
2791
}
2525
2792
 
2526
 
static unsigned char *get_warning_count(THD *thd)
 
2793
static uchar *get_warning_count(THD *thd)
2527
2794
{
2528
2795
  thd->sys_var_tmp.long_value=
2529
 
    (thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_NOTE] +
2530
 
     thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR] +
2531
 
     thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_WARN]);
2532
 
  return (unsigned char*) &thd->sys_var_tmp.long_value;
 
2796
    (thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
 
2797
     thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
 
2798
     thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
 
2799
  return (uchar*) &thd->sys_var_tmp.long_value;
2533
2800
}
2534
2801
 
2535
 
static unsigned char *get_error_count(THD *thd)
 
2802
static uchar *get_error_count(THD *thd)
2536
2803
{
2537
2804
  thd->sys_var_tmp.long_value= 
2538
 
    thd->warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_ERROR];
2539
 
  return (unsigned char*) &thd->sys_var_tmp.long_value;
 
2805
    thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
 
2806
  return (uchar*) &thd->sys_var_tmp.long_value;
2540
2807
}
2541
2808
 
2542
2809
 
2554
2821
  @retval
2555
2822
    ptr         pointer to NUL-terminated string
2556
2823
*/
2557
 
static unsigned char *get_tmpdir(THD *thd __attribute__((unused)))
 
2824
static uchar *get_tmpdir(THD *thd __attribute__((__unused__)))
2558
2825
{
2559
2826
  if (opt_mysql_tmpdir)
2560
 
    return (unsigned char *)opt_mysql_tmpdir;
2561
 
  return (unsigned char*)mysql_tmpdir;
 
2827
    return (uchar *)opt_mysql_tmpdir;
 
2828
  return (uchar*)mysql_tmpdir;
2562
2829
}
2563
2830
 
2564
2831
/****************************************************************************
2583
2850
 
2584
2851
static struct my_option *find_option(struct my_option *opt, const char *name) 
2585
2852
{
2586
 
  uint32_t length=strlen(name);
 
2853
  uint length=strlen(name);
2587
2854
  for (; opt->name; opt++)
2588
2855
  {
2589
2856
    if (!getopt_compare_strings(opt->name, name, length) &&
2604
2871
  Return variable name and length for hashing of variables.
2605
2872
*/
2606
2873
 
2607
 
static unsigned char *get_sys_var_length(const sys_var *var, size_t *length,
2608
 
                                 bool first __attribute__((unused)))
 
2874
static uchar *get_sys_var_length(const sys_var *var, size_t *length,
 
2875
                                 my_bool first __attribute__((__unused__)))
2609
2876
{
2610
2877
  *length= var->name_length;
2611
 
  return (unsigned char*) var->name;
 
2878
  return (uchar*) var->name;
2612
2879
}
2613
2880
 
2614
2881
 
2636
2903
  {
2637
2904
    var->name_length= strlen(var->name);
2638
2905
    /* this fails if there is a conflicting variable name. see HASH_UNIQUE */
2639
 
    if (my_hash_insert(&system_variable_hash, (unsigned char*) var))
 
2906
    if (my_hash_insert(&system_variable_hash, (uchar*) var))
2640
2907
      goto error;
2641
2908
    if (long_options)
2642
2909
      var->option_limits= find_option(long_options, var->name);
2645
2912
 
2646
2913
error:
2647
2914
  for (; first != var; first= first->next)
2648
 
    hash_delete(&system_variable_hash, (unsigned char*) first);
 
2915
    hash_delete(&system_variable_hash, (uchar*) first);
2649
2916
  return 1;
2650
2917
}
2651
2918
 
2669
2936
  /* A write lock should be held on LOCK_system_variables_hash */
2670
2937
   
2671
2938
  for (sys_var *var= first; var; var= var->next)
2672
 
    result|= hash_delete(&system_variable_hash, (unsigned char*) var);
 
2939
    result|= hash_delete(&system_variable_hash, (uchar*) var);
2673
2940
 
2674
2941
  return result;
2675
2942
}
2721
2988
               (qsort_cmp) show_cmp);
2722
2989
    
2723
2990
    /* make last element empty */
2724
 
    memset(show, 0, sizeof(SHOW_VAR));
 
2991
    bzero(show, sizeof(SHOW_VAR));
2725
2992
  }
2726
2993
  return result;
2727
2994
}
2740
3007
 
2741
3008
int set_var_init()
2742
3009
{
2743
 
  uint32_t count= 0;
 
3010
  uint count= 0;
2744
3011
  
2745
3012
  for (sys_var *var=vars.first; var; var= var->next, count++) {};
2746
3013
 
2759
3026
  if (mysql_add_sys_var_chain(vars.first, my_long_options))
2760
3027
    goto error;
2761
3028
 
 
3029
  /*
 
3030
    Special cases
 
3031
    Needed because MySQL can't find the limits for a variable it it has
 
3032
    a different name than the command line option.
 
3033
    As these variables are deprecated, this code will disappear soon...
 
3034
  */
 
3035
  sys_sql_max_join_size.option_limits= sys_max_join_size.option_limits;
 
3036
 
2762
3037
  return(0);
2763
3038
 
2764
3039
error:
2786
3061
    0           SUCCESS
2787
3062
    otherwise   FAILURE
2788
3063
*/
2789
 
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint32_t count)
 
3064
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count)
2790
3065
{
2791
3066
  for (; count > 0; count--, show_vars++)
2792
 
    if (insert_dynamic(&fixed_show_vars, (unsigned char*) show_vars))
 
3067
    if (insert_dynamic(&fixed_show_vars, (uchar*) show_vars))
2793
3068
      return 1;
2794
3069
  return 0;
2795
3070
}
2809
3084
    0           Unknown variable (error message is given)
2810
3085
*/
2811
3086
 
2812
 
sys_var *intern_find_sys_var(const char *str, uint32_t length, bool no_error)
 
3087
sys_var *intern_find_sys_var(const char *str, uint length, bool no_error)
2813
3088
{
2814
3089
  sys_var *var;
2815
3090
 
2818
3093
    A lock on LOCK_system_variable_hash should be held
2819
3094
  */
2820
3095
  var= (sys_var*) hash_search(&system_variable_hash,
2821
 
                              (unsigned char*) str, length ? length : strlen(str));
 
3096
                              (uchar*) str, length ? length : strlen(str));
2822
3097
  if (!(var || no_error))
2823
3098
    my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str);
2824
3099
 
2977
3252
}
2978
3253
 
2979
3254
 
2980
 
int set_var_user::update(THD *thd __attribute__((unused)))
 
3255
int set_var_user::update(THD *thd __attribute__((__unused__)))
2981
3256
{
2982
3257
  if (user_var_item->update())
2983
3258
  {
2998
3273
{
2999
3274
  char buff[STRING_BUFFER_USUAL_SIZE];
3000
3275
  const char *value;
3001
 
  String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res;
 
3276
  String str(buff, sizeof(buff), &my_charset_latin1), *res;
3002
3277
 
3003
3278
  var->save_result.plugin= NULL;
3004
3279
  if (var->value->result_type() == STRING_RESULT)
3009
3284
        !(engine_name.str= (char *)res->ptr()) ||
3010
3285
        !(engine_name.length= res->length()) ||
3011
3286
        !(var->save_result.plugin= ha_resolve_by_name(thd, &engine_name)) ||
3012
 
        !(hton= plugin_data(var->save_result.plugin, handlerton *)))
 
3287
        !(hton= plugin_data(var->save_result.plugin, handlerton *)) ||
 
3288
        ha_checktype(thd, ha_legacy_type(hton), 1, 0) != hton)
3013
3289
    {
3014
3290
      value= res ? res->c_ptr() : "NULL";
3015
3291
      goto err;
3024
3300
}
3025
3301
 
3026
3302
 
3027
 
unsigned char *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
3028
 
                                             LEX_STRING *base __attribute__((unused)))
 
3303
uchar *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
 
3304
                                             LEX_STRING *base __attribute__((__unused__)))
3029
3305
{
3030
 
  unsigned char* result;
 
3306
  uchar* result;
3031
3307
  handlerton *hton;
3032
3308
  LEX_STRING *engine_name;
3033
3309
  plugin_ref plugin= thd->variables.*offset;
3035
3311
    plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
3036
3312
  hton= plugin_data(plugin, handlerton*);
3037
3313
  engine_name= &hton2plugin[hton->slot]->name;
3038
 
  result= (unsigned char *) thd->strmake(engine_name->str, engine_name->length);
 
3314
  result= (uchar *) thd->strmake(engine_name->str, engine_name->length);
3039
3315
  if (type == OPT_GLOBAL)
3040
3316
    plugin_unlock(thd, plugin);
3041
3317
  return result;
3081
3357
symbolic_mode_representation(THD *thd, uint64_t val, LEX_STRING *rep)
3082
3358
{
3083
3359
  char buff[STRING_BUFFER_USUAL_SIZE*8];
3084
 
  String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
3360
  String tmp(buff, sizeof(buff), &my_charset_latin1);
3085
3361
 
3086
3362
  tmp.length(0);
3087
3363
 
3088
 
  for (uint32_t i= 0; val; val>>= 1, i++)
 
3364
  for (uint i= 0; val; val>>= 1, i++)
3089
3365
  {
3090
3366
    if (val & 1)
3091
3367
    {
3106
3382
}
3107
3383
 
3108
3384
 
3109
 
unsigned char *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3110
 
                                               LEX_STRING *base __attribute__((unused)))
 
3385
uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
 
3386
                                               LEX_STRING *base __attribute__((__unused__)))
3111
3387
{
3112
3388
  LEX_STRING opts;
3113
3389
  uint64_t val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3114
3390
                  thd->variables.*offset);
3115
3391
  (void) symbolic_mode_representation(thd, val, &opts);
3116
 
  return (unsigned char *) opts.str;
 
3392
  return (uchar *) opts.str;
3117
3393
}
3118
3394
 
3119
3395
 
3130
3406
  Named list handling
3131
3407
****************************************************************************/
3132
3408
 
3133
 
unsigned char* find_named(I_List<NAMED_LIST> *list, const char *name, uint32_t length,
 
3409
uchar* find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
3134
3410
                NAMED_LIST **found)
3135
3411
{
3136
3412
  I_List_iterator<NAMED_LIST> it(*list);
3149
3425
 
3150
3426
 
3151
3427
void delete_elements(I_List<NAMED_LIST> *list,
3152
 
                     void (*free_element)(const char *name, unsigned char*))
 
3428
                     void (*free_element)(const char *name, uchar*))
3153
3429
{
3154
3430
  NAMED_LIST *element;
3155
3431
  while ((element= list->get()))
3163
3439
 
3164
3440
/* Key cache functions */
3165
3441
 
3166
 
static KEY_CACHE *create_key_cache(const char *name, uint32_t length)
 
3442
static KEY_CACHE *create_key_cache(const char *name, uint length)
3167
3443
{
3168
3444
  KEY_CACHE *key_cache;
3169
3445
  
3170
3446
  if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
3171
3447
                                             MYF(MY_ZEROFILL | MY_WME))))
3172
3448
  {
3173
 
    if (!new NAMED_LIST(&key_caches, name, length, (unsigned char*) key_cache))
 
3449
    if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache))
3174
3450
    {
3175
 
      free((char*) key_cache);
 
3451
      my_free((char*) key_cache, MYF(0));
3176
3452
      key_cache= 0;
3177
3453
    }
3178
3454
    else
3192
3468
}
3193
3469
 
3194
3470
 
3195
 
KEY_CACHE *get_or_create_key_cache(const char *name, uint32_t length)
 
3471
KEY_CACHE *get_or_create_key_cache(const char *name, uint length)
3196
3472
{
3197
3473
  LEX_STRING key_cache_name;
3198
3474
  KEY_CACHE *key_cache;
3207
3483
}
3208
3484
 
3209
3485
 
3210
 
void free_key_cache(const char *name __attribute__((unused)),
 
3486
void free_key_cache(const char *name __attribute__((__unused__)),
3211
3487
                    KEY_CACHE *key_cache)
3212
3488
{
3213
3489
  ha_end_key_cache(key_cache);
3214
 
  free((char*) key_cache);
 
3490
  my_free((char*) key_cache, MYF(0));
3215
3491
}
3216
3492
 
3217
3493