From e687d6beae78b980d984fdbfb518c494295d5200 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Apr 2005 18:25:31 -0700 Subject: [PATCH] Check that the default storage engine is really available, and refuse to start up if it is not. (Bug #9815) sql/handler.cc: Add ha_storage_engine_is_enabled function. sql/handler.h: Declare ha_storage_engine_is_enabled() sql/mysqld.cc: Abort startup if the specified default storage engine is not available. --- sql/handler.cc | 14 ++++++++++++++ sql/handler.h | 1 + sql/mysqld.cc | 12 ++++++++++++ 3 files changed, 27 insertions(+) diff --git a/sql/handler.cc b/sql/handler.cc index b12032ccd81..7d8fc5d8110 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -145,6 +145,20 @@ const char *ha_get_storage_engine(enum db_type db_type) return "none"; } + +my_bool ha_storage_engine_is_enabled(enum db_type database_type) +{ + show_table_type_st *types; + for (types= sys_table_types; types->type; types++) + { + if ((database_type == types->db_type) && + (*types->value == SHOW_OPTION_YES)) + return TRUE; + } + return FALSE; +} + + /* Use other database handler if databasehandler is not incompiled */ enum db_type ha_checktype(enum db_type database_type) diff --git a/sql/handler.h b/sql/handler.h index 4c31da6a492..d2f77c4149a 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -542,6 +542,7 @@ int ha_init(void); int ha_panic(enum ha_panic_function flag); void ha_close_connection(THD* thd); enum db_type ha_checktype(enum db_type database_type); +my_bool ha_storage_engine_is_enabled(enum db_type database_type); int ha_create_table(const char *name, HA_CREATE_INFO *create_info, bool update_create_info); int ha_create_table_from_engine(THD* thd, const char *db, const char *name, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b568b75fbad..41e3069a6c0 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6435,6 +6435,18 @@ static void get_options(int argc,char **argv) sql_print_warning("this binary does not contain BDB storage engine"); #endif + /* + Check that the default storage engine is actually available. + */ + if (!ha_storage_engine_is_enabled((enum db_type) + global_system_variables.table_type)) + { + sql_print_error("Default storage engine (%s) is not available", + ha_get_storage_engine((enum db_type) + global_system_variables.table_type)); + exit(1); + } + if (argc > 0) { fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a list of available options\n", my_progname, *argv);