diff options
author | unknown <magnus@neptunus.(none)> | 2004-04-15 09:14:14 +0200 |
---|---|---|
committer | unknown <magnus@neptunus.(none)> | 2004-04-15 09:14:14 +0200 |
commit | b43af929f871332335b0c1f2c4257aabca6b8a2f (patch) | |
tree | e8f88e89d865e1db6c1ca7d6c5fa4d85a090de4c /sql/handler.cc | |
parent | fd1d14a017fcbe86d641675c3de4788cefa8f28f (diff) | |
download | mariadb-git-b43af929f871332335b0c1f2c4257aabca6b8a2f.tar.gz |
Added NDB storage engine
include/my_base.h:
Added three new errorcodes to be returned by the handler
sql/Makefile.am:
Add new files discover.cc, ha_ndbcluster.cc and ha_ndbcluster.h
Add include path of NDB files
sql/handler.cc:
Added variable for keeping track of number of "discovers"
Added NDB to list of storage engines
Added calls to NDB for commit, rollback etc.
Added function ha_discover for discovering a table from handler
sql/handler.h:
Added NDB to list of storage engines
Added vbariable in transaction for keeping a ndb transaction handle
sql/lex.h:
Changed AND to AND_SYM and OR to OR_SYM to avoid nameclash
sql/mysql_priv.h:
Added prototypes for new functions readfrm, writefrm and create_table_from_handler
sql/mysqld.cc:
Added NDB support
Disable NDB with --skip-ndbcluster
sql/set_var.cc:
Add posibilty to show if NDB handler is supported
sql/ha_ndbcluster.cc:
Add ifdef for whole file for not compiling anything if NDB sholdn't be included
Updated timestamp handling to use new vars timestamp_default_now and timestamp_on_update_now
sql/sql_base.cc:
If frm file is not found on disk, ask handler if it knows about the table. Then retry the open.
This new functionality is called "discover" and can be used by any handler.
sql/sql_class.h:
Added variable for keeping a NDB connection handle
sql/sql_table.cc:
Before trying to create a table, ask handler if a table with that name already exists.
If user said CREATE TABLE IF NOT EXISTS, disocver the table from handler
sql/sql_yacc.yy:
Add NDBCLUSTER_SYM
Change AND to AND_SYM
Change OR to OR_SYM
sql/table.cc:
Fixe for probelm when NullS is returned from bas_ext of a handler.
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 92 |
1 files changed, 88 insertions, 4 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 2b22563bc3c..e1ee3315f40 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -37,6 +37,9 @@ #else #define innobase_query_caching_of_table_permitted(X,Y,Z) 1 #endif +#ifdef HAVE_NDBCLUSTER_DB +#include "ha_ndbcluster.h" +#endif #include <myisampack.h> #include <errno.h> @@ -48,7 +51,7 @@ ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count, ha_read_key_count, ha_read_next_count, ha_read_prev_count, ha_read_first_count, ha_read_last_count, ha_commit_count, ha_rollback_count, - ha_read_rnd_count, ha_read_rnd_next_count; + ha_read_rnd_count, ha_read_rnd_next_count, ha_discover_count; static SHOW_COMP_OPTION have_yes= SHOW_OPTION_YES; @@ -76,6 +79,10 @@ struct show_table_type_st sys_table_types[]= "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}, {NullS, NULL, NullS, DB_TYPE_UNKNOWN} }; @@ -172,6 +179,10 @@ handler *get_new_handler(TABLE *table, enum db_type db_type) case DB_TYPE_INNODB: return new ha_innobase(table); #endif +#ifdef HAVE_NDBCLUSTER_DB + case DB_TYPE_NDBCLUSTER: + return new ha_ndbcluster(table); +#endif case DB_TYPE_HEAP: return new ha_heap(table); default: // should never happen @@ -216,6 +227,18 @@ int ha_init() opt_using_transactions=1; } #endif +#ifdef HAVE_NDBCLUSTER_DB + if (have_ndbcluster == SHOW_OPTION_YES) + { + if (ndbcluster_init()) + { + have_ndbcluster= SHOW_OPTION_DISABLED; + error= 1; + } + else + opt_using_transactions=1; + } +#endif return error; } @@ -243,6 +266,10 @@ int ha_panic(enum ha_panic_function flag) if (have_innodb == SHOW_OPTION_YES) error|=innobase_end(); #endif +#ifdef HAVE_NDBCLUSTER_DB + if (have_ndbcluster == SHOW_OPTION_YES) + error|=ndbcluster_end(); +#endif return error; } /* ha_panic */ @@ -252,6 +279,10 @@ void ha_drop_database(char* path) if (have_innodb == SHOW_OPTION_YES) innobase_drop_database(path); #endif +#ifdef HAVE_NDBCLUSTER_DB + if (have_ndbcluster == SHOW_OPTION_YES) + ndbcluster_drop_database(path); +#endif } void ha_close_connection(THD* thd) @@ -260,6 +291,10 @@ void ha_close_connection(THD* thd) if (have_innodb == SHOW_OPTION_YES) innobase_close_connection(thd); #endif +#ifdef HAVE_NDBCLUSTER_DB + if (have_ndbcluster == SHOW_OPTION_YES) + ndbcluster_close_connection(thd); +#endif } /* @@ -419,6 +454,19 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans) WRITE_CACHE, (my_off_t) 0, 0, 1); thd->transaction.trans_log.end_of_file= max_binlog_cache_size; } +#ifdef HAVE_NDBCLUSTER_DB + if (trans->ndb_tid) + { + if ((error=ndbcluster_commit(thd,trans->ndb_tid))) + { + my_error(ER_ERROR_DURING_COMMIT, MYF(0), error); + error=1; + } + if (trans == &thd->transaction.all) + operation_done= transaction_commited= 1; + trans->ndb_tid=0; + } +#endif #ifdef HAVE_BERKELEY_DB if (trans->bdb_tid) { @@ -472,6 +520,18 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans) if (opt_using_transactions) { bool operation_done=0; +#ifdef HAVE_NDBCLUSTER_DB + if (trans->ndb_tid) + { + if ((error=ndbcluster_rollback(thd, trans->ndb_tid))) + { + my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), error); + error=1; + } + trans->ndb_tid = 0; + operation_done=1; + } +#endif #ifdef HAVE_BERKELEY_DB if (trans->bdb_tid) { @@ -1151,8 +1211,10 @@ bool handler::caching_allowed(THD* thd, char* table_key, ** Some general functions that isn't in the handler class ****************************************************************************/ - /* Initiates table-file and calls apropriate database-creator */ - /* Returns 1 if something got wrong */ +/* + Initiates table-file and calls apropriate database-creator + Returns 1 if something got wrong +*/ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, bool update_create_info) @@ -1168,7 +1230,7 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, { update_create_info_from_table(create_info, &table); if (table.file->table_flags() & HA_DROP_BEFORE_CREATE) - table.file->delete_table(name); // Needed for BDB tables + table.file->delete_table(name); } if (lower_case_table_names == 2 && !(table.file->table_flags() & HA_FILE_BASED)) @@ -1290,6 +1352,26 @@ int ha_change_key_cache(KEY_CACHE *old_key_cache, /* + Try to discover one table from handler(s) +*/ + +int ha_discover(const char* dbname, const char* name, + const void** frmblob, uint* frmlen) +{ + int error= 1; // Table does not exist in any handler + DBUG_ENTER("ha_discover"); + DBUG_PRINT("enter", ("db: %s, name: %s", dbname, name)); +#ifdef HAVE_NDBCLUSTER_DB + if (have_ndbcluster == SHOW_OPTION_YES) + error= ndbcluster_discover(dbname, name, frmblob, frmlen); +#endif + if (!error) + statistic_increment(ha_discover_count,&LOCK_status); + DBUG_RETURN(error); +} + + +/* Read first row between two ranges. Store ranges for future calls to read_range_next @@ -1425,3 +1507,5 @@ int handler::compare_key(key_range *range) } return key_compare_result_on_equal; } + + |