Skip to content

Commit 9b53276

Browse files
Merge [email protected]:/home/bk/mysql-5.1-new
into poseidon.ndb.mysql.com:/home/tomas/mysql-5.1-new
2 parents c1038de + 63a497a commit 9b53276

File tree

5 files changed

+95
-237
lines changed

5 files changed

+95
-237
lines changed

sql/set_var.cc

Lines changed: 55 additions & 231 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ static KEY_CACHE *create_key_cache(const char *name, uint length);
120120
void fix_sql_mode_var(THD *thd, enum_var_type type);
121121
static byte *get_error_count(THD *thd);
122122
static byte *get_warning_count(THD *thd);
123-
static byte *get_have_innodb(THD *thd);
124123

125124
/*
126125
Variable definition list
@@ -129,6 +128,9 @@ static byte *get_have_innodb(THD *thd);
129128
alphabetic order
130129
*/
131130

131+
sys_var *sys_var::first= NULL;
132+
uint sys_var::sys_vars= 0;
133+
132134
sys_var_thd_ulong sys_auto_increment_increment("auto_increment_increment",
133135
&SV::auto_increment_increment);
134136
sys_var_thd_ulong sys_auto_increment_offset("auto_increment_offset",
@@ -552,203 +554,33 @@ sys_var_thd_time_zone sys_time_zone("time_zone");
552554
/* Read only variables */
553555

554556
sys_var_const_str sys_os("version_compile_os", SYSTEM_TYPE);
555-
sys_var_readonly sys_have_innodb("have_innodb", OPT_GLOBAL,
556-
SHOW_CHAR, get_have_innodb);
557-
/* Global read-only variable describing server license */
558-
sys_var_const_str sys_license("license", STRINGIFY_ARG(LICENSE));
559-
560557

561-
/*
562-
List of all variables for initialisation and storage in hash
563-
This is sorted in alphabetical order to make it easy to add new variables
564-
565-
If the variable is not in this list, it can't be changed with
566-
SET variable_name=
567-
*/
558+
sys_var_have_variable sys_have_archive_db("have_archive", &have_archive_db);
559+
sys_var_have_variable sys_have_berkeley_db("have_bdb", &have_berkeley_db);
560+
sys_var_have_variable sys_have_blackhole_db("have_blackhole_engine",
561+
&have_blackhole_db);
562+
sys_var_have_variable sys_have_compress("have_compress", &have_compress);
563+
sys_var_have_variable sys_have_crypt("have_crypt", &have_crypt);
564+
sys_var_have_variable sys_have_csv_db("have_csv", &have_csv_db);
565+
sys_var_have_variable sys_have_example_db("have_example_engine",
566+
&have_example_db);
567+
sys_var_have_variable sys_have_federated_db("have_federated_engine",
568+
&have_federated_db);
569+
sys_var_have_variable sys_have_geometry("have_geometry", &have_geometry);
570+
sys_var_have_variable sys_have_innodb("have_innodb", &have_innodb);
571+
sys_var_have_variable sys_have_isam("have_isam", &have_isam);
572+
sys_var_have_variable sys_have_ndbcluster("have_ndbcluster", &have_ndbcluster);
573+
sys_var_have_variable sys_have_openssl("have_openssl", &have_openssl);
574+
sys_var_have_variable sys_have_partition_db("have_partition_engine",
575+
&have_partition_db);
576+
sys_var_have_variable sys_have_query_cache("have_query_cache",
577+
&have_query_cache);
578+
sys_var_have_variable sys_have_raid("have_raid", &have_raid);
579+
sys_var_have_variable sys_have_rtree_keys("have_rtree_keys", &have_rtree_keys);
580+
sys_var_have_variable sys_have_symlink("have_symlink", &have_symlink);
568581

569-
sys_var *sys_variables[]=
570-
{
571-
&sys_auto_is_null,
572-
&sys_auto_increment_increment,
573-
&sys_auto_increment_offset,
574-
&sys_autocommit,
575-
&sys_automatic_sp_privileges,
576-
&sys_big_tables,
577-
&sys_big_selects,
578-
&sys_binlog_cache_size,
579-
&sys_buffer_results,
580-
&sys_bulk_insert_buff_size,
581-
&sys_character_set_server,
582-
&sys_character_set_database,
583-
&sys_character_set_client,
584-
&sys_character_set_connection,
585-
&sys_character_set_results,
586-
&sys_charset_system,
587-
&sys_collation_connection,
588-
&sys_collation_database,
589-
&sys_collation_server,
590-
&sys_completion_type,
591-
&sys_concurrent_insert,
592-
&sys_connect_timeout,
593-
&sys_date_format,
594-
&sys_datetime_format,
595-
&sys_div_precincrement,
596-
&sys_default_week_format,
597-
&sys_delay_key_write,
598-
&sys_delayed_insert_limit,
599-
&sys_delayed_insert_timeout,
600-
&sys_delayed_queue_size,
601-
&sys_error_count,
602-
&sys_expire_logs_days,
603-
&sys_flush,
604-
&sys_flush_time,
605-
&sys_ft_boolean_syntax,
606-
&sys_foreign_key_checks,
607-
&sys_group_concat_max_len,
608-
&sys_have_innodb,
609-
&sys_identity,
610-
&sys_init_connect,
611-
&sys_init_slave,
612-
&sys_insert_id,
613-
&sys_interactive_timeout,
614-
&sys_join_buffer_size,
615-
&sys_key_buffer_size,
616-
&sys_key_cache_block_size,
617-
&sys_key_cache_division_limit,
618-
&sys_key_cache_age_threshold,
619-
&sys_last_insert_id,
620-
&sys_license,
621-
&sys_local_infile,
622-
&sys_log_binlog,
623-
&sys_log_off,
624-
&sys_log_update,
625-
&sys_log_warnings,
626-
&sys_long_query_time,
627-
&sys_low_priority_updates,
628-
&sys_max_allowed_packet,
629-
&sys_max_binlog_cache_size,
630-
&sys_max_binlog_size,
631-
&sys_max_connect_errors,
632-
&sys_max_connections,
633-
&sys_max_delayed_threads,
634-
&sys_max_error_count,
635-
&sys_max_insert_delayed_threads,
636-
&sys_max_heap_table_size,
637-
&sys_max_join_size,
638-
&sys_max_length_for_sort_data,
639-
&sys_max_relay_log_size,
640-
&sys_max_seeks_for_key,
641-
&sys_max_sort_length,
642-
&sys_max_tmp_tables,
643-
&sys_max_user_connections,
644-
&sys_max_write_lock_count,
645-
&sys_multi_range_count,
646-
&sys_myisam_data_pointer_size,
647-
&sys_myisam_max_sort_file_size,
648-
&sys_myisam_repair_threads,
649-
&sys_myisam_sort_buffer_size,
650-
&sys_myisam_stats_method,
651-
&sys_net_buffer_length,
652-
&sys_net_read_timeout,
653-
&sys_net_retry_count,
654-
&sys_net_wait_timeout,
655-
&sys_net_write_timeout,
656-
&sys_new_mode,
657-
&sys_old_alter_table,
658-
&sys_old_passwords,
659-
&sys_optimizer_prune_level,
660-
&sys_optimizer_search_depth,
661-
&sys_preload_buff_size,
662-
&sys_pseudo_thread_id,
663-
&sys_query_alloc_block_size,
664-
&sys_query_cache_size,
665-
&sys_query_prealloc_size,
666-
#ifdef HAVE_QUERY_CACHE
667-
&sys_query_cache_limit,
668-
&sys_query_cache_min_res_unit,
669-
&sys_query_cache_type,
670-
&sys_query_cache_wlock_invalidate,
671-
#endif /* HAVE_QUERY_CACHE */
672-
&sys_quote_show_create,
673-
&sys_rand_seed1,
674-
&sys_rand_seed2,
675-
&sys_range_alloc_block_size,
676-
&sys_readonly,
677-
&sys_read_buff_size,
678-
&sys_read_rnd_buff_size,
679-
#ifdef HAVE_REPLICATION
680-
&sys_relay_log_purge,
681-
#endif
682-
&sys_rpl_recovery_rank,
683-
&sys_safe_updates,
684-
&sys_secure_auth,
685-
&sys_select_limit,
686-
&sys_server_id,
687-
#ifdef HAVE_REPLICATION
688-
&sys_slave_compressed_protocol,
689-
&sys_slave_net_timeout,
690-
&sys_slave_trans_retries,
691-
&sys_slave_skip_counter,
692-
#endif
693-
&sys_slow_launch_time,
694-
&sys_sort_buffer,
695-
&sys_sql_big_tables,
696-
&sys_sql_low_priority_updates,
697-
&sys_sql_max_join_size,
698-
&sys_sql_mode,
699-
&sys_sql_warnings,
700-
&sys_sql_notes,
701-
&sys_storage_engine,
702-
#ifdef HAVE_REPLICATION
703-
&sys_sync_binlog_period,
704-
&sys_sync_replication,
705-
&sys_sync_replication_slave_id,
706-
&sys_sync_replication_timeout,
707-
#endif
708-
&sys_sync_frm,
709-
&sys_table_cache_size,
710-
&sys_table_lock_wait_timeout,
711-
&sys_table_type,
712-
&sys_thread_cache_size,
713-
&sys_time_format,
714-
&sys_timed_mutexes,
715-
&sys_timestamp,
716-
&sys_time_zone,
717-
&sys_tmp_table_size,
718-
&sys_trans_alloc_block_size,
719-
&sys_trans_prealloc_size,
720-
&sys_tx_isolation,
721-
&sys_os,
722-
#ifdef HAVE_INNOBASE_DB
723-
&sys_innodb_fast_shutdown,
724-
&sys_innodb_max_dirty_pages_pct,
725-
&sys_innodb_max_purge_lag,
726-
&sys_innodb_table_locks,
727-
&sys_innodb_support_xa,
728-
&sys_innodb_max_purge_lag,
729-
&sys_innodb_autoextend_increment,
730-
&sys_innodb_sync_spin_loops,
731-
&sys_innodb_concurrency_tickets,
732-
&sys_innodb_thread_sleep_delay,
733-
&sys_innodb_thread_concurrency,
734-
&sys_innodb_commit_concurrency,
735-
#endif
736-
&sys_trust_routine_creators,
737-
&sys_engine_condition_pushdown,
738-
#ifdef HAVE_NDBCLUSTER_DB
739-
&sys_ndb_autoincrement_prefetch_sz,
740-
&sys_ndb_cache_check_time,
741-
&sys_ndb_force_send,
742-
&sys_ndb_use_exact_count,
743-
&sys_ndb_use_transactions,
744-
&sys_ndb_index_stat_enable,
745-
&sys_ndb_index_stat_cache_entries,
746-
&sys_ndb_index_stat_update_freq,
747-
#endif
748-
&sys_unique_checks,
749-
&sys_updatable_views_with_limit,
750-
&sys_warning_count
751-
};
582+
/* Global read-only variable describing server license */
583+
sys_var_const_str sys_license("license", STRINGIFY_ARG(LICENSE));
752584

753585

754586
/*
@@ -805,24 +637,24 @@ struct show_var_st init_vars[]= {
805637
{"ft_query_expansion_limit",(char*) &ft_query_expansion_limit, SHOW_LONG},
806638
{"ft_stopword_file", (char*) &ft_stopword_file, SHOW_CHAR_PTR},
807639
{sys_group_concat_max_len.name, (char*) &sys_group_concat_max_len, SHOW_SYS},
808-
{"have_archive", (char*) &have_archive_db, SHOW_HAVE},
809-
{"have_bdb", (char*) &have_berkeley_db, SHOW_HAVE},
810-
{"have_blackhole_engine", (char*) &have_blackhole_db, SHOW_HAVE},
811-
{"have_compress", (char*) &have_compress, SHOW_HAVE},
812-
{"have_crypt", (char*) &have_crypt, SHOW_HAVE},
813-
{"have_csv", (char*) &have_csv_db, SHOW_HAVE},
814-
{"have_example_engine", (char*) &have_example_db, SHOW_HAVE},
815-
{"have_federated_engine", (char*) &have_federated_db, SHOW_HAVE},
816-
{"have_geometry", (char*) &have_geometry, SHOW_HAVE},
817-
{"have_innodb", (char*) &have_innodb, SHOW_HAVE},
818-
{"have_isam", (char*) &have_isam, SHOW_HAVE},
819-
{"have_ndbcluster", (char*) &have_ndbcluster, SHOW_HAVE},
820-
{"have_openssl", (char*) &have_openssl, SHOW_HAVE},
821-
{"have_partition_engine", (char*) &have_partition_db, SHOW_HAVE},
822-
{"have_query_cache", (char*) &have_query_cache, SHOW_HAVE},
823-
{"have_raid", (char*) &have_raid, SHOW_HAVE},
824-
{"have_rtree_keys", (char*) &have_rtree_keys, SHOW_HAVE},
825-
{"have_symlink", (char*) &have_symlink, SHOW_HAVE},
640+
{sys_have_archive_db.name, (char*) &have_archive_db, SHOW_HAVE},
641+
{sys_have_berkeley_db.name, (char*) &have_berkeley_db, SHOW_HAVE},
642+
{sys_have_blackhole_db.name,(char*) &have_blackhole_db, SHOW_HAVE},
643+
{sys_have_compress.name, (char*) &have_compress, SHOW_HAVE},
644+
{sys_have_crypt.name, (char*) &have_crypt, SHOW_HAVE},
645+
{sys_have_csv_db.name, (char*) &have_csv_db, SHOW_HAVE},
646+
{sys_have_example_db.name, (char*) &have_example_db, SHOW_HAVE},
647+
{sys_have_federated_db.name,(char*) &have_federated_db, SHOW_HAVE},
648+
{sys_have_geometry.name, (char*) &have_geometry, SHOW_HAVE},
649+
{sys_have_innodb.name, (char*) &have_innodb, SHOW_HAVE},
650+
{sys_have_isam.name, (char*) &have_isam, SHOW_HAVE},
651+
{sys_have_ndbcluster.name, (char*) &have_ndbcluster, SHOW_HAVE},
652+
{sys_have_openssl.name, (char*) &have_openssl, SHOW_HAVE},
653+
{sys_have_partition_db.name,(char*) &have_partition_db, SHOW_HAVE},
654+
{sys_have_query_cache.name, (char*) &have_query_cache, SHOW_HAVE},
655+
{sys_have_raid.name, (char*) &have_raid, SHOW_HAVE},
656+
{sys_have_rtree_keys.name, (char*) &have_rtree_keys, SHOW_HAVE},
657+
{sys_have_symlink.name, (char*) &have_symlink, SHOW_HAVE},
826658
{"init_connect", (char*) &sys_init_connect, SHOW_SYS},
827659
{"init_file", (char*) &opt_init_file, SHOW_CHAR_PTR},
828660
{"init_slave", (char*) &sys_init_slave, SHOW_SYS},
@@ -2794,12 +2626,6 @@ static byte *get_error_count(THD *thd)
27942626
}
27952627

27962628

2797-
static byte *get_have_innodb(THD *thd)
2798-
{
2799-
return (byte*) show_comp_option_name[have_innodb];
2800-
}
2801-
2802-
28032629
/****************************************************************************
28042630
Main handling of variables:
28052631
- Initialisation
@@ -2858,17 +2684,15 @@ static byte *get_sys_var_length(const sys_var *var, uint *length,
28582684

28592685
void set_var_init()
28602686
{
2861-
hash_init(&system_variable_hash, system_charset_info,
2862-
array_elements(sys_variables),0,0,
2863-
(hash_get_key) get_sys_var_length,0,0);
2864-
sys_var **var, **end;
2865-
for (var= sys_variables, end= sys_variables+array_elements(sys_variables) ;
2866-
var < end;
2867-
var++)
2868-
{
2869-
(*var)->name_length= strlen((*var)->name);
2870-
(*var)->option_limits= find_option(my_long_options, (*var)->name);
2871-
my_hash_insert(&system_variable_hash, (byte*) *var);
2687+
sys_var *var;
2688+
2689+
hash_init(&system_variable_hash, system_charset_info, sys_var::sys_vars, 0,
2690+
0, (hash_get_key) get_sys_var_length, 0, 0);
2691+
for (var= sys_var::first; var; var= var->next)
2692+
{
2693+
var->name_length= strlen(var->name);
2694+
var->option_limits= find_option(my_long_options, var->name);
2695+
my_hash_insert(&system_variable_hash, (byte*) var);
28722696
}
28732697
/*
28742698
Special cases

sql/set_var.h

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ typedef byte *(*sys_value_ptr_func)(THD *thd);
3939
class sys_var
4040
{
4141
public:
42+
static sys_var *first;
43+
static uint sys_vars;
44+
sys_var *next;
4245
struct my_option *option_limits; /* Updated by by set_var_init() */
4346
uint name_length; /* Updated by by set_var_init() */
4447
const char *name;
@@ -48,12 +51,18 @@ class sys_var
4851
sys_var(const char *name_arg)
4952
:name(name_arg), after_update(0)
5053
, no_support_one_shot(1)
51-
{}
54+
{ add_sys_var(); }
5255
sys_var(const char *name_arg,sys_after_update_func func)
5356
:name(name_arg), after_update(func)
5457
, no_support_one_shot(1)
55-
{}
58+
{ add_sys_var(); }
5659
virtual ~sys_var() {}
60+
void add_sys_var()
61+
{
62+
next= first;
63+
first= this;
64+
sys_vars++;
65+
}
5766
virtual bool check(THD *thd, set_var *var);
5867
bool check_enum(THD *thd, set_var *var, TYPELIB *enum_names);
5968
bool check_set(THD *thd, set_var *var, TYPELIB *enum_names);
@@ -701,6 +710,30 @@ class sys_var_readonly: public sys_var
701710
bool is_readonly() const { return 1; }
702711
};
703712

713+
714+
class sys_var_have_variable: public sys_var
715+
{
716+
SHOW_COMP_OPTION *have_variable;
717+
718+
public:
719+
sys_var_have_variable(const char *variable_name,
720+
SHOW_COMP_OPTION *have_variable_arg):
721+
sys_var(variable_name),
722+
have_variable(have_variable_arg)
723+
{ }
724+
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
725+
{
726+
return (byte*) show_comp_option_name[*have_variable];
727+
}
728+
bool update(THD *thd, set_var *var) { return 1; }
729+
bool check_default(enum_var_type type) { return 1; }
730+
bool check_type(enum_var_type type) { return type != OPT_GLOBAL; }
731+
bool check_update_type(Item_result type) { return 1; }
732+
SHOW_TYPE type() { return SHOW_CHAR; }
733+
bool is_readonly() const { return 1; }
734+
};
735+
736+
704737
class sys_var_thd_time_zone :public sys_var_thd
705738
{
706739
public:

0 commit comments

Comments
 (0)