summaryrefslogtreecommitdiff
path: root/sql/ha_berkeley.cc
diff options
context:
space:
mode:
authorunknown <acurtis@poseidon.ndb.mysql.com>2005-11-07 16:25:06 +0100
committerunknown <acurtis@poseidon.ndb.mysql.com>2005-11-07 16:25:06 +0100
commit6b3a9caef9b8cf42f8a706f778bba72db89cdd2b (patch)
tree2b8ffe29d899326e4ad244ac3f67d4fcf29bfae6 /sql/ha_berkeley.cc
parentdf33aacd87ff08c27fd371a0bb348fe3986e6f95 (diff)
downloadmariadb-git-6b3a9caef9b8cf42f8a706f778bba72db89cdd2b.tar.gz
Make storage engines "pluggable", handlerton work
Makefile.am: Changes to autoconf subst config/ac-macros/ha_berkeley.m4: simplify config/ac-macros/ha_ndbcluster.m4: simplify config/ac-macros/ha_partition.m4: simplify configure.in: strip configure of storage engine specific cruft and simplify extra/Makefile.am: changes to autoconf/automake subst libmysqld/Makefile.am: only compile storage engines if required. make find object file a little smarter libmysqld/examples/Makefile.am: changes to autoconf subst mysql-test/Makefile.am: remove storage engine specific cruft mysql-test/r/ps_1general.result: cannot gaurantee order of results from 'show storage engines' mysql-test/r/show_check.result: fix test - frm file fails to be deleted if it is invalid mysql-test/r/sql_mode.result: isam does not exist, test may need to be redone/fixed in 5.0 mysql-test/r/warnings.result: isam no longer exists mysql-test/t/ps_1general.test: cannot gaurantee order of results from 'show storage engines' mysql-test/t/show_check.test: fix test - frm file fails to be deleted if it is invalid mysql-test/t/sql_mode.test: isam does not exist, test may need to be redone/fixed in 5.0 mysql-test/t/system_mysql_db_fix.test: change isam to myisam mysql-test/t/view.test: change isam to myisam mysql-test/t/warnings.test: isam no longer exists sql/Makefile.am: Make storage engines "pluggable" stage 1 only compile storage engines if included sql/examples/ha_example.cc: handlerton work sql/examples/ha_example.h: handlerton work sql/examples/ha_tina.cc: handlerton work sql/examples/ha_tina.h: handlerton work sql/ha_archive.cc: handlerton work sql/ha_archive.h: handlerton work sql/ha_berkeley.cc: handlerton work sql/ha_berkeley.h: handlerton work sql/ha_blackhole.cc: handlerton work sql/ha_federated.cc: handlerton work sql/ha_federated.h: handlerton work sql/ha_heap.cc: handlerton work sql/ha_innodb.cc: handlerton work sql/ha_innodb.h: handlerton work sql/ha_myisam.cc: handlerton work sql/ha_myisammrg.cc: handlerton work sql/ha_ndbcluster.cc: handlerton work sql/ha_ndbcluster.h: handlerton work sql/ha_partition.cc: handlerton work sql/handler.cc: start removing storage engine specific cruft sql/handler.h: start removing storage engine specific cruft db_type for binlog handlerton handlerton flag for not-user-selectable storage engines sql/lex.h: start removing storage engine specific cruft sql/log.cc: handlerton work give binlog handlerton a 'real' db_type sql/mysql_priv.h: start removing storage engine specific cruft sql/mysqld.cc: start removing storage engine specific cruft sql/set_var.cc: start removing storage engine specific cruft sql/sp_head.cc: start removing storage engine specific cruft sql/sql_class.cc: start removing storage engine specific cruft sql/sql_class.h: start removing storage engine specific cruft sql/sql_lex.h: start removing storage engine specific cruft sql/sql_manager.cc: start removing storage engine specific cruft sql/sql_manager.h: start removing storage engine specific cruft sql/sql_parse.cc: start removing storage engine specific cruft sql/sql_partition.cc: start removing storage engine specific cruft sql/sql_prepare.cc: start removing storage engine specific cruft sql/sql_show.cc: start removing storage engine specific cruft sql/sql_table.cc: changed define from HAVE_PARTITION_DB to WITH_PARTITION_STORAGE_ENGINE start removing storage engine specific cruft sql/sql_update.cc: changed define from HAVE_PARTITION_DB to WITH_PARTITION_STORAGE_ENGINE sql/sql_yacc.yy: start removing storage engine specific cruft test if we should throw error sql/table.cc: changed define from HAVE_PARTITION_DB to WITH_PARTITION_STORAGE_ENGINE sql/table.h: changed define from HAVE_PARTITION_DB to WITH_PARTITION_STORAGE_ENGINE sql/unireg.cc: changed define from HAVE_PARTITION_DB to WITH_PARTITION_STORAGE_ENGINE storage/ndb/include/kernel/kernel_types.h: added my_config.h storage/ndb/include/ndb_global.h.in: added my_config.h storage/ndb/include/ndb_types.h.in: added my_config.h config/ac-macros/storage.m4: New BitKeeper file ``config/ac-macros/storage.m4'' sql/handlerton.cc.in: New BitKeeper file ``sql/handlerton.cc.in''
Diffstat (limited to 'sql/ha_berkeley.cc')
-rw-r--r--sql/ha_berkeley.cc77
1 files changed, 50 insertions, 27 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index fa8cda44866..eeca6cb1657 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -53,7 +53,6 @@
#include "mysql_priv.h"
-#ifdef HAVE_BERKELEY_DB
#include <m_ctype.h>
#include <myisampack.h>
#include <hash.h>
@@ -72,6 +71,9 @@
#define STATUS_ROW_COUNT_INIT 2
#define STATUS_BDB_ANALYZE 4
+const u_int32_t bdb_DB_TXN_NOSYNC= DB_TXN_NOSYNC;
+const u_int32_t bdb_DB_RECOVER= DB_RECOVER;
+const u_int32_t bdb_DB_PRIVATE= DB_PRIVATE;
const char *ha_berkeley_ext=".db";
bool berkeley_shared_data=0;
u_int32_t berkeley_init_flags= DB_PRIVATE | DB_RECOVER, berkeley_env_flags=0,
@@ -107,6 +109,7 @@ static void berkeley_noticecall(DB_ENV *db_env, db_notices notice);
static int berkeley_close_connection(THD *thd);
static int berkeley_commit(THD *thd, bool all);
static int berkeley_rollback(THD *thd, bool all);
+static handler *berkeley_create_handler(TABLE *table);
handlerton berkeley_hton = {
"BerkeleyDB",
@@ -129,9 +132,23 @@ handlerton berkeley_hton = {
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
- HTON_CLOSE_CURSORS_AT_COMMIT
+ berkeley_create_handler, /* Create a new handler */
+ NULL, /* Drop a database */
+ berkeley_end, /* Panic call */
+ NULL, /* Release temporary latches */
+ NULL, /* Update Statistics */
+ NULL, /* Start Consistent Snapshot */
+ berkeley_flush_logs, /* Flush logs */
+ berkeley_show_status, /* Show status */
+ NULL, /* Replication Report Sent Binlog */
+ HTON_CLOSE_CURSORS_AT_COMMIT | HTON_FLUSH_AFTER_RENAME
};
+handler *berkeley_create_handler(TABLE *table)
+{
+ return new ha_berkeley(table);
+}
+
typedef struct st_berkeley_trx_data {
DB_TXN *all;
DB_TXN *stmt;
@@ -215,18 +232,19 @@ error:
}
-bool berkeley_end(void)
+int berkeley_end(ha_panic_function type)
{
- int error;
+ int error= 0;
DBUG_ENTER("berkeley_end");
- if (!db_env)
- return 1; /* purecov: tested */
- berkeley_cleanup_log_files();
- error=db_env->close(db_env,0); // Error is logged
- db_env=0;
- hash_free(&bdb_open_tables);
- pthread_mutex_destroy(&bdb_mutex);
- DBUG_RETURN(error != 0);
+ if (db_env)
+ {
+ berkeley_cleanup_log_files();
+ error= db_env->close(db_env,0); // Error is logged
+ db_env= 0;
+ hash_free(&bdb_open_tables);
+ pthread_mutex_destroy(&bdb_mutex);
+ }
+ DBUG_RETURN(error);
}
static int berkeley_close_connection(THD *thd)
@@ -280,7 +298,7 @@ static int berkeley_rollback(THD *thd, bool all)
}
-int berkeley_show_logs(Protocol *protocol)
+static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
{
char **all_logs, **free_logs, **a, **f;
int error=1;
@@ -307,21 +325,19 @@ int berkeley_show_logs(Protocol *protocol)
{
for (a = all_logs, f = free_logs; *a; ++a)
{
- protocol->prepare_for_resend();
- protocol->store(*a, system_charset_info);
- protocol->store("BDB", 3, system_charset_info);
+ const char *status;
if (f && *f && strcmp(*a, *f) == 0)
{
- f++;
- protocol->store(SHOW_LOG_STATUS_FREE, system_charset_info);
+ f++;
+ status= SHOW_LOG_STATUS_FREE;
}
else
- protocol->store(SHOW_LOG_STATUS_INUSE, system_charset_info);
-
- if (protocol->write())
+ status= SHOW_LOG_STATUS_INUSE;
+
+ if (stat_print(thd, berkeley_hton.name, *a, status))
{
- error=1;
- goto err;
+ error=1;
+ goto err;
}
}
}
@@ -331,6 +347,16 @@ err:
DBUG_RETURN(error);
}
+bool berkeley_show_status(THD *thd, stat_print_fn *stat_print,
+ enum ha_stat_type stat_type)
+{
+ switch (stat_type) {
+ case HA_ENGINE_LOGS:
+ return berkeley_show_logs(thd, stat_print);
+ default:
+ return FALSE;
+ }
+}
static void berkeley_print_error(const DB_ENV *db_env, const char *db_errpfx,
const char *buffer)
@@ -344,9 +370,7 @@ static void berkeley_noticecall(DB_ENV *db_env, db_notices notice)
switch (notice)
{
case DB_NOTICE_LOGFILE_CHANGED: /* purecov: tested */
- pthread_mutex_lock(&LOCK_manager);
- manager_status |= MANAGER_BERKELEY_LOG_CLEANUP;
- pthread_mutex_unlock(&LOCK_manager);
+ mysql_manager_submit(berkeley_cleanup_log_files);
pthread_cond_signal(&COND_manager);
break;
}
@@ -2669,4 +2693,3 @@ bool ha_berkeley::check_if_incompatible_data(HA_CREATE_INFO *info,
}
-#endif /* HAVE_BERKELEY_DB */