summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mysql/plugin.h24
-rw-r--r--mysql-test/extra/binlog_tests/binlog.test6
-rw-r--r--mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test26
-rwxr-xr-xmysql-test/mysql-test-run.pl6
-rw-r--r--mysql-test/mysql-test-run.sh3
-rw-r--r--mysql-test/r/ndb_dd_backuprestore.result7
-rw-r--r--mysql-test/r/ndb_dd_basic.result2
-rw-r--r--mysql-test/t/disabled.def1
-rw-r--r--mysql-test/t/ndb_dd_backuprestore.test10
-rw-r--r--mysql-test/t/partition_mgm_err2.test2
-rw-r--r--sql/Makefile.am2
-rw-r--r--sql/discover.cc2
-rw-r--r--sql/ha_berkeley.cc81
-rw-r--r--sql/ha_berkeley.h2
-rw-r--r--sql/ha_federated.cc63
-rw-r--r--sql/ha_heap.cc63
-rw-r--r--sql/ha_innodb.cc89
-rw-r--r--sql/ha_innodb.h2
-rw-r--r--sql/ha_myisam.cc75
-rw-r--r--sql/ha_myisammrg.cc63
-rw-r--r--sql/ha_ndbcluster.cc54
-rw-r--r--sql/ha_ndbcluster.h4
-rw-r--r--sql/ha_ndbcluster_binlog.cc6
-rw-r--r--sql/ha_partition.cc62
-rw-r--r--sql/handler.cc177
-rw-r--r--sql/handler.h31
-rw-r--r--sql/log.cc71
-rw-r--r--sql/log_event.cc14
-rw-r--r--sql/log_event.h3
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/mysqld.cc60
-rw-r--r--sql/set_var.cc2
-rw-r--r--sql/slave.cc243
-rw-r--r--sql/sql_parse.cc4
-rw-r--r--sql/sql_partition.cc22
-rw-r--r--sql/sql_plugin.cc44
-rw-r--r--sql/sql_plugin.h5
-rw-r--r--sql/sql_show.cc51
-rw-r--r--sql/sql_table.cc9
-rw-r--r--sql/sql_tablespace.cc10
-rw-r--r--sql/sql_yacc.yy16
-rw-r--r--storage/archive/ha_archive.cc81
-rw-r--r--storage/archive/ha_archive.h2
-rw-r--r--storage/blackhole/ha_blackhole.cc70
-rw-r--r--storage/csv/ha_tina.cc53
-rw-r--r--storage/example/ha_example.cc68
46 files changed, 691 insertions, 1002 deletions
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index 728b62ab2f4..0cee54bffde 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -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 0x0100
@@ -282,5 +282,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
diff --git a/mysql-test/extra/binlog_tests/binlog.test b/mysql-test/extra/binlog_tests/binlog.test
index ff43debf967..6f7990893f0 100644
--- a/mysql-test/extra/binlog_tests/binlog.test
+++ b/mysql-test/extra/binlog_tests/binlog.test
@@ -22,7 +22,7 @@ insert t2 values (5);
commit;
# first COMMIT must be Query_log_event, second - Xid_log_event
--replace_column 2 # 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
drop table t1,t2;
@@ -44,8 +44,8 @@ while ($1)
commit;
drop table t1;
--replace_column 2 # 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events in 'master-bin.000001' from 102;
--replace_column 2 # 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events in 'master-bin.000002' from 102;
diff --git a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
index b75a326d5a8..241c96d078b 100644
--- a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
+++ b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
@@ -30,7 +30,7 @@ insert into t2 select * from t1;
commit;
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
delete from t1;
@@ -44,7 +44,7 @@ insert into t2 select * from t1;
rollback;
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
delete from t1;
@@ -60,7 +60,7 @@ rollback to savepoint my_savepoint;
commit;
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
delete from t1;
@@ -78,7 +78,7 @@ commit;
select a from t1 order by a; # check that savepoints work :)
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
# and when ROLLBACK is not explicit?
@@ -100,7 +100,7 @@ connection con2;
# logging has been done, we use a user lock.
select get_lock("a",10);
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
# and when not in a transact1on?
@@ -112,7 +112,7 @@ insert into t1 values(9);
insert into t2 select * from t1;
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
# Check that when the query updat1ng the MyISAM table is the first in the
@@ -125,13 +125,13 @@ insert into t1 values(10); # first make t1 non-empty
begin;
insert into t2 select * from t1;
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
insert into t1 values(11);
commit;
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
@@ -150,7 +150,7 @@ insert into t2 select * from t1;
commit;
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
delete from t1;
@@ -163,7 +163,7 @@ insert into t2 select * from t1;
rollback;
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
delete from t1;
@@ -179,7 +179,7 @@ rollback to savepoint my_savepoint;
commit;
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
delete from t1;
@@ -197,7 +197,7 @@ commit;
select a from t1 order by a; # check that savepoints work :)
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
# Test for BUG#5714, where a MyISAM update in the transaction used to
@@ -258,7 +258,7 @@ disconnect con2;
connection con3;
select get_lock("lock1",60);
--replace_column 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
do release_lock("lock1");
drop table t0,t2;
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 8923c032dff..af7bdeb0621 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -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.
@@ -2603,7 +2605,6 @@ sub mysqld_arguments ($$$$$$) {
mtr_add_arg($args, "%s--character-sets-dir=%s", $prefix, $path_charsetsdir);
mtr_add_arg($args, "%s--core", $prefix);
mtr_add_arg($args, "%s--log-bin-trust-function-creators", $prefix);
- mtr_add_arg($args, "%s--loose-binlog-show-xid=0", $prefix);
mtr_add_arg($args, "%s--default-character-set=latin1", $prefix);
mtr_add_arg($args, "%s--language=%s", $prefix, $path_language);
mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix);
@@ -2749,7 +2750,6 @@ sub mysqld_arguments ($$$$$$) {
mtr_add_arg($args, "%s--sort_buffer=256K", $prefix);
mtr_add_arg($args, "%s--max_heap_table_size=1M", $prefix);
mtr_add_arg($args, "%s--log-bin-trust-function-creators", $prefix);
- mtr_add_arg($args, "%s--loose-binlog-show-xid=0", $prefix);
if ( $opt_ssl_supported )
{
@@ -3281,7 +3281,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'}";
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index f56099f3a49..d4e70054d82 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -1345,7 +1345,6 @@ start_master()
--innodb_data_file_path=ibdata1:128M:autoextend \
--open-files-limit=1024 \
--log-bin-trust-function-creators \
- --loose-binlog-show-xid=0 \
$MASTER_40_ARGS \
$SMALL_SERVER \
$MASTER_MYSQLD_BINLOG_OPT \
@@ -1369,7 +1368,6 @@ start_master()
--language=$LANGUAGE \
--innodb_data_file_path=ibdata1:128M:autoextend \
--log-bin-trust-function-creators \
- --loose-binlog-show-xid=0 \
$MASTER_40_ARGS \
$SMALL_SERVER \
$MASTER_MYSQLD_BINLOG_OPT \
@@ -1542,7 +1540,6 @@ start_slave()
--master-retry-count=10 \
-O slave_net_timeout=10 \
--log-bin-trust-function-creators \
- --loose-binlog-show-xid=0 \
$SMALL_SERVER \
$SLAVE_MYSQLD_BINLOG_OPT \
$EXTRA_SLAVE_MYSQLD_OPT $EXTRA_SLAVE_OPT \
diff --git a/mysql-test/r/ndb_dd_backuprestore.result b/mysql-test/r/ndb_dd_backuprestore.result
index 8c39c8c582f..33edf6783e6 100644
--- a/mysql-test/r/ndb_dd_backuprestore.result
+++ b/mysql-test/r/ndb_dd_backuprestore.result
@@ -155,3 +155,10 @@ DROP TABLE test.t1;
DROP TABLE test.t2;
DROP TABLE test.t3;
DROP TABLE test.t4;
+ALTER TABLESPACE table_space1
+DROP DATAFILE './table_space1/datafile.dat'
+ENGINE = NDB;
+DROP TABLESPACE table_space1
+ENGINE = NDB;
+DROP LOGFILE GROUP log_group1
+ENGINE =NDB;
diff --git a/mysql-test/r/ndb_dd_basic.result b/mysql-test/r/ndb_dd_basic.result
index 008be3aa79f..6c10fbe63b3 100644
--- a/mysql-test/r/ndb_dd_basic.result
+++ b/mysql-test/r/ndb_dd_basic.result
@@ -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'
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 552827c47f9..d6083ab8bfe 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -38,4 +38,3 @@ rpl_sp : BUG#16456 2006-02-16 jmiller
# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open
#ndb_binlog_ddl_multi : BUG#18976 2006-04-10 kent CRBR: multiple binlog, second binlog may miss schema log events
-ndb_dd_backuprestore : Nikolay: removed partitions from the test. Review pending.
diff --git a/mysql-test/t/ndb_dd_backuprestore.test b/mysql-test/t/ndb_dd_backuprestore.test
index 65f141288e7..1508cccb46d 100644
--- a/mysql-test/t/ndb_dd_backuprestore.test
+++ b/mysql-test/t/ndb_dd_backuprestore.test
@@ -160,4 +160,14 @@ DROP TABLE test.t2;
DROP TABLE test.t3;
DROP TABLE test.t4;
+ALTER TABLESPACE table_space1
+DROP DATAFILE './table_space1/datafile.dat'
+ENGINE = NDB;
+
+DROP TABLESPACE table_space1
+ENGINE = NDB;
+
+DROP LOGFILE GROUP log_group1
+ENGINE =NDB;
+
#End 5.1 test case
diff --git a/mysql-test/t/partition_mgm_err2.test b/mysql-test/t/partition_mgm_err2.test
index dd96731ccdd..7d15bd7b19f 100644
--- a/mysql-test/t/partition_mgm_err2.test
+++ b/mysql-test/t/partition_mgm_err2.test
@@ -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;
diff --git a/sql/Makefile.am b/sql/Makefile.am
index 7f711a1e212..d7a6eac72cc 100644
--- a/sql/Makefile.am
+++ b/sql/Makefile.am
@@ -35,7 +35,7 @@ LDADD = $(top_builddir)/vio/libvio.a \
$(top_builddir)/dbug/libdbug.a \
$(top_builddir)/regex/libregex.a \
$(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
-
+mysqld_DEPENDENCIES= @mysql_plugin_libs@ $(LDADD)
mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
@pstack_libs@ \
@mysql_plugin_libs@ \
diff --git a/sql/discover.cc b/sql/discover.cc
index 2a3da55f154..938a05ff4a7 100644
--- a/sql/discover.cc
+++ b/sql/discover.cc
@@ -119,8 +119,8 @@ int writefrm(const char *name, const void *frmdata, uint len)
{
if (my_write(file,(byte*)frmdata,len,MYF(MY_WME | MY_NABP)))
error= 2;
+ VOID(my_close(file,MYF(0)));
}
- VOID(my_close(file,MYF(0)));
DBUG_RETURN(error);
} /* writefrm */
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index 473fb149871..9a144066057 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -97,6 +97,9 @@ pthread_mutex_t bdb_mutex;
static DB_ENV *db_env;
static HASH bdb_open_tables;
+static const char berkeley_hton_name[]= "BerkeleyDB";
+static const int berkeley_hton_name_length=sizeof(berkeley_hton_name)-1;
+
const char *berkeley_lock_names[] =
{ "DEFAULT", "OLDEST", "RANDOM", "YOUNGEST", "EXPIRE", "MAXLOCKS",
"MAXWRITE", "MINLOCKS", "MINWRITE", 0 };
@@ -125,47 +128,7 @@ static int berkeley_savepoint(THD* thd, void *savepoint);
static int berkeley_release_savepoint(THD* thd, void *savepoint);
static handler *berkeley_create_handler(TABLE_SHARE *table);
-static const char berkeley_hton_name[]= "BerkeleyDB";
-static const char berkeley_hton_comment[]=
- "Supports transactions and page-level locking";
-
-handlerton berkeley_hton = {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- berkeley_hton_name,
- SHOW_OPTION_YES,
- berkeley_hton_comment,
- DB_TYPE_BERKELEY_DB,
- berkeley_init,
- 0, /* slot */
- sizeof(DB_TXN *), /* savepoint size */
- berkeley_close_connection,
- berkeley_savepoint, /* savepoint_set */
- berkeley_rollback_to_savepoint, /* savepoint_rollback */
- berkeley_release_savepoint, /* savepoint_release */
- berkeley_commit,
- berkeley_rollback,
- NULL, /* prepare */
- NULL, /* recover */
- NULL, /* commit_by_xid */
- NULL, /* rollback_by_xid */
- NULL, /* create_cursor_read_view */
- NULL, /* set_cursor_read_view */
- NULL, /* close_cursor_read_view */
- berkeley_create_handler, /* Create a new handler */
- NULL, /* Drop a database */
- berkeley_end, /* Panic call */
- NULL, /* Start Consistent Snapshot */
- berkeley_flush_logs, /* Flush logs */
- berkeley_show_status, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill Files Table */
- HTON_CLOSE_CURSORS_AT_COMMIT | HTON_FLUSH_AFTER_RENAME,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
+handlerton berkeley_hton;
handler *berkeley_create_handler(TABLE_SHARE *table)
{
@@ -181,12 +144,27 @@ typedef struct st_berkeley_trx_data {
/* General functions */
-bool berkeley_init(void)
+int berkeley_init(void)
{
DBUG_ENTER("berkeley_init");
+ berkeley_hton.state=SHOW_OPTION_YES;
+ berkeley_hton.db_type=DB_TYPE_BERKELEY_DB;
+ berkeley_hton.savepoint_offset=sizeof(DB_TXN *);
+ berkeley_hton.close_connection=berkeley_close_connection;
+ berkeley_hton.savepoint_set=berkeley_savepoint;
+ berkeley_hton.savepoint_rollback=berkeley_rollback_to_savepoint;
+ berkeley_hton.savepoint_release=berkeley_release_savepoint;
+ berkeley_hton.commit=berkeley_commit;
+ berkeley_hton.rollback=berkeley_rollback;
+ berkeley_hton.create=berkeley_create_handler;
+ berkeley_hton.panic=berkeley_end;
+ berkeley_hton.flush_logs=berkeley_flush_logs;
+ berkeley_hton.show_status=berkeley_show_status;
+ berkeley_hton.flags=HTON_CLOSE_CURSORS_AT_COMMIT | HTON_FLUSH_AFTER_RENAME;
+
if (have_berkeley_db != SHOW_OPTION_YES)
- goto error;
+ return 0; // nothing else to do
if (!berkeley_tmpdir)
berkeley_tmpdir=mysql_tmpdir;
@@ -373,7 +351,6 @@ static int berkeley_release_savepoint(THD* thd, void *savepoint)
static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
{
char **all_logs, **free_logs, **a, **f;
- uint hton_name_len= strlen(berkeley_hton.name);
int error=1;
MEM_ROOT **root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC);
MEM_ROOT show_logs_root, *old_mem_root= *root_ptr;
@@ -401,15 +378,15 @@ static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
if (f && *f && strcmp(*a, *f) == 0)
{
f++;
- if ((error= stat_print(thd, berkeley_hton.name, hton_name_len,
- *a, strlen(*a),
+ if ((error= stat_print(thd, berkeley_hton_name,
+ berkeley_hton_name_length, *a, strlen(*a),
STRING_WITH_LEN(SHOW_LOG_STATUS_FREE))))
break;
}
else
{
- if ((error= stat_print(thd, berkeley_hton.name, hton_name_len,
- *a, strlen(*a),
+ if ((error= stat_print(thd, berkeley_hton_name,
+ berkeley_hton_name_length, *a, strlen(*a),
STRING_WITH_LEN(SHOW_LOG_STATUS_INUSE))))
break;
}
@@ -2732,15 +2709,17 @@ bool ha_berkeley::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES;
}
+struct st_mysql_storage_engine berkeley_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &berkeley_hton };
mysql_declare_plugin(berkeley)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &berkeley_hton,
+ &berkeley_storage_engine,
berkeley_hton_name,
"Sleepycat Software",
- berkeley_hton_comment,
- NULL, /* Plugin Init */
+ "Supports transactions and page-level locking",
+ berkeley_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100, /* 1.0 */
0
diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h
index 21b618b8d6d..50a2aec3963 100644
--- a/sql/ha_berkeley.h
+++ b/sql/ha_berkeley.h
@@ -172,7 +172,7 @@ extern char *berkeley_home, *berkeley_tmpdir, *berkeley_logdir;
extern long berkeley_lock_scan_time;
extern TYPELIB berkeley_lock_typelib;
-bool berkeley_init(void);
+int berkeley_init(void);
int berkeley_end(ha_panic_function type);
bool berkeley_flush_logs(void);
bool berkeley_show_status(THD *thd, stat_print_fn *print, enum ha_stat_type);
diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc
index f4fc5f47193..30988c6c8d0 100644
--- a/sql/ha_federated.cc
+++ b/sql/ha_federated.cc
@@ -370,47 +370,7 @@ static int federated_rollback(THD *thd, bool all);
/* Federated storage engine handlerton */
-static const char federated_hton_name[]= "FEDERATED";
-static const char federated_hton_comment[]= "Federated MySQL storage engine";
-
-handlerton federated_hton= {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- federated_hton_name,
- SHOW_OPTION_YES,
- federated_hton_comment,
- DB_TYPE_FEDERATED_DB,
- federated_db_init,
- 0, /* slot */
- 0, /* savepoint size. */
- NULL, /* close_connection */
- NULL, /* savepoint */
- NULL, /* rollback to savepoint */
- NULL, /* release savepoint */
- federated_commit, /* commit */
- federated_rollback, /* rollback */
- NULL, /* prepare */
- NULL, /* recover */
- NULL, /* commit_by_xid */
- NULL, /* rollback_by_xid */
- NULL, /* create_cursor_read_view */
- NULL, /* set_cursor_read_view */
- NULL, /* close_cursor_read_view */
- federated_create_handler, /* Create a new handler */
- NULL, /* Drop a database */
- federated_db_end, /* Panic call */
- NULL, /* Start Consistent Snapshot */
- NULL, /* Flush logs */
- NULL, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill FILES table */
- HTON_ALTER_NOT_SUPPORTED,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
-
+handlerton federated_hton;
static handler *federated_create_handler(TABLE_SHARE *table)
{
@@ -442,6 +402,15 @@ static byte *federated_get_key(FEDERATED_SHARE *share, uint *length,
bool federated_db_init()
{
DBUG_ENTER("federated_db_init");
+
+ federated_hton.state= SHOW_OPTION_YES;
+ federated_hton.db_type= DB_TYPE_FEDERATED_DB;
+ federated_hton.commit= federated_commit;
+ federated_hton.rollback= federated_rollback;
+ federated_hton.create= federated_create_handler;
+ federated_hton.panic= federated_db_end;
+ federated_hton.flags= HTON_ALTER_NOT_SUPPORTED;
+
if (pthread_mutex_init(&federated_mutex, MY_MUTEX_INIT_FAST))
goto error;
if (!hash_init(&federated_open_tables, system_charset_info, 32, 0, 0,
@@ -2797,7 +2766,7 @@ int ha_federated::connection_autocommit(bool state)
DBUG_ENTER("ha_federated::connection_autocommit");
text= (state == true) ? "SET AUTOCOMMIT=1" : "SET AUTOCOMMIT=0";
DBUG_RETURN(execute_simple_query(text, 16));
-}
+}
int ha_federated::execute_simple_query(const char *query, int len)
@@ -2811,15 +2780,17 @@ int ha_federated::execute_simple_query(const char *query, int len)
DBUG_RETURN(0);
}
+struct st_mysql_storage_engine federated_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &federated_hton };
mysql_declare_plugin(federated)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &federated_hton,
- federated_hton_name,
+ &federated_storage_engine,
+ "FEDERATED",
"Patrick Galbraith and Brian Aker, MySQL AB",
- federated_hton_comment,
- NULL, /* Plugin Init */
+ "Federated MySQL storage engine",
+ federated_db_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
}
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index 1a7efb42748..15cec9ec4a6 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -26,47 +26,17 @@
static handler *heap_create_handler(TABLE_SHARE *table);
-static const char heap_hton_name[]= "MEMORY";
-static const char heap_hton_comment[]=
- "Hash based, stored in memory, useful for temporary tables";
-
-handlerton heap_hton= {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- heap_hton_name,
- SHOW_OPTION_YES,
- heap_hton_comment,
- DB_TYPE_HEAP,
- NULL,
- 0, /* slot */
- 0, /* savepoint size. */
- NULL, /* close_connection */
- NULL, /* savepoint */
- NULL, /* rollback to savepoint */
- NULL, /* release savepoint */
- NULL, /* commit */
- NULL, /* rollback */
- NULL, /* prepare */
- NULL, /* recover */
- NULL, /* commit_by_xid */
- NULL, /* rollback_by_xid */
- NULL, /* create_cursor_read_view */
- NULL, /* set_cursor_read_view */
- NULL, /* close_cursor_read_view */
- heap_create_handler, /* Create a new handler */
- NULL, /* Drop a database */
- heap_panic, /* Panic call */
- NULL, /* Start Consistent Snapshot */
- NULL, /* Flush logs */
- NULL, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill Files Table */
- HTON_CAN_RECREATE,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
+handlerton heap_hton;
+
+int heap_init()
+{
+ heap_hton.state= SHOW_OPTION_YES;
+ heap_hton.db_type= DB_TYPE_HEAP;
+ heap_hton.create= heap_create_handler;
+ heap_hton.panic= heap_panic;
+ heap_hton.flags= HTON_CAN_RECREATE;
+ return 0;
+}
static handler *heap_create_handler(TABLE_SHARE *table)
{
@@ -711,14 +681,17 @@ bool ha_heap::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES;
}
+struct st_mysql_storage_engine heap_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &heap_hton};
+
mysql_declare_plugin(heap)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &heap_hton,
- heap_hton_name,
+ &heap_storage_engine,
+ "MEMORY",
"MySQL AB",
- heap_hton_comment,
- NULL,
+ "Hash based, stored in memory, useful for temporary tables",
+ heap_init,
NULL,
0x0100, /* 1.0 */
0
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 0b2f561e8c9..4be8a81b845 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -42,7 +42,6 @@ have disables the InnoDB inlining in this file. */
#define MAX_ULONG_BIT ((ulong) 1 << (sizeof(ulong)*8-1))
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
#include "ha_innodb.h"
pthread_mutex_t innobase_share_mutex, /* to protect innobase_open_files */
@@ -206,47 +205,8 @@ static int innobase_release_savepoint(THD* thd, void *savepoint);
static handler *innobase_create_handler(TABLE_SHARE *table);
static const char innobase_hton_name[]= "InnoDB";
-static const char innobase_hton_comment[]=
- "Supports transactions, row-level locking, and foreign keys";
-
-handlerton innobase_hton = {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- innobase_hton_name,
- SHOW_OPTION_YES,
- innobase_hton_comment,
- DB_TYPE_INNODB,
- innobase_init,
- 0, /* slot */
- sizeof(trx_named_savept_t), /* savepoint size. TODO: use it */
- innobase_close_connection,
- innobase_savepoint,
- innobase_rollback_to_savepoint,
- innobase_release_savepoint,
- innobase_commit, /* commit */
- innobase_rollback, /* rollback */
- innobase_xa_prepare, /* prepare */
- innobase_xa_recover, /* recover */
- innobase_commit_by_xid, /* commit_by_xid */
- innobase_rollback_by_xid, /* rollback_by_xid */
- innobase_create_cursor_view,
- innobase_set_cursor_view,
- innobase_close_cursor_view,
- innobase_create_handler, /* Create a new handler */
- innobase_drop_database, /* Drop a database */
- innobase_end, /* Panic call */
- innobase_start_trx_and_assign_read_view, /* Start Consistent Snapshot */
- innobase_flush_logs, /* Flush logs */
- innobase_show_status, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* alter_tablespace */
- NULL, /* Fill FILES table */
- HTON_NO_FLAGS,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- innobase_release_temporary_latches
-};
+handlerton innobase_hton;
static handler *innobase_create_handler(TABLE_SHARE *table)
{
@@ -1230,10 +1190,9 @@ ha_innobase::init_table_handle_for_HANDLER(void)
/*************************************************************************
Opens an InnoDB database. */
-bool
+int
innobase_init(void)
/*===============*/
- /* out: &innobase_hton, or NULL on error */
{
static char current_dir[3]; /* Set if using current lib */
int err;
@@ -1242,8 +1201,33 @@ innobase_init(void)
DBUG_ENTER("innobase_init");
+ innobase_hton.state=have_innodb;
+ innobase_hton.db_type= DB_TYPE_INNODB;
+ innobase_hton.savepoint_offset=sizeof(trx_named_savept_t);
+ innobase_hton.close_connection=innobase_close_connection;
+ innobase_hton.savepoint_set=innobase_savepoint;
+ innobase_hton.savepoint_rollback=innobase_rollback_to_savepoint;
+ innobase_hton.savepoint_release=innobase_release_savepoint;
+ innobase_hton.commit=innobase_commit;
+ innobase_hton.rollback=innobase_rollback;
+ innobase_hton.prepare=innobase_xa_prepare;
+ innobase_hton.recover=innobase_xa_recover;
+ innobase_hton.commit_by_xid=innobase_commit_by_xid;
+ innobase_hton.rollback_by_xid=innobase_rollback_by_xid;
+ innobase_hton.create_cursor_read_view=innobase_create_cursor_view;
+ innobase_hton.set_cursor_read_view=innobase_set_cursor_view;
+ innobase_hton.close_cursor_read_view=innobase_close_cursor_view;
+ innobase_hton.create=innobase_create_handler;
+ innobase_hton.drop_database=innobase_drop_database;
+ innobase_hton.panic=innobase_end;
+ innobase_hton.start_consistent_snapshot=innobase_start_trx_and_assign_read_view;
+ innobase_hton.flush_logs=innobase_flush_logs;
+ innobase_hton.show_status=innobase_show_status;
+ innobase_hton.flags=HTON_NO_FLAGS;
+ innobase_hton.release_temporary_latches=innobase_release_temporary_latches;
+
if (have_innodb != SHOW_OPTION_YES)
- goto error;
+ DBUG_RETURN(0); // nothing else to do
ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
@@ -6473,7 +6457,7 @@ innodb_show_status(
bool result = FALSE;
- if (stat_print(thd, innobase_hton.name, strlen(innobase_hton.name),
+ if (stat_print(thd, innobase_hton_name, strlen(innobase_hton_name),
STRING_WITH_LEN(""), str, flen)) {
result= TRUE;
}
@@ -6500,7 +6484,7 @@ innodb_mutex_show_status(
ulint rw_lock_count_os_wait= 0;
ulint rw_lock_count_os_yield= 0;
ulonglong rw_lock_wait_time= 0;
- uint hton_name_len= strlen(innobase_hton.name), buf1len, buf2len;
+ uint hton_name_len= strlen(innobase_hton_name), buf1len, buf2len;
DBUG_ENTER("innodb_mutex_show_status");
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
@@ -6527,7 +6511,7 @@ innodb_mutex_show_status(
mutex->count_os_yield,
mutex->lspent_time/1000);
- if (stat_print(thd, innobase_hton.name,
+ if (stat_print(thd, innobase_hton_name,
hton_name_len, buf1, buf1len,
buf2, buf2len)) {
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
@@ -6557,7 +6541,7 @@ innodb_mutex_show_status(
rw_lock_count_os_wait, rw_lock_count_os_yield,
rw_lock_wait_time/1000);
- if (stat_print(thd, innobase_hton.name, hton_name_len,
+ if (stat_print(thd, innobase_hton_name, hton_name_len,
STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len)) {
DBUG_RETURN(1);
}
@@ -7459,19 +7443,20 @@ bool ha_innobase::check_if_incompatible_data(
return COMPATIBLE_DATA_YES;
}
+struct st_mysql_storage_engine innobase_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &innobase_hton};
mysql_declare_plugin(innobase)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &innobase_hton,
+ &innobase_storage_engine,
innobase_hton_name,
"Innobase OY",
- innobase_hton_comment,
- NULL, /* Plugin Init */
+ "Supports transactions, row-level locking, and foreign keys",
+ innobase_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100 /* 1.0 */,
0
}
mysql_declare_plugin_end;
-#endif
diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h
index 4f0c9eb151b..638ecc432b9 100644
--- a/sql/ha_innodb.h
+++ b/sql/ha_innodb.h
@@ -249,7 +249,7 @@ extern ulong srv_thread_concurrency;
extern ulong srv_commit_concurrency;
}
-bool innobase_init(void);
+int innobase_init(void);
int innobase_end(ha_panic_function type);
bool innobase_flush_logs(void);
uint innobase_get_free_space(void);
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 40081c975c8..d11eb7aa891 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -52,63 +52,11 @@ TYPELIB myisam_stats_method_typelib= {
** MyISAM tables
*****************************************************************************/
-static handler *myisam_create_handler(TABLE_SHARE *table);
-
-/* MyISAM handlerton */
-
-static const char myisam_hton_name[]= "MyISAM";
-static const char myisam_hton_comment[]=
- "Default engine as of MySQL 3.23 with great performance";
-
-handlerton myisam_hton= {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- myisam_hton_name,
- SHOW_OPTION_YES,
- myisam_hton_comment,
- DB_TYPE_MYISAM,
- NULL,
- 0, /* slot */
- 0, /* savepoint size. */
- NULL, /* close_connection */
- NULL, /* savepoint */
- NULL, /* rollback to savepoint */
- NULL, /* release savepoint */
- NULL, /* commit */
- NULL, /* rollback */
- NULL, /* prepare */
- NULL, /* recover */
- NULL, /* commit_by_xid */
- NULL, /* rollback_by_xid */
- NULL, /* create_cursor_read_view */
- NULL, /* set_cursor_read_view */
- NULL, /* close_cursor_read_view */
- /*
- MyISAM doesn't support transactions and doesn't have
- transaction-dependent context: cursors can survive a commit.
- */
- myisam_create_handler, /* Create a new handler */
- NULL, /* Drop a database */
- mi_panic,/* Panic call */
- NULL, /* Start Consistent Snapshot */
- NULL, /* Flush logs */
- NULL, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill Files Table */
- HTON_CAN_RECREATE,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
-
-
static handler *myisam_create_handler(TABLE_SHARE *table)
{
return new ha_myisam(table);
}
-
// collect errors printed by mi_check routines
static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
@@ -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;
+
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index f4a052cea8a..b874923a077 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -38,47 +38,7 @@ static handler *myisammrg_create_handler(TABLE_SHARE *table);
/* MyISAM MERGE handlerton */
-static const char myisammrg_hton_name[]= "MRG_MYISAM";
-static const char myisammrg_hton_comment[]=
- "Collection of identical MyISAM tables";
-
-handlerton myisammrg_hton= {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- myisammrg_hton_name,
- SHOW_OPTION_YES,
- myisammrg_hton_comment,
- DB_TYPE_MRG_MYISAM,
- NULL,
- 0, /* slot */
- 0, /* savepoint size. */
- NULL, /* close_connection */
- NULL, /* savepoint */
- NULL, /* rollback to savepoint */
- NULL, /* release savepoint */
- NULL, /* commit */
- NULL, /* rollback */
- NULL, /* prepare */
- NULL, /* recover */
- NULL, /* commit_by_xid */
- NULL, /* rollback_by_xid */
- NULL, /* create_cursor_read_view */
- NULL, /* set_cursor_read_view */
- NULL, /* close_cursor_read_view */
- myisammrg_create_handler, /* Create a new handler */
- NULL, /* Drop a database */
- myrg_panic, /* Panic call */
- NULL, /* Start Consistent Snapshot */
- NULL, /* Flush logs */
- NULL, /* Show status */
- NULL, /* Partition flags */
- NULL, /* Alter table flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill Files Table */
- HTON_CAN_RECREATE | HTON_ALTER_CANNOT_CREATE,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
+handlerton myisammrg_hton;
static handler *myisammrg_create_handler(TABLE_SHARE *table)
{
@@ -580,14 +540,27 @@ bool ha_myisammrg::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_NO;
}
+static int myisammrg_init()
+{
+ myisammrg_hton.state=SHOW_OPTION_YES;
+ myisammrg_hton.db_type=DB_TYPE_MRG_MYISAM;
+ myisammrg_hton.create=myisammrg_create_handler;
+ myisammrg_hton.panic=myrg_panic;
+ myisammrg_hton.flags= HTON_CAN_RECREATE | HTON_ALTER_CANNOT_CREATE;
+ return 0;
+}
+
+struct st_mysql_storage_engine myisammrg_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION, &myisammrg_hton };
+
mysql_declare_plugin(myisammrg)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
- &myisammrg_hton,
- myisammrg_hton_name,
+ &myisammrg_storage_engine,
+ "MRG_MYISAM",
"MySQL AB",
- myisammrg_hton_comment,
- NULL, /* Plugin Init */
+ "Collection of identical MyISAM tables",
+ myisammrg_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100, /* 1.0 */
0
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 3425c638005..2b19594615f 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -63,26 +63,13 @@ static const int max_transactions= 3; // should really be 2 but there is a trans
static uint ndbcluster_partition_flags();
static uint ndbcluster_alter_table_flags(uint flags);
-static bool ndbcluster_init(void);
+static int ndbcluster_init(void);
static int ndbcluster_end(ha_panic_function flag);
static bool ndbcluster_show_status(THD*,stat_print_fn *,enum ha_stat_type);
static int ndbcluster_alter_tablespace(THD* thd, st_alter_tablespace *info);
static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond);
-static const char ndbcluster_hton_name[]= "ndbcluster";
-static const char ndbcluster_hton_comment[]= "Clustered, fault-tolerant tables";
-
-handlerton ndbcluster_hton = {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- "ndbcluster",
- SHOW_OPTION_YES,
- "Clustered, fault-tolerant tables",
- DB_TYPE_NDBCLUSTER,
- ndbcluster_init,
- ~(uint)0, /* slot */
- /* below are initialized by name in ndbcluster_init() */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
-};
+handlerton ndbcluster_hton;
static handler *ndbcluster_create_handler(TABLE_SHARE *table)
{
@@ -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
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index badca69941a..3c8a4d260a3 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -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;
+
diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc
index 144c073d565..9bf1fe1db28 100644
--- a/sql/ha_ndbcluster_binlog.cc
+++ b/sql/ha_ndbcluster_binlog.cc
@@ -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);
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index af0556f1e6f..7fa5b89abf8 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -73,46 +73,18 @@ static handler *partition_create_handler(TABLE_SHARE *share);
static uint partition_flags();
static uint alter_table_flags(uint flags);
-static const char partition_hton_name[]= "partition";
-static const char partition_hton_comment[]= "Partition Storage Engine Helper";
-
-handlerton partition_hton = {
- MYSQL_HANDLERTON_INTERFACE_VERSION,
- partition_hton_name,
- SHOW_OPTION_YES,
- partition_hton_comment, /* A comment used by SHOW to describe an engine */
- DB_TYPE_PARTITION_DB,
- 0, /* Method that initializes a storage engine */
- 0, /* slot */
- 0, /* savepoint size */
- NULL /*ndbcluster_close_connection*/,
- NULL, /* savepoint_set */
- NULL, /* savepoint_rollback */
- NULL, /* savepoint_release */
- NULL /*ndbcluster_commit*/,
- NULL /*ndbcluster_rollback*/,
- NULL, /* prepare */
- NULL, /* recover */
- NULL, /* commit_by_xid */
- NULL, /* rollback_by_xid */
- NULL,
- NULL,
- NULL,
- partition_create_handler, /* Create a new handler */
- NULL, /* Drop a database */
- NULL, /* Panic call */
- NULL, /* Start Consistent Snapshot */
- NULL, /* Flush logs */
- NULL, /* Show status */
- partition_flags, /* Partition flags */
- alter_table_flags, /* Partition flags */
- NULL, /* Alter Tablespace */
- NULL, /* Fill FILES table */
- HTON_NOT_USER_SELECTABLE | HTON_HIDDEN,
- NULL, /* binlog_func */
- NULL, /* binlog_log_query */
- NULL /* release_temporary_latches */
-};
+handlerton partition_hton;
+
+static int partition_initialize()
+{
+ partition_hton.state= SHOW_OPTION_YES;
+ partition_hton.db_type= DB_TYPE_PARTITION_DB;
+ partition_hton.create= partition_create_handler;
+ partition_hton.partition_flags= partition_flags;
+ partition_hton.alter_table_flags= alter_table_flags;
+ partition_hton.flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN;
+ return 0;
+}
/*
Create new partition handler
@@ -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
diff --git a/sql/handler.cc b/sql/handler.cc
index f51e91f1882..261925a3a60 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -48,6 +48,7 @@
check for dups and to find handlerton from legacy_db_type.
Remove when legacy_db_type is finally gone */
static handlerton *installed_htons[128];
+st_plugin_int *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= (handlerton *)plugin->data;
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.str;
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;
}
}
@@ -372,22 +351,19 @@ static int ha_finish_errors(void)
int ha_finalize_handlerton(st_plugin_int *plugin)
{
- handlerton *hton;
+ handlerton *hton= (handlerton *)plugin->data;
DBUG_ENTER("ha_finalize_handlerton");
- if (!(hton= (handlerton *) plugin->plugin->info))
- DBUG_RETURN(1);
-
switch (hton->state)
{
case SHOW_OPTION_NO:
case SHOW_OPTION_DISABLED:
break;
case SHOW_OPTION_YES:
- if (hton->panic && hton->panic(HA_PANIC_CLOSE))
- DBUG_RETURN(1);
if (installed_htons[hton->db_type] == hton)
installed_htons[hton->db_type]= NULL;
+ if (hton->panic && hton->panic(HA_PANIC_CLOSE))
+ DBUG_RETURN(1);
break;
};
DBUG_RETURN(0);
@@ -396,37 +372,28 @@ 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;
-
+ plugin->data= hton; // shortcut for the future
+ /*
+ 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++;
-
+ uint tmp;
/* 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 +404,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;
+ tmp= hton->savepoint_offset;
+ hton->savepoint_offset= savepoint_alloc_size;
+ savepoint_alloc_size+= tmp;
+ hton->slot= total_ha++;
+ hton2plugin[hton->slot]=plugin;
+ if (hton->prepare)
+ total_ha_2pc++;
break;
}
/* fall through */
@@ -451,33 +425,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
@@ -489,16 +444,14 @@ int ha_init()
DBUG_RETURN(error);
}
+/*
+ close, flush or restart databases
+ Ignore this for other databases than ours
+*/
-
-
- /* close, flush or restart databases */
- /* Ignore this for other databases than ours */
-
-static my_bool panic_handlerton(THD *unused1, st_plugin_int *plugin,
- void *arg)
+static my_bool panic_handlerton(THD *unused1, st_plugin_int *plugin, void *arg)
{
- handlerton *hton= (handlerton *) plugin->plugin->info;
+ handlerton *hton= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->panic)
((int*)arg)[0]|= hton->panic((enum ha_panic_function)((int*)arg)[1]);
return FALSE;
@@ -508,10 +461,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 +473,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= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->drop_database)
hton->drop_database((char *)path);
return FALSE;
@@ -536,9 +489,11 @@ 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
- be rolled back already */
+ handlerton *hton= (handlerton *)plugin->data;
+ /*
+ 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])
hton->close_connection(thd);
@@ -628,7 +583,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.str);
}
}
}
@@ -867,7 +823,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= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->recover)
{
hton->commit_by_xid(((struct xahton_st *)arg)->xid);
@@ -879,7 +835,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= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->recover)
{
hton->rollback_by_xid(((struct xahton_st *)arg)->xid);
@@ -894,7 +850,7 @@ int ha_commit_or_rollback_by_xid(XID *xid, bool commit)
struct xahton_st xaop;
xaop.xid= xid;
xaop.result= 1;
-
+
plugin_foreach(NULL, commit ? xacommit_handlerton : xarollback_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, &xaop);
@@ -986,16 +942,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= (handlerton *)plugin->data;
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.str);
for (int i=0; i < got; i ++)
{
my_xid x=info->list[i].get_my_xid();
@@ -1175,7 +1131,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= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->release_temporary_latches)
hton->release_temporary_latches(thd);
@@ -1300,7 +1256,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= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES &&
hton->start_consistent_snapshot)
{
@@ -1331,7 +1287,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= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->flush_logs && hton->flush_logs())
return TRUE;
return FALSE;
@@ -2642,7 +2598,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= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->binlog_func)
{
uint sz= hton_list->sz;
@@ -2732,7 +2688,7 @@ static my_bool binlog_log_query_handlerton(THD *thd,
st_plugin_int *plugin,
void *args)
{
- return binlog_log_query_handlerton2(thd, (const handlerton *) plugin->plugin->info, args);
+ return binlog_log_query_handlerton2(thd, (const handlerton *)plugin->data, args);
}
void ha_binlog_log_query(THD *thd, const handlerton *hton,
@@ -3013,7 +2969,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 +2983,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= (handlerton *)plugin->data;
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 +3019,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 +3059,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= (handlerton *)plugin->data;
if (hton->state == SHOW_OPTION_YES && hton->show_status &&
hton->show_status(thd, stat_print, stat))
return TRUE;
@@ -3126,16 +3082,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 LEX_STRING *name=&hton2plugin[db_type->slot]->name;
+ result= stat_print(thd, name->str, name->length,
"", 0, "DISABLED", 8) ? 1 : 0;
+ }
else
- result= db_type->show_status &&
+ result= db_type->show_status &&
db_type->show_status(thd, stat_print, stat) ? 1 : 0;
}
diff --git a/sql/handler.h b/sql/handler.h
index 9a5a3b04823..564f391ce2d 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -177,6 +177,7 @@
so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
example + csv + heap + blackhole + federated + 0
(yes, the sum is deliberately inaccurate)
+ TODO remove the limit, use dynarrays
*/
#define MAX_HA 15
@@ -460,6 +461,7 @@ typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len,
const char *file, uint file_len,
const char *status, uint status_len);
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
+extern st_plugin_int *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.str;
}
static inline bool ha_check_storage_engine_flag(const handlerton *db_type, uint32 flag)
diff --git a/sql/log.cc b/sql/log.cc
index 31133a71757..86a29feb026 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -47,7 +47,7 @@ ulong sync_binlog_counter= 0;
static bool test_if_number(const char *str,
long *res, bool allow_wildcards);
-static bool binlog_init();
+static int binlog_init();
static int binlog_close_connection(THD *thd);
static int binlog_savepoint_set(THD *thd, void *sv);
static int binlog_savepoint_rollback(THD *thd, void *sv);
@@ -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 */,
}
diff --git a/sql/log_event.cc b/sql/log_event.cc
index ab9fa2975a1..cbf1875c9ec 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -3481,24 +3481,12 @@ int Rand_log_event::exec_event(struct st_relay_log_info* rli)
Xid_log_event methods
**************************************************************************/
-#if !defined(DBUG_OFF) && !defined(MYSQL_CLIENT)
-/*
- This static class member could be removed when mysqltest is made to support
- a --replace-regex command: then tests which have XIDs in their output can
- use this command to suppress non-deterministic XID values.
-*/
-my_bool Xid_log_event::show_xid;
-#endif
-
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Xid_log_event::pack_info(Protocol *protocol)
{
char buf[128], *pos;
pos= strmov(buf, "COMMIT /* xid=");
-#if !defined(DBUG_OFF) && !defined(MYSQL_CLIENT)
- if (show_xid)
-#endif
- pos= longlong10_to_str(xid, pos, 10);
+ pos= longlong10_to_str(xid, pos, 10);
pos= strmov(pos, " */");
protocol->store(buf, (uint) (pos-buf), &my_charset_bin);
}
diff --git a/sql/log_event.h b/sql/log_event.h
index d9a9d93a1e5..36933f4a7dd 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -1221,9 +1221,6 @@ class Xid_log_event: public Log_event
bool write(IO_CACHE* file);
#endif
bool is_valid() const { return 1; }
-#if !defined(DBUG_OFF) && !defined(MYSQL_CLIENT)
- static my_bool show_xid;
-#endif
};
/*****************************************************************************
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index e3db96be2e7..499b4a741b6 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -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"
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 91828edec9c..8e58b82a3a5 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -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;
@@ -2651,12 +2651,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);
@@ -3172,6 +3166,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())
{
@@ -3218,15 +3218,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 ?
@@ -4901,14 +4913,6 @@ Disable with --skip-bdb (will save memory).",
{"binlog-ignore-db", OPT_BINLOG_IGNORE_DB,
"Tells the master that updates to the given database should not be logged tothe binary log.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-#if !defined(DBUG_OFF) && !defined(MYSQL_CLIENT)
- {"binlog-show-xid", OPT_BINLOG_SHOW_XID,
- "Option used by mysql-test for debugging and testing: "
- "do not display the XID in SHOW BINLOG EVENTS; "
- "may be removed in future versions",
- (gptr*) &Xid_log_event::show_xid, (gptr*) &Xid_log_event::show_xid,
- 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
-#endif
#ifdef HAVE_ROW_BASED_REPLICATION
{"binlog-row-event-max-size", OPT_BINLOG_ROWS_EVENT_MAX_SIZE,
"The maximum size of a row-based binary log event in bytes. Rows will be "
@@ -4975,7 +4979,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,
@@ -7004,8 +7009,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;
@@ -7465,17 +7470,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_BOOTSTRAP:
opt_noacl=opt_bootstrap=1;
break;
- case OPT_STORAGE_ENGINE:
- {
- LEX_STRING name= { argument, strlen(argument) };
- if ((global_system_variables.table_type=
- ha_resolve_by_name(current_thd, &name)) == NULL)
- {
- fprintf(stderr,"Unknown/unsupported table type: %s\n",argument);
- exit(1);
- }
- break;
- }
case OPT_SERVER_ID:
server_id_supplied = 1;
break;
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 242fe0f6068..3dbbd243ee4 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -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.str;
}
diff --git a/sql/slave.cc b/sql/slave.cc
index 4ab9e951813..5ef91b1f0d4 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -95,6 +95,8 @@ void init_thread_mask(int* mask,MASTER_INFO* mi,bool inverse)
{
bool set_io = mi->slave_running, set_sql = mi->rli.slave_running;
register int tmp_mask=0;
+ DBUG_ENTER("init_thread_mask");
+
if (set_io)
tmp_mask |= SLAVE_IO;
if (set_sql)
@@ -102,6 +104,7 @@ void init_thread_mask(int* mask,MASTER_INFO* mi,bool inverse)
if (inverse)
tmp_mask^= (SLAVE_IO | SLAVE_SQL);
*mask = tmp_mask;
+ DBUG_VOID_RETURN;
}
@@ -111,9 +114,12 @@ void init_thread_mask(int* mask,MASTER_INFO* mi,bool inverse)
void lock_slave_threads(MASTER_INFO* mi)
{
+ DBUG_ENTER("lock_slave_threads");
+
//TODO: see if we can do this without dual mutex
pthread_mutex_lock(&mi->run_lock);
pthread_mutex_lock(&mi->rli.run_lock);
+ DBUG_VOID_RETURN;
}
@@ -123,9 +129,12 @@ void lock_slave_threads(MASTER_INFO* mi)
void unlock_slave_threads(MASTER_INFO* mi)
{
+ DBUG_ENTER("unlock_slave_threads");
+
//TODO: see if we can do this without dual mutex
pthread_mutex_unlock(&mi->rli.run_lock);
pthread_mutex_unlock(&mi->run_lock);
+ DBUG_VOID_RETURN;
}
@@ -423,6 +432,8 @@ err:
void init_slave_skip_errors(const char* arg)
{
const char *p;
+ DBUG_ENTER("init_slave_skip_errors");
+
if (bitmap_init(&slave_error_mask,0,MAX_SLAVE_ERROR,0))
{
fprintf(stderr, "Badly out of memory, please check your system status\n");
@@ -434,7 +445,7 @@ void init_slave_skip_errors(const char* arg)
if (!my_strnncoll(system_charset_info,(uchar*)arg,4,(const uchar*)"all",4))
{
bitmap_set_all(&slave_error_mask);
- return;
+ DBUG_VOID_RETURN;
}
for (p= arg ; *p; )
{
@@ -446,12 +457,15 @@ void init_slave_skip_errors(const char* arg)
while (!my_isdigit(system_charset_info,*p) && *p)
p++;
}
+ DBUG_VOID_RETURN;
}
void st_relay_log_info::inc_group_relay_log_pos(ulonglong log_pos,
bool skip_lock)
{
+ DBUG_ENTER("st_relay_log_info::inc_group_relay_log_pos");
+
if (!skip_lock)
pthread_mutex_lock(&data_lock);
inc_event_relay_log_pos();
@@ -500,12 +514,14 @@ void st_relay_log_info::inc_group_relay_log_pos(ulonglong log_pos,
pthread_cond_broadcast(&data_cond);
if (!skip_lock)
pthread_mutex_unlock(&data_lock);
+ DBUG_VOID_RETURN;
}
void st_relay_log_info::close_temporary_tables()
{
TABLE *table,*next;
+ DBUG_ENTER("st_relay_log_info::close_temporary_tables");
for (table=save_temporary_tables ; table ; table=next)
{
@@ -514,10 +530,12 @@ void st_relay_log_info::close_temporary_tables()
Don't ask for disk deletion. For now, anyway they will be deleted when
slave restarts, but it is a better intention to not delete them.
*/
+ DBUG_PRINT("info", ("table: %p", table));
close_temporary(table, 1, 0);
}
save_temporary_tables= 0;
slave_open_temp_tables= 0;
+ DBUG_VOID_RETURN;
}
/*
@@ -613,12 +631,13 @@ err:
int terminate_slave_threads(MASTER_INFO* mi,int thread_mask,bool skip_lock)
{
+ DBUG_ENTER("terminate_slave_threads");
+
if (!mi->inited)
- return 0; /* successfully do nothing */
+ DBUG_RETURN(0); /* successfully do nothing */
int error,force_all = (thread_mask & SLAVE_FORCE_ALL);
pthread_mutex_t *sql_lock = &mi->rli.run_lock, *io_lock = &mi->run_lock;
pthread_mutex_t *sql_cond_lock,*io_cond_lock;
- DBUG_ENTER("terminate_slave_threads");
sql_cond_lock=sql_lock;
io_cond_lock=io_lock;
@@ -704,9 +723,10 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
{
pthread_t th;
ulong start_id;
- DBUG_ASSERT(mi->inited);
DBUG_ENTER("start_slave_thread");
+ DBUG_ASSERT(mi->inited);
+
if (start_lock)
pthread_mutex_lock(start_lock);
if (!server_id)
@@ -810,8 +830,10 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
#ifdef NOT_USED_YET
static int end_slave_on_walk(MASTER_INFO* mi, gptr /*unused*/)
{
+ DBUG_ENTER("end_slave_on_walk");
+
end_master_info(mi);
- return 0;
+ DBUG_RETURN(0);
}
#endif
@@ -825,6 +847,8 @@ static int end_slave_on_walk(MASTER_INFO* mi, gptr /*unused*/)
void end_slave()
{
+ DBUG_ENTER("end_slave");
+
/*
This is called when the server terminates, in close_connections().
It terminates slave threads. However, some CHANGE MASTER etc may still be
@@ -846,19 +870,24 @@ void end_slave()
active_mi= 0;
}
pthread_mutex_unlock(&LOCK_active_mi);
+ DBUG_VOID_RETURN;
}
static bool io_slave_killed(THD* thd, MASTER_INFO* mi)
{
+ DBUG_ENTER("io_slave_killed");
+
DBUG_ASSERT(mi->io_thd == thd);
DBUG_ASSERT(mi->slave_running); // tracking buffer overrun
- return mi->abort_slave || abort_loop || thd->killed;
+ DBUG_RETURN(mi->abort_slave || abort_loop || thd->killed);
}
static bool sql_slave_killed(THD* thd, RELAY_LOG_INFO* rli)
{
+ DBUG_ENTER("sql_slave_killed");
+
DBUG_ASSERT(rli->sql_thd == thd);
DBUG_ASSERT(rli->slave_running == 1);// tracking buffer overrun
if (abort_loop || thd->killed || rli->abort_slave)
@@ -873,7 +902,7 @@ static bool sql_slave_killed(THD* thd, RELAY_LOG_INFO* rli)
is actively working.
*/
if (!rli->unsafe_to_stop_at)
- return 1;
+ DBUG_RETURN(1);
DBUG_PRINT("info", ("Slave SQL thread is in an unsafe situation, giving "
"it some grace period"));
if (difftime(time(0), rli->unsafe_to_stop_at) > 60)
@@ -885,10 +914,10 @@ static bool sql_slave_killed(THD* thd, RELAY_LOG_INFO* rli)
"There is a risk of duplicate updates when the slave "
"SQL thread is restarted. Please check your tables' "
"contents after restart.");
- return 1;
+ DBUG_RETURN(1);
}
}
- return 0;
+ DBUG_RETURN(0);
}
@@ -917,6 +946,8 @@ void slave_print_msg(enum loglevel level, RELAY_LOG_INFO* rli,
char buff[MAX_SLAVE_ERRMSG], *pbuff= buff;
uint pbuffsize= sizeof(buff);
va_list args;
+ DBUG_ENTER("slave_print_msg");
+
va_start(args,msg);
switch (level)
{
@@ -943,7 +974,7 @@ void slave_print_msg(enum loglevel level, RELAY_LOG_INFO* rli,
break;
default:
DBUG_ASSERT(0); // should not come here
- return; // don't crash production builds, just do nothing
+ DBUG_VOID_RETURN; // don't crash production builds, just do nothing
}
my_vsnprintf(pbuff, pbuffsize, msg, args);
/* If the msg string ends with '.', do not add a ',' it would be ugly */
@@ -951,6 +982,7 @@ void slave_print_msg(enum loglevel level, RELAY_LOG_INFO* rli,
(*report_function)("Slave: %s Error_code: %d", pbuff, err_code);
else
(*report_function)("Slave: %s, Error_code: %d", pbuff, err_code);
+ DBUG_VOID_RETURN;
}
/*
@@ -962,9 +994,12 @@ void slave_print_msg(enum loglevel level, RELAY_LOG_INFO* rli,
void skip_load_data_infile(NET *net)
{
+ DBUG_ENTER("skip_load_data_infile");
+
(void)net_request_file(net, "/dev/null");
(void)my_net_read(net); // discard response
(void)net_write_command(net, 0, "", 0, "", 0); // Send ok
+ DBUG_VOID_RETURN;
}
@@ -983,13 +1018,17 @@ bool net_request_file(NET* net, const char* fname)
const char *print_slave_db_safe(const char* db)
{
- return (db ? db : "");
+ DBUG_ENTER("*print_slave_db_safe");
+
+ DBUG_RETURN((db ? db : ""));
}
static int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
const char *default_val)
{
uint length;
+ DBUG_ENTER("init_strvar_from_file");
+
if ((length=my_b_gets(f,var, max_size)))
{
char* last_p = var + length -1;
@@ -1004,32 +1043,34 @@ static int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
int c;
while (((c=my_b_get(f)) != '\n' && c != my_b_EOF));
}
- return 0;
+ DBUG_RETURN(0);
}
else if (default_val)
{
strmake(var, default_val, max_size-1);
- return 0;
+ DBUG_RETURN(0);
}
- return 1;
+ DBUG_RETURN(1);
}
static int init_intvar_from_file(int* var, IO_CACHE* f, int default_val)
{
char buf[32];
+ DBUG_ENTER("init_intvar_from_file");
+
if (my_b_gets(f, buf, sizeof(buf)))
{
*var = atoi(buf);
- return 0;
+ DBUG_RETURN(0);
}
else if (default_val)
{
*var = default_val;
- return 0;
+ DBUG_RETURN(0);
}
- return 1;
+ DBUG_RETURN(1);
}
/*
@@ -1049,6 +1090,7 @@ static int init_intvar_from_file(int* var, IO_CACHE* f, int default_val)
static int get_master_version_and_clock(MYSQL* mysql, MASTER_INFO* mi)
{
const char* errmsg= 0;
+ DBUG_ENTER("get_master_version_and_clock");
/*
Free old description_event_for_queue (that is needed if we are in
@@ -1104,14 +1146,14 @@ static int get_master_version_and_clock(MYSQL* mysql, MASTER_INFO* mi)
if (errmsg)
{
sql_print_error(errmsg);
- return 1;
+ DBUG_RETURN(1);
}
/* as we are here, we tried to allocate the event */
if (!mi->rli.relay_log.description_event_for_queue)
{
sql_print_error("Slave I/O thread failed to create a default Format_description_log_event");
- return 1;
+ DBUG_RETURN(1);
}
/*
@@ -1227,10 +1269,10 @@ err:
if (errmsg)
{
sql_print_error(errmsg);
- return 1;
+ DBUG_RETURN(1);
}
- return 0;
+ DBUG_RETURN(0);
}
/*
@@ -1257,7 +1299,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
handler *file;
ulong save_options;
NET *net= &mysql->net;
- DBUG_ENTER("create_table_from_dump");
+ DBUG_ENTER("create_table_from_dump");
packet_len= my_net_read(net); // read create table statement
if (packet_len == packet_error)
@@ -1666,7 +1708,6 @@ static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli)
MASTER_INFO* mi = rli->mi;
const char *save_proc_info;
THD* thd = mi->io_thd;
-
DBUG_ENTER("wait_for_relay_log_space");
pthread_mutex_lock(&rli->log_space_lock);
@@ -1725,6 +1766,8 @@ static void write_ignored_events_info_to_relay_log(THD *thd, MASTER_INFO *mi)
{
RELAY_LOG_INFO *rli= &mi->rli;
pthread_mutex_t *log_lock= rli->relay_log.get_log_lock();
+ DBUG_ENTER("write_ignored_events_info_to_relay_log");
+
DBUG_ASSERT(thd == mi->io_thd);
pthread_mutex_lock(log_lock);
if (rli->ign_master_log_name_end[0])
@@ -1755,11 +1798,14 @@ static void write_ignored_events_info_to_relay_log(THD *thd, MASTER_INFO *mi)
}
else
pthread_mutex_unlock(log_lock);
+ DBUG_VOID_RETURN;
}
void init_master_info_with_options(MASTER_INFO* mi)
{
+ DBUG_ENTER("init_master_info_with_options");
+
mi->master_log_name[0] = 0;
mi->master_log_pos = BIN_LOG_HEADER_SIZE; // skip magic number
@@ -1783,13 +1829,17 @@ void init_master_info_with_options(MASTER_INFO* mi)
strmake(mi->ssl_cipher, master_ssl_cipher, sizeof(mi->ssl_cipher)-1);
if (master_ssl_key)
strmake(mi->ssl_key, master_ssl_key, sizeof(mi->ssl_key)-1);
+ DBUG_VOID_RETURN;
}
void clear_slave_error(RELAY_LOG_INFO* rli)
{
+ DBUG_ENTER("clear_slave_error");
+
/* Clear the errors displayed by SHOW SLAVE STATUS */
rli->last_slave_error[0]= 0;
rli->last_slave_errno= 0;
+ DBUG_VOID_RETURN;
}
/*
@@ -1800,9 +1850,12 @@ void clear_slave_error(RELAY_LOG_INFO* rli)
*/
void clear_until_condition(RELAY_LOG_INFO* rli)
{
+ DBUG_ENTER("clear_until_condition");
+
rli->until_condition= RELAY_LOG_INFO::UNTIL_NONE;
rli->until_log_name[0]= 0;
rli->until_log_pos= 0;
+ DBUG_VOID_RETURN;
}
@@ -2031,9 +2084,10 @@ int register_slave_on_master(MYSQL* mysql)
{
char buf[1024], *pos= buf;
uint report_host_len, report_user_len=0, report_password_len=0;
+ DBUG_ENTER("register_slave_on_master");
if (!report_host)
- return 0;
+ DBUG_RETURN(0);
report_host_len= strlen(report_host);
if (report_user)
report_user_len= strlen(report_user);
@@ -2042,7 +2096,7 @@ int register_slave_on_master(MYSQL* mysql)
/* 30 is a good safety margin */
if (report_host_len + report_user_len + report_password_len + 30 >
sizeof(buf))
- return 0; // safety
+ DBUG_RETURN(0); // safety
int4store(pos, server_id); pos+= 4;
pos= net_store_data(pos, report_host, report_host_len);
@@ -2059,9 +2113,9 @@ int register_slave_on_master(MYSQL* mysql)
sql_print_error("Error on COM_REGISTER_SLAVE: %d '%s'",
mysql_errno(mysql),
mysql_error(mysql));
- return 1;
+ DBUG_RETURN(1);
}
- return 0;
+ DBUG_RETURN(0);
}
@@ -2313,6 +2367,8 @@ st_relay_log_info::st_relay_log_info()
m_reload_flags(RELOAD_NONE_F),
unsafe_to_stop_at(0)
{
+ DBUG_ENTER("st_relay_log_info::st_relay_log_info");
+
group_relay_log_name[0]= event_relay_log_name[0]=
group_master_log_name[0]= 0;
last_slave_error[0]= until_log_name[0]= ign_master_log_name_end[0]= 0;
@@ -2327,11 +2383,14 @@ st_relay_log_info::st_relay_log_info()
pthread_cond_init(&stop_cond, NULL);
pthread_cond_init(&log_space_cond, NULL);
relay_log.init_pthread_objects();
+ DBUG_VOID_RETURN;
}
st_relay_log_info::~st_relay_log_info()
{
+ DBUG_ENTER("st_relay_log_info::~st_relay_log_info");
+
pthread_mutex_destroy(&run_lock);
pthread_mutex_destroy(&data_lock);
pthread_mutex_destroy(&log_space_lock);
@@ -2340,6 +2399,7 @@ st_relay_log_info::~st_relay_log_info()
pthread_cond_destroy(&stop_cond);
pthread_cond_destroy(&log_space_cond);
relay_log.cleanup();
+ DBUG_VOID_RETURN;
}
/*
@@ -2371,14 +2431,16 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name,
longlong log_pos,
longlong timeout)
{
- if (!inited)
- return -1;
int event_count = 0;
ulong init_abort_pos_wait;
int error=0;
struct timespec abstime; // for timeout checking
const char *msg;
- DBUG_ENTER("wait_for_pos");
+ DBUG_ENTER("st_relay_log_info::wait_for_pos");
+
+ if (!inited)
+ DBUG_RETURN(-1);
+
DBUG_PRINT("enter",("log_name: '%s' log_pos: %lu timeout: %lu",
log_name->c_ptr(), (ulong) log_pos, (ulong) timeout));
@@ -2546,13 +2608,18 @@ improper_arguments: %d timed_out: %d",
void set_slave_thread_options(THD* thd)
{
+ DBUG_ENTER("set_slave_thread_options");
+
thd->options = ((opt_log_slave_updates) ? OPTION_BIN_LOG:0) |
OPTION_AUTO_IS_NULL;
thd->variables.completion_type= 0;
+ DBUG_VOID_RETURN;
}
void set_slave_thread_default_charset(THD* thd, RELAY_LOG_INFO *rli)
{
+ DBUG_ENTER("set_slave_thread_default_charset");
+
thd->variables.character_set_client=
global_system_variables.character_set_client;
thd->variables.collation_connection=
@@ -2561,6 +2628,7 @@ void set_slave_thread_default_charset(THD* thd, RELAY_LOG_INFO *rli)
global_system_variables.collation_server;
thd->update_charset();
rli->cached_charset_invalidate();
+ DBUG_VOID_RETURN;
}
/*
@@ -2622,6 +2690,8 @@ static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed,
{
int nap_time;
thr_alarm_t alarmed;
+ DBUG_ENTER("safe_sleep");
+
thr_alarm_init(&alarmed);
time_t start_time= time((time_t*) 0);
time_t end_time= start_time+sec;
@@ -2639,10 +2709,10 @@ static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed,
thr_end_alarm(&alarmed);
if ((*thread_killed)(thd,thread_killed_arg))
- return 1;
+ DBUG_RETURN(1);
start_time=time((time_t*) 0);
}
- return 0;
+ DBUG_RETURN(0);
}
@@ -2684,13 +2754,15 @@ static int request_dump(MYSQL* mysql, MASTER_INFO* mi,
static int request_table_dump(MYSQL* mysql, const char* db, const char* table)
{
char buf[1024];
+ DBUG_ENTER("request_table_dump");
+
char * p = buf;
uint table_len = (uint) strlen(table);
uint db_len = (uint) strlen(db);
if (table_len + db_len > sizeof(buf) - 2)
{
sql_print_error("request_table_dump: Buffer overrun");
- return 1;
+ DBUG_RETURN(1);
}
*p++ = db_len;
@@ -2703,10 +2775,10 @@ static int request_table_dump(MYSQL* mysql, const char* db, const char* table)
{
sql_print_error("request_table_dump: Error sending the table dump \
command");
- return 1;
+ DBUG_RETURN(1);
}
- return 0;
+ DBUG_RETURN(0);
}
@@ -2730,6 +2802,7 @@ command");
static ulong read_event(MYSQL* mysql, MASTER_INFO *mi, bool* suppress_warnings)
{
ulong len;
+ DBUG_ENTER("read_event");
*suppress_warnings= 0;
/*
@@ -2738,7 +2811,7 @@ static ulong read_event(MYSQL* mysql, MASTER_INFO *mi, bool* suppress_warnings)
*/
#ifndef DBUG_OFF
if (disconnect_slave_event_count && !(mi->events_till_disconnect--))
- return packet_error;
+ DBUG_RETURN(packet_error);
#endif
len = net_safe_read(mysql);
@@ -2756,7 +2829,7 @@ static ulong read_event(MYSQL* mysql, MASTER_INFO *mi, bool* suppress_warnings)
else
sql_print_error("Error reading packet from server: %s ( server_errno=%d)",
mysql_error(mysql), mysql_errno(mysql));
- return packet_error;
+ DBUG_RETURN(packet_error);
}
/* Check if eof packet */
@@ -2765,25 +2838,27 @@ static ulong read_event(MYSQL* mysql, MASTER_INFO *mi, bool* suppress_warnings)
sql_print_information("Slave: received end packet from server, apparent "
"master shutdown: %s",
mysql_error(mysql));
- return packet_error;
+ DBUG_RETURN(packet_error);
}
DBUG_PRINT("info",( "len=%u, net->read_pos[4] = %d\n",
len, mysql->net.read_pos[4]));
- return len - 1;
+ DBUG_RETURN(len - 1);
}
int check_expected_error(THD* thd, RELAY_LOG_INFO* rli, int expected_error)
{
+ DBUG_ENTER("check_expected_error");
+
switch (expected_error) {
case ER_NET_READ_ERROR:
case ER_NET_ERROR_ON_WRITE:
case ER_SERVER_SHUTDOWN:
case ER_NEW_ABORTING_CONNECTION:
- return 1;
+ DBUG_RETURN(1);
default:
- return 0;
+ DBUG_RETURN(0);
}
}
@@ -2819,6 +2894,7 @@ bool st_relay_log_info::is_until_satisfied()
{
const char *log_name;
ulonglong log_pos;
+ DBUG_ENTER("st_relay_log_info::is_until_satisfied");
DBUG_ASSERT(until_condition != UNTIL_NONE);
@@ -2865,34 +2941,39 @@ bool st_relay_log_info::is_until_satisfied()
/* Probably error so we aborting */
sql_print_error("Slave SQL thread is stopped because UNTIL "
"condition is bad.");
- return TRUE;
+ DBUG_RETURN(TRUE);
}
}
else
- return until_log_pos == 0;
+ DBUG_RETURN(until_log_pos == 0);
}
- return ((until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_EQUAL &&
+ DBUG_RETURN(((until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_EQUAL &&
log_pos >= until_log_pos) ||
- until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_GREATER);
+ until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_GREATER));
}
void st_relay_log_info::cached_charset_invalidate()
{
+ DBUG_ENTER("st_relay_log_info::cached_charset_invalidate");
+
/* Full of zeroes means uninitialized. */
bzero(cached_charset, sizeof(cached_charset));
+ DBUG_VOID_RETURN;
}
bool st_relay_log_info::cached_charset_compare(char *charset)
{
+ DBUG_ENTER("st_relay_log_info::cached_charset_compare");
+
if (bcmp(cached_charset, charset, sizeof(cached_charset)))
{
memcpy(cached_charset, charset, sizeof(cached_charset));
- return 1;
+ DBUG_RETURN(1);
}
- return 0;
+ DBUG_RETURN(0);
}
/*
@@ -2904,8 +2985,10 @@ bool st_relay_log_info::cached_charset_compare(char *charset)
*/
static int has_temporary_error(THD *thd)
{
+ DBUG_ENTER("has_temporary_error");
+
if (thd->is_fatal_error)
- return 0;
+ DBUG_RETURN(0);
/*
Temporary error codes:
@@ -2914,7 +2997,7 @@ static int has_temporary_error(THD *thd)
*/
if (thd->net.last_errno == ER_LOCK_DEADLOCK ||
thd->net.last_errno == ER_LOCK_WAIT_TIMEOUT)
- return 1;
+ DBUG_RETURN(1);
#ifdef HAVE_NDB_BINLOG
/*
@@ -2928,17 +3011,19 @@ static int has_temporary_error(THD *thd)
switch (err->code)
{
case ER_GET_TEMPORARY_ERRMSG:
- return 1;
+ DBUG_RETURN(1);
default:
break;
}
}
#endif
- return 0;
+ DBUG_RETURN(0);
}
static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
{
+ DBUG_ENTER("exec_relay_log_event");
+
/*
We acquire this mutex since we need it for all operations except
event execution. But we will release it in places where we will
@@ -2965,7 +3050,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
*/
rli->abort_slave= 1;
pthread_mutex_unlock(&rli->data_lock);
- return 1;
+ DBUG_RETURN(1);
}
Log_event * ev = next_event(rli);
@@ -2976,7 +3061,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
{
pthread_mutex_unlock(&rli->data_lock);
delete ev;
- return 1;
+ DBUG_RETURN(1);
}
if (ev)
{
@@ -3044,7 +3129,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
--rli->slave_skip_counter;
pthread_mutex_unlock(&rli->data_lock);
delete ev;
- return 0; // avoid infinite update loops
+ DBUG_RETURN(0); // avoid infinite update loops
}
pthread_mutex_unlock(&rli->data_lock);
@@ -3125,13 +3210,11 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
*/
rli->trans_retries= 0; // restart from fresh
}
- }
- return exec_res;
+ }
+ DBUG_RETURN(exec_res);
}
- else
- {
- pthread_mutex_unlock(&rli->data_lock);
- slave_print_msg(ERROR_LEVEL, rli, 0, "\
+ pthread_mutex_unlock(&rli->data_lock);
+ slave_print_msg(ERROR_LEVEL, rli, 0, "\
Could not parse relay log event entry. The possible reasons are: the master's \
binary log is corrupted (you can check this by running 'mysqlbinlog' on the \
binary log), the slave's relay log is corrupted (you can check this by running \
@@ -3140,8 +3223,7 @@ or slave's MySQL code. If you want to check the master's binary log or slave's \
relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' \
on this slave.\
");
- return 1;
- }
+ DBUG_RETURN(1);
}
@@ -3461,6 +3543,7 @@ pthread_handler_t handle_slave_sql(void *arg)
{
THD *thd; /* needs to be first for thread_stack */
char llbuff[22],llbuff1[22];
+
RELAY_LOG_INFO* rli = &((MASTER_INFO*)arg)->rli;
const char *errmsg;
@@ -4060,16 +4143,18 @@ err:
static int queue_old_event(MASTER_INFO *mi, const char *buf,
ulong event_len)
{
+ DBUG_ENTER("queue_old_event");
+
switch (mi->rli.relay_log.description_event_for_queue->binlog_version)
{
case 1:
- return queue_binlog_ver_1_event(mi,buf,event_len);
+ DBUG_RETURN(queue_binlog_ver_1_event(mi,buf,event_len));
case 3:
- return queue_binlog_ver_3_event(mi,buf,event_len);
+ DBUG_RETURN(queue_binlog_ver_3_event(mi,buf,event_len));
default: /* unsupported format; eg version 2 */
DBUG_PRINT("info",("unsupported binlog format %d in queue_old_event()",
mi->rli.relay_log.description_event_for_queue->binlog_version));
- return 1;
+ DBUG_RETURN(1);
}
}
@@ -4282,7 +4367,9 @@ void end_relay_log_info(RELAY_LOG_INFO* rli)
static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi)
{
- return connect_to_master(thd, mysql, mi, 0, 0);
+ DBUG_ENTER("safe_connect");
+
+ DBUG_RETURN(connect_to_master(thd, mysql, mi, 0, 0));
}
@@ -4439,9 +4526,10 @@ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
bool flush_relay_log_info(RELAY_LOG_INFO* rli)
{
bool error=0;
+ DBUG_ENTER("flush_relay_log_info");
if (unlikely(rli->no_storage))
- return 0;
+ DBUG_RETURN(0);
IO_CACHE *file = &rli->info_file;
char buff[FN_REFLEN*2+22*2+4], *pos;
@@ -4461,7 +4549,7 @@ bool flush_relay_log_info(RELAY_LOG_INFO* rli)
error=1;
/* Flushing the relay log is done by the slave I/O thread */
- return error;
+ DBUG_RETURN(error);
}
@@ -4471,9 +4559,9 @@ bool flush_relay_log_info(RELAY_LOG_INFO* rli)
static IO_CACHE *reopen_relay_log(RELAY_LOG_INFO *rli, const char **errmsg)
{
+ DBUG_ENTER("reopen_relay_log");
DBUG_ASSERT(rli->cur_log != &rli->cache_buf);
DBUG_ASSERT(rli->cur_log_fd == -1);
- DBUG_ENTER("reopen_relay_log");
IO_CACHE *cur_log = rli->cur_log=&rli->cache_buf;
if ((rli->cur_log_fd=open_binlog(cur_log,rli->event_relay_log_name,
@@ -4494,11 +4582,11 @@ static Log_event* next_event(RELAY_LOG_INFO* rli)
{
Log_event* ev;
IO_CACHE* cur_log = rli->cur_log;
- pthread_mutex_t *log_lock = rli->relay_log.get_log_lock();
+ pthread_mutex_t *log_lock = rli->relay_log.get_log_lock();
const char* errmsg=0;
THD* thd = rli->sql_thd;
-
DBUG_ENTER("next_event");
+
DBUG_ASSERT(thd != 0);
#ifndef DBUG_OFF
@@ -4909,12 +4997,16 @@ static int reload_entry_compare(const void *lhs, const void *rhs)
{
const char *lstr = static_cast<const char *>(lhs);
const char *rstr = static_cast<const st_reload_entry*>(rhs)->table;
- return strcmp(lstr, rstr);
+ DBUG_ENTER("reload_entry_compare");
+
+ DBUG_RETURN(strcmp(lstr, rstr));
}
void st_relay_log_info::touching_table(char const* db, char const* table,
ulong table_id)
{
+ DBUG_ENTER("st_relay_log_info::touching_table");
+
if (strcmp(db,"mysql") == 0)
{
#if defined(HAVE_BSEARCH) && defined(HAVE_SIZE_T)
@@ -4935,10 +5027,13 @@ void st_relay_log_info::touching_table(char const* db, char const* table,
if (entry)
m_reload_flags|= entry->flag;
}
+ DBUG_VOID_RETURN;
}
void st_relay_log_info::transaction_end(THD* thd)
{
+ DBUG_ENTER("st_relay_log_info::transaction_end");
+
if (m_reload_flags != RELOAD_NONE_F)
{
if (m_reload_flags & RELOAD_ACCESS_F)
@@ -4949,11 +5044,14 @@ void st_relay_log_info::transaction_end(THD* thd)
m_reload_flags= RELOAD_NONE_F;
}
+ DBUG_VOID_RETURN;
}
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
void st_relay_log_info::cleanup_context(THD *thd, bool error)
{
+ DBUG_ENTER("st_relay_log_info::cleanup_context");
+
DBUG_ASSERT(sql_thd == thd);
/*
1) Instances of Table_map_log_event, if ::exec_event() was called on them,
@@ -4976,6 +5074,7 @@ void st_relay_log_info::cleanup_context(THD *thd, bool error)
close_thread_tables(thd);
clear_tables_to_lock();
unsafe_to_stop_at= 0;
+ DBUG_VOID_RETURN;
}
#endif
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 3206cfa2d52..9041e713782 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -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;
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index e946e972968..733287f8359 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -1665,8 +1665,8 @@ 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;
- DBUG_PRINT("info", ("ENGINE = %s", engine_str));
+ const char *engine_str= hton2plugin[engine_type->slot]->name.str;
+ DBUG_PRINT("info", ("ENGINE: %s", engine_str));
int err= add_string(fptr, "ENGINE = ");
return err + add_string(fptr, engine_str);
}
@@ -1676,7 +1676,7 @@ static int add_partition_options(File fptr, partition_element *p_elem)
int err= 0;
if (p_elem->tablespace_name)
- err+= add_keyword_string(fptr,"TABLESPACE", FALSE,
+ err+= add_keyword_string(fptr,"TABLESPACE", FALSE,
p_elem->tablespace_name);
if (p_elem->nodegroup_id != UNDEF_NODEGROUP)
err+= add_keyword_int(fptr,"NODEGROUP",(longlong)p_elem->nodegroup_id);
@@ -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 &&
@@ -4523,8 +4515,8 @@ the generated partition syntax in a correct manner.
DBUG_PRINT("info", ("No explicit engine used"));
create_info->db_type= table->part_info->default_engine_type;
}
- DBUG_PRINT("info", ("New engine type = %s",
- create_info->db_type->name));
+ DBUG_PRINT("info", ("New engine type: %s",
+ hton2plugin[create_info->db_type->slot]->name.str));
thd->work_part_info= NULL;
*partition_changed= TRUE;
}
@@ -4586,11 +4578,9 @@ the generated partition syntax in a correct manner.
}
if (!is_native_partitioned)
{
- DBUG_ASSERT(create_info->db_type != &default_hton);
+ DBUG_ASSERT(create_info->db_type);
create_info->db_type= &partition_hton;
}
- DBUG_PRINT("info", ("default_engine_type = %s",
- thd->work_part_info->default_engine_type->name));
}
}
DBUG_RETURN(FALSE);
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 00dbdcf84a2..4f5d952eb7b 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -23,12 +23,18 @@ extern struct st_mysql_plugin *mysqld_builtins[];
char *opt_plugin_dir_ptr;
char opt_plugin_dir[FN_REFLEN];
-LEX_STRING plugin_type_names[]=
+LEX_STRING plugin_type_names[MYSQL_MAX_PLUGIN_TYPE_NUM]=
{
{ (char *)STRING_WITH_LEN("UDF") },
{ (char *)STRING_WITH_LEN("STORAGE ENGINE") },
{ (char *)STRING_WITH_LEN("FTPARSER") }
};
+
+plugin_type_init plugin_type_initialize[MYSQL_MAX_PLUGIN_TYPE_NUM]=
+{
+ 0,ha_initialize_handlerton,0
+};
+
static const char *plugin_interface_version_sym=
"_mysql_plugin_interface_version_";
static const char *sizeof_st_plugin_sym=
@@ -523,27 +529,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);
@@ -555,14 +549,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:
@@ -592,7 +586,7 @@ static int plugin_finalize(THD *thd, struct st_plugin_int *plugin)
goto err;
}
}
-
+
DBUG_RETURN(0);
err:
DBUG_RETURN(1);
@@ -677,7 +671,7 @@ int plugin_init(void)
get_hash_key, NULL, 0))
goto err;
}
-
+
/* Register all the built-in plugins */
for (builtins= mysqld_builtins; *builtins; builtins++)
{
@@ -685,6 +679,12 @@ int plugin_init(void)
{
if (plugin_register_builtin(plugin))
goto err;
+ struct st_plugin_int *tmp=dynamic_element(&plugin_array,
+ plugin_array.elements-1,
+ struct st_plugin_int *);
+ if (plugin_initialize(tmp))
+ goto err;
+ tmp->state= PLUGIN_IS_READY;
}
}
diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h
index 672db105cd1..b013beaba1f 100644
--- a/sql/sql_plugin.h
+++ b/sql/sql_plugin.h
@@ -58,9 +58,12 @@ struct st_plugin_int
struct st_mysql_plugin *plugin;
struct st_plugin_dl *plugin_dl;
enum enum_plugin_state state;
- uint ref_count; /* number of threads using the plugin */
+ uint ref_count; /* number of threads using the plugin */
+ void *data; /* plugin type specific, e.g. handlerton */
};
+typedef int (*plugin_type_init)(struct st_plugin_int *);
+
extern char *opt_plugin_dir_ptr;
extern char opt_plugin_dir[FN_REFLEN];
extern LEX_STRING plugin_type_names[];
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index bdf0724ee96..8c492e9457b 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -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,26 @@ 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= (handlerton *)plugin->data;
if (!(hton->flags & HTON_HIDDEN))
{
protocol->prepare_for_resend();
- protocol->store(hton->name, system_charset_info);
+ protocol->store(plugin->name.str, plugin->name.length,
+ 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 +94,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 +3092,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= (handlerton *)plugin->data;
const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
CHARSET_INFO *scs= system_charset_info;
DBUG_ENTER("iter_schema_engines");
@@ -3099,21 +3100,25 @@ 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->name.str,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->name.str, plugin->name.length, 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;
@@ -5003,7 +5008,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= (handlerton *)plugin->data;
if(hton->fill_files_table)
hton->fill_files_table(thd, args->tables, args->cond);
return false;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 289051c2dd1..21dee4d3f2f 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -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.str, "TEMPORARY");
*new_engine= 0;
return TRUE;
}
diff --git a/sql/sql_tablespace.cc b/sql/sql_tablespace.cc
index 8bc39ec82c6..94318a67575 100644
--- a/sql/sql_tablespace.cc
+++ b/sql/sql_tablespace.cc
@@ -28,16 +28,16 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
If the user haven't defined an engine, this will fallback to using the
default storage engine.
*/
- if (hton == NULL || hton == &default_hton || hton->state != SHOW_OPTION_YES)
+ if (hton == NULL || hton->state != SHOW_OPTION_YES)
{
hton= ha_resolve_by_legacy_type(thd, DB_TYPE_DEFAULT);
if (ts_info->storage_engine != 0)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_WARN_USING_OTHER_HANDLER,
ER(ER_WARN_USING_OTHER_HANDLER),
- hton->name,
- ts_info->tablespace_name
- ? ts_info->tablespace_name : ts_info->logfile_group_name);
+ hton2plugin[hton->slot]->name.str,
+ 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.str,
"TABLESPACE or LOGFILE GROUP");
}
if (mysql_bin_log.is_open())
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 82dcc758ff0..af2bf8231aa 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -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();
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index f3f20f6b103..739acffeb0d 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -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,
@@ -1355,25 +1320,18 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
we don't check rc here because we want to open the file back up even
if the optimize failed but we will return rc below so that we will
know it failed.
+ We also need to reopen our read descriptor since it has changed.
*/
DBUG_PRINT("info", ("Reopening archive data file"));
- if (!(azopen(&(share->archive_write), share->data_file_name,
- O_WRONLY|O_APPEND|O_BINARY)))
+ if (!azopen(&(share->archive_write), share->data_file_name,
+ O_WRONLY|O_APPEND|O_BINARY) ||
+ !azopen(&archive, share->data_file_name, O_RDONLY|O_BINARY))
{
DBUG_PRINT("info", ("Could not open archive write file"));
rc= HA_ERR_CRASHED_ON_USAGE;
- goto error;
- }
-
- /*
- Now we need to reopen our read descriptor since it has changed.
- */
- if (!(azopen(&archive, share->data_file_name, O_RDONLY|O_BINARY)))
- {
- rc= HA_ERR_CRASHED_ON_USAGE;
- goto error;
}
+ DBUG_RETURN(rc);
error:
azclose(&writer);
@@ -1582,16 +1540,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;
+
diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h
index 4663531b674..4c53c5c4064 100644
--- a/storage/archive/ha_archive.h
+++ b/storage/archive/ha_archive.h
@@ -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);
diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc
index 098e44f39ee..3ee784c201f 100644
--- a/storage/blackhole/ha_blackhole.cc
+++ b/storage/blackhole/ha_blackhole.cc
@@ -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 */,
}
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index f15ce7cccb5..7d34571fb1d 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -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 */,
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc
index 2ce543dfbb0..28bccc7df2d 100644
--- a/storage/example/ha_example.cc
+++ b/storage/example/ha_example.cc
@@ -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 */,