mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Merge
BitKeeper/etc/ignore: auto-union BUILD/autorun.sh: Auto merged BitKeeper/deleted/.del-bdb.vcproj~ed8534936e40cefb: Auto merged BitKeeper/deleted/.del-heap.vcproj~70c0cc1d680a51c1: Auto merged BitKeeper/deleted/.del-innobase.vcproj~71e1de81f11138bf: Auto merged BitKeeper/deleted/.del-myisam.vcproj~32bb9e4a163fcb5a: Auto merged BitKeeper/deleted/.del-myisammrg.vcproj~6534e59acbfbb63: Auto merged BitKeeper/deleted/.del-mysqld.vcproj~703886a28862bb2: Auto merged Makefile.am: Auto merged client/mysqltest.c: Auto merged include/my_global.h: Auto merged include/mysql_com.h: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/r/ndb_alter_table.result: Auto merged mysql-test/r/ps_6bdb.result: Auto merged mysql-test/r/ps_7ndb.result: Auto merged mysql-test/t/query_cache.test: Auto merged mysys/default.c: Auto merged scripts/make_win_src_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged sql/Makefile.am: Auto merged sql/field.cc: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_berkeley.h: Auto merged sql/ha_federated.cc: Auto merged sql/ha_heap.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.cc: Auto merged sql/ha_myisammrg.cc: Auto merged sql/ha_ndbcluster.h: Auto merged sql/handler.cc: Auto merged sql/item.cc: Auto merged sql/item_subselect.cc: Auto merged sql/log.cc: Auto merged sql/mysql_priv.h: Auto merged sql/opt_sum.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.cc: Auto merged sql/sp.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.h: Auto merged sql/unireg.cc: Auto merged storage/innobase/buf/buf0buf.c: Auto merged storage/innobase/buf/buf0flu.c: Auto merged storage/innobase/data/data0data.c: Auto merged storage/innobase/dict/dict0dict.c: Auto merged storage/innobase/include/btr0btr.h: Auto merged storage/innobase/include/data0type.ic: Auto merged storage/innobase/include/dict0dict.h: Auto merged storage/innobase/include/dict0mem.h: Auto merged storage/innobase/include/mem0mem.h: Auto merged storage/innobase/include/mem0mem.ic: Auto merged storage/innobase/include/os0file.h: Auto merged storage/innobase/include/row0mysql.h: Auto merged storage/innobase/include/trx0trx.h: Auto merged storage/innobase/include/ut0mem.h: Auto merged storage/innobase/mem/mem0mem.c: Auto merged storage/innobase/os/os0file.c: Auto merged storage/innobase/os/os0proc.c: Auto merged storage/innobase/rem/rem0rec.c: Auto merged storage/innobase/row/row0ins.c: Auto merged storage/innobase/row/row0mysql.c: Auto merged storage/innobase/srv/srv0start.c: Auto merged storage/innobase/trx/trx0sys.c: Auto merged storage/innobase/trx/trx0trx.c: Auto merged storage/innobase/ut/ut0mem.c: Auto merged storage/myisam/ft_boolean_search.c: Auto merged storage/myisam/mi_check.c: Auto merged storage/myisam/mi_dbug.c: Auto merged storage/myisam/mi_delete.c: Auto merged storage/myisam/mi_delete_all.c: Auto merged storage/myisam/mi_key.c: Auto merged storage/myisam/mi_open.c: Auto merged storage/myisam/mi_rkey.c: Auto merged storage/myisam/mi_search.c: Auto merged storage/myisam/mi_test1.c: Auto merged storage/myisam/mi_update.c: Auto merged storage/myisam/mi_write.c: Auto merged storage/myisam/myisamchk.c: Auto merged storage/myisam/myisamdef.h: Auto merged storage/myisam/myisampack.c: Auto merged storage/myisam/sp_key.c: Auto merged storage/myisammrg/myrg_rkey.c: Auto merged storage/ndb/include/kernel/GlobalSignalNumbers.h: Auto merged storage/ndb/include/kernel/signaldata/ApiVersion.hpp: Auto merged storage/ndb/include/kernel/signaldata/EventReport.hpp: Auto merged storage/ndb/include/kernel/signaldata/StopReq.hpp: Auto merged storage/ndb/include/mgmapi/ndb_logevent.h: Auto merged storage/ndb/include/ndbapi/NdbBlob.hpp: Auto merged storage/ndb/include/ndbapi/NdbIndexOperation.hpp: Auto merged storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp: Auto merged storage/ndb/include/ndbapi/NdbOperation.hpp: Auto merged storage/ndb/include/ndbapi/NdbRecAttr.hpp: Auto merged storage/ndb/include/ndbapi/NdbTransaction.hpp: Auto merged storage/ndb/src/common/util/SimpleProperties.cpp: Auto merged storage/ndb/src/kernel/blocks/backup/Backup.cpp: Auto merged storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Auto merged storage/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupTrigger.cpp: Auto merged storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Auto merged storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Auto merged storage/ndb/src/mgmapi/ndb_logevent.cpp: Auto merged storage/ndb/src/mgmclient/CommandInterpreter.cpp: Auto merged storage/ndb/src/mgmsrv/Config.cpp: Auto merged storage/ndb/src/mgmsrv/Config.hpp: Auto merged storage/ndb/src/mgmsrv/ConfigInfo.cpp: Auto merged storage/ndb/src/mgmsrv/InitConfigFileParser.cpp: Auto merged storage/ndb/src/mgmsrv/InitConfigFileParser.hpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.hpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvrGeneralSignalHandling.cpp: Auto merged storage/ndb/src/mgmsrv/Services.cpp: Auto merged storage/ndb/src/mgmsrv/Services.hpp: Auto merged storage/ndb/src/mgmsrv/main.cpp: Auto merged storage/ndb/src/ndbapi/NdbApiSignal.cpp: Auto merged storage/ndb/src/ndbapi/NdbApiSignal.hpp: Auto merged storage/ndb/src/ndbapi/NdbBlob.cpp: Auto merged storage/ndb/src/ndbapi/NdbImpl.hpp: Auto merged storage/ndb/src/ndbapi/NdbRecAttr.cpp: Auto merged storage/ndb/src/ndbapi/NdbUtil.cpp: Auto merged storage/ndb/src/ndbapi/NdbUtil.hpp: Auto merged storage/ndb/src/ndbapi/Ndbif.cpp: Auto merged storage/ndb/src/ndbapi/Ndblist.cpp: Auto merged storage/ndb/src/ndbapi/ObjectMap.hpp: Auto merged storage/ndb/test/include/NDBT_Test.hpp: Auto merged storage/ndb/test/ndbapi/bank/BankLoad.cpp: Auto merged storage/ndb/test/ndbapi/testOIBasic.cpp: Auto merged storage/ndb/test/src/HugoCalculator.cpp: Auto merged storage/ndb/test/src/NDBT_Test.cpp: Auto merged storage/ndb/test/src/NdbBackup.cpp: Auto merged storage/ndb/test/src/NdbRestarts.cpp: Auto merged storage/ndb/tools/ndb_condig.cpp: Auto merged storage/ndb/tools/restore/Restore.cpp: Auto merged storage/ndb/tools/restore/consumer_restore.cpp: Auto merged support-files/mysql.spec.sh: Auto merged configure.in: merge BUILD/SETUP.sh: merge BitKeeper/deleted/.del-mysql.sln~f2120278f8a437be: SCCS merged libmysqld/Makefile.am: merge sql/ha_ndbcluster.cc: merge sql/handler.h: merge sql/mysqld.cc: merge sql/opt_range.cc: merge sql/slave.cc: merge sql/slave.h: e merge sql/sql_parse.cc: merge sql/table.cc: merge sql/examples/ha_tina.cc: merge sql/examples/ha_tina.h: merge sql/share/errmsg.txt: merge storage/ndb/include/ndbapi/Ndb.hpp: merge storage/ndb/src/common/debugger/EventLogger.cpp: merge storage/ndb/src/kernel/blocks/dbdict/Makefile.am: merge storage/ndb/src/mgmsrv/MgmtSrvr.cpp: merge storage/ndb/src/ndbapi/Ndbinit.cpp: SCCS merged
This commit is contained in:
353
sql/handler.cc
353
sql/handler.cc
@@ -25,43 +25,111 @@
|
||||
#include "ha_heap.h"
|
||||
#include "ha_myisam.h"
|
||||
#include "ha_myisammrg.h"
|
||||
|
||||
|
||||
/*
|
||||
We have dummy hanldertons in case the handler has not been compiled
|
||||
in. This will be removed in 5.1.
|
||||
*/
|
||||
#ifdef HAVE_BERKELEY_DB
|
||||
#include "ha_berkeley.h"
|
||||
extern handlerton berkeley_hton;
|
||||
#else
|
||||
handlerton berkeley_hton = { "BerkeleyDB", SHOW_OPTION_NO,
|
||||
"Supports transactions and page-level locking", DB_TYPE_BERKELEY_DB, NULL,
|
||||
0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, HTON_NO_FLAGS };
|
||||
#endif
|
||||
#ifdef HAVE_BLACKHOLE_DB
|
||||
#include "ha_blackhole.h"
|
||||
extern handlerton blackhole_hton;
|
||||
#else
|
||||
handlerton blackhole_hton = { "BLACKHOLE", SHOW_OPTION_NO,
|
||||
"/dev/null storage engine (anything you write to it disappears)",
|
||||
DB_TYPE_BLACKHOLE_DB, NULL, 0, 0, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
HTON_NO_FLAGS };
|
||||
#endif
|
||||
#ifdef HAVE_EXAMPLE_DB
|
||||
#include "examples/ha_example.h"
|
||||
extern handlerton example_hton;
|
||||
#else
|
||||
handlerton example_hton = { "EXAMPLE", SHOW_OPTION_NO,
|
||||
"Example storage engine",
|
||||
DB_TYPE_EXAMPLE_DB, NULL, 0, 0, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
HTON_NO_FLAGS };
|
||||
#endif
|
||||
#ifdef HAVE_PARTITION_DB
|
||||
#include "ha_partition.h"
|
||||
#endif
|
||||
#ifdef HAVE_ARCHIVE_DB
|
||||
#include "examples/ha_archive.h"
|
||||
#include "ha_archive.h"
|
||||
extern handlerton archive_hton;
|
||||
#else
|
||||
handlerton archive_hton = { "ARCHIVE", SHOW_OPTION_NO,
|
||||
"Archive storage engine", DB_TYPE_ARCHIVE_DB, NULL, 0, 0, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
HTON_NO_FLAGS };
|
||||
#endif
|
||||
#ifdef HAVE_CSV_DB
|
||||
#include "examples/ha_tina.h"
|
||||
extern handlerton tina_hton;
|
||||
#else
|
||||
handlerton tina_hton = { "CSV", SHOW_OPTION_NO, "CSV storage engine",
|
||||
DB_TYPE_CSV_DB, NULL, 0, 0, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
HTON_NO_FLAGS };
|
||||
#endif
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
#include "ha_innodb.h"
|
||||
extern handlerton innobase_hton;
|
||||
#else
|
||||
handlerton innobase_hton = { "InnoDB", SHOW_OPTION_NO,
|
||||
"Supports transactions, row-level locking, and foreign keys",
|
||||
DB_TYPE_INNODB, NULL, 0, 0, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
HTON_NO_FLAGS };
|
||||
#endif
|
||||
#ifdef HAVE_NDBCLUSTER_DB
|
||||
#include "ha_ndbcluster.h"
|
||||
extern handlerton ndbcluster_hton;
|
||||
#else
|
||||
handlerton ndbcluster_hton = { "ndbcluster", SHOW_OPTION_NO,
|
||||
"Clustered, fault-tolerant, memory-based tables",
|
||||
DB_TYPE_NDBCLUSTER, NULL, 0, 0, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
HTON_NO_FLAGS };
|
||||
#endif
|
||||
#ifdef HAVE_FEDERATED_DB
|
||||
#include "ha_federated.h"
|
||||
extern handlerton federated_hton;
|
||||
#else
|
||||
handlerton federated_hton = { "FEDERATED", SHOW_OPTION_NO,
|
||||
"Federated MySQL storage engine", DB_TYPE_FEDERATED_DB, NULL, 0, 0, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
HTON_NO_FLAGS };
|
||||
#endif
|
||||
#include <myisampack.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* static functions defined in this file */
|
||||
extern handlerton myisam_hton;
|
||||
extern handlerton myisammrg_hton;
|
||||
extern handlerton heap_hton;
|
||||
extern handlerton binlog_hton;
|
||||
|
||||
/*
|
||||
Obsolete
|
||||
*/
|
||||
handlerton isam_hton = { "ISAM", SHOW_OPTION_NO, "Obsolete storage engine",
|
||||
DB_TYPE_ISAM, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, HTON_NO_FLAGS };
|
||||
|
||||
|
||||
/* static functions defined in this file */
|
||||
|
||||
static SHOW_COMP_OPTION have_yes= SHOW_OPTION_YES;
|
||||
|
||||
/* list of all available storage engines (of their handlertons) */
|
||||
handlerton *handlertons[MAX_HA]={0};
|
||||
|
||||
/* number of entries in handlertons[] */
|
||||
ulong total_ha;
|
||||
/* number of storage engines (from handlertons[]) that support 2pc */
|
||||
@@ -69,46 +137,35 @@ ulong total_ha_2pc;
|
||||
/* size of savepoint storage area (see ha_init) */
|
||||
ulong savepoint_alloc_size;
|
||||
|
||||
struct show_table_type_st sys_table_types[]=
|
||||
/*
|
||||
This array is used for processing compiled in engines.
|
||||
*/
|
||||
handlerton *sys_table_types[]=
|
||||
{
|
||||
{"MyISAM", &have_yes,
|
||||
"Default engine as of MySQL 3.23 with great performance", DB_TYPE_MYISAM},
|
||||
{"MEMORY", &have_yes,
|
||||
"Hash based, stored in memory, useful for temporary tables", DB_TYPE_HEAP},
|
||||
{"HEAP", &have_yes,
|
||||
"Alias for MEMORY", DB_TYPE_HEAP},
|
||||
{"MERGE", &have_yes,
|
||||
"Collection of identical MyISAM tables", DB_TYPE_MRG_MYISAM},
|
||||
{"MRG_MYISAM",&have_yes,
|
||||
"Alias for MERGE", DB_TYPE_MRG_MYISAM},
|
||||
{"ISAM", &have_isam,
|
||||
"Obsolete storage engine, now replaced by MyISAM", DB_TYPE_ISAM},
|
||||
{"MRG_ISAM", &have_isam,
|
||||
"Obsolete storage engine, now replaced by MERGE", DB_TYPE_MRG_ISAM},
|
||||
{"InnoDB", &have_innodb,
|
||||
"Supports transactions, row-level locking, and foreign keys", DB_TYPE_INNODB},
|
||||
{"INNOBASE", &have_innodb,
|
||||
"Alias for INNODB", DB_TYPE_INNODB},
|
||||
{"BDB", &have_berkeley_db,
|
||||
"Supports transactions and page-level locking", DB_TYPE_BERKELEY_DB},
|
||||
{"BERKELEYDB",&have_berkeley_db,
|
||||
"Alias for BDB", DB_TYPE_BERKELEY_DB},
|
||||
{"NDBCLUSTER", &have_ndbcluster,
|
||||
"Clustered, fault-tolerant, memory-based tables", DB_TYPE_NDBCLUSTER},
|
||||
{"NDB", &have_ndbcluster,
|
||||
"Alias for NDBCLUSTER", DB_TYPE_NDBCLUSTER},
|
||||
{"EXAMPLE",&have_example_db,
|
||||
"Example storage engine", DB_TYPE_EXAMPLE_DB},
|
||||
{"ARCHIVE",&have_archive_db,
|
||||
"Archive storage engine", DB_TYPE_ARCHIVE_DB},
|
||||
{"CSV",&have_csv_db,
|
||||
"CSV storage engine", DB_TYPE_CSV_DB},
|
||||
{"FEDERATED",&have_federated_db,
|
||||
"Federated MySQL storage engine", DB_TYPE_FEDERATED_DB},
|
||||
{"BLACKHOLE",&have_blackhole_db,
|
||||
"/dev/null storage engine (anything you write to it disappears)",
|
||||
DB_TYPE_BLACKHOLE_DB},
|
||||
{NullS, NULL, NullS, DB_TYPE_UNKNOWN}
|
||||
&myisam_hton,
|
||||
&heap_hton,
|
||||
&innobase_hton,
|
||||
&berkeley_hton,
|
||||
&blackhole_hton,
|
||||
&example_hton,
|
||||
&archive_hton,
|
||||
&tina_hton,
|
||||
&ndbcluster_hton,
|
||||
&federated_hton,
|
||||
&myisammrg_hton,
|
||||
&binlog_hton,
|
||||
&isam_hton,
|
||||
NULL
|
||||
};
|
||||
|
||||
struct show_table_alias_st sys_table_aliases[]=
|
||||
{
|
||||
{"INNOBASE", "InnoDB"},
|
||||
{"NDB", "NDBCLUSTER"},
|
||||
{"BDB", "BERKELEYDB"},
|
||||
{"HEAP", "MEMORY"},
|
||||
{"MERGE", "MRG_MYISAM"},
|
||||
{NullS, NullS}
|
||||
};
|
||||
|
||||
const char *ha_row_type[] = {
|
||||
@@ -127,46 +184,78 @@ uint known_extensions_id= 0;
|
||||
enum db_type ha_resolve_by_name(const char *name, uint namelen)
|
||||
{
|
||||
THD *thd= current_thd;
|
||||
if (thd && !my_strcasecmp(&my_charset_latin1, name, "DEFAULT")) {
|
||||
show_table_alias_st *table_alias;
|
||||
handlerton **types;
|
||||
const char *ptr= name;
|
||||
|
||||
if (thd && !my_strcasecmp(&my_charset_latin1, ptr, "DEFAULT"))
|
||||
return (enum db_type) thd->variables.table_type;
|
||||
|
||||
retest:
|
||||
for (types= sys_table_types; *types; types++)
|
||||
{
|
||||
if (!my_strcasecmp(&my_charset_latin1, ptr, (*types)->name))
|
||||
return (enum db_type) (*types)->db_type;
|
||||
}
|
||||
|
||||
show_table_type_st *types;
|
||||
for (types= sys_table_types; types->type; types++)
|
||||
/*
|
||||
We check for the historical aliases.
|
||||
*/
|
||||
for (table_alias= sys_table_aliases; table_alias->type; table_alias++)
|
||||
{
|
||||
if (!my_strcasecmp(&my_charset_latin1, name, types->type))
|
||||
return (enum db_type) types->db_type;
|
||||
if (!my_strcasecmp(&my_charset_latin1, ptr, table_alias->alias))
|
||||
{
|
||||
ptr= table_alias->type;
|
||||
goto retest;
|
||||
}
|
||||
}
|
||||
|
||||
return DB_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
const char *ha_get_storage_engine(enum db_type db_type)
|
||||
{
|
||||
show_table_type_st *types;
|
||||
for (types= sys_table_types; types->type; types++)
|
||||
handlerton **types;
|
||||
for (types= sys_table_types; *types; types++)
|
||||
{
|
||||
if (db_type == types->db_type)
|
||||
return types->type;
|
||||
if (db_type == (*types)->db_type)
|
||||
return (*types)->name;
|
||||
}
|
||||
|
||||
return "none";
|
||||
}
|
||||
|
||||
bool ha_check_storage_engine_flag(enum db_type db_type, uint32 flag)
|
||||
{
|
||||
handlerton **types;
|
||||
for (types= sys_table_types; *types; types++)
|
||||
{
|
||||
if (db_type == (*types)->db_type)
|
||||
{
|
||||
if ((*types)->flags & flag)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
my_bool ha_storage_engine_is_enabled(enum db_type database_type)
|
||||
{
|
||||
show_table_type_st *types;
|
||||
for (types= sys_table_types; types->type; types++)
|
||||
handlerton **types;
|
||||
for (types= sys_table_types; *types; types++)
|
||||
{
|
||||
if ((database_type == types->db_type) &&
|
||||
(*types->value == SHOW_OPTION_YES))
|
||||
if ((database_type == (*types)->db_type) &&
|
||||
((*types)->state == SHOW_OPTION_YES))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* Use other database handler if databasehandler is not incompiled */
|
||||
/* Use other database handler if databasehandler is not compiled in */
|
||||
|
||||
enum db_type ha_checktype(THD *thd, enum db_type database_type,
|
||||
bool no_substitute, bool report_error)
|
||||
@@ -372,8 +461,8 @@ static int ha_init_errors(void)
|
||||
SETMSG(HA_ERR_READ_ONLY_TRANSACTION, ER(ER_READ_ONLY_TRANSACTION));
|
||||
SETMSG(HA_ERR_LOCK_DEADLOCK, ER(ER_LOCK_DEADLOCK));
|
||||
SETMSG(HA_ERR_CANNOT_ADD_FOREIGN, ER(ER_CANNOT_ADD_FOREIGN));
|
||||
SETMSG(HA_ERR_NO_REFERENCED_ROW, ER(ER_NO_REFERENCED_ROW));
|
||||
SETMSG(HA_ERR_ROW_IS_REFERENCED, ER(ER_ROW_IS_REFERENCED));
|
||||
SETMSG(HA_ERR_NO_REFERENCED_ROW, ER(ER_NO_REFERENCED_ROW_2));
|
||||
SETMSG(HA_ERR_ROW_IS_REFERENCED, ER(ER_ROW_IS_REFERENCED_2));
|
||||
SETMSG(HA_ERR_NO_SAVEPOINT, "No savepoint with that name");
|
||||
SETMSG(HA_ERR_NON_UNIQUE_BLOCK_SIZE, "Non unique key block size");
|
||||
SETMSG(HA_ERR_NO_SUCH_TABLE, "No such table: '%.64s'");
|
||||
@@ -422,81 +511,24 @@ static inline void ha_was_inited_ok(handlerton **ht)
|
||||
int ha_init()
|
||||
{
|
||||
int error= 0;
|
||||
handlerton **ht= handlertons;
|
||||
handlerton **types;
|
||||
show_table_alias_st *table_alias;
|
||||
total_ha= savepoint_alloc_size= 0;
|
||||
|
||||
if (ha_init_errors())
|
||||
return 1;
|
||||
|
||||
if (opt_bin_log)
|
||||
/*
|
||||
We now initialize everything here.
|
||||
*/
|
||||
for (types= sys_table_types; *types; types++)
|
||||
{
|
||||
if (!(*ht= binlog_init())) // Always succeed
|
||||
{
|
||||
mysql_bin_log.close(LOG_CLOSE_INDEX); // Never used
|
||||
opt_bin_log= 0; // Never used
|
||||
error= 1; // Never used
|
||||
}
|
||||
if (!(*types)->init || !(*types)->init())
|
||||
ha_was_inited_ok(types);
|
||||
else
|
||||
ha_was_inited_ok(ht++);
|
||||
(*types)->state= SHOW_OPTION_DISABLED;
|
||||
}
|
||||
#ifdef HAVE_BERKELEY_DB
|
||||
if (have_berkeley_db == SHOW_OPTION_YES)
|
||||
{
|
||||
if (!(*ht= berkeley_init()))
|
||||
{
|
||||
have_berkeley_db= SHOW_OPTION_DISABLED; // If we couldn't use handler
|
||||
error= 1;
|
||||
}
|
||||
else
|
||||
ha_was_inited_ok(ht++);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
if (have_innodb == SHOW_OPTION_YES)
|
||||
{
|
||||
if (!(*ht= innobase_init()))
|
||||
{
|
||||
have_innodb= SHOW_OPTION_DISABLED; // If we couldn't use handler
|
||||
error= 1;
|
||||
}
|
||||
else
|
||||
ha_was_inited_ok(ht++);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_NDBCLUSTER_DB
|
||||
if (have_ndbcluster == SHOW_OPTION_YES)
|
||||
{
|
||||
if (!(*ht= ndbcluster_init()))
|
||||
{
|
||||
have_ndbcluster= SHOW_OPTION_DISABLED;
|
||||
error= 1;
|
||||
}
|
||||
else
|
||||
ha_was_inited_ok(ht++);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_FEDERATED_DB
|
||||
if (have_federated_db == SHOW_OPTION_YES)
|
||||
{
|
||||
if (federated_db_init())
|
||||
{
|
||||
have_federated_db= SHOW_OPTION_DISABLED;
|
||||
error= 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_ARCHIVE_DB
|
||||
if (have_archive_db == SHOW_OPTION_YES)
|
||||
{
|
||||
if (!(*ht= archive_db_init()))
|
||||
{
|
||||
have_archive_db= SHOW_OPTION_DISABLED;
|
||||
error= 1;
|
||||
}
|
||||
else
|
||||
ha_was_inited_ok(ht++);
|
||||
}
|
||||
#endif
|
||||
|
||||
DBUG_ASSERT(total_ha < MAX_HA);
|
||||
/*
|
||||
Check if there is a transaction-capable storage engine besides the
|
||||
@@ -543,6 +575,10 @@ int ha_panic(enum ha_panic_function flag)
|
||||
#ifdef HAVE_ARCHIVE_DB
|
||||
if (have_archive_db == SHOW_OPTION_YES)
|
||||
error|= archive_db_end();
|
||||
#endif
|
||||
#ifdef HAVE_CSV_DB
|
||||
if (have_csv_db == SHOW_OPTION_YES)
|
||||
error|= tina_end();
|
||||
#endif
|
||||
if (ha_finish_errors())
|
||||
error= 1;
|
||||
@@ -564,9 +600,10 @@ void ha_drop_database(char* path)
|
||||
/* don't bother to rollback here, it's done already */
|
||||
void ha_close_connection(THD* thd)
|
||||
{
|
||||
for (uint i=0; i < total_ha; i++)
|
||||
if (thd->ha_data[i])
|
||||
(*handlertons[i]->close_connection)(thd);
|
||||
handlerton **types;
|
||||
for (types= sys_table_types; *types; types++)
|
||||
if (thd->ha_data[(*types)->slot])
|
||||
(*types)->close_connection(thd);
|
||||
}
|
||||
|
||||
/* ========================================================================
|
||||
@@ -877,13 +914,13 @@ int ha_autocommit_or_rollback(THD *thd, int error)
|
||||
|
||||
int ha_commit_or_rollback_by_xid(XID *xid, bool commit)
|
||||
{
|
||||
handlerton **ht= handlertons, **end_ht=ht+total_ha;
|
||||
handlerton **types;
|
||||
int res= 1;
|
||||
|
||||
for ( ; ht < end_ht ; ht++)
|
||||
if ((*ht)->recover)
|
||||
for (types= sys_table_types; *types; types++)
|
||||
if ((*types)->state == SHOW_OPTION_YES && (*types)->recover)
|
||||
res= res &&
|
||||
(*(commit ? (*ht)->commit_by_xid : (*ht)->rollback_by_xid))(xid);
|
||||
(*(commit ? (*types)->commit_by_xid : (*types)->rollback_by_xid))(xid);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -962,7 +999,7 @@ static char* xid_to_str(char *buf, XID *xid)
|
||||
int ha_recover(HASH *commit_list)
|
||||
{
|
||||
int len, got, found_foreign_xids=0, found_my_xids=0;
|
||||
handlerton **ht= handlertons, **end_ht=ht+total_ha;
|
||||
handlerton **types;
|
||||
XID *list=0;
|
||||
bool dry_run=(commit_list==0 && tc_heuristic_recover==0);
|
||||
DBUG_ENTER("ha_recover");
|
||||
@@ -998,14 +1035,14 @@ int ha_recover(HASH *commit_list)
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
for ( ; ht < end_ht ; ht++)
|
||||
for (types= sys_table_types; *types; types++)
|
||||
{
|
||||
if (!(*ht)->recover)
|
||||
if ((*types)->state != SHOW_OPTION_YES || !(*types)->recover)
|
||||
continue;
|
||||
while ((got=(*(*ht)->recover)(list, len)) > 0 )
|
||||
while ((got=(*(*types)->recover)(list, len)) > 0 )
|
||||
{
|
||||
sql_print_information("Found %d prepared transaction(s) in %s",
|
||||
got, (*ht)->name);
|
||||
got, (*types)->name);
|
||||
for (int i=0; i < got; i ++)
|
||||
{
|
||||
my_xid x=list[i].get_my_xid();
|
||||
@@ -1033,7 +1070,7 @@ int ha_recover(HASH *commit_list)
|
||||
char buf[XIDDATASIZE*4+6]; // see xid_to_str
|
||||
sql_print_information("commit xid %s", xid_to_str(buf, list+i));
|
||||
#endif
|
||||
(*(*ht)->commit_by_xid)(list+i);
|
||||
(*(*types)->commit_by_xid)(list+i);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1041,7 +1078,7 @@ int ha_recover(HASH *commit_list)
|
||||
char buf[XIDDATASIZE*4+6]; // see xid_to_str
|
||||
sql_print_information("rollback xid %s", xid_to_str(buf, list+i));
|
||||
#endif
|
||||
(*(*ht)->rollback_by_xid)(list+i);
|
||||
(*(*types)->rollback_by_xid)(list+i);
|
||||
}
|
||||
}
|
||||
if (got < len)
|
||||
@@ -1401,11 +1438,9 @@ int handler::ha_open(const char *name, int mode, int test_if_locked)
|
||||
table->db_stat|=HA_READ_ONLY;
|
||||
(void) extra(HA_EXTRA_NO_READCHECK); // Not needed in SQL
|
||||
|
||||
if (!alloc_root_inited(&table->mem_root)) // If temporary table
|
||||
ref=(byte*) sql_alloc(ALIGN_SIZE(ref_length)*2);
|
||||
else
|
||||
ref=(byte*) alloc_root(&table->mem_root, ALIGN_SIZE(ref_length)*2);
|
||||
if (!ref)
|
||||
DBUG_ASSERT(alloc_root_inited(&table->mem_root));
|
||||
|
||||
if (!(ref= (byte*) alloc_root(&table->mem_root, ALIGN_SIZE(ref_length)*2)))
|
||||
{
|
||||
close();
|
||||
error=HA_ERR_OUT_OF_MEM;
|
||||
@@ -1870,11 +1905,19 @@ void handler::print_error(int error, myf errflag)
|
||||
textno=ER_CANNOT_ADD_FOREIGN;
|
||||
break;
|
||||
case HA_ERR_ROW_IS_REFERENCED:
|
||||
textno=ER_ROW_IS_REFERENCED;
|
||||
break;
|
||||
{
|
||||
String str;
|
||||
get_error_message(error, &str);
|
||||
my_error(ER_ROW_IS_REFERENCED_2, MYF(0), str.c_ptr_safe());
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
case HA_ERR_NO_REFERENCED_ROW:
|
||||
textno=ER_NO_REFERENCED_ROW;
|
||||
break;
|
||||
{
|
||||
String str;
|
||||
get_error_message(error, &str);
|
||||
my_error(ER_NO_REFERENCED_ROW_2, MYF(0), str.c_ptr_safe());
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
case HA_ERR_TABLE_DEF_CHANGED:
|
||||
textno=ER_TABLE_DEF_CHANGED;
|
||||
break;
|
||||
@@ -2585,7 +2628,7 @@ TYPELIB *ha_known_exts(void)
|
||||
{
|
||||
if (!known_extensions.type_names || mysys_usage_id != known_extensions_id)
|
||||
{
|
||||
show_table_type_st *types;
|
||||
handlerton **types;
|
||||
List<char> found_exts;
|
||||
List_iterator_fast<char> it(found_exts);
|
||||
const char **ext, *old_ext;
|
||||
@@ -2593,11 +2636,11 @@ 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);
|
||||
for (types= sys_table_types; types->type; types++)
|
||||
for (types= sys_table_types; *types; types++)
|
||||
{
|
||||
if (*types->value == SHOW_OPTION_YES)
|
||||
if ((*types)->state == SHOW_OPTION_YES)
|
||||
{
|
||||
handler *file= get_new_handler(0,(enum db_type) types->db_type);
|
||||
handler *file= get_new_handler(0,(enum db_type) (*types)->db_type);
|
||||
for (ext= file->bas_ext(); *ext; ext++)
|
||||
{
|
||||
while ((old_ext= it++))
|
||||
|
||||
Reference in New Issue
Block a user