Merge bk-internal.mysql.com:/home/bk/mysql-5.1-new

into sergbook.mysql.com:/usr/home/serg/Abk/mysql-5.1


mysql-test/mysql-test-run.pl:
  Auto merged
sql/ha_myisam.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/ha_ndbcluster.h:
  Auto merged
sql/ha_ndbcluster_binlog.cc:
  Auto merged
sql/ha_partition.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/handler.h:
  Auto merged
sql/log.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
storage/archive/ha_archive.cc:
  Auto merged
storage/csv/ha_tina.cc:
  Auto merged
This commit is contained in:
unknown 2006-05-28 14:54:28 +02:00
commit 4eeb61b7e3
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_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 */
/*
@ -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
@ -265,5 +265,25 @@ struct st_mysql_ftparser
int (*init)(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

View file

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

View file

@ -11,7 +11,7 @@ ADD UNDOFILE 'undofile02.dat'
INITIAL_SIZE = 4M
ENGINE=XYZ;
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'
CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'

View file

@ -15,7 +15,7 @@ enable_query_log;
--system mkdir $MYSQLTEST_VARDIR/tmp/bug14354
disable_query_log;
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"
INDEX DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354");
enable_query_log;

View file

@ -97,6 +97,9 @@ pthread_mutex_t bdb_mutex;
static DB_ENV *db_env;
static HASH bdb_open_tables;
static const char berkeley_hton_name[]= "BerkeleyDB";
static const int berkeley_hton_name_length=sizeof(berkeley_hton_name)-1;
const char *berkeley_lock_names[] =
{ "DEFAULT", "OLDEST", "RANDOM", "YOUNGEST", "EXPIRE", "MAXLOCKS",
"MAXWRITE", "MINLOCKS", "MINWRITE", 0 };
@ -125,47 +128,7 @@ static int berkeley_savepoint(THD* thd, void *savepoint);
static int berkeley_release_savepoint(THD* thd, void *savepoint);
static handler *berkeley_create_handler(TABLE_SHARE *table);
static const char berkeley_hton_name[]= "BerkeleyDB";
static const char berkeley_hton_comment[]=
"Supports transactions and page-level locking";
handlerton berkeley_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
berkeley_hton_name,
SHOW_OPTION_YES,
berkeley_hton_comment,
DB_TYPE_BERKELEY_DB,
berkeley_init,
0, /* slot */
sizeof(DB_TXN *), /* savepoint size */
berkeley_close_connection,
berkeley_savepoint, /* savepoint_set */
berkeley_rollback_to_savepoint, /* savepoint_rollback */
berkeley_release_savepoint, /* savepoint_release */
berkeley_commit,
berkeley_rollback,
NULL, /* prepare */
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
berkeley_create_handler, /* Create a new handler */
NULL, /* Drop a database */
berkeley_end, /* Panic call */
NULL, /* Start Consistent Snapshot */
berkeley_flush_logs, /* Flush logs */
berkeley_show_status, /* Show status */
NULL, /* Partition flags */
NULL, /* Alter table flags */
NULL, /* Alter Tablespace */
NULL, /* Fill Files Table */
HTON_CLOSE_CURSORS_AT_COMMIT | HTON_FLUSH_AFTER_RENAME,
NULL, /* binlog_func */
NULL, /* binlog_log_query */
NULL /* release_temporary_latches */
};
handlerton berkeley_hton;
handler *berkeley_create_handler(TABLE_SHARE *table)
{
@ -181,12 +144,27 @@ typedef struct st_berkeley_trx_data {
/* General functions */
bool berkeley_init(void)
int berkeley_init(void)
{
DBUG_ENTER("berkeley_init");
berkeley_hton.state=SHOW_OPTION_YES;
berkeley_hton.db_type=DB_TYPE_BERKELEY_DB;
berkeley_hton.savepoint_offset=sizeof(DB_TXN *);
berkeley_hton.close_connection=berkeley_close_connection;
berkeley_hton.savepoint_set=berkeley_savepoint;
berkeley_hton.savepoint_rollback=berkeley_rollback_to_savepoint;
berkeley_hton.savepoint_release=berkeley_release_savepoint;
berkeley_hton.commit=berkeley_commit;
berkeley_hton.rollback=berkeley_rollback;
berkeley_hton.create=berkeley_create_handler;
berkeley_hton.panic=berkeley_end;
berkeley_hton.flush_logs=berkeley_flush_logs;
berkeley_hton.show_status=berkeley_show_status;
berkeley_hton.flags=HTON_CLOSE_CURSORS_AT_COMMIT | HTON_FLUSH_AFTER_RENAME;
if (have_berkeley_db != SHOW_OPTION_YES)
goto error;
return 0; // nothing else to do
if (!berkeley_tmpdir)
berkeley_tmpdir=mysql_tmpdir;
@ -373,7 +351,6 @@ static int berkeley_release_savepoint(THD* thd, void *savepoint)
static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
{
char **all_logs, **free_logs, **a, **f;
uint hton_name_len= strlen(berkeley_hton.name);
int error=1;
MEM_ROOT **root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC);
MEM_ROOT show_logs_root, *old_mem_root= *root_ptr;
@ -401,15 +378,15 @@ static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
if (f && *f && strcmp(*a, *f) == 0)
{
f++;
if ((error= stat_print(thd, berkeley_hton.name, hton_name_len,
*a, strlen(*a),
if ((error= stat_print(thd, berkeley_hton_name,
berkeley_hton_name_length, *a, strlen(*a),
STRING_WITH_LEN(SHOW_LOG_STATUS_FREE))))
break;
}
else
{
if ((error= stat_print(thd, berkeley_hton.name, hton_name_len,
*a, strlen(*a),
if ((error= stat_print(thd, berkeley_hton_name,
berkeley_hton_name_length, *a, strlen(*a),
STRING_WITH_LEN(SHOW_LOG_STATUS_INUSE))))
break;
}
@ -2732,15 +2709,17 @@ bool ha_berkeley::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES;
}
struct st_mysql_storage_engine berkeley_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &berkeley_hton };
mysql_declare_plugin(berkeley)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&berkeley_hton,
&berkeley_storage_engine,
berkeley_hton_name,
"Sleepycat Software",
berkeley_hton_comment,
NULL, /* Plugin Init */
"Supports transactions and page-level locking",
berkeley_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100, /* 1.0 */
0

View file

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

View file

@ -370,47 +370,7 @@ static int federated_rollback(THD *thd, bool all);
/* Federated storage engine handlerton */
static const char federated_hton_name[]= "FEDERATED";
static const char federated_hton_comment[]= "Federated MySQL storage engine";
handlerton federated_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
federated_hton_name,
SHOW_OPTION_YES,
federated_hton_comment,
DB_TYPE_FEDERATED_DB,
federated_db_init,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
NULL, /* savepoint */
NULL, /* rollback to savepoint */
NULL, /* release savepoint */
federated_commit, /* commit */
federated_rollback, /* rollback */
NULL, /* prepare */
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
federated_create_handler, /* Create a new handler */
NULL, /* Drop a database */
federated_db_end, /* Panic call */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Partition flags */
NULL, /* Alter table flags */
NULL, /* Alter Tablespace */
NULL, /* Fill FILES table */
HTON_ALTER_NOT_SUPPORTED,
NULL, /* binlog_func */
NULL, /* binlog_log_query */
NULL /* release_temporary_latches */
};
handlerton federated_hton;
static handler *federated_create_handler(TABLE_SHARE *table)
{
@ -442,6 +402,15 @@ static byte *federated_get_key(FEDERATED_SHARE *share, uint *length,
bool federated_db_init()
{
DBUG_ENTER("federated_db_init");
federated_hton.state= SHOW_OPTION_YES;
federated_hton.db_type= DB_TYPE_FEDERATED_DB;
federated_hton.commit= federated_commit;
federated_hton.rollback= federated_rollback;
federated_hton.create= federated_create_handler;
federated_hton.panic= federated_db_end;
federated_hton.flags= HTON_ALTER_NOT_SUPPORTED;
if (pthread_mutex_init(&federated_mutex, MY_MUTEX_INIT_FAST))
goto error;
if (!hash_init(&federated_open_tables, system_charset_info, 32, 0, 0,
@ -2797,7 +2766,7 @@ int ha_federated::connection_autocommit(bool state)
DBUG_ENTER("ha_federated::connection_autocommit");
text= (state == true) ? "SET AUTOCOMMIT=1" : "SET AUTOCOMMIT=0";
DBUG_RETURN(execute_simple_query(text, 16));
}
}
int ha_federated::execute_simple_query(const char *query, int len)
@ -2811,15 +2780,17 @@ int ha_federated::execute_simple_query(const char *query, int len)
DBUG_RETURN(0);
}
struct st_mysql_storage_engine federated_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &federated_hton };
mysql_declare_plugin(federated)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&federated_hton,
federated_hton_name,
&federated_storage_engine,
"FEDERATED",
"Patrick Galbraith and Brian Aker, MySQL AB",
federated_hton_comment,
NULL, /* Plugin Init */
"Federated MySQL storage engine",
federated_db_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
}

View file

@ -26,47 +26,17 @@
static handler *heap_create_handler(TABLE_SHARE *table);
static const char heap_hton_name[]= "MEMORY";
static const char heap_hton_comment[]=
"Hash based, stored in memory, useful for temporary tables";
handlerton heap_hton;
handlerton heap_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
heap_hton_name,
SHOW_OPTION_YES,
heap_hton_comment,
DB_TYPE_HEAP,
NULL,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
NULL, /* savepoint */
NULL, /* rollback to savepoint */
NULL, /* release savepoint */
NULL, /* commit */
NULL, /* rollback */
NULL, /* prepare */
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
heap_create_handler, /* Create a new handler */
NULL, /* Drop a database */
heap_panic, /* Panic call */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Partition flags */
NULL, /* Alter table flags */
NULL, /* Alter Tablespace */
NULL, /* Fill Files Table */
HTON_CAN_RECREATE,
NULL, /* binlog_func */
NULL, /* binlog_log_query */
NULL /* release_temporary_latches */
};
int heap_init()
{
heap_hton.state= SHOW_OPTION_YES;
heap_hton.db_type= DB_TYPE_HEAP;
heap_hton.create= heap_create_handler;
heap_hton.panic= heap_panic;
heap_hton.flags= HTON_CAN_RECREATE;
return 0;
}
static handler *heap_create_handler(TABLE_SHARE *table)
{
@ -711,14 +681,17 @@ bool ha_heap::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES;
}
struct st_mysql_storage_engine heap_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &heap_hton};
mysql_declare_plugin(heap)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&heap_hton,
heap_hton_name,
&heap_storage_engine,
"MEMORY",
"MySQL AB",
heap_hton_comment,
NULL,
"Hash based, stored in memory, useful for temporary tables",
heap_init,
NULL,
0x0100, /* 1.0 */
0

View file

@ -42,7 +42,6 @@ have disables the InnoDB inlining in this file. */
#define MAX_ULONG_BIT ((ulong) 1 << (sizeof(ulong)*8-1))
#ifdef WITH_INNOBASE_STORAGE_ENGINE
#include "ha_innodb.h"
pthread_mutex_t innobase_share_mutex, /* to protect innobase_open_files */
@ -206,47 +205,8 @@ static int innobase_release_savepoint(THD* thd, void *savepoint);
static handler *innobase_create_handler(TABLE_SHARE *table);
static const char innobase_hton_name[]= "InnoDB";
static const char innobase_hton_comment[]=
"Supports transactions, row-level locking, and foreign keys";
handlerton innobase_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
innobase_hton_name,
SHOW_OPTION_YES,
innobase_hton_comment,
DB_TYPE_INNODB,
innobase_init,
0, /* slot */
sizeof(trx_named_savept_t), /* savepoint size. TODO: use it */
innobase_close_connection,
innobase_savepoint,
innobase_rollback_to_savepoint,
innobase_release_savepoint,
innobase_commit, /* commit */
innobase_rollback, /* rollback */
innobase_xa_prepare, /* prepare */
innobase_xa_recover, /* recover */
innobase_commit_by_xid, /* commit_by_xid */
innobase_rollback_by_xid, /* rollback_by_xid */
innobase_create_cursor_view,
innobase_set_cursor_view,
innobase_close_cursor_view,
innobase_create_handler, /* Create a new handler */
innobase_drop_database, /* Drop a database */
innobase_end, /* Panic call */
innobase_start_trx_and_assign_read_view, /* Start Consistent Snapshot */
innobase_flush_logs, /* Flush logs */
innobase_show_status, /* Show status */
NULL, /* Partition flags */
NULL, /* Alter table flags */
NULL, /* alter_tablespace */
NULL, /* Fill FILES table */
HTON_NO_FLAGS,
NULL, /* binlog_func */
NULL, /* binlog_log_query */
innobase_release_temporary_latches
};
handlerton innobase_hton;
static handler *innobase_create_handler(TABLE_SHARE *table)
{
@ -1230,10 +1190,9 @@ ha_innobase::init_table_handle_for_HANDLER(void)
/*************************************************************************
Opens an InnoDB database. */
bool
int
innobase_init(void)
/*===============*/
/* out: &innobase_hton, or NULL on error */
{
static char current_dir[3]; /* Set if using current lib */
int err;
@ -1242,8 +1201,33 @@ innobase_init(void)
DBUG_ENTER("innobase_init");
innobase_hton.state=have_innodb;
innobase_hton.db_type= DB_TYPE_INNODB;
innobase_hton.savepoint_offset=sizeof(trx_named_savept_t);
innobase_hton.close_connection=innobase_close_connection;
innobase_hton.savepoint_set=innobase_savepoint;
innobase_hton.savepoint_rollback=innobase_rollback_to_savepoint;
innobase_hton.savepoint_release=innobase_release_savepoint;
innobase_hton.commit=innobase_commit;
innobase_hton.rollback=innobase_rollback;
innobase_hton.prepare=innobase_xa_prepare;
innobase_hton.recover=innobase_xa_recover;
innobase_hton.commit_by_xid=innobase_commit_by_xid;
innobase_hton.rollback_by_xid=innobase_rollback_by_xid;
innobase_hton.create_cursor_read_view=innobase_create_cursor_view;
innobase_hton.set_cursor_read_view=innobase_set_cursor_view;
innobase_hton.close_cursor_read_view=innobase_close_cursor_view;
innobase_hton.create=innobase_create_handler;
innobase_hton.drop_database=innobase_drop_database;
innobase_hton.panic=innobase_end;
innobase_hton.start_consistent_snapshot=innobase_start_trx_and_assign_read_view;
innobase_hton.flush_logs=innobase_flush_logs;
innobase_hton.show_status=innobase_show_status;
innobase_hton.flags=HTON_NO_FLAGS;
innobase_hton.release_temporary_latches=innobase_release_temporary_latches;
if (have_innodb != SHOW_OPTION_YES)
goto error;
DBUG_RETURN(0); // nothing else to do
ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
@ -6473,7 +6457,7 @@ innodb_show_status(
bool result = FALSE;
if (stat_print(thd, innobase_hton.name, strlen(innobase_hton.name),
if (stat_print(thd, innobase_hton_name, strlen(innobase_hton_name),
STRING_WITH_LEN(""), str, flen)) {
result= TRUE;
}
@ -6500,7 +6484,7 @@ innodb_mutex_show_status(
ulint rw_lock_count_os_wait= 0;
ulint rw_lock_count_os_yield= 0;
ulonglong rw_lock_wait_time= 0;
uint hton_name_len= strlen(innobase_hton.name), buf1len, buf2len;
uint hton_name_len= strlen(innobase_hton_name), buf1len, buf2len;
DBUG_ENTER("innodb_mutex_show_status");
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
@ -6527,7 +6511,7 @@ innodb_mutex_show_status(
mutex->count_os_yield,
mutex->lspent_time/1000);
if (stat_print(thd, innobase_hton.name,
if (stat_print(thd, innobase_hton_name,
hton_name_len, buf1, buf1len,
buf2, buf2len)) {
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
@ -6557,7 +6541,7 @@ innodb_mutex_show_status(
rw_lock_count_os_wait, rw_lock_count_os_yield,
rw_lock_wait_time/1000);
if (stat_print(thd, innobase_hton.name, hton_name_len,
if (stat_print(thd, innobase_hton_name, hton_name_len,
STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len)) {
DBUG_RETURN(1);
}
@ -7459,19 +7443,20 @@ bool ha_innobase::check_if_incompatible_data(
return COMPATIBLE_DATA_YES;
}
struct st_mysql_storage_engine innobase_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &innobase_hton};
mysql_declare_plugin(innobase)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&innobase_hton,
&innobase_storage_engine,
innobase_hton_name,
"Innobase OY",
innobase_hton_comment,
NULL, /* Plugin Init */
"Supports transactions, row-level locking, and foreign keys",
innobase_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
0
}
mysql_declare_plugin_end;
#endif

View file

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

View file

@ -52,63 +52,11 @@ TYPELIB myisam_stats_method_typelib= {
** MyISAM tables
*****************************************************************************/
static handler *myisam_create_handler(TABLE_SHARE *table);
/* MyISAM handlerton */
static const char myisam_hton_name[]= "MyISAM";
static const char myisam_hton_comment[]=
"Default engine as of MySQL 3.23 with great performance";
handlerton myisam_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
myisam_hton_name,
SHOW_OPTION_YES,
myisam_hton_comment,
DB_TYPE_MYISAM,
NULL,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
NULL, /* savepoint */
NULL, /* rollback to savepoint */
NULL, /* release savepoint */
NULL, /* commit */
NULL, /* rollback */
NULL, /* prepare */
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
/*
MyISAM doesn't support transactions and doesn't have
transaction-dependent context: cursors can survive a commit.
*/
myisam_create_handler, /* Create a new handler */
NULL, /* Drop a database */
mi_panic,/* Panic call */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Partition flags */
NULL, /* Alter table flags */
NULL, /* Alter Tablespace */
NULL, /* Fill Files Table */
HTON_CAN_RECREATE,
NULL, /* binlog_func */
NULL, /* binlog_log_query */
NULL /* release_temporary_latches */
};
static handler *myisam_create_handler(TABLE_SHARE *table)
{
return new ha_myisam(table);
}
// collect errors printed by mi_check routines
static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
@ -1798,17 +1746,32 @@ bool ha_myisam::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES;
}
handlerton myisam_hton;
static int myisam_init()
{
myisam_hton.state=SHOW_OPTION_YES;
myisam_hton.db_type=DB_TYPE_MYISAM;
myisam_hton.create=myisam_create_handler;
myisam_hton.panic=mi_panic;
myisam_hton.flags=HTON_CAN_RECREATE;
return 0;
}
struct st_mysql_storage_engine myisam_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &myisam_hton };
mysql_declare_plugin(myisam)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&myisam_hton,
myisam_hton_name,
&myisam_storage_engine,
"MyISAM",
"MySQL AB",
myisam_hton_comment,
NULL, /* Plugin Init */
"Default engine as of MySQL 3.23 with great performance",
myisam_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100, /* 1.0 */
0
}
mysql_declare_plugin_end;

View file

@ -38,47 +38,7 @@ static handler *myisammrg_create_handler(TABLE_SHARE *table);
/* MyISAM MERGE handlerton */
static const char myisammrg_hton_name[]= "MRG_MYISAM";
static const char myisammrg_hton_comment[]=
"Collection of identical MyISAM tables";
handlerton myisammrg_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
myisammrg_hton_name,
SHOW_OPTION_YES,
myisammrg_hton_comment,
DB_TYPE_MRG_MYISAM,
NULL,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
NULL, /* savepoint */
NULL, /* rollback to savepoint */
NULL, /* release savepoint */
NULL, /* commit */
NULL, /* rollback */
NULL, /* prepare */
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
myisammrg_create_handler, /* Create a new handler */
NULL, /* Drop a database */
myrg_panic, /* Panic call */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Partition flags */
NULL, /* Alter table flags */
NULL, /* Alter Tablespace */
NULL, /* Fill Files Table */
HTON_CAN_RECREATE | HTON_ALTER_CANNOT_CREATE,
NULL, /* binlog_func */
NULL, /* binlog_log_query */
NULL /* release_temporary_latches */
};
handlerton myisammrg_hton;
static handler *myisammrg_create_handler(TABLE_SHARE *table)
{
@ -580,14 +540,27 @@ bool ha_myisammrg::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_NO;
}
static int myisammrg_init()
{
myisammrg_hton.state=SHOW_OPTION_YES;
myisammrg_hton.db_type=DB_TYPE_MRG_MYISAM;
myisammrg_hton.create=myisammrg_create_handler;
myisammrg_hton.panic=myrg_panic;
myisammrg_hton.flags= HTON_CAN_RECREATE | HTON_ALTER_CANNOT_CREATE;
return 0;
}
struct st_mysql_storage_engine myisammrg_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &myisammrg_hton };
mysql_declare_plugin(myisammrg)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&myisammrg_hton,
myisammrg_hton_name,
&myisammrg_storage_engine,
"MRG_MYISAM",
"MySQL AB",
myisammrg_hton_comment,
NULL, /* Plugin Init */
"Collection of identical MyISAM tables",
myisammrg_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100, /* 1.0 */
0

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_alter_table_flags(uint flags);
static bool ndbcluster_init(void);
static int ndbcluster_init(void);
static int ndbcluster_end(ha_panic_function flag);
static bool ndbcluster_show_status(THD*,stat_print_fn *,enum ha_stat_type);
static int ndbcluster_alter_tablespace(THD* thd, st_alter_tablespace *info);
static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond);
static const char ndbcluster_hton_name[]= "ndbcluster";
static const char ndbcluster_hton_comment[]= "Clustered, fault-tolerant tables";
handlerton ndbcluster_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"ndbcluster",
SHOW_OPTION_YES,
"Clustered, fault-tolerant tables",
DB_TYPE_NDBCLUSTER,
ndbcluster_init,
~(uint)0, /* slot */
/* below are initialized by name in ndbcluster_init() */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
handlerton ndbcluster_hton;
static handler *ndbcluster_create_handler(TABLE_SHARE *table)
{
@ -6107,17 +6094,18 @@ static int connect_callback()
}
extern int ndb_dictionary_is_mysqld;
static bool ndbcluster_init()
static int ndbcluster_init()
{
int res;
DBUG_ENTER("ndbcluster_init");
ndb_dictionary_is_mysqld= 1;
if (have_ndbcluster != SHOW_OPTION_YES)
goto ndbcluster_init_error;
{
handlerton &h= ndbcluster_hton;
h.state= have_ndbcluster;
h.db_type= DB_TYPE_NDBCLUSTER;
h.close_connection= ndbcluster_close_connection;
h.commit= ndbcluster_commit;
h.rollback= ndbcluster_rollback;
@ -6135,6 +6123,9 @@ static bool ndbcluster_init()
h.flags= HTON_TEMPORARY_NOT_SUPPORTED;
}
if (have_ndbcluster != SHOW_OPTION_YES)
DBUG_RETURN(0); // nothing else to do
// Set connectstring if specified
if (opt_ndbcluster_connectstring != 0)
DBUG_PRINT("connectstring", ("%s", opt_ndbcluster_connectstring));
@ -6206,7 +6197,7 @@ static bool ndbcluster_init()
if (ndbcluster_binlog_start())
goto ndbcluster_init_error;
#endif /* HAVE_NDB_BINLOG */
pthread_mutex_init(&LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_ndb_util_thread, NULL);
@ -6222,7 +6213,7 @@ static bool ndbcluster_init()
pthread_cond_destroy(&COND_ndb_util_thread);
goto ndbcluster_init_error;
}
ndbcluster_inited= 1;
DBUG_RETURN(FALSE);
@ -9383,9 +9374,8 @@ ndbcluster_show_status(THD* thd, stat_print_fn *stat_print,
ndb_number_of_storage_nodes,
ndb_number_of_ready_storage_nodes,
ndb_connect_count);
if (stat_print(thd, ndbcluster_hton.name, strlen(ndbcluster_hton.name),
"connection", strlen("connection"),
buf, buflen))
if (stat_print(thd, ndbcluster_hton_name, ndbcluster_hton_name_length,
STRING_WITH_LEN("connection"), buf, buflen))
DBUG_RETURN(TRUE);
if (get_thd_ndb(thd) && get_thd_ndb(thd)->ndb)
@ -9399,7 +9389,7 @@ ndbcluster_show_status(THD* thd, stat_print_fn *stat_print,
my_snprintf(buf, sizeof(buf),
"created=%u, free=%u, sizeof=%u",
tmp.m_created, tmp.m_free, tmp.m_sizeof);
if (stat_print(thd, ndbcluster_hton.name, strlen(ndbcluster_hton.name),
if (stat_print(thd, ndbcluster_hton_name, ndbcluster_hton_name_length,
tmp.m_name, strlen(tmp.m_name), buf, buflen))
DBUG_RETURN(TRUE);
}
@ -10064,8 +10054,8 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond)
strlen(ts.getDefaultLogfileGroup()),
system_charset_info);
table->field[c++]->set_null(); // LOGFILE_GROUP_NUMBER
table->field[c++]->store(ndbcluster_hton.name,
strlen(ndbcluster_hton.name),
table->field[c++]->store(ndbcluster_hton_name,
ndbcluster_hton_name_length,
system_charset_info); // ENGINE
table->field[c++]->set_null(); // FULLTEXT_KEYS
@ -10158,8 +10148,8 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond)
strlen(uf.getLogfileGroup()),
system_charset_info);
table->field[c++]->store(uf.getLogfileGroupId()); // LOGFILE_GROUP_NUMBER
table->field[c++]->store(ndbcluster_hton.name,
strlen(ndbcluster_hton.name),
table->field[c++]->store(ndbcluster_hton_name,
ndbcluster_hton_name_length,
system_charset_info); // ENGINE
table->field[c++]->set_null(); // FULLTEXT_KEYS
@ -10205,15 +10195,17 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond)
DBUG_RETURN(0);
}
struct st_mysql_storage_engine ndbcluster_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &ndbcluster_hton };
mysql_declare_plugin(ndbcluster)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&ndbcluster_hton,
&ndbcluster_storage_engine,
ndbcluster_hton_name,
"MySQL AB",
ndbcluster_hton_comment,
NULL, /* Plugin Init */
"Clustered, fault-tolerant tables",
ndbcluster_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
0

View file

@ -903,3 +903,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
int ndbcluster_table_exists_in_engine(THD* thd,
const char *db, const char *name);
void ndbcluster_print_error(int error, const NdbOperation *error_op);
static const char ndbcluster_hton_name[]= "ndbcluster";
static const int ndbcluster_hton_name_length=sizeof(ndbcluster_hton_name)-1;

View file

@ -2360,9 +2360,9 @@ ndbcluster_create_event(Ndb *ndb, const NDBTAB *ndbtab,
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_ILLEGAL_HA_CREATE_OPTION,
ER(ER_ILLEGAL_HA_CREATE_OPTION),
ndbcluster_hton.name,
ndbcluster_hton_name,
"Binlog of table with BLOB attribute and no PK");
share->flags|= NSF_NO_BINLOG;
DBUG_RETURN(-1);
}
@ -3822,7 +3822,7 @@ ndbcluster_show_status_binlog(THD* thd, stat_print_fn *stat_print,
ndb_latest_received_binlog_epoch,
ndb_latest_handled_binlog_epoch,
ndb_latest_applied_binlog_epoch);
if (stat_print(thd, ndbcluster_hton.name, strlen(ndbcluster_hton.name),
if (stat_print(thd, ndbcluster_hton_name, ndbcluster_hton_name_length,
"binlog", strlen("binlog"),
buf, buflen))
DBUG_RETURN(TRUE);

View file

@ -73,46 +73,18 @@ static handler *partition_create_handler(TABLE_SHARE *share);
static uint partition_flags();
static uint alter_table_flags(uint flags);
static const char partition_hton_name[]= "partition";
static const char partition_hton_comment[]= "Partition Storage Engine Helper";
handlerton partition_hton;
handlerton partition_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
partition_hton_name,
SHOW_OPTION_YES,
partition_hton_comment, /* A comment used by SHOW to describe an engine */
DB_TYPE_PARTITION_DB,
0, /* Method that initializes a storage engine */
0, /* slot */
0, /* savepoint size */
NULL /*ndbcluster_close_connection*/,
NULL, /* savepoint_set */
NULL, /* savepoint_rollback */
NULL, /* savepoint_release */
NULL /*ndbcluster_commit*/,
NULL /*ndbcluster_rollback*/,
NULL, /* prepare */
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
NULL,
NULL,
NULL,
partition_create_handler, /* Create a new handler */
NULL, /* Drop a database */
NULL, /* Panic call */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
partition_flags, /* Partition flags */
alter_table_flags, /* Partition flags */
NULL, /* Alter Tablespace */
NULL, /* Fill FILES table */
HTON_NOT_USER_SELECTABLE | HTON_HIDDEN,
NULL, /* binlog_func */
NULL, /* binlog_log_query */
NULL /* release_temporary_latches */
};
static int partition_initialize()
{
partition_hton.state= SHOW_OPTION_YES;
partition_hton.db_type= DB_TYPE_PARTITION_DB;
partition_hton.create= partition_create_handler;
partition_hton.partition_flags= partition_flags;
partition_hton.alter_table_flags= alter_table_flags;
partition_hton.flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN;
return 0;
}
/*
Create new partition handler
@ -5523,15 +5495,17 @@ static int free_share(PARTITION_SHARE *share)
}
#endif /* NOT_USED */
struct st_mysql_storage_engine partition_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &partition_hton };
mysql_declare_plugin(partition)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&partition_hton,
partition_hton_name,
&partition_storage_engine,
"partition",
"Mikael Ronstrom, MySQL AB",
partition_hton_comment,
NULL, /* Plugin Init */
"Partition Storage Engine Helper",
partition_initialize, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100, /* 1.0 */
0

View file

@ -48,6 +48,7 @@
check for dups and to find handlerton from legacy_db_type.
Remove when legacy_db_type is finally gone */
static handlerton *installed_htons[128];
st_mysql_plugin *hton2plugin[MAX_HA];
#define BITMAP_STACKBUF_SIZE (128/8)
@ -57,35 +58,14 @@ KEY_CREATE_INFO default_key_create_info= { HA_KEY_ALG_UNDEF, 0, {NullS,0} };
static handler *create_default(TABLE_SHARE *table);
const handlerton default_hton =
{
MYSQL_HANDLERTON_INTERFACE_VERSION,
"DEFAULT",
SHOW_OPTION_YES,
NULL,
DB_TYPE_DEFAULT,
NULL,
0, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL,
create_default,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, /* alter_tablespace */
NULL, /* fill_files_table */
HTON_NO_FLAGS, /* flags */
NULL, /* binlog_func */
NULL, /* binlog_log_query */
NULL /* release_temporary_latches */
};
static SHOW_COMP_OPTION have_yes= SHOW_OPTION_YES;
/* number of entries in handlertons[] */
ulong total_ha;
ulong total_ha= 0;
/* number of storage engines (from handlertons[]) that support 2pc */
ulong total_ha_2pc;
ulong total_ha_2pc= 0;
/* size of savepoint storage area (see ha_init) */
ulong savepoint_alloc_size;
ulong savepoint_alloc_size= 0;
struct show_table_alias_st sys_table_aliases[]=
{
@ -122,7 +102,7 @@ handlerton *ha_resolve_by_name(THD *thd, LEX_STRING *name)
if ((plugin= plugin_lock(name, MYSQL_STORAGE_ENGINE_PLUGIN)))
{
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (!(hton->flags & HTON_NOT_USER_SELECTABLE))
return hton;
plugin_unlock(plugin);
@ -155,7 +135,7 @@ const char *ha_get_storage_engine(enum legacy_db_type db_type)
default:
if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT &&
installed_htons[db_type])
return installed_htons[db_type]->name;
return hton2plugin[installed_htons[db_type]->slot]->name;
return "*NONE*";
}
}
@ -164,8 +144,7 @@ const char *ha_get_storage_engine(enum legacy_db_type db_type)
static handler *create_default(TABLE_SHARE *table)
{
handlerton *hton=ha_resolve_by_legacy_type(current_thd, DB_TYPE_DEFAULT);
return (hton && hton != &default_hton && hton->create) ?
hton->create(table) : NULL;
return (hton && hton->create) ? hton->create(table) : NULL;
}
@ -183,7 +162,7 @@ handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type)
default:
if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT)
return installed_htons[db_type];
return NULL;
return NULL;
}
}
@ -375,7 +354,7 @@ int ha_finalize_handlerton(st_plugin_int *plugin)
handlerton *hton;
DBUG_ENTER("ha_finalize_handlerton");
if (!(hton= (handlerton *) plugin->plugin->info))
if (!(hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton))
DBUG_RETURN(1);
switch (hton->state)
@ -396,37 +375,26 @@ int ha_finalize_handlerton(st_plugin_int *plugin)
int ha_initialize_handlerton(st_plugin_int *plugin)
{
handlerton *hton;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
DBUG_ENTER("ha_initialize_handlerton");
if (!(hton= (handlerton *) plugin->plugin->info))
DBUG_RETURN(1);
/* for the sake of sanity, we set the handlerton name to be the
same as the plugin name */
hton->name= plugin->name.str;
/*
the switch below and hton->state should be removed when
command-line options for plugins will be implemented
*/
switch (hton->state) {
case SHOW_OPTION_NO:
break;
case SHOW_OPTION_YES:
if (!hton->init || !hton->init())
{
uint tmp= hton->savepoint_offset;
hton->savepoint_offset= savepoint_alloc_size;
savepoint_alloc_size+= tmp;
hton->slot= total_ha++;
if (hton->prepare)
total_ha_2pc++;
/* now check the db_type for conflict */
if (hton->db_type <= DB_TYPE_UNKNOWN ||
if (hton->db_type <= DB_TYPE_UNKNOWN ||
hton->db_type >= DB_TYPE_DEFAULT ||
installed_htons[hton->db_type])
{
int idx= (int) DB_TYPE_FIRST_DYNAMIC;
while (idx < (int) DB_TYPE_DEFAULT && installed_htons[idx])
idx++;
@ -437,10 +405,17 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
}
if (hton->db_type != DB_TYPE_UNKNOWN)
sql_print_warning("Storage engine '%s' has conflicting typecode. "
"Assigning value %d.", hton->name, idx);
"Assigning value %d.", plugin->plugin->name, idx);
hton->db_type= (enum legacy_db_type) idx;
}
installed_htons[hton->db_type]= hton;
uint tmp= hton->savepoint_offset;
hton->savepoint_offset= savepoint_alloc_size;
savepoint_alloc_size+= tmp;
hton->slot= total_ha++;
hton2plugin[hton->slot]=plugin->plugin;
if (hton->prepare)
total_ha_2pc++;
break;
}
/* fall through */
@ -451,33 +426,14 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
DBUG_RETURN(0);
}
static my_bool init_handlerton(THD *unused1, st_plugin_int *plugin,
void *unused2)
{
if (plugin->state == PLUGIN_IS_UNINITIALIZED)
{
ha_initialize_handlerton(plugin);
plugin->state= PLUGIN_IS_READY;
}
return FALSE;
}
int ha_init()
{
int error= 0;
total_ha= savepoint_alloc_size= 0;
DBUG_ENTER("ha_init");
bzero(installed_htons, sizeof(installed_htons));
if (ha_init_errors())
DBUG_RETURN(1);
if (plugin_foreach(NULL, init_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, 0))
DBUG_RETURN(1);
DBUG_ASSERT(total_ha < MAX_HA);
/*
Check if there is a transaction-capable storage engine besides the
@ -498,7 +454,7 @@ int ha_init()
static my_bool panic_handlerton(THD *unused1, st_plugin_int *plugin,
void *arg)
{
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->panic)
((int*)arg)[0]|= hton->panic((enum ha_panic_function)((int*)arg)[1]);
return FALSE;
@ -508,10 +464,10 @@ static my_bool panic_handlerton(THD *unused1, st_plugin_int *plugin,
int ha_panic(enum ha_panic_function flag)
{
int error[2];
error[0]= 0; error[1]= (int)flag;
plugin_foreach(NULL, panic_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, error);
if (flag == HA_PANIC_CLOSE && ha_finish_errors())
error[0]= 1;
return error[0];
@ -520,7 +476,7 @@ int ha_panic(enum ha_panic_function flag)
static my_bool dropdb_handlerton(THD *unused1, st_plugin_int *plugin,
void *path)
{
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->drop_database)
hton->drop_database((char *)path);
return FALSE;
@ -536,8 +492,8 @@ void ha_drop_database(char* path)
static my_bool closecon_handlerton(THD *thd, st_plugin_int *plugin,
void *unused)
{
handlerton *hton= (handlerton *) plugin->plugin->info;
/* there's no need to rollback here as all transactions must
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
/* there's no need to rollback here as all transactions must
be rolled back already */
if (hton->state == SHOW_OPTION_YES && hton->close_connection &&
thd->ha_data[hton->slot])
@ -628,7 +584,8 @@ int ha_prepare(THD *thd)
else
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), (*ht)->name);
ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
hton2plugin[(*ht)->slot]->name);
}
}
}
@ -867,7 +824,7 @@ struct xahton_st {
static my_bool xacommit_handlerton(THD *unused1, st_plugin_int *plugin,
void *arg)
{
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->recover)
{
hton->commit_by_xid(((struct xahton_st *)arg)->xid);
@ -879,7 +836,7 @@ static my_bool xacommit_handlerton(THD *unused1, st_plugin_int *plugin,
static my_bool xarollback_handlerton(THD *unused1, st_plugin_int *plugin,
void *arg)
{
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->recover)
{
hton->rollback_by_xid(((struct xahton_st *)arg)->xid);
@ -986,16 +943,16 @@ struct xarecover_st
static my_bool xarecover_handlerton(THD *unused, st_plugin_int *plugin,
void *arg)
{
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
struct xarecover_st *info= (struct xarecover_st *) arg;
int got;
if (hton->state == SHOW_OPTION_YES && hton->recover)
{
while ((got= hton->recover(info->list, info->len)) > 0 )
{
sql_print_information("Found %d prepared transaction(s) in %s",
got, hton->name);
got, hton2plugin[hton->slot]->name);
for (int i=0; i < got; i ++)
{
my_xid x=info->list[i].get_my_xid();
@ -1175,7 +1132,7 @@ bool mysql_xa_recover(THD *thd)
static my_bool release_temporary_latches(THD *thd, st_plugin_int *plugin,
void *unused)
{
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->release_temporary_latches)
hton->release_temporary_latches(thd);
@ -1300,7 +1257,7 @@ int ha_release_savepoint(THD *thd, SAVEPOINT *sv)
static my_bool snapshot_handlerton(THD *thd, st_plugin_int *plugin,
void *arg)
{
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES &&
hton->start_consistent_snapshot)
{
@ -1331,7 +1288,7 @@ int ha_start_consistent_snapshot(THD *thd)
static my_bool flush_handlerton(THD *thd, st_plugin_int *plugin,
void *arg)
{
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->flush_logs && hton->flush_logs())
return TRUE;
return FALSE;
@ -2642,7 +2599,7 @@ struct binlog_func_st
static my_bool binlog_func_list(THD *thd, st_plugin_int *plugin, void *arg)
{
hton_list_st *hton_list= (hton_list_st *)arg;
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->binlog_func)
{
uint sz= hton_list->sz;
@ -3013,7 +2970,7 @@ int handler::index_read_idx(byte * buf, uint index, const byte * key,
SYNOPSIS
ha_known_exts()
NOTES
No mutexes, worst case race is a minor surplus memory allocation
We have to recreate the extension map if mysqld is restarted (for example
@ -3027,14 +2984,14 @@ static my_bool exts_handlerton(THD *unused, st_plugin_int *plugin,
void *arg)
{
List<char> *found_exts= (List<char> *) arg;
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
handler *file;
if (hton->state == SHOW_OPTION_YES && hton->create &&
(file= hton->create((TABLE_SHARE*) 0)))
{
List_iterator_fast<char> it(*found_exts);
const char **ext, *old_ext;
for (ext= file->bas_ext(); *ext; ext++)
{
while ((old_ext= it++))
@ -3063,14 +3020,14 @@ TYPELIB *ha_known_exts(void)
known_extensions_id= mysys_usage_id;
found_exts.push_back((char*) triggers_file_ext);
found_exts.push_back((char*) trigname_file_ext);
plugin_foreach(NULL, exts_handlerton,
plugin_foreach(NULL, exts_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, &found_exts);
ext= (const char **) my_once_alloc(sizeof(char *)*
(found_exts.elements+1),
MYF(MY_WME | MY_FAE));
DBUG_ASSERT(ext != 0);
known_extensions.count= found_exts.elements;
known_extensions.type_names= ext;
@ -3103,7 +3060,7 @@ static my_bool showstat_handlerton(THD *thd, st_plugin_int *plugin,
void *arg)
{
enum ha_stat_type stat= *(enum ha_stat_type *) arg;
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (hton->state == SHOW_OPTION_YES && hton->show_status &&
hton->show_status(thd, stat_print, stat))
return TRUE;
@ -3126,16 +3083,19 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat)
if (db_type == NULL)
{
result= plugin_foreach(thd, showstat_handlerton,
result= plugin_foreach(thd, showstat_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, &stat);
}
else
{
if (db_type->state != SHOW_OPTION_YES)
result= stat_print(thd, db_type->name, strlen(db_type->name),
{
const char *name=hton2plugin[db_type->slot]->name;
result= stat_print(thd, name, strlen(name),
"", 0, "DISABLED", 8) ? 1 : 0;
}
else
result= db_type->show_status &&
result= db_type->show_status &&
db_type->show_status(thd, stat_print, stat) ? 1 : 0;
}

View file

@ -177,6 +177,7 @@
so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
example + csv + heap + blackhole + federated + 0
(yes, the sum is deliberately inaccurate)
TODO remove the limit, use dynarrays
*/
#define MAX_HA 15
@ -460,6 +461,7 @@ typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len,
const char *file, uint file_len,
const char *status, uint status_len);
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
extern st_mysql_plugin *hton2plugin[MAX_HA];
/*
handlerton is a singleton structure - one instance per storage engine -
@ -475,38 +477,15 @@ enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
struct handlerton
{
/*
handlerton structure version
*/
const int interface_version;
/* last version change: 0x0001 in 5.1.6 */
#define MYSQL_HANDLERTON_INTERFACE_VERSION 0x0001
/*
storage engine name as it should be printed to a user
*/
const char *name;
/*
Historical marker for if the engine is available of not
Historical marker for if the engine is available of not
*/
SHOW_COMP_OPTION state;
/*
A comment used by SHOW to describe an engine.
*/
const char *comment;
/*
Historical number used for frm file to determine the correct storage engine.
This is going away and new engines will just use "name" for this.
*/
enum legacy_db_type db_type;
/*
Method that initizlizes a storage engine
*/
bool (*init)();
/*
each storage engine has it's own memory area (actually a pointer)
in the thd, for storing per-connection information.
@ -587,8 +566,6 @@ struct handlerton
int (*release_temporary_latches)(THD *thd);
};
extern const handlerton default_hton;
struct show_table_alias_st {
const char *alias;
enum legacy_db_type type;
@ -1553,7 +1530,7 @@ static inline enum legacy_db_type ha_legacy_type(const handlerton *db_type)
static inline const char *ha_resolve_storage_engine_name(const handlerton *db_type)
{
return db_type == NULL ? "UNKNOWN" : db_type->name;
return db_type == NULL ? "UNKNOWN" : hton2plugin[db_type->slot]->name;
}
static inline bool ha_check_storage_engine_flag(const handlerton *db_type, uint32 flag)

View file

@ -47,7 +47,7 @@ ulong sync_binlog_counter= 0;
static bool test_if_number(const char *str,
long *res, bool allow_wildcards);
static bool binlog_init();
static int binlog_init();
static int binlog_close_connection(THD *thd);
static int binlog_savepoint_set(THD *thd, void *sv);
static int binlog_savepoint_rollback(THD *thd, void *sv);
@ -78,49 +78,7 @@ struct binlog_trx_data {
Rows_log_event *pending; // The pending binrows event
};
static const char binlog_hton_name[]= "binlog";
static const char binlog_hton_comment[]=
"This is a meta storage engine to represent the binlog in a transaction";
handlerton binlog_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
binlog_hton_name,
SHOW_OPTION_YES,
binlog_hton_comment,
DB_TYPE_BINLOG, /* IGNORE for now */
binlog_init,
0,
sizeof(my_off_t), /* savepoint size = binlog offset */
binlog_close_connection,
binlog_savepoint_set,
binlog_savepoint_rollback,
NULL, /* savepoint_release */
binlog_commit,
binlog_rollback,
binlog_prepare,
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
NULL, /* Create a new handler */
NULL, /* Drop a database */
NULL, /* Panic call */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Partition flags */
NULL, /* Alter table flags */
NULL, /* Alter Tablespace */
NULL, /* Fill FILES table */
HTON_NOT_USER_SELECTABLE | HTON_HIDDEN,
NULL, /* binlog_func */
NULL, /* binlog_log_query */
NULL /* release_temporary_latches */
};
handlerton binlog_hton;
/*
Open log table of a given type (general or slow log)
@ -1066,9 +1024,20 @@ void Log_to_csv_event_handler::
should be moved here.
*/
bool binlog_init()
int binlog_init()
{
return !opt_bin_log;
binlog_hton.state=opt_bin_log ? SHOW_OPTION_YES : SHOW_OPTION_NO;
binlog_hton.db_type=DB_TYPE_BINLOG;
binlog_hton.savepoint_offset= sizeof(my_off_t);
binlog_hton.close_connection= binlog_close_connection;
binlog_hton.savepoint_set= binlog_savepoint_set;
binlog_hton.savepoint_rollback= binlog_savepoint_rollback;
binlog_hton.commit= binlog_commit;
binlog_hton.rollback= binlog_rollback;
binlog_hton.prepare= binlog_prepare;
binlog_hton.flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN;
return 0;
}
static int binlog_close_connection(THD *thd)
@ -4372,15 +4341,17 @@ err1:
return 1;
}
struct st_mysql_storage_engine binlog_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &binlog_hton };
mysql_declare_plugin(binlog)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&binlog_hton,
binlog_hton_name,
&binlog_storage_engine,
"binlog",
"MySQL AB",
binlog_hton_comment,
NULL, /* Plugin Init */
"This is a pseudo storage engine to represent the binlog in a transaction",
binlog_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
}

View file

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

View file

@ -329,7 +329,7 @@ static char *opt_init_slave, *language_ptr, *opt_init_connect;
static char *default_character_set_name;
static char *character_set_filesystem_name;
static char *my_bind_addr_str;
static char *default_collation_name;
static char *default_collation_name, *default_storage_engine_str;
static char mysql_data_home_buff[2];
static struct passwd *user_info;
static I_List<THD> thread_cache;
@ -2638,12 +2638,6 @@ static int init_common_variables(const char *conf_file_name, int argc,
if (add_status_vars(status_vars))
return 1; // an error was already reported
if (plugin_init())
{
sql_print_error("Failed to init plugins.");
return 1;
}
load_defaults(conf_file_name, groups, &argc, &argv);
defaults_argv=argv;
get_options(argc,argv);
@ -3159,6 +3153,12 @@ server.");
using_update_log=1;
}
if (plugin_init())
{
sql_print_error("Failed to init plugins.");
return 1;
}
/* We have to initialize the storage engines before CSV logging */
if (ha_init())
{
@ -3205,15 +3205,27 @@ server.");
/*
Check that the default storage engine is actually available.
*/
if (!ha_storage_engine_is_enabled(global_system_variables.table_type))
{
if (!opt_bootstrap)
LEX_STRING name= { default_storage_engine_str,
strlen(default_storage_engine_str) };
handlerton *hton= ha_resolve_by_name(0, &name);
if (hton == NULL)
{
sql_print_error("Default storage engine (%s) is not available",
global_system_variables.table_type->name);
sql_print_error("Unknown/unsupported table type: %s",
default_storage_engine_str);
unireg_abort(1);
}
global_system_variables.table_type= &myisam_hton;
if (!ha_storage_engine_is_enabled(hton))
{
if (!opt_bootstrap)
{
sql_print_error("Default storage engine (%s) is not available",
default_storage_engine_str);
unireg_abort(1);
}
hton= &myisam_hton;
}
global_system_variables.table_type= hton;
}
tc_log= (total_ha_2pc > 1 ? (opt_bin_log ?
@ -4962,7 +4974,8 @@ Disable with --skip-bdb (will save memory).",
"Set the default storage engine (table type) for tables.", 0, 0,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"default-table-type", OPT_STORAGE_ENGINE,
"(deprecated) Use --default-storage-engine.", 0, 0,
"(deprecated) Use --default-storage-engine.",
(gptr*)default_storage_engine_str, (gptr*)default_storage_engine_str,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"default-time-zone", OPT_DEFAULT_TIME_ZONE, "Set the default time zone.",
(gptr*) &default_tz_name, (gptr*) &default_tz_name,
@ -6991,8 +7004,8 @@ static void mysql_init_variables(void)
sys_charset_system.value= (char*) system_charset_info->csname;
character_set_filesystem_name= (char*) "binary";
/* Set default values for some option variables */
default_storage_engine_str="MyISAM";
global_system_variables.table_type= &myisam_hton;
global_system_variables.tx_isolation= ISO_REPEATABLE_READ;
global_system_variables.select_limit= (ulonglong) HA_POS_ERROR;
@ -7452,17 +7465,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_BOOTSTRAP:
opt_noacl=opt_bootstrap=1;
break;
case OPT_STORAGE_ENGINE:
{
LEX_STRING name= { argument, strlen(argument) };
if ((global_system_variables.table_type=
ha_resolve_by_name(current_thd, &name)) == NULL)
{
fprintf(stderr,"Unknown/unsupported table type: %s\n",argument);
exit(1);
}
break;
}
case OPT_SERVER_ID:
server_id_supplied = 1;
break;

View file

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

View file

@ -7143,7 +7143,7 @@ bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
HA_CREATE_INFO create_info;
DBUG_ENTER("mysql_create_index");
bzero((char*) &create_info,sizeof(create_info));
create_info.db_type= (handlerton*) &default_hton;
create_info.db_type= 0;
create_info.default_table_charset= thd->variables.collation_database;
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
&create_info, table_list,
@ -7159,7 +7159,7 @@ bool mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info)
HA_CREATE_INFO create_info;
DBUG_ENTER("mysql_drop_index");
bzero((char*) &create_info,sizeof(create_info));
create_info.db_type= (handlerton*) &default_hton;
create_info.db_type= 0;
create_info.default_table_charset= thd->variables.collation_database;
alter_info->clear();
alter_info->flags= ALTER_DROP_INDEX;

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

View file

@ -23,12 +23,18 @@ extern struct st_mysql_plugin *mysqld_builtins[];
char *opt_plugin_dir_ptr;
char opt_plugin_dir[FN_REFLEN];
LEX_STRING plugin_type_names[]=
LEX_STRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]=
{
{ (char *)STRING_WITH_LEN("UDF") },
{ (char *)STRING_WITH_LEN("STORAGE ENGINE") },
{ (char *)STRING_WITH_LEN("FTPARSER") }
};
plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
{
0,ha_initialize_handlerton,0
};
static const char *plugin_interface_version_sym=
"_mysql_plugin_interface_version_";
static const char *sizeof_st_plugin_sym=
@ -522,27 +528,15 @@ static int plugin_initialize(struct st_plugin_int *plugin)
{
sql_print_error("Plugin '%s' init function returned error.",
plugin->name.str);
DBUG_PRINT("warning", ("Plugin '%s' init function returned error.",
plugin->name.str));
goto err;
}
}
switch (plugin->plugin->type)
if (plugin_type_initialize[plugin->plugin->type] &&
(*plugin_type_initialize[plugin->plugin->type])(plugin))
{
case MYSQL_STORAGE_ENGINE_PLUGIN:
if (ha_initialize_handlerton(plugin))
{
sql_print_error("Plugin '%s' handlerton init returned error.",
plugin->name.str);
DBUG_PRINT("warning", ("Plugin '%s' handlerton init returned error.",
plugin->name.str));
goto err;
}
break;
default:
break;
sql_print_error("Plugin '%s' registration as a %s failed.",
plugin->name.str, plugin_type_names[plugin->plugin->type]);
goto err;
}
DBUG_RETURN(0);
@ -554,14 +548,14 @@ static int plugin_finalize(THD *thd, struct st_plugin_int *plugin)
{
int rc;
DBUG_ENTER("plugin_finalize");
if (plugin->ref_count)
{
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
"Plugin is busy and will be uninstalled on shutdown");
goto err;
}
switch (plugin->plugin->type)
{
case MYSQL_STORAGE_ENGINE_PLUGIN:
@ -591,7 +585,7 @@ static int plugin_finalize(THD *thd, struct st_plugin_int *plugin)
goto err;
}
}
DBUG_RETURN(0);
err:
DBUG_RETURN(1);
@ -676,7 +670,7 @@ int plugin_init(void)
get_hash_key, NULL, 0))
goto err;
}
/* Register all the built-in plugins */
for (builtins= mysqld_builtins; *builtins; builtins++)
{
@ -684,6 +678,12 @@ int plugin_init(void)
{
if (plugin_register_builtin(plugin))
goto err;
struct st_plugin_int *tmp=dynamic_element(&plugin_array,
plugin_array.elements-1,
struct st_plugin_int *);
if (plugin_initialize(tmp))
goto err;
tmp->state= PLUGIN_IS_READY;
}
}

View file

@ -61,6 +61,8 @@ struct st_plugin_int
uint ref_count; /* number of threads using the plugin */
};
typedef int (*plugin_type_init)(struct st_plugin_int *);
extern char *opt_plugin_dir_ptr;
extern char opt_plugin_dir[FN_REFLEN];
extern LEX_STRING plugin_type_names[];

View file

@ -47,7 +47,7 @@ static void store_key_options(THD *thd, String *packet, TABLE *table,
KEY *key_info);
/***************************************************************************
** List all table types supported
** List all table types supported
***************************************************************************/
static my_bool show_handlerton(THD *thd, st_plugin_int *plugin,
@ -55,25 +55,25 @@ static my_bool show_handlerton(THD *thd, st_plugin_int *plugin,
{
handlerton *default_type= (handlerton *) arg;
Protocol *protocol= thd->protocol;
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if (!(hton->flags & HTON_HIDDEN))
{
protocol->prepare_for_resend();
protocol->store(hton->name, system_charset_info);
protocol->store(plugin->plugin->name, system_charset_info);
const char *option_name= show_comp_option_name[(int) hton->state];
if (hton->state == SHOW_OPTION_YES && default_type == hton)
option_name= "DEFAULT";
protocol->store(option_name, system_charset_info);
protocol->store(hton->comment, system_charset_info);
protocol->store(plugin->plugin->descr, system_charset_info);
protocol->store(hton->commit ? "YES" : "NO", system_charset_info);
protocol->store(hton->prepare ? "YES" : "NO", system_charset_info);
protocol->store(hton->savepoint_set ? "YES" : "NO", system_charset_info);
return protocol->write() ? 1 : 0;
}
return 0;
return 0;
}
bool mysqld_show_storage_engines(THD *thd)
@ -93,7 +93,7 @@ bool mysqld_show_storage_engines(THD *thd)
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
if (plugin_foreach(thd, show_handlerton,
if (plugin_foreach(thd, show_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, thd->variables.table_type))
DBUG_RETURN(TRUE);
@ -3091,7 +3091,7 @@ static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin,
void *ptable)
{
TABLE *table= (TABLE *) ptable;
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
CHARSET_INFO *scs= system_charset_info;
DBUG_ENTER("iter_schema_engines");
@ -3099,21 +3099,26 @@ static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin,
if (!(hton->flags & HTON_HIDDEN))
{
if (!(wild && wild[0] &&
wild_case_compare(scs, hton->name,wild)))
wild_case_compare(scs, plugin->plugin->name,wild)))
{
const char *tmp;
LEX_STRING state[2]={{STRING_WITH_LEN("ENABLED")},
{STRING_WITH_LEN("DISABLED")}};
LEX_STRING yesno[2]={{STRING_WITH_LEN("NO")}, {STRING_WITH_LEN("YES")}};
LEX_STRING *tmp;
restore_record(table, s->default_values);
table->field[0]->store(hton->name, strlen(hton->name), scs);
tmp= hton->state ? "DISABLED" : "ENABLED";
table->field[1]->store( tmp, strlen(tmp), scs);
table->field[2]->store(hton->comment, strlen(hton->comment), scs);
tmp= hton->commit ? "YES" : "NO";
table->field[3]->store( tmp, strlen(tmp), scs);
tmp= hton->prepare ? "YES" : "NO";
table->field[4]->store( tmp, strlen(tmp), scs);
tmp= hton->savepoint_set ? "YES" : "NO";
table->field[5]->store( tmp, strlen(tmp), scs);
table->field[0]->store(plugin->plugin->name,
strlen(plugin->plugin->name), scs);
tmp= &state[test(hton->state)];
table->field[1]->store(tmp->str, tmp->length, scs);
table->field[2]->store(plugin->plugin->descr,
strlen(plugin->plugin->descr), scs);
tmp= &yesno[test(hton->commit)];
table->field[3]->store(tmp->str, tmp->length, scs);
tmp= &yesno[test(hton->prepare)];
table->field[4]->store(tmp->str, tmp->length, scs);
tmp= &yesno[test(hton->savepoint_set)];
table->field[5]->store(tmp->str, tmp->length, scs);
if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
@ -3125,7 +3130,7 @@ static my_bool iter_schema_engines(THD *thd, st_plugin_int *plugin,
int fill_schema_engines(THD *thd, TABLE_LIST *tables, COND *cond)
{
return plugin_foreach(thd, iter_schema_engines,
return plugin_foreach(thd, iter_schema_engines,
MYSQL_STORAGE_ENGINE_PLUGIN, tables->table);
}
@ -3140,7 +3145,7 @@ int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond)
{
CHARSET_INFO **cl;
CHARSET_INFO *tmp_cs= cs[0];
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
(tmp_cs->state & MY_CS_HIDDEN) ||
!(tmp_cs->state & MY_CS_PRIMARY))
continue;
@ -4897,7 +4902,7 @@ static my_bool run_hton_fill_schema_files(THD *thd, st_plugin_int *plugin,
{
struct run_hton_fill_schema_files_args *args=
(run_hton_fill_schema_files_args *) arg;
handlerton *hton= (handlerton *) plugin->plugin->info;
handlerton *hton= ((st_mysql_storage_engine *)plugin->plugin->info)->handlerton;
if(hton->fill_files_table)
hton->fill_files_table(thd, args->tables, args->cond);
return false;

View file

@ -4980,7 +4980,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
old_db_type= table->s->db_type;
if (create_info->db_type == (handlerton*) &default_hton)
if (!create_info->db_type)
create_info->db_type= old_db_type;
#ifdef WITH_PARTITION_STORAGE_ENGINE
@ -6307,7 +6307,7 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list,
lex->col_list.empty();
lex->alter_info.reset();
bzero((char*) &create_info,sizeof(create_info));
create_info.db_type= (handlerton*) &default_hton;
create_info.db_type= 0;
create_info.row_type=ROW_TYPE_NOT_USED;
create_info.default_table_charset=default_charset_info;
/* Force alter table to recreate table */
@ -6451,7 +6451,7 @@ static bool check_engine(THD *thd, const char *table_name,
no_substitution, 1)))
return TRUE;
if (req_engine != (handlerton*) &default_hton && req_engine != *new_engine)
if (req_engine && req_engine != *new_engine)
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_USING_OTHER_HANDLER,
@ -6464,7 +6464,8 @@ static bool check_engine(THD *thd, const char *table_name,
{
if (create_info->used_fields & HA_CREATE_USED_ENGINE)
{
my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0), (*new_engine)->name, "TEMPORARY");
my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0),
hton2plugin[(*new_engine)->slot]->name, "TEMPORARY");
*new_engine= 0;
return TRUE;
}

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
default storage engine.
*/
if (hton == NULL || hton == &default_hton || hton->state != SHOW_OPTION_YES)
if (hton == NULL || hton->state != SHOW_OPTION_YES)
{
hton= ha_resolve_by_legacy_type(thd, DB_TYPE_DEFAULT);
if (ts_info->storage_engine != 0)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_WARN_USING_OTHER_HANDLER,
ER(ER_WARN_USING_OTHER_HANDLER),
hton->name,
ts_info->tablespace_name
? ts_info->tablespace_name : ts_info->logfile_group_name);
hton2plugin[hton->slot]->name,
ts_info->tablespace_name ? ts_info->tablespace_name
: ts_info->logfile_group_name);
}
if (hton->alter_tablespace)
@ -64,7 +64,7 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_ILLEGAL_HA_CREATE_OPTION,
ER(ER_ILLEGAL_HA_CREATE_OPTION),
hton->name,
hton2plugin[hton->slot]->name,
"TABLESPACE or LOGFILE GROUP");
}
if (mysql_bin_log.is_open())

View file

@ -3102,11 +3102,11 @@ opt_ts_engine:
"STORAGE ENGINE");
YYABORT;
}
lex->alter_tablespace_info->storage_engine= $4 ? $4 : &default_hton;
lex->alter_tablespace_info->storage_engine= $4;
};
opt_ts_wait:
/* empty */
/* empty */
| ts_wait
;
@ -3942,12 +3942,18 @@ storage_engines:
ident_or_text
{
$$ = ha_resolve_by_name(YYTHD, &$1);
if ($$ == NULL &&
test(YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION))
if ($$ == NULL)
if (YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION)
{
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
YYABORT;
}
else
{
push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_UNKNOWN_STORAGE_ENGINE,
ER(ER_UNKNOWN_STORAGE_ENGINE), $1.str);
}
};
row_types:
@ -4624,7 +4630,7 @@ alter:
lex->select_lex.db=lex->name= 0;
lex->like_name= 0;
bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.db_type= (handlerton*) &default_hton;
lex->create_info.db_type= 0;
lex->create_info.default_table_charset= NULL;
lex->create_info.row_type= ROW_TYPE_NOT_USED;
lex->alter_info.reset();

View file

@ -145,49 +145,7 @@ static handler *archive_create_handler(TABLE_SHARE *table);
*/
#define ARCHIVE_MIN_ROWS_TO_USE_BULK_INSERT 2
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 */
};
handlerton archive_hton;
static handler *archive_create_handler(TABLE_SHARE *table)
{
@ -217,11 +175,18 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length,
TRUE Error
*/
bool archive_db_init()
int archive_db_init()
{
DBUG_ENTER("archive_db_init");
if (archive_inited)
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))
goto error;
if (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0,
@ -1582,16 +1547,19 @@ bool ha_archive::check_and_repair(THD *thd)
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_STORAGE_ENGINE_PLUGIN,
&archive_hton,
archive_hton_name,
&archive_storage_engine,
"ARCHIVE",
"Brian Aker, MySQL AB",
archive_hton_comment,
NULL, /* Plugin Init */
"Archive storage engine",
archive_db_init, /* Plugin Init */
archive_db_done, /* Plugin Deinit */
0x0100 /* 1.0 */,
}
mysql_declare_plugin_end;

View file

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

View file

@ -22,57 +22,9 @@
#include "mysql_priv.h"
#include "ha_blackhole.h"
#include <mysql/plugin.h>
/* Static declarations for handlerton */
static handler *blackhole_create_handler(TABLE_SHARE *table);
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 */
};
handlerton blackhole_hton;
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);
}
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_STORAGE_ENGINE_PLUGIN,
&blackhole_hton,
blackhole_hton_name,
&blackhole_storage_engine,
"BLACKHOLE",
"MySQL AB",
blackhole_hton_comment,
NULL, /* Plugin Init */
"/dev/null storage engine (anything you write to it disappears)",
blackhole_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
}

View file

@ -77,45 +77,7 @@ static int tina_init= 0;
static handler *tina_create_handler(TABLE_SHARE *table);
static int tina_init_func();
static const char tina_hton_name[]= "CSV";
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 */
};
handlerton tina_hton;
/*****************************************************************************
** TINA tables
@ -197,6 +159,11 @@ static int tina_init_func()
VOID(pthread_mutex_init(&tina_mutex,MY_MUTEX_INIT_FAST));
(void) hash_init(&tina_open_tables,system_charset_info,32,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;
}
@ -1422,14 +1389,16 @@ bool ha_tina::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES;
}
struct st_mysql_storage_engine csv_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &tina_hton };
mysql_declare_plugin(csv)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&tina_hton,
tina_hton_name,
&csv_storage_engine,
"CSV",
"Brian Aker, MySQL AB",
tina_hton_comment,
"CSV storage engine",
tina_init_func, /* Plugin Init */
tina_done_func, /* Plugin Deinit */
0x0100 /* 1.0 */,

View file

@ -77,46 +77,7 @@ static int example_init_func();
static bool example_init_func_for_handlerton();
static int example_panic(enum ha_panic_function flag);
static const char example_hton_name[]= "EXAMPLE";
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,
};
handlerton example_hton;
/* Variables for example share methods */
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) hash_init(&example_open_tables,system_charset_info,32,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);
}
@ -163,17 +129,6 @@ static int example_done_func()
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
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)
{
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);
}
struct st_mysql_storage_engine example_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &example_hton };
mysql_declare_plugin(example)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&example_hton,
example_hton_name,
&example_storage_engine,
"EXAMPLE",
"Brian Aker, MySQL AB",
example_hton_comment,
"Example storage engine",
example_init_func, /* Plugin Init */
example_done_func, /* Plugin Deinit */
0x0001 /* 0.1 */,