diff options
author | unknown <kostja@bodhi.(none)> | 2007-12-20 21:16:55 +0300 |
---|---|---|
committer | unknown <kostja@bodhi.(none)> | 2007-12-20 21:16:55 +0300 |
commit | 0fbc29c197d931fdcf99c071e3ac1e31bf8761ee (patch) | |
tree | f154da404267333803f8dc058a8c8d0bc0fea5d6 /sql/handler.cc | |
parent | 5473858b644f2b3c7b6aed186a4f39917af7248e (diff) | |
download | mariadb-git-0fbc29c197d931fdcf99c071e3ac1e31bf8761ee.tar.gz |
A pre-requisite for the fix for Bug#12713 "Error in a stored function
called from a SELECT doesn't cause ROLLBACK of state"
Make private all class handler methods (PSEA API) that may modify
data. Introduce and deploy public ha_* wrappers for these methods in
all sql/.
This necessary to keep track of all data modifications in sql/,
which is in turn necessary to be able to optimize two-phase
commit of those transactions that do not modify data.
sql/ha_partition.cc:
Class ha_partition is no longer a friend of class handler.
Use the public handler interface (handler::ha_ methods) for partition
operations.
Remove unnecessary casts from char[] to const char *.ppзи выафвыаafa
sql/handler.cc:
Function ha_create_table() is no longer a friend of class handler.
Use public handler::change_table_ptr() to access private members.
This fixes a subtle bug (no test case in the test suite) when a
deletion error occurs inside one partition of a partitioned engine.
The old code would crash in handler::print_error() in this case.
Implement the newly introduced public ha_* wrappers of the private
virtual handler methods.
sql/handler.h:
Introduce ha_* wrappers to all class handler methods that may
modify data. This is necessary to be able to keep track of
data modifying operations of class handler and optimize read-only
transactions.
sql/item_sum.cc:
delete_all_rows -> ha_delete_all_rows
sql/sql_base.cc:
Use the new public wrappers.
sql/sql_delete.cc:
delete_all_rows -> ha_delete_all_rows
sql/sql_partition.cc:
Use the new public wrappers.
sql/sql_select.cc:
delete_all_rows -> ha_delete_all_rows
delete_table -> ha_delete_table
disabe_indexes -> ha_disable_idnexes
sql/sql_show.cc:
delete_all_rows -> ha_delete_all_rows
sql/sql_table.cc:
Use the public wrappers for class handler DDL methods.
All methods which may change handler data are now accessed via a public
wrapper.
sql/sql_union.cc:
delete_all_rows -> ha_delete_all_rows
{enable,disable}_indexes -> ha_{enable,disable}_indexes
sql/sql_update.cc:
bulk_update_row -> ha_bulk_update_row
sql/unireg.cc:
create_handler_files -> ha_create_handler_files
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 337 |
1 files changed, 332 insertions, 5 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index a4926071598..1448678a35c 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1468,7 +1468,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, DBUG_RETURN(ENOENT); path= check_lowercase_names(file, path, tmp_path); - if ((error= file->delete_table(path)) && generate_warning) + if ((error= file->ha_delete_table(path)) && generate_warning) { /* Because file->print_error() use my_error() to generate the error message @@ -1487,8 +1487,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, dummy_share.table_name.length= strlen(alias); dummy_table.alias= alias; - file->table_share= &dummy_share; - file->table= &dummy_table; + file->change_table_ptr(&dummy_table, &dummy_share); thd->push_internal_handler(&ha_delete_table_error_handler); file->print_error(error, 0); @@ -2502,6 +2501,12 @@ int handler::ha_check(THD *thd, HA_CHECK_OPT *check_opt) } +/** + Repair table: public interface. + + @sa handler::repair() +*/ + int handler::ha_repair(THD* thd, HA_CHECK_OPT* check_opt) { int result; @@ -2511,6 +2516,328 @@ int handler::ha_repair(THD* thd, HA_CHECK_OPT* check_opt) } +/** + Bulk update row: public interface. + + @sa handler::bulk_update_row() +*/ + +int +handler::ha_bulk_update_row(const uchar *old_data, uchar *new_data, + uint *dup_key_found) +{ + return bulk_update_row(old_data, new_data, dup_key_found); +} + + +/** + Delete all rows: public interface. + + @sa handler::delete_all_rows() +*/ + +int +handler::ha_delete_all_rows() +{ + return delete_all_rows(); +} + + +/** + Reset auto increment: public interface. + + @sa handler::reset_auto_increment() +*/ + +int +handler::ha_reset_auto_increment(ulonglong value) +{ + return reset_auto_increment(value); +} + + +/** + Backup table: public interface. + + @sa handler::backup() +*/ + +int +handler::ha_backup(THD* thd, HA_CHECK_OPT* check_opt) +{ + return backup(thd, check_opt); +} + + +/** + Restore table: public interface. + + @sa handler::restore() +*/ + +int +handler::ha_restore(THD* thd, HA_CHECK_OPT* check_opt) +{ + return restore(thd, check_opt); +} + + +/** + Optimize table: public interface. + + @sa handler::optimize() +*/ + +int +handler::ha_optimize(THD* thd, HA_CHECK_OPT* check_opt) +{ + return optimize(thd, check_opt); +} + + +/** + Analyze table: public interface. + + @sa handler::analyze() +*/ + +int +handler::ha_analyze(THD* thd, HA_CHECK_OPT* check_opt) +{ + return analyze(thd, check_opt); +} + + +/** + Check and repair table: public interface. + + @sa handler::check_and_repair() +*/ + +bool +handler::ha_check_and_repair(THD *thd) +{ + return check_and_repair(thd); +} + + +/** + Disable indexes: public interface. + + @sa handler::disable_indexes() +*/ + +int +handler::ha_disable_indexes(uint mode) +{ + return disable_indexes(mode); +} + + +/** + Enable indexes: public interface. + + @sa handler::enable_indexes() +*/ + +int +handler::ha_enable_indexes(uint mode) +{ + return enable_indexes(mode); +} + + +/** + Discard or import tablespace: public interface. + + @sa handler::discard_or_import_tablespace() +*/ + +int +handler::ha_discard_or_import_tablespace(my_bool discard) +{ + return discard_or_import_tablespace(discard); +} + + +/** + Prepare for alter: public interface. + + Called to prepare an *online* ALTER. + + @sa handler::prepare_for_alter() +*/ + +void +handler::ha_prepare_for_alter() +{ + prepare_for_alter(); +} + + +/** + Rename table: public interface. + + @sa handler::rename_table() +*/ + +int +handler::ha_rename_table(const char *from, const char *to) +{ + return rename_table(from, to); +} + + +/** + Delete table: public interface. + + @sa handler::delete_table() +*/ + +int +handler::ha_delete_table(const char *name) +{ + return delete_table(name); +} + + +/** + Drop table in the engine: public interface. + + @sa handler::drop_table() +*/ + +void +handler::ha_drop_table(const char *name) +{ + return drop_table(name); +} + + +/** + Create a table in the engine: public interface. + + @sa handler::create() +*/ + +int +handler::ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info) +{ + return create(name, form, info); +} + + +/** + Create handler files for CREATE TABLE: public interface. + + @sa handler::create_handler_files() +*/ + +int +handler::ha_create_handler_files(const char *name, const char *old_name, + int action_flag, HA_CREATE_INFO *info) +{ + return create_handler_files(name, old_name, action_flag, info); +} + + +/** + Change partitions: public interface. + + @sa handler::change_partitions() +*/ + +int +handler::ha_change_partitions(HA_CREATE_INFO *create_info, + const char *path, + ulonglong *copied, + ulonglong *deleted, + const uchar *pack_frm_data, + size_t pack_frm_len) +{ + return change_partitions(create_info, path, copied, deleted, + pack_frm_data, pack_frm_len); +} + + +/** + Drop partitions: public interface. + + @sa handler::drop_partitions() +*/ + +int +handler::ha_drop_partitions(const char *path) +{ + return drop_partitions(path); +} + + +/** + Rename partitions: public interface. + + @sa handler::rename_partitions() +*/ + +int +handler::ha_rename_partitions(const char *path) +{ + return rename_partitions(path); +} + + +/** + Optimize partitions: public interface. + + @sa handler::optimize_partitions() +*/ + +int +handler::ha_optimize_partitions(THD *thd) +{ + return optimize_partitions(thd); +} + + +/** + Analyze partitions: public interface. + + @sa handler::analyze_partitions() +*/ + +int +handler::ha_analyze_partitions(THD *thd) +{ + return analyze_partitions(thd); +} + + +/** + Check partitions: public interface. + + @sa handler::check_partitions() +*/ + +int +handler::ha_check_partitions(THD *thd) +{ + return check_partitions(thd); +} + + +/** + Repair partitions: public interface. + + @sa handler::repair_partitions() +*/ + +int +handler::ha_repair_partitions(THD *thd) +{ + return repair_partitions(thd); +} + + /** @brief Tell the storage engine that it is allowed to "disable transaction" in the handler. It is a hint that ACID is not required - it is used in NDB for @@ -2654,7 +2981,7 @@ int ha_create_table(THD *thd, const char *path, name= check_lowercase_names(table.file, share.path.str, name_buff); - error= table.file->create(name, &table, create_info); + error= table.file->ha_create(name, &table, create_info); VOID(closefrm(&table, 0)); if (error) { @@ -2724,7 +3051,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name) create_info.table_options|= HA_OPTION_CREATE_FROM_ENGINE; check_lowercase_names(table.file, path, path); - error=table.file->create(path,&table,&create_info); + error=table.file->ha_create(path, &table, &create_info); VOID(closefrm(&table, 1)); DBUG_RETURN(error != 0); |