码迷,mamicode.com
首页 > 其他好文 > 详细

class ha_innobase: public handler

时间:2015-12-12 00:00:25      阅读:500      评论:0      收藏:0      [点我收藏+]

标签:

 

/** The class defining a handle to an Innodb table */
class ha_innobase: public handler
{
    row_prebuilt_t*    prebuilt;    /*!< prebuilt struct in InnoDB, used
                    to save CPU time with prebuilt data
                    structures*/
    THD*        user_thd;    /*!< the thread handle of the user
                    currently using the handle; this is
                    set in external_lock function */
    THR_LOCK_DATA    lock;
    INNOBASE_SHARE*    share;        /*!< information for MySQL
                    table locking */

    uchar*        upd_buf;    /*!< buffer used in updates */
    ulint        upd_buf_size;    /*!< the size of upd_buf in bytes */
    uchar        srch_key_val1[MAX_KEY_LENGTH + MAX_REF_PARTS*2];
    uchar        srch_key_val2[MAX_KEY_LENGTH + MAX_REF_PARTS*2];
                    /*!< buffers used in converting
                    search key values from MySQL format
                    to InnoDB format. For each column
                    2 bytes are used to store length,
                    hence MAX_REF_PARTS*2. */
    Table_flags    int_table_flags;
    uint        primary_key;
    ulong        start_of_scan;    /*!< this is set to 1 when we are
                    starting a table scan but have not
                    yet fetched any row, else 0 */
    uint        last_match_mode;/* match mode of the latest search:
                    ROW_SEL_EXACT, ROW_SEL_EXACT_PREFIX,
                    or undefined */
    uint        num_write_row;    /*!< number of write_row() calls */

    uint store_key_val_for_row(uint keynr, char* buff, uint buff_len,
                                   const uchar* record);
    inline void update_thd(THD* thd);
    void update_thd();
    int change_active_index(uint keynr);
    int general_fetch(uchar* buf, uint direction, uint match_mode);
    ulint innobase_lock_autoinc();
    ulonglong innobase_peek_autoinc();
    ulint innobase_set_max_autoinc(ulonglong auto_inc);
    ulint innobase_reset_autoinc(ulonglong auto_inc);
    ulint innobase_get_autoinc(ulonglong* value);
    ulint innobase_update_autoinc(ulonglong    auto_inc);
    void innobase_initialize_autoinc();
    dict_index_t* innobase_get_index(uint keynr);
    int info_low(uint flag, bool called_from_analyze);

    /* Init values for the class: */
 public:
    ha_innobase(handlerton *hton, TABLE_SHARE *table_arg);
    ~ha_innobase();
    /*
      Get the row type from the storage engine.  If this method returns
      ROW_TYPE_NOT_USED, the information in HA_CREATE_INFO should be used.
    */
    enum row_type get_row_type() const;

    const char* table_type() const;
    const char* index_type(uint key_number);
    const char** bas_ext() const;
    Table_flags table_flags() const;
    ulong index_flags(uint idx, uint part, bool all_parts) const;
    uint max_supported_keys() const;
    uint max_supported_key_length() const;
    uint max_supported_key_part_length() const;
    const key_map* keys_to_use_for_scanning();

    int open(const char *name, int mode, uint test_if_locked);
    handler* clone(const char *name, MEM_ROOT *mem_root);
    int close(void);
    double scan_time();
    double read_time(uint index, uint ranges, ha_rows rows);

    int write_row(uchar * buf);
    int update_row(const uchar * old_data, uchar * new_data);
    int delete_row(const uchar * buf);
    bool was_semi_consistent_read();
    void try_semi_consistent_read(bool yes);
    void unlock_row();

    int index_init(uint index, bool sorted);
    int index_end();
    int index_read(uchar * buf, const uchar * key,
        uint key_len, enum ha_rkey_function find_flag);
    int index_read_idx(uchar * buf, uint index, const uchar * key,
               uint key_len, enum ha_rkey_function find_flag);
    int index_read_last(uchar * buf, const uchar * key, uint key_len);
    int index_next(uchar * buf);
    int index_next_same(uchar * buf, const uchar *key, uint keylen);
    int index_prev(uchar * buf);
    int index_first(uchar * buf);
    int index_last(uchar * buf);

    int rnd_init(bool scan);
    int rnd_end();
    int rnd_next(uchar *buf);
    int rnd_pos(uchar * buf, uchar *pos);

    void position(const uchar *record);
    int info(uint);
    int analyze(THD* thd,HA_CHECK_OPT* check_opt);
    int optimize(THD* thd,HA_CHECK_OPT* check_opt);
    int discard_or_import_tablespace(my_bool discard);
    int extra(enum ha_extra_function operation);
        int reset();
    int external_lock(THD *thd, int lock_type);
    int transactional_table_lock(THD *thd, int lock_type);
    int start_stmt(THD *thd, thr_lock_type lock_type);
    void position(uchar *record);
    ha_rows records_in_range(uint inx, key_range *min_key, key_range
                                *max_key);
    ha_rows estimate_rows_upper_bound();

    void update_create_info(HA_CREATE_INFO* create_info);
    int create(const char *name, register TABLE *form,
                    HA_CREATE_INFO *create_info);
    int truncate();
    int delete_table(const char *name);
    int rename_table(const char* from, const char* to);
    int check(THD* thd, HA_CHECK_OPT* check_opt);
    char* update_table_comment(const char* comment);
    char* get_foreign_key_create_info();
    int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
    int get_parent_foreign_key_list(THD *thd,
                    List<FOREIGN_KEY_INFO> *f_key_list);
    bool can_switch_engines();
    uint referenced_by_foreign_key();
    void free_foreign_key_create_info(char* str);
    THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
                    enum thr_lock_type lock_type);
    void init_table_handle_for_HANDLER();
        virtual void get_auto_increment(ulonglong offset, ulonglong increment,
                                        ulonglong nb_desired_values,
                                        ulonglong *first_value,
                                        ulonglong *nb_reserved_values);
    int reset_auto_increment(ulonglong value);

    virtual bool get_error_message(int error, String *buf);

    uint8 table_cache_type();
    /*
      ask handler about permission to cache table during query registration
    */
    my_bool register_query_cache_table(THD *thd, char *table_key,
                       uint key_length,
                       qc_engine_callback *call_back,
                       ulonglong *engine_data);
    static char *get_mysql_bin_log_name();
    static ulonglong get_mysql_bin_log_pos();
    bool primary_key_is_clustered();
    int cmp_ref(const uchar *ref1, const uchar *ref2);
    /** Fast index creation (smart ALTER TABLE) @see handler0alter.cc @{ */
    int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys,
              handler_add_index **add);
    int final_add_index(handler_add_index *add, bool commit);
    int prepare_drop_index(TABLE *table_arg, uint *key_num,
                   uint num_of_keys);
    int final_drop_index(TABLE *table_arg);
    /** @} */
    bool check_if_incompatible_data(HA_CREATE_INFO *info,
                    uint table_changes);
};

 

class ha_innobase: public handler

标签:

原文地址:http://www.cnblogs.com/taek/p/5040490.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!