1396
1398
table_share= share;
1398
1400
/* Estimates calculation */
1399
virtual double scan_time()
1401
virtual double scan_time(void)
1400
1402
{ return ulonglong2double(stats.data_file_length) / IO_SIZE + 2; }
1401
virtual double read_time(uint index, uint ranges, ha_rows rows)
1403
virtual double read_time(uint index __attribute__((__unused__)),
1404
uint ranges, ha_rows rows)
1402
1405
{ return rows2double(ranges+rows); }
1404
1407
virtual double index_only_read_time(uint keynr, double records);
1538
1542
virtual int index_read_idx_map(uchar * buf, uint index, const uchar * key,
1539
1543
key_part_map keypart_map,
1540
1544
enum ha_rkey_function find_flag);
1541
virtual int index_next(uchar * buf)
1542
{ return HA_ERR_WRONG_COMMAND; }
1543
virtual int index_prev(uchar * buf)
1544
{ return HA_ERR_WRONG_COMMAND; }
1545
virtual int index_first(uchar * buf)
1546
{ return HA_ERR_WRONG_COMMAND; }
1547
virtual int index_last(uchar * buf)
1548
{ return HA_ERR_WRONG_COMMAND; }
1549
virtual int index_next_same(uchar *buf, const uchar *key, uint keylen);
1545
virtual int index_next(uchar * buf __attribute__((__unused__)))
1546
{ return HA_ERR_WRONG_COMMAND; }
1547
virtual int index_prev(uchar * buf __attribute__((__unused__)))
1548
{ return HA_ERR_WRONG_COMMAND; }
1549
virtual int index_first(uchar * buf __attribute__((__unused__)))
1550
{ return HA_ERR_WRONG_COMMAND; }
1551
virtual int index_last(uchar * buf __attribute__((__unused__)))
1552
{ return HA_ERR_WRONG_COMMAND; }
1553
virtual int index_next_same(uchar *buf __attribute__((__unused__)),
1554
const uchar *key __attribute__((__unused__)),
1555
uint keylen __attribute__((__unused__)));
1552
1558
The following functions works like index_read, but it find the last
1566
1572
int compare_key2(key_range *range);
1567
1573
virtual int ft_init() { return HA_ERR_WRONG_COMMAND; }
1568
1574
void ft_end() { ft_handler=NULL; }
1569
virtual FT_INFO *ft_init_ext(uint flags, uint inx,String *key)
1575
virtual FT_INFO *ft_init_ext(uint flags __attribute__((__unused__)),
1576
uint inx __attribute__((__unused__)),
1577
String *key __attribute__((__unused__)))
1570
1578
{ return NULL; }
1571
virtual int ft_read(uchar *buf) { return HA_ERR_WRONG_COMMAND; }
1572
virtual int rnd_next(uchar *buf)=0;
1573
virtual int rnd_pos(uchar * buf, uchar *pos)=0;
1579
virtual int ft_read(uchar *buf __attribute__((__unused__))) { return HA_ERR_WRONG_COMMAND; }
1580
virtual int rnd_next(uchar *buf __attribute__((__unused__)))=0;
1581
virtual int rnd_pos(uchar * buf __attribute__((__unused__)),
1582
uchar *pos __attribute__((__unused__)))=0;
1575
1584
One has to use this method when to find
1576
1585
random position by record as the plain
1583
1592
The following function is only needed for tables that may be temporary
1584
1593
tables during joins.
1586
virtual int restart_rnd_next(uchar *buf, uchar *pos)
1587
{ return HA_ERR_WRONG_COMMAND; }
1588
virtual int rnd_same(uchar *buf, uint inx)
1589
{ return HA_ERR_WRONG_COMMAND; }
1590
virtual ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key)
1595
virtual int restart_rnd_next(uchar *buf __attribute__((__unused__)),
1596
uchar *pos __attribute__((__unused__)))
1597
{ return HA_ERR_WRONG_COMMAND; }
1598
virtual int rnd_same(uchar *buf __attribute__((__unused__)),
1599
uint inx __attribute__((__unused__)))
1600
{ return HA_ERR_WRONG_COMMAND; }
1601
virtual ha_rows records_in_range(uint inx __attribute__((__unused__)),
1602
key_range *min_key __attribute__((__unused__)),
1603
key_range *max_key __attribute__((__unused__)))
1591
1604
{ return (ha_rows) 10; }
1592
1605
virtual void position(const uchar *record)=0;
1593
1606
virtual int info(uint)=0; // see my_base.h for full description
1594
virtual uint32 calculate_key_hash_value(Field **field_array)
1607
virtual uint32 calculate_key_hash_value(Field **field_array __attribute__((__unused__)))
1595
1608
{ DBUG_ASSERT(0); return 0; }
1596
virtual int extra(enum ha_extra_function operation)
1609
virtual int extra(enum ha_extra_function operation __attribute__((__unused__)))
1598
virtual int extra_opt(enum ha_extra_function operation, uint32_t cache_size)
1611
virtual int extra_opt(enum ha_extra_function operation,
1612
uint32_t cache_size __attribute__((__unused__)))
1599
1613
{ return extra(operation); }
1618
1632
the last committed row value under the cursor.
1620
1634
virtual void try_semi_consistent_read(bool) {}
1621
virtual void unlock_row() {}
1622
virtual int start_stmt(THD *thd, thr_lock_type lock_type) {return 0;}
1635
virtual void unlock_row(void) {}
1636
virtual int start_stmt(THD *thd __attribute__((__unused__)),
1637
thr_lock_type lock_type __attribute__((__unused__)))
1623
1639
virtual void get_auto_increment(uint64_t offset, uint64_t increment,
1624
1640
uint64_t nb_desired_values,
1625
1641
uint64_t *first_value,
1645
1661
insert_id_for_cur_row;
1648
virtual void update_create_info(HA_CREATE_INFO *create_info) {}
1649
int check_old_types();
1650
virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt)
1664
virtual void update_create_info(HA_CREATE_INFO *create_info __attribute__((__unused__))) {}
1665
int check_old_types(void);
1666
virtual int assign_to_keycache(THD* thd __attribute__((__unused__)),
1667
HA_CHECK_OPT* check_opt __attribute__((__unused__)))
1651
1668
{ return HA_ADMIN_NOT_IMPLEMENTED; }
1652
1669
/* end of the list of admin commands */
1654
1671
virtual int indexes_are_disabled(void) {return 0;}
1655
1672
virtual char *update_table_comment(const char * comment)
1656
1673
{ return (char*) comment;}
1657
virtual void append_create_info(String *packet) {}
1674
virtual void append_create_info(String *packet __attribute__((__unused__)))
1659
1677
If index == MAX_KEY then a check for table is made and if index <
1660
1678
MAX_KEY then a check is made if the table has foreign keys and if
1665
1683
@retval TRUE Foreign key defined on table or index
1666
1684
@retval FALSE No foreign key defined
1668
virtual bool is_fk_defined_on_table_or_index(uint index)
1686
virtual bool is_fk_defined_on_table_or_index(uint index __attribute__((__unused__)))
1669
1687
{ return FALSE; }
1670
virtual char* get_foreign_key_create_info()
1688
virtual char* get_foreign_key_create_info(void)
1671
1689
{ return(NULL);} /* gets foreign key create string from InnoDB */
1672
1690
/* gets tablespace name from handler */
1673
const char* get_tablespace_name();
1691
const char* get_tablespace_name(void);
1674
1692
/** used in ALTER TABLE; 1 if changing storage engine is allowed */
1675
virtual bool can_switch_engines() { return 1; }
1693
virtual bool can_switch_engines(void) { return 1; }
1676
1694
/** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */
1677
virtual int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
1695
virtual int get_foreign_key_list(THD *thd __attribute__((__unused__)),
1696
List<FOREIGN_KEY_INFO> *f_key_list __attribute__((__unused__)))
1679
1698
virtual uint referenced_by_foreign_key() { return 0;}
1680
1699
virtual void init_table_handle_for_HANDLER()
1681
1700
{ return; } /* prepare InnoDB for HANDLER */
1682
virtual void free_foreign_key_create_info(char* str) {}
1701
virtual void free_foreign_key_create_info(char* str __attribute__((__unused__))) {}
1683
1702
/** The following can be called without an open handler */
1684
1703
virtual const char *table_type() const =0;
1696
1715
virtual const char **bas_ext() const =0;
1698
virtual int get_default_no_partitions(HA_CREATE_INFO *info) { return 1;}
1699
virtual bool get_no_parts(const char *name,
1717
virtual int get_default_no_partitions(HA_CREATE_INFO *info __attribute__((__unused__))) { return 1;}
1718
virtual bool get_no_parts(const char *name __attribute__((__unused__)),
1700
1719
uint *no_parts)
1706
1725
virtual uint32_t index_flags(uint idx, uint part, bool all_parts) const =0;
1708
virtual int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys)
1709
{ return (HA_ERR_WRONG_COMMAND); }
1710
virtual int prepare_drop_index(TABLE *table_arg, uint *key_num,
1712
{ return (HA_ERR_WRONG_COMMAND); }
1713
virtual int final_drop_index(TABLE *table_arg)
1727
virtual int add_index(TABLE *table_arg __attribute__((__unused__)),
1728
KEY *key_info __attribute__((__unused__)),
1729
uint num_of_keys __attribute__((__unused__)))
1730
{ return (HA_ERR_WRONG_COMMAND); }
1731
virtual int prepare_drop_index(TABLE *table_arg __attribute__((__unused__)),
1732
uint *key_num __attribute__((__unused__)),
1733
uint num_of_keys __attribute__((__unused__)))
1734
{ return (HA_ERR_WRONG_COMMAND); }
1735
virtual int final_drop_index(TABLE *table_arg __attribute__((__unused__)))
1714
1736
{ return (HA_ERR_WRONG_COMMAND); }
1716
1738
uint max_record_length() const
1721
1743
{ return min(MAX_REF_PARTS, max_supported_key_parts()); }
1722
1744
uint max_key_length() const
1723
1745
{ return min(MAX_KEY_LENGTH, max_supported_key_length()); }
1724
uint max_key_part_length() const
1746
uint max_key_part_length(void) const
1725
1747
{ return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
1727
virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
1728
virtual uint max_supported_keys() const { return 0; }
1729
virtual uint max_supported_key_parts() const { return MAX_REF_PARTS; }
1730
virtual uint max_supported_key_length() const { return MAX_KEY_LENGTH; }
1731
virtual uint max_supported_key_part_length() const { return 255; }
1732
virtual uint min_record_length(uint options) const { return 1; }
1749
virtual uint max_supported_record_length(void) const
1750
{ return HA_MAX_REC_LENGTH; }
1751
virtual uint max_supported_keys(void) const { return 0; }
1752
virtual uint max_supported_key_parts(void) const { return MAX_REF_PARTS; }
1753
virtual uint max_supported_key_length(void) const { return MAX_KEY_LENGTH; }
1754
virtual uint max_supported_key_part_length(void) const { return 255; }
1755
virtual uint min_record_length(uint options __attribute__((__unused__))) const
1734
virtual bool low_byte_first() const { return 1; }
1735
virtual uint checksum() const { return 0; }
1736
virtual bool is_crashed() const { return 0; }
1737
virtual bool auto_repair() const { return 0; }
1758
virtual bool low_byte_first(void) const { return 1; }
1759
virtual uint checksum(void) const { return 0; }
1760
virtual bool is_crashed(void) const { return 0; }
1761
virtual bool auto_repair(void) const { return 0; }
1740
1764
#define CHF_CREATE_FLAG 0
1800
virtual my_bool register_query_cache_table(THD *thd, char *table_key,
1804
uint64_t *engine_data)
1825
register_query_cache_table(THD *thd __attribute__((__unused__)),
1826
char *table_key __attribute__((__unused__)),
1827
uint key_length __attribute__((__unused__)),
1828
qc_engine_callback *engine_callback,
1829
uint64_t *engine_data __attribute__((__unused__)))
1806
1831
*engine_callback= 0;
1846
1871
condition stack.
1848
1873
virtual const COND *cond_push(const COND *cond) { return cond; }
1851
1876
Pop the top condition from the condition stack of the handler instance.
1853
1878
Pops the top if condition stack, if stack is not empty.
1855
virtual void cond_pop() { return; }
1880
virtual void cond_pop(void) { return; }
1857
virtual Item *idx_cond_push(uint keyno, Item* idx_cond) { return idx_cond; }
1883
*idx_cond_push(uint keyno __attribute__((__unused__)),
1884
Item* idx_cond __attribute__((__unused__)))
1885
{ return idx_cond; }
1860
1888
Part of old fast alter table, to be depricated
1862
virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
1891
check_if_incompatible_data(HA_CREATE_INFO *create_info __attribute__((__unused__)),
1892
uint table_changes __attribute__((__unused__)))
1864
1893
{ return COMPATIBLE_DATA_NO; }
1866
1895
/* On-line ALTER TABLE interface */
1886
1915
The default implementation is implemented to support fast
1887
1916
alter table (storage engines that support some changes by
1888
1917
just changing the frm file) without any change in the handler
1891
virtual int check_if_supported_alter(TABLE *altered_table,
1892
HA_CREATE_INFO *create_info,
1893
HA_ALTER_FLAGS *alter_flags,
1921
check_if_supported_alter(TABLE *altered_table __attribute__((__unused__)),
1922
HA_CREATE_INFO *create_info,
1923
HA_ALTER_FLAGS *alter_flags __attribute__((__unused__)),
1896
1926
DBUG_ENTER("check_if_supported_alter");
1897
1927
if (this->check_if_incompatible_data(create_info, table_changes)
1914
1944
@retval error error code passed from storage engine
1916
virtual int alter_table_phase1(THD *thd,
1917
TABLE *altered_table,
1918
HA_CREATE_INFO *create_info,
1919
HA_ALTER_INFO *alter_info,
1920
HA_ALTER_FLAGS *alter_flags)
1946
virtual int alter_table_phase1(THD *thd __attribute__((__unused__)),
1947
TABLE *altered_table __attribute__((__unused__)),
1948
HA_CREATE_INFO *create_info __attribute__((__unused__)),
1949
HA_ALTER_INFO *alter_info __attribute__((__unused__)),
1950
HA_ALTER_FLAGS *alter_flags __attribute__((__unused__)))
1922
1952
return HA_ERR_UNSUPPORTED;
1939
1969
this call is to be wrapped with a DDL lock. This is currently NOT
1942
virtual int alter_table_phase2(THD *thd,
1943
TABLE *altered_table,
1944
HA_CREATE_INFO *create_info,
1945
HA_ALTER_INFO *alter_info,
1946
HA_ALTER_FLAGS *alter_flags)
1972
virtual int alter_table_phase2(THD *thd __attribute__((__unused__)),
1973
TABLE *altered_table __attribute__((__unused__)),
1974
HA_CREATE_INFO *create_info __attribute__((__unused__)),
1975
HA_ALTER_INFO *alter_info __attribute__((__unused__)),
1976
HA_ALTER_FLAGS *alter_flags __attribute__((__unused__)))
1948
1978
return HA_ERR_UNSUPPORTED;
1954
1984
@param thd The thread handle
1955
1985
@param table The altered table, re-opened
1957
virtual int alter_table_phase3(THD *thd, TABLE *table)
1987
virtual int alter_table_phase3(THD *thd __attribute__((__unused__)),
1988
TABLE *table __attribute__((__unused__)))
1959
1990
return HA_ERR_UNSUPPORTED;
2030
2061
virtual int open(const char *name, int mode, uint test_if_locked)=0;
2031
virtual int index_init(uint idx, bool sorted) { active_index= idx; return 0; }
2062
virtual int index_init(uint idx,
2063
bool sorted __attribute__((__unused__)))
2064
{ active_index= idx; return 0; }
2032
2065
virtual int index_end() { active_index= MAX_KEY; return 0; }
2034
2067
rnd_init() can be called two times without rnd_end() in between
2092
virtual void release_auto_increment() { return; };
2125
virtual void release_auto_increment(void) { return; };
2093
2126
/** admin commands - called from mysql_admin_table */
2094
virtual int check_for_upgrade(HA_CHECK_OPT *check_opt)
2127
virtual int check_for_upgrade(HA_CHECK_OPT *check_opt __attribute__((__unused__)))
2096
virtual int check(THD* thd, HA_CHECK_OPT* check_opt)
2129
virtual int check(THD* thd __attribute__((__unused__)),
2130
HA_CHECK_OPT* check_opt __attribute__((__unused__)))
2097
2131
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2101
2135
to specify CHECK option to use to call check()
2102
2136
upon the table.
2104
virtual int repair(THD* thd, HA_CHECK_OPT* check_opt)
2138
virtual int repair(THD* thd __attribute__((__unused__)),
2139
HA_CHECK_OPT* check_opt __attribute__((__unused__)))
2105
2140
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2106
virtual void start_bulk_insert(ha_rows rows) {}
2107
virtual int end_bulk_insert() { return 0; }
2108
virtual int index_read(uchar * buf, const uchar * key, uint key_len,
2109
enum ha_rkey_function find_flag)
2141
virtual void start_bulk_insert(ha_rows rows __attribute__((__unused__)))
2143
virtual int end_bulk_insert(void) { return 0; }
2144
virtual int index_read(uchar * buf __attribute__((__unused__)),
2145
const uchar * key __attribute__((__unused__)),
2146
uint key_len __attribute__((__unused__)),
2147
enum ha_rkey_function find_flag __attribute__((__unused__)))
2110
2148
{ return HA_ERR_WRONG_COMMAND; }
2111
virtual int index_read_last(uchar * buf, const uchar * key, uint key_len)
2149
virtual int index_read_last(uchar * buf __attribute__((__unused__)),
2150
const uchar * key __attribute__((__unused__)),
2151
uint key_len __attribute__((__unused__)))
2112
2152
{ return (my_errno= HA_ERR_WRONG_COMMAND); }
2114
2154
This method is similar to update_row, however the handler doesn't need
2123
2163
@retval 0 Bulk delete used by handler
2124
2164
@retval 1 Bulk delete not used, normal operation used
2126
virtual int bulk_update_row(const uchar *old_data, uchar *new_data,
2127
uint *dup_key_found)
2166
virtual int bulk_update_row(const uchar *old_data __attribute__((__unused__)),
2167
uchar *new_data __attribute__((__unused__)),
2168
uint *dup_key_found __attribute__((__unused__)))
2129
2170
DBUG_ASSERT(FALSE);
2130
2171
return HA_ERR_WRONG_COMMAND;
2143
2184
is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
2144
2185
returned by storage engines that don't support this operation.
2146
virtual int reset_auto_increment(uint64_t value)
2147
{ return HA_ERR_WRONG_COMMAND; }
2148
virtual int optimize(THD* thd, HA_CHECK_OPT* check_opt)
2149
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2150
virtual int analyze(THD* thd, HA_CHECK_OPT* check_opt)
2151
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2152
virtual bool check_and_repair(THD *thd) { return TRUE; }
2153
virtual int disable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; }
2154
virtual int enable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; }
2155
virtual int discard_or_import_tablespace(my_bool discard)
2187
virtual int reset_auto_increment(uint64_t value __attribute__((__unused__)))
2188
{ return HA_ERR_WRONG_COMMAND; }
2189
virtual int optimize(THD* thd __attribute__((__unused__)),
2190
HA_CHECK_OPT* check_opt __attribute__((__unused__)))
2191
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2192
virtual int analyze(THD* thd __attribute__((__unused__)),
2193
HA_CHECK_OPT* check_opt __attribute__((__unused__)))
2194
{ return HA_ADMIN_NOT_IMPLEMENTED; }
2195
virtual bool check_and_repair(THD *thd __attribute__((__unused__)))
2197
virtual int disable_indexes(uint mode __attribute__((__unused__)))
2198
{ return HA_ERR_WRONG_COMMAND; }
2199
virtual int enable_indexes(uint mode __attribute__((__unused__)))
2200
{ return HA_ERR_WRONG_COMMAND; }
2201
virtual int discard_or_import_tablespace(my_bool discard __attribute__((__unused__)))
2156
2202
{ return (my_errno=HA_ERR_WRONG_COMMAND); }
2157
virtual void prepare_for_alter() { return; }
2203
virtual void prepare_for_alter(void) { return; }
2158
2204
virtual void drop_table(const char *name);
2159
virtual int create(const char *name, TABLE *form, HA_CREATE_INFO *info)=0;
2205
virtual int create(const char *name __attribute__((__unused__)),
2206
TABLE *form __attribute__((__unused__)),
2207
HA_CREATE_INFO *info __attribute__((__unused__)))=0;
2161
virtual int create_handler_files(const char *name, const char *old_name,
2162
int action_flag, HA_CREATE_INFO *info)
2209
virtual int create_handler_files(const char *name __attribute__((__unused__)),
2210
const char *old_name __attribute__((__unused__)),
2211
int action_flag __attribute__((__unused__)),
2212
HA_CREATE_INFO *info __attribute__((__unused__)))
2163
2213
{ return FALSE; }