summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <serg@sergbook.mysql.com>2006-05-28 14:51:01 +0200
committerunknown <serg@sergbook.mysql.com>2006-05-28 14:51:01 +0200
commite2e582d1fba236d40e7233dcdb47d46618529390 (patch)
treef608495a4495b48130506f40d940b93ebdb1bfe1 /sql
parentcccd302c91a0bfb82ed6b387016a12a23420fb6f (diff)
downloadmariadb-git-e2e582d1fba236d40e7233dcdb47d46618529390.tar.gz
handlerton cleanup:
duplicate fields removed, st_mysql_storage_engine added to support run-time handlerton initialization (no compiler warnings), handler API is now tied to MySQL version, handlerton->plugin mapping added (slot-based), dummy default_hton removed, plugin-type-specific initialization generalized, built-in plugins are now initialized too, --default-storage-engine no longer needs a list of storage engines in handle_options(). mysql-test-run.pl bugfixes include/mysql/plugin.h: added st_mysql_storage_engine made handlerton tied to MySQL version mysql-test/mysql-test-run.pl: bugfixes (umask, --no-defaults) mysql-test/r/ndb_dd_basic.result: update error message mysql-test/t/partition_mgm_err2.test: fix typo sql/ha_berkeley.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings sql/ha_berkeley.h: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings sql/ha_federated.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings sql/ha_heap.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings sql/ha_innodb.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings sql/ha_innodb.h: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings sql/ha_myisam.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings sql/ha_myisammrg.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings sql/ha_ndbcluster.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings sql/ha_ndbcluster.h: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings sql/ha_ndbcluster_binlog.cc: no 'name' in the handlerton anymore sql/ha_partition.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings sql/handler.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, handlerton->plugin mapping sql/handler.h: handlerton cleanup: remove duplicate fields sql/log.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings sql/mysql_priv.h: handler.h needs plugin.h sql/mysqld.cc: Convert --default-storage-engine to a handlerton* when all storage engines are initialized and not in getopt sql/set_var.cc: no name in the handlerton anymore sql/sql_parse.cc: no default_hton anymore sql/sql_partition.cc: no name in the handlerton anymore sql/sql_plugin.cc: generalize plugin type-specific initialization. initialize built-in plugins too sql/sql_plugin.h: generalize plugin type-specific initialization. sql/sql_show.cc: st_mysql_storage_engine structure no name in the handlerton anymore sql/sql_table.cc: no name in the handlerton anymore no default_hton anymore sql/sql_tablespace.cc: no name in the handlerton anymore no default_hton anymore sql/sql_yacc.yy: no default_hton anymore issue "unknown storage engine" warning where it is discovered storage/archive/ha_archive.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings storage/archive/ha_archive.h: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings storage/blackhole/ha_blackhole.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings storage/csv/ha_tina.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings storage/example/ha_example.cc: handlerton cleanup: remove duplicate fields, add st_mysql_storage_engine, initialize handlerton run-time to avoid compiler warnings
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_berkeley.cc81
-rw-r--r--sql/ha_berkeley.h2
-rw-r--r--sql/ha_federated.cc63
-rw-r--r--sql/ha_heap.cc63
-rw-r--r--sql/ha_innodb.cc89
-rw-r--r--sql/ha_innodb.h2
-rw-r--r--sql/ha_myisam.cc75
-rw-r--r--sql/ha_myisammrg.cc63
-rw-r--r--sql/ha_ndbcluster.cc54
-rw-r--r--sql/ha_ndbcluster.h4
-rw-r--r--sql/ha_ndbcluster_binlog.cc6
-rw-r--r--sql/ha_partition.cc62
-rw-r--r--sql/handler.cc150
-rw-r--r--sql/handler.h31
-rw-r--r--sql/log.cc71
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/mysqld.cc52
-rw-r--r--sql/set_var.cc2
-rw-r--r--sql/sql_parse.cc4
-rw-r--r--sql/sql_partition.cc16
-rw-r--r--sql/sql_plugin.cc44
-rw-r--r--sql/sql_plugin.h2
-rw-r--r--sql/sql_show.cc51
-rw-r--r--sql/sql_table.cc9
-rw-r--r--sql/sql_tablespace.cc10
-rw-r--r--sql/sql_yacc.yy16
26 files changed, 376 insertions, 648 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index 473fb149871..9a144066057 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -97,6 +97,9 @@ pthread_mutex_t bdb_mutex;
static DB_ENV *db_env;
static HASH bdb_open_tables;
+static const char berkeley_hton_name[]= "BerkeleyDB";
+static const int berkeley_hton_name_length=sizeof(berkeley_hton_name)-1;
+
const char *berkeley_lock_names[] =
{ "DEFAULT", "OLDEST", "RANDOM", "YOUNGEST", "EXPIRE", "MAXLOCKS",
"MAXWRITE", "MINLOCKS", "MINWRITE", 0 };
@@ -125,47 +128,7 @@ static int berkeley_savepoint(THD* thd, void *savepoint);
static int berkeley_release_savepoint(THD* thd, void *savepoint);
static handler *berkeley_create_handler(TABLE_SHARE *table);
-static const char berkeley_hton_name[]= "BerkeleyDB";
-static const char berkeley_hton_comment[]=
- "Supports transactions and page-level locking";
-
-handlerton berkeley_hton = {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- berkeley_hton_name,
- SHOW_OPTION_YES,
- berkeley_hton_comment,
- DB_TYPE_BERKELEY_DB,
- berkeley_init,
- 0, /* slot */
- sizeof(DB_TXN *), /* savepoint size */
- berkeley_close_connection,
- berkeley_savepoint, /* savepoint_set */
- berkeley_rollback_to_savepoint, /* savepoint_rollback */
- berkeley_release_savepoint, /* savepoint_release */
- berkeley_commit,
- berkeley_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 */
- berkeley_create_handler, /* Create a new handler */
- NULL, /* Drop a database */
- berkeley_end, /* Panic call */
- NULL, /* Start Consistent Snapshot */
- berkeley_flush_logs, /* Flush logs */
- berkeley_show_status, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill Files Table */
- HTON_CLOSE_CURSORS_AT_COMMIT | HTON_FLUSH_AFTER_RENAME,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
+handlerton berkeley_hton;
handler *berkeley_create_handler(TABLE_SHARE *table)
{
@@ -181,12 +144,27 @@ typedef struct st_berkeley_trx_data {
/* General functions */
-bool berkeley_init(void)
+int berkeley_init(void)
{
DBUG_ENTER("berkeley_init");
+ berkeley_hton.state=SHOW_OPTION_YES;
+ berkeley_hton.db_type=DB_TYPE_BERKELEY_DB;
+ berkeley_hton.savepoint_offset=sizeof(DB_TXN *);
+ berkeley_hton.close_connection=berkeley_close_connection;
+ berkeley_hton.savepoint_set=berkeley_savepoint;
+ berkeley_hton.savepoint_rollback=berkeley_rollback_to_savepoint;
+ berkeley_hton.savepoint_release=berkeley_release_savepoint;
+ berkeley_hton.commit=berkeley_commit;
+ berkeley_hton.rollback=berkeley_rollback;
+ berkeley_hton.create=berkeley_create_handler;
+ berkeley_hton.panic=berkeley_end;
+ berkeley_hton.flush_logs=berkeley_flush_logs;
+ berkeley_hton.show_status=berkeley_show_status;
+ berkeley_hton.flags=HTON_CLOSE_CURSORS_AT_COMMIT | HTON_FLUSH_AFTER_RENAME;
+
if (have_berkeley_db != SHOW_OPTION_YES)
- goto error;
+ return 0; // nothing else to do
if (!berkeley_tmpdir)
berkeley_tmpdir=mysql_tmpdir;
@@ -373,7 +351,6 @@ static int berkeley_release_savepoint(THD* thd, void *savepoint)
static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
{
char **all_logs, **free_logs, **a, **f;
- uint hton_name_len= strlen(berkeley_hton.name);
int error=1;
MEM_ROOT **root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC);
MEM_ROOT show_logs_root, *old_mem_root= *root_ptr;
@@ -401,15 +378,15 @@ static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
if (f && *f && strcmp(*a, *f) == 0)
{
f++;
- if ((error= stat_print(thd, berkeley_hton.name, hton_name_len,
- *a, strlen(*a),
+ if ((error= stat_print(thd, berkeley_hton_name,
+ berkeley_hton_name_length, *a, strlen(*a),
STRING_WITH_LEN(SHOW_LOG_STATUS_FREE))))
break;
}
else
{
- if ((error= stat_print(thd, berkeley_hton.name, hton_name_len,
- *a, strlen(*a),
+ if ((error= stat_print(thd, berkeley_hton_name,
+ berkeley_hton_name_length, *a, strlen(*a),
STRING_WITH_LEN(SHOW_LOG_STATUS_INUSE))))
break;
}
@@ -2732,15 +2709,17 @@ bool ha_berkeley::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES;
}
+struct st_mysql_storage_engine berkeley_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &berkeley_hton };
mysql_declare_plugin(berkeley)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &berkeley_hton,
+ &berkeley_storage_engine,
berkeley_hton_name,
"Sleepycat Software",
- berkeley_hton_comment,
- NULL, /* Plugin Init */
+ "Supports transactions and page-level locking",
+ berkeley_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100, /* 1.0 */
0
diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h
index 21b618b8d6d..50a2aec3963 100644
--- a/sql/ha_berkeley.h
+++ b/sql/ha_berkeley.h
@@ -172,7 +172,7 @@ extern char *berkeley_home, *berkeley_tmpdir, *berkeley_logdir;
extern long berkeley_lock_scan_time;
extern TYPELIB berkeley_lock_typelib;
-bool berkeley_init(void);
+int berkeley_init(void);
int berkeley_end(ha_panic_function type);
bool berkeley_flush_logs(void);
bool berkeley_show_status(THD *thd, stat_print_fn *print, enum ha_stat_type);
diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc
index f4fc5f47193..30988c6c8d0 100644
--- a/sql/ha_federated.cc
+++ b/sql/ha_federated.cc
@@ -370,47 +370,7 @@ static int federated_rollback(THD *thd, bool all);
/* Federated storage engine handlerton */
-static const char federated_hton_name[]= "FEDERATED";
-static const char federated_hton_comment[]= "Federated MySQL storage engine";
-
-handlerton federated_hton= {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- federated_hton_name,
- SHOW_OPTION_YES,
- federated_hton_comment,
- DB_TYPE_FEDERATED_DB,
- federated_db_init,
- 0, /* slot */
- 0, /* savepoint size. */
- NULL, /* close_connection */
- NULL, /* savepoint */
- NULL, /* rollback to savepoint */
- NULL, /* release savepoint */
- federated_commit, /* commit */
- federated_rollback, /* 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 */
- federated_create_handler, /* Create a new handler */
- NULL, /* Drop a database */
- federated_db_end, /* Panic call */
- NULL, /* Start Consistent Snapshot */
- NULL, /* Flush logs */
- NULL, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill FILES table */
- HTON_ALTER_NOT_SUPPORTED,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
-
+handlerton federated_hton;
static handler *federated_create_handler(TABLE_SHARE *table)
{
@@ -442,6 +402,15 @@ static byte *federated_get_key(FEDERATED_SHARE *share, uint *length,
bool federated_db_init()
{
DBUG_ENTER("federated_db_init");
+
+ federated_hton.state= SHOW_OPTION_YES;
+ federated_hton.db_type= DB_TYPE_FEDERATED_DB;
+ federated_hton.commit= federated_commit;
+ federated_hton.rollback= federated_rollback;
+ federated_hton.create= federated_create_handler;
+ federated_hton.panic= federated_db_end;
+ federated_hton.flags= HTON_ALTER_NOT_SUPPORTED;
+
if (pthread_mutex_init(&federated_mutex, MY_MUTEX_INIT_FAST))
goto error;
if (!hash_init(&federated_open_tables, system_charset_info, 32, 0, 0,
@@ -2797,7 +2766,7 @@ int ha_federated::connection_autocommit(bool state)
DBUG_ENTER("ha_federated::connection_autocommit");
text= (state == true) ? "SET AUTOCOMMIT=1" : "SET AUTOCOMMIT=0";
DBUG_RETURN(execute_simple_query(text, 16));
-}
+}
int ha_federated::execute_simple_query(const char *query, int len)
@@ -2811,15 +2780,17 @@ int ha_federated::execute_simple_query(const char *query, int len)
DBUG_RETURN(0);
}
+struct st_mysql_storage_engine federated_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &federated_hton };
mysql_declare_plugin(federated)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &federated_hton,
- federated_hton_name,
+ &federated_storage_engine,
+ "FEDERATED",
"Patrick Galbraith and Brian Aker, MySQL AB",
- federated_hton_comment,
- NULL, /* Plugin Init */
+ "Federated MySQL storage engine",
+ federated_db_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
}
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index 1a7efb42748..15cec9ec4a6 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -26,47 +26,17 @@
static handler *heap_create_handler(TABLE_SHARE *table);
-static const char heap_hton_name[]= "MEMORY";
-static const char heap_hton_comment[]=
- "Hash based, stored in memory, useful for temporary tables";
-
-handlerton heap_hton= {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- heap_hton_name,
- SHOW_OPTION_YES,
- heap_hton_comment,
- DB_TYPE_HEAP,
- NULL,
- 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 */
- heap_create_handler, /* Create a new handler */
- NULL, /* Drop a database */
- heap_panic, /* Panic call */
- NULL, /* Start Consistent Snapshot */
- NULL, /* Flush logs */
- NULL, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill Files Table */
- HTON_CAN_RECREATE,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
+handlerton heap_hton;
+
+int heap_init()
+{
+ heap_hton.state= SHOW_OPTION_YES;
+ heap_hton.db_type= DB_TYPE_HEAP;
+ heap_hton.create= heap_create_handler;
+ heap_hton.panic= heap_panic;
+ heap_hton.flags= HTON_CAN_RECREATE;
+ return 0;
+}
static handler *heap_create_handler(TABLE_SHARE *table)
{
@@ -711,14 +681,17 @@ bool ha_heap::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES;
}
+struct st_mysql_storage_engine heap_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &heap_hton};
+
mysql_declare_plugin(heap)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &heap_hton,
- heap_hton_name,
+ &heap_storage_engine,
+ "MEMORY",
"MySQL AB",
- heap_hton_comment,
- NULL,
+ "Hash based, stored in memory, useful for temporary tables",
+ heap_init,
NULL,
0x0100, /* 1.0 */
0
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 0b2f561e8c9..4be8a81b845 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -42,7 +42,6 @@ have disables the InnoDB inlining in this file. */
#define MAX_ULONG_BIT ((ulong) 1 << (sizeof(ulong)*8-1))
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
#include "ha_innodb.h"
pthread_mutex_t innobase_share_mutex, /* to protect innobase_open_files */
@@ -206,47 +205,8 @@ static int innobase_release_savepoint(THD* thd, void *savepoint);
static handler *innobase_create_handler(TABLE_SHARE *table);
static const char innobase_hton_name[]= "InnoDB";
-static const char innobase_hton_comment[]=
- "Supports transactions, row-level locking, and foreign keys";
-
-handlerton innobase_hton = {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- innobase_hton_name,
- SHOW_OPTION_YES,
- innobase_hton_comment,
- DB_TYPE_INNODB,
- innobase_init,
- 0, /* slot */
- sizeof(trx_named_savept_t), /* savepoint size. TODO: use it */
- innobase_close_connection,
- innobase_savepoint,
- innobase_rollback_to_savepoint,
- innobase_release_savepoint,
- innobase_commit, /* commit */
- innobase_rollback, /* rollback */
- innobase_xa_prepare, /* prepare */
- innobase_xa_recover, /* recover */
- innobase_commit_by_xid, /* commit_by_xid */
- innobase_rollback_by_xid, /* rollback_by_xid */
- innobase_create_cursor_view,
- innobase_set_cursor_view,
- innobase_close_cursor_view,
- innobase_create_handler, /* Create a new handler */
- innobase_drop_database, /* Drop a database */
- innobase_end, /* Panic call */
- innobase_start_trx_and_assign_read_view, /* Start Consistent Snapshot */
- innobase_flush_logs, /* Flush logs */
- innobase_show_status, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* alter_tablespace */
- NULL, /* Fill FILES table */
- HTON_NO_FLAGS,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- innobase_release_temporary_latches
-};
+handlerton innobase_hton;
static handler *innobase_create_handler(TABLE_SHARE *table)
{
@@ -1230,10 +1190,9 @@ ha_innobase::init_table_handle_for_HANDLER(void)
/*************************************************************************
Opens an InnoDB database. */
-bool
+int
innobase_init(void)
/*===============*/
- /* out: &innobase_hton, or NULL on error */
{
static char current_dir[3]; /* Set if using current lib */
int err;
@@ -1242,8 +1201,33 @@ innobase_init(void)
DBUG_ENTER("innobase_init");
+ innobase_hton.state=have_innodb;
+ innobase_hton.db_type= DB_TYPE_INNODB;
+ innobase_hton.savepoint_offset=sizeof(trx_named_savept_t);
+ innobase_hton.close_connection=innobase_close_connection;
+ innobase_hton.savepoint_set=innobase_savepoint;
+ innobase_hton.savepoint_rollback=innobase_rollback_to_savepoint;
+ innobase_hton.savepoint_release=innobase_release_savepoint;
+ innobase_hton.commit=innobase_commit;
+ innobase_hton.rollback=innobase_rollback;
+ innobase_hton.prepare=innobase_xa_prepare;
+ innobase_hton.recover=innobase_xa_recover;
+ innobase_hton.commit_by_xid=innobase_commit_by_xid;
+ innobase_hton.rollback_by_xid=innobase_rollback_by_xid;
+ innobase_hton.create_cursor_read_view=innobase_create_cursor_view;
+ innobase_hton.set_cursor_read_view=innobase_set_cursor_view;
+ innobase_hton.close_cursor_read_view=innobase_close_cursor_view;
+ innobase_hton.create=innobase_create_handler;
+ innobase_hton.drop_database=innobase_drop_database;
+ innobase_hton.panic=innobase_end;
+ innobase_hton.start_consistent_snapshot=innobase_start_trx_and_assign_read_view;
+ innobase_hton.flush_logs=innobase_flush_logs;
+ innobase_hton.show_status=innobase_show_status;
+ innobase_hton.flags=HTON_NO_FLAGS;
+ innobase_hton.release_temporary_latches=innobase_release_temporary_latches;
+
if (have_innodb != SHOW_OPTION_YES)
- goto error;
+ DBUG_RETURN(0); // nothing else to do
ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
@@ -6473,7 +6457,7 @@ innodb_show_status(
bool result = FALSE;
- if (stat_print(thd, innobase_hton.name, strlen(innobase_hton.name),
+ if (stat_print(thd, innobase_hton_name, strlen(innobase_hton_name),
STRING_WITH_LEN(""), str, flen)) {
result= TRUE;
}
@@ -6500,7 +6484,7 @@ innodb_mutex_show_status(
ulint rw_lock_count_os_wait= 0;
ulint rw_lock_count_os_yield= 0;
ulonglong rw_lock_wait_time= 0;
- uint hton_name_len= strlen(innobase_hton.name), buf1len, buf2len;
+ uint hton_name_len= strlen(innobase_hton_name), buf1len, buf2len;
DBUG_ENTER("innodb_mutex_show_status");
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
@@ -6527,7 +6511,7 @@ innodb_mutex_show_status(
mutex->count_os_yield,
mutex->lspent_time/1000);
- if (stat_print(thd, innobase_hton.name,
+ if (stat_print(thd, innobase_hton_name,
hton_name_len, buf1, buf1len,
buf2, buf2len)) {
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
@@ -6557,7 +6541,7 @@ innodb_mutex_show_status(
rw_lock_count_os_wait, rw_lock_count_os_yield,
rw_lock_wait_time/1000);
- if (stat_print(thd, innobase_hton.name, hton_name_len,
+ if (stat_print(thd, innobase_hton_name, hton_name_len,
STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len)) {
DBUG_RETURN(1);
}
@@ -7459,19 +7443,20 @@ bool ha_innobase::check_if_incompatible_data(
return COMPATIBLE_DATA_YES;
}
+struct st_mysql_storage_engine innobase_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &innobase_hton};
mysql_declare_plugin(innobase)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &innobase_hton,
+ &innobase_storage_engine,
innobase_hton_name,
"Innobase OY",
- innobase_hton_comment,
- NULL, /* Plugin Init */
+ "Supports transactions, row-level locking, and foreign keys",
+ innobase_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
0
}
mysql_declare_plugin_end;
-#endif
diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h
index 4f0c9eb151b..638ecc432b9 100644
--- a/sql/ha_innodb.h
+++ b/sql/ha_innodb.h
@@ -249,7 +249,7 @@ extern ulong srv_thread_concurrency;
extern ulong srv_commit_concurrency;
}
-bool innobase_init(void);
+int innobase_init(void);
int innobase_end(ha_panic_function type);
bool innobase_flush_logs(void);
uint innobase_get_free_space(void);
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 786d45a4966..645998602bb 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -52,63 +52,11 @@ TYPELIB myisam_stats_method_typelib= {
** MyISAM tables
*****************************************************************************/
-static handler *myisam_create_handler(TABLE_SHARE *table);
-
-/* MyISAM handlerton */
-
-static const char myisam_hton_name[]= "MyISAM";
-static const char myisam_hton_comment[]=
- "Default engine as of MySQL 3.23 with great performance";
-
-handlerton myisam_hton= {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- myisam_hton_name,
- SHOW_OPTION_YES,
- myisam_hton_comment,
- DB_TYPE_MYISAM,
- NULL,
- 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 */
- /*
- MyISAM doesn't support transactions and doesn't have
- transaction-dependent context: cursors can survive a commit.
- */
- myisam_create_handler, /* Create a new handler */
- NULL, /* Drop a database */
- mi_panic,/* Panic call */
- NULL, /* Start Consistent Snapshot */
- NULL, /* Flush logs */
- NULL, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill Files Table */
- HTON_CAN_RECREATE,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
-
-
static handler *myisam_create_handler(TABLE_SHARE *table)
{
return new ha_myisam(table);
}
-
// collect errors printed by mi_check routines
static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
@@ -1797,17 +1745,32 @@ bool ha_myisam::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES;
}
+handlerton myisam_hton;
+
+static int myisam_init()
+{
+ myisam_hton.state=SHOW_OPTION_YES;
+ myisam_hton.db_type=DB_TYPE_MYISAM;
+ myisam_hton.create=myisam_create_handler;
+ myisam_hton.panic=mi_panic;
+ myisam_hton.flags=HTON_CAN_RECREATE;
+ return 0;
+}
+
+struct st_mysql_storage_engine myisam_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &myisam_hton };
mysql_declare_plugin(myisam)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &myisam_hton,
- myisam_hton_name,
+ &myisam_storage_engine,
+ "MyISAM",
"MySQL AB",
- myisam_hton_comment,
- NULL, /* Plugin Init */
+ "Default engine as of MySQL 3.23 with great performance",
+ myisam_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100, /* 1.0 */
0
}
mysql_declare_plugin_end;
+
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index f4a052cea8a..b874923a077 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -38,47 +38,7 @@ static handler *myisammrg_create_handler(TABLE_SHARE *table);
/* MyISAM MERGE handlerton */
-static const char myisammrg_hton_name[]= "MRG_MYISAM";
-static const char myisammrg_hton_comment[]=
- "Collection of identical MyISAM tables";
-
-handlerton myisammrg_hton= {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- myisammrg_hton_name,
- SHOW_OPTION_YES,
- myisammrg_hton_comment,
- DB_TYPE_MRG_MYISAM,
- NULL,
- 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 */
- myisammrg_create_handler, /* Create a new handler */
- NULL, /* Drop a database */
- myrg_panic, /* Panic call */
- NULL, /* Start Consistent Snapshot */
- NULL, /* Flush logs */
- NULL, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill Files Table */
- HTON_CAN_RECREATE | HTON_ALTER_CANNOT_CREATE,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
+handlerton myisammrg_hton;
static handler *myisammrg_create_handler(TABLE_SHARE *table)
{
@@ -580,14 +540,27 @@ bool ha_myisammrg::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_NO;
}
+static int myisammrg_init()
+{
+ myisammrg_hton.state=SHOW_OPTION_YES;
+ myisammrg_hton.db_type=DB_TYPE_MRG_MYISAM;
+ myisammrg_hton.create=myisammrg_create_handler;
+ myisammrg_hton.panic=myrg_panic;
+ myisammrg_hton.flags= HTON_CAN_RECREATE | HTON_ALTER_CANNOT_CREATE;
+ return 0;
+}
+
+struct st_mysql_storage_engine myisammrg_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &myisammrg_hton };
+
mysql_declare_plugin(myisammrg)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &myisammrg_hton,
- myisammrg_hton_name,
+ &myisammrg_storage_engine,
+ "MRG_MYISAM",
"MySQL AB",
- myisammrg_hton_comment,
- NULL, /* Plugin Init */
+ "Collection of identical MyISAM tables",
+ myisammrg_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100, /* 1.0 */
0
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 89b9ed93d69..d62660343dc 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -63,26 +63,13 @@ static const int max_transactions= 3; // should really be 2 but there is a trans
static uint ndbcluster_partition_flags();
static uint ndbcluster_alter_table_flags(uint flags);
-static bool ndbcluster_init(void);
+static int ndbcluster_init(void);
static int ndbcluster_end(ha_panic_function flag);
static bool ndbcluster_show_status(THD*,stat_print_fn *,enum ha_stat_type);
static int ndbcluster_alter_tablespace(THD* thd, st_alter_tablespace *info);
static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond);
-static const char ndbcluster_hton_name[]= "ndbcluster";
-static const char ndbcluster_hton_comment[]= "Clustered, fault-tolerant tables";
-
-handlerton ndbcluster_hton = {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- "ndbcluster",
- SHOW_OPTION_YES,
- "Clustered, fault-tolerant tables",
- DB_TYPE_NDBCLUSTER,
- ndbcluster_init,
- ~(uint)0, /* slot */
- /* below are initialized by name in ndbcluster_init() */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
-};
+handlerton ndbcluster_hton;
static handler *ndbcluster_create_handler(TABLE_SHARE *table)
{
@@ -6080,17 +6067,18 @@ static int connect_callback()
}
extern int ndb_dictionary_is_mysqld;
-static bool ndbcluster_init()
+
+static int ndbcluster_init()
{
int res;
DBUG_ENTER("ndbcluster_init");
ndb_dictionary_is_mysqld= 1;
- if (have_ndbcluster != SHOW_OPTION_YES)
- goto ndbcluster_init_error;
{
handlerton &h= ndbcluster_hton;
+ h.state= have_ndbcluster;
+ h.db_type= DB_TYPE_NDBCLUSTER;
h.close_connection= ndbcluster_close_connection;
h.commit= ndbcluster_commit;
h.rollback= ndbcluster_rollback;
@@ -6108,6 +6096,9 @@ static bool ndbcluster_init()
h.flags= HTON_TEMPORARY_NOT_SUPPORTED;
}
+ if (have_ndbcluster != SHOW_OPTION_YES)
+ DBUG_RETURN(0); // nothing else to do
+
// Set connectstring if specified
if (opt_ndbcluster_connectstring != 0)
DBUG_PRINT("connectstring", ("%s", opt_ndbcluster_connectstring));
@@ -6179,7 +6170,7 @@ static bool ndbcluster_init()
if (ndbcluster_binlog_start())
goto ndbcluster_init_error;
#endif /* HAVE_NDB_BINLOG */
-
+
pthread_mutex_init(&LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_ndb_util_thread, NULL);
@@ -6195,7 +6186,7 @@ static bool ndbcluster_init()
pthread_cond_destroy(&COND_ndb_util_thread);
goto ndbcluster_init_error;
}
-
+
ndbcluster_inited= 1;
DBUG_RETURN(FALSE);
@@ -9356,9 +9347,8 @@ ndbcluster_show_status(THD* thd, stat_print_fn *stat_print,
ndb_connected_host,
ndb_connected_port,
ndb_number_of_storage_nodes);
- if (stat_print(thd, ndbcluster_hton.name, strlen(ndbcluster_hton.name),
- "connection", strlen("connection"),
- buf, buflen))
+ if (stat_print(thd, ndbcluster_hton_name, ndbcluster_hton_name_length,
+ STRING_WITH_LEN("connection"), buf, buflen))
DBUG_RETURN(TRUE);
if (get_thd_ndb(thd) && get_thd_ndb(thd)->ndb)
@@ -9372,7 +9362,7 @@ ndbcluster_show_status(THD* thd, stat_print_fn *stat_print,
my_snprintf(buf, sizeof(buf),
"created=%u, free=%u, sizeof=%u",
tmp.m_created, tmp.m_free, tmp.m_sizeof);
- if (stat_print(thd, ndbcluster_hton.name, strlen(ndbcluster_hton.name),
+ if (stat_print(thd, ndbcluster_hton_name, ndbcluster_hton_name_length,
tmp.m_name, strlen(tmp.m_name), buf, buflen))
DBUG_RETURN(TRUE);
}
@@ -10037,8 +10027,8 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond)
strlen(ts.getDefaultLogfileGroup()),
system_charset_info);
table->field[c++]->set_null(); // LOGFILE_GROUP_NUMBER
- table->field[c++]->store(ndbcluster_hton.name,
- strlen(ndbcluster_hton.name),
+ table->field[c++]->store(ndbcluster_hton_name,
+ ndbcluster_hton_name_length,
system_charset_info); // ENGINE
table->field[c++]->set_null(); // FULLTEXT_KEYS
@@ -10131,8 +10121,8 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond)
strlen(uf.getLogfileGroup()),
system_charset_info);
table->field[c++]->store(uf.getLogfileGroupId()); // LOGFILE_GROUP_NUMBER
- table->field[c++]->store(ndbcluster_hton.name,
- strlen(ndbcluster_hton.name),
+ table->field[c++]->store(ndbcluster_hton_name,
+ ndbcluster_hton_name_length,
system_charset_info); // ENGINE
table->field[c++]->set_null(); // FULLTEXT_KEYS
@@ -10178,15 +10168,17 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond)
DBUG_RETURN(0);
}
+struct st_mysql_storage_engine ndbcluster_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &ndbcluster_hton };
mysql_declare_plugin(ndbcluster)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &ndbcluster_hton,
+ &ndbcluster_storage_engine,
ndbcluster_hton_name,
"MySQL AB",
- ndbcluster_hton_comment,
- NULL, /* Plugin Init */
+ "Clustered, fault-tolerant tables",
+ ndbcluster_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
0
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index f407cb0090f..e2e8f04bf00 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -889,3 +889,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
int ndbcluster_table_exists_in_engine(THD* thd,
const char *db, const char *name);
void ndbcluster_print_error(int error, const NdbOperation *error_op);
+
+static const char ndbcluster_hton_name[]= "ndbcluster";
+static const int ndbcluster_hton_name_length=sizeof(ndbcluster_hton_name)-1;
+
diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc
index a125fd5e722..c2190e79bfc 100644
--- a/sql/ha_ndbcluster_binlog.cc
+++ b/sql/ha_ndbcluster_binlog.cc
@@ -2323,9 +2323,9 @@ ndbcluster_create_event(Ndb *ndb, const NDBTAB *ndbtab,
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_ILLEGAL_HA_CREATE_OPTION,
ER(ER_ILLEGAL_HA_CREATE_OPTION),
- ndbcluster_hton.name,
+ ndbcluster_hton_name,
"Binlog of table with BLOB attribute and no PK");
-
+
share->flags|= NSF_NO_BINLOG;
DBUG_RETURN(-1);
}
@@ -3688,7 +3688,7 @@ ndbcluster_show_status_binlog(THD* thd, stat_print_fn *stat_print,
ndb_latest_received_binlog_epoch,
ndb_latest_handled_binlog_epoch,
ndb_latest_applied_binlog_epoch);
- if (stat_print(thd, ndbcluster_hton.name, strlen(ndbcluster_hton.name),
+ if (stat_print(thd, ndbcluster_hton_name, ndbcluster_hton_name_length,
"binlog", strlen("binlog"),
buf, buflen))
DBUG_RETURN(TRUE);
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 7b9dd00ed56..2f69fb50a92 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -73,46 +73,18 @@ static handler *partition_create_handler(TABLE_SHARE *share);
static uint partition_flags();
static uint alter_table_flags(uint flags);
-static const char partition_hton_name[]= "partition";
-static const char partition_hton_comment[]= "Partition Storage Engine Helper";
-
-handlerton partition_hton = {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- partition_hton_name,
- SHOW_OPTION_YES,
- partition_hton_comment, /* A comment used by SHOW to describe an engine */
- DB_TYPE_PARTITION_DB,
- 0, /* Method that initializes a storage engine */
- 0, /* slot */
- 0, /* savepoint size */
- NULL /*ndbcluster_close_connection*/,
- NULL, /* savepoint_set */
- NULL, /* savepoint_rollback */
- NULL, /* savepoint_release */
- NULL /*ndbcluster_commit*/,
- NULL /*ndbcluster_rollback*/,
- NULL, /* prepare */
- NULL, /* recover */
- NULL, /* commit_by_xid */
- NULL, /* rollback_by_xid */
- NULL,
- NULL,
- NULL,
- partition_create_handler, /* Create a new handler */
- NULL, /* Drop a database */
- NULL, /* Panic call */
- NULL, /* Start Consistent Snapshot */
- NULL, /* Flush logs */
- NULL, /* Show status */
- partition_flags, /* Partition flags */
- alter_table_flags, /* Partition flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill FILES table */
- HTON_NOT_USER_SELECTABLE | HTON_HIDDEN,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
+handlerton partition_hton;
+
+static int partition_initialize()
+{
+ partition_hton.state= SHOW_OPTION_YES;
+ partition_hton.db_type= DB_TYPE_PARTITION_DB;
+ partition_hton.create= partition_create_handler;
+ partition_hton.partition_flags= partition_flags;
+ partition_hton.alter_table_flags= alter_table_flags;
+ partition_hton.flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN;
+ return 0;
+}
/*
Create new partition handler
@@ -5525,15 +5497,17 @@ static int free_share(PARTITION_SHARE *share)
}
#endif /* NOT_USED */
+struct st_mysql_storage_engine partition_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &partition_hton };
mysql_declare_plugin(partition)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &partition_hton,
- partition_hton_name,
+ &partition_storage_engine,
+ "partition",
"Mikael Ronstrom, MySQL AB",
- partition_hton_comment,
- NULL, /* Plugin Init */
+ "Partition Storage Engine Helper",
+ partition_initialize, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100, /* 1.0 */
0
diff --git a/sql/handler.cc b/sql/handler.cc
index b9ef05a33c2..22ce41decef 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -48,6 +48,7 @@
check for dups and to find handlerton from legacy_db_type.
Remove when legacy_db_type is finally gone */
static handlerton *installed_htons[128];
+st_mysql_plugin *hton2plugin[MAX_HA];
#define BITMAP_STACKBUF_SIZE (128/8)
@@ -57,35 +58,14 @@ KEY_CREATE_INFO default_key_create_info= { HA_KEY_ALG_UNDEF, 0, {NullS,0} };
static handler *create_default(TABLE_SHARE *table);
-const handlerton default_hton =
-{
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- "DEFAULT",
- SHOW_OPTION_YES,
- NULL,
- DB_TYPE_DEFAULT,
- NULL,
- 0, 0,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL,
- create_default,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, /* alter_tablespace */
- NULL, /* fill_files_table */
- HTON_NO_FLAGS, /* flags */
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
-
static SHOW_COMP_OPTION have_yes= SHOW_OPTION_YES;
/* number of entries in handlertons[] */
-ulong total_ha;
+ulong total_ha= 0;
/* number of storage engines (from handlertons[]) that support 2pc */
-ulong total_ha_2pc;
+ulong total_ha_2pc= 0;
/* size of savepoint storage area (see ha_init) */
-ulong savepoint_alloc_size;
+ulong savepoint_alloc_size= 0;
struct show_table_alias_st sys_table_aliases[]=
{
@@ -122,7 +102,7 @@ handlerton *ha_resolve_by_name(THD *thd, LEX_STRING *name)
if ((plugin= plugin_lock(name, MYSQL_STORAGE_ENGINE_PLUGIN)))
{
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (!(hton->flags & HTON_NOT_USER_SELECTABLE))
return hton;
plugin_unlock(plugin);
@@ -155,7 +135,7 @@ const char *ha_get_storage_engine(enum legacy_db_type db_type)
default:
if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT &&
installed_htons[db_type])
- return installed_htons[db_type]->name;
+ return hton2plugin[installed_htons[db_type]->slot]->name;
return "*NONE*";
}
}
@@ -164,8 +144,7 @@ const char *ha_get_storage_engine(enum legacy_db_type db_type)
static handler *create_default(TABLE_SHARE *table)
{
handlerton *hton=ha_resolve_by_legacy_type(current_thd, DB_TYPE_DEFAULT);
- return (hton && hton != &default_hton && hton->create) ?
- hton->create(table) : NULL;
+ return (hton && hton->create) ? hton->create(table) : NULL;
}
@@ -183,7 +162,7 @@ handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type)
default:
if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT)
return installed_htons[db_type];
- return NULL;
+ return NULL;
}
}
@@ -375,7 +354,7 @@ int ha_finalize_handlerton(st_plugin_int *plugin)
handlerton *hton;
DBUG_ENTER("ha_finalize_handlerton");
- if (!(hton= (handlerton *) plugin->plugin->info))
+ if (!(hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton))
DBUG_RETURN(1);
switch (hton->state)
@@ -396,37 +375,26 @@ int ha_finalize_handlerton(st_plugin_int *plugin)
int ha_initialize_handlerton(st_plugin_int *plugin)
{
- handlerton *hton;
- DBUG_ENTER("ha_initialize_handlerton");
-
- if (!(hton= (handlerton *) plugin->plugin->info))
- DBUG_RETURN(1);
-
- /* for the sake of sanity, we set the handlerton name to be the
- same as the plugin name */
- hton->name= plugin->name.str;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
+ DBUG_ENTER("ha_initialize_handlerton");
+ /*
+ the switch below and hton->state should be removed when
+ command-line options for plugins will be implemented
+ */
switch (hton->state) {
case SHOW_OPTION_NO:
break;
case SHOW_OPTION_YES:
- if (!hton->init || !hton->init())
{
- uint tmp= hton->savepoint_offset;
- hton->savepoint_offset= savepoint_alloc_size;
- savepoint_alloc_size+= tmp;
- hton->slot= total_ha++;
- if (hton->prepare)
- total_ha_2pc++;
-
/* now check the db_type for conflict */
- if (hton->db_type <= DB_TYPE_UNKNOWN ||
+ if (hton->db_type <= DB_TYPE_UNKNOWN ||
hton->db_type >= DB_TYPE_DEFAULT ||
installed_htons[hton->db_type])
{
int idx= (int) DB_TYPE_FIRST_DYNAMIC;
-
+
while (idx < (int) DB_TYPE_DEFAULT && installed_htons[idx])
idx++;
@@ -437,10 +405,17 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
}
if (hton->db_type != DB_TYPE_UNKNOWN)
sql_print_warning("Storage engine '%s' has conflicting typecode. "
- "Assigning value %d.", hton->name, idx);
+ "Assigning value %d.", plugin->plugin->name, idx);
hton->db_type= (enum legacy_db_type) idx;
}
installed_htons[hton->db_type]= hton;
+ uint tmp= hton->savepoint_offset;
+ hton->savepoint_offset= savepoint_alloc_size;
+ savepoint_alloc_size+= tmp;
+ hton->slot= total_ha++;
+ hton2plugin[hton->slot]=plugin->plugin;
+ if (hton->prepare)
+ total_ha_2pc++;
break;
}
/* fall through */
@@ -451,33 +426,14 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
DBUG_RETURN(0);
}
-
-static my_bool init_handlerton(THD *unused1, st_plugin_int *plugin,
- void *unused2)
-{
- if (plugin->state == PLUGIN_IS_UNINITIALIZED)
- {
- ha_initialize_handlerton(plugin);
- plugin->state= PLUGIN_IS_READY;
- }
- return FALSE;
-}
-
-
int ha_init()
{
int error= 0;
- total_ha= savepoint_alloc_size= 0;
DBUG_ENTER("ha_init");
- bzero(installed_htons, sizeof(installed_htons));
-
if (ha_init_errors())
DBUG_RETURN(1);
- if (plugin_foreach(NULL, init_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, 0))
- DBUG_RETURN(1);
-
DBUG_ASSERT(total_ha < MAX_HA);
/*
Check if there is a transaction-capable storage engine besides the
@@ -498,7 +454,7 @@ int ha_init()
static my_bool panic_handlerton(THD *unused1, st_plugin_int *plugin,
void *arg)
{
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->panic)
((int*)arg)[0]|= hton->panic((enum ha_panic_function)((int*)arg)[1]);
return FALSE;
@@ -508,10 +464,10 @@ static my_bool panic_handlerton(THD *unused1, st_plugin_int *plugin,
int ha_panic(enum ha_panic_function flag)
{
int error[2];
-
+
error[0]= 0; error[1]= (int)flag;
plugin_foreach(NULL, panic_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, error);
-
+
if (flag == HA_PANIC_CLOSE && ha_finish_errors())
error[0]= 1;
return error[0];
@@ -520,7 +476,7 @@ int ha_panic(enum ha_panic_function flag)
static my_bool dropdb_handlerton(THD *unused1, st_plugin_int *plugin,
void *path)
{
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->drop_database)
hton->drop_database((char *)path);
return FALSE;
@@ -536,8 +492,8 @@ void ha_drop_database(char* path)
static my_bool closecon_handlerton(THD *thd, st_plugin_int *plugin,
void *unused)
{
- handlerton *hton= (handlerton *) plugin->plugin->info;
- /* there's no need to rollback here as all transactions must
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
+ /* there's no need to rollback here as all transactions must
be rolled back already */
if (hton->state == SHOW_OPTION_YES && hton->close_connection &&
thd->ha_data[hton->slot])
@@ -628,7 +584,8 @@ int ha_prepare(THD *thd)
else
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), (*ht)->name);
+ ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
+ hton2plugin[(*ht)->slot]->name);
}
}
}
@@ -867,7 +824,7 @@ struct xahton_st {
static my_bool xacommit_handlerton(THD *unused1, st_plugin_int *plugin,
void *arg)
{
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->recover)
{
hton->commit_by_xid(((struct xahton_st *)arg)->xid);
@@ -879,7 +836,7 @@ static my_bool xacommit_handlerton(THD *unused1, st_plugin_int *plugin,
static my_bool xarollback_handlerton(THD *unused1, st_plugin_int *plugin,
void *arg)
{
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->recover)
{
hton->rollback_by_xid(((struct xahton_st *)arg)->xid);
@@ -986,16 +943,16 @@ struct xarecover_st
static my_bool xarecover_handlerton(THD *unused, st_plugin_int *plugin,
void *arg)
{
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
struct xarecover_st *info= (struct xarecover_st *) arg;
int got;
-
+
if (hton->state == SHOW_OPTION_YES && hton->recover)
{
while ((got= hton->recover(info->list, info->len)) > 0 )
{
sql_print_information("Found %d prepared transaction(s) in %s",
- got, hton->name);
+ got, hton2plugin[hton->slot]->name);
for (int i=0; i < got; i ++)
{
my_xid x=info->list[i].get_my_xid();
@@ -1175,7 +1132,7 @@ bool mysql_xa_recover(THD *thd)
static my_bool release_temporary_latches(THD *thd, st_plugin_int *plugin,
void *unused)
{
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->release_temporary_latches)
hton->release_temporary_latches(thd);
@@ -1300,7 +1257,7 @@ int ha_release_savepoint(THD *thd, SAVEPOINT *sv)
static my_bool snapshot_handlerton(THD *thd, st_plugin_int *plugin,
void *arg)
{
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES &&
hton->start_consistent_snapshot)
{
@@ -1331,7 +1288,7 @@ int ha_start_consistent_snapshot(THD *thd)
static my_bool flush_handlerton(THD *thd, st_plugin_int *plugin,
void *arg)
{
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->flush_logs && hton->flush_logs())
return TRUE;
return FALSE;
@@ -2635,7 +2592,7 @@ struct binlog_func_st
static my_bool binlog_func_list(THD *thd, st_plugin_int *plugin, void *arg)
{
hton_list_st *hton_list= (hton_list_st *)arg;
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->binlog_func)
{
uint sz= hton_list->sz;
@@ -3006,7 +2963,7 @@ int handler::index_read_idx(byte * buf, uint index, const byte * key,
SYNOPSIS
ha_known_exts()
-
+
NOTES
No mutexes, worst case race is a minor surplus memory allocation
We have to recreate the extension map if mysqld is restarted (for example
@@ -3020,14 +2977,14 @@ static my_bool exts_handlerton(THD *unused, st_plugin_int *plugin,
void *arg)
{
List<char> *found_exts= (List<char> *) arg;
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
handler *file;
if (hton->state == SHOW_OPTION_YES && hton->create &&
(file= hton->create((TABLE_SHARE*) 0)))
{
List_iterator_fast<char> it(*found_exts);
const char **ext, *old_ext;
-
+
for (ext= file->bas_ext(); *ext; ext++)
{
while ((old_ext= it++))
@@ -3056,14 +3013,14 @@ 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);
-
- plugin_foreach(NULL, exts_handlerton,
+
+ plugin_foreach(NULL, exts_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, &found_exts);
ext= (const char **) my_once_alloc(sizeof(char *)*
(found_exts.elements+1),
MYF(MY_WME | MY_FAE));
-
+
DBUG_ASSERT(ext != 0);
known_extensions.count= found_exts.elements;
known_extensions.type_names= ext;
@@ -3096,7 +3053,7 @@ static my_bool showstat_handlerton(THD *thd, st_plugin_int *plugin,
void *arg)
{
enum ha_stat_type stat= *(enum ha_stat_type *) arg;
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->show_status &&
hton->show_status(thd, stat_print, stat))
return TRUE;
@@ -3119,16 +3076,19 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat)
if (db_type == NULL)
{
- result= plugin_foreach(thd, showstat_handlerton,
+ result= plugin_foreach(thd, showstat_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, &stat);
}
else
{
if (db_type->state != SHOW_OPTION_YES)
- result= stat_print(thd, db_type->name, strlen(db_type->name),
+ {
+ const char *name=hton2plugin[db_type->slot]->name;
+ result= stat_print(thd, name, strlen(name),
"", 0, "DISABLED", 8) ? 1 : 0;
+ }
else
- result= db_type->show_status &&
+ result= db_type->show_status &&
db_type->show_status(thd, stat_print, stat) ? 1 : 0;
}
diff --git a/sql/handler.h b/sql/handler.h
index afee6bb9f8d..83143d9729d 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -177,6 +177,7 @@
so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
example + csv + heap + blackhole + federated + 0
(yes, the sum is deliberately inaccurate)
+ TODO remove the limit, use dynarrays
*/
#define MAX_HA 15
@@ -460,6 +461,7 @@ typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len,
const char *file, uint file_len,
const char *status, uint status_len);
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
+extern st_mysql_plugin *hton2plugin[MAX_HA];
/*
handlerton is a singleton structure - one instance per storage engine -
@@ -475,38 +477,15 @@ enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
struct handlerton
{
/*
- handlerton structure version
- */
- const int interface_version;
-/* last version change: 0x0001 in 5.1.6 */
-#define MYSQL_HANDLERTON_INTERFACE_VERSION 0x0001
-
-
- /*
- storage engine name as it should be printed to a user
- */
- const char *name;
-
- /*
- Historical marker for if the engine is available of not
+ 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 legacy_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.
@@ -587,8 +566,6 @@ struct handlerton
int (*release_temporary_latches)(THD *thd);
};
-extern const handlerton default_hton;
-
struct show_table_alias_st {
const char *alias;
enum legacy_db_type type;
@@ -1552,7 +1529,7 @@ static inline enum legacy_db_type ha_legacy_type(const handlerton *db_type)
static inline const char *ha_resolve_storage_engine_name(const handlerton *db_type)
{
- return db_type == NULL ? "UNKNOWN" : db_type->name;
+ return db_type == NULL ? "UNKNOWN" : hton2plugin[db_type->slot]->name;
}
static inline bool ha_check_storage_engine_flag(const handlerton *db_type, uint32 flag)
diff --git a/sql/log.cc b/sql/log.cc
index 7c8f314bc08..1f8bb5f0b69 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -47,7 +47,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_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);
@@ -70,49 +70,7 @@ struct binlog_trx_data {
Rows_log_event *pending; // The pending binrows event
};
-static const char binlog_hton_name[]= "binlog";
-static const char binlog_hton_comment[]=
- "This is a meta storage engine to represent the binlog in a transaction";
-
-handlerton binlog_hton = {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- binlog_hton_name,
- SHOW_OPTION_YES,
- binlog_hton_comment,
- DB_TYPE_BINLOG, /* IGNORE for now */
- binlog_init,
- 0,
- sizeof(my_off_t), /* savepoint size = binlog offset */
- binlog_close_connection,
- binlog_savepoint_set,
- binlog_savepoint_rollback,
- NULL, /* savepoint_release */
- binlog_commit,
- binlog_rollback,
- binlog_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 */
- NULL, /* Create a new handler */
- NULL, /* Drop a database */
- NULL, /* Panic call */
- NULL, /* Start Consistent Snapshot */
- NULL, /* Flush logs */
- NULL, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill FILES table */
- HTON_NOT_USER_SELECTABLE | HTON_HIDDEN,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
-
-
+handlerton binlog_hton;
/*
Open log table of a given type (general or slow log)
@@ -1058,9 +1016,20 @@ void Log_to_csv_event_handler::
should be moved here.
*/
-bool binlog_init()
+int binlog_init()
{
- return !opt_bin_log;
+
+ binlog_hton.state=opt_bin_log ? SHOW_OPTION_YES : SHOW_OPTION_NO;
+ binlog_hton.db_type=DB_TYPE_BINLOG;
+ binlog_hton.savepoint_offset= sizeof(my_off_t);
+ binlog_hton.close_connection= binlog_close_connection;
+ binlog_hton.savepoint_set= binlog_savepoint_set;
+ binlog_hton.savepoint_rollback= binlog_savepoint_rollback;
+ binlog_hton.commit= binlog_commit;
+ binlog_hton.rollback= binlog_rollback;
+ binlog_hton.prepare= binlog_prepare;
+ binlog_hton.flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN;
+ return 0;
}
static int binlog_close_connection(THD *thd)
@@ -4354,15 +4323,17 @@ err1:
return 1;
}
+struct st_mysql_storage_engine binlog_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &binlog_hton };
mysql_declare_plugin(binlog)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &binlog_hton,
- binlog_hton_name,
+ &binlog_storage_engine,
+ "binlog",
"MySQL AB",
- binlog_hton_comment,
- NULL, /* Plugin Init */
+ "This is a pseudo storage engine to represent the binlog in a transaction",
+ binlog_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
}
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 127aa6c5acd..5dea2473fa0 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -502,13 +502,13 @@ typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key,
#include "sql_list.h"
#include "sql_map.h"
#include "my_decimal.h"
+#include "sql_plugin.h"
#include "handler.h"
#include "parse_file.h"
#include "table.h"
#include "sql_error.h"
#include "field.h" /* Field definitions */
#include "protocol.h"
-#include "sql_plugin.h"
#include "sql_udf.h"
#include "sql_partition.h"
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 0c02971a2bc..fa8b80bf9b6 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -330,7 +330,7 @@ static char *opt_init_slave, *language_ptr, *opt_init_connect;
static char *default_character_set_name;
static char *character_set_filesystem_name;
static char *my_bind_addr_str;
-static char *default_collation_name;
+static char *default_collation_name, *default_storage_engine_str;
static char mysql_data_home_buff[2];
static struct passwd *user_info;
static I_List<THD> thread_cache;
@@ -2630,12 +2630,6 @@ static int init_common_variables(const char *conf_file_name, int argc,
if (add_status_vars(status_vars))
return 1; // an error was already reported
- if (plugin_init())
- {
- sql_print_error("Failed to init plugins.");
- return 1;
- }
-
load_defaults(conf_file_name, groups, &argc, &argv);
defaults_argv=argv;
get_options(argc,argv);
@@ -3151,6 +3145,12 @@ server.");
using_update_log=1;
}
+ if (plugin_init())
+ {
+ sql_print_error("Failed to init plugins.");
+ return 1;
+ }
+
/* We have to initialize the storage engines before CSV logging */
if (ha_init())
{
@@ -3197,15 +3197,27 @@ server.");
/*
Check that the default storage engine is actually available.
*/
- if (!ha_storage_engine_is_enabled(global_system_variables.table_type))
{
- if (!opt_bootstrap)
+ LEX_STRING name= { default_storage_engine_str,
+ strlen(default_storage_engine_str) };
+ handlerton *hton= ha_resolve_by_name(0, &name);
+ if (hton == NULL)
{
- sql_print_error("Default storage engine (%s) is not available",
- global_system_variables.table_type->name);
+ sql_print_error("Unknown/unsupported table type: %s",
+ default_storage_engine_str);
unireg_abort(1);
}
- global_system_variables.table_type= &myisam_hton;
+ if (!ha_storage_engine_is_enabled(hton))
+ {
+ if (!opt_bootstrap)
+ {
+ sql_print_error("Default storage engine (%s) is not available",
+ default_storage_engine_str);
+ unireg_abort(1);
+ }
+ hton= &myisam_hton;
+ }
+ global_system_variables.table_type= hton;
}
tc_log= (total_ha_2pc > 1 ? (opt_bin_log ?
@@ -4951,7 +4963,8 @@ Disable with --skip-bdb (will save memory).",
"Set the default storage engine (table type) for tables.", 0, 0,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"default-table-type", OPT_STORAGE_ENGINE,
- "(deprecated) Use --default-storage-engine.", 0, 0,
+ "(deprecated) Use --default-storage-engine.",
+ (gptr*)default_storage_engine_str, (gptr*)default_storage_engine_str,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"default-time-zone", OPT_DEFAULT_TIME_ZONE, "Set the default time zone.",
(gptr*) &default_tz_name, (gptr*) &default_tz_name,
@@ -6980,8 +6993,8 @@ static void mysql_init_variables(void)
sys_charset_system.value= (char*) system_charset_info->csname;
character_set_filesystem_name= (char*) "binary";
-
/* Set default values for some option variables */
+ default_storage_engine_str="MyISAM";
global_system_variables.table_type= &myisam_hton;
global_system_variables.tx_isolation= ISO_REPEATABLE_READ;
global_system_variables.select_limit= (ulonglong) HA_POS_ERROR;
@@ -7423,17 +7436,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_BOOTSTRAP:
opt_noacl=opt_bootstrap=1;
break;
- case OPT_STORAGE_ENGINE:
- {
- LEX_STRING name= { argument, strlen(argument) };
- if ((global_system_variables.table_type=
- ha_resolve_by_name(current_thd, &name)) == NULL)
- {
- fprintf(stderr,"Unknown/unsupported table type: %s\n",argument);
- exit(1);
- }
- break;
- }
case OPT_SERVER_ID:
server_id_supplied = 1;
break;
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 57eeeed46e1..c69d5505a8f 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -3250,7 +3250,7 @@ byte *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
handlerton *val;
val= (type == OPT_GLOBAL) ? global_system_variables.*offset :
thd->variables.*offset;
- return (byte *) val->name;
+ return (byte *) hton2plugin[val->slot]->name;
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 6bba78a836e..8d45cbcad2c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -7104,7 +7104,7 @@ bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
HA_CREATE_INFO create_info;
DBUG_ENTER("mysql_create_index");
bzero((char*) &create_info,sizeof(create_info));
- create_info.db_type= (handlerton*) &default_hton;
+ create_info.db_type= 0;
create_info.default_table_charset= thd->variables.collation_database;
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
&create_info, table_list,
@@ -7120,7 +7120,7 @@ bool mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info)
HA_CREATE_INFO create_info;
DBUG_ENTER("mysql_drop_index");
bzero((char*) &create_info,sizeof(create_info));
- create_info.db_type= (handlerton*) &default_hton;
+ create_info.db_type= 0;
create_info.default_table_charset= thd->variables.collation_database;
alter_info->clear();
alter_info->flags= ALTER_DROP_INDEX;
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index e946e972968..03dfe378ec2 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -1665,7 +1665,7 @@ static int add_keyword_int(File fptr, const char *keyword, longlong num)
static int add_engine(File fptr, handlerton *engine_type)
{
- const char *engine_str= engine_type->name;
+ const char *engine_str= hton2plugin[engine_type->slot]->name;
DBUG_PRINT("info", ("ENGINE = %s", engine_str));
int err= add_string(fptr, "ENGINE = ");
return err + add_string(fptr, engine_str);
@@ -3559,17 +3559,9 @@ static bool check_engine_condition(partition_element *p_elem,
DBUG_ENTER("check_engine_condition");
DBUG_PRINT("enter", ("def_eng = %u, first = %u", default_engine, *first));
- if (*engine_type)
- DBUG_PRINT("info", ("engine_type = %s", (*engine_type)->name));
- else
- DBUG_PRINT("info", ("engine_type = NULL"));
if (*first && default_engine)
{
*engine_type= p_elem->engine_type;
- if (*engine_type)
- DBUG_PRINT("info", ("engine_type changed to = %s", (*engine_type)->name));
- else
- DBUG_PRINT("info", ("engine_type changed to = NULL"));
}
*first= FALSE;
if ((!default_engine &&
@@ -4524,7 +4516,7 @@ the generated partition syntax in a correct manner.
create_info->db_type= table->part_info->default_engine_type;
}
DBUG_PRINT("info", ("New engine type = %s",
- create_info->db_type->name));
+ hton2plugin[create_info->db_type->slot]->name));
thd->work_part_info= NULL;
*partition_changed= TRUE;
}
@@ -4586,11 +4578,9 @@ the generated partition syntax in a correct manner.
}
if (!is_native_partitioned)
{
- DBUG_ASSERT(create_info->db_type != &default_hton);
+ DBUG_ASSERT(create_info->db_type);
create_info->db_type= &partition_hton;
}
- DBUG_PRINT("info", ("default_engine_type = %s",
- thd->work_part_info->default_engine_type->name));
}
}
DBUG_RETURN(FALSE);
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 01faae22c57..d06a682bdce 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -23,12 +23,18 @@ extern struct st_mysql_plugin *mysqld_builtins[];
char *opt_plugin_dir_ptr;
char opt_plugin_dir[FN_REFLEN];
-LEX_STRING plugin_type_names[]=
+LEX_STRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]=
{
{ (char *)STRING_WITH_LEN("UDF") },
{ (char *)STRING_WITH_LEN("STORAGE ENGINE") },
{ (char *)STRING_WITH_LEN("FTPARSER") }
};
+
+plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
+{
+ 0,ha_initialize_handlerton,0
+};
+
static const char *plugin_interface_version_sym=
"_mysql_plugin_interface_version_";
static const char *sizeof_st_plugin_sym=
@@ -522,27 +528,15 @@ static int plugin_initialize(struct st_plugin_int *plugin)
{
sql_print_error("Plugin '%s' init function returned error.",
plugin->name.str);
- DBUG_PRINT("warning", ("Plugin '%s' init function returned error.",
- plugin->name.str));
goto err;
}
}
-
- switch (plugin->plugin->type)
+ if (plugin_type_initialize[plugin->plugin->type] &&
+ (*plugin_type_initialize[plugin->plugin->type])(plugin))
{
- case MYSQL_STORAGE_ENGINE_PLUGIN:
- if (ha_initialize_handlerton(plugin))
- {
- sql_print_error("Plugin '%s' handlerton init returned error.",
- plugin->name.str);
- DBUG_PRINT("warning", ("Plugin '%s' handlerton init returned error.",
- plugin->name.str));
- goto err;
- }
- break;
-
- default:
- break;
+ sql_print_error("Plugin '%s' registration as a %s failed.",
+ plugin->name.str, plugin_type_names[plugin->plugin->type]);
+ goto err;
}
DBUG_RETURN(0);
@@ -554,14 +548,14 @@ static int plugin_finalize(THD *thd, struct st_plugin_int *plugin)
{
int rc;
DBUG_ENTER("plugin_finalize");
-
+
if (plugin->ref_count)
{
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
"Plugin is busy and will be uninstalled on shutdown");
goto err;
}
-
+
switch (plugin->plugin->type)
{
case MYSQL_STORAGE_ENGINE_PLUGIN:
@@ -591,7 +585,7 @@ static int plugin_finalize(THD *thd, struct st_plugin_int *plugin)
goto err;
}
}
-
+
DBUG_RETURN(0);
err:
DBUG_RETURN(1);
@@ -676,7 +670,7 @@ int plugin_init(void)
get_hash_key, NULL, 0))
goto err;
}
-
+
/* Register all the built-in plugins */
for (builtins= mysqld_builtins; *builtins; builtins++)
{
@@ -684,6 +678,12 @@ int plugin_init(void)
{
if (plugin_register_builtin(plugin))
goto err;
+ struct st_plugin_int *tmp=dynamic_element(&plugin_array,
+ plugin_array.elements-1,
+ struct st_plugin_int *);
+ if (plugin_initialize(tmp))
+ goto err;
+ tmp->state= PLUGIN_IS_READY;
}
}
diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h
index 672db105cd1..8459346fb53 100644
--- a/sql/sql_plugin.h
+++ b/sql/sql_plugin.h
@@ -61,6 +61,8 @@ struct st_plugin_int
uint ref_count; /* number of threads using the plugin */
};
+typedef int (*plugin_type_init)(struct st_plugin_int *);
+
extern char *opt_plugin_dir_ptr;
extern char opt_plugin_dir[FN_REFLEN];
extern LEX_STRING plugin_type_names[];
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 5fad0c7e09b..d8ae1bc1abb 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -46,7 +46,7 @@ static void store_key_options(THD *thd, String *packet, TABLE *table,
KEY *key_info);
/***************************************************************************
-** List all table types supported
+** List all table types supported
***************************************************************************/
static my_bool show_handlerton(THD *thd, st_plugin_int *plugin,
@@ -54,25 +54,25 @@ static my_bool show_handlerton(THD *thd, st_plugin_int *plugin,
{
handlerton *default_type= (handlerton *) arg;
Protocol *protocol= thd->protocol;
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (!(hton->flags & HTON_HIDDEN))
{
protocol->prepare_for_resend();
- protocol->store(hton->name, system_charset_info);
+ protocol->store(plugin->plugin->name, system_charset_info);
const char *option_name= show_comp_option_name[(int) hton->state];
if (hton->state == SHOW_OPTION_YES && default_type == hton)
option_name= "DEFAULT";
protocol->store(option_name, system_charset_info);
- protocol->store(hton->comment, system_charset_info);
+ protocol->store(plugin->plugin->descr, system_charset_info);
protocol->store(hton->commit ? "YES" : "NO", system_charset_info);
protocol->store(hton->prepare ? "YES" : "NO", system_charset_info);
protocol->store(hton->savepoint_set ? "YES" : "NO", system_charset_info);
-
+
return protocol->write() ? 1 : 0;
}
- return 0;
+ return 0;
}
bool mysqld_show_storage_engines(THD *thd)
@@ -92,7 +92,7 @@ bool mysqld_show_storage_engines(THD *thd)
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
- if (plugin_foreach(thd, show_handlerton,
+ if (plugin_foreach(thd, show_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, thd->variables.table_type))
DBUG_RETURN(TRUE);
@@ -3055,7 +3055,7 @@ static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin,
void *ptable)
{
TABLE *table= (TABLE *) ptable;
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
CHARSET_INFO *scs= system_charset_info;
DBUG_ENTER("iter_schema_engines");
@@ -3063,21 +3063,26 @@ static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin,
if (!(hton->flags & HTON_HIDDEN))
{
if (!(wild && wild[0] &&
- wild_case_compare(scs, hton->name,wild)))
+ wild_case_compare(scs, plugin->plugin->name,wild)))
{
- const char *tmp;
+ LEX_STRING state[2]={{STRING_WITH_LEN("ENABLED")},
+ {STRING_WITH_LEN("DISABLED")}};
+ LEX_STRING yesno[2]={{STRING_WITH_LEN("NO")}, {STRING_WITH_LEN("YES")}};
+ LEX_STRING *tmp;
restore_record(table, s->default_values);
- table->field[0]->store(hton->name, strlen(hton->name), scs);
- tmp= hton->state ? "DISABLED" : "ENABLED";
- table->field[1]->store( tmp, strlen(tmp), scs);
- table->field[2]->store(hton->comment, strlen(hton->comment), scs);
- tmp= hton->commit ? "YES" : "NO";
- table->field[3]->store( tmp, strlen(tmp), scs);
- tmp= hton->prepare ? "YES" : "NO";
- table->field[4]->store( tmp, strlen(tmp), scs);
- tmp= hton->savepoint_set ? "YES" : "NO";
- table->field[5]->store( tmp, strlen(tmp), scs);
+ table->field[0]->store(plugin->plugin->name,
+ strlen(plugin->plugin->name), scs);
+ tmp= &state[test(hton->state)];
+ table->field[1]->store(tmp->str, tmp->length, scs);
+ table->field[2]->store(plugin->plugin->descr,
+ strlen(plugin->plugin->descr), scs);
+ tmp= &yesno[test(hton->commit)];
+ table->field[3]->store(tmp->str, tmp->length, scs);
+ tmp= &yesno[test(hton->prepare)];
+ table->field[4]->store(tmp->str, tmp->length, scs);
+ tmp= &yesno[test(hton->savepoint_set)];
+ table->field[5]->store(tmp->str, tmp->length, scs);
if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
@@ -3089,7 +3094,7 @@ static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin,
int fill_schema_engines(THD *thd, TABLE_LIST *tables, COND *cond)
{
- return plugin_foreach(thd, iter_schema_engines,
+ return plugin_foreach(thd, iter_schema_engines,
MYSQL_STORAGE_ENGINE_PLUGIN, tables->table);
}
@@ -3104,7 +3109,7 @@ int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond)
{
CHARSET_INFO **cl;
CHARSET_INFO *tmp_cs= cs[0];
- if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
+ if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
(tmp_cs->state & MY_CS_HIDDEN) ||
!(tmp_cs->state & MY_CS_PRIMARY))
continue;
@@ -4839,7 +4844,7 @@ static my_bool run_hton_fill_schema_files(THD *thd, st_plugin_int *plugin,
{
struct run_hton_fill_schema_files_args *args=
(run_hton_fill_schema_files_args *) arg;
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if(hton->fill_files_table)
hton->fill_files_table(thd, args->tables, args->cond);
return false;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 37506d11867..f06554979db 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -5085,7 +5085,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
old_db_type= table->s->db_type;
- if (create_info->db_type == (handlerton*) &default_hton)
+ if (!create_info->db_type)
create_info->db_type= old_db_type;
#ifdef WITH_PARTITION_STORAGE_ENGINE
@@ -6398,7 +6398,7 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list,
lex->col_list.empty();
lex->alter_info.reset();
bzero((char*) &create_info,sizeof(create_info));
- create_info.db_type= (handlerton*) &default_hton;
+ create_info.db_type= 0;
create_info.row_type=ROW_TYPE_NOT_USED;
create_info.default_table_charset=default_charset_info;
/* Force alter table to recreate table */
@@ -6542,7 +6542,7 @@ static bool check_engine(THD *thd, const char *table_name,
no_substitution, 1)))
return TRUE;
- if (req_engine != (handlerton*) &default_hton && req_engine != *new_engine)
+ if (req_engine && req_engine != *new_engine)
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_USING_OTHER_HANDLER,
@@ -6555,7 +6555,8 @@ static bool check_engine(THD *thd, const char *table_name,
{
if (create_info->used_fields & HA_CREATE_USED_ENGINE)
{
- my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0), (*new_engine)->name, "TEMPORARY");
+ my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0),
+ hton2plugin[(*new_engine)->slot]->name, "TEMPORARY");
*new_engine= 0;
return TRUE;
}
diff --git a/sql/sql_tablespace.cc b/sql/sql_tablespace.cc
index 8bc39ec82c6..84e2b9c7d04 100644
--- a/sql/sql_tablespace.cc
+++ b/sql/sql_tablespace.cc
@@ -28,16 +28,16 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
If the user haven't defined an engine, this will fallback to using the
default storage engine.
*/
- if (hton == NULL || hton == &default_hton || hton->state != SHOW_OPTION_YES)
+ if (hton == NULL || hton->state != SHOW_OPTION_YES)
{
hton= ha_resolve_by_legacy_type(thd, DB_TYPE_DEFAULT);
if (ts_info->storage_engine != 0)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_WARN_USING_OTHER_HANDLER,
ER(ER_WARN_USING_OTHER_HANDLER),
- hton->name,
- ts_info->tablespace_name
- ? ts_info->tablespace_name : ts_info->logfile_group_name);
+ hton2plugin[hton->slot]->name,
+ ts_info->tablespace_name ? ts_info->tablespace_name
+ : ts_info->logfile_group_name);
}
if (hton->alter_tablespace)
@@ -64,7 +64,7 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_ILLEGAL_HA_CREATE_OPTION,
ER(ER_ILLEGAL_HA_CREATE_OPTION),
- hton->name,
+ hton2plugin[hton->slot]->name,
"TABLESPACE or LOGFILE GROUP");
}
if (mysql_bin_log.is_open())
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 31ef2d8907e..8cced1c47f8 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -3099,11 +3099,11 @@ opt_ts_engine:
"STORAGE ENGINE");
YYABORT;
}
- lex->alter_tablespace_info->storage_engine= $4 ? $4 : &default_hton;
+ lex->alter_tablespace_info->storage_engine= $4;
};
opt_ts_wait:
- /* empty */
+ /* empty */
| ts_wait
;
@@ -3939,12 +3939,18 @@ storage_engines:
ident_or_text
{
$$ = ha_resolve_by_name(YYTHD, &$1);
- if ($$ == NULL &&
- test(YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION))
+ if ($$ == NULL)
+ if (YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION)
{
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
YYABORT;
}
+ else
+ {
+ push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_UNKNOWN_STORAGE_ENGINE,
+ ER(ER_UNKNOWN_STORAGE_ENGINE), $1.str);
+ }
};
row_types:
@@ -4621,7 +4627,7 @@ alter:
lex->select_lex.db=lex->name= 0;
lex->like_name= 0;
bzero((char*) &lex->create_info,sizeof(lex->create_info));
- lex->create_info.db_type= (handlerton*) &default_hton;
+ lex->create_info.db_type= 0;
lex->create_info.default_table_charset= NULL;
lex->create_info.row_type= ROW_TYPE_NOT_USED;
lex->alter_info.reset();