~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/set_var.cc

  • Committer: Mark Atwood
  • Date: 2008-07-12 07:25:25 UTC
  • mto: This revision was merged to the branch mainline in revision 139.
  • Revision ID: me@mark.atwood.name-20080712072525-s1dq9mtwo5td7af7
more hackery to get plugin UDFs working

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
{
835
930
  if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 &&
836
931
      bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
837
932
  {
838
 
    sql_print_error(_("Ambiguous slave modes combination."
839
 
                    " STRICT will be used"));
 
933
    sql_print_error("Ambiguous slave modes combination."
 
934
                    " STRICT will be used");
840
935
    bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT);
841
936
  }
842
937
  if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0)
879
974
 
880
975
 
881
976
void fix_binlog_format_after_update(THD *thd,
882
 
                                    enum_var_type type __attribute__((unused)))
 
977
                                    enum_var_type type __attribute__((__unused__)))
883
978
{
884
979
  thd->reset_current_stmt_binlog_row_based();
885
980
}
886
981
 
887
982
 
888
 
static void fix_max_binlog_size(THD *thd __attribute__((unused)),
889
 
                                enum_var_type type __attribute__((unused)))
 
983
static void fix_max_binlog_size(THD *thd __attribute__((__unused__)),
 
984
                                enum_var_type type __attribute__((__unused__)))
890
985
{
891
986
  mysql_bin_log.set_max_size(max_binlog_size);
 
987
#ifdef HAVE_REPLICATION
892
988
  if (!max_relay_log_size)
893
989
    active_mi->rli.relay_log.set_max_size(max_binlog_size);
 
990
#endif
894
991
  return;
895
992
}
896
993
 
897
 
static void fix_max_relay_log_size(THD *thd __attribute__((unused)),
898
 
                                   enum_var_type type __attribute__((unused)))
 
994
static void fix_max_relay_log_size(THD *thd __attribute__((__unused__)),
 
995
                                   enum_var_type type __attribute__((__unused__)))
899
996
{
 
997
#ifdef HAVE_REPLICATION
900
998
  active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
901
999
                                        max_relay_log_size: max_binlog_size);
 
1000
#endif
902
1001
  return;
903
1002
}
904
1003
 
905
 
static void fix_max_connections(THD *thd __attribute__((unused)),
906
 
                                enum_var_type type __attribute__((unused)))
 
1004
static void fix_max_connections(THD *thd __attribute__((__unused__)),
 
1005
                                enum_var_type type __attribute__((__unused__)))
907
1006
{
908
1007
  resize_thr_alarm(max_connections +  10);
909
1008
}
927
1026
}
928
1027
 
929
1028
 
930
 
static void fix_server_id(THD *thd __attribute__((unused)),
931
 
                          enum_var_type type __attribute__((unused)))
 
1029
static void fix_server_id(THD *thd __attribute__((__unused__)),
 
1030
                          enum_var_type type __attribute__((__unused__)))
932
1031
{
933
1032
  server_id_supplied = 1;
934
1033
  thd->server_id= server_id;
936
1035
 
937
1036
 
938
1037
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
939
 
                          const char *name, int64_t val)
 
1038
                          const char *name, longlong val)
940
1039
{
941
1040
  if (fixed)
942
1041
  {
943
1042
    char buf[22];
944
1043
 
945
1044
    if (unsignd)
946
 
      ullstr((uint64_t) val, buf);
 
1045
      ullstr((ulonglong) val, buf);
947
1046
    else
948
1047
      llstr(val, buf);
949
1048
 
950
 
    push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1049
    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
951
1050
                        ER_TRUNCATED_WRONG_VALUE,
952
1051
                        ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
953
1052
  }
954
1053
  return false;
955
1054
}
956
1055
 
957
 
static uint64_t fix_unsigned(THD *thd, uint64_t num,
 
1056
static ulonglong fix_unsigned(THD *thd, ulonglong num,
958
1057
                              const struct my_option *option_limits)
959
1058
{
960
 
  bool fixed= false;
961
 
  uint64_t out= getopt_ull_limit_value(num, option_limits, &fixed);
 
1059
  my_bool fixed= false;
 
1060
  ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
962
1061
 
963
 
  throw_bounds_warning(thd, fixed, true, option_limits->name, (int64_t) num);
 
1062
  throw_bounds_warning(thd, fixed, true, option_limits->name, (longlong) num);
964
1063
  return out;
965
1064
}
966
1065
 
967
 
static bool get_unsigned(THD *thd __attribute__((unused)), set_var *var)
 
1066
static bool get_unsigned(THD *thd __attribute__((__unused__)), set_var *var)
968
1067
{
969
1068
  if (var->value->unsigned_flag)
970
 
    var->save_result.uint64_t_value= (uint64_t) var->value->val_int();
 
1069
    var->save_result.ulonglong_value= (ulonglong) var->value->val_int();
971
1070
  else
972
1071
  {
973
 
    int64_t v= var->value->val_int();
974
 
    var->save_result.uint64_t_value= (uint64_t) ((v < 0) ? 0 : v);
 
1072
    longlong v= var->value->val_int();
 
1073
    var->save_result.ulonglong_value= (ulonglong) ((v < 0) ? 0 : v);
975
1074
  }
976
1075
  return 0;
977
1076
}
992
1091
 
993
1092
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
994
1093
{
995
 
  uint64_t tmp= var->save_result.uint64_t_value;
 
1094
  ulonglong tmp= var->save_result.ulonglong_value;
996
1095
  pthread_mutex_lock(guard);
997
1096
  if (option_limits)
998
1097
    *value= (ulong) fix_unsigned(thd, tmp, option_limits);
1004
1103
    {
1005
1104
      tmp= ULONG_MAX;
1006
1105
      throw_bounds_warning(thd, true, true, name,
1007
 
                           (int64_t) var->save_result.uint64_t_value);
 
1106
                           (longlong) var->save_result.ulonglong_value);
1008
1107
    }
1009
1108
#endif
1010
1109
    *value= (ulong) tmp;
1015
1114
}
1016
1115
 
1017
1116
 
1018
 
void sys_var_long_ptr_global::set_default(THD *thd __attribute__((unused)), enum_var_type type __attribute__((unused)))
 
1117
void sys_var_long_ptr_global::set_default(THD *thd __attribute__((__unused__)), enum_var_type type __attribute__((__unused__)))
1019
1118
{
1020
 
  bool not_used;
 
1119
  my_bool not_used;
1021
1120
  pthread_mutex_lock(guard);
1022
1121
  *value= (ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
1023
1122
                                         option_limits, &not_used);
1025
1124
}
1026
1125
 
1027
1126
 
1028
 
bool sys_var_uint64_t_ptr::update(THD *thd, set_var *var)
 
1127
bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
1029
1128
{
1030
 
  uint64_t tmp= var->save_result.uint64_t_value;
 
1129
  ulonglong tmp= var->save_result.ulonglong_value;
1031
1130
  pthread_mutex_lock(&LOCK_global_system_variables);
1032
1131
  if (option_limits)
1033
 
    *value= (uint64_t) fix_unsigned(thd, tmp, option_limits);
 
1132
    *value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
1034
1133
  else
1035
 
    *value= (uint64_t) tmp;
 
1134
    *value= (ulonglong) tmp;
1036
1135
  pthread_mutex_unlock(&LOCK_global_system_variables);
1037
1136
  return 0;
1038
1137
}
1039
1138
 
1040
1139
 
1041
 
void sys_var_uint64_t_ptr::set_default(THD *thd __attribute__((unused)),
1042
 
                                        enum_var_type type __attribute__((unused)))
 
1140
void sys_var_ulonglong_ptr::set_default(THD *thd __attribute__((__unused__)),
 
1141
                                        enum_var_type type __attribute__((__unused__)))
1043
1142
{
1044
 
  bool not_used;
 
1143
  my_bool not_used;
1045
1144
  pthread_mutex_lock(&LOCK_global_system_variables);
1046
 
  *value= getopt_ull_limit_value((uint64_t) option_limits->def_value,
 
1145
  *value= getopt_ull_limit_value((ulonglong) option_limits->def_value,
1047
1146
                                 option_limits, &not_used);
1048
1147
  pthread_mutex_unlock(&LOCK_global_system_variables);
1049
1148
}
1050
1149
 
1051
1150
 
1052
 
bool sys_var_bool_ptr::update(THD *thd __attribute__((unused)), set_var *var)
 
1151
bool sys_var_bool_ptr::update(THD *thd __attribute__((__unused__)), set_var *var)
1053
1152
{
1054
 
  *value= (bool) var->save_result.ulong_value;
 
1153
  *value= (my_bool) var->save_result.ulong_value;
1055
1154
  return 0;
1056
1155
}
1057
1156
 
1058
1157
 
1059
 
void sys_var_bool_ptr::set_default(THD *thd __attribute__((unused)), enum_var_type type __attribute__((unused)))
 
1158
void sys_var_bool_ptr::set_default(THD *thd __attribute__((__unused__)), enum_var_type type __attribute__((__unused__)))
1060
1159
{
1061
 
  *value= (bool) option_limits->def_value;
 
1160
  *value= (my_bool) option_limits->def_value;
1062
1161
}
1063
1162
 
1064
1163
 
1065
 
bool sys_var_enum::update(THD *thd __attribute__((unused)), set_var *var)
 
1164
bool sys_var_enum::update(THD *thd __attribute__((__unused__)), set_var *var)
1066
1165
{
1067
1166
  *value= (uint) var->save_result.ulong_value;
1068
1167
  return 0;
1069
1168
}
1070
1169
 
1071
1170
 
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)))
 
1171
uchar *sys_var_enum::value_ptr(THD *thd __attribute__((__unused__)),
 
1172
                               enum_var_type type __attribute__((__unused__)),
 
1173
                               LEX_STRING *base __attribute__((__unused__)))
1075
1174
{
1076
 
  return (unsigned char*) enum_names->type_names[*value];
 
1175
  return (uchar*) enum_names->type_names[*value];
1077
1176
}
1078
1177
 
1079
1178
 
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)))
 
1179
uchar *sys_var_enum_const::value_ptr(THD *thd __attribute__((__unused__)),
 
1180
                                     enum_var_type type __attribute__((__unused__)),
 
1181
                                     LEX_STRING *base __attribute__((__unused__)))
1083
1182
{
1084
 
  return (unsigned char*) enum_names->type_names[global_system_variables.*offset];
 
1183
  return (uchar*) enum_names->type_names[global_system_variables.*offset];
1085
1184
}
1086
1185
 
1087
1186
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
1092
1191
 
1093
1192
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
1094
1193
{
1095
 
  uint64_t tmp= var->save_result.uint64_t_value;
 
1194
  ulonglong tmp= var->save_result.ulonglong_value;
1096
1195
  
1097
1196
  /* Don't use bigger value than given with --maximum-variable-name=.. */
1098
1197
  if ((ulong) tmp > max_system_variables.*offset)
1099
1198
  {
1100
 
    throw_bounds_warning(thd, true, true, name, (int64_t) tmp);
 
1199
    throw_bounds_warning(thd, true, true, name, (longlong) tmp);
1101
1200
    tmp= max_system_variables.*offset;
1102
1201
  }
1103
1202
  
1107
1206
  else if (tmp > ULONG_MAX)
1108
1207
  {
1109
1208
    tmp= ULONG_MAX;
1110
 
    throw_bounds_warning(thd, true, true, name, (int64_t) var->save_result.uint64_t_value);
 
1209
    throw_bounds_warning(thd, true, true, name, (longlong) var->save_result.ulonglong_value);
1111
1210
  }
1112
1211
#endif
1113
1212
  
1124
1223
 {
1125
1224
   if (type == OPT_GLOBAL)
1126
1225
   {
1127
 
     bool not_used;
 
1226
     my_bool not_used;
1128
1227
     /* We will not come here if option_limits is not set */
1129
1228
     global_system_variables.*offset=
1130
1229
       (ulong) getopt_ull_limit_value((ulong) option_limits->def_value,
1135
1234
 }
1136
1235
 
1137
1236
 
1138
 
unsigned char *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
1139
 
                                    LEX_STRING *base __attribute__((unused)))
 
1237
uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type,
 
1238
                                    LEX_STRING *base __attribute__((__unused__)))
1140
1239
{
1141
1240
  if (type == OPT_GLOBAL)
1142
 
    return (unsigned char*) &(global_system_variables.*offset);
1143
 
  return (unsigned char*) &(thd->variables.*offset);
 
1241
    return (uchar*) &(global_system_variables.*offset);
 
1242
  return (uchar*) &(thd->variables.*offset);
1144
1243
}
1145
1244
 
1146
1245
 
1147
1246
bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
1148
1247
{
1149
 
  uint64_t tmp= var->save_result.uint64_t_value;
 
1248
  ulonglong tmp= var->save_result.ulonglong_value;
1150
1249
 
1151
1250
  /* Don't use bigger value than given with --maximum-variable-name=.. */
1152
1251
  if ((ha_rows) tmp > max_system_variables.*offset)
1171
1270
{
1172
1271
  if (type == OPT_GLOBAL)
1173
1272
  {
1174
 
    bool not_used;
 
1273
    my_bool not_used;
1175
1274
    /* We will not come here if option_limits is not set */
1176
1275
    pthread_mutex_lock(&LOCK_global_system_variables);
1177
1276
    global_system_variables.*offset=
1184
1283
}
1185
1284
 
1186
1285
 
1187
 
unsigned char *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
1188
 
                                      LEX_STRING *base __attribute__((unused)))
 
1286
uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
 
1287
                                      LEX_STRING *base __attribute__((__unused__)))
1189
1288
{
1190
1289
  if (type == OPT_GLOBAL)
1191
 
    return (unsigned char*) &(global_system_variables.*offset);
1192
 
  return (unsigned char*) &(thd->variables.*offset);
 
1290
    return (uchar*) &(global_system_variables.*offset);
 
1291
  return (uchar*) &(thd->variables.*offset);
1193
1292
}
1194
1293
 
1195
 
bool sys_var_thd_uint64_t::check(THD *thd, set_var *var)
 
1294
bool sys_var_thd_ulonglong::check(THD *thd, set_var *var)
1196
1295
{
1197
1296
  return get_unsigned(thd, var);
1198
1297
}
1199
1298
 
1200
 
bool sys_var_thd_uint64_t::update(THD *thd,  set_var *var)
 
1299
bool sys_var_thd_ulonglong::update(THD *thd,  set_var *var)
1201
1300
{
1202
 
  uint64_t tmp= var->save_result.uint64_t_value;
 
1301
  ulonglong tmp= var->save_result.ulonglong_value;
1203
1302
 
1204
1303
  if (tmp > max_system_variables.*offset)
1205
1304
    tmp= max_system_variables.*offset;
1210
1309
  {
1211
1310
    /* Lock is needed to make things safe on 32 bit systems */
1212
1311
    pthread_mutex_lock(&LOCK_global_system_variables);
1213
 
    global_system_variables.*offset= (uint64_t) tmp;
 
1312
    global_system_variables.*offset= (ulonglong) tmp;
1214
1313
    pthread_mutex_unlock(&LOCK_global_system_variables);
1215
1314
  }
1216
1315
  else
1217
 
    thd->variables.*offset= (uint64_t) tmp;
 
1316
    thd->variables.*offset= (ulonglong) tmp;
1218
1317
  return 0;
1219
1318
}
1220
1319
 
1221
1320
 
1222
 
void sys_var_thd_uint64_t::set_default(THD *thd, enum_var_type type)
 
1321
void sys_var_thd_ulonglong::set_default(THD *thd, enum_var_type type)
1223
1322
{
1224
1323
  if (type == OPT_GLOBAL)
1225
1324
  {
1226
 
    bool not_used;
 
1325
    my_bool not_used;
1227
1326
    pthread_mutex_lock(&LOCK_global_system_variables);
1228
1327
    global_system_variables.*offset=
1229
 
      getopt_ull_limit_value((uint64_t) option_limits->def_value,
 
1328
      getopt_ull_limit_value((ulonglong) option_limits->def_value,
1230
1329
                             option_limits, &not_used);
1231
1330
    pthread_mutex_unlock(&LOCK_global_system_variables);
1232
1331
  }
1235
1334
}
1236
1335
 
1237
1336
 
1238
 
unsigned char *sys_var_thd_uint64_t::value_ptr(THD *thd, enum_var_type type,
1239
 
                                        LEX_STRING *base __attribute__((unused)))
 
1337
uchar *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type,
 
1338
                                        LEX_STRING *base __attribute__((__unused__)))
1240
1339
{
1241
1340
  if (type == OPT_GLOBAL)
1242
 
    return (unsigned char*) &(global_system_variables.*offset);
1243
 
  return (unsigned char*) &(thd->variables.*offset);
 
1341
    return (uchar*) &(global_system_variables.*offset);
 
1342
  return (uchar*) &(thd->variables.*offset);
1244
1343
}
1245
1344
 
1246
1345
 
1247
1346
bool sys_var_thd_bool::update(THD *thd,  set_var *var)
1248
1347
{
1249
1348
  if (var->type == OPT_GLOBAL)
1250
 
    global_system_variables.*offset= (bool) var->save_result.ulong_value;
 
1349
    global_system_variables.*offset= (my_bool) var->save_result.ulong_value;
1251
1350
  else
1252
 
    thd->variables.*offset= (bool) var->save_result.ulong_value;
 
1351
    thd->variables.*offset= (my_bool) var->save_result.ulong_value;
1253
1352
  return 0;
1254
1353
}
1255
1354
 
1257
1356
void sys_var_thd_bool::set_default(THD *thd,  enum_var_type type)
1258
1357
{
1259
1358
  if (type == OPT_GLOBAL)
1260
 
    global_system_variables.*offset= (bool) option_limits->def_value;
 
1359
    global_system_variables.*offset= (my_bool) option_limits->def_value;
1261
1360
  else
1262
1361
    thd->variables.*offset= global_system_variables.*offset;
1263
1362
}
1264
1363
 
1265
1364
 
1266
 
unsigned char *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
1267
 
                                   LEX_STRING *base __attribute__((unused)))
 
1365
uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type,
 
1366
                                   LEX_STRING *base __attribute__((__unused__)))
1268
1367
{
1269
1368
  if (type == OPT_GLOBAL)
1270
 
    return (unsigned char*) &(global_system_variables.*offset);
1271
 
  return (unsigned char*) &(thd->variables.*offset);
 
1369
    return (uchar*) &(global_system_variables.*offset);
 
1370
  return (uchar*) &(thd->variables.*offset);
1272
1371
}
1273
1372
 
1274
1373
 
1275
 
bool sys_var::check_enum(THD *thd __attribute__((unused)),
 
1374
bool sys_var::check_enum(THD *thd __attribute__((__unused__)),
1276
1375
                         set_var *var, const TYPELIB *enum_names)
1277
1376
{
1278
1377
  char buff[STRING_BUFFER_USUAL_SIZE];
1292
1391
  }
1293
1392
  else
1294
1393
  {
1295
 
    uint64_t tmp=var->value->val_int();
 
1394
    ulonglong tmp=var->value->val_int();
1296
1395
    if (tmp >= enum_names->count)
1297
1396
    {
1298
1397
      llstr(tmp,buff);
1309
1408
}
1310
1409
 
1311
1410
 
1312
 
bool sys_var::check_set(THD *thd __attribute__((unused)),
 
1411
bool sys_var::check_set(THD *thd __attribute__((__unused__)),
1313
1412
                        set_var *var, TYPELIB *enum_names)
1314
1413
{
1315
1414
  bool not_used;
1316
1415
  char buff[STRING_BUFFER_USUAL_SIZE], *error= 0;
1317
 
  uint32_t error_len= 0;
 
1416
  uint error_len= 0;
1318
1417
  String str(buff, sizeof(buff), system_charset_info), *res;
1319
1418
 
1320
1419
  if (var->value->result_type() == STRING_RESULT)
1321
1420
  {
1322
1421
    if (!(res= var->value->val_str(&str)))
1323
1422
    {
1324
 
      my_stpcpy(buff, "NULL");
 
1423
      strmov(buff, "NULL");
1325
1424
      goto err;
1326
1425
    }
1327
1426
 
1340
1439
                                            &not_used));
1341
1440
    if (error_len)
1342
1441
    {
1343
 
      strmake(buff, error, cmin(sizeof(buff) - 1, (ulong)error_len));
 
1442
      strmake(buff, error, min(sizeof(buff) - 1, error_len));
1344
1443
      goto err;
1345
1444
    }
1346
1445
  }
1347
1446
  else
1348
1447
  {
1349
 
    uint64_t tmp= var->value->val_int();
 
1448
    ulonglong tmp= var->value->val_int();
1350
1449
 
1351
1450
    if (!m_allow_empty_value &&
1352
1451
        tmp == 0)
1360
1459
      For when the enum is made to contain 64 elements, as 1ULL<<64 is
1361
1460
      undefined, we guard with a "count<64" test.
1362
1461
    */
1363
 
    if (unlikely((tmp >= ((1UL) << enum_names->count)) &&
 
1462
    if (unlikely((tmp >= ((1ULL) << enum_names->count)) &&
1364
1463
                 (enum_names->count < 64)))
1365
1464
    {
1366
1465
      llstr(tmp, buff);
1400
1499
  switch (show_type()) {
1401
1500
  case SHOW_INT:
1402
1501
  {
1403
 
    uint32_t value;
 
1502
    uint value;
1404
1503
    pthread_mutex_lock(&LOCK_global_system_variables);
1405
1504
    value= *(uint*) value_ptr(thd, var_type, base);
1406
1505
    pthread_mutex_unlock(&LOCK_global_system_variables);
1407
 
    return new Item_uint((uint64_t) value);
 
1506
    return new Item_uint((ulonglong) value);
1408
1507
  }
1409
1508
  case SHOW_LONG:
1410
1509
  {
1412
1511
    pthread_mutex_lock(&LOCK_global_system_variables);
1413
1512
    value= *(ulong*) value_ptr(thd, var_type, base);
1414
1513
    pthread_mutex_unlock(&LOCK_global_system_variables);
1415
 
    return new Item_uint((uint64_t) value);
 
1514
    return new Item_uint((ulonglong) value);
1416
1515
  }
1417
1516
  case SHOW_LONGLONG:
1418
1517
  {
1419
 
    int64_t value;
 
1518
    longlong value;
1420
1519
    pthread_mutex_lock(&LOCK_global_system_variables);
1421
 
    value= *(int64_t*) value_ptr(thd, var_type, base);
 
1520
    value= *(longlong*) value_ptr(thd, var_type, base);
1422
1521
    pthread_mutex_unlock(&LOCK_global_system_variables);
1423
1522
    return new Item_int(value);
1424
1523
  }
1437
1536
    pthread_mutex_lock(&LOCK_global_system_variables);
1438
1537
    value= *(ha_rows*) value_ptr(thd, var_type, base);
1439
1538
    pthread_mutex_unlock(&LOCK_global_system_variables);
1440
 
    return new Item_int((uint64_t) value);
 
1539
    return new Item_int((ulonglong) value);
1441
1540
  }
1442
1541
  case SHOW_MY_BOOL:
1443
1542
  {
1444
 
    int32_t value;
 
1543
    int32 value;
1445
1544
    pthread_mutex_lock(&LOCK_global_system_variables);
1446
 
    value= *(bool*) value_ptr(thd, var_type, base);
 
1545
    value= *(my_bool*) value_ptr(thd, var_type, base);
1447
1546
    pthread_mutex_unlock(&LOCK_global_system_variables);
1448
1547
    return new Item_int(value,1);
1449
1548
  }
1454
1553
    char *str= *(char**) value_ptr(thd, var_type, base);
1455
1554
    if (str)
1456
1555
    {
1457
 
      uint32_t length= strlen(str);
 
1556
      uint length= strlen(str);
1458
1557
      tmp= new Item_string(thd->strmake(str, length), length,
1459
1558
                           system_charset_info, DERIVATION_SYSCONST);
1460
1559
    }
1508
1607
}
1509
1608
 
1510
1609
 
1511
 
unsigned char *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
1512
 
                                   LEX_STRING *base __attribute__((unused)))
 
1610
uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type,
 
1611
                                   LEX_STRING *base __attribute__((__unused__)))
1513
1612
{
1514
1613
  ulong tmp= ((type == OPT_GLOBAL) ?
1515
1614
              global_system_variables.*offset :
1516
1615
              thd->variables.*offset);
1517
 
  return (unsigned char*) enum_names->type_names[tmp];
 
1616
  return (uchar*) enum_names->type_names[tmp];
1518
1617
}
1519
1618
 
1520
1619
bool sys_var_thd_bit::check(THD *thd, set_var *var)
1530
1629
}
1531
1630
 
1532
1631
 
1533
 
unsigned char *sys_var_thd_bit::value_ptr(THD *thd,
1534
 
                                  enum_var_type type __attribute__((unused)),
1535
 
                                  LEX_STRING *base __attribute__((unused)))
 
1632
uchar *sys_var_thd_bit::value_ptr(THD *thd,
 
1633
                                  enum_var_type type __attribute__((__unused__)),
 
1634
                                  LEX_STRING *base __attribute__((__unused__)))
1536
1635
{
1537
1636
  /*
1538
1637
    If reverse is 0 (default) return 1 if bit is set.
1539
1638
    If reverse is 1, return 0 if bit is set
1540
1639
  */
1541
 
  thd->sys_var_tmp.bool_value= ((thd->options & bit_flag) ?
 
1640
  thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ?
1542
1641
                                   !reverse : reverse);
1543
 
  return (unsigned char*) &thd->sys_var_tmp.bool_value;
 
1642
  return (uchar*) &thd->sys_var_tmp.my_bool_value;
1544
1643
}
1545
1644
 
1546
1645
 
1563
1662
    old= (thd->variables.*offset);
1564
1663
    (thd->variables.*offset)= new_value;
1565
1664
  }
1566
 
  free((char*) old);
 
1665
  my_free((char*) old, MYF(MY_ALLOW_ZERO_PTR));
1567
1666
  return;
1568
1667
}
1569
1668
 
1602
1701
    update is aborted
1603
1702
  */
1604
1703
  var->save_result.date_time_format= date_time_format_copy(thd, format);
1605
 
  free((char*) format);
 
1704
  my_free((char*) format, MYF(0));
1606
1705
  return var->save_result.date_time_format == 0;
1607
1706
}
1608
1707
 
1628
1727
}
1629
1728
 
1630
1729
 
1631
 
unsigned char *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
1632
 
                                               LEX_STRING *base __attribute__((unused)))
 
1730
uchar *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type,
 
1731
                                               LEX_STRING *base __attribute__((__unused__)))
1633
1732
{
1634
1733
  if (type == OPT_GLOBAL)
1635
1734
  {
1641
1740
    */
1642
1741
    res= thd->strmake((global_system_variables.*offset)->format.str,
1643
1742
                      (global_system_variables.*offset)->format.length);
1644
 
    return (unsigned char*) res;
 
1743
    return (uchar*) res;
1645
1744
  }
1646
 
  return (unsigned char*) (thd->variables.*offset)->format.str;
 
1745
  return (uchar*) (thd->variables.*offset)->format.str;
1647
1746
}
1648
1747
 
1649
1748
 
1653
1752
  const char *new_name;
1654
1753
} my_old_conv;
1655
1754
 
1656
 
bool sys_var_collation::check(THD *thd __attribute__((unused)),
 
1755
static my_old_conv old_conv[]= 
 
1756
{
 
1757
  {     "cp1251_koi8"           ,       "cp1251"        },
 
1758
  {     "cp1250_latin2"         ,       "cp1250"        },
 
1759
  {     "kam_latin2"            ,       "keybcs2"       },
 
1760
  {     "mac_latin2"            ,       "MacRoman"      },
 
1761
  {     "macce_latin2"          ,       "MacCE"         },
 
1762
  {     "pc2_latin2"            ,       "pclatin2"      },
 
1763
  {     "vga_latin2"            ,       "pclatin1"      },
 
1764
  {     "koi8_cp1251"           ,       "koi8r"         },
 
1765
  {     "win1251ukr_koi8_ukr"   ,       "win1251ukr"    },
 
1766
  {     "koi8_ukr_win1251ukr"   ,       "koi8u"         },
 
1767
  {     NULL                    ,       NULL            }
 
1768
};
 
1769
 
 
1770
CHARSET_INFO *get_old_charset_by_name(const char *name)
 
1771
{
 
1772
  my_old_conv *conv;
 
1773
 
 
1774
  for (conv= old_conv; conv->old_name; conv++)
 
1775
  {
 
1776
    if (!my_strcasecmp(&my_charset_latin1, name, conv->old_name))
 
1777
      return get_charset_by_csname(conv->new_name, MY_CS_PRIMARY, MYF(0));
 
1778
  }
 
1779
  return NULL;
 
1780
}
 
1781
 
 
1782
 
 
1783
bool sys_var_collation::check(THD *thd __attribute__((__unused__)),
1657
1784
                              set_var *var)
1658
1785
{
1659
 
  const CHARSET_INFO *tmp;
 
1786
  CHARSET_INFO *tmp;
1660
1787
 
1661
1788
  if (var->value->result_type() == STRING_RESULT)
1662
1789
  {
1688
1815
}
1689
1816
 
1690
1817
 
1691
 
bool sys_var_character_set::check(THD *thd __attribute__((unused)),
 
1818
bool sys_var_character_set::check(THD *thd __attribute__((__unused__)),
1692
1819
                                  set_var *var)
1693
1820
{
1694
 
  const CHARSET_INFO *tmp;
 
1821
  CHARSET_INFO *tmp;
1695
1822
 
1696
1823
  if (var->value->result_type() == STRING_RESULT)
1697
1824
  {
1706
1833
      }
1707
1834
      tmp= NULL;
1708
1835
    }
1709
 
    else if (!(tmp= get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))))
 
1836
    else if (!(tmp=get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))) &&
 
1837
             !(tmp=get_old_charset_by_name(res->c_ptr())))
1710
1838
    {
1711
1839
      my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
1712
1840
      return 1;
1735
1863
}
1736
1864
 
1737
1865
 
1738
 
unsigned char *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
1739
 
                                        LEX_STRING *base __attribute__((unused)))
 
1866
uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type,
 
1867
                                        LEX_STRING *base __attribute__((__unused__)))
1740
1868
{
1741
 
  const CHARSET_INFO * const cs= ci_ptr(thd,type)[0];
1742
 
  return cs ? (unsigned char*) cs->csname : (unsigned char*) NULL;
 
1869
  CHARSET_INFO *cs= ci_ptr(thd,type)[0];
 
1870
  return cs ? (uchar*) cs->csname : (uchar*) NULL;
1743
1871
}
1744
1872
 
1745
1873
 
1753
1881
    thd->update_charset();
1754
1882
  }
1755
1883
}
1756
 
const CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
 
1884
CHARSET_INFO **sys_var_character_set_sv::ci_ptr(THD *thd, enum_var_type type)
1757
1885
{
1758
1886
  if (type == OPT_GLOBAL)
1759
1887
    return &(global_system_variables.*offset);
1777
1905
}
1778
1906
 
1779
1907
 
1780
 
const CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
 
1908
CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd,
1781
1909
                                                       enum_var_type type)
1782
1910
{
1783
1911
  if (type == OPT_GLOBAL)
1824
1952
}
1825
1953
 
1826
1954
 
1827
 
unsigned char *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
1828
 
                                       LEX_STRING *base __attribute__((unused)))
 
1955
uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type,
 
1956
                                       LEX_STRING *base __attribute__((__unused__)))
1829
1957
{
1830
 
  const CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
 
1958
  CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
1831
1959
                     global_system_variables.*offset : thd->variables.*offset);
1832
 
  return cs ? (unsigned char*) cs->name : (unsigned char*) "NULL";
 
1960
  return cs ? (uchar*) cs->name : (uchar*) "NULL";
1833
1961
}
1834
1962
 
1835
1963
 
1847
1975
}
1848
1976
 
1849
1977
 
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)))
 
1978
uchar *sys_var_key_cache_param::value_ptr(THD *thd __attribute__((__unused__)),
 
1979
                                          enum_var_type type __attribute__((__unused__)),
 
1980
                                          LEX_STRING *base __attribute__((__unused__)))
1853
1981
{
1854
1982
  KEY_CACHE *key_cache= get_key_cache(base);
1855
1983
  if (!key_cache)
1856
1984
    key_cache= &zero_key_cache;
1857
 
  return (unsigned char*) key_cache + offset ;
 
1985
  return (uchar*) key_cache + offset ;
1858
1986
}
1859
1987
 
1860
1988
 
1861
1989
bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
1862
1990
{
1863
 
  uint64_t tmp= var->save_result.uint64_t_value;
 
1991
  ulonglong tmp= var->save_result.ulonglong_value;
1864
1992
  LEX_STRING *base_name= &var->base;
1865
1993
  KEY_CACHE *key_cache;
1866
1994
  bool error= 0;
1896
2024
  {
1897
2025
    if (key_cache == dflt_key_cache)
1898
2026
    {
1899
 
      push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
2027
      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1900
2028
                          ER_WARN_CANT_DROP_DEFAULT_KEYCACHE,
1901
2029
                          ER(ER_WARN_CANT_DROP_DEFAULT_KEYCACHE));
1902
2030
      goto end;                                 // Ignore default key cache
1925
2053
  }
1926
2054
 
1927
2055
  key_cache->param_buff_size=
1928
 
    (uint64_t) fix_unsigned(thd, tmp, option_limits);
 
2056
    (ulonglong) fix_unsigned(thd, tmp, option_limits);
1929
2057
 
1930
2058
  /* If key cache didn't existed initialize it, else resize it */
1931
2059
  key_cache->in_init= 1;
2000
2128
}
2001
2129
 
2002
2130
 
2003
 
bool sys_var_log_state::update(THD *thd __attribute__((unused)), set_var *var)
 
2131
bool sys_var_log_state::update(THD *thd, set_var *var)
2004
2132
{
2005
2133
  bool res;
2006
2134
  pthread_mutex_lock(&LOCK_global_system_variables);
2007
2135
  if (!var->save_result.ulong_value)
 
2136
  {
 
2137
    logger.deactivate_log_handler(thd, log_type);
2008
2138
    res= false;
 
2139
  }
2009
2140
  else
2010
 
    res= true;
 
2141
    res= logger.activate_log_handler(thd, log_type);
2011
2142
  pthread_mutex_unlock(&LOCK_global_system_variables);
2012
2143
  return res;
2013
2144
}
2014
2145
 
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)),
 
2146
void sys_var_log_state::set_default(THD *thd,
 
2147
                                    enum_var_type type __attribute__((__unused__)))
 
2148
{
 
2149
  pthread_mutex_lock(&LOCK_global_system_variables);
 
2150
  logger.deactivate_log_handler(thd, log_type);
 
2151
  pthread_mutex_unlock(&LOCK_global_system_variables);
 
2152
}
 
2153
 
 
2154
 
 
2155
static int  sys_check_log_path(THD *thd __attribute__((__unused__)),
 
2156
                               set_var *var)
 
2157
{
 
2158
  char path[FN_REFLEN], buff[FN_REFLEN];
 
2159
  struct stat f_stat;
 
2160
  String str(buff, sizeof(buff), system_charset_info), *res;
 
2161
  const char *log_file_str;
 
2162
  size_t path_length;
 
2163
 
 
2164
  if (!(res= var->value->val_str(&str)))
 
2165
    goto err;
 
2166
 
 
2167
  log_file_str= res->c_ptr();
 
2168
  bzero(&f_stat, sizeof(struct stat));
 
2169
 
 
2170
  path_length= unpack_filename(path, log_file_str);
 
2171
 
 
2172
  if (!path_length)
 
2173
  {
 
2174
    /* File name is empty. */
 
2175
 
 
2176
    goto err;
 
2177
  }
 
2178
 
 
2179
  if (!stat(path, &f_stat))
 
2180
  {
 
2181
    /*
 
2182
      A file system object exists. Check if argument is a file and we have
 
2183
      'write' permission.
 
2184
    */
 
2185
 
 
2186
    if (!MY_S_ISREG(f_stat.st_mode) ||
 
2187
        !(f_stat.st_mode & MY_S_IWRITE))
 
2188
      goto err;
 
2189
 
 
2190
    return 0;
 
2191
  }
 
2192
 
 
2193
  /* Get dirname of the file path. */
 
2194
  (void) dirname_part(path, log_file_str, &path_length);
 
2195
 
 
2196
  /* Dirname is empty if file path is relative. */
 
2197
  if (!path_length)
 
2198
    return 0;
 
2199
 
 
2200
  /*
 
2201
    Check if directory exists and we have permission to create file and
 
2202
    write to file.
 
2203
  */
 
2204
  if (my_access(path, (F_OK|W_OK)))
 
2205
    goto err;
 
2206
 
 
2207
  return 0;
 
2208
 
 
2209
err:
 
2210
  my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name, 
 
2211
           res ? log_file_str : "NULL");
 
2212
  return 1;
 
2213
}
 
2214
 
 
2215
 
 
2216
bool update_sys_var_str_path(THD *thd __attribute__((__unused__)),
2022
2217
                             sys_var_str *var_str,
2023
2218
                             set_var *var, const char *log_ext,
2024
 
                             bool log_state, uint32_t log_type)
 
2219
                             bool log_state, uint log_type)
2025
2220
{
 
2221
  MYSQL_QUERY_LOG *file_log;
2026
2222
  char buff[FN_REFLEN];
2027
2223
  char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
2028
2224
  bool result= 0;
2029
 
  uint32_t str_length= (var ? var->value->str_value.length() : 0);
 
2225
  uint str_length= (var ? var->value->str_value.length() : 0);
2030
2226
 
2031
2227
  switch (log_type) {
 
2228
  case QUERY_LOG_SLOW:
 
2229
    file_log= logger.get_slow_log_file_handler();
 
2230
    break;
 
2231
  case QUERY_LOG_GENERAL:
 
2232
    file_log= logger.get_log_file_handler();
 
2233
    break;
2032
2234
  default:
2033
2235
    assert(0);                                  // Impossible
2034
2236
  }
2047
2249
  pthread_mutex_lock(&LOCK_global_system_variables);
2048
2250
  logger.lock_exclusive();
2049
2251
 
 
2252
  if (file_log && log_state)
 
2253
    file_log->close(0);
2050
2254
  old_value= var_str->value;
2051
2255
  var_str->value= res;
2052
2256
  var_str->value_length= str_length;
2053
 
  free(old_value);
2054
 
  if (log_state)
 
2257
  my_free(old_value, MYF(MY_ALLOW_ZERO_PTR));
 
2258
  if (file_log && log_state)
2055
2259
  {
2056
2260
    switch (log_type) {
 
2261
    case QUERY_LOG_SLOW:
 
2262
      file_log->open_slow_log(sys_var_slow_log_path.value);
 
2263
      break;
 
2264
    case QUERY_LOG_GENERAL:
 
2265
      file_log->open_query_log(sys_var_general_log_path.value);
 
2266
      break;
2057
2267
    default:
2058
2268
      assert(0);
2059
2269
    }
2067
2277
}
2068
2278
 
2069
2279
 
2070
 
bool sys_var_log_output::update(THD *thd __attribute__((unused)),
 
2280
static bool sys_update_general_log_path(THD *thd, set_var * var)
 
2281
{
 
2282
  return update_sys_var_str_path(thd, &sys_var_general_log_path,
 
2283
                                 var, ".log", opt_log, QUERY_LOG_GENERAL);
 
2284
}
 
2285
 
 
2286
 
 
2287
static void sys_default_general_log_path(THD *thd,
 
2288
                                         enum_var_type type __attribute__((__unused__)))
 
2289
{
 
2290
  (void) update_sys_var_str_path(thd, &sys_var_general_log_path,
 
2291
                                 0, ".log", opt_log, QUERY_LOG_GENERAL);
 
2292
}
 
2293
 
 
2294
 
 
2295
static bool sys_update_slow_log_path(THD *thd, set_var * var)
 
2296
{
 
2297
  return update_sys_var_str_path(thd, &sys_var_slow_log_path,
 
2298
                                 var, "-slow.log", opt_slow_log,
 
2299
                                 QUERY_LOG_SLOW);
 
2300
}
 
2301
 
 
2302
 
 
2303
static void sys_default_slow_log_path(THD *thd,
 
2304
                                      enum_var_type type __attribute__((__unused__)))
 
2305
{
 
2306
  (void) update_sys_var_str_path(thd, &sys_var_slow_log_path,
 
2307
                                 0, "-slow.log", opt_slow_log,
 
2308
                                 QUERY_LOG_SLOW);
 
2309
}
 
2310
 
 
2311
 
 
2312
bool sys_var_log_output::update(THD *thd __attribute__((__unused__)),
2071
2313
                                set_var *var)
2072
2314
{
2073
2315
  pthread_mutex_lock(&LOCK_global_system_variables);
2074
2316
  logger.lock_exclusive();
 
2317
  logger.init_slow_log(var->save_result.ulong_value);
 
2318
  logger.init_general_log(var->save_result.ulong_value);
2075
2319
  *value= var->save_result.ulong_value;
2076
2320
  logger.unlock();
2077
2321
  pthread_mutex_unlock(&LOCK_global_system_variables);
2079
2323
}
2080
2324
 
2081
2325
 
2082
 
void sys_var_log_output::set_default(THD *thd __attribute__((unused)),
2083
 
                                     enum_var_type type __attribute__((unused)))
 
2326
void sys_var_log_output::set_default(THD *thd __attribute__((__unused__)),
 
2327
                                     enum_var_type type __attribute__((__unused__)))
2084
2328
{
2085
2329
  pthread_mutex_lock(&LOCK_global_system_variables);
2086
2330
  logger.lock_exclusive();
 
2331
  logger.init_slow_log(LOG_FILE);
 
2332
  logger.init_general_log(LOG_FILE);
2087
2333
  *value= LOG_FILE;
2088
2334
  logger.unlock();
2089
2335
  pthread_mutex_unlock(&LOCK_global_system_variables);
2090
2336
}
2091
2337
 
2092
2338
 
2093
 
unsigned char *sys_var_log_output::value_ptr(THD *thd,
2094
 
                                     enum_var_type type __attribute__((unused)),
2095
 
                                     LEX_STRING *base __attribute__((unused)))
 
2339
uchar *sys_var_log_output::value_ptr(THD *thd,
 
2340
                                     enum_var_type type __attribute__((__unused__)),
 
2341
                                     LEX_STRING *base __attribute__((__unused__)))
2096
2342
{
2097
2343
  char buff[256];
2098
 
  String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
2344
  String tmp(buff, sizeof(buff), &my_charset_latin1);
2099
2345
  ulong length;
2100
2346
  ulong val= *value;
2101
2347
 
2102
2348
  tmp.length(0);
2103
 
  for (uint32_t i= 0; val; val>>= 1, i++)
 
2349
  for (uint i= 0; val; val>>= 1, i++)
2104
2350
  {
2105
2351
    if (val & 1)
2106
2352
    {
2112
2358
 
2113
2359
  if ((length= tmp.length()))
2114
2360
    length--;
2115
 
  return (unsigned char*) thd->strmake(tmp.ptr(), length);
 
2361
  return (uchar*) thd->strmake(tmp.ptr(), length);
2116
2362
}
2117
2363
 
2118
2364
 
2120
2366
  Functions to handle SET NAMES and SET CHARACTER SET
2121
2367
*****************************************************************************/
2122
2368
 
2123
 
int set_var_collation_client::check(THD *thd __attribute__((unused)))
 
2369
int set_var_collation_client::check(THD *thd __attribute__((__unused__)))
2124
2370
{
2125
2371
  /* Currently, UCS-2 cannot be used as a client character set */
2126
2372
  if (character_set_client->mbminlen > 1)
2146
2392
 
2147
2393
bool sys_var_timestamp::update(THD *thd,  set_var *var)
2148
2394
{
2149
 
  thd->set_time((time_t) var->save_result.uint64_t_value);
 
2395
  thd->set_time((time_t) var->save_result.ulonglong_value);
2150
2396
  return 0;
2151
2397
}
2152
2398
 
2153
2399
 
2154
2400
void sys_var_timestamp::set_default(THD *thd,
2155
 
                                    enum_var_type type __attribute__((unused)))
 
2401
                                    enum_var_type type __attribute__((__unused__)))
2156
2402
{
2157
2403
  thd->user_time=0;
2158
2404
}
2159
2405
 
2160
2406
 
2161
 
unsigned char *sys_var_timestamp::value_ptr(THD *thd,
2162
 
                                    enum_var_type type __attribute__((unused)),
2163
 
                                    LEX_STRING *base __attribute__((unused)))
 
2407
uchar *sys_var_timestamp::value_ptr(THD *thd,
 
2408
                                    enum_var_type type __attribute__((__unused__)),
 
2409
                                    LEX_STRING *base __attribute__((__unused__)))
2164
2410
{
2165
2411
  thd->sys_var_tmp.long_value= (long) thd->start_time;
2166
 
  return (unsigned char*) &thd->sys_var_tmp.long_value;
 
2412
  return (uchar*) &thd->sys_var_tmp.long_value;
2167
2413
}
2168
2414
 
2169
2415
 
2170
2416
bool sys_var_last_insert_id::update(THD *thd, set_var *var)
2171
2417
{
2172
2418
  thd->first_successful_insert_id_in_prev_stmt=
2173
 
    var->save_result.uint64_t_value;
 
2419
    var->save_result.ulonglong_value;
2174
2420
  return 0;
2175
2421
}
2176
2422
 
2177
2423
 
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)))
 
2424
uchar *sys_var_last_insert_id::value_ptr(THD *thd,
 
2425
                                         enum_var_type type __attribute__((__unused__)),
 
2426
                                         LEX_STRING *base __attribute__((__unused__)))
2181
2427
{
2182
2428
  /*
2183
2429
    this tmp var makes it robust againt change of type of
2184
2430
    read_first_successful_insert_id_in_prev_stmt().
2185
2431
  */
2186
 
  thd->sys_var_tmp.uint64_t_value= 
 
2432
  thd->sys_var_tmp.ulonglong_value= 
2187
2433
    thd->read_first_successful_insert_id_in_prev_stmt();
2188
 
  return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
 
2434
  return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2189
2435
}
2190
2436
 
2191
2437
 
2192
2438
bool sys_var_insert_id::update(THD *thd, set_var *var)
2193
2439
{
2194
 
  thd->force_one_auto_inc_interval(var->save_result.uint64_t_value);
 
2440
  thd->force_one_auto_inc_interval(var->save_result.ulonglong_value);
2195
2441
  return 0;
2196
2442
}
2197
2443
 
2198
2444
 
2199
 
unsigned char *sys_var_insert_id::value_ptr(THD *thd,
2200
 
                                    enum_var_type type __attribute__((unused)),
2201
 
                                    LEX_STRING *base __attribute__((unused)))
 
2445
uchar *sys_var_insert_id::value_ptr(THD *thd,
 
2446
                                    enum_var_type type __attribute__((__unused__)),
 
2447
                                    LEX_STRING *base __attribute__((__unused__)))
2202
2448
{
2203
 
  thd->sys_var_tmp.uint64_t_value=
 
2449
  thd->sys_var_tmp.ulonglong_value=
2204
2450
    thd->auto_inc_intervals_forced.minimum();
2205
 
  return (unsigned char*) &thd->sys_var_tmp.uint64_t_value;
 
2451
  return (uchar*) &thd->sys_var_tmp.ulonglong_value;
2206
2452
}
2207
2453
 
2208
2454
 
2209
2455
bool sys_var_rand_seed1::update(THD *thd, set_var *var)
2210
2456
{
2211
 
  thd->rand.seed1= (ulong) var->save_result.uint64_t_value;
 
2457
  thd->rand.seed1= (ulong) var->save_result.ulonglong_value;
2212
2458
  return 0;
2213
2459
}
2214
2460
 
2215
2461
bool sys_var_rand_seed2::update(THD *thd, set_var *var)
2216
2462
{
2217
 
  thd->rand.seed2= (ulong) var->save_result.uint64_t_value;
 
2463
  thd->rand.seed2= (ulong) var->save_result.ulonglong_value;
2218
2464
  return 0;
2219
2465
}
2220
2466
 
2222
2468
bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
2223
2469
{
2224
2470
  char buff[MAX_TIME_ZONE_NAME_LENGTH];
2225
 
  String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
2471
  String str(buff, sizeof(buff), &my_charset_latin1);
2226
2472
  String *res= var->value->val_str(&str);
2227
2473
 
2228
2474
  if (!(var->save_result.time_zone= my_tz_find(thd, res)))
2249
2495
}
2250
2496
 
2251
2497
 
2252
 
unsigned char *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
2253
 
                                        LEX_STRING *base __attribute__((unused)))
 
2498
uchar *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type,
 
2499
                                        LEX_STRING *base __attribute__((__unused__)))
2254
2500
{
2255
2501
  /* 
2256
2502
    We can use ptr() instead of c_ptr() here because String contaning
2257
2503
    time zone name is guaranteed to be zero ended.
2258
2504
  */
2259
2505
  if (type == OPT_GLOBAL)
2260
 
    return (unsigned char *)(global_system_variables.time_zone->get_name()->ptr());
 
2506
    return (uchar *)(global_system_variables.time_zone->get_name()->ptr());
2261
2507
  else
2262
2508
  {
2263
2509
    /*
2269
2515
      (binlog code stores session value only).
2270
2516
    */
2271
2517
    thd->time_zone_used= 1;
2272
 
    return (unsigned char *)(thd->variables.time_zone->get_name()->ptr());
 
2518
    return (uchar *)(thd->variables.time_zone->get_name()->ptr());
2273
2519
  }
2274
2520
}
2275
2521
 
2281
2527
 {
2282
2528
   if (default_tz_name)
2283
2529
   {
2284
 
     String str(default_tz_name, &my_charset_utf8_general_ci);
 
2530
     String str(default_tz_name, &my_charset_latin1);
2285
2531
     /*
2286
2532
       We are guaranteed to find this time zone since its existence
2287
2533
       is checked during start-up.
2312
2558
  }
2313
2559
}
2314
2560
 
2315
 
bool sys_var_max_user_conn::update(THD *thd __attribute__((unused)),
 
2561
bool sys_var_max_user_conn::update(THD *thd __attribute__((__unused__)),
2316
2562
                                   set_var *var)
2317
2563
{
2318
2564
  assert(var->type == OPT_GLOBAL);
2319
2565
  pthread_mutex_lock(&LOCK_global_system_variables);
2320
 
  max_user_connections= (uint)var->save_result.uint64_t_value;
 
2566
  max_user_connections= (uint)var->save_result.ulonglong_value;
2321
2567
  pthread_mutex_unlock(&LOCK_global_system_variables);
2322
2568
  return 0;
2323
2569
}
2324
2570
 
2325
2571
 
2326
 
void sys_var_max_user_conn::set_default(THD *thd __attribute__((unused)),
2327
 
                                        enum_var_type type __attribute__((unused)))
 
2572
void sys_var_max_user_conn::set_default(THD *thd __attribute__((__unused__)),
 
2573
                                        enum_var_type type __attribute__((__unused__)))
2328
2574
{
2329
2575
  assert(type == OPT_GLOBAL);
2330
2576
  pthread_mutex_lock(&LOCK_global_system_variables);
2333
2579
}
2334
2580
 
2335
2581
 
2336
 
unsigned char *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
2337
 
                                        LEX_STRING *base __attribute__((unused)))
 
2582
uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type,
 
2583
                                        LEX_STRING *base __attribute__((__unused__)))
2338
2584
{
2339
2585
  if (type != OPT_GLOBAL &&
2340
2586
      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);
 
2587
    return (uchar*) &(thd->user_connect->user_resources.user_conn);
 
2588
  return (uchar*) &(max_user_connections);
2343
2589
}
2344
2590
 
2345
2591
 
2346
 
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((unused)),
 
2592
bool sys_var_thd_lc_time_names::check(THD *thd __attribute__((__unused__)),
2347
2593
                                      set_var *var)
2348
2594
{
2349
2595
  MY_LOCALE *locale_match;
2361
2607
  else // STRING_RESULT
2362
2608
  {
2363
2609
    char buff[6]; 
2364
 
    String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res;
 
2610
    String str(buff, sizeof(buff), &my_charset_latin1), *res;
2365
2611
    if (!(res=var->value->val_str(&str)))
2366
2612
    {
2367
2613
      my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
2391
2637
}
2392
2638
 
2393
2639
 
2394
 
unsigned char *sys_var_thd_lc_time_names::value_ptr(THD *thd,
 
2640
uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd,
2395
2641
                                            enum_var_type type,
2396
 
                                            LEX_STRING *base __attribute__((unused)))
 
2642
                                            LEX_STRING *base __attribute__((__unused__)))
2397
2643
{
2398
2644
  return type == OPT_GLOBAL ?
2399
 
                 (unsigned char *) global_system_variables.lc_time_names->name :
2400
 
                 (unsigned char *) thd->variables.lc_time_names->name;
 
2645
                 (uchar *) global_system_variables.lc_time_names->name :
 
2646
                 (uchar *) thd->variables.lc_time_names->name;
2401
2647
}
2402
2648
 
2403
2649
 
2414
2660
 
2415
2661
  NOTES
2416
2662
    The argument to long query time is in seconds in decimal
2417
 
    which is converted to uint64_t integer holding microseconds for storage.
 
2663
    which is converted to ulonglong integer holding microseconds for storage.
2418
2664
    This is used for handling long_query_time
2419
2665
*/
2420
2666
 
2421
2667
bool sys_var_microseconds::update(THD *thd, set_var *var)
2422
2668
{
2423
2669
  double num= var->value->val_real();
2424
 
  int64_t microseconds;
 
2670
  longlong microseconds;
2425
2671
  if (num > (double) option_limits->max_value)
2426
2672
    num= (double) option_limits->max_value;
2427
2673
  if (num < (double) option_limits->min_value)
2428
2674
    num= (double) option_limits->min_value;
2429
 
  microseconds= (int64_t) (num * 1000000.0 + 0.5);
 
2675
  microseconds= (longlong) (num * 1000000.0 + 0.5);
2430
2676
  if (var->type == OPT_GLOBAL)
2431
2677
  {
2432
2678
    pthread_mutex_lock(&LOCK_global_system_variables);
2441
2687
 
2442
2688
void sys_var_microseconds::set_default(THD *thd, enum_var_type type)
2443
2689
{
2444
 
  int64_t microseconds= (int64_t) (option_limits->def_value * 1000000.0);
 
2690
  longlong microseconds= (longlong) (option_limits->def_value * 1000000.0);
2445
2691
  if (type == OPT_GLOBAL)
2446
2692
  {
2447
2693
    pthread_mutex_lock(&LOCK_global_system_variables);
2453
2699
}
2454
2700
 
2455
2701
 
2456
 
unsigned char *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
2457
 
                                          LEX_STRING *base __attribute__((unused)))
 
2702
uchar *sys_var_microseconds::value_ptr(THD *thd, enum_var_type type,
 
2703
                                          LEX_STRING *base __attribute__((__unused__)))
2458
2704
{
2459
2705
  thd->tmp_double_value= (double) ((type == OPT_GLOBAL) ?
2460
2706
                                   global_system_variables.*offset :
2461
2707
                                   thd->variables.*offset) / 1000000.0;
2462
 
  return (unsigned char*) &thd->tmp_double_value;
 
2708
  return (uchar*) &thd->tmp_double_value;
2463
2709
}
2464
2710
 
2465
2711
 
2482
2728
{
2483
2729
  /* The test is negative as the flag we use is NOT autocommit */
2484
2730
 
2485
 
  uint64_t org_options= thd->options;
 
2731
  ulonglong org_options= thd->options;
2486
2732
 
2487
2733
  if (var->save_result.ulong_value != 0)
2488
2734
    thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;
2494
2740
    if ((org_options & OPTION_NOT_AUTOCOMMIT))
2495
2741
    {
2496
2742
      /* We changed to auto_commit mode */
2497
 
      thd->options&= ~(uint64_t) (OPTION_BEGIN | OPTION_KEEP_LOG);
 
2743
      thd->options&= ~(ulonglong) (OPTION_BEGIN | OPTION_KEEP_LOG);
2498
2744
      thd->transaction.all.modified_non_trans_table= false;
2499
2745
      thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
2500
2746
      if (ha_commit(thd))
2509
2755
  return 0;
2510
2756
}
2511
2757
 
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)),
 
2758
static int check_log_update(THD *thd __attribute__((__unused__)),
 
2759
                            set_var *var __attribute__((__unused__)))
 
2760
{
 
2761
  return 0;
 
2762
}
 
2763
 
 
2764
static bool set_log_update(THD *thd __attribute__((__unused__)),
 
2765
                           set_var *var __attribute__((__unused__)))
 
2766
{
 
2767
  /*
 
2768
    The update log is not supported anymore since 5.0.
 
2769
    See sql/mysqld.cc/, comments in function init_server_components() for an
 
2770
    explaination of the different warnings we send below
 
2771
  */
 
2772
 
 
2773
  if (opt_sql_bin_update)
 
2774
  {
 
2775
    push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
 
2776
                 ER_UPDATE_LOG_DEPRECATED_TRANSLATED,
 
2777
                 ER(ER_UPDATE_LOG_DEPRECATED_TRANSLATED));
 
2778
  }
 
2779
  else
 
2780
    push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
 
2781
                 ER_UPDATE_LOG_DEPRECATED_IGNORED,
 
2782
                 ER(ER_UPDATE_LOG_DEPRECATED_IGNORED));
 
2783
  set_option_bit(thd, var);
 
2784
  return 0;
 
2785
}
 
2786
 
 
2787
 
 
2788
static int check_pseudo_thread_id(THD *thd __attribute__((__unused__)),
2520
2789
                                  set_var *var)
2521
2790
{
2522
 
  var->save_result.uint64_t_value= var->value->val_int();
 
2791
  var->save_result.ulonglong_value= var->value->val_int();
2523
2792
  return 0;
2524
2793
}
2525
2794
 
2526
 
static unsigned char *get_warning_count(THD *thd)
 
2795
static uchar *get_warning_count(THD *thd)
2527
2796
{
2528
2797
  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;
 
2798
    (thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
 
2799
     thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
 
2800
     thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
 
2801
  return (uchar*) &thd->sys_var_tmp.long_value;
2533
2802
}
2534
2803
 
2535
 
static unsigned char *get_error_count(THD *thd)
 
2804
static uchar *get_error_count(THD *thd)
2536
2805
{
2537
2806
  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;
 
2807
    thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR];
 
2808
  return (uchar*) &thd->sys_var_tmp.long_value;
2540
2809
}
2541
2810
 
2542
2811
 
2554
2823
  @retval
2555
2824
    ptr         pointer to NUL-terminated string
2556
2825
*/
2557
 
static unsigned char *get_tmpdir(THD *thd __attribute__((unused)))
 
2826
static uchar *get_tmpdir(THD *thd __attribute__((__unused__)))
2558
2827
{
2559
2828
  if (opt_mysql_tmpdir)
2560
 
    return (unsigned char *)opt_mysql_tmpdir;
2561
 
  return (unsigned char*)mysql_tmpdir;
 
2829
    return (uchar *)opt_mysql_tmpdir;
 
2830
  return (uchar*)mysql_tmpdir;
2562
2831
}
2563
2832
 
2564
2833
/****************************************************************************
2583
2852
 
2584
2853
static struct my_option *find_option(struct my_option *opt, const char *name) 
2585
2854
{
2586
 
  uint32_t length=strlen(name);
 
2855
  uint length=strlen(name);
2587
2856
  for (; opt->name; opt++)
2588
2857
  {
2589
2858
    if (!getopt_compare_strings(opt->name, name, length) &&
2604
2873
  Return variable name and length for hashing of variables.
2605
2874
*/
2606
2875
 
2607
 
static unsigned char *get_sys_var_length(const sys_var *var, size_t *length,
2608
 
                                 bool first __attribute__((unused)))
 
2876
static uchar *get_sys_var_length(const sys_var *var, size_t *length,
 
2877
                                 my_bool first __attribute__((__unused__)))
2609
2878
{
2610
2879
  *length= var->name_length;
2611
 
  return (unsigned char*) var->name;
 
2880
  return (uchar*) var->name;
2612
2881
}
2613
2882
 
2614
2883
 
2636
2905
  {
2637
2906
    var->name_length= strlen(var->name);
2638
2907
    /* this fails if there is a conflicting variable name. see HASH_UNIQUE */
2639
 
    if (my_hash_insert(&system_variable_hash, (unsigned char*) var))
 
2908
    if (my_hash_insert(&system_variable_hash, (uchar*) var))
2640
2909
      goto error;
2641
2910
    if (long_options)
2642
2911
      var->option_limits= find_option(long_options, var->name);
2645
2914
 
2646
2915
error:
2647
2916
  for (; first != var; first= first->next)
2648
 
    hash_delete(&system_variable_hash, (unsigned char*) first);
 
2917
    hash_delete(&system_variable_hash, (uchar*) first);
2649
2918
  return 1;
2650
2919
}
2651
2920
 
2669
2938
  /* A write lock should be held on LOCK_system_variables_hash */
2670
2939
   
2671
2940
  for (sys_var *var= first; var; var= var->next)
2672
 
    result|= hash_delete(&system_variable_hash, (unsigned char*) var);
 
2941
    result|= hash_delete(&system_variable_hash, (uchar*) var);
2673
2942
 
2674
2943
  return result;
2675
2944
}
2721
2990
               (qsort_cmp) show_cmp);
2722
2991
    
2723
2992
    /* make last element empty */
2724
 
    memset(show, 0, sizeof(SHOW_VAR));
 
2993
    bzero(show, sizeof(SHOW_VAR));
2725
2994
  }
2726
2995
  return result;
2727
2996
}
2740
3009
 
2741
3010
int set_var_init()
2742
3011
{
2743
 
  uint32_t count= 0;
 
3012
  uint count= 0;
2744
3013
  
2745
3014
  for (sys_var *var=vars.first; var; var= var->next, count++) {};
2746
3015
 
2759
3028
  if (mysql_add_sys_var_chain(vars.first, my_long_options))
2760
3029
    goto error;
2761
3030
 
 
3031
  /*
 
3032
    Special cases
 
3033
    Needed because MySQL can't find the limits for a variable it it has
 
3034
    a different name than the command line option.
 
3035
    As these variables are deprecated, this code will disappear soon...
 
3036
  */
 
3037
  sys_sql_max_join_size.option_limits= sys_max_join_size.option_limits;
 
3038
 
2762
3039
  return(0);
2763
3040
 
2764
3041
error:
2786
3063
    0           SUCCESS
2787
3064
    otherwise   FAILURE
2788
3065
*/
2789
 
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint32_t count)
 
3066
int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count)
2790
3067
{
2791
3068
  for (; count > 0; count--, show_vars++)
2792
 
    if (insert_dynamic(&fixed_show_vars, (unsigned char*) show_vars))
 
3069
    if (insert_dynamic(&fixed_show_vars, (uchar*) show_vars))
2793
3070
      return 1;
2794
3071
  return 0;
2795
3072
}
2809
3086
    0           Unknown variable (error message is given)
2810
3087
*/
2811
3088
 
2812
 
sys_var *intern_find_sys_var(const char *str, uint32_t length, bool no_error)
 
3089
sys_var *intern_find_sys_var(const char *str, uint length, bool no_error)
2813
3090
{
2814
3091
  sys_var *var;
2815
3092
 
2818
3095
    A lock on LOCK_system_variable_hash should be held
2819
3096
  */
2820
3097
  var= (sys_var*) hash_search(&system_variable_hash,
2821
 
                              (unsigned char*) str, length ? length : strlen(str));
 
3098
                              (uchar*) str, length ? length : strlen(str));
2822
3099
  if (!(var || no_error))
2823
3100
    my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str);
2824
3101
 
2977
3254
}
2978
3255
 
2979
3256
 
2980
 
int set_var_user::update(THD *thd __attribute__((unused)))
 
3257
int set_var_user::update(THD *thd __attribute__((__unused__)))
2981
3258
{
2982
3259
  if (user_var_item->update())
2983
3260
  {
2998
3275
{
2999
3276
  char buff[STRING_BUFFER_USUAL_SIZE];
3000
3277
  const char *value;
3001
 
  String str(buff, sizeof(buff), &my_charset_utf8_general_ci), *res;
 
3278
  String str(buff, sizeof(buff), &my_charset_latin1), *res;
3002
3279
 
3003
3280
  var->save_result.plugin= NULL;
3004
3281
  if (var->value->result_type() == STRING_RESULT)
3009
3286
        !(engine_name.str= (char *)res->ptr()) ||
3010
3287
        !(engine_name.length= res->length()) ||
3011
3288
        !(var->save_result.plugin= ha_resolve_by_name(thd, &engine_name)) ||
3012
 
        !(hton= plugin_data(var->save_result.plugin, handlerton *)))
 
3289
        !(hton= plugin_data(var->save_result.plugin, handlerton *)) ||
 
3290
        ha_checktype(thd, ha_legacy_type(hton), 1, 0) != hton)
3013
3291
    {
3014
3292
      value= res ? res->c_ptr() : "NULL";
3015
3293
      goto err;
3024
3302
}
3025
3303
 
3026
3304
 
3027
 
unsigned char *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
3028
 
                                             LEX_STRING *base __attribute__((unused)))
 
3305
uchar *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
 
3306
                                             LEX_STRING *base __attribute__((__unused__)))
3029
3307
{
3030
 
  unsigned char* result;
 
3308
  uchar* result;
3031
3309
  handlerton *hton;
3032
3310
  LEX_STRING *engine_name;
3033
3311
  plugin_ref plugin= thd->variables.*offset;
3035
3313
    plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
3036
3314
  hton= plugin_data(plugin, handlerton*);
3037
3315
  engine_name= &hton2plugin[hton->slot]->name;
3038
 
  result= (unsigned char *) thd->strmake(engine_name->str, engine_name->length);
 
3316
  result= (uchar *) thd->strmake(engine_name->str, engine_name->length);
3039
3317
  if (type == OPT_GLOBAL)
3040
3318
    plugin_unlock(thd, plugin);
3041
3319
  return result;
3078
3356
 
3079
3357
bool
3080
3358
sys_var_thd_optimizer_switch::
3081
 
symbolic_mode_representation(THD *thd, uint64_t val, LEX_STRING *rep)
 
3359
symbolic_mode_representation(THD *thd, ulonglong val, LEX_STRING *rep)
3082
3360
{
3083
3361
  char buff[STRING_BUFFER_USUAL_SIZE*8];
3084
 
  String tmp(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
3362
  String tmp(buff, sizeof(buff), &my_charset_latin1);
3085
3363
 
3086
3364
  tmp.length(0);
3087
3365
 
3088
 
  for (uint32_t i= 0; val; val>>= 1, i++)
 
3366
  for (uint i= 0; val; val>>= 1, i++)
3089
3367
  {
3090
3368
    if (val & 1)
3091
3369
    {
3106
3384
}
3107
3385
 
3108
3386
 
3109
 
unsigned char *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
3110
 
                                               LEX_STRING *base __attribute__((unused)))
 
3387
uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
 
3388
                                               LEX_STRING *base __attribute__((__unused__)))
3111
3389
{
3112
3390
  LEX_STRING opts;
3113
 
  uint64_t val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
 
3391
  ulonglong val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
3114
3392
                  thd->variables.*offset);
3115
3393
  (void) symbolic_mode_representation(thd, val, &opts);
3116
 
  return (unsigned char *) opts.str;
 
3394
  return (uchar *) opts.str;
3117
3395
}
3118
3396
 
3119
3397
 
3130
3408
  Named list handling
3131
3409
****************************************************************************/
3132
3410
 
3133
 
unsigned char* find_named(I_List<NAMED_LIST> *list, const char *name, uint32_t length,
 
3411
uchar* find_named(I_List<NAMED_LIST> *list, const char *name, uint length,
3134
3412
                NAMED_LIST **found)
3135
3413
{
3136
3414
  I_List_iterator<NAMED_LIST> it(*list);
3149
3427
 
3150
3428
 
3151
3429
void delete_elements(I_List<NAMED_LIST> *list,
3152
 
                     void (*free_element)(const char *name, unsigned char*))
 
3430
                     void (*free_element)(const char *name, uchar*))
3153
3431
{
3154
3432
  NAMED_LIST *element;
3155
3433
  while ((element= list->get()))
3163
3441
 
3164
3442
/* Key cache functions */
3165
3443
 
3166
 
static KEY_CACHE *create_key_cache(const char *name, uint32_t length)
 
3444
static KEY_CACHE *create_key_cache(const char *name, uint length)
3167
3445
{
3168
3446
  KEY_CACHE *key_cache;
3169
3447
  
3170
3448
  if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE),
3171
3449
                                             MYF(MY_ZEROFILL | MY_WME))))
3172
3450
  {
3173
 
    if (!new NAMED_LIST(&key_caches, name, length, (unsigned char*) key_cache))
 
3451
    if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache))
3174
3452
    {
3175
 
      free((char*) key_cache);
 
3453
      my_free((char*) key_cache, MYF(0));
3176
3454
      key_cache= 0;
3177
3455
    }
3178
3456
    else
3192
3470
}
3193
3471
 
3194
3472
 
3195
 
KEY_CACHE *get_or_create_key_cache(const char *name, uint32_t length)
 
3473
KEY_CACHE *get_or_create_key_cache(const char *name, uint length)
3196
3474
{
3197
3475
  LEX_STRING key_cache_name;
3198
3476
  KEY_CACHE *key_cache;
3207
3485
}
3208
3486
 
3209
3487
 
3210
 
void free_key_cache(const char *name __attribute__((unused)),
 
3488
void free_key_cache(const char *name __attribute__((__unused__)),
3211
3489
                    KEY_CACHE *key_cache)
3212
3490
{
3213
3491
  ha_end_key_cache(key_cache);
3214
 
  free((char*) key_cache);
 
3492
  my_free((char*) key_cache, MYF(0));
3215
3493
}
3216
3494
 
3217
3495