Cleanup ha_checktype() and redundant variables.

parent 7f3771bc
...@@ -419,7 +419,7 @@ int init_embedded_server(int argc, char **argv, char **groups) ...@@ -419,7 +419,7 @@ int init_embedded_server(int argc, char **argv, char **groups)
if ( if (
#ifdef HAVE_BERKELEY_DB #ifdef HAVE_BERKELEY_DB
!berkeley_skip || (have_berkeley_db == SHOW_OPTION_YES) ||
#endif #endif
(flush_time && flush_time != ~(ulong) 0L)) (flush_time && flush_time != ~(ulong) 0L))
{ {
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
#define STATUS_BDB_ANALYZE 4 #define STATUS_BDB_ANALYZE 4
const char *ha_berkeley_ext=".db"; const char *ha_berkeley_ext=".db";
bool berkeley_skip=0,berkeley_shared_data=0; bool berkeley_shared_data=0;
u_int32_t berkeley_init_flags= DB_PRIVATE | DB_RECOVER, berkeley_env_flags=0, u_int32_t berkeley_init_flags= DB_PRIVATE | DB_RECOVER, berkeley_env_flags=0,
berkeley_lock_type=DB_LOCK_DEFAULT; berkeley_lock_type=DB_LOCK_DEFAULT;
ulong berkeley_cache_size, berkeley_log_buffer_size, berkeley_log_file_size=0; ulong berkeley_cache_size, berkeley_log_buffer_size, berkeley_log_file_size=0;
......
...@@ -170,7 +170,7 @@ class ha_berkeley: public handler ...@@ -170,7 +170,7 @@ class ha_berkeley: public handler
uint8 table_cache_type() { return HA_CACHE_TBL_TRANSACT; } uint8 table_cache_type() { return HA_CACHE_TBL_TRANSACT; }
}; };
extern bool berkeley_skip, berkeley_shared_data; extern bool berkeley_shared_data;
extern u_int32_t berkeley_init_flags,berkeley_env_flags, berkeley_lock_type, extern u_int32_t berkeley_init_flags,berkeley_env_flags, berkeley_lock_type,
berkeley_lock_types[]; berkeley_lock_types[];
extern ulong berkeley_cache_size, berkeley_max_lock, berkeley_log_buffer_size; extern ulong berkeley_cache_size, berkeley_max_lock, berkeley_log_buffer_size;
......
...@@ -80,7 +80,6 @@ extern "C" { ...@@ -80,7 +80,6 @@ extern "C" {
#define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */ #define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */
#define HA_INNOBASE_RANGE_COUNT 100 #define HA_INNOBASE_RANGE_COUNT 100
bool innodb_skip = 0;
uint innobase_init_flags = 0; uint innobase_init_flags = 0;
ulong innobase_cache_size = 0; ulong innobase_cache_size = 0;
...@@ -4758,7 +4757,7 @@ innodb_show_status( ...@@ -4758,7 +4757,7 @@ innodb_show_status(
DBUG_ENTER("innodb_show_status"); DBUG_ENTER("innodb_show_status");
if (innodb_skip) { if (have_innodb != SHOW_OPTION_YES) {
my_message(ER_NOT_SUPPORTED_YET, my_message(ER_NOT_SUPPORTED_YET,
"Cannot call SHOW INNODB STATUS because skip-innodb is defined", "Cannot call SHOW INNODB STATUS because skip-innodb is defined",
MYF(0)); MYF(0));
......
...@@ -190,7 +190,6 @@ class ha_innobase: public handler ...@@ -190,7 +190,6 @@ class ha_innobase: public handler
uint8 table_cache_type() { return HA_CACHE_TBL_ASKTRANSACT; } uint8 table_cache_type() { return HA_CACHE_TBL_ASKTRANSACT; }
}; };
extern bool innodb_skip;
extern uint innobase_init_flags, innobase_lock_type; extern uint innobase_init_flags, innobase_lock_type;
extern uint innobase_flush_log_at_trx_commit; extern uint innobase_flush_log_at_trx_commit;
extern ulong innobase_cache_size; extern ulong innobase_cache_size;
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
** isam tables ** isam tables
*****************************************************************************/ *****************************************************************************/
bool isam_skip;
const char **ha_isam::bas_ext() const const char **ha_isam::bas_ext() const
{ static const char *ext[]= { ".ISM",".ISD", NullS }; return ext; } { static const char *ext[]= { ".ISM",".ISD", NullS }; return ext; }
......
...@@ -82,4 +82,3 @@ class ha_isam: public handler ...@@ -82,4 +82,3 @@ class ha_isam: public handler
enum thr_lock_type lock_type); enum thr_lock_type lock_type);
}; };
extern bool isam_skip;
...@@ -120,34 +120,21 @@ const char *ha_get_storage_engine(enum db_type db_type) ...@@ -120,34 +120,21 @@ const char *ha_get_storage_engine(enum db_type db_type)
enum db_type ha_checktype(enum db_type database_type) enum db_type ha_checktype(enum db_type database_type)
{ {
show_table_type_st *types;
for (types= sys_table_types; types->type; types++)
{
if ((database_type == types->db_type) &&
(SHOW_OPTION_YES == *types->value))
return database_type;
}
switch (database_type) { switch (database_type) {
#ifdef HAVE_BERKELEY_DB
case DB_TYPE_BERKELEY_DB:
if (berkeley_skip) break;
return (database_type);
#endif
#ifdef HAVE_INNOBASE_DB
case DB_TYPE_INNODB:
if (innodb_skip) break;
return (database_type);
#endif
#ifndef NO_HASH #ifndef NO_HASH
case DB_TYPE_HASH: case DB_TYPE_HASH:
#endif
#ifdef HAVE_ISAM
case DB_TYPE_ISAM:
if (isam_skip) break;
return (database_type); return (database_type);
case DB_TYPE_MRG_ISAM: #endif
return (isam_skip ? DB_TYPE_MRG_MYISAM : database_type);
#else
case DB_TYPE_MRG_ISAM: case DB_TYPE_MRG_ISAM:
return (DB_TYPE_MRG_MYISAM); return (DB_TYPE_MRG_MYISAM);
#endif
case DB_TYPE_HEAP:
case DB_TYPE_MYISAM:
case DB_TYPE_MRG_MYISAM:
return (database_type); /* Database exists on system */
default: default:
break; break;
} }
...@@ -165,6 +152,7 @@ handler *get_new_handler(TABLE *table, enum db_type db_type) ...@@ -165,6 +152,7 @@ handler *get_new_handler(TABLE *table, enum db_type db_type)
{ {
switch (db_type) { switch (db_type) {
#ifndef NO_HASH #ifndef NO_HASH
case DB_TYPE_HASH:
return new ha_hash(table); return new ha_hash(table);
#endif #endif
#ifdef HAVE_ISAM #ifdef HAVE_ISAM
...@@ -203,30 +191,32 @@ handler *get_new_handler(TABLE *table, enum db_type db_type) ...@@ -203,30 +191,32 @@ handler *get_new_handler(TABLE *table, enum db_type db_type)
int ha_init() int ha_init()
{ {
int error= 0;
#ifdef HAVE_BERKELEY_DB #ifdef HAVE_BERKELEY_DB
if (!berkeley_skip) if (have_berkeley_db == SHOW_OPTION_YES)
{ {
int error; if (berkeley_init())
if ((error=berkeley_init())) {
return error; have_berkeley_db= SHOW_OPTION_DISABLED; // If we couldn't use handler
if (!berkeley_skip) // If we couldn't use handler error= 1;
opt_using_transactions=1; }
else else
have_berkeley_db=SHOW_OPTION_DISABLED; opt_using_transactions=1;
} }
#endif #endif
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
if (!innodb_skip) if (have_innodb == SHOW_OPTION_YES)
{ {
if (innobase_init()) if (innobase_init())
return -1; {
if (!innodb_skip) // If we couldn't use handler have_innodb= SHOW_OPTION_DISABLED; // If we couldn't use handler
opt_using_transactions=1; error= 1;
}
else else
have_innodb=SHOW_OPTION_DISABLED; opt_using_transactions=1;
} }
#endif #endif
return 0; return error;
} }
/* close, flush or restart databases */ /* close, flush or restart databases */
...@@ -246,11 +236,11 @@ int ha_panic(enum ha_panic_function flag) ...@@ -246,11 +236,11 @@ int ha_panic(enum ha_panic_function flag)
error|=mi_panic(flag); error|=mi_panic(flag);
error|=myrg_panic(flag); error|=myrg_panic(flag);
#ifdef HAVE_BERKELEY_DB #ifdef HAVE_BERKELEY_DB
if (!berkeley_skip) if (have_berkeley_db == SHOW_OPTION_YES)
error|=berkeley_end(); error|=berkeley_end();
#endif #endif
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
if (!innodb_skip) if (have_innodb == SHOW_OPTION_YES)
error|=innobase_end(); error|=innobase_end();
#endif #endif
return error; return error;
...@@ -259,7 +249,7 @@ int ha_panic(enum ha_panic_function flag) ...@@ -259,7 +249,7 @@ int ha_panic(enum ha_panic_function flag)
void ha_drop_database(char* path) void ha_drop_database(char* path)
{ {
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
if (!innodb_skip) if (have_innodb == SHOW_OPTION_YES)
innobase_drop_database(path); innobase_drop_database(path);
#endif #endif
} }
...@@ -267,7 +257,7 @@ void ha_drop_database(char* path) ...@@ -267,7 +257,7 @@ void ha_drop_database(char* path)
void ha_close_connection(THD* thd) void ha_close_connection(THD* thd)
{ {
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
if (!innodb_skip) if (have_innodb == SHOW_OPTION_YES)
innobase_close_connection(thd); innobase_close_connection(thd);
#endif #endif
} }
...@@ -632,11 +622,13 @@ bool ha_flush_logs() ...@@ -632,11 +622,13 @@ bool ha_flush_logs()
{ {
bool result=0; bool result=0;
#ifdef HAVE_BERKELEY_DB #ifdef HAVE_BERKELEY_DB
if (!berkeley_skip && berkeley_flush_logs()) if ((have_berkeley_db == SHOW_OPTION_YES) &&
berkeley_flush_logs())
result=1; result=1;
#endif #endif
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
if (!innodb_skip && innobase_flush_logs()) if ((have_innodb == SHOW_OPTION_YES) &&
innobase_flush_logs())
result=1; result=1;
#endif #endif
return result; return result;
......
...@@ -2362,7 +2362,7 @@ static void create_maintenance_thread() ...@@ -2362,7 +2362,7 @@ static void create_maintenance_thread()
{ {
if ( if (
#ifdef HAVE_BERKELEY_DB #ifdef HAVE_BERKELEY_DB
!berkeley_skip || (have_berkeley_db == SHOW_OPTION_YES) ||
#endif #endif
(flush_time && flush_time != ~(ulong) 0L)) (flush_time && flush_time != ~(ulong) 0L))
{ {
...@@ -5532,43 +5532,25 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -5532,43 +5532,25 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_BDB: case OPT_BDB:
#ifdef HAVE_BERKELEY_DB #ifdef HAVE_BERKELEY_DB
if (opt_bdb) if (opt_bdb)
{
berkeley_skip=0;
have_berkeley_db=SHOW_OPTION_YES; have_berkeley_db=SHOW_OPTION_YES;
}
else else
{
berkeley_skip=1;
have_berkeley_db=SHOW_OPTION_DISABLED; have_berkeley_db=SHOW_OPTION_DISABLED;
}
#endif #endif
break; break;
case OPT_ISAM: case OPT_ISAM:
#ifdef HAVE_ISAM #ifdef HAVE_ISAM
if (opt_isam) if (opt_isam)
{
isam_skip=0;
have_isam= SHOW_OPTION_YES; have_isam= SHOW_OPTION_YES;
}
else else
{
isam_skip=1;
have_isam= SHOW_OPTION_DISABLED; have_isam= SHOW_OPTION_DISABLED;
}
#endif #endif
break; break;
case OPT_INNODB: case OPT_INNODB:
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
if (opt_innodb) if (opt_innodb)
{
innodb_skip=0;
have_innodb=SHOW_OPTION_YES; have_innodb=SHOW_OPTION_YES;
}
else else
{
innodb_skip=1;
have_innodb=SHOW_OPTION_DISABLED; have_innodb=SHOW_OPTION_DISABLED;
}
#endif #endif
break; break;
case OPT_INNODB_DATA_FILE_PATH: case OPT_INNODB_DATA_FILE_PATH:
......
...@@ -921,7 +921,7 @@ mysqld_show_logs(THD *thd) ...@@ -921,7 +921,7 @@ mysqld_show_logs(THD *thd)
DBUG_RETURN(1); DBUG_RETURN(1);
#ifdef HAVE_BERKELEY_DB #ifdef HAVE_BERKELEY_DB
if (!berkeley_skip && berkeley_show_logs(protocol)) if ((have_berkeley_db == SHOW_OPTION_YES) && berkeley_show_logs(protocol))
DBUG_RETURN(-1); DBUG_RETURN(-1);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment