2004-05-06 15:53:01 +02:00
|
|
|
/* Copyright (C) 2000,2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
2001-12-06 13:10:51 +01:00
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2001-12-06 13:10:51 +01:00
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2001-12-06 13:10:51 +01:00
|
|
|
|
2000-07-31 21:29:14 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
|
|
|
|
2005-05-04 15:05:56 +02:00
|
|
|
#ifdef USE_PRAGMA_INTERFACE
|
2000-07-31 21:29:14 +02:00
|
|
|
#pragma interface /* gcc class implementation */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* class for the the heap handler */
|
|
|
|
|
|
|
|
#include <heap.h>
|
|
|
|
|
|
|
|
class ha_heap: public handler
|
|
|
|
{
|
|
|
|
HP_INFO *file;
|
2004-03-25 14:05:01 +01:00
|
|
|
key_map btree_keys;
|
2004-09-08 00:07:53 +02:00
|
|
|
/* number of records changed since last statistics update */
|
|
|
|
uint records_changed;
|
2005-06-24 17:47:09 +02:00
|
|
|
bool key_stats_ok;
|
2004-09-08 00:07:53 +02:00
|
|
|
public:
|
2005-07-19 20:21:12 +02:00
|
|
|
ha_heap(TABLE *table);
|
2000-07-31 21:29:14 +02:00
|
|
|
~ha_heap() {}
|
2005-01-14 02:38:13 +01:00
|
|
|
const char *table_type() const
|
|
|
|
{
|
|
|
|
return (table->in_use->variables.sql_mode & MODE_MYSQL323) ?
|
|
|
|
"HEAP" : "MEMORY";
|
|
|
|
}
|
2002-04-12 20:35:46 +02:00
|
|
|
const char *index_type(uint inx)
|
|
|
|
{
|
2005-11-05 12:20:35 +01:00
|
|
|
return ((table->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ?
|
|
|
|
"BTREE" : "HASH");
|
2002-04-12 20:35:46 +02:00
|
|
|
}
|
2005-08-05 22:19:48 +02:00
|
|
|
/* Rows also use a fixed-size format */
|
|
|
|
enum row_type get_row_type() const { return ROW_TYPE_FIXED; }
|
2000-07-31 21:29:14 +02:00
|
|
|
const char **bas_ext() const;
|
2002-04-12 20:35:46 +02:00
|
|
|
ulong table_flags() const
|
|
|
|
{
|
2004-06-23 12:29:05 +02:00
|
|
|
return (HA_FAST_KEY_READ | HA_NO_BLOBS | HA_NULL_IN_KEY |
|
|
|
|
HA_REC_NOT_IN_SEQ | HA_READ_RND_SAME |
|
|
|
|
HA_CAN_INSERT_DELAYED);
|
2002-04-12 20:35:46 +02:00
|
|
|
}
|
2004-07-08 14:45:25 +02:00
|
|
|
ulong index_flags(uint inx, uint part, bool all_parts) const
|
2002-04-12 20:35:46 +02:00
|
|
|
{
|
|
|
|
return ((table->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ?
|
2004-06-23 12:29:05 +02:00
|
|
|
HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE :
|
|
|
|
HA_ONLY_WHOLE_INDEX);
|
2002-04-12 20:35:46 +02:00
|
|
|
}
|
2004-03-25 14:05:01 +01:00
|
|
|
const key_map *keys_to_use_for_scanning() { return &btree_keys; }
|
2004-06-23 12:29:05 +02:00
|
|
|
uint max_supported_keys() const { return MAX_KEY; }
|
2005-05-24 21:21:15 +02:00
|
|
|
uint max_supported_key_part_length() const { return MAX_KEY_LENGTH; }
|
2003-04-23 20:52:16 +02:00
|
|
|
double scan_time() { return (double) (records+deleted) / 20.0+10; }
|
|
|
|
double read_time(uint index, uint ranges, ha_rows rows)
|
|
|
|
{ return (double) rows / 20.0+1; }
|
2000-07-31 21:29:14 +02:00
|
|
|
|
2000-09-25 23:33:25 +02:00
|
|
|
int open(const char *name, int mode, uint test_if_locked);
|
2000-07-31 21:29:14 +02:00
|
|
|
int close(void);
|
2004-05-06 15:53:01 +02:00
|
|
|
void set_keys_for_scanning(void);
|
2000-07-31 21:29:14 +02:00
|
|
|
int write_row(byte * buf);
|
|
|
|
int update_row(const byte * old_data, byte * new_data);
|
|
|
|
int delete_row(const byte * buf);
|
2004-09-15 21:10:31 +02:00
|
|
|
ulonglong get_auto_increment();
|
2000-07-31 21:29:14 +02:00
|
|
|
int index_read(byte * buf, const byte * key,
|
|
|
|
uint key_len, enum ha_rkey_function find_flag);
|
|
|
|
int index_read_idx(byte * buf, uint idx, const byte * key,
|
|
|
|
uint key_len, enum ha_rkey_function find_flag);
|
2002-11-28 12:19:42 +01:00
|
|
|
int index_read_last(byte * buf, const byte * key, uint key_len);
|
2000-07-31 21:29:14 +02:00
|
|
|
int index_next(byte * buf);
|
|
|
|
int index_prev(byte * buf);
|
|
|
|
int index_first(byte * buf);
|
|
|
|
int index_last(byte * buf);
|
2004-06-25 17:49:36 +02:00
|
|
|
int rnd_init(bool scan);
|
2000-07-31 21:29:14 +02:00
|
|
|
int rnd_next(byte *buf);
|
|
|
|
int rnd_pos(byte * buf, byte *pos);
|
|
|
|
void position(const byte *record);
|
|
|
|
void info(uint);
|
|
|
|
int extra(enum ha_extra_function operation);
|
|
|
|
int external_lock(THD *thd, int lock_type);
|
|
|
|
int delete_all_rows(void);
|
2004-05-06 15:53:01 +02:00
|
|
|
int disable_indexes(uint mode);
|
|
|
|
int enable_indexes(uint mode);
|
|
|
|
int indexes_are_disabled(void);
|
2004-05-16 13:48:32 +02:00
|
|
|
ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key);
|
2000-07-31 21:29:14 +02:00
|
|
|
int delete_table(const char *from);
|
|
|
|
int rename_table(const char * from, const char * to);
|
|
|
|
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
|
2002-10-07 14:49:03 +02:00
|
|
|
void update_create_info(HA_CREATE_INFO *create_info);
|
2000-07-31 21:29:14 +02:00
|
|
|
|
|
|
|
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
|
|
|
|
enum thr_lock_type lock_type);
|
2004-05-12 23:38:40 +02:00
|
|
|
int cmp_ref(const byte *ref1, const byte *ref2)
|
|
|
|
{
|
|
|
|
HEAP_PTR ptr1=*(HEAP_PTR*)ref1;
|
|
|
|
HEAP_PTR ptr2=*(HEAP_PTR*)ref2;
|
|
|
|
return ptr1 < ptr2? -1 : (ptr1 > ptr2? 1 : 0);
|
|
|
|
}
|
2005-07-22 22:43:59 +02:00
|
|
|
bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes);
|
2004-09-08 00:07:53 +02:00
|
|
|
private:
|
|
|
|
void update_key_stats();
|
2000-07-31 21:29:14 +02:00
|
|
|
};
|