summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/examples/ha_tina.cc15
-rw-r--r--sql/examples/ha_tina.h7
-rw-r--r--sql/ha_archive.cc3
-rw-r--r--sql/ha_berkeley.cc1
-rw-r--r--sql/ha_federated.cc1
-rw-r--r--sql/ha_innodb.cc1
-rw-r--r--sql/ha_ndbcluster.cc1
-rw-r--r--sql/handler.cc150
-rw-r--r--sql/handler.h1
9 files changed, 85 insertions, 95 deletions
diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc
index 86e6ae8a2de..541e91f4b46 100644
--- a/sql/examples/ha_tina.cc
+++ b/sql/examples/ha_tina.cc
@@ -862,21 +862,6 @@ THR_LOCK_DATA **ha_tina::store_lock(THD *thd,
}
/*
- 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).
*/
diff --git a/sql/examples/ha_tina.h b/sql/examples/ha_tina.h
index 1ccb3418771..84854e868fa 100644
--- a/sql/examples/ha_tina.h
+++ b/sql/examples/ha_tina.h
@@ -78,7 +78,6 @@ public:
*/
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 @@ public:
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,
diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc
index bc066b672d3..59c56e80cc3 100644
--- a/sql/ha_archive.cc
+++ b/sql/ha_archive.cc
@@ -137,7 +137,7 @@ 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,
@@ -201,7 +201,6 @@ bool archive_db_init()
}
error:
have_archive_db= SHOW_OPTION_DISABLED; // If we couldn't use handler
- archive_hton.state= SHOW_OPTION_DISABLED;
DBUG_RETURN(TRUE);
}
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index 60dd27efa69..c7e56b350bf 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -210,7 +210,6 @@ bool berkeley_init(void)
DBUG_RETURN(FALSE);
error:
have_berkeley_db= SHOW_OPTION_DISABLED; // If we couldn't use handler
- berkeley_hton.state= SHOW_OPTION_DISABLED;
DBUG_RETURN(TRUE);
}
diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc
index c129cb3058c..2b2be71cf53 100644
--- a/sql/ha_federated.cc
+++ b/sql/ha_federated.cc
@@ -428,7 +428,6 @@ bool federated_db_init()
}
error:
have_federated_db= SHOW_OPTION_DISABLED; // If we couldn't use handler
- federated_hton.state= SHOW_OPTION_DISABLED;
DBUG_RETURN(TRUE);
}
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index ebe1e41f890..1129251f06b 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -1423,7 +1423,6 @@ innobase_init(void)
DBUG_RETURN(FALSE);
error:
have_innodb= SHOW_OPTION_DISABLED; // If we couldn't use handler
- innobase_hton.state= SHOW_OPTION_DISABLED;
DBUG_RETURN(TRUE);
}
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 030f5881861..5451447ec43 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -4837,7 +4837,6 @@ ndbcluster_init_error:
delete g_ndb_cluster_connection;
g_ndb_cluster_connection= NULL;
have_ndbcluster= SHOW_OPTION_DISABLED; // If we couldn't use handler
- ndbcluster_hton.state= SHOW_OPTION_DISABLED;
DBUG_RETURN(TRUE);
}
diff --git a/sql/handler.cc b/sql/handler.cc
index 211da341da1..d449a0b90f2 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -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>
@@ -65,13 +115,17 @@ 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;
@@ -87,31 +141,17 @@ handlerton *sys_table_types[]=
{
&myisam_hton,
&heap_hton,
-#ifdef HAVE_INNOBASE_DB
&innobase_hton,
-#endif
-#ifdef HAVE_BERKELEY_DB
&berkeley_hton,
-#endif
-#ifdef HAVE_BLACKHOLE_DB
&blackhole_hton,
-#endif
-#ifdef HAVE_EXAMPLE_DB
&example_hton,
-#endif
-#ifdef HAVE_ARCHIVE_DB
&archive_hton,
-#endif
-#ifdef HAVE_CSV_DB
&tina_hton,
-#endif
-#ifdef HAVE_NDBCLUSTER_DB
&ndbcluster_hton,
-#endif
-#ifdef HAVE_FEDERATED_DB
&federated_hton,
-#endif
&myisammrg_hton,
+ &binlog_hton,
+ &isam_hton,
NULL
};
@@ -183,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;
@@ -409,7 +449,6 @@ static inline void ha_was_inited_ok(handlerton **ht)
int ha_init()
{
int error= 0;
- handlerton **ht= handlertons;
handlerton **types;
show_table_alias_st *table_alias;
total_ha= savepoint_alloc_size= 0;
@@ -418,38 +457,16 @@ int ha_init()
return 1;
/*
- This will go away soon.
+ We now initialize everything here.
*/
for (types= sys_table_types; *types; types++)
{
- /*
- FUTURE -
- We need to collapse sys_table_types and handlertons variables into
- one variable.
- */
- *ht= *types;
- ht++;
- if ((*types)->init)
- {
- if (!(*types)->init())
- ha_was_inited_ok(types);
- }
- }
-
- if (opt_bin_log)
- {
- if (0) // Should fail until binlog is a bit more se like
- {
- mysql_bin_log.close(LOG_CLOSE_INDEX); // Never used
- opt_bin_log= 0; // Never used
- error= 1; // Never used
- }
+ if (!(*types)->init || !(*types)->init())
+ ha_was_inited_ok(types);
else
- {
- *types= &binlog_hton;
- ha_was_inited_ok(types);
- }
+ (*types)->state= SHOW_OPTION_DISABLED;
}
+
DBUG_ASSERT(total_ha < MAX_HA);
/*
Check if there is a transaction-capable storage engine besides the
@@ -521,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);
}
/* ========================================================================
@@ -834,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;
}
@@ -919,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");
@@ -955,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();
@@ -990,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
{
@@ -998,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)
diff --git a/sql/handler.h b/sql/handler.h
index 18c39de28e6..81048c0730e 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -854,7 +854,6 @@ 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 */