diff options
author | unknown <antony@ltantony.rdg.cyberkinetica.homeunix.net> | 2003-12-17 22:52:03 +0000 |
---|---|---|
committer | unknown <antony@ltantony.rdg.cyberkinetica.homeunix.net> | 2003-12-17 22:52:03 +0000 |
commit | fcbb2f077b942794a21e640414a31d18537c543e (patch) | |
tree | c639b3a159120373264b2f97623f8759e2226d61 /sql | |
parent | 27bcbf336ce5e23bf9651cc6382bf3556ded71dc (diff) | |
download | mariadb-git-fcbb2f077b942794a21e640414a31d18537c543e.tar.gz |
WorkLog #1323 (part 2)
New Statement: SHOW [STORAGE] ENGINES
New System Variable: storage_engine
New mysqld Argument: --default-storage-engine=
include/mysqld_error.h:
We now call handlers STORAGE ENGINEs
include/sql_state.h:
We now call handlers STORAGE ENGINEs
mysql-test/r/create.result:
table_type system variable becomes storage_engine
mysql-test/r/key_cache.result:
table_type system variable becomes storage_engine
mysql-test/r/variables.result:
table_type system variable becomes storage_engine
mysql-test/r/warnings.result:
Test for deprecated table_type system variable
mysql-test/t/create.test:
table_type system variable becomes storage_engine
mysql-test/t/key_cache.test:
table_type system variable becomes storage_engine
mysql-test/t/variables.test:
table_type system variable becomes storage_engine
mysql-test/t/warnings.test:
Test for deprecated table_type system variable
sql/handler.cc:
change name for consistency
sql/handler.h:
change name for consistency
sql/lex.h:
New keywords - ENGINES and STORAGE
sql/mysql_priv.h:
change name for consistency
sql/mysqld.cc:
New command like argument for default-storage-engine
sql/set_var.cc:
New system variable for storage_engine
sql/set_var.h:
New system variable for storage_engine
sql/sql_lex.h:
Change for consistancy
sql/sql_parse.cc:
Change for consistancy
sql/sql_show.cc:
Change for consistancy
sql/sql_table.cc:
Change for consistancy
sql/sql_yacc.yy:
New keywords: STORAGE and ENGINES
Change table_types to storage_engines
New statement: SHOW [STORAGE] ENGINES
Diffstat (limited to 'sql')
-rw-r--r-- | sql/handler.cc | 2 | ||||
-rw-r--r-- | sql/handler.h | 2 | ||||
-rw-r--r-- | sql/lex.h | 2 | ||||
-rw-r--r-- | sql/mysql_priv.h | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 13 | ||||
-rw-r--r-- | sql/set_var.cc | 37 | ||||
-rw-r--r-- | sql/set_var.h | 14 | ||||
-rw-r--r-- | sql/sql_lex.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 4 | ||||
-rw-r--r-- | sql/sql_show.cc | 6 | ||||
-rw-r--r-- | sql/sql_table.cc | 4 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 29 |
12 files changed, 85 insertions, 32 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index fe168d12fce..e9eecabaa84 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -104,7 +104,7 @@ enum db_type ha_resolve_by_name(const char *name, uint namelen) return DB_TYPE_UNKNOWN; } -const char *ha_get_table_type(enum db_type db_type) +const char *ha_get_storage_engine(enum db_type db_type) { show_table_type_st *types; for (types= sys_table_types; types->type; types++) diff --git a/sql/handler.h b/sql/handler.h index 2183b8fa992..36700695406 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -392,7 +392,7 @@ extern TYPELIB tx_isolation_typelib; #define ha_supports_generate(T) (T != DB_TYPE_INNODB) enum db_type ha_resolve_by_name(const char *name, uint namelen); -const char *ha_get_table_type(enum db_type db_type); +const char *ha_get_storage_engine(enum db_type db_type); handler *get_new_handler(TABLE *table, enum db_type db_type); my_off_t ha_get_ptr(byte *ptr, uint pack_length); void ha_store_ptr(byte *buff, uint pack_length, my_off_t pos); diff --git a/sql/lex.h b/sql/lex.h index a7c8735e193..6e69df6f96c 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -146,6 +146,7 @@ static SYMBOL symbols[] = { { "ENCLOSED", SYM(ENCLOSED),0,0}, { "END", SYM(END),0,0}, { "ENGINE", SYM(ENGINE_SYM),0,0}, + { "ENGINES", SYM(ENGINES_SYM),0,0}, { "ENUM", SYM(ENUM),0,0}, { "ERRORS", SYM(ERRORS),0,0}, { "ESCAPE", SYM(ESCAPE_SYM),0,0}, @@ -379,6 +380,7 @@ static SYMBOL symbols[] = { { "STARTING", SYM(STARTING),0,0}, { "STATUS", SYM(STATUS_SYM),0,0}, { "STOP", SYM(STOP_SYM),0,0}, + { "STORAGE", SYM(STORAGE_SYM),0,0}, { "STRAIGHT_JOIN", SYM(STRAIGHT_JOIN),0,0}, { "STRING", SYM(STRING_SYM),0,0}, { "STRIPED", SYM(RAID_STRIPED_SYM),0,0}, diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 7164a4e496d..7f003d0ce1f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -606,7 +606,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, pthread_mutex_t *mutex); int mysqld_show_charsets(THD *thd,const char *wild); int mysqld_show_collations(THD *thd,const char *wild); -int mysqld_show_table_types(THD *thd); +int mysqld_show_storage_engines(THD *thd); int mysqld_show_privileges(THD *thd); int mysqld_show_column_types(THD *thd); int mysqld_help (THD *thd, const char *text); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 49f0b753549..f90e653b44c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3547,7 +3547,7 @@ enum options_mysqld OPT_SKIP_HOST_CACHE, OPT_SHORT_LOG_FORMAT, OPT_FLUSH, OPT_SAFE, OPT_BOOTSTRAP, OPT_SKIP_SHOW_DB, - OPT_TABLE_TYPE, OPT_INIT_FILE, + OPT_STORAGE_ENGINE, OPT_INIT_FILE, OPT_DELAY_KEY_WRITE_ALL, OPT_SLOW_QUERY_LOG, OPT_DELAY_KEY_WRITE, OPT_CHARSETS_DIR, OPT_BDB_HOME, OPT_BDB_LOG, @@ -3756,8 +3756,11 @@ Disable with --skip-bdb (will save memory).", {"default-collation", OPT_DEFAULT_COLLATION, "Set the default collation.", (gptr*) &default_collation_name, (gptr*) &default_collation_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, - {"default-table-type", OPT_TABLE_TYPE, - "Set the default table type for tables.", 0, 0, + {"default-storage-engine", OPT_STORAGE_ENGINE, + "Set the default storage engine (table tyoe) for tables.", 0, 0, + 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"default-table-type", OPT_STORAGE_ENGINE, + "(deprecated) Use default-storage-engine.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"delay-key-write", OPT_DELAY_KEY_WRITE, "Type of DELAY_KEY_WRITE.", 0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -4734,8 +4737,8 @@ struct show_var_st status_vars[]= { {"Com_show_slave_hosts", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_HOSTS),SHOW_LONG}, {"Com_show_slave_status", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_STAT),SHOW_LONG}, {"Com_show_status", (char*) (com_stat+(uint) SQLCOM_SHOW_STATUS),SHOW_LONG}, + {"Com_show_storage_engines", (char*) (com_stat+(uint) SQLCOM_SHOW_STORAGE_ENGINES),SHOW_LONG}, {"Com_show_tables", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLES),SHOW_LONG}, - {"Com_show_table_types", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLE_TYPES),SHOW_LONG}, {"Com_show_variables", (char*) (com_stat+(uint) SQLCOM_SHOW_VARIABLES),SHOW_LONG}, {"Com_show_warnings", (char*) (com_stat+(uint) SQLCOM_SHOW_WARNS),SHOW_LONG}, {"Com_slave_start", (char*) (com_stat+(uint) SQLCOM_SLAVE_START),SHOW_LONG}, @@ -5422,7 +5425,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case OPT_BOOTSTRAP: opt_noacl=opt_bootstrap=1; break; - case OPT_TABLE_TYPE: + case OPT_STORAGE_ENGINE: { if ((enum db_type)((global_system_variables.table_type= ha_resolve_by_name(argument, strlen(argument)))) == DB_TYPE_UNKNOWN) diff --git a/sql/set_var.cc b/sql/set_var.cc index 66f8c3327a2..f9d5377b890 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -294,6 +294,8 @@ sys_var_thd_sql_mode sys_sql_mode("sql_mode", &SV::sql_mode); sys_var_thd_table_type sys_table_type("table_type", &SV::table_type); +sys_var_thd_storage_engine sys_storage_engine("storage_engine", + &SV::table_type); sys_var_long_ptr sys_table_cache_size("table_cache", &table_cache_size); sys_var_long_ptr sys_thread_cache_size("thread_cache_size", @@ -526,6 +528,7 @@ sys_var *sys_variables[]= &sys_sql_max_join_size, &sys_sql_mode, &sys_sql_warnings, + &sys_storage_engine, &sys_table_cache_size, &sys_table_type, &sys_thread_cache_size, @@ -731,6 +734,7 @@ struct show_var_st init_vars[]= { #endif {sys_sort_buffer.name, (char*) &sys_sort_buffer, SHOW_SYS}, {sys_sql_mode.name, (char*) &sys_sql_mode, SHOW_SYS}, + {sys_storage_engine.name, (char*) &sys_storage_engine, SHOW_SYS}, {"table_cache", (char*) &table_cache_size, SHOW_LONG}, {sys_table_type.name, (char*) &sys_table_type, SHOW_SYS}, {sys_thread_cache_size.name,(char*) &sys_thread_cache_size, SHOW_SYS}, @@ -2484,7 +2488,7 @@ int set_var_password::update(THD *thd) /* Based upon sys_var::check_enum() */ -bool sys_var_thd_table_type::check(THD *thd, set_var *var) +bool sys_var_thd_storage_engine::check(THD *thd, set_var *var) { char buff[80]; const char *value; @@ -2503,23 +2507,23 @@ bool sys_var_thd_table_type::check(THD *thd, set_var *var) } err: - my_error(ER_UNKNOWN_TABLE_ENGINE, MYF(0), value); + my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), value); return 1; } -byte *sys_var_thd_table_type::value_ptr(THD *thd, enum_var_type type, - LEX_STRING *base) +byte *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type, + LEX_STRING *base) { ulong val; val= ((type == OPT_GLOBAL) ? global_system_variables.*offset : thd->variables.*offset); - const char *table_type= ha_get_table_type((enum db_type)val); + const char *table_type= ha_get_storage_engine((enum db_type)val); return (byte *) table_type; } -void sys_var_thd_table_type::set_default(THD *thd, enum_var_type type) +void sys_var_thd_storage_engine::set_default(THD *thd, enum_var_type type) { if (type == OPT_GLOBAL) global_system_variables.*offset= (ulong) DB_TYPE_MYISAM; @@ -2528,7 +2532,7 @@ void sys_var_thd_table_type::set_default(THD *thd, enum_var_type type) } -bool sys_var_thd_table_type::update(THD *thd, set_var *var) +bool sys_var_thd_storage_engine::update(THD *thd, set_var *var) { if (var->type == OPT_GLOBAL) global_system_variables.*offset= var->save_result.ulong_value; @@ -2537,6 +2541,25 @@ bool sys_var_thd_table_type::update(THD *thd, set_var *var) return 0; } +void sys_var_thd_table_type::warn_deprecated(THD *thd) +{ + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WARN_DEPRECATED_SYNTAX, + ER(ER_WARN_DEPRECATED_SYNTAX), "table_type", "storage_engine"); +} + +void sys_var_thd_table_type::set_default(THD *thd, enum_var_type type) +{ + warn_deprecated(thd); + sys_var_thd_storage_engine::set_default(thd, type); +} + +bool sys_var_thd_table_type::update(THD *thd, set_var *var) +{ + warn_deprecated(thd); + return sys_var_thd_storage_engine::update(thd, var); +} + /**************************************************************************** Functions to handle sql_mode diff --git a/sql/set_var.h b/sql/set_var.h index fc7610ee500..85871c90ebb 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -344,12 +344,12 @@ public: }; -class sys_var_thd_table_type :public sys_var_thd +class sys_var_thd_storage_engine :public sys_var_thd { protected: ulong SV::*offset; public: - sys_var_thd_table_type(const char *name_arg, ulong SV::*offset_arg) + sys_var_thd_storage_engine(const char *name_arg, ulong SV::*offset_arg) :sys_var_thd(name_arg), offset(offset_arg) {} bool check(THD *thd, set_var *var); @@ -363,6 +363,16 @@ SHOW_TYPE type() { return SHOW_CHAR; } byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; +class sys_var_thd_table_type :public sys_var_thd_storage_engine +{ +public: + sys_var_thd_table_type(const char *name_arg, ulong SV::*offset_arg) + :sys_var_thd_storage_engine(name_arg, offset_arg) + {} + void warn_deprecated(THD *thd); + void set_default(THD *thd, enum_var_type type); + bool update(THD *thd, set_var *var); +}; class sys_var_thd_bit :public sys_var_thd { diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 15da6ca57a3..a3403ff5edf 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -73,7 +73,7 @@ enum enum_sql_command { SQLCOM_SHOW_SLAVE_HOSTS, SQLCOM_DELETE_MULTI, SQLCOM_UPDATE_MULTI, SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO, SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS, - SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_TABLE_TYPES, SQLCOM_SHOW_PRIVILEGES, + SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_STORAGE_ENGINES, SQLCOM_SHOW_PRIVILEGES, SQLCOM_HELP, SQLCOM_DROP_USER, SQLCOM_REVOKE_ALL, SQLCOM_CHECKSUM, /* This should be the last !!! */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 92a21b5982d..1d49c2fa21f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2831,8 +2831,8 @@ mysql_execute_command(THD *thd) #endif ,lex->verbose); break; - case SQLCOM_SHOW_TABLE_TYPES: - res= mysqld_show_table_types(thd); + case SQLCOM_SHOW_STORAGE_ENGINES: + res= mysqld_show_storage_engines(thd); break; case SQLCOM_SHOW_PRIVILEGES: res= mysqld_show_privileges(thd); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 781ee2e7082..c3996f142ad 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -173,11 +173,11 @@ int mysqld_show_tables(THD *thd,const char *db,const char *wild) ** List all table types supported ***************************************************************************/ -int mysqld_show_table_types(THD *thd) +int mysqld_show_storage_engines(THD *thd) { List<Item> field_list; Protocol *protocol= thd->protocol; - DBUG_ENTER("mysqld_show_table_types"); + DBUG_ENTER("mysqld_show_storage_engines"); field_list.push_back(new Item_empty_string("Type",10)); field_list.push_back(new Item_empty_string("Support",10)); @@ -187,7 +187,7 @@ int mysqld_show_table_types(THD *thd) DBUG_RETURN(1); const char *default_type_name= - ha_get_table_type((enum db_type)thd->variables.table_type); + ha_get_storage_engine((enum db_type)thd->variables.table_type); show_table_type_st *types; for (types= sys_table_types; types->type; types++) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 3a579986b6e..a7a3e325bd9 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -404,7 +404,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_USING_OTHER_HANDLER, ER(ER_WARN_USING_OTHER_HANDLER), - ha_get_table_type(new_db_type), + ha_get_storage_engine(new_db_type), table_name); } db_options=create_info->table_options; @@ -2016,7 +2016,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_USING_OTHER_HANDLER, ER(ER_WARN_USING_OTHER_HANDLER), - ha_get_table_type(new_db_type), + ha_get_storage_engine(new_db_type), new_name); } if (create_info->row_type == ROW_TYPE_NOT_USED) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 3e013d89992..6fb71730559 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -361,6 +361,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token SSL_SYM %token STARTING %token STATUS_SYM +%token STORAGE_SYM %token STRAIGHT_JOIN %token SUBJECT_SYM %token TABLES @@ -473,6 +474,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token ELT_FUNC %token ENCODE_SYM %token ENGINE_SYM +%token ENGINES_SYM %token ENCRYPT %token EXPORT_SET %token EXTRACT_SYM @@ -654,7 +656,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %type <date_time_type> date_time_type; %type <interval> interval -%type <db_type> table_types +%type <db_type> storage_engines %type <row_type> row_types @@ -1074,8 +1076,8 @@ create_table_options: | create_table_option ',' create_table_options; create_table_option: - ENGINE_SYM opt_equal table_types { Lex->create_info.db_type= $3; } - | TYPE_SYM opt_equal table_types { Lex->create_info.db_type= $3; WARN_DEPRECATED("TYPE=database_engine","ENGINE=database_engine"); } + ENGINE_SYM opt_equal storage_engines { Lex->create_info.db_type= $3; } + | TYPE_SYM opt_equal storage_engines { Lex->create_info.db_type= $3; WARN_DEPRECATED("TYPE=database_engine","ENGINE=database_engine"); } | MAX_ROWS opt_equal ulonglong_num { Lex->create_info.max_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;} | MIN_ROWS opt_equal ulonglong_num { Lex->create_info.min_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;} | AVG_ROW_LENGTH opt_equal ULONG_NUM { Lex->create_info.avg_row_length=$3; Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;} @@ -1128,12 +1130,12 @@ create_table_option: { Lex->create_info.data_file_name= $4.str; } | INDEX DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.index_file_name= $4.str; }; -table_types: +storage_engines: ident_or_text { $$ = ha_resolve_by_name($1.str,$1.length); if ($$ == DB_TYPE_UNKNOWN) { - net_printf(YYTHD, ER_UNKNOWN_TABLE_ENGINE, $1.str); + net_printf(YYTHD, ER_UNKNOWN_STORAGE_ENGINE, $1.str); YYABORT; } }; @@ -3971,7 +3973,7 @@ show_param: lex->select_lex.db= $3; lex->select_lex.options= 0; } - | ENGINE_SYM table_types + | ENGINE_SYM storage_engines { Lex->create_info.db_type= $2; } show_engine_param | opt_full COLUMNS from_or_in table_ident opt_db wild @@ -4021,7 +4023,13 @@ show_param: | TABLE_SYM TYPES_SYM { LEX *lex=Lex; - lex->sql_command= SQLCOM_SHOW_TABLE_TYPES; + lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES; + WARN_DEPRECATED("SHOW TABLE TYPES", "SHOW [STORAGE] ENGINES"); + } + | opt_storage ENGINES_SYM + { + LEX *lex=Lex; + lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES; } | PRIVILEGES { @@ -4112,6 +4120,10 @@ master_or_binary: MASTER_SYM | BINARY; +opt_storage: + /* empty */ + | STORAGE_SYM; + opt_db: /* empty */ { $$= 0; } | from_or_in ident { $$= $2.str; }; @@ -4664,6 +4676,7 @@ keyword: | END {} | ENUM {} | ENGINE_SYM {} + | ENGINES_SYM {} | ERRORS {} | ESCAPE_SYM {} | EVENTS_SYM {} @@ -4790,6 +4803,7 @@ keyword: | START_SYM {} | STATUS_SYM {} | STOP_SYM {} + | STORAGE_SYM {} | STRING_SYM {} | SUBDATE_SYM {} | SUBJECT_SYM {} @@ -4802,6 +4816,7 @@ keyword: | TIMESTAMP {} | TIME_SYM {} | TYPE_SYM {} + | TYPES_SYM {} | UDF_SYM {} | UNCOMMITTED_SYM {} | UNICODE_SYM {} |