80
80
#include "drizzled/field/varstring.h"
81
81
#include "drizzled/field/timestamp.h"
82
82
#include "drizzled/plugin/xa_storage_engine.h"
83
#include "drizzled/plugin/daemon.h"
83
84
#include "drizzled/memory/multi_malloc.h"
84
85
#include "drizzled/pthread_globals.h"
85
86
#include "drizzled/named_savepoint.h"
260
261
class InnobaseEngine : public plugin::XaStorageEngine
263
InnobaseEngine(string name_arg) :
264
explicit InnobaseEngine(string name_arg) :
264
265
plugin::XaStorageEngine(name_arg,
266
HTON_CAN_INDEX_BLOBS |
267
HTON_PRIMARY_KEY_REQUIRED_FOR_POSITION |
268
HTON_PRIMARY_KEY_IN_READ_INDEX |
269
HTON_PARTIAL_COLUMN_READ |
270
HTON_TABLE_SCAN_ON_INDEX |
271
HTON_HAS_DOES_TRANSACTIONS)
267
HTON_CAN_INDEX_BLOBS |
268
HTON_PRIMARY_KEY_REQUIRED_FOR_POSITION |
269
HTON_PRIMARY_KEY_IN_READ_INDEX |
270
HTON_PARTIAL_COLUMN_READ |
271
HTON_TABLE_SCAN_ON_INDEX |
272
HTON_HAS_FOREIGN_KEYS |
273
HTON_HAS_DOES_TRANSACTIONS)
273
275
table_definition_ext= plugin::DEFAULT_DEFINITION_FILE_EXT;
274
276
addAlias("INNOBASE");
279
virtual ~InnobaseEngine()
284
srv_fast_shutdown = (ulint) innobase_fast_shutdown;
286
hash_table_free(innobase_open_tables);
287
innobase_open_tables = NULL;
288
if (innobase_shutdown_for_mysql() != DB_SUCCESS) {
291
srv_free_paths_and_sizes();
292
if (internal_innobase_data_file_path)
293
free(internal_innobase_data_file_path);
294
pthread_mutex_destroy(&innobase_share_mutex);
295
pthread_mutex_destroy(&prepare_commit_mutex);
296
pthread_mutex_destroy(&commit_threads_m);
297
pthread_mutex_destroy(&commit_cond_m);
298
pthread_cond_destroy(&commit_cond);
277
303
virtual int doStartTransaction(Session *session, start_transaction_option_t options);
278
304
virtual void doStartStatement(Session *session);
397
423
drizzled::TableIdentifier &identifier,
398
424
message::Table&);
399
UNIV_INTERN int doRenameTable(Session* session,
425
UNIV_INTERN int doRenameTable(Session&, TableIdentifier &from, TableIdentifier &to);
402
426
UNIV_INTERN int doDropTable(Session& session, TableIdentifier &identifier);
404
428
UNIV_INTERN virtual bool get_error_message(int error, String *buf);
511
535
NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0);
514
/***********************************************************************
515
Closes an InnoDB database. */
518
innobase_deinit(plugin::Registry ®istry);
520
538
/*****************************************************************//**
521
539
Commits a transaction in an InnoDB database. */
1962
1979
status_table_function_ptr= new InnodbStatusTool;
1964
registry.add(innodb_engine_ptr);
1981
context.add(innodb_engine_ptr);
1966
registry.add(status_table_function_ptr);
1983
context.add(status_table_function_ptr);
1968
1985
cmp_tool= new(std::nothrow)CmpTool(false);
1969
registry.add(cmp_tool);
1986
context.add(cmp_tool);
1971
1988
cmp_reset_tool= new(std::nothrow)CmpTool(true);
1972
registry.add(cmp_reset_tool);
1989
context.add(cmp_reset_tool);
1974
1991
cmp_mem_tool= new(std::nothrow)CmpmemTool(false);
1975
registry.add(cmp_mem_tool);
1992
context.add(cmp_mem_tool);
1977
1994
cmp_mem_reset_tool= new(std::nothrow)CmpmemTool(true);
1978
registry.add(cmp_mem_reset_tool);
1995
context.add(cmp_mem_reset_tool);
1980
1997
innodb_trx_tool= new(std::nothrow)InnodbTrxTool("INNODB_TRX");
1981
registry.add(innodb_trx_tool);
1998
context.add(innodb_trx_tool);
1983
2000
innodb_locks_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCKS");
1984
registry.add(innodb_locks_tool);
2001
context.add(innodb_locks_tool);
1986
2003
innodb_lock_waits_tool= new(std::nothrow)InnodbTrxTool("INNODB_LOCK_WAITS");
1987
registry.add(innodb_lock_waits_tool);
2004
context.add(innodb_lock_waits_tool);
1989
2006
/* Get the current high water mark format. */
1990
2007
innobase_file_format_check = (char*) trx_sys_file_format_max_get();
1997
/*******************************************************************//**
1998
Closes an InnoDB database.
1999
@return TRUE if error */
2002
innobase_deinit(plugin::Registry ®istry)
2006
registry.remove(status_table_function_ptr);
2007
delete status_table_function_ptr;
2009
registry.remove(cmp_tool);
2012
registry.remove(cmp_reset_tool);
2013
delete cmp_reset_tool;
2015
registry.remove(cmp_mem_tool);
2016
delete cmp_mem_tool;
2018
registry.remove(cmp_mem_reset_tool);
2019
delete cmp_mem_reset_tool;
2021
registry.remove(innodb_trx_tool);
2022
delete innodb_trx_tool;
2024
registry.remove(innodb_locks_tool);
2025
delete innodb_locks_tool;
2027
registry.remove(innodb_lock_waits_tool);
2028
delete innodb_lock_waits_tool;
2030
registry.remove(innodb_engine_ptr);
2031
delete innodb_engine_ptr;
2033
if (innodb_inited) {
2035
srv_fast_shutdown = (ulint) innobase_fast_shutdown;
2037
hash_table_free(innobase_open_tables);
2038
innobase_open_tables = NULL;
2039
if (innobase_shutdown_for_mysql() != DB_SUCCESS) {
2042
srv_free_paths_and_sizes();
2043
if (internal_innobase_data_file_path)
2044
free(internal_innobase_data_file_path);
2045
pthread_mutex_destroy(&innobase_share_mutex);
2046
pthread_mutex_destroy(&prepare_commit_mutex);
2047
pthread_mutex_destroy(&commit_threads_m);
2048
pthread_mutex_destroy(&commit_cond_m);
2049
pthread_cond_destroy(&commit_cond);
2055
2015
/****************************************************************//**
2056
2016
Flushes InnoDB logs to disk and makes a checkpoint. Really, a commit flushes
6081
6041
/*********************************************************************//**
6082
6042
Renames an InnoDB table.
6083
6043
@return 0 or error code */
6086
InnobaseEngine::doRenameTable(
6087
/*======================*/
6089
const char* from, /*!< in: old name of the table */
6090
const char* to) /*!< in: new name of the table */
6044
UNIV_INTERN int InnobaseEngine::doRenameTable(Session &session, TableIdentifier &from, TableIdentifier &to)
6096
6050
/* Get the transaction associated with the current session, or create one
6097
6051
if not yet created */
6099
parent_trx = check_trx_exists(session);
6053
parent_trx = check_trx_exists(&session);
6101
6055
/* In case MySQL calls this in the middle of a SELECT query, release
6102
6056
possible adaptive hash latch to avoid deadlocks of threads */
6104
6058
trx_search_latch_release_if_reserved(parent_trx);
6106
trx = innobase_trx_allocate(session);
6060
trx = innobase_trx_allocate(&session);
6108
error = innobase_rename_table(trx, from, to, TRUE);
6062
error = innobase_rename_table(trx, from.getPath().c_str(), to.getPath().c_str(), TRUE);
6110
6064
/* Tell the InnoDB server that there might be work for
6111
6065
utility threads: */
8839
8793
"Supports transactions, row-level locking, and foreign keys",
8840
8794
PLUGIN_LICENSE_GPL,
8841
8795
innobase_init, /* Plugin Init */
8842
innobase_deinit, /* Plugin Deinit */
8843
8796
innobase_system_variables, /* system variables */
8844
8797
NULL /* reserved */