MySQL 8.0.39
Source Code Documentation
ha_myisammrg.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2000, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24
25/**
26 @file storage/myisammrg/ha_myisammrg.h
27 MyISAM merge storage engine.
28*/
29
30#include <sys/types.h>
31
32#include "lex_string.h"
33#include "my_double2ulonglong.h"
34#include "my_inttypes.h"
35#include "my_io.h"
36#include "myisammrg.h"
37#include "myrg_def.h"
38#include "sql/handler.h"
39#include "sql/table.h"
40
41/**
42 Represents one name of a MERGE child.
43
44 @todo Add MYRG_SHARE and store children names in the
45 share.
46*/
47
49 /* Remembered MERGE child def version. See top comment in ha_myisammrg.cc */
52
53 public:
56
57 /* Access MERGE child def version. See top comment in ha_myisammrg.cc */
60 }
62 inline void set_child_def_version(enum_table_ref_type child_table_ref_type,
64 m_child_table_ref_type = child_table_ref_type;
66 }
67
68 Mrg_child_def(char *db_arg, size_t db_len_arg, char *table_name_arg,
69 size_t table_name_len_arg) {
70 db.str = db_arg;
71 db.length = db_len_arg;
72 name.str = table_name_arg;
73 name.length = table_name_len_arg;
74 m_child_def_version = ~0ULL;
76 }
77};
78
79class ha_myisammrg : public handler {
81 bool is_cloned; /* This instance has been cloned */
82
83 public:
84 /* mem root for children list */
87 Table_ref *children_l; /* children list */
88 Table_ref **children_last_l; /* children list end */
89 uint test_if_locked; /* flags from ::open() */
90
91 ha_myisammrg(handlerton *hton, TABLE_SHARE *table_arg);
92 ~ha_myisammrg() override = default;
93 const char *table_type() const override { return "MRG_MyISAM"; }
95 return HA_KEY_ALG_BTREE;
96 }
97 bool is_index_algorithm_supported(enum ha_key_alg key_alg) const override {
98 return key_alg == HA_KEY_ALG_BTREE || key_alg == HA_KEY_ALG_RTREE;
99 }
100 ulonglong table_flags() const override {
105 }
106 ulong index_flags(uint inx, uint, bool) const override {
107 return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT)
108 ? 0
111 }
112 uint max_supported_keys() const override { return MI_MAX_KEY; }
115 [[maybe_unused]]) const override {
116 return MI_MAX_KEY_LENGTH;
117 }
118 double scan_time() override {
119 return ulonglong2double(stats.data_file_length) / IO_SIZE + file->tables;
120 }
121
122 int open(const char *name, int mode, uint test_if_locked_arg,
123 const dd::Table *table_def) override;
124 int add_children_list(void);
125 int attach_children(void);
126 int detach_children(void);
127 handler *clone(const char *name, MEM_ROOT *mem_root) override;
128 int close(void) override;
129 int write_row(uchar *buf) override;
130 int update_row(const uchar *old_data, uchar *new_data) override;
131 int delete_row(const uchar *buf) override;
132 int index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map,
133 enum ha_rkey_function find_flag) override;
134 int index_read_idx_map(uchar *buf, uint index, const uchar *key,
135 key_part_map keypart_map,
136 enum ha_rkey_function find_flag) override;
138 key_part_map keypart_map) override;
139 int index_next(uchar *buf) override;
140 int index_prev(uchar *buf) override;
141 int index_first(uchar *buf) override;
142 int index_last(uchar *buf) override;
143 int index_next_same(uchar *buf, const uchar *key, uint keylen) override;
144 int rnd_init(bool scan) override;
145 int rnd_next(uchar *buf) override;
146 int rnd_pos(uchar *buf, uchar *pos) override;
147 void position(const uchar *record) override;
149 key_range *max_key) override;
150 int truncate(dd::Table *table_def) override;
151 int info(uint) override;
152 int reset(void) override;
153 int extra(enum ha_extra_function operation) override;
154 int extra_opt(enum ha_extra_function operation, ulong cache_size) override;
155 int external_lock(THD *thd, int lock_type) override;
156 uint lock_count(void) const override;
157 int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info,
158 dd::Table *table_def) override;
160 enum thr_lock_type lock_type) override;
161 void update_create_info(HA_CREATE_INFO *create_info) override;
162 void append_create_info(String *packet) override;
163 MYRG_INFO *myrg_info() { return file; }
164 TABLE *table_ptr() { return table; }
166 uint table_changes) override;
167 int check(THD *thd, HA_CHECK_OPT *check_opt) override;
168 int records(ha_rows *num_rows) override;
169};
app_data_ptr new_data(u_int n, char *val, cons_type consensus)
Definition: sql_list.h:434
Represents one name of a MERGE child.
Definition: ha_myisammrg.h:48
LEX_STRING db
Definition: ha_myisammrg.h:54
enum_table_ref_type get_child_table_ref_type()
Definition: ha_myisammrg.h:58
LEX_STRING name
Definition: ha_myisammrg.h:55
void set_child_def_version(enum_table_ref_type child_table_ref_type, ulonglong version)
Definition: ha_myisammrg.h:62
ulonglong get_child_def_version()
Definition: ha_myisammrg.h:61
enum_table_ref_type m_child_table_ref_type
Definition: ha_myisammrg.h:50
Mrg_child_def(char *db_arg, size_t db_len_arg, char *table_name_arg, size_t table_name_len_arg)
Definition: ha_myisammrg.h:68
ulonglong m_child_def_version
Definition: ha_myisammrg.h:51
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:168
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Definition: table.h:2791
Definition: table.h:47
Definition: ha_myisammrg.h:79
TABLE * table_ptr()
Definition: ha_myisammrg.h:164
double scan_time() override
Definition: ha_myisammrg.h:118
int extra(enum ha_extra_function operation) override
Storage engine specific implementation of ha_extra()
Definition: ha_myisammrg.cc:1173
int records(ha_rows *num_rows) override
Number of rows in table.
Definition: ha_myisammrg.cc:1408
int index_next_same(uchar *buf, const uchar *key, uint keylen) override
Definition: ha_myisammrg.cc:1060
int reset(void) override
Reset state of file to after 'open'.
Definition: ha_myisammrg.cc:1201
uint max_supported_keys() const override
Definition: ha_myisammrg.h:112
int attach_children(void)
Attach children to a MERGE table.
Definition: ha_myisammrg.cc:721
enum ha_key_alg get_default_index_algorithm() const override
Get default key algorithm for SE.
Definition: ha_myisammrg.h:94
bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes) override
Part of old, deprecated in-place ALTER API.
Definition: ha_myisammrg.cc:1396
void position(const uchar *record) override
Definition: ha_myisammrg.cc:1090
ha_myisammrg(handlerton *hton, TABLE_SHARE *table_arg)
Constructor.
Definition: ha_myisammrg.cc:132
List< Mrg_child_def > child_def_list
Definition: ha_myisammrg.h:86
int open(const char *name, int mode, uint test_if_locked_arg, const dd::Table *table_def) override
Open a MERGE parent table, but not its children.
Definition: ha_myisammrg.cc:302
const char * table_type() const override
The following can be called without an open handler.
Definition: ha_myisammrg.h:93
void append_create_info(String *packet) override
Definition: ha_myisammrg.cc:1358
int external_lock(THD *thd, int lock_type) override
Is not invoked for non-transactional temporary tables.
Definition: ha_myisammrg.cc:1214
int index_last(uchar *buf) override
Definition: ha_myisammrg.cc:1053
int rnd_init(bool scan) override
rnd_init() can be called two times without rnd_end() in between (it only makes sense if scan=1).
Definition: ha_myisammrg.cc:1071
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info, dd::Table *table_def) override
Create table (implementation).
Definition: ha_myisammrg.cc:1299
Table_ref * children_l
Definition: ha_myisammrg.h:87
uint max_supported_key_length() const override
Definition: ha_myisammrg.h:113
int delete_row(const uchar *buf) override
Definition: ha_myisammrg.cc:999
void update_create_info(HA_CREATE_INFO *create_info) override
Update create info as part of ALTER TABLE.
Definition: ha_myisammrg.cc:1257
int check(THD *thd, HA_CHECK_OPT *check_opt) override
Definition: ha_myisammrg.cc:1404
int rnd_next(uchar *buf) override
Definition: ha_myisammrg.cc:1076
int index_next(uchar *buf) override
Definition: ha_myisammrg.cc:1032
bool is_index_algorithm_supported(enum ha_key_alg key_alg) const override
Check if SE supports specific key algorithm.
Definition: ha_myisammrg.h:97
handler * clone(const char *name, MEM_ROOT *mem_root) override
Returns a cloned instance of the current handler.
Definition: ha_myisammrg.cc:660
MEM_ROOT children_mem_root
Definition: ha_myisammrg.h:85
uint lock_count(void) const override
Get number of lock objects returned in store_lock.
Definition: ha_myisammrg.cc:1229
int index_prev(uchar *buf) override
Definition: ha_myisammrg.cc:1039
int write_row(uchar *buf) override
Write a row.
Definition: ha_myisammrg.cc:977
THR_LOCK_DATA ** store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) override
Is not invoked for non-transactional temporary tables.
Definition: ha_myisammrg.cc:1231
int detach_children(void)
Detach all children from a MERGE table and from the query list of tables.
Definition: ha_myisammrg.cc:859
int close(void) override
Close a MERGE parent table, but not its children.
Definition: ha_myisammrg.cc:963
int add_children_list(void)
Add list of MERGE children to a Table_ref chain.
Definition: ha_myisammrg.cc:382
int index_read_idx_map(uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) override
Positions an index cursor to the index specified in argument.
Definition: ha_myisammrg.cc:1014
int info(uint) override
General method to gather info from handler.
Definition: ha_myisammrg.cc:1114
int index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) override
Positions an index cursor to the index specified in the handle ('active_index').
Definition: ha_myisammrg.cc:1005
int update_row(const uchar *old_data, uchar *new_data) override
Update a single row.
Definition: ha_myisammrg.cc:993
int truncate(dd::Table *table_def) override
Quickly remove all rows from a table.
Definition: ha_myisammrg.cc:1102
uint max_supported_key_part_length(HA_CREATE_INFO *create_info) const override
Definition: ha_myisammrg.h:114
MYRG_INFO * file
Definition: ha_myisammrg.h:80
ulonglong table_flags() const override
Definition: ha_myisammrg.h:100
Table_ref ** children_last_l
Definition: ha_myisammrg.h:88
int extra_opt(enum ha_extra_function operation, ulong cache_size) override
Definition: ha_myisammrg.cc:1208
int index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map) override
The following functions works like index_read, but it find the last row with the current key value or...
Definition: ha_myisammrg.cc:1023
bool is_cloned
Definition: ha_myisammrg.h:81
~ha_myisammrg() override=default
ulong index_flags(uint inx, uint, bool) const override
Definition: ha_myisammrg.h:106
MYRG_INFO * myrg_info()
Definition: ha_myisammrg.h:163
ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key) override
Find number of records in a range.
Definition: ha_myisammrg.cc:1096
uint test_if_locked
Definition: ha_myisammrg.h:89
int index_first(uchar *buf) override
Definition: ha_myisammrg.cc:1046
int rnd_pos(uchar *buf, uchar *pos) override
Definition: ha_myisammrg.cc:1083
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4414
TABLE_SHARE * table_share
Definition: handler.h:4421
TABLE * table
Definition: handler.h:4422
A table definition from the master.
Definition: rpl_utility.h:248
static MEM_ROOT mem_root
Definition: client_plugin.cc:110
ha_key_alg
Definition: my_base.h:97
@ HA_KEY_ALG_RTREE
Definition: my_base.h:108
@ HA_KEY_ALG_BTREE
Definition: my_base.h:107
@ HA_KEY_ALG_FULLTEXT
Definition: my_base.h:110
ha_rkey_function
Definition: my_base.h:78
ulong key_part_map
Definition: my_base.h:1007
my_off_t ha_rows
Definition: my_base.h:1140
ha_extra_function
Definition: my_base.h:184
Utility functions for converting between ulonglong and double.
#define ulonglong2double(A)
Definition: my_double2ulonglong.h:46
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
unsigned char uchar
Definition: my_inttypes.h:52
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:83
constexpr const size_t IO_SIZE
Definition: my_io.h:159
#define MI_MAX_KEY_LENGTH
Definition: myisam.h:64
#define MI_MAX_KEY
Definition: myisam.h:56
This file should be included when using merge isam functions.
PSI_memory_key rg_key_memory_children
Definition: myrg_static.cc:44
static int record
Definition: mysqltest.cc:188
Definition: buf0block_hint.cc:30
Definition: os0file.h:86
mode
Definition: file_handle.h:60
required string key
Definition: replication_asynchronous_connection_failover.proto:60
required uint64 version
Definition: replication_group_member_actions.proto:41
#define HA_COUNT_ROWS_INSTANT
Definition: handler.h:332
#define HA_BINLOG_ROW_CAPABLE
Definition: handler.h:339
#define HA_NO_COPY_ON_ALTER
Definition: handler.h:331
#define HA_CAN_BIT_FIELD
Definition: handler.h:329
#define HA_FILE_BASED
Definition: handler.h:324
#define HA_CAN_INDEX_BLOBS
Definition: handler.h:257
#define HA_READ_NEXT
Definition: handler.h:526
#define HA_KEYREAD_ONLY
Definition: handler.h:571
#define HA_ANY_INDEX_MAY_BE_UNIQUE
Definition: handler.h:330
#define HA_BINLOG_STMT_CAPABLE
Definition: handler.h:340
#define HA_DUPLICATE_POS
Definition: handler.h:251
#define HA_READ_ORDER
Definition: handler.h:542
#define HA_READ_RANGE
Definition: handler.h:549
#define HA_NO_TRANSACTIONS
Definition: handler.h:210
#define HA_AUTO_PART_KEY
Definition: handler.h:262
#define HA_NULL_IN_KEY
Definition: handler.h:245
#define HA_READ_PREV
Definition: handler.h:530
enum_table_ref_type
Enumerate possible types of a table from re-execution standpoint.
Definition: table.h:173
@ TABLE_REF_NULL
Initial value set by the parser.
Definition: table.h:175
case opt name
Definition: sslopt-case.h:33
Definition: handler.h:3632
Struct to hold information about the table that should be created.
Definition: handler.h:3045
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: myisammrg.h:72
Definition: mysql_lex_string.h:35
char * str
Definition: mysql_lex_string.h:36
size_t length
Definition: mysql_lex_string.h:37
This structure is shared between different table objects.
Definition: table.h:690
KEY * key_info
Definition: table.h:746
Definition: table.h:1399
Definition: thr_lock.h:124
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2622
Definition: my_base.h:1124
Definition: mysqlslap.cc:238
thr_lock_type
Definition: thr_lock.h:51
unsigned int uint
Definition: uca9-dump.cc:75
static uint64_t cache_size
Definition: xcom_cache.cc:362