Cleanup ha_checktype() and redundant variables.

parent 7f3771bc
......@@ -419,7 +419,7 @@ int init_embedded_server(int argc, char **argv, char **groups)
if (
#ifdef HAVE_BERKELEY_DB
!berkeley_skip ||
(have_berkeley_db == SHOW_OPTION_YES) ||
#endif
(flush_time && flush_time != ~(ulong) 0L))
{
......
......@@ -72,7 +72,7 @@
#define STATUS_BDB_ANALYZE 4
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,
berkeley_lock_type=DB_LOCK_DEFAULT;
ulong berkeley_cache_size, berkeley_log_buffer_size, berkeley_log_file_size=0;
......
......@@ -170,7 +170,7 @@ class ha_berkeley: public handler
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,
berkeley_lock_types[];
extern ulong berkeley_cache_size, berkeley_max_lock, berkeley_log_buffer_size;
......
......@@ -80,7 +80,6 @@ extern "C" {
#define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */
#define HA_INNOBASE_RANGE_COUNT 100
bool innodb_skip = 0;
uint innobase_init_flags = 0;
ulong innobase_cache_size = 0;
......@@ -4758,7 +4757,7 @@ innodb_show_status(
DBUG_ENTER("innodb_show_status");
if (innodb_skip) {
if (have_innodb != SHOW_OPTION_YES) {
my_message(ER_NOT_SUPPORTED_YET,
"Cannot call SHOW INNODB STATUS because skip-innodb is defined",
MYF(0));
......
......@@ -190,7 +190,6 @@ class ha_innobase: public handler
uint8 table_cache_type() { return HA_CACHE_TBL_ASKTRANSACT; }
};
extern bool innodb_skip;
extern uint innobase_init_flags, innobase_lock_type;
extern uint innobase_flush_log_at_trx_commit;
extern ulong innobase_cache_size;
......
......@@ -34,7 +34,6 @@
** isam tables
*****************************************************************************/
bool isam_skip;
const char **ha_isam::bas_ext() const
{ static const char *ext[]= { ".ISM",".ISD", NullS }; return ext; }
......
......@@ -82,4 +82,3 @@ class ha_isam: public handler
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)
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) {
#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
case DB_TYPE_HASH:
#endif
#ifdef HAVE_ISAM
case DB_TYPE_ISAM:
if (isam_skip) break;
return (database_type);
case DB_TYPE_MRG_ISAM:
return (isam_skip ? DB_TYPE_MRG_MYISAM : database_type);
#else
#endif
case DB_TYPE_MRG_ISAM:
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:
break;
}
......@@ -165,7 +152,8 @@ handler *get_new_handler(TABLE *table, enum db_type db_type)
{
switch (db_type) {
#ifndef NO_HASH
return new ha_hash(table);
case DB_TYPE_HASH:
return new ha_hash(table);
#endif
#ifdef HAVE_ISAM
case DB_TYPE_MRG_ISAM:
......@@ -203,30 +191,32 @@ handler *get_new_handler(TABLE *table, enum db_type db_type)
int ha_init()
{
int error= 0;
#ifdef HAVE_BERKELEY_DB
if (!berkeley_skip)
if (have_berkeley_db == SHOW_OPTION_YES)
{
int error;
if ((error=berkeley_init()))
return error;
if (!berkeley_skip) // If we couldn't use handler
opt_using_transactions=1;
if (berkeley_init())
{
have_berkeley_db= SHOW_OPTION_DISABLED; // If we couldn't use handler
error= 1;
}
else
have_berkeley_db=SHOW_OPTION_DISABLED;
opt_using_transactions=1;
}
#endif
#ifdef HAVE_INNOBASE_DB
if (!innodb_skip)
if (have_innodb == SHOW_OPTION_YES)
{
if (innobase_init())
return -1;
if (!innodb_skip) // If we couldn't use handler
opt_using_transactions=1;
{
have_innodb= SHOW_OPTION_DISABLED; // If we couldn't use handler
error= 1;
}
else
have_innodb=SHOW_OPTION_DISABLED;
opt_using_transactions=1;
}
#endif
return 0;
return error;
}
/* close, flush or restart databases */
......@@ -246,11 +236,11 @@ int ha_panic(enum ha_panic_function flag)
error|=mi_panic(flag);
error|=myrg_panic(flag);
#ifdef HAVE_BERKELEY_DB
if (!berkeley_skip)
if (have_berkeley_db == SHOW_OPTION_YES)
error|=berkeley_end();
#endif
#ifdef HAVE_INNOBASE_DB
if (!innodb_skip)
if (have_innodb == SHOW_OPTION_YES)
error|=innobase_end();
#endif
return error;
......@@ -259,7 +249,7 @@ int ha_panic(enum ha_panic_function flag)
void ha_drop_database(char* path)
{
#ifdef HAVE_INNOBASE_DB
if (!innodb_skip)
if (have_innodb == SHOW_OPTION_YES)
innobase_drop_database(path);
#endif
}
......@@ -267,7 +257,7 @@ void ha_drop_database(char* path)
void ha_close_connection(THD* thd)
{
#ifdef HAVE_INNOBASE_DB
if (!innodb_skip)
if (have_innodb == SHOW_OPTION_YES)
innobase_close_connection(thd);
#endif
}
......@@ -632,11 +622,13 @@ bool ha_flush_logs()
{
bool result=0;
#ifdef HAVE_BERKELEY_DB
if (!berkeley_skip && berkeley_flush_logs())
if ((have_berkeley_db == SHOW_OPTION_YES) &&
berkeley_flush_logs())
result=1;
#endif
#ifdef HAVE_INNOBASE_DB
if (!innodb_skip && innobase_flush_logs())
if ((have_innodb == SHOW_OPTION_YES) &&
innobase_flush_logs())
result=1;
#endif
return result;
......
......@@ -2362,7 +2362,7 @@ static void create_maintenance_thread()
{
if (
#ifdef HAVE_BERKELEY_DB
!berkeley_skip ||
(have_berkeley_db == SHOW_OPTION_YES) ||
#endif
(flush_time && flush_time != ~(ulong) 0L))
{
......@@ -5532,43 +5532,25 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_BDB:
#ifdef HAVE_BERKELEY_DB
if (opt_bdb)
{
berkeley_skip=0;
have_berkeley_db=SHOW_OPTION_YES;
}
else
{
berkeley_skip=1;
have_berkeley_db=SHOW_OPTION_DISABLED;
}
#endif
break;
case OPT_ISAM:
#ifdef HAVE_ISAM
if (opt_isam)
{
isam_skip=0;
have_isam= SHOW_OPTION_YES;
}
else
{
isam_skip=1;
have_isam= SHOW_OPTION_DISABLED;
}
#endif
break;
case OPT_INNODB:
#ifdef HAVE_INNOBASE_DB
if (opt_innodb)
{
innodb_skip=0;
have_innodb=SHOW_OPTION_YES;
}
else
{
innodb_skip=1;
have_innodb=SHOW_OPTION_DISABLED;
}
#endif
break;
case OPT_INNODB_DATA_FILE_PATH:
......
......@@ -921,7 +921,7 @@ mysqld_show_logs(THD *thd)
DBUG_RETURN(1);
#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);
#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