MySQL 8.0.39
Source Code Documentation
handler.h
Go to the documentation of this file.
1#ifndef HANDLER_INCLUDED
2#define HANDLER_INCLUDED
3
4/*
5 Copyright (c) 2000, 2024, Oracle and/or its affiliates.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License, version 2.0,
9 as published by the Free Software Foundation.
10
11 This program is designed to work with certain software (including
12 but not limited to OpenSSL) that is licensed under separate terms,
13 as designated in a particular file or component or in included license
14 documentation. The authors of MySQL hereby grant you an additional
15 permission to link the program and your derivative works with the
16 separately licensed software that they have either included with
17 the program or referenced in the documentation.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License, version 2.0, for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27*/
28
29/* Definitions for parameters to do with handler-routines */
30
31#include <fcntl.h>
32#include <float.h>
33#include <string.h>
34#include <sys/types.h>
35#include <time.h>
36#include <algorithm>
37#include <bitset>
38#include <functional>
39#include <map>
40#include <optional>
41#include <random> // std::mt19937
42#include <set>
43#include <string>
44#include <string_view>
45
47#include "ft_global.h" // ft_hints
48#include "lex_string.h"
49#include "m_ctype.h"
50#include "map_helpers.h"
51#include "my_alloc.h"
52#include "my_base.h"
53#include "my_bitmap.h"
54#include "my_checksum.h" // ha_checksum
55#include "my_compiler.h"
56#include "my_dbug.h"
57#include "my_double2ulonglong.h"
58#include "my_inttypes.h"
59#include "my_io.h"
60#include "my_sys.h"
61#include "my_table_map.h"
62#include "my_thread_local.h" // my_errno
64#include "sql/dd/object_id.h" // dd::Object_id
65#include "sql/dd/string_type.h"
66#include "sql/dd/types/object_table.h" // dd::Object_table
67#include "sql/discrete_interval.h" // Discrete_interval
68#include "sql/key.h"
69#include "sql/sql_const.h" // SHOW_COMP_OPTION
70#include "sql/sql_list.h" // SQL_I_List
71#include "sql/sql_plugin_ref.h" // plugin_ref
72#include "thr_lock.h" // thr_lock_type
73#include "typelib.h"
74
75class Alter_info;
76class Create_field;
77class Field;
78class Item;
79class JOIN;
80class Json_dom;
82class Plugin_table;
84class Record_buffer;
85class SE_cost_constants; // see opt_costconstants.h
86class String;
87class THD;
88class handler;
89class partition_info;
91
92namespace dd {
93class Properties;
94} // namespace dd
95struct AccessPath;
96struct JoinHypergraph;
97struct KEY_CACHE;
98struct LEX;
99struct MY_BITMAP;
100struct SAVEPOINT;
101struct TABLE;
102class Table_ref;
103struct TABLE_SHARE;
104struct Tablespace_options;
105struct handlerton;
106
107typedef struct xid_t XID;
109struct MDL_key;
110
111namespace dd {
112enum class enum_column_types;
113class Table;
114class Tablespace;
115} // namespace dd
116
117constexpr const ha_rows EXTRA_RECORDS{10};
118
119/** Id for identifying Table SDIs */
120constexpr const uint32 SDI_TYPE_TABLE = 1;
121
122/** Id for identifying Tablespace SDIs */
123constexpr const uint32 SDI_TYPE_TABLESPACE = 2;
124
125/** Key to identify a dictionary object */
126struct sdi_key_t {
127 /** Type of Object, For ex: column, index, etc */
129
130 /** Object id which should be unique in tablespsace */
132};
133
134using sdi_container = std::vector<sdi_key_t>;
137};
138
139typedef bool (*qc_engine_callback)(THD *thd, const char *table_key,
140 uint key_length, ulonglong *engine_data);
141
142typedef bool(stat_print_fn)(THD *thd, const char *type, size_t type_len,
143 const char *file, size_t file_len,
144 const char *status, size_t status_len);
145
146class ha_statistics;
148class Unique_on_insert;
149
150extern ulong savepoint_alloc_size;
151
152/// Maps from slot to plugin. May return NULL if plugin has been unloaded.
154/// Returns the size of the array holding pointers to plugins.
155size_t num_hton2plugins();
156
157/**
158 For unit testing.
159 Insert plugin into arbitrary slot in array.
160 Remove plugin from arbitrary slot in array.
161*/
164
165extern const char *ha_row_type[];
166extern const char *tx_isolation_names[];
167extern const char *binlog_format_names[];
169extern ulong total_ha_2pc;
170
171// the following is for checking tables
172
173#define HA_ADMIN_ALREADY_DONE 1
174#define HA_ADMIN_OK 0
175#define HA_ADMIN_NOT_IMPLEMENTED -1
176#define HA_ADMIN_FAILED -2
177#define HA_ADMIN_CORRUPT -3
178#define HA_ADMIN_INTERNAL_ERROR -4
179#define HA_ADMIN_INVALID -5
180#define HA_ADMIN_REJECT -6
181#define HA_ADMIN_TRY_ALTER -7
182#define HA_ADMIN_WRONG_CHECKSUM -8
183#define HA_ADMIN_NOT_BASE_TABLE -9
184#define HA_ADMIN_NEEDS_UPGRADE -10
185#define HA_ADMIN_NEEDS_ALTER -11
186#define HA_ADMIN_NEEDS_CHECK -12
187#define HA_ADMIN_STATS_UPD_ERR -13
188/** User needs to dump and re-create table to fix pre 5.0 decimal types */
189#define HA_ADMIN_NEEDS_DUMP_UPGRADE -14
190
191/**
192 Return values for check_if_supported_inplace_alter().
193
194 @see check_if_supported_inplace_alter() for description of
195 the individual values.
196*/
207
208/* Bits in table_flags() to show what database can do */
209
210#define HA_NO_TRANSACTIONS (1 << 0) /* Doesn't support transactions */
211#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
212/*
213 Used to avoid scanning full tables on an index. If this flag is set then
214 the handler always has a primary key (hidden if not defined) and this
215 index is used for scanning rather than a full table scan in all
216 situations. No separate data/index file.
217*/
218#define HA_TABLE_SCAN_ON_INDEX (1 << 2)
219
220/// Not in use.
221#define HA_UNUSED3 (1 << 3)
222
223/*
224 Can the storage engine handle spatial data.
225 Used to check that no spatial attributes are declared unless
226 the storage engine is capable of handling it.
227*/
228#define HA_CAN_GEOMETRY (1 << 4)
229/*
230 Reading keys in random order is as fast as reading keys in sort order
231 (Used by filesort to decide if we should sort key + data or key +
232 pointer-to-row.)
233*/
234#define HA_FAST_KEY_READ (1 << 5)
235/*
236 Set the following flag if we on delete should force all key to be read
237 and on update read all keys that changes
238*/
239#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
240/*
241 Is NULL values allowed in indexes.
242 If this is not allowed then it is not possible to use an index on a
243 NULLable field.
244*/
245#define HA_NULL_IN_KEY (1 << 7)
246/*
247 Tells that we can the position for the conflicting duplicate key
248 record is stored in table->file->dupp_ref. (insert uses rnd_pos() on
249 this to find the duplicated row)
250*/
251#define HA_DUPLICATE_POS (1 << 8)
252#define HA_NO_BLOBS (1 << 9) /* Doesn't support blobs */
253/*
254 Is the storage engine capable of defining an index of a prefix on
255 a BLOB attribute.
256*/
257#define HA_CAN_INDEX_BLOBS (1 << 10)
258/*
259 Auto increment fields can be part of a multi-part key. For second part
260 auto-increment keys, the auto_incrementing is done in handler.cc
261*/
262#define HA_AUTO_PART_KEY (1 << 11)
263/*
264 Can't define a table without primary key (and cannot handle a table
265 with hidden primary key)
266*/
267#define HA_REQUIRE_PRIMARY_KEY (1 << 12)
268/*
269 Does the counter of records after the info call specify an exact
270 value or not. If it does this flag is set.
271*/
272#define HA_STATS_RECORDS_IS_EXACT (1 << 13)
273/// Not in use.
274#define HA_UNUSED14 (1 << 14)
275/*
276 This parameter is set when the handler will also return the primary key
277 when doing read-only-key on another index, i.e., if we get the primary
278 key columns for free when we do an index read (usually, it also implies
279 that HA_PRIMARY_KEY_REQUIRED_FOR_POSITION flag is set).
280*/
281#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
282/*
283 If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
284 uses a primary key given by the record argument.
285 Without primary key, we can't call position().
286 If not set, the position is returned as the current rows position
287 regardless of what argument is given.
288*/
289#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
290#define HA_CAN_RTREEKEYS (1 << 17)
291/// Not in use.
292#define HA_UNUSED18
293/*
294 The following is we need to a primary key to delete (and update) a row.
295 If there is no primary key, all columns needs to be read on update and delete
296*/
297#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
298/*
299 Indexes on prefixes of character fields are not allowed.
300*/
301#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
302/*
303 Does the storage engine support fulltext indexes.
304*/
305#define HA_CAN_FULLTEXT (1 << 21)
306/*
307 Can the HANDLER interface in the MySQL API be used towards this
308 storage engine.
309*/
310#define HA_CAN_SQL_HANDLER (1 << 22)
311/*
312 Set if the storage engine does not support auto increment fields.
313*/
314#define HA_NO_AUTO_INCREMENT (1 << 23)
315/*
316 Supports CHECKSUM option in CREATE TABLE (MyISAM feature).
317*/
318#define HA_HAS_CHECKSUM (1 << 24)
319/*
320 Table data are stored in separate files (for lower_case_table_names).
321 Should file names always be in lower case (used by engines that map
322 table names to file names.
323*/
324#define HA_FILE_BASED (1 << 26)
325#define HA_NO_VARCHAR (1 << 27)
326/*
327 Is the storage engine capable of handling bit fields.
328*/
329#define HA_CAN_BIT_FIELD (1 << 28)
330#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
331#define HA_NO_COPY_ON_ALTER (1LL << 31)
332#define HA_COUNT_ROWS_INSTANT (1LL << 32) /* records() gives exact count*/
333/* Has it's own method of binlog logging */
334#define HA_HAS_OWN_BINLOGGING (1LL << 33)
335/*
336 Engine is capable of row-format and statement-format logging,
337 respectively
338*/
339#define HA_BINLOG_ROW_CAPABLE (1LL << 34)
340#define HA_BINLOG_STMT_CAPABLE (1LL << 35)
341/*
342 When a multiple key conflict happens in a REPLACE command mysql
343 expects the conflicts to be reported in the ascending order of
344 key names.
345
346 For e.g.
347
348 CREATE TABLE t1 (a INT, UNIQUE (a), b INT NOT NULL, UNIQUE (b), c INT NOT
349 NULL, INDEX(c));
350
351 REPLACE INTO t1 VALUES (1,1,1),(2,2,2),(2,1,3);
352
353 MySQL expects the conflict with 'a' to be reported before the conflict with
354 'b'.
355
356 If the underlying storage engine does not report the conflicting keys in
357 ascending order, it causes unexpected errors when the REPLACE command is
358 executed.
359
360 This flag helps the underlying SE to inform the server that the keys are not
361 ordered.
362*/
363#define HA_DUPLICATE_KEY_NOT_IN_ORDER (1LL << 36)
364/*
365 Engine supports REPAIR TABLE. Used by CHECK TABLE FOR UPGRADE if an
366 incompatible table is detected. If this flag is set, CHECK TABLE FOR UPGRADE
367 will report ER_TABLE_NEEDS_UPGRADE, otherwise ER_TABLE_NEED_REBUILD.
368*/
369#define HA_CAN_REPAIR (1LL << 37)
370
371/*
372 Set of all binlog flags. Currently only contain the capabilities
373 flags.
374 */
375#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
376
377/**
378 The handler supports read before write removal optimization
379
380 Read before write removal may be used for storage engines which support
381 write without previous read of the row to be updated. Handler returning
382 this flag must implement start_read_removal() and end_read_removal().
383 The handler may return "fake" rows constructed from the key of the row
384 asked for. This is used to optimize UPDATE and DELETE by reducing the
385 number of round-trips between handler and storage engine.
386
387 Example:
388 UPDATE a=1 WHERE pk IN (@<keys@>)
389
390 @verbatim
391 mysql_update()
392 {
393 if (<conditions for starting read removal>)
394 start_read_removal()
395 -> handler returns true if read removal supported for this table/query
396
397 while(read_record("pk=<key>"))
398 -> handler returns fake row with column "pk" set to <key>
399
400 ha_update_row()
401 -> handler sends write "a=1" for row with "pk=<key>"
402
403 end_read_removal()
404 -> handler returns the number of rows actually written
405 }
406 @endverbatim
407
408 @note This optimization in combination with batching may be used to
409 remove even more round-trips.
410*/
411#define HA_READ_BEFORE_WRITE_REMOVAL (1LL << 38)
412
413/*
414 Engine supports extended fulltext API
415 */
416#define HA_CAN_FULLTEXT_EXT (1LL << 39)
417
418/*
419 Storage engine doesn't synchronize result set with expected table contents.
420 Used by replication slave to check if it is possible to retrieve rows from
421 the table when deciding whether to do a full table scan, index scan or hash
422 scan while applying a row event.
423 */
424#define HA_READ_OUT_OF_SYNC (1LL << 40)
425
426/*
427 Storage engine supports table export using the
428 FLUSH TABLE <table_list> FOR EXPORT statement.
429 */
430#define HA_CAN_EXPORT (1LL << 41)
431
432/*
433 The handler don't want accesses to this table to
434 be const-table optimized
435*/
436#define HA_BLOCK_CONST_TABLE (1LL << 42)
437
438/*
439 Handler supports FULLTEXT hints
440*/
441#define HA_CAN_FULLTEXT_HINTS (1LL << 43)
442
443/**
444 Storage engine doesn't support LOCK TABLE ... READ LOCAL locks
445 but doesn't want to use handler::store_lock() API for upgrading
446 them to LOCK TABLE ... READ locks, for example, because it doesn't
447 use THR_LOCK locks at all.
448*/
449#define HA_NO_READ_LOCAL_LOCK (1LL << 44)
450
451/**
452 A storage engine is compatible with the attachable transaction requirements
453 means that
454
455 - either SE detects the fact that THD::ha_data was reset and starts a new
456 attachable transaction, closes attachable transaction on close_connection
457 and resumes regular (outer) transaction when THD::ha_data is restored;
458
459 - or SE completely ignores THD::ha_data and close_connection like MyISAM
460 does.
461*/
462#define HA_ATTACHABLE_TRX_COMPATIBLE (1LL << 45)
463
464/**
465 Handler supports Generated Columns
466*/
467#define HA_GENERATED_COLUMNS (1LL << 46)
468
469/**
470 Supports index on virtual generated column
471*/
472#define HA_CAN_INDEX_VIRTUAL_GENERATED_COLUMN (1LL << 47)
473
474/**
475 Supports descending indexes
476*/
477#define HA_DESCENDING_INDEX (1LL << 48)
478
479/**
480 Supports partial update of BLOB columns.
481*/
482#define HA_BLOB_PARTIAL_UPDATE (1LL << 49)
483
484/**
485 If this isn't defined, only columns/indexes with Cartesian coordinate systems
486 (projected SRS or SRID 0) is supported. Columns/indexes without SRID
487 restriction is also supported if this isn't defined.
488*/
489#define HA_SUPPORTS_GEOGRAPHIC_GEOMETRY_COLUMN (1LL << 50)
490
491/**
492 Handler supports expressions as DEFAULT for a column.
493*/
494#define HA_SUPPORTS_DEFAULT_EXPRESSION (1LL << 51)
495
496/**
497 Handlers with this flag set do not support UPDATE operations.
498*/
499#define HA_UPDATE_NOT_SUPPORTED (1LL << 52)
500
501/**
502 Handlers with this flag set do not support DELETE operations.
503*/
504#define HA_DELETE_NOT_SUPPORTED (1LL << 53)
505
506/**
507 The storage engine does not support using indexes for access. Indexes can only
508 be used for estimating cost.
509*/
510#define HA_NO_INDEX_ACCESS (1LL << 54)
511
512/**
513 Supports multi-valued index
514*/
515#define HA_MULTI_VALUED_KEY_SUPPORT (1LL << 55)
516
517/*
518 Bits in index_flags(index_number) for what you can do with index.
519 If you do not implement indexes, just return zero here.
520*/
521/*
522 Does the index support read next, this is assumed in the server
523 code and never checked so all indexes must support this.
524 Note that the handler can be used even if it doesn't have any index.
525*/
526#define HA_READ_NEXT 1 /* TODO really use this flag */
527/*
528 Can the index be used to scan backwards (supports ::index_prev).
529*/
530#define HA_READ_PREV 2
531/*
532 Can the index deliver its record in index order. Typically true for
533 all ordered indexes and not true for hash indexes. Used to set keymap
534 part_of_sortkey.
535 This keymap is only used to find indexes usable for resolving an ORDER BY
536 in the query. Thus in most cases index_read will work just fine without
537 order in result production. When this flag is set it is however safe to
538 order all output started by index_read since most engines do this. With
539 read_multi_range calls there is a specific flag setting order or not
540 order so in those cases ordering of index output can be avoided.
541*/
542#define HA_READ_ORDER 4
543/*
544 Specify whether index can handle ranges, typically true for all
545 ordered indexes and not true for hash indexes.
546 Used by optimiser to check if ranges (as key >= 5) can be optimised
547 by index.
548*/
549#define HA_READ_RANGE 8
550/*
551 Can't use part key searches. This is typically true for hash indexes
552 and typically not true for ordered indexes.
553*/
554#define HA_ONLY_WHOLE_INDEX 16
555/*
556 Index does not store NULL values, even if the column is nullable.
557 (KEY::flags may still contain HA_NULL_PART_KEY)
558 If the key has a NULL-value, the handler need to do a full table scan
559 instead of using this key. This is typically true for NDB hash indexes.
560*/
561#define HA_TABLE_SCAN_ON_NULL 32
562/*
563 Does the storage engine support index-only scans on this index.
564 Enables use of HA_EXTRA_KEYREAD and HA_EXTRA_NO_KEYREAD
565 Used to set Key_map keys_for_keyread and to check in optimiser for
566 index-only scans. When doing a read under HA_EXTRA_KEYREAD the handler
567 only have to fill in the columns the key covers. If
568 HA_PRIMARY_KEY_IN_READ_INDEX is set then also the PRIMARY KEY columns
569 must be updated in the row.
570*/
571#define HA_KEYREAD_ONLY 64
572/*
573 Index scan will not return records in rowid order. Not guaranteed to be
574 set for unordered (e.g. HASH) indexes.
575*/
576#define HA_KEY_SCAN_NOT_ROR 128
577#define HA_DO_INDEX_COND_PUSHDOWN 256 /* Supports Index Condition Pushdown */
578
579/* operations for disable/enable indexes */
580#define HA_KEY_SWITCH_NONUNIQ 0
581#define HA_KEY_SWITCH_ALL 1
582#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
583#define HA_KEY_SWITCH_ALL_SAVE 3
584
585/*
586 Use this instead of 0 as the initial value for the slot number of
587 handlerton, so that we can distinguish uninitialized slot number
588 from slot 0.
589*/
590#define HA_SLOT_UNDEF ((uint)-1)
591
592/*
593 Parameters for open() (in register form->filestat)
594 HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
595*/
596
597#define HA_OPEN_KEYFILE 1
598#define HA_OPEN_RNDFILE 2
599#define HA_GET_INDEX 4
600#define HA_GET_INFO 8 /* do a handler::info() after open */
601#define HA_READ_ONLY 16 /* File opened as readonly */
602/* Try readonly if can't open with read and write */
603#define HA_TRY_READ_ONLY 32
604#define HA_WAIT_IF_LOCKED 64 /* Wait if locked on open */
605#define HA_ABORT_IF_LOCKED 128 /* skip if locked on open.*/
606#define HA_BLOCK_LOCK 256 /* unlock when reading some records */
607#define HA_OPEN_TEMPORARY 512
608
609/* Some key definitions */
610#define HA_KEY_NULL_LENGTH 1
611#define HA_KEY_BLOB_LENGTH 2
612
613#define HA_LEX_CREATE_TMP_TABLE 1
614#define HA_LEX_CREATE_IF_NOT_EXISTS 2
615#define HA_LEX_CREATE_TABLE_LIKE 4
616#define HA_LEX_CREATE_INTERNAL_TMP_TABLE 8
617#define HA_MAX_REC_LENGTH 65535U
618
619/**
620 Options for the START TRANSACTION statement.
621
622 Note that READ ONLY and READ WRITE are logically mutually exclusive.
623 This is enforced by the parser and depended upon by trans_begin().
624
625 We need two flags instead of one in order to differentiate between
626 situation when no READ WRITE/ONLY clause were given and thus transaction
627 is implicitly READ WRITE and the case when READ WRITE clause was used
628 explicitly.
629*/
630
631// WITH CONSISTENT SNAPSHOT option
633// READ ONLY option
635// READ WRITE option
637// HIGH PRIORITY option
639
661 DB_TYPE_PARTITION_DB, // No longer used.
669 /** Performance schema engine. */
673 DB_TYPE_DEFAULT = 127 // Must be last
675
676enum row_type : int {
684 /** Unused. Reserved for future versions. */
687
696
705};
706
708
709/* Bits in used_fields */
710#define HA_CREATE_USED_AUTO (1L << 0)
711#define HA_CREATE_USED_RAID (1L << 1) // RAID is no longer available
712#define HA_CREATE_USED_UNION (1L << 2)
713#define HA_CREATE_USED_INSERT_METHOD (1L << 3)
714#define HA_CREATE_USED_MIN_ROWS (1L << 4)
715#define HA_CREATE_USED_MAX_ROWS (1L << 5)
716#define HA_CREATE_USED_AVG_ROW_LENGTH (1L << 6)
717#define HA_CREATE_USED_PACK_KEYS (1L << 7)
718#define HA_CREATE_USED_CHARSET (1L << 8)
719#define HA_CREATE_USED_DEFAULT_CHARSET (1L << 9)
720#define HA_CREATE_USED_DATADIR (1L << 10)
721#define HA_CREATE_USED_INDEXDIR (1L << 11)
722#define HA_CREATE_USED_ENGINE (1L << 12)
723#define HA_CREATE_USED_CHECKSUM (1L << 13)
724#define HA_CREATE_USED_DELAY_KEY_WRITE (1L << 14)
725#define HA_CREATE_USED_ROW_FORMAT (1L << 15)
726#define HA_CREATE_USED_COMMENT (1L << 16)
727#define HA_CREATE_USED_PASSWORD (1L << 17)
728#define HA_CREATE_USED_CONNECTION (1L << 18)
729#define HA_CREATE_USED_KEY_BLOCK_SIZE (1L << 19)
730/** Unused. Reserved for future versions. */
731#define HA_CREATE_USED_TRANSACTIONAL (1L << 20)
732/** Unused. Reserved for future versions. */
733#define HA_CREATE_USED_PAGE_CHECKSUM (1L << 21)
734/** This is set whenever STATS_PERSISTENT=0|1|default has been
735specified in CREATE/ALTER TABLE. See also HA_OPTION_STATS_PERSISTENT in
736include/my_base.h. It is possible to distinguish whether
737STATS_PERSISTENT=default has been specified or no STATS_PERSISTENT= is
738given at all. */
739#define HA_CREATE_USED_STATS_PERSISTENT (1L << 22)
740/**
741 This is set whenever STATS_AUTO_RECALC=0|1|default has been
742 specified in CREATE/ALTER TABLE. See enum_stats_auto_recalc.
743 It is possible to distinguish whether STATS_AUTO_RECALC=default
744 has been specified or no STATS_AUTO_RECALC= is given at all.
745*/
746#define HA_CREATE_USED_STATS_AUTO_RECALC (1L << 23)
747/**
748 This is set whenever STATS_SAMPLE_PAGES=N|default has been
749 specified in CREATE/ALTER TABLE. It is possible to distinguish whether
750 STATS_SAMPLE_PAGES=default has been specified or no STATS_SAMPLE_PAGES= is
751 given at all.
752*/
753#define HA_CREATE_USED_STATS_SAMPLE_PAGES (1L << 24)
754
755/**
756 This is set whenever a 'TABLESPACE=...' phrase is used on CREATE TABLE
757*/
758#define HA_CREATE_USED_TABLESPACE (1L << 25)
759
760/** COMPRESSION="zlib|lz4|none" used during table create. */
761#define HA_CREATE_USED_COMPRESS (1L << 26)
762
763/** ENCRYPTION="Y" used during table create. */
764#define HA_CREATE_USED_ENCRYPT (1L << 27)
765
766/**
767 CREATE|ALTER SCHEMA|DATABASE|TABLE has an explicit COLLATE clause.
768
769 Implies HA_CREATE_USED_DEFAULT_CHARSET.
770*/
771#define HA_CREATE_USED_DEFAULT_COLLATE (1L << 28)
772
773/** SECONDARY_ENGINE used during table create. */
774#define HA_CREATE_USED_SECONDARY_ENGINE (1L << 29)
775
776/**
777 CREATE|ALTER SCHEMA|DATABASE has an explicit ENCRYPTION clause.
778
779 Implies HA_CREATE_USED_DEFAULT_ENCRYPTION.
780*/
781#define HA_CREATE_USED_DEFAULT_ENCRYPTION (1L << 30)
782
783/**
784 This option is used to convey that the create table should not
785 commit the operation and keep the transaction started.
786*/
787constexpr const uint64_t HA_CREATE_USED_START_TRANSACTION{1ULL << 31};
788
789constexpr const uint64_t HA_CREATE_USED_ENGINE_ATTRIBUTE{1ULL << 32};
790constexpr const uint64_t HA_CREATE_USED_SECONDARY_ENGINE_ATTRIBUTE{1ULL << 33};
791
792/**
793 ALTER SCHEMA|DATABASE has an explicit READ_ONLY clause.
794
795 Implies HA_CREATE_USED_READ_ONLY.
796*/
797constexpr const uint64_t HA_CREATE_USED_READ_ONLY{1ULL << 34};
798
799/**
800 These flags convey that the options AUTOEXTEND_SIZE has been
801 specified in the CREATE TABLE statement
802*/
803constexpr const uint64_t HA_CREATE_USED_AUTOEXTEND_SIZE{1ULL << 35};
804
805/*
806 End of bits used in used_fields
807*/
808
809/*
810 Structure to hold list of database_name.table_name.
811 This is used at both mysqld and storage engine layer.
812*/
814 const char *db;
815 const char *tablename;
816};
817
818#define MAXGTRIDSIZE 64
819#define MAXBQUALSIZE 64
820
821#define COMPATIBLE_DATA_YES 0
822#define COMPATIBLE_DATA_NO 1
823
824/*
825 These structures are used to pass information from a set of SQL commands
826 on add/drop/change tablespace definitions to the proper hton.
827*/
828#define UNDEF_NODEGROUP 65535
829
830// FUTURE: Combine these two enums into one enum class
845
855
856/**
857 Legacy struct for passing tablespace information to SEs.
858
859 FUTURE: Pass all info through dd objects
860 */
862 public:
863 const char *tablespace_name = nullptr;
864 const char *logfile_group_name = nullptr;
868 const char *data_file_name = nullptr;
869 const char *undo_file_name = nullptr;
870 ulonglong extent_size = 1024 * 1024; // Default 1 MByte
871 ulonglong undo_buffer_size = 8 * 1024 * 1024; // Default 8 MByte
872 ulonglong redo_buffer_size = 8 * 1024 * 1024; // Default 8 MByte
873 ulonglong initial_size = 128 * 1024 * 1024; // Default 128 MByte
874 std::optional<ulonglong> autoextend_size; // No autoextension as default
875 ulonglong max_size = 0; // Max size == initial size => no extension
876 ulonglong file_block_size = 0; // 0=default or must be a valid Page Size
879 const char *ts_comment = nullptr;
880 const char *encryption = nullptr;
881
883 return ts_cmd_type == CREATE_TABLESPACE ||
887 }
888
889 /**
890 Proper constructor even for all-public class simplifies initialization and
891 allows members to be const.
892
893 FUTURE: With constructor all members can be made const, and do not need
894 default initializers.
895
896 @param tablespace name of tabelspace (nullptr for logfile group statements)
897 @param logfile_group name of logfile group or nullptr
898 @param cmd main statement type
899 @param alter_tablespace_cmd subcommand type for ALTER TABLESPACE
900 @param datafile tablespace file for CREATE and ALTER ... ADD ...
901 @param undofile only applies to logfile group statements. nullptr otherwise.
902 @param opts options provided by parser
903 */
904 st_alter_tablespace(const char *tablespace, const char *logfile_group,
905 ts_command_type cmd,
906 enum ts_alter_tablespace_type alter_tablespace_cmd,
907 const char *datafile, const char *undofile,
908 const Tablespace_options &opts);
909};
910
911/*
912 Make sure that the order of schema_tables and enum_schema_tables are the same.
913*/
931
934enum ha_ddl_type : int {
940
941/** Clone start operation mode */
943 /** Start a new clone operation */
945
946 /** Re-start a clone operation after failure */
948
949 /** Add a new task to a running clone operation */
951
952 /** Get version for transfer data format */
954
955 /** Max value for clone mode */
958
959/** Clone operation types. */
960enum Ha_clone_type : size_t {
961 /** Caller must block all write operation to the SE. */
963
964 /** For transactional SE, archive redo to support concurrent dml */
966
967 /** For transactional SE, track page changes to support concurrent dml */
969
970 /** For transactional SE, use both page tracking and redo to optimize
971 clone with concurrent dml. Currently supported by Innodb. */
973
974 /** SE supports multiple threads for clone */
976
977 /** SE supports restarting clone after network failure */
979
980 /** Maximum value of clone type */
983
984using Ha_clone_flagset = std::bitset<HA_CLONE_TYPE_MAX>;
985
988
989/** File reference for clone */
991 /** File reference type */
992 enum {
993 /** File handle */
995
996 /** File descriptor */
998
1000
1001 /** File reference */
1002 union {
1003 /** File descriptor */
1005
1006 /** File handle for windows */
1008 };
1009};
1010
1011/* Abstract callback interface to stream data back to the caller. */
1013 protected:
1014 /** Constructor to initialize members. */
1016 : m_hton(),
1017 m_loc_idx(),
1019 m_data_desc(),
1020 m_desc_len(),
1021 m_src_name(),
1022 m_dest_name(),
1024 m_flag() {}
1025
1026 public:
1027 /** Callback providing data from current position of a
1028 file descriptor of specific length.
1029 @param[in] from_file source file to read from
1030 @param[in] len data length
1031 @return error code */
1032 virtual int file_cbk(Ha_clone_file from_file, uint len) = 0;
1033
1034 /** Callback providing data in buffer of specific length.
1035 @param[in] from_buffer source buffer to read from
1036 @param[in] len data length
1037 @return error code */
1038 virtual int buffer_cbk(uchar *from_buffer, uint len) = 0;
1039
1040 /** Callback providing a file descriptor to write data starting
1041 from current position.
1042 @param[in] to_file destination file to write data
1043 @return error code */
1044 virtual int apply_file_cbk(Ha_clone_file to_file) = 0;
1045
1046 /** Callback to get data in buffer.
1047 @param[out] to_buffer data buffer
1048 @param[out] len data length
1049 @return error code */
1050 virtual int apply_buffer_cbk(uchar *&to_buffer, uint &len) = 0;
1051
1052 /** virtual destructor. */
1053 virtual ~Ha_clone_cbk() = default;
1054
1055 /** Set current storage engine handlerton.
1056 @param[in] hton SE handlerton */
1057 void set_hton(handlerton *hton) { m_hton = hton; }
1058
1059 /** Get current storage engine handlerton.
1060 @return SE handlerton */
1061 handlerton *get_hton() { return (m_hton); }
1062
1063 /** Set caller's transfer buffer size. SE can adjust the data chunk size
1064 based on this parameter.
1065 @param[in] size buffer size in bytes */
1067
1068 /** Get caller's transfer buffer size.
1069 @return buffer size in bytes */
1071
1072 /** Set current SE index.
1073 @param[in] idx SE index in locator array */
1074 void set_loc_index(uint idx) { m_loc_idx = idx; }
1075
1076 /** Get current SE index.
1077 @return SE index in locator array */
1079
1080 /** Set data descriptor. SE specific descriptor for the
1081 data transferred by the callbacks.
1082 @param[in] desc serialized data descriptor
1083 @param[in] len length of the descriptor byte stream */
1084 void set_data_desc(const uchar *desc, uint len) {
1085 m_data_desc = desc;
1086 m_desc_len = len;
1087 }
1088
1089 /** Get data descriptor. SE specific descriptor for the
1090 data transferred by the callbacks.
1091 @param[out] lenp length of the descriptor byte stream
1092 @return pointer to the serialized data descriptor */
1093 const uchar *get_data_desc(uint *lenp) {
1094 if (lenp != nullptr) {
1095 *lenp = m_desc_len;
1096 }
1097
1098 return (m_data_desc);
1099 }
1100
1101 /** Get SE source file name. Used for debug printing and error message.
1102 @return null terminated string for source file name */
1103 const char *get_source_name() { return (m_src_name); }
1104
1105 /** Set SE source file name.
1106 @param[in] name null terminated string for source file name */
1107 void set_source_name(const char *name) { m_src_name = name; }
1108
1109 /** Get SE destination file name. Used for debug printing and error message.
1110 @return null terminated string for destination file name */
1111 const char *get_dest_name() { return (m_dest_name); }
1112
1113 /** Set SE destination file name.
1114 @param[in] name null terminated string for destination file name */
1115 void set_dest_name(const char *name) { m_dest_name = name; }
1116
1117 /** Clear all flags set by SE */
1118 void clear_flags() { m_flag = 0; }
1119
1120 /** Mark that ACK is needed for the data transfer before returning
1121 from callback. Set by SE. */
1123
1124 /** Check if ACK is needed for the data transfer
1125 @return true if ACK is needed */
1126 bool is_ack_needed() const { return (m_flag & HA_CLONE_ACK); }
1127
1128 /** Mark that the file descriptor is opened for read/write
1129 with OS buffer cache. For O_DIRECT, the flag is not set. */
1131
1132 /** Check if the file descriptor is opened for read/write with OS
1133 buffer cache. Currently clone avoids using zero copy (sendfile on linux),
1134 if SE is using O_DIRECT. This improves data copy performance.
1135 @return true if O_DIRECT is not used */
1136 bool is_os_buffer_cache() const { return (m_flag & HA_CLONE_FILE_CACHE); }
1137
1138 /** Mark that the file can be transferred with zero copy. */
1140
1141 /** Check if zero copy optimization is suggested. */
1142 bool is_zero_copy() const { return (m_flag & HA_CLONE_ZERO_COPY); }
1143
1144 /** Mark that data needs secure transfer. */
1146
1147 /** Check if data needs secure transfer. */
1148 bool is_secure() const { return (m_flag & HA_CLONE_SECURE); }
1149
1150 /** Set state information and notify state change.
1151 @param[in] estimate estimated bytes for current state. */
1152 void mark_state_change(uint64_t estimate) {
1154 m_state_estimate = estimate;
1155 }
1156
1157 /** Check if SE notified state change. */
1158 bool is_state_change(uint64_t &estimate) {
1159 estimate = m_state_estimate;
1160 return (m_flag & HA_CLONE_STATE_CHANGE);
1161 }
1162
1163 private:
1164 /** Handlerton for the SE */
1166
1167 /** SE index in caller's locator array */
1169
1170 /** Caller's transfer buffer size. */
1172
1173 /** SE's Serialized data descriptor */
1175
1176 /** SE's Serialized descriptor length. */
1178
1179 /** Current source file name */
1180 const char *m_src_name;
1181
1182 /** Current destination file name */
1183 const char *m_dest_name;
1184
1185 /** Estimated bytes to be transferred. */
1187
1188 /** Flag storing data related options */
1190
1191 /** Acknowledgement is needed for the data transfer. */
1192 const int HA_CLONE_ACK = 0x01;
1193
1194 /** Data file is opened for read/write with OS buffer cache. */
1195 const int HA_CLONE_FILE_CACHE = 0x02;
1196
1197 /** Data file can be transferred with zero copy. */
1198 const int HA_CLONE_ZERO_COPY = 0x04;
1199
1200 /** Data needs to be transferred securely over SSL connection. */
1201 const int HA_CLONE_SECURE = 0x08;
1202
1203 /** State change notification by SE. */
1204 const int HA_CLONE_STATE_CHANGE = 0x10;
1205};
1206
1207/**
1208 Column type description for foreign key columns compatibility check.
1209
1210 Contains subset of information from dd::Column class. It is inconvenient
1211 to use dd::Column class directly for such checks because it requires valid
1212 dd::Table object and in some cases we want to produce Ha_fk_column_type
1213 right from column description in Create_field format.
1214*/
1217 /*
1218 Note that both dd::Column::char_length() and length here are really
1219 in bytes.
1220 */
1226};
1227
1228typedef ulonglong my_xid; // this line is the same as in log_event.h
1229/**
1230 Enumeration of possible states for externally coordinated transactions (XA).
1231 */
1233 NOT_FOUND = -1, // Trnasaction not found
1234 PREPARED_IN_SE = 0, // Transaction is prepared in SEs
1235 PREPARED_IN_TC = 1, // Transaction is prepared in SEs and TC
1236 COMMITTED_WITH_ONEPHASE = 2, // Transaction was one-phase committed
1237 COMMITTED = 3, // Transaction was committed
1238 ROLLEDBACK = 4 // Transaction was rolled back
1239};
1240/**
1241 Single occurrence set of XIDs of internally coordinated transactions
1242 found as been committed in the transaction coordinator state.
1243 */
1245 std::unordered_set<my_xid, std::hash<my_xid>, std::equal_to<my_xid>,
1247
1248/**
1249 Class to maintain list of externally coordinated transactions and their
1250 current state at recovery.
1251 */
1253 public:
1254 using pair = std::pair<const XID, enum_ha_recover_xa_state>;
1256 using list = std::map<XID, enum_ha_recover_xa_state, std::less<XID>,
1258 using iterator = std::map<XID, enum_ha_recover_xa_state, std::less<XID>,
1260 using instantiation_tuple = std::tuple<
1261 std::unique_ptr<MEM_ROOT>, std::unique_ptr<Xa_state_list::allocator>,
1262 std::unique_ptr<Xa_state_list::list>, std::unique_ptr<Xa_state_list>>;
1263
1264 /**
1265 Class constructor.
1266
1267 @param populated_by_tc The underlying list of XIDs and transaction
1268 states, after being populated by the transaction
1269 coodinator.
1270 */
1271 Xa_state_list(Xa_state_list::list &populated_by_tc);
1272 virtual ~Xa_state_list() = default;
1273
1274 /**
1275 Searches the underlying map to find an key that corresponds to the
1276 parameter.
1277
1278 @param to_find The XID to find within the underlying map.
1279
1280 @return Ha_recover_states::NOT_FOUND if the transaction wasn't found,
1281 the state of the transaction, otherwise.
1282 */
1283 enum_ha_recover_xa_state find(XID const &to_find);
1284 /**
1285 Adds a transaction and state to the underlying map. If the given XID
1286 already exists in the underlying map, the associated state changes according
1287 to the following rules:
1288
1289 - If the parameter state is `PREPARED_IN_SE` it means that the
1290 transaction didn't reach PREPARED_IN_TC, COMMIT or ROLLBACK for
1291 sure. In that case:
1292 . If other participants state is `COMMITTED`/`ROLLEDBACK`, it would
1293 mean that it's a state inherited from a previous execution with the
1294 same XID and we should set the state to `PREPARED_IN_SE`.
1295 . If other participants state is `PREPARED_IN_TC`/
1296 `COMMITTED_WITH_ONEPHASE` it means that the current participant
1297 didn't reach it but some other did so, keep the state as
1298 `PREPARED_IN_TC`/`COMMITTED_WITH_ONEPHASE`.
1299
1300 - If the parameter state is `PREPARED_IN_TC`, it means that other
1301 participants must have persisted either the PREPARE, the COMMIT or
1302 the ROLLBACK. In that case, keep whatever state is already there and
1303 ensure that is not `PREPARED_IN_SE`.
1304
1305 - If the parameter state is `COMMITTED_WITH_ONEPHASE`, `COMMITTED` or
1306 `ROLLEDBACK`, do nothing, only the active transaction coordinator has
1307 the ability, for now, to set the transaction state to those values.
1308
1309 @param xid The XID to be added (the key).
1310 @param xid The state to be added (the value).
1311
1312 @return The current value of the transaction state if the XID has
1313 already been added, Ha_recover_states::NOT_FOUND otherwise.
1314 */
1316 /**
1317 Factory like method to instantiate all the infra-structure needed to
1318 create an `Xa_state_list`. Since such infra-structuer is dependent on
1319 `MEM_ROOT` and `Mem_root_allocator`, the method returns a tuple
1320 containing unique pointers to all 4 objects needed: MEM_ROOT;
1321 Mem_root_allocator; Xa_state_list::list; Xa_state_list.
1322
1323 @return An std::tuple containing unique pointers to all 4 objects
1324 needed: MEM_ROOT; Mem_root_allocator; Xa_state_list::list;
1325 Xa_state_list.
1326 */
1328
1329 private:
1330 /** The underlying map holding the trx and states*/
1332};
1333
1334/* handlerton methods */
1335
1336/**
1337 close_connection is only called if
1338 thd->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
1339 this storage area - set it to something, so that MySQL would know
1340 this storage engine was accessed in this connection
1341*/
1342typedef int (*close_connection_t)(handlerton *hton, THD *thd);
1343
1344/** Terminate connection/statement notification. */
1345typedef void (*kill_connection_t)(handlerton *hton, THD *thd);
1346
1347/**
1348 Shut down all storage engine background tasks that might access
1349 the data dictionary, before the main shutdown.
1350*/
1351typedef void (*pre_dd_shutdown_t)(handlerton *hton);
1352
1353/**
1354 sv points to a storage area, that was earlier passed
1355 to the savepoint_set call
1356*/
1357typedef int (*savepoint_rollback_t)(handlerton *hton, THD *thd, void *sv);
1358
1359/**
1360 sv points to an uninitialized storage area of requested size
1361 (see savepoint_offset description)
1362*/
1363typedef int (*savepoint_set_t)(handlerton *hton, THD *thd, void *sv);
1364
1365/**
1366 Check if storage engine allows to release metadata locks which were
1367 acquired after the savepoint if rollback to savepoint is done.
1368 @return true - If it is safe to release MDL locks.
1369 false - If it is not.
1370*/
1372 THD *thd);
1373
1374typedef int (*savepoint_release_t)(handlerton *hton, THD *thd, void *sv);
1375
1376/**
1377 'all' is true if it's a real commit, that makes persistent changes
1378 'all' is false if it's not in fact a commit but an end of the
1379 statement that is part of the transaction.
1380 NOTE 'all' is also false in auto-commit mode where 'end of statement'
1381 and 'real commit' mean the same event.
1382*/
1383typedef int (*commit_t)(handlerton *hton, THD *thd, bool all);
1384
1385typedef int (*rollback_t)(handlerton *hton, THD *thd, bool all);
1386
1387typedef int (*prepare_t)(handlerton *hton, THD *thd, bool all);
1388
1389typedef int (*recover_t)(handlerton *hton, XA_recover_txn *xid_list, uint len,
1391/**
1392 Retrieves information about externally coordinated transactions for which
1393 the two-phase prepare was finished and transactions were prepared in the
1394 server TC.
1395 */
1397 Xa_state_list &xa_list);
1398/**
1399 Instructs the storage engine to mark the externally coordinated
1400 transactions held by the THD parameters as prepared in the server TC.
1401 */
1402using set_prepared_in_tc_t = int (*)(handlerton *hton, THD *thd);
1403
1404/** X/Open XA distributed transaction status codes */
1406 /**
1407 normal execution
1408 */
1410
1411 /**
1412 asynchronous operation already outstanding
1413 */
1415
1416 /**
1417 a resource manager error occurred in the transaction branch
1418 */
1420
1421 /**
1422 the XID is not valid
1423 */
1425
1426 /**
1427 invalid arguments were given
1428 */
1430
1431 /**
1432 routine invoked in an improper context
1433 */
1435
1436 /**
1437 resource manager unavailable
1438 */
1440
1441 /**
1442 the XID already exists
1443 */
1445
1446 /**
1447 resource manager doing work outside transaction
1448 */
1449 XAER_OUTSIDE = -9
1451
1453
1455
1456/**
1457 Instructs the storage engine to mark the externally coordinated
1458 transactions identified by the XID parameters as prepared in the server
1459 TC.
1460 */
1462 XID *xid);
1463
1464/**
1465 Create handler object for the table in the storage engine.
1466
1467 @param hton Handlerton object for the storage engine.
1468 @param table TABLE_SHARE for the table, can be NULL if caller
1469 didn't perform full-blown open of table definition.
1470 @param partitioned Indicates whether table is partitioned.
1471 @param mem_root Memory root to be used for allocating handler
1472 object.
1473*/
1474typedef handler *(*create_t)(handlerton *hton, TABLE_SHARE *table,
1475 bool partitioned, MEM_ROOT *mem_root);
1476
1477typedef void (*drop_database_t)(handlerton *hton, char *path);
1478
1479typedef int (*panic_t)(handlerton *hton, enum ha_panic_function flag);
1480
1481typedef int (*start_consistent_snapshot_t)(handlerton *hton, THD *thd);
1482
1483/**
1484 Flush the log(s) of storage engine(s).
1485
1486 @param hton Handlerton of storage engine.
1487 @param binlog_group_flush true if we got invoked by binlog group
1488 commit during flush stage, false in other cases.
1489 @retval false Succeed
1490 @retval true Error
1491*/
1492typedef bool (*flush_logs_t)(handlerton *hton, bool binlog_group_flush);
1493
1494typedef bool (*show_status_t)(handlerton *hton, THD *thd, stat_print_fn *print,
1495 enum ha_stat_type stat);
1496
1497/**
1498 The flag values are defined in sql_partition.h.
1499 If this function is set, then it implies that the handler supports
1500 partitioned tables.
1501 If this function exists, then handler::get_partition_handler must also be
1502 implemented.
1503*/
1505
1506/**
1507 SE specific validation of the tablespace name.
1508
1509 This function will ask the relevant SE whether the submitted tablespace
1510 name is valid.
1511
1512 @param ts_cmd Purpose of usage - is this tablespace DDL?
1513 @param tablespace_name Name of the tablespace.
1514
1515 @return Tablespace name validity.
1516 @retval Whether the tablespace name is valid.
1517*/
1519 const char *tablespace_name);
1520
1521/**
1522 Get the tablespace name from the SE for the given schema and table.
1523
1524 @param thd Thread context.
1525 @param db_name Name of the relevant schema.
1526 @param table_name Name of the relevant table.
1527 @param [out] tablespace_name Name of the tablespace containing the table.
1528
1529 @return Operation status.
1530 @retval == 0 Success.
1531 @retval != 0 Error (handler error code returned).
1532*/
1535 LEX_CSTRING *tablespace_name);
1536
1537/**
1538 Create/drop or alter tablespace in the storage engine.
1539
1540 @param hton Hadlerton of the SE.
1541 @param thd Thread context.
1542 @param ts_info Description of tablespace and specific
1543 operation on it.
1544 @param old_ts_def dd::Tablespace object describing old version
1545 of tablespace.
1546 @param [in,out] new_ts_def dd::Tablespace object describing new version
1547 of tablespace. Engines which support atomic DDL
1548 can adjust this object. The updated information
1549 will be saved to the data-dictionary.
1550
1551 @return Operation status.
1552 @retval == 0 Success.
1553 @retval != 0 Error (handler error code returned).
1554*/
1555typedef int (*alter_tablespace_t)(handlerton *hton, THD *thd,
1556 st_alter_tablespace *ts_info,
1557 const dd::Tablespace *old_ts_def,
1558 dd::Tablespace *new_ts_def);
1559
1560/**
1561 SE interface for getting tablespace extension.
1562 @return Extension of tablespace datafile name.
1563*/
1564typedef const char *(*get_tablespace_filename_ext_t)();
1565
1566/**
1567 Get the tablespace data from SE and insert it into Data dictionary
1568
1569 @param thd Thread context
1570
1571 @return Operation status.
1572 @retval == 0 Success.
1573 @retval != 0 Error (handler error code returned)
1574*/
1575typedef int (*upgrade_tablespace_t)(THD *thd);
1576
1577/**
1578 Get the tablespace data from SE and insert it into Data dictionary
1579
1580 @param[in] tablespace tablespace object
1581
1582 @return Operation status.
1583 @retval == 0 Success.
1584 @retval != 0 Error (handler error code returned)
1585*/
1586typedef bool (*upgrade_space_version_t)(dd::Tablespace *tablespace);
1587
1588/**
1589 Finish upgrade process inside storage engines.
1590 This includes resetting flags to indicate upgrade process
1591 and cleanup after upgrade.
1592
1593 @param thd Thread context
1594 @param failed_upgrade True if the upgrade failed.
1595
1596 @return Operation status.
1597 @retval == 0 Success.
1598 @retval != 0 Error (handler error code returned)
1599*/
1600typedef int (*finish_upgrade_t)(THD *thd, bool failed_upgrade);
1601
1602/**
1603 Upgrade logs after the checkpoint from where upgrade
1604 process can only roll forward.
1605
1606 @param thd Thread context
1607
1608 @return Operation status.
1609 @retval == 0 Success.
1610 @retval != 0 Error (handler error code returned)
1611*/
1612typedef int (*upgrade_logs_t)(THD *thd);
1613
1621};
1622
1623/**
1624 Get the tablespace type from the SE.
1625
1626 @param[in] space tablespace object
1627 @param[out] space_type type of space
1628
1629 @return Operation status.
1630 @retval false on success and true for failure.
1631*/
1632typedef bool (*get_tablespace_type_t)(const dd::Tablespace &space,
1633 Tablespace_type *space_type);
1634
1635/**
1636 Get the tablespace type given the name, from the SE.
1637
1638 @param[in] tablespace_name tablespace name
1639 @param[out] space_type type of space
1640
1641 @return Operation status.
1642 @retval false on success and true for failure.
1643*/
1644typedef bool (*get_tablespace_type_by_name_t)(const char *tablespace_name,
1645 Tablespace_type *space_type);
1646
1647typedef int (*fill_is_table_t)(handlerton *hton, THD *thd, Table_ref *tables,
1648 class Item *cond, enum enum_schema_tables);
1649
1650typedef int (*binlog_func_t)(handlerton *hton, THD *thd, enum_binlog_func fn,
1651 void *arg);
1652
1653typedef void (*binlog_log_query_t)(handlerton *hton, THD *thd,
1654 enum_binlog_command binlog_command,
1655 const char *query, uint query_length,
1656 const char *db, const char *table_name);
1657
1658typedef void (*acl_notify_t)(THD *thd,
1659 const class Acl_change_notification *notice);
1660
1661typedef int (*discover_t)(handlerton *hton, THD *thd, const char *db,
1662 const char *name, uchar **frmblob, size_t *frmlen);
1663
1664typedef int (*find_files_t)(handlerton *hton, THD *thd, const char *db,
1665 const char *path, const char *wild, bool dir,
1666 List<LEX_STRING> *files);
1667
1668typedef int (*table_exists_in_engine_t)(handlerton *hton, THD *thd,
1669 const char *db, const char *name);
1670
1671/**
1672 Let storage engine inspect the query Accesspath and pick whatever
1673 it like for being pushed down to the engine. (Join, conditions, ..)
1674
1675 The handler implementation should itself keep track of what it 'pushed',
1676 such that later calls to the handlers access methods should
1677 activate the pushed parts of the execution plan on the storage
1678 engines.
1679
1680 @param thd Thread context
1681 @param query The AccessPath for the entire query.
1682 @param join The JOIN to be pushed
1683
1684 @returns
1685 0 on success
1686 error otherwise
1687*/
1688using push_to_engine_t = int (*)(THD *thd, AccessPath *query, JOIN *);
1689
1690/**
1691 Check if the given db.tablename is a system table for this SE.
1692
1693 @param db Database name to check.
1694 @param table_name table name to check.
1695 @param is_sql_layer_system_table if the supplied db.table_name is a SQL
1696 layer system table.
1697
1698 @see example_is_supported_system_table in ha_example.cc
1699
1700 is_sql_layer_system_table is supplied to make more efficient
1701 checks possible for SEs that support all SQL layer tables.
1702
1703 This interface is optional, so every SE need not implement it.
1704*/
1705typedef bool (*is_supported_system_table_t)(const char *db,
1706 const char *table_name,
1707 bool is_sql_layer_system_table);
1708
1709/**
1710 Create SDI in a tablespace. This API should be used when upgrading
1711 a tablespace with no SDI or after invoking sdi_drop().
1712 @param[in] tablespace tablespace object
1713 @retval false success
1714 @retval true failure
1715*/
1716typedef bool (*sdi_create_t)(dd::Tablespace *tablespace);
1717
1718/**
1719 Drop SDI in a tablespace. This API should be used only when
1720 SDI is corrupted.
1721 @param[in] tablespace tablespace object
1722 @retval false success
1723 @retval true failure
1724*/
1725typedef bool (*sdi_drop_t)(dd::Tablespace *tablespace);
1726
1727/**
1728 Get the SDI keys in a tablespace into vector.
1729 @param[in] tablespace tablespace object
1730 @param[in,out] vector vector of SDI Keys
1731 @retval false success
1732 @retval true failure
1733*/
1734typedef bool (*sdi_get_keys_t)(const dd::Tablespace &tablespace,
1736
1737/**
1738 Retrieve SDI for a given SDI key.
1739
1740 Since the caller of this api will not know the SDI length, SDI retrieval
1741 should be done in the following way.
1742
1743 i. Allocate initial memory of some size (Lets say 64KB)
1744 ii. Pass the allocated memory to the below api.
1745 iii. If passed buffer is sufficient, sdi_get_by_id() copies the sdi
1746 to the buffer passed and returns success, else sdi_len is modified
1747 with the actual length of the SDI (and returns false on failure).
1748 For genuine errors, sdi_len is returned as UINT64_MAX
1749 iv. If sdi_len != UINT64_MAX, retry the call after allocating the memory
1750 of sdi_len
1751 v. Free the memory after using SDI (responsibility of caller)
1752
1753 @param[in] tablespace tablespace object
1754 @param[in] sdi_key SDI key to uniquely identify SDI obj
1755 @param[in,out] sdi SDI retrieved from tablespace
1756 A non-null pointer must be passed in
1757 @param[in,out] sdi_len in: length of the memory allocated
1758 out: actual length of SDI
1759 @retval false success
1760 @retval true failure
1761*/
1762typedef bool (*sdi_get_t)(const dd::Tablespace &tablespace,
1763 const sdi_key_t *sdi_key, void *sdi, uint64 *sdi_len);
1764
1765/**
1766 Insert/Update SDI for a given SDI key.
1767 @param[in] hton handlerton object
1768 @param[in] tablespace tablespace object
1769 @param[in] table table object
1770 @param[in] sdi_key SDI key to uniquely identify SDI obj
1771 @param[in] sdi SDI to write into the tablespace
1772 @param[in] sdi_len length of SDI BLOB returned
1773 @retval false success
1774 @retval true failure, my_error() should be called
1775 by SE
1776*/
1777typedef bool (*sdi_set_t)(handlerton *hton, const dd::Tablespace &tablespace,
1778 const dd::Table *table, const sdi_key_t *sdi_key,
1779 const void *sdi, uint64 sdi_len);
1780
1781/**
1782 Delete SDI for a given SDI key.
1783 @param[in] tablespace tablespace object
1784 @param[in] table table object
1785 @param[in] sdi_key SDI key to uniquely identify SDI obj
1786 @retval false success
1787 @retval true failure, my_error() should be called
1788 by SE
1789*/
1790typedef bool (*sdi_delete_t)(const dd::Tablespace &tablespace,
1791 const dd::Table *table, const sdi_key_t *sdi_key);
1792
1793/**
1794 Check if the DDSE is started in a way that leaves thd DD being read only.
1795
1796 @retval true The data dictionary can only be read.
1797 @retval false The data dictionary can be read and written.
1798 */
1799typedef bool (*is_dict_readonly_t)();
1800
1801/**
1802 Drop all temporary tables which have been left from previous server
1803 run belonging to this SE. Used on server start-up.
1804
1805 @param[in] hton Handlerton for storage engine.
1806 @param[in] thd Thread context.
1807 @param[in,out] files List of files in directories for temporary files
1808 which match tmp_file_prefix and thus can belong to
1809 temporary tables (but not necessarily in this SE).
1810 It is recommended to remove file from the list if
1811 SE recognizes it as belonging to temporary table
1812 in this SE and deletes it.
1813*/
1814typedef bool (*rm_tmp_tables_t)(handlerton *hton, THD *thd,
1815 List<LEX_STRING> *files);
1816
1817/**
1818 Retrieve cost constants to be used for this storage engine.
1819
1820 A storage engine that wants to provide its own cost constants to
1821 be used in the optimizer cost model, should implement this function.
1822 The server will call this function to get a cost constant object
1823 that will be used for tables stored in this storage engine instead
1824 of using the default cost constants.
1825
1826 Life cycle for the cost constant object: The storage engine must
1827 allocate the cost constant object on the heap. After the function
1828 returns, the server takes over the ownership of this object.
1829 The server will eventually delete the object by calling delete.
1830
1831 @note In the initial version the storage_category parameter will
1832 not be used. The only valid value this will have is DEFAULT_STORAGE_CLASS
1833 (see declaration in opt_costconstants.h).
1834
1835 @param storage_category the storage type that the cost constants will
1836 be used for
1837
1838 @return a pointer to the cost constant object, if NULL is returned
1839 the default cost constants will be used
1840*/
1841typedef SE_cost_constants *(*get_cost_constants_t)(uint storage_category);
1842
1843/**
1844 @param[in,out] thd pointer to THD
1845 @param[in] new_trx_arg pointer to replacement transaction
1846 @param[out] ptr_trx_arg double pointer to being replaced transaction
1847
1848 Associated with THD engine's native transaction is replaced
1849 with @c new_trx_arg. The old value is returned through a buffer if non-null
1850 pointer is provided with @c ptr_trx_arg.
1851 The method is adapted by XA start and XA prepare handlers to
1852 handle XA transaction that is logged as two parts by slave applier.
1853
1854 This interface concerns engines that are aware of XA transaction.
1855*/
1856typedef void (*replace_native_transaction_in_thd_t)(THD *thd, void *new_trx_arg,
1857 void **ptr_trx_arg);
1858
1859/** Mode for initializing the data dictionary. */
1861 DICT_INIT_CREATE_FILES, ///< Create all required SE files
1862 DICT_INIT_CHECK_FILES, ///< Verify existence of expected files
1863 DICT_INIT_UPGRADE_57_FILES, ///< Used for upgrade from mysql-5.7
1864 DICT_INIT_IGNORE_FILES ///< Don't care about files at all
1866
1867/**
1868 Initialize the SE for being used to store the DD tables. Create
1869 the required files according to the dict_init_mode. Create strings
1870 representing the required DDSE tables, i.e., tables that the DDSE
1871 expects to exist in the DD, and add them to the appropriate out
1872 parameter.
1873
1874 @note There are two variants of this function type, one is to be
1875 used by the DDSE, and has a different type of output parameters
1876 because the SQL layer needs more information about the DDSE tables
1877 in order to support upgrade.
1878
1879 @param dict_init_mode How to initialize files
1880 @param version Target DD version if a new
1881 server is being installed.
1882 0 if restarting an existing
1883 server.
1884 @param [out] DDSE_tables List of SQL DDL statements
1885 for creating DD tables that
1886 are needed by the DDSE.
1887 @param [out] DDSE_tablespaces List of meta data for predefined
1888 tablespaces created by the DDSE.
1889
1890 @retval true An error occurred.
1891 @retval false Success - no errors.
1892 */
1893
1894typedef bool (*dict_init_t)(dict_init_mode_t dict_init_mode, uint version,
1895 List<const Plugin_table> *DDSE_tables,
1896 List<const Plugin_tablespace> *DDSE_tablespaces);
1897
1898typedef bool (*ddse_dict_init_t)(
1899 dict_init_mode_t dict_init_mode, uint version,
1900 List<const dd::Object_table> *DDSE_tables,
1901 List<const Plugin_tablespace> *DDSE_tablespaces);
1902
1903/**
1904 Initialize the set of hard coded DD table ids.
1905*/
1906typedef void (*dict_register_dd_table_id_t)(dd::Object_id hard_coded_tables);
1907
1908/**
1909 Invalidate an entry in the local dictionary cache.
1910
1911 Needed during bootstrap to make sure the contents in the DDSE
1912 dictionary cache is in sync with the global DD.
1913
1914 @param schema_name Schema name.
1915 @param table_name Table name.
1916 */
1917
1918typedef void (*dict_cache_reset_t)(const char *schema_name,
1919 const char *table_name);
1920
1921/**
1922 Invalidate all table and tablespace entries in the local dictionary cache.
1923
1924 Needed for recovery during server restart.
1925 */
1926
1928
1929/** Mode for data dictionary recovery. */
1931 DICT_RECOVERY_INITIALIZE_SERVER, ///< First start of a new server
1932 DICT_RECOVERY_INITIALIZE_TABLESPACES, ///< First start, create tablespaces
1933 DICT_RECOVERY_RESTART_SERVER ///< Restart of an existing server
1935
1936/**
1937 Do recovery in the DDSE as part of initializing the data dictionary.
1938 The dict_recovery_mode indicates what kind of recovery should be
1939 done.
1940
1941 @param dict_recovery_mode How to do recovery
1942 @param version Target DD version if a new
1943 server is being installed.
1944 Actual DD version if restarting
1945 an existing server.
1946
1947 @retval true An error occurred.
1948 @retval false Success - no errors.
1949 */
1950
1951typedef bool (*dict_recover_t)(dict_recovery_mode_t dict_recovery_mode,
1952 uint version);
1953
1954/**
1955 Get the server version id stored in the header of the
1956 dictionary tablespace.
1957
1958 @param [out] version Version number from the DD
1959 tablespace header.
1960
1961 @retval Operation outcome, false if no error, otherwise true.
1962*/
1964
1965/**
1966 Store the current server version number into the
1967 header of the dictionary tablespace.
1968
1969 @retval Operation outcome, false if no error, otherwise true.
1970*/
1972
1973/**
1974 Notify/get permission from storage engine before acquisition or after
1975 release of exclusive metadata lock on object represented by key.
1976
1977 @param thd Thread context.
1978 @param mdl_key MDL key identifying object on which exclusive
1979 lock is to be acquired/was released.
1980 @param notification_type Indicates whether this is pre-acquire or
1981 post-release notification.
1982 @param victimized 'true' if locking failed as we were selected
1983 as a victim in order to avoid possible deadlocks.
1984
1985 @note Notification is done only for objects from TABLESPACE, SCHEMA,
1986 TABLE, FUNCTION, PROCEDURE, TRIGGER and EVENT namespaces.
1987
1988 @note Problems during notification are to be reported as warnings, MDL
1989 subsystem will report generic error if pre-acquire notification
1990 fails/SE refuses lock acquisition.
1991 @note Return value is ignored/error is not reported in case of
1992 post-release notification.
1993
1994 @note In some cases post-release notification might happen even if
1995 there were no prior pre-acquire notification. For example,
1996 when SE was loaded after exclusive lock acquisition, or when
1997 we need notify SEs which permitted lock acquisition that it
1998 didn't happen because one of SEs didn't allow it (in such case
1999 we will do post-release notification for all SEs for simplicity).
2000
2001 @return False - if notification was successful/lock can be acquired,
2002 True - if it has failed/lock should not be acquired.
2003*/
2004typedef bool (*notify_exclusive_mdl_t)(THD *thd, const MDL_key *mdl_key,
2005 ha_notification_type notification_type,
2006 bool *victimized);
2007
2008/**
2009 Notify/get permission from storage engine before or after execution of
2010 ALTER TABLE operation on the table identified by the MDL key.
2011
2012 @param thd Thread context.
2013 @param mdl_key MDL key identifying table which is going to be
2014 or was ALTERed.
2015 @param notification_type Indicates whether this is pre-ALTER TABLE or
2016 post-ALTER TABLE notification.
2017
2018 @note This hook is necessary because for ALTER TABLE upgrade to X
2019 metadata lock happens fairly late during the execution process,
2020 so it can be expensive to abort ALTER TABLE operation at this
2021 stage by returning failure from notify_exclusive_mdl() hook.
2022
2023 @note This hook follows the same error reporting convention as
2024 @see notify_exclusive_mdl().
2025
2026 @note Similarly to notify_exclusive_mdl() in some cases post-ALTER
2027 notification might happen even if there were no prior pre-ALTER
2028 notification.
2029
2030 @note Post-ALTER notification can happen before post-release notification
2031 for exclusive metadata lock acquired by this ALTER TABLE.
2032
2033 @return False - if notification was successful/ALTER TABLE can proceed.
2034 True - if it has failed/ALTER TABLE should be aborted.
2035*/
2036typedef bool (*notify_alter_table_t)(THD *thd, const MDL_key *mdl_key,
2037 ha_notification_type notification_type);
2038
2039/**
2040 Notify/get permission from storage engine before or after execution of
2041 RENAME TABLE operation on the table identified by the MDL key.
2042
2043 @param thd Thread context.
2044 @param mdl_key MDL key identifying table which is going to be
2045 or was RENAMEd.
2046 @param notification_type Indicates whether this is pre-RENAME TABLE or
2047 post-RENAME TABLE notification.
2048 @param old_db_name
2049 @param old_table_name
2050 @param new_db_name
2051 @param new_table_name
2052*/
2053typedef bool (*notify_rename_table_t)(THD *thd, const MDL_key *mdl_key,
2054 ha_notification_type notification_type,
2055 const char *old_db_name,
2056 const char *old_table_name,
2057 const char *new_db_name,
2058 const char *new_table_name);
2059
2060/**
2061 Notify/get permission from storage engine before or after execution of
2062 TRUNCATE TABLE operation on the table identified by the MDL key.
2063
2064 @param thd Thread context.
2065 @param mdl_key MDL key identifying table which is going to be
2066 or was TRUNCATEd.
2067 @param notification_type Indicates whether this is pre-TRUNCATE TABLE or
2068 post-TRUNCATE TABLE notification.
2069*/
2070typedef bool (*notify_truncate_table_t)(THD *thd, const MDL_key *mdl_key,
2071 ha_notification_type notification_type);
2072
2073/**
2074 @brief
2075 Initiate master key rotation
2076
2077 @returns false on success,
2078 true on failure
2079*/
2081
2082/**
2083 @brief
2084 Enable or Disable SE write ahead logging.
2085
2086 @param[in] thd server thread handle
2087 @param[in] enable enable/disable redo logging
2088
2089 @return true iff failed.
2090*/
2091typedef bool (*redo_log_set_state_t)(THD *thd, bool enable);
2092
2093/**
2094 @brief
2095 Retrieve ha_statistics from SE.
2096
2097 @param db_name Name of schema
2098 @param table_name Name of table
2099 @param se_private_id SE private id of the table.
2100 @param ts_se_private_data Tablespace SE private data.
2101 @param tbl_se_private_data Table SE private data.
2102 @param flags Type of statistics to retrieve.
2103 @param[out] stats Contains statistics read from SE.
2104
2105 @note Handlers that implement this callback/API should adhere
2106 to servers expectation that, the implementation would invoke
2107 my_error() before returning 'true'/failure from this function.
2108
2109 @returns false on success,
2110 true on failure
2111*/
2113 const char *db_name, const char *table_name, dd::Object_id se_private_id,
2114 const dd::Properties &ts_se_private_data,
2115 const dd::Properties &tbl_se_private_data, uint flags,
2117
2118/**
2119 @brief
2120 Retrieve index column cardinality from SE.
2121
2122 @param db_name Name of schema
2123 @param table_name Name of table
2124 @param index_name Name of index
2125 @param index_ordinal_position Position of index.
2126 @param column_ordinal_position Position of column in index.
2127 @param se_private_id SE private id of the table.
2128 @param[out] cardinality cardinality being returned by SE.
2129
2130 @note Handlers that implement this callback/API should adhere
2131 to servers expectation that, the implementation would invoke
2132 my_error() before returning 'true'/failure from this function.
2133
2134 @returns false on success,
2135 true on failure
2136*/
2138 const char *db_name, const char *table_name, const char *index_name,
2139 uint index_ordinal_position, uint column_ordinal_position,
2140 dd::Object_id se_private_id, ulonglong *cardinality);
2141
2142/**
2143 Retrieve ha_tablespace_statistics from SE.
2144
2145 @param tablespace_name Tablespace_name
2146 @param file_name Tablespace file name.
2147 @param ts_se_private_data Tablespace SE private data.
2148 @param[out] stats Contains tablespace
2149 statistics read from SE.
2150
2151 @note Handlers that implement this callback/API should adhere
2152 to servers expectation that, the implementation would invoke
2153 my_error() before returning 'true'/failure from this function.
2154
2155 @returns false on success, true on failure
2156*/
2158 const char *tablespace_name, const char *file_name,
2159 const dd::Properties &ts_se_private_data, ha_tablespace_statistics *stats);
2160
2161/* Database physical clone interfaces */
2162
2163/** Get capability flags for clone operation
2164@param[out] flags capability flag */
2166
2167/** Begin copy from source database
2168@param[in] hton handlerton for SE
2169@param[in] thd server thread handle
2170@param[in,out] loc locator
2171@param[in,out] loc_len locator length
2172@param[out] task_id task identifier
2173@param[in] type clone type
2174@param[in] mode mode for starting clone
2175@return error code */
2176using Clone_begin_t = int (*)(handlerton *hton, THD *thd, const uchar *&loc,
2177 uint &loc_len, uint &task_id, Ha_clone_type type,
2179
2180/** Copy data from source database in chunks via callback
2181@param[in] hton handlerton for SE
2182@param[in] thd server thread handle
2183@param[in] loc locator
2184@param[in] loc_len locator length in bytes
2185@param[in] task_id task identifier
2186@param[in] cbk callback interface for sending data
2187@return error code */
2188using Clone_copy_t = int (*)(handlerton *hton, THD *thd, const uchar *loc,
2189 uint loc_len, uint task_id, Ha_clone_cbk *cbk);
2190
2191/** Acknowledge data transfer to source database
2192@param[in] hton handlerton for SE
2193@param[in] thd server thread handle
2194@param[in] loc locator
2195@param[in] loc_len locator length in bytes
2196@param[in] task_id task identifier
2197@param[in] in_err inform any error occurred
2198@param[in] cbk callback interface
2199@return error code */
2200using Clone_ack_t = int (*)(handlerton *hton, THD *thd, const uchar *loc,
2201 uint loc_len, uint task_id, int in_err,
2202 Ha_clone_cbk *cbk);
2203
2204/** End copy from source database
2205@param[in] hton handlerton for SE
2206@param[in] thd server thread handle
2207@param[in] loc locator
2208@param[in] loc_len locator length in bytes
2209@param[in] task_id task identifier
2210@param[in] in_err error code when ending after error
2211@return error code */
2212using Clone_end_t = int (*)(handlerton *hton, THD *thd, const uchar *loc,
2213 uint loc_len, uint task_id, int in_err);
2214
2215/** Begin apply to destination database
2216@param[in] hton handlerton for SE
2217@param[in] thd server thread handle
2218@param[in,out] loc locator
2219@param[in,out] loc_len locator length
2220@param[in] task_id task identifier
2221@param[in] mode mode for starting clone
2222@param[in] data_dir target data directory
2223@return error code */
2224using Clone_apply_begin_t = int (*)(handlerton *hton, THD *thd,
2225 const uchar *&loc, uint &loc_len,
2226 uint &task_id, Ha_clone_mode mode,
2227 const char *data_dir);
2228
2229/** Apply data to destination database in chunks via callback
2230@param[in] hton handlerton for SE
2231@param[in] thd server thread handle
2232@param[in] loc locator
2233@param[in] loc_len locator length in bytes
2234@param[in] task_id task identifier
2235@param[in] in_err inform any error occurred
2236@param[in] cbk callback interface for receiving data
2237@return error code */
2238using Clone_apply_t = int (*)(handlerton *hton, THD *thd, const uchar *loc,
2239 uint loc_len, uint task_id, int in_err,
2240 Ha_clone_cbk *cbk);
2241
2242/** End apply to destination database
2243@param[in] hton handlerton for SE
2244@param[in] thd server thread handle
2245@param[in] loc locator
2246@param[in] loc_len locator length in bytes
2247@param[in] task_id task identifier
2248@param[in] in_err error code when ending after error
2249@return error code */
2250using Clone_apply_end_t = int (*)(handlerton *hton, THD *thd, const uchar *loc,
2251 uint loc_len, uint task_id, int in_err);
2252
2254 /* Get clone capabilities of an SE */
2256
2257 /* Interfaces to copy data. */
2262
2263 /* Interfaces to apply data. */
2267};
2268
2269/**
2270 Perform post-commit/rollback cleanup after DDL statement (e.g. in
2271 case of DROP TABLES really remove table files from disk).
2272
2273 @note This hook will be invoked after DDL commit or rollback only
2274 for storage engines supporting atomic DDL.
2275
2276 @note Problems during execution of this method should be reported to
2277 error log and as warnings/notes to user. Since this method is
2278 called after successful commit of the statement we can't fail
2279 statement with error.
2280*/
2281typedef void (*post_ddl_t)(THD *thd);
2282
2283/**
2284 Perform SE-specific cleanup after recovery of transactions.
2285
2286 @note Particularly SEs supporting atomic DDL can use this call
2287 to perform post-DDL actions for DDL statements which were
2288 committed or rolled back during recovery stage.
2289*/
2290typedef void (*post_recover_t)(void);
2291
2292/**
2293 Lock a handlerton (resource) log to collect log information.
2294*/
2295
2296typedef bool (*lock_hton_log_t)(handlerton *hton);
2297
2298/**
2299 Unlock a handlerton (resource) log after collecting log information.
2300*/
2301
2302typedef bool (*unlock_hton_log_t)(handlerton *hton);
2303
2304/**
2305 Collect a handlerton (resource) log information.
2306*/
2307
2308typedef bool (*collect_hton_log_info_t)(handlerton *hton, Json_dom *json);
2309
2310/**
2311 Check SE considers types of child and parent columns in foreign key
2312 to be compatible.
2313
2314 @param child_column_type Child column type description.
2315 @param parent_column_type Parent column type description.
2316 @param check_charsets Indicates whether we need to check
2317 that charsets of string columns
2318 match. Which is true in most cases.
2319
2320 @returns True if types are compatible, False if not.
2321*/
2322
2324 const Ha_fk_column_type *child_column_type,
2325 const Ha_fk_column_type *parent_column_type, bool check_charsets);
2326
2327typedef bool (*is_reserved_db_name_t)(handlerton *hton, const char *name);
2328
2329/**
2330 Prepare the secondary engine for executing a statement. This function is
2331 called right after the secondary engine TABLE objects have been opened by
2332 open_secondary_engine_tables(), before the statement is optimized and
2333 executed. Secondary engines will typically create a context object in this
2334 function, which they can use to store state that is needed during the
2335 optimization and execution phases.
2336
2337 @param thd thread context
2338 @param lex the statement to execute
2339 @return true on error, false on success
2340*/
2341using prepare_secondary_engine_t = bool (*)(THD *thd, LEX *lex);
2342
2343/**
2344 Optimize a statement for execution on a secondary storage engine. This
2345 function is called when the optimization of a statement has completed, just
2346 before the statement is executed. Secondary engines can use this function to
2347 apply engine-specific optimizations to the execution plan. They can also
2348 reject executing the query by raising an error, in which case the query will
2349 be reprepared and executed by the primary storage engine.
2350
2351 @param thd thread context
2352 @param lex the statement being optimized
2353 @return true on error, false on success
2354*/
2355using optimize_secondary_engine_t = bool (*)(THD *thd, LEX *lex);
2356
2357/**
2358 Compares the cost of two join plans in the secondary storage engine. The cost
2359 of the current candidate is compared with the cost of the best plan seen so
2360 far.
2361
2362 @param thd thread context
2363 @param join the candidate plan to evaluate
2364 @param optimizer_cost the cost estimate calculated by the optimizer
2365 @param[out] use_best_so_far true if the optimizer should stop searching for
2366 a better plan and use the best plan it has seen so far
2367 @param[out] cheaper true if the candidate is the best plan seen so far for
2368 this JOIN (must be true if it is the first plan seen),
2369 false otherwise
2370 @param[out] secondary_engine_cost the cost estimated by the secondary engine
2371
2372 @return false on success, or true if an error has been raised
2373*/
2374using compare_secondary_engine_cost_t = bool (*)(THD *thd, const JOIN &join,
2375 double optimizer_cost,
2376 bool *use_best_so_far,
2377 bool *cheaper,
2378 double *secondary_engine_cost);
2379
2380/**
2381 Evaluates the cost of executing the given access path in this secondary
2382 storage engine, and potentially modifies the cost estimates that are in the
2383 access path. This function is only called from the hypergraph join optimizer.
2384
2385 The function is called on every access path that the join optimizer might
2386 compare to an alternative access path. This includes both paths that represent
2387 complete execution plans and paths that represent partial plans. It is not
2388 guaranteed to be called on every child path. For example, if GROUP BY is done
2389 by sorting first and then aggregating the sorted results, the function will
2390 only be called on the aggregation path, and not on the sort path, because only
2391 the aggregation path will be compared to other paths.
2392
2393 The secondary engine is allowed to modify the estimates in the access path to
2394 better match the costs of the access path in the secondary engine. It can
2395 change any of the following AccessPath members:
2396
2397 - init_once_cost
2398 - init_cost
2399 - cost
2400 - cost_before_filter
2401 - num_output_rows
2402 - num_output_rows_before_filter
2403 - secondary_engine_data
2404
2405 Any other members should be left unchanged. The AccessPath must be in an
2406 internally consistent state when the function returns, and satisfy invariants
2407 expected by the hypergraph join optimizer, such as:
2408
2409 - init_cost <= cost_before_filter <= cost
2410 - num_output_rows <= num_output_rows_before_filter
2411
2412 The secondary engine can also reject an access path altogether, by returning
2413 true, in which case the join optimizer will not use that path in the final
2414 plan. Since the secondary engine can reject any partial or complete plan, it
2415 is possible that the join optimizer does not find any valid plan that is
2416 accepted. In this case, the join optimizer will raise an error.
2417
2418 If the secondary encounters an error when evaluating the cost of the path, it
2419 can signal an error by calling my_error() and return true, in which case the
2420 join optimizer will not suggest any plan for the query.
2421
2422 @param thd The thread context.
2423 @param hypergraph The hypergraph that represents the search space.
2424 @param[in,out] access_path The AccessPath to evaluate.
2425
2426 @retval false on success.
2427 @retval true if the plan is to be rejected, or if an error was raised.
2428*/
2430 THD *thd, const JoinHypergraph &hypergraph, AccessPath *access_path);
2431
2432/**
2433 Looks up and returns a specific secondary engine query offload or exec
2434 failure reason as a string given a thread context (representing the query)
2435 when the offloaded query fails in the secondary storage engine.
2436
2437 @param thd thread context.
2438
2439 @retval const char * as the offload failure reason.
2440 The memory pointed to is managed by the handlerton and may be freed
2441 when the statement completes.
2442*/
2444 const char *(*)(THD *thd);
2445
2446/**
2447 Sets a specific secondary engine offload failure reason for a query
2448 represented by the thread context when the offloaded query fails in
2449 the secondary storage engine.
2450
2451 @param thd thread context.
2452
2453 @param const char * as the offload failure reason.
2454*/
2456 const char *);
2457
2458// Capabilities (bit flags) for secondary engines.
2459using SecondaryEngineFlags = uint64_t;
2463
2464 // If this flag is set, aggregation (GROUP BY and DISTINCT) do not require
2465 // ordered inputs and create unordered outputs. This is typically the case
2466 // if they are implemented using hash-based techniques.
2468
2469 /// This flag can be set to signal that a secondary storage engine will not
2470 /// use MySQL's executor (see JOIN::override_executor_func). In this case, it
2471 /// doesn't need MySQL's execution data structures, like internal temporary
2472 /// tables, filesort objects or iterators. If the flag is set,
2473 /// FinalizePlanForQueryBlock() will not make any changes to the plan, and
2474 /// CreateIteratorFromAccessPath() will not be called.
2476};
2477
2478/// Creates an empty bitmap of access path types. This is the base
2479/// case for the function template with the same name below.
2480inline constexpr SecondaryEngineFlags MakeSecondaryEngineFlags() { return 0; }
2481
2482/// Creates a bitmap representing a set of access path types.
2483template <typename... Args>
2485 SecondaryEngineFlag flag1, Args... rest) {
2486 return (uint64_t{1} << static_cast<int>(flag1)) |
2487 MakeSecondaryEngineFlags(rest...);
2488}
2489
2490/// Returns the handlerton of the secondary engine that is used in the session,
2491/// or nullptr if a secondary engine is not used.
2492const handlerton *SecondaryEngineHandlerton(const THD *thd);
2493
2494// FIXME: Temporary workaround to enable storage engine plugins to use the
2495// before_commit hook. Remove after WL#11320 has been completed.
2496typedef void (*se_before_commit_t)(void *arg);
2497
2498// FIXME: Temporary workaround to enable storage engine plugins to use the
2499// after_commit hook. Remove after WL#11320 has been completed.
2500typedef void (*se_after_commit_t)(void *arg);
2501
2502// FIXME: Temporary workaround to enable storage engine plugins to use the
2503// before_rollback hook. Remove after WL#11320 has been completed.
2504typedef void (*se_before_rollback_t)(void *arg);
2505
2506/*
2507 Page Tracking : interfaces to handlerton functions which starts/stops page
2508 tracking, and purges/fetches page tracking information.
2509*/
2510
2511/**
2512 Start page tracking.
2513
2514 @param[out] start_id SE specific sequence number [LSN for InnoDB]
2515 indicating when the tracking was started
2516
2517 @return Operation status.
2518 @retval 0 Success
2519 @retval other ER_* mysql error. Get error details from THD.
2520*/
2521using page_track_start_t = int (*)(uint64_t *start_id);
2522
2523/**
2524 Stop page tracking.
2525
2526 @param[out] stop_id SE specific sequence number [LSN for InnoDB]
2527 indicating when the tracking was stopped
2528
2529 @return Operation status.
2530 @retval 0 Success
2531 @retval other ER_* mysql error. Get error details from THD.
2532*/
2533using page_track_stop_t = int (*)(uint64_t *stop_id);
2534
2535/**
2536 Purge page tracking data.
2537
2538 @param[in,out] purge_id SE specific sequence number [LSN for InnoDB]
2539 initially indicating till where the data needs to be purged and finally
2540 updated to until where it was actually purged
2541
2542 @return Operation status.
2543 @retval 0 Success
2544 @retval other ER_* mysql error. Get error details from THD.
2545*/
2546using page_track_purge_t = int (*)(uint64_t *purge_id);
2547
2548/**
2549 Fetch tracked pages.
2550
2551 @param[in] cbk_func callback function return page IDs
2552 @param[in] cbk_ctx caller's context for callback
2553 @param[in,out] start_id SE specific sequence number [LSN for InnoDB] from
2554 where the pages tracked would be returned.
2555 @note The range might get expanded and the actual start_id used for the
2556 querying will be updated.
2557 @param[in,out] stop_id SE specific sequence number [LSN for InnoDB]
2558 until where the pages tracked would be returned.
2559 @note The range might get expanded and the actual stop_id used for the
2560 querying will be updated.
2561 @param[out] buffer allocated buffer to copy page IDs
2562 @param[in] buffer_len length of buffer in bytes
2563
2564 @return Operation status.
2565 @retval 0 Success
2566 @retval other ER_* mysql error. Get error details from THD.
2567*/
2569 void *cbk_ctx, uint64_t *start_id,
2570 uint64_t *stop_id,
2571 unsigned char *buffer,
2572 size_t buffer_len);
2573
2574/**
2575 Fetch approximate number of tracked pages in the given range.
2576
2577 @param[in,out] start_id SE specific sequence number [LSN for InnoDB] from
2578 where the pages tracked would be returned.
2579 @note the range might get expanded and the actual start_id used for the
2580 querying will be updated.
2581 @param[in,out] stop_id SE specific sequence number [LSN for InnoDB]
2582 until where the pages tracked would be returned.
2583 @note the range might get expanded and the actual stop_id used for the
2584 querying will be updated.
2585 @param[out] num_pages number of pages tracked
2586
2587 @return Operation status.
2588 @retval 0 Success
2589 @retval other ER_* mysql error. Get error details from THD.
2590*/
2591using page_track_get_num_page_ids_t = int (*)(uint64_t *start_id,
2592 uint64_t *stop_id,
2593 uint64_t *num_pages);
2594
2595/** Fetch the status of the page tracking system.
2596@param[out] status vector of a pair of (ID, bool) where ID is the
2597start/stop point and bool is true if the ID is a start point else false */
2599 void (*)(std::vector<std::pair<uint64_t, bool>> &status);
2600
2601/** Page track interface */
2609};
2610
2611/**
2612 handlerton is a singleton structure - one instance per storage engine -
2613 to provide access to storage engine functionality that works on the
2614 "global" level (unlike handler class that works on a per-table basis).
2615
2616 usually handlerton instance is defined statically in ha_xxx.cc as
2617
2618 static handlerton { ... } xxx_hton;
2619
2620 savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
2621*/
2623 /**
2624 Historical marker for if the engine is available or not.
2625 */
2627
2628 /**
2629 Historical number used for frm file to determine the correct storage engine.
2630 This is going away and new engines will just use "name" for this.
2631 */
2633 /**
2634 Each storage engine has it's own memory area (actually a pointer)
2635 in the thd, for storing per-connection information.
2636 It is accessed as
2637
2638 thd->ha_data[xxx_hton.slot]
2639
2640 slot number is initialized by MySQL after xxx_init() is called.
2641 */
2643 /**
2644 To store per-savepoint data storage engine is provided with an area
2645 of a requested size (0 is ok here).
2646 savepoint_offset must be initialized statically to the size of
2647 the needed memory to store per-savepoint information.
2648 After xxx_init it is changed to be an offset to savepoint storage
2649 area and need not be used by storage engine.
2650 see binlog_hton and binlog_savepoint_set/rollback for an example.
2651 */
2653
2654 /* handlerton methods */
2655
2700
2701 /** Global handler flags. */
2703
2704 /*
2705 Those handlerton functions below are properly initialized at handler
2706 init.
2707 */
2708
2717
2718 /*
2719 APIs for retrieving Serialized Dictionary Information by tablespace id
2720 */
2721
2728
2729 /**
2730 Null-ended array of file extensions that exist for the storage engine.
2731 Used by frm_error() and the default handler::rename_table and delete_table
2732 methods in handler.cc.
2733
2734 For engines that have two file name extensions (separate meta/index file
2735 and data file), the order of elements is relevant. First element of engine
2736 file name extensions array should be meta/index file extension. Second
2737 element - data file extension. This order is assumed by
2738 prepare_for_repair() when REPAIR TABLE ... USE_FRM is issued.
2739
2740 For engines that don't have files, file_extensions is NULL.
2741
2742 Currently, the following alternatives are used:
2743 - file_extensions == NULL;
2744 - file_extensions[0] != NULL, file_extensions[1] == NULL;
2745 - file_extensions[0] != NULL, file_extensions[1] != NULL,
2746 file_extensions[2] == NULL;
2747 */
2748 const char **file_extensions;
2749
2760
2764
2767
2768 /** Clone data transfer interfaces */
2770
2771 /** Flag for Engine License. */
2773 /** Location for engines to keep personal structures. */
2774 void *data;
2775
2776 /*
2777 Log_resource functions that must be supported by storage engines
2778 with relevant log information to be collected.
2779 */
2783
2784 /** Flags describing details of foreign key support by storage engine. */
2786
2788
2789 /**
2790 Suffix for auto-generated foreign key names for tables using this storage
2791 engine. If such suffix is specified by SE then its generated foreign key
2792 names follow (table name)(SE-specific FK name suffix)(FK number) pattern.
2793 Length of such suffix should not exceed MAX_FK_NAME_SUFFIX_LENGTH bytes.
2794 If no suffix is specified then FK_NAME_DEFAULT_SUFFIX is used as
2795 default.
2796 */
2798
2799 /**
2800 Pointer to a function that prepares a secondary engine for executing a
2801 statement.
2802
2803 @see prepare_secondary_engine_t for function signature.
2804 */
2806
2807 /**
2808 Pointer to a function that optimizes the current statement for
2809 execution on the secondary storage engine represented by this
2810 handlerton.
2811
2812 @see optimize_secondary_engine_t for function signature.
2813 */
2815
2816 /**
2817 Pointer to a function that estimates the cost of executing a join in a
2818 secondary storage engine.
2819
2820 @see compare_secondary_engine_cost_t for function signature.
2821 */
2823
2824 /// Bitmap which contains the supported join types and other flags
2825 /// for a secondary storage engine when used with the hypergraph join
2826 /// optimizer. If it is empty, it means that the secondary engine
2827 /// does not support the hypergraph join optimizer.
2829
2830 /// Pointer to a function that evaluates the cost of executing an access path
2831 /// in a secondary storage engine.
2832 ///
2833 /// @see secondary_engine_modify_access_path_cost_t for function signature.
2836
2837 /// Pointer to a function that returns the query offload or exec failure
2838 /// reason as a string given a thread context (representing the query) when
2839 /// the offloaded query failed in a secondary storage engine.
2840 ///
2841 /// @see get_secondary_engine_offload_or_exec_fail_reason_t for function
2842 /// signature.
2845
2846 /// Pointer to a function that sets the offload failure reason as a string
2847 /// for a thread context (representing the query) when the offloaded query
2848 /// failed in a secondary storage engine.
2849 ///
2850 /// @see set_secondary_engine_offload_fail_reason_t for function signature.
2853
2857
2858 /** Page tracking interface */
2860};
2861
2862/* Possible flags of a handlerton (there can be 32 of them) */
2863#define HTON_NO_FLAGS 0
2864#define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0)
2865#define HTON_ALTER_NOT_SUPPORTED (1 << 1) // Engine does not support alter
2866#define HTON_CAN_RECREATE (1 << 2) // Delete all is used for truncate
2867#define HTON_HIDDEN (1 << 3) // Engine does not appear in lists
2868/*
2869 Bit 4 was occupied by BDB-specific HTON_FLUSH_AFTER_RENAME flag and is no
2870 longer used.
2871*/
2872#define HTON_NOT_USER_SELECTABLE (1 << 5)
2873#define HTON_TEMPORARY_NOT_SUPPORTED \
2874 (1 << 6) // Having temporary tables not supported
2875#define HTON_SUPPORT_LOG_TABLES (1 << 7) // Engine supports log tables
2876#define HTON_NO_PARTITION (1 << 8) // You can not partition these tables
2877
2878/*
2879 This flag should be set when deciding that the engine does not allow row based
2880 binary logging (RBL) optimizations.
2881
2882 Currently, setting this flag, means that table's read/write_set will be left
2883 untouched when logging changes to tables in this engine. In practice this
2884 means that the server will not mess around with table->write_set and/or
2885 table->read_set when using RBL and deciding whether to log full or minimal
2886 rows.
2887
2888 It's valuable for instance for virtual tables, eg: Performance Schema which
2889 have no meaning for replication.
2890*/
2891#define HTON_NO_BINLOG_ROW_OPT (1 << 9)
2892
2893/**
2894 Engine supports extended keys. The flag allows to
2895 use 'extended key' feature if the engine is able to
2896 do it (has primary key values in the secondary key).
2897 Note that handler flag HA_PRIMARY_KEY_IN_READ_INDEX is
2898 actually partial case of HTON_SUPPORTS_EXTENDED_KEYS.
2899*/
2900
2901#define HTON_SUPPORTS_EXTENDED_KEYS (1 << 10)
2902
2903// Engine support foreign key constraint.
2904
2905#define HTON_SUPPORTS_FOREIGN_KEYS (1 << 11)
2906
2907/**
2908 Engine supports atomic DDL. That is rollback of transaction for DDL
2909 statement will also rollback all changes in SE, commit of transaction
2910 of DDL statement will make it durable.
2911*/
2912
2913#define HTON_SUPPORTS_ATOMIC_DDL (1 << 12)
2914
2915/* Engine supports packed keys. */
2916#define HTON_SUPPORTS_PACKED_KEYS (1 << 13)
2917
2918/** Engine is a secondary storage engine. */
2919#define HTON_IS_SECONDARY_ENGINE (1 << 14)
2920
2921/** Engine supports secondary storage engines. */
2922#define HTON_SUPPORTS_SECONDARY_ENGINE (1 << 15)
2923
2924/** Engine supports table or tablespace encryption . */
2925#define HTON_SUPPORTS_TABLE_ENCRYPTION (1 << 16)
2926
2928 1 << 17};
2929
2930/** Engine supports Generated invisible primary key. */
2931constexpr const decltype(
2933
2934/** Whether the secondary engine supports DDLs. No meaning if the engine is not
2935 * secondary. */
2936#define HTON_SECONDARY_ENGINE_SUPPORTS_DDL (1 << 19)
2937
2938/** Whether the engine does not support triggers. */
2939#define HTON_NO_TRIGGER_SUPPORT (1 << 20)
2940
2941/** Whether the primary engine supports external data sources. This case refers
2942 to having tables with data in object store and the engine does not store any
2943 of those data, only metadata. Table contents can be accessed only after
2944 loading the table in the secondary storage engine. The flag is used for
2945 a primary engine only.
2946 */
2947#define HTON_SUPPORTS_EXTERNAL_SOURCE (1 << 21)
2948
2950 assert(hton->flags & HTON_IS_SECONDARY_ENGINE);
2951
2952 return (hton->flags & HTON_SECONDARY_ENGINE_SUPPORTS_DDL) != 0;
2953}
2954
2955inline bool ddl_is_atomic(const handlerton *hton) {
2956 return (hton->flags & HTON_SUPPORTS_ATOMIC_DDL) != 0;
2957}
2958
2959/* Bits for handlerton::foreign_keys_flags bitmap. */
2960
2961/**
2962 Engine supports both unique and non-unique parent keys for
2963 foreign keys which contain full foreign key as its prefix.
2964
2965 Storage engines which support foreign keys but do not have
2966 this flag set are assumed to support only parent keys which
2967 are primary/unique and contain exactly the same columns as
2968 the foreign key, possibly, in different order.
2969*/
2970
2972
2973/**
2974 Storage engine supports hash keys as supporting keys for foreign
2975 keys. Hash key should contain all foreign key columns and only
2976 them (although in any order).
2977
2978 Storage engines which support foreign keys but do not have this
2979 flag set are assumed to not allow hash keys as supporting keys.
2980*/
2981
2983
2984/**
2985 Storage engine supports non-hash keys which have common prefix
2986 with the foreign key as supporting keys for it. If there are
2987 several such keys, one which shares biggest prefix with FK is
2988 chosen.
2989
2990 Storage engines which support foreign keys but do not have this
2991 flag set are assumed to require that supporting key contains full
2992 foreign key as its prefix.
2993*/
2994
2996
2997/**
2998 Storage engine does not support using the same key for both parent
2999 and supporting key, but requires the two to be different.
3000*/
3001
3003 (1 << 3);
3004
3005/**
3006 Engine takes into account hidden part of key (coming from primary key)
3007 when determines if it can serve as parent key for a foreign key.
3008
3009 Implies HTON_FKS_WITH_PREFIX_PARENT_KEYS and is related to
3010 HTON_SUPPORTS_EXTENDED_KEYS.
3011*/
3012
3014
3015/**
3016 Maximum possible length of SE-specific suffixes for auto-generated
3017 foreign key names.
3018*/
3019static const size_t MAX_FK_NAME_SUFFIX_LENGTH = 16;
3020
3021/**
3022 Suffix for auto-generated foreign key names for tables in SE's which
3023 don't specify own suffix. I.e. for foreign keys on tables in such
3024 SE's generated names follow (table name)FK_NAME_DEFAULT_SUFFIX(FK number)
3025 pattern.
3026*/
3028
3035
3041
3042/**
3043 Struct to hold information about the table that should be created.
3044 */
3048 bool schema_read_only{false};
3050 const char *password{nullptr};
3051 const char *tablespace{nullptr};
3052 LEX_STRING comment{nullptr, 0};
3053
3054 /**
3055 Algorithm (and possible options) to be used for InnoDB's transparent
3056 page compression. If this attribute is set then it is hint to the
3057 storage engine to try and compress the data using the specified algorithm
3058 where possible. Note: this value is interpreted by the storage engine only.
3059 and ignored by the Server layer. */
3060
3062
3063 /**
3064 This attribute is used for InnoDB's transparent page encryption.
3065 If this attribute is set then it is hint to the storage engine to encrypt
3066 the data. Note: this value is interpreted by the storage engine only.
3067 and ignored by the Server layer. */
3068
3070
3071 /**
3072 * Secondary engine of the table.
3073 * Is nullptr if no secondary engine defined.
3074 */
3076 /** Secondary engine load status */
3077 bool secondary_load{false};
3078
3079 const char *data_file_name{nullptr};
3080 const char *index_file_name{nullptr};
3081 const char *alias{nullptr};
3087 uint64_t used_fields{0};
3088 // Can only be 1,2,4,8 or 16, but use uint32_t since that how it is
3089 // represented in InnoDB
3090 std::uint32_t key_block_size{0};
3091 uint stats_sample_pages{0}; /* number of pages to sample during
3092 stats estimation, if used, otherwise 0. */
3096 /**
3097 Row type of the table definition.
3098
3099 Defaults to ROW_TYPE_DEFAULT for all non-ALTER statements.
3100 For ALTER TABLE defaults to ROW_TYPE_NOT_USED (means "keep the current").
3101
3102 Can be changed either explicitly by the parser.
3103 If nothing specified inherits the value of the original table (if present).
3104 */
3106 uint null_bits{0}; /* NULL bits at start of record */
3107 uint options{0}; /* OR of HA_CREATE_ options */
3109 ha_storage_media storage_media{HA_SM_DEFAULT}; /* DEFAULT, DISK or MEMORY */
3110
3111 /*
3112 A flag to indicate if this table should be marked as a hidden table in
3113 the data dictionary. One use case is to mark the temporary tables
3114 created by ALTER to be marked as hidden.
3115 */
3116 bool m_hidden{false};
3117
3118 /*
3119 A flag to indicate if this table should be created but not committed at
3120 the end of statement.
3121 */
3123
3126
3128
3130
3131 /**
3132 Fill HA_CREATE_INFO to be used by ALTER as well as upgrade code.
3133 This function separates code from mysql_prepare_alter_table() to be
3134 used by upgrade code as well to reduce code duplication.
3135 For ALTER code path, this lets new create options override the old
3136 ones.
3137
3138 @param[in] share TABLE_SHARE object
3139 @param[in] used_fields If a given create option is not flagged, old
3140 value be copied from the TABLE_SHARE.
3141 */
3142
3144 uint64_t used_fields);
3145};
3146
3147/**
3148 Structure describing changes to an index to be caused by ALTER TABLE.
3149*/
3150
3151struct KEY_PAIR {
3152 /**
3153 Pointer to KEY object describing old version of index in
3154 TABLE::key_info array for TABLE instance representing old
3155 version of table.
3156 */
3158 /**
3159 Pointer to KEY object describing new version of index in
3160 Alter_inplace_info::key_info_buffer array.
3161 */
3163};
3164
3165/**
3166 In-place alter handler context.
3167
3168 This is a superclass intended to be subclassed by individual handlers
3169 in order to store handler unique context between in-place alter API calls.
3170
3171 The handler is responsible for creating the object. This can be done
3172 as early as during check_if_supported_inplace_alter().
3173
3174 The SQL layer is responsible for destroying the object.
3175
3176 @see Alter_inplace_info
3177*/
3178
3180 public:
3182
3184 [[maybe_unused]]) {}
3185 virtual ~inplace_alter_handler_ctx() = default;
3186};
3187
3188/**
3189 Class describing changes to be done by ALTER TABLE.
3190 Instance of this class is passed to storage engine in order
3191 to determine if this ALTER TABLE can be done using in-place
3192 algorithm. It is also used for executing the ALTER TABLE
3193 using in-place algorithm.
3194*/
3195
3197 public:
3198 /**
3199 Bits to show in detail what operations the storage engine is
3200 to execute.
3201
3202 All these operations are supported as in-place operations by the
3203 SQL layer. This means that operations that by their nature must
3204 be performed by copying the table to a temporary table, will not
3205 have their own flags here (e.g. ALTER TABLE FORCE, ALTER TABLE
3206 ENGINE).
3207
3208 We generally try to specify handler flags only if there are real
3209 changes. But in cases when it is cumbersome to determine if some
3210 attribute has really changed we might choose to set flag
3211 pessimistically, for example, relying on parser output only.
3212 */
3214
3215 // Add non-unique, non-primary index
3216 static const HA_ALTER_FLAGS ADD_INDEX = 1ULL << 0;
3217
3218 // Drop non-unique, non-primary index
3219 static const HA_ALTER_FLAGS DROP_INDEX = 1ULL << 1;
3220
3221 // Add unique, non-primary index
3222 static const HA_ALTER_FLAGS ADD_UNIQUE_INDEX = 1ULL << 2;
3223
3224 // Drop unique, non-primary index
3225 static const HA_ALTER_FLAGS DROP_UNIQUE_INDEX = 1ULL << 3;
3226
3227 // Add primary index
3228 static const HA_ALTER_FLAGS ADD_PK_INDEX = 1ULL << 4;
3229
3230 // Drop primary index
3231 static const HA_ALTER_FLAGS DROP_PK_INDEX = 1ULL << 5;
3232
3233 // Add column
3234
3235 // Virtual generated column
3236 static const HA_ALTER_FLAGS ADD_VIRTUAL_COLUMN = 1ULL << 6;
3237 // Stored base (non-generated) column
3238 static const HA_ALTER_FLAGS ADD_STORED_BASE_COLUMN = 1ULL << 7;
3239 // Stored generated column
3241 // Add generic column (convenience constant).
3244
3245 // Drop column
3246 static const HA_ALTER_FLAGS DROP_VIRTUAL_COLUMN = 1ULL << 9;
3247 static const HA_ALTER_FLAGS DROP_STORED_COLUMN = 1ULL << 10;
3250
3251 // Rename column
3252 static const HA_ALTER_FLAGS ALTER_COLUMN_NAME = 1ULL << 11;
3253
3254 // Change column datatype
3256 static const HA_ALTER_FLAGS ALTER_STORED_COLUMN_TYPE = 1ULL << 13;
3257
3258 /**
3259 Change column datatype in such way that new type has compatible
3260 packed representation with old type, so it is theoretically
3261 possible to perform change by only updating data dictionary
3262 without changing table rows.
3263 */
3265
3266 /// A virtual column has changed its position
3268
3269 /// A stored column has changed its position (disregarding virtual columns)
3271
3272 // Change column from NOT NULL to NULL
3273 static const HA_ALTER_FLAGS ALTER_COLUMN_NULLABLE = 1ULL << 17;
3274
3275 // Change column from NULL to NOT NULL
3277
3278 // Set or remove default column value
3279 static const HA_ALTER_FLAGS ALTER_COLUMN_DEFAULT = 1ULL << 19;
3280
3281 // Change column generation expression
3282 static const HA_ALTER_FLAGS ALTER_VIRTUAL_GCOL_EXPR = 1ULL << 20;
3283 static const HA_ALTER_FLAGS ALTER_STORED_GCOL_EXPR = 1ULL << 21;
3284
3285 // Add foreign key
3286 static const HA_ALTER_FLAGS ADD_FOREIGN_KEY = 1ULL << 22;
3287
3288 // Drop foreign key
3289 static const HA_ALTER_FLAGS DROP_FOREIGN_KEY = 1ULL << 23;
3290
3291 // table_options changed, see HA_CREATE_INFO::used_fields for details.
3292 static const HA_ALTER_FLAGS CHANGE_CREATE_OPTION = 1ULL << 24;
3293
3294 // Table is renamed
3295 static const HA_ALTER_FLAGS ALTER_RENAME = 1ULL << 25;
3296
3297 // Change the storage type of column
3299
3300 // Change the column format of column
3302
3303 // Add partition
3304 static const HA_ALTER_FLAGS ADD_PARTITION = 1ULL << 28;
3305
3306 // Drop partition
3307 static const HA_ALTER_FLAGS DROP_PARTITION = 1ULL << 29;
3308
3309 // Changing partition options
3310 static const HA_ALTER_FLAGS ALTER_PARTITION = 1ULL << 30;
3311
3312 // Coalesce partition
3313 static const HA_ALTER_FLAGS COALESCE_PARTITION = 1ULL << 31;
3314
3315 // Reorganize partition ... into
3316 static const HA_ALTER_FLAGS REORGANIZE_PARTITION = 1ULL << 32;
3317
3318 // Reorganize partition
3319 static const HA_ALTER_FLAGS ALTER_TABLE_REORG = 1ULL << 33;
3320
3321 // Remove partitioning
3323
3324 // Partition operation with ALL keyword
3325 static const HA_ALTER_FLAGS ALTER_ALL_PARTITION = 1ULL << 35;
3326
3327 /**
3328 Rename index. Note that we set this flag only if there are no other
3329 changes to the index being renamed. Also for simplicity we don't
3330 detect renaming of indexes which is done by dropping index and then
3331 re-creating index with identical definition under different name.
3332 */
3333 static const HA_ALTER_FLAGS RENAME_INDEX = 1ULL << 36;
3334
3335 /**
3336 Recreate the table for ALTER TABLE FORCE, ALTER TABLE ENGINE
3337 and OPTIMIZE TABLE operations.
3338 */
3339 static const HA_ALTER_FLAGS RECREATE_TABLE = 1ULL << 37;
3340
3341 // Add spatial index
3342 static const HA_ALTER_FLAGS ADD_SPATIAL_INDEX = 1ULL << 38;
3343
3344 // Alter index comment
3345 static const HA_ALTER_FLAGS ALTER_INDEX_COMMENT = 1ULL << 39;
3346
3347 // New/changed virtual generated column require validation
3348 static const HA_ALTER_FLAGS VALIDATE_VIRTUAL_COLUMN = 1ULL << 40;
3349
3350 /**
3351 Change index option in a way which is likely not to require index
3352 recreation. For example, change COMMENT or KEY::is_algorithm_explicit
3353 flag (without change of index algorithm itself).
3354 */
3355 static const HA_ALTER_FLAGS CHANGE_INDEX_OPTION = 1LL << 41;
3356
3357 // Rebuild partition
3358 static const HA_ALTER_FLAGS ALTER_REBUILD_PARTITION = 1ULL << 42;
3359
3360 /**
3361 Change in index length such that it does not require index rebuild.
3362 For example, change in index length due to column expansion like
3363 varchar(X) changed to varchar(X + N).
3364 */
3366
3367 /**
3368 Change to one of columns on which virtual generated column depends,
3369 so its values require re-evaluation.
3370 */
3371 static const HA_ALTER_FLAGS VIRTUAL_GCOL_REEVAL = 1ULL << 44;
3372
3373 /**
3374 Change to one of columns on which stored generated column depends,
3375 so its values require re-evaluation.
3376 */
3377 static const HA_ALTER_FLAGS STORED_GCOL_REEVAL = 1ULL << 45;
3378
3379 // Add check constraint.
3380 static const HA_ALTER_FLAGS ADD_CHECK_CONSTRAINT = 1ULL << 46;
3381
3382 // Drop check constraint.
3383 static const HA_ALTER_FLAGS DROP_CHECK_CONSTRAINT = 1ULL << 47;
3384
3385 // Suspend check constraint.
3386 static const HA_ALTER_FLAGS SUSPEND_CHECK_CONSTRAINT = 1ULL << 48;
3387
3388 // Alter column visibility.
3389 static const HA_ALTER_FLAGS ALTER_COLUMN_VISIBILITY = 1ULL << 49;
3390
3391 /**
3392 Create options (like MAX_ROWS) for the new version of table.
3393
3394 @note The referenced instance of HA_CREATE_INFO object was already
3395 used to create new .FRM file for table being altered. So it
3396 has been processed by mysql_prepare_create_table() already.
3397 For example, this means that it has HA_OPTION_PACK_RECORD
3398 flag in HA_CREATE_INFO::table_options member correctly set.
3399 */
3401
3402 /**
3403 Alter options, fields and keys for the new version of table.
3404
3405 @note The referenced instance of Alter_info object was already
3406 used to create new .FRM file for table being altered. So it
3407 has been processed by mysql_prepare_create_table() already.
3408 In particular, this means that in Create_field objects for
3409 fields which were present in some form in the old version
3410 of table, Create_field::field member points to corresponding
3411 Field instance for old version of table.
3412 */
3414
3415 /**
3416 Indicates whether operation should fail if table is non-empty.
3417 Storage engines should not suggest/allow execution of such operations
3418 using INSTANT algorithm since check whether table is empty done from
3419 SQL-layer is not "instant". Also SEs might choose different algorithm for
3420 ALTER TABLE execution knowing that it will be allowed to proceed only if
3421 table is empty.
3422
3423 Unlike for Alter_table_ctx::error_if_not_empty, we use bool for this flag
3424 and not bitmap, since SEs are really interested in the fact that ALTER
3425 will fail if table is not empty and not in exact reason behind this fact,
3426 and because we want to avoid extra dependency between Alter_table_ctx and
3427 Alter_inplace_info.
3428 */
3430
3431 /**
3432 Array of KEYs for new version of table - including KEYs to be added.
3433
3434 @note Currently this array is produced as result of
3435 mysql_prepare_create_table() call.
3436 This means that it follows different convention for
3437 KEY_PART_INFO::fieldnr values than objects in TABLE::key_info
3438 array.
3439
3440 @todo This is mainly due to the fact that we need to keep compatibility
3441 with removed handler::add_index() call. We plan to switch to
3442 TABLE::key_info numbering later.
3443
3444 KEYs are sorted - see sort_keys().
3445 */
3447
3448 /** Size of key_info_buffer array. */
3450
3451 /** Size of index_drop_buffer array. */
3453
3454 /**
3455 Array of pointers to KEYs to be dropped belonging to the TABLE instance
3456 for the old version of the table.
3457 */
3459
3460 /** Size of index_add_buffer array. */
3462
3463 /**
3464 Array of indexes into key_info_buffer for KEYs to be added,
3465 sorted in increasing order.
3466 */
3468
3469 /** Size of index_rename_buffer array. */
3471
3472 /** Size of index_rename_buffer array. */
3474
3475 /**
3476 Array of KEY_PAIR objects describing indexes being renamed.
3477 For each index renamed it contains object with KEY_PAIR::old_key
3478 pointing to KEY object belonging to the TABLE instance for old
3479 version of table representing old version of index and with
3480 KEY_PAIR::new_key pointing to KEY object for new version of
3481 index in key_info_buffer member.
3482 */
3485
3486 /** Number of virtual columns to be added. */
3488
3489 /** number of virtual columns to be dropped. */
3491
3492 /**
3493 Context information to allow handlers to keep context between in-place
3494 alter API calls.
3495
3496 @see inplace_alter_handler_ctx for information about object lifecycle.
3497 */
3499
3500 /**
3501 If the table uses several handlers, like ha_partition uses one handler
3502 per partition, this contains a Null terminated array of ctx pointers
3503 that should all be committed together.
3504 Or NULL if only handler_ctx should be committed.
3505 Set to NULL if the low level handler::commit_inplace_alter_table uses it,
3506 to signal to the main handler that everything was committed as atomically.
3507
3508 @see inplace_alter_handler_ctx for information about object lifecycle.
3509 */
3511
3512 /**
3513 Flags describing in detail which operations the storage engine is to
3514 execute.
3515 */
3517
3518 /**
3519 Partition_info taking into account the partition changes to be performed.
3520 Contains all partitions which are present in the old version of the table
3521 with partitions to be dropped or changed marked as such + all partitions
3522 to be added in the new version of table marked as such.
3523 */
3525
3526 /** true for online operation (LOCK=NONE) */
3528
3529 /**
3530 Can be set by handler along with handler_ctx. The difference is that
3531 this flag can be used to store SE-specific in-place ALTER context in cases
3532 when constructing full-blown inplace_alter_handler_ctx descendant is
3533 inconvenient.
3534 */
3536
3537 /**
3538 Can be set by handler to describe why a given operation cannot be done
3539 in-place (HA_ALTER_INPLACE_NOT_SUPPORTED) or why it cannot be done
3540 online (HA_ALTER_INPLACE_NO_LOCK or HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE)
3541 If set, it will be used with ER_ALTER_OPERATION_NOT_SUPPORTED_REASON if
3542 results from handler::check_if_supported_inplace_alter() doesn't match
3543 requirements set by user. If not set, the more generic
3544 ER_ALTER_OPERATION_NOT_SUPPORTED will be used.
3545
3546 Please set to a properly localized string, for example using
3547 my_get_err_msg(), so that the error message as a whole is localized.
3548 */
3550
3552 Alter_info *alter_info_arg, bool error_if_not_empty_arg,
3553 KEY *key_info_arg, uint key_count_arg,
3554 partition_info *modified_part_info_arg)
3555 : create_info(create_info_arg),
3556 alter_info(alter_info_arg),
3557 error_if_not_empty(error_if_not_empty_arg),
3558 key_info_buffer(key_info_arg),
3559 key_count(key_count_arg),
3562 index_add_count(0),
3571 handler_flags(0),
3572 modified_part_info(modified_part_info_arg),
3573 online(false),
3576
3578
3579 /**
3580 Used after check_if_supported_inplace_alter() to report
3581 error if the result does not match the LOCK/ALGORITHM
3582 requirements set by the user.
3583
3584 @param not_supported Part of statement that was not supported.
3585 @param try_instead Suggestion as to what the user should
3586 replace not_supported with.
3587 */
3588 void report_unsupported_error(const char *not_supported,
3589 const char *try_instead);
3590
3591 /** Add old and new version of key to array of indexes to be renamed. */
3592 void add_renamed_key(KEY *old_key, KEY *new_key) {
3594 key_pair->old_key = old_key;
3595 key_pair->new_key = new_key;
3596 DBUG_PRINT("info",
3597 ("index renamed: '%s' to '%s'", old_key->name, new_key->name));
3598 }
3599
3600 void add_altered_index_visibility(KEY *old_key, KEY *new_key) {
3601 KEY_PAIR *key_pair =
3603 key_pair->old_key = old_key;
3604 key_pair->new_key = new_key;
3605 DBUG_PRINT("info", ("index had visibility altered: %i to %i",
3606 old_key->is_visible, new_key->is_visible));
3607 }
3608
3609 /**
3610 Add old and new version of modified key to arrays of indexes to
3611 be dropped and added (correspondingly).
3612 */
3613 void add_modified_key(KEY *old_key, KEY *new_key) {
3616 DBUG_PRINT("info", ("index changed: '%s'", old_key->name));
3617 }
3618
3619 /** Drop key to array of indexes to be dropped. */
3620 void add_dropped_key(KEY *old_key) {
3622 DBUG_PRINT("info", ("index dropped: '%s'", old_key->name));
3623 }
3624
3625 /** Add key to array of indexes to be added. */
3626 void add_added_key(KEY *new_key) {
3628 DBUG_PRINT("info", ("index added: '%s'", new_key->name));
3629 }
3630};
3631
3633 uint flags{0}; /* isam layer flags (e.g. for myisamchk) */
3634 uint sql_flags{0}; /* sql layer flags - for something myisamchk cannot do */
3635 KEY_CACHE *key_cache; /* new key cache when changing key cache */
3636};
3637
3638/*
3639 This is a buffer area that the handler can use to store rows.
3640 'end_of_used_area' should be kept updated after calls to
3641 read-functions so that other parts of the code can use the
3642 remaining area (until next read calls is issued).
3643*/
3644
3646 uchar *buffer; /* Buffer one can start using */
3647 uchar *buffer_end; /* End of buffer */
3648 uchar *end_of_used_area; /* End of area that was used by handler */
3649};
3650
3651typedef void *range_seq_t;
3652
3654 /*
3655 Initialize the traversal of range sequence
3656
3657 SYNOPSIS
3658 init()
3659 init_params The seq_init_param parameter
3660 n_ranges The number of ranges obtained
3661 flags A combination of HA_MRR_SINGLE_POINT, HA_MRR_FIXED_KEY
3662
3663 RETURN
3664 An opaque value to be used as RANGE_SEQ_IF::next() parameter
3665 */
3666 range_seq_t (*init)(void *init_params, uint n_ranges, uint flags);
3667
3668 /*
3669 Get the next range in the range sequence
3670
3671 SYNOPSIS
3672 next()
3673 seq The value returned by RANGE_SEQ_IF::init()
3674 range OUT Information about the next range
3675
3676 RETURN
3677 0 - Ok, the range structure filled with info about the next range
3678 1 - No more ranges
3679 */
3681
3682 /*
3683 Check whether range_info orders to skip the next record
3684
3685 SYNOPSIS
3686 skip_record()
3687 seq The value returned by RANGE_SEQ_IF::init()
3688 range_info Information about the next range
3689 (Ignored if MRR_NO_ASSOCIATION is set)
3690 rowid Rowid of the record to be checked (ignored if set to 0)
3691
3692 RETURN
3693 1 - Record with this range_info and/or this rowid shall be filtered
3694 out from the stream of records returned by ha_multi_range_read_next()
3695 0 - The record shall be left in the stream
3696 */
3697 bool (*skip_record)(range_seq_t seq, char *range_info, uchar *rowid);
3698};
3699
3700/**
3701 Used to store optimizer cost estimates.
3702
3703 The class consists of PODs only: default operator=, copy constructor
3704 and destructor are used.
3705 */
3707 private:
3708 double io_cost; ///< cost of I/O operations
3709 double cpu_cost; ///< cost of CPU operations
3710 double import_cost; ///< cost of remote operations
3711 double mem_cost; ///< memory used (bytes)
3712
3713 public:
3715
3716 /// Returns sum of time-consuming costs, i.e., not counting memory cost
3717 double total_cost() const { return io_cost + cpu_cost + import_cost; }
3718 double get_io_cost() const { return io_cost; }
3719 double get_cpu_cost() const { return cpu_cost; }
3720 double get_import_cost() const { return import_cost; }
3721 double get_mem_cost() const { return mem_cost; }
3722
3723 /**
3724 Whether or not all costs in the object are zero
3725
3726 @return true if all costs are zero, false otherwise
3727 */
3728 bool is_zero() const {
3729 return !(io_cost || cpu_cost || import_cost || mem_cost);
3730 }
3731 /**
3732 Whether or not the total cost is the maximal double
3733
3734 @return true if total cost is the maximal double, false otherwise
3735 */
3736 bool is_max_cost() const { return io_cost == DBL_MAX; }
3737 /// Reset all costs to zero
3739 /// Set current cost to the maximal double
3741 reset();
3742 io_cost = DBL_MAX;
3743 }
3744
3745 /// Multiply io, cpu and import costs by parameter
3746 void multiply(double m) {
3747 assert(!is_max_cost());
3748
3749 io_cost *= m;
3750 cpu_cost *= m;
3751 import_cost *= m;
3752 /* Don't multiply mem_cost */
3753 }
3754
3756 assert(!is_max_cost() && !other.is_max_cost());
3757
3758 io_cost += other.io_cost;
3759 cpu_cost += other.cpu_cost;
3760 import_cost += other.import_cost;
3761 mem_cost += other.mem_cost;
3762
3763 return *this;
3764 }
3765
3767 Cost_estimate result = *this;
3768 result += other;
3769
3770 return result;
3771 }
3772
3775
3776 assert(!other.is_max_cost());
3777
3778 result.io_cost = io_cost - other.io_cost;
3779 result.cpu_cost = cpu_cost - other.cpu_cost;
3780 result.import_cost = import_cost - other.import_cost;
3781 result.mem_cost = mem_cost - other.mem_cost;
3782 return result;
3783 }
3784
3785 bool operator>(const Cost_estimate &other) const {
3786 return total_cost() > other.total_cost() ? true : false;
3787 }
3788
3789 bool operator<(const Cost_estimate &other) const {
3790 return other > *this ? true : false;
3791 }
3792
3793 /// Add to IO cost
3794 void add_io(double add_io_cost) {
3795 assert(!is_max_cost());
3796 io_cost += add_io_cost;
3797 }
3798
3799 /// Add to CPU cost
3800 void add_cpu(double add_cpu_cost) {
3801 assert(!is_max_cost());
3802 cpu_cost += add_cpu_cost;
3803 }
3804
3805 /// Add to import cost
3806 void add_import(double add_import_cost) {
3807 assert(!is_max_cost());
3808 import_cost += add_import_cost;
3809 }
3810
3811 /// Add to memory cost
3812 void add_mem(double add_mem_cost) {
3813 assert(!is_max_cost());
3814 mem_cost += add_mem_cost;
3815 }
3816};
3817
3818void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted,
3819 Cost_estimate *cost);
3820
3821/*
3822 The below two are not used (and not handled) in this milestone of this WL
3823 entry because there seems to be no use for them at this stage of
3824 implementation.
3825*/
3826#define HA_MRR_SINGLE_POINT 1
3827#define HA_MRR_FIXED_KEY 2
3828
3829/*
3830 Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
3831 'range' parameter.
3832*/
3833#define HA_MRR_NO_ASSOCIATION 4
3834
3835/*
3836 The MRR user will provide ranges in key order, and MRR implementation
3837 must return rows in key order.
3838 Passing this flag to multi_read_range_init() may cause the
3839 default MRR handler to be used even if HA_MRR_USE_DEFAULT_IMPL
3840 was not specified.
3841 (If the native MRR impl. can not provide SORTED result)
3842*/
3843#define HA_MRR_SORTED 8
3844
3845/* MRR implementation doesn't have to retrieve full records */
3846#define HA_MRR_INDEX_ONLY 16
3847
3848/*
3849 The passed memory buffer is of maximum possible size, the caller can't
3850 assume larger buffer.
3851*/
3852#define HA_MRR_LIMITS 32
3853
3854/*
3855 Flag set <=> default MRR implementation is used
3856 (The choice is made by **_info[_const]() function which may set this
3857 flag. SQL layer remembers the flag value and then passes it to
3858 multi_read_range_init().
3859*/
3860#define HA_MRR_USE_DEFAULT_IMPL 64
3861
3862/*
3863 Used only as parameter to multi_range_read_info():
3864 Flag set <=> the caller guarantees that the bounds of the scanned ranges
3865 will not have NULL values.
3866*/
3867#define HA_MRR_NO_NULL_ENDPOINTS 128
3868
3869/*
3870 Set by the MRR implementation to signal that it will natively
3871 produced sorted result if multi_range_read_init() is called with
3872 the HA_MRR_SORTED flag - Else multi_range_read_init(HA_MRR_SORTED)
3873 will revert to use the default MRR implementation.
3874*/
3875#define HA_MRR_SUPPORT_SORTED 256
3876
3878 public:
3879 ulonglong data_file_length; /* Length off data file */
3880 ulonglong max_data_file_length; /* Length off data file */
3883 ulonglong delete_length; /* Free bytes */
3885 /*
3886 The number of records in the table.
3887 0 - means the table has exactly 0 rows
3888 other - if (table_flags() & HA_STATS_RECORDS_IS_EXACT)
3889 the value is the exact number of records in the table
3890 else
3891 it is an estimate
3892 */
3894 ha_rows deleted; /* Deleted records */
3895 ulong mean_rec_length; /* physical reclength */
3896 /* TODO: create_time should be retrieved from the new DD. Remove this. */
3897 time_t create_time; /* When table was created */
3900 uint block_size; /* index block size */
3901
3902 /*
3903 number of buffer bytes that native mrr implementation needs,
3904 */
3906
3907 /**
3908 Estimate for how much of the table that is available in a memory
3909 buffer. Valid range is [0..1]. If it has the special value
3910 IN_MEMORY_ESTIMATE_UNKNOWN (defined in structs.h), it means that
3911 the storage engine has not supplied any value for it.
3912 */
3914
3916 : data_file_length(0),
3919 delete_length(0),
3921 records(0),
3922 deleted(0),
3923 mean_rec_length(0),
3924 create_time(0),
3925 check_time(0),
3926 update_time(0),
3927 block_size(0),
3929};
3930
3931/**
3932 Calculates length of key.
3933
3934 Given a key index and a map of key parts return length of buffer used by key
3935 parts.
3936
3937 @param table Table containing the key
3938 @param key Key index
3939 @param keypart_map which key parts that is used
3940
3941 @return Length of used key parts.
3942*/
3943uint calculate_key_len(TABLE *table, uint key, key_part_map keypart_map);
3944/*
3945 bitmap with first N+1 bits set
3946 (keypart_map for a key prefix of [0..N] keyparts)
3947*/
3948#define make_keypart_map(N) (((key_part_map)2 << (N)) - 1)
3949/*
3950 bitmap with first N bits set
3951 (keypart_map for a key prefix of [0..N-1] keyparts)
3952*/
3953#define make_prev_keypart_map(N) (((key_part_map)1 << (N)) - 1)
3954
3955/** Base class to be used by handlers different shares */
3957 public:
3958 Handler_share() = default;
3959 virtual ~Handler_share() = default;
3960};
3961
3962/**
3963 Wrapper for struct ft_hints.
3964*/
3965
3967 private:
3969
3970 public:
3971 explicit Ft_hints(uint ft_flags) {
3972 hints.flags = ft_flags;
3974 hints.op_value = 0.0;
3976 }
3977
3978 /**
3979 Set comparison operation type and and value for master MATCH function.
3980
3981 @param type comparison operation type
3982 @param value comparison operation value
3983 */
3984 void set_hint_op(enum ft_operation type, double value) {
3985 hints.op_type = type;
3986 hints.op_value = value;
3987 }
3988
3989 /**
3990 Set Ft_hints flag.
3991
3992 @param ft_flag Ft_hints flag
3993 */
3994 void set_hint_flag(uint ft_flag) { hints.flags |= ft_flag; }
3995
3996 /**
3997 Set Ft_hints limit.
3998
3999 @param ft_limit limit
4000 */
4001 void set_hint_limit(ha_rows ft_limit) { hints.limit = ft_limit; }
4002
4003 /**
4004 Get Ft_hints limit.
4005
4006 @return Ft_hints limit
4007 */
4008 ha_rows get_limit() const { return hints.limit; }
4009
4010 /**
4011 Get Ft_hints operation value.
4012
4013 @return operation value
4014 */
4015 double get_op_value() const { return hints.op_value; }
4016
4017 /**
4018 Get Ft_hints operation type.
4019
4020 @return operation type
4021 */
4022 enum ft_operation get_op_type() const { return hints.op_type; }
4023
4024 /**
4025 Get Ft_hints flags.
4026
4027 @return Ft_hints flags
4028 */
4029 uint get_flags() const { return hints.flags; }
4030
4031 /**
4032 Get ft_hints struct.
4033
4034 @return pointer to ft_hints struct
4035 */
4037 return &hints;
4038 }
4039};
4040
4041/**
4042 The handler class is the interface for dynamically loadable
4043 storage engines. Do not add ifdefs and take care when adding or
4044 changing virtual functions to avoid vtable confusion
4045
4046 Functions in this class accept and return table columns data. Two data
4047 representation formats are used:
4048 1. TableRecordFormat - Used to pass [partial] table records to/from
4049 storage engine
4050
4051 2. KeyTupleFormat - used to pass index search tuples (aka "keys") to
4052 storage engine. See opt_range.cc for description of this format.
4053
4054 TableRecordFormat
4055 =================
4056 [Warning: this description is work in progress and may be incomplete]
4057 The table record is stored in a fixed-size buffer:
4058
4059 record: null_bytes, column1_data, column2_data, ...
4060
4061 The offsets of the parts of the buffer are also fixed: every column has
4062 an offset to its column{i}_data, and if it is nullable it also has its own
4063 bit in null_bytes.
4064
4065 The record buffer only includes data about columns that are marked in the
4066 relevant column set (table->read_set and/or table->write_set, depending on
4067 the situation).
4068 <not-sure>It could be that it is required that null bits of non-present
4069 columns are set to 1</not-sure>
4070
4071 VARIOUS EXCEPTIONS AND SPECIAL CASES
4072
4073 If the table has no nullable columns, then null_bytes is still
4074 present, its length is one byte <not-sure> which must be set to 0xFF
4075 at all times. </not-sure>
4076
4077 If the table has columns of type BIT, then certain bits from those columns
4078 may be stored in null_bytes as well. Grep around for Field_bit for
4079 details.
4080
4081 For blob columns (see Field_blob), the record buffer stores length of the
4082 data, following by memory pointer to the blob data. The pointer is owned
4083 by the storage engine and is valid until the next operation.
4084
4085 If a blob column has NULL value, then its length and blob data pointer
4086 must be set to 0.
4087
4088
4089 Overview of main modules of the handler API
4090 ===========================================
4091 The overview below was copied from the storage/partition/ha_partition.h when
4092 support for non-native partitioning was removed.
4093
4094 -------------------------------------------------------------------------
4095 MODULE create/delete handler object
4096 -------------------------------------------------------------------------
4097 Object create/delete method. Normally called when a table object
4098 exists.
4099
4100 -------------------------------------------------------------------------
4101 MODULE meta data changes
4102 -------------------------------------------------------------------------
4103 Meta data routines to CREATE, DROP, RENAME table are often used at
4104 ALTER TABLE (update_create_info used from ALTER TABLE and SHOW ..).
4105
4106 Methods:
4107 delete_table()
4108 rename_table()
4109 create()
4110 update_create_info()
4111
4112 -------------------------------------------------------------------------
4113 MODULE open/close object
4114 -------------------------------------------------------------------------
4115 Open and close handler object to ensure all underlying files and
4116 objects allocated and deallocated for query handling is handled
4117 properly.
4118
4119 A handler object is opened as part of its initialisation and before
4120 being used for normal queries (not before meta-data changes always.
4121 If the object was opened it will also be closed before being deleted.
4122
4123 Methods:
4124 open()
4125 close()
4126
4127 -------------------------------------------------------------------------
4128 MODULE start/end statement
4129 -------------------------------------------------------------------------
4130 This module contains methods that are used to understand start/end of
4131 statements, transaction boundaries, and aid for proper concurrency
4132 control.
4133
4134 Methods:
4135 store_lock()
4136 external_lock()
4137 start_stmt()
4138 lock_count()
4139 unlock_row()
4140 was_semi_consistent_read()
4141 try_semi_consistent_read()
4142
4143 -------------------------------------------------------------------------
4144 MODULE change record
4145 -------------------------------------------------------------------------
4146 This part of the handler interface is used to change the records
4147 after INSERT, DELETE, UPDATE, REPLACE method calls but also other
4148 special meta-data operations as ALTER TABLE, LOAD DATA, TRUNCATE.
4149
4150 These methods are used for insert (write_row), update (update_row)
4151 and delete (delete_row). All methods to change data always work on
4152 one row at a time. update_row and delete_row also contains the old
4153 row.
4154 delete_all_rows will delete all rows in the table in one call as a
4155 special optimization for DELETE from table;
4156
4157 Bulk inserts are supported if all underlying handlers support it.
4158 start_bulk_insert and end_bulk_insert is called before and after a
4159 number of calls to write_row.
4160
4161 Methods:
4162 write_row()
4163 update_row()
4164 delete_row()
4165 delete_all_rows()
4166 start_bulk_insert()
4167 end_bulk_insert()
4168
4169 -------------------------------------------------------------------------
4170 MODULE full table scan
4171 -------------------------------------------------------------------------
4172 This module is used for the most basic access method for any table
4173 handler. This is to fetch all data through a full table scan. No
4174 indexes are needed to implement this part.
4175 It contains one method to start the scan (rnd_init) that can also be
4176 called multiple times (typical in a nested loop join). Then proceeding
4177 to the next record (rnd_next) and closing the scan (rnd_end).
4178 To remember a record for later access there is a method (position)
4179 and there is a method used to retrieve the record based on the stored
4180 position.
4181 The position can be a file position, a primary key, a ROWID dependent
4182 on the handler below.
4183
4184 All functions that retrieve records and are callable through the
4185 handler interface must indicate whether a record is present after the call
4186 or not. Record found is indicated by returning 0 and setting table status
4187 to "has row". Record not found is indicated by returning a non-zero value
4188 and setting table status to "no row".
4189 @see TABLE::set_found_row() and TABLE::set_no_row().
4190 By enforcing these rules in the handler interface, storage handler functions
4191 need not set any status in struct TABLE. These notes also apply to module
4192 index scan, documented below.
4193
4194 Methods:
4195
4196 rnd_init()
4197 rnd_end()
4198 rnd_next()
4199 rnd_pos()
4200 rnd_pos_by_record()
4201 position()
4202
4203 -------------------------------------------------------------------------
4204 MODULE index scan
4205 -------------------------------------------------------------------------
4206 This part of the handler interface is used to perform access through
4207 indexes. The interface is defined as a scan interface but the handler
4208 can also use key lookup if the index is a unique index or a primary
4209 key index.
4210 Index scans are mostly useful for SELECT queries but are an important
4211 part also of UPDATE, DELETE, REPLACE and CREATE TABLE table AS SELECT
4212 and so forth.
4213 Naturally an index is needed for an index scan and indexes can either
4214 be ordered, hash based. Some ordered indexes can return data in order
4215 but not necessarily all of them.
4216 There are many flags that define the behavior of indexes in the
4217 various handlers. These methods are found in the optimizer module.
4218
4219 index_read is called to start a scan of an index. The find_flag defines
4220 the semantics of the scan. These flags are defined in
4221 include/my_base.h
4222 index_read_idx is the same but also initializes index before calling doing
4223 the same thing as index_read. Thus it is similar to index_init followed
4224 by index_read. This is also how we implement it.
4225
4226 index_read/index_read_idx does also return the first row. Thus for
4227 key lookups, the index_read will be the only call to the handler in
4228 the index scan.
4229
4230 index_init initializes an index before using it and index_end does
4231 any end processing needed.
4232
4233 Methods:
4234 index_read_map()
4235 index_init()
4236 index_end()
4237 index_read_idx_map()
4238 index_next()
4239 index_prev()
4240 index_first()
4241 index_last()
4242 index_next_same()
4243 index_read_last_map()
4244 read_range_first()
4245 read_range_next()
4246
4247 -------------------------------------------------------------------------
4248 MODULE information calls
4249 -------------------------------------------------------------------------
4250 This calls are used to inform the handler of specifics of the ongoing
4251 scans and other actions. Most of these are used for optimisation
4252 purposes.
4253
4254 Methods:
4255 info()
4256 get_dynamic_partition_info
4257 extra()
4258 extra_opt()
4259 reset()
4260
4261 -------------------------------------------------------------------------
4262 MODULE optimizer support
4263 -------------------------------------------------------------------------
4264 NOTE:
4265 One important part of the public handler interface that is not depicted in
4266 the methods is the attribute records which is defined in the base class.
4267 This is looked upon directly and is set by calling info(HA_STATUS_INFO) ?
4268
4269 Methods:
4270 min_rows_for_estimate()
4271 get_biggest_used_partition()
4272 scan_time()
4273 read_time()
4274 records_in_range()
4275 estimate_rows_upper_bound()
4276 records()
4277
4278 -------------------------------------------------------------------------
4279 MODULE print messages
4280 -------------------------------------------------------------------------
4281 This module contains various methods that returns text messages for
4282 table types, index type and error messages.
4283
4284 Methods:
4285 table_type()
4286 get_row_type()
4287 print_error()
4288 get_error_message()
4289
4290 -------------------------------------------------------------------------
4291 MODULE handler characteristics
4292 -------------------------------------------------------------------------
4293 This module contains a number of methods defining limitations and
4294 characteristics of the handler (see also documentation regarding the
4295 individual flags).
4296
4297 Methods:
4298 table_flags()
4299 index_flags()
4300 min_of_the_max_uint()
4301 max_supported_record_length()
4302 max_supported_keys()
4303 max_supported_key_parts()
4304 max_supported_key_length()
4305 max_supported_key_part_length()
4306 low_byte_first()
4307 extra_rec_buf_length()
4308 min_record_length(uint options)
4309 primary_key_is_clustered()
4310 ha_key_alg get_default_index_algorithm()
4311 is_index_algorithm_supported()
4312
4313 -------------------------------------------------------------------------
4314 MODULE compare records
4315 -------------------------------------------------------------------------
4316 cmp_ref checks if two references are the same. For most handlers this is
4317 a simple memcmp of the reference. However some handlers use primary key
4318 as reference and this can be the same even if memcmp says they are
4319 different. This is due to character sets and end spaces and so forth.
4320
4321 Methods:
4322 cmp_ref()
4323
4324 -------------------------------------------------------------------------
4325 MODULE auto increment
4326 -------------------------------------------------------------------------
4327 This module is used to handle the support of auto increments.
4328
4329 This variable in the handler is used as part of the handler interface
4330 It is maintained by the parent handler object and should not be
4331 touched by child handler objects (see handler.cc for its use).
4332
4333 Methods:
4334 get_auto_increment()
4335 release_auto_increment()
4336
4337 -------------------------------------------------------------------------
4338 MODULE initialize handler for HANDLER call
4339 -------------------------------------------------------------------------
4340 This method is a special InnoDB method called before a HANDLER query.
4341
4342 Methods:
4343 init_table_handle_for_HANDLER()
4344
4345 -------------------------------------------------------------------------
4346 MODULE fulltext index
4347 -------------------------------------------------------------------------
4348 Fulltext index support.
4349
4350 Methods:
4351 ft_init_ext_with_hints()
4352 ft_init()
4353 ft_init_ext()
4354 ft_read()
4355
4356 -------------------------------------------------------------------------
4357 MODULE in-place ALTER TABLE
4358 -------------------------------------------------------------------------
4359 Methods for in-place ALTER TABLE support (implemented by InnoDB and NDB).
4360
4361 Methods:
4362 check_if_supported_inplace_alter()
4363 prepare_inplace_alter_table()
4364 inplace_alter_table()
4365 commit_inplace_alter_table()
4366 notify_table_changed()
4367
4368 -------------------------------------------------------------------------
4369 MODULE tablespace support
4370 -------------------------------------------------------------------------
4371 Methods:
4372 discard_or_import_tablespace()
4373
4374 -------------------------------------------------------------------------
4375 MODULE administrative DDL
4376 -------------------------------------------------------------------------
4377 Methods:
4378 optimize()
4379 analyze()
4380 check()
4381 repair()
4382 check_and_repair()
4383 auto_repair()
4384 is_crashed()
4385 check_for_upgrade()
4386 checksum()
4387 assign_to_keycache()
4388
4389 -------------------------------------------------------------------------
4390 MODULE enable/disable indexes
4391 -------------------------------------------------------------------------
4392 Enable/Disable Indexes are only supported by HEAP and MyISAM.
4393
4394 Methods:
4395 disable_indexes()
4396 enable_indexes()
4397 indexes_are_disabled()
4398
4399 -------------------------------------------------------------------------
4400 MODULE append_create_info
4401 -------------------------------------------------------------------------
4402 Only used by MyISAM MERGE tables.
4403
4404 Methods:
4405 append_create_info()
4406
4407 -------------------------------------------------------------------------
4408 MODULE partitioning specific handler API
4409 -------------------------------------------------------------------------
4410 Methods:
4411 get_partition_handler()
4412*/
4413
4414class handler {
4415 friend class Partition_handler;
4416
4417 public:
4419
4420 protected:
4421 TABLE_SHARE *table_share; /* The table definition */
4422 TABLE *table; /* The current open table */
4423 Table_flags cached_table_flags{0}; /* Set on init() and open() */
4424
4426
4427 public:
4428 handlerton *ht; /* storage engine of this handler */
4429 /** Pointer to current row */
4431 /** Pointer to duplicate row */
4433
4435
4436 /* MultiRangeRead-related members: */
4437 range_seq_t mrr_iter; /* Iterator to traverse the range sequence */
4438 RANGE_SEQ_IF mrr_funcs; /* Range sequence traversal functions */
4439 HANDLER_BUFFER *multi_range_buffer; /* MRR buffer info */
4440 uint ranges_in_seq; /* Total number of ranges in the traversed sequence */
4441 /* true <=> source MRR ranges and the output are ordered */
4443
4444 /* true <=> we're currently traversing a range in mrr_cur_range. */
4446 /* Current range (the one we're now returning rows from) */
4448
4449 /*
4450 The direction of the current range or index scan. This is used by
4451 the ICP implementation to determine if it has reached the end
4452 of the current range.
4453 */
4455
4456 private:
4457 Record_buffer *m_record_buffer = nullptr; ///< Buffer for multi-row reads.
4458 /*
4459 Storage space for the end range value. Should only be accessed using
4460 the end_range pointer. The content is invalid when end_range is NULL.
4461 */
4465
4466 /**
4467 Pointer to the handler of the table in the primary storage engine,
4468 if this handler represents a table in a secondary storage engine.
4469 */
4471
4472 protected:
4475 /*
4476 true <=> the engine guarantees that returned records are within the range
4477 being scanned.
4478 */
4480
4481 public:
4482 /**
4483 End value for a range scan. If this is NULL the range scan has no
4484 end value. Should also be NULL when there is no ongoing range scan.
4485 Used by the read_range() functions and also evaluated by pushed
4486 index conditions.
4487 */
4489 /**
4490 Flag which tells if #end_range contains a virtual generated column.
4491 The content is invalid when #end_range is @c nullptr.
4492 */
4494 uint errkey; /* Last dup key */
4497 /** Length of ref (1-8 or the clustered key length) */
4500 enum { NONE = 0, INDEX, RND, SAMPLING } inited;
4501 bool implicit_emptied; /* Can be !=0 only if HEAP */
4503
4505 uint pushed_idx_cond_keyno; /* The index which the above condition is for */
4506
4507 /**
4508 next_insert_id is the next value which should be inserted into the
4509 auto_increment column: in a inserting-multi-row statement (like INSERT
4510 SELECT), for the first row where the autoinc value is not specified by the
4511 statement, get_auto_increment() called and asked to generate a value,
4512 next_insert_id is set to the next value, then for all other rows
4513 next_insert_id is used (and increased each time) without calling
4514 get_auto_increment().
4515 */
4517 /**
4518 insert id for the current row (*autogenerated*; if not
4519 autogenerated, it's 0).
4520 At first successful insertion, this variable is stored into
4521 THD::first_successful_insert_id_in_cur_stmt.
4522 */
4524 /**
4525 Interval returned by get_auto_increment() and being consumed by the
4526 inserter.
4527 */
4529 /**
4530 Number of reserved auto-increment intervals. Serves as a heuristic
4531 when we have no estimation of how many records the statement will insert:
4532 the more intervals we have reserved, the bigger the next one. Reset in
4533 handler::ha_release_auto_increment().
4534 */
4536
4537 /**
4538 Instrumented table associated with this handler.
4539 */
4541
4544
4545 private:
4546 /** Internal state of the batch instrumentation. */
4548 /** Batch mode not used. */
4550 /** Batch mode used, before first table io. */
4552 /** Batch mode used, after first table io. */
4555 /**
4556 Batch mode state.
4557 @sa start_psi_batch_mode.
4558 @sa end_psi_batch_mode.
4559 */
4561 /**
4562 The number of rows in the batch.
4563 @sa start_psi_batch_mode.
4564 @sa end_psi_batch_mode.
4565 */
4567 /**
4568 The current event in a batch.
4569 @sa start_psi_batch_mode.
4570 @sa end_psi_batch_mode.
4571 */
4573 /**
4574 Storage for the event in a batch.
4575 @sa start_psi_batch_mode.
4576 @sa end_psi_batch_mode.
4577 */
4579
4580 public:
4581 void unbind_psi();
4582 void rebind_psi();
4583 /**
4584 Put the handler in 'batch' mode when collecting
4585 table io instrumented events.
4586 When operating in batch mode:
4587 - a single start event is generated in the performance schema.
4588 - all table io performed between @c start_psi_batch_mode
4589 and @c end_psi_batch_mode is not instrumented:
4590 the number of rows affected is counted instead in @c m_psi_numrows.
4591 - a single end event is generated in the performance schema
4592 when the batch mode ends with @c end_psi_batch_mode.
4593 */
4594 void start_psi_batch_mode();
4595 /** End a batch started with @c start_psi_batch_mode. */
4596 void end_psi_batch_mode();
4597 /**
4598 If a PSI batch was started, turn if off.
4599 @returns true if it was started.
4600 */
4602 bool rc = m_psi_batch_mode;
4603 if (rc) end_psi_batch_mode();
4604 return rc;
4605 }
4606
4607 private:
4608 /**
4609 The lock type set by when calling::ha_external_lock(). This is
4610 propagated down to the storage engine. The reason for also storing
4611 it here, is that when doing MRR we need to create/clone a second handler
4612 object. This cloned handler object needs to know about the lock_type used.
4613 */
4615 /**
4616 Pointer where to store/retrieve the Handler_share pointer.
4617 For non partitioned handlers this is &TABLE_SHARE::ha_share.
4618 */
4620
4621 /**
4622 Some non-virtual ha_* functions, responsible for reading rows,
4623 like ha_rnd_pos(), must ensure that virtual generated columns are
4624 calculated before they return. For that, they should set this
4625 member to true at their start, and check it before they return: if
4626 the member is still true, it means they should calculate; if it's
4627 false, it means the calculation has been done by some called
4628 lower-level function and does not need to be re-done (which is why
4629 we need this status flag: to avoid redundant calculations, for
4630 performance).
4631
4632 Note that when updating generated fields, the NULL row status in
4633 the underlying TABLE objects matter, so be sure to reset them if needed!
4634 */
4636
4637 /* Filter row ids to weed out duplicates when multi-valued index is used */
4639
4640 public:
4641 handler(handlerton *ht_arg, TABLE_SHARE *share_arg)
4642 : table_share(share_arg),
4643 table(nullptr),
4645 ht(ht_arg),
4646 ref(nullptr),
4652 ref_length(sizeof(my_off_t)),
4654 inited(NONE),
4655 implicit_emptied(false),
4659 next_insert_id(0),
4662 m_psi(nullptr),
4664 m_psi_numrows(0),
4666 m_lock_type(F_UNLCK),
4669 m_unique(nullptr) {
4670 DBUG_PRINT("info", ("handler created F_UNLCK %d F_RDLCK %d F_WRLCK %d",
4671 F_UNLCK, F_RDLCK, F_WRLCK));
4672 }
4673
4674 virtual ~handler(void) {
4675 assert(m_psi == nullptr);
4677 assert(m_psi_locker == nullptr);
4678 assert(m_lock_type == F_UNLCK);
4679 assert(inited == NONE);
4680 }
4681
4682 /**
4683 Return extra handler specific text for EXPLAIN.
4684 */
4685 virtual std::string explain_extra() const { return ""; }
4686
4687 /*
4688 @todo reorganize functions, make proper public/protected/private qualifiers
4689 */
4690 virtual handler *clone(const char *name, MEM_ROOT *mem_root);
4691 /** This is called after create to allow us to set up cached variables */
4693 /* ha_ methods: public wrappers for private virtual API */
4694
4695 /**
4696 Set a record buffer that the storage engine can use for multi-row reads.
4697 The buffer has to be provided prior to the first read from an index or a
4698 table.
4699
4700 @param buffer the buffer to use for multi-row reads
4701 */
4703
4704 /**
4705 Get the record buffer that was set with ha_set_record_buffer().
4706
4707 @return the buffer to use for multi-row reads, or nullptr if there is none
4708 */
4710
4711 /**
4712 Does this handler want to get a Record_buffer for multi-row reads
4713 via the ha_set_record_buffer() function? And if so, what is the
4714 maximum number of records to allocate space for in the buffer?
4715
4716 Storage engines that support using a Record_buffer should override
4717 handler::is_record_buffer_wanted().
4718
4719 @param[out] max_rows gets set to the maximum number of records to
4720 allocate space for in the buffer if the function
4721 returns true
4722
4723 @retval true if the handler would like a Record_buffer
4724 @retval false if the handler does not want a Record_buffer
4725 */
4726 bool ha_is_record_buffer_wanted(ha_rows *const max_rows) const {
4727 return is_record_buffer_wanted(max_rows);
4728 }
4729
4730 int ha_open(TABLE *table, const char *name, int mode, int test_if_locked,
4731 const dd::Table *table_def);
4732 int ha_close(void);
4733 int ha_index_init(uint idx, bool sorted);
4734 int ha_index_end();
4735 int ha_rnd_init(bool scan);
4736 int ha_rnd_end();
4737 int ha_rnd_next(uchar *buf);
4738 // See the comment on m_update_generated_read_fields.
4739 int ha_rnd_pos(uchar *buf, uchar *pos);
4740 int ha_index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map,
4741 enum ha_rkey_function find_flag);
4743 key_part_map keypart_map);
4744 int ha_index_read_idx_map(uchar *buf, uint index, const uchar *key,
4745 key_part_map keypart_map,
4746 enum ha_rkey_function find_flag);
4747 int ha_index_next(uchar *buf);
4748 int ha_index_prev(uchar *buf);
4749 int ha_index_first(uchar *buf);
4750 int ha_index_last(uchar *buf);
4751 int ha_index_next_same(uchar *buf, const uchar *key, uint keylen);
4752 int ha_reset();
4753 /* this is necessary in many places, e.g. in HANDLER command */
4755 return inited == INDEX ? ha_index_end() : inited == RND ? ha_rnd_end() : 0;
4756 }
4757 /**
4758 The cached_table_flags is set at ha_open and ha_external_lock
4759 */
4761 /**
4762 These functions represent the public interface to *users* of the
4763 handler class, hence they are *not* virtual. For the inheritance
4764 interface, see the (private) functions write_row(), update_row(),
4765 and delete_row() below.
4766 */
4767 int ha_external_lock(THD *thd, int lock_type);
4768 int ha_write_row(uchar *buf);
4769 /**
4770 Update the current row.
4771
4772 @param old_data the old contents of the row
4773 @param new_data the new contents of the row
4774 @return error status (zero on success, HA_ERR_* error code on error)
4775 */
4776 int ha_update_row(const uchar *old_data, uchar *new_data);
4777 int ha_delete_row(const uchar *buf);
4779
4780 int ha_check_for_upgrade(HA_CHECK_OPT *check_opt);
4781 /** to be actually called to get 'check()' functionality*/
4782 int ha_check(THD *thd, HA_CHECK_OPT *check_opt);
4783 int ha_repair(THD *thd, HA_CHECK_OPT *check_opt);
4784 void ha_start_bulk_insert(ha_rows rows);
4785 int ha_end_bulk_insert();
4786 int ha_bulk_update_row(const uchar *old_data, uchar *new_data,
4787 uint *dup_key_found);
4788 int ha_delete_all_rows();
4790 int ha_optimize(THD *thd, HA_CHECK_OPT *check_opt);
4791 int ha_analyze(THD *thd, HA_CHECK_OPT *check_opt);
4792 bool ha_check_and_repair(THD *thd);
4796 int ha_rename_table(const char *from, const char *to,
4797 const dd::Table *from_table_def, dd::Table *to_table_def);
4798 int ha_delete_table(const char *name, const dd::Table *table_def);
4799 void ha_drop_table(const char *name);
4800
4801 int ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info,
4803
4804 int ha_load_table(const TABLE &table);
4805
4806 int ha_unload_table(const char *db_name, const char *table_name,
4807 bool error_if_not_loaded);
4808
4809 /**
4810 Initializes a parallel scan. It creates a parallel_scan_ctx that has to
4811 be used across all parallel_scan methods. Also, gets the number of
4812 threads that would be spawned for parallel scan.
4813 @param[out] scan_ctx The parallel scan context.
4814 @param[out] num_threads Number of threads used for the scan.
4815 @param[in] use_reserved_threads true if reserved threads are to be used
4816 if we exhaust the max cap of number of
4817 parallel read threads that can be
4818 spawned at a time
4819 @return error code
4820 @retval 0 on success
4821 */
4822 virtual int parallel_scan_init(void *&scan_ctx [[maybe_unused]],
4823 size_t *num_threads [[maybe_unused]],
4824 bool use_reserved_threads [[maybe_unused]]) {
4825 return 0;
4826 }
4827
4828 /**
4829 This callback is called by each parallel load thread at the beginning of
4830 the parallel load for the adapter scan.
4831 @param cookie The cookie for this thread
4832 @param ncols Number of columns in each row
4833 @param row_len The size of a row in bytes
4834 @param col_offsets An array of size ncols, where each element represents
4835 the offset of a column in the row data. The memory of
4836 this array belongs to the caller and will be free-ed
4837 after the pload_end_cbk call.
4838 @param null_byte_offsets An array of size ncols, where each element
4839 represents the offset of a column in the row data. The
4840 memory of this array belongs to the caller and will be
4841 free-ed after the pload_end_cbk call.
4842 @param null_bitmasks An array of size ncols, where each element
4843 represents the bitmask required to get the null bit. The
4844 memory of this array belongs to the caller and will be
4845 free-ed after the pload_end_cbk call.
4846 */
4847 using Load_init_cbk = std::function<bool(
4848 void *cookie, ulong ncols, ulong row_len, const ulong *col_offsets,
4849 const ulong *null_byte_offsets, const ulong *null_bitmasks)>;
4850
4851 /**
4852 This callback is called by each parallel load thread when processing
4853 of rows is required for the adapter scan.
4854 @param[in] cookie The cookie for this thread
4855 @param[in] nrows The nrows that are available
4856 @param[in] rowdata The mysql-in-memory row data buffer. This is a
4857 memory buffer for nrows records. The length of each record is fixed and
4858 communicated via Load_init_cbk
4859 @param[in] partition_id Partition id if it's a partitioned table, else
4860 std::numeric_limits<uint64_t>::max()
4861 @returns true if there is an error, false otherwise.
4862 */
4863 using Load_cbk = std::function<bool(void *cookie, uint nrows, void *rowdata,
4864 uint64_t partition_id)>;
4865
4866 /**
4867 This callback is called by each parallel load thread when processing
4868 of rows has ended for the adapter scan.
4869 @param[in] cookie The cookie for this thread
4870 */
4871 using Load_end_cbk = std::function<void(void *cookie)>;
4872
4873 /**
4874 Run the parallel read of data.
4875 @param[in] scan_ctx Scan context of the parallel read.
4876 @param[in,out] thread_ctxs Caller thread contexts.
4877 @param[in] init_fn Callback called by each parallel load
4878 thread at the beginning of the parallel load.
4879 @param[in] load_fn Callback called by each parallel load
4880 thread when processing of rows is required.
4881 @param[in] end_fn Callback called by each parallel load
4882 thread when processing of rows has ended.
4883 @return error code
4884 @retval 0 on success
4885 */
4886 virtual int parallel_scan(void *scan_ctx [[maybe_unused]],
4887 void **thread_ctxs [[maybe_unused]],
4888 Load_init_cbk init_fn [[maybe_unused]],
4889 Load_cbk load_fn [[maybe_unused]],
4890 Load_end_cbk end_fn [[maybe_unused]]) {
4891 return 0;
4892 }
4893
4894 /**
4895 End of the parallel scan.
4896 @param[in] scan_ctx A scan context created by parallel_scan_init.
4897 */
4898 virtual void parallel_scan_end(void *scan_ctx [[maybe_unused]]) { return; }
4899
4900 /**
4901 Submit a dd::Table object representing a core DD table having
4902 hardcoded data to be filled in by the DDSE. This function can be
4903 used for retrieving the hard coded SE private data for the
4904 mysql.dd_properties table, before creating or opening it, or for
4905 retrieving the hard coded SE private data for a core table,
4906 before creating or opening them.
4907
4908 @param dd_table [in,out] A dd::Table object representing
4909 a core DD table.
4910 @param reset Reset counters.
4911
4912 @retval true An error occurred.
4913 @retval false Success - no errors.
4914 */
4915
4916 bool ha_get_se_private_data(dd::Table *dd_table, bool reset);
4917
4920 virtual void print_error(int error, myf errflag);
4921 virtual bool get_error_message(int error, String *buf);
4922 uint get_dup_key(int error);
4923 /**
4924 Retrieves the names of the table and the key for which there was a
4925 duplicate entry in the case of HA_ERR_FOREIGN_DUPLICATE_KEY.
4926
4927 If any of the table or key name is not available this method will return
4928 false and will not change any of child_table_name or child_key_name.
4929
4930 @param [out] child_table_name Table name
4931 @param [in] child_table_name_len Table name buffer size
4932 @param [out] child_key_name Key name
4933 @param [in] child_key_name_len Key name buffer size
4934
4935 @retval true table and key names were available
4936 and were written into the corresponding
4937 out parameters.
4938 @retval false table and key names were not available,
4939 the out parameters were not touched.
4940 */
4941 virtual bool get_foreign_dup_key(char *child_table_name,
4942 uint child_table_name_len,
4943 char *child_key_name,
4944 uint child_key_name_len);
4945 /**
4946 Change the internal TABLE_SHARE pointer.
4947
4948 @param table_arg TABLE object
4949 @param share New share to use
4950
4951 @note Is used in error handling in ha_delete_table.
4952 */
4953
4954 virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) {
4955 table = table_arg;
4956 table_share = share;
4957 }
4958 const TABLE_SHARE *get_table_share() const { return table_share; }
4959
4960 /* Estimates calculation */
4961
4962 /**
4963 @deprecated This function is deprecated and will be removed in a future
4964 version. Use table_scan_cost() instead.
4965 */
4966
4967 virtual double scan_time() {
4968 return ulonglong2double(stats.data_file_length) / IO_SIZE + 2;
4969 }
4970
4971 /**
4972 The cost of reading a set of ranges from the table using an index
4973 to access it.
4974
4975 @deprecated This function is deprecated and will be removed in a future
4976 version. Use read_cost() instead.
4977
4978 @param index The index number.
4979 @param ranges The number of ranges to be read.
4980 @param rows Total number of rows to be read.
4981
4982 This method can be used to calculate the total cost of scanning a table
4983 using an index by calling it using read_time(index, 1, table_size).
4984 */
4985
4986 virtual double read_time(uint index [[maybe_unused]], uint ranges,
4987 ha_rows rows) {
4988 return rows2double(ranges + rows);
4989 }
4990
4991 /**
4992 @deprecated This function is deprecated and will be removed in a future
4993 version. Use index_scan_cost() instead.
4994 */
4995
4996 virtual double index_only_read_time(uint keynr, double records);
4997
4998 /**
4999 Cost estimate for doing a complete table scan.
5000
5001 @note For this version it is recommended that storage engines continue
5002 to override scan_time() instead of this function.
5003
5004 @returns the estimated cost
5005 */
5006
5008
5009 /**
5010 Cost estimate for reading a number of ranges from an index.
5011
5012 The cost estimate will only include the cost of reading data that
5013 is contained in the index. If the records need to be read, use
5014 read_cost() instead.
5015
5016 @note The ranges parameter is currently ignored and is not taken
5017 into account in the cost estimate.
5018
5019 @note For this version it is recommended that storage engines continue
5020 to override index_only_read_time() instead of this function.
5021
5022 @param index the index number
5023 @param ranges the number of ranges to be read
5024 @param rows total number of rows to be read
5025
5026 @returns the estimated cost
5027 */
5028
5029 virtual Cost_estimate index_scan_cost(uint index, double ranges, double rows);
5030
5031 /**
5032 Cost estimate for reading a set of ranges from the table using an index
5033 to access it.
5034
5035 @note For this version it is recommended that storage engines continue
5036 to override read_time() instead of this function.
5037
5038 @param index the index number
5039 @param ranges the number of ranges to be read
5040 @param rows total number of rows to be read
5041
5042 @returns the estimated cost
5043 */
5044
5045 virtual Cost_estimate read_cost(uint index, double ranges, double rows);
5046
5047 /**
5048 Cost estimate for doing a number of non-sequentially accesses
5049 against the storage engine. Such accesses can be either number
5050 of rows to read, or number of disk pages to access.
5051 Each handler implementation is free to interpret that as best
5052 suited, depending on what is the dominating cost for that
5053 storage engine.
5054
5055 This method is mainly provided as a temporary workaround for
5056 bug#33317872, where we fix problems caused by calling
5057 Cost_model::page_read_cost() directly from the optimizer.
5058 That should be avoided, as it introduced assumption about all
5059 storage engines being disk-page based, and having a 'page' cost.
5060 Furthermore, this page cost was even compared against read_cost(),
5061 which was computed with an entirely different algorithm, and thus
5062 could not be compared.
5063
5064 The default implementation still call Cost_model::page_read_cost(),
5065 thus behaving just as before. However, handler implementation may
5066 override it to call handler::read_cost() instead(), which probably
5067 will be more correct. (If a page_read_cost should be included
5068 in the cost estimate, that should preferable be done inside
5069 each read_cost() implementation)
5070
5071 Longer term we should consider to remove all page_read_cost()
5072 usage from the optimizer itself, making this method obsolete.
5073
5074 @param index the index number
5075 @param reads the number of accesses being made
5076
5077 @returns the estimated cost
5078 */
5079 virtual double page_read_cost(uint index, double reads);
5080
5081 /**
5082 Provide an upper cost-limit of doing a specified number of
5083 seek-and-read key lookups. This need to be comparable and
5084 calculated with the same 'metric' as page_read_cost.
5085
5086 @param reads the number of rows read in the 'worst' case.
5087
5088 @returns the estimated cost
5089 */
5090 virtual double worst_seek_times(double reads);
5091
5092 /**
5093 Return an estimate on the amount of memory the storage engine will
5094 use for caching data in memory. If this is unknown or the storage
5095 engine does not cache data in memory -1 is returned.
5096 */
5097 virtual longlong get_memory_buffer_size() const { return -1; }
5098
5099 /**
5100 Return an estimate of how much of the table that is currently stored
5101 in main memory.
5102
5103 This estimate should be the fraction of the table that currently
5104 is available in a main memory buffer. The estimate should be in the
5105 range from 0.0 (nothing in memory) to 1.0 (entire table in memory).
5106
5107 @return The fraction of the table in main memory buffer
5108 */
5109
5110 double table_in_memory_estimate() const;
5111
5112 /**
5113 Return an estimate of how much of the index that is currently stored
5114 in main memory.
5115
5116 This estimate should be the fraction of the index that currently
5117 is available in a main memory buffer. The estimate should be in the
5118 range from 0.0 (nothing in memory) to 1.0 (entire index in memory).
5119
5120 @param keyno the index to get an estimate for
5121
5122 @return The fraction of the index in main memory buffer
5123 */
5124
5125 double index_in_memory_estimate(uint keyno) const;
5126
5127 /**
5128 Initialize sampling.
5129
5130 @param[out] scan_ctx A scan context created by this method that has to be
5131 used in sample_next
5132 @param[in] sampling_percentage percentage of records that need to be
5133 sampled
5134 @param[in] sampling_seed random seed that the random generator will
5135 use
5136 @param[in] sampling_method sampling method to be used; currently only
5137 SYSTEM sampling is supported
5138 @param[in] tablesample true if the sampling is for tablesample
5139
5140 @return 0 for success, else one of the HA_xxx values in case of error.
5141 */
5142 int ha_sample_init(void *&scan_ctx, double sampling_percentage,
5143 int sampling_seed, enum_sampling_method sampling_method,
5144 const bool tablesample);
5145
5146 /**
5147 Get the next record for sampling.
5148
5149 @param[in] scan_ctx Scan context of the sampling
5150 @param[in] buf buffer to place the read record
5151
5152 @return 0 for success, else one of the HA_xxx values in case of error.
5153 */
5154 int ha_sample_next(void *scan_ctx, uchar *buf);
5155
5156 /**
5157 End sampling.
5158
5159 @param[in] scan_ctx Scan context of the sampling
5160
5161 @return 0 for success, else one of the HA_xxx values in case of error.
5162 */
5163 int ha_sample_end(void *scan_ctx);
5164
5165 private:
5167
5168 /**
5169 Make a guesstimate for how much of a table or index is in a memory
5170 buffer in the case where the storage engine has not provided any
5171 estimate for this.
5172
5173 @param table_index_size size of the table or index
5174
5175 @return The fraction of the table or index in main memory buffer
5176 */
5177
5178 double estimate_in_memory_buffer(ulonglong table_index_size) const;
5179
5180 public:
5182 void *seq_init_param,
5183 uint n_ranges, uint *bufsz,
5184 uint *flags, Cost_estimate *cost);
5185 virtual ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
5186 uint *bufsz, uint *flags,
5187 Cost_estimate *cost);
5188 virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
5189 uint n_ranges, uint mode,
5191
5192 int ha_multi_range_read_next(char **range_info);
5193
5194 int ha_read_range_first(const key_range *start_key, const key_range *end_key,
5195 bool eq_range, bool sorted);
5196 int ha_read_range_next();
5197
5199 return (ha_table_flags() & HA_NO_TRANSACTIONS) == 0;
5200 }
5201 virtual uint extra_rec_buf_length() const { return 0; }
5202
5203 /**
5204 @brief Determine whether an error can be ignored or not.
5205
5206 @details This method is used to analyze the error to see whether the
5207 error is ignorable or not. Such errors will be reported as warnings
5208 instead of errors for IGNORE statements. This means that the statement
5209 will not abort, but instead continue to the next row.
5210
5211 HA_ERR_FOUND_DUP_UNIQUE is a special case in MyISAM that means the
5212 same thing as HA_ERR_FOUND_DUP_KEY, but can in some cases lead to
5213 a slightly different error message.
5214
5215 @param error error code received from the handler interface (HA_ERR_...)
5216
5217 @return whether the error is ignorable or not
5218 @retval true the error is ignorable
5219 @retval false the error is not ignorable
5220 */
5221
5222 virtual bool is_ignorable_error(int error);
5223
5224 /**
5225 @brief Determine whether an error is fatal or not.
5226
5227 @details This method is used to analyze the error to see whether the
5228 error is fatal or not. A fatal error is an error that will not be
5229 possible to handle with SP handlers and will not be subject to
5230 retry attempts on the slave.
5231
5232 @param error error code received from the handler interface (HA_ERR_...)
5233
5234 @return whether the error is fatal or not
5235 @retval true the error is fatal
5236 @retval false the error is not fatal
5237 */
5238
5239 virtual bool is_fatal_error(int error);
5240
5241 protected:
5242 virtual int multi_range_read_next(char **range_info);
5243
5244 /**
5245 Number of rows in table. If HA_COUNT_ROWS_INSTANT is set, count is
5246 available instantly. Else do a table scan.
5247
5248 @param num_rows [out] num_rows number of rows in table.
5249
5250 @retval 0 for OK, one of the HA_xxx values in case of error.
5251 */
5252 virtual int records(ha_rows *num_rows);
5253
5254 /**
5255 Number of rows in table counted using the secondary index chosen by
5256 optimizer. See comments in optimize_aggregated_query() .
5257
5258 @param num_rows [out] Number of rows in table.
5259 @param index Index chosen by optimizer for counting.
5260
5261 @retval 0 for OK, one of the HA_xxx values in case of error.
5262 */
5263 virtual int records_from_index(ha_rows *num_rows, uint index);
5264
5265 private:
5266 /**
5267 Function will handle the error code from call to records() and
5268 records_from_index().
5269
5270 @param error return code from records() and records_from_index().
5271 @param num_rows Check if it contains HA_POS_ERROR in case error < 0.
5272
5273 @retval 0 for OK, one of the HA_xxx values in case of error.
5274 */
5275 int handle_records_error(int error, ha_rows *num_rows);
5276
5277 public:
5278 /**
5279 Wrapper function to call records() in storage engine.
5280
5281 @param num_rows [out] Number of rows in table.
5282
5283 @retval 0 for OK, one of the HA_xxx values in case of error.
5284 */
5285 int ha_records(ha_rows *num_rows) {
5286 return handle_records_error(records(num_rows), num_rows);
5287 }
5288
5289 /**
5290 Wrapper function to call records_from_index() in storage engine.
5291
5292 @param num_rows [out] Number of rows in table.
5293 @param index Index chosen by optimizer for counting.
5294
5295 @retval 0 for OK, one of the HA_xxx values in case of error.
5296 */
5297 int ha_records(ha_rows *num_rows, uint index) {
5298 return handle_records_error(records_from_index(num_rows, index), num_rows);
5299 }
5300
5301 /**
5302 Return upper bound of current number of records in the table
5303 (max. of how many records one will retrieve when doing a full table scan)
5304 If upper bound is not known, HA_POS_ERROR should be returned as a max
5305 possible upper bound.
5306 */
5308 return stats.records + EXTRA_RECORDS;
5309 }
5310
5311 /**
5312 Get real row type for the table created based on one specified by user,
5313 CREATE TABLE options and SE capabilities.
5314 */
5316 const HA_CREATE_INFO *create_info) const {
5317 return (create_info->table_options & HA_OPTION_COMPRESS_RECORD)
5319 : ((create_info->table_options & HA_OPTION_PACK_RECORD)
5321 : ROW_TYPE_FIXED);
5322 }
5323
5324 /**
5325 Get default key algorithm for SE. It is used when user has not provided
5326 algorithm explicitly or when algorithm specified is not supported by SE.
5327 */
5330 }
5331
5332 /**
5333 Check if SE supports specific key algorithm.
5334
5335 @note This method is never used for FULLTEXT or SPATIAL keys.
5336 We rely on handler::ha_table_flags() to check if such keys
5337 are supported.
5338 */
5339 virtual bool is_index_algorithm_supported(enum ha_key_alg key_alg) const {
5340 return key_alg == HA_KEY_ALG_SE_SPECIFIC;
5341 }
5342
5343 /**
5344 Signal that the table->read_set and table->write_set table maps changed
5345 The handler is allowed to set additional bits in the above map in this
5346 call. Normally the handler should ignore all calls until we have done
5347 a ha_rnd_init() or ha_index_init(), write_row(), update_row or delete_row()
5348 as there may be several calls to this routine.
5349 */
5350 virtual void column_bitmaps_signal();
5351 uint get_index(void) const { return active_index; }
5352
5353 /**
5354 @retval false Bulk update used by handler
5355 @retval true Bulk update not used, normal operation used
5356 */
5357 virtual bool start_bulk_update() { return true; }
5358 /**
5359 @retval false Bulk delete used by handler
5360 @retval true Bulk delete not used, normal operation used
5361 */
5362 virtual bool start_bulk_delete() { return true; }
5363 /**
5364 After this call all outstanding updates must be performed. The number
5365 of duplicate key errors are reported in the duplicate key parameter.
5366 It is allowed to continue to the batched update after this call, the
5367 handler has to wait until end_bulk_update with changing state.
5368
5369 @param dup_key_found Number of duplicate keys found
5370
5371 @retval 0 Success
5372 @retval >0 Error code
5373 */
5374 virtual int exec_bulk_update(uint *dup_key_found [[maybe_unused]]) {
5375 assert(false);
5376 return HA_ERR_WRONG_COMMAND;
5377 }
5378 /**
5379 Perform any needed clean-up, no outstanding updates are there at the
5380 moment.
5381 */
5382 virtual void end_bulk_update() { return; }
5383 /**
5384 Execute all outstanding deletes and close down the bulk delete.
5385
5386 @retval 0 Success
5387 @retval >0 Error code
5388 */
5389 virtual int end_bulk_delete() {
5390 assert(false);
5391 return HA_ERR_WRONG_COMMAND;
5392 }
5393
5394 protected:
5395 /**
5396 @brief
5397 Positions an index cursor to the index specified in the handle
5398 ('active_index'). Fetches the row if available. If the key value is null,
5399 begin at the first key of the index.
5400 @returns 0 if success (found a record); non-zero if no record.
5401 */
5402 virtual int index_read_map(uchar *buf, const uchar *key,
5403 key_part_map keypart_map,
5404 enum ha_rkey_function find_flag) {
5405 uint key_len = calculate_key_len(table, active_index, keypart_map);
5406 return index_read(buf, key, key_len, find_flag);
5407 }
5408 /**
5409 Positions an index cursor to the index specified in argument. Fetches
5410 the row if available. If the key value is null, begin at the first key of
5411 the index.
5412 @sa index_read_map()
5413 */
5414 virtual int index_read_idx_map(uchar *buf, uint index, const uchar *key,
5415 key_part_map keypart_map,
5416 enum ha_rkey_function find_flag);
5417
5418 /*
5419 These methods are used to jump to next or previous entry in the index
5420 scan. There are also methods to jump to first and last entry.
5421 */
5422 /// @see index_read_map().
5423 virtual int index_next(uchar *) { return HA_ERR_WRONG_COMMAND; }
5424
5425 /// @see index_read_map().
5426 virtual int index_prev(uchar *) { return HA_ERR_WRONG_COMMAND; }
5427
5428 /// @see index_read_map().
5429 virtual int index_first(uchar *) { return HA_ERR_WRONG_COMMAND; }
5430
5431 /// @see index_read_map().
5432 virtual int index_last(uchar *) { return HA_ERR_WRONG_COMMAND; }
5433
5434 /// @see index_read_map().
5435 virtual int index_next_same(uchar *buf, const uchar *key, uint keylen);
5436 /**
5437 The following functions works like index_read, but it find the last
5438 row with the current key value or prefix.
5439 @see index_read_map().
5440 */
5441 virtual int index_read_last_map(uchar *buf, const uchar *key,
5442 key_part_map keypart_map) {
5443 uint key_len = calculate_key_len(table, active_index, keypart_map);
5444 return index_read_last(buf, key, key_len);
5445 }
5446
5447 virtual int read_range_first(const key_range *start_key,
5448 const key_range *end_key, bool eq_range_arg,
5449 bool sorted);
5450 virtual int read_range_next();
5451
5452 public:
5453 /**
5454 Set the end position for a range scan. This is used for checking
5455 for when to end the range scan and by the ICP code to determine
5456 that the next record is within the current range.
5457
5458 @param range The end value for the range scan
5459 @param direction Direction of the range scan
5460 */
5461 void set_end_range(const key_range *range,
5462 enum_range_scan_direction direction);
5464 int compare_key_icp(const key_range *range) const;
5465 int compare_key_in_buffer(const uchar *buf) const;
5466 virtual int ft_init() { return HA_ERR_WRONG_COMMAND; }
5467 virtual FT_INFO *ft_init_ext(uint flags, uint inx, String *key);
5469 Ft_hints *hints) {
5470 return ft_init_ext(hints->get_flags(), inx, key);
5471 }
5472 int ha_ft_read(uchar *buf);
5474
5475 protected:
5476 /// @see index_read_map().
5477 virtual int rnd_next(uchar *buf) = 0;
5478 /// @see index_read_map().
5479 virtual int rnd_pos(uchar *buf, uchar *pos) = 0;
5480
5481 virtual int ft_read(uchar *) { return HA_ERR_WRONG_COMMAND; }
5482
5483 public:
5484 /**
5485 This function only works for handlers having
5486 HA_PRIMARY_KEY_REQUIRED_FOR_POSITION set.
5487 It will return the row with the PK given in the record argument.
5488 */
5490 int error;
5492
5493 error = ha_rnd_init(false);
5494 if (error != 0) return error;
5495
5498
5499 ha_rnd_end();
5500 return error;
5501 }
5502
5503 /**
5504 Find number of records in a range.
5505
5506 Given a starting key, and an ending key estimate the number of rows that
5507 will exist between the two. max_key may be empty which in case determine
5508 if start_key matches any rows. Used by optimizer to calculate cost of
5509 using a particular index.
5510
5511 @param inx Index number
5512 @param min_key Start of range
5513 @param max_key End of range
5514
5515 @return Number of rows in range.
5516 */
5517
5518 virtual ha_rows records_in_range(uint inx [[maybe_unused]],
5519 key_range *min_key [[maybe_unused]],
5520 key_range *max_key [[maybe_unused]]) {
5521 return (ha_rows)10;
5522 }
5523 /*
5524 If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, then it sets ref
5525 (reference to the row, aka position, with the primary key given in
5526 the record).
5527 Otherwise it set ref to the current row.
5528 */
5529 virtual void position(const uchar *record) = 0;
5530
5531 /**
5532 General method to gather info from handler
5533
5534 ::info() is used to return information to the optimizer.
5535 SHOW also makes use of this data Another note, if your handler
5536 doesn't proved exact record count, you will probably want to
5537 have the following in your code:
5538 if (records < 2)
5539 records = 2;
5540 The reason is that the server will optimize for cases of only a single
5541 record. If in a table scan you don't know the number of records
5542 it will probably be better to set records to two so you can return
5543 as many records as you need.
5544
5545 Along with records a few more variables you may wish to set are:
5546 records
5547 deleted
5548 data_file_length
5549 index_file_length
5550 delete_length
5551 check_time
5552 Take a look at the public variables in handler.h for more information.
5553 See also my_base.h for a full description.
5554
5555 @param flag Specifies what info is requested
5556 */
5557
5558 virtual int info(uint flag) = 0;
5560 [[maybe_unused]]) {
5561 assert(0);
5562 return 0;
5563 }
5564 /**
5565 Request storage engine to do an extra operation: enable,disable or run some
5566 functionality.
5567
5568 @param operation the operation to perform
5569
5570 @returns
5571 0 on success
5572 error otherwise
5573 */
5574 int ha_extra(enum ha_extra_function operation);
5575
5576 private:
5577 /**
5578 Storage engine specific implementation of ha_extra()
5579
5580 @param operation the operation to perform
5581
5582 @returns
5583 0 on success
5584 error otherwise
5585 */
5586 virtual int extra(enum ha_extra_function operation [[maybe_unused]]) {
5587 return 0;
5588 }
5589
5590 public:
5591 virtual int extra_opt(enum ha_extra_function operation,
5592 ulong cache_size [[maybe_unused]]) {
5593 return extra(operation);
5594 }
5595
5596 /**
5597 Get the handlerton of the storage engine if the SE is capable of
5598 pushing down some of the AccessPath functionality.
5599 (Join, Filter conditions, ... possiby more)
5600
5601 Call the handlerton::push_to_engine() method for performing the
5602 actual pushdown of (parts of) the AccessPath functionality
5603
5604 @returns handlerton* of the SE if it may be capable of
5605 off loading part of the query by calling
5606 handlerton::push_to_engine()
5607
5608 Else, 'nullptr' is returned.
5609 */
5611 return nullptr;
5612 }
5613
5614 /**
5615 Start read (before write) removal on the current table.
5616 @see HA_READ_BEFORE_WRITE_REMOVAL
5617 */
5618 virtual bool start_read_removal(void) {
5619 assert(0);
5620 return false;
5621 }
5622
5623 /**
5624 End read (before write) removal and return the number of rows
5625 really written
5626 @see HA_READ_BEFORE_WRITE_REMOVAL
5627 */
5629 assert(0);
5630 return (ha_rows)0;
5631 }
5632
5633 /**
5634 Normally, when running UPDATE or DELETE queries, we need to wait for other
5635 transactions to release their locks on a given row before we can read it and
5636 potentially update it. However, in READ UNCOMMITTED and READ COMMITTED, we
5637 can ignore these locks if we don't intend to modify the row (e.g., because
5638 it failed a WHERE). This is signaled through enabling “semi-consistent
5639 read”, by calling try_semi_consistent_read(true) (and then setting it back
5640 to false after finishing the query).
5641
5642 If semi-consistent read is enabled, and we are in READ UNCOMMITTED or READ
5643 COMMITTED, the storage engine is permitted to return rows that are locked
5644 and thus un-updatable. If the optimizer doesn't want the row, e.g., because
5645 it got filtered out, it can call unlock_row() as usual. However, if it
5646 intends to update the row, it needs to call was_semi_consistent_read()
5647 before doing so. If was_semi_consistent_read() returns false, the row was
5648 never locked to begin with and can be updated as usual. However, if it
5649 returns 1, it was read optimistically, must be discarded (ie., do not try to
5650 update the row) and must be re-read with locking enabled. The next read call
5651 after was_semi_consistent_read() will automatically re-read the same row,
5652 this time with locking enabled.
5653
5654 Thus, typical use in an UPDATE scenario would look like this:
5655
5656 file->try_semi_consistent_read(true);
5657 file->ha_rnd_init(true);
5658 while (file->ha_rnd_next(table->record[0]) == 0) {
5659 if (row is filtered...) {
5660 file->unlock_row();
5661 continue;
5662 }
5663 if (file->was_semi_consistent_read()) {
5664 // Discard the row; next ha_rnd_next() will read it again with
5665 // locking.
5666 continue;
5667 }
5668 // Process row here.
5669 }
5670 file->ha_rnd_end();
5671 file->try_semi_consistent_read(false);
5672
5673 If the transaction isolation level is REPEATABLE READ or SERIALIZABLE,
5674 enabling this flag has no effect.
5675 */
5676 virtual bool was_semi_consistent_read() { return false; }
5677 /**
5678 Tell the engine whether it should avoid unnecessary lock waits.
5679 If yes, in an UPDATE or DELETE, if the row under the cursor was locked
5680 by another transaction, the engine may try an optimistic read of
5681 the last committed row value under the cursor.
5682 */
5683 virtual void try_semi_consistent_read(bool) {}
5684
5685 /**
5686 Unlock last accessed row.
5687
5688 Record currently processed was not in the result set of the statement
5689 and is thus unlocked. Used for UPDATE and DELETE queries.
5690 */
5691
5692 virtual void unlock_row() {}
5693
5694 /**
5695 Start a statement when table is locked
5696
5697 This method is called instead of external lock when the table is locked
5698 before the statement is executed.
5699
5700 @param thd Thread object.
5701 @param lock_type Type of external lock.
5702
5703 @retval >0 Error code.
5704 @retval 0 Success.
5705 */
5706
5707 virtual int start_stmt(THD *thd [[maybe_unused]],
5708 thr_lock_type lock_type [[maybe_unused]]) {
5709 return 0;
5710 }
5711 virtual void get_auto_increment(ulonglong offset, ulonglong increment,
5712 ulonglong nb_desired_values,
5713 ulonglong *first_value,
5714 ulonglong *nb_reserved_values);
5716 DBUG_PRINT("info", ("auto_increment: next value %lu", (ulong)id));
5718 }
5720 /*
5721 Insertion of a row failed, re-use the lastly generated auto_increment
5722 id, for the next row. This is achieved by resetting next_insert_id to
5723 what it was before the failed insertion (that old value is provided by
5724 the caller). If that value was 0, it was the first row of the INSERT;
5725 then if insert_id_for_cur_row contains 0 it means no id was generated
5726 for this first row, so no id was generated since the INSERT started, so
5727 we should set next_insert_id to 0; if insert_id_for_cur_row is not 0, it
5728 is the generated id of the first and failed row, so we use it.
5729 */
5732 }
5733
5734 /**
5735 Update create info as part of ALTER TABLE.
5736
5737 Forward this handler call to the storage engine foreach
5738 partition handler. The data_file_name for each partition may
5739 need to be reset if the tablespace was moved. Use a dummy
5740 HA_CREATE_INFO structure and transfer necessary data.
5741
5742 @param create_info Create info from ALTER TABLE.
5743 */
5744
5745 virtual void update_create_info(HA_CREATE_INFO *create_info
5746 [[maybe_unused]]) {}
5749 }
5750 virtual int preload_keys(THD *, HA_CHECK_OPT *) {
5752 }
5753 /* end of the list of admin commands */
5754
5755 /**
5756 Check if indexes are disabled.
5757
5758 @retval 0 Indexes are enabled.
5759 @retval != 0 Indexes are disabled.
5760 */
5761
5762 virtual int indexes_are_disabled(void) { return 0; }
5763 virtual void append_create_info(String *packet [[maybe_unused]]) {}
5765 return;
5766 } /* prepare InnoDB for HANDLER */
5767 /** The following can be called without an open handler */
5768 virtual const char *table_type() const = 0;
5769
5770 virtual ulong index_flags(uint idx, uint part, bool all_parts) const = 0;
5771
5774 }
5775 uint max_keys() const {
5776 return std::min<uint>(MAX_KEY, max_supported_keys());
5777 }
5779 return std::min(MAX_REF_PARTS, max_supported_key_parts());
5780 }
5782 return std::min(MAX_KEY_LENGTH, max_supported_key_length());
5783 }
5785 return std::min(MAX_KEY_LENGTH, max_supported_key_part_length(create_info));
5786 }
5787
5789 virtual uint max_supported_keys() const { return 0; }
5790 virtual uint max_supported_key_parts() const { return MAX_REF_PARTS; }
5793 [[maybe_unused]]) const {
5794 return 255;
5795 }
5796 virtual uint min_record_length(uint options [[maybe_unused]]) const {
5797 return 1;
5798 }
5799
5800 virtual bool low_byte_first() const { return true; }
5801 virtual ha_checksum checksum() const { return 0; }
5802
5803 /**
5804 Check if the table is crashed.
5805
5806 @retval true Crashed
5807 @retval false Not crashed
5808 */
5809
5810 virtual bool is_crashed() const { return false; }
5811
5812 /**
5813 Check if the table can be automatically repaired.
5814
5815 @retval true Can be auto repaired
5816 @retval false Cannot be auto repaired
5817 */
5818
5819 virtual bool auto_repair() const { return false; }
5820
5821 /**
5822 Get number of lock objects returned in store_lock.
5823
5824 Returns the number of store locks needed in call to store lock.
5825 We return number of partitions we will lock multiplied with number of
5826 locks needed by each partition. Assists the above functions in allocating
5827 sufficient space for lock structures.
5828
5829 @returns Number of locks returned in call to store_lock.
5830
5831 @note lock_count() can return > 1 if the table is MERGE or partitioned.
5832 */
5833
5834 virtual uint lock_count(void) const { return 1; }
5835
5836 /**
5837 Is not invoked for non-transactional temporary tables.
5838
5839 @note store_lock() can return more than one lock if the table is MERGE
5840 or partitioned.
5841
5842 @note that one can NOT rely on table->in_use in store_lock(). It may
5843 refer to a different thread if called from mysql_lock_abort_for_thread().
5844
5845 @note If the table is MERGE, store_lock() can return less locks
5846 than lock_count() claimed. This can happen when the MERGE children
5847 are not attached when this is called from another thread.
5848
5849 The idea with handler::store_lock() is the following:
5850
5851 The statement decided which locks we should need for the table
5852 for updates/deletes/inserts we get WRITE locks, for SELECT... we get
5853 read locks.
5854
5855 Before adding the lock into the table lock handler (see thr_lock.c)
5856 mysqld calls store lock with the requested locks. Store lock can now
5857 modify a write lock to a read lock (or some other lock), ignore the
5858 lock (if we don't want to use MySQL table locks at all) or add locks
5859 for many tables (like we do when we are using a MERGE handler).
5860
5861 In some exceptional cases MySQL may send a request for a TL_IGNORE;
5862 This means that we are requesting the same lock as last time and this
5863 should also be ignored.
5864
5865 Called from lock.cc by get_lock_data().
5866 */
5868 enum thr_lock_type lock_type) = 0;
5869
5870 /**
5871 Check if the primary key is clustered or not.
5872
5873 @retval true Primary key (if there is one) is a clustered
5874 key covering all fields
5875 @retval false otherwise
5876 */
5877
5878 virtual bool primary_key_is_clustered() const { return false; }
5879
5880 /**
5881 Compare two positions.
5882
5883 @param ref1 First position.
5884 @param ref2 Second position.
5885
5886 @retval <0 ref1 < ref2.
5887 @retval 0 Equal.
5888 @retval >0 ref1 > ref2.
5889 */
5890
5891 virtual int cmp_ref(const uchar *ref1, const uchar *ref2) const {
5892 return memcmp(ref1, ref2, ref_length);
5893 }
5894
5895 /*
5896 Condition pushdown to storage engines
5897 */
5898
5899 /**
5900 Push condition down to the table handler.
5901
5902 @param cond Condition to be pushed. The condition tree
5903 must not be modified by the caller.
5904
5905 @return
5906 The 'remainder' condition that caller must use to filter out records.
5907 NULL means the handler will not return rows that do not match the
5908 passed condition.
5909
5910 @note
5911 handler->ha_reset() call discard any pushed conditions.
5912 Calls to rnd_init/rnd_end, index_init/index_end etc do not affect the
5913 pushed conditions.
5914 */
5915 virtual const Item *cond_push(const Item *cond) {
5916 assert(pushed_cond == nullptr);
5917 return cond;
5918 }
5919
5920 /**
5921 Push down an index condition to the handler.
5922
5923 The server will use this method to push down a condition it wants
5924 the handler to evaluate when retrieving records using a specified
5925 index. The pushed index condition will only refer to fields from
5926 this handler that is contained in the index (but it may also refer
5927 to fields in other handlers). Before the handler evaluates the
5928 condition it must read the content of the index entry into the
5929 record buffer.
5930
5931 The handler is free to decide if and how much of the condition it
5932 will take responsibility for evaluating. Based on this evaluation
5933 it should return the part of the condition it will not evaluate.
5934 If it decides to evaluate the entire condition it should return
5935 NULL. If it decides not to evaluate any part of the condition it
5936 should return a pointer to the same condition as given as argument.
5937
5938 @param keyno the index number to evaluate the condition on
5939 @param idx_cond the condition to be evaluated by the handler
5940
5941 @return The part of the pushed condition that the handler decides
5942 not to evaluate
5943 */
5944
5945 virtual Item *idx_cond_push(uint keyno [[maybe_unused]], Item *idx_cond) {
5946 return idx_cond;
5947 }
5948
5949 /** Reset information about pushed index conditions */
5950 virtual void cancel_pushed_idx_cond() {
5951 pushed_idx_cond = nullptr;
5954 }
5955
5956 /**
5957 Reports number of tables included in pushed join which this
5958 handler instance is part of. ==0 -> Not pushed
5959 */
5960 virtual uint number_of_pushed_joins() const { return 0; }
5961
5962 /**
5963 If this handler instance is part of a pushed join sequence
5964 returned TABLE instance being root of the pushed query?
5965 */
5966 virtual const TABLE *member_of_pushed_join() const { return nullptr; }
5967
5968 /**
5969 If this handler instance is a child in a pushed join sequence
5970 returned TABLE instance being my parent?
5971 */
5972 virtual const TABLE *parent_of_pushed_join() const { return nullptr; }
5973
5974 /// @returns a map of the tables involved in this pushed join, or 0 if not
5975 /// part of a pushed join.
5976 virtual table_map tables_in_pushed_join() const { return 0; }
5977
5978 int ha_index_read_pushed(uchar *buf, const uchar *key,
5979 key_part_map keypart_map);
5980
5982
5983 protected:
5984 virtual int index_read_pushed(uchar *, const uchar *, key_part_map) {
5985 return HA_ERR_WRONG_COMMAND;
5986 }
5987
5989
5990 public:
5991 /**
5992 Part of old, deprecated in-place ALTER API.
5993 */
5995 [[maybe_unused]],
5996 uint table_changes [[maybe_unused]]) {
5997 return COMPATIBLE_DATA_NO;
5998 }
5999
6000 /* On-line/in-place/instant ALTER TABLE interface. */
6001
6002 /*
6003 Here is an outline of on-line/in-place ALTER TABLE execution through
6004 this interface.
6005
6006 Phase 1 : Initialization
6007 ========================
6008 During this phase we determine which algorithm should be used
6009 for execution of ALTER TABLE and what level concurrency it will
6010 require.
6011
6012 *) This phase starts by opening the table and preparing description
6013 of the new version of the table.
6014 *) Then we check if it is impossible even in theory to carry out
6015 this ALTER TABLE using the in-place/instant algorithm. For example,
6016 because we need to change storage engine or the user has explicitly
6017 requested usage of the "copy" algorithm.
6018 *) If in-place/instant ALTER TABLE is theoretically possible, we continue
6019 by compiling differences between old and new versions of the table
6020 in the form of HA_ALTER_FLAGS bitmap. We also build a few
6021 auxiliary structures describing requested changes and store
6022 all these data in the Alter_inplace_info object.
6023 *) Then the handler::check_if_supported_inplace_alter() method is called
6024 in order to find if the storage engine can carry out changes requested
6025 by this ALTER TABLE using the in-place or instant algorithm.
6026 To determine this, the engine can rely on data in HA_ALTER_FLAGS/
6027 Alter_inplace_info passed to it as well as on its own checks.
6028 If the in-place algorithm can be used for this ALTER TABLE, the level
6029 of required concurrency for its execution is also returned.
6030 If any errors occur during the handler call, ALTER TABLE is aborted
6031 and no further handler functions are called.
6032 Note that in cases when there is difference between in-place and
6033 instant algorithm and user explicitly asked for usage of in-place
6034 algorithm storage engine MUST return one of values corresponding
6035 to in-place algorithm and not HA_ALTER_INPLACE_INSTANT from this
6036 method.
6037 *) Locking requirements of the in-place algorithm are compared to any
6038 concurrency requirements specified by user. If there is a conflict
6039 between them, we either switch to the copy algorithm or emit an error.
6040
6041 Phase 2 : Execution
6042 ===================
6043
6044 In this phase the operations are executed.
6045
6046 *) As the first step, we acquire a lock corresponding to the concurrency
6047 level which was returned by handler::check_if_supported_inplace_alter()
6048 and requested by the user. This lock is held for most of the
6049 duration of in-place ALTER (if HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE
6050 or HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE were returned we acquire an
6051 exclusive lock for duration of the next step only).
6052 For HA_ALTER_INPLACE_INSTANT we keep shared upgradable metadata lock
6053 which was acquired at table open time.
6054 *) After that we call handler::ha_prepare_inplace_alter_table() to give the
6055 storage engine a chance to update its internal structures with a higher
6056 lock level than the one that will be used for the main step of algorithm.
6057 After that we downgrade the lock if it is necessary.
6058 This step should be no-op for instant algorithm.
6059 *) After that, the main step of this phase and algorithm is executed.
6060 We call the handler::ha_inplace_alter_table() method, which carries out
6061 the changes requested by ALTER TABLE but does not makes them visible to
6062 other connections yet.
6063 This step should be no-op for instant algorithm as well.
6064 *) We ensure that no other connection uses the table by upgrading our
6065 lock on it to exclusive.
6066 *) a) If the previous step succeeds,
6067 handler::ha_commit_inplace_alter_table() is called to allow the storage
6068 engine to do any final updates to its structures, to make all earlier
6069 changes durable and visible to other connections.
6070 For instant algorithm this is the step during which SE changes are done.
6071 Engines that support atomic DDL only prepare for the commit during this
6072 step but do not finalize it. Real commit happens later when the whole
6073 statement is committed. Also in some situations statement might be rolled
6074 back after call to commit_inplace_alter_table() for such storage engines.
6075 In the latter special case SE might require call to
6076 handlerton::dict_cache_reset() in order to invalidate its internal table
6077 definition cache after rollback.
6078 b) If we have failed to upgrade lock or any errors have occurred during
6079 the handler functions calls (including commit), we call
6080 handler::ha_commit_inplace_alter_table() to rollback all changes which
6081 were done during previous steps.
6082
6083 All the above calls to SE are provided with dd::Table objects describing old
6084 and new version of table being altered. Engines which support atomic DDL are
6085 allowed to adjust object corresponding to the new version. During phase 3
6086 these changes are saved to the data-dictionary.
6087
6088
6089 Phase 3 : Final
6090 ===============
6091
6092 In this phase we:
6093
6094 a) For engines which don't support atomic DDL:
6095
6096 *) Update the SQL-layer data-dictionary by replacing description of old
6097 version of the table with its new version. This change is immediately
6098 committed.
6099 *) Inform the storage engine about this change by calling the
6100 handler::ha_notify_table_changed() method.
6101 *) Process the RENAME clause by calling handler::ha_rename_table() and
6102 updating the data-dictionary accordingly. Again this change is
6103 immediately committed.
6104 *) Destroy the Alter_inplace_info and handler_ctx objects.
6105
6106 b) For engines which support atomic DDL:
6107
6108 *) Update the SQL-layer data-dictionary by replacing description of old
6109 version of the table with its new version.
6110 *) Process the RENAME clause by calling handler::ha_rename_table() and
6111 updating the data-dictionary accordingly.
6112 *) Commit the statement/transaction.
6113 *) Finalize atomic DDL operation by calling handlerton::post_ddl() hook
6114 for the storage engine.
6115 *) Additionally inform the storage engine about completion of ALTER TABLE
6116 for the table by calling the handler::ha_notify_table_changed()
6117 method.
6118 *) Destroy the Alter_inplace_info and handler_ctx objects.
6119 */
6120
6121 /**
6122 Check if a storage engine supports a particular alter table in-place
6123
6124 @param altered_table TABLE object for new version of table.
6125 @param ha_alter_info Structure describing changes to be done
6126 by ALTER TABLE and holding data used
6127 during in-place alter.
6128
6129 @retval HA_ALTER_ERROR Unexpected error.
6130 @retval HA_ALTER_INPLACE_NOT_SUPPORTED Not supported, must use copy.
6131 @retval HA_ALTER_INPLACE_EXCLUSIVE_LOCK Supported, but requires X lock.
6132 @retval HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE
6133 Supported, but requires SNW lock
6134 during main phase. Prepare phase
6135 requires X lock.
6136 @retval HA_ALTER_INPLACE_SHARED_LOCK Supported, but requires SNW lock.
6137 @retval HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE
6138 Supported, concurrent
6139 reads/writes allowed. However, prepare phase requires X lock.
6140 @retval HA_ALTER_INPLACE_NO_LOCK Supported, concurrent
6141 reads/writes allowed.
6142 @retval HA_ALTER_INPLACE_INSTANT Instant algorithm is supported.
6143 Prepare and main phases are
6144 no-op. Changes happen during
6145 commit phase and it should be
6146 "instant". We keep SU lock,
6147 allowing concurrent reads and
6148 writes during no-op phases and
6149 upgrade it to X lock before
6150 commit phase.
6151
6152 @note The default implementation uses the old in-place ALTER API
6153 to determine if the storage engine supports in-place ALTER or not.
6154
6155 @note In cases when there is difference between in-place and instant
6156 algorithm and explicit ALGORITHM=INPLACE clause was provided SE MUST
6157 return one of values corresponding to in-place algorithm and not
6158 HA_ALTER_INPLACE_INSTANT from this method.
6159
6160 @note Called without holding thr_lock.c lock.
6161 */
6163 TABLE *altered_table, Alter_inplace_info *ha_alter_info);
6164
6165 /**
6166 Public functions wrapping the actual handler call.
6167 @see prepare_inplace_alter_table()
6168 */
6169 bool ha_prepare_inplace_alter_table(TABLE *altered_table,
6170 Alter_inplace_info *ha_alter_info,
6171 const dd::Table *old_table_def,
6172 dd::Table *new_table_def);
6173
6174 /**
6175 Public function wrapping the actual handler call.
6176 @see inplace_alter_table()
6177 */
6178 bool ha_inplace_alter_table(TABLE *altered_table,
6179 Alter_inplace_info *ha_alter_info,
6180 const dd::Table *old_table_def,
6181 dd::Table *new_table_def) {
6182 return inplace_alter_table(altered_table, ha_alter_info, old_table_def,
6183 new_table_def);
6184 }
6185
6186 /**
6187 Public function wrapping the actual handler call.
6188 Allows us to enforce asserts regardless of handler implementation.
6189 @see commit_inplace_alter_table()
6190 */
6191 bool ha_commit_inplace_alter_table(TABLE *altered_table,
6192 Alter_inplace_info *ha_alter_info,
6193 bool commit,
6194 const dd::Table *old_table_def,
6195 dd::Table *new_table_def);
6196
6197 /**
6198 Public function wrapping the actual handler call.
6199
6200 @see notify_table_changed()
6201 */
6203 notify_table_changed(ha_alter_info);
6204 }
6205
6206 protected:
6207 /**
6208 Allows the storage engine to update internal structures with concurrent
6209 writes blocked. If check_if_supported_inplace_alter() returns
6210 HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE or
6211 HA_ALTER_INPLACE_SHARED_AFTER_PREPARE, this function is called with
6212 exclusive lock otherwise the same level of locking as for
6213 inplace_alter_table() will be used.
6214
6215 @note Should be no-op for instant algorithm.
6216
6217 @note Storage engines are responsible for reporting any errors by
6218 calling my_error()/print_error()
6219
6220 @note If this function reports error, commit_inplace_alter_table()
6221 will be called with commit= false.
6222
6223 @note For partitioning, failing to prepare one partition, means that
6224 commit_inplace_alter_table() will be called to roll back changes for
6225 all partitions. This means that commit_inplace_alter_table() might be
6226 called without prepare_inplace_alter_table() having been called first
6227 for a given partition.
6228
6229 @param altered_table TABLE object for new version of table.
6230 @param ha_alter_info Structure describing changes to be done
6231 by ALTER TABLE and holding data used
6232 during in-place alter.
6233 @param old_table_def dd::Table object describing old version of
6234 the table.
6235 @param new_table_def dd::Table object for the new version of the
6236 table. Can be adjusted by this call if SE
6237 supports atomic DDL. These changes to the
6238 table definition will be persisted in the
6239 data-dictionary at statement commit time.
6240
6241 @retval true Error
6242 @retval false Success
6243 */
6245 TABLE *altered_table [[maybe_unused]],
6246 Alter_inplace_info *ha_alter_info [[maybe_unused]],
6247 const dd::Table *old_table_def [[maybe_unused]],
6248 dd::Table *new_table_def [[maybe_unused]]) {
6249 return false;
6250 }
6251
6252 /**
6253 Alter the table structure in-place with operations specified using
6254 HA_ALTER_FLAGS and Alter_inplace_info. The level of concurrency allowed
6255 during this operation depends on the return value from
6256 check_if_supported_inplace_alter().
6257
6258 @note Should be no-op for instant algorithm.
6259
6260 @note Storage engines are responsible for reporting any errors by
6261 calling my_error()/print_error()
6262
6263 @note If this function reports error, commit_inplace_alter_table()
6264 will be called with commit= false.
6265
6266 @param altered_table TABLE object for new version of table.
6267 @param ha_alter_info Structure describing changes to be done
6268 by ALTER TABLE and holding data used
6269 during in-place alter.
6270 @param old_table_def dd::Table object describing old version of
6271 the table.
6272 @param new_table_def dd::Table object for the new version of the
6273 table. Can be adjusted by this call if SE
6274 supports atomic DDL. These changes to the
6275 table definition will be persisted in the
6276 data-dictionary at statement commit time.
6277
6278 @retval true Error
6279 @retval false Success
6280 */
6281 virtual bool inplace_alter_table(TABLE *altered_table [[maybe_unused]],
6282 Alter_inplace_info *ha_alter_info
6283 [[maybe_unused]],
6284 const dd::Table *old_table_def
6285 [[maybe_unused]],
6286 dd::Table *new_table_def [[maybe_unused]]) {
6287 return false;
6288 }
6289
6290 /**
6291 Commit or rollback the changes made during prepare_inplace_alter_table()
6292 and inplace_alter_table() inside the storage engine.
6293 Note that in case of rollback the allowed level of concurrency during
6294 this operation will be the same as for inplace_alter_table() and thus
6295 might be higher than during prepare_inplace_alter_table(). (For example,
6296 concurrent writes were blocked during prepare, but might not be during
6297 rollback).
6298
6299 @note This is the place where SE changes happen for instant algorithm.
6300
6301 @note For storage engines supporting atomic DDL this method should only
6302 prepare for the commit but do not finalize it. Real commit should happen
6303 later when the whole statement is committed. Also in some situations
6304 statement might be rolled back after call to commit_inplace_alter_table()
6305 for such storage engines. In the latter special case SE might require call
6306 to handlerton::dict_cache_reset() in order to invalidate its internal
6307 table definition cache after rollback.
6308
6309 @note Storage engines are responsible for reporting any errors by
6310 calling my_error()/print_error()
6311
6312 @note If this function with commit= true reports error, it will be called
6313 again with commit= false.
6314
6315 @note In case of partitioning, this function might be called for rollback
6316 without prepare_inplace_alter_table() having been called first.
6317 Also partitioned tables sets ha_alter_info->group_commit_ctx to a NULL
6318 terminated array of the partitions handlers and if all of them are
6319 committed as one, then group_commit_ctx should be set to NULL to indicate
6320 to the partitioning handler that all partitions handlers are committed.
6321 @see prepare_inplace_alter_table().
6322
6323 @param altered_table TABLE object for new version of table.
6324 @param ha_alter_info Structure describing changes to be done
6325 by ALTER TABLE and holding data used
6326 during in-place alter.
6327 @param commit True => Commit, False => Rollback.
6328 @param old_table_def dd::Table object describing old version of
6329 the table.
6330 @param new_table_def dd::Table object for the new version of the
6331 table. Can be adjusted by this call if SE
6332 supports atomic DDL. These changes to the
6333 table definition will be persisted in the
6334 data-dictionary at statement commit time.
6335
6336 @retval true Error
6337 @retval false Success
6338 */
6339 virtual bool commit_inplace_alter_table(TABLE *altered_table [[maybe_unused]],
6340 Alter_inplace_info *ha_alter_info
6341 [[maybe_unused]],
6342 bool commit [[maybe_unused]],
6343 const dd::Table *old_table_def
6344 [[maybe_unused]],
6345 dd::Table *new_table_def
6346 [[maybe_unused]]) {
6347 /* Nothing to commit/rollback, mark all handlers committed! */
6348 ha_alter_info->group_commit_ctx = nullptr;
6349 return false;
6350 }
6351
6352 /**
6353 Notify the storage engine that the table definition has been updated.
6354
6355 @param ha_alter_info Structure describing changes done by
6356 ALTER TABLE and holding data used
6357 during in-place alter.
6358
6359 @note No errors are allowed during notify_table_changed().
6360
6361 @note For storage engines supporting atomic DDL this method is invoked
6362 after the whole ALTER TABLE is completed and committed.
6363 Particularly this means that for ALTER TABLE statements with RENAME
6364 clause TABLE/handler object used for invoking this method will be
6365 associated with new table name. If storage engine needs to know
6366 the old schema and table name in this method for some reason it
6367 has to use ha_alter_info object to figure it out.
6368 */
6369 virtual void notify_table_changed(Alter_inplace_info *ha_alter_info
6370 [[maybe_unused]]) {}
6371
6372 public:
6373 /* End of On-line/in-place ALTER TABLE interface. */
6374
6375 /**
6376 use_hidden_primary_key() is called in case of an update/delete when
6377 (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
6378 but we don't have a primary key
6379 */
6380 virtual void use_hidden_primary_key();
6381
6382 protected:
6383 /* Service methods for use by storage engines. */
6385 THD *ha_thd() const;
6386
6387 /**
6388 Acquire the instrumented table information from a table share.
6389 @param share a table share
6390 @return an instrumented table share, or NULL.
6391 */
6392 PSI_table_share *ha_table_share_psi(const TABLE_SHARE *share) const;
6393
6394 /**
6395 Default rename_table() and delete_table() rename/delete files with a
6396 given name and extensions from handlerton::file_extensions.
6397
6398 These methods can be overridden, but their default implementation
6399 provide useful functionality.
6400
6401 @param [in] from Path for the old table name.
6402 @param [in] to Path for the new table name.
6403 @param [in] from_table_def Old version of definition for table
6404 being renamed (i.e. prior to rename).
6405 @param [in,out] to_table_def New version of definition for table
6406 being renamed. Storage engines which
6407 support atomic DDL (i.e. having
6408 HTON_SUPPORTS_ATOMIC_DDL flag set)
6409 are allowed to adjust this object.
6410
6411 @retval >0 Error.
6412 @retval 0 Success.
6413 */
6414 virtual int rename_table(const char *from, const char *to,
6415 const dd::Table *from_table_def,
6416 dd::Table *to_table_def);
6417
6418 /**
6419 Delete a table.
6420
6421 Used to delete a table. By the time delete_table() has been called all
6422 opened references to this table will have been closed (and your globally
6423 shared references released. The variable name will just be the name of
6424 the table. You will need to remove any files you have created at this
6425 point. Called for base as well as temporary tables.
6426
6427 @param name Full path of table name.
6428 @param table_def dd::Table describing table being deleted
6429 (can be NULL for temporary tables created
6430 by optimizer).
6431
6432 @return Zero on success, nonzero otherwise.
6433 */
6434 virtual int delete_table(const char *name, const dd::Table *table_def);
6435
6436 private:
6437 /* Private helpers */
6438 void mark_trx_read_write();
6439 /*
6440 Low-level primitives for storage engines. These should be
6441 overridden by the storage engine class. To call these methods, use
6442 the corresponding 'ha_*' method above.
6443 */
6444
6445 virtual int open(const char *name, int mode, uint test_if_locked,
6446 const dd::Table *table_def) = 0;
6447 virtual int close(void) = 0;
6448 virtual int index_init(uint idx, bool sorted [[maybe_unused]]) {
6449 active_index = idx;
6450 return 0;
6451 }
6452 virtual int index_end() {
6454 return 0;
6455 }
6456 /**
6457 rnd_init() can be called two times without rnd_end() in between
6458 (it only makes sense if scan=1).
6459 then the second call should prepare for the new table scan (e.g
6460 if rnd_init allocates the cursor, second call should position it
6461 to the start of the table, no need to deallocate and allocate it again
6462 */
6463 virtual int rnd_init(bool scan) = 0;
6464 virtual int rnd_end() { return 0; }
6465 /**
6466 Write a row.
6467
6468 write_row() inserts a row. buf is a byte array of data, normally
6469 record[0].
6470
6471 You can use the field information to extract the data from the native byte
6472 array type.
6473
6474 Example of this would be:
6475 for (Field **field=table->field ; *field ; field++)
6476 {
6477 ...
6478 }
6479
6480 @param buf Buffer to write from.
6481
6482 @return Operation status.
6483 @retval 0 Success.
6484 @retval != 0 Error code.
6485 */
6486 virtual int write_row(uchar *buf [[maybe_unused]]) {
6487 return HA_ERR_WRONG_COMMAND;
6488 }
6489
6490 /**
6491 Update a single row.
6492
6493 Note: If HA_ERR_FOUND_DUPP_KEY is returned, the handler must read
6494 all columns of the row so MySQL can create an error message. If
6495 the columns required for the error message are not read, the error
6496 message will contain garbage.
6497 */
6498 virtual int update_row(const uchar *old_data [[maybe_unused]],
6499 uchar *new_data [[maybe_unused]]) {
6500 return HA_ERR_WRONG_COMMAND;
6501 }
6502
6503 virtual int delete_row(const uchar *buf [[maybe_unused]]) {
6504 return HA_ERR_WRONG_COMMAND;
6505 }
6506 /**
6507 Reset state of file to after 'open'.
6508 This function is called after every statement for all tables used
6509 by that statement.
6510 */
6511 virtual int reset() { return 0; }
6512 virtual Table_flags table_flags(void) const = 0;
6513 /**
6514 Is not invoked for non-transactional temporary tables.
6515
6516 Tells the storage engine that we intend to read or write data
6517 from the table. This call is prefixed with a call to handler::store_lock()
6518 and is invoked only for those handler instances that stored the lock.
6519
6520 Calls to @c rnd_init / @c index_init are prefixed with this call. When table
6521 IO is complete, we call @code external_lock(F_UNLCK) @endcode.
6522 A storage engine writer should expect that each call to
6523 @code ::external_lock(F_[RD|WR]LOCK @endcode is followed by a call to
6524 @code ::external_lock(F_UNLCK) @endcode. If it is not, it is a bug in MySQL.
6525
6526 The name and signature originate from the first implementation
6527 in MyISAM, which would call @c fcntl to set/clear an advisory
6528 lock on the data file in this method.
6529
6530 Originally this method was used to set locks on file level to enable
6531 several MySQL Servers to work on the same data. For transactional
6532 engines it has been "abused" to also mean start and end of statements
6533 to enable proper rollback of statements and transactions. When LOCK
6534 TABLES has been issued the start_stmt method takes over the role of
6535 indicating start of statement but in this case there is no end of
6536 statement indicator(?).
6537
6538 Called from lock.cc by lock_external() and unlock_external(). Also called
6539 from sql_table.cc by copy_data_between_tables().
6540
6541 @param thd the current thread
6542 @param lock_type F_RDLCK, F_WRLCK, F_UNLCK
6543
6544 @return non-0 in case of failure, 0 in case of success.
6545 When lock_type is F_UNLCK, the return value is ignored.
6546 */
6547 virtual int external_lock(THD *thd [[maybe_unused]],
6548 int lock_type [[maybe_unused]]) {
6549 return 0;
6550 }
6551 virtual void release_auto_increment() { return; }
6552 /** admin commands - called from mysql_admin_table */
6553 virtual int check_for_upgrade(HA_CHECK_OPT *) { return 0; }
6554 virtual int check(THD *, HA_CHECK_OPT *) { return HA_ADMIN_NOT_IMPLEMENTED; }
6555
6556 /**
6557 In this method check_opt can be modified
6558 to specify CHECK option to use to call check()
6559 upon the table.
6560 */
6561 virtual int repair(THD *, HA_CHECK_OPT *) {
6562 assert(!(ha_table_flags() & HA_CAN_REPAIR));
6564 }
6566 virtual int end_bulk_insert() { return 0; }
6567
6568 /**
6569 Does this handler want to get a Record_buffer for multi-row reads
6570 via the ha_set_record_buffer() function? And if so, what is the
6571 maximum number of records to allocate space for in the buffer?
6572
6573 Storage engines that support using a Record_buffer should override
6574 this function and return true for scans that could benefit from a
6575 buffer.
6576
6577 @param[out] max_rows gets set to the maximum number of records to
6578 allocate space for in the buffer if the function
6579 returns true
6580
6581 @retval true if the handler would like a Record_buffer
6582 @retval false if the handler does not want a Record_buffer
6583 */
6584 virtual bool is_record_buffer_wanted(ha_rows *const max_rows) const {
6585 *max_rows = 0;
6586 return false;
6587 }
6588
6589 // Set se_private_id and se_private_data during upgrade
6590 virtual bool upgrade_table(THD *thd [[maybe_unused]],
6591 const char *dbname [[maybe_unused]],
6592 const char *table_name [[maybe_unused]],
6593 dd::Table *dd_table [[maybe_unused]]) {
6594 return false;
6595 }
6596
6597 /** Initialize sampling.
6598 @param[out] scan_ctx A scan context created by this method that has to be
6599 used in sample_next
6600 @param[in] sampling_percentage percentage of records that need to be sampled
6601 @param[in] sampling_seed random seed
6602 @param[in] sampling_method sampling method to be used; currently only
6603 SYSTEM sampling is supported
6604 @param[in] tablesample true if the sampling is for tablesample
6605 @return 0 for success, else failure. */
6606 virtual int sample_init(void *&scan_ctx, double sampling_percentage,
6607 int sampling_seed,
6608 enum_sampling_method sampling_method,
6609 const bool tablesample);
6610
6611 /** Get the next record for sampling.
6612 @param[in] scan_ctx Scan context of the sampling
6613 @param[in] buf buffer to place the read record
6614 @return 0 for success, else failure. */
6615 virtual int sample_next(void *scan_ctx, uchar *buf);
6616
6617 /** End sampling.
6618 @param[in] scan_ctx Scan context of the sampling
6619 @return 0 for success, else failure. */
6620 virtual int sample_end(void *scan_ctx);
6621
6622 /**
6623 * Loads a table into its defined secondary storage engine.
6624 *
6625 * @param table Table opened in primary storage engine. Its read_set tells
6626 * which columns to load.
6627 *
6628 * @return 0 if success, error code otherwise.
6629 */
6630 virtual int load_table(const TABLE &table [[maybe_unused]]) {
6631 /* purecov: begin inspected */
6632 assert(false);
6633 return HA_ERR_WRONG_COMMAND;
6634 /* purecov: end */
6635 }
6636
6637 /**
6638 * Unloads a table from its defined secondary storage engine.
6639 *
6640 * @param db_name Database name.
6641 * @param table_name Table name.
6642 * @param error_if_not_loaded If true, then errors will be reported by this
6643 * function. If false, no errors will be reported
6644 * (silently fail). This case of false is useful
6645 * during DROP TABLE where a failure to unload
6646 * should not prevent dropping the whole table.
6647 * @return 0 if success, error code otherwise.
6648 */
6649 virtual int unload_table(const char *db_name [[maybe_unused]],
6650 const char *table_name [[maybe_unused]],
6651 bool error_if_not_loaded [[maybe_unused]]) {
6652 /* purecov: begin inspected */
6653 assert(false);
6654 return HA_ERR_WRONG_COMMAND;
6655 /* purecov: end */
6656 }
6657
6658 protected:
6659 virtual int index_read(uchar *buf [[maybe_unused]],
6660 const uchar *key [[maybe_unused]],
6661 uint key_len [[maybe_unused]],
6662 enum ha_rkey_function find_flag [[maybe_unused]]) {
6663 return HA_ERR_WRONG_COMMAND;
6664 }
6665 virtual int index_read_last(uchar *buf [[maybe_unused]],
6666 const uchar *key [[maybe_unused]],
6667 uint key_len [[maybe_unused]]) {
6669 return HA_ERR_WRONG_COMMAND;
6670 }
6671
6672 public:
6673 /**
6674 This method is similar to update_row, however the handler doesn't need
6675 to execute the updates at this point in time. The handler can be certain
6676 that another call to bulk_update_row will occur OR a call to
6677 exec_bulk_update before the set of updates in this query is concluded.
6678
6679 Note: If HA_ERR_FOUND_DUPP_KEY is returned, the handler must read
6680 all columns of the row so MySQL can create an error message. If
6681 the columns required for the error message are not read, the error
6682 message will contain garbage.
6683
6684 @param old_data Old record
6685 @param new_data New record
6686 @param dup_key_found Number of duplicate keys found
6687
6688 */
6689 virtual int bulk_update_row(const uchar *old_data [[maybe_unused]],
6690 uchar *new_data [[maybe_unused]],
6691 uint *dup_key_found [[maybe_unused]]) {
6692 assert(false);
6693 return HA_ERR_WRONG_COMMAND;
6694 }
6695 /**
6696 Delete all rows in a table.
6697
6698 This is called both for cases of truncate and for cases where the
6699 optimizer realizes that all rows will be removed as a result of an
6700 SQL statement.
6701
6702 If the handler don't support this, then this function will
6703 return HA_ERR_WRONG_COMMAND and MySQL will delete the rows one
6704 by one.
6705 */
6706 virtual int delete_all_rows() {
6708 return HA_ERR_WRONG_COMMAND;
6709 }
6710 /**
6711 Quickly remove all rows from a table.
6712
6713 @param[in,out] table_def dd::Table object for table being truncated.
6714
6715 @remark This method is responsible for implementing MySQL's TRUNCATE
6716 TABLE statement, which is a DDL operation. As such, a engine
6717 can bypass certain integrity checks and in some cases avoid
6718 fine-grained locking (e.g. row locks) which would normally be
6719 required for a DELETE statement.
6720
6721 @remark Typically, truncate is not used if it can result in integrity
6722 violation. For example, truncate is not used when a foreign
6723 key references the table, but it might be used if foreign key
6724 checks are disabled.
6725
6726 @remark Engine is responsible for resetting the auto-increment counter.
6727
6728 @remark The table is locked in exclusive mode. All open TABLE/handler
6729 instances except the one which is used for truncate() call
6730 are closed.
6731
6732 @note It is assumed that transactional storage engines implementing
6733 this method can revert its effects if transaction is rolled
6734 back (e.g. because we failed to write statement to the binary
6735 log).
6736
6737 @note Changes to dd::Table object done by this method will be saved
6738 to data-dictionary only if storage engine supports atomic DDL
6739 (i.e. has HTON_SUPPORTS_ATOMIC_DDL flag set).
6740 */
6741 virtual int truncate(dd::Table *table_def [[maybe_unused]]) {
6742 return HA_ERR_WRONG_COMMAND;
6743 }
6744 virtual int optimize(THD *, HA_CHECK_OPT *) {
6746 }
6747 virtual int analyze(THD *, HA_CHECK_OPT *) {
6749 }
6750
6751 /**
6752 @brief Check and repair the table if necessary.
6753
6754 @param thd Thread object
6755
6756 @retval true Error/Not supported
6757 @retval false Success
6758
6759 @note Called if open_table_from_share fails and is_crashed().
6760 */
6761
6762 virtual bool check_and_repair(THD *thd [[maybe_unused]]) { return true; }
6763
6764 /**
6765 Disable indexes for a while.
6766
6767 @param mode Mode.
6768
6769 @retval 0 Success.
6770 @retval != 0 Error.
6771 */
6772
6773 virtual int disable_indexes(uint mode [[maybe_unused]]) {
6774 return HA_ERR_WRONG_COMMAND;
6775 }
6776
6777 /**
6778 Enable indexes again.
6779
6780 @param mode Mode.
6781
6782 @retval 0 Success.
6783 @retval != 0 Error.
6784 */
6785
6786 virtual int enable_indexes(uint mode [[maybe_unused]]) {
6787 return HA_ERR_WRONG_COMMAND;
6788 }
6789
6790 /**
6791 Discard or import tablespace.
6792
6793 @param [in] discard Indicates whether this is discard operation.
6794 @param [in,out] table_def dd::Table object describing the table
6795 in which tablespace needs to be discarded
6796 or imported. This object can be adjusted by
6797 storage engine if it supports atomic DDL
6798 (i.e. has HTON_SUPPORTS_ATOMIC_DDL flag set).
6799 These changes will be persisted in the
6800 data-dictionary.
6801 @retval 0 Success.
6802 @retval != 0 Error.
6803 */
6804
6805 virtual int discard_or_import_tablespace(bool discard [[maybe_unused]],
6807 [[maybe_unused]]) {
6809 return HA_ERR_WRONG_COMMAND;
6810 }
6811
6812 virtual void drop_table(const char *name);
6813
6814 /**
6815 Create table (implementation).
6816
6817 @param [in] name Table name.
6818 @param [in] form TABLE object describing the table to be
6819 created.
6820 @param [in] info HA_CREATE_INFO describing table.
6821 @param [in,out] table_def dd::Table object describing the table
6822 to be created. This object can be
6823 adjusted by storage engine if it
6824 supports atomic DDL (i.e. has
6825 HTON_SUPPORTS_ATOMIC_DDL flag set).
6826 These changes will be persisted in the
6827 data-dictionary. Can be NULL for
6828 temporary tables created by optimizer.
6829
6830 @retval 0 Success.
6831 @retval non-0 Error.
6832 */
6833 virtual int create(const char *name, TABLE *form, HA_CREATE_INFO *info,
6834 dd::Table *table_def) = 0;
6835
6836 virtual bool get_se_private_data(dd::Table *dd_table [[maybe_unused]],
6837 bool reset [[maybe_unused]]) {
6838 return false;
6839 }
6840
6841 /**
6842 Adjust definition of table to be created by adding implicit columns
6843 and indexes necessary for the storage engine.
6844
6845 @param [in] create_info HA_CREATE_INFO describing the table.
6846 @param [in] create_list List of columns in the table.
6847 @param [in] key_info Array of KEY objects describing table
6848 indexes.
6849 @param [in] key_count Number of indexes in the table.
6850 @param [in,out] table_obj dd::Table object describing the table
6851 to be created. Implicit columns and
6852 indexes are to be added to this object.
6853 Adjusted table description will be
6854 saved into the data-dictionary.
6855
6856 @retval 0 Success.
6857 @retval non-0 Error.
6858 */
6860 const HA_CREATE_INFO *create_info [[maybe_unused]],
6861 const List<Create_field> *create_list [[maybe_unused]],
6862 const KEY *key_info [[maybe_unused]], uint key_count [[maybe_unused]],
6863 dd::Table *table_obj [[maybe_unused]]) {
6864 return 0;
6865 }
6866
6867 virtual bool set_ha_share_ref(Handler_share **arg_ha_share) {
6868 ha_share = arg_ha_share;
6869 return false;
6870 }
6871
6872 void set_ha_table(TABLE *table_arg) { table = table_arg; }
6873
6874 int get_lock_type() const { return m_lock_type; }
6875
6876 /**
6877 Callback function that will be called by my_prepare_gcolumn_template
6878 once the table has been opened.
6879 */
6880 typedef void (*my_gcolumn_template_callback_t)(const TABLE *, void *);
6881 static bool my_prepare_gcolumn_template(THD *thd, const char *db_name,
6882 const char *table_name,
6884 void *ib_table);
6885 static bool my_eval_gcolumn_expr_with_open(THD *thd, const char *db_name,
6886 const char *table_name,
6887 const MY_BITMAP *const fields,
6888 uchar *record,
6889 const char **mv_data_ptr,
6890 ulong *mv_length);
6891
6892 /**
6893 Callback for computing generated column values.
6894
6895 Storage engines that need to have virtual column values for a row
6896 can use this function to get the values computed. The storage
6897 engine must have filled in the values for the base columns that
6898 the virtual columns depend on.
6899
6900 @param thd thread handle
6901 @param table table object
6902 @param fields bitmap of field index of evaluated generated
6903 column
6904 @param[in,out] record buff of base columns generated column depends.
6905 After calling this function, it will be
6906 used to return the value of the generated
6907 columns.
6908 @param[out] mv_data_ptr When given (not null) and the field
6909 needs to be calculated is a typed array field, it
6910 will contain pointer to field's calculated value.
6911 @param[out] mv_length Length of the data above
6912
6913 @retval true in case of error
6914 @retval false on success
6915 */
6916 static bool my_eval_gcolumn_expr(THD *thd, TABLE *table,
6917 const MY_BITMAP *const fields, uchar *record,
6918 const char **mv_data_ptr, ulong *mv_length);
6919
6920 /* This must be implemented if the handlerton's partition_flags() is set. */
6921 virtual Partition_handler *get_partition_handler() { return nullptr; }
6922
6923 /**
6924 Set se_private_id and se_private_data during upgrade
6925
6926 @param thd Pointer of THD
6927 @param dbname Database name
6928 @param table_name Table name
6929 @param dd_table dd::Table for the table
6930 @param table_arg TABLE object for the table.
6931
6932 @return Operation status
6933 @retval false Success
6934 @retval true Error
6935 */
6936
6937 bool ha_upgrade_table(THD *thd, const char *dbname, const char *table_name,
6938 dd::Table *dd_table, TABLE *table_arg);
6939
6940 /**
6941 Store a pointer to the handler of the primary table that
6942 corresponds to the secondary table in this handler.
6943 */
6944 void ha_set_primary_handler(handler *primary_handler);
6945
6946 /**
6947 Get a pointer to a handler for the table in the primary storage
6948 engine, if this handler is for a table in a secondary storage
6949 engine.
6950 */
6952
6953 /**
6954 Return max limits for a single set of multi-valued keys
6955
6956 @param[out] num_keys number of keys to store
6957 @param[out] keys_length total length of keys, bytes
6958 */
6959 void ha_mv_key_capacity(uint *num_keys, size_t *keys_length) const {
6960 return mv_key_capacity(num_keys, keys_length);
6961 }
6962
6963 /**
6964 Propagates the secondary storage engine offload failure reason for a query
6965 to the external engine when the offloaded query fails in the secondary
6966 storage engine.
6967 */
6968 virtual void set_external_table_offload_error(const char * /*reason*/) {}
6969
6970 /**
6971 Identifies and throws the propagated external engine query offload or exec
6972 failure reason given by the external engine handler.
6973 */
6974 virtual void external_table_offload_error() const {}
6975
6976 private:
6977 /**
6978 Engine-specific function for ha_can_store_mv_keys().
6979 Dummy function. SE's overloaded method is used instead.
6980 */
6981 /* purecov: begin inspected */
6982 virtual void mv_key_capacity(uint *num_keys, size_t *keys_length) const {
6983 *num_keys = 0;
6984 *keys_length = 0;
6985 }
6986 /* purecov: end */
6987
6988 /**
6989 Filter duplicate records when multi-valued index is used for retrieval
6990
6991 @returns
6992 true duplicate, such row id was already seen
6993 false row id is seen for the first time
6994 */
6995 bool filter_dup_records();
6996
6997 protected:
6999 void set_ha_share_ptr(Handler_share *arg_ha_share);
7000 void lock_shared_ha_data();
7001 void unlock_shared_ha_data();
7002
7003 friend class DsMrr_impl;
7004};
7005
7006/* Temporary Table handle for opening uncached table */
7008 public:
7010
7011 /** Open the table handler
7012 @param[in] thd Thread object
7013 @param[in] db_name Database name
7014 @param[in] table_name Table name
7015 @return table object or nullptr */
7016 TABLE *open(THD *thd, const char *db_name, const char *table_name);
7017
7019
7020 private:
7022};
7023
7024/**
7025 Function identifies any old data type present in table.
7026
7027 This function was handler::check_old_types().
7028 Function is not part of SE API. It is now converted to
7029 auxiliary standalone function.
7030
7031 @param[in] table TABLE object
7032 @param[in] check_temporal_upgrade Check if temporal upgrade is needed
7033
7034 @retval 0 ON SUCCESS
7035 @retval error code ON FAILURE
7036*/
7037
7038int check_table_for_old_types(const TABLE *table, bool check_temporal_upgrade);
7039
7040/*
7041 A Disk-Sweep MRR interface implementation
7042
7043 This implementation makes range (and, in the future, 'ref') scans to read
7044 table rows in disk sweeps.
7045
7046 Currently it is used by MyISAM and InnoDB. Potentially it can be used with
7047 any table handler that has non-clustered indexes and on-disk rows.
7048*/
7049
7051 public:
7052 DsMrr_impl(handler *owner) : h(owner), table(nullptr), h2(nullptr) {}
7053
7055 /*
7056 If ha_reset() has not been called then the h2 dialog might still
7057 exist. This must be closed and deleted (this is the case for
7058 internally created temporary tables).
7059 */
7060 if (h2) reset();
7061 assert(h2 == nullptr);
7062 }
7063
7064 private:
7065 /*
7066 The "owner" handler object (the one that calls dsmrr_XXX functions.
7067 It is used to retrieve full table rows by calling rnd_pos().
7068 */
7069 handler *const h;
7070 TABLE *table; /* Always equal to h->table */
7071
7072 /* Secondary handler object. It is used for scanning the index */
7074
7075 /* Buffer to store rowids, or (rowid, range_id) pairs */
7077 uchar *rowids_buf_cur; /* Current position when reading/writing */
7078 uchar *rowids_buf_last; /* When reading: end of used buffer space */
7079 uchar *rowids_buf_end; /* End of the buffer */
7080
7081 bool dsmrr_eof; /* true <=> We have reached EOF when reading index tuples */
7082
7083 /* true <=> need range association, buffer holds {rowid, range_id} pairs */
7085
7086 bool use_default_impl; /* true <=> shortcut all calls to default MRR impl */
7087 public:
7088 /**
7089 Initialize the DsMrr_impl object.
7090
7091 This object is used for both doing default MRR scans and DS-MRR scans.
7092 This function just initializes the object. To do a DS-MRR scan,
7093 this must also be initialized by calling dsmrr_init().
7094
7095 @param table_arg pointer to the TABLE that owns the handler
7096 */
7097
7098 void init(TABLE *table_arg) {
7099 assert(table_arg != nullptr);
7100 table = table_arg;
7101 }
7102
7103 int dsmrr_init(RANGE_SEQ_IF *seq_funcs, void *seq_init_param, uint n_ranges,
7105 void dsmrr_close();
7106
7107 /**
7108 Resets the DS-MRR object to the state it had after being initialized.
7109
7110 If there is an open scan then it will be closed.
7111
7112 This function should be called by handler::ha_reset() which is called
7113 when a statement is completed in order to make the handler object ready
7114 for re-use by a different statement.
7115 */
7116
7117 void reset();
7118 int dsmrr_fill_buffer();
7119 int dsmrr_next(char **range_info);
7120
7121 ha_rows dsmrr_info(uint keyno, uint n_ranges, uint keys, uint *bufsz,
7122 uint *flags, Cost_estimate *cost);
7123
7124 ha_rows dsmrr_info_const(uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param,
7125 uint n_ranges, uint *bufsz, uint *flags,
7126 Cost_estimate *cost);
7127
7128 private:
7129 bool choose_mrr_impl(uint keyno, ha_rows rows, uint *flags, uint *bufsz,
7130 Cost_estimate *cost);
7131 bool get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags,
7133};
7134
7135/* lookups */
7138/**
7139 Resolve handlerton plugin by name, without checking for "DEFAULT" or
7140 HTON_NOT_USER_SELECTABLE.
7141
7142 @param thd Thread context.
7143 @param name Plugin name.
7144
7145 @return plugin or NULL if not found.
7146*/
7149 bool is_temp_table);
7150plugin_ref ha_lock_engine(THD *thd, const handlerton *hton);
7152handler *get_new_handler(TABLE_SHARE *share, bool partitioned, MEM_ROOT *alloc,
7153 handlerton *db_type);
7154handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type,
7155 bool no_substitute, bool report_error);
7156
7158 THD *thd, const LEX_CSTRING &secondary_engine) noexcept;
7159
7160/**
7161 Get default handlerton, if handler supplied is null.
7162
7163 @param thd Thread context.
7164 @param hton The handlerton passed.
7165
7166 @returns pointer to handlerton.
7167*/
7169 if (!hton) {
7170 hton = ha_checktype(thd, DB_TYPE_UNKNOWN, false, false);
7171 assert(hton);
7172 }
7173 return hton;
7174}
7175
7176static inline enum legacy_db_type ha_legacy_type(const handlerton *db_type) {
7177 return (db_type == nullptr) ? DB_TYPE_UNKNOWN : db_type->db_type;
7178}
7179
7180const char *ha_resolve_storage_engine_name(const handlerton *db_type);
7181
7182static inline bool ha_check_storage_engine_flag(const handlerton *db_type,
7183 uint32 flag) {
7184 return db_type == nullptr ? false : (db_type->flags & flag);
7185}
7186
7187/**
7188 Predicate to determine if a storage engine, represented by a handlerton*, is
7189 enabled.
7190 @note "Enabled" in this context refers only the state of the handlerton
7191 object, and does not consider the disabled_storage_engines system variable.
7192 This leads to the very counter-intuitive and confusing situation that it is
7193 possible for a storage engine to be enabled, but at the same time also be
7194 disabled.
7195 */
7196inline bool ha_storage_engine_is_enabled(const handlerton *db_type) {
7197 return (db_type && db_type->create) ? (db_type->state == SHOW_OPTION_YES)
7198 : false;
7199}
7200
7201/* basic stuff */
7202int ha_init_errors(void);
7203int ha_init(void);
7204void ha_end();
7207
7210void ha_close_connection(THD *thd);
7211void ha_kill_connection(THD *thd);
7212/** Invoke handlerton::pre_dd_shutdown() on every storage engine plugin. */
7213void ha_pre_dd_shutdown(void);
7214
7215/**
7216 Flush the log(s) of storage engine(s).
7217
7218 @param binlog_group_flush true if we got invoked by binlog group
7219 commit during flush stage, false in other cases.
7220 @retval false Succeed
7221 @retval true Error
7222*/
7223bool ha_flush_logs(bool binlog_group_flush = false);
7224void ha_drop_database(char *path);
7225int ha_create_table(THD *thd, const char *path, const char *db,
7226 const char *table_name, HA_CREATE_INFO *create_info,
7227 bool update_create_info, bool is_temp_table,
7229
7230int ha_delete_table(THD *thd, handlerton *db_type, const char *path,
7231 const char *db, const char *alias,
7232 const dd::Table *table_def, bool generate_warning);
7233bool ha_check_reserved_db_name(const char *name);
7234
7235/* statistics and info */
7236bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat);
7237
7238typedef bool Log_func(THD *, TABLE *, bool, const uchar *, const uchar *);
7239
7240int binlog_log_row(TABLE *table, const uchar *before_record,
7241 const uchar *after_record, Log_func *log_func);
7242
7243/* discovery */
7244int ha_create_table_from_engine(THD *thd, const char *db, const char *name);
7245bool ha_check_if_table_exists(THD *thd, const char *db, const char *name,
7246 bool *exists);
7247int ha_find_files(THD *thd, const char *db, const char *path, const char *wild,
7248 bool dir, List<LEX_STRING> *files);
7249int ha_table_exists_in_engine(THD *thd, const char *db, const char *name);
7250bool ha_check_if_supported_system_table(handlerton *hton, const char *db,
7251 const char *table_name);
7252bool ha_rm_tmp_tables(THD *thd, List<LEX_STRING> *files);
7253bool default_rm_tmp_tables(handlerton *hton, THD *thd, List<LEX_STRING> *files);
7254
7255/* key cache */
7256int ha_init_key_cache(std::string_view name, KEY_CACHE *key_cache);
7257int ha_resize_key_cache(KEY_CACHE *key_cache);
7258int ha_change_key_cache(KEY_CACHE *old_key_cache, KEY_CACHE *new_key_cache);
7259
7260/* transactions: interface to handlerton functions */
7262int ha_commit_trans(THD *thd, bool all, bool ignore_global_read_lock = false);
7263int ha_commit_attachable(THD *thd);
7264int ha_rollback_trans(THD *thd, bool all);
7265
7266/**
7267 Stage of the recovery process where information is collected from the
7268 storage engines (SE), merged with information from the transaction
7269 coordinator (TC) and transactions states are determined and enforced.
7270
7271 Implemented heuristics is as follows:
7272
7273 1. The `commit_list` parameter contains the set of internally coordinated
7274 transactions that the TC ensures were marked as committed.
7275
7276 2. The `xa_state_list` parameter contains the list of externally
7277 coordinated transactions and their states, as recorded by the TC.
7278
7279 3. For each SE:
7280 a. Collect list of transactions found in `PREPARED_IN_TC` state in the
7281 SE and merge it with the information collected from the TC, in
7282 `xa_state_list`.
7283 b. Retrieve the list of transactions found in prepared state in the
7284 SE.
7285
7286 c. For each internally coordinated transactions found in prepared
7287 state:
7288 1. If the transaction is found in `commit_list`, commit it.
7289 2. If the transaction is NOT found in `commit_list` but
7290 `tc_heuristic_recover = TC_HEURISTIC_RECOVER_COMMIT`, commit it.
7291 3. Otherwise, roll it back.
7292
7293 d. For each externally coordinated transactions found in prepared
7294 state:
7295 1. If the transaction isn't found in `xa_state_list`, roll it back.
7296 2. If the transaction is found in `xa_state_list` in `COMMITTED`
7297 state, commit it.
7298 3. If the transaction is found in `xa_state_list` in `ROLLEDBACK`
7299 state, roll it back.
7300 4. If the transaction is found in `xa_state_list` in `PREPARED`
7301 state, ensure that the transaction state in the SE is
7302 `PREPARED_IN_TC`.
7303
7304 @param commit_list Set of XIDs of internally coordinated transactions
7305 found as been committed in the transaction coordinator
7306 state.
7307 @param xa_state_list Map between XIDs and states of externally
7308 coordinated transactions as found in the internal
7309 transaction coordinator state.
7310
7311 @return 0 if recovery was successful, non-zero otherwise.
7312*/
7313int ha_recover(Xid_commit_list *commit_list = nullptr,
7314 Xa_state_list *xa_state_list = nullptr);
7315
7316/**
7317 Perform SE-specific cleanup after recovery of transactions.
7318
7319 @note SE supporting atomic DDL can use this method to perform
7320 post-DDL actions for DDL statements which were committed
7321 or rolled back during recovery stage.
7322*/
7323void ha_post_recover();
7324
7325/*
7326 transactions: interface to low-level handlerton functions. These are
7327 intended to be used by the transaction coordinators to
7328 commit/prepare/rollback transactions in the engines.
7329*/
7330int ha_commit_low(THD *thd, bool all, bool run_after_commit = true);
7331/**
7332 Prepares the underlying transaction of the THD session object parameter
7333 in the storage engines that participate in the transaction.
7334
7335 In case of failure, an error will be emitted by the function in the case
7336 of internally coordinated transactions. In the case of externally
7337 coordinated transactions (XA), the error treatment must follow the
7338 XA/Open specification and is handled by the `Sql_cmd_xa_prepare` class.
7339
7340 @param thd The THD session object holding the transaction to be prepared.
7341 @param all Whether or not the prepare regards a full transaction or the
7342 statement being executed..
7343
7344 @return 0 if the transaction was successfully prepared, non-zero
7345 otherwise.
7346 */
7347int ha_prepare_low(THD *thd, bool all);
7348int ha_rollback_low(THD *thd, bool all);
7349
7350/* transactions: these functions never call handlerton functions directly */
7351int ha_enable_transaction(THD *thd, bool on);
7352
7353/* savepoints */
7356int ha_savepoint(THD *thd, SAVEPOINT *sv);
7357int ha_release_savepoint(THD *thd, SAVEPOINT *sv);
7358
7359/* these are called by storage engines */
7360void trans_register_ha(THD *thd, bool all, handlerton *ht,
7361 const ulonglong *trxid);
7362
7363int ha_reset_logs(THD *thd);
7364
7365/**
7366 Inform storage engine(s) that a binary log file will be purged and any
7367 references to it should be removed.
7368
7369 The function is called for all purged files, regardless if it is an explicit
7370 PURGE BINARY LOGS statement, or an automatic purge performed by the server.
7371
7372 @note Since function is called with the LOCK_index mutex held the work
7373 performed in this callback should be kept at minimum. One way to defer work is
7374 to schedule work and use the `ha_binlog_index_purge_wait` callback to wait for
7375 completion.
7376
7377 @param thd Thread handle of session purging file. The nullptr value indicates
7378 that purge is done at server startup.
7379 @param file Name of file being purged.
7380 @return Always 0, return value are ignored by caller.
7381*/
7382int ha_binlog_index_purge_file(THD *thd, const char *file);
7383
7384/**
7385 Request the storage engine to complete any operations that were initiated
7386 by `ha_binlog_index_purge_file` and which need to complete
7387 before PURGE BINARY LOGS completes.
7388
7389 The function is called only from PURGE BINARY LOGS. Each PURGE BINARY LOGS
7390 statement will result in 0, 1 or more calls to `ha_binlog_index_purge_file`,
7391 followed by exactly 1 call to `ha_binlog_index_purge_wait`.
7392
7393 @note This function is called without LOCK_index mutex held and thus any
7394 waiting performed will only affect the current session.
7395
7396 @param thd Thread handle of session.
7397*/
7399
7400void ha_reset_slave(THD *thd);
7401void ha_binlog_log_query(THD *thd, handlerton *db_type,
7402 enum_binlog_command binlog_command, const char *query,
7403 size_t query_length, const char *db,
7404 const char *table_name);
7405void ha_acl_notify(THD *thd, class Acl_change_notification *);
7406void ha_binlog_wait(THD *thd);
7407
7408/* It is required by basic binlog features on both MySQL server and libmysqld */
7409int ha_binlog_end(THD *thd);
7410
7411const char *get_canonical_filename(handler *file, const char *path,
7412 char *tmp_path);
7413
7414const char *table_case_name(const HA_CREATE_INFO *info, const char *name);
7415
7416void print_keydup_error(TABLE *table, KEY *key, const char *msg, myf errflag,
7417 const char *org_table_name);
7418void print_keydup_error(TABLE *table, KEY *key, myf errflag,
7419 const char *org_table_name);
7420
7421inline void print_keydup_error(TABLE *table, KEY *key, const char *msg,
7422 myf errflag) {
7423 print_keydup_error(table, key, msg, errflag, nullptr);
7424}
7425inline void print_keydup_error(TABLE *table, KEY *key, myf errflag) {
7426 print_keydup_error(table, key, errflag, nullptr);
7427}
7428
7430
7431bool ha_notify_exclusive_mdl(THD *thd, const MDL_key *mdl_key,
7432 ha_notification_type notification_type,
7433 bool *victimized);
7434bool ha_notify_table_ddl(THD *thd, const MDL_key *mdl_key,
7435 ha_notification_type notification_type,
7436 ha_ddl_type ddl_type, const char *old_db_name,
7437 const char *old_table_name, const char *new_db_name,
7438 const char *new_table_name);
7439
7440std::pair<int, bool> commit_owned_gtids(THD *thd, bool all);
7441bool set_tx_isolation(THD *thd, enum_tx_isolation tx_isolation, bool one_shot);
7443
7444/*
7445 This class is used by INFORMATION_SCHEMA.FILES to read SE specific
7446 tablespace dynamic metadata. Some member like m_type and id, is not
7447 really dynamic, but as this information is not stored in data dictionary
7448 in a generic format and still is SE specific Some member like m_type and
7449 id, is not really dynamic, but as this information is not stored in data
7450 dictionary in a generic format and still needs SE specific decision, we
7451 are requesting the same from SE.
7452*/
7453
7455 public:
7457 : m_id(0),
7459 m_free_extents(0),
7460 m_total_extents(0),
7461 m_extent_size(0),
7462 m_initial_size(0),
7463 m_maximum_size(0),
7465 m_version(~0ULL),
7466 m_data_free(0) {}
7467
7483};
7484
7485#endif /* HANDLER_INCLUDED */
app_data_ptr new_data(u_int n, char *val, cons_type consensus)
Definition: acl_change_notification.h:32
const std::string db
Definition: acl_change_notification.h:51
Data describing the table being created by CREATE TABLE or altered by ALTER TABLE.
Definition: sql_alter.h:204
Class describing changes to be done by ALTER TABLE.
Definition: handler.h:3196
static const HA_ALTER_FLAGS COALESCE_PARTITION
Definition: handler.h:3313
Alter_info * alter_info
Alter options, fields and keys for the new version of table.
Definition: handler.h:3413
static const HA_ALTER_FLAGS CHANGE_INDEX_OPTION
Change index option in a way which is likely not to require index recreation.
Definition: handler.h:3355
uint key_count
Size of key_info_buffer array.
Definition: handler.h:3449
static const HA_ALTER_FLAGS ALTER_VIRTUAL_COLUMN_TYPE
Definition: handler.h:3255
static const HA_ALTER_FLAGS DROP_PARTITION
Definition: handler.h:3307
static const HA_ALTER_FLAGS ADD_VIRTUAL_COLUMN
Definition: handler.h:3236
const char * unsupported_reason
Can be set by handler to describe why a given operation cannot be done in-place (HA_ALTER_INPLACE_NOT...
Definition: handler.h:3549
KEY * key_info_buffer
Array of KEYs for new version of table - including KEYs to be added.
Definition: handler.h:3446
static const HA_ALTER_FLAGS ADD_FOREIGN_KEY
Definition: handler.h:3286
static const HA_ALTER_FLAGS DROP_COLUMN
Definition: handler.h:3248
static const HA_ALTER_FLAGS ALTER_COLUMN_INDEX_LENGTH
Change in index length such that it does not require index rebuild.
Definition: handler.h:3365
static const HA_ALTER_FLAGS ADD_STORED_GENERATED_COLUMN
Definition: handler.h:3240
static const HA_ALTER_FLAGS ALTER_TABLE_REORG
Definition: handler.h:3319
static const HA_ALTER_FLAGS VALIDATE_VIRTUAL_COLUMN
Definition: handler.h:3348
static const HA_ALTER_FLAGS ADD_SPATIAL_INDEX
Definition: handler.h:3342
static const HA_ALTER_FLAGS DROP_CHECK_CONSTRAINT
Definition: handler.h:3383
static const HA_ALTER_FLAGS ALTER_STORED_GCOL_EXPR
Definition: handler.h:3283
uint virtual_column_add_count
Number of virtual columns to be added.
Definition: handler.h:3487
static const HA_ALTER_FLAGS RECREATE_TABLE
Recreate the table for ALTER TABLE FORCE, ALTER TABLE ENGINE and OPTIMIZE TABLE operations.
Definition: handler.h:3339
static const HA_ALTER_FLAGS STORED_GCOL_REEVAL
Change to one of columns on which stored generated column depends, so its values require re-evaluatio...
Definition: handler.h:3377
static const HA_ALTER_FLAGS ADD_PARTITION
Definition: handler.h:3304
static const HA_ALTER_FLAGS ADD_STORED_BASE_COLUMN
Definition: handler.h:3238
static const HA_ALTER_FLAGS ADD_PK_INDEX
Definition: handler.h:3228
uint index_drop_count
Size of index_drop_buffer array.
Definition: handler.h:3452
ulonglong HA_ALTER_FLAGS
Bits to show in detail what operations the storage engine is to execute.
Definition: handler.h:3213
static const HA_ALTER_FLAGS ALTER_COLUMN_STORAGE_TYPE
Definition: handler.h:3298
static const HA_ALTER_FLAGS ALTER_COLUMN_NAME
Definition: handler.h:3252
static const HA_ALTER_FLAGS ALTER_COLUMN_COLUMN_FORMAT
Definition: handler.h:3301
static const HA_ALTER_FLAGS ADD_COLUMN
Definition: handler.h:3242
static const HA_ALTER_FLAGS ALTER_REBUILD_PARTITION
Definition: handler.h:3358
static const HA_ALTER_FLAGS ALTER_INDEX_COMMENT
Definition: handler.h:3345
KEY_PAIR * index_rename_buffer
Array of KEY_PAIR objects describing indexes being renamed.
Definition: handler.h:3483
uint index_altered_visibility_count
Size of index_rename_buffer array.
Definition: handler.h:3473
void report_unsupported_error(const char *not_supported, const char *try_instead)
Used after check_if_supported_inplace_alter() to report error if the result does not match the LOCK/A...
Definition: handler.cc:4989
bool error_if_not_empty
Indicates whether operation should fail if table is non-empty.
Definition: handler.h:3429
static const HA_ALTER_FLAGS ADD_CHECK_CONSTRAINT
Definition: handler.h:3380
static const HA_ALTER_FLAGS ALTER_RENAME
Definition: handler.h:3295
void add_renamed_key(KEY *old_key, KEY *new_key)
Add old and new version of key to array of indexes to be renamed.
Definition: handler.h:3592
static const HA_ALTER_FLAGS SUSPEND_CHECK_CONSTRAINT
Definition: handler.h:3386
static const HA_ALTER_FLAGS ALTER_REMOVE_PARTITIONING
Definition: handler.h:3322
static const HA_ALTER_FLAGS ALTER_COLUMN_EQUAL_PACK_LENGTH
Change column datatype in such way that new type has compatible packed representation with old type,...
Definition: handler.h:3264
uint index_add_count
Size of index_add_buffer array.
Definition: handler.h:3461
static const HA_ALTER_FLAGS REORGANIZE_PARTITION
Definition: handler.h:3316
inplace_alter_handler_ctx * handler_ctx
Context information to allow handlers to keep context between in-place alter API calls.
Definition: handler.h:3498
static const HA_ALTER_FLAGS ALTER_VIRTUAL_GCOL_EXPR
Definition: handler.h:3282
static const HA_ALTER_FLAGS ADD_INDEX
Definition: handler.h:3216
static const HA_ALTER_FLAGS DROP_FOREIGN_KEY
Definition: handler.h:3289
uint index_rename_count
Size of index_rename_buffer array.
Definition: handler.h:3470
static const HA_ALTER_FLAGS ADD_UNIQUE_INDEX
Definition: handler.h:3222
HA_CREATE_INFO * create_info
Create options (like MAX_ROWS) for the new version of table.
Definition: handler.h:3400
uint handler_trivial_ctx
Can be set by handler along with handler_ctx.
Definition: handler.h:3535
KEY_PAIR * index_altered_visibility_buffer
Definition: handler.h:3484
static const HA_ALTER_FLAGS DROP_INDEX
Definition: handler.h:3219
static const HA_ALTER_FLAGS ALTER_COLUMN_NOT_NULLABLE
Definition: handler.h:3276
static const HA_ALTER_FLAGS DROP_UNIQUE_INDEX
Definition: handler.h:3225
static const HA_ALTER_FLAGS ALTER_PARTITION
Definition: handler.h:3310
static const HA_ALTER_FLAGS ALTER_COLUMN_NULLABLE
Definition: handler.h:3273
partition_info * modified_part_info
Partition_info taking into account the partition changes to be performed.
Definition: handler.h:3524
HA_ALTER_FLAGS handler_flags
Flags describing in detail which operations the storage engine is to execute.
Definition: handler.h:3516
Alter_inplace_info(HA_CREATE_INFO *create_info_arg, Alter_info *alter_info_arg, bool error_if_not_empty_arg, KEY *key_info_arg, uint key_count_arg, partition_info *modified_part_info_arg)
Definition: handler.h:3551
~Alter_inplace_info()
Definition: handler.h:3577
static const HA_ALTER_FLAGS VIRTUAL_GCOL_REEVAL
Change to one of columns on which virtual generated column depends, so its values require re-evaluati...
Definition: handler.h:3371
void add_added_key(KEY *new_key)
Add key to array of indexes to be added.
Definition: handler.h:3626
void add_altered_index_visibility(KEY *old_key, KEY *new_key)
Definition: handler.h:3600
static const HA_ALTER_FLAGS ALTER_VIRTUAL_COLUMN_ORDER
A virtual column has changed its position.
Definition: handler.h:3267
static const HA_ALTER_FLAGS RENAME_INDEX
Rename index.
Definition: handler.h:3333
uint virtual_column_drop_count
number of virtual columns to be dropped.
Definition: handler.h:3490
void add_modified_key(KEY *old_key, KEY *new_key)
Add old and new version of modified key to arrays of indexes to be dropped and added (correspondingly...
Definition: handler.h:3613
static const HA_ALTER_FLAGS DROP_PK_INDEX
Definition: handler.h:3231
static const HA_ALTER_FLAGS ALTER_STORED_COLUMN_ORDER
A stored column has changed its position (disregarding virtual columns)
Definition: handler.h:3270
bool online
true for online operation (LOCK=NONE)
Definition: handler.h:3527
KEY ** index_drop_buffer
Array of pointers to KEYs to be dropped belonging to the TABLE instance for the old version of the ta...
Definition: handler.h:3458
uint * index_add_buffer
Array of indexes into key_info_buffer for KEYs to be added, sorted in increasing order.
Definition: handler.h:3467
void add_dropped_key(KEY *old_key)
Drop key to array of indexes to be dropped.
Definition: handler.h:3620
static const HA_ALTER_FLAGS CHANGE_CREATE_OPTION
Definition: handler.h:3292
static const HA_ALTER_FLAGS DROP_VIRTUAL_COLUMN
Definition: handler.h:3246
static const HA_ALTER_FLAGS ALTER_COLUMN_VISIBILITY
Definition: handler.h:3389
static const HA_ALTER_FLAGS ALTER_STORED_COLUMN_TYPE
Definition: handler.h:3256
inplace_alter_handler_ctx ** group_commit_ctx
If the table uses several handlers, like ha_partition uses one handler per partition,...
Definition: handler.h:3510
static const HA_ALTER_FLAGS ALTER_COLUMN_DEFAULT
Definition: handler.h:3279
static const HA_ALTER_FLAGS DROP_STORED_COLUMN
Definition: handler.h:3247
static const HA_ALTER_FLAGS ALTER_ALL_PARTITION
Definition: handler.h:3325
Used to store optimizer cost estimates.
Definition: handler.h:3706
Cost_estimate & operator+=(const Cost_estimate &other)
Definition: handler.h:3755
Cost_estimate operator-(const Cost_estimate &other)
Definition: handler.h:3773
void add_import(double add_import_cost)
Add to import cost.
Definition: handler.h:3806
void reset()
Reset all costs to zero.
Definition: handler.h:3738
void set_max_cost()
Set current cost to the maximal double.
Definition: handler.h:3740
Cost_estimate()
Definition: handler.h:3714
void add_cpu(double add_cpu_cost)
Add to CPU cost.
Definition: handler.h:3800
double mem_cost
memory used (bytes)
Definition: handler.h:3711
double io_cost
cost of I/O operations
Definition: handler.h:3708
bool is_max_cost() const
Whether or not the total cost is the maximal double.
Definition: handler.h:3736
void add_mem(double add_mem_cost)
Add to memory cost.
Definition: handler.h:3812
bool operator<(const Cost_estimate &other) const
Definition: handler.h:3789
double get_cpu_cost() const
Definition: handler.h:3719
double get_mem_cost() const
Definition: handler.h:3721
double total_cost() const
Returns sum of time-consuming costs, i.e., not counting memory cost.
Definition: handler.h:3717
double get_io_cost() const
Definition: handler.h:3718
void add_io(double add_io_cost)
Add to IO cost.
Definition: handler.h:3794
double import_cost
cost of remote operations
Definition: handler.h:3710
double cpu_cost
cost of CPU operations
Definition: handler.h:3709
double get_import_cost() const
Definition: handler.h:3720
void multiply(double m)
Multiply io, cpu and import costs by parameter.
Definition: handler.h:3746
bool is_zero() const
Whether or not all costs in the object are zero.
Definition: handler.h:3728
bool operator>(const Cost_estimate &other) const
Definition: handler.h:3785
Cost_estimate operator+(const Cost_estimate &other)
Definition: handler.h:3766
Create_field is a description a field/column that may or may not exists in a table.
Definition: create_field.h:51
Definition: discrete_interval.h:41
Definition: handler.h:7050
DsMrr_impl(handler *owner)
Definition: handler.h:7052
bool get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags, uint *buffer_size, Cost_estimate *cost)
Get cost of DS-MRR scan.
Definition: handler.cc:7038
void reset()
Resets the DS-MRR object to the state it had after being initialized.
Definition: handler.cc:6713
ha_rows dsmrr_info(uint keyno, uint n_ranges, uint keys, uint *bufsz, uint *flags, Cost_estimate *cost)
Definition: handler.cc:6855
ha_rows dsmrr_info_const(uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint *bufsz, uint *flags, Cost_estimate *cost)
Definition: handler.cc:6884
void dsmrr_close()
Definition: handler.cc:6702
uchar * rowids_buf_end
Definition: handler.h:7079
uchar * rowids_buf_cur
Definition: handler.h:7077
int dsmrr_fill_buffer()
DS-MRR: Fill the buffer with rowids and sort it by rowid.
Definition: handler.cc:6742
uchar * rowids_buf
Definition: handler.h:7076
handler * h2
Definition: handler.h:7073
handler *const h
Definition: handler.h:7069
~DsMrr_impl()
Definition: handler.h:7054
bool use_default_impl
Definition: handler.h:7086
void init(TABLE *table_arg)
Initialize the DsMrr_impl object.
Definition: handler.h:7098
int dsmrr_init(RANGE_SEQ_IF *seq_funcs, void *seq_init_param, uint n_ranges, uint mode, HANDLER_BUFFER *buf)
DS-MRR: Initialize and start MRR scan.
Definition: handler.cc:6525
bool choose_mrr_impl(uint keyno, ha_rows rows, uint *flags, uint *bufsz, Cost_estimate *cost)
DS-MRR Internals: Choose between Default MRR implementation and DS-MRR.
Definition: handler.cc:6941
bool dsmrr_eof
Definition: handler.h:7081
bool is_mrr_assoc
Definition: handler.h:7084
uchar * rowids_buf_last
Definition: handler.h:7078
TABLE * table
Definition: handler.h:7070
int dsmrr_next(char **range_info)
Definition: handler.cc:6809
Definition: field.h:575
Wrapper for struct ft_hints.
Definition: handler.h:3966
uint get_flags() const
Get Ft_hints flags.
Definition: handler.h:4029
void set_hint_flag(uint ft_flag)
Set Ft_hints flag.
Definition: handler.h:3994
double get_op_value() const
Get Ft_hints operation value.
Definition: handler.h:4015
struct ft_hints * get_hints()
Get ft_hints struct.
Definition: handler.h:4036
Ft_hints(uint ft_flags)
Definition: handler.h:3971
ha_rows get_limit() const
Get Ft_hints limit.
Definition: handler.h:4008
enum ft_operation get_op_type() const
Get Ft_hints operation type.
Definition: handler.h:4022
void set_hint_limit(ha_rows ft_limit)
Set Ft_hints limit.
Definition: handler.h:4001
void set_hint_op(enum ft_operation type, double value)
Set comparison operation type and and value for master MATCH function.
Definition: handler.h:3984
struct ft_hints hints
Definition: handler.h:3968
Definition: handler.h:1012
const char * get_source_name()
Get SE source file name.
Definition: handler.h:1103
void set_dest_name(const char *name)
Set SE destination file name.
Definition: handler.h:1115
virtual int file_cbk(Ha_clone_file from_file, uint len)=0
Callback providing data from current position of a file descriptor of specific length.
uint m_desc_len
SE's Serialized descriptor length.
Definition: handler.h:1177
void set_hton(handlerton *hton)
Set current storage engine handlerton.
Definition: handler.h:1057
handlerton * get_hton()
Get current storage engine handlerton.
Definition: handler.h:1061
virtual int buffer_cbk(uchar *from_buffer, uint len)=0
Callback providing data in buffer of specific length.
Ha_clone_cbk()
Constructor to initialize members.
Definition: handler.h:1015
const int HA_CLONE_FILE_CACHE
Data file is opened for read/write with OS buffer cache.
Definition: handler.h:1195
void mark_state_change(uint64_t estimate)
Set state information and notify state change.
Definition: handler.h:1152
bool is_os_buffer_cache() const
Check if the file descriptor is opened for read/write with OS buffer cache.
Definition: handler.h:1136
void set_os_buffer_cache()
Mark that the file descriptor is opened for read/write with OS buffer cache.
Definition: handler.h:1130
const int HA_CLONE_STATE_CHANGE
State change notification by SE.
Definition: handler.h:1204
const char * m_dest_name
Current destination file name.
Definition: handler.h:1183
int m_flag
Flag storing data related options.
Definition: handler.h:1189
void set_source_name(const char *name)
Set SE source file name.
Definition: handler.h:1107
bool is_zero_copy() const
Check if zero copy optimization is suggested.
Definition: handler.h:1142
const char * m_src_name
Current source file name.
Definition: handler.h:1180
bool is_state_change(uint64_t &estimate)
Check if SE notified state change.
Definition: handler.h:1158
uint m_loc_idx
SE index in caller's locator array.
Definition: handler.h:1168
const uchar * get_data_desc(uint *lenp)
Get data descriptor.
Definition: handler.h:1093
uint64_t m_state_estimate
Estimated bytes to be transferred.
Definition: handler.h:1186
const uchar * m_data_desc
SE's Serialized data descriptor.
Definition: handler.h:1174
const char * get_dest_name()
Get SE destination file name.
Definition: handler.h:1111
bool is_secure() const
Check if data needs secure transfer.
Definition: handler.h:1148
void set_zero_copy()
Mark that the file can be transferred with zero copy.
Definition: handler.h:1139
virtual ~Ha_clone_cbk()=default
virtual destructor.
const int HA_CLONE_SECURE
Data needs to be transferred securely over SSL connection.
Definition: handler.h:1201
virtual int apply_buffer_cbk(uchar *&to_buffer, uint &len)=0
Callback to get data in buffer.
uint m_client_buff_size
Caller's transfer buffer size.
Definition: handler.h:1171
virtual int apply_file_cbk(Ha_clone_file to_file)=0
Callback providing a file descriptor to write data starting from current position.
void set_ack()
Mark that ACK is needed for the data transfer before returning from callback.
Definition: handler.h:1122
bool is_ack_needed() const
Check if ACK is needed for the data transfer.
Definition: handler.h:1126
void set_client_buffer_size(uint size)
Set caller's transfer buffer size.
Definition: handler.h:1066
void set_secure()
Mark that data needs secure transfer.
Definition: handler.h:1145
const int HA_CLONE_ACK
Acknowledgement is needed for the data transfer.
Definition: handler.h:1192
void set_loc_index(uint idx)
Set current SE index.
Definition: handler.h:1074
void clear_flags()
Clear all flags set by SE.
Definition: handler.h:1118
handlerton * m_hton
Handlerton for the SE.
Definition: handler.h:1165
uint get_client_buffer_size()
Get caller's transfer buffer size.
Definition: handler.h:1070
uint get_loc_index()
Get current SE index.
Definition: handler.h:1078
const int HA_CLONE_ZERO_COPY
Data file can be transferred with zero copy.
Definition: handler.h:1198
void set_data_desc(const uchar *desc, uint len)
Set data descriptor.
Definition: handler.h:1084
Base class to be used by handlers different shares.
Definition: handler.h:3956
Handler_share()=default
virtual ~Handler_share()=default
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:853
Definition: sql_optimizer.h:133
JSON DOM abstract base class.
Definition: json_dom.h:173
Definition: key.h:57
Definition: key.h:113
const char * name
Name of key.
Definition: key.h:153
bool is_visible
True if this index is visible to the query optimizer.
Definition: key.h:201
Definition: sql_list.h:434
Mem_root_allocator is a C++ STL memory allocator based on MEM_ROOT.
Definition: mem_root_allocator.h:68
Class for partitioning specific operations.
Definition: partition_handler.h:194
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
Class to hold information regarding a predefined tablespace created by a storage engine.
Definition: plugin_table.h:129
This class represents a buffer that can be used for multi-row reads.
Definition: record_buffer.h:47
Cost constants for a storage engine.
Definition: opt_costconstants.h:197
Simple intrusive linked list.
Definition: sql_list.h:46
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
Data structure that contains the information about shared tablespaces.
Definition: fsp0space.h:47
Definition: handler.h:7007
Temp_table_handle()
Definition: handler.h:7009
~Temp_table_handle()
Definition: handler.cc:8520
TABLE * open(THD *thd, const char *db_name, const char *table_name)
Open the table handler.
Definition: handler.cc:8491
TABLE * table
Definition: handler.h:7021
Unique_on_insert – similar to above, but rejects duplicates on insert, not just on read of the final ...
Definition: uniques.h:123
Class to maintain list of externally coordinated transactions and their current state at recovery.
Definition: handler.h:1252
enum_ha_recover_xa_state add(XID const &xid, enum_ha_recover_xa_state state)
Adds a transaction and state to the underlying map.
Definition: handler.cc:8845
std::map< XID, enum_ha_recover_xa_state, std::less< XID >, Xa_state_list::allocator >::iterator iterator
Definition: handler.h:1259
enum_ha_recover_xa_state find(XID const &to_find)
Searches the underlying map to find an key that corresponds to the parameter.
Definition: handler.cc:8839
static Xa_state_list::instantiation_tuple new_instance()
Factory like method to instantiate all the infra-structure needed to create an Xa_state_list.
Definition: handler.cc:8877
Xa_state_list(Xa_state_list::list &populated_by_tc)
Class constructor.
Definition: handler.cc:8836
std::pair< const XID, enum_ha_recover_xa_state > pair
Definition: handler.h:1254
Xa_state_list::list & m_underlying
The underlying map holding the trx and states.
Definition: handler.h:1331
std::map< XID, enum_ha_recover_xa_state, std::less< XID >, Xa_state_list::allocator > list
Definition: handler.h:1257
std::tuple< std::unique_ptr< MEM_ROOT >, std::unique_ptr< Xa_state_list::allocator >, std::unique_ptr< Xa_state_list::list >, std::unique_ptr< Xa_state_list > > instantiation_tuple
Definition: handler.h:1262
virtual ~Xa_state_list()=default
The Properties class defines an interface for storing key=value pairs, where both key and value may b...
Definition: properties.h:74
Definition: table.h:47
Definition: tablespace.h:55
Definition: handler.h:3877
ulonglong index_file_length
Definition: handler.h:3881
uint block_size
Definition: handler.h:3900
ulonglong data_file_length
Definition: handler.h:3879
ulong update_time
Definition: handler.h:3899
ha_rows records
Definition: handler.h:3893
ulonglong max_data_file_length
Definition: handler.h:3880
ulong check_time
Definition: handler.h:3898
time_t create_time
Definition: handler.h:3897
ulonglong max_index_file_length
Definition: handler.h:3882
ulong mean_rec_length
Definition: handler.h:3895
ulonglong auto_increment_value
Definition: handler.h:3884
ha_statistics()
Definition: handler.h:3915
double table_in_mem_estimate
Estimate for how much of the table that is available in a memory buffer.
Definition: handler.h:3913
ulonglong delete_length
Definition: handler.h:3883
uint mrr_length_per_rec
Definition: handler.h:3905
ha_rows deleted
Definition: handler.h:3894
Definition: handler.h:7454
ulonglong m_id
Definition: handler.h:7468
ulonglong m_initial_size
Definition: handler.h:7475
dd::String_type m_row_format
Definition: handler.h:7479
ulonglong m_data_free
Definition: handler.h:7480
ulonglong m_version
Definition: handler.h:7478
dd::String_type m_status
Definition: handler.h:7481
ulonglong m_maximum_size
Definition: handler.h:7476
ulonglong m_logfile_group_number
Definition: handler.h:7471
ulonglong m_free_extents
Definition: handler.h:7472
ha_tablespace_statistics()
Definition: handler.h:7456
ulonglong m_autoextend_size
Definition: handler.h:7477
ulonglong m_total_extents
Definition: handler.h:7473
ulonglong m_extent_size
Definition: handler.h:7474
dd::String_type m_logfile_group_name
Definition: handler.h:7470
dd::String_type m_type
Definition: handler.h:7469
dd::String_type m_extra
Definition: handler.h:7482
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4414
virtual int sample_end(void *scan_ctx)
End sampling.
Definition: handler.cc:3086
KEY_PART_INFO * range_key_part
Definition: handler.h:4473
virtual int ft_read(uchar *)
Definition: handler.h:5481
virtual bool get_foreign_dup_key(char *child_table_name, uint child_table_name_len, char *child_key_name, uint child_key_name_len)
Retrieves the names of the table and the key for which there was a duplicate entry in the case of HA_...
Definition: handler.cc:4606
virtual int load_table(const TABLE &table)
Loads a table into its defined secondary storage engine.
Definition: handler.h:6630
virtual int repair(THD *, HA_CHECK_OPT *)
In this method check_opt can be modified to specify CHECK option to use to call check() upon the tabl...
Definition: handler.h:6561
ulonglong insert_id_for_cur_row
insert id for the current row (autogenerated; if not autogenerated, it's 0).
Definition: handler.h:4523
virtual bool is_index_algorithm_supported(enum ha_key_alg key_alg) const
Check if SE supports specific key algorithm.
Definition: handler.h:5339
virtual void set_external_table_offload_error(const char *)
Propagates the secondary storage engine offload failure reason for a query to the external engine whe...
Definition: handler.h:6968
virtual double read_time(uint index, uint ranges, ha_rows rows)
The cost of reading a set of ranges from the table using an index to access it.
Definition: handler.h:4986
handler * m_primary_handler
Pointer to the handler of the table in the primary storage engine, if this handler represents a table...
Definition: handler.h:4470
virtual ~handler(void)
Definition: handler.h:4674
@ SAMPLING
Definition: handler.h:4500
@ NONE
Definition: handler.h:4500
@ INDEX
Definition: handler.h:4500
@ RND
Definition: handler.h:4500
int ha_index_init(uint idx, bool sorted)
Initialize use of index.
Definition: handler.cc:2874
virtual int index_prev(uchar *)
Definition: handler.h:5426
virtual FT_INFO * ft_init_ext(uint flags, uint inx, String *key)
Definition: handler.cc:3010
virtual void external_table_offload_error() const
Identifies and throws the propagated external engine query offload or exec failure reason given by th...
Definition: handler.h:6974
virtual uint max_supported_key_length() const
Definition: handler.h:5791
const Item * pushed_cond
Definition: handler.h:4502
void set_ha_table(TABLE *table_arg)
Definition: handler.h:6872
Unique_on_insert * m_unique
Definition: handler.h:4638
std::mt19937 m_random_number_engine
Definition: handler.h:4542
virtual int reset()
Reset state of file to after 'open'.
Definition: handler.h:6511
virtual int records_from_index(ha_rows *num_rows, uint index)
Number of rows in table counted using the secondary index chosen by optimizer.
Definition: handler.cc:3133
virtual int open(const char *name, int mode, uint test_if_locked, const dd::Table *table_def)=0
virtual int index_first(uchar *)
Definition: handler.h:5429
Handler_share * get_ha_share_ptr()
Get an initialized ha_share.
Definition: handler.cc:8085
bool m_update_generated_read_fields
Some non-virtual ha_* functions, responsible for reading rows, like ha_rnd_pos(), must ensure that vi...
Definition: handler.h:4635
batch_mode_t
Internal state of the batch instrumentation.
Definition: handler.h:4547
@ PSI_BATCH_MODE_STARTING
Batch mode used, before first table io.
Definition: handler.h:4551
@ PSI_BATCH_MODE_STARTED
Batch mode used, after first table io.
Definition: handler.h:4553
@ PSI_BATCH_MODE_NONE
Batch mode not used.
Definition: handler.h:4549
Discrete_interval auto_inc_interval_for_cur_row
Interval returned by get_auto_increment() and being consumed by the inserter.
Definition: handler.h:4528
void restore_auto_increment(ulonglong prev_insert_id)
Definition: handler.h:5719
bool ha_check_and_repair(THD *thd)
Check and repair table: public interface.
Definition: handler.cc:4854
virtual enum ha_key_alg get_default_index_algorithm() const
Get default key algorithm for SE.
Definition: handler.h:5328
double table_in_memory_estimate() const
Return an estimate of how much of the table that is currently stored in main memory.
Definition: handler.cc:5926
virtual const char * table_type() const =0
The following can be called without an open handler.
virtual Cost_estimate read_cost(uint index, double ranges, double rows)
Cost estimate for reading a set of ranges from the table using an index to access it.
Definition: handler.cc:6064
bool in_range_check_pushed_down
Definition: handler.h:4479
uint ranges_in_seq
Definition: handler.h:4440
uint max_key_parts() const
Definition: handler.h:5778
virtual bool primary_key_is_clustered() const
Check if the primary key is clustered or not.
Definition: handler.h:5878
bool m_virt_gcol_in_end_range
Flag which tells if end_range contains a virtual generated column.
Definition: handler.h:4493
int ha_index_next_pushed(uchar *buf)
Definition: handler.cc:3568
ha_statistics stats
Definition: handler.h:4434
void rebind_psi()
Definition: handler.cc:2709
int ha_update_row(const uchar *old_data, uchar *new_data)
Update the current row.
Definition: handler.cc:8006
int ha_delete_all_rows()
Delete all rows: public interface.
Definition: handler.cc:4802
virtual int index_init(uint idx, bool sorted)
Definition: handler.h:6448
virtual int enable_indexes(uint mode)
Enable indexes again.
Definition: handler.h:6786
int check_collation_compatibility()
Check for incompatible collation changes.
Definition: handler.cc:4491
virtual uint lock_count(void) const
Get number of lock objects returned in store_lock.
Definition: handler.h:5834
std::function< void(void *cookie)> Load_end_cbk
This callback is called by each parallel load thread when processing of rows has ended for the adapte...
Definition: handler.h:4871
virtual const TABLE * parent_of_pushed_join() const
If this handler instance is a child in a pushed join sequence returned TABLE instance being my parent...
Definition: handler.h:5972
virtual uint max_supported_key_parts() const
Definition: handler.h:5790
enum_range_scan_direction range_scan_direction
Definition: handler.h:4463
bool eq_range
Definition: handler.h:4474
virtual int disable_indexes(uint mode)
Disable indexes for a while.
Definition: handler.h:6773
virtual uint extra_rec_buf_length() const
Definition: handler.h:5201
key_range * end_range
End value for a range scan.
Definition: handler.h:4488
virtual void init_table_handle_for_HANDLER()
Definition: handler.h:5764
uint active_index
Definition: handler.h:4496
RANGE_SEQ_IF mrr_funcs
Definition: handler.h:4438
int ha_index_last(uchar *buf)
Reads the last row via index.
Definition: handler.cc:3444
virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share)
Change the internal TABLE_SHARE pointer.
Definition: handler.h:4954
virtual int extra(enum ha_extra_function operation)
Storage engine specific implementation of ha_extra()
Definition: handler.h:5586
virtual void end_bulk_update()
Perform any needed clean-up, no outstanding updates are there at the moment.
Definition: handler.h:5382
int ha_multi_range_read_next(char **range_info)
Definition: handler.cc:6394
int ha_end_bulk_insert()
End bulk insert.
Definition: handler.cc:4775
uint errkey
Definition: handler.h:4494
virtual ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key)
Find number of records in a range.
Definition: handler.h:5518
virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint mode, HANDLER_BUFFER *buf)
Initialize the MRR scan.
Definition: handler.cc:6382
virtual int multi_range_read_next(char **range_info)
Get next record in MRR scan.
Definition: handler.cc:6424
virtual int update_row(const uchar *old_data, uchar *new_data)
Update a single row.
Definition: handler.h:6498
virtual int index_read_pushed(uchar *, const uchar *, key_part_map)
Definition: handler.h:5984
virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info, uint table_changes)
Part of old, deprecated in-place ALTER API.
Definition: handler.h:5994
int ha_enable_indexes(uint mode)
Enable indexes: public interface.
Definition: handler.cc:4880
virtual bool is_fatal_error(int error)
Determine whether an error is fatal or not.
Definition: handler.cc:4140
virtual int sample_next(void *scan_ctx, uchar *buf)
Get the next record for sampling.
Definition: handler.cc:3088
double index_in_memory_estimate(uint keyno) const
Return an estimate of how much of the index that is currently stored in main memory.
Definition: handler.cc:5945
bool filter_dup_records()
Filter duplicate records when multi-valued index is used for retrieval.
Definition: handler.cc:8458
int m_lock_type
The lock type set by when calling::ha_external_lock().
Definition: handler.h:4614
handlerton * ht
Definition: handler.h:4428
virtual bool is_ignorable_error(int error)
Determine whether an error can be ignored or not.
Definition: handler.cc:4115
TABLE_SHARE * table_share
Definition: handler.h:4421
int ha_read_range_next()
Definition: handler.cc:7345
int ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info, dd::Table *table_def)
Create a table in the engine: public interface.
Definition: handler.cc:5046
virtual int info(uint flag)=0
General method to gather info from handler.
virtual bool start_read_removal(void)
Start read (before write) removal on the current table.
Definition: handler.h:5618
int ha_sample_end(void *scan_ctx)
End sampling.
Definition: handler.cc:3052
void ha_start_bulk_insert(ha_rows rows)
Start bulk insert.
Definition: handler.cc:4760
int ha_delete_row(const uchar *buf)
Definition: handler.cc:8034
int ha_index_next_same(uchar *buf, const uchar *key, uint keylen)
Reads the next same row via index.
Definition: handler.cc:3480
int ha_index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map)
Definition: handler.cc:3257
virtual void cancel_pushed_idx_cond()
Reset information about pushed index conditions.
Definition: handler.h:5950
int ha_sample_init(void *&scan_ctx, double sampling_percentage, int sampling_seed, enum_sampling_method sampling_method, const bool tablesample)
Initialize sampling.
Definition: handler.cc:3033
virtual void append_create_info(String *packet)
Definition: handler.h:5763
virtual uint max_supported_key_part_length(HA_CREATE_INFO *create_info) const
Definition: handler.h:5792
bool ha_upgrade_table(THD *thd, const char *dbname, const char *table_name, dd::Table *dd_table, TABLE *table_arg)
Set se_private_id and se_private_data during upgrade.
Definition: handler.cc:8370
virtual int check(THD *, HA_CHECK_OPT *)
Definition: handler.h:6554
virtual const Item * cond_push(const Item *cond)
Push condition down to the table handler.
Definition: handler.h:5915
virtual longlong get_memory_buffer_size() const
Return an estimate on the amount of memory the storage engine will use for caching data in memory.
Definition: handler.h:5097
virtual int rnd_next(uchar *buf)=0
virtual void unlock_row()
Unlock last accessed row.
Definition: handler.h:5692
virtual int preload_keys(THD *, HA_CHECK_OPT *)
Definition: handler.h:5750
uint max_keys() const
Definition: handler.h:5775
void ha_statistic_increment(ulonglong System_status_var::*offset) const
Definition: handler.cc:2685
int ha_bulk_update_row(const uchar *old_data, uchar *new_data, uint *dup_key_found)
Bulk update row: public interface.
Definition: handler.cc:4788
virtual double index_only_read_time(uint keynr, double records)
Calculate cost of 'index only' scan for given index and number of records.
Definition: handler.cc:5916
double m_sampling_percentage
Definition: handler.h:4543
virtual FT_INFO * ft_init_ext_with_hints(uint inx, String *key, Ft_hints *hints)
Definition: handler.h:5468
void set_end_range(const key_range *range, enum_range_scan_direction direction)
Set the end position for a range scan.
Definition: handler.cc:7411
int ha_index_next(uchar *buf)
Reads the next row via index.
Definition: handler.cc:3326
virtual int index_read(uchar *buf, const uchar *key, uint key_len, enum ha_rkey_function find_flag)
Definition: handler.h:6659
int ha_discard_or_import_tablespace(bool discard, dd::Table *table_def)
Discard or import tablespace: public interface.
Definition: handler.cc:4893
uint pushed_idx_cond_keyno
Definition: handler.h:4505
virtual void column_bitmaps_signal()
Signal that the table->read_set and table->write_set table maps changed The handler is allowed to set...
Definition: handler.cc:3942
virtual Partition_handler * get_partition_handler()
Definition: handler.h:6921
virtual ha_rows end_read_removal(void)
End read (before write) removal and return the number of rows really written.
Definition: handler.h:5628
HANDLER_BUFFER * multi_range_buffer
Definition: handler.h:4439
uchar * ref
Pointer to current row.
Definition: handler.h:4430
int ha_reset()
Check handler usage and reset state of file to after 'open'.
Definition: handler.cc:7950
virtual int index_next_same(uchar *buf, const uchar *key, uint keylen)
Definition: handler.cc:5109
virtual bool was_semi_consistent_read()
Definition: handler.h:5676
int ha_records(ha_rows *num_rows, uint index)
Wrapper function to call records_from_index() in storage engine.
Definition: handler.h:5297
virtual Cost_estimate index_scan_cost(uint index, double ranges, double rows)
Cost estimate for reading a number of ranges from an index.
Definition: handler.cc:6044
int ha_check(THD *thd, HA_CHECK_OPT *check_opt)
to be actually called to get 'check()' functionality
Definition: handler.cc:4680
virtual int index_next(uchar *)
Definition: handler.h:5423
int ha_read_range_first(const key_range *start_key, const key_range *end_key, bool eq_range, bool sorted)
Definition: handler.cc:7326
virtual void update_create_info(HA_CREATE_INFO *create_info)
Update create info as part of ALTER TABLE.
Definition: handler.h:5745
virtual int rnd_end()
Definition: handler.h:6464
uint key_used_on_scan
Definition: handler.h:4495
virtual ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys, uint *bufsz, uint *flags, Cost_estimate *cost)
Get cost and other information about MRR scan over some sequence of ranges.
Definition: handler.cc:6323
virtual Cost_estimate table_scan_cost()
Cost estimate for doing a complete table scan.
Definition: handler.cc:6030
virtual ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint *bufsz, uint *flags, Cost_estimate *cost)
Get cost and other information about MRR scan over a known list of ranges.
Definition: handler.cc:6164
virtual ulong index_flags(uint idx, uint part, bool all_parts) const =0
virtual int external_lock(THD *thd, int lock_type)
Is not invoked for non-transactional temporary tables.
Definition: handler.h:6547
int ha_extra(enum ha_extra_function operation)
Request storage engine to do an extra operation: enable,disable or run some functionality.
Definition: handler.cc:8464
ulonglong next_insert_id
next_insert_id is the next value which should be inserted into the auto_increment column: in a insert...
Definition: handler.h:4516
virtual bool low_byte_first() const
Definition: handler.h:5800
void ha_set_primary_handler(handler *primary_handler)
Store a pointer to the handler of the primary table that corresponds to the secondary table in this h...
Definition: handler.cc:8776
uint ref_length
Length of ref (1-8 or the clustered key length)
Definition: handler.h:4498
virtual double scan_time()
Definition: handler.h:4967
int ha_analyze(THD *thd, HA_CHECK_OPT *check_opt)
Analyze table: public interface.
Definition: handler.cc:4841
virtual uint max_supported_record_length() const
Definition: handler.h:5788
virtual enum_alter_inplace_result check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_info *ha_alter_info)
Check if a storage engine supports a particular alter table in-place.
Definition: handler.cc:4937
ulonglong Table_flags
Definition: handler.h:4418
virtual void parallel_scan_end(void *scan_ctx)
End of the parallel scan.
Definition: handler.h:4898
bool ha_commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit, const dd::Table *old_table_def, dd::Table *new_table_def)
Public function wrapping the actual handler call.
Definition: handler.cc:4912
PSI_table_share * ha_table_share_psi(const TABLE_SHARE *share) const
Acquire the instrumented table information from a table share.
Definition: handler.cc:2743
int get_lock_type() const
Definition: handler.h:6874
std::function< bool(void *cookie, ulong ncols, ulong row_len, const ulong *col_offsets, const ulong *null_byte_offsets, const ulong *null_bitmasks)> Load_init_cbk
This callback is called by each parallel load thread at the beginning of the parallel load for the ad...
Definition: handler.h:4849
Table_flags ha_table_flags() const
The cached_table_flags is set at ha_open and ha_external_lock.
Definition: handler.h:4760
virtual int extra_opt(enum ha_extra_function operation, ulong cache_size)
Definition: handler.h:5591
void ha_drop_table(const char *name)
Drop table in the engine: public interface.
Definition: handler.cc:5033
bool ha_prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, const dd::Table *old_table_def, dd::Table *new_table_def)
Public functions wrapping the actual handler call.
Definition: handler.cc:4901
void start_psi_batch_mode()
Put the handler in 'batch' mode when collecting table io instrumented events.
Definition: handler.cc:2722
int ha_index_or_rnd_end()
Definition: handler.h:4754
virtual bool is_crashed() const
Check if the table is crashed.
Definition: handler.h:5810
int ha_truncate(dd::Table *table_def)
Truncate table: public interface.
Definition: handler.cc:4815
virtual int close(void)=0
int ha_index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag)
Read [part of] row via [part of] index.
Definition: handler.cc:3227
int ha_sample_next(void *scan_ctx, uchar *buf)
Get the next record for sampling.
Definition: handler.cc:3060
void unbind_psi()
Definition: handler.cc:2697
virtual int assign_to_keycache(THD *, HA_CHECK_OPT *)
Definition: handler.h:5747
virtual bool start_bulk_update()
Definition: handler.h:5357
uchar * dup_ref
Pointer to duplicate row.
Definition: handler.h:4432
bool end_psi_batch_mode_if_started()
If a PSI batch was started, turn if off.
Definition: handler.h:4601
int ha_check_for_upgrade(HA_CHECK_OPT *check_opt)
Definition: handler.cc:4523
handler * ha_get_primary_handler() const
Get a pointer to a handler for the table in the primary storage engine, if this handler is for a tabl...
Definition: handler.h:6951
bool ha_get_se_private_data(dd::Table *dd_table, bool reset)
Submit a dd::Table object representing a core DD table having hardcoded data to be filled in by the D...
Definition: handler.cc:5079
virtual uint32 calculate_key_hash_value(Field **field_array)
Definition: handler.h:5559
uint max_record_length() const
Definition: handler.h:5772
void unlock_shared_ha_data()
Release lock for protecting ha_share.
Definition: handler.cc:8131
virtual int parallel_scan_init(void *&scan_ctx, size_t *num_threads, bool use_reserved_threads)
Initializes a parallel scan.
Definition: handler.h:4822
void mark_trx_read_write()
A helper function to mark a transaction read-write, if it is started.
Definition: handler.cc:4708
virtual uint number_of_pushed_joins() const
Reports number of tables included in pushed join which this handler instance is part of.
Definition: handler.h:5960
virtual int sample_init(void *&scan_ctx, double sampling_percentage, int sampling_seed, enum_sampling_method sampling_method, const bool tablesample)
Initialize sampling.
Definition: handler.cc:3081
PSI_table * m_psi
Instrumented table associated with this handler.
Definition: handler.h:4540
virtual int discard_or_import_tablespace(bool discard, dd::Table *table_def)
Discard or import tablespace.
Definition: handler.h:6805
virtual int exec_bulk_update(uint *dup_key_found)
After this call all outstanding updates must be performed.
Definition: handler.h:5374
int update_auto_increment()
Definition: handler.cc:3739
virtual int indexes_are_disabled(void)
Check if indexes are disabled.
Definition: handler.h:5762
Record_buffer * ha_get_record_buffer() const
Get the record buffer that was set with ha_set_record_buffer().
Definition: handler.h:4709
virtual Table_flags table_flags(void) const =0
THD * ha_thd() const
Definition: handler.cc:2690
batch_mode_t m_psi_batch_mode
Batch mode state.
Definition: handler.h:4560
virtual int index_read_last(uchar *buf, const uchar *key, uint key_len)
Definition: handler.h:6665
virtual int start_stmt(THD *thd, thr_lock_type lock_type)
Start a statement when table is locked.
Definition: handler.h:5707
virtual const TABLE * member_of_pushed_join() const
If this handler instance is part of a pushed join sequence returned TABLE instance being root of the ...
Definition: handler.h:5966
virtual int index_next_pushed(uchar *)
Definition: handler.h:5988
FT_INFO * ft_handler
Definition: handler.h:4499
int ha_index_read_pushed(uchar *buf, const uchar *key, key_part_map keypart_map)
Definition: handler.cc:3552
virtual const handlerton * hton_supporting_engine_pushdown()
Get the handlerton of the storage engine if the SE is capable of pushing down some of the AccessPath ...
Definition: handler.h:5610
virtual bool is_record_buffer_wanted(ha_rows *const max_rows) const
Does this handler want to get a Record_buffer for multi-row reads via the ha_set_record_buffer() func...
Definition: handler.h:6584
Handler_share ** ha_share
Pointer where to store/retrieve the Handler_share pointer.
Definition: handler.h:4619
virtual handler * clone(const char *name, MEM_ROOT *mem_root)
Definition: handler.cc:2653
int ha_optimize(THD *thd, HA_CHECK_OPT *check_opt)
Optimize table: public interface.
Definition: handler.cc:4828
Table_flags cached_table_flags
Definition: handler.h:4423
virtual int analyze(THD *, HA_CHECK_OPT *)
Definition: handler.h:6747
int ha_external_lock(THD *thd, int lock_type)
These functions represent the public interface to users of the handler class, hence they are not virt...
Definition: handler.cc:7907
virtual void notify_table_changed(Alter_inplace_info *ha_alter_info)
Notify the storage engine that the table definition has been updated.
Definition: handler.h:6369
handler(handlerton *ht_arg, TABLE_SHARE *share_arg)
Definition: handler.h:4641
virtual uint max_supported_keys() const
Definition: handler.h:5789
virtual int records(ha_rows *num_rows)
Number of rows in table.
Definition: handler.cc:3099
virtual int rnd_init(bool scan)=0
rnd_init() can be called two times without rnd_end() in between (it only makes sense if scan=1).
uint max_key_length() const
Definition: handler.h:5781
range_seq_t mrr_iter
Definition: handler.h:4437
int handle_records_error(int error, ha_rows *num_rows)
Function will handle the error code from call to records() and records_from_index().
Definition: handler.cc:3173
virtual int rename_table(const char *from, const char *to, const dd::Table *from_table_def, dd::Table *to_table_def)
Default rename_table() and delete_table() rename/delete files with a given name and extensions from h...
Definition: handler.cc:4639
int ha_records(ha_rows *num_rows)
Wrapper function to call records() in storage engine.
Definition: handler.h:5285
void lock_shared_ha_data()
Take a lock for protecting shared handler data.
Definition: handler.cc:8121
PSI_table_locker * m_psi_locker
The current event in a batch.
Definition: handler.h:4572
int ha_open(TABLE *table, const char *name, int mode, int test_if_locked, const dd::Table *table_def)
Definition: handler.cc:2773
virtual void start_bulk_insert(ha_rows)
Definition: handler.h:6565
static bool my_prepare_gcolumn_template(THD *thd, const char *db_name, const char *table_name, my_gcolumn_template_callback_t myc, void *ib_table)
Callback to allow InnoDB to prepare a template for generated column processing.
Definition: handler.cc:8392
virtual bool inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, const dd::Table *old_table_def, dd::Table *new_table_def)
Alter the table structure in-place with operations specified using HA_ALTER_FLAGS and Alter_inplace_i...
Definition: handler.h:6281
uint get_index(void) const
Definition: handler.h:5351
virtual int read_range_first(const key_range *start_key, const key_range *end_key, bool eq_range_arg, bool sorted)
Read first row between two ranges.
Definition: handler.cc:7296
int ha_delete_table(const char *name, const dd::Table *table_def)
Delete table: public interface.
Definition: handler.cc:5020
virtual void get_auto_increment(ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong *first_value, ulonglong *nb_reserved_values)
Reserves an interval of auto_increment values from the handler.
Definition: handler.cc:3964
virtual bool prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, const dd::Table *old_table_def, dd::Table *new_table_def)
Allows the storage engine to update internal structures with concurrent writes blocked.
Definition: handler.h:6244
virtual uint min_record_length(uint options) const
Definition: handler.h:5796
void init()
This is called after create to allow us to set up cached variables.
Definition: handler.h:4692
void set_ha_share_ptr(Handler_share *arg_ha_share)
Set ha_share to be used by all instances of the same table/partition.
Definition: handler.cc:8106
virtual std::string explain_extra() const
Return extra handler specific text for EXPLAIN.
Definition: handler.h:4685
virtual int write_row(uchar *buf)
Write a row.
Definition: handler.h:6486
virtual void try_semi_consistent_read(bool)
Tell the engine whether it should avoid unnecessary lock waits.
Definition: handler.h:5683
enum_range_scan_direction
Definition: handler.h:4454
@ RANGE_SCAN_ASC
Definition: handler.h:4454
@ RANGE_SCAN_DESC
Definition: handler.h:4454
void end_psi_batch_mode()
End a batch started with start_psi_batch_mode.
Definition: handler.cc:2731
void set_next_insert_id(ulonglong id)
Definition: handler.h:5715
virtual int ft_init()
Definition: handler.h:5466
int compare_key_icp(const key_range *range) const
Definition: handler.cc:7489
TABLE * table
Definition: handler.h:4422
void ha_notify_table_changed(Alter_inplace_info *ha_alter_info)
Public function wrapping the actual handler call.
Definition: handler.h:6202
int ha_index_prev(uchar *buf)
Reads the previous row via index.
Definition: handler.cc:3370
int ha_rnd_pos(uchar *buf, uchar *pos)
Read row via random scan from position.
Definition: handler.cc:2990
int ha_index_first(uchar *buf)
Reads the first row via index.
Definition: handler.cc:3406
bool ha_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, const dd::Table *old_table_def, dd::Table *new_table_def)
Public function wrapping the actual handler call.
Definition: handler.h:6178
Record_buffer * m_record_buffer
Buffer for multi-row reads.
Definition: handler.h:4457
void ha_release_auto_increment()
Definition: handler.cc:4028
virtual int truncate(dd::Table *table_def)
Quickly remove all rows from a table.
Definition: handler.h:6741
virtual int index_end()
Definition: handler.h:6452
virtual table_map tables_in_pushed_join() const
Definition: handler.h:5976
virtual int delete_all_rows()
Delete all rows in a table.
Definition: handler.h:6706
virtual int rnd_pos_by_record(uchar *record)
This function only works for handlers having HA_PRIMARY_KEY_REQUIRED_FOR_POSITION set.
Definition: handler.h:5489
int ha_load_table(const TABLE &table)
Loads a table into its defined secondary storage engine: public interface.
Definition: handler.cc:5062
virtual void drop_table(const char *name)
Definition: handler.cc:4660
virtual int unload_table(const char *db_name, const char *table_name, bool error_if_not_loaded)
Unloads a table from its defined secondary storage engine.
Definition: handler.h:6649
void ha_mv_key_capacity(uint *num_keys, size_t *keys_length) const
Return max limits for a single set of multi-valued keys.
Definition: handler.h:6959
virtual int optimize(THD *, HA_CHECK_OPT *)
Definition: handler.h:6744
int ha_index_read_idx_map(uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag)
Initializes an index and read it.
Definition: handler.cc:3287
virtual int bulk_update_row(const uchar *old_data, uchar *new_data, uint *dup_key_found)
This method is similar to update_row, however the handler doesn't need to execute the updates at this...
Definition: handler.h:6689
virtual bool check_and_repair(THD *thd)
Check and repair the table if necessary.
Definition: handler.h:6762
virtual bool auto_repair() const
Check if the table can be automatically repaired.
Definition: handler.h:5819
virtual int end_bulk_insert()
Definition: handler.h:6566
virtual int index_read_idx_map(uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag)
Positions an index cursor to the index specified in argument.
Definition: handler.cc:7548
virtual bool start_bulk_delete()
Definition: handler.h:5362
uint auto_inc_intervals_count
Number of reserved auto-increment intervals.
Definition: handler.h:4535
void ha_set_record_buffer(Record_buffer *buffer)
Set a record buffer that the storage engine can use for multi-row reads.
Definition: handler.h:4702
virtual ha_checksum checksum() const
Definition: handler.h:5801
virtual void mv_key_capacity(uint *num_keys, size_t *keys_length) const
Engine-specific function for ha_can_store_mv_keys().
Definition: handler.h:6982
static bool my_eval_gcolumn_expr_with_open(THD *thd, const char *db_name, const char *table_name, const MY_BITMAP *const fields, uchar *record, const char **mv_data_ptr, ulong *mv_length)
Callback for generated columns processing.
Definition: handler.cc:8430
virtual bool get_se_private_data(dd::Table *dd_table, bool reset)
Definition: handler.h:6836
int ha_repair(THD *thd, HA_CHECK_OPT *check_opt)
Repair table: public interface.
Definition: handler.cc:4737
int ha_rnd_next(uchar *buf)
Read next row via random scan.
Definition: handler.cc:2959
virtual void position(const uchar *record)=0
void adjust_next_insert_id_after_explicit_value(ulonglong nr)
Definition: handler.cc:3614
void(* my_gcolumn_template_callback_t)(const TABLE *, void *)
Callback function that will be called by my_prepare_gcolumn_template once the table has been opened.
Definition: handler.h:6880
int ha_rnd_end()
End use of random access.
Definition: handler.cc:2937
uint get_dup_key(int error)
Definition: handler.cc:4596
virtual bool upgrade_table(THD *thd, const char *dbname, const char *table_name, dd::Table *dd_table)
Definition: handler.h:6590
int ha_write_row(uchar *buf)
Definition: handler.cc:7978
virtual int delete_table(const char *name, const dd::Table *table_def)
Delete a table.
Definition: handler.cc:4611
virtual int get_extra_columns_and_keys(const HA_CREATE_INFO *create_info, const List< Create_field > *create_list, const KEY *key_info, uint key_count, dd::Table *table_obj)
Adjust definition of table to be created by adding implicit columns and indexes necessary for the sto...
Definition: handler.h:6859
virtual void use_hidden_primary_key()
use_hidden_primary_key() is called in case of an update/delete when (table_flags() and HA_PRIMARY_KEY...
Definition: handler.cc:8069
int ha_ft_read(uchar *buf)
Definition: handler.cc:3017
key_range save_end_range
Definition: handler.h:4462
PSI_table_locker_state m_psi_locker_state
Storage for the event in a batch.
Definition: handler.h:4578
ha_rows estimation_rows_to_insert
Definition: handler.h:4425
virtual int rnd_pos(uchar *buf, uchar *pos)=0
bool mrr_is_output_sorted
Definition: handler.h:4442
virtual int index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map)
The following functions works like index_read, but it find the last row with the current key value or...
Definition: handler.h:5441
int ha_close(void)
Close handler.
Definition: handler.cc:2843
uint max_key_part_length(HA_CREATE_INFO *create_info) const
Definition: handler.h:5784
virtual bool set_ha_share_ref(Handler_share **arg_ha_share)
Definition: handler.h:6867
virtual void release_auto_increment()
Definition: handler.h:6551
const TABLE_SHARE * get_table_share() const
Definition: handler.h:4958
virtual int read_range_next()
Read next row between two endpoints.
Definition: handler.cc:7373
int ha_read_first_row(uchar *buf, uint primary_key)
Read first row (only) from a table.
Definition: handler.cc:3522
virtual ha_rows estimate_rows_upper_bound()
Return upper bound of current number of records in the table (max.
Definition: handler.h:5307
bool has_transactions()
Definition: handler.h:5198
virtual int delete_row(const uchar *buf)
Definition: handler.h:6503
Item * pushed_idx_cond
Definition: handler.h:4504
int compare_key_in_buffer(const uchar *buf) const
Check if the key in the given buffer (which is not necessarily TABLE::record[0]) is within range.
Definition: handler.cc:7524
virtual int parallel_scan(void *scan_ctx, void **thread_ctxs, Load_init_cbk init_fn, Load_cbk load_fn, Load_end_cbk end_fn)
Run the parallel read of data.
Definition: handler.h:4886
virtual int check_for_upgrade(HA_CHECK_OPT *)
admin commands - called from mysql_admin_table
Definition: handler.h:6553
enum handler::@50 inited
int ha_disable_indexes(uint mode)
Disable indexes: public interface.
Definition: handler.cc:4867
double estimate_in_memory_buffer(ulonglong table_index_size) const
Make a guesstimate for how much of a table or index is in a memory buffer in the case where the stora...
Definition: handler.cc:5973
virtual int index_last(uchar *)
Definition: handler.h:5432
virtual double page_read_cost(uint index, double reads)
Cost estimate for doing a number of non-sequentially accesses against the storage engine.
Definition: handler.cc:6083
virtual Item * idx_cond_push(uint keyno, Item *idx_cond)
Push down an index condition to the handler.
Definition: handler.h:5945
int key_compare_result_on_equal
Definition: handler.h:4464
int compare_key(key_range *range)
Compare if found key (in row) is over max-value.
Definition: handler.cc:7454
KEY_MULTI_RANGE mrr_cur_range
Definition: handler.h:4447
bool mrr_have_range
Definition: handler.h:4445
virtual int cmp_ref(const uchar *ref1, const uchar *ref2) const
Compare two positions.
Definition: handler.h:5891
bool ha_is_record_buffer_wanted(ha_rows *const max_rows) const
Does this handler want to get a Record_buffer for multi-row reads via the ha_set_record_buffer() func...
Definition: handler.h:4726
ulonglong m_psi_numrows
The number of rows in the batch.
Definition: handler.h:4566
virtual bool commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit, const dd::Table *old_table_def, dd::Table *new_table_def)
Commit or rollback the changes made during prepare_inplace_alter_table() and inplace_alter_table() in...
Definition: handler.h:6339
virtual int end_bulk_delete()
Execute all outstanding deletes and close down the bulk delete.
Definition: handler.h:5389
virtual int create(const char *name, TABLE *form, HA_CREATE_INFO *info, dd::Table *table_def)=0
Create table (implementation).
virtual double worst_seek_times(double reads)
Provide an upper cost-limit of doing a specified number of seek-and-read key lookups.
Definition: handler.cc:6097
int ha_rename_table(const char *from, const char *to, const dd::Table *from_table_def, dd::Table *to_table_def)
Rename table: public interface.
Definition: handler.cc:5005
virtual enum row_type get_real_row_type(const HA_CREATE_INFO *create_info) const
Get real row type for the table created based on one specified by user, CREATE TABLE options and SE c...
Definition: handler.h:5315
virtual int index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag)
Positions an index cursor to the index specified in the handle ('active_index').
Definition: handler.h:5402
std::function< bool(void *cookie, uint nrows, void *rowdata, uint64_t partition_id)> Load_cbk
This callback is called by each parallel load thread when processing of rows is required for the adap...
Definition: handler.h:4864
int ha_index_end()
End use of index.
Definition: handler.cc:2894
virtual THR_LOCK_DATA ** store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type)=0
Is not invoked for non-transactional temporary tables.
int ha_unload_table(const char *db_name, const char *table_name, bool error_if_not_loaded)
Unloads a table from its defined secondary storage engine: public interface.
Definition: handler.cc:5069
int ha_rnd_init(bool scan)
Initialize table for random read or scan.
Definition: handler.cc:2918
virtual bool get_error_message(int error, String *buf)
Return an error message specific to this handler.
Definition: handler.cc:4477
bool implicit_emptied
Definition: handler.h:4501
virtual void print_error(int error, myf errflag)
Print error that we got from handler function.
Definition: handler.cc:4175
static bool my_eval_gcolumn_expr(THD *thd, TABLE *table, const MY_BITMAP *const fields, uchar *record, const char **mv_data_ptr, ulong *mv_length)
Callback for computing generated column values.
Definition: handler.cc:8448
In-place alter handler context.
Definition: handler.h:3179
virtual void set_shared_data(const inplace_alter_handler_ctx *ctx)
Definition: handler.h:3183
virtual ~inplace_alter_handler_ctx()=default
inplace_alter_handler_ctx()=default
Definition: partition_info.h:209
Legacy struct for passing tablespace information to SEs.
Definition: handler.h:861
ts_command_type ts_cmd_type
Definition: handler.h:865
bool wait_until_completed
Definition: handler.h:878
ulonglong undo_buffer_size
Definition: handler.h:871
ulonglong extent_size
Definition: handler.h:870
st_alter_tablespace(const char *tablespace, const char *logfile_group, ts_command_type cmd, enum ts_alter_tablespace_type alter_tablespace_cmd, const char *datafile, const char *undofile, const Tablespace_options &opts)
Proper constructor even for all-public class simplifies initialization and allows members to be const...
Definition: sql_tablespace.cc:93
const char * logfile_group_name
Definition: handler.h:864
ulonglong file_block_size
Definition: handler.h:876
const char * encryption
Definition: handler.h:880
const char * undo_file_name
Definition: handler.h:869
const char * tablespace_name
Definition: handler.h:863
const char * ts_comment
Definition: handler.h:879
std::optional< ulonglong > autoextend_size
Definition: handler.h:874
ulonglong redo_buffer_size
Definition: handler.h:872
ulonglong max_size
Definition: handler.h:875
ulonglong initial_size
Definition: handler.h:873
const char * data_file_name
Definition: handler.h:868
uint nodegroup_id
Definition: handler.h:877
bool is_tablespace_command()
Definition: handler.h:882
A table definition from the master.
Definition: rpl_utility.h:248
static MEM_ROOT mem_root
Definition: client_plugin.cc:110
static bool report_error(THD *thd, int error_code, Sql_condition::enum_severity_level level, Args... args)
Definition: error_handler.cc:291
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
Some definitions for full-text indices.
ft_operation
Operation types, used in FT_HINTS.
Definition: ft_global.h:99
@ FT_OP_UNDEFINED
Definition: ft_global.h:100
struct PSI_table_locker PSI_table_locker
Definition: psi_table_bits.h:43
struct PSI_table_share PSI_table_share
Definition: psi_table_bits.h:100
struct PSI_table PSI_table
Definition: psi_table_bits.h:107
static int flags[50]
Definition: hp_test1.cc:40
static int flag
Definition: hp_test1.cc:40
static uint keys
Definition: hp_test2.cc:46
#define IN_MEMORY_ESTIMATE_UNKNOWN
If the "in memory estimate" for a table (in ha_statistics.table_in_mem_estimate) or index (in KEY::m_...
Definition: key.h:111
constexpr const LEX_CSTRING NULL_CSTR
Definition: lex_string.h:47
A better implementation of the UNIX ctype(3) library.
#define STRING_WITH_LEN(X)
Definition: m_string.h:315
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
This file includes constants used by all storage engines.
#define HA_OPTION_PACK_RECORD
Indicates that storage engine needs to use packed row format.
Definition: my_base.h:602
#define rows2double(A)
Definition: my_base.h:1139
ha_panic_function
Definition: my_base.h:431
ha_key_alg
Definition: my_base.h:97
@ HA_KEY_ALG_SE_SPECIFIC
Used for cases when key algorithm which is supported by SE can't be described by one of other classes...
Definition: my_base.h:106
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
#define HA_POS_ERROR
Definition: my_base.h:1142
#define HA_ERR_WRONG_COMMAND
Command not supported.
Definition: my_base.h:840
#define HA_OPTION_COMPRESS_RECORD
Flag indicating that table is compressed.
Definition: my_base.h:628
ha_storage_media
Definition: my_base.h:115
@ HA_SM_DEFAULT
Definition: my_base.h:116
Abstraction functions over zlib/intrinsics.
std::uint32_t ha_checksum
Definition: my_checksum.h:106
Header for compiler-dependent features.
#define DBUG_PRINT(keyword, arglist)
Definition: my_dbug.h:181
Utility functions for converting between ulonglong and double.
#define ulonglong2double(A)
Definition: my_double2ulonglong.h:46
Some integer typedefs for easier portability.
int myf
Definition: my_inttypes.h:94
unsigned long long int ulonglong
Definition: my_inttypes.h:56
ulonglong my_off_t
Definition: my_inttypes.h:72
unsigned char uchar
Definition: my_inttypes.h:52
long long int longlong
Definition: my_inttypes.h:55
uint64_t uint64
Definition: my_inttypes.h:69
uint32_t uint32
Definition: my_inttypes.h:67
Common #defines and includes for file and socket I/O.
constexpr const size_t IO_SIZE
Definition: my_io.h:159
Common header for many mysys elements.
uint64_t table_map
Definition: my_table_map.h:30
void set_my_errno(int my_errno)
Set the MySQL thread-local storage variant of errno.
Definition: my_thr_init.cc:345
static char * query
Definition: myisam_ftdump.cc:45
static HashTable ht
Definition: mysql.cc:148
Log error(cerr, "ERROR")
Log info(cout, "NOTE")
static bool interrupted
Definition: mysqladmin.cc:66
static char * path
Definition: mysqldump.cc:137
struct stats stats
Definition: mysqlslap.cc:236
static Secondary_engine * secondary_engine
Definition: mysqltest.cc:249
static int record
Definition: mysqltest.cc:188
bool is_temp_table(const HA_CREATE_INFO &ci)
Definition: sql_table.cc:212
Definition: buf0block_hint.cc:30
constexpr value_type primary_key
Definition: classic_protocol_constants.h:269
std::string dir
Double write files location.
Definition: buf0dblwr.cc:77
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
unsigned long long Object_id
Definition: object_id.h:31
enum_column_types
Definition: column.h:53
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
Definition: os0file.h:86
Definition: hypergraph.cc:30
void print(trx_t *trx, dict_index_t *index, std::ostream &out, ref_t ref, bool fatal)
Print information about the given LOB.
Definition: lob0impl.cc:1331
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:94
static int destroy(mysql_cond_t *that, const char *, unsigned int)
Definition: mysql_cond_v1_native.cc:54
std::string join(Container cont, const std::string &delim)
join elements of an container into a string separated by a delimiter.
Definition: string.h:151
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:420
size_t buffer_size(const ConstBufferSequence &buffers) noexcept
Definition: buffer.h:315
Definition: options.cc:49
const char * table_name
Definition: rules_table_service.cc:56
const char * db_name
Definition: rules_table_service.cc:55
mode
Definition: file_handle.h:60
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2874
static int exists(node_address *name, node_list const *nodes, u_int with_uid)
Definition: node_list.cc:106
int(* Page_Track_Callback)(MYSQL_THD thd, const unsigned char *buffer, size_t buf_len, int num_pages, void *user_ctx)
Page tracking callback function.
Definition: page_track_service.h:66
struct result result
Definition: result.h:34
Performance schema instrumentation interface.
required string key
Definition: replication_asynchronous_connection_failover.proto:60
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:61
required uint64 version
Definition: replication_group_member_actions.proto:41
required string type
Definition: replication_group_member_actions.proto:34
ulonglong prev_insert_id(ulonglong nr, struct System_variables *variables)
Computes the largest number X:
Definition: handler.cc:3639
void trans_register_ha(THD *thd, bool all, handlerton *ht, const ulonglong *trxid)
Register a storage engine for a transaction.
Definition: handler.cc:1290
bool(* sdi_get_t)(const dd::Tablespace &tablespace, const sdi_key_t *sdi_key, void *sdi, uint64 *sdi_len)
Retrieve SDI for a given SDI key.
Definition: handler.h:1762
int ha_finalize_handlerton(st_plugin_int *plugin)
Definition: handler.cc:723
bool(* ddse_dict_init_t)(dict_init_mode_t dict_init_mode, uint version, List< const dd::Object_table > *DDSE_tables, List< const Plugin_tablespace > *DDSE_tablespaces)
Definition: handler.h:1898
handlerton * ha_checktype(THD *thd, enum legacy_db_type database_type, bool no_substitute, bool report_error)
Use other database handler if databasehandler is not compiled in.
Definition: handler.cc:565
bool(* qc_engine_callback)(THD *thd, const char *table_key, uint key_length, ulonglong *engine_data)
Definition: handler.h:139
int(* savepoint_set_t)(handlerton *hton, THD *thd, void *sv)
sv points to an uninitialized storage area of requested size (see savepoint_offset description)
Definition: handler.h:1363
bool(* show_status_t)(handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat)
Definition: handler.h:1494
#define UNDEF_NODEGROUP
Definition: handler.h:828
static const uint32 HTON_FKS_WITH_ANY_PREFIX_SUPPORTING_KEYS
Storage engine supports non-hash keys which have common prefix with the foreign key as supporting key...
Definition: handler.h:2995
int(*)(uint64_t *purge_id) page_track_purge_t
Purge page tracking data.
Definition: handler.h:2546
bool(* sdi_set_t)(handlerton *hton, const dd::Tablespace &tablespace, const dd::Table *table, const sdi_key_t *sdi_key, const void *sdi, uint64 sdi_len)
Insert/Update SDI for a given SDI key.
Definition: handler.h:1777
int ha_rollback_low(THD *thd, bool all)
Definition: handler.cc:1979
bool ha_notify_exclusive_mdl(THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type, bool *victimized)
Notify/get permission from all interested storage engines before acquisition or after release of excl...
Definition: handler.cc:8596
size_t num_hton2plugins()
Returns the size of the array holding pointers to plugins.
Definition: handler.cc:240
int ha_find_files(THD *thd, const char *db, const char *path, const char *wild, bool dir, List< LEX_STRING > *files)
Definition: handler.cc:5712
bool(* dict_recover_t)(dict_recovery_mode_t dict_recovery_mode, uint version)
Do recovery in the DDSE as part of initializing the data dictionary.
Definition: handler.h:1951
int(*)(handlerton *hton, THD *thd, const uchar *&loc, uint &loc_len, uint &task_id, Ha_clone_mode mode, const char *data_dir) Clone_apply_begin_t
Begin apply to destination database.
Definition: handler.h:2227
constexpr const uint32 SDI_TYPE_TABLE
Id for identifying Table SDIs.
Definition: handler.h:120
void ha_kill_connection(THD *thd)
Definition: handler.cc:964
enum_ha_recover_xa_state
Enumeration of possible states for externally coordinated transactions (XA).
Definition: handler.h:1232
#define COMPATIBLE_DATA_NO
Definition: handler.h:822
std::unordered_set< my_xid, std::hash< my_xid >, std::equal_to< my_xid >, Mem_root_allocator< my_xid > > Xid_commit_list
Single occurrence set of XIDs of internally coordinated transactions found as been committed in the t...
Definition: handler.h:1246
bool(* lock_hton_log_t)(handlerton *hton)
Lock a handlerton (resource) log to collect log information.
Definition: handler.h:2296
Ha_clone_mode
Clone start operation mode.
Definition: handler.h:942
@ HA_CLONE_MODE_ADD_TASK
Add a new task to a running clone operation.
Definition: handler.h:950
@ HA_CLONE_MODE_START
Start a new clone operation.
Definition: handler.h:944
@ HA_CLONE_MODE_MAX
Max value for clone mode.
Definition: handler.h:956
@ HA_CLONE_MODE_VERSION
Get version for transfer data format.
Definition: handler.h:953
@ HA_CLONE_MODE_RESTART
Re-start a clone operation after failure.
Definition: handler.h:947
int(*)(uint64_t *start_id) page_track_start_t
Start page tracking.
Definition: handler.h:2521
static const size_t MAX_FK_NAME_SUFFIX_LENGTH
Maximum possible length of SE-specific suffixes for auto-generated foreign key names.
Definition: handler.h:3019
ha_stat_type
Definition: handler.h:932
@ HA_ENGINE_LOGS
Definition: handler.h:932
@ HA_ENGINE_MUTEX
Definition: handler.h:932
@ HA_ENGINE_STATUS
Definition: handler.h:932
st_plugin_int * remove_hton2plugin(uint slot)
Definition: handler.cc:248
int check_table_for_old_types(const TABLE *table, bool check_temporal_upgrade)
Function identifies any old data type present in table.
Definition: handler.cc:4553
static const uint MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT
Options for the START TRANSACTION statement.
Definition: handler.h:632
int ha_create_table(THD *thd, const char *path, const char *db, const char *table_name, HA_CREATE_INFO *create_info, bool update_create_info, bool is_temp_table, dd::Table *table_def)
Initiates table-file and calls appropriate database-creator.
Definition: handler.cc:5180
std::pair< int, bool > commit_owned_gtids(THD *thd, bool all)
The function computes condition to call gtid persistor wrapper, and executes it.
Definition: handler.cc:1536
int ha_resize_key_cache(KEY_CACHE *key_cache)
Resize key cache.
Definition: handler.cc:5601
std::bitset< HA_CLONE_TYPE_MAX > Ha_clone_flagset
Definition: handler.h:984
bool(*)(THD *thd, LEX *lex) optimize_secondary_engine_t
Optimize a statement for execution on a secondary storage engine.
Definition: handler.h:2355
bool(* notify_alter_table_t)(THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type)
Notify/get permission from storage engine before or after execution of ALTER TABLE operation on the t...
Definition: handler.h:2036
bool(* savepoint_rollback_can_release_mdl_t)(handlerton *hton, THD *thd)
Check if storage engine allows to release metadata locks which were acquired after the savepoint if r...
Definition: handler.h:1371
void(* dict_register_dd_table_id_t)(dd::Object_id hard_coded_tables)
Initialize the set of hard coded DD table ids.
Definition: handler.h:1906
ts_command_type
Definition: handler.h:831
@ CREATE_LOGFILE_GROUP
Definition: handler.h:835
@ DROP_UNDO_TABLESPACE
Definition: handler.h:843
@ TS_CMD_NOT_DEFINED
Definition: handler.h:832
@ ALTER_TABLESPACE
Definition: handler.h:834
@ DROP_LOGFILE_GROUP
Definition: handler.h:838
@ ALTER_ACCESS_MODE_TABLESPACE
Definition: handler.h:840
@ ALTER_UNDO_TABLESPACE
Definition: handler.h:842
@ CHANGE_FILE_TABLESPACE
Definition: handler.h:839
@ DROP_TABLESPACE
Definition: handler.h:837
@ CREATE_UNDO_TABLESPACE
Definition: handler.h:841
@ CREATE_TABLESPACE
Definition: handler.h:833
@ ALTER_LOGFILE_GROUP
Definition: handler.h:836
bool(* is_dict_readonly_t)()
Check if the DDSE is started in a way that leaves thd DD being read only.
Definition: handler.h:1799
int(* recover_t)(handlerton *hton, XA_recover_txn *xid_list, uint len, MEM_ROOT *mem_root)
Definition: handler.h:1389
const char *(*)(THD *thd) get_secondary_engine_offload_or_exec_fail_reason_t
Looks up and returns a specific secondary engine query offload or exec failure reason as a string giv...
Definition: handler.h:2444
bool(* get_table_statistics_t)(const char *db_name, const char *table_name, dd::Object_id se_private_id, const dd::Properties &ts_se_private_data, const dd::Properties &tbl_se_private_data, uint flags, ha_statistics *stats)
Retrieve ha_statistics from SE.
Definition: handler.h:2112
#define HA_MAX_REC_LENGTH
Definition: handler.h:617
#define HTON_SUPPORTS_ATOMIC_DDL
Engine supports atomic DDL.
Definition: handler.h:2913
int ha_change_key_cache(KEY_CACHE *old_key_cache, KEY_CACHE *new_key_cache)
Move all tables from one key cache to another one.
Definition: handler.cc:5622
int(* savepoint_release_t)(handlerton *hton, THD *thd, void *sv)
Definition: handler.h:1374
plugin_ref ha_lock_engine(THD *thd, const handlerton *hton)
Definition: handler.cc:516
int(*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, int in_err) Clone_apply_end_t
End apply to destination database.
Definition: handler.h:2251
int(* find_files_t)(handlerton *hton, THD *thd, const char *db, const char *path, const char *wild, bool dir, List< LEX_STRING > *files)
Definition: handler.h:1664
int(*)(THD *thd, AccessPath *query, JOIN *) push_to_engine_t
Let storage engine inspect the query Accesspath and pick whatever it like for being pushed down to th...
Definition: handler.h:1688
bool(* redo_log_set_state_t)(THD *thd, bool enable)
Enable or Disable SE write ahead logging.
Definition: handler.h:2091
void ha_post_recover()
Perform SE-specific cleanup after recovery of transactions.
Definition: handler.cc:8771
void(* acl_notify_t)(THD *thd, const class Acl_change_notification *notice)
Definition: handler.h:1658
int(*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, int in_err, Ha_clone_cbk *cbk) Clone_apply_t
Apply data to destination database in chunks via callback.
Definition: handler.h:2240
TYPELIB tx_isolation_typelib
Definition: handler.cc:293
handlerton * ha_default_temp_handlerton(THD *thd)
Return the default storage engine handlerton used for explicitly created temp tables for a thread.
Definition: handler.cc:370
bool(* collect_hton_log_info_t)(handlerton *hton, Json_dom *json)
Collect a handlerton (resource) log information.
Definition: handler.h:2308
int(*)(handlerton *hton, THD *thd) set_prepared_in_tc_t
Instructs the storage engine to mark the externally coordinated transactions held by the THD paramete...
Definition: handler.h:1402
void ha_reset_slave(THD *thd)
Definition: handler.cc:5819
void ha_end()
Definition: handler.cc:914
static enum legacy_db_type ha_legacy_type(const handlerton *db_type)
Definition: handler.h:7176
int(*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, int in_err) Clone_end_t
End copy from source database.
Definition: handler.h:2213
int ha_release_savepoint(THD *thd, SAVEPOINT *sv)
Definition: handler.cc:2371
static const uint MYSQL_START_TRANS_OPT_READ_WRITE
Definition: handler.h:636
int(*)(uint64_t *stop_id) page_track_stop_t
Stop page tracking.
Definition: handler.h:2533
bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat)
Definition: handler.cc:7651
bool(* unlock_hton_log_t)(handlerton *hton)
Unlock a handlerton (resource) log after collecting log information.
Definition: handler.h:2302
constexpr const uint64_t HA_CREATE_USED_ENGINE_ATTRIBUTE
Definition: handler.h:789
void(* se_before_rollback_t)(void *arg)
Definition: handler.h:2504
int(*)(Page_Track_Callback cbk_func, void *cbk_ctx, uint64_t *start_id, uint64_t *stop_id, unsigned char *buffer, size_t buffer_len) page_track_get_page_ids_t
Fetch tracked pages.
Definition: handler.h:2572
plugin_ref ha_resolve_by_name_raw(THD *thd, const LEX_CSTRING &name)
Resolve handlerton plugin by name, without checking for "DEFAULT" or HTON_NOT_USER_SELECTABLE.
Definition: handler.cc:387
void ha_binlog_index_purge_wait(THD *thd)
Request the storage engine to complete any operations that were initiated by ha_binlog_index_purge_fi...
Definition: handler.cc:5835
#define HA_ADMIN_NOT_IMPLEMENTED
Definition: handler.h:175
bool(* is_supported_system_table_t)(const char *db, const char *table_name, bool is_sql_layer_system_table)
Check if the given db.tablename is a system table for this SE.
Definition: handler.h:1705
bool ha_rm_tmp_tables(THD *thd, List< LEX_STRING > *files)
Ask all SEs to drop all temporary tables which have been left from previous server run.
Definition: handler.cc:5525
bool(*)(THD *thd, LEX *lex) prepare_secondary_engine_t
Prepare the secondary engine for executing a statement.
Definition: handler.h:2341
#define HA_CAN_REPAIR
Definition: handler.h:369
bool ha_check_if_supported_system_table(handlerton *hton, const char *db, const char *table_name)
Check if a given table is a system table.
Definition: handler.cc:5405
int ha_commit_attachable(THD *thd)
Commit the attachable transaction in storage engines.
Definition: handler.cc:2140
bool ha_secondary_engine_supports_ddl(THD *thd, const LEX_CSTRING &secondary_engine) noexcept
Definition: handler.cc:437
xa_status_code(*)(handlerton *hton, XID *xid) set_prepared_in_tc_by_xid_t
Instructs the storage engine to mark the externally coordinated transactions identified by the XID pa...
Definition: handler.h:1462
int(* close_connection_t)(handlerton *hton, THD *thd)
close_connection is only called if thd->ha_data[xxx_hton.slot] is non-zero, so even if you don't need...
Definition: handler.h:1342
const char * tx_isolation_names[]
Definition: handler.cc:291
TYPELIB * ha_known_exts()
Definition: handler.cc:7606
bool(* sdi_create_t)(dd::Tablespace *tablespace)
Create SDI in a tablespace.
Definition: handler.h:1716
bool(* dict_init_t)(dict_init_mode_t dict_init_mode, uint version, List< const Plugin_table > *DDSE_tables, List< const Plugin_tablespace > *DDSE_tablespaces)
Initialize the SE for being used to store the DD tables.
Definition: handler.h:1894
int(* panic_t)(handlerton *hton, enum ha_panic_function flag)
Definition: handler.h:1479
constexpr const uint64_t HA_CREATE_USED_SECONDARY_ENGINE_ATTRIBUTE
Definition: handler.h:790
void ha_drop_database(char *path)
Definition: handler.cc:927
int(* get_tablespace_t)(THD *thd, LEX_CSTRING db_name, LEX_CSTRING table_name, LEX_CSTRING *tablespace_name)
Get the tablespace name from the SE for the given schema and table.
Definition: handler.h:1533
static bool ha_check_storage_engine_flag(const handlerton *db_type, uint32 flag)
Definition: handler.h:7182
int ha_prepare_low(THD *thd, bool all)
Prepares the underlying transaction of the THD session object parameter in the storage engines that p...
Definition: handler.cc:2286
ha_ddl_type
Definition: handler.h:934
@ HA_TRUNCATE_DDL
Definition: handler.h:937
@ HA_INVALID_DDL
Definition: handler.h:935
@ HA_ALTER_DDL
Definition: handler.h:936
@ HA_RENAME_DDL
Definition: handler.h:938
int ha_init_key_cache(std::string_view name, KEY_CACHE *key_cache)
Init a key cache if it has not been initied before.
Definition: handler.cc:5582
uint64_t SecondaryEngineFlags
Definition: handler.h:2459
int(* finish_upgrade_t)(THD *thd, bool failed_upgrade)
Finish upgrade process inside storage engines.
Definition: handler.h:1600
void(*)(std::vector< std::pair< uint64_t, bool > > &status) page_track_get_status_t
Fetch the status of the page tracking system.
Definition: handler.h:2599
bool(* rm_tmp_tables_t)(handlerton *hton, THD *thd, List< LEX_STRING > *files)
Drop all temporary tables which have been left from previous server run belonging to this SE.
Definition: handler.h:1814
static const uint32 HTON_FKS_WITH_SUPPORTING_HASH_KEYS
Storage engine supports hash keys as supporting keys for foreign keys.
Definition: handler.h:2982
static const uint MYSQL_START_TRANS_OPT_HIGH_PRIORITY
Definition: handler.h:638
int ha_binlog_index_purge_file(THD *thd, const char *file)
Inform storage engine(s) that a binary log file will be purged and any references to it should be rem...
Definition: handler.cc:5829
#define HTON_SECONDARY_ENGINE_SUPPORTS_DDL
Whether the secondary engine supports DDLs.
Definition: handler.h:2936
bool(* get_index_column_cardinality_t)(const char *db_name, const char *table_name, const char *index_name, uint index_ordinal_position, uint column_ordinal_position, dd::Object_id se_private_id, ulonglong *cardinality)
Retrieve index column cardinality from SE.
Definition: handler.h:2137
bool default_rm_tmp_tables(handlerton *hton, THD *thd, List< LEX_STRING > *files)
Default implementation for handlerton::rm_tmp_tables() method which simply removes all files from "fi...
Definition: handler.cc:5537
enum_alter_inplace_result
Return values for check_if_supported_inplace_alter().
Definition: handler.h:197
@ HA_ALTER_INPLACE_NOT_SUPPORTED
Definition: handler.h:199
@ HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE
Definition: handler.h:203
@ HA_ALTER_INPLACE_INSTANT
Definition: handler.h:205
@ HA_ALTER_INPLACE_SHARED_LOCK
Definition: handler.h:202
@ HA_ALTER_INPLACE_NO_LOCK
Definition: handler.h:204
@ HA_ALTER_INPLACE_EXCLUSIVE_LOCK
Definition: handler.h:200
@ HA_ALTER_ERROR
Definition: handler.h:198
@ HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE
Definition: handler.h:201
constexpr const decltype(handlerton::flags) HTON_SUPPORTS_ENGINE_ATTRIBUTE
Definition: handler.h:2927
bool Log_func(THD *, TABLE *, bool, const uchar *, const uchar *)
Definition: handler.h:7238
void(*)(THD *thd, const char *) set_secondary_engine_offload_fail_reason_t
Sets a specific secondary engine offload failure reason for a query represented by the thread context...
Definition: handler.h:2456
static const uint MYSQL_START_TRANS_OPT_READ_ONLY
Definition: handler.h:634
void(* kill_connection_t)(handlerton *hton, THD *thd)
Terminate connection/statement notification.
Definition: handler.h:1345
uint calculate_key_len(TABLE *table, uint key, key_part_map keypart_map)
Calculates length of key.
Definition: handler.cc:7560
int(* prepare_t)(handlerton *hton, THD *thd, bool all)
Definition: handler.h:1387
bool(* sdi_drop_t)(dd::Tablespace *tablespace)
Drop SDI in a tablespace.
Definition: handler.h:1725
void print_keydup_error(TABLE *table, KEY *key, const char *msg, myf errflag, const char *org_table_name)
Construct and emit duplicate key error message using information from table's record buffer.
Definition: handler.cc:4063
int ha_init(void)
Definition: handler.cc:899
int(* alter_tablespace_t)(handlerton *hton, THD *thd, st_alter_tablespace *ts_info, const dd::Tablespace *old_ts_def, dd::Tablespace *new_ts_def)
Create/drop or alter tablespace in the storage engine.
Definition: handler.h:1555
int ha_enable_transaction(THD *thd, bool on)
Tell the storage engine that it is allowed to "disable transaction" in the handler.
Definition: handler.cc:5091
bool secondary_engine_supports_ddl(const handlerton *hton)
Definition: handler.h:2949
Ha_clone_type
Clone operation types.
Definition: handler.h:960
@ HA_CLONE_BLOCKING
Caller must block all write operation to the SE.
Definition: handler.h:962
@ HA_CLONE_RESTART
SE supports restarting clone after network failure.
Definition: handler.h:978
@ HA_CLONE_HYBRID
For transactional SE, use both page tracking and redo to optimize clone with concurrent dml.
Definition: handler.h:972
@ HA_CLONE_MULTI_TASK
SE supports multiple threads for clone.
Definition: handler.h:975
@ HA_CLONE_TYPE_MAX
Maximum value of clone type.
Definition: handler.h:981
@ HA_CLONE_PAGE
For transactional SE, track page changes to support concurrent dml.
Definition: handler.h:968
@ HA_CLONE_REDO
For transactional SE, archive redo to support concurrent dml.
Definition: handler.h:965
enum_schema_tables
Definition: handler.h:914
@ SCH_OPTIMIZER_TRACE
Definition: handler.h:919
@ SCH_ENGINES
Definition: handler.h:917
@ SCH_TABLE_PRIVILEGES
Definition: handler.h:925
@ SCH_COLUMN_PRIVILEGES
Definition: handler.h:916
@ SCH_SCHEMA_PRIVILEGES
Definition: handler.h:923
@ SCH_PLUGINS
Definition: handler.h:920
@ SCH_PROFILES
Definition: handler.h:922
@ SCH_LAST
Definition: handler.h:929
@ SCH_TMP_TABLE_KEYS
Definition: handler.h:928
@ SCH_TABLESPACES
Definition: handler.h:924
@ SCH_USER_PRIVILEGES
Definition: handler.h:926
@ SCH_PROCESSLIST
Definition: handler.h:921
@ SCH_OPEN_TABLES
Definition: handler.h:918
@ SCH_TMP_TABLE_COLUMNS
Definition: handler.h:927
@ SCH_FIRST
Definition: handler.h:915
constexpr const uint64_t HA_CREATE_USED_AUTOEXTEND_SIZE
These flags convey that the options AUTOEXTEND_SIZE has been specified in the CREATE TABLE statement.
Definition: handler.h:803
bool(* get_tablespace_type_by_name_t)(const char *tablespace_name, Tablespace_type *space_type)
Get the tablespace type given the name, from the SE.
Definition: handler.h:1644
bool ha_check_if_table_exists(THD *thd, const char *db, const char *name, bool *exists)
Try to find a table in a storage engine.
Definition: handler.cc:5342
std::vector< sdi_key_t > sdi_container
Definition: handler.h:134
st_plugin_int * hton2plugin(uint slot)
Maps from slot to plugin. May return NULL if plugin has been unloaded.
Definition: handler.cc:238
st_plugin_int * insert_hton2plugin(uint slot, st_plugin_int *plugin)
For unit testing.
Definition: handler.cc:242
SecondaryEngineFlag
Definition: handler.h:2460
@ USE_EXTERNAL_EXECUTOR
This flag can be set to signal that a secondary storage engine will not use MySQL's executor (see JOI...
void ha_pre_dd_shutdown(void)
Invoke handlerton::pre_dd_shutdown() on every storage engine plugin.
Definition: handler.cc:979
void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted, Cost_estimate *cost)
Get cost of reading nrows table records in a "disk sweep".
Definition: handler.cc:7206
constexpr const decltype(handlerton::flags) HTON_SUPPORTS_GENERATED_INVISIBLE_PK
Engine supports Generated invisible primary key.
Definition: handler.h:2932
bool(* get_tablespace_type_t)(const dd::Tablespace &space, Tablespace_type *space_type)
Get the tablespace type from the SE.
Definition: handler.h:1632
bool(* rotate_encryption_master_key_t)(void)
Initiate master key rotation.
Definition: handler.h:2080
void(* post_recover_t)(void)
Perform SE-specific cleanup after recovery of transactions.
Definition: handler.h:2290
bool(* notify_rename_table_t)(THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type, const char *old_db_name, const char *old_table_name, const char *new_db_name, const char *new_table_name)
Notify/get permission from storage engine before or after execution of RENAME TABLE operation on the ...
Definition: handler.h:2053
int ha_commit_trans(THD *thd, bool all, bool ignore_global_read_lock=false)
Definition: handler.cc:1608
#define HTON_IS_SECONDARY_ENGINE
Engine is a secondary storage engine.
Definition: handler.h:2919
int(* start_consistent_snapshot_t)(handlerton *hton, THD *thd)
Definition: handler.h:1481
enum_stats_auto_recalc
Definition: handler.h:3036
@ HA_STATS_AUTO_RECALC_DEFAULT
Definition: handler.h:3037
@ HA_STATS_AUTO_RECALC_OFF
Definition: handler.h:3039
@ HA_STATS_AUTO_RECALC_ON
Definition: handler.h:3038
const char *(* get_tablespace_filename_ext_t)()
SE interface for getting tablespace extension.
Definition: handler.h:1564
ts_alter_tablespace_type
Definition: handler.h:846
@ TS_ALTER_TABLESPACE_TYPE_NOT_DEFINED
Definition: handler.h:847
@ ALTER_UNDO_TABLESPACE_SET_ACTIVE
Definition: handler.h:852
@ ALTER_UNDO_TABLESPACE_SET_INACTIVE
Definition: handler.h:853
@ ALTER_TABLESPACE_OPTIONS
Definition: handler.h:851
@ ALTER_TABLESPACE_DROP_FILE
Definition: handler.h:849
@ ALTER_TABLESPACE_RENAME
Definition: handler.h:850
@ ALTER_TABLESPACE_ADD_FILE
Definition: handler.h:848
void(* binlog_log_query_t)(handlerton *hton, THD *thd, enum_binlog_command binlog_command, const char *query, uint query_length, const char *db, const char *table_name)
Definition: handler.h:1653
xa_status_code(* commit_by_xid_t)(handlerton *hton, XID *xid)
Definition: handler.h:1452
bool is_index_access_error(int error)
Check whether an error is index access error or not after an index read.
Definition: handler.cc:8832
plugin_ref ha_resolve_by_name(THD *thd, const LEX_CSTRING *name, bool is_temp_table)
Return the storage engine handlerton for the supplied name.
Definition: handler.cc:402
void(* replace_native_transaction_in_thd_t)(THD *thd, void *new_trx_arg, void **ptr_trx_arg)
Definition: handler.h:1856
constexpr const uint64_t HA_CREATE_USED_READ_ONLY
ALTER SCHEMA|DATABASE has an explicit READ_ONLY clause.
Definition: handler.h:797
bool(* sdi_delete_t)(const dd::Tablespace &tablespace, const dd::Table *table, const sdi_key_t *sdi_key)
Delete SDI for a given SDI key.
Definition: handler.h:1790
bool(* get_tablespace_statistics_t)(const char *tablespace_name, const char *file_name, const dd::Properties &ts_se_private_data, ha_tablespace_statistics *stats)
Retrieve ha_tablespace_statistics from SE.
Definition: handler.h:2157
int(* discover_t)(handlerton *hton, THD *thd, const char *db, const char *name, uchar **frmblob, size_t *frmlen)
Definition: handler.h:1661
ulong total_ha_2pc
Definition: handler.cc:262
int(* table_exists_in_engine_t)(handlerton *hton, THD *thd, const char *db, const char *name)
Definition: handler.h:1668
enum_binlog_command
Definition: handler.h:697
@ LOGCOM_DROP_TABLE
Definition: handler.h:701
@ LOGCOM_CREATE_DB
Definition: handler.h:702
@ LOGCOM_DROP_DB
Definition: handler.h:704
@ LOGCOM_RENAME_TABLE
Definition: handler.h:700
@ LOGCOM_ALTER_TABLE
Definition: handler.h:699
@ LOGCOM_ALTER_DB
Definition: handler.h:703
@ LOGCOM_CREATE_TABLE
Definition: handler.h:698
static const uint32 HTON_FKS_NEED_DIFFERENT_PARENT_AND_SUPPORTING_KEYS
Storage engine does not support using the same key for both parent and supporting key,...
Definition: handler.h:3002
bool set_tx_isolation(THD *thd, enum_tx_isolation tx_isolation, bool one_shot)
Set the transaction isolation level for the next transaction and update session tracker information a...
Definition: handler.cc:8726
bool ha_is_storage_engine_disabled(handlerton *se_engine)
Definition: handler.cc:511
const char * ha_row_type[]
Definition: handler.cc:280
bool ha_notify_table_ddl(THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type, ha_ddl_type ddl_type, const char *old_db_name, const char *old_table_name, const char *new_db_name, const char *new_table_name)
Notify/get permission from all interested storage engines before or after executed DDL (ALTER TABLE,...
Definition: handler.cc:8694
handlerton * ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type)
Definition: handler.cc:547
handler * get_new_handler(TABLE_SHARE *share, bool partitioned, MEM_ROOT *alloc, handlerton *db_type)
Create handler object for the table in the storage engine.
Definition: handler.cc:603
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION
Definition: handler.h:289
enum_tx_isolation
Definition: handler.h:3029
@ ISO_READ_UNCOMMITTED
Definition: handler.h:3030
@ ISO_REPEATABLE_READ
Definition: handler.h:3032
@ ISO_READ_COMMITTED
Definition: handler.h:3031
@ ISO_SERIALIZABLE
Definition: handler.h:3033
bool(* notify_truncate_table_t)(THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type)
Notify/get permission from storage engine before or after execution of TRUNCATE TABLE operation on th...
Definition: handler.h:2070
void(* pre_dd_shutdown_t)(handlerton *hton)
Shut down all storage engine background tasks that might access the data dictionary,...
Definition: handler.h:1351
const char * ha_resolve_storage_engine_name(const handlerton *db_type)
Definition: handler.cc:255
bool(* flush_logs_t)(handlerton *hton, bool binlog_group_flush)
Flush the log(s) of storage engine(s).
Definition: handler.h:1492
bool ha_check_reserved_db_name(const char *name)
Check if the database name is reserved word used by SE.
Definition: handler.cc:8815
const char * table_case_name(const HA_CREATE_INFO *info, const char *name)
Definition: handler.cc:4046
const char * get_canonical_filename(handler *file, const char *path, char *tmp_path)
make canonical filename
Definition: handler.cc:2466
bool(* dict_set_server_version_t)()
Store the current server version number into the header of the dictionary tablespace.
Definition: handler.h:1971
int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv)
Definition: handler.cc:2225
int ha_panic(enum ha_panic_function flag)
int(* commit_t)(handlerton *hton, THD *thd, bool all)
'all' is true if it's a real commit, that makes persistent changes 'all' is false if it's not in fact...
Definition: handler.h:1383
int ha_recover(Xid_commit_list *commit_list=nullptr, Xa_state_list *xa_state_list=nullptr)
Stage of the recovery process where information is collected from the storage engines (SE),...
Definition: xa.cc:268
int ha_delete_table(THD *thd, handlerton *db_type, const char *path, const char *db, const char *alias, const dd::Table *table_def, bool generate_warning)
Delete table from the storage engine.
Definition: handler.cc:2513
static const uint32 HTON_FKS_WITH_EXTENDED_PARENT_KEYS
Engine takes into account hidden part of key (coming from primary key) when determines if it can serv...
Definition: handler.h:3013
row_type
Definition: handler.h:676
@ ROW_TYPE_COMPRESSED
Definition: handler.h:681
@ ROW_TYPE_REDUNDANT
Definition: handler.h:682
@ ROW_TYPE_NOT_USED
Definition: handler.h:677
@ ROW_TYPE_FIXED
Definition: handler.h:679
@ ROW_TYPE_PAGED
Unused.
Definition: handler.h:685
@ ROW_TYPE_DEFAULT
Definition: handler.h:678
@ ROW_TYPE_COMPACT
Definition: handler.h:683
@ ROW_TYPE_DYNAMIC
Definition: handler.h:680
bool() stat_print_fn(THD *thd, const char *type, size_t type_len, const char *file, size_t file_len, const char *status, size_t status_len)
Definition: handler.h:142
const handlerton * SecondaryEngineHandlerton(const THD *thd)
Returns the handlerton of the secondary engine that is used in the session, or nullptr if a secondary...
Definition: handler.cc:8782
static const LEX_CSTRING FK_NAME_DEFAULT_SUFFIX
Suffix for auto-generated foreign key names for tables in SE's which don't specify own suffix.
Definition: handler.h:3027
handlerton * ha_default_handlerton(THD *thd)
Return the default storage engine handlerton used for non-temp tables for thread.
Definition: handler.cc:346
int ha_savepoint(THD *thd, SAVEPOINT *sv)
Definition: handler.cc:2329
void ha_close_connection(THD *thd)
Definition: handler.cc:949
int(*)(handlerton *hton, THD *thd, const uchar *&loc, uint &loc_len, uint &task_id, Ha_clone_type type, Ha_clone_mode mode) Clone_begin_t
Begin copy from source database.
Definition: handler.h:2178
int(* upgrade_logs_t)(THD *thd)
Upgrade logs after the checkpoint from where upgrade process can only roll forward.
Definition: handler.h:1612
bool(* is_reserved_db_name_t)(handlerton *hton, const char *name)
Definition: handler.h:2327
int(* savepoint_rollback_t)(handlerton *hton, THD *thd, void *sv)
sv points to a storage area, that was earlier passed to the savepoint_set call
Definition: handler.h:1357
void(*)(Ha_clone_flagset &flags) Clone_capability_t
Get capability flags for clone operation.
Definition: handler.h:2165
int ha_binlog_end(THD *thd)
Definition: handler.cc:5881
const char * binlog_format_names[]
Definition: mysqld.cc:1313
constexpr const uint64_t HA_CREATE_USED_START_TRANSACTION
This option is used to convey that the create table should not commit the operation and keep the tran...
Definition: handler.h:787
int(*)(uint64_t *start_id, uint64_t *stop_id, uint64_t *num_pages) page_track_get_num_page_ids_t
Fetch approximate number of tracked pages in the given range.
Definition: handler.h:2593
int(*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, Ha_clone_cbk *cbk) Clone_copy_t
Copy data from source database in chunks via callback.
Definition: handler.h:2189
xa_status_code
X/Open XA distributed transaction status codes.
Definition: handler.h:1405
@ XAER_ASYNC
asynchronous operation already outstanding
Definition: handler.h:1414
@ XAER_PROTO
routine invoked in an improper context
Definition: handler.h:1434
@ XAER_INVAL
invalid arguments were given
Definition: handler.h:1429
@ XAER_NOTA
the XID is not valid
Definition: handler.h:1424
@ XAER_OUTSIDE
resource manager doing work outside transaction
Definition: handler.h:1449
@ XAER_RMFAIL
resource manager unavailable
Definition: handler.h:1439
@ XA_OK
normal execution
Definition: handler.h:1409
@ XAER_DUPID
the XID already exists
Definition: handler.h:1444
@ XAER_RMERR
a resource manager error occurred in the transaction branch
Definition: handler.h:1419
void ha_binlog_wait(THD *thd)
Definition: handler.cc:5824
bool(* dict_get_server_version_t)(uint *version)
Get the server version id stored in the header of the dictionary tablespace.
Definition: handler.h:1963
int ha_start_consistent_snapshot(THD *thd)
Definition: handler.cc:2412
constexpr const uint32 SDI_TYPE_TABLESPACE
Id for identifying Tablespace SDIs.
Definition: handler.h:123
int(*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, int in_err, Ha_clone_cbk *cbk) Clone_ack_t
Acknowledge data transfer to source database.
Definition: handler.h:2202
bool(* is_valid_tablespace_name_t)(ts_command_type ts_cmd, const char *tablespace_name)
SE specific validation of the tablespace name.
Definition: handler.h:1518
int ha_table_exists_in_engine(THD *thd, const char *db, const char *name)
Definition: handler.cc:5755
int(* upgrade_tablespace_t)(THD *thd)
Get the tablespace data from SE and insert it into Data dictionary.
Definition: handler.h:1575
bool(* notify_exclusive_mdl_t)(THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type, bool *victimized)
Notify/get permission from storage engine before acquisition or after release of exclusive metadata l...
Definition: handler.h:2004
int ha_commit_low(THD *thd, bool all, bool run_after_commit=true)
Commit the sessions outstanding transaction.
Definition: handler.cc:1880
uint(* partition_flags_t)()
The flag values are defined in sql_partition.h.
Definition: handler.h:1504
bool ha_flush_logs(bool binlog_group_flush=false)
Flush the log(s) of storage engine(s).
Definition: handler.cc:2436
dict_recovery_mode_t
Mode for data dictionary recovery.
Definition: handler.h:1930
@ DICT_RECOVERY_RESTART_SERVER
Restart of an existing server.
Definition: handler.h:1933
@ DICT_RECOVERY_INITIALIZE_TABLESPACES
First start, create tablespaces.
Definition: handler.h:1932
@ DICT_RECOVERY_INITIALIZE_SERVER
First start of a new server.
Definition: handler.h:1931
bool(* sdi_get_keys_t)(const dd::Tablespace &tablespace, sdi_vector_t &vector)
Get the SDI keys in a tablespace into vector.
Definition: handler.h:1734
ulong savepoint_alloc_size
Definition: handler.cc:264
int(* fill_is_table_t)(handlerton *hton, THD *thd, Table_ref *tables, class Item *cond, enum enum_schema_tables)
Definition: handler.h:1647
int(* binlog_func_t)(handlerton *hton, THD *thd, enum_binlog_func fn, void *arg)
Definition: handler.h:1650
int ha_create_table_from_engine(THD *thd, const char *db, const char *name)
Try to discover table from engine.
Definition: handler.cc:5262
enum_binlog_func
Definition: handler.h:688
@ BFN_BINLOG_WAIT
Definition: handler.h:691
@ BFN_BINLOG_PURGE_WAIT
Definition: handler.h:694
@ BFN_BINLOG_END
Definition: handler.h:692
@ BFN_RESET_SLAVE
Definition: handler.h:690
@ BFN_BINLOG_PURGE_FILE
Definition: handler.h:693
@ BFN_RESET_LOGS
Definition: handler.h:689
void set_externally_disabled_storage_engine_names(const char *)
Read a comma-separated list of storage engine names.
Definition: handler.cc:460
void(* se_after_commit_t)(void *arg)
Definition: handler.h:2500
bool(*)(THD *thd, const JoinHypergraph &hypergraph, AccessPath *access_path) secondary_engine_modify_access_path_cost_t
Evaluates the cost of executing the given access path in this secondary storage engine,...
Definition: handler.h:2430
int(* rollback_t)(handlerton *hton, THD *thd, bool all)
Definition: handler.h:1385
void(* dict_cache_reset_t)(const char *schema_name, const char *table_name)
Invalidate an entry in the local dictionary cache.
Definition: handler.h:1918
bool ha_rollback_to_savepoint_can_release_mdl(THD *thd)
Check if all storage engines used in transaction agree that after rollback to savepoint it is safe to...
Definition: handler.cc:2202
int binlog_log_row(TABLE *table, const uchar *before_record, const uchar *after_record, Log_func *log_func)
Definition: handler.cc:7836
void * range_seq_t
Definition: handler.h:3651
int ha_init_errors(void)
Register handler error messages for use with my_error().
Definition: handler.cc:638
bool(*)(THD *thd, const JOIN &join, double optimizer_cost, bool *use_best_so_far, bool *cheaper, double *secondary_engine_cost) compare_secondary_engine_cost_t
Compares the cost of two join plans in the secondary storage engine.
Definition: handler.h:2378
handlerton * get_default_handlerton(THD *thd, handlerton *hton)
Get default handlerton, if handler supplied is null.
Definition: handler.h:7168
int ha_rollback_trans(THD *thd, bool all)
Definition: handler.cc:2041
constexpr const ha_rows EXTRA_RECORDS
Definition: handler.h:117
enum_sampling_method
Definition: handler.h:707
int ha_reset_logs(THD *thd)
Definition: handler.cc:5813
bool ha_storage_engine_is_enabled(const handlerton *db_type)
Predicate to determine if a storage engine, represented by a handlerton*, is enabled.
Definition: handler.h:7196
dict_init_mode_t
Mode for initializing the data dictionary.
Definition: handler.h:1860
@ DICT_INIT_IGNORE_FILES
Don't care about files at all.
Definition: handler.h:1864
@ DICT_INIT_UPGRADE_57_FILES
Used for upgrade from mysql-5.7.
Definition: handler.h:1863
@ DICT_INIT_CREATE_FILES
Create all required SE files.
Definition: handler.h:1861
@ DICT_INIT_CHECK_FILES
Verify existence of expected files.
Definition: handler.h:1862
bool(* check_fk_column_compat_t)(const Ha_fk_column_type *child_column_type, const Ha_fk_column_type *parent_column_type, bool check_charsets)
Check SE considers types of child and parent columns in foreign key to be compatible.
Definition: handler.h:2323
constexpr SecondaryEngineFlags MakeSecondaryEngineFlags()
Creates an empty bitmap of access path types.
Definition: handler.h:2480
void(* drop_database_t)(handlerton *hton, char *path)
Definition: handler.h:1477
bool ha_is_externally_disabled(const handlerton &)
Returns true if the storage engine of the handlerton argument has been listed in the disabled_storage...
Definition: handler.cc:504
int(*)(handlerton *hton, Xa_state_list &xa_list) recover_prepared_in_tc_t
Retrieves information about externally coordinated transactions for which the two-phase prepare was f...
Definition: handler.h:1397
static const uint32 HTON_FKS_WITH_PREFIX_PARENT_KEYS
Engine supports both unique and non-unique parent keys for foreign keys which contain full foreign ke...
Definition: handler.h:2971
void(* dict_cache_reset_tables_and_tablespaces_t)()
Invalidate all table and tablespace entries in the local dictionary cache.
Definition: handler.h:1927
#define HA_NO_TRANSACTIONS
Definition: handler.h:210
void(* post_ddl_t)(THD *thd)
Perform post-commit/rollback cleanup after DDL statement (e.g.
Definition: handler.h:2281
bool ddl_is_atomic(const handlerton *hton)
Definition: handler.h:2955
ulonglong my_xid
Definition: handler.h:1228
legacy_db_type
Definition: handler.h:640
@ DB_TYPE_MARIA
Definition: handler.h:668
@ DB_TYPE_FEDERATED_DB
Definition: handler.h:659
@ DB_TYPE_GEMINI
Definition: handler.h:654
@ DB_TYPE_FIRST_DYNAMIC
Definition: handler.h:672
@ DB_TYPE_MISAM
Definition: handler.h:644
@ DB_TYPE_HEAP
Definition: handler.h:647
@ DB_TYPE_TABLE_FUNCTION
Definition: handler.h:665
@ DB_TYPE_DIAB_ISAM
Definition: handler.h:642
@ DB_TYPE_TEMPTABLE
Definition: handler.h:671
@ DB_TYPE_HASH
Definition: handler.h:643
@ DB_TYPE_PARTITION_DB
Definition: handler.h:661
@ DB_TYPE_BINLOG
Definition: handler.h:662
@ DB_TYPE_SOLID
Definition: handler.h:663
@ DB_TYPE_UNKNOWN
Definition: handler.h:641
@ DB_TYPE_ISAM
Definition: handler.h:648
@ DB_TYPE_MRG_MYISAM
Definition: handler.h:651
@ DB_TYPE_PERFORMANCE_SCHEMA
Performance schema engine.
Definition: handler.h:670
@ DB_TYPE_EXAMPLE_DB
Definition: handler.h:656
@ DB_TYPE_CSV_DB
Definition: handler.h:658
@ DB_TYPE_NDBCLUSTER
Definition: handler.h:655
@ DB_TYPE_INNODB
Definition: handler.h:653
@ DB_TYPE_FALCON
Definition: handler.h:667
@ DB_TYPE_DEFAULT
Definition: handler.h:673
@ DB_TYPE_BLACKHOLE_DB
Definition: handler.h:660
@ DB_TYPE_MYISAM
Definition: handler.h:650
@ DB_TYPE_RMS_ISAM
Definition: handler.h:646
@ DB_TYPE_BERKELEY_DB
Definition: handler.h:652
@ DB_TYPE_MRG_ISAM
Definition: handler.h:649
@ DB_TYPE_PBXT
Definition: handler.h:664
@ DB_TYPE_PISAM
Definition: handler.h:645
@ DB_TYPE_ARCHIVE_DB
Definition: handler.h:657
@ DB_TYPE_MEMCACHE
Definition: handler.h:666
void(* se_before_commit_t)(void *arg)
Definition: handler.h:2496
int ha_initialize_handlerton(st_plugin_int *plugin)
Definition: handler.cc:773
ha_notification_type
Definition: handler.h:933
@ HA_NOTIFY_POST_EVENT
Definition: handler.h:933
@ HA_NOTIFY_PRE_EVENT
Definition: handler.h:933
bool(* upgrade_space_version_t)(dd::Tablespace *tablespace)
Get the tablespace data from SE and insert it into Data dictionary.
Definition: handler.h:1586
Tablespace_type
Definition: handler.h:1614
xa_status_code(* rollback_by_xid_t)(handlerton *hton, XID *xid)
Definition: handler.h:1454
void ha_binlog_log_query(THD *thd, handlerton *db_type, enum_binlog_command binlog_command, const char *query, size_t query_length, const char *db, const char *table_name)
Definition: handler.cc:5864
handler *(* create_t)(handlerton *hton, TABLE_SHARE *table, bool partitioned, MEM_ROOT *mem_root)
Create handler object for the table in the storage engine.
Definition: handler.h:1474
void ha_acl_notify(THD *thd, class Acl_change_notification *)
Definition: handler.cc:5895
SE_cost_constants *(* get_cost_constants_t)(uint storage_category)
Retrieve cost constants to be used for this storage engine.
Definition: handler.h:1841
static bool commit(THD *thd)
Commit the current statement and transaction.
Definition: sql_cmd_srs.cc:152
File containing constants that can be used throughout the server.
SHOW_COMP_OPTION
Definition: sql_const.h:228
@ SHOW_OPTION_YES
Definition: sql_const.h:228
constexpr const unsigned int MAX_KEY
Definition: sql_const.h:46
constexpr const unsigned int MAX_REF_PARTS
Definition: sql_const.h:47
constexpr const unsigned int MAX_KEY_LENGTH
Definition: sql_const.h:48
case opt name
Definition: sslopt-case.h:33
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:193
Definition: m_ctype.h:385
Definition: handler.h:2253
Clone_apply_t clone_apply
Definition: handler.h:2265
Clone_end_t clone_end
Definition: handler.h:2261
Clone_capability_t clone_capability
Definition: handler.h:2255
Clone_apply_begin_t clone_apply_begin
Definition: handler.h:2264
Clone_begin_t clone_begin
Definition: handler.h:2258
Clone_copy_t clone_copy
Definition: handler.h:2259
Clone_apply_end_t clone_apply_end
Definition: handler.h:2266
Clone_ack_t clone_ack
Definition: handler.h:2260
Definition: ft_global.h:72
Definition: handler.h:3645
uchar * buffer_end
Definition: handler.h:3647
uchar * buffer
Definition: handler.h:3646
uchar * end_of_used_area
Definition: handler.h:3648
Definition: handler.h:3632
KEY_CACHE * key_cache
Definition: handler.h:3635
uint sql_flags
Definition: handler.h:3634
uint flags
Definition: handler.h:3633
Struct to hold information about the table that should be created.
Definition: handler.h:3045
ulonglong auto_increment_value
Definition: handler.h:3084
bool m_hidden
Definition: handler.h:3116
bool m_transactional_ddl
Definition: handler.h:3122
bool m_implicit_tablespace_autoextend_size_change
Definition: handler.h:3129
handlerton * db_type
Definition: handler.h:3095
LEX_STRING compress
Algorithm (and possible options) to be used for InnoDB's transparent page compression.
Definition: handler.h:3061
LEX_STRING encrypt_type
This attribute is used for InnoDB's transparent page encryption.
Definition: handler.h:3069
LEX_CSTRING engine_attribute
Definition: handler.h:3124
ulong avg_row_length
Definition: handler.h:3086
const CHARSET_INFO * table_charset
Definition: handler.h:3046
const char * data_file_name
Definition: handler.h:3079
ulonglong m_implicit_tablespace_autoextend_size
Definition: handler.h:3127
bool secondary_load
Secondary engine load status.
Definition: handler.h:3077
ulong table_options
Definition: handler.h:3085
const CHARSET_INFO * default_table_charset
Definition: handler.h:3047
uint stats_sample_pages
Definition: handler.h:3091
const char * alias
Definition: handler.h:3081
uint null_bits
Definition: handler.h:3106
uint merge_insert_method
Definition: handler.h:3108
LEX_STRING connect_string
Definition: handler.h:3049
const char * tablespace
Definition: handler.h:3051
ulonglong max_rows
Definition: handler.h:3082
void init_create_options_from_share(const TABLE_SHARE *share, uint64_t used_fields)
Fill HA_CREATE_INFO to be used by ALTER as well as upgrade code.
Definition: handler.cc:2581
const char * password
Definition: handler.h:3050
ha_storage_media storage_media
Definition: handler.h:3109
LEX_STRING comment
Definition: handler.h:3052
const char * index_file_name
Definition: handler.h:3080
SQL_I_List< Table_ref > merge_list
Definition: handler.h:3094
std::uint32_t key_block_size
Definition: handler.h:3090
LEX_CSTRING secondary_engine_attribute
Definition: handler.h:3125
LEX_CSTRING secondary_engine
Secondary engine of the table.
Definition: handler.h:3075
ulonglong min_rows
Definition: handler.h:3083
uint64_t used_fields
Definition: handler.h:3087
bool schema_read_only
Definition: handler.h:3048
enum_stats_auto_recalc stats_auto_recalc
Definition: handler.h:3093
File reference for clone.
Definition: handler.h:990
@ FILE_DESC
File descriptor.
Definition: handler.h:997
@ FILE_HANDLE
File handle.
Definition: handler.h:994
enum Ha_clone_file::@47 type
File reference type.
void * file_handle
File handle for windows.
Definition: handler.h:1007
int file_desc
File descriptor.
Definition: handler.h:1004
Column type description for foreign key columns compatibility check.
Definition: handler.h:1215
size_t elements_count
Definition: handler.h:1223
bool is_unsigned
Definition: handler.h:1225
size_t char_length
Definition: handler.h:1221
const CHARSET_INFO * field_charset
Definition: handler.h:1222
uint numeric_scale
Definition: handler.h:1224
dd::enum_column_types type
Definition: handler.h:1216
A struct containing a join hypergraph of a single query block, encapsulating the constraints given by...
Definition: make_join_hypergraph.h:77
Definition: keycache.h:73
Definition: my_base.h:1131
Structure describing changes to an index to be caused by ALTER TABLE.
Definition: handler.h:3151
KEY * new_key
Pointer to KEY object describing new version of index in Alter_inplace_info::key_info_buffer array.
Definition: handler.h:3162
KEY * old_key
Pointer to KEY object describing old version of index in TABLE::key_info array for TABLE instance rep...
Definition: handler.h:3157
The LEX object currently serves three different purposes:
Definition: sql_lex.h:3710
Metadata lock object key.
Definition: mdl.h:365
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: mysql_lex_string.h:40
Definition: mysql_lex_string.h:35
Definition: my_bitmap.h:43
State data storage for start_table_io_wait_v1_t, start_table_lock_wait_v1_t.
Definition: psi_table_bits.h:69
Page track interface.
Definition: handler.h:2602
page_track_get_num_page_ids_t get_num_page_ids
Definition: handler.h:2607
page_track_purge_t purge
Definition: handler.h:2605
page_track_start_t start
Definition: handler.h:2603
page_track_stop_t stop
Definition: handler.h:2604
page_track_get_status_t get_status
Definition: handler.h:2608
page_track_get_page_ids_t get_page_ids
Definition: handler.h:2606
Definition: handler.h:3653
range_seq_t(* init)(void *init_params, uint n_ranges, uint flags)
Definition: handler.h:3666
uint(* next)(range_seq_t seq, KEY_MULTI_RANGE *range)
Definition: handler.h:3680
bool(* skip_record)(range_seq_t seq, char *range_info, uchar *rowid)
Definition: handler.h:3697
Definition: transaction_info.h:44
Per thread status variables.
Definition: system_variables.h:511
This structure is shared between different table objects.
Definition: table.h:690
Definition: table.h:1399
Definition: thr_lock.h:124
Definition: typelib.h:35
Structure used by parser to store options for tablespace statements and pass them on to Execution cla...
Definition: sql_tablespace.h:43
Info about FULLTEXT index hints, passed to the storage engine.
Definition: ft_global.h:117
double op_value
Operation value.
Definition: ft_global.h:123
ha_rows limit
LIMIT value, HA_POS_ERROR if not set.
Definition: ft_global.h:125
enum ft_operation op_type
Operation type.
Definition: ft_global.h:121
uint flags
FULLTEXT flags, see FT_NL, etc.
Definition: ft_global.h:119
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2622
sdi_get_keys_t sdi_get_keys
Definition: handler.h:2724
sdi_drop_t sdi_drop
Definition: handler.h:2723
unlock_hton_log_t unlock_hton_log
Definition: handler.h:2781
notify_alter_table_t notify_alter_table
Definition: handler.h:2755
dict_cache_reset_t dict_cache_reset
Definition: handler.h:2693
void * data
Location for engines to keep personal structures.
Definition: handler.h:2774
set_prepared_in_tc_by_xid_t set_prepared_in_tc_by_xid
Definition: handler.h:2671
se_before_rollback_t se_before_rollback
Definition: handler.h:2856
sdi_set_t sdi_set
Definition: handler.h:2726
lock_hton_log_t lock_hton_log
Definition: handler.h:2780
is_dict_readonly_t is_dict_readonly
Definition: handler.h:2750
alter_tablespace_t alter_tablespace
Definition: handler.h:2681
finish_upgrade_t finish_upgrade
Definition: handler.h:2688
create_t create
Definition: handler.h:2672
collect_hton_log_info_t collect_hton_log_info
Definition: handler.h:2782
dict_register_dd_table_id_t dict_register_dd_table_id
Definition: handler.h:2692
redo_log_set_state_t redo_log_set_state
Definition: handler.h:2759
find_files_t find_files
Definition: handler.h:2713
ddse_dict_init_t ddse_dict_init
Definition: handler.h:2691
replace_native_transaction_in_thd_t replace_native_transaction_in_thd
Definition: handler.h:2753
LEX_CSTRING fk_name_suffix
Suffix for auto-generated foreign key names for tables using this storage engine.
Definition: handler.h:2797
pre_dd_shutdown_t pre_dd_shutdown
Definition: handler.h:2658
check_fk_column_compat_t check_fk_column_compat
Definition: handler.h:2787
SecondaryEngineFlags secondary_engine_flags
Bitmap which contains the supported join types and other flags for a secondary storage engine when us...
Definition: handler.h:2828
uint32 license
Flag for Engine License.
Definition: handler.h:2772
is_supported_system_table_t is_supported_system_table
Definition: handler.h:2716
secondary_engine_modify_access_path_cost_t secondary_engine_modify_access_path_cost
Pointer to a function that evaluates the cost of executing an access path in a secondary storage engi...
Definition: handler.h:2835
commit_t commit
Definition: handler.h:2663
get_tablespace_statistics_t get_tablespace_statistics
Definition: handler.h:2763
se_after_commit_t se_after_commit
Definition: handler.h:2855
savepoint_set_t savepoint_set
Definition: handler.h:2659
uint savepoint_offset
To store per-savepoint data storage engine is provided with an area of a requested size (0 is ok here...
Definition: handler.h:2652
drop_database_t drop_database
Definition: handler.h:2673
savepoint_release_t savepoint_release
Definition: handler.h:2662
enum legacy_db_type db_type
Historical number used for frm file to determine the correct storage engine.
Definition: handler.h:2632
is_valid_tablespace_name_t is_valid_tablespace_name
Definition: handler.h:2679
se_before_commit_t se_before_commit
Definition: handler.h:2854
flush_logs_t flush_logs
Definition: handler.h:2676
uint slot
Each storage engine has it's own memory area (actually a pointer) in the thd, for storing per-connect...
Definition: handler.h:2642
dict_get_server_version_t dict_get_server_version
Definition: handler.h:2697
get_tablespace_type_t get_tablespace_type
Definition: handler.h:2685
close_connection_t close_connection
Definition: handler.h:2656
rotate_encryption_master_key_t rotate_encryption_master_key
Definition: handler.h:2758
notify_truncate_table_t notify_truncate_table
Definition: handler.h:2757
start_consistent_snapshot_t start_consistent_snapshot
Definition: handler.h:2675
savepoint_rollback_t savepoint_rollback
Definition: handler.h:2660
fill_is_table_t fill_is_table
Definition: handler.h:2689
binlog_func_t binlog_func
Definition: handler.h:2709
optimize_secondary_engine_t optimize_secondary_engine
Pointer to a function that optimizes the current statement for execution on the secondary storage eng...
Definition: handler.h:2814
notify_exclusive_mdl_t notify_exclusive_mdl
Definition: handler.h:2754
get_cost_constants_t get_cost_constants
Definition: handler.h:2752
set_secondary_engine_offload_fail_reason_t set_secondary_engine_offload_fail_reason
Pointer to a function that sets the offload failure reason as a string for a thread context (represen...
Definition: handler.h:2852
rollback_by_xid_t rollback_by_xid
Definition: handler.h:2669
sdi_delete_t sdi_delete
Definition: handler.h:2727
get_index_column_cardinality_t get_index_column_cardinality
Definition: handler.h:2762
rollback_t rollback
Definition: handler.h:2664
dict_recover_t dict_recover
Definition: handler.h:2696
rm_tmp_tables_t rm_tmp_tables
Definition: handler.h:2751
prepare_secondary_engine_t prepare_secondary_engine
Pointer to a function that prepares a secondary engine for executing a statement.
Definition: handler.h:2805
get_table_statistics_t get_table_statistics
Definition: handler.h:2761
Page_track_t page_track
Page tracking interface.
Definition: handler.h:2859
sdi_create_t sdi_create
Definition: handler.h:2722
dict_init_t dict_init
Definition: handler.h:2690
uint32 foreign_keys_flags
Flags describing details of foreign key support by storage engine.
Definition: handler.h:2785
binlog_log_query_t binlog_log_query
Definition: handler.h:2710
get_tablespace_filename_ext_t get_tablespace_filename_ext
Definition: handler.h:2682
upgrade_logs_t upgrade_logs
Definition: handler.h:2687
get_secondary_engine_offload_or_exec_fail_reason_t get_secondary_engine_offload_or_exec_fail_reason
Pointer to a function that returns the query offload or exec failure reason as a string given a threa...
Definition: handler.h:2844
partition_flags_t partition_flags
Definition: handler.h:2678
const char ** file_extensions
Null-ended array of file extensions that exist for the storage engine.
Definition: handler.h:2748
dict_cache_reset_tables_and_tablespaces_t dict_cache_reset_tables_and_tablespaces
Definition: handler.h:2695
push_to_engine_t push_to_engine
Definition: handler.h:2715
Clone_interface_t clone_interface
Clone data transfer interfaces.
Definition: handler.h:2769
recover_prepared_in_tc_t recover_prepared_in_tc
Definition: handler.h:2667
discover_t discover
Definition: handler.h:2712
table_exists_in_engine_t table_exists_in_engine
Definition: handler.h:2714
upgrade_tablespace_t upgrade_tablespace
Definition: handler.h:2683
sdi_get_t sdi_get
Definition: handler.h:2725
get_tablespace_type_by_name_t get_tablespace_type_by_name
Definition: handler.h:2686
get_tablespace_t get_tablespace
Definition: handler.h:2680
dict_set_server_version_t dict_set_server_version
Definition: handler.h:2698
recover_t recover
Definition: handler.h:2666
SHOW_COMP_OPTION state
Historical marker for if the engine is available or not.
Definition: handler.h:2626
post_recover_t post_recover
Definition: handler.h:2766
uint32 flags
Global handler flags.
Definition: handler.h:2702
upgrade_space_version_t upgrade_space_version
Definition: handler.h:2684
kill_connection_t kill_connection
Definition: handler.h:2657
prepare_t prepare
Definition: handler.h:2665
panic_t panic
Definition: handler.h:2674
post_ddl_t post_ddl
Definition: handler.h:2765
compare_secondary_engine_cost_t compare_secondary_engine_cost
Pointer to a function that estimates the cost of executing a join in a secondary storage engine.
Definition: handler.h:2822
commit_by_xid_t commit_by_xid
Definition: handler.h:2668
set_prepared_in_tc_t set_prepared_in_tc
Definition: handler.h:2670
acl_notify_t acl_notify
Definition: handler.h:2711
show_status_t show_status
Definition: handler.h:2677
is_reserved_db_name_t is_reserved_db_name
Definition: handler.h:2699
savepoint_rollback_can_release_mdl_t savepoint_rollback_can_release_mdl
Definition: handler.h:2661
notify_rename_table_t notify_rename_table
Definition: handler.h:2756
Definition: my_base.h:1124
Definition: gen_lex_token.cc:149
Definition: result.h:30
Key to identify a dictionary object.
Definition: handler.h:126
uint32 type
Type of Object, For ex: column, index, etc.
Definition: handler.h:128
uint64 id
Object id which should be unique in tablespsace.
Definition: handler.h:131
Definition: handler.h:135
sdi_container m_vec
Definition: handler.h:136
Definition: handler.h:813
const char * db
Definition: handler.h:814
const char * tablename
Definition: handler.h:815
Definition: sql_plugin_ref.h:45
Plain structure to store information about XA transaction id and a list of table names involved into ...
Definition: xa.h:290
Definition: mysqlslap.cc:238
struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification,...
Definition: xa.h:83
thr_lock_type
Definition: thr_lock.h:51
Include file for Sun RPC to compile out of the box.
unsigned int uint
Definition: uca9-dump.cc:75
unsigned long id[MAX_DEAD]
Definition: xcom_base.cc:510
static uint64_t cache_size
Definition: xcom_cache.cc:362
static int all(site_def const *s, node_no node)
Definition: xcom_transport.cc:871