Commit 11be8401 authored by brian@zim.(none)'s avatar brian@zim.(none)

Merge baker@bk-internal.mysql.com:/home/bk/mysql-5.0

into  zim.(none):/home/brian/mysql/fix-5.0
parents fe26e59d 2a42afd1
......@@ -323,17 +323,17 @@ execute stmt4;
Engine Support Comment
MyISAM YES/NO Default engine as of MySQL 3.23 with great performance
MEMORY YES/NO Hash based, stored in memory, useful for temporary tables
MRG_MYISAM YES/NO Collection of identical MyISAM tables
ISAM YES/NO Obsolete storage engine, now replaced by MyISAM
MRG_ISAM YES/NO Obsolete storage engine, now replaced by MERGE
InnoDB YES/NO Supports transactions, row-level locking, and foreign keys
BERKELEYDB YES/NO Supports transactions and page-level locking
NDBCLUSTER YES/NO Clustered, fault-tolerant, memory-based tables
BerkeleyDB YES/NO Supports transactions and page-level locking
BLACKHOLE YES/NO /dev/null storage engine (anything you write to it disappears)
EXAMPLE YES/NO Example storage engine
ARCHIVE YES/NO Archive storage engine
CSV YES/NO CSV storage engine
ndbcluster YES/NO Clustered, fault-tolerant, memory-based tables
FEDERATED YES/NO Federated MySQL storage engine
BLACKHOLE YES/NO /dev/null storage engine (anything you write to it disappears)
MRG_MYISAM YES/NO Collection of identical MyISAM tables
binlog YES/NO This is a meta storage engine to represent the binlog in a transaction
ISAM YES/NO Obsolete storage engine
drop table if exists t5;
prepare stmt1 from ' drop table if exists t5 ' ;
execute stmt1 ;
......
......@@ -74,7 +74,11 @@
handlerton example_hton= {
"CSV",
"EXAMPLE",
SHOW_OPTION_YES,
"Example storage engine",
DB_TYPE_EXAMPLE_DB,
NULL, /* We do need to write one! */
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
......
......@@ -56,6 +56,10 @@ static int tina_init= 0;
handlerton tina_hton= {
"CSV",
SHOW_OPTION_YES,
"CSV storage engine",
DB_TYPE_CSV_DB,
NULL, /* One needs to be written! */
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
......@@ -857,21 +861,6 @@ THR_LOCK_DATA **ha_tina::store_lock(THD *thd,
return to;
}
/*
Range optimizer calls this.
I need to update the information on this.
*/
ha_rows ha_tina::records_in_range(int inx,
const byte *start_key,uint start_key_len,
enum ha_rkey_function start_search_flag,
const byte *end_key,uint end_key_len,
enum ha_rkey_function end_search_flag)
{
DBUG_ENTER("ha_tina::records_in_range ");
DBUG_RETURN(records); // Good guess
}
/*
Create a table. You do not want to leave the table open after a call to
this (the database will call ::open() if it needs to).
......
......@@ -78,7 +78,6 @@ class ha_tina: public handler
*/
virtual double scan_time() { return (double) (records+deleted) / 20.0+10; }
/* The next method will never be called */
virtual double read_time(ha_rows rows) { DBUG_ASSERT(0); return((double) rows / 20.0+1); }
virtual bool fast_key_read() { return 1;}
/*
TODO: return actual upper bound of number of records in the table.
......@@ -110,12 +109,6 @@ class ha_tina: public handler
int reset(void);
int external_lock(THD *thd, int lock_type);
int delete_all_rows(void);
ha_rows records_in_range(int inx, const byte *start_key,uint start_key_len,
enum ha_rkey_function start_search_flag,
const byte *end_key,uint end_key_len,
enum ha_rkey_function end_search_flag);
// int delete_table(const char *from);
// int rename_table(const char * from, const char * to);
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
......
......@@ -116,7 +116,7 @@
*/
/* If the archive storage engine has been inited */
static bool archive_inited= 0;
static bool archive_inited= FALSE;
/* Variables for archive share methods */
pthread_mutex_t archive_mutex;
static HASH archive_open_tables;
......@@ -137,7 +137,11 @@ static HASH archive_open_tables;
/* dummy handlerton - only to have something to return from archive_db_init */
handlerton archive_hton = {
"archive",
"ARCHIVE",
SHOW_OPTION_YES,
"Archive storage engine",
DB_TYPE_ARCHIVE_DB,
archive_db_init,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
......@@ -176,18 +180,28 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length,
void
RETURN
&archive_hton OK
0 Error
FALSE OK
TRUE Error
*/
handlerton *archive_db_init()
bool archive_db_init()
{
archive_inited= 1;
VOID(pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST));
DBUG_ENTER("archive_db_init");
if (pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST))
goto error;
if (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0,
(hash_get_key) archive_get_key, 0, 0))
return 0;
return &archive_hton;
{
VOID(pthread_mutex_destroy(&archive_mutex));
}
else
{
archive_inited= TRUE;
DBUG_RETURN(FALSE);
}
error:
have_archive_db= SHOW_OPTION_DISABLED; // If we couldn't use handler
DBUG_RETURN(TRUE);
}
/*
......
......@@ -105,6 +105,6 @@ class ha_archive: public handler
enum thr_lock_type lock_type);
};
handlerton *archive_db_init(void);
bool archive_db_init(void);
bool archive_db_end(void);
......@@ -109,6 +109,10 @@ static int berkeley_rollback(THD *thd, bool all);
handlerton berkeley_hton = {
"BerkeleyDB",
SHOW_OPTION_YES,
"Supports transactions and page-level locking",
DB_TYPE_BERKELEY_DB,
berkeley_init,
0, /* slot */
0, /* savepoint size */
berkeley_close_connection,
......@@ -135,10 +139,13 @@ typedef struct st_berkeley_trx_data {
/* General functions */
handlerton *berkeley_init(void)
bool berkeley_init(void)
{
DBUG_ENTER("berkeley_init");
if (have_berkeley_db != SHOW_OPTION_YES)
goto error;
if (!berkeley_tmpdir)
berkeley_tmpdir=mysql_tmpdir;
if (!berkeley_home)
......@@ -164,7 +171,7 @@ handlerton *berkeley_init(void)
berkeley_log_file_size= max(berkeley_log_file_size, 10*1024*1024L);
if (db_env_create(&db_env,0))
DBUG_RETURN(0);
goto error;
db_env->set_errcall(db_env,berkeley_print_error);
db_env->set_errpfx(db_env,"bdb");
db_env->set_noticecall(db_env, berkeley_noticecall);
......@@ -194,13 +201,16 @@ handlerton *berkeley_init(void)
{
db_env->close(db_env,0);
db_env=0;
DBUG_RETURN(0);
goto error;
}
(void) hash_init(&bdb_open_tables,system_charset_info,32,0,0,
(hash_get_key) bdb_get_key,0,0);
pthread_mutex_init(&bdb_mutex,MY_MUTEX_INIT_FAST);
DBUG_RETURN(&berkeley_hton);
DBUG_RETURN(FALSE);
error:
have_berkeley_db= SHOW_OPTION_DISABLED; // If we couldn't use handler
DBUG_RETURN(TRUE);
}
......
......@@ -161,7 +161,7 @@ extern char *berkeley_home, *berkeley_tmpdir, *berkeley_logdir;
extern long berkeley_lock_scan_time;
extern TYPELIB berkeley_lock_typelib;
handlerton *berkeley_init(void);
bool berkeley_init(void);
bool berkeley_end(void);
bool berkeley_flush_logs(void);
int berkeley_show_logs(Protocol *protocol);
......@@ -28,6 +28,10 @@
handlerton blackhole_hton= {
"BLACKHOLE",
SHOW_OPTION_YES,
"/dev/null storage engine (anything you write to it disappears)",
DB_TYPE_BLACKHOLE_DB,
NULL,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
......
......@@ -363,6 +363,33 @@ pthread_mutex_t federated_mutex; // This is the mutex we use to
static int federated_init= FALSE; // Variable for checking the
// init state of hash
/* Federated storage engine handlerton */
handlerton federated_hton= {
"FEDERATED",
SHOW_OPTION_YES,
"Federated MySQL storage engine",
DB_TYPE_FEDERATED_DB,
federated_db_init,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
NULL, /* savepoint */
NULL, /* rollback to savepoint */
NULL, /* release savepoint */
NULL, /* commit */
NULL, /* rollback */
NULL, /* prepare */
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
HTON_ALTER_NOT_SUPPORTED
};
/* Function we use in the creation of our hash to get key. */
static byte *federated_get_key(FEDERATED_SHARE *share, uint *length,
......@@ -386,10 +413,22 @@ static byte *federated_get_key(FEDERATED_SHARE *share, uint *length,
bool federated_db_init()
{
federated_init= 1;
VOID(pthread_mutex_init(&federated_mutex, MY_MUTEX_INIT_FAST));
return (hash_init(&federated_open_tables, system_charset_info, 32, 0, 0,
(hash_get_key) federated_get_key, 0, 0));
DBUG_ENTER("federated_db_init");
if (pthread_mutex_init(&federated_mutex, MY_MUTEX_INIT_FAST))
goto error;
if (hash_init(&federated_open_tables, system_charset_info, 32, 0, 0,
(hash_get_key) federated_get_key, 0, 0))
{
VOID(pthread_mutex_destroy(&federated_mutex));
}
else
{
federated_init= TRUE;
DBUG_RETURN(FALSE);
}
error:
have_federated_db= SHOW_OPTION_DISABLED; // If we couldn't use handler
DBUG_RETURN(TRUE);
}
......@@ -694,29 +733,6 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
}
/* Federated storage engine handlerton */
handlerton federated_hton= {
"FEDERATED",
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
NULL, /* savepoint */
NULL, /* rollback to savepoint */
NULL, /* release savepoint */
NULL, /* commit */
NULL, /* rollback */
NULL, /* prepare */
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
HTON_ALTER_NOT_SUPPORTED
};
/*****************************************************************************
** FEDERATED tables
*****************************************************************************/
......
......@@ -25,6 +25,10 @@
handlerton heap_hton= {
"MEMORY",
SHOW_OPTION_YES,
"Hash based, stored in memory, useful for temporary tables",
DB_TYPE_HEAP,
NULL,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
......
......@@ -208,6 +208,10 @@ static int innobase_release_savepoint(THD* thd, void *savepoint);
handlerton innobase_hton = {
"InnoDB",
SHOW_OPTION_YES,
"Supports transactions, row-level locking, and foreign keys",
DB_TYPE_INNODB,
innobase_init,
0, /* slot */
sizeof(trx_named_savept_t), /* savepoint size. TODO: use it */
innobase_close_connection,
......@@ -1188,7 +1192,7 @@ ha_innobase::init_table_handle_for_HANDLER(void)
/*************************************************************************
Opens an InnoDB database. */
handlerton*
bool
innobase_init(void)
/*===============*/
/* out: &innobase_hton, or NULL on error */
......@@ -1200,6 +1204,9 @@ innobase_init(void)
DBUG_ENTER("innobase_init");
if (have_innodb != SHOW_OPTION_YES)
goto error;
ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
os_innodb_umask = (ulint)my_umask;
......@@ -1267,7 +1274,7 @@ innobase_init(void)
"InnoDB: syntax error in innodb_data_file_path");
my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
DBUG_RETURN(0);
goto error;
}
/* -------------- Log files ---------------------------*/
......@@ -1298,7 +1305,7 @@ innobase_init(void)
my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
DBUG_RETURN(0);
goto error;
}
/* --------------------------------------------------*/
......@@ -1386,7 +1393,7 @@ innobase_init(void)
if (err != DB_SUCCESS) {
my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
DBUG_RETURN(0);
goto error;
}
(void) hash_init(&innobase_open_tables,system_charset_info, 32, 0, 0,
......@@ -1413,7 +1420,10 @@ innobase_init(void)
glob_mi.pos = trx_sys_mysql_master_log_pos;
}
*/
DBUG_RETURN(&innobase_hton);
DBUG_RETURN(FALSE);
error:
have_innodb= SHOW_OPTION_DISABLED; // If we couldn't use handler
DBUG_RETURN(TRUE);
}
/***********************************************************************
......
......@@ -241,7 +241,7 @@ extern ulong srv_commit_concurrency;
extern TYPELIB innobase_lock_typelib;
handlerton *innobase_init(void);
bool innobase_init(void);
bool innobase_end(void);
bool innobase_flush_logs(void);
uint innobase_get_free_space(void);
......
......@@ -54,6 +54,10 @@ TYPELIB myisam_stats_method_typelib= {
handlerton myisam_hton= {
"MyISAM",
SHOW_OPTION_YES,
"Default engine as of MySQL 3.23 with great performance",
DB_TYPE_MYISAM,
NULL,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
......
......@@ -36,6 +36,10 @@
handlerton myisammrg_hton= {
"MRG_MYISAM",
SHOW_OPTION_YES,
"Collection of identical MyISAM tables",
DB_TYPE_MRG_MYISAM,
NULL,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
......
......@@ -51,6 +51,10 @@ static int ndbcluster_rollback(THD *thd, bool all);
handlerton ndbcluster_hton = {
"ndbcluster",
SHOW_OPTION_YES,
"Clustered, fault-tolerant, memory-based tables",
DB_TYPE_NDBCLUSTER,
ndbcluster_init,
0, /* slot */
0, /* savepoint size */
ndbcluster_close_connection,
......@@ -4735,11 +4739,14 @@ static int connect_callback()
return 0;
}
handlerton *
ndbcluster_init()
bool ndbcluster_init()
{
int res;
DBUG_ENTER("ndbcluster_init");
if (have_ndbcluster != SHOW_OPTION_YES)
goto ndbcluster_init_error;
// Set connectstring if specified
if (opt_ndbcluster_connectstring != 0)
DBUG_PRINT("connectstring", ("%s", opt_ndbcluster_connectstring));
......@@ -4820,16 +4827,17 @@ ndbcluster_init()
}
ndbcluster_inited= 1;
DBUG_RETURN(&ndbcluster_hton);
DBUG_RETURN(FALSE);
ndbcluster_init_error:
ndbcluster_init_error:
if (g_ndb)
delete g_ndb;
g_ndb= NULL;
if (g_ndb_cluster_connection)
delete g_ndb_cluster_connection;
g_ndb_cluster_connection= NULL;
DBUG_RETURN(NULL);
have_ndbcluster= SHOW_OPTION_DISABLED; // If we couldn't use handler
DBUG_RETURN(TRUE);
}
......
......@@ -716,7 +716,7 @@ static void set_tabname(const char *pathname, char *tabname);
extern struct show_var_st ndb_status_variables[];
handlerton *ndbcluster_init(void);
bool ndbcluster_init(void);
bool ndbcluster_end(void);
int ndbcluster_discover(THD* thd, const char* dbname, const char* name,
......
......@@ -25,37 +25,87 @@
#include "ha_heap.h"
#include "ha_myisam.h"
#include "ha_myisammrg.h"
/*
We have dummy hanldertons in case the handler has not been compiled
in. This will be removed in 5.1.
*/
#ifdef HAVE_BERKELEY_DB
#include "ha_berkeley.h"
extern handlerton berkeley_hton;
#else
handlerton berkeley_hton = { "BerkeleyDB", SHOW_OPTION_NO,
"Supports transactions and page-level locking", DB_TYPE_BERKELEY_DB, NULL,
0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, HTON_NO_FLAGS };
#endif
#ifdef HAVE_BLACKHOLE_DB
#include "ha_blackhole.h"
extern handlerton blackhole_hton;
#else
handlerton blackhole_hton = { "BLACKHOLE", SHOW_OPTION_NO,
"/dev/null storage engine (anything you write to it disappears)",
DB_TYPE_BLACKHOLE_DB, NULL, 0, 0, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
HTON_NO_FLAGS };
#endif
#ifdef HAVE_EXAMPLE_DB
#include "examples/ha_example.h"
extern handlerton example_hton;
#else
handlerton example_hton = { "EXAMPLE", SHOW_OPTION_NO,
"Example storage engine",
DB_TYPE_EXAMPLE_DB, NULL, 0, 0, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
HTON_NO_FLAGS };
#endif
#ifdef HAVE_ARCHIVE_DB
#include "ha_archive.h"
extern handlerton archive_hton;
#else
handlerton archive_hton = { "ARCHIVE", SHOW_OPTION_NO,
"Archive storage engine", DB_TYPE_ARCHIVE_DB, NULL, 0, 0, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
HTON_NO_FLAGS };
#endif
#ifdef HAVE_CSV_DB
#include "examples/ha_tina.h"
extern handlerton tina_hton;
#else
handlerton tina_hton = { "CSV", SHOW_OPTION_NO, "CSV storage engine",
DB_TYPE_CSV_DB, NULL, 0, 0, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
HTON_NO_FLAGS };
#endif
#ifdef HAVE_INNOBASE_DB
#include "ha_innodb.h"
extern handlerton innobase_hton;
#else
handlerton innobase_hton = { "InnoDB", SHOW_OPTION_NO,
"Supports transactions, row-level locking, and foreign keys",
DB_TYPE_INNODB, NULL, 0, 0, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
HTON_NO_FLAGS };
#endif
#ifdef HAVE_NDBCLUSTER_DB
#include "ha_ndbcluster.h"
extern handlerton ndbcluster_hton;
#else
handlerton ndbcluster_hton = { "ndbcluster", SHOW_OPTION_NO,
"Clustered, fault-tolerant, memory-based tables",
DB_TYPE_NDBCLUSTER, NULL, 0, 0, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
HTON_NO_FLAGS };
#endif
#ifdef HAVE_FEDERATED_DB
#include "ha_federated.h"
extern handlerton federated_hton;
#else
handlerton federated_hton = { "FEDERATED", SHOW_OPTION_NO,
"Federated MySQL storage engine", DB_TYPE_FEDERATED_DB, NULL, 0, 0, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
HTON_NO_FLAGS };
#endif
#include <myisampack.h>
#include <errno.h>
......@@ -63,14 +113,19 @@ extern handlerton federated_hton;
extern handlerton myisam_hton;
extern handlerton myisammrg_hton;
extern handlerton heap_hton;
extern handlerton binlog_hton;
/*
Obsolete
*/
handlerton isam_hton = { "ISAM", SHOW_OPTION_NO, "Obsolete storage engine",
DB_TYPE_ISAM, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, HTON_NO_FLAGS };
/* static functions defined in this file */
static SHOW_COMP_OPTION have_yes= SHOW_OPTION_YES;
/* static functions defined in this file */
/* list of all available storage engines (of their handlertons) */
handlerton *handlertons[MAX_HA]={0};
static SHOW_COMP_OPTION have_yes= SHOW_OPTION_YES;
/* number of entries in handlertons[] */
ulong total_ha;
......@@ -80,41 +135,24 @@ ulong total_ha_2pc;
ulong savepoint_alloc_size;
/*
This structure will go away in the future.
This array is used for processing compiled in engines.
*/
struct show_table_type_st sys_table_types[]=
{
{"MyISAM", &have_yes,
"Default engine as of MySQL 3.23 with great performance", DB_TYPE_MYISAM,
NULL},
{"MEMORY", &have_yes,
"Hash based, stored in memory, useful for temporary tables", DB_TYPE_HEAP,
NULL},
{"MRG_MYISAM", &have_yes,
"Collection of identical MyISAM tables", DB_TYPE_MRG_MYISAM, NULL},
{"ISAM", &have_isam,
"Obsolete storage engine, now replaced by MyISAM", DB_TYPE_ISAM, NULL},
{"MRG_ISAM", &have_isam,
"Obsolete storage engine, now replaced by MERGE", DB_TYPE_MRG_ISAM, NULL},
{"InnoDB", &have_innodb,
"Supports transactions, row-level locking, and foreign keys", DB_TYPE_INNODB,
NULL},
{"BERKELEYDB", &have_berkeley_db,
"Supports transactions and page-level locking", DB_TYPE_BERKELEY_DB, NULL},
{"NDBCLUSTER", &have_ndbcluster,
"Clustered, fault-tolerant, memory-based tables", DB_TYPE_NDBCLUSTER, NULL},
{"EXAMPLE",&have_example_db,
"Example storage engine", DB_TYPE_EXAMPLE_DB, NULL},
{"ARCHIVE",&have_archive_db,
"Archive storage engine", DB_TYPE_ARCHIVE_DB, NULL},
{"CSV",&have_csv_db,
"CSV storage engine", DB_TYPE_CSV_DB, NULL},
{"FEDERATED",&have_federated_db,
"Federated MySQL storage engine", DB_TYPE_FEDERATED_DB, NULL},
{"BLACKHOLE",&have_blackhole_db,
"/dev/null storage engine (anything you write to it disappears)",
DB_TYPE_BLACKHOLE_DB, NULL},
{NullS, NULL, NullS, DB_TYPE_UNKNOWN, NULL}
handlerton *sys_table_types[]=
{
&myisam_hton,
&heap_hton,
&innobase_hton,
&berkeley_hton,
&blackhole_hton,
&example_hton,
&archive_hton,
&tina_hton,
&ndbcluster_hton,
&federated_hton,
&myisammrg_hton,
&binlog_hton,
&isam_hton,
NULL
};
struct show_table_alias_st sys_table_aliases[]=
......@@ -144,17 +182,17 @@ enum db_type ha_resolve_by_name(const char *name, uint namelen)
{
THD *thd= current_thd;
show_table_alias_st *table_alias;
show_table_type_st *types;
handlerton **types;
const char *ptr= name;
if (thd && !my_strcasecmp(&my_charset_latin1, ptr, "DEFAULT"))
return (enum db_type) thd->variables.table_type;
retest:
for (types= sys_table_types; types->type; types++)
for (types= sys_table_types; *types; types++)
{
if (!my_strcasecmp(&my_charset_latin1, ptr, types->type))
return (enum db_type) types->db_type;
if (!my_strcasecmp(&my_charset_latin1, ptr, (*types)->name))
return (enum db_type) (*types)->db_type;
}
/*
......@@ -173,11 +211,11 @@ enum db_type ha_resolve_by_name(const char *name, uint namelen)
}
const char *ha_get_storage_engine(enum db_type db_type)
{
show_table_type_st *types;
for (types= sys_table_types; types->type; types++)
handlerton **types;
for (types= sys_table_types; *types; types++)
{
if (db_type == types->db_type)
return types->type;
if (db_type == (*types)->db_type)
return (*types)->name;
}
return "none";
......@@ -185,12 +223,12 @@ const char *ha_get_storage_engine(enum db_type db_type)
bool ha_check_storage_engine_flag(enum db_type db_type, uint32 flag)
{
show_table_type_st *types;
for (types= sys_table_types; types->type; types++)
handlerton **types;
for (types= sys_table_types; *types; types++)
{
if (db_type == types->db_type)
if (db_type == (*types)->db_type)
{
if (types->ht->flags & flag)
if ((*types)->flags & flag)
return TRUE;
else
return FALSE;
......@@ -203,18 +241,18 @@ bool ha_check_storage_engine_flag(enum db_type db_type, uint32 flag)
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++)
handlerton **types;
for (types= sys_table_types; *types; types++)
{
if ((database_type == types->db_type) &&
(*types->value == SHOW_OPTION_YES))
if ((database_type == (*types)->db_type) &&
((*types)->state == SHOW_OPTION_YES))
return TRUE;
}
return FALSE;
}
/* Use other database handler if databasehandler is not incompiled */
/* Use other database handler if databasehandler is not compiled in */
enum db_type ha_checktype(THD *thd, enum db_type database_type,
bool no_substitute, bool report_error)
......@@ -411,8 +449,7 @@ static inline void ha_was_inited_ok(handlerton **ht)
int ha_init()
{
int error= 0;
handlerton **ht= handlertons;
show_table_type_st *types;
handlerton **types;
show_table_alias_st *table_alias;
total_ha= savepoint_alloc_size= 0;
......@@ -420,135 +457,16 @@ int ha_init()
return 1;
/*
This will go away soon.
We now initialize everything here.
*/
for (types= sys_table_types; types->type; types++)
{
switch (types->db_type) {
case DB_TYPE_HEAP:
types->ht= &heap_hton;
break;
case DB_TYPE_MYISAM:
types->ht= &myisam_hton;
break;
case DB_TYPE_MRG_MYISAM:
types->ht= &myisammrg_hton;
break;
#ifdef HAVE_BERKELEY_DB
case DB_TYPE_BERKELEY_DB:
if (have_berkeley_db == SHOW_OPTION_YES)
{
if (!(*ht= berkeley_init()))
for (types= sys_table_types; *types; types++)
{
have_berkeley_db= SHOW_OPTION_DISABLED; // If we couldn't use handler
error= 1;
}
if (!(*types)->init || !(*types)->init())
ha_was_inited_ok(types);
else
{
types->ht= &berkeley_hton;
ha_was_inited_ok(ht++);
}
}
break;
#endif
#ifdef HAVE_INNOBASE_DB
case DB_TYPE_INNODB:
if (have_innodb == SHOW_OPTION_YES)
{
if (!(*ht= innobase_init()))
{
have_innodb= SHOW_OPTION_DISABLED; // If we couldn't use handler
error= 1;
}
else
{
ha_was_inited_ok(ht++);
types->ht= &innobase_hton;
}
}
break;
#endif
#ifdef HAVE_NDBCLUSTER_DB
case DB_TYPE_NDBCLUSTER:
if (have_ndbcluster == SHOW_OPTION_YES)
{
if (!(*ht= ndbcluster_init()))
{
have_ndbcluster= SHOW_OPTION_DISABLED;
error= 1;
}
else
{
ha_was_inited_ok(ht++);
types->ht= &ndbcluster_hton;
}
}
break;
#endif
#ifdef HAVE_EXAMPLE_DB
case DB_TYPE_EXAMPLE_DB:
types->ht= &example_hton;
break;
#endif
#ifdef HAVE_ARCHIVE_DB
case DB_TYPE_ARCHIVE_DB:
if (have_archive_db == SHOW_OPTION_YES)
{
if (!(*ht= archive_db_init()))
{
have_archive_db= SHOW_OPTION_DISABLED;
error= 1;
}
else
{
ha_was_inited_ok(ht++);
types->ht= &archive_hton;
}
}
break;
#endif
#ifdef HAVE_CSV_DB
case DB_TYPE_CSV_DB:
types->ht= &tina_hton;
break;
#endif
#ifdef HAVE_FEDERATED_DB
case DB_TYPE_FEDERATED_DB:
if (have_federated_db == SHOW_OPTION_YES)
{
if (federated_db_init())
{
have_federated_db= SHOW_OPTION_DISABLED;
error= 1;
}
else
{
types->ht= &federated_hton;
}
}
break;
#endif
#ifdef HAVE_BLACKHOLE_DB
case DB_TYPE_BLACKHOLE_DB:
types->ht= &blackhole_hton;
break;
#endif
default:
types->ht= NULL;
}
(*types)->state= SHOW_OPTION_DISABLED;
}
if (opt_bin_log)
{
if (!(*ht= binlog_init())) // Always succeed
{
mysql_bin_log.close(LOG_CLOSE_INDEX); // Never used
opt_bin_log= 0; // Never used
error= 1; // Never used
}
else
ha_was_inited_ok(ht++);
}
DBUG_ASSERT(total_ha < MAX_HA);
/*
Check if there is a transaction-capable storage engine besides the
......@@ -620,9 +538,10 @@ void ha_drop_database(char* path)
/* don't bother to rollback here, it's done already */
void ha_close_connection(THD* thd)
{
for (uint i=0; i < total_ha; i++)
if (thd->ha_data[i])
(*handlertons[i]->close_connection)(thd);
handlerton **types;
for (types= sys_table_types; *types; types++)
if (thd->ha_data[(*types)->slot])
(*types)->close_connection(thd);
}
/* ========================================================================
......@@ -933,13 +852,13 @@ int ha_autocommit_or_rollback(THD *thd, int error)
int ha_commit_or_rollback_by_xid(XID *xid, bool commit)
{
handlerton **ht= handlertons, **end_ht=ht+total_ha;
handlerton **types;
int res= 1;
for ( ; ht < end_ht ; ht++)
if ((*ht)->recover)
for (types= sys_table_types; *types; types++)
if ((*types)->state == SHOW_OPTION_YES && (*types)->recover)
res= res &&
(*(commit ? (*ht)->commit_by_xid : (*ht)->rollback_by_xid))(xid);
(*(commit ? (*types)->commit_by_xid : (*types)->rollback_by_xid))(xid);
return res;
}
......@@ -1018,7 +937,7 @@ static char* xid_to_str(char *buf, XID *xid)
int ha_recover(HASH *commit_list)
{
int len, got, found_foreign_xids=0, found_my_xids=0;
handlerton **ht= handlertons, **end_ht=ht+total_ha;
handlerton **types;
XID *list=0;
bool dry_run=(commit_list==0 && tc_heuristic_recover==0);
DBUG_ENTER("ha_recover");
......@@ -1054,14 +973,14 @@ int ha_recover(HASH *commit_list)
DBUG_RETURN(1);
}
for ( ; ht < end_ht ; ht++)
for (types= sys_table_types; *types; types++)
{
if (!(*ht)->recover)
if ((*types)->state != SHOW_OPTION_YES || !(*types)->recover)
continue;
while ((got=(*(*ht)->recover)(list, len)) > 0 )
while ((got=(*(*types)->recover)(list, len)) > 0 )
{
sql_print_information("Found %d prepared transaction(s) in %s",
got, (*ht)->name);
got, (*types)->name);
for (int i=0; i < got; i ++)
{
my_xid x=list[i].get_my_xid();
......@@ -1089,7 +1008,7 @@ int ha_recover(HASH *commit_list)
char buf[XIDDATASIZE*4+6]; // see xid_to_str
sql_print_information("commit xid %s", xid_to_str(buf, list+i));
#endif
(*(*ht)->commit_by_xid)(list+i);
(*(*types)->commit_by_xid)(list+i);
}
else
{
......@@ -1097,7 +1016,7 @@ int ha_recover(HASH *commit_list)
char buf[XIDDATASIZE*4+6]; // see xid_to_str
sql_print_information("rollback xid %s", xid_to_str(buf, list+i));
#endif
(*(*ht)->rollback_by_xid)(list+i);
(*(*types)->rollback_by_xid)(list+i);
}
}
if (got < len)
......@@ -2542,7 +2461,7 @@ TYPELIB *ha_known_exts(void)
{
if (!known_extensions.type_names || mysys_usage_id != known_extensions_id)
{
show_table_type_st *types;
handlerton **types;
List<char> found_exts;
List_iterator_fast<char> it(found_exts);
const char **ext, *old_ext;
......@@ -2550,11 +2469,11 @@ TYPELIB *ha_known_exts(void)
known_extensions_id= mysys_usage_id;
found_exts.push_back((char*) triggers_file_ext);
found_exts.push_back((char*) trigname_file_ext);
for (types= sys_table_types; types->type; types++)
for (types= sys_table_types; *types; types++)
{
if (*types->value == SHOW_OPTION_YES)
if ((*types)->state == SHOW_OPTION_YES)
{
handler *file= get_new_handler(0,(enum db_type) types->db_type);
handler *file= get_new_handler(0,(enum db_type) (*types)->db_type);
for (ext= file->bas_ext(); *ext; ext++)
{
while ((old_ext= it++))
......
......@@ -304,6 +304,27 @@ typedef struct
storage engine name as it should be printed to a user
*/
const char *name;
/*
Historical marker for if the engine is available of not
*/
SHOW_COMP_OPTION state;
/*
A comment used by SHOW to describe an engine.
*/
const char *comment;
/*
Historical number used for frm file to determine the correct storage engine.
This is going away and new engines will just use "name" for this.
*/
enum db_type db_type;
/*
Method that initizlizes a storage engine
*/
bool (*init)();
/*
each storage engine has it's own memory area (actually a pointer)
in the thd, for storing per-connection information.
......@@ -363,14 +384,6 @@ typedef struct
uint32 flags; /* global handler flags */
} handlerton;
struct show_table_type_st {
const char *type;
SHOW_COMP_OPTION *value;
const char *comment;
enum db_type db_type;
handlerton *ht;
};
struct show_table_alias_st {
const char *alias;
const char *type;
......@@ -837,11 +850,10 @@ class handler :public Sql_alloc
/* Some extern variables used with handlers */
extern struct show_table_type_st sys_table_types[];
extern handlerton *sys_table_types[];
extern const char *ha_row_type[];
extern TYPELIB tx_isolation_typelib;
extern TYPELIB myisam_stats_method_typelib;
extern handlerton *handlertons[MAX_HA];
extern ulong total_ha, total_ha_2pc;
/* Wrapper functions */
......
......@@ -38,6 +38,7 @@ ulong sync_binlog_counter= 0;
static bool test_if_number(const char *str,
long *res, bool allow_wildcards);
static bool binlog_init();
static int binlog_close_connection(THD *thd);
static int binlog_savepoint_set(THD *thd, void *sv);
static int binlog_savepoint_rollback(THD *thd, void *sv);
......@@ -45,8 +46,12 @@ static int binlog_commit(THD *thd, bool all);
static int binlog_rollback(THD *thd, bool all);
static int binlog_prepare(THD *thd, bool all);
static handlerton binlog_hton = {
handlerton binlog_hton = {
"binlog",
SHOW_OPTION_YES,
"This is a meta storage engine to represent the binlog in a transaction",
DB_TYPE_UNKNOWN, /* IGNORE for now */
binlog_init,
0,
sizeof(my_off_t), /* savepoint size = binlog offset */
binlog_close_connection,
......@@ -71,9 +76,9 @@ static handlerton binlog_hton = {
should be moved here.
*/
handlerton *binlog_init()
bool binlog_init()
{
return &binlog_hton;
return false;
}
static int binlog_close_connection(THD *thd)
......
......@@ -1070,7 +1070,6 @@ bool fn_format_relative_to_data_home(my_string to, const char *name,
const char *dir, const char *extension);
File open_binlog(IO_CACHE *log, const char *log_file_name,
const char **errmsg);
handlerton *binlog_init();
/* mysqld.cc */
extern void yyerror(const char*);
......
......@@ -67,18 +67,18 @@ bool mysqld_show_storage_engines(THD *thd)
const char *default_type_name=
ha_get_storage_engine((enum db_type)thd->variables.table_type);
show_table_type_st *types;
for (types= sys_table_types; types->type; types++)
handlerton **types;
for (types= sys_table_types; *types; types++)
{
protocol->prepare_for_resend();
protocol->store(types->type, system_charset_info);
const char *option_name= show_comp_option_name[(int) *types->value];
protocol->store((*types)->name, system_charset_info);
const char *option_name= show_comp_option_name[(int) (*types)->state];
if (*types->value == SHOW_OPTION_YES &&
!my_strcasecmp(system_charset_info, default_type_name, types->type))
if ((*types)->state == SHOW_OPTION_YES &&
!my_strcasecmp(system_charset_info, default_type_name, (*types)->name))
option_name= "DEFAULT";
protocol->store(option_name, system_charset_info);
protocol->store(types->comment, system_charset_info);
protocol->store((*types)->comment, system_charset_info);
if (protocol->write())
DBUG_RETURN(TRUE);
}
......
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