ha_innobase.h
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:6k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2.    && Innobase Oy
  3.    -This file is modified from ha_berkeley.h of MySQL distribution-
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2 of the License, or
  7.    (at your option) any later version.
  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.
  12.    You should have received a copy of the GNU General Public License
  13.    along with this program; if not, write to the Free Software
  14.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  15. #ifdef __GNUC__
  16. #pragma interface /* gcc class implementation */
  17. #endif
  18. /* This file defines the Innobase handler: the interface between MySQL and
  19. Innobase */
  20. typedef struct st_innobase_share {
  21.   THR_LOCK lock;
  22.   pthread_mutex_t mutex;
  23.   char *table_name;
  24.   uint table_name_length,use_count;
  25. } INNOBASE_SHARE;
  26. /* The class defining a handle to an Innobase table */
  27. class ha_innobase: public handler
  28. {
  29. void* innobase_prebuilt; /* (row_prebuilt_t*) prebuilt
  30. struct in Innobase, used to save
  31. CPU */
  32. THD* user_thd; /* the thread handle of the user
  33. currently using the handle; this is
  34. set in external_lock function */
  35.    THR_LOCK_DATA  lock;
  36. INNOBASE_SHARE  *share;
  37.    gptr  alloc_ptr;
  38.    byte* upd_buff; /* buffer used in updates */
  39.    byte* key_val_buff; /* buffer used in converting
  40.    search key values from MySQL format
  41.    to Innobase format */
  42. uint ref_stored_len; /* length of the key value stored to
  43. 'ref' buffer of the handle, if any */
  44.    ulong  int_option_flag;
  45.    uint  primary_key;
  46. uint last_dup_key;
  47. ulong start_of_scan; /* this is set to 1 when we are
  48. starting a table scan but have not
  49. yet fetched any row, else 0 */
  50. uint last_match_mode;/* match mode of the latest search:
  51. ROW_SEL_EXACT, ROW_SEL_EXACT_PREFIX,
  52. or undefined */
  53. ulong max_row_length(const byte *buf);
  54. uint store_key_val_for_row(uint keynr, char* buff, const byte* record);
  55. int update_thd(THD* thd);
  56. int change_active_index(uint keynr);
  57. int general_fetch(byte* buf, uint direction, uint match_mode);
  58. /* Init values for the class: */
  59.  public:
  60.    ha_innobase(TABLE *table): handler(table),
  61.   int_option_flag(HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER |
  62.   HA_REC_NOT_IN_SEQ |
  63.   HA_KEYPOS_TO_RNDPOS | HA_LASTKEY_ORDER |
  64.   HA_HAVE_KEY_READ_ONLY | HA_READ_NOT_EXACT_KEY |
  65.   HA_LONGLONG_KEYS | HA_NULL_KEY |
  66.   HA_NOT_EXACT_COUNT |
  67.   HA_NO_WRITE_DELAYED |
  68.   HA_PRIMARY_KEY_IN_READ_INDEX |
  69.   HA_DROP_BEFORE_CREATE |
  70.   HA_NOT_READ_AFTER_KEY),
  71.   last_dup_key((uint) -1),
  72.   start_of_scan(0)
  73.    {
  74.    }
  75.    ~ha_innobase() {}
  76.    const char* table_type() const { return("Innobase");}
  77.    const char** bas_ext() const;
  78.   ulong option_flag() const { return int_option_flag; }
  79.    uint max_record_length() const { return HA_MAX_REC_LENGTH; }
  80.    uint max_keys()          const { return MAX_KEY; }
  81.    uint max_key_parts()     const { return MAX_REF_PARTS; }
  82.    uint max_key_length()    const { return MAX_KEY_LENGTH; }
  83.    bool fast_key_read()  { return 1;}
  84.    bool has_transactions()  { return 1;}
  85.    int open(const char *name, int mode, uint test_if_locked);
  86.    void initialize(void);
  87.    int close(void);
  88.    double scan_time();
  89.    int write_row(byte * buf);
  90.    int update_row(const byte * old_data, byte * new_data);
  91.    int delete_row(const byte * buf);
  92.    int index_init(uint index);
  93.    int index_end();
  94.    int index_read(byte * buf, const byte * key,
  95.   uint key_len, enum ha_rkey_function find_flag);
  96.    int index_read_idx(byte * buf, uint index, const byte * key,
  97.       uint key_len, enum ha_rkey_function find_flag);
  98.    int index_next(byte * buf);
  99.    int index_next_same(byte * buf, const byte *key, uint keylen);
  100.    int index_prev(byte * buf);
  101.    int index_first(byte * buf);
  102.    int index_last(byte * buf);
  103.    int rnd_init(bool scan=1);
  104.    int rnd_end();
  105.    int rnd_next(byte *buf);
  106.    int rnd_pos(byte * buf, byte *pos);
  107.    void position(const byte *record);
  108.    void info(uint);
  109.    int extra(enum ha_extra_function operation);
  110.    int reset(void);
  111.    int external_lock(THD *thd, int lock_type);
  112.    void position(byte *record);
  113.    ha_rows records_in_range(int inx,
  114.    const byte *start_key,uint start_key_len,
  115.    enum ha_rkey_function start_search_flag,
  116.    const byte *end_key,uint end_key_len,
  117.    enum ha_rkey_function end_search_flag);
  118.    int create(const char *name, register TABLE *form,
  119. HA_CREATE_INFO *create_info);
  120.    int delete_table(const char *name);
  121. int rename_table(const char* from, const char* to);
  122.         char* update_table_comment(const char* comment);
  123.    THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
  124.       enum thr_lock_type lock_type);
  125. };
  126. extern bool innobase_skip;
  127. extern uint innobase_init_flags, innobase_lock_type;
  128. extern ulong innobase_cache_size;
  129. extern char *innobase_home, *innobase_tmpdir, *innobase_logdir;
  130. extern long innobase_lock_scan_time;
  131. extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
  132. extern long innobase_log_file_size, innobase_log_buffer_size;
  133. extern long innobase_buffer_pool_size, innobase_additional_mem_pool_size;
  134. extern long innobase_file_io_threads, innobase_lock_wait_timeout;
  135. extern char *innobase_data_home_dir, *innobase_data_file_path;
  136. extern char *innobase_log_group_home_dir, *innobase_log_arch_dir;
  137. extern bool innobase_flush_log_at_trx_commit, innobase_log_archive,
  138. innobase_use_native_aio;
  139. extern TYPELIB innobase_lock_typelib;
  140. bool innobase_init(void);
  141. bool innobase_end(void);
  142. bool innobase_flush_logs(void);
  143. uint innobase_get_free_space(void);
  144. int innobase_commit(THD *thd, void* trx_handle);
  145. int innobase_rollback(THD *thd, void* trx_handle);
  146. int innobase_close_connection(THD *thd);