~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/set_var.cc

Removed/replaced DBUG symbols and standardized TRUE/FALSE

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 
43
43
  @note
44
44
    Be careful with var->save_result: sys_var::check() only updates
45
 
    uint64_t_value; so other members of the union are garbage then; to use
 
45
    ulonglong_value; so other members of the union are garbage then; to use
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);
107
113
static void fix_thd_mem_root(THD *thd, enum_var_type type);
108
114
static void fix_trans_mem_root(THD *thd, enum_var_type type);
109
115
static void fix_server_id(THD *thd, enum_var_type type);
110
 
static uint64_t fix_unsigned(THD *, uint64_t, const struct my_option *);
 
116
static ulonglong fix_unsigned(THD *, ulonglong, const struct my_option *);
111
117
static bool get_unsigned(THD *thd, set_var *var);
112
118
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
113
 
                          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);
 
119
                          const char *name, longlong val);
 
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);
240
260
                                               &max_connect_errors);
241
261
static sys_var_thd_ulong        sys_max_error_count(&vars, "max_error_count",
242
262
                                            &SV::max_error_count);
243
 
static sys_var_thd_uint64_t     sys_max_heap_table_size(&vars, "max_heap_table_size",
 
263
static sys_var_thd_ulonglong    sys_max_heap_table_size(&vars, "max_heap_table_size",
244
264
                                                &SV::max_heap_table_size);
245
265
static sys_var_thd_ulong sys_pseudo_thread_id(&vars, "pseudo_thread_id",
246
266
                                              &SV::pseudo_thread_id,
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);
268
 
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);
 
293
static sys_var_long_ptr sys_myisam_data_pointer_size(&vars, "myisam_data_pointer_size",
 
294
                                                    &myisam_data_pointer_size);
 
295
static sys_var_thd_ulonglong    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);
271
298
 
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",
379
414
                                         &tx_isolation_typelib,
380
415
                                         fix_tx_isolation,
381
416
                                         check_tx_isolation);
382
 
static sys_var_thd_uint64_t     sys_tmp_table_size(&vars, "tmp_table_size",
 
417
static sys_var_thd_ulonglong    sys_tmp_table_size(&vars, "tmp_table_size",
383
418
                                           &SV::tmp_table_size);
384
 
static sys_var_bool_ptr  sys_timed_mutexes(&vars, "timed_mutexes", &timed_mutexes);
 
419
static sys_var_bool_ptr  sys_timed_mutexes(&vars, "timed_mutexes",
 
420
                                    &timed_mutexes);
385
421
static sys_var_const_str        sys_version(&vars, "version", server_version);
386
422
static sys_var_const_str        sys_version_comment(&vars, "version_comment",
387
 
                                            DRIZZLE_COMPILATION_COMMENT);
 
423
                                            MYSQL_COMPILATION_COMMENT);
388
424
static sys_var_const_str        sys_version_compile_machine(&vars, "version_compile_machine",
389
425
                                                    MACHINE_TYPE);
390
426
static sys_var_const_str        sys_version_compile_os(&vars, "version_compile_os",
401
437
 
402
438
static sys_var_thd_date_time_format sys_time_format(&vars, "time_format",
403
439
                                             &SV::time_format,
404
 
                                             DRIZZLE_TIMESTAMP_TIME);
 
440
                                             MYSQL_TIMESTAMP_TIME);
405
441
static sys_var_thd_date_time_format sys_date_format(&vars, "date_format",
406
442
                                             &SV::date_format,
407
 
                                             DRIZZLE_TIMESTAMP_DATE);
 
443
                                             MYSQL_TIMESTAMP_DATE);
408
444
static sys_var_thd_date_time_format sys_datetime_format(&vars, "datetime_format",
409
445
                                                 &SV::datetime_format,
410
 
                                                 DRIZZLE_TIMESTAMP_DATETIME);
 
446
                                                 MYSQL_TIMESTAMP_DATETIME);
411
447
 
412
448
/* Variables that are bits in THD */
413
449
 
426
462
static sys_var_thd_bit  sys_big_selects(&vars, "sql_big_selects", 0,
427
463
                                        set_option_bit,
428
464
                                        OPTION_BIG_SELECTS);
 
465
static sys_var_thd_bit  sys_log_off(&vars, "sql_log_off",
 
466
                                    check_log_update,
 
467
                                    set_option_bit,
 
468
                                    OPTION_LOG_OFF);
 
469
static sys_var_thd_bit  sys_log_update(&vars, "sql_log_update",
 
470
                                       check_log_update,
 
471
                                       set_log_update,
 
472
                                       OPTION_BIN_LOG);
429
473
static sys_var_thd_bit  sys_log_binlog(&vars, "sql_log_bin",
430
474
                                       check_log_update,
431
475
                                       set_option_bit,
436
480
static sys_var_thd_bit  sys_sql_notes(&vars, "sql_notes", 0,
437
481
                                         set_option_bit,
438
482
                                         OPTION_SQL_NOTES);
 
483
static sys_var_thd_bit  sys_auto_is_null(&vars, "sql_auto_is_null", 0,
 
484
                                         set_option_bit,
 
485
                                         OPTION_AUTO_IS_NULL, 0,
 
486
                                         sys_var::SESSION_VARIABLE_IN_BINLOG);
439
487
static sys_var_thd_bit  sys_safe_updates(&vars, "sql_safe_updates", 0,
440
488
                                         set_option_bit,
441
489
                                         OPTION_SAFE_UPDATES);
523
571
static sys_var_const_str_ptr    sys_repl_report_user(&vars, "report_user", &report_user);
524
572
static sys_var_const_str_ptr    sys_repl_report_password(&vars, "report_password", &report_password);
525
573
 
526
 
static unsigned char *slave_get_report_port(THD *thd)
 
574
static uchar *slave_get_report_port(THD *thd)
527
575
{
528
576
  thd->sys_var_tmp.long_value= report_port;
529
 
  return (unsigned char*) &thd->sys_var_tmp.long_value;
 
577
  return (uchar*) &thd->sys_var_tmp.long_value;
530
578
}
531
579
 
532
580
static sys_var_readonly    sys_repl_report_port(&vars, "report_port", OPT_GLOBAL, SHOW_INT, slave_get_report_port);
536
584
/* Read only variables */
537
585
 
538
586
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
 
587
static sys_var_have_variable sys_have_crypt(&vars, "have_crypt", &have_crypt);
 
588
static sys_var_have_plugin sys_have_csv(&vars, "have_csv", C_STRING_WITH_LEN("csv"), MYSQL_STORAGE_ENGINE_PLUGIN);
 
589
static sys_var_have_variable sys_have_dlopen(&vars, "have_dynamic_loading", &have_dlopen);
 
590
static sys_var_have_plugin sys_have_innodb(&vars, "have_innodb", C_STRING_WITH_LEN("innodb"), MYSQL_STORAGE_ENGINE_PLUGIN);
539
591
static sys_var_have_variable sys_have_symlink(&vars, "have_symlink", &have_symlink);
 
592
/* Global read-only variable describing server license */
 
593
static sys_var_const_str        sys_license(&vars, "license", STRINGIFY_ARG(LICENSE));
 
594
/* Global variables which enable|disable logging */
 
595
static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log,
 
596
                                      QUERY_LOG_GENERAL);
 
597
/* Synonym of "general_log" for consistency with SHOW VARIABLES output */
 
598
static sys_var_log_state sys_var_log(&vars, "log", &opt_log,
 
599
                                      QUERY_LOG_GENERAL);
 
600
static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
 
601
                                         QUERY_LOG_SLOW);
 
602
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
 
603
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
 
604
                                          &opt_slow_log, QUERY_LOG_SLOW);
 
605
sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path,
 
606
                                     sys_update_general_log_path,
 
607
                                     sys_default_general_log_path,
 
608
                                     opt_logname);
 
609
sys_var_str sys_var_slow_log_path(&vars, "slow_query_log_file", sys_check_log_path,
 
610
                                  sys_update_slow_log_path, 
 
611
                                  sys_default_slow_log_path,
 
612
                                  opt_slow_logname);
 
613
static sys_var_log_output sys_var_log_output_state(&vars, "log_output", &log_output_options,
 
614
                                            &log_output_typelib, 0);
 
615
 
 
616
 
540
617
/*
541
618
  Additional variables (not derived from sys_var class, not accessible as
542
619
  @@varname in SELECT or SET). Sorted in alphabetical order to facilitate
547
624
#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(SHOW_VAR))
548
625
static SHOW_VAR fixed_vars[]= {
549
626
  {"back_log",                (char*) &back_log,                    SHOW_LONG},
 
627
  {"character_sets_dir",      mysql_charsets_dir,                   SHOW_CHAR},
550
628
  {"init_file",               (char*) &opt_init_file,               SHOW_CHAR_PTR},
551
629
  {"language",                language,                             SHOW_CHAR},
552
630
#ifdef HAVE_MLOCKALL
554
632
#endif
555
633
  {"log_bin",                 (char*) &opt_bin_log,                 SHOW_BOOL},
556
634
  {"log_error",               (char*) log_error_file,               SHOW_CHAR},
 
635
  {"lower_case_file_system",  (char*) &lower_case_file_system,      SHOW_MY_BOOL},
 
636
  {"lower_case_table_names",  (char*) &lower_case_table_names,      SHOW_INT},
557
637
  {"myisam_recover_options",  (char*) &myisam_recover_options_str,  SHOW_CHAR_PTR},
558
638
  {"open_files_limit",        (char*) &open_files_limit,            SHOW_LONG},
559
639
  {"pid_file",                (char*) pidfile_name,                 SHOW_CHAR},
560
640
  {"plugin_dir",              (char*) opt_plugin_dir,               SHOW_CHAR},
561
641
  {"port",                    (char*) &mysqld_port,                 SHOW_INT},
562
642
  {"protocol_version",        (char*) &protocol_version,            SHOW_INT},
 
643
  {"skip_external_locking",   (char*) &my_disable_locking,          SHOW_MY_BOOL},
 
644
  {"skip_networking",         (char*) &opt_disable_networking,      SHOW_BOOL},
 
645
  {"skip_show_database",      (char*) &opt_skip_show_db,            SHOW_BOOL},
563
646
  {"thread_stack",            (char*) &my_thread_stack_size,        SHOW_LONG},
564
647
};
565
648
 
566
649
 
567
 
bool sys_var::check(THD *thd __attribute__((unused)), set_var *var)
 
650
bool sys_var::check(THD *thd __attribute__((__unused__)), set_var *var)
568
651
{
569
 
  var->save_result.uint64_t_value= var->value->val_int();
 
652
  var->save_result.ulonglong_value= var->value->val_int();
570
653
  return 0;
571
654
}
572
655
 
599
682
                        set_var *var)
600
683
{
601
684
  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);
 
685
  uint new_length= (var ? var->value->str_value.length() : 0);
603
686
  if (!old_value)
604
687
    old_value= (char*) "";
605
688
  if (!(res= my_strndup(old_value, new_length, MYF(0))))
613
696
  var_str->value= res;
614
697
  var_str->value_length= new_length;
615
698
  rw_unlock(var_mutex);
616
 
  free(old_value);
 
699
  my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
617
700
  return 0;
618
701
}
619
702
 
620
703
 
621
 
static bool sys_update_init_connect(THD *thd __attribute__((unused)), set_var *var)
 
704
static bool sys_update_init_connect(THD *thd __attribute__((__unused__)), set_var *var)
622
705
{
623
706
  return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var);
624
707
}
625
708
 
626
709
 
627
 
static void sys_default_init_connect(THD* thd __attribute__((unused)),
628
 
                                     enum_var_type type __attribute__((unused)))
 
710
static void sys_default_init_connect(THD* thd __attribute__((__unused__)),
 
711
                                     enum_var_type type __attribute__((__unused__)))
629
712
{
630
713
  update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, 0);
631
714
}
632
715
 
633
716
 
634
 
static bool sys_update_init_slave(THD *thd __attribute__((unused)),
 
717
static bool sys_update_init_slave(THD *thd __attribute__((__unused__)),
635
718
                                  set_var *var)
636
719
{
637
720
  return update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, var);
638
721
}
639
722
 
640
723
 
641
 
static void sys_default_init_slave(THD* thd __attribute__((unused)),
642
 
                                   enum_var_type type __attribute__((unused)))
 
724
static void sys_default_init_slave(THD* thd __attribute__((__unused__)),
 
725
                                   enum_var_type type __attribute__((__unused__)))
643
726
{
644
727
  update_sys_var_str(&sys_init_slave, &LOCK_sys_init_slave, 0);
645
728
}
663
746
 
664
747
 
665
748
static void
666
 
fix_myisam_max_sort_file_size(THD *thd __attribute__((unused)),
667
 
                              enum_var_type type __attribute__((unused)))
 
749
fix_myisam_max_sort_file_size(THD *thd __attribute__((__unused__)),
 
750
                              enum_var_type type __attribute__((__unused__)))
668
751
{
669
752
  myisam_max_temp_length=
670
753
    (my_off_t) global_system_variables.myisam_max_sort_file_size;
714
797
static void fix_completion_type(THD *thd __attribute__((unused)),
715
798
                                enum_var_type type __attribute__((unused))) {}
716
799
 
717
 
static int check_completion_type(THD *thd __attribute__((unused)),
 
800
static int check_completion_type(THD *thd __attribute__((__unused__)),
718
801
                                 set_var *var)
719
802
{
720
 
  int64_t val= var->value->val_int();
 
803
  longlong val= var->value->val_int();
721
804
  if (val < 0 || val > 2)
722
805
  {
723
806
    char buf[64];
732
815
  If we are changing the thread variable, we have to copy it to NET too
733
816
*/
734
817
 
 
818
#ifdef HAVE_REPLICATION
735
819
static void fix_net_read_timeout(THD *thd, enum_var_type type)
736
820
{
737
821
  if (type != OPT_GLOBAL)
750
834
  if (type != OPT_GLOBAL)
751
835
    thd->net.retry_count=thd->variables.net_retry_count;
752
836
}
753
 
 
754
 
 
755
 
extern void fix_delay_key_write(THD *thd __attribute__((unused)),
756
 
                                enum_var_type type __attribute__((unused)))
 
837
#else /* HAVE_REPLICATION */
 
838
static void fix_net_read_timeout(THD *thd __attribute__((unused)),
 
839
                                 enum_var_type type __attribute__((unused)))
 
840
{}
 
841
static void fix_net_write_timeout(THD *thd __attribute__((unused)),
 
842
                                  enum_var_type type __attribute__((unused)))
 
843
{}
 
844
static void fix_net_retry_count(THD *thd __attribute__((unused)),
 
845
                                enum_var_type type __attribute__((unused)))
 
846
{}
 
847
#endif /* HAVE_REPLICATION */
 
848
 
 
849
 
 
850
extern void fix_delay_key_write(THD *thd __attribute__((__unused__)),
 
851
                                enum_var_type type __attribute__((__unused__)))
757
852
{
758
853
  switch ((enum_delay_key_write) delay_key_write_options) {
759
854
  case DELAY_KEY_WRITE_NONE:
769
864
  }
770
865
}
771
866
 
772
 
bool sys_var_set::update(THD *thd __attribute__((unused)),
 
867
bool sys_var_set::update(THD *thd __attribute__((__unused__)),
773
868
                         set_var *var)
774
869
{
775
870
  *value= var->save_result.ulong_value;
776
871
  return 0;
777
872
}
778
873
 
779
 
unsigned char *sys_var_set::value_ptr(THD *thd,
780
 
                              enum_var_type type __attribute__((unused)),
781
 
                              LEX_STRING *base __attribute__((unused)))
 
874
uchar *sys_var_set::value_ptr(THD *thd,
 
875
                              enum_var_type type __attribute__((__unused__)),
 
876
                              LEX_STRING *base __attribute__((__unused__)))
782
877
{
783
878
  char buff[256];
784
 
  String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
879
  String tmp(buff, sizeof(buff), &my_charset_latin1);
785
880
  ulong length;
786
881
  ulong val= *value;
787
882
 
788
883
  tmp.length(0);
789
 
  for (uint32_t i= 0; val; val>>= 1, i++)
 
884
  for (uint i= 0; val; val>>= 1, i++)
790
885
  {
791
886
    if (val & 1)
792
887
    {
798
893
 
799
894
  if ((length= tmp.length()))
800
895
    length--;
801
 
  return (unsigned char*) thd->strmake(tmp.ptr(), length);
 
896
  return (uchar*) thd->strmake(tmp.ptr(), length);
802
897
}
803
898
 
804
 
void sys_var_set_slave_mode::set_default(THD *thd __attribute__((unused)),
805
 
                                         enum_var_type type __attribute__((unused)))
 
899
void sys_var_set_slave_mode::set_default(THD *thd __attribute__((__unused__)),
 
900
                                         enum_var_type type __attribute__((__unused__)))
806
901
{
807
902
  slave_exec_mode_options= 0;
808
903
  bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT);
830
925
  return rc;
831
926
}
832
927
 
833
 
void fix_slave_exec_mode(enum_var_type type __attribute__((unused)))
 
928
void fix_slave_exec_mode(enum_var_type type __attribute__((__unused__)))
834
929
{
 
930
  compile_time_assert(sizeof(slave_exec_mode_options) * CHAR_BIT
 
931
                      > SLAVE_EXEC_MODE_LAST_BIT - 1);
835
932
  if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
836
933
      bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
837
934
  {
838
 
    sql_print_error(_("Ambiguous slave modes combination."
839
 
                    " STRICT will be used"));
 
935
    sql_print_error("Ambiguous slave modes combination."
 
936
                    " STRICT will be used");
840
937
    bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
841
938
  }
842
939
  if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
879
976
 
880
977
 
881
978
void fix_binlog_format_after_update(THD *thd,
882
 
                                    enum_var_type type __attribute__((unused)))
 
979
                                    enum_var_type type __attribute__((__unused__)))
883
980
{
884
981
  thd->reset_current_stmt_binlog_row_based();
885
982
}
886
983
 
887
984
 
888
 
static void fix_max_binlog_size(THD *thd __attribute__((unused)),
889
 
                                enum_var_type type __attribute__((unused)))
 
985
static void fix_max_binlog_size(THD *thd __attribute__((__unused__)),
 
986
                                enum_var_type type __attribute__((__unused__)))
890
987
{
891
988
  mysql_bin_log.set_max_size(max_binlog_size);
 
989
#ifdef HAVE_REPLICATION
892
990
  if (!max_relay_log_size)
893
991
    active_mi->rli.relay_log.set_max_size(max_binlog_size);
 
992
#endif
894
993
  return;
895
994
}
896
995
 
897
 
static void fix_max_relay_log_size(THD *thd __attribute__((unused)),
898
 
                                   enum_var_type type __attribute__((unused)))
 
996
static void fix_max_relay_log_size(THD *thd __attribute__((__unused__)),
 
997
                                   enum_var_type type __attribute__((__unused__)))
899
998
{
 
999
#ifdef HAVE_REPLICATION
900
1000
  active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
901
1001
                                        max_relay_log_size: max_binlog_size);
 
1002
#endif
902
1003
  return;
903
1004
}
904
1005
 
905
 
static void fix_max_connections(THD *thd __attribute__((unused)),
906
 
                                enum_var_type type __attribute__((unused)))
 
1006
static void fix_max_connections(THD *thd __attribute__((__unused__)),
 
1007
                                enum_var_type type __attribute__((__unused__)))
907
1008
{
908
1009
  resize_thr_alarm(max_connections +  10);
909
1010
}
927
1028
}
928
1029
 
929
1030
 
930
 
static void fix_server_id(THD *thd __attribute__((unused)),
931
 
                          enum_var_type type __attribute__((unused)))
 
1031
static void fix_server_id(THD *thd __attribute__((__unused__)),
 
1032
                          enum_var_type type __attribute__((__unused__)))
932
1033
{
933
1034
  server_id_supplied = 1;
934
1035
  thd->server_id= server_id;
936
1037
 
937
1038
 
938
1039
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
939
 
                          const char *name, int64_t val)
 
1040
                          const char *name, longlong val)
940
1041
{
941
1042
  if (fixed)
942
1043
  {
943
1044
    char buf[22];
944
1045
 
945
1046
    if (unsignd)
946
 
      ullstr((uint64_t) val, buf);
 
1047
      ullstr((ulonglong) val, buf);
947
1048
    else
948
1049
      llstr(val, buf);
949
1050
 
950
 
    push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1051
    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
951
1052
                        ER_TRUNCATED_WRONG_VALUE,
952
1053
                        ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
953
1054
  }
954
1055
  return false;
955
1056
}
956
1057
 
957
 
static uint64_t fix_unsigned(THD *thd, uint64_t num,
 
1058
static ulonglong fix_unsigned(THD *thd, ulonglong num,
958
1059
                              const struct my_option *option_limits)
959
1060
{
960
 
  bool fixed= false;
961
 
  uint64_t out= getopt_ull_limit_value(num, option_limits, &fixed);
 
1061
  my_bool fixed= false;
 
1062
  ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
962
1063
 
963
 
  throw_bounds_warning(thd, fixed, true, option_limits->name, (int64_t) num);
 
1064
  throw_bounds_warning(thd, fixed, true, option_limits->name, (longlong) num);
964
1065
  return out;
965
1066
}
966
1067
 
967
 
static bool get_unsigned(THD *thd __attribute__((unused)), set_var *var)
 
1068
static bool get_unsigned(THD *thd __attribute__((__unused__)), set_var *var)
968
1069
{
969
1070
  if (var->value->unsigned_flag)
970
 
    var->save_result.uint64_t_value= (uint64_t) var->value->val_int();
 
1071
    var->save_result.ulonglong_value= (ulonglong) var->value->val_int();
971
1072
  else
972
1073
  {
973
 
    int64_t v= var->value->val_int();
974
 
    var->save_result.uint64_t_value= (uint64_t) ((v < 0) ? 0 : v);
 
1074
    longlong v= var->value->val_int();
 
1075
    var->save_result.ulonglong_value= (ulonglong) ((v < 0) ? 0 : v);
975
1076
  }
976
1077
  return 0;
977
1078
}
992
1093
 
993
1094
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
994
1095
{
995
 
  uint64_t tmp= var->save_result.uint64_t_value;
 
1096
  ulonglong tmp= var->save_result.ulonglong_value;
996
1097
  pthread_mutex_lock(guard);
997
1098
  if (option_limits)
998
1099
    *value= (ulong) fix_unsigned(thd, tmp, option_limits);
1004
1105
    {
1005
1106
      tmp= ULONG_MAX;
1006
1107
      throw_bounds_warning(thd, true, true, name,
1007
 
                           (int64_t) var->save_result.uint64_t_value);
 
1108
                           (longlong) var->save_result.ulonglong_value);
1008
1109
    }
1009
1110
#endif
1010
1111
    *value= (ulong) tmp;
1015
1116
}
1016
1117
 
1017
1118
 
1018
 
void sys_var_long_ptr_global::set_default(THD *thd __attribute__((unused)), enum_var_type type __attribute__((unused)))
 
1119
void sys_var_long_ptr_global::set_default(THD *thd __attribute__((__unused__)), enum_var_type type __attribute__((__unused__)))
1019
1120
{
1020
 
  bool not_used;
 
1121
  my_bool not_used;
1021
1122
  pthread_mutex_lock(guard);
1022
1123
  *value= (ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
1023
1124
                                         option_limits, &not_used);
1025
1126
}
1026
1127
 
1027
1128
 
1028
 
bool sys_var_uint64_t_ptr::update(THD *thd, set_var *var)
 
1129
bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
1029
1130
{
1030
 
  uint64_t tmp= var->save_result.uint64_t_value;
 
1131
  ulonglong tmp= var->save_result.ulonglong_value;
1031
1132
  pthread_mutex_lock(&LOCK_global_system_variables);
1032
1133
  if (option_limits)
1033
 
    *value= (uint64_t) fix_unsigned(thd, tmp, option_limits);
 
1134
    *value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
1034
1135
  else
1035
 
    *value= (uint64_t) tmp;
 
1136
    *value= (ulonglong) tmp;
1036
1137
  pthread_mutex_unlock(&LOCK_global_system_variables);
1037
1138
  return 0;
1038
1139
}
1039
1140
 
1040
1141
 
1041
 
void sys_var_uint64_t_ptr::set_default(THD *thd __attribute__((unused)),
1042
 
                                        enum_var_type type __attribute__((unused)))
 
1142
void sys_var_ulonglong_ptr::set_default(THD *thd __attribute__((__unused__)),
 
1143
                                        enum_var_type type __attribute__((__unused__)))
1043
1144
{
1044
 
  bool not_used;
 
1145
  my_bool not_used;
1045
1146
  pthread_mutex_lock(&LOCK_global_system_variables);
1046
 
  *value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
 
1147
  *value= getopt_ull_limit_value((ulonglong) option_limits->def_value,
1047
1148
                                 option_limits, &not_used);
1048
1149
  pthread_mutex_unlock(&LOCK_global_system_variables);
1049
1150
}
1050
1151
 
1051
1152
 
1052
 
bool sys_var_bool_ptr::update(THD *thd __attribute__((unused)), set_var *var)
 
1153
bool sys_var_bool_ptr::update(THD *thd __attribute__((__unused__)), set_var *var)
1053
1154
{
1054
 
  *value= (bool) var->save_result.ulong_value;
 
1155
  *value= (my_bool) var->save_result.ulong_value;
1055
1156
  return 0;
1056
1157
}
1057
1158
 
1058
1159
 
1059
 
void sys_var_bool_ptr::set_default(THD *thd __attribute__((unused)), enum_var_type type __attribute__((unused)))
 
1160
void sys_var_bool_ptr::set_default(THD *thd __attribute__((__unused__)), enum_var_type type __attribute__((__unused__)))
1060
1161
{
1061
 
  *value= (bool) option_limits->def_value;
 
1162
  *value= (my_bool) option_limits->def_value;
1062
1163
}
1063
1164
 
1064
1165
 
1065
 
bool sys_var_enum::update(THD *thd __attribute__((unused)), set_var *var)
 
1166
bool sys_var_enum::update(THD *thd __attribute__((__unused__)), set_var *var)
1066
1167
{
1067
1168
  *value= (uint) var->save_result.ulong_value;
1068
1169
  return 0;
1069
1170
}
1070
1171
 
1071
1172
 
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)))
 
1173
uchar *sys_var_enum::value_ptr(THD *thd __attribute__((__unused__)),
 
1174
                               enum_var_type type __attribute__((__unused__)),
 
1175
                               LEX_STRING *base __attribute__((__unused__)))
1075
1176
{
1076
 
  return (unsigned char*) enum_names->type_names[*value];
 
1177
  return (uchar*) enum_names->type_names[*value];
1077
1178
}
1078
1179
 
1079
1180
 
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)))
 
1181
uchar *sys_var_enum_const::value_ptr(THD *thd __attribute__((__unused__)),
 
1182
                                     enum_var_type type __attribute__((__unused__)),
 
1183
                                     LEX_STRING *base __attribute__((__unused__)))
1083
1184
{
1084
 
  return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
 
1185
  return (uchar*) enum_names->type_names[global_system_variables.*offset];
1085
1186
}
1086
1187
 
1087
1188
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1092
1193
 
1093
1194
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
1094
1195
{
1095
 
  uint64_t tmp= var->save_result.uint64_t_value;
 
1196
  ulonglong tmp= var->save_result.ulonglong_value;
1096
1197
  
1097
1198
  /* Don't use bigger value than given with --maximum-variable-name=.. */
1098
1199
  if ((ulong) tmp > max_system_variables.*offset)
1099
1200
  {
1100
 
    throw_bounds_warning(thd, true, true, name, (int64_t) tmp);
 
1201
    throw_bounds_warning(thd, true, true, name, (longlong) tmp);
1101
1202
    tmp= max_system_variables.*offset;
1102
1203
  }
1103
1204
  
1107
1208
  else if (tmp > ULONG_MAX)
1108
1209
  {
1109
1210
    tmp= ULONG_MAX;
1110
 
    throw_bounds_warning(thd, true, true, name, (int64_t) var->save_result.uint64_t_value);
 
1211
    throw_bounds_warning(thd, true, true, name, (longlong) var->save_result.ulonglong_value);
1111
1212
  }
1112
1213
#endif
1113
1214
  
1124
1225
 {
1125
1226
   if (type == OPT_GLOBAL)
1126
1227
   {
1127
 
     bool not_used;
 
1228
     my_bool not_used;
1128
1229
     /* We will not come here if option_limits is not set */
1129
1230
     global_system_variables.*offset=
1130
1231
       (ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
1135
1236
 }
1136
1237
 
1137
1238
 
1138
 
unsigned char *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1139
 
                                    LEX_STRING *base __attribute__((unused)))
 
1239
uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
 
1240
                                    LEX_STRING *base __attribute__((__unused__)))
1140
1241
{
1141
1242
  if (type == OPT_GLOBAL)
1142
 
    return (unsigned char*) &(global_system_variables.*offset);
1143
 
  return (unsigned char*) &(thd->variables.*offset);
 
1243
    return (uchar*) &(global_system_variables.*offset);
 
1244
  return (uchar*) &(thd->variables.*offset);
1144
1245
}
1145
1246
 
1146
1247
 
1147
1248
bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
1148
1249
{
1149
 
  uint64_t tmp= var->save_result.uint64_t_value;
 
1250
  ulonglong tmp= var->save_result.ulonglong_value;
1150
1251
 
1151
1252
  /* Don't use bigger value than given with --maximum-variable-name=.. */
1152
1253
  if ((ha_rows) tmp > max_system_variables.*offset)
1171
1272
{
1172
1273
  if (type == OPT_GLOBAL)
1173
1274
  {
1174
 
    bool not_used;
 
1275
    my_bool not_used;
1175
1276
    /* We will not come here if option_limits is not set */
1176
1277
    pthread_mutex_lock(&LOCK_global_system_variables);
1177
1278
    global_system_variables.*offset=
1184
1285
}
1185
1286
 
1186
1287
 
1187
 
unsigned char *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1188
 
                                      LEX_STRING *base __attribute__((unused)))
 
1288
uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
 
1289
                                      LEX_STRING *base __attribute__((__unused__)))
1189
1290
{
1190
1291
  if (type == OPT_GLOBAL)
1191
 
    return (unsigned char*) &(global_system_variables.*offset);
1192
 
  return (unsigned char*) &(thd->variables.*offset);
 
1292
    return (uchar*) &(global_system_variables.*offset);
 
1293
  return (uchar*) &(thd->variables.*offset);
1193
1294
}
1194
1295
 
1195
 
bool sys_var_thd_uint64_t::check(THD *thd, set_var *var)
 
1296
bool sys_var_thd_ulonglong::check(THD *thd, set_var *var)
1196
1297
{
1197
1298
  return get_unsigned(thd, var);
1198
1299
}
1199
1300
 
1200
 
bool sys_var_thd_uint64_t::update(THD *thd,  set_var *var)
 
1301
bool sys_var_thd_ulonglong::update(THD *thd,  set_var *var)
1201
1302
{
1202
 
  uint64_t tmp= var->save_result.uint64_t_value;
 
1303
  ulonglong tmp= var->save_result.ulonglong_value;
1203
1304
 
1204
1305
  if (tmp > max_system_variables.*offset)
1205
1306
    tmp= max_system_variables.*offset;
1210
1311
  {
1211
1312
    /* Lock is needed to make things safe on 32 bit systems */
1212
1313
    pthread_mutex_lock(&LOCK_global_system_variables);
1213
 
    global_system_variables.*offset= (uint64_t) tmp;
 
1314
    global_system_variables.*offset= (ulonglong) tmp;
1214
1315
    pthread_mutex_unlock(&LOCK_global_system_variables);
1215
1316
  }
1216
1317
  else
1217
 
    thd->variables.*offset= (uint64_t) tmp;
 
1318
    thd->variables.*offset= (ulonglong) tmp;
1218
1319
  return 0;
1219
1320
}
1220
1321
 
1221
1322
 
1222
 
void sys_var_thd_uint64_t::set_default(THD *thd, enum_var_type type)
 
1323
void sys_var_thd_ulonglong::set_default(THD *thd, enum_var_type type)
1223
1324
{
1224
1325
  if (type == OPT_GLOBAL)
1225
1326
  {
1226
 
    bool not_used;
 
1327
    my_bool not_used;
1227
1328
    pthread_mutex_lock(&LOCK_global_system_variables);
1228
1329
    global_system_variables.*offset=
1229
 
      getopt_ull_limit_value((uint64_t) option_limits->def_value,
 
1330
      getopt_ull_limit_value((ulonglong) option_limits->def_value,
1230
1331
                             option_limits, &not_used);
1231
1332
    pthread_mutex_unlock(&LOCK_global_system_variables);
1232
1333
  }
1235
1336
}
1236
1337
 
1237
1338
 
1238
 
unsigned char *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
1239
 
                                        LEX_STRING *base __attribute__((unused)))
 
1339
uchar *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type,
 
1340
                                        LEX_STRING *base __attribute__((__unused__)))
1240
1341
{
1241
1342
  if (type == OPT_GLOBAL)
1242
 
    return (unsigned char*) &(global_system_variables.*offset);
1243
 
  return (unsigned char*) &(thd->variables.*offset);
 
1343
    return (uchar*) &(global_system_variables.*offset);
 
1344
  return (uchar*) &(thd->variables.*offset);
1244
1345
}
1245
1346
 
1246
1347
 
1247
1348
bool sys_var_thd_bool::update(THD *thd,  set_var *var)
1248
1349
{
1249
1350
  if (var->type == OPT_GLOBAL)
1250
 
    global_system_variables.*offset= (bool) var->save_result.ulong_value;
 
1351
    global_system_variables.*offset= (my_bool) var->save_result.ulong_value;
1251
1352
  else
1252
 
    thd->variables.*offset= (bool) var->save_result.ulong_value;
 
1353
    thd->variables.*offset= (my_bool) var->save_result.ulong_value;
1253
1354
  return 0;
1254
1355
}
1255
1356
 
1257
1358
void sys_var_thd_bool::set_default(THD *thd,  enum_var_type type)
1258
1359
{
1259
1360
  if (type == OPT_GLOBAL)
1260
 
    global_system_variables.*offset= (bool) option_limits->def_value;
 
1361
    global_system_variables.*offset= (my_bool) option_limits->def_value;
1261
1362
  else
1262
1363
    thd->variables.*offset= global_system_variables.*offset;
1263
1364
}
1264
1365
 
1265
1366
 
1266
 
unsigned char *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1267
 
                                   LEX_STRING *base __attribute__((unused)))
 
1367
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
 
1368
                                   LEX_STRING *base __attribute__((__unused__)))
1268
1369
{
1269
1370
  if (type == OPT_GLOBAL)
1270
 
    return (unsigned char*) &(global_system_variables.*offset);
1271
 
  return (unsigned char*) &(thd->variables.*offset);
 
1371
    return (uchar*) &(global_system_variables.*offset);
 
1372
  return (uchar*) &(thd->variables.*offset);
1272
1373
}
1273
1374
 
1274
1375
 
1275
 
bool sys_var::check_enum(THD *thd __attribute__((unused)),
 
1376
bool sys_var::check_enum(THD *thd __attribute__((__unused__)),
1276
1377
                         set_var *var, const TYPELIB *enum_names)
1277
1378
{
1278
1379
  char buff[STRING_BUFFER_USUAL_SIZE];
1292
1393
  }
1293
1394
  else
1294
1395
  {
1295
 
    uint64_t tmp=var->value->val_int();
 
1396
    ulonglong tmp=var->value->val_int();
1296
1397
    if (tmp >= enum_names->count)
1297
1398
    {
1298
1399
      llstr(tmp,buff);
1309
1410
}
1310
1411
 
1311
1412
 
1312
 
bool sys_var::check_set(THD *thd __attribute__((unused)),
 
1413
bool sys_var::check_set(THD *thd __attribute__((__unused__)),
1313
1414
                        set_var *var, TYPELIB *enum_names)
1314
1415
{
1315
1416
  bool not_used;
1316
1417
  char buff[STRING_BUFFER_USUAL_SIZE], *error= 0;
1317
 
  uint32_t error_len= 0;
 
1418
  uint error_len= 0;
1318
1419
  String str(buff, sizeof(buff), system_charset_info), *res;
1319
1420
 
1320
1421
  if (var->value->result_type() == STRING_RESULT)
1321
1422
  {
1322
1423
    if (!(res= var->value->val_str(&str)))
1323
1424
    {
1324
 
      my_stpcpy(buff, "NULL");
 
1425
      strmov(buff, "NULL");
1325
1426
      goto err;
1326
1427
    }
1327
1428
 
1340
1441
                                            &not_used));
1341
1442
    if (error_len)
1342
1443
    {
1343
 
      strmake(buff, error, cmin(sizeof(buff) - 1, (ulong)error_len));
 
1444
      strmake(buff, error, min(sizeof(buff) - 1, error_len));
1344
1445
      goto err;
1345
1446
    }
1346
1447
  }
1347
1448
  else
1348
1449
  {
1349
 
    uint64_t tmp= var->value->val_int();
 
1450
    ulonglong tmp= var->value->val_int();
1350
1451
 
1351
1452
    if (!m_allow_empty_value &&
1352
1453
        tmp == 0)
1360
1461
      For when the enum is made to contain 64 elements, as 1ULL<<64 is
1361
1462
      undefined, we guard with a "count<64" test.
1362
1463
    */
1363
 
    if (unlikely((tmp >= ((1UL) << enum_names->count)) &&
 
1464
    if (unlikely((tmp >= ((1ULL) << enum_names->count)) &&
1364
1465
                 (enum_names->count < 64)))
1365
1466
    {
1366
1467
      llstr(tmp, buff);
1400
1501
  switch (show_type()) {
1401
1502
  case SHOW_INT:
1402
1503
  {
1403
 
    uint32_t value;
 
1504
    uint value;
1404
1505
    pthread_mutex_lock(&LOCK_global_system_variables);
1405
1506
    value= *(uint*) value_ptr(thd, var_type, base);
1406
1507
    pthread_mutex_unlock(&LOCK_global_system_variables);
1407
 
    return new Item_uint((uint64_t) value);
 
1508
    return new Item_uint((ulonglong) value);
1408
1509
  }
1409
1510
  case SHOW_LONG:
1410
1511
  {
1412
1513
    pthread_mutex_lock(&LOCK_global_system_variables);
1413
1514
    value= *(ulong*) value_ptr(thd, var_type, base);
1414
1515
    pthread_mutex_unlock(&LOCK_global_system_variables);
1415
 
    return new Item_uint((uint64_t) value);
 
1516
    return new Item_uint((ulonglong) value);
1416
1517
  }
1417
1518
  case SHOW_LONGLONG:
1418
1519
  {
1419
 
    int64_t value;
 
1520
    longlong value;
1420
1521
    pthread_mutex_lock(&LOCK_global_system_variables);
1421
 
    value= *(int64_t*) value_ptr(thd, var_type, base);
 
1522
    value= *(longlong*) value_ptr(thd, var_type, base);
1422
1523
    pthread_mutex_unlock(&LOCK_global_system_variables);
1423
1524
    return new Item_int(value);
1424
1525
  }
1437
1538
    pthread_mutex_lock(&LOCK_global_system_variables);
1438
1539
    value= *(ha_rows*) value_ptr(thd, var_type, base);
1439
1540
    pthread_mutex_unlock(&LOCK_global_system_variables);
1440
 
    return new Item_int((uint64_t) value);
 
1541
    return new Item_int((ulonglong) value);
1441
1542
  }
1442
1543
  case SHOW_MY_BOOL:
1443
1544
  {
1444
 
    int32_t value;
 
1545
    int32 value;
1445
1546
    pthread_mutex_lock(&LOCK_global_system_variables);
1446
 
    value= *(bool*) value_ptr(thd, var_type, base);
 
1547
    value= *(my_bool*) value_ptr(thd, var_type, base);
1447
1548
    pthread_mutex_unlock(&LOCK_global_system_variables);
1448
1549
    return new Item_int(value,1);
1449
1550
  }
1454
1555
    char *str= *(char**) value_ptr(thd, var_type, base);
1455
1556
    if (str)
1456
1557
    {
1457
 
      uint32_t length= strlen(str);
 
1558
      uint length= strlen(str);
1458
1559
      tmp= new Item_string(thd->strmake(str, length), length,
1459
1560
                           system_charset_info, DERIVATION_SYSCONST);
1460
1561
    }
1508
1609
}
1509
1610
 
1510
1611
 
1511
 
unsigned char *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1512
 
                                   LEX_STRING *base __attribute__((unused)))
 
1612
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
 
1613
                                   LEX_STRING *base __attribute__((__unused__)))
1513
1614
{
1514
1615
  ulong tmp= ((type == OPT_GLOBAL) ?
1515
1616
              global_system_variables.*offset :
1516
1617
              thd->variables.*offset);
1517
 
  return (unsigned char*) enum_names->type_names[tmp];
 
1618
  return (uchar*) enum_names->type_names[tmp];
1518
1619
}
1519
1620
 
1520
1621
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1530
1631
}
1531
1632
 
1532
1633
 
1533
 
unsigned char *sys_var_thd_bit::value_ptr(THD *thd,
1534
 
                                  enum_var_type type __attribute__((unused)),
1535
 
                                  LEX_STRING *base __attribute__((unused)))
 
1634
uchar *sys_var_thd_bit::value_ptr(THD *thd,
 
1635
                                  enum_var_type type __attribute__((__unused__)),
 
1636
                                  LEX_STRING *base __attribute__((__unused__)))
1536
1637
{
1537
1638
  /*
1538
1639
    If reverse is 0 (default) return 1 if bit is set.
1539
1640
    If reverse is 1, return 0 if bit is set
1540
1641
  */
1541
 
  thd->sys_var_tmp.bool_value= ((thd->options & bit_flag) ?
 
1642
  thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ?
1542
1643
                                   !reverse : reverse);
1543
 
  return (unsigned char*) &thd->sys_var_tmp.bool_value;
 
1644
  return (uchar*) &thd->sys_var_tmp.my_bool_value;
1544
1645
}
1545
1646
 
1546
1647
 
1563
1664
    old= (thd->variables.*offset);
1564
1665
    (thd->variables.*offset)= new_value;
1565
1666
  }
1566
 
  free((char*) old);
 
1667
  my_free((char*) old, MYF(MY_ALLOW_ZERO_PTR));
1567
1668
  return;
1568
1669
}
1569
1670
 
1602
1703
    update is aborted
1603
1704
  */
1604
1705
  var->save_result.date_time_format= date_time_format_copy(thd, format);
1605
 
  free((char*) format);
 
1706
  my_free((char*) format, MYF(0));
1606
1707
  return var->save_result.date_time_format == 0;
1607
1708
}
1608
1709
 
1628
1729
}
1629
1730
 
1630
1731
 
1631
 
unsigned char *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
1632
 
                                               LEX_STRING *base __attribute__((unused)))
 
1732
uchar *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
 
1733
                                               LEX_STRING *base __attribute__((__unused__)))
1633
1734
{
1634
1735
  if (type == OPT_GLOBAL)
1635
1736
  {
1641
1742
    */
1642
1743
    res= thd->strmake((global_system_variables.*offset)->format.str,
1643
1744
                      (global_system_variables.*offset)->format.length);
1644
 
    return (unsigned char*) res;
 
1745
    return (uchar*) res;
1645
1746
  }
1646
 
  return (unsigned char*) (thd->variables.*offset)->format.str;
 
1747
  return (uchar*) (thd->variables.*offset)->format.str;
1647
1748
}
1648
1749
 
1649
1750
 
1653
1754
  const char *new_name;
1654
1755
} my_old_conv;
1655
1756
 
1656
 
bool sys_var_collation::check(THD *thd __attribute__((unused)),
 
1757
static my_old_conv old_conv[]= 
 
1758
{
 
1759
  {     "cp1251_koi8"           ,       "cp1251"        },
 
1760
  {     "cp1250_latin2"         ,       "cp1250"        },
 
1761
  {     "kam_latin2"            ,       "keybcs2"       },
 
1762
  {     "mac_latin2"            ,       "MacRoman"      },
 
1763
  {     "macce_latin2"          ,       "MacCE"         },
 
1764
  {     "pc2_latin2"            ,       "pclatin2"      },
 
1765
  {     "vga_latin2"            ,       "pclatin1"      },
 
1766
  {     "koi8_cp1251"           ,       "koi8r"         },
 
1767
  {     "win1251ukr_koi8_ukr"   ,       "win1251ukr"    },
 
1768
  {     "koi8_ukr_win1251ukr"   ,       "koi8u"         },
 
1769
  {     NULL                    ,       NULL            }
 
1770
};
 
1771
 
 
1772
CHARSET_INFO *get_old_charset_by_name(const char *name)
 
1773
{
 
1774
  my_old_conv *conv;
 
1775
 
 
1776
  for (conv= old_conv; conv->old_name; conv++)
 
1777
  {
 
1778
    if (!my_strcasecmp(&my_charset_latin1, name, conv->old_name))
 
1779
      return get_charset_by_csname(conv->new_name, MY_CS_PRIMARY, MYF(0));
 
1780
  }
 
1781
  return NULL;
 
1782
}
 
1783
 
 
1784
 
 
1785
bool sys_var_collation::check(THD *thd __attribute__((__unused__)),
1657
1786
                              set_var *var)
1658
1787
{
1659
 
  const CHARSET_INFO *tmp;
 
1788
  CHARSET_INFO *tmp;
1660
1789
 
1661
1790
  if (var->value->result_type() == STRING_RESULT)
1662
1791
  {
1688
1817
}
1689
1818
 
1690
1819
 
1691
 
bool sys_var_character_set::check(THD *thd __attribute__((unused)),
 
1820
bool sys_var_character_set::check(THD *thd __attribute__((__unused__)),
1692
1821
                                  set_var *var)
1693
1822
{
1694
 
  const CHARSET_INFO *tmp;
 
1823
  CHARSET_INFO *tmp;
1695
1824
 
1696
1825
  if (var->value->result_type() == STRING_RESULT)
1697
1826
  {
1706
1835
      }
1707
1836
      tmp= NULL;
1708
1837
    }
1709
 
    else if (!(tmp= get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))))
 
1838
    else if (!(tmp=get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))) &&
 
1839
             !(tmp=get_old_charset_by_name(res->c_ptr())))
1710
1840
    {
1711
1841
      my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
1712
1842
      return 1;
1735
1865
}
1736
1866
 
1737
1867
 
1738
 
unsigned char *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1739
 
                                        LEX_STRING *base __attribute__((unused)))
 
1868
uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
 
1869
                                        LEX_STRING *base __attribute__((__unused__)))
1740
1870
{
1741
 
  const CHARSET_INFO * const cs= ci_ptr(thd,type)[0];
1742
 
  return cs ? (unsigned char*) cs->csname : (unsigned char*) NULL;
 
1871
  CHARSET_INFO *cs= ci_ptr(thd,type)[0];
 
1872
  return cs ? (uchar*) cs->csname : (uchar*) NULL;
1743
1873
}
1744
1874
 
1745
1875
 
1753
1883
    thd->update_charset();
1754
1884
  }
1755
1885
}
1756
 
const CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
 
1886
CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
1757
1887
{
1758
1888
  if (type == OPT_GLOBAL)
1759
1889
    return &(global_system_variables.*offset);
1777
1907
}
1778
1908
 
1779
1909
 
1780
 
const CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
 
1910
CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
1781
1911
                                                       enum_var_type type)
1782
1912
{
1783
1913
  if (type == OPT_GLOBAL)
1824
1954
}
1825
1955
 
1826
1956
 
1827
 
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1828
 
                                       LEX_STRING *base __attribute__((unused)))
 
1957
uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
 
1958
                                       LEX_STRING *base __attribute__((__unused__)))
1829
1959
{
1830
 
  const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
 
1960
  CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1831
1961
                     global_system_variables.*offset : thd->variables.*offset);
1832
 
  return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
 
1962
  return cs ? (uchar*) cs->name : (uchar*) "NULL";
1833
1963
}
1834
1964
 
1835
1965
 
1847
1977
}
1848
1978
 
1849
1979
 
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)))
 
1980
uchar *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((__unused__)),
 
1981
                                          enum_var_type type __attribute__((__unused__)),
 
1982
                                          LEX_STRING *base __attribute__((__unused__)))
1853
1983
{
1854
1984
  KEY_CACHE *key_cache= get_key_cache(base);
1855
1985
  if (!key_cache)
1856
1986
    key_cache= &zero_key_cache;
1857
 
  return (unsigned char*) key_cache + offset ;
 
1987
  return (uchar*) key_cache + offset ;
1858
1988
}
1859
1989
 
1860
1990
 
1861
1991
bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
1862
1992
{
1863
 
  uint64_t tmp= var->save_result.uint64_t_value;
 
1993
  ulonglong tmp= var->save_result.ulonglong_value;
1864
1994
  LEX_STRING *base_name= &var->base;
1865
1995
  KEY_CACHE *key_cache;
1866
1996
  bool error= 0;
1896
2026
  {
1897
2027
    if (key_cache == dflt_key_cache)
1898
2028
    {
1899
 
      push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
2029
      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1900
2030
                          ER_WARN_CANT_DROP_DEFAULT_KEYCACHE,
1901
2031
                          ER(ER_WARN_CANT_DROP_DEFAULT_KEYCACHE));
1902
2032
      goto end;                                 // Ignore default key cache
1925
2055
  }
1926
2056
 
1927
2057
  key_cache->param_buff_size=
1928
 
    (uint64_t) fix_unsigned(thd, tmp, option_limits);
 
2058
    (ulonglong) fix_unsigned(thd, tmp, option_limits);
1929
2059
 
1930
2060
  /* If key cache didn't existed initialize it, else resize it */
1931
2061
  key_cache->in_init= 1;
2000
2130
}
2001
2131
 
2002
2132
 
2003
 
bool sys_var_log_state::update(THD *thd __attribute__((unused)), set_var *var)
 
2133
bool sys_var_log_state::update(THD *thd, set_var *var)
2004
2134
{
2005
2135
  bool res;
2006
2136
  pthread_mutex_lock(&LOCK_global_system_variables);
2007
2137
  if (!var->save_result.ulong_value)
 
2138
  {
 
2139
    logger.deactivate_log_handler(thd, log_type);
2008
2140
    res= false;
 
2141
  }
2009
2142
  else
2010
 
    res= true;
 
2143
    res= logger.activate_log_handler(thd, log_type);
2011
2144
  pthread_mutex_unlock(&LOCK_global_system_variables);
2012
2145
  return res;
2013
2146
}
2014
2147
 
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)),
 
2148
void sys_var_log_state::set_default(THD *thd,
 
2149
                                    enum_var_type type __attribute__((__unused__)))
 
2150
{
 
2151
  pthread_mutex_lock(&LOCK_global_system_variables);
 
2152
  logger.deactivate_log_handler(thd, log_type);
 
2153
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
2154
}
 
2155
 
 
2156
 
 
2157
static int  sys_check_log_path(THD *thd __attribute__((__unused__)),
 
2158
                               set_var *var)
 
2159
{
 
2160
  char path[FN_REFLEN], buff[FN_REFLEN];
 
2161
  struct stat f_stat;
 
2162
  String str(buff, sizeof(buff), system_charset_info), *res;
 
2163
  const char *log_file_str;
 
2164
  size_t path_length;
 
2165
 
 
2166
  if (!(res= var->value->val_str(&str)))
 
2167
    goto err;
 
2168
 
 
2169
  log_file_str= res->c_ptr();
 
2170
  bzero(&f_stat, sizeof(struct stat));
 
2171
 
 
2172
  path_length= unpack_filename(path, log_file_str);
 
2173
 
 
2174
  if (!path_length)
 
2175
  {
 
2176
    /* File name is empty. */
 
2177
 
 
2178
    goto err;
 
2179
  }
 
2180
 
 
2181
  if (!stat(path, &f_stat))
 
2182
  {
 
2183
    /*
 
2184
      A file system object exists. Check if argument is a file and we have
 
2185
      'write' permission.
 
2186
    */
 
2187
 
 
2188
    if (!MY_S_ISREG(f_stat.st_mode) ||
 
2189
        !(f_stat.st_mode & MY_S_IWRITE))
 
2190
      goto err;
 
2191
 
 
2192
    return 0;
 
2193
  }
 
2194
 
 
2195
  /* Get dirname of the file path. */
 
2196
  (void) dirname_part(path, log_file_str, &path_length);
 
2197
 
 
2198
  /* Dirname is empty if file path is relative. */
 
2199
  if (!path_length)
 
2200
    return 0;
 
2201
 
 
2202
  /*
 
2203
    Check if directory exists and we have permission to create file and
 
2204
    write to file.
 
2205
  */
 
2206
  if (my_access(path, (F_OK|W_OK)))
 
2207
    goto err;
 
2208
 
 
2209
  return 0;
 
2210
 
 
2211
err:
 
2212
  my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name, 
 
2213
           res ? log_file_str : "NULL");
 
2214
  return 1;
 
2215
}
 
2216
 
 
2217
 
 
2218
bool update_sys_var_str_path(THD *thd __attribute__((__unused__)),
2022
2219
                             sys_var_str *var_str,
2023
2220
                             set_var *var, const char *log_ext,
2024
 
                             bool log_state, uint32_t log_type)
 
2221
                             bool log_state, uint log_type)
2025
2222
{
 
2223
  MYSQL_QUERY_LOG *file_log;
2026
2224
  char buff[FN_REFLEN];
2027
2225
  char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
2028
2226
  bool result= 0;
2029
 
  uint32_t str_length= (var ? var->value->str_value.length() : 0);
 
2227
  uint str_length= (var ? var->value->str_value.length() : 0);
2030
2228
 
2031
2229
  switch (log_type) {
 
2230
  case QUERY_LOG_SLOW:
 
2231
    file_log= logger.get_slow_log_file_handler();
 
2232
    break;
 
2233
  case QUERY_LOG_GENERAL:
 
2234
    file_log= logger.get_log_file_handler();
 
2235
    break;
2032
2236
  default:
2033
2237
    assert(0);                                  // Impossible
2034
2238
  }
2047
2251
  pthread_mutex_lock(&LOCK_global_system_variables);
2048
2252
  logger.lock_exclusive();
2049
2253
 
 
2254
  if (file_log && log_state)
 
2255
    file_log->close(0);
2050
2256
  old_value= var_str->value;
2051
2257
  var_str->value= res;
2052
2258
  var_str->value_length= str_length;
2053
 
  free(old_value);
2054
 
  if (log_state)
 
2259
  my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
 
2260
  if (file_log && log_state)
2055
2261
  {
2056
2262
    switch (log_type) {
 
2263
    case QUERY_LOG_SLOW:
 
2264
      file_log->open_slow_log(sys_var_slow_log_path.value);
 
2265
      break;
 
2266
    case QUERY_LOG_GENERAL:
 
2267
      file_log->open_query_log(sys_var_general_log_path.value);
 
2268
      break;
2057
2269
    default:
2058
2270
      assert(0);
2059
2271
    }
2067
2279
}
2068
2280
 
2069
2281
 
2070
 
bool sys_var_log_output::update(THD *thd __attribute__((unused)),
 
2282
static bool sys_update_general_log_path(THD *thd, set_var * var)
 
2283
{
 
2284
  return update_sys_var_str_path(thd, &sys_var_general_log_path,
 
2285
                                 var, ".log", opt_log, QUERY_LOG_GENERAL);
 
2286
}
 
2287
 
 
2288
 
 
2289
static void sys_default_general_log_path(THD *thd,
 
2290
                                         enum_var_type type __attribute__((__unused__)))
 
2291
{
 
2292
  (void) update_sys_var_str_path(thd, &sys_var_general_log_path,
 
2293
                                 0, ".log", opt_log, QUERY_LOG_GENERAL);
 
2294
}
 
2295
 
 
2296
 
 
2297
static bool sys_update_slow_log_path(THD *thd, set_var * var)
 
2298
{
 
2299
  return update_sys_var_str_path(thd, &sys_var_slow_log_path,
 
2300
                                 var, "-slow.log", opt_slow_log,
 
2301
                                 QUERY_LOG_SLOW);
 
2302
}
 
2303
 
 
2304
 
 
2305
static void sys_default_slow_log_path(THD *thd,
 
2306
                                      enum_var_type type __attribute__((__unused__)))
 
2307
{
 
2308
  (void) update_sys_var_str_path(thd, &sys_var_slow_log_path,
 
2309
                                 0, "-slow.log", opt_slow_log,
 
2310
                                 QUERY_LOG_SLOW);
 
2311
}
 
2312
 
 
2313
 
 
2314
bool sys_var_log_output::update(THD *thd __attribute__((__unused__)),
2071
2315
                                set_var *var)
2072
2316
{
2073
2317
  pthread_mutex_lock(&LOCK_global_system_variables);
2074
2318
  logger.lock_exclusive();
 
2319
  logger.init_slow_log(var->save_result.ulong_value);
 
2320
  logger.init_general_log(var->save_result.ulong_value);
2075
2321
  *value= var->save_result.ulong_value;
2076
2322
  logger.unlock();
2077
2323
  pthread_mutex_unlock(&LOCK_global_system_variables);
2079
2325
}
2080
2326
 
2081
2327
 
2082
 
void sys_var_log_output::set_default(THD *thd __attribute__((unused)),
2083
 
                                     enum_var_type type __attribute__((unused)))
 
2328
void sys_var_log_output::set_default(THD *thd __attribute__((__unused__)),
 
2329
                                     enum_var_type type __attribute__((__unused__)))
2084
2330
{
2085
2331
  pthread_mutex_lock(&LOCK_global_system_variables);
2086
2332
  logger.lock_exclusive();
 
2333
  logger.init_slow_log(LOG_FILE);
 
2334
  logger.init_general_log(LOG_FILE);
2087
2335
  *value= LOG_FILE;
2088
2336
  logger.unlock();
2089
2337
  pthread_mutex_unlock(&LOCK_global_system_variables);
2090
2338
}
2091
2339
 
2092
2340
 
2093
 
unsigned char *sys_var_log_output::value_ptr(THD *thd,
2094
 
                                     enum_var_type type __attribute__((unused)),
2095
 
                                     LEX_STRING *base __attribute__((unused)))
 
2341
uchar *sys_var_log_output::value_ptr(THD *thd,
 
2342
                                     enum_var_type type __attribute__((__unused__)),
 
2343
                                     LEX_STRING *base __attribute__((__unused__)))
2096
2344
{
2097
2345
  char buff[256];
2098
 
  String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
2346
  String tmp(buff, sizeof(buff), &my_charset_latin1);
2099
2347
  ulong length;
2100
2348
  ulong val= *value;
2101
2349
 
2102
2350
  tmp.length(0);
2103
 
  for (uint32_t i= 0; val; val>>= 1, i++)
 
2351
  for (uint i= 0; val; val>>= 1, i++)
2104
2352
  {
2105
2353
    if (val & 1)
2106
2354
    {
2112
2360
 
2113
2361
  if ((length= tmp.length()))
2114
2362
    length--;
2115
 
  return (unsigned char*) thd->strmake(tmp.ptr(), length);
 
2363
  return (uchar*) thd->strmake(tmp.ptr(), length);
2116
2364
}
2117
2365
 
2118
2366
 
2120
2368
  Functions to handle SET NAMES and SET CHARACTER SET
2121
2369
*****************************************************************************/
2122
2370
 
2123
 
int set_var_collation_client::check(THD *thd __attribute__((unused)))
 
2371
int set_var_collation_client::check(THD *thd __attribute__((__unused__)))
2124
2372
{
2125
2373
  /* Currently, UCS-2 cannot be used as a client character set */
2126
2374
  if (character_set_client->mbminlen > 1)
2146
2394
 
2147
2395
bool sys_var_timestamp::update(THD *thd,  set_var *var)
2148
2396
{
2149
 
  thd->set_time((time_t) var->save_result.uint64_t_value);
 
2397
  thd->set_time((time_t) var->save_result.ulonglong_value);
2150
2398
  return 0;
2151
2399
}
2152
2400
 
2153
2401
 
2154
2402
void sys_var_timestamp::set_default(THD *thd,
2155
 
                                    enum_var_type type __attribute__((unused)))
 
2403
                                    enum_var_type type __attribute__((__unused__)))
2156
2404
{
2157
2405
  thd->user_time=0;
2158
2406
}
2159
2407
 
2160
2408
 
2161
 
unsigned char *sys_var_timestamp::value_ptr(THD *thd,
2162
 
                                    enum_var_type type __attribute__((unused)),
2163
 
                                    LEX_STRING *base __attribute__((unused)))
 
2409
uchar *sys_var_timestamp::value_ptr(THD *thd,
 
2410
                                    enum_var_type type __attribute__((__unused__)),
 
2411
                                    LEX_STRING *base __attribute__((__unused__)))
2164
2412
{
2165
2413
  thd->sys_var_tmp.long_value= (long) thd->start_time;
2166
 
  return (unsigned char*) &thd->sys_var_tmp.long_value;
 
2414
  return (uchar*) &thd->sys_var_tmp.long_value;
2167
2415
}
2168
2416
 
2169
2417
 
2170
2418
bool sys_var_last_insert_id::update(THD *thd, set_var *var)
2171
2419
{
2172
2420
  thd->first_successful_insert_id_in_prev_stmt=
2173
 
    var->save_result.uint64_t_value;
 
2421
    var->save_result.ulonglong_value;
2174
2422
  return 0;
2175
2423
}
2176
2424
 
2177
2425
 
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)))
 
2426
uchar *sys_var_last_insert_id::value_ptr(THD *thd,
 
2427
                                         enum_var_type type __attribute__((__unused__)),
 
2428
                                         LEX_STRING *base __attribute__((__unused__)))
2181
2429
{
2182
2430
  /*
2183
2431
    this tmp var makes it robust againt change of type of
2184
2432
    read_first_successful_insert_id_in_prev_stmt().
2185
2433
  */
2186
 
  thd->sys_var_tmp.uint64_t_value= 
 
2434
  thd->sys_var_tmp.ulonglong_value= 
2187
2435
    thd->read_first_successful_insert_id_in_prev_stmt();
2188
 
  return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
 
2436
  return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2189
2437
}
2190
2438
 
2191
2439
 
2192
2440
bool sys_var_insert_id::update(THD *thd, set_var *var)
2193
2441
{
2194
 
  thd->force_one_auto_inc_interval(var->save_result.uint64_t_value);
 
2442
  thd->force_one_auto_inc_interval(var->save_result.ulonglong_value);
2195
2443
  return 0;
2196
2444
}
2197
2445
 
2198
2446
 
2199
 
unsigned char *sys_var_insert_id::value_ptr(THD *thd,
2200
 
                                    enum_var_type type __attribute__((unused)),
2201
 
                                    LEX_STRING *base __attribute__((unused)))
 
2447
uchar *sys_var_insert_id::value_ptr(THD *thd,
 
2448
                                    enum_var_type type __attribute__((__unused__)),
 
2449
                                    LEX_STRING *base __attribute__((__unused__)))
2202
2450
{
2203
 
  thd->sys_var_tmp.uint64_t_value=
 
2451
  thd->sys_var_tmp.ulonglong_value=
2204
2452
    thd->auto_inc_intervals_forced.minimum();
2205
 
  return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
 
2453
  return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2206
2454
}
2207
2455
 
2208
2456
 
2209
2457
bool sys_var_rand_seed1::update(THD *thd, set_var *var)
2210
2458
{
2211
 
  thd->rand.seed1= (ulong) var->save_result.uint64_t_value;
 
2459
  thd->rand.seed1= (ulong) var->save_result.ulonglong_value;
2212
2460
  return 0;
2213
2461
}
2214
2462
 
2215
2463
bool sys_var_rand_seed2::update(THD *thd, set_var *var)
2216
2464
{
2217
 
  thd->rand.seed2= (ulong) var->save_result.uint64_t_value;
 
2465
  thd->rand.seed2= (ulong) var->save_result.ulonglong_value;
2218
2466
  return 0;
2219
2467
}
2220
2468
 
2222
2470
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
2223
2471
{
2224
2472
  char buff[MAX_TIME_ZONE_NAME_LENGTH];
2225
 
  String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
2473
  String str(buff, sizeof(buff), &my_charset_latin1);
2226
2474
  String *res= var->value->val_str(&str);
2227
2475
 
2228
2476
  if (!(var->save_result.time_zone= my_tz_find(thd, res)))
2249
2497
}
2250
2498
 
2251
2499
 
2252
 
unsigned char *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
2253
 
                                        LEX_STRING *base __attribute__((unused)))
 
2500
uchar *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
 
2501
                                        LEX_STRING *base __attribute__((__unused__)))
2254
2502
{
2255
2503
  /* 
2256
2504
    We can use ptr() instead of c_ptr() here because String contaning
2257
2505
    time zone name is guaranteed to be zero ended.
2258
2506
  */
2259
2507
  if (type == OPT_GLOBAL)
2260
 
    return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr());
 
2508
    return (uchar *)(global_system_variables.time_zone->get_name()->ptr());
2261
2509
  else
2262
2510
  {
2263
2511
    /*
2269
2517
      (binlog code stores session value only).
2270
2518
    */
2271
2519
    thd->time_zone_used= 1;
2272
 
    return (unsigned char *)(thd->variables.time_zone->get_name()->ptr());
 
2520
    return (uchar *)(thd->variables.time_zone->get_name()->ptr());
2273
2521
  }
2274
2522
}
2275
2523
 
2281
2529
 {
2282
2530
   if (default_tz_name)
2283
2531
   {
2284
 
     String str(default_tz_name, &my_charset_utf8_general_ci);
 
2532
     String str(default_tz_name, &my_charset_latin1);
2285
2533
     /*
2286
2534
       We are guaranteed to find this time zone since its existence
2287
2535
       is checked during start-up.
2312
2560
  }
2313
2561
}
2314
2562
 
2315
 
bool sys_var_max_user_conn::update(THD *thd __attribute__((unused)),
 
2563
bool sys_var_max_user_conn::update(THD *thd __attribute__((__unused__)),
2316
2564
                                   set_var *var)
2317
2565
{
2318
2566
  assert(var->type == OPT_GLOBAL);
2319
2567
  pthread_mutex_lock(&LOCK_global_system_variables);
2320
 
  max_user_connections= (uint)var->save_result.uint64_t_value;
 
2568
  max_user_connections= (uint)var->save_result.ulonglong_value;
2321
2569
  pthread_mutex_unlock(&LOCK_global_system_variables);
2322
2570
  return 0;
2323
2571
}
2324
2572
 
2325
2573
 
2326
 
void sys_var_max_user_conn::set_default(THD *thd __attribute__((unused)),
2327
 
                                        enum_var_type type __attribute__((unused)))
 
2574
void sys_var_max_user_conn::set_default(THD *thd __attribute__((__unused__)),
 
2575
                                        enum_var_type type __attribute__((__unused__)))
2328
2576
{
2329
2577
  assert(type == OPT_GLOBAL);
2330
2578
  pthread_mutex_lock(&LOCK_global_system_variables);
2333
2581
}
2334
2582
 
2335
2583
 
2336
 
unsigned char *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2337
 
                                        LEX_STRING *base __attribute__((unused)))
 
2584
uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
 
2585
                                        LEX_STRING *base __attribute__((__unused__)))
2338
2586
{
2339
2587
  if (type != OPT_GLOBAL &&
2340
2588
      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);
 
2589
    return (uchar*) &(thd->user_connect->user_resources.user_conn);
 
2590
  return (uchar*) &(max_user_connections);
2343
2591
}
2344
2592
 
2345
2593
 
2346
 
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((unused)),
 
2594
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((__unused__)),
2347
2595
                                      set_var *var)
2348
2596
{
2349
2597
  MY_LOCALE *locale_match;
2361
2609
  else // STRING_RESULT
2362
2610
  {
2363
2611
    char buff[6]; 
2364
 
    String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res;
 
2612
    String str(buff, sizeof(buff), &my_charset_latin1), *res;
2365
2613
    if (!(res=var->value->val_str(&str)))
2366
2614
    {
2367
2615
      my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
2391
2639
}
2392
2640
 
2393
2641
 
2394
 
unsigned char *sys_var_thd_lc_time_names::value_ptr(THD *thd,
 
2642
uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2395
2643
                                            enum_var_type type,
2396
 
                                            LEX_STRING *base __attribute__((unused)))
 
2644
                                            LEX_STRING *base __attribute__((__unused__)))
2397
2645
{
2398
2646
  return type == OPT_GLOBAL ?
2399
 
                 (unsigned char *) global_system_variables.lc_time_names->name :
2400
 
                 (unsigned char *) thd->variables.lc_time_names->name;
 
2647
                 (uchar *) global_system_variables.lc_time_names->name :
 
2648
                 (uchar *) thd->variables.lc_time_names->name;
2401
2649
}
2402
2650
 
2403
2651
 
2414
2662
 
2415
2663
  NOTES
2416
2664
    The argument to long query time is in seconds in decimal
2417
 
    which is converted to uint64_t integer holding microseconds for storage.
 
2665
    which is converted to ulonglong integer holding microseconds for storage.
2418
2666
    This is used for handling long_query_time
2419
2667
*/
2420
2668
 
2421
2669
bool sys_var_microseconds::update(THD *thd, set_var *var)
2422
2670
{
2423
2671
  double num= var->value->val_real();
2424
 
  int64_t microseconds;
 
2672
  longlong microseconds;
2425
2673
  if (num > (double) option_limits->max_value)
2426
2674
    num= (double) option_limits->max_value;
2427
2675
  if (num < (double) option_limits->min_value)
2428
2676
    num= (double) option_limits->min_value;
2429
 
  microseconds= (int64_t) (num * 1000000.0 + 0.5);
 
2677
  microseconds= (longlong) (num * 1000000.0 + 0.5);
2430
2678
  if (var->type == OPT_GLOBAL)
2431
2679
  {
2432
2680
    pthread_mutex_lock(&LOCK_global_system_variables);
2441
2689
 
2442
2690
void sys_var_microseconds::set_default(THD *thd, enum_var_type type)
2443
2691
{
2444
 
  int64_t microseconds= (int64_t) (option_limits->def_value * 1000000.0);
 
2692
  longlong microseconds= (longlong) (option_limits->def_value * 1000000.0);
2445
2693
  if (type == OPT_GLOBAL)
2446
2694
  {
2447
2695
    pthread_mutex_lock(&LOCK_global_system_variables);
2453
2701
}
2454
2702
 
2455
2703
 
2456
 
unsigned char *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2457
 
                                          LEX_STRING *base __attribute__((unused)))
 
2704
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
 
2705
                                          LEX_STRING *base __attribute__((__unused__)))
2458
2706
{
2459
2707
  thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2460
2708
                                   global_system_variables.*offset :
2461
2709
                                   thd->variables.*offset) / 1000000.0;
2462
 
  return (unsigned char*) &thd->tmp_double_value;
 
2710
  return (uchar*) &thd->tmp_double_value;
2463
2711
}
2464
2712
 
2465
2713
 
2482
2730
{
2483
2731
  /* The test is negative as the flag we use is NOT autocommit */
2484
2732
 
2485
 
  uint64_t org_options= thd->options;
 
2733
  ulonglong org_options= thd->options;
2486
2734
 
2487
2735
  if (var->save_result.ulong_value != 0)
2488
2736
    thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;
2494
2742
    if ((org_options & OPTION_NOT_AUTOCOMMIT))
2495
2743
    {
2496
2744
      /* We changed to auto_commit mode */
2497
 
      thd->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
 
2745
      thd->options&= ~(ulonglong) (OPTION_BEGIN | OPTION_KEEP_LOG);
2498
2746
      thd->transaction.all.modified_non_trans_table= false;
2499
2747
      thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
2500
2748
      if (ha_commit(thd))
2509
2757
  return 0;
2510
2758
}
2511
2759
 
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)),
 
2760
static int check_log_update(THD *thd __attribute__((__unused__)),
 
2761
                            set_var *var __attribute__((__unused__)))
 
2762
{
 
2763
  return 0;
 
2764
}
 
2765
 
 
2766
static bool set_log_update(THD *thd __attribute__((__unused__)),
 
2767
                           set_var *var __attribute__((__unused__)))
 
2768
{
 
2769
  /*
 
2770
    The update log is not supported anymore since 5.0.
 
2771
    See sql/mysqld.cc/, comments in function init_server_components() for an
 
2772
    explaination of the different warnings we send below
 
2773
  */
 
2774
 
 
2775
  if (opt_sql_bin_update)
 
2776
  {
 
2777
    push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
 
2778
                 ER_UPDATE_LOG_DEPRECATED_TRANSLATED,
 
2779
                 ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED));
 
2780
  }
 
2781
  else
 
2782
    push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
 
2783
                 ER_UPDATE_LOG_DEPRECATED_IGNORED,
 
2784
                 ER(ER_UPDATE_LOG_DEPRECATED_IGNORED));
 
2785
  set_option_bit(thd, var);
 
2786
  return 0;
 
2787
}
 
2788
 
 
2789
 
 
2790
static int check_pseudo_thread_id(THD *thd __attribute__((__unused__)),
2520
2791
                                  set_var *var)
2521
2792
{
2522
 
  var->save_result.uint64_t_value= var->value->val_int();
 
2793
  var->save_result.ulonglong_value= var->value->val_int();
2523
2794
  return 0;
2524
2795
}
2525
2796
 
2526
 
static unsigned char *get_warning_count(THD *thd)
 
2797
static uchar *get_warning_count(THD *thd)
2527
2798
{
2528
2799
  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;
 
2800
    (thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
 
2801
     thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
 
2802
     thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
 
2803
  return (uchar*) &thd->sys_var_tmp.long_value;
2533
2804
}
2534
2805
 
2535
 
static unsigned char *get_error_count(THD *thd)
 
2806
static uchar *get_error_count(THD *thd)
2536
2807
{
2537
2808
  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;
 
2809
    thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
 
2810
  return (uchar*) &thd->sys_var_tmp.long_value;
2540
2811
}
2541
2812
 
2542
2813
 
2554
2825
  @retval
2555
2826
    ptr         pointer to NUL-terminated string
2556
2827
*/
2557
 
static unsigned char *get_tmpdir(THD *thd __attribute__((unused)))
 
2828
static uchar *get_tmpdir(THD *thd __attribute__((__unused__)))
2558
2829
{
2559
2830
  if (opt_mysql_tmpdir)
2560
 
    return (unsigned char *)opt_mysql_tmpdir;
2561
 
  return (unsigned char*)mysql_tmpdir;
 
2831
    return (uchar *)opt_mysql_tmpdir;
 
2832
  return (uchar*)mysql_tmpdir;
2562
2833
}
2563
2834
 
2564
2835
/****************************************************************************
2583
2854
 
2584
2855
static struct my_option *find_option(struct my_option *opt, const char *name) 
2585
2856
{
2586
 
  uint32_t length=strlen(name);
 
2857
  uint length=strlen(name);
2587
2858
  for (; opt->name; opt++)
2588
2859
  {
2589
2860
    if (!getopt_compare_strings(opt->name, name, length) &&
2604
2875
  Return variable name and length for hashing of variables.
2605
2876
*/
2606
2877
 
2607
 
static unsigned char *get_sys_var_length(const sys_var *var, size_t *length,
2608
 
                                 bool first __attribute__((unused)))
 
2878
static uchar *get_sys_var_length(const sys_var *var, size_t *length,
 
2879
                                 my_bool first __attribute__((__unused__)))
2609
2880
{
2610
2881
  *length= var->name_length;
2611
 
  return (unsigned char*) var->name;
 
2882
  return (uchar*) var->name;
2612
2883
}
2613
2884
 
2614
2885
 
2636
2907
  {
2637
2908
    var->name_length= strlen(var->name);
2638
2909
    /* this fails if there is a conflicting variable name. see HASH_UNIQUE */
2639
 
    if (my_hash_insert(&system_variable_hash, (unsigned char*) var))
 
2910
    if (my_hash_insert(&system_variable_hash, (uchar*) var))
2640
2911
      goto error;
2641
2912
    if (long_options)
2642
2913
      var->option_limits= find_option(long_options, var->name);
2645
2916
 
2646
2917
error:
2647
2918
  for (; first != var; first= first->next)
2648
 
    hash_delete(&system_variable_hash, (unsigned char*) first);
 
2919
    hash_delete(&system_variable_hash, (uchar*) first);
2649
2920
  return 1;
2650
2921
}
2651
2922
 
2669
2940
  /* A write lock should be held on LOCK_system_variables_hash */
2670
2941
   
2671
2942
  for (sys_var *var= first; var; var= var->next)
2672
 
    result|= hash_delete(&system_variable_hash, (unsigned char*) var);
 
2943
    result|= hash_delete(&system_variable_hash, (uchar*) var);
2673
2944
 
2674
2945
  return result;
2675
2946
}
2721
2992
               (qsort_cmp) show_cmp);
2722
2993
    
2723
2994
    /* make last element empty */
2724
 
    memset(show, 0, sizeof(SHOW_VAR));
 
2995
    bzero(show, sizeof(SHOW_VAR));
2725
2996
  }
2726
2997
  return result;
2727
2998
}
2740
3011
 
2741
3012
int set_var_init()
2742
3013
{
2743
 
  uint32_t count= 0;
 
3014
  uint count= 0;
2744
3015
  
2745
3016
  for (sys_var *var=vars.first; var; var= var->next, count++) {};
2746
3017
 
2759
3030
  if (mysql_add_sys_var_chain(vars.first, my_long_options))
2760
3031
    goto error;
2761
3032
 
 
3033
  /*
 
3034
    Special cases
 
3035
    Needed because MySQL can't find the limits for a variable it it has
 
3036
    a different name than the command line option.
 
3037
    As these variables are deprecated, this code will disappear soon...
 
3038
  */
 
3039
  sys_sql_max_join_size.option_limits= sys_max_join_size.option_limits;
 
3040
 
2762
3041
  return(0);
2763
3042
 
2764
3043
error:
2786
3065
    0           SUCCESS
2787
3066
    otherwise   FAILURE
2788
3067
*/
2789
 
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint32_t count)
 
3068
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count)
2790
3069
{
2791
3070
  for (; count > 0; count--, show_vars++)
2792
 
    if (insert_dynamic(&fixed_show_vars, (unsigned char*) show_vars))
 
3071
    if (insert_dynamic(&fixed_show_vars, (uchar*) show_vars))
2793
3072
      return 1;
2794
3073
  return 0;
2795
3074
}
2809
3088
    0           Unknown variable (error message is given)
2810
3089
*/
2811
3090
 
2812
 
sys_var *intern_find_sys_var(const char *str, uint32_t length, bool no_error)
 
3091
sys_var *intern_find_sys_var(const char *str, uint length, bool no_error)
2813
3092
{
2814
3093
  sys_var *var;
2815
3094
 
2818
3097
    A lock on LOCK_system_variable_hash should be held
2819
3098
  */
2820
3099
  var= (sys_var*) hash_search(&system_variable_hash,
2821
 
                              (unsigned char*) str, length ? length : strlen(str));
 
3100
                              (uchar*) str, length ? length : strlen(str));
2822
3101
  if (!(var || no_error))
2823
3102
    my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str);
2824
3103
 
2977
3256
}
2978
3257
 
2979
3258
 
2980
 
int set_var_user::update(THD *thd __attribute__((unused)))
 
3259
int set_var_user::update(THD *thd __attribute__((__unused__)))
2981
3260
{
2982
3261
  if (user_var_item->update())
2983
3262
  {
2998
3277
{
2999
3278
  char buff[STRING_BUFFER_USUAL_SIZE];
3000
3279
  const char *value;
3001
 
  String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res;
 
3280
  String str(buff, sizeof(buff), &my_charset_latin1), *res;
3002
3281
 
3003
3282
  var->save_result.plugin= NULL;
3004
3283
  if (var->value->result_type() == STRING_RESULT)
3009
3288
        !(engine_name.str= (char *)res->ptr()) ||
3010
3289
        !(engine_name.length= res->length()) ||
3011
3290
        !(var->save_result.plugin= ha_resolve_by_name(thd, &engine_name)) ||
3012
 
        !(hton= plugin_data(var->save_result.plugin, handlerton *)))
 
3291
        !(hton= plugin_data(var->save_result.plugin, handlerton *)) ||
 
3292
        ha_checktype(thd, ha_legacy_type(hton), 1, 0) != hton)
3013
3293
    {
3014
3294
      value= res ? res->c_ptr() : "NULL";
3015
3295
      goto err;
3024
3304
}
3025
3305
 
3026
3306
 
3027
 
unsigned char *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
3028
 
                                             LEX_STRING *base __attribute__((unused)))
 
3307
uchar *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
 
3308
                                             LEX_STRING *base __attribute__((__unused__)))
3029
3309
{
3030
 
  unsigned char* result;
 
3310
  uchar* result;
3031
3311
  handlerton *hton;
3032
3312
  LEX_STRING *engine_name;
3033
3313
  plugin_ref plugin= thd->variables.*offset;
3035
3315
    plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
3036
3316
  hton= plugin_data(plugin, handlerton*);
3037
3317
  engine_name= &hton2plugin[hton->slot]->name;
3038
 
  result= (unsigned char *) thd->strmake(engine_name->str, engine_name->length);
 
3318
  result= (uchar *) thd->strmake(engine_name->str, engine_name->length);
3039
3319
  if (type == OPT_GLOBAL)
3040
3320
    plugin_unlock(thd, plugin);
3041
3321
  return result;
3078
3358
 
3079
3359
bool
3080
3360
sys_var_thd_optimizer_switch::
3081
 
symbolic_mode_representation(THD *thd, uint64_t val, LEX_STRING *rep)
 
3361
symbolic_mode_representation(THD *thd, ulonglong val, LEX_STRING *rep)
3082
3362
{
3083
3363
  char buff[STRING_BUFFER_USUAL_SIZE*8];
3084
 
  String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
3364
  String tmp(buff, sizeof(buff), &my_charset_latin1);
3085
3365
 
3086
3366
  tmp.length(0);
3087
3367
 
3088
 
  for (uint32_t i= 0; val; val>>= 1, i++)
 
3368
  for (uint i= 0; val; val>>= 1, i++)
3089
3369
  {
3090
3370
    if (val & 1)
3091
3371
    {
3106
3386
}
3107
3387
 
3108
3388
 
3109
 
unsigned char *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3110
 
                                               LEX_STRING *base __attribute__((unused)))
 
3389
uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
 
3390
                                               LEX_STRING *base __attribute__((__unused__)))
3111
3391
{
3112
3392
  LEX_STRING opts;
3113
 
  uint64_t val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
 
3393
  ulonglong val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3114
3394
                  thd->variables.*offset);
3115
3395
  (void) symbolic_mode_representation(thd, val, &opts);
3116
 
  return (unsigned char *) opts.str;
 
3396
  return (uchar *) opts.str;
3117
3397
}
3118
3398
 
3119
3399
 
3130
3410
  Named list handling
3131
3411
****************************************************************************/
3132
3412
 
3133
 
unsigned char* find_named(I_List<NAMED_LIST> *list, const char *name, uint32_t length,
 
3413
uchar* find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
3134
3414
                NAMED_LIST **found)
3135
3415
{
3136
3416
  I_List_iterator<NAMED_LIST> it(*list);
3149
3429
 
3150
3430
 
3151
3431
void delete_elements(I_List<NAMED_LIST> *list,
3152
 
                     void (*free_element)(const char *name, unsigned char*))
 
3432
                     void (*free_element)(const char *name, uchar*))
3153
3433
{
3154
3434
  NAMED_LIST *element;
3155
3435
  while ((element= list->get()))
3163
3443
 
3164
3444
/* Key cache functions */
3165
3445
 
3166
 
static KEY_CACHE *create_key_cache(const char *name, uint32_t length)
 
3446
static KEY_CACHE *create_key_cache(const char *name, uint length)
3167
3447
{
3168
3448
  KEY_CACHE *key_cache;
3169
3449
  
3170
3450
  if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
3171
3451
                                             MYF(MY_ZEROFILL | MY_WME))))
3172
3452
  {
3173
 
    if (!new NAMED_LIST(&key_caches, name, length, (unsigned char*) key_cache))
 
3453
    if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache))
3174
3454
    {
3175
 
      free((char*) key_cache);
 
3455
      my_free((char*) key_cache, MYF(0));
3176
3456
      key_cache= 0;
3177
3457
    }
3178
3458
    else
3192
3472
}
3193
3473
 
3194
3474
 
3195
 
KEY_CACHE *get_or_create_key_cache(const char *name, uint32_t length)
 
3475
KEY_CACHE *get_or_create_key_cache(const char *name, uint length)
3196
3476
{
3197
3477
  LEX_STRING key_cache_name;
3198
3478
  KEY_CACHE *key_cache;
3207
3487
}
3208
3488
 
3209
3489
 
3210
 
void free_key_cache(const char *name __attribute__((unused)),
 
3490
void free_key_cache(const char *name __attribute__((__unused__)),
3211
3491
                    KEY_CACHE *key_cache)
3212
3492
{
3213
3493
  ha_end_key_cache(key_cache);
3214
 
  free((char*) key_cache);
 
3494
  my_free((char*) key_cache, MYF(0));
3215
3495
}
3216
3496
 
3217
3497