diff options
Diffstat (limited to 'sql/handler.h')
-rw-r--r-- | sql/handler.h | 69 |
1 files changed, 48 insertions, 21 deletions
diff --git a/sql/handler.h b/sql/handler.h index 7b49ff1ffd4..53e8997acbe 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1,8 +1,8 @@ #ifndef HANDLER_INCLUDED #define HANDLER_INCLUDED /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. - Copyright (c) 2009, 2013, Monty Program Ab. + Copyright (c) 2000, 2014, Oracle and/or its affiliates. + Copyright (c) 2009, 2014, Monty Program Ab. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -1026,6 +1026,13 @@ struct handlerton to the savepoint_set call */ int (*savepoint_rollback)(handlerton *hton, THD *thd, void *sv); + /** + Check if storage engine allows to release metadata locks which were + acquired after the savepoint if rollback to savepoint is done. + @return true - If it is safe to release MDL locks. + false - If it is not. + */ + bool (*savepoint_rollback_can_release_mdl)(handlerton *hton, THD *thd); int (*savepoint_release)(handlerton *hton, THD *thd, void *sv); /* 'all' is true if it's a real commit, that makes persistent changes @@ -1678,8 +1685,7 @@ public: All these operations are supported as in-place operations by the SQL layer. This means that operations that by their nature must be performed by copying the table to a temporary table, will not - have their own flags here (e.g. ALTER TABLE FORCE, ALTER TABLE - ENGINE). + have their own flags here. We generally try to specify handler flags only if there are real changes. But in cases when it is cumbersome to determine if some @@ -1783,8 +1789,17 @@ public: // Partition operation with ALL keyword static const HA_ALTER_FLAGS ALTER_ALL_PARTITION = 1L << 28; + /** + Recreate the table for ALTER TABLE FORCE, ALTER TABLE ENGINE + and OPTIMIZE TABLE operations. + */ + static const HA_ALTER_FLAGS RECREATE_TABLE = 1L << 29; + // Virtual columns changed - static const HA_ALTER_FLAGS ALTER_COLUMN_VCOL = 1L << 29; + static const HA_ALTER_FLAGS ALTER_COLUMN_VCOL = 1L << 30; + + // ALTER TABLE for a partitioned table + static const HA_ALTER_FLAGS ALTER_PARTITIONED = 1L << 31; /** Create options (like MAX_ROWS) for the new version of table. @@ -1857,6 +1872,18 @@ public: inplace_alter_handler_ctx *handler_ctx; /** + If the table uses several handlers, like ha_partition uses one handler + per partition, this contains a Null terminated array of ctx pointers + that should all be committed together. + Or NULL if only handler_ctx should be committed. + Set to NULL if the low level handler::commit_inplace_alter_table uses it, + to signal to the main handler that everything was committed as atomically. + + @see inplace_alter_handler_ctx for information about object lifecycle. + */ + inplace_alter_handler_ctx **group_commit_ctx; + + /** Flags describing in detail which operations the storage engine is to execute. */ HA_ALTER_FLAGS handler_flags; @@ -1904,6 +1931,7 @@ public: index_add_count(0), index_add_buffer(NULL), handler_ctx(NULL), + group_commit_ctx(NULL), handler_flags(0), modified_part_info(modified_part_info_arg), ignore(ignore_arg), @@ -2451,7 +2479,6 @@ public: FT_INFO *ft_handler; enum {NONE=0, INDEX, RND} inited; bool implicit_emptied; /* Can be !=0 only if HEAP */ - bool mark_trx_done; const COND *pushed_cond; /** next_insert_id is the next value which should be inserted into the @@ -2532,7 +2559,7 @@ public: in_range_check_pushed_down(FALSE), ref_length(sizeof(my_off_t)), ft_handler(0), inited(NONE), - implicit_emptied(0), mark_trx_done(FALSE), + implicit_emptied(0), pushed_cond(0), next_insert_id(0), insert_id_for_cur_row(0), pushed_idx_cond(NULL), pushed_idx_cond_keyno(MAX_KEY), @@ -2613,13 +2640,6 @@ public: } int ha_rnd_init_with_error(bool scan) __attribute__ ((warn_unused_result)); int ha_reset(); - /* Tell handler (not storage engine) this is start of a new statement */ - void ha_start_of_new_statement() - { - ft_handler= 0; - mark_trx_done= FALSE; - } - /* this is necessary in many places, e.g. in HANDLER command */ int ha_index_or_rnd_end() { @@ -3623,6 +3643,10 @@ protected: @note In case of partitioning, this function might be called for rollback without prepare_inplace_alter_table() having been called first. + Also partitioned tables sets ha_alter_info->group_commit_ctx to a NULL + terminated array of the partitions handlers and if all of them are + committed as one, then group_commit_ctx should be set to NULL to indicate + to the partitioning handler that all partitions handlers are committed. @see prepare_inplace_alter_table(). @param altered_table TABLE object for new version of table. @@ -3637,7 +3661,11 @@ protected: virtual bool commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit) - { return false; } +{ + /* Nothing to commit/rollback, mark all handlers committed! */ + ha_alter_info->group_commit_ctx= NULL; + return false; +} /** @@ -3710,12 +3738,8 @@ protected: private: /* Private helpers */ - void mark_trx_read_write_part2(); - inline void mark_trx_read_write() - { - if (!mark_trx_done) - mark_trx_read_write_part2(); - } + inline void mark_trx_read_write(); +private: inline void increment_statistics(ulong SSV::*offset) const; inline void decrement_statistics(ulong SSV::*offset) const; @@ -3921,6 +3945,8 @@ public: inline int ha_write_tmp_row(uchar *buf); inline int ha_update_tmp_row(const uchar * old_data, uchar * new_data); + virtual void set_lock_type(enum thr_lock_type lock); + friend enum icp_result handler_index_cond_check(void* h_arg); protected: Handler_share *get_ha_share_ptr(); @@ -4057,6 +4083,7 @@ int ha_enable_transaction(THD *thd, bool on); /* savepoints */ int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv); +bool ha_rollback_to_savepoint_can_release_mdl(THD *thd); int ha_savepoint(THD *thd, SAVEPOINT *sv); int ha_release_savepoint(THD *thd, SAVEPOINT *sv); #ifdef WITH_WSREP |