diff options
Diffstat (limited to 'sql/ha_partition.h')
-rw-r--r-- | sql/ha_partition.h | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/sql/ha_partition.h b/sql/ha_partition.h index efd0707252e..c2bdd23a256 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -36,6 +36,16 @@ enum partition_keywords HA_DUPLICATE_POS | \ HA_CAN_SQL_HANDLER | \ HA_CAN_INSERT_DELAYED) + +/* First 4 bytes in the .par file is the number of 32-bit words in the file */ +#define PAR_WORD_SIZE 4 +/* offset to the .par file checksum */ +#define PAR_CHECKSUM_OFFSET 4 +/* offset to the total number of partitions */ +#define PAR_NUM_PARTS_OFFSET 8 +/* offset to the engines array */ +#define PAR_ENGINES_OFFSET 12 + class ha_partition :public handler { private: @@ -51,7 +61,7 @@ private: /* Data for the partition handler */ int m_mode; // Open mode uint m_open_test_lock; // Open test_if_locked - char *m_file_buffer; // Buffer with names + char *m_file_buffer; // Content of the .par file char *m_name_buffer_ptr; // Pointer to first partition name plugin_ref *m_engine_array; // Array of types of the handlers handler **m_file; // Array of references to handler inst. @@ -113,6 +123,13 @@ private: bool m_is_sub_partitioned; // Is subpartitioned bool m_ordered_scan_ongoing; + /* + If set, this object was created with ha_partition::clone and doesn't + "own" the m_part_info structure. + */ + ha_partition *m_is_clone_of; + MEM_ROOT *m_clone_mem_root; + /* We keep track if all underlying handlers are MyISAM since MyISAM has a great number of extra flags not needed by other handlers. @@ -146,11 +163,6 @@ private: */ THR_LOCK_DATA lock; /* MySQL lock */ - /* - TRUE <=> this object was created with ha_partition::clone and doesn't - "own" the m_part_info structure. - */ - bool is_clone; bool auto_increment_lock; /**< lock reading/updating auto_inc */ /** Flag to keep the auto_increment lock through out the statement. @@ -163,7 +175,7 @@ private: /** used for prediction of start_bulk_insert rows */ enum_monotonicity_info m_part_func_monotonicity_info; public: - handler *clone(MEM_ROOT *mem_root); + handler *clone(const char *name, MEM_ROOT *mem_root); virtual void set_part_info(partition_info *part_info) { m_part_info= part_info; @@ -182,6 +194,10 @@ public: */ ha_partition(handlerton *hton, TABLE_SHARE * table); ha_partition(handlerton *hton, partition_info * part_info); + ha_partition(handlerton *hton, TABLE_SHARE *share,
+ partition_info *part_info_arg,
+ ha_partition *clone_arg,
+ MEM_ROOT *clone_mem_root_arg); ~ha_partition(); /* A partition handler has no characteristics in itself. It only inherits @@ -253,7 +269,10 @@ private: And one method to read it in. */ bool create_handler_file(const char *name); - bool get_from_handler_file(const char *name, MEM_ROOT *mem_root); + bool setup_engine_array(MEM_ROOT *mem_root); + bool read_par_file(const char *name); + bool get_from_handler_file(const char *name, MEM_ROOT *mem_root, + bool is_clone); bool new_handlers_from_part_info(MEM_ROOT *mem_root); bool create_handlers(MEM_ROOT *mem_root); void clear_handler_file(); @@ -345,6 +364,7 @@ public: virtual int update_row(const uchar * old_data, uchar * new_data); virtual int delete_row(const uchar * buf); virtual int delete_all_rows(void); + virtual int truncate(); virtual void start_bulk_insert(ha_rows rows); virtual int end_bulk_insert(); private: @@ -353,6 +373,15 @@ private: long estimate_read_buffer_size(long original_size); public: + /* + Method for truncating a specific partition. + (i.e. ALTER TABLE t1 TRUNCATE PARTITION p). + + @remark This method is a partitioning-specific hook + and thus not a member of the general SE API. + */ + int truncate_partition(Alter_info *, bool *binlog_stmt); + virtual bool is_fatal_error(int error, uint flags) { if (!handler::is_fatal_error(error, flags) || @@ -1023,7 +1052,9 @@ public: They are used for on-line/fast alter table add/drop index: ------------------------------------------------------------------------- */ - virtual int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys); + virtual int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys, + handler_add_index **add); + virtual int final_add_index(handler_add_index *add, bool commit); virtual int prepare_drop_index(TABLE *table_arg, uint *key_num, uint num_of_keys); virtual int final_drop_index(TABLE *table_arg); |