| 1 | /* |
| 2 | Copyright (c) 2000, 2011, Oracle and/or its affiliates |
| 3 | Copyright (c) 2009, 2011, Monty Program Ab |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; version 2 of the License. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ |
| 17 | |
| 18 | /* class for the the heap handler */ |
| 19 | |
| 20 | #include <heap.h>cxx . . $ `<file>/include/heap.h`/ |
| 21 | #include "sql_class.h"cxx . . $ `<file>/sql/sql_class.h`/ /* THD */ |
| 22 | |
| 23 | class ha_heapcxx . . $ ha_heap# final : public handlercxx . . $ handler# |
| 24 | { |
| 25 | HP_INFO *filecxx . . $ ha_heap#file.; |
| 26 | HP_SHARE *internal_sharecxx . . $ ha_heap#internal_share.; |
| 27 | key_mapcxx . . $ key_map# btree_keyscxx . . $ ha_heap#btree_keys.; |
| 28 | /* number of records changed since last statistics update */ |
| 29 | ulong records_changedcxx . . $ ha_heap#records_changed.; |
| 30 | uint key_stat_versioncxx . . $ ha_heap#key_stat_version.; |
| 31 | my_boolcxx . . $ my_bool# internal_tablecxx . . $ ha_heap#internal_table.; |
| 32 | public: |
| 33 | ha_heapcxx . . $ ha_heap#ha_heap(4ed6374a37a121ca).(handlertoncxx . . $ handlerton# *hton, TABLE_SHAREcxx . . $ TABLE_SHARE# *table); |
| 34 | ~cxx . . $ ha_heap#`~ha_heap`(ced63f7c635d850d).ha_heapcxx . . $ ha_heap#() = default; |
| 35 | handlercxx . . $ handler# *clonecxx . . $ ha_heap#clone(5728aa33ab292386).(const char *name, MEM_ROOTcxx . . $ MEM_ROOT# *mem_root) override; |
| 36 | /* Rows also use a fixed-size format */ |
| 37 | enum row_typecxx . . $ row_type# get_row_typecxx . . $ ha_heap#get_row_type(288dcaa8a50eb472).() const override { return ROW_TYPE_FIXEDcxx . . $ ROW_TYPE_FIXED.; } |
| 38 | ulonglongcxx . . $ ulonglong# table_flagscxx . . $ ha_heap#table_flags(1c5fc1fd41a99ae7).() const override |
| 39 | { |
| 40 | return (HA_FAST_KEY_READcxx . . $ `sql/handler.h:142:9`! | HA_NO_BLOBScxx . . $ `sql/handler.h:150:9`! | HA_NULL_IN_KEYcxx . . $ `sql/handler.h:148:9`! | |
| 41 | HA_BINLOG_ROW_CAPABLEcxx . . $ `sql/handler.h:206:9`! | HA_BINLOG_STMT_CAPABLEcxx . . $ `sql/handler.h:207:9`! | |
| 42 | HA_CAN_SQL_HANDLERcxx . . $ `sql/handler.h:189:9`! | HA_CAN_ONLINE_BACKUPScxx . . $ `sql/handler.h:362:9`! | |
| 43 | HA_REC_NOT_IN_SEQcxx . . $ `sql/handler.h:135:9`! | HA_CAN_INSERT_DELAYEDcxx . . $ `sql/handler.h:165:9`! | HA_NO_TRANSACTIONScxx . . $ `sql/handler.h:124:9`! | |
| 44 | HA_HAS_RECORDScxx . . $ `sql/handler.h:199:9`! | HA_STATS_RECORDS_IS_EXACTcxx . . $ `sql/handler.h:160:9`! | HA_CAN_HASH_KEYScxx . . $ `sql/handler.h:365:9`!); |
| 45 | } |
| 46 | ulong index_flagscxx . . $ ha_heap#index_flags(ac3be7eff3a46d11).(uint inx, uint part, bool all_parts) const override |
| 47 | { |
| 48 | return ((table_sharecxx . . $ handler#table_share.->key_infocxx . . $ TABLE_SHARE#key_info.[inx].algorithmcxx . . $ st_key#algorithm. == HA_KEY_ALG_BTREEcxx . . $ HA_KEY_ALG_BTREE.) ? |
| 49 | HA_READ_NEXTcxx . . $ `sql/handler.h:394:9`! | HA_READ_PREVcxx . . $ `sql/handler.h:395:9`! | HA_READ_ORDERcxx . . $ `sql/handler.h:396:9`! | HA_READ_RANGEcxx . . $ `sql/handler.h:397:9`! : |
| 50 | HA_ONLY_WHOLE_INDEXcxx . . $ `sql/handler.h:398:9`! | HA_KEY_SCAN_NOT_RORcxx . . $ `sql/handler.h:405:9`!); |
| 51 | } |
| 52 | const key_mapcxx . . $ key_map# *keys_to_use_for_scanningcxx . . $ ha_heap#keys_to_use_for_scanning(749ab6840124b054).() override; |
| 53 | uint max_supported_keyscxx . . $ ha_heap#max_supported_keys(ddd8539a2fcdd4ce).() const override { return MAX_KEYcxx . . $ `sql/sql_const.h:34:9`!; } |
| 54 | uint max_supported_key_part_lengthcxx . . $ ha_heap#max_supported_key_part_length(ddd8539a2fcdd4ce).() const override { return MAX_KEY_LENGTHcxx . . $ `sql/handler.h:502:9`!; } |
| 55 | IO_AND_CPU_COSTcxx . . $ IO_AND_CPU_COST# scan_timecxx . . $ ha_heap#scan_time(607c3ae9fc3acc62).() override; |
| 56 | IO_AND_CPU_COSTcxx . . $ IO_AND_CPU_COST# keyread_timecxx . . $ ha_heap#keyread_time(c781e7ba35b2cf46).(uint index, ulong ranges, ha_rowscxx . . $ ha_rows# rows, |
| 57 | ulonglongcxx . . $ ulonglong# blocks) override; |
| 58 | IO_AND_CPU_COSTcxx . . $ IO_AND_CPU_COST# rnd_pos_timecxx . . $ ha_heap#rnd_pos_time(e3fb9b078e5ff6d3).(ha_rowscxx . . $ ha_rows# rows) override; |
| 59 | /* 0 for avg_io_cost ensures that there are no read-block calculations */ |
| 60 | |
| 61 | int opencxx . . $ ha_heap#open(ac5e327aedb29b06).(const char *name, int mode, uint test_if_locked) override; |
| 62 | int closecxx . . $ ha_heap#close(b126dc7c1de90089).(void) override; |
| 63 | int write_rowcxx . . $ ha_heap#write_row(b84ccf4e0bb14b06).(const ucharcxx . . $ uchar# * buf) override; |
| 64 | int update_rowcxx . . $ ha_heap#update_row(e46526da1a64e2fc).(const ucharcxx . . $ uchar# * old_data, const ucharcxx . . $ uchar# * new_data) override; |
| 65 | int delete_rowcxx . . $ ha_heap#delete_row(b84ccf4e0bb14b06).(const ucharcxx . . $ uchar# * buf) override; |
| 66 | void get_auto_incrementcxx . . $ ha_heap#get_auto_increment(a593684596ab789f).(ulonglongcxx . . $ ulonglong# offset, ulonglongcxx . . $ ulonglong# increment, |
| 67 | ulonglongcxx . . $ ulonglong# nb_desired_values, |
| 68 | ulonglongcxx . . $ ulonglong# *first_value, |
| 69 | ulonglongcxx . . $ ulonglong# *nb_reserved_values) override; |
| 70 | int index_read_mapcxx . . $ ha_heap#index_read_map(7b885921314fca32).(ucharcxx . . $ uchar# * buf, const ucharcxx . . $ uchar# * key, key_part_mapcxx . . $ key_part_map# keypart_map, |
| 71 | enum ha_rkey_functioncxx . . $ ha_rkey_function# find_flag) override; |
| 72 | int index_read_last_mapcxx . . $ ha_heap#index_read_last_map(b2b400a4aaec9333).(ucharcxx . . $ uchar# *buf, const ucharcxx . . $ uchar# *key, key_part_mapcxx . . $ key_part_map# keypart_map) |
| 73 | override; |
| 74 | int index_read_idx_mapcxx . . $ ha_heap#index_read_idx_map(f8f1a1f168aa973c).(ucharcxx . . $ uchar# * buf, uint index, const ucharcxx . . $ uchar# * key, |
| 75 | key_part_mapcxx . . $ key_part_map# keypart_map, |
| 76 | enum ha_rkey_functioncxx . . $ ha_rkey_function# find_flag) override; |
| 77 | int index_nextcxx . . $ ha_heap#index_next(b2e27cdb9bef2230).(ucharcxx . . $ uchar# * buf) override; |
| 78 | int index_prevcxx . . $ ha_heap#index_prev(b2e27cdb9bef2230).(ucharcxx . . $ uchar# * buf) override; |
| 79 | int index_firstcxx . . $ ha_heap#index_first(b2e27cdb9bef2230).(ucharcxx . . $ uchar# * buf) override; |
| 80 | int index_lastcxx . . $ ha_heap#index_last(b2e27cdb9bef2230).(ucharcxx . . $ uchar# * buf) override; |
| 81 | int rnd_initcxx . . $ ha_heap#rnd_init(73da94e76e6bd037).(bool scan) override; |
| 82 | int rnd_nextcxx . . $ ha_heap#rnd_next(b2e27cdb9bef2230).(ucharcxx . . $ uchar# *buf) override; |
| 83 | int rnd_poscxx . . $ ha_heap#rnd_pos(b2844eacf1e6a17b).(ucharcxx . . $ uchar# * buf, ucharcxx . . $ uchar# *pos) override; |
| 84 | void positioncxx . . $ ha_heap#position(28caea9380bfac8a).(const ucharcxx . . $ uchar# *record) override; |
| 85 | int can_continue_handler_scancxx . . $ ha_heap#can_continue_handler_scan(b126dc7c1de90089).() override; |
| 86 | int infocxx . . $ ha_heap#info(4c679297bf94b9eb).(uint) override; |
| 87 | int extracxx . . $ ha_heap#extra(3f7d7dcfae14d7dd).(enum ha_extra_functioncxx . . $ ha_extra_function# operation) override; |
| 88 | int resetcxx . . $ ha_heap#reset(b126dc7c1de90089).() override; |
| 89 | int external_lockcxx . . $ ha_heap#external_lock(55bfda0c556d7e61).(THDcxx . . $ THD# *thd, int lock_type) override; |
| 90 | int delete_all_rowscxx . . $ ha_heap#delete_all_rows(b126dc7c1de90089).(void) override; |
| 91 | int reset_auto_incrementcxx . . $ ha_heap#reset_auto_increment(642c2e9948c4ad2).(ulonglongcxx . . $ ulonglong# value) override; |
| 92 | int disable_indexescxx . . $ ha_heap#disable_indexes(f5cd2bccb9a33102).(key_mapcxx . . $ key_map# map, bool persist) override; |
| 93 | int enable_indexescxx . . $ ha_heap#enable_indexes(f5cd2bccb9a33102).(key_mapcxx . . $ key_map# map, bool persist) override; |
| 94 | int indexes_are_disabledcxx . . $ ha_heap#indexes_are_disabled(b126dc7c1de90089).(void) override; |
| 95 | ha_rowscxx . . $ ha_rows# records_in_rangecxx . . $ ha_heap#records_in_range(b018bf152a3ffa81).(uint inx, const key_rangecxx . . $ key_range# *start_key, |
| 96 | const key_rangecxx . . $ key_range# *end_key, page_rangecxx . . $ page_range# *pages) override; |
| 97 | int delete_tablecxx . . $ ha_heap#delete_table(5c4306d8553b3696).(const char *from) override; |
| 98 | void drop_tablecxx . . $ ha_heap#drop_table(85c52e162fed56f9).(const char *name) override; |
| 99 | int rename_tablecxx . . $ ha_heap#rename_table(5ae29d726ae57f88).(const char * from, const char * to) override; |
| 100 | int createcxx . . $ ha_heap#create(cdb011dbefdc6262).(const char *name, TABLEcxx . . $ TABLE# *form, HA_CREATE_INFOcxx . . $ HA_CREATE_INFO# *create_info) override; |
| 101 | void update_create_infocxx . . $ ha_heap#update_create_info(3ce3e72f07fbae22).(HA_CREATE_INFOcxx . . $ HA_CREATE_INFO# *create_info) override; |
| 102 | |
| 103 | THR_LOCK_DATA **store_lockcxx . . $ ha_heap#store_lock(47e46f62a15ac189).(THDcxx . . $ THD# *thd, THR_LOCK_DATA **to, |
| 104 | enum thr_lock_type lock_type) override; |
| 105 | int cmp_refcxx . . $ ha_heap#cmp_ref(e46526da1a64e2fc).(const ucharcxx . . $ uchar# *ref1, const ucharcxx . . $ uchar# *ref2) override |
| 106 | { |
| 107 | return memcmp(ref1, ref2, sizeof(HEAP_PTR)); |
| 108 | } |
| 109 | bool check_if_incompatible_datacxx . . $ ha_heap#check_if_incompatible_data(fd3c848ebdb5aff0).(HA_CREATE_INFOcxx . . $ HA_CREATE_INFO# *info, uint table_changes) |
| 110 | override; |
| 111 | int find_unique_rowcxx . . $ ha_heap#find_unique_row(c271a33def0f2b11).(ucharcxx . . $ uchar# *record, uint unique_idx) override; |
| 112 | private: |
| 113 | void update_key_statscxx . . $ ha_heap#update_key_stats(49f6e7a06ebc5aa8).(); |
| 114 | }; |