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