The world's most popular open source database
00001 /* Copyright (C) 2000,2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 00018 #ifdef USE_PRAGMA_INTERFACE 00019 #pragma interface /* gcc class implementation */ 00020 #endif 00021 00022 /* class for the the myisam handler */ 00023 00024 #include <myisam.h> 00025 #include <ft_global.h> 00026 00027 #define HA_RECOVER_NONE 0 /* No automatic recover */ 00028 #define HA_RECOVER_DEFAULT 1 /* Automatic recover active */ 00029 #define HA_RECOVER_BACKUP 2 /* Make a backupfile on recover */ 00030 #define HA_RECOVER_FORCE 4 /* Recover even if we loose rows */ 00031 #define HA_RECOVER_QUICK 8 /* Don't check rows in data file */ 00032 00033 extern ulong myisam_sort_buffer_size; 00034 extern TYPELIB myisam_recover_typelib; 00035 extern ulong myisam_recover_options; 00036 00037 class ha_myisam: public handler 00038 { 00039 MI_INFO *file; 00040 ulong int_table_flags; 00041 char *data_file_name, *index_file_name; 00042 bool can_enable_indexes; 00043 int repair(THD *thd, MI_CHECK ¶m, bool optimize); 00044 00045 public: 00046 ha_myisam(TABLE_SHARE *table_arg); 00047 ~ha_myisam() {} 00048 const char *table_type() const { return "MyISAM"; } 00049 const char *index_type(uint key_number); 00050 const char **bas_ext() const; 00051 ulonglong table_flags() const { return int_table_flags; } 00052 ulong index_flags(uint inx, uint part, bool all_parts) const 00053 { 00054 return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ? 00055 0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE | 00056 HA_READ_ORDER | HA_KEYREAD_ONLY); 00057 } 00058 uint max_supported_keys() const { return MI_MAX_KEY; } 00059 uint max_supported_key_length() const { return MI_MAX_KEY_LENGTH; } 00060 uint max_supported_key_part_length() const { return MI_MAX_KEY_LENGTH; } 00061 uint checksum() const; 00062 00063 virtual bool check_if_locking_is_allowed(uint sql_command, 00064 ulong type, TABLE *table, 00065 uint count, 00066 bool called_by_logger_thread); 00067 int open(const char *name, int mode, uint test_if_locked); 00068 int close(void); 00069 int write_row(byte * buf); 00070 int update_row(const byte * old_data, byte * new_data); 00071 int delete_row(const byte * buf); 00072 int index_read(byte * buf, const byte * key, 00073 uint key_len, enum ha_rkey_function find_flag); 00074 int index_read_idx(byte * buf, uint idx, const byte * key, 00075 uint key_len, enum ha_rkey_function find_flag); 00076 int index_read_last(byte * buf, const byte * key, uint key_len); 00077 int index_next(byte * buf); 00078 int index_prev(byte * buf); 00079 int index_first(byte * buf); 00080 int index_last(byte * buf); 00081 int index_next_same(byte *buf, const byte *key, uint keylen); 00082 int ft_init() 00083 { 00084 if (!ft_handler) 00085 return 1; 00086 ft_handler->please->reinit_search(ft_handler); 00087 return 0; 00088 } 00089 FT_INFO *ft_init_ext(uint flags, uint inx,String *key) 00090 { 00091 return ft_init_search(flags,file,inx, 00092 (byte *)key->ptr(), key->length(), key->charset(), 00093 table->record[0]); 00094 } 00095 int ft_read(byte *buf); 00096 int rnd_init(bool scan); 00097 int rnd_next(byte *buf); 00098 int rnd_pos(byte * buf, byte *pos); 00099 int restart_rnd_next(byte *buf, byte *pos); 00100 void position(const byte *record); 00101 void info(uint); 00102 int extra(enum ha_extra_function operation); 00103 int extra_opt(enum ha_extra_function operation, ulong cache_size); 00104 int reset(void); 00105 int external_lock(THD *thd, int lock_type); 00106 int delete_all_rows(void); 00107 int disable_indexes(uint mode); 00108 int enable_indexes(uint mode); 00109 int indexes_are_disabled(void); 00110 void start_bulk_insert(ha_rows rows); 00111 int end_bulk_insert(); 00112 ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); 00113 void update_create_info(HA_CREATE_INFO *create_info); 00114 int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); 00115 THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, 00116 enum thr_lock_type lock_type); 00117 virtual void get_auto_increment(ulonglong offset, ulonglong increment, 00118 ulonglong nb_desired_values, 00119 ulonglong *first_value, 00120 ulonglong *nb_reserved_values); 00121 int rename_table(const char * from, const char * to); 00122 int delete_table(const char *name); 00123 int check(THD* thd, HA_CHECK_OPT* check_opt); 00124 int analyze(THD* thd,HA_CHECK_OPT* check_opt); 00125 int repair(THD* thd, HA_CHECK_OPT* check_opt); 00126 bool check_and_repair(THD *thd); 00127 bool is_crashed() const; 00128 bool auto_repair() const { return myisam_recover_options != 0; } 00129 int optimize(THD* thd, HA_CHECK_OPT* check_opt); 00130 int restore(THD* thd, HA_CHECK_OPT* check_opt); 00131 int backup(THD* thd, HA_CHECK_OPT* check_opt); 00132 int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt); 00133 int preload_keys(THD* thd, HA_CHECK_OPT* check_opt); 00134 bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); 00135 #ifdef HAVE_REPLICATION 00136 int dump(THD* thd, int fd); 00137 int net_read_dump(NET* net); 00138 #endif 00139 };
1.4.7

