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
This commit is contained in:
serg@sergbook.mysql.com 2006-05-28 14:51:01 +02:00
parent 9c26c629a2
commit fe97dbb587
35 changed files with 459 additions and 850 deletions

View File

@ -28,7 +28,7 @@
*/ */
#define MYSQL_UDF_PLUGIN 0 /* User-defined function */ #define MYSQL_UDF_PLUGIN 0 /* User-defined function */
#define MYSQL_STORAGE_ENGINE_PLUGIN 1 /* Storage Engine */ #define MYSQL_STORAGE_ENGINE_PLUGIN 1 /* Storage Engine */
#define MYSQL_FTPARSER_PLUGIN 2 /* Full-text [pre]parser */ #define MYSQL_FTPARSER_PLUGIN 2 /* Full-text parser plugin */
#define MYSQL_MAX_PLUGIN_TYPE_NUM 3 /* The number of plugin types */ #define MYSQL_MAX_PLUGIN_TYPE_NUM 3 /* The number of plugin types */
/* /*
@ -95,7 +95,7 @@ struct st_mysql_plugin
}; };
/************************************************************************* /*************************************************************************
API for Full-text [pre]parser plugin. (MYSQL_FTPARSER_PLUGIN) API for Full-text parser plugin. (MYSQL_FTPARSER_PLUGIN)
*/ */
#define MYSQL_FTPARSER_INTERFACE_VERSION 0x0000 #define MYSQL_FTPARSER_INTERFACE_VERSION 0x0000
@ -265,5 +265,25 @@ struct st_mysql_ftparser
int (*init)(MYSQL_FTPARSER_PARAM *param); int (*init)(MYSQL_FTPARSER_PARAM *param);
int (*deinit)(MYSQL_FTPARSER_PARAM *param); int (*deinit)(MYSQL_FTPARSER_PARAM *param);
}; };
/*************************************************************************
API for Storage Engine plugin. (MYSQL_STORAGE_ENGINE_PLUGIN)
*/
/* handlertons of different MySQL releases are incompatible */
#define MYSQL_HANDLERTON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
/*
The real API is in the sql/handler.h
Here we define only the descriptor structure, that is referred from
st_mysql_plugin.
*/
struct st_mysql_storage_engine
{
int interface_version;
struct handlerton *handlerton;
};
#endif #endif

View File

@ -1171,6 +1171,8 @@ sub executable_setup () {
sub environment_setup () { sub environment_setup () {
umask(022);
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# We might not use a standard installation directory, like /usr/lib. # We might not use a standard installation directory, like /usr/lib.
# Set LD_LIBRARY_PATH to make sure we find our installed libraries. # Set LD_LIBRARY_PATH to make sure we find our installed libraries.
@ -3218,7 +3220,7 @@ sub run_mysqltest ($) {
} }
my $cmdline_mysql= my $cmdline_mysql=
"$exe_mysql --host=localhost --user=root --password= " . "$exe_mysql --no-defaults --host=localhost --user=root --password= " .
"--port=$master->[0]->{'path_myport'} " . "--port=$master->[0]->{'path_myport'} " .
"--socket=$master->[0]->{'path_mysock'}"; "--socket=$master->[0]->{'path_mysock'}";

View File

@ -11,7 +11,7 @@ ADD UNDOFILE 'undofile02.dat'
INITIAL_SIZE = 4M INITIAL_SIZE = 4M
ENGINE=XYZ; ENGINE=XYZ;
Warnings: Warnings:
Error 1266 Using storage engine MyISAM for table 'lg1' Error 1286 Unknown table engine 'XYZ'
Error 1465 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' Error 1465 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP'
CREATE TABLESPACE ts1 CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat' ADD DATAFILE 'datafile.dat'

View File

@ -15,7 +15,7 @@ enable_query_log;
--system mkdir $MYSQLTEST_VARDIR/tmp/bug14354 --system mkdir $MYSQLTEST_VARDIR/tmp/bug14354
disable_query_log; disable_query_log;
eval CREATE TABLE t1 (id int) PARTITION BY RANGE(id) ( eval CREATE TABLE t1 (id int) PARTITION BY RANGE(id) (
PARTITION p1 VALUES LESS THAN (20) ENGINE=myiasm PARTITION p1 VALUES LESS THAN (20) ENGINE=myisam
DATA DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354" DATA DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354"
INDEX DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354"); INDEX DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354");
enable_query_log; enable_query_log;

View File

@ -97,6 +97,9 @@ pthread_mutex_t bdb_mutex;
static DB_ENV *db_env; static DB_ENV *db_env;
static HASH bdb_open_tables; 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[] = const char *berkeley_lock_names[] =
{ "DEFAULT", "OLDEST", "RANDOM", "YOUNGEST", "EXPIRE", "MAXLOCKS", { "DEFAULT", "OLDEST", "RANDOM", "YOUNGEST", "EXPIRE", "MAXLOCKS",
"MAXWRITE", "MINLOCKS", "MINWRITE", 0 }; "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 int berkeley_release_savepoint(THD* thd, void *savepoint);
static handler *berkeley_create_handler(TABLE_SHARE *table); static handler *berkeley_create_handler(TABLE_SHARE *table);
static const char berkeley_hton_name[]= "BerkeleyDB"; handlerton berkeley_hton;
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 */
};
handler *berkeley_create_handler(TABLE_SHARE *table) handler *berkeley_create_handler(TABLE_SHARE *table)
{ {
@ -181,12 +144,27 @@ typedef struct st_berkeley_trx_data {
/* General functions */ /* General functions */
bool berkeley_init(void) int berkeley_init(void)
{ {
DBUG_ENTER("berkeley_init"); 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) if (have_berkeley_db != SHOW_OPTION_YES)
goto error; return 0; // nothing else to do
if (!berkeley_tmpdir) if (!berkeley_tmpdir)
berkeley_tmpdir=mysql_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) static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
{ {
char **all_logs, **free_logs, **a, **f; char **all_logs, **free_logs, **a, **f;
uint hton_name_len= strlen(berkeley_hton.name);
int error=1; int error=1;
MEM_ROOT **root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC); MEM_ROOT **root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC);
MEM_ROOT show_logs_root, *old_mem_root= *root_ptr; 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) if (f && *f && strcmp(*a, *f) == 0)
{ {
f++; f++;
if ((error= stat_print(thd, berkeley_hton.name, hton_name_len, if ((error= stat_print(thd, berkeley_hton_name,
*a, strlen(*a), berkeley_hton_name_length, *a, strlen(*a),
STRING_WITH_LEN(SHOW_LOG_STATUS_FREE)))) STRING_WITH_LEN(SHOW_LOG_STATUS_FREE))))
break; break;
} }
else else
{ {
if ((error= stat_print(thd, berkeley_hton.name, hton_name_len, if ((error= stat_print(thd, berkeley_hton_name,
*a, strlen(*a), berkeley_hton_name_length, *a, strlen(*a),
STRING_WITH_LEN(SHOW_LOG_STATUS_INUSE)))) STRING_WITH_LEN(SHOW_LOG_STATUS_INUSE))))
break; break;
} }
@ -2732,15 +2709,17 @@ bool ha_berkeley::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES; return COMPATIBLE_DATA_YES;
} }
struct st_mysql_storage_engine berkeley_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &berkeley_hton };
mysql_declare_plugin(berkeley) mysql_declare_plugin(berkeley)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&berkeley_hton, &berkeley_storage_engine,
berkeley_hton_name, berkeley_hton_name,
"Sleepycat Software", "Sleepycat Software",
berkeley_hton_comment, "Supports transactions and page-level locking",
NULL, /* Plugin Init */ berkeley_init, /* Plugin Init */
NULL, /* Plugin Deinit */ NULL, /* Plugin Deinit */
0x0100, /* 1.0 */ 0x0100, /* 1.0 */
0 0

View File

@ -172,7 +172,7 @@ extern char *berkeley_home, *berkeley_tmpdir, *berkeley_logdir;
extern long berkeley_lock_scan_time; extern long berkeley_lock_scan_time;
extern TYPELIB berkeley_lock_typelib; extern TYPELIB berkeley_lock_typelib;
bool berkeley_init(void); int berkeley_init(void);
int berkeley_end(ha_panic_function type); int berkeley_end(ha_panic_function type);
bool berkeley_flush_logs(void); bool berkeley_flush_logs(void);
bool berkeley_show_status(THD *thd, stat_print_fn *print, enum ha_stat_type); bool berkeley_show_status(THD *thd, stat_print_fn *print, enum ha_stat_type);

View File

@ -370,47 +370,7 @@ static int federated_rollback(THD *thd, bool all);
/* Federated storage engine handlerton */ /* Federated storage engine handlerton */
static const char federated_hton_name[]= "FEDERATED"; handlerton federated_hton;
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 */
};
static handler *federated_create_handler(TABLE_SHARE *table) 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() bool federated_db_init()
{ {
DBUG_ENTER("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)) if (pthread_mutex_init(&federated_mutex, MY_MUTEX_INIT_FAST))
goto error; goto error;
if (!hash_init(&federated_open_tables, system_charset_info, 32, 0, 0, if (!hash_init(&federated_open_tables, system_charset_info, 32, 0, 0,
@ -2811,15 +2780,17 @@ int ha_federated::execute_simple_query(const char *query, int len)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
struct st_mysql_storage_engine federated_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &federated_hton };
mysql_declare_plugin(federated) mysql_declare_plugin(federated)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&federated_hton, &federated_storage_engine,
federated_hton_name, "FEDERATED",
"Patrick Galbraith and Brian Aker, MySQL AB", "Patrick Galbraith and Brian Aker, MySQL AB",
federated_hton_comment, "Federated MySQL storage engine",
NULL, /* Plugin Init */ federated_db_init, /* Plugin Init */
NULL, /* Plugin Deinit */ NULL, /* Plugin Deinit */
0x0100 /* 1.0 */, 0x0100 /* 1.0 */,
} }

View File

@ -26,47 +26,17 @@
static handler *heap_create_handler(TABLE_SHARE *table); static handler *heap_create_handler(TABLE_SHARE *table);
static const char heap_hton_name[]= "MEMORY"; handlerton heap_hton;
static const char heap_hton_comment[]=
"Hash based, stored in memory, useful for temporary tables";
handlerton heap_hton= { int heap_init()
MYSQL_HANDLERTON_INTERFACE_VERSION, {
heap_hton_name, heap_hton.state= SHOW_OPTION_YES;
SHOW_OPTION_YES, heap_hton.db_type= DB_TYPE_HEAP;
heap_hton_comment, heap_hton.create= heap_create_handler;
DB_TYPE_HEAP, heap_hton.panic= heap_panic;
NULL, heap_hton.flags= HTON_CAN_RECREATE;
0, /* slot */ return 0;
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 */
};
static handler *heap_create_handler(TABLE_SHARE *table) 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; return COMPATIBLE_DATA_YES;
} }
struct st_mysql_storage_engine heap_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &heap_hton};
mysql_declare_plugin(heap) mysql_declare_plugin(heap)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&heap_hton, &heap_storage_engine,
heap_hton_name, "MEMORY",
"MySQL AB", "MySQL AB",
heap_hton_comment, "Hash based, stored in memory, useful for temporary tables",
NULL, heap_init,
NULL, NULL,
0x0100, /* 1.0 */ 0x0100, /* 1.0 */
0 0

View File

@ -42,7 +42,6 @@ have disables the InnoDB inlining in this file. */
#define MAX_ULONG_BIT ((ulong) 1 << (sizeof(ulong)*8-1)) #define MAX_ULONG_BIT ((ulong) 1 << (sizeof(ulong)*8-1))
#ifdef WITH_INNOBASE_STORAGE_ENGINE
#include "ha_innodb.h" #include "ha_innodb.h"
pthread_mutex_t innobase_share_mutex, /* to protect innobase_open_files */ 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 handler *innobase_create_handler(TABLE_SHARE *table);
static const char innobase_hton_name[]= "InnoDB"; 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) static handler *innobase_create_handler(TABLE_SHARE *table)
{ {
@ -1230,10 +1190,9 @@ ha_innobase::init_table_handle_for_HANDLER(void)
/************************************************************************* /*************************************************************************
Opens an InnoDB database. */ Opens an InnoDB database. */
bool int
innobase_init(void) innobase_init(void)
/*===============*/ /*===============*/
/* out: &innobase_hton, or NULL on error */
{ {
static char current_dir[3]; /* Set if using current lib */ static char current_dir[3]; /* Set if using current lib */
int err; int err;
@ -1242,8 +1201,33 @@ innobase_init(void)
DBUG_ENTER("innobase_init"); 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) 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); ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
@ -6473,7 +6457,7 @@ innodb_show_status(
bool result = FALSE; 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)) { STRING_WITH_LEN(""), str, flen)) {
result= TRUE; result= TRUE;
} }
@ -6500,7 +6484,7 @@ innodb_mutex_show_status(
ulint rw_lock_count_os_wait= 0; ulint rw_lock_count_os_wait= 0;
ulint rw_lock_count_os_yield= 0; ulint rw_lock_count_os_yield= 0;
ulonglong rw_lock_wait_time= 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"); DBUG_ENTER("innodb_mutex_show_status");
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER #ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
@ -6527,7 +6511,7 @@ innodb_mutex_show_status(
mutex->count_os_yield, mutex->count_os_yield,
mutex->lspent_time/1000); mutex->lspent_time/1000);
if (stat_print(thd, innobase_hton.name, if (stat_print(thd, innobase_hton_name,
hton_name_len, buf1, buf1len, hton_name_len, buf1, buf1len,
buf2, buf2len)) { buf2, buf2len)) {
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER #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_count_os_wait, rw_lock_count_os_yield,
rw_lock_wait_time/1000); 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)) { STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len)) {
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@ -7459,19 +7443,20 @@ bool ha_innobase::check_if_incompatible_data(
return COMPATIBLE_DATA_YES; return COMPATIBLE_DATA_YES;
} }
struct st_mysql_storage_engine innobase_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &innobase_hton};
mysql_declare_plugin(innobase) mysql_declare_plugin(innobase)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&innobase_hton, &innobase_storage_engine,
innobase_hton_name, innobase_hton_name,
"Innobase OY", "Innobase OY",
innobase_hton_comment, "Supports transactions, row-level locking, and foreign keys",
NULL, /* Plugin Init */ innobase_init, /* Plugin Init */
NULL, /* Plugin Deinit */ NULL, /* Plugin Deinit */
0x0100 /* 1.0 */, 0x0100 /* 1.0 */,
0 0
} }
mysql_declare_plugin_end; mysql_declare_plugin_end;
#endif

View File

@ -249,7 +249,7 @@ extern ulong srv_thread_concurrency;
extern ulong srv_commit_concurrency; extern ulong srv_commit_concurrency;
} }
bool innobase_init(void); int innobase_init(void);
int innobase_end(ha_panic_function type); int innobase_end(ha_panic_function type);
bool innobase_flush_logs(void); bool innobase_flush_logs(void);
uint innobase_get_free_space(void); uint innobase_get_free_space(void);

View File

@ -52,63 +52,11 @@ TYPELIB myisam_stats_method_typelib= {
** MyISAM tables ** 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) static handler *myisam_create_handler(TABLE_SHARE *table)
{ {
return new ha_myisam(table); return new ha_myisam(table);
} }
// collect errors printed by mi_check routines // collect errors printed by mi_check routines
static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, 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; 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_declare_plugin(myisam)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&myisam_hton, &myisam_storage_engine,
myisam_hton_name, "MyISAM",
"MySQL AB", "MySQL AB",
myisam_hton_comment, "Default engine as of MySQL 3.23 with great performance",
NULL, /* Plugin Init */ myisam_init, /* Plugin Init */
NULL, /* Plugin Deinit */ NULL, /* Plugin Deinit */
0x0100, /* 1.0 */ 0x0100, /* 1.0 */
0 0
} }
mysql_declare_plugin_end; mysql_declare_plugin_end;

View File

@ -38,47 +38,7 @@ static handler *myisammrg_create_handler(TABLE_SHARE *table);
/* MyISAM MERGE handlerton */ /* MyISAM MERGE handlerton */
static const char myisammrg_hton_name[]= "MRG_MYISAM"; handlerton myisammrg_hton;
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 */
};
static handler *myisammrg_create_handler(TABLE_SHARE *table) 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; 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_declare_plugin(myisammrg)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&myisammrg_hton, &myisammrg_storage_engine,
myisammrg_hton_name, "MRG_MYISAM",
"MySQL AB", "MySQL AB",
myisammrg_hton_comment, "Collection of identical MyISAM tables",
NULL, /* Plugin Init */ myisammrg_init, /* Plugin Init */
NULL, /* Plugin Deinit */ NULL, /* Plugin Deinit */
0x0100, /* 1.0 */ 0x0100, /* 1.0 */
0 0

View File

@ -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_partition_flags();
static uint ndbcluster_alter_table_flags(uint 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 int ndbcluster_end(ha_panic_function flag);
static bool ndbcluster_show_status(THD*,stat_print_fn *,enum ha_stat_type); 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_alter_tablespace(THD* thd, st_alter_tablespace *info);
static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond); static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond);
static const char ndbcluster_hton_name[]= "ndbcluster"; handlerton ndbcluster_hton;
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
};
static handler *ndbcluster_create_handler(TABLE_SHARE *table) static handler *ndbcluster_create_handler(TABLE_SHARE *table)
{ {
@ -6080,17 +6067,18 @@ static int connect_callback()
} }
extern int ndb_dictionary_is_mysqld; extern int ndb_dictionary_is_mysqld;
static bool ndbcluster_init()
static int ndbcluster_init()
{ {
int res; int res;
DBUG_ENTER("ndbcluster_init"); DBUG_ENTER("ndbcluster_init");
ndb_dictionary_is_mysqld= 1; ndb_dictionary_is_mysqld= 1;
if (have_ndbcluster != SHOW_OPTION_YES)
goto ndbcluster_init_error;
{ {
handlerton &h= ndbcluster_hton; handlerton &h= ndbcluster_hton;
h.state= have_ndbcluster;
h.db_type= DB_TYPE_NDBCLUSTER;
h.close_connection= ndbcluster_close_connection; h.close_connection= ndbcluster_close_connection;
h.commit= ndbcluster_commit; h.commit= ndbcluster_commit;
h.rollback= ndbcluster_rollback; h.rollback= ndbcluster_rollback;
@ -6108,6 +6096,9 @@ static bool ndbcluster_init()
h.flags= HTON_TEMPORARY_NOT_SUPPORTED; h.flags= HTON_TEMPORARY_NOT_SUPPORTED;
} }
if (have_ndbcluster != SHOW_OPTION_YES)
DBUG_RETURN(0); // nothing else to do
// Set connectstring if specified // Set connectstring if specified
if (opt_ndbcluster_connectstring != 0) if (opt_ndbcluster_connectstring != 0)
DBUG_PRINT("connectstring", ("%s", opt_ndbcluster_connectstring)); DBUG_PRINT("connectstring", ("%s", opt_ndbcluster_connectstring));
@ -9356,9 +9347,8 @@ ndbcluster_show_status(THD* thd, stat_print_fn *stat_print,
ndb_connected_host, ndb_connected_host,
ndb_connected_port, ndb_connected_port,
ndb_number_of_storage_nodes); ndb_number_of_storage_nodes);
if (stat_print(thd, ndbcluster_hton.name, strlen(ndbcluster_hton.name), if (stat_print(thd, ndbcluster_hton_name, ndbcluster_hton_name_length,
"connection", strlen("connection"), STRING_WITH_LEN("connection"), buf, buflen))
buf, buflen))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (get_thd_ndb(thd) && get_thd_ndb(thd)->ndb) 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), my_snprintf(buf, sizeof(buf),
"created=%u, free=%u, sizeof=%u", "created=%u, free=%u, sizeof=%u",
tmp.m_created, tmp.m_free, tmp.m_sizeof); 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)) tmp.m_name, strlen(tmp.m_name), buf, buflen))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -10037,8 +10027,8 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond)
strlen(ts.getDefaultLogfileGroup()), strlen(ts.getDefaultLogfileGroup()),
system_charset_info); system_charset_info);
table->field[c++]->set_null(); // LOGFILE_GROUP_NUMBER table->field[c++]->set_null(); // LOGFILE_GROUP_NUMBER
table->field[c++]->store(ndbcluster_hton.name, table->field[c++]->store(ndbcluster_hton_name,
strlen(ndbcluster_hton.name), ndbcluster_hton_name_length,
system_charset_info); // ENGINE system_charset_info); // ENGINE
table->field[c++]->set_null(); // FULLTEXT_KEYS 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()), strlen(uf.getLogfileGroup()),
system_charset_info); system_charset_info);
table->field[c++]->store(uf.getLogfileGroupId()); // LOGFILE_GROUP_NUMBER table->field[c++]->store(uf.getLogfileGroupId()); // LOGFILE_GROUP_NUMBER
table->field[c++]->store(ndbcluster_hton.name, table->field[c++]->store(ndbcluster_hton_name,
strlen(ndbcluster_hton.name), ndbcluster_hton_name_length,
system_charset_info); // ENGINE system_charset_info); // ENGINE
table->field[c++]->set_null(); // FULLTEXT_KEYS 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); DBUG_RETURN(0);
} }
struct st_mysql_storage_engine ndbcluster_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &ndbcluster_hton };
mysql_declare_plugin(ndbcluster) mysql_declare_plugin(ndbcluster)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&ndbcluster_hton, &ndbcluster_storage_engine,
ndbcluster_hton_name, ndbcluster_hton_name,
"MySQL AB", "MySQL AB",
ndbcluster_hton_comment, "Clustered, fault-tolerant tables",
NULL, /* Plugin Init */ ndbcluster_init, /* Plugin Init */
NULL, /* Plugin Deinit */ NULL, /* Plugin Deinit */
0x0100 /* 1.0 */, 0x0100 /* 1.0 */,
0 0

View File

@ -889,3 +889,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
int ndbcluster_table_exists_in_engine(THD* thd, int ndbcluster_table_exists_in_engine(THD* thd,
const char *db, const char *name); const char *db, const char *name);
void ndbcluster_print_error(int error, const NdbOperation *error_op); 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;

View File

@ -2323,7 +2323,7 @@ ndbcluster_create_event(Ndb *ndb, const NDBTAB *ndbtab,
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_ILLEGAL_HA_CREATE_OPTION, ER_ILLEGAL_HA_CREATE_OPTION,
ER(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"); "Binlog of table with BLOB attribute and no PK");
share->flags|= NSF_NO_BINLOG; share->flags|= NSF_NO_BINLOG;
@ -3688,7 +3688,7 @@ ndbcluster_show_status_binlog(THD* thd, stat_print_fn *stat_print,
ndb_latest_received_binlog_epoch, ndb_latest_received_binlog_epoch,
ndb_latest_handled_binlog_epoch, ndb_latest_handled_binlog_epoch,
ndb_latest_applied_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"), "binlog", strlen("binlog"),
buf, buflen)) buf, buflen))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);

View File

@ -73,46 +73,18 @@ static handler *partition_create_handler(TABLE_SHARE *share);
static uint partition_flags(); static uint partition_flags();
static uint alter_table_flags(uint flags); static uint alter_table_flags(uint flags);
static const char partition_hton_name[]= "partition"; handlerton partition_hton;
static const char partition_hton_comment[]= "Partition Storage Engine Helper";
handlerton partition_hton = { static int partition_initialize()
MYSQL_HANDLERTON_INTERFACE_VERSION, {
partition_hton_name, partition_hton.state= SHOW_OPTION_YES;
SHOW_OPTION_YES, partition_hton.db_type= DB_TYPE_PARTITION_DB;
partition_hton_comment, /* A comment used by SHOW to describe an engine */ partition_hton.create= partition_create_handler;
DB_TYPE_PARTITION_DB, partition_hton.partition_flags= partition_flags;
0, /* Method that initializes a storage engine */ partition_hton.alter_table_flags= alter_table_flags;
0, /* slot */ partition_hton.flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN;
0, /* savepoint size */ return 0;
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 */
};
/* /*
Create new partition handler Create new partition handler
@ -5525,15 +5497,17 @@ static int free_share(PARTITION_SHARE *share)
} }
#endif /* NOT_USED */ #endif /* NOT_USED */
struct st_mysql_storage_engine partition_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &partition_hton };
mysql_declare_plugin(partition) mysql_declare_plugin(partition)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&partition_hton, &partition_storage_engine,
partition_hton_name, "partition",
"Mikael Ronstrom, MySQL AB", "Mikael Ronstrom, MySQL AB",
partition_hton_comment, "Partition Storage Engine Helper",
NULL, /* Plugin Init */ partition_initialize, /* Plugin Init */
NULL, /* Plugin Deinit */ NULL, /* Plugin Deinit */
0x0100, /* 1.0 */ 0x0100, /* 1.0 */
0 0

View File

@ -48,6 +48,7 @@
check for dups and to find handlerton from legacy_db_type. check for dups and to find handlerton from legacy_db_type.
Remove when legacy_db_type is finally gone */ Remove when legacy_db_type is finally gone */
static handlerton *installed_htons[128]; static handlerton *installed_htons[128];
st_mysql_plugin *hton2plugin[MAX_HA];
#define BITMAP_STACKBUF_SIZE (128/8) #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); 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; static SHOW_COMP_OPTION have_yes= SHOW_OPTION_YES;
/* number of entries in handlertons[] */ /* number of entries in handlertons[] */
ulong total_ha; ulong total_ha= 0;
/* number of storage engines (from handlertons[]) that support 2pc */ /* 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) */ /* 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[]= 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))) 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)) if (!(hton->flags & HTON_NOT_USER_SELECTABLE))
return hton; return hton;
plugin_unlock(plugin); plugin_unlock(plugin);
@ -155,7 +135,7 @@ const char *ha_get_storage_engine(enum legacy_db_type db_type)
default: default:
if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT && if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT &&
installed_htons[db_type]) installed_htons[db_type])
return installed_htons[db_type]->name; return hton2plugin[installed_htons[db_type]->slot]->name;
return "*NONE*"; 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) static handler *create_default(TABLE_SHARE *table)
{ {
handlerton *hton=ha_resolve_by_legacy_type(current_thd, DB_TYPE_DEFAULT); handlerton *hton=ha_resolve_by_legacy_type(current_thd, DB_TYPE_DEFAULT);
return (hton && hton != &default_hton && hton->create) ? return (hton && hton->create) ? hton->create(table) : NULL;
hton->create(table) : NULL;
} }
@ -375,7 +354,7 @@ int ha_finalize_handlerton(st_plugin_int *plugin)
handlerton *hton; handlerton *hton;
DBUG_ENTER("ha_finalize_handlerton"); DBUG_ENTER("ha_finalize_handlerton");
if (!(hton= (handlerton *) plugin->plugin->info)) if (!(hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton))
DBUG_RETURN(1); DBUG_RETURN(1);
switch (hton->state) switch (hton->state)
@ -396,30 +375,19 @@ int ha_finalize_handlerton(st_plugin_int *plugin)
int ha_initialize_handlerton(st_plugin_int *plugin) int ha_initialize_handlerton(st_plugin_int *plugin)
{ {
handlerton *hton; handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
DBUG_ENTER("ha_initialize_handlerton"); DBUG_ENTER("ha_initialize_handlerton");
if (!(hton= (handlerton *) plugin->plugin->info)) /*
DBUG_RETURN(1); the switch below and hton->state should be removed when
command-line options for plugins will be implemented
/* for the sake of sanity, we set the handlerton name to be the */
same as the plugin name */
hton->name= plugin->name.str;
switch (hton->state) { switch (hton->state) {
case SHOW_OPTION_NO: case SHOW_OPTION_NO:
break; break;
case SHOW_OPTION_YES: 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 */ /* 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 || hton->db_type >= DB_TYPE_DEFAULT ||
@ -437,10 +405,17 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
} }
if (hton->db_type != DB_TYPE_UNKNOWN) if (hton->db_type != DB_TYPE_UNKNOWN)
sql_print_warning("Storage engine '%s' has conflicting typecode. " 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; hton->db_type= (enum legacy_db_type) idx;
} }
installed_htons[hton->db_type]= hton; 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; break;
} }
/* fall through */ /* fall through */
@ -451,33 +426,14 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
DBUG_RETURN(0); 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 ha_init()
{ {
int error= 0; int error= 0;
total_ha= savepoint_alloc_size= 0;
DBUG_ENTER("ha_init"); DBUG_ENTER("ha_init");
bzero(installed_htons, sizeof(installed_htons));
if (ha_init_errors()) if (ha_init_errors())
DBUG_RETURN(1); DBUG_RETURN(1);
if (plugin_foreach(NULL, init_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, 0))
DBUG_RETURN(1);
DBUG_ASSERT(total_ha < MAX_HA); DBUG_ASSERT(total_ha < MAX_HA);
/* /*
Check if there is a transaction-capable storage engine besides the 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, static my_bool panic_handlerton(THD *unused1, st_plugin_int *plugin,
void *arg) 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) if (hton->state == SHOW_OPTION_YES && hton->panic)
((int*)arg)[0]|= hton->panic((enum ha_panic_function)((int*)arg)[1]); ((int*)arg)[0]|= hton->panic((enum ha_panic_function)((int*)arg)[1]);
return FALSE; return FALSE;
@ -520,7 +476,7 @@ int ha_panic(enum ha_panic_function flag)
static my_bool dropdb_handlerton(THD *unused1, st_plugin_int *plugin, static my_bool dropdb_handlerton(THD *unused1, st_plugin_int *plugin,
void *path) 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) if (hton->state == SHOW_OPTION_YES && hton->drop_database)
hton->drop_database((char *)path); hton->drop_database((char *)path);
return FALSE; return FALSE;
@ -536,7 +492,7 @@ void ha_drop_database(char* path)
static my_bool closecon_handlerton(THD *thd, st_plugin_int *plugin, static my_bool closecon_handlerton(THD *thd, st_plugin_int *plugin,
void *unused) void *unused)
{ {
handlerton *hton= (handlerton *) plugin->plugin->info; handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
/* there's no need to rollback here as all transactions must /* there's no need to rollback here as all transactions must
be rolled back already */ be rolled back already */
if (hton->state == SHOW_OPTION_YES && hton->close_connection && if (hton->state == SHOW_OPTION_YES && hton->close_connection &&
@ -628,7 +584,8 @@ int ha_prepare(THD *thd)
else else
{ {
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 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, static my_bool xacommit_handlerton(THD *unused1, st_plugin_int *plugin,
void *arg) 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) if (hton->state == SHOW_OPTION_YES && hton->recover)
{ {
hton->commit_by_xid(((struct xahton_st *)arg)->xid); 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, static my_bool xarollback_handlerton(THD *unused1, st_plugin_int *plugin,
void *arg) 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) if (hton->state == SHOW_OPTION_YES && hton->recover)
{ {
hton->rollback_by_xid(((struct xahton_st *)arg)->xid); hton->rollback_by_xid(((struct xahton_st *)arg)->xid);
@ -986,7 +943,7 @@ struct xarecover_st
static my_bool xarecover_handlerton(THD *unused, st_plugin_int *plugin, static my_bool xarecover_handlerton(THD *unused, st_plugin_int *plugin,
void *arg) 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; struct xarecover_st *info= (struct xarecover_st *) arg;
int got; int got;
@ -995,7 +952,7 @@ static my_bool xarecover_handlerton(THD *unused, st_plugin_int *plugin,
while ((got= hton->recover(info->list, info->len)) > 0 ) while ((got= hton->recover(info->list, info->len)) > 0 )
{ {
sql_print_information("Found %d prepared transaction(s) in %s", 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 ++) for (int i=0; i < got; i ++)
{ {
my_xid x=info->list[i].get_my_xid(); 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, static my_bool release_temporary_latches(THD *thd, st_plugin_int *plugin,
void *unused) 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) if (hton->state == SHOW_OPTION_YES && hton->release_temporary_latches)
hton->release_temporary_latches(thd); 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, static my_bool snapshot_handlerton(THD *thd, st_plugin_int *plugin,
void *arg) void *arg)
{ {
handlerton *hton= (handlerton *) plugin->plugin->info; handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && if (hton->state == SHOW_OPTION_YES &&
hton->start_consistent_snapshot) 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, static my_bool flush_handlerton(THD *thd, st_plugin_int *plugin,
void *arg) 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()) if (hton->state == SHOW_OPTION_YES && hton->flush_logs && hton->flush_logs())
return TRUE; return TRUE;
return FALSE; return FALSE;
@ -2635,7 +2592,7 @@ struct binlog_func_st
static my_bool binlog_func_list(THD *thd, st_plugin_int *plugin, void *arg) static my_bool binlog_func_list(THD *thd, st_plugin_int *plugin, void *arg)
{ {
hton_list_st *hton_list= (hton_list_st *)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) if (hton->state == SHOW_OPTION_YES && hton->binlog_func)
{ {
uint sz= hton_list->sz; uint sz= hton_list->sz;
@ -3020,7 +2977,7 @@ static my_bool exts_handlerton(THD *unused, st_plugin_int *plugin,
void *arg) void *arg)
{ {
List<char> *found_exts= (List<char> *) 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; handler *file;
if (hton->state == SHOW_OPTION_YES && hton->create && if (hton->state == SHOW_OPTION_YES && hton->create &&
(file= hton->create((TABLE_SHARE*) 0))) (file= hton->create((TABLE_SHARE*) 0)))
@ -3096,7 +3053,7 @@ static my_bool showstat_handlerton(THD *thd, st_plugin_int *plugin,
void *arg) void *arg)
{ {
enum ha_stat_type stat= *(enum ha_stat_type *) 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 && if (hton->state == SHOW_OPTION_YES && hton->show_status &&
hton->show_status(thd, stat_print, stat)) hton->show_status(thd, stat_print, stat))
return TRUE; return TRUE;
@ -3125,8 +3082,11 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat)
else else
{ {
if (db_type->state != SHOW_OPTION_YES) 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; "", 0, "DISABLED", 8) ? 1 : 0;
}
else else
result= db_type->show_status && result= db_type->show_status &&
db_type->show_status(thd, stat_print, stat) ? 1 : 0; db_type->show_status(thd, stat_print, stat) ? 1 : 0;

View File

@ -177,6 +177,7 @@
so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive + so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
example + csv + heap + blackhole + federated + 0 example + csv + heap + blackhole + federated + 0
(yes, the sum is deliberately inaccurate) (yes, the sum is deliberately inaccurate)
TODO remove the limit, use dynarrays
*/ */
#define MAX_HA 15 #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 *file, uint file_len,
const char *status, uint status_len); const char *status, uint status_len);
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX }; 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 - handlerton is a singleton structure - one instance per storage engine -
@ -474,39 +476,16 @@ enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
*/ */
struct handlerton 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; 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. 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. This is going away and new engines will just use "name" for this.
*/ */
enum legacy_db_type db_type; 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) each storage engine has it's own memory area (actually a pointer)
in the thd, for storing per-connection information. in the thd, for storing per-connection information.
@ -587,8 +566,6 @@ struct handlerton
int (*release_temporary_latches)(THD *thd); int (*release_temporary_latches)(THD *thd);
}; };
extern const handlerton default_hton;
struct show_table_alias_st { struct show_table_alias_st {
const char *alias; const char *alias;
enum legacy_db_type type; 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) 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) static inline bool ha_check_storage_engine_flag(const handlerton *db_type, uint32 flag)

View File

@ -47,7 +47,7 @@ ulong sync_binlog_counter= 0;
static bool test_if_number(const char *str, static bool test_if_number(const char *str,
long *res, bool allow_wildcards); long *res, bool allow_wildcards);
static bool binlog_init(); static int binlog_init();
static int binlog_close_connection(THD *thd); static int binlog_close_connection(THD *thd);
static int binlog_savepoint_set(THD *thd, void *sv); static int binlog_savepoint_set(THD *thd, void *sv);
static int binlog_savepoint_rollback(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 Rows_log_event *pending; // The pending binrows event
}; };
static const char binlog_hton_name[]= "binlog"; handlerton binlog_hton;
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 */
};
/* /*
Open log table of a given type (general or slow log) 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. 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) static int binlog_close_connection(THD *thd)
@ -4354,15 +4323,17 @@ err1:
return 1; return 1;
} }
struct st_mysql_storage_engine binlog_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &binlog_hton };
mysql_declare_plugin(binlog) mysql_declare_plugin(binlog)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&binlog_hton, &binlog_storage_engine,
binlog_hton_name, "binlog",
"MySQL AB", "MySQL AB",
binlog_hton_comment, "This is a pseudo storage engine to represent the binlog in a transaction",
NULL, /* Plugin Init */ binlog_init, /* Plugin Init */
NULL, /* Plugin Deinit */ NULL, /* Plugin Deinit */
0x0100 /* 1.0 */, 0x0100 /* 1.0 */,
} }

View File

@ -502,13 +502,13 @@ typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key,
#include "sql_list.h" #include "sql_list.h"
#include "sql_map.h" #include "sql_map.h"
#include "my_decimal.h" #include "my_decimal.h"
#include "sql_plugin.h"
#include "handler.h" #include "handler.h"
#include "parse_file.h" #include "parse_file.h"
#include "table.h" #include "table.h"
#include "sql_error.h" #include "sql_error.h"
#include "field.h" /* Field definitions */ #include "field.h" /* Field definitions */
#include "protocol.h" #include "protocol.h"
#include "sql_plugin.h"
#include "sql_udf.h" #include "sql_udf.h"
#include "sql_partition.h" #include "sql_partition.h"

View File

@ -330,7 +330,7 @@ static char *opt_init_slave, *language_ptr, *opt_init_connect;
static char *default_character_set_name; static char *default_character_set_name;
static char *character_set_filesystem_name; static char *character_set_filesystem_name;
static char *my_bind_addr_str; 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 char mysql_data_home_buff[2];
static struct passwd *user_info; static struct passwd *user_info;
static I_List<THD> thread_cache; 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)) if (add_status_vars(status_vars))
return 1; // an error was already reported 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); load_defaults(conf_file_name, groups, &argc, &argv);
defaults_argv=argv; defaults_argv=argv;
get_options(argc,argv); get_options(argc,argv);
@ -3151,6 +3145,12 @@ server.");
using_update_log=1; 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 */ /* We have to initialize the storage engines before CSV logging */
if (ha_init()) if (ha_init())
{ {
@ -3197,15 +3197,27 @@ server.");
/* /*
Check that the default storage engine is actually available. Check that the default storage engine is actually available.
*/ */
if (!ha_storage_engine_is_enabled(global_system_variables.table_type)) {
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("Unknown/unsupported table type: %s",
default_storage_engine_str);
unireg_abort(1);
}
if (!ha_storage_engine_is_enabled(hton))
{ {
if (!opt_bootstrap) if (!opt_bootstrap)
{ {
sql_print_error("Default storage engine (%s) is not available", sql_print_error("Default storage engine (%s) is not available",
global_system_variables.table_type->name); default_storage_engine_str);
unireg_abort(1); unireg_abort(1);
} }
global_system_variables.table_type= &myisam_hton; hton= &myisam_hton;
}
global_system_variables.table_type= hton;
} }
tc_log= (total_ha_2pc > 1 ? (opt_bin_log ? 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, "Set the default storage engine (table type) for tables.", 0, 0,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"default-table-type", OPT_STORAGE_ENGINE, {"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}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"default-time-zone", OPT_DEFAULT_TIME_ZONE, "Set the default time zone.", {"default-time-zone", OPT_DEFAULT_TIME_ZONE, "Set the default time zone.",
(gptr*) &default_tz_name, (gptr*) &default_tz_name, (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; sys_charset_system.value= (char*) system_charset_info->csname;
character_set_filesystem_name= (char*) "binary"; character_set_filesystem_name= (char*) "binary";
/* Set default values for some option variables */ /* Set default values for some option variables */
default_storage_engine_str="MyISAM";
global_system_variables.table_type= &myisam_hton; global_system_variables.table_type= &myisam_hton;
global_system_variables.tx_isolation= ISO_REPEATABLE_READ; global_system_variables.tx_isolation= ISO_REPEATABLE_READ;
global_system_variables.select_limit= (ulonglong) HA_POS_ERROR; 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: case OPT_BOOTSTRAP:
opt_noacl=opt_bootstrap=1; opt_noacl=opt_bootstrap=1;
break; 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: case OPT_SERVER_ID:
server_id_supplied = 1; server_id_supplied = 1;
break; break;

View File

@ -3250,7 +3250,7 @@ byte *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
handlerton *val; handlerton *val;
val= (type == OPT_GLOBAL) ? global_system_variables.*offset : val= (type == OPT_GLOBAL) ? global_system_variables.*offset :
thd->variables.*offset; thd->variables.*offset;
return (byte *) val->name; return (byte *) hton2plugin[val->slot]->name;
} }

View File

@ -7104,7 +7104,7 @@ bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
HA_CREATE_INFO create_info; HA_CREATE_INFO create_info;
DBUG_ENTER("mysql_create_index"); DBUG_ENTER("mysql_create_index");
bzero((char*) &create_info,sizeof(create_info)); 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; create_info.default_table_charset= thd->variables.collation_database;
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name, DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
&create_info, table_list, &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; HA_CREATE_INFO create_info;
DBUG_ENTER("mysql_drop_index"); DBUG_ENTER("mysql_drop_index");
bzero((char*) &create_info,sizeof(create_info)); 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; create_info.default_table_charset= thd->variables.collation_database;
alter_info->clear(); alter_info->clear();
alter_info->flags= ALTER_DROP_INDEX; alter_info->flags= ALTER_DROP_INDEX;

View File

@ -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) 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)); DBUG_PRINT("info", ("ENGINE = %s", engine_str));
int err= add_string(fptr, "ENGINE = "); int err= add_string(fptr, "ENGINE = ");
return err + add_string(fptr, engine_str); 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_ENTER("check_engine_condition");
DBUG_PRINT("enter", ("def_eng = %u, first = %u", default_engine, *first)); 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) if (*first && default_engine)
{ {
*engine_type= p_elem->engine_type; *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; *first= FALSE;
if ((!default_engine && 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; create_info->db_type= table->part_info->default_engine_type;
} }
DBUG_PRINT("info", ("New engine type = %s", DBUG_PRINT("info", ("New engine type = %s",
create_info->db_type->name)); hton2plugin[create_info->db_type->slot]->name));
thd->work_part_info= NULL; thd->work_part_info= NULL;
*partition_changed= TRUE; *partition_changed= TRUE;
} }
@ -4586,11 +4578,9 @@ the generated partition syntax in a correct manner.
} }
if (!is_native_partitioned) if (!is_native_partitioned)
{ {
DBUG_ASSERT(create_info->db_type != &default_hton); DBUG_ASSERT(create_info->db_type);
create_info->db_type= &partition_hton; create_info->db_type= &partition_hton;
} }
DBUG_PRINT("info", ("default_engine_type = %s",
thd->work_part_info->default_engine_type->name));
} }
} }
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);

View File

@ -23,12 +23,18 @@ extern struct st_mysql_plugin *mysqld_builtins[];
char *opt_plugin_dir_ptr; char *opt_plugin_dir_ptr;
char opt_plugin_dir[FN_REFLEN]; 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("UDF") },
{ (char *)STRING_WITH_LEN("STORAGE ENGINE") }, { (char *)STRING_WITH_LEN("STORAGE ENGINE") },
{ (char *)STRING_WITH_LEN("FTPARSER") } { (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= static const char *plugin_interface_version_sym=
"_mysql_plugin_interface_version_"; "_mysql_plugin_interface_version_";
static const char *sizeof_st_plugin_sym= static const char *sizeof_st_plugin_sym=
@ -522,28 +528,16 @@ static int plugin_initialize(struct st_plugin_int *plugin)
{ {
sql_print_error("Plugin '%s' init function returned error.", sql_print_error("Plugin '%s' init function returned error.",
plugin->name.str); plugin->name.str);
DBUG_PRINT("warning", ("Plugin '%s' init function returned error.",
plugin->name.str));
goto err; goto err;
} }
} }
if (plugin_type_initialize[plugin->plugin->type] &&
switch (plugin->plugin->type) (*plugin_type_initialize[plugin->plugin->type])(plugin))
{ {
case MYSQL_STORAGE_ENGINE_PLUGIN: sql_print_error("Plugin '%s' registration as a %s failed.",
if (ha_initialize_handlerton(plugin)) plugin->name.str, plugin_type_names[plugin->plugin->type]);
{
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; goto err;
} }
break;
default:
break;
}
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
@ -684,6 +678,12 @@ int plugin_init(void)
{ {
if (plugin_register_builtin(plugin)) if (plugin_register_builtin(plugin))
goto err; 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;
} }
} }

View File

@ -61,6 +61,8 @@ struct st_plugin_int
uint ref_count; /* number of threads using the plugin */ 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_ptr;
extern char opt_plugin_dir[FN_REFLEN]; extern char opt_plugin_dir[FN_REFLEN];
extern LEX_STRING plugin_type_names[]; extern LEX_STRING plugin_type_names[];

View File

@ -54,18 +54,18 @@ static my_bool show_handlerton(THD *thd, st_plugin_int *plugin,
{ {
handlerton *default_type= (handlerton *) arg; handlerton *default_type= (handlerton *) arg;
Protocol *protocol= thd->protocol; 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)) if (!(hton->flags & HTON_HIDDEN))
{ {
protocol->prepare_for_resend(); 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]; const char *option_name= show_comp_option_name[(int) hton->state];
if (hton->state == SHOW_OPTION_YES && default_type == hton) if (hton->state == SHOW_OPTION_YES && default_type == hton)
option_name= "DEFAULT"; option_name= "DEFAULT";
protocol->store(option_name, system_charset_info); 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->commit ? "YES" : "NO", system_charset_info);
protocol->store(hton->prepare ? "YES" : "NO", system_charset_info); protocol->store(hton->prepare ? "YES" : "NO", system_charset_info);
protocol->store(hton->savepoint_set ? "YES" : "NO", system_charset_info); protocol->store(hton->savepoint_set ? "YES" : "NO", system_charset_info);
@ -3055,7 +3055,7 @@ static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin,
void *ptable) void *ptable)
{ {
TABLE *table= (TABLE *) 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; const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
CHARSET_INFO *scs= system_charset_info; CHARSET_INFO *scs= system_charset_info;
DBUG_ENTER("iter_schema_engines"); 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 (!(hton->flags & HTON_HIDDEN))
{ {
if (!(wild && wild[0] && 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); restore_record(table, s->default_values);
table->field[0]->store(hton->name, strlen(hton->name), scs); table->field[0]->store(plugin->plugin->name,
tmp= hton->state ? "DISABLED" : "ENABLED"; strlen(plugin->plugin->name), scs);
table->field[1]->store( tmp, strlen(tmp), scs); tmp= &state[test(hton->state)];
table->field[2]->store(hton->comment, strlen(hton->comment), scs); table->field[1]->store(tmp->str, tmp->length, scs);
tmp= hton->commit ? "YES" : "NO"; table->field[2]->store(plugin->plugin->descr,
table->field[3]->store( tmp, strlen(tmp), scs); strlen(plugin->plugin->descr), scs);
tmp= hton->prepare ? "YES" : "NO"; tmp= &yesno[test(hton->commit)];
table->field[4]->store( tmp, strlen(tmp), scs); table->field[3]->store(tmp->str, tmp->length, scs);
tmp= hton->savepoint_set ? "YES" : "NO"; tmp= &yesno[test(hton->prepare)];
table->field[5]->store( tmp, strlen(tmp), scs); 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)) if (schema_table_store_record(thd, table))
DBUG_RETURN(1); DBUG_RETURN(1);
@ -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= struct run_hton_fill_schema_files_args *args=
(run_hton_fill_schema_files_args *) arg; (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) if(hton->fill_files_table)
hton->fill_files_table(thd, args->tables, args->cond); hton->fill_files_table(thd, args->tables, args->cond);
return false; return false;

View File

@ -5085,7 +5085,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
} }
old_db_type= table->s->db_type; 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; create_info->db_type= old_db_type;
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
@ -6398,7 +6398,7 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list,
lex->col_list.empty(); lex->col_list.empty();
lex->alter_info.reset(); lex->alter_info.reset();
bzero((char*) &create_info,sizeof(create_info)); 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.row_type=ROW_TYPE_NOT_USED;
create_info.default_table_charset=default_charset_info; create_info.default_table_charset=default_charset_info;
/* Force alter table to recreate table */ /* Force alter table to recreate table */
@ -6542,7 +6542,7 @@ static bool check_engine(THD *thd, const char *table_name,
no_substitution, 1))) no_substitution, 1)))
return TRUE; 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, push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_USING_OTHER_HANDLER, 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) 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; *new_engine= 0;
return TRUE; return TRUE;
} }

View File

@ -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 If the user haven't defined an engine, this will fallback to using the
default storage engine. 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); hton= ha_resolve_by_legacy_type(thd, DB_TYPE_DEFAULT);
if (ts_info->storage_engine != 0) if (ts_info->storage_engine != 0)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_WARN_USING_OTHER_HANDLER, ER_WARN_USING_OTHER_HANDLER,
ER(ER_WARN_USING_OTHER_HANDLER), ER(ER_WARN_USING_OTHER_HANDLER),
hton->name, hton2plugin[hton->slot]->name,
ts_info->tablespace_name ts_info->tablespace_name ? ts_info->tablespace_name
? ts_info->tablespace_name : ts_info->logfile_group_name); : ts_info->logfile_group_name);
} }
if (hton->alter_tablespace) 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, push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_ILLEGAL_HA_CREATE_OPTION, ER_ILLEGAL_HA_CREATE_OPTION,
ER(ER_ILLEGAL_HA_CREATE_OPTION), ER(ER_ILLEGAL_HA_CREATE_OPTION),
hton->name, hton2plugin[hton->slot]->name,
"TABLESPACE or LOGFILE GROUP"); "TABLESPACE or LOGFILE GROUP");
} }
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())

View File

@ -3099,7 +3099,7 @@ opt_ts_engine:
"STORAGE ENGINE"); "STORAGE ENGINE");
YYABORT; YYABORT;
} }
lex->alter_tablespace_info->storage_engine= $4 ? $4 : &default_hton; lex->alter_tablespace_info->storage_engine= $4;
}; };
opt_ts_wait: opt_ts_wait:
@ -3939,12 +3939,18 @@ storage_engines:
ident_or_text ident_or_text
{ {
$$ = ha_resolve_by_name(YYTHD, &$1); $$ = ha_resolve_by_name(YYTHD, &$1);
if ($$ == NULL && if ($$ == NULL)
test(YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION)) if (YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION)
{ {
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str); my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
YYABORT; YYABORT;
} }
else
{
push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_UNKNOWN_STORAGE_ENGINE,
ER(ER_UNKNOWN_STORAGE_ENGINE), $1.str);
}
}; };
row_types: row_types:
@ -4621,7 +4627,7 @@ alter:
lex->select_lex.db=lex->name= 0; lex->select_lex.db=lex->name= 0;
lex->like_name= 0; lex->like_name= 0;
bzero((char*) &lex->create_info,sizeof(lex->create_info)); 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.default_table_charset= NULL;
lex->create_info.row_type= ROW_TYPE_NOT_USED; lex->create_info.row_type= ROW_TYPE_NOT_USED;
lex->alter_info.reset(); lex->alter_info.reset();

View File

@ -145,49 +145,7 @@ static handler *archive_create_handler(TABLE_SHARE *table);
*/ */
#define ARCHIVE_MIN_ROWS_TO_USE_BULK_INSERT 2 #define ARCHIVE_MIN_ROWS_TO_USE_BULK_INSERT 2
handlerton archive_hton;
static const char archive_hton_name[]= "ARCHIVE";
static const char archive_hton_comment[]= "Archive storage engine";
/* dummy handlerton - only to have something to return from archive_db_init */
handlerton archive_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
archive_hton_name,
SHOW_OPTION_YES,
archive_hton_comment,
DB_TYPE_ARCHIVE_DB,
archive_db_init,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
NULL, /* savepoint */
NULL, /* rollback to savepoint */
NULL, /* releas 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 */
archive_create_handler, /* Create a new handler */
NULL, /* Drop a database */
archive_db_end, /* Panic call */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Partition flags */
NULL, /* Alter table flags */
NULL, /* Alter interface */
NULL, /* fill_files_table */
HTON_NO_FLAGS,
NULL, /* binlog_func */
NULL, /* binlog_log_query */
NULL /* release_temporary_latches */
};
static handler *archive_create_handler(TABLE_SHARE *table) static handler *archive_create_handler(TABLE_SHARE *table)
{ {
@ -217,11 +175,18 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length,
TRUE Error TRUE Error
*/ */
bool archive_db_init() int archive_db_init()
{ {
DBUG_ENTER("archive_db_init"); DBUG_ENTER("archive_db_init");
if (archive_inited) if (archive_inited)
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
archive_hton.state=SHOW_OPTION_YES;
archive_hton.db_type=DB_TYPE_ARCHIVE_DB;
archive_hton.create=archive_create_handler;
archive_hton.panic=archive_db_end;
archive_hton.flags=HTON_NO_FLAGS;
if (pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST)) if (pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST))
goto error; goto error;
if (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0, if (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0,
@ -1575,16 +1540,19 @@ bool ha_archive::check_and_repair(THD *thd)
DBUG_RETURN(repair(thd, &check_opt)); DBUG_RETURN(repair(thd, &check_opt));
} }
struct st_mysql_storage_engine archive_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &archive_hton };
mysql_declare_plugin(archive) mysql_declare_plugin(archive)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&archive_hton, &archive_storage_engine,
archive_hton_name, "ARCHIVE",
"Brian Aker, MySQL AB", "Brian Aker, MySQL AB",
archive_hton_comment, "Archive storage engine",
NULL, /* Plugin Init */ archive_db_init, /* Plugin Init */
archive_db_done, /* Plugin Deinit */ archive_db_done, /* Plugin Deinit */
0x0100 /* 1.0 */, 0x0100 /* 1.0 */,
} }
mysql_declare_plugin_end; mysql_declare_plugin_end;

View File

@ -136,6 +136,6 @@ public:
bool check_and_repair(THD *thd); bool check_and_repair(THD *thd);
}; };
bool archive_db_init(void); int archive_db_init(void);
int archive_db_end(ha_panic_function type); int archive_db_end(ha_panic_function type);

View File

@ -22,57 +22,9 @@
#include "mysql_priv.h" #include "mysql_priv.h"
#include "ha_blackhole.h" #include "ha_blackhole.h"
#include <mysql/plugin.h>
/* Static declarations for handlerton */ /* Static declarations for handlerton */
static handler *blackhole_create_handler(TABLE_SHARE *table); handlerton blackhole_hton;
static const char blackhole_hton_name[]= "BLACKHOLE";
static const char blackhole_hton_comment[]=
"/dev/null storage engine (anything you write to it disappears)";
/* Blackhole storage engine handlerton */
handlerton blackhole_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
blackhole_hton_name,
SHOW_OPTION_YES,
blackhole_hton_comment,
DB_TYPE_BLACKHOLE_DB,
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 */
blackhole_create_handler, /* 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_CAN_RECREATE | HTON_ALTER_CANNOT_CREATE,
NULL, /* binlog_func */
NULL, /* binlog_log_query */
NULL /* release_temporary_latches */
};
static handler *blackhole_create_handler(TABLE_SHARE *table) static handler *blackhole_create_handler(TABLE_SHARE *table)
{ {
@ -256,14 +208,26 @@ int ha_blackhole::index_last(byte * buf)
DBUG_RETURN(HA_ERR_END_OF_FILE); DBUG_RETURN(HA_ERR_END_OF_FILE);
} }
static int blackhole_init()
{
blackhole_hton.state= SHOW_OPTION_YES;
blackhole_hton.db_type= DB_TYPE_BLACKHOLE_DB;
blackhole_hton.create= blackhole_create_handler;
blackhole_hton.flags= HTON_CAN_RECREATE | HTON_ALTER_CANNOT_CREATE;
return 0;
}
struct st_mysql_storage_engine blackhole_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &blackhole_hton };
mysql_declare_plugin(blackhole) mysql_declare_plugin(blackhole)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&blackhole_hton, &blackhole_storage_engine,
blackhole_hton_name, "BLACKHOLE",
"MySQL AB", "MySQL AB",
blackhole_hton_comment, "/dev/null storage engine (anything you write to it disappears)",
NULL, /* Plugin Init */ blackhole_init, /* Plugin Init */
NULL, /* Plugin Deinit */ NULL, /* Plugin Deinit */
0x0100 /* 1.0 */, 0x0100 /* 1.0 */,
} }

View File

@ -77,45 +77,7 @@ static int tina_init= 0;
static handler *tina_create_handler(TABLE_SHARE *table); static handler *tina_create_handler(TABLE_SHARE *table);
static int tina_init_func(); static int tina_init_func();
static const char tina_hton_name[]= "CSV"; handlerton tina_hton;
static const char tina_hton_comment[]= "CSV storage engine";
handlerton tina_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
tina_hton_name,
SHOW_OPTION_YES,
tina_hton_comment,
DB_TYPE_CSV_DB,
(bool (*)()) tina_init_func,
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 */
tina_create_handler, /* Create a new handler */
NULL, /* Drop a database */
tina_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_CAN_RECREATE,
NULL, /* binlog_func */
NULL /* binlog_log_query */
};
/***************************************************************************** /*****************************************************************************
** TINA tables ** TINA tables
@ -191,6 +153,11 @@ static int tina_init_func()
VOID(pthread_mutex_init(&tina_mutex,MY_MUTEX_INIT_FAST)); VOID(pthread_mutex_init(&tina_mutex,MY_MUTEX_INIT_FAST));
(void) hash_init(&tina_open_tables,system_charset_info,32,0,0, (void) hash_init(&tina_open_tables,system_charset_info,32,0,0,
(hash_get_key) tina_get_key,0,0); (hash_get_key) tina_get_key,0,0);
tina_hton.state= SHOW_OPTION_YES;
tina_hton.db_type= DB_TYPE_CSV_DB;
tina_hton.create= tina_create_handler;
tina_hton.panic= tina_end;
tina_hton.flags= HTON_CAN_RECREATE;
} }
return 0; return 0;
} }
@ -1401,14 +1368,16 @@ bool ha_tina::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES; return COMPATIBLE_DATA_YES;
} }
struct st_mysql_storage_engine csv_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &tina_hton };
mysql_declare_plugin(csv) mysql_declare_plugin(csv)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&tina_hton, &csv_storage_engine,
tina_hton_name, "CSV",
"Brian Aker, MySQL AB", "Brian Aker, MySQL AB",
tina_hton_comment, "CSV storage engine",
tina_init_func, /* Plugin Init */ tina_init_func, /* Plugin Init */
tina_done_func, /* Plugin Deinit */ tina_done_func, /* Plugin Deinit */
0x0100 /* 1.0 */, 0x0100 /* 1.0 */,

View File

@ -77,46 +77,7 @@ static int example_init_func();
static bool example_init_func_for_handlerton(); static bool example_init_func_for_handlerton();
static int example_panic(enum ha_panic_function flag); static int example_panic(enum ha_panic_function flag);
static const char example_hton_name[]= "EXAMPLE"; handlerton example_hton;
static const char example_hton_comment[]= "Example storage engine";
handlerton example_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
example_hton_name,
SHOW_OPTION_YES,
example_hton_comment,
DB_TYPE_EXAMPLE_DB,
example_init_func_for_handlerton,
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 */
example_create_handler, /* Create a new handler */
NULL, /* Drop a database */
example_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,
NULL,
NULL,
};
/* Variables for example share methods */ /* Variables for example share methods */
static HASH example_open_tables; // Hash used to track open tables static HASH example_open_tables; // Hash used to track open tables
@ -143,6 +104,11 @@ static int example_init_func()
VOID(pthread_mutex_init(&example_mutex,MY_MUTEX_INIT_FAST)); VOID(pthread_mutex_init(&example_mutex,MY_MUTEX_INIT_FAST));
(void) hash_init(&example_open_tables,system_charset_info,32,0,0, (void) hash_init(&example_open_tables,system_charset_info,32,0,0,
(hash_get_key) example_get_key,0,0); (hash_get_key) example_get_key,0,0);
example_hton.state= SHOW_OPTION_YES;
example_hton.db_type= DB_TYPE_EXAMPLE_DB;
example_hton.create= example_create_handler;
example_hton.flags= HTON_CAN_RECREATE;
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -163,17 +129,6 @@ static int example_done_func()
DBUG_RETURN(0); DBUG_RETURN(0);
} }
static bool example_init_func_for_handlerton()
{
return example_init_func();
}
static int example_panic(enum ha_panic_function flag)
{
return example_done_func();
}
/* /*
Example of simple lock controls. The "share" it creates is structure we will Example of simple lock controls. The "share" it creates is structure we will
pass to each example handler. Do you have to have one of these? Well, you have pass to each example handler. Do you have to have one of these? Well, you have
@ -741,18 +696,21 @@ int ha_example::create(const char *name, TABLE *table_arg,
HA_CREATE_INFO *create_info) HA_CREATE_INFO *create_info)
{ {
DBUG_ENTER("ha_example::create"); DBUG_ENTER("ha_example::create");
/* This is not implemented but we want someone to be able that it works. */ /* This is not implemented but we want someone to be able to see that it works. */
DBUG_RETURN(0); DBUG_RETURN(0);
} }
struct st_mysql_storage_engine example_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &example_hton };
mysql_declare_plugin(example) mysql_declare_plugin(example)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, MYSQL_STORAGE_ENGINE_PLUGIN,
&example_hton, &example_storage_engine,
example_hton_name, "EXAMPLE",
"Brian Aker, MySQL AB", "Brian Aker, MySQL AB",
example_hton_comment, "Example storage engine",
example_init_func, /* Plugin Init */ example_init_func, /* Plugin Init */
example_done_func, /* Plugin Deinit */ example_done_func, /* Plugin Deinit */
0x0001 /* 0.1 */, 0x0001 /* 0.1 */,