MySQL 9.5.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 @param thd Thread context
1597
1598 @return Operation status.
1599 @retval == 0 Success.
1600 @retval != 0 Error (handler error code returned)
1601*/
1602typedef int (*upgrade_tablespace_t)(THD *thd);
1603
1604/**
1605 Get the tablespace data from SE and insert it into Data dictionary
1606
1607 @param[in] tablespace tablespace object
1608
1609 @return Operation status.
1610 @retval == 0 Success.
1611 @retval != 0 Error (handler error code returned)
1612*/
1613typedef bool (*upgrade_space_version_t)(dd::Tablespace *tablespace);
1614
1615/**
1616 Finish upgrade process inside storage engines.
1617 This includes resetting flags to indicate upgrade process
1618 and cleanup after upgrade.
1619
1620 @param thd Thread context
1621 @param failed_upgrade True if the upgrade failed.
1622
1623 @return Operation status.
1624 @retval == 0 Success.
1625 @retval != 0 Error (handler error code returned)
1626*/
1627typedef int (*finish_upgrade_t)(THD *thd, bool failed_upgrade);
1628
1629/**
1630 Upgrade logs after the checkpoint from where upgrade
1631 process can only roll forward.
1632
1633 @param thd Thread context
1634
1635 @return Operation status.
1636 @retval == 0 Success.
1637 @retval != 0 Error (handler error code returned)
1638*/
1639typedef int (*upgrade_logs_t)(THD *thd);
1640
1648};
1649
1650/**
1651 Get the tablespace type from the SE.
1652
1653 @param[in] space tablespace object
1654 @param[out] space_type type of space
1655
1656 @return Operation status.
1657 @retval false on success and true for failure.
1658*/
1659typedef bool (*get_tablespace_type_t)(const dd::Tablespace &space,
1660 Tablespace_type *space_type);
1661
1662/**
1663 Get the tablespace type given the name, from the SE.
1664
1665 @param[in] tablespace_name tablespace name
1666 @param[out] space_type type of space
1667
1668 @return Operation status.
1669 @retval false on success and true for failure.
1670*/
1671typedef bool (*get_tablespace_type_by_name_t)(const char *tablespace_name,
1672 Tablespace_type *space_type);
1673
1674typedef int (*fill_is_table_t)(handlerton *hton, THD *thd, Table_ref *tables,
1675 class Item *cond, enum enum_schema_tables);
1676
1677typedef int (*binlog_func_t)(handlerton *hton, THD *thd, enum_binlog_func fn,
1678 void *arg);
1679
1680typedef void (*binlog_log_query_t)(handlerton *hton, THD *thd,
1681 enum_binlog_command binlog_command,
1682 const char *query, uint query_length,
1683 const char *db, const char *table_name);
1684
1685typedef void (*acl_notify_t)(THD *thd,
1686 const class Acl_change_notification *notice);
1687
1688typedef int (*discover_t)(handlerton *hton, THD *thd, const char *db,
1689 const char *name, uchar **frmblob, size_t *frmlen);
1690
1691typedef int (*find_files_t)(handlerton *hton, THD *thd, const char *db,
1692 const char *path, const char *wild, bool dir,
1693 List<LEX_STRING> *files);
1694
1695typedef int (*table_exists_in_engine_t)(handlerton *hton, THD *thd,
1696 const char *db, const char *name);
1697
1698/**
1699 Let storage engine inspect the query Accesspath and pick whatever
1700 it like for being pushed down to the engine. (Join, conditions, ..)
1701
1702 The handler implementation should itself keep track of what it 'pushed',
1703 such that later calls to the handlers access methods should
1704 activate the pushed parts of the execution plan on the storage
1705 engines.
1706
1707 @param thd Thread context
1708 @param query The AccessPath for the entire query.
1709 @param join The JOIN to be pushed
1710
1711 @returns
1712 0 on success
1713 error otherwise
1714*/
1715using push_to_engine_t = int (*)(THD *thd, AccessPath *query, JOIN *join);
1716
1717/**
1718 Check if the given db.tablename is a system table for this SE.
1719
1720 @param db Database name to check.
1721 @param table_name table name to check.
1722 @param is_sql_layer_system_table if the supplied db.table_name is a SQL
1723 layer system table.
1724
1725 @see example_is_supported_system_table in ha_example.cc
1726
1727 is_sql_layer_system_table is supplied to make more efficient
1728 checks possible for SEs that support all SQL layer tables.
1729
1730 This interface is optional, so every SE need not implement it.
1731*/
1732typedef bool (*is_supported_system_table_t)(const char *db,
1733 const char *table_name,
1734 bool is_sql_layer_system_table);
1735
1736/**
1737 Create SDI in a tablespace. This API should be used when upgrading
1738 a tablespace with no SDI or after invoking sdi_drop().
1739 @param[in] tablespace tablespace object
1740 @retval false success
1741 @retval true failure
1742*/
1743typedef bool (*sdi_create_t)(dd::Tablespace *tablespace);
1744
1745/**
1746 Drop SDI in a tablespace. This API should be used only when
1747 SDI is corrupted.
1748 @param[in] tablespace tablespace object
1749 @retval false success
1750 @retval true failure
1751*/
1752typedef bool (*sdi_drop_t)(dd::Tablespace *tablespace);
1753
1754/**
1755 Get the SDI keys in a tablespace into vector.
1756 @param[in] tablespace tablespace object
1757 @param[in,out] vector vector of SDI Keys
1758 @retval false success
1759 @retval true failure
1760*/
1761typedef bool (*sdi_get_keys_t)(const dd::Tablespace &tablespace,
1763
1764/**
1765 Retrieve SDI for a given SDI key.
1766
1767 Since the caller of this api will not know the SDI length, SDI retrieval
1768 should be done in the following way.
1769
1770 i. Allocate initial memory of some size (Lets say 64KB)
1771 ii. Pass the allocated memory to the below api.
1772 iii. If passed buffer is sufficient, sdi_get_by_id() copies the sdi
1773 to the buffer passed and returns success, else sdi_len is modified
1774 with the actual length of the SDI (and returns false on failure).
1775 For genuine errors, sdi_len is returned as UINT64_MAX
1776 iv. If sdi_len != UINT64_MAX, retry the call after allocating the memory
1777 of sdi_len
1778 v. Free the memory after using SDI (responsibility of caller)
1779
1780 @param[in] tablespace tablespace object
1781 @param[in] sdi_key SDI key to uniquely identify SDI obj
1782 @param[in,out] sdi SDI retrieved from tablespace
1783 A non-null pointer must be passed in
1784 @param[in,out] sdi_len in: length of the memory allocated
1785 out: actual length of SDI
1786 @retval false success
1787 @retval true failure
1788*/
1789typedef bool (*sdi_get_t)(const dd::Tablespace &tablespace,
1790 const sdi_key_t *sdi_key, void *sdi, uint64 *sdi_len);
1791
1792/**
1793 Insert/Update SDI for a given SDI key.
1794 @param[in] hton handlerton object
1795 @param[in] tablespace tablespace object
1796 @param[in] table table object
1797 @param[in] sdi_key SDI key to uniquely identify SDI obj
1798 @param[in] sdi SDI to write into the tablespace
1799 @param[in] sdi_len length of SDI BLOB returned
1800 @retval false success
1801 @retval true failure, my_error() should be called
1802 by SE
1803*/
1804typedef bool (*sdi_set_t)(handlerton *hton, const dd::Tablespace &tablespace,
1805 const dd::Table *table, const sdi_key_t *sdi_key,
1806 const void *sdi, uint64 sdi_len);
1807
1808/**
1809 Delete SDI for a given SDI key.
1810 @param[in] tablespace tablespace object
1811 @param[in] table table object
1812 @param[in] sdi_key SDI key to uniquely identify SDI obj
1813 @retval false success
1814 @retval true failure, my_error() should be called
1815 by SE
1816*/
1817typedef bool (*sdi_delete_t)(const dd::Tablespace &tablespace,
1818 const dd::Table *table, const sdi_key_t *sdi_key);
1819
1820/**
1821 Check if the DDSE is started in a way that leaves thd DD being read only.
1822
1823 @retval true The data dictionary can only be read.
1824 @retval false The data dictionary can be read and written.
1825 */
1826typedef bool (*is_dict_readonly_t)();
1827
1828/**
1829 Drop all temporary tables which have been left from previous server
1830 run belonging to this SE. Used on server start-up.
1831
1832 @param[in] hton Handlerton for storage engine.
1833 @param[in] thd Thread context.
1834 @param[in,out] files List of files in directories for temporary files
1835 which match tmp_file_prefix and thus can belong to
1836 temporary tables (but not necessarily in this SE).
1837 It is recommended to remove file from the list if
1838 SE recognizes it as belonging to temporary table
1839 in this SE and deletes it.
1840*/
1841typedef bool (*rm_tmp_tables_t)(handlerton *hton, THD *thd,
1842 List<LEX_STRING> *files);
1843
1844/**
1845 Retrieve cost constants to be used for this storage engine.
1846
1847 A storage engine that wants to provide its own cost constants to
1848 be used in the optimizer cost model, should implement this function.
1849 The server will call this function to get a cost constant object
1850 that will be used for tables stored in this storage engine instead
1851 of using the default cost constants.
1852
1853 Life cycle for the cost constant object: The storage engine must
1854 allocate the cost constant object on the heap. After the function
1855 returns, the server takes over the ownership of this object.
1856 The server will eventually delete the object by calling delete.
1857
1858 @note In the initial version the storage_category parameter will
1859 not be used. The only valid value this will have is DEFAULT_STORAGE_CLASS
1860 (see declaration in opt_costconstants.h).
1861
1862 @param storage_category the storage type that the cost constants will
1863 be used for
1864
1865 @return a pointer to the cost constant object, if NULL is returned
1866 the default cost constants will be used
1867*/
1868typedef SE_cost_constants *(*get_cost_constants_t)(uint storage_category);
1869
1870/**
1871 @param[in,out] thd pointer to THD
1872 @param[in] new_trx_arg pointer to replacement transaction
1873 @param[out] ptr_trx_arg double pointer to being replaced transaction
1874
1875 Associated with THD engine's native transaction is replaced
1876 with @c new_trx_arg. The old value is returned through a buffer if non-null
1877 pointer is provided with @c ptr_trx_arg.
1878 The method is adapted by XA start and XA prepare handlers to
1879 handle XA transaction that is logged as two parts by slave applier.
1880
1881 This interface concerns engines that are aware of XA transaction.
1882*/
1883typedef void (*replace_native_transaction_in_thd_t)(THD *thd, void *new_trx_arg,
1884 void **ptr_trx_arg);
1885
1886/** Mode for initializing the data dictionary. */
1888 DICT_INIT_CREATE_FILES, ///< Create all required SE files
1889 DICT_INIT_CHECK_FILES ///< Verify existence of expected files
1891
1892/**
1893 Initialize the SE for being used to store the DD tables. Create
1894 the required files according to the dict_init_mode. Create strings
1895 representing the required DDSE tables, i.e., tables that the DDSE
1896 expects to exist in the DD, and add them to the appropriate out
1897 parameter.
1898
1899 @note There are two variants of this function type, one is to be
1900 used by the DDSE, and has a different type of output parameters
1901 because the SQL layer needs more information about the DDSE tables
1902 in order to support upgrade.
1903
1904 @param dict_init_mode How to initialize files
1905 @param version Target DD version if a new
1906 server is being installed.
1907 0 if restarting an existing
1908 server.
1909 @param [out] DDSE_tables List of SQL DDL statements
1910 for creating DD tables that
1911 are needed by the DDSE.
1912 @param [out] DDSE_tablespaces List of meta data for predefined
1913 tablespaces created by the DDSE.
1914
1915 @retval true An error occurred.
1916 @retval false Success - no errors.
1917 */
1918
1919typedef bool (*dict_init_t)(dict_init_mode_t dict_init_mode, uint version,
1920 List<const Plugin_table> *DDSE_tables,
1921 List<const Plugin_tablespace> *DDSE_tablespaces);
1922
1923typedef bool (*ddse_dict_init_t)(
1924 dict_init_mode_t dict_init_mode, uint version,
1925 List<const dd::Object_table> *DDSE_tables,
1926 List<const Plugin_tablespace> *DDSE_tablespaces);
1927
1928/**
1929 Initialize the set of hard coded DD table ids.
1930*/
1931typedef void (*dict_register_dd_table_id_t)(dd::Object_id hard_coded_tables);
1932
1933/**
1934 Invalidate an entry in the local dictionary cache.
1935
1936 Needed during bootstrap to make sure the contents in the DDSE
1937 dictionary cache is in sync with the global DD.
1938
1939 @param schema_name Schema name.
1940 @param table_name Table name.
1941 */
1942
1943typedef void (*dict_cache_reset_t)(const char *schema_name,
1944 const char *table_name);
1945
1946/**
1947 Invalidate all table and tablespace entries in the local dictionary cache.
1948
1949 Needed for recovery during server restart.
1950 */
1951
1953
1954/** Mode for data dictionary recovery. */
1956 DICT_RECOVERY_INITIALIZE_SERVER, ///< First start of a new server
1957 DICT_RECOVERY_INITIALIZE_TABLESPACES, ///< First start, create tablespaces
1958 DICT_RECOVERY_RESTART_SERVER ///< Restart of an existing server
1960
1961/**
1962 Do recovery in the DDSE as part of initializing the data dictionary.
1963 The dict_recovery_mode indicates what kind of recovery should be
1964 done.
1965
1966 @param dict_recovery_mode How to do recovery
1967 @param version Target DD version if a new
1968 server is being installed.
1969 Actual DD version if restarting
1970 an existing server.
1971
1972 @retval true An error occurred.
1973 @retval false Success - no errors.
1974 */
1975
1976typedef bool (*dict_recover_t)(dict_recovery_mode_t dict_recovery_mode,
1977 uint version);
1978
1979/**
1980 Get the server version id stored in the header of the
1981 dictionary tablespace.
1982
1983 @param [out] version Version number from the DD
1984 tablespace header.
1985
1986 @retval Operation outcome, false if no error, otherwise true.
1987*/
1988typedef bool (*dict_get_server_version_t)(uint *version);
1989
1990/**
1991 Store the current server version number into the
1992 header of the dictionary tablespace.
1993
1994 @retval Operation outcome, false if no error, otherwise true.
1995*/
1997
1998/**
1999 Notify/get permission from storage engine before acquisition or after
2000 release of exclusive metadata lock on object represented by key.
2001
2002 @param thd Thread context.
2003 @param mdl_key MDL key identifying object on which exclusive
2004 lock is to be acquired/was released.
2005 @param notification_type Indicates whether this is pre-acquire or
2006 post-release notification.
2007 @param victimized 'true' if locking failed as we were selected
2008 as a victim in order to avoid possible deadlocks.
2009
2010 @note Notification is done only for objects from TABLESPACE, SCHEMA,
2011 TABLE, FUNCTION, PROCEDURE, TRIGGER and EVENT namespaces.
2012
2013 @note Problems during notification are to be reported as warnings, MDL
2014 subsystem will report generic error if pre-acquire notification
2015 fails/SE refuses lock acquisition.
2016 @note Return value is ignored/error is not reported in case of
2017 post-release notification.
2018
2019 @note In some cases post-release notification might happen even if
2020 there were no prior pre-acquire notification. For example,
2021 when SE was loaded after exclusive lock acquisition, or when
2022 we need notify SEs which permitted lock acquisition that it
2023 didn't happen because one of SEs didn't allow it (in such case
2024 we will do post-release notification for all SEs for simplicity).
2025
2026 @return False - if notification was successful/lock can be acquired,
2027 True - if it has failed/lock should not be acquired.
2028*/
2029typedef bool (*notify_exclusive_mdl_t)(THD *thd, const MDL_key *mdl_key,
2030 ha_notification_type notification_type,
2031 bool *victimized);
2032
2033/**
2034 Notify/get permission from storage engine before or after execution of
2035 ALTER TABLE operation on the table identified by the MDL key.
2036
2037 @param thd Thread context.
2038 @param mdl_key MDL key identifying table which is going to be
2039 or was ALTERed.
2040 @param notification_type Indicates whether this is pre-ALTER TABLE or
2041 post-ALTER TABLE notification.
2042
2043 @note This hook is necessary because for ALTER TABLE upgrade to X
2044 metadata lock happens fairly late during the execution process,
2045 so it can be expensive to abort ALTER TABLE operation at this
2046 stage by returning failure from notify_exclusive_mdl() hook.
2047
2048 @note This hook follows the same error reporting convention as
2049 @see notify_exclusive_mdl().
2050
2051 @note Similarly to notify_exclusive_mdl() in some cases post-ALTER
2052 notification might happen even if there were no prior pre-ALTER
2053 notification.
2054
2055 @note Post-ALTER notification can happen before post-release notification
2056 for exclusive metadata lock acquired by this ALTER TABLE.
2057
2058 @return False - if notification was successful/ALTER TABLE can proceed.
2059 True - if it has failed/ALTER TABLE should be aborted.
2060*/
2061typedef bool (*notify_alter_table_t)(THD *thd, const MDL_key *mdl_key,
2062 ha_notification_type notification_type);
2063
2064/**
2065 Notify/get permission from storage engine before or after execution of
2066 RENAME TABLE operation on the table identified by the MDL key.
2067
2068 @param thd Thread context.
2069 @param mdl_key MDL key identifying table which is going to be
2070 or was RENAMEd.
2071 @param notification_type Indicates whether this is pre-RENAME TABLE or
2072 post-RENAME TABLE notification.
2073 @param old_db_name old db name
2074 @param old_table_name old table name
2075 @param new_db_name new db name
2076 @param new_table_name new table name
2077*/
2078typedef bool (*notify_rename_table_t)(THD *thd, const MDL_key *mdl_key,
2079 ha_notification_type notification_type,
2080 const char *old_db_name,
2081 const char *old_table_name,
2082 const char *new_db_name,
2083 const char *new_table_name);
2084
2085/**
2086 Notify/get permission from storage engine before or after execution of
2087 TRUNCATE TABLE operation on the table identified by the MDL key.
2088
2089 @param thd Thread context.
2090 @param mdl_key MDL key identifying table which is going to be
2091 or was TRUNCATEd.
2092 @param notification_type Indicates whether this is pre-TRUNCATE TABLE or
2093 post-TRUNCATE TABLE notification.
2094*/
2095typedef bool (*notify_truncate_table_t)(THD *thd, const MDL_key *mdl_key,
2096 ha_notification_type notification_type);
2097
2098/**
2099 @brief
2100 Initiate master key rotation
2101
2102 @returns false on success,
2103 true on failure
2104*/
2106
2107/**
2108 @brief
2109 Enable or Disable SE write ahead logging.
2110
2111 @param[in] thd server thread handle
2112 @param[in] enable enable/disable redo logging
2113
2114 @return true iff failed.
2115*/
2116typedef bool (*redo_log_set_state_t)(THD *thd, bool enable);
2117
2118/**
2119 @brief
2120 Retrieve ha_statistics from SE.
2121
2122 @param db_name Name of schema
2123 @param table_name Name of table
2124 @param se_private_id SE private id of the table.
2125 @param ts_se_private_data Tablespace SE private data.
2126 @param tbl_se_private_data Table SE private data.
2127 @param flags Type of statistics to retrieve.
2128 @param[out] stats Contains statistics read from SE.
2129
2130 @note Handlers that implement this callback/API should adhere
2131 to servers expectation that, the implementation would invoke
2132 my_error() before returning 'true'/failure from this function.
2133
2134 @returns false on success,
2135 true on failure
2136*/
2138 const char *db_name, const char *table_name, dd::Object_id se_private_id,
2139 const dd::Properties &ts_se_private_data,
2140 const dd::Properties &tbl_se_private_data, uint flags,
2142
2143/**
2144 Retrieve column_statistics from SE.
2145 @param thd Current THD
2146 @param db_name Name of schema
2147 @param table_name Name of table
2148 @param column_name Name of column
2149 @param rows_in_table Nrows in table
2150
2151 @returns The statistics if available, empty value otherwise.
2152*/
2153typedef std::optional<ha_column_statistics> (*get_column_statistics_t)(
2154 THD *thd, const char *db_name, const char *table_name,
2155 const char *column_name, double rows_in_table);
2156
2157/**
2158 @brief
2159 Retrieve index column cardinality from SE.
2160
2161 @param db_name Name of schema
2162 @param table_name Name of table
2163 @param index_name Name of index
2164 @param index_ordinal_position Position of index.
2165 @param column_ordinal_position Position of column in index.
2166 @param se_private_id SE private id of the table.
2167 @param[out] cardinality cardinality being returned by SE.
2168
2169 @note Handlers that implement this callback/API should adhere
2170 to servers expectation that, the implementation would invoke
2171 my_error() before returning 'true'/failure from this function.
2172
2173 @returns false on success,
2174 true on failure
2175*/
2177 const char *db_name, const char *table_name, const char *index_name,
2178 uint index_ordinal_position, uint column_ordinal_position,
2179 dd::Object_id se_private_id, ulonglong *cardinality);
2180
2181/**
2182 Retrieve ha_tablespace_statistics from SE.
2183
2184 @param tablespace_name Tablespace_name
2185 @param file_name Tablespace file name.
2186 @param ts_se_private_data Tablespace SE private data.
2187 @param[out] stats Contains tablespace
2188 statistics read from SE.
2189
2190 @note Handlers that implement this callback/API should adhere
2191 to servers expectation that, the implementation would invoke
2192 my_error() before returning 'true'/failure from this function.
2193
2194 @returns false on success, true on failure
2195*/
2197 const char *tablespace_name, const char *file_name,
2198 const dd::Properties &ts_se_private_data, ha_tablespace_statistics *stats);
2199
2200/* Database physical clone interfaces */
2201
2202/** Get capability flags for clone operation
2203@param[out] flags capability flag */
2205
2206/** Begin copy from source database
2207@param[in] hton handlerton for SE
2208@param[in] thd server thread handle
2209@param[in,out] loc locator
2210@param[in,out] loc_len locator length
2211@param[out] task_id task identifier
2212@param[in] type clone type
2213@param[in] mode mode for starting clone
2214@return error code */
2215using Clone_begin_t = int (*)(handlerton *hton, THD *thd, const uchar *&loc,
2216 uint &loc_len, uint &task_id, Ha_clone_type type,
2218
2219/** Copy data from source database in chunks via callback
2220@param[in] hton handlerton for SE
2221@param[in] thd server thread handle
2222@param[in] loc locator
2223@param[in] loc_len locator length in bytes
2224@param[in] task_id task identifier
2225@param[in] cbk callback interface for sending data
2226@return error code */
2227using Clone_copy_t = int (*)(handlerton *hton, THD *thd, const uchar *loc,
2228 uint loc_len, uint task_id, Ha_clone_cbk *cbk);
2229
2230/** Acknowledge data transfer to source database
2231@param[in] hton handlerton for SE
2232@param[in] thd server thread handle
2233@param[in] loc locator
2234@param[in] loc_len locator length in bytes
2235@param[in] task_id task identifier
2236@param[in] in_err inform any error occurred
2237@param[in] cbk callback interface
2238@return error code */
2239using Clone_ack_t = int (*)(handlerton *hton, THD *thd, const uchar *loc,
2240 uint loc_len, uint task_id, int in_err,
2241 Ha_clone_cbk *cbk);
2242
2243/** End copy from source database
2244@param[in] hton handlerton for SE
2245@param[in] thd server thread handle
2246@param[in] loc locator
2247@param[in] loc_len locator length in bytes
2248@param[in] task_id task identifier
2249@param[in] in_err error code when ending after error
2250@return error code */
2251using Clone_end_t = int (*)(handlerton *hton, THD *thd, const uchar *loc,
2252 uint loc_len, uint task_id, int in_err);
2253
2254/** Begin apply to destination database
2255@param[in] hton handlerton for SE
2256@param[in] thd server thread handle
2257@param[in,out] loc locator
2258@param[in,out] loc_len locator length
2259@param[in] task_id task identifier
2260@param[in] mode mode for starting clone
2261@param[in] data_dir target data directory
2262@return error code */
2263using Clone_apply_begin_t = int (*)(handlerton *hton, THD *thd,
2264 const uchar *&loc, uint &loc_len,
2265 uint &task_id, Ha_clone_mode mode,
2266 const char *data_dir);
2267
2268/** Apply data to destination database in chunks via callback
2269@param[in] hton handlerton for SE
2270@param[in] thd server thread handle
2271@param[in] loc locator
2272@param[in] loc_len locator length in bytes
2273@param[in] task_id task identifier
2274@param[in] in_err inform any error occurred
2275@param[in] cbk callback interface for receiving data
2276@return error code */
2277using Clone_apply_t = int (*)(handlerton *hton, THD *thd, const uchar *loc,
2278 uint loc_len, uint task_id, int in_err,
2279 Ha_clone_cbk *cbk);
2280
2281/** End apply to destination database
2282@param[in] hton handlerton for SE
2283@param[in] thd server thread handle
2284@param[in] loc locator
2285@param[in] loc_len locator length in bytes
2286@param[in] task_id task identifier
2287@param[in] in_err error code when ending after error
2288@return error code */
2289using Clone_apply_end_t = int (*)(handlerton *hton, THD *thd, const uchar *loc,
2290 uint loc_len, uint task_id, int in_err);
2291
2293 /* Get clone capabilities of an SE */
2295
2296 /* Interfaces to copy data. */
2301
2302 /* Interfaces to apply data. */
2306};
2307
2308/**
2309 Perform post-commit/rollback cleanup after DDL statement (e.g. in
2310 case of DROP TABLES really remove table files from disk).
2311
2312 @note This hook will be invoked after DDL commit or rollback only
2313 for storage engines supporting atomic DDL.
2314
2315 @note Problems during execution of this method should be reported to
2316 error log and as warnings/notes to user. Since this method is
2317 called after successful commit of the statement we can't fail
2318 statement with error.
2319*/
2320typedef void (*post_ddl_t)(THD *thd);
2321
2322/**
2323 Perform SE-specific cleanup after recovery of transactions.
2324
2325 @note Particularly SEs supporting atomic DDL can use this call
2326 to perform post-DDL actions for DDL statements which were
2327 committed or rolled back during recovery stage.
2328*/
2329typedef void (*post_recover_t)(void);
2330
2331/**
2332 Lock a handlerton (resource) log to collect log information.
2333*/
2334
2335typedef bool (*lock_hton_log_t)(handlerton *hton);
2336
2337/**
2338 Unlock a handlerton (resource) log after collecting log information.
2339*/
2340
2341typedef bool (*unlock_hton_log_t)(handlerton *hton);
2342
2343/**
2344 Collect a handlerton (resource) log information.
2345*/
2346
2347typedef bool (*collect_hton_log_info_t)(handlerton *hton, Json_dom *json);
2348
2349/**
2350 Check SE considers types of child and parent columns in foreign key
2351 to be compatible.
2352
2353 @param child_column_type Child column type description.
2354 @param parent_column_type Parent column type description.
2355 @param check_charsets Indicates whether we need to check
2356 that charsets of string columns
2357 match. Which is true in most cases.
2358
2359 @returns True if types are compatible, False if not.
2360*/
2361
2363 const Ha_fk_column_type *child_column_type,
2364 const Ha_fk_column_type *parent_column_type, bool check_charsets);
2365
2366typedef bool (*is_reserved_db_name_t)(handlerton *hton, const char *name);
2367
2368/**
2369 Prepare the secondary engine for executing a statement. This function is
2370 called right after the secondary engine TABLE objects have been opened by
2371 open_secondary_engine_tables(), before the statement is optimized and
2372 executed. Secondary engines will typically create a context object in this
2373 function, which they can use to store state that is needed during the
2374 optimization and execution phases.
2375
2376 @param thd thread context
2377 @param lex the statement to execute
2378 @return true on error, false on success
2379*/
2380using prepare_secondary_engine_t = bool (*)(THD *thd, LEX *lex);
2381
2382/**
2383 Optimize a statement for execution on a secondary storage engine. This
2384 function is called when the optimization of a statement has completed, just
2385 before the statement is executed. Secondary engines can use this function to
2386 apply engine-specific optimizations to the execution plan. They can also
2387 reject executing the query by raising an error, in which case the query will
2388 be reprepared and executed by the primary storage engine.
2389
2390 @param thd thread context
2391 @param lex the statement being optimized
2392 @return true on error, false on success
2393*/
2394using optimize_secondary_engine_t = bool (*)(THD *thd, LEX *lex);
2395
2396/**
2397 Compares the cost of two join plans in the secondary storage engine. The cost
2398 of the current candidate is compared with the cost of the best plan seen so
2399 far.
2400
2401 @param thd thread context
2402 @param join the candidate plan to evaluate
2403 @param optimizer_cost the cost estimate calculated by the optimizer
2404 @param[out] use_best_so_far true if the optimizer should stop searching for
2405 a better plan and use the best plan it has seen so far
2406 @param[out] cheaper true if the candidate is the best plan seen so far for
2407 this JOIN (must be true if it is the first plan seen),
2408 false otherwise
2409 @param[out] secondary_engine_cost the cost estimated by the secondary engine
2410
2411 @return false on success, or true if an error has been raised
2412*/
2413using compare_secondary_engine_cost_t = bool (*)(THD *thd, const JOIN &join,
2414 double optimizer_cost,
2415 bool *use_best_so_far,
2416 bool *cheaper,
2417 double *secondary_engine_cost);
2418
2419/**
2420 Evaluates/Views the cost of executing the given access path in the secondary
2421 storage engine, and potentially modifies the cost estimates that are in the
2422 access path when optimization is being done for secondary engine. For primary
2423 engine, the cost should be only viewed. This function is only called from the
2424 hypergraph join optimizer.
2425
2426 The function is called on every access path that the join optimizer might
2427 compare to an alternative access path. This includes both paths that represent
2428 complete execution plans and paths that represent partial plans. It is not
2429 guaranteed to be called on every child path. For example, if GROUP BY is done
2430 by sorting first and then aggregating the sorted results, the function will
2431 only be called on the aggregation path, and not on the sort path, because only
2432 the aggregation path will be compared to other paths.
2433
2434 The secondary engine is allowed to modify the estimates in the access path to
2435 better match the costs of the access path in the secondary engine. It can
2436 change any of the following AccessPath members:
2437
2438 - init_once_cost
2439 - init_cost
2440 - cost
2441 - cost_before_filter
2442 - num_output_rows
2443 - num_output_rows_before_filter
2444 - secondary_engine_data
2445
2446 Any other members should be left unchanged. The AccessPath must be in an
2447 internally consistent state when the function returns, and satisfy invariants
2448 expected by the hypergraph join optimizer, such as:
2449
2450 - init_cost <= cost_before_filter <= cost
2451 - num_output_rows <= num_output_rows_before_filter
2452
2453 The secondary engine can also reject an access path altogether, by returning
2454 true, in which case the join optimizer will not use that path in the final
2455 plan. Since the secondary engine can reject any partial or complete plan, it
2456 is possible that the join optimizer does not find any valid plan that is
2457 accepted. In this case, the join optimizer will raise an error.
2458
2459 If the secondary encounters an error when evaluating the cost of the path, it
2460 can signal an error by calling my_error() and return true, in which case the
2461 join optimizer will not suggest any plan for the query.
2462
2463 @param thd The thread context.
2464 @param hypergraph The hypergraph that represents the search space.
2465 @param[in,out] access_path The AccessPath to evaluate.
2466
2467 @retval false on success.
2468 @retval true if the plan is to be rejected, or if an error was raised.
2469*/
2471 THD *thd, const JoinHypergraph &hypergraph, AccessPath *access_path);
2472
2473/**
2474 Type for signature generation and for retrieving nrows estimate
2475 from secondary engine for current AccessPath.
2476*/
2478 /** The thread context */
2480 /** The AccessPath to retrieve Nrows for. */
2482 /** Hypergraph for current query block. */
2484 /** Predicates actually applied for AccessPath::REF and other parameterized
2485 * types. */
2487 /** if ap->nrows should be acually updated. */
2488 bool to_update_rows{true};
2489 /** if ap->signature generation should be forced. Default behavior is to
2490 * generate if ap->signature != 0. */
2491 bool to_force_resign{false};
2492 /** if nonnull, an additional signature should be combined with current AP. */
2493 size_t *extra_sig{nullptr};
2494
2496 const JoinHypergraph *graph)
2498
2501};
2502
2503/**
2504 Type for signature generation and for retrieving nrows estimate
2505 from secondary engine for current AccessPath.
2506 @param params for this function. Refer to typedef for detailed description.
2507 @retval true if an updated nrow estimate is available.
2508 @retval false if no nrow estimate is available.
2509 */
2511 bool (*)(const SecondaryEngineNrowsParameters &params);
2512
2513/**
2514 Checks whether the tables used in an explain query are loaded in the secondary
2515 engine.
2516 @param thd thread context.
2517
2518 @retval true if there is a table not loaded to the secondary engine, false
2519 otherwise
2520*/
2522
2523/**
2524 Looks up and returns a specific secondary engine query offload or exec
2525 failure reason as a string given a thread context (representing the query)
2526 when the offloaded query fails in the secondary storage engine.
2527
2528 @param thd thread context.
2529
2530 @retval std::string_view as the offload failure reason.
2531 The memory pointed to is managed by the handlerton and may be freed
2532 when the statement completes.
2533*/
2535 std::string_view (*)(const THD *thd);
2536
2537/**
2538 Finds and returns a specific secondary engine query offload failure reason
2539 as a string given a thread context (representing the query) whenever
2540 get_secondary_engine_offload_or_exec_fail_reason_t returns an empty reason.
2541
2542 @param thd thread context.
2543
2544 @retval std::string_view as the offload failure reason.
2545*/
2547 std::string_view (*)(THD *thd);
2548
2549/**
2550 Sets a specific secondary engine offload failure reason for a query
2551 represented by the thread context when the offloaded query fails in
2552 the secondary storage engine.
2553
2554 @param thd thread context.
2555
2556 @param reason offload failure reason.
2557
2558 @retval bool to indicate if the setting succeeded or failed
2559*/
2561 bool (*)(const THD *thd, std::string_view reason);
2562
2564 /** Continue optimization phase with current hypergraph. */
2565 kContinue = 0,
2566 /** Trigger restart of hypergraph with provided number of subgraph pairs. */
2567 kRestart = 1,
2568};
2569
2571 /** Optimizer request from the secondary engine. */
2573 /** Subgraph pairs requested by the secondary engine. */
2575 /** Indicates if simplification is guided using secondary engine */
2577};
2578
2579/**
2580 Hook to evaluate the current hypergraph optimization state in optimization for
2581 all the engines, and returns the state that hypergraph should transition to.
2582 Usually invoked after secondary_engine_modify_view_ap_cost_t is invoked via
2583 the optimizer. The state is returned as object of type
2584 SecondaryEngineGraphSimplificationRequestParameters, and can lead to
2585 simplification of hypergraph search space, or resetting the graph and starting
2586 search afresh.
2587
2588 @param thd The thread context.
2589 @param hypergraph The hypergraph that represents the search space.
2590 @param access_path The AccessPath to evaluate.
2591 @param current_subgraph_pairs Count of subgraph pairs explored so far.
2592 @param current_subgraph_pairs_limit Limit for current hypergraph.
2593 @param is_root_access_path Indicating if access_path is root.
2594 @param trace Optimizer trace string.
2595
2596 @returns instance of SecondaryEngineGraphSimplificationRequestParameters which
2597 contains description of the state hypergraph optimizer should transition to.
2598*/
2601 THD *thd, const JoinHypergraph &hypergraph,
2602 const AccessPath *access_path, int current_subgraph_pairs,
2603 int current_subgraph_pairs_limit, bool is_root_access_path,
2604 std::string *trace);
2605
2606// Capabilities (bit flags) for secondary engines.
2607using SecondaryEngineFlags = uint64_t;
2611
2612 // If this flag is set, aggregation (GROUP BY and DISTINCT) do not require
2613 // ordered inputs and create unordered outputs. This is typically the case
2614 // if they are implemented using hash-based techniques.
2616
2617 /// This flag can be set to signal that a secondary storage engine will not
2618 /// use MySQL's executor (see JOIN::override_executor_func). In this case, it
2619 /// doesn't need MySQL's execution data structures, like internal temporary
2620 /// tables, filesort objects or iterators. If the flag is set,
2621 /// FinalizePlanForQueryBlock() will not make any changes to the plan, and
2622 /// CreateIteratorFromAccessPath() will not be called.
2624};
2625
2626/// Creates an empty bitmap of access path types. This is the base
2627/// case for the function template with the same name below.
2628inline constexpr SecondaryEngineFlags MakeSecondaryEngineFlags() { return 0; }
2629
2630/// Creates a bitmap representing a set of access path types.
2631template <typename... Args>
2633 SecondaryEngineFlag flag1, Args... rest) {
2634 return (uint64_t{1} << static_cast<int>(flag1)) |
2635 MakeSecondaryEngineFlags(rest...);
2636}
2637
2638/// Returns the handlerton of the secondary engine that is used in the session,
2639/// or nullptr if a secondary engine is not used.
2640const handlerton *SecondaryEngineHandlerton(const THD *thd);
2641
2642/// Returns the handlerton of the eligible secondary engine that is used in the
2643/// session, If found, also initialises the thd member which caches this
2644/// eligible secondary engine, or returns nullptr if a secondary engine is not
2645/// used.
2647 THD *thd, const LEX_CSTRING *secondary_engine_in_name);
2648
2649// Returns the secondary_engine_nrows hook from plugin, if plugin is install and
2650// the hook is installed.
2651std::optional<secondary_engine_nrows_t> RetrieveSecondaryEngineNrowsHook(
2652 THD *thd);
2653
2654// FIXME: Temporary workaround to enable storage engine plugins to use the
2655// before_commit hook. Remove after WL#11320 has been completed.
2656using se_before_commit_t = void (*)(void *arg);
2657
2658// FIXME: Temporary workaround to enable storage engine plugins to use the
2659// after_commit hook. Remove after WL#11320 has been completed.
2660using se_after_commit_t = void (*)(void *arg);
2661
2662// FIXME: Temporary workaround to enable storage engine plugins to use the
2663// before_rollback hook. Remove after WL#11320 has been completed.
2664using se_before_rollback_t = void (*)(void *arg);
2665
2666/**
2667 Notify plugins when a SELECT query was executed. The plugins will be notified
2668 only if the query is not considered secondary engine relevant, i.e.:
2669 1. for a query with missing secondary_engine_statement_ctx, its estimated cost
2670 is greater than the currently configured 'secondary_engine_cost_threshold'
2671 2. for queries with secondary_engine_statement_ctx, wherever
2672 secondary_engine_statement_ctx::is_primary_engine_optimal() returns False
2673 indicating secondary engine relevance.
2674 */
2675using notify_after_select_t = void (*)(THD *thd, SelectExecutedIn executed_in);
2676
2677/**
2678 * Notify plugins when a table is created.
2679 */
2680using notify_create_table_t = void (*)(struct HA_CREATE_INFO *create_info,
2681 const char *db, const char *table_name);
2682
2683/**
2684 * Notify plugins when a materialized view is referenced in a query.
2685 * The plugin is expected to check if the materialized view is available.
2686 * @param[in] thd current thd.
2687 * @param[in] db_name view database
2688 * @param[in] table_name view name
2689 * @param[in] view_def view definition query
2690 * @param[in] mdl_ticket the mdl ticket on the view to upgrade shared
2691 * lock to exclusive lock in case of
2692 * re-materialization.
2693 * @return :
2694 * @retval true The materialized view is found and can be used.
2695 * @retval false The materialzied view is not available and cannot be used.
2696 */
2698 std::string_view db_name,
2699 std::string_view table_name,
2700 std::string_view view_def,
2701 MDL_ticket *mdl_ticket);
2702
2703/**
2704 Secondary engine hook called after PRIMARY_TENTATIVELY optimization is
2705 complete, and decides if secondary engine optimization will be performed, and
2706 comparison of primary engine cost and secondary engine cost will determine
2707 which engine to use for execution.
2708 @param[in] thd current thd.
2709 @return :
2710 @retval true When secondary_engine's prepare hook is to be further called
2711 @retval false When secondary_engine's prepare hook is NOT to be further called
2712
2713 */
2715
2716/**
2717 Hook used to estimate the cardinality of table Node objects in the
2718 JoinHypergraph. For each Node, it attempts to estimate the cardinality,
2719 and if successful, stores it in the field `cardinality`.
2720
2721 @param thd The thread context.
2722 @param graph The JoinHypergraph where the estimates are to be made.
2723*/
2724using cardinality_estimation_hook_t = void (*)(THD *thd, JoinHypergraph *graph);
2725
2726/**
2727 * Notify plugins when a table is dropped.
2728 */
2729using notify_drop_table_t = void (*)(Table_ref *tab);
2730
2731/**
2732 * Store the name of default secondary engine, if any.
2733 */
2734extern std::atomic<const char *> default_secondary_engine_name;
2735/*
2736 Page Tracking : interfaces to handlerton functions which starts/stops page
2737 tracking, and purges/fetches page tracking information.
2738*/
2739
2740/**
2741 Start page tracking.
2742
2743 @param[out] start_id SE specific sequence number [LSN for InnoDB]
2744 indicating when the tracking was started
2745
2746 @return Operation status.
2747 @retval 0 Success
2748 @retval other ER_* mysql error. Get error details from THD.
2749*/
2750using page_track_start_t = int (*)(uint64_t *start_id);
2751
2752/**
2753 Stop page tracking.
2754
2755 @param[out] stop_id SE specific sequence number [LSN for InnoDB]
2756 indicating when the tracking was stopped
2757
2758 @return Operation status.
2759 @retval 0 Success
2760 @retval other ER_* mysql error. Get error details from THD.
2761*/
2762using page_track_stop_t = int (*)(uint64_t *stop_id);
2763
2764/**
2765 Purge page tracking data.
2766
2767 @param[in,out] purge_id SE specific sequence number [LSN for InnoDB]
2768 initially indicating till where the data needs to be purged and finally
2769 updated to until where it was actually purged
2770
2771 @return Operation status.
2772 @retval 0 Success
2773 @retval other ER_* mysql error. Get error details from THD.
2774*/
2775using page_track_purge_t = int (*)(uint64_t *purge_id);
2776
2777/**
2778 Fetch tracked pages.
2779
2780 @param[in] cbk_func callback function return page IDs
2781 @param[in] cbk_ctx caller's context for callback
2782 @param[in,out] start_id SE specific sequence number [LSN for InnoDB] from
2783 where the pages tracked would be returned.
2784 @note The range might get expanded and the actual start_id used for the
2785 querying will be updated.
2786 @param[in,out] stop_id SE specific sequence number [LSN for InnoDB]
2787 until where the pages tracked would be returned.
2788 @note The range might get expanded and the actual stop_id used for the
2789 querying will be updated.
2790 @param[out] buffer allocated buffer to copy page IDs
2791 @param[in] buffer_len length of buffer in bytes
2792
2793 @return Operation status.
2794 @retval 0 Success
2795 @retval other ER_* mysql error. Get error details from THD.
2796*/
2798 void *cbk_ctx, uint64_t *start_id,
2799 uint64_t *stop_id,
2800 unsigned char *buffer,
2801 size_t buffer_len);
2802
2803/**
2804 Fetch approximate number of tracked pages in the given range.
2805
2806 @param[in,out] start_id SE specific sequence number [LSN for InnoDB] from
2807 where the pages tracked would be returned.
2808 @note the range might get expanded and the actual start_id used for the
2809 querying will be updated.
2810 @param[in,out] stop_id SE specific sequence number [LSN for InnoDB]
2811 until where the pages tracked would be returned.
2812 @note the range might get expanded and the actual stop_id used for the
2813 querying will be updated.
2814 @param[out] num_pages number of pages tracked
2815
2816 @return Operation status.
2817 @retval 0 Success
2818 @retval other ER_* mysql error. Get error details from THD.
2819*/
2820using page_track_get_num_page_ids_t = int (*)(uint64_t *start_id,
2821 uint64_t *stop_id,
2822 uint64_t *num_pages);
2823
2824/** Fetch the status of the page tracking system.
2825@param[out] status vector of a pair of (ID, bool) where ID is the
2826start/stop point and bool is true if the ID is a start point else false */
2828 void (*)(std::vector<std::pair<uint64_t, bool>> &status);
2829
2830/** Page track interface */
2838};
2839
2840/**
2841 handlerton is a singleton structure - one instance per storage engine -
2842 to provide access to storage engine functionality that works on the
2843 "global" level (unlike handler class that works on a per-table basis).
2844
2845 usually handlerton instance is defined statically in ha_xxx.cc as
2846
2847 static handlerton { ... } xxx_hton;
2848
2849 savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
2850*/
2852 /**
2853 Historical marker for if the engine is available or not.
2854 */
2856
2857 /**
2858 Historical number used for frm file to determine the correct storage engine.
2859 This is going away and new engines will just use "name" for this.
2860 */
2862 /**
2863 Each storage engine has it's own memory area (actually a pointer)
2864 in the thd, for storing per-connection information.
2865 It is accessed as
2866
2867 thd->ha_data[xxx_hton.slot]
2868
2869 slot number is initialized by MySQL after xxx_init() is called.
2870 */
2871 uint slot;
2872 /**
2873 To store per-savepoint data storage engine is provided with an area
2874 of a requested size (0 is ok here).
2875 savepoint_offset must be initialized statically to the size of
2876 the needed memory to store per-savepoint information.
2877 After xxx_init it is changed to be an offset to savepoint storage
2878 area and need not be used by storage engine.
2879 see binlog_hton and binlog_savepoint_set/rollback for an example.
2880 */
2882
2883 /* handlerton methods */
2884
2931
2932 /** Global handler flags. */
2934
2935 /*
2936 Those handlerton functions below are properly initialized at handler
2937 init.
2938 */
2939
2948
2949 /*
2950 APIs for retrieving Serialized Dictionary Information by tablespace id
2951 */
2952
2959
2960 /**
2961 Null-ended array of file extensions that exist for the storage engine.
2962 Used by frm_error() and the default handler::rename_table and delete_table
2963 methods in handler.cc.
2964
2965 For engines that have two file name extensions (separate meta/index file
2966 and data file), the order of elements is relevant. First element of engine
2967 file name extensions array should be meta/index file extension. Second
2968 element - data file extension. This order is assumed by
2969 prepare_for_repair() when REPAIR TABLE ... USE_FRM is issued.
2970
2971 For engines that don't have files, file_extensions is NULL.
2972
2973 Currently, the following alternatives are used:
2974 - file_extensions == NULL;
2975 - file_extensions[0] != NULL, file_extensions[1] == NULL;
2976 - file_extensions[0] != NULL, file_extensions[1] != NULL,
2977 file_extensions[2] == NULL;
2978 */
2979 const char **file_extensions;
2980
2991
2996
2999
3000 /** Clone data transfer interfaces */
3002
3003 /** Flag for Engine License. */
3005 /** Location for engines to keep personal structures. */
3006 void *data;
3007
3008 /*
3009 Log_resource functions that must be supported by storage engines
3010 with relevant log information to be collected.
3011 */
3015
3016 /** Flags describing details of foreign key support by storage engine. */
3018
3020
3021 /**
3022 Suffix for auto-generated foreign key names for tables using this storage
3023 engine. If such suffix is specified by SE then its generated foreign key
3024 names follow (table name)(SE-specific FK name suffix)(FK number) pattern.
3025 Length of such suffix should not exceed MAX_FK_NAME_SUFFIX_LENGTH bytes.
3026 If no suffix is specified then FK_NAME_DEFAULT_SUFFIX is used as
3027 default.
3028 */
3030
3031 /**
3032 Pointer to a function that prepares a secondary engine for executing a
3033 statement.
3034
3035 @see prepare_secondary_engine_t for function signature.
3036 */
3038
3039 /**
3040 Pointer to a function that optimizes the current statement for
3041 execution on the secondary storage engine represented by this
3042 handlerton.
3043
3044 @see optimize_secondary_engine_t for function signature.
3045 */
3047
3048 /**
3049 Pointer to a function that estimates the cost of executing a join in a
3050 secondary storage engine.
3051
3052 @see compare_secondary_engine_cost_t for function signature.
3053 */
3055
3056 /// Bitmap which contains the supported join types and other flags
3057 /// for a secondary storage engine when used with the hypergraph join
3058 /// optimizer. If it is empty, it means that the secondary engine
3059 /// does not support the hypergraph join optimizer.
3061
3062 /// Pointer to a function that checks if the table is loaded in the
3063 /// secondary engine in the case of an explain statement.
3064 ///
3065 /// @see external_engine_explain_check_t for function signature.
3067
3068 /// Pointer to a function that evaluates the cost of executing an access path
3069 /// in a secondary storage engine.
3070 ///
3071 /// @see secondary_engine_modify_view_ap_cost_t for function signature.
3073
3074 /// Pointer to a function that provides nrow estimates for access paths
3075 /// from secondary storage engine
3076 ///
3077 /// @see secondary_engine_nrows_t for function signature.
3079
3080 /// Pointer to a function that returns the query offload or exec failure
3081 /// reason as a string given a thread context (representing the query) when
3082 /// the offloaded query failed in a secondary storage engine.
3083 ///
3084 /// @see get_secondary_engine_offload_or_exec_fail_reason_t for function
3085 /// signature.
3088
3089 /// Pointer to a function that finds and returns the query offload failure
3090 /// reason as a string given a thread context (representing the query) when
3091 /// get_secondary_engine_offload_or_exec_fail_reason returns an empty reason.
3092 ///
3093 /// @see find_secondary_engine_offload_fail_reason_t for function
3094 /// signature.
3097
3098 /// Pointer to a function that sets the offload failure reason as a string
3099 /// for a thread context (representing the query) when the offloaded query
3100 /// failed in a secondary storage engine.
3101 ///
3102 /// @see set_secondary_engine_offload_fail_reason_t for function signature.
3105
3106 /// Pointer to function that checks secondary engine request for updating
3107 /// hypergraph join optimization.
3108 ///
3109 /// @see secondary_engine_check_optimizer_request_t for function signature.
3112
3113 /* Pointer to a function that is called at the end of the PRIMARY_TENTATIVELY
3114 * optimization stage, which also decides that the statement should be
3115 * attempted offloaded to a secondary storage engine. */
3117
3118 /* Pointer to a function to request table filter estimation to the
3119 * secondary_engine. */
3121
3125
3127
3130
3132
3133 /** Page tracking interface */
3135};
3136
3137/* Possible flags of a handlerton (there can be 32 of them) */
3138#define HTON_NO_FLAGS 0
3139#define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0)
3140#define HTON_ALTER_NOT_SUPPORTED (1 << 1) // Engine does not support alter
3141#define HTON_CAN_RECREATE (1 << 2) // Delete all is used for truncate
3142#define HTON_HIDDEN (1 << 3) // Engine does not appear in lists
3143/*
3144 Bit 4 was occupied by BDB-specific HTON_FLUSH_AFTER_RENAME flag and is no
3145 longer used.
3146*/
3147#define HTON_NOT_USER_SELECTABLE (1 << 5)
3148#define HTON_TEMPORARY_NOT_SUPPORTED \
3149 (1 << 6) // Having temporary tables not supported
3150#define HTON_SUPPORT_LOG_TABLES (1 << 7) // Engine supports log tables
3151#define HTON_NO_PARTITION (1 << 8) // You can not partition these tables
3152
3153/*
3154 This flag should be set when deciding that the engine does not allow row based
3155 binary logging (RBL) optimizations.
3156
3157 Currently, setting this flag, means that table's read/write_set will be left
3158 untouched when logging changes to tables in this engine. In practice this
3159 means that the server will not mess around with table->write_set and/or
3160 table->read_set when using RBL and deciding whether to log full or minimal
3161 rows.
3162
3163 It's valuable for instance for virtual tables, eg: Performance Schema which
3164 have no meaning for replication.
3165*/
3166#define HTON_NO_BINLOG_ROW_OPT (1 << 9)
3167
3168/**
3169 Engine supports extended keys. The flag allows to
3170 use 'extended key' feature if the engine is able to
3171 do it (has primary key values in the secondary key).
3172 Note that handler flag HA_PRIMARY_KEY_IN_READ_INDEX is
3173 actually partial case of HTON_SUPPORTS_EXTENDED_KEYS.
3174*/
3175
3176#define HTON_SUPPORTS_EXTENDED_KEYS (1 << 10)
3177
3178// Engine support foreign key constraint.
3179
3180#define HTON_SUPPORTS_FOREIGN_KEYS (1 << 11)
3181
3182/**
3183 Engine supports atomic DDL. That is rollback of transaction for DDL
3184 statement will also rollback all changes in SE, commit of transaction
3185 of DDL statement will make it durable.
3186*/
3187
3188#define HTON_SUPPORTS_ATOMIC_DDL (1 << 12)
3189
3190/* Engine supports packed keys. */
3191#define HTON_SUPPORTS_PACKED_KEYS (1 << 13)
3192
3193/** Engine is a secondary storage engine. */
3194#define HTON_IS_SECONDARY_ENGINE (1 << 14)
3195
3196/** Engine supports secondary storage engines. */
3197#define HTON_SUPPORTS_SECONDARY_ENGINE (1 << 15)
3198
3199/** Engine supports table or tablespace encryption . */
3200#define HTON_SUPPORTS_TABLE_ENCRYPTION (1 << 16)
3201
3203 1 << 17};
3204
3205/** Engine supports Generated invisible primary key. */
3206// clang-format off
3207constexpr const decltype(
3209// clang-format on
3210
3211/** Whether the secondary engine supports DDLs. No meaning if the engine is not
3212 * secondary. */
3213#define HTON_SECONDARY_ENGINE_SUPPORTS_DDL (1 << 19)
3214
3215/** Whether the engine does not support triggers. */
3216#define HTON_NO_TRIGGER_SUPPORT (1 << 20)
3217
3218/** Whether the primary engine supports external data sources. This case refers
3219 to having tables with data in object store and the engine does not store any
3220 of those data, only metadata. Table contents can be accessed only after
3221 loading the table in the secondary storage engine. The flag is used for
3222 a primary engine only.
3223 */
3224#define HTON_SUPPORTS_EXTERNAL_SOURCE (1 << 21)
3225
3226constexpr const decltype(handlerton::flags) HTON_SUPPORTS_BULK_LOAD{1 << 22};
3227
3228/** Engine supports index distance scan. */
3229inline constexpr const decltype(handlerton::flags) HTON_SUPPORTS_DISTANCE_SCAN{
3230 1 << 23};
3231
3232/* Whether the engine supports being specified as a default storage engine */
3233inline constexpr const decltype(handlerton::flags)
3235
3236/** Whether the secondary engine supports creation of temporary tables. */
3237inline constexpr const decltype(handlerton::flags)
3239
3240/* Whether the handlerton is a secondary engine. */
3241inline bool hton_is_secondary_engine(const handlerton *hton) {
3242 return hton != nullptr && (hton->flags & HTON_IS_SECONDARY_ENGINE) != 0U;
3243}
3244
3245/* Whether the secondary engine handlerton supports DDLs */
3247 assert(hton->flags & HTON_IS_SECONDARY_ENGINE);
3248 return (hton->flags & HTON_SECONDARY_ENGINE_SUPPORTS_DDL) != 0;
3249}
3250
3251/* Whether the secondary engine handlerton supports temporary tables. */
3253 assert(hton->flags & HTON_IS_SECONDARY_ENGINE);
3254 return (hton->flags & HTON_SECONDARY_SUPPORTS_TEMPORARY_TABLE) != 0U;
3255}
3256
3257inline bool ddl_is_atomic(const handlerton *hton) {
3258 return (hton->flags & HTON_SUPPORTS_ATOMIC_DDL) != 0;
3259}
3260
3261/* Bits for handlerton::foreign_keys_flags bitmap. */
3262
3263/**
3264 Engine supports both unique and non-unique parent keys for
3265 foreign keys which contain full foreign key as its prefix.
3266
3267 Storage engines which support foreign keys but do not have
3268 this flag set are assumed to support only parent keys which
3269 are primary/unique and contain exactly the same columns as
3270 the foreign key, possibly, in different order.
3271*/
3272
3274
3275/**
3276 Storage engine supports hash keys as supporting keys for foreign
3277 keys. Hash key should contain all foreign key columns and only
3278 them (although in any order).
3279
3280 Storage engines which support foreign keys but do not have this
3281 flag set are assumed to not allow hash keys as supporting keys.
3282*/
3283
3285
3286/**
3287 Storage engine supports non-hash keys which have common prefix
3288 with the foreign key as supporting keys for it. If there are
3289 several such keys, one which shares biggest prefix with FK is
3290 chosen.
3291
3292 Storage engines which support foreign keys but do not have this
3293 flag set are assumed to require that supporting key contains full
3294 foreign key as its prefix.
3295*/
3296
3298
3299/**
3300 Storage engine does not support using the same key for both parent
3301 and supporting key, but requires the two to be different.
3302*/
3303
3305 (1 << 3);
3306
3307/**
3308 Engine takes into account hidden part of key (coming from primary key)
3309 when determines if it can serve as parent key for a foreign key.
3310
3311 Implies HTON_FKS_WITH_PREFIX_PARENT_KEYS and is related to
3312 HTON_SUPPORTS_EXTENDED_KEYS.
3313*/
3314
3316
3317/**
3318 Maximum possible length of SE-specific suffixes for auto-generated
3319 foreign key names.
3320*/
3321static const size_t MAX_FK_NAME_SUFFIX_LENGTH = 16;
3322
3323/**
3324 Suffix for auto-generated foreign key names for tables in SE's which
3325 don't specify own suffix. I.e. for foreign keys on tables in such
3326 SE's generated names follow (table name)FK_NAME_DEFAULT_SUFFIX(FK number)
3327 pattern.
3328*/
3330
3337
3343
3344/**
3345 Struct to hold information about the table that should be created.
3346 */
3350 bool schema_read_only{false};
3352 const char *password{nullptr};
3353 const char *tablespace{nullptr};
3354 LEX_STRING comment{nullptr, 0};
3355
3356 /**
3357 Algorithm (and possible options) to be used for InnoDB's transparent
3358 page compression. If this attribute is set then it is hint to the
3359 storage engine to try and compress the data using the specified algorithm
3360 where possible. Note: this value is interpreted by the storage engine only.
3361 and ignored by the Server layer. */
3362
3364
3365 /**
3366 This attribute is used for InnoDB's transparent page encryption.
3367 If this attribute is set then it is hint to the storage engine to encrypt
3368 the data. Note: this value is interpreted by the storage engine only.
3369 and ignored by the Server layer. */
3370
3372
3373 /**
3374 * Secondary engine of the table.
3375 * Is nullptr if no secondary engine defined.
3376 */
3378 /** Secondary engine load status */
3379 bool secondary_load{false};
3380
3381 /** Part info in order to maintain in HA_CREATE_INFO the per-partition
3382 * secondary_load status*/
3384
3385 const char *data_file_name{nullptr};
3386 const char *index_file_name{nullptr};
3387 const char *alias{nullptr};
3391 uint64_t table_options{0};
3393 uint64_t used_fields{0};
3394 // Can only be 1,2,4,8 or 16, but use uint32_t since that how it is
3395 // represented in InnoDB
3396 std::uint32_t key_block_size{0};
3397 uint stats_sample_pages{0}; /* number of pages to sample during
3398 stats estimation, if used, otherwise 0. */
3402 /**
3403 Row type of the table definition.
3404
3405 Defaults to ROW_TYPE_DEFAULT for all non-ALTER statements.
3406 For ALTER TABLE defaults to ROW_TYPE_NOT_USED (means "keep the current").
3407
3408 Can be changed either explicitly by the parser.
3409 If nothing specified inherits the value of the original table (if present).
3410 */
3412 uint null_bits{0}; /* NULL bits at start of record */
3413 uint options{0}; /* OR of HA_CREATE_ options */
3415 ha_storage_media storage_media{HA_SM_DEFAULT}; /* DEFAULT, DISK or MEMORY */
3416
3417 /*
3418 A flag to indicate if this table should be marked as a hidden table in
3419 the data dictionary. One use case is to mark the temporary tables
3420 created by ALTER to be marked as hidden.
3421 */
3422 bool m_hidden{false};
3423
3424 /*
3425 A flag to indicate if this table should be created but not committed at
3426 the end of statement.
3427 */
3429
3432
3434
3436
3440
3441 // Position in query text where column definitions end and table options start
3443
3444 /**
3445 Fill HA_CREATE_INFO to be used by ALTER as well as upgrade code.
3446 This function separates code from mysql_prepare_alter_table() to be
3447 used by upgrade code as well to reduce code duplication.
3448 For ALTER code path, this lets new create options override the old
3449 ones.
3450
3451 @param[in] share TABLE_SHARE object
3452 @param[in] used_fields If a given create option is not flagged, old
3453 value be copied from the TABLE_SHARE.
3454 */
3455
3457 uint64_t used_fields);
3458
3459 /**
3460 Populate the db_type member depending on internal state and thd variables.
3461
3462 @param[in] thd user session
3463 */
3464 bool set_db_type(THD *thd);
3465};
3466
3467/**
3468 Structure describing changes to an index to be caused by ALTER TABLE.
3469*/
3470
3471struct KEY_PAIR {
3472 /**
3473 Pointer to KEY object describing old version of index in
3474 TABLE::key_info array for TABLE instance representing old
3475 version of table.
3476 */
3478 /**
3479 Pointer to KEY object describing new version of index in
3480 Alter_inplace_info::key_info_buffer array.
3481 */
3483};
3484
3485/**
3486 In-place alter handler context.
3487
3488 This is a superclass intended to be subclassed by individual handlers
3489 in order to store handler unique context between in-place alter API calls.
3490
3491 The handler is responsible for creating the object. This can be done
3492 as early as during check_if_supported_inplace_alter().
3493
3494 The SQL layer is responsible for destroying the object.
3495
3496 @see Alter_inplace_info
3497*/
3498
3500 public:
3502
3504 [[maybe_unused]]) {}
3505 virtual ~inplace_alter_handler_ctx() = default;
3506};
3507
3508/**
3509 Class describing changes to be done by ALTER TABLE.
3510 Instance of this class is passed to storage engine in order
3511 to determine if this ALTER TABLE can be done using in-place
3512 algorithm. It is also used for executing the ALTER TABLE
3513 using in-place algorithm.
3514*/
3515
3517 public:
3518 /**
3519 Bits to show in detail what operations the storage engine is
3520 to execute.
3521
3522 All these operations are supported as in-place operations by the
3523 SQL layer. This means that operations that by their nature must
3524 be performed by copying the table to a temporary table, will not
3525 have their own flags here (e.g. ALTER TABLE FORCE, ALTER TABLE
3526 ENGINE).
3527
3528 We generally try to specify handler flags only if there are real
3529 changes. But in cases when it is cumbersome to determine if some
3530 attribute has really changed we might choose to set flag
3531 pessimistically, for example, relying on parser output only.
3532 */
3534
3535 // Add non-unique, non-primary index
3536 static const HA_ALTER_FLAGS ADD_INDEX = 1ULL << 0;
3537
3538 // Drop non-unique, non-primary index
3539 static const HA_ALTER_FLAGS DROP_INDEX = 1ULL << 1;
3540
3541 // Add unique, non-primary index
3542 static const HA_ALTER_FLAGS ADD_UNIQUE_INDEX = 1ULL << 2;
3543
3544 // Drop unique, non-primary index
3545 static const HA_ALTER_FLAGS DROP_UNIQUE_INDEX = 1ULL << 3;
3546
3547 // Add primary index
3548 static const HA_ALTER_FLAGS ADD_PK_INDEX = 1ULL << 4;
3549
3550 // Drop primary index
3551 static const HA_ALTER_FLAGS DROP_PK_INDEX = 1ULL << 5;
3552
3553 // Add column
3554
3555 // Virtual generated column
3556 static const HA_ALTER_FLAGS ADD_VIRTUAL_COLUMN = 1ULL << 6;
3557 // Stored base (non-generated) column
3558 static const HA_ALTER_FLAGS ADD_STORED_BASE_COLUMN = 1ULL << 7;
3559 // Stored generated column
3561 // Add generic column (convenience constant).
3564
3565 // Drop column
3566 static const HA_ALTER_FLAGS DROP_VIRTUAL_COLUMN = 1ULL << 9;
3567 static const HA_ALTER_FLAGS DROP_STORED_COLUMN = 1ULL << 10;
3570
3571 // Rename column
3572 static const HA_ALTER_FLAGS ALTER_COLUMN_NAME = 1ULL << 11;
3573
3574 // Change column datatype
3576 static const HA_ALTER_FLAGS ALTER_STORED_COLUMN_TYPE = 1ULL << 13;
3577
3578 /**
3579 Change column datatype in such way that new type has compatible
3580 packed representation with old type, so it is theoretically
3581 possible to perform change by only updating data dictionary
3582 without changing table rows.
3583 */
3585
3586 /// A virtual column has changed its position
3588
3589 /// A stored column has changed its position (disregarding virtual columns)
3591
3592 // Change column from NOT NULL to NULL
3593 static const HA_ALTER_FLAGS ALTER_COLUMN_NULLABLE = 1ULL << 17;
3594
3595 // Change column from NULL to NOT NULL
3597
3598 // Set or remove default column value
3599 static const HA_ALTER_FLAGS ALTER_COLUMN_DEFAULT = 1ULL << 19;
3600
3601 // Change column generation expression
3602 static const HA_ALTER_FLAGS ALTER_VIRTUAL_GCOL_EXPR = 1ULL << 20;
3603 static const HA_ALTER_FLAGS ALTER_STORED_GCOL_EXPR = 1ULL << 21;
3604
3605 // Add foreign key
3606 static const HA_ALTER_FLAGS ADD_FOREIGN_KEY = 1ULL << 22;
3607
3608 // Drop foreign key
3609 static const HA_ALTER_FLAGS DROP_FOREIGN_KEY = 1ULL << 23;
3610
3611 // table_options changed, see HA_CREATE_INFO::used_fields for details.
3612 static const HA_ALTER_FLAGS CHANGE_CREATE_OPTION = 1ULL << 24;
3613
3614 // Table is renamed
3615 static const HA_ALTER_FLAGS ALTER_RENAME = 1ULL << 25;
3616
3617 // Change the storage type of column
3619
3620 // Change the column format of column
3622
3623 // Add partition
3624 static const HA_ALTER_FLAGS ADD_PARTITION = 1ULL << 28;
3625
3626 // Drop partition
3627 static const HA_ALTER_FLAGS DROP_PARTITION = 1ULL << 29;
3628
3629 // Changing partition options
3630 static const HA_ALTER_FLAGS ALTER_PARTITION = 1ULL << 30;
3631
3632 // Coalesce partition
3633 static const HA_ALTER_FLAGS COALESCE_PARTITION = 1ULL << 31;
3634
3635 // Reorganize partition ... into
3636 static const HA_ALTER_FLAGS REORGANIZE_PARTITION = 1ULL << 32;
3637
3638 // Reorganize partition
3639 static const HA_ALTER_FLAGS ALTER_TABLE_REORG = 1ULL << 33;
3640
3641 // Remove partitioning
3643
3644 // Partition operation with ALL keyword
3645 static const HA_ALTER_FLAGS ALTER_ALL_PARTITION = 1ULL << 35;
3646
3647 /**
3648 Rename index. Note that we set this flag only if there are no other
3649 changes to the index being renamed. Also for simplicity we don't
3650 detect renaming of indexes which is done by dropping index and then
3651 re-creating index with identical definition under different name.
3652 */
3653 static const HA_ALTER_FLAGS RENAME_INDEX = 1ULL << 36;
3654
3655 /**
3656 Recreate the table for ALTER TABLE FORCE, ALTER TABLE ENGINE
3657 and OPTIMIZE TABLE operations.
3658 */
3659 static const HA_ALTER_FLAGS RECREATE_TABLE = 1ULL << 37;
3660
3661 // Add spatial index
3662 static const HA_ALTER_FLAGS ADD_SPATIAL_INDEX = 1ULL << 38;
3663
3664 // Alter index comment
3665 static const HA_ALTER_FLAGS ALTER_INDEX_COMMENT = 1ULL << 39;
3666
3667 // New/changed virtual generated column require validation
3668 static const HA_ALTER_FLAGS VALIDATE_VIRTUAL_COLUMN = 1ULL << 40;
3669
3670 /**
3671 Change index option in a way which is likely not to require index
3672 recreation. For example, change COMMENT or KEY::is_algorithm_explicit
3673 flag (without change of index algorithm itself).
3674 */
3675 static const HA_ALTER_FLAGS CHANGE_INDEX_OPTION = 1LL << 41;
3676
3677 // Rebuild partition
3678 static const HA_ALTER_FLAGS ALTER_REBUILD_PARTITION = 1ULL << 42;
3679
3680 /**
3681 Change in index length such that it does not require index rebuild.
3682 For example, change in index length due to column expansion like
3683 varchar(X) changed to varchar(X + N).
3684 */
3686
3687 /**
3688 Change to one of columns on which virtual generated column depends,
3689 so its values require re-evaluation.
3690 */
3691 static const HA_ALTER_FLAGS VIRTUAL_GCOL_REEVAL = 1ULL << 44;
3692
3693 /**
3694 Change to one of columns on which stored generated column depends,
3695 so its values require re-evaluation.
3696 */
3697 static const HA_ALTER_FLAGS STORED_GCOL_REEVAL = 1ULL << 45;
3698
3699 // Add check constraint.
3700 static const HA_ALTER_FLAGS ADD_CHECK_CONSTRAINT = 1ULL << 46;
3701
3702 // Drop check constraint.
3703 static const HA_ALTER_FLAGS DROP_CHECK_CONSTRAINT = 1ULL << 47;
3704
3705 // Suspend check constraint.
3706 static const HA_ALTER_FLAGS SUSPEND_CHECK_CONSTRAINT = 1ULL << 48;
3707
3708 // Alter column visibility.
3709 static const HA_ALTER_FLAGS ALTER_COLUMN_VISIBILITY = 1ULL << 49;
3710
3711 /**
3712 Create options (like MAX_ROWS) for the new version of table.
3713
3714 @note The referenced instance of HA_CREATE_INFO object was already
3715 used to create new .FRM file for table being altered. So it
3716 has been processed by mysql_prepare_create_table() already.
3717 For example, this means that it has HA_OPTION_PACK_RECORD
3718 flag in HA_CREATE_INFO::table_options member correctly set.
3719 */
3721
3722 /**
3723 Alter options, fields and keys for the new version of table.
3724
3725 @note The referenced instance of Alter_info object was already
3726 used to create new .FRM file for table being altered. So it
3727 has been processed by mysql_prepare_create_table() already.
3728 In particular, this means that in Create_field objects for
3729 fields which were present in some form in the old version
3730 of table, Create_field::field member points to corresponding
3731 Field instance for old version of table.
3732 */
3734
3735 /**
3736 Indicates whether operation should fail if table is non-empty.
3737 Storage engines should not suggest/allow execution of such operations
3738 using INSTANT algorithm since check whether table is empty done from
3739 SQL-layer is not "instant". Also SEs might choose different algorithm for
3740 ALTER TABLE execution knowing that it will be allowed to proceed only if
3741 table is empty.
3742
3743 Unlike for Alter_table_ctx::error_if_not_empty, we use bool for this flag
3744 and not bitmap, since SEs are really interested in the fact that ALTER
3745 will fail if table is not empty and not in exact reason behind this fact,
3746 and because we want to avoid extra dependency between Alter_table_ctx and
3747 Alter_inplace_info.
3748 */
3750
3751 /**
3752 Array of KEYs for new version of table - including KEYs to be added.
3753
3754 @note Currently this array is produced as result of
3755 mysql_prepare_create_table() call.
3756 This means that it follows different convention for
3757 KEY_PART_INFO::fieldnr values than objects in TABLE::key_info
3758 array.
3759
3760 @todo This is mainly due to the fact that we need to keep compatibility
3761 with removed handler::add_index() call. We plan to switch to
3762 TABLE::key_info numbering later.
3763
3764 KEYs are sorted - see sort_keys().
3765 */
3767
3768 /** Size of key_info_buffer array. */
3770
3771 /** Size of index_drop_buffer array. */
3773
3774 /**
3775 Array of pointers to KEYs to be dropped belonging to the TABLE instance
3776 for the old version of the table.
3777 */
3779
3780 /** Size of index_add_buffer array. */
3782
3783 /**
3784 Array of indexes into key_info_buffer for KEYs to be added,
3785 sorted in increasing order.
3786 */
3788
3789 /** Size of index_rename_buffer array. */
3791
3792 /** Size of index_rename_buffer array. */
3794
3795 /**
3796 Array of KEY_PAIR objects describing indexes being renamed.
3797 For each index renamed it contains object with KEY_PAIR::old_key
3798 pointing to KEY object belonging to the TABLE instance for old
3799 version of table representing old version of index and with
3800 KEY_PAIR::new_key pointing to KEY object for new version of
3801 index in key_info_buffer member.
3802 */
3805
3806 /** Number of virtual columns to be added. */
3808
3809 /** number of virtual columns to be dropped. */
3811
3812 /**
3813 Context information to allow handlers to keep context between in-place
3814 alter API calls.
3815
3816 @see inplace_alter_handler_ctx for information about object lifecycle.
3817 */
3819
3820 /**
3821 If the table uses several handlers, like ha_partition uses one handler
3822 per partition, this contains a Null terminated array of ctx pointers
3823 that should all be committed together.
3824 Or NULL if only handler_ctx should be committed.
3825 Set to NULL if the low level handler::commit_inplace_alter_table uses it,
3826 to signal to the main handler that everything was committed as atomically.
3827
3828 @see inplace_alter_handler_ctx for information about object lifecycle.
3829 */
3831
3832 /**
3833 Flags describing in detail which operations the storage engine is to
3834 execute.
3835 */
3837
3838 /**
3839 Partition_info taking into account the partition changes to be performed.
3840 Contains all partitions which are present in the old version of the table
3841 with partitions to be dropped or changed marked as such + all partitions
3842 to be added in the new version of table marked as such.
3843 */
3845
3846 /** true for online operation (LOCK=NONE) */
3848
3849 /**
3850 Can be set by handler along with handler_ctx. The difference is that
3851 this flag can be used to store SE-specific in-place ALTER context in cases
3852 when constructing full-blown inplace_alter_handler_ctx descendant is
3853 inconvenient.
3854 */
3856
3857 /**
3858 Can be set by handler to describe why a given operation cannot be done
3859 in-place (HA_ALTER_INPLACE_NOT_SUPPORTED) or why it cannot be done
3860 online (HA_ALTER_INPLACE_NO_LOCK or HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE)
3861 If set, it will be used with ER_ALTER_OPERATION_NOT_SUPPORTED_REASON if
3862 results from handler::check_if_supported_inplace_alter() doesn't match
3863 requirements set by user. If not set, the more generic
3864 ER_ALTER_OPERATION_NOT_SUPPORTED will be used.
3865
3866 Please set to a properly localized string, for example using
3867 my_get_err_msg(), so that the error message as a whole is localized.
3868 */
3870
3872 Alter_info *alter_info_arg, bool error_if_not_empty_arg,
3873 KEY *key_info_arg, uint key_count_arg,
3874 partition_info *modified_part_info_arg)
3875 : create_info(create_info_arg),
3876 alter_info(alter_info_arg),
3877 error_if_not_empty(error_if_not_empty_arg),
3878 key_info_buffer(key_info_arg),
3879 key_count(key_count_arg),
3882 index_add_count(0),
3891 handler_flags(0),
3892 modified_part_info(modified_part_info_arg),
3893 online(false),
3896
3898 if (handler_ctx != nullptr) ::destroy_at(handler_ctx);
3899 }
3900
3901 /**
3902 Used after check_if_supported_inplace_alter() to report
3903 error if the result does not match the LOCK/ALGORITHM
3904 requirements set by the user.
3905
3906 @param not_supported Part of statement that was not supported.
3907 @param try_instead Suggestion as to what the user should
3908 replace not_supported with.
3909 */
3910 void report_unsupported_error(const char *not_supported,
3911 const char *try_instead);
3912
3913 /** Add old and new version of key to array of indexes to be renamed. */
3914 void add_renamed_key(KEY *old_key, KEY *new_key) {
3916 key_pair->old_key = old_key;
3917 key_pair->new_key = new_key;
3918 DBUG_PRINT("info",
3919 ("index renamed: '%s' to '%s'", old_key->name, new_key->name));
3920 }
3921
3922 void add_altered_index_visibility(KEY *old_key, KEY *new_key) {
3923 KEY_PAIR *key_pair =
3925 key_pair->old_key = old_key;
3926 key_pair->new_key = new_key;
3927 DBUG_PRINT("info", ("index had visibility altered: %i to %i",
3928 old_key->is_visible, new_key->is_visible));
3929 }
3930
3931 /**
3932 Add old and new version of modified key to arrays of indexes to
3933 be dropped and added (correspondingly).
3934 */
3935 void add_modified_key(KEY *old_key, KEY *new_key) {
3937 index_add_buffer[index_add_count++] = (uint)(new_key - key_info_buffer);
3938 DBUG_PRINT("info", ("index changed: '%s'", old_key->name));
3939 }
3940
3941 /** Drop key to array of indexes to be dropped. */
3942 void add_dropped_key(KEY *old_key) {
3944 DBUG_PRINT("info", ("index dropped: '%s'", old_key->name));
3945 }
3946
3947 /** Add key to array of indexes to be added. */
3948 void add_added_key(KEY *new_key) {
3949 index_add_buffer[index_add_count++] = (uint)(new_key - key_info_buffer);
3950 DBUG_PRINT("info", ("index added: '%s'", new_key->name));
3951 }
3952};
3953
3955 uint flags{0}; /* isam layer flags (e.g. for myisamchk) */
3956 uint sql_flags{0}; /* sql layer flags - for something myisamchk cannot do */
3957 KEY_CACHE *key_cache; /* new key cache when changing key cache */
3958};
3959
3960/*
3961 This is a buffer area that the handler can use to store rows.
3962 'end_of_used_area' should be kept updated after calls to
3963 read-functions so that other parts of the code can use the
3964 remaining area (until next read calls is issued).
3965*/
3966
3968 uchar *buffer; /* Buffer one can start using */
3969 uchar *buffer_end; /* End of buffer */
3970 uchar *end_of_used_area; /* End of area that was used by handler */
3971};
3972
3973typedef void *range_seq_t;
3974
3976 /*
3977 Initialize the traversal of range sequence
3978
3979 SYNOPSIS
3980 init()
3981 init_params The seq_init_param parameter
3982 n_ranges The number of ranges obtained
3983 flags A combination of HA_MRR_SINGLE_POINT, HA_MRR_FIXED_KEY
3984
3985 RETURN
3986 An opaque value to be used as RANGE_SEQ_IF::next() parameter
3987 */
3988 range_seq_t (*init)(void *init_params, uint n_ranges, uint flags);
3989
3990 /*
3991 Get the next range in the range sequence
3992
3993 SYNOPSIS
3994 next()
3995 seq The value returned by RANGE_SEQ_IF::init()
3996 range OUT Information about the next range
3997
3998 RETURN
3999 0 - Ok, the range structure filled with info about the next range
4000 1 - No more ranges
4001 */
4003
4004 /*
4005 Check whether range_info orders to skip the next record
4006
4007 SYNOPSIS
4008 skip_record()
4009 seq The value returned by RANGE_SEQ_IF::init()
4010 range_info Information about the next range
4011 (Ignored if MRR_NO_ASSOCIATION is set)
4012 rowid Rowid of the record to be checked (ignored if set to 0)
4013
4014 RETURN
4015 1 - Record with this range_info and/or this rowid shall be filtered
4016 out from the stream of records returned by ha_multi_range_read_next()
4017 0 - The record shall be left in the stream
4018 */
4019 bool (*skip_record)(range_seq_t seq, char *range_info, uchar *rowid);
4020};
4021
4022/**
4023 Used to store optimizer cost estimates.
4024
4025 The class consists of PODs only: default operator=, copy constructor
4026 and destructor are used.
4027 */
4029 private:
4030 double io_cost; ///< cost of I/O operations
4031 double cpu_cost; ///< cost of CPU operations
4032 double import_cost; ///< cost of remote operations
4033 double mem_cost; ///< memory used (bytes)
4034
4035 public:
4037
4038 /// Returns sum of time-consuming costs, i.e., not counting memory cost
4039 double total_cost() const { return io_cost + cpu_cost + import_cost; }
4040 double get_io_cost() const { return io_cost; }
4041 double get_cpu_cost() const { return cpu_cost; }
4042 double get_import_cost() const { return import_cost; }
4043 double get_mem_cost() const { return mem_cost; }
4044
4045 /**
4046 Whether or not all costs in the object are zero
4047
4048 @return true if all costs are zero, false otherwise
4049 */
4050 bool is_zero() const {
4051 return !(io_cost || cpu_cost || import_cost || mem_cost);
4052 }
4053 /**
4054 Whether or not the total cost is the maximal double
4055
4056 @return true if total cost is the maximal double, false otherwise
4057 */
4058 bool is_max_cost() const { return io_cost == DBL_MAX; }
4059 /// Reset all costs to zero
4061 /// Set current cost to the maximal double
4063 reset();
4064 io_cost = DBL_MAX;
4065 }
4066
4067 /// Multiply io, cpu and import costs by parameter
4068 void multiply(double m) {
4069 assert(!is_max_cost());
4070
4071 io_cost *= m;
4072 cpu_cost *= m;
4073 import_cost *= m;
4074 /* Don't multiply mem_cost */
4075 }
4076
4078 assert(!is_max_cost() && !other.is_max_cost());
4079
4080 io_cost += other.io_cost;
4081 cpu_cost += other.cpu_cost;
4082 import_cost += other.import_cost;
4083 mem_cost += other.mem_cost;
4084
4085 return *this;
4086 }
4087
4089 Cost_estimate result = *this;
4090 result += other;
4091
4092 return result;
4093 }
4094
4097
4098 assert(!other.is_max_cost());
4099
4100 result.io_cost = io_cost - other.io_cost;
4101 result.cpu_cost = cpu_cost - other.cpu_cost;
4102 result.import_cost = import_cost - other.import_cost;
4103 result.mem_cost = mem_cost - other.mem_cost;
4104 return result;
4105 }
4106
4107 bool operator>(const Cost_estimate &other) const {
4108 return total_cost() > other.total_cost() ? true : false;
4109 }
4110
4111 bool operator<(const Cost_estimate &other) const {
4112 return other > *this ? true : false;
4113 }
4114
4115 /// Add to IO cost
4116 void add_io(double add_io_cost) {
4117 assert(!is_max_cost());
4118 io_cost += add_io_cost;
4119 }
4120
4121 /// Add to CPU cost
4122 void add_cpu(double add_cpu_cost) {
4123 assert(!is_max_cost());
4124 cpu_cost += add_cpu_cost;
4125 }
4126
4127 /// Add to import cost
4128 void add_import(double add_import_cost) {
4129 assert(!is_max_cost());
4130 import_cost += add_import_cost;
4131 }
4132
4133 /// Add to memory cost
4134 void add_mem(double add_mem_cost) {
4135 assert(!is_max_cost());
4136 mem_cost += add_mem_cost;
4137 }
4138};
4139
4141 Cost_estimate *cost);
4142
4143/*
4144 The below two are not used (and not handled) in this milestone of this WL
4145 entry because there seems to be no use for them at this stage of
4146 implementation.
4147*/
4148#define HA_MRR_SINGLE_POINT 1
4149#define HA_MRR_FIXED_KEY 2
4150
4151/*
4152 Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
4153 'range' parameter.
4154*/
4155#define HA_MRR_NO_ASSOCIATION 4
4156
4157/*
4158 The MRR user will provide ranges in key order, and MRR implementation
4159 must return rows in key order.
4160 Passing this flag to multi_read_range_init() may cause the
4161 default MRR handler to be used even if HA_MRR_USE_DEFAULT_IMPL
4162 was not specified.
4163 (If the native MRR impl. can not provide SORTED result)
4164*/
4165#define HA_MRR_SORTED 8
4166
4167/* MRR implementation doesn't have to retrieve full records */
4168#define HA_MRR_INDEX_ONLY 16
4169
4170/*
4171 The passed memory buffer is of maximum possible size, the caller can't
4172 assume larger buffer.
4173*/
4174#define HA_MRR_LIMITS 32
4175
4176/*
4177 Flag set <=> default MRR implementation is used
4178 (The choice is made by **_info[_const]() function which may set this
4179 flag. SQL layer remembers the flag value and then passes it to
4180 multi_read_range_init().
4181*/
4182#define HA_MRR_USE_DEFAULT_IMPL 64
4183
4184/*
4185 Used only as parameter to multi_range_read_info():
4186 Flag set <=> the caller guarantees that the bounds of the scanned ranges
4187 will not have NULL values.
4188*/
4189#define HA_MRR_NO_NULL_ENDPOINTS 128
4190
4191/*
4192 Set by the MRR implementation to signal that it will natively
4193 produced sorted result if multi_range_read_init() is called with
4194 the HA_MRR_SORTED flag - Else multi_range_read_init(HA_MRR_SORTED)
4195 will revert to use the default MRR implementation.
4196*/
4197#define HA_MRR_SUPPORT_SORTED 256
4198
4200 public:
4201 ulonglong data_file_length; /* Length off data file */
4202 ulonglong max_data_file_length; /* Length off data file */
4205 ulonglong delete_length; /* Free bytes */
4207 /*
4208 The number of records in the table.
4209 0 - means the table has exactly 0 rows
4210 other - if (table_flags() & HA_STATS_RECORDS_IS_EXACT)
4211 the value is the exact number of records in the table
4212 else
4213 it is an estimate
4214 */
4216 ha_rows deleted; /* Deleted records */
4217 ulong mean_rec_length; /* physical reclength */
4218 /* TODO: create_time should be retrieved from the new DD. Remove this. */
4219 time_t create_time; /* When table was created */
4222 uint block_size; /* index block size */
4223
4224 /*
4225 number of buffer bytes that native mrr implementation needs,
4226 */
4228
4229 /**
4230 Estimate for how much of the table that is available in a memory
4231 buffer. Valid range is [0..1]. If it has the special value
4232 IN_MEMORY_ESTIMATE_UNKNOWN (defined in structs.h), it means that
4233 the storage engine has not supplied any value for it.
4234 */
4236
4238 : data_file_length(0),
4241 delete_length(0),
4243 records(0),
4244 deleted(0),
4245 mean_rec_length(0),
4246 create_time(0),
4247 check_time(0),
4248 update_time(0),
4249 block_size(0),
4251};
4252
4254 public:
4256
4258};
4259
4260/**
4261 Calculates length of key.
4262
4263 Given a key index and a map of key parts return length of buffer used by key
4264 parts.
4265
4266 @param table Table containing the key
4267 @param key Key index
4268 @param keypart_map which key parts that is used
4269
4270 @return Length of used key parts.
4271*/
4272uint calculate_key_len(TABLE *table, uint key, key_part_map keypart_map);
4273/*
4274 bitmap with first N+1 bits set
4275 (keypart_map for a key prefix of [0..N] keyparts)
4276*/
4277#define make_keypart_map(N) (((key_part_map)2 << (N)) - 1)
4278/*
4279 bitmap with first N bits set
4280 (keypart_map for a key prefix of [0..N-1] keyparts)
4281*/
4282#define make_prev_keypart_map(N) (((key_part_map)1 << (N)) - 1)
4283
4284/** Base class to be used by handlers different shares */
4286 public:
4287 Handler_share() = default;
4288 virtual ~Handler_share() = default;
4289};
4290
4291/**
4292 Wrapper for struct ft_hints.
4293*/
4294
4296 private:
4298
4299 public:
4300 explicit Ft_hints(uint ft_flags) {
4301 hints.flags = ft_flags;
4303 hints.op_value = 0.0;
4305 }
4306
4307 /**
4308 Set comparison operation type and and value for master MATCH function.
4309
4310 @param type comparison operation type
4311 @param value comparison operation value
4312 */
4313 void set_hint_op(enum ft_operation type, double value) {
4314 hints.op_type = type;
4316 }
4317
4318 /**
4319 Set Ft_hints flag.
4320
4321 @param ft_flag Ft_hints flag
4322 */
4323 void set_hint_flag(uint ft_flag) { hints.flags |= ft_flag; }
4324
4325 /**
4326 Set Ft_hints limit.
4327
4328 @param ft_limit limit
4329 */
4330 void set_hint_limit(ha_rows ft_limit) { hints.limit = ft_limit; }
4331
4332 /**
4333 Get Ft_hints limit.
4334
4335 @return Ft_hints limit
4336 */
4337 ha_rows get_limit() const { return hints.limit; }
4338
4339 /**
4340 Get Ft_hints operation value.
4341
4342 @return operation value
4343 */
4344 double get_op_value() const { return hints.op_value; }
4345
4346 /**
4347 Get Ft_hints operation type.
4348
4349 @return operation type
4350 */
4351 enum ft_operation get_op_type() const { return hints.op_type; }
4352
4353 /**
4354 Get Ft_hints flags.
4355
4356 @return Ft_hints flags
4357 */
4358 uint get_flags() const { return hints.flags; }
4359
4360 /**
4361 Get ft_hints struct.
4362
4363 @return pointer to ft_hints struct
4364 */
4365 struct ft_hints *get_hints() { return &hints; }
4366};
4367
4368/**
4369 The handler class is the interface for dynamically loadable
4370 storage engines. Do not add ifdefs and take care when adding or
4371 changing virtual functions to avoid vtable confusion
4372
4373 Functions in this class accept and return table columns data. Two data
4374 representation formats are used:
4375 1. TableRecordFormat - Used to pass [partial] table records to/from
4376 storage engine
4377
4378 2. KeyTupleFormat - used to pass index search tuples (aka "keys") to
4379 storage engine. See opt_range.cc for description of this format.
4380
4381 TableRecordFormat
4382 =================
4383 [Warning: this description is work in progress and may be incomplete]
4384 The table record is stored in a fixed-size buffer:
4385
4386 record: null_bytes, column1_data, column2_data, ...
4387
4388 The offsets of the parts of the buffer are also fixed: every column has
4389 an offset to its column{i}_data, and if it is nullable it also has its own
4390 bit in null_bytes.
4391
4392 The record buffer only includes data about columns that are marked in the
4393 relevant column set (table->read_set and/or table->write_set, depending on
4394 the situation).
4395 <not-sure>It could be that it is required that null bits of non-present
4396 columns are set to 1</not-sure>
4397
4398 VARIOUS EXCEPTIONS AND SPECIAL CASES
4399
4400 If the table has no nullable columns, then null_bytes is still
4401 present, its length is one byte <not-sure> which must be set to 0xFF
4402 at all times. </not-sure>
4403
4404 If the table has columns of type BIT, then certain bits from those columns
4405 may be stored in null_bytes as well. Grep around for Field_bit for
4406 details.
4407
4408 For blob columns (see Field_blob), the record buffer stores length of the
4409 data, following by memory pointer to the blob data. The pointer is owned
4410 by the storage engine and is valid until the next operation.
4411
4412 If a blob column has NULL value, then its length and blob data pointer
4413 must be set to 0.
4414
4415
4416 Overview of main modules of the handler API
4417 ===========================================
4418 The overview below was copied from the storage/partition/ha_partition.h when
4419 support for non-native partitioning was removed.
4420
4421 -------------------------------------------------------------------------
4422 MODULE create/delete handler object
4423 -------------------------------------------------------------------------
4424 Object create/delete method. Normally called when a table object
4425 exists.
4426
4427 -------------------------------------------------------------------------
4428 MODULE meta data changes
4429 -------------------------------------------------------------------------
4430 Meta data routines to CREATE, DROP, RENAME table are often used at
4431 ALTER TABLE (update_create_info used from ALTER TABLE and SHOW ..).
4432
4433 Methods:
4434 delete_table()
4435 rename_table()
4436 create()
4437 update_create_info()
4438
4439 -------------------------------------------------------------------------
4440 MODULE open/close object
4441 -------------------------------------------------------------------------
4442 Open and close handler object to ensure all underlying files and
4443 objects allocated and deallocated for query handling is handled
4444 properly.
4445
4446 A handler object is opened as part of its initialisation and before
4447 being used for normal queries (not before meta-data changes always.
4448 If the object was opened it will also be closed before being deleted.
4449
4450 Methods:
4451 open()
4452 close()
4453
4454 -------------------------------------------------------------------------
4455 MODULE start/end statement
4456 -------------------------------------------------------------------------
4457 This module contains methods that are used to understand start/end of
4458 statements, transaction boundaries, and aid for proper concurrency
4459 control.
4460
4461 Methods:
4462 store_lock()
4463 external_lock()
4464 start_stmt()
4465 lock_count()
4466 unlock_row()
4467 was_semi_consistent_read()
4468 try_semi_consistent_read()
4469
4470 -------------------------------------------------------------------------
4471 MODULE change record
4472 -------------------------------------------------------------------------
4473 This part of the handler interface is used to change the records
4474 after INSERT, DELETE, UPDATE, REPLACE method calls but also other
4475 special meta-data operations as ALTER TABLE, LOAD DATA, TRUNCATE.
4476
4477 These methods are used for insert (write_row), update (update_row)
4478 and delete (delete_row). All methods to change data always work on
4479 one row at a time. update_row and delete_row also contains the old
4480 row.
4481 delete_all_rows will delete all rows in the table in one call as a
4482 special optimization for DELETE from table;
4483
4484 Bulk inserts are supported if all underlying handlers support it.
4485 start_bulk_insert and end_bulk_insert is called before and after a
4486 number of calls to write_row.
4487
4488 Methods:
4489 write_row()
4490 update_row()
4491 delete_row()
4492 delete_all_rows()
4493 start_bulk_insert()
4494 end_bulk_insert()
4495
4496 -------------------------------------------------------------------------
4497 MODULE full table scan
4498 -------------------------------------------------------------------------
4499 This module is used for the most basic access method for any table
4500 handler. This is to fetch all data through a full table scan. No
4501 indexes are needed to implement this part.
4502 It contains one method to start the scan (rnd_init) that can also be
4503 called multiple times (typical in a nested loop join). Then proceeding
4504 to the next record (rnd_next) and closing the scan (rnd_end).
4505 To remember a record for later access there is a method (position)
4506 and there is a method used to retrieve the record based on the stored
4507 position.
4508 The position can be a file position, a primary key, a ROWID dependent
4509 on the handler below.
4510
4511 All functions that retrieve records and are callable through the
4512 handler interface must indicate whether a record is present after the call
4513 or not. Record found is indicated by returning 0 and setting table status
4514 to "has row". Record not found is indicated by returning a non-zero value
4515 and setting table status to "no row".
4516 @see TABLE::set_found_row() and TABLE::set_no_row().
4517 By enforcing these rules in the handler interface, storage handler functions
4518 need not set any status in struct TABLE. These notes also apply to module
4519 index scan, documented below.
4520
4521 Methods:
4522
4523 rnd_init()
4524 rnd_end()
4525 rnd_next()
4526 rnd_pos()
4527 rnd_pos_by_record()
4528 position()
4529
4530 -------------------------------------------------------------------------
4531 MODULE index scan
4532 -------------------------------------------------------------------------
4533 This part of the handler interface is used to perform access through
4534 indexes. The interface is defined as a scan interface but the handler
4535 can also use key lookup if the index is a unique index or a primary
4536 key index.
4537 Index scans are mostly useful for SELECT queries but are an important
4538 part also of UPDATE, DELETE, REPLACE and CREATE TABLE table AS SELECT
4539 and so forth.
4540 Naturally an index is needed for an index scan and indexes can either
4541 be ordered, hash based. Some ordered indexes can return data in order
4542 but not necessarily all of them.
4543 There are many flags that define the behavior of indexes in the
4544 various handlers. These methods are found in the optimizer module.
4545
4546 index_read is called to start a scan of an index. The find_flag defines
4547 the semantics of the scan. These flags are defined in
4548 include/my_base.h
4549 index_read_idx is the same but also initializes index before calling doing
4550 the same thing as index_read. Thus it is similar to index_init followed
4551 by index_read. This is also how we implement it.
4552
4553 index_read/index_read_idx does also return the first row. Thus for
4554 key lookups, the index_read will be the only call to the handler in
4555 the index scan.
4556
4557 index_init initializes an index before using it and index_end does
4558 any end processing needed.
4559
4560 Methods:
4561 index_read_map()
4562 index_init()
4563 index_end()
4564 index_read_idx_map()
4565 index_next()
4566 index_prev()
4567 index_first()
4568 index_last()
4569 index_next_same()
4570 index_read_last_map()
4571 read_range_first()
4572 read_range_next()
4573
4574 -------------------------------------------------------------------------
4575 MODULE information calls
4576 -------------------------------------------------------------------------
4577 This calls are used to inform the handler of specifics of the ongoing
4578 scans and other actions. Most of these are used for optimisation
4579 purposes.
4580
4581 Methods:
4582 info()
4583 get_dynamic_partition_info
4584 extra()
4585 extra_opt()
4586 reset()
4587
4588 -------------------------------------------------------------------------
4589 MODULE optimizer support
4590 -------------------------------------------------------------------------
4591 NOTE:
4592 One important part of the public handler interface that is not depicted in
4593 the methods is the attribute records which is defined in the base class.
4594 This is looked upon directly and is set by calling info(HA_STATUS_INFO) ?
4595
4596 Methods:
4597 min_rows_for_estimate()
4598 get_biggest_used_partition()
4599 scan_time()
4600 read_time()
4601 records_in_range()
4602 estimate_rows_upper_bound()
4603 records()
4604
4605 -------------------------------------------------------------------------
4606 MODULE print messages
4607 -------------------------------------------------------------------------
4608 This module contains various methods that returns text messages for
4609 table types, index type and error messages.
4610
4611 Methods:
4612 table_type()
4613 get_row_type()
4614 print_error()
4615 get_error_message()
4616
4617 -------------------------------------------------------------------------
4618 MODULE handler characteristics
4619 -------------------------------------------------------------------------
4620 This module contains a number of methods defining limitations and
4621 characteristics of the handler (see also documentation regarding the
4622 individual flags).
4623
4624 Methods:
4625 table_flags()
4626 index_flags()
4627 min_of_the_max_uint()
4628 max_supported_record_length()
4629 max_supported_keys()
4630 max_supported_key_parts()
4631 max_supported_key_length()
4632 max_supported_key_part_length()
4633 low_byte_first()
4634 extra_rec_buf_length()
4635 min_record_length(uint options)
4636 primary_key_is_clustered()
4637 ha_key_alg get_default_index_algorithm()
4638 is_index_algorithm_supported()
4639
4640 -------------------------------------------------------------------------
4641 MODULE compare records
4642 -------------------------------------------------------------------------
4643 cmp_ref checks if two references are the same. For most handlers this is
4644 a simple memcmp of the reference. However some handlers use primary key
4645 as reference and this can be the same even if memcmp says they are
4646 different. This is due to character sets and end spaces and so forth.
4647
4648 Methods:
4649 cmp_ref()
4650
4651 -------------------------------------------------------------------------
4652 MODULE auto increment
4653 -------------------------------------------------------------------------
4654 This module is used to handle the support of auto increments.
4655
4656 This variable in the handler is used as part of the handler interface
4657 It is maintained by the parent handler object and should not be
4658 touched by child handler objects (see handler.cc for its use).
4659
4660 Methods:
4661 get_auto_increment()
4662 release_auto_increment()
4663
4664 -------------------------------------------------------------------------
4665 MODULE initialize handler for HANDLER call
4666 -------------------------------------------------------------------------
4667 This method is a special InnoDB method called before a HANDLER query.
4668
4669 Methods:
4670 init_table_handle_for_HANDLER()
4671
4672 -------------------------------------------------------------------------
4673 MODULE fulltext index
4674 -------------------------------------------------------------------------
4675 Fulltext index support.
4676
4677 Methods:
4678 ft_init_ext_with_hints()
4679 ft_init()
4680 ft_init_ext()
4681 ft_read()
4682
4683 -------------------------------------------------------------------------
4684 MODULE in-place ALTER TABLE
4685 -------------------------------------------------------------------------
4686 Methods for in-place ALTER TABLE support (implemented by InnoDB and NDB).
4687
4688 Methods:
4689 check_if_supported_inplace_alter()
4690 prepare_inplace_alter_table()
4691 inplace_alter_table()
4692 commit_inplace_alter_table()
4693 notify_table_changed()
4694
4695 -------------------------------------------------------------------------
4696 MODULE tablespace support
4697 -------------------------------------------------------------------------
4698 Methods:
4699 discard_or_import_tablespace()
4700
4701 -------------------------------------------------------------------------
4702 MODULE administrative DDL
4703 -------------------------------------------------------------------------
4704 Methods:
4705 optimize()
4706 analyze()
4707 check()
4708 repair()
4709 check_and_repair()
4710 auto_repair()
4711 is_crashed()
4712 check_for_upgrade()
4713 checksum()
4714 assign_to_keycache()
4715
4716 -------------------------------------------------------------------------
4717 MODULE enable/disable indexes
4718 -------------------------------------------------------------------------
4719 Enable/Disable Indexes are only supported by HEAP and MyISAM.
4720
4721 Methods:
4722 disable_indexes()
4723 enable_indexes()
4724 indexes_are_disabled()
4725
4726 -------------------------------------------------------------------------
4727 MODULE append_create_info
4728 -------------------------------------------------------------------------
4729 Only used by MyISAM MERGE tables.
4730
4731 Methods:
4732 append_create_info()
4733
4734 -------------------------------------------------------------------------
4735 MODULE partitioning specific handler API
4736 -------------------------------------------------------------------------
4737 Methods:
4738 get_partition_handler()
4739*/
4740
4741class handler {
4742 friend class Partition_handler;
4743
4744 public:
4746 using Blob_context = void *;
4747
4748 protected:
4749 TABLE_SHARE *table_share; /* The table definition */
4750 TABLE *table; /* The current open table */
4751 Table_flags cached_table_flags{0}; /* Set on init() and open() */
4752
4754
4755 public:
4756 handlerton *ht; /* storage engine of this handler */
4757 /** Pointer to current row */
4759 /** Pointer to duplicate row */
4761
4763
4764 /* MultiRangeRead-related members: */
4765 range_seq_t mrr_iter; /* Iterator to traverse the range sequence */
4766 RANGE_SEQ_IF mrr_funcs; /* Range sequence traversal functions */
4767 HANDLER_BUFFER *multi_range_buffer; /* MRR buffer info */
4768 uint ranges_in_seq; /* Total number of ranges in the traversed sequence */
4769 /* true <=> source MRR ranges and the output are ordered */
4771
4772 /* true <=> we're currently traversing a range in mrr_cur_range. */
4774 /* Current range (the one we're now returning rows from) */
4776
4777 /*
4778 The direction of the current range or index scan. This is used by
4779 the ICP implementation to determine if it has reached the end
4780 of the current range.
4781 */
4783
4784 private:
4785 Record_buffer *m_record_buffer = nullptr; ///< Buffer for multi-row reads.
4786 /*
4787 Storage space for the end range value. Should only be accessed using
4788 the end_range pointer. The content is invalid when end_range is NULL.
4789 */
4793
4794 /**
4795 Pointer to the handler of the table in the primary storage engine,
4796 if this handler represents a table in a secondary storage engine.
4797 */
4799
4800 protected:
4803 /*
4804 true <=> the engine guarantees that returned records are within the range
4805 being scanned.
4806 */
4808
4809 public:
4810 /**
4811 End value for a range scan. If this is NULL the range scan has no
4812 end value. Should also be NULL when there is no ongoing range scan.
4813 Used by the read_range() functions and also evaluated by pushed
4814 index conditions.
4815 */
4817 /**
4818 Flag which tells if #end_range contains a virtual generated column.
4819 The content is invalid when #end_range is @c nullptr.
4820 */
4822 uint errkey; /* Last dup key */
4825 /** Length of ref (1-8 or the clustered key length) */
4828 enum { NONE = 0, INDEX, RND, SAMPLING } inited;
4829 bool implicit_emptied; /* Can be !=0 only if HEAP */
4831
4833 uint pushed_idx_cond_keyno; /* The index which the above condition is for */
4834
4835 /**
4836 next_insert_id is the next value which should be inserted into the
4837 auto_increment column: in a inserting-multi-row statement (like INSERT
4838 SELECT), for the first row where the autoinc value is not specified by the
4839 statement, get_auto_increment() called and asked to generate a value,
4840 next_insert_id is set to the next value, then for all other rows
4841 next_insert_id is used (and increased each time) without calling
4842 get_auto_increment().
4843 */
4845 /**
4846 insert id for the current row (*autogenerated*; if not
4847 autogenerated, it's 0).
4848 At first successful insertion, this variable is stored into
4849 THD::first_successful_insert_id_in_cur_stmt.
4850 */
4852 /**
4853 Interval returned by get_auto_increment() and being consumed by the
4854 inserter.
4855 */
4857 /**
4858 Number of reserved auto-increment intervals. Serves as a heuristic
4859 when we have no estimation of how many records the statement will insert:
4860 the more intervals we have reserved, the bigger the next one. Reset in
4861 handler::ha_release_auto_increment().
4862 */
4864
4865 /**
4866 Instrumented table associated with this handler.
4867 */
4869
4870 std::mt19937 *m_random_number_engine{nullptr};
4872
4873 private:
4874 /** Internal state of the batch instrumentation. */
4876 /** Batch mode not used. */
4878 /** Batch mode used, before first table io. */
4880 /** Batch mode used, after first table io. */
4883 /**
4884 Batch mode state.
4885 @sa start_psi_batch_mode.
4886 @sa end_psi_batch_mode.
4887 */
4889 /**
4890 The number of rows in the batch.
4891 @sa start_psi_batch_mode.
4892 @sa end_psi_batch_mode.
4893 */
4895 /**
4896 The current event in a batch.
4897 @sa start_psi_batch_mode.
4898 @sa end_psi_batch_mode.
4899 */
4901 /**
4902 Storage for the event in a batch.
4903 @sa start_psi_batch_mode.
4904 @sa end_psi_batch_mode.
4905 */
4907
4908 public:
4909 void unbind_psi();
4910 void rebind_psi();
4911 /**
4912 Put the handler in 'batch' mode when collecting
4913 table io instrumented events.
4914 When operating in batch mode:
4915 - a single start event is generated in the performance schema.
4916 - all table io performed between @c start_psi_batch_mode
4917 and @c end_psi_batch_mode is not instrumented:
4918 the number of rows affected is counted instead in @c m_psi_numrows.
4919 - a single end event is generated in the performance schema
4920 when the batch mode ends with @c end_psi_batch_mode.
4921 */
4922 void start_psi_batch_mode();
4923 /** End a batch started with @c start_psi_batch_mode. */
4924 void end_psi_batch_mode();
4925 /**
4926 If a PSI batch was started, turn if off.
4927 @returns true if it was started.
4928 */
4930 const bool rc = m_psi_batch_mode;
4931 if (rc) end_psi_batch_mode();
4932 return rc;
4933 }
4934
4935 private:
4936 /**
4937 The lock type set by when calling::ha_external_lock(). This is
4938 propagated down to the storage engine. The reason for also storing
4939 it here, is that when doing MRR we need to create/clone a second handler
4940 object. This cloned handler object needs to know about the lock_type used.
4941 */
4943 /**
4944 Pointer where to store/retrieve the Handler_share pointer.
4945 For non partitioned handlers this is &TABLE_SHARE::ha_share.
4946 */
4948
4949 /**
4950 Some non-virtual ha_* functions, responsible for reading rows,
4951 like ha_rnd_pos(), must ensure that virtual generated columns are
4952 calculated before they return. For that, they should set this
4953 member to true at their start, and check it before they return: if
4954 the member is still true, it means they should calculate; if it's
4955 false, it means the calculation has been done by some called
4956 lower-level function and does not need to be re-done (which is why
4957 we need this status flag: to avoid redundant calculations, for
4958 performance).
4959
4960 Note that when updating generated fields, the NULL row status in
4961 the underlying TABLE objects matter, so be sure to reset them if needed!
4962 */
4964
4965 /* Filter row ids to weed out duplicates when multi-valued index is used */
4967
4968 public:
4969 handler(handlerton *ht_arg, TABLE_SHARE *share_arg)
4970 : table_share(share_arg),
4971 table(nullptr),
4973 ht(ht_arg),
4974 ref(nullptr),
4980 ref_length(sizeof(my_off_t)),
4982 inited(NONE),
4983 implicit_emptied(false),
4987 next_insert_id(0),
4990 m_psi(nullptr),
4992 m_psi_numrows(0),
4994 m_lock_type(F_UNLCK),
4997 m_unique(nullptr) {
4998 DBUG_PRINT("info", ("handler created F_UNLCK %d F_RDLCK %d F_WRLCK %d",
4999 F_UNLCK, F_RDLCK, F_WRLCK));
5000 }
5001
5002 virtual ~handler(void) {
5003 assert(m_psi == nullptr);
5005 assert(m_psi_locker == nullptr);
5006 assert(m_lock_type == F_UNLCK);
5007 assert(inited == NONE);
5008 }
5009
5010 /**
5011 Return extra handler specific text for EXPLAIN.
5012 */
5013 virtual std::string explain_extra() const { return ""; }
5014
5015 /*
5016 @todo reorganize functions, make proper public/protected/private qualifiers
5017 */
5018 virtual handler *clone(const char *name, MEM_ROOT *mem_root);
5019 /** This is called after create to allow us to set up cached variables */
5021 /* ha_ methods: public wrappers for private virtual API */
5022
5023 /**
5024 Set a record buffer that the storage engine can use for multi-row reads.
5025 The buffer has to be provided prior to the first read from an index or a
5026 table.
5027
5028 @param buffer the buffer to use for multi-row reads
5029 */
5031
5032 /**
5033 Get the record buffer that was set with ha_set_record_buffer().
5034
5035 @return the buffer to use for multi-row reads, or nullptr if there is none
5036 */
5038
5039 /**
5040 Does this handler want to get a Record_buffer for multi-row reads
5041 via the ha_set_record_buffer() function? And if so, what is the
5042 maximum number of records to allocate space for in the buffer?
5043
5044 Storage engines that support using a Record_buffer should override
5045 handler::is_record_buffer_wanted().
5046
5047 @param[out] max_rows gets set to the maximum number of records to
5048 allocate space for in the buffer if the function
5049 returns true
5050
5051 @retval true if the handler would like a Record_buffer
5052 @retval false if the handler does not want a Record_buffer
5053 */
5054 bool ha_is_record_buffer_wanted(ha_rows *const max_rows) const {
5055 return is_record_buffer_wanted(max_rows);
5056 }
5057
5058 int ha_open(TABLE *table, const char *name, int mode, int test_if_locked,
5059 const dd::Table *table_def);
5060 int ha_close(void);
5061 int ha_index_init(uint idx, bool sorted);
5062 int ha_index_end();
5063 int ha_rnd_init(bool scan);
5064 int ha_rnd_end();
5065 int ha_rnd_next(uchar *buf);
5066 // See the comment on m_update_generated_read_fields.
5067 int ha_rnd_pos(uchar *buf, uchar *pos);
5068 int ha_index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map,
5069 enum ha_rkey_function find_flag);
5071 key_part_map keypart_map);
5072 int ha_index_read_idx_map(uchar *buf, uint index, const uchar *key,
5073 key_part_map keypart_map,
5074 enum ha_rkey_function find_flag);
5075 int ha_index_next(uchar *buf);
5076 int ha_index_prev(uchar *buf);
5077 int ha_index_first(uchar *buf);
5078 int ha_index_last(uchar *buf);
5079 int ha_index_next_same(uchar *buf, const uchar *key, uint keylen);
5080 int ha_reset();
5081 /* this is necessary in many places, e.g. in HANDLER command */
5083 return inited == INDEX ? ha_index_end() : inited == RND ? ha_rnd_end() : 0;
5084 }
5085 /**
5086 The cached_table_flags is set at ha_open and ha_external_lock
5087 */
5089 /**
5090 These functions represent the public interface to *users* of the
5091 handler class, hence they are *not* virtual. For the inheritance
5092 interface, see the (private) functions write_row(), update_row(),
5093 and delete_row() below.
5094 */
5095 int ha_external_lock(THD *thd, int lock_type);
5096 int ha_write_row(uchar *buf);
5097 /**
5098 Update the current row.
5099
5100 @param old_data the old contents of the row
5101 @param new_data the new contents of the row
5102 @return error status (zero on success, HA_ERR_* error code on error)
5103 */
5104 int ha_update_row(const uchar *old_data, uchar *new_data);
5105 int ha_delete_row(const uchar *buf);
5107
5108 int ha_check_for_upgrade(HA_CHECK_OPT *check_opt);
5109 /** to be actually called to get 'check()' functionality*/
5110 int ha_check(THD *thd, HA_CHECK_OPT *check_opt);
5111 int ha_repair(THD *thd, HA_CHECK_OPT *check_opt);
5112 void ha_start_bulk_insert(ha_rows rows);
5113 int ha_end_bulk_insert();
5114 int ha_bulk_update_row(const uchar *old_data, uchar *new_data,
5115 uint *dup_key_found);
5116 int ha_delete_all_rows();
5118 int ha_optimize(THD *thd, HA_CHECK_OPT *check_opt);
5119 int ha_analyze(THD *thd, HA_CHECK_OPT *check_opt);
5120 bool ha_check_and_repair(THD *thd);
5121 int ha_disable_indexes(uint mode);
5122 int ha_enable_indexes(uint mode);
5124 int ha_rename_table(const char *from, const char *to,
5125 const dd::Table *from_table_def, dd::Table *to_table_def);
5126 int ha_delete_table(const char *name, const dd::Table *table_def);
5127 void ha_drop_table(const char *name);
5128
5129 int ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info,
5131
5132 int ha_load_table(const TABLE &table, bool *skip_metadata_update);
5133
5134 int ha_unload_table(const char *db_name, const char *table_name,
5135 bool error_if_not_loaded);
5136
5137 /**
5138 Initializes a parallel scan. It creates a parallel_scan_ctx that has to
5139 be used across all parallel_scan methods. Also, gets the number of
5140 threads that would be spawned for parallel scan.
5141 @param[out] scan_ctx The parallel scan context.
5142 @param[out] num_threads Number of threads used for the scan.
5143 @param[in] use_reserved_threads true if reserved threads are to be used
5144 if we exhaust the max cap of number of
5145 parallel read threads that can be
5146 spawned at a time
5147 @param[in] max_desired_threads Maximum number of desired scan threads;
5148 passing 0 has no effect, it is ignored.
5149 @return error code
5150 @retval 0 on success
5151 */
5152 virtual int parallel_scan_init(void *&scan_ctx [[maybe_unused]],
5153 size_t *num_threads [[maybe_unused]],
5154 bool use_reserved_threads [[maybe_unused]],
5155 size_t max_desired_threads [[maybe_unused]]) {
5156 return 0;
5157 }
5158
5159 /**
5160 This callback is called by each parallel load thread at the beginning of
5161 the parallel load for the adapter scan.
5162 @param cookie The cookie for this thread
5163 @param ncols Number of columns in each row
5164 @param row_len The size of a row in bytes
5165 @param col_offsets An array of size ncols, where each element represents
5166 the offset of a column in the row data. The memory of
5167 this array belongs to the caller and will be free-ed
5168 after the pload_end_cbk call.
5169 @param null_byte_offsets An array of size ncols, where each element
5170 represents the offset of a column in the row data. The
5171 memory of this array belongs to the caller and will be
5172 free-ed after the pload_end_cbk call.
5173 @param null_bitmasks An array of size ncols, where each element
5174 represents the bitmask required to get the null bit. The
5175 memory of this array belongs to the caller and will be
5176 free-ed after the pload_end_cbk call.
5177 */
5178 using Load_init_cbk = std::function<bool(
5179 void *cookie, ulong ncols, ulong row_len, const ulong *col_offsets,
5180 const ulong *null_byte_offsets, const ulong *null_bitmasks)>;
5181
5182 /**
5183 This callback is called by each parallel load thread when processing
5184 of rows is required for the adapter scan.
5185 @param[in] cookie The cookie for this thread
5186 @param[in] nrows The nrows that are available
5187 @param[in] rowdata The mysql-in-memory row data buffer. This is a
5188 memory buffer for nrows records. The length of each record is fixed and
5189 communicated via Load_init_cbk
5190 @param[in] partition_id Partition id if it's a partitioned table, else
5191 std::numeric_limits<uint64_t>::max()
5192 @returns true if there is an error, false otherwise.
5193 */
5194 using Load_cbk = std::function<bool(void *cookie, uint nrows, void *rowdata,
5195 uint64_t partition_id)>;
5196
5197 /**
5198 This callback is called by each parallel load thread when processing
5199 of rows has ended for the adapter scan.
5200 @param[in] cookie The cookie for this thread
5201 */
5202 using Load_end_cbk = std::function<void(void *cookie)>;
5203
5204 /**
5205 Run the parallel read of data.
5206 @param[in] scan_ctx Scan context of the parallel read.
5207 @param[in,out] thread_ctxs Caller thread contexts.
5208 @param[in] init_fn Callback called by each parallel load
5209 thread at the beginning of the parallel load.
5210 @param[in] load_fn Callback called by each parallel load
5211 thread when processing of rows is required.
5212 @param[in] end_fn Callback called by each parallel load
5213 thread when processing of rows has ended.
5214 @return error code
5215 @retval 0 on success
5216 */
5217 virtual int parallel_scan(void *scan_ctx [[maybe_unused]],
5218 void **thread_ctxs [[maybe_unused]],
5219 Load_init_cbk init_fn [[maybe_unused]],
5220 Load_cbk load_fn [[maybe_unused]],
5221 Load_end_cbk end_fn [[maybe_unused]]) {
5222 return 0;
5223 }
5224
5225 /**
5226 End of the parallel scan.
5227 @param[in] scan_ctx A scan context created by parallel_scan_init.
5228 */
5229 virtual void parallel_scan_end(void *scan_ctx [[maybe_unused]]) { return; }
5230
5231 /** Check if the table is ready for bulk load
5232 @param[in] thd user session
5233 @return true iff bulk load can be done on the table. */
5234 virtual bool bulk_load_check(THD *thd [[maybe_unused]]) const {
5235 return false;
5236 }
5237
5238 /** Get the total memory available for bulk load in SE.
5239 @param[in] thd user session
5240 @return available memory for bulk load */
5241 virtual size_t bulk_load_available_memory(THD *thd [[maybe_unused]]) const {
5242 return 0;
5243 }
5244
5245 /** Begin parallel bulk data load to the table.
5246 @param[in] thd user session
5247 @param[in] data_size total data size to load
5248 @param[in] memory memory to be used by SE
5249 @param[in] num_threads number of concurrent threads used for load.
5250 @return bulk load context or nullptr if unsuccessful. */
5251 virtual void *bulk_load_begin(THD *thd [[maybe_unused]],
5252 size_t keynr [[maybe_unused]],
5253 size_t data_size [[maybe_unused]],
5254 size_t memory [[maybe_unused]],
5255 size_t num_threads [[maybe_unused]]) {
5256 return nullptr;
5257 }
5258
5259 /** Execute bulk load operation. To be called by each of the concurrent
5260 threads idenified by thread index.
5261 @param[in,out] thd user session
5262 @param[in,out] load_ctx load execution context
5263 @param[in] thread_idx index of the thread executing
5264 @param[in] rows rows to be loaded to the table
5265 @return error code. */
5266 virtual int bulk_load_execute(THD *thd [[maybe_unused]],
5267 void *load_ctx [[maybe_unused]],
5268 size_t thread_idx [[maybe_unused]],
5269 const Rows_mysql &rows [[maybe_unused]],
5271 [[maybe_unused]]) {
5272 return HA_ERR_UNSUPPORTED;
5273 }
5274
5275 /** Open a blob for write operation.
5276 @param[in,out] thd user session
5277 @param[in,out] load_ctx load execution context
5278 @param[in] thread_idx index of the thread executing
5279 @param[out] blob_ctx a blob context
5280 @param[out] blobref a blob reference to be placed in the record.
5281 @return 0 on success, error code on failure */
5282 virtual int open_blob(THD *thd [[maybe_unused]],
5283 void *load_ctx [[maybe_unused]],
5284 size_t thread_idx [[maybe_unused]],
5285 Blob_context &blob_ctx [[maybe_unused]],
5286 unsigned char *blobref [[maybe_unused]]) {
5287 return HA_ERR_UNSUPPORTED;
5288 }
5289
5290 /** Write to a blob
5291 @param[in,out] thd user session
5292 @param[in,out] load_ctx load execution context
5293 @param[in] thread_idx index of the thread executing
5294 @param[in] blob_ctx a blob context
5295 @param[in] data data to be written to blob.
5296 @param[in] data_len length of data to be written in bytes.
5297 @return 0 on success, error code on failure */
5298 virtual int write_blob(THD *thd [[maybe_unused]],
5299 void *load_ctx [[maybe_unused]],
5300 size_t thread_idx [[maybe_unused]],
5301 Blob_context blob_ctx [[maybe_unused]],
5302 unsigned char *blobref [[maybe_unused]],
5303 const unsigned char *data [[maybe_unused]],
5304 size_t data_len [[maybe_unused]]) {
5305 return HA_ERR_UNSUPPORTED;
5306 }
5307
5308 /** Close the blob
5309 @param[in,out] thd user session
5310 @param[in,out] load_ctx load execution context
5311 @param[in] thread_idx index of the thread executing
5312 @param[in] blob_ctx a blob context
5313 @return 0 on success, error code on failure */
5314 virtual int close_blob(THD *thd [[maybe_unused]],
5315 void *load_ctx [[maybe_unused]],
5316 size_t thread_idx [[maybe_unused]],
5317 Blob_context blob_ctx [[maybe_unused]],
5318 unsigned char *blobref [[maybe_unused]]) {
5319 return HA_ERR_UNSUPPORTED;
5320 }
5321
5322 /** End bulk load operation. Must be called after all execution threads have
5323 completed. Must be called even if the bulk load execution failed.
5324 @param[in,out] thd user session
5325 @param[in,out] load_ctx load execution context
5326 @param[in] is_error true, if bulk load execution have failed
5327 @return error code. */
5328 virtual int bulk_load_end(THD *thd [[maybe_unused]],
5329 void *load_ctx [[maybe_unused]],
5330 bool is_error [[maybe_unused]]) {
5331 return false;
5332 }
5333
5334 /**
5335 Submit a dd::Table object representing a core DD table having
5336 hardcoded data to be filled in by the DDSE. This function can be
5337 used for retrieving the hard coded SE private data for the
5338 mysql.dd_properties table, before creating or opening it, or for
5339 retrieving the hard coded SE private data for a core table,
5340 before creating or opening them.
5341
5342 @param dd_table [in,out] A dd::Table object representing
5343 a core DD table.
5344 @param reset Reset counters.
5345
5346 @retval true An error occurred.
5347 @retval false Success - no errors.
5348 */
5349
5350 bool ha_get_se_private_data(dd::Table *dd_table, bool reset);
5351
5354 virtual void print_error(int error, myf errflag);
5355 virtual bool get_error_message(int error, String *buf);
5356 uint get_dup_key(int error);
5357 /**
5358 Retrieves the names of the table and the key for which there was a
5359 duplicate entry in the case of HA_ERR_FOREIGN_DUPLICATE_KEY.
5360
5361 If any of the table or key name is not available this method will return
5362 false and will not change any of child_table_name or child_key_name.
5363
5364 @param [out] child_table_name Table name
5365 @param [in] child_table_name_len Table name buffer size
5366 @param [out] child_key_name Key name
5367 @param [in] child_key_name_len Key name buffer size
5368
5369 @retval true table and key names were available
5370 and were written into the corresponding
5371 out parameters.
5372 @retval false table and key names were not available,
5373 the out parameters were not touched.
5374 */
5375 virtual bool get_foreign_dup_key(char *child_table_name,
5376 uint child_table_name_len,
5377 char *child_key_name,
5378 uint child_key_name_len);
5379 /**
5380 Change the internal TABLE_SHARE pointer.
5381
5382 @param table_arg TABLE object
5383 @param share New share to use
5384
5385 @note Is used in error handling in ha_delete_table.
5386 */
5387
5388 virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) {
5389 table = table_arg;
5391 }
5392 const TABLE_SHARE *get_table_share() const { return table_share; }
5393 const TABLE *get_table() const { return table; }
5394
5395 /* Estimates calculation */
5396
5397 /**
5398 @deprecated This function is deprecated and will be removed in a future
5399 version. Use table_scan_cost() instead.
5400 */
5401
5402 virtual double scan_time() {
5403 return ulonglong2double(stats.data_file_length) / IO_SIZE + 2;
5404 }
5405
5406 /**
5407 The cost of reading a set of ranges from the table using an index
5408 to access it.
5409
5410 @deprecated This function is deprecated and will be removed in a future
5411 version. Use read_cost() instead.
5412
5413 @param index The index number.
5414 @param ranges The number of ranges to be read.
5415 @param rows Total number of rows to be read.
5416
5417 This method can be used to calculate the total cost of scanning a table
5418 using an index by calling it using read_time(index, 1, table_size).
5419 */
5420
5421 virtual double read_time(uint index [[maybe_unused]], uint ranges,
5422 ha_rows rows) {
5423 return rows2double(ranges + rows);
5424 }
5425
5426 /**
5427 @deprecated This function is deprecated and will be removed in a future
5428 version. Use index_scan_cost() instead.
5429 */
5430
5431 virtual double index_only_read_time(uint keynr, double records);
5432
5433 /**
5434 Cost estimate for doing a complete table scan.
5435
5436 @note For this version it is recommended that storage engines continue
5437 to override scan_time() instead of this function.
5438
5439 @returns the estimated cost
5440 */
5441
5443
5444 /**
5445 Cost estimate for reading a number of ranges from an index.
5446
5447 The cost estimate will only include the cost of reading data that
5448 is contained in the index. If the records need to be read, use
5449 read_cost() instead.
5450
5451 @note The ranges parameter is currently ignored and is not taken
5452 into account in the cost estimate.
5453
5454 @note For this version it is recommended that storage engines continue
5455 to override index_only_read_time() instead of this function.
5456
5457 @param index the index number
5458 @param ranges the number of ranges to be read
5459 @param rows total number of rows to be read
5460
5461 @returns the estimated cost
5462 */
5463
5464 virtual Cost_estimate index_scan_cost(uint index, double ranges, double rows);
5465
5466 /**
5467 Cost estimate for reading a set of ranges from the table using an index
5468 to access it.
5469
5470 @note For this version it is recommended that storage engines continue
5471 to override read_time() instead of this function.
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 @returns the estimated cost
5478 */
5479
5480 virtual Cost_estimate read_cost(uint index, double ranges, double rows);
5481
5482 /**
5483 Cost estimate for doing a number of non-sequentially accesses
5484 against the storage engine. Such accesses can be either number
5485 of rows to read, or number of disk pages to access.
5486 Each handler implementation is free to interpret that as best
5487 suited, depending on what is the dominating cost for that
5488 storage engine.
5489
5490 This method is mainly provided as a temporary workaround for
5491 bug#33317872, where we fix problems caused by calling
5492 Cost_model::page_read_cost() directly from the optimizer.
5493 That should be avoided, as it introduced assumption about all
5494 storage engines being disk-page based, and having a 'page' cost.
5495 Furthermore, this page cost was even compared against read_cost(),
5496 which was computed with an entirely different algorithm, and thus
5497 could not be compared.
5498
5499 The default implementation still call Cost_model::page_read_cost(),
5500 thus behaving just as before. However, handler implementation may
5501 override it to call handler::read_cost() instead(), which probably
5502 will be more correct. (If a page_read_cost should be included
5503 in the cost estimate, that should preferable be done inside
5504 each read_cost() implementation)
5505
5506 Longer term we should consider to remove all page_read_cost()
5507 usage from the optimizer itself, making this method obsolete.
5508
5509 @param index the index number
5510 @param reads the number of accesses being made
5511
5512 @returns the estimated cost
5513 */
5514 virtual double page_read_cost(uint index, double reads);
5515
5516 /**
5517 Provide an upper cost-limit of doing a specified number of
5518 seek-and-read key lookups. This need to be comparable and
5519 calculated with the same 'metric' as page_read_cost.
5520
5521 @param reads the number of rows read in the 'worst' case.
5522
5523 @returns the estimated cost
5524 */
5525 virtual double worst_seek_times(double reads);
5526
5527 /**
5528 Return an estimate on the amount of memory the storage engine will
5529 use for caching data in memory. If this is unknown or the storage
5530 engine does not cache data in memory -1 is returned.
5531 */
5532 virtual longlong get_memory_buffer_size() const { return -1; }
5533
5534 /**
5535 Return an estimate of how much of the table that is currently stored
5536 in main memory.
5537
5538 This estimate should be the fraction of the table that currently
5539 is available in a main memory buffer. The estimate should be in the
5540 range from 0.0 (nothing in memory) to 1.0 (entire table in memory).
5541
5542 @return The fraction of the table in main memory buffer
5543 */
5544
5545 double table_in_memory_estimate() const;
5546
5547 /**
5548 Return an estimate of how much of the index that is currently stored
5549 in main memory.
5550
5551 This estimate should be the fraction of the index that currently
5552 is available in a main memory buffer. The estimate should be in the
5553 range from 0.0 (nothing in memory) to 1.0 (entire index in memory).
5554
5555 @param keyno the index to get an estimate for
5556
5557 @return The fraction of the index in main memory buffer
5558 */
5559
5560 double index_in_memory_estimate(uint keyno) const;
5561
5562 /**
5563 Initialize sampling.
5564
5565 @param[out] scan_ctx A scan context created by this method that has to be
5566 used in sample_next
5567 @param[in] sampling_percentage percentage of records that need to be
5568 sampled
5569 @param[in] sampling_seed random seed that the random generator will
5570 use
5571 @param[in] sampling_method sampling method to be used; currently only
5572 SYSTEM sampling is supported
5573 @param[in] tablesample true if the sampling is for tablesample
5574
5575 @return 0 for success, else one of the HA_xxx values in case of error.
5576 */
5577 int ha_sample_init(void *&scan_ctx, double sampling_percentage,
5578 int sampling_seed, enum_sampling_method sampling_method,
5579 const bool tablesample);
5580
5581 /**
5582 Get the next record for sampling.
5583
5584 @param[in] scan_ctx Scan context of the sampling
5585 @param[in] buf buffer to place the read record
5586
5587 @return 0 for success, else one of the HA_xxx values in case of error.
5588 */
5589 int ha_sample_next(void *scan_ctx, uchar *buf);
5590
5591 /**
5592 End sampling.
5593
5594 @param[in] scan_ctx Scan context of the sampling
5595
5596 @return 0 for success, else one of the HA_xxx values in case of error.
5597 */
5598 int ha_sample_end(void *scan_ctx);
5599
5600 private:
5602
5603 /**
5604 Make a guesstimate for how much of a table or index is in a memory
5605 buffer in the case where the storage engine has not provided any
5606 estimate for this.
5607
5608 @param table_index_size size of the table or index
5609
5610 @return The fraction of the table or index in main memory buffer
5611 */
5612
5613 double estimate_in_memory_buffer(ulonglong table_index_size) const;
5614
5615 public:
5617 uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges,
5618 uint *bufsz, uint *flags, bool *force_default_mrr, Cost_estimate *cost);
5619 virtual ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
5620 uint *bufsz, uint *flags,
5621 Cost_estimate *cost);
5622 virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
5623 uint n_ranges, uint mode,
5625
5626 int ha_multi_range_read_next(char **range_info);
5627
5628 int ha_read_range_first(const key_range *start_key, const key_range *end_key,
5629 bool eq_range, bool sorted);
5630 int ha_read_range_next();
5631
5633 return (ha_table_flags() & HA_NO_TRANSACTIONS) == 0;
5634 }
5635 virtual uint extra_rec_buf_length() const { return 0; }
5636
5637 /**
5638 @brief Determine whether an error can be ignored or not.
5639
5640 @details This method is used to analyze the error to see whether the
5641 error is ignorable or not. Such errors will be reported as warnings
5642 instead of errors for IGNORE statements. This means that the statement
5643 will not abort, but instead continue to the next row.
5644
5645 HA_ERR_FOUND_DUP_UNIQUE is a special case in MyISAM that means the
5646 same thing as HA_ERR_FOUND_DUP_KEY, but can in some cases lead to
5647 a slightly different error message.
5648
5649 @param error error code received from the handler interface (HA_ERR_...)
5650
5651 @return whether the error is ignorable or not
5652 @retval true the error is ignorable
5653 @retval false the error is not ignorable
5654 */
5655
5656 virtual bool is_ignorable_error(int error);
5657
5658 /**
5659 @brief Determine whether an error is fatal or not.
5660
5661 @details This method is used to analyze the error to see whether the
5662 error is fatal or not. A fatal error is an error that will not be
5663 possible to handle with SP handlers and will not be subject to
5664 retry attempts on the slave.
5665
5666 @param error error code received from the handler interface (HA_ERR_...)
5667
5668 @return whether the error is fatal or not
5669 @retval true the error is fatal
5670 @retval false the error is not fatal
5671 */
5672
5673 virtual bool is_fatal_error(int error);
5674
5675 protected:
5676 virtual int multi_range_read_next(char **range_info);
5677
5678 /**
5679 Number of rows in table. If HA_COUNT_ROWS_INSTANT is set, count is
5680 available instantly. Else do a table scan.
5681
5682 @param num_rows [out] num_rows number of rows in table.
5683
5684 @retval 0 for OK, one of the HA_xxx values in case of error.
5685 */
5686 virtual int records(ha_rows *num_rows);
5687
5688 /**
5689 Number of rows in table counted using the secondary index chosen by
5690 optimizer. See comments in optimize_aggregated_query() .
5691
5692 @param num_rows [out] Number of rows in table.
5693 @param index Index chosen by optimizer for counting.
5694
5695 @retval 0 for OK, one of the HA_xxx values in case of error.
5696 */
5697 virtual int records_from_index(ha_rows *num_rows, uint index);
5698
5699 private:
5700 /**
5701 Function will handle the error code from call to records() and
5702 records_from_index().
5703
5704 @param error return code from records() and records_from_index().
5705 @param num_rows Check if it contains HA_POS_ERROR in case error < 0.
5706
5707 @retval 0 for OK, one of the HA_xxx values in case of error.
5708 */
5709 int handle_records_error(int error, ha_rows *num_rows);
5710
5711 public:
5712 /**
5713 Wrapper function to call records() in storage engine.
5714
5715 @param num_rows [out] Number of rows in table.
5716
5717 @retval 0 for OK, one of the HA_xxx values in case of error.
5718 */
5719 int ha_records(ha_rows *num_rows) {
5720 return handle_records_error(records(num_rows), num_rows);
5721 }
5722
5723 /**
5724 Wrapper function to call records_from_index() in storage engine.
5725
5726 @param num_rows [out] Number of rows in table.
5727 @param index Index chosen by optimizer for counting.
5728
5729 @retval 0 for OK, one of the HA_xxx values in case of error.
5730 */
5731 int ha_records(ha_rows *num_rows, uint index) {
5732 return handle_records_error(records_from_index(num_rows, index), num_rows);
5733 }
5734
5735 /**
5736 Return upper bound of current number of records in the table
5737 (max. of how many records one will retrieve when doing a full table scan)
5738 If upper bound is not known, HA_POS_ERROR should be returned as a max
5739 possible upper bound.
5740 */
5742 return stats.records + EXTRA_RECORDS;
5743 }
5744
5745 /**
5746 Get real row type for the table created based on one specified by user,
5747 CREATE TABLE options and SE capabilities.
5748 */
5750 const HA_CREATE_INFO *create_info) const {
5751 return (create_info->table_options & HA_OPTION_COMPRESS_RECORD)
5753 : ((create_info->table_options & HA_OPTION_PACK_RECORD)
5755 : ROW_TYPE_FIXED);
5756 }
5757
5758 /**
5759 Get default key algorithm for SE. It is used when user has not provided
5760 algorithm explicitly or when algorithm specified is not supported by SE.
5761 */
5764 }
5765
5766 /**
5767 Check if SE supports specific key algorithm.
5768
5769 @note This method is never used for FULLTEXT or SPATIAL keys.
5770 We rely on handler::ha_table_flags() to check if such keys
5771 are supported.
5772 */
5773 virtual bool is_index_algorithm_supported(enum ha_key_alg key_alg) const {
5774 return key_alg == HA_KEY_ALG_SE_SPECIFIC;
5775 }
5776
5777 /**
5778 Signal that the table->read_set and table->write_set table maps changed
5779 The handler is allowed to set additional bits in the above map in this
5780 call. Normally the handler should ignore all calls until we have done
5781 a ha_rnd_init() or ha_index_init(), write_row(), update_row or delete_row()
5782 as there may be several calls to this routine.
5783 */
5784 virtual void column_bitmaps_signal();
5785 uint get_index(void) const { return active_index; }
5786
5787 /**
5788 @retval false Bulk update used by handler
5789 @retval true Bulk update not used, normal operation used
5790 */
5791 virtual bool start_bulk_update() { return true; }
5792 /**
5793 @retval false Bulk delete used by handler
5794 @retval true Bulk delete not used, normal operation used
5795 */
5796 virtual bool start_bulk_delete() { return true; }
5797 /**
5798 After this call all outstanding updates must be performed. The number
5799 of duplicate key errors are reported in the duplicate key parameter.
5800 It is allowed to continue to the batched update after this call, the
5801 handler has to wait until end_bulk_update with changing state.
5802
5803 @param dup_key_found Number of duplicate keys found
5804
5805 @retval 0 Success
5806 @retval >0 Error code
5807 */
5808 virtual int exec_bulk_update(uint *dup_key_found [[maybe_unused]]) {
5809 assert(false);
5810 return HA_ERR_WRONG_COMMAND;
5811 }
5812 /**
5813 Perform any needed clean-up, no outstanding updates are there at the
5814 moment.
5815 */
5816 virtual void end_bulk_update() { return; }
5817 /**
5818 Execute all outstanding deletes and close down the bulk delete.
5819
5820 @retval 0 Success
5821 @retval >0 Error code
5822 */
5823 virtual int end_bulk_delete() {
5824 assert(false);
5825 return HA_ERR_WRONG_COMMAND;
5826 }
5827
5828 protected:
5829 /**
5830 @brief
5831 Positions an index cursor to the index specified in the handle
5832 ('active_index'). Fetches the row if available. If the key value is null,
5833 begin at the first key of the index.
5834 @returns 0 if success (found a record); non-zero if no record.
5835 */
5836 virtual int index_read_map(uchar *buf, const uchar *key,
5837 key_part_map keypart_map,
5838 enum ha_rkey_function find_flag) {
5839 const uint key_len = calculate_key_len(table, active_index, keypart_map);
5840 return index_read(buf, key, key_len, find_flag);
5841 }
5842 /**
5843 Positions an index cursor to the index specified in argument. Fetches
5844 the row if available. If the key value is null, begin at the first key of
5845 the index.
5846 @sa index_read_map()
5847 */
5848 virtual int index_read_idx_map(uchar *buf, uint index, const uchar *key,
5849 key_part_map keypart_map,
5850 enum ha_rkey_function find_flag);
5851
5852 /*
5853 These methods are used to jump to next or previous entry in the index
5854 scan. There are also methods to jump to first and last entry.
5855 */
5856 /// @see index_read_map().
5857 virtual int index_next(uchar *) { return HA_ERR_WRONG_COMMAND; }
5858
5859 /// @see index_read_map().
5860 virtual int index_prev(uchar *) { return HA_ERR_WRONG_COMMAND; }
5861
5862 /// @see index_read_map().
5863 virtual int index_first(uchar *) { return HA_ERR_WRONG_COMMAND; }
5864
5865 /// @see index_read_map().
5866 virtual int index_last(uchar *) { return HA_ERR_WRONG_COMMAND; }
5867
5868 /// @see index_read_map().
5869 virtual int index_next_same(uchar *buf, const uchar *key, uint keylen);
5870
5871 /**
5872 The following functions works like index_read, but it find the last
5873 row with the current key value or prefix.
5874 @see index_read_map().
5875 */
5876 virtual int index_read_last_map(uchar *buf, const uchar *key,
5877 key_part_map keypart_map) {
5878 const uint key_len = calculate_key_len(table, active_index, keypart_map);
5879 return index_read_last(buf, key, key_len);
5880 }
5881
5882 virtual int read_range_first(const key_range *start_key,
5883 const key_range *end_key, bool eq_range_arg,
5884 bool sorted);
5885 virtual int read_range_next();
5886
5887 public:
5888 /**
5889 Set the end position for a range scan. This is used for checking
5890 for when to end the range scan and by the ICP code to determine
5891 that the next record is within the current range.
5892
5893 @param range The end value for the range scan
5894 @param direction Direction of the range scan
5895 */
5896 void set_end_range(const key_range *range,
5897 enum_range_scan_direction direction);
5899 int compare_key_icp(const key_range *range) const;
5900 int compare_key_in_buffer(const uchar *buf) const;
5901 virtual int ft_init() { return HA_ERR_WRONG_COMMAND; }
5902 virtual FT_INFO *ft_init_ext(uint flags, uint inx, String *key);
5904 Ft_hints *hints) {
5905 return ft_init_ext(hints->get_flags(), inx, key);
5906 }
5907 int ha_ft_read(uchar *buf);
5909
5910 protected:
5911 /// @see index_read_map().
5912 virtual int rnd_next(uchar *buf) = 0;
5913 /// @see index_read_map().
5914 virtual int rnd_pos(uchar *buf, uchar *pos) = 0;
5915
5916 virtual int ft_read(uchar *) { return HA_ERR_WRONG_COMMAND; }
5917
5918 public:
5919 /**
5920 This function only works for handlers having
5921 HA_PRIMARY_KEY_REQUIRED_FOR_POSITION set.
5922 It will return the row with the PK given in the record argument.
5923 */
5925 int error;
5927
5928 error = ha_rnd_init(false);
5929 if (error != 0) return error;
5930
5933
5934 ha_rnd_end();
5935 return error;
5936 }
5937
5938 /**
5939 Find number of records in a range.
5940
5941 Given a starting key, and an ending key estimate the number of rows that
5942 will exist between the two. max_key may be empty which in case determine
5943 if start_key matches any rows. Used by optimizer to calculate cost of
5944 using a particular index.
5945
5946 @param inx Index number
5947 @param min_key Start of range
5948 @param max_key End of range
5949
5950 @return Number of rows in range.
5951 */
5952
5953 virtual ha_rows records_in_range(uint inx [[maybe_unused]],
5954 key_range *min_key [[maybe_unused]],
5955 key_range *max_key [[maybe_unused]]) {
5956 return (ha_rows)10;
5957 }
5958 /*
5959 If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, then it sets ref
5960 (reference to the row, aka position, with the primary key given in
5961 the record).
5962 Otherwise it set ref to the current row.
5963 */
5964 virtual void position(const uchar *record) = 0;
5965
5966 /**
5967 General method to gather info from handler
5968
5969 ::info() is used to return information to the optimizer.
5970 SHOW also makes use of this data Another note, if your handler
5971 doesn't proved exact record count, you will probably want to
5972 have the following in your code:
5973 if (records < 2)
5974 records = 2;
5975 The reason is that the server will optimize for cases of only a single
5976 record. If in a table scan you don't know the number of records
5977 it will probably be better to set records to two so you can return
5978 as many records as you need.
5979
5980 Along with records a few more variables you may wish to set are:
5981 records
5982 deleted
5983 data_file_length
5984 index_file_length
5985 delete_length
5986 check_time
5987 Take a look at the public variables in handler.h for more information.
5988 See also my_base.h for a full description.
5989
5990 @param flag Specifies what info is requested
5991 */
5992
5993 virtual int info(uint flag) = 0;
5995 [[maybe_unused]]) {
5996 assert(0);
5997 return 0;
5998 }
5999 /**
6000 Request storage engine to do an extra operation: enable,disable or run some
6001 functionality.
6002
6003 @param operation the operation to perform
6004
6005 @returns
6006 0 on success
6007 error otherwise
6008 */
6009 int ha_extra(enum ha_extra_function operation);
6010
6011 private:
6012 /**
6013 Storage engine specific implementation of ha_extra()
6014
6015 @param operation the operation to perform
6016
6017 @returns
6018 0 on success
6019 error otherwise
6020 */
6021 virtual int extra(enum ha_extra_function operation [[maybe_unused]]) {
6022 return 0;
6023 }
6024
6025 public:
6026 virtual int extra_opt(enum ha_extra_function operation,
6027 ulong cache_size [[maybe_unused]]) {
6028 return extra(operation);
6029 }
6030
6031 /**
6032 Get the handlerton of the storage engine if the SE is capable of
6033 pushing down some of the AccessPath functionality.
6034 (Join, Filter conditions, ... possiby more)
6035
6036 Call the handlerton::push_to_engine() method for performing the
6037 actual pushdown of (parts of) the AccessPath functionality
6038
6039 @returns handlerton* of the SE if it may be capable of
6040 off loading part of the query by calling
6041 handlerton::push_to_engine()
6042
6043 Else, 'nullptr' is returned.
6044 */
6046 return nullptr;
6047 }
6048
6049 /**
6050 Start read (before write) removal on the current table.
6051 @see HA_READ_BEFORE_WRITE_REMOVAL
6052 */
6053 virtual bool start_read_removal(void) {
6054 assert(0);
6055 return false;
6056 }
6057
6058 /**
6059 End read (before write) removal and return the number of rows
6060 really written
6061 @see HA_READ_BEFORE_WRITE_REMOVAL
6062 */
6064 assert(0);
6065 return (ha_rows)0;
6066 }
6067
6068 /**
6069 Normally, when running UPDATE or DELETE queries, we need to wait for other
6070 transactions to release their locks on a given row before we can read it and
6071 potentially update it. However, in READ UNCOMMITTED and READ COMMITTED, we
6072 can ignore these locks if we don't intend to modify the row (e.g., because
6073 it failed a WHERE). This is signaled through enabling “semi-consistent
6074 read”, by calling try_semi_consistent_read(true) (and then setting it back
6075 to false after finishing the query).
6076
6077 If semi-consistent read is enabled, and we are in READ UNCOMMITTED or READ
6078 COMMITTED, the storage engine is permitted to return rows that are locked
6079 and thus un-updatable. If the optimizer doesn't want the row, e.g., because
6080 it got filtered out, it can call unlock_row() as usual. However, if it
6081 intends to update the row, it needs to call was_semi_consistent_read()
6082 before doing so. If was_semi_consistent_read() returns false, the row was
6083 never locked to begin with and can be updated as usual. However, if it
6084 returns 1, it was read optimistically, must be discarded (ie., do not try to
6085 update the row) and must be re-read with locking enabled. The next read call
6086 after was_semi_consistent_read() will automatically re-read the same row,
6087 this time with locking enabled.
6088
6089 Thus, typical use in an UPDATE scenario would look like this:
6090
6091 file->try_semi_consistent_read(true);
6092 file->ha_rnd_init(true);
6093 while (file->ha_rnd_next(table->record[0]) == 0) {
6094 if (row is filtered...) {
6095 file->unlock_row();
6096 continue;
6097 }
6098 if (file->was_semi_consistent_read()) {
6099 // Discard the row; next ha_rnd_next() will read it again with
6100 // locking.
6101 continue;
6102 }
6103 // Process row here.
6104 }
6105 file->ha_rnd_end();
6106 file->try_semi_consistent_read(false);
6107
6108 If the transaction isolation level is REPEATABLE READ or SERIALIZABLE,
6109 enabling this flag has no effect.
6110 */
6111 virtual bool was_semi_consistent_read() { return false; }
6112 /**
6113 Tell the engine whether it should avoid unnecessary lock waits.
6114 If yes, in an UPDATE or DELETE, if the row under the cursor was locked
6115 by another transaction, the engine may try an optimistic read of
6116 the last committed row value under the cursor.
6117 */
6118 virtual void try_semi_consistent_read(bool) {}
6119
6120 /**
6121 Unlock last accessed row.
6122
6123 Record currently processed was not in the result set of the statement
6124 and is thus unlocked. Used for UPDATE and DELETE queries.
6125 */
6126
6127 virtual void unlock_row() {}
6128
6129 /**
6130 Start a statement when table is locked
6131
6132 This method is called instead of external lock when the table is locked
6133 before the statement is executed.
6134
6135 @param thd Thread object.
6136 @param lock_type Type of external lock.
6137
6138 @retval >0 Error code.
6139 @retval 0 Success.
6140 */
6141
6142 virtual int start_stmt(THD *thd [[maybe_unused]],
6143 thr_lock_type lock_type [[maybe_unused]]) {
6144 return 0;
6145 }
6146 virtual void get_auto_increment(ulonglong offset, ulonglong increment,
6147 ulonglong nb_desired_values,
6148 ulonglong *first_value,
6149 ulonglong *nb_reserved_values);
6151 DBUG_PRINT("info", ("auto_increment: next value %lu", (ulong)id));
6153 }
6155 /*
6156 Insertion of a row failed, re-use the lastly generated auto_increment
6157 id, for the next row. This is achieved by resetting next_insert_id to
6158 what it was before the failed insertion (that old value is provided by
6159 the caller). If that value was 0, it was the first row of the INSERT;
6160 then if insert_id_for_cur_row contains 0 it means no id was generated
6161 for this first row, so no id was generated since the INSERT started, so
6162 we should set next_insert_id to 0; if insert_id_for_cur_row is not 0, it
6163 is the generated id of the first and failed row, so we use it.
6164 */
6167 }
6168
6169 /**
6170 Update create info as part of ALTER TABLE.
6171
6172 Forward this handler call to the storage engine foreach
6173 partition handler. The data_file_name for each partition may
6174 need to be reset if the tablespace was moved. Use a dummy
6175 HA_CREATE_INFO structure and transfer necessary data.
6176
6177 @param create_info Create info from ALTER TABLE.
6178 */
6179
6180 virtual void update_create_info(HA_CREATE_INFO *create_info
6181 [[maybe_unused]]) {}
6184 }
6185 virtual int preload_keys(THD *, HA_CHECK_OPT *) {
6187 }
6188 /* end of the list of admin commands */
6189
6190 /**
6191 Check if indexes are disabled.
6192
6193 @retval 0 Indexes are enabled.
6194 @retval != 0 Indexes are disabled.
6195 */
6196
6197 virtual int indexes_are_disabled(void) { return 0; }
6198 virtual void append_create_info(String *packet [[maybe_unused]]) {}
6200 return;
6201 } /* prepare InnoDB for HANDLER */
6202 /** The following can be called without an open handler */
6203 virtual const char *table_type() const = 0;
6204
6205 virtual ulong index_flags(uint idx, uint part, bool all_parts) const = 0;
6206
6207 uint max_record_length() const {
6209 }
6210 uint max_keys() const {
6211 return std::min<uint>(MAX_KEY, max_supported_keys());
6212 }
6213 uint max_key_parts() const {
6214 return std::min(MAX_REF_PARTS, max_supported_key_parts());
6215 }
6216 uint max_key_length() const {
6217 return std::min(MAX_KEY_LENGTH, max_supported_key_length());
6218 }
6219 uint max_key_part_length(HA_CREATE_INFO *create_info) const {
6220 return std::min(MAX_KEY_LENGTH, max_supported_key_part_length(create_info));
6221 }
6222
6223 virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
6224 virtual uint max_supported_keys() const { return 0; }
6225 virtual uint max_supported_key_parts() const { return MAX_REF_PARTS; }
6226 virtual uint max_supported_key_length() const { return MAX_KEY_LENGTH; }
6228 [[maybe_unused]]) const {
6229 return 255;
6230 }
6231 virtual uint min_record_length(uint options [[maybe_unused]]) const {
6232 return 1;
6233 }
6234
6235 virtual bool low_byte_first() const { return true; }
6236 virtual ha_checksum checksum() const { return 0; }
6237
6238 /**
6239 Check if the table is crashed.
6240
6241 @retval true Crashed
6242 @retval false Not crashed
6243 */
6244
6245 virtual bool is_crashed() const { return false; }
6246
6247 /**
6248 Check if the table can be automatically repaired.
6249
6250 @retval true Can be auto repaired
6251 @retval false Cannot be auto repaired
6252 */
6253
6254 virtual bool auto_repair() const { return false; }
6255
6256 /**
6257 Get number of lock objects returned in store_lock.
6258
6259 Returns the number of store locks needed in call to store lock.
6260 We return number of partitions we will lock multiplied with number of
6261 locks needed by each partition. Assists the above functions in allocating
6262 sufficient space for lock structures.
6263
6264 @returns Number of locks returned in call to store_lock.
6265
6266 @note lock_count() can return > 1 if the table is MERGE or partitioned.
6267 */
6268
6269 virtual uint lock_count(void) const { return 1; }
6270
6271 /**
6272 Is not invoked for non-transactional temporary tables.
6273
6274 @note store_lock() can return more than one lock if the table is MERGE
6275 or partitioned.
6276
6277 @note that one can NOT rely on table->in_use in store_lock(). It may
6278 refer to a different thread if called from mysql_lock_abort_for_thread().
6279
6280 @note If the table is MERGE, store_lock() can return less locks
6281 than lock_count() claimed. This can happen when the MERGE children
6282 are not attached when this is called from another thread.
6283
6284 The idea with handler::store_lock() is the following:
6285
6286 The statement decided which locks we should need for the table
6287 for updates/deletes/inserts we get WRITE locks, for SELECT... we get
6288 read locks.
6289
6290 Before adding the lock into the table lock handler (see thr_lock.c)
6291 mysqld calls store lock with the requested locks. Store lock can now
6292 modify a write lock to a read lock (or some other lock), ignore the
6293 lock (if we don't want to use MySQL table locks at all) or add locks
6294 for many tables (like we do when we are using a MERGE handler).
6295
6296 In some exceptional cases MySQL may send a request for a TL_IGNORE;
6297 This means that we are requesting the same lock as last time and this
6298 should also be ignored.
6299
6300 Called from lock.cc by get_lock_data().
6301 */
6303 enum thr_lock_type lock_type) = 0;
6304
6305 /**
6306 Check if the primary key is clustered or not.
6307
6308 @retval true Primary key (if there is one) is a clustered
6309 key covering all fields
6310 @retval false otherwise
6311 */
6312
6313 virtual bool primary_key_is_clustered() const { return false; }
6314
6315 /**
6316 Compare two positions.
6317
6318 @param ref1 First position.
6319 @param ref2 Second position.
6320
6321 @retval <0 ref1 < ref2.
6322 @retval 0 Equal.
6323 @retval >0 ref1 > ref2.
6324 */
6325
6326 virtual int cmp_ref(const uchar *ref1, const uchar *ref2) const {
6327 return memcmp(ref1, ref2, ref_length);
6328 }
6329
6330 /*
6331 Condition pushdown to storage engines
6332 */
6333
6334 /**
6335 Push condition down to the table handler.
6336
6337 @param cond Condition to be pushed. The condition tree
6338 must not be modified by the caller.
6339
6340 @return
6341 The 'remainder' condition that caller must use to filter out records.
6342 NULL means the handler will not return rows that do not match the
6343 passed condition.
6344
6345 @note
6346 handler->ha_reset() call discard any pushed conditions.
6347 Calls to rnd_init/rnd_end, index_init/index_end etc do not affect the
6348 pushed conditions.
6349 */
6350 virtual const Item *cond_push(const Item *cond) {
6351 assert(pushed_cond == nullptr);
6352 return cond;
6353 }
6354
6355 /**
6356 Push down an index condition to the handler.
6357
6358 The server will use this method to push down a condition it wants
6359 the handler to evaluate when retrieving records using a specified
6360 index. The pushed index condition will only refer to fields from
6361 this handler that is contained in the index (but it may also refer
6362 to fields in other handlers). Before the handler evaluates the
6363 condition it must read the content of the index entry into the
6364 record buffer.
6365
6366 The handler is free to decide if and how much of the condition it
6367 will take responsibility for evaluating. Based on this evaluation
6368 it should return the part of the condition it will not evaluate.
6369 If it decides to evaluate the entire condition it should return
6370 NULL. If it decides not to evaluate any part of the condition it
6371 should return a pointer to the same condition as given as argument.
6372
6373 @param keyno the index number to evaluate the condition on
6374 @param idx_cond the condition to be evaluated by the handler
6375
6376 @return The part of the pushed condition that the handler decides
6377 not to evaluate
6378 */
6379
6380 virtual Item *idx_cond_push(uint keyno [[maybe_unused]], Item *idx_cond) {
6381 return idx_cond;
6382 }
6383
6384 /** Reset information about pushed index conditions */
6385 virtual void cancel_pushed_idx_cond() {
6386 pushed_idx_cond = nullptr;
6389 }
6390
6391 /**
6392 Reports number of tables included in pushed join which this
6393 handler instance is part of. ==0 -> Not pushed
6394 */
6395 virtual uint number_of_pushed_joins() const { return 0; }
6396
6397 /**
6398 If this handler instance is part of a pushed join sequence
6399 returned TABLE instance being root of the pushed query?
6400 */
6401 virtual const TABLE *member_of_pushed_join() const { return nullptr; }
6402
6403 /**
6404 If this handler instance is a child in a pushed join sequence
6405 returned TABLE instance being my parent?
6406 */
6407 virtual const TABLE *parent_of_pushed_join() const { return nullptr; }
6408
6409 /// @returns a map of the tables involved in this pushed join, or 0 if not
6410 /// part of a pushed join.
6411 virtual table_map tables_in_pushed_join() const { return 0; }
6412
6413 int ha_index_read_pushed(uchar *buf, const uchar *key,
6414 key_part_map keypart_map);
6415
6417
6418 protected:
6419 virtual int index_read_pushed(uchar *, const uchar *, key_part_map) {
6420 return HA_ERR_WRONG_COMMAND;
6421 }
6422
6424
6425 public:
6426 /**
6427 Part of old, deprecated in-place ALTER API.
6428 */
6430 [[maybe_unused]],
6431 uint table_changes [[maybe_unused]]) {
6432 return COMPATIBLE_DATA_NO;
6433 }
6434
6435 /* On-line/in-place/instant ALTER TABLE interface. */
6436
6437 /*
6438 Here is an outline of on-line/in-place ALTER TABLE execution through
6439 this interface.
6440
6441 Phase 1 : Initialization
6442 ========================
6443 During this phase we determine which algorithm should be used
6444 for execution of ALTER TABLE and what level concurrency it will
6445 require.
6446
6447 *) This phase starts by opening the table and preparing description
6448 of the new version of the table.
6449 *) Then we check if it is impossible even in theory to carry out
6450 this ALTER TABLE using the in-place/instant algorithm. For example,
6451 because we need to change storage engine or the user has explicitly
6452 requested usage of the "copy" algorithm.
6453 *) If in-place/instant ALTER TABLE is theoretically possible, we continue
6454 by compiling differences between old and new versions of the table
6455 in the form of HA_ALTER_FLAGS bitmap. We also build a few
6456 auxiliary structures describing requested changes and store
6457 all these data in the Alter_inplace_info object.
6458 *) Then the handler::check_if_supported_inplace_alter() method is called
6459 in order to find if the storage engine can carry out changes requested
6460 by this ALTER TABLE using the in-place or instant algorithm.
6461 To determine this, the engine can rely on data in HA_ALTER_FLAGS/
6462 Alter_inplace_info passed to it as well as on its own checks.
6463 If the in-place algorithm can be used for this ALTER TABLE, the level
6464 of required concurrency for its execution is also returned.
6465 If any errors occur during the handler call, ALTER TABLE is aborted
6466 and no further handler functions are called.
6467 Note that in cases when there is difference between in-place and
6468 instant algorithm and user explicitly asked for usage of in-place
6469 algorithm storage engine MUST return one of values corresponding
6470 to in-place algorithm and not HA_ALTER_INPLACE_INSTANT from this
6471 method.
6472 *) Locking requirements of the in-place algorithm are compared to any
6473 concurrency requirements specified by user. If there is a conflict
6474 between them, we either switch to the copy algorithm or emit an error.
6475
6476 Phase 2 : Execution
6477 ===================
6478
6479 In this phase the operations are executed.
6480
6481 *) As the first step, we acquire a lock corresponding to the concurrency
6482 level which was returned by handler::check_if_supported_inplace_alter()
6483 and requested by the user. This lock is held for most of the
6484 duration of in-place ALTER (if HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE
6485 or HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE were returned we acquire an
6486 exclusive lock for duration of the next step only).
6487 For HA_ALTER_INPLACE_INSTANT we keep shared upgradable metadata lock
6488 which was acquired at table open time.
6489 *) After that we call handler::ha_prepare_inplace_alter_table() to give the
6490 storage engine a chance to update its internal structures with a higher
6491 lock level than the one that will be used for the main step of algorithm.
6492 After that we downgrade the lock if it is necessary.
6493 This step should be no-op for instant algorithm.
6494 *) After that, the main step of this phase and algorithm is executed.
6495 We call the handler::ha_inplace_alter_table() method, which carries out
6496 the changes requested by ALTER TABLE but does not makes them visible to
6497 other connections yet.
6498 This step should be no-op for instant algorithm as well.
6499 *) We ensure that no other connection uses the table by upgrading our
6500 lock on it to exclusive.
6501 *) a) If the previous step succeeds,
6502 handler::ha_commit_inplace_alter_table() is called to allow the storage
6503 engine to do any final updates to its structures, to make all earlier
6504 changes durable and visible to other connections.
6505 For instant algorithm this is the step during which SE changes are done.
6506 Engines that support atomic DDL only prepare for the commit during this
6507 step but do not finalize it. Real commit happens later when the whole
6508 statement is committed. Also in some situations statement might be rolled
6509 back after call to commit_inplace_alter_table() for such storage engines.
6510 In the latter special case SE might require call to
6511 handlerton::dict_cache_reset() in order to invalidate its internal table
6512 definition cache after rollback.
6513 b) If we have failed to upgrade lock or any errors have occurred during
6514 the handler functions calls (including commit), we call
6515 handler::ha_commit_inplace_alter_table() to rollback all changes which
6516 were done during previous steps.
6517
6518 All the above calls to SE are provided with dd::Table objects describing old
6519 and new version of table being altered. Engines which support atomic DDL are
6520 allowed to adjust object corresponding to the new version. During phase 3
6521 these changes are saved to the data-dictionary.
6522
6523
6524 Phase 3 : Final
6525 ===============
6526
6527 In this phase we:
6528
6529 a) For engines which don't support atomic DDL:
6530
6531 *) Update the SQL-layer data-dictionary by replacing description of old
6532 version of the table with its new version. This change is immediately
6533 committed.
6534 *) Inform the storage engine about this change by calling the
6535 handler::ha_notify_table_changed() method.
6536 *) Process the RENAME clause by calling handler::ha_rename_table() and
6537 updating the data-dictionary accordingly. Again this change is
6538 immediately committed.
6539 *) Destroy the Alter_inplace_info and handler_ctx objects.
6540
6541 b) For engines which support atomic DDL:
6542
6543 *) Update the SQL-layer data-dictionary by replacing description of old
6544 version of the table with its new version.
6545 *) Process the RENAME clause by calling handler::ha_rename_table() and
6546 updating the data-dictionary accordingly.
6547 *) Commit the statement/transaction.
6548 *) Finalize atomic DDL operation by calling handlerton::post_ddl() hook
6549 for the storage engine.
6550 *) Additionally inform the storage engine about completion of ALTER TABLE
6551 for the table by calling the handler::ha_notify_table_changed()
6552 method.
6553 *) Destroy the Alter_inplace_info and handler_ctx objects.
6554 */
6555
6556 /**
6557 Check if a storage engine supports a particular alter table in-place
6558
6559 @param altered_table TABLE object for new version of table.
6560 @param ha_alter_info Structure describing changes to be done
6561 by ALTER TABLE and holding data used
6562 during in-place alter.
6563
6564 @retval HA_ALTER_ERROR Unexpected error.
6565 @retval HA_ALTER_INPLACE_NOT_SUPPORTED Not supported, must use copy.
6566 @retval HA_ALTER_INPLACE_EXCLUSIVE_LOCK Supported, but requires X lock.
6567 @retval HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE
6568 Supported, but requires SNW lock
6569 during main phase. Prepare phase
6570 requires X lock.
6571 @retval HA_ALTER_INPLACE_SHARED_LOCK Supported, but requires SNW lock.
6572 @retval HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE
6573 Supported, concurrent
6574 reads/writes allowed. However, prepare phase requires X lock.
6575 @retval HA_ALTER_INPLACE_NO_LOCK Supported, concurrent
6576 reads/writes allowed.
6577 @retval HA_ALTER_INPLACE_INSTANT Instant algorithm is supported.
6578 Prepare and main phases are
6579 no-op. Changes happen during
6580 commit phase and it should be
6581 "instant". We keep SU lock,
6582 allowing concurrent reads and
6583 writes during no-op phases and
6584 upgrade it to X lock before
6585 commit phase.
6586
6587 @note The default implementation uses the old in-place ALTER API
6588 to determine if the storage engine supports in-place ALTER or not.
6589
6590 @note In cases when there is difference between in-place and instant
6591 algorithm and explicit ALGORITHM=INPLACE clause was provided SE MUST
6592 return one of values corresponding to in-place algorithm and not
6593 HA_ALTER_INPLACE_INSTANT from this method.
6594
6595 @note Called without holding thr_lock.c lock.
6596 */
6598 TABLE *altered_table, Alter_inplace_info *ha_alter_info);
6599
6600 /**
6601 Public functions wrapping the actual handler call.
6602 @see prepare_inplace_alter_table()
6603 */
6604 bool ha_prepare_inplace_alter_table(TABLE *altered_table,
6605 Alter_inplace_info *ha_alter_info,
6606 const dd::Table *old_table_def,
6607 dd::Table *new_table_def);
6608
6609 /**
6610 Public function wrapping the actual handler call.
6611 @see inplace_alter_table()
6612 */
6613 bool ha_inplace_alter_table(TABLE *altered_table,
6614 Alter_inplace_info *ha_alter_info,
6615 const dd::Table *old_table_def,
6616 dd::Table *new_table_def) {
6617 return inplace_alter_table(altered_table, ha_alter_info, old_table_def,
6618 new_table_def);
6619 }
6620
6621 /**
6622 Public function wrapping the actual handler call.
6623 Allows us to enforce asserts regardless of handler implementation.
6624 @see commit_inplace_alter_table()
6625 */
6626 bool ha_commit_inplace_alter_table(TABLE *altered_table,
6627 Alter_inplace_info *ha_alter_info,
6628 bool commit,
6629 const dd::Table *old_table_def,
6630 dd::Table *new_table_def);
6631
6632 /**
6633 Public function wrapping the actual handler call.
6634
6635 @see notify_table_changed()
6636 */
6638 notify_table_changed(ha_alter_info);
6639 }
6640
6641 protected:
6642 /**
6643 Allows the storage engine to update internal structures with concurrent
6644 writes blocked. If check_if_supported_inplace_alter() returns
6645 HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE or
6646 HA_ALTER_INPLACE_SHARED_AFTER_PREPARE, this function is called with
6647 exclusive lock otherwise the same level of locking as for
6648 inplace_alter_table() will be used.
6649
6650 @note Should be no-op for instant algorithm.
6651
6652 @note Storage engines are responsible for reporting any errors by
6653 calling my_error()/print_error()
6654
6655 @note If this function reports error, commit_inplace_alter_table()
6656 will be called with commit= false.
6657
6658 @note For partitioning, failing to prepare one partition, means that
6659 commit_inplace_alter_table() will be called to roll back changes for
6660 all partitions. This means that commit_inplace_alter_table() might be
6661 called without prepare_inplace_alter_table() having been called first
6662 for a given partition.
6663
6664 @param altered_table TABLE object for new version of table.
6665 @param ha_alter_info Structure describing changes to be done
6666 by ALTER TABLE and holding data used
6667 during in-place alter.
6668 @param old_table_def dd::Table object describing old version of
6669 the table.
6670 @param new_table_def dd::Table object for the new version of the
6671 table. Can be adjusted by this call if SE
6672 supports atomic DDL. These changes to the
6673 table definition will be persisted in the
6674 data-dictionary at statement commit time.
6675
6676 @retval true Error
6677 @retval false Success
6678 */
6680 TABLE *altered_table [[maybe_unused]],
6681 Alter_inplace_info *ha_alter_info [[maybe_unused]],
6682 const dd::Table *old_table_def [[maybe_unused]],
6683 dd::Table *new_table_def [[maybe_unused]]) {
6684 return false;
6685 }
6686
6687 /**
6688 Alter the table structure in-place with operations specified using
6689 HA_ALTER_FLAGS and Alter_inplace_info. The level of concurrency allowed
6690 during this operation depends on the return value from
6691 check_if_supported_inplace_alter().
6692
6693 @note Should be no-op for instant algorithm.
6694
6695 @note Storage engines are responsible for reporting any errors by
6696 calling my_error()/print_error()
6697
6698 @note If this function reports error, commit_inplace_alter_table()
6699 will be called with commit= false.
6700
6701 @param altered_table TABLE object for new version of table.
6702 @param ha_alter_info Structure describing changes to be done
6703 by ALTER TABLE and holding data used
6704 during in-place alter.
6705 @param old_table_def dd::Table object describing old version of
6706 the table.
6707 @param new_table_def dd::Table object for the new version of the
6708 table. Can be adjusted by this call if SE
6709 supports atomic DDL. These changes to the
6710 table definition will be persisted in the
6711 data-dictionary at statement commit time.
6712
6713 @retval true Error
6714 @retval false Success
6715 */
6716 virtual bool inplace_alter_table(TABLE *altered_table [[maybe_unused]],
6717 Alter_inplace_info *ha_alter_info
6718 [[maybe_unused]],
6719 const dd::Table *old_table_def
6720 [[maybe_unused]],
6721 dd::Table *new_table_def [[maybe_unused]]) {
6722 return false;
6723 }
6724
6725 /**
6726 Commit or rollback the changes made during prepare_inplace_alter_table()
6727 and inplace_alter_table() inside the storage engine.
6728 Note that in case of rollback the allowed level of concurrency during
6729 this operation will be the same as for inplace_alter_table() and thus
6730 might be higher than during prepare_inplace_alter_table(). (For example,
6731 concurrent writes were blocked during prepare, but might not be during
6732 rollback).
6733
6734 @note This is the place where SE changes happen for instant algorithm.
6735
6736 @note For storage engines supporting atomic DDL this method should only
6737 prepare for the commit but do not finalize it. Real commit should happen
6738 later when the whole statement is committed. Also in some situations
6739 statement might be rolled back after call to commit_inplace_alter_table()
6740 for such storage engines. In the latter special case SE might require call
6741 to handlerton::dict_cache_reset() in order to invalidate its internal
6742 table definition cache after rollback.
6743
6744 @note Storage engines are responsible for reporting any errors by
6745 calling my_error()/print_error()
6746
6747 @note If this function with commit= true reports error, it will be called
6748 again with commit= false.
6749
6750 @note In case of partitioning, this function might be called for rollback
6751 without prepare_inplace_alter_table() having been called first.
6752 Also partitioned tables sets ha_alter_info->group_commit_ctx to a NULL
6753 terminated array of the partitions handlers and if all of them are
6754 committed as one, then group_commit_ctx should be set to NULL to indicate
6755 to the partitioning handler that all partitions handlers are committed.
6756 @see prepare_inplace_alter_table().
6757
6758 @param altered_table TABLE object for new version of table.
6759 @param ha_alter_info Structure describing changes to be done
6760 by ALTER TABLE and holding data used
6761 during in-place alter.
6762 @param commit True => Commit, False => Rollback.
6763 @param old_table_def dd::Table object describing old version of
6764 the table.
6765 @param new_table_def dd::Table object for the new version of the
6766 table. Can be adjusted by this call if SE
6767 supports atomic DDL. These changes to the
6768 table definition will be persisted in the
6769 data-dictionary at statement commit time.
6770
6771 @retval true Error
6772 @retval false Success
6773 */
6774 virtual bool commit_inplace_alter_table(TABLE *altered_table [[maybe_unused]],
6775 Alter_inplace_info *ha_alter_info
6776 [[maybe_unused]],
6777 bool commit [[maybe_unused]],
6778 const dd::Table *old_table_def
6779 [[maybe_unused]],
6780 dd::Table *new_table_def
6781 [[maybe_unused]]) {
6782 /* Nothing to commit/rollback, mark all handlers committed! */
6783 ha_alter_info->group_commit_ctx = nullptr;
6784 return false;
6785 }
6786
6787 /**
6788 Notify the storage engine that the table definition has been updated.
6789
6790 @param ha_alter_info Structure describing changes done by
6791 ALTER TABLE and holding data used
6792 during in-place alter.
6793
6794 @note No errors are allowed during notify_table_changed().
6795
6796 @note For storage engines supporting atomic DDL this method is invoked
6797 after the whole ALTER TABLE is completed and committed.
6798 Particularly this means that for ALTER TABLE statements with RENAME
6799 clause TABLE/handler object used for invoking this method will be
6800 associated with new table name. If storage engine needs to know
6801 the old schema and table name in this method for some reason it
6802 has to use ha_alter_info object to figure it out.
6803 */
6804 virtual void notify_table_changed(Alter_inplace_info *ha_alter_info
6805 [[maybe_unused]]) {}
6806
6807 public:
6808 /* End of On-line/in-place ALTER TABLE interface. */
6809
6810 /**
6811 use_hidden_primary_key() is called in case of an update/delete when
6812 (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
6813 but we don't have a primary key
6814 */
6815 virtual void use_hidden_primary_key();
6816
6817 protected:
6818 /* Service methods for use by storage engines. */
6820 THD *ha_thd() const;
6821
6822 /**
6823 Acquire the instrumented table information from a table share.
6824 @param share a table share
6825 @return an instrumented table share, or NULL.
6826 */
6828
6829 /**
6830 Default rename_table() and delete_table() rename/delete files with a
6831 given name and extensions from handlerton::file_extensions.
6832
6833 These methods can be overridden, but their default implementation
6834 provide useful functionality.
6835
6836 @param [in] from Path for the old table name.
6837 @param [in] to Path for the new table name.
6838 @param [in] from_table_def Old version of definition for table
6839 being renamed (i.e. prior to rename).
6840 @param [in,out] to_table_def New version of definition for table
6841 being renamed. Storage engines which
6842 support atomic DDL (i.e. having
6843 HTON_SUPPORTS_ATOMIC_DDL flag set)
6844 are allowed to adjust this object.
6845
6846 @retval >0 Error.
6847 @retval 0 Success.
6848 */
6849 virtual int rename_table(const char *from, const char *to,
6850 const dd::Table *from_table_def,
6851 dd::Table *to_table_def);
6852
6853 /**
6854 Delete a table.
6855
6856 Used to delete a table. By the time delete_table() has been called all
6857 opened references to this table will have been closed (and your globally
6858 shared references released. The variable name will just be the name of
6859 the table. You will need to remove any files you have created at this
6860 point. Called for base as well as temporary tables.
6861
6862 @param name Full path of table name.
6863 @param table_def dd::Table describing table being deleted
6864 (can be NULL for temporary tables created
6865 by optimizer).
6866
6867 @return Zero on success, nonzero otherwise.
6868 */
6869 virtual int delete_table(const char *name, const dd::Table *table_def);
6870
6871 private:
6872 /* Private helpers */
6873 void mark_trx_read_write();
6874 /*
6875 Low-level primitives for storage engines. These should be
6876 overridden by the storage engine class. To call these methods, use
6877 the corresponding 'ha_*' method above.
6878 */
6879
6880 virtual int open(const char *name, int mode, uint test_if_locked,
6881 const dd::Table *table_def) = 0;
6882 virtual int close(void) = 0;
6883 virtual int index_init(uint idx, bool sorted [[maybe_unused]]) {
6884 active_index = idx;
6885 return 0;
6886 }
6887 virtual int index_end() {
6889 return 0;
6890 }
6891 /**
6892 rnd_init() can be called two times without rnd_end() in between
6893 (it only makes sense if scan=1).
6894 then the second call should prepare for the new table scan (e.g
6895 if rnd_init allocates the cursor, second call should position it
6896 to the start of the table, no need to deallocate and allocate it again
6897 */
6898 virtual int rnd_init(bool scan) = 0;
6899 virtual int rnd_end() { return 0; }
6900 /**
6901 Write a row.
6902
6903 write_row() inserts a row. buf is a byte array of data, normally
6904 record[0].
6905
6906 You can use the field information to extract the data from the native byte
6907 array type.
6908
6909 Example of this would be:
6910 for (Field **field=table->field ; *field ; field++)
6911 {
6912 ...
6913 }
6914
6915 @param buf Buffer to write from.
6916
6917 @return Operation status.
6918 @retval 0 Success.
6919 @retval != 0 Error code.
6920 */
6921 virtual int write_row(uchar *buf [[maybe_unused]]) {
6922 return HA_ERR_WRONG_COMMAND;
6923 }
6924
6925 /**
6926 Update a single row.
6927
6928 Note: If HA_ERR_FOUND_DUPP_KEY is returned, the handler must read
6929 all columns of the row so MySQL can create an error message. If
6930 the columns required for the error message are not read, the error
6931 message will contain garbage.
6932 */
6933 virtual int update_row(const uchar *old_data [[maybe_unused]],
6934 uchar *new_data [[maybe_unused]]) {
6935 return HA_ERR_WRONG_COMMAND;
6936 }
6937
6938 virtual int delete_row(const uchar *buf [[maybe_unused]]) {
6939 return HA_ERR_WRONG_COMMAND;
6940 }
6941 /**
6942 Reset state of file to after 'open'.
6943 This function is called after every statement for all tables used
6944 by that statement.
6945 */
6946 virtual int reset() { return 0; }
6947 virtual Table_flags table_flags(void) const = 0;
6948 /**
6949 Is not invoked for non-transactional temporary tables.
6950
6951 Tells the storage engine that we intend to read or write data
6952 from the table. This call is prefixed with a call to handler::store_lock()
6953 and is invoked only for those handler instances that stored the lock.
6954
6955 Calls to @c rnd_init / @c index_init are prefixed with this call. When table
6956 IO is complete, we call @code external_lock(F_UNLCK) @endcode.
6957 A storage engine writer should expect that each call to
6958 @code ::external_lock(F_[RD|WR]LOCK @endcode is followed by a call to
6959 @code ::external_lock(F_UNLCK) @endcode. If it is not, it is a bug in MySQL.
6960
6961 The name and signature originate from the first implementation
6962 in MyISAM, which would call @c fcntl to set/clear an advisory
6963 lock on the data file in this method.
6964
6965 Originally this method was used to set locks on file level to enable
6966 several MySQL Servers to work on the same data. For transactional
6967 engines it has been "abused" to also mean start and end of statements
6968 to enable proper rollback of statements and transactions. When LOCK
6969 TABLES has been issued the start_stmt method takes over the role of
6970 indicating start of statement but in this case there is no end of
6971 statement indicator(?).
6972
6973 Called from lock.cc by lock_external() and unlock_external(). Also called
6974 from sql_table.cc by copy_data_between_tables().
6975
6976 @param thd the current thread
6977 @param lock_type F_RDLCK, F_WRLCK, F_UNLCK
6978
6979 @return non-0 in case of failure, 0 in case of success.
6980 When lock_type is F_UNLCK, the return value is ignored.
6981 */
6982 virtual int external_lock(THD *thd [[maybe_unused]],
6983 int lock_type [[maybe_unused]]) {
6984 return 0;
6985 }
6986 virtual void release_auto_increment() { return; }
6987 /** admin commands - called from mysql_admin_table */
6988 virtual int check_for_upgrade(HA_CHECK_OPT *) { return 0; }
6989 virtual int check(THD *, HA_CHECK_OPT *) { return HA_ADMIN_NOT_IMPLEMENTED; }
6990
6991 /**
6992 In this method check_opt can be modified
6993 to specify CHECK option to use to call check()
6994 upon the table.
6995 */
6996 virtual int repair(THD *, HA_CHECK_OPT *) {
6997 assert(!(ha_table_flags() & HA_CAN_REPAIR));
6999 }
7001 virtual int end_bulk_insert() { return 0; }
7002
7003 /**
7004 Does this handler want to get a Record_buffer for multi-row reads
7005 via the ha_set_record_buffer() function? And if so, what is the
7006 maximum number of records to allocate space for in the buffer?
7007
7008 Storage engines that support using a Record_buffer should override
7009 this function and return true for scans that could benefit from a
7010 buffer.
7011
7012 @param[out] max_rows gets set to the maximum number of records to
7013 allocate space for in the buffer if the function
7014 returns true
7015
7016 @retval true if the handler would like a Record_buffer
7017 @retval false if the handler does not want a Record_buffer
7018 */
7019 virtual bool is_record_buffer_wanted(ha_rows *const max_rows) const {
7020 *max_rows = 0;
7021 return false;
7022 }
7023
7024 // Set se_private_id and se_private_data during upgrade
7025 virtual bool upgrade_table(THD *thd [[maybe_unused]],
7026 const char *dbname [[maybe_unused]],
7027 const char *table_name [[maybe_unused]],
7028 dd::Table *dd_table [[maybe_unused]]) {
7029 return false;
7030 }
7031
7032 /** Initialize sampling.
7033 @param[out] scan_ctx A scan context created by this method that has to be
7034 used in sample_next
7035 @param[in] sampling_percentage percentage of records that need to be sampled
7036 @param[in] sampling_seed random seed
7037 @param[in] sampling_method sampling method to be used; currently only
7038 SYSTEM sampling is supported
7039 @param[in] tablesample true if the sampling is for tablesample
7040 @return 0 for success, else failure. */
7041 virtual int sample_init(void *&scan_ctx, double sampling_percentage,
7042 int sampling_seed,
7043 enum_sampling_method sampling_method,
7044 const bool tablesample);
7045
7046 /** Get the next record for sampling.
7047 @param[in] scan_ctx Scan context of the sampling
7048 @param[in] buf buffer to place the read record
7049 @return 0 for success, else failure. */
7050 virtual int sample_next(void *scan_ctx, uchar *buf);
7051
7052 /** End sampling.
7053 @param[in] scan_ctx Scan context of the sampling
7054 @return 0 for success, else failure. */
7055 virtual int sample_end(void *scan_ctx);
7056
7057 /**
7058 * Loads a table into its defined secondary storage engine.
7059 *
7060 * @param[in] table - Table opened in primary storage engine. Its read_set
7061 * tells which columns to load.
7062 * @param[out] skip_metadata_update - should the DD metadata be updated for
7063 * the load of this table
7064 *
7065 * @return 0 if success, error code otherwise.
7066 */
7067 virtual int load_table(const TABLE &table [[maybe_unused]],
7068 bool *skip_metadata_update [[maybe_unused]]) {
7069 /* purecov: begin inspected */
7070 assert(false);
7071 return HA_ERR_WRONG_COMMAND;
7072 /* purecov: end */
7073 }
7074
7075 /**
7076 * Unloads a table from its defined secondary storage engine.
7077 *
7078 * @param db_name Database name.
7079 * @param table_name Table name.
7080 * @param error_if_not_loaded If true, then errors will be reported by this
7081 * function. If false, no errors will be reported
7082 * (silently fail). This case of false is useful
7083 * during DROP TABLE where a failure to unload
7084 * should not prevent dropping the whole table.
7085 * @return 0 if success, error code otherwise.
7086 */
7087 virtual int unload_table(const char *db_name [[maybe_unused]],
7088 const char *table_name [[maybe_unused]],
7089 bool error_if_not_loaded [[maybe_unused]]) {
7090 /* purecov: begin inspected */
7091 assert(false);
7092 return HA_ERR_WRONG_COMMAND;
7093 /* purecov: end */
7094 }
7095
7096 protected:
7097 virtual int index_read(uchar *buf [[maybe_unused]],
7098 const uchar *key [[maybe_unused]],
7099 uint key_len [[maybe_unused]],
7100 enum ha_rkey_function find_flag [[maybe_unused]]) {
7101 return HA_ERR_WRONG_COMMAND;
7102 }
7103 virtual int index_read_last(uchar *buf [[maybe_unused]],
7104 const uchar *key [[maybe_unused]],
7105 uint key_len [[maybe_unused]]) {
7107 return HA_ERR_WRONG_COMMAND;
7108 }
7109
7110 public:
7111 /**
7112 This method is similar to update_row, however the handler doesn't need
7113 to execute the updates at this point in time. The handler can be certain
7114 that another call to bulk_update_row will occur OR a call to
7115 exec_bulk_update before the set of updates in this query is concluded.
7116
7117 Note: If HA_ERR_FOUND_DUPP_KEY is returned, the handler must read
7118 all columns of the row so MySQL can create an error message. If
7119 the columns required for the error message are not read, the error
7120 message will contain garbage.
7121
7122 @param old_data Old record
7123 @param new_data New record
7124 @param dup_key_found Number of duplicate keys found
7125
7126 */
7127 virtual int bulk_update_row(const uchar *old_data [[maybe_unused]],
7128 uchar *new_data [[maybe_unused]],
7129 uint *dup_key_found [[maybe_unused]]) {
7130 assert(false);
7131 return HA_ERR_WRONG_COMMAND;
7132 }
7133 /**
7134 Delete all rows in a table.
7135
7136 This is called both for cases of truncate and for cases where the
7137 optimizer realizes that all rows will be removed as a result of an
7138 SQL statement.
7139
7140 If the handler don't support this, then this function will
7141 return HA_ERR_WRONG_COMMAND and MySQL will delete the rows one
7142 by one.
7143 */
7144 virtual int delete_all_rows() {
7146 return HA_ERR_WRONG_COMMAND;
7147 }
7148 /**
7149 Quickly remove all rows from a table.
7150
7151 @param[in,out] table_def dd::Table object for table being truncated.
7152
7153 @remark This method is responsible for implementing MySQL's TRUNCATE
7154 TABLE statement, which is a DDL operation. As such, a engine
7155 can bypass certain integrity checks and in some cases avoid
7156 fine-grained locking (e.g. row locks) which would normally be
7157 required for a DELETE statement.
7158
7159 @remark Typically, truncate is not used if it can result in integrity
7160 violation. For example, truncate is not used when a foreign
7161 key references the table, but it might be used if foreign key
7162 checks are disabled.
7163
7164 @remark Engine is responsible for resetting the auto-increment counter.
7165
7166 @remark The table is locked in exclusive mode. All open TABLE/handler
7167 instances except the one which is used for truncate() call
7168 are closed.
7169
7170 @note It is assumed that transactional storage engines implementing
7171 this method can revert its effects if transaction is rolled
7172 back (e.g. because we failed to write statement to the binary
7173 log).
7174
7175 @note Changes to dd::Table object done by this method will be saved
7176 to data-dictionary only if storage engine supports atomic DDL
7177 (i.e. has HTON_SUPPORTS_ATOMIC_DDL flag set).
7178 */
7179 virtual int truncate(dd::Table *table_def [[maybe_unused]]) {
7180 return HA_ERR_WRONG_COMMAND;
7181 }
7182 virtual int optimize(THD *, HA_CHECK_OPT *) {
7184 }
7185 virtual int analyze(THD *, HA_CHECK_OPT *) {
7187 }
7188
7189 /**
7190 @brief Check and repair the table if necessary.
7191
7192 @param thd Thread object
7193
7194 @retval true Error/Not supported
7195 @retval false Success
7196
7197 @note Called if open_table_from_share fails and is_crashed().
7198 */
7199
7200 virtual bool check_and_repair(THD *thd [[maybe_unused]]) { return true; }
7201
7202 /**
7203 Disable indexes for a while.
7204
7205 @param mode Mode.
7206
7207 @retval 0 Success.
7208 @retval != 0 Error.
7209 */
7210
7211 virtual int disable_indexes(uint mode [[maybe_unused]]) {
7212 return HA_ERR_WRONG_COMMAND;
7213 }
7214
7215 /**
7216 Enable indexes again.
7217
7218 @param mode Mode.
7219
7220 @retval 0 Success.
7221 @retval != 0 Error.
7222 */
7223
7224 virtual int enable_indexes(uint mode [[maybe_unused]]) {
7225 return HA_ERR_WRONG_COMMAND;
7226 }
7227
7228 /**
7229 Discard or import tablespace.
7230
7231 @param [in] discard Indicates whether this is discard operation.
7232 @param [in,out] table_def dd::Table object describing the table
7233 in which tablespace needs to be discarded
7234 or imported. This object can be adjusted by
7235 storage engine if it supports atomic DDL
7236 (i.e. has HTON_SUPPORTS_ATOMIC_DDL flag set).
7237 These changes will be persisted in the
7238 data-dictionary.
7239 @retval 0 Success.
7240 @retval != 0 Error.
7241 */
7242
7243 virtual int discard_or_import_tablespace(bool discard [[maybe_unused]],
7245 [[maybe_unused]]) {
7247 return HA_ERR_WRONG_COMMAND;
7248 }
7249
7250 virtual void drop_table(const char *name);
7251
7252 /**
7253 Create table (implementation).
7254
7255 @param [in] name Table name.
7256 @param [in] form TABLE object describing the table to be
7257 created.
7258 @param [in] info HA_CREATE_INFO describing table.
7259 @param [in,out] table_def dd::Table object describing the table
7260 to be created. This object can be
7261 adjusted by storage engine if it
7262 supports atomic DDL (i.e. has
7263 HTON_SUPPORTS_ATOMIC_DDL flag set).
7264 These changes will be persisted in the
7265 data-dictionary. Can be NULL for
7266 temporary tables created by optimizer.
7267
7268 @retval 0 Success.
7269 @retval non-0 Error.
7270 */
7271 virtual int create(const char *name, TABLE *form, HA_CREATE_INFO *info,
7272 dd::Table *table_def) = 0;
7273
7274 virtual bool get_se_private_data(dd::Table *dd_table [[maybe_unused]],
7275 bool reset [[maybe_unused]]) {
7276 return false;
7277 }
7278
7279 /**
7280 Adjust definition of table to be created by adding implicit columns
7281 and indexes necessary for the storage engine.
7282
7283 @param [in] create_info HA_CREATE_INFO describing the table.
7284 @param [in] create_list List of columns in the table.
7285 @param [in] key_info Array of KEY objects describing table
7286 indexes.
7287 @param [in] key_count Number of indexes in the table.
7288 @param [in,out] table_obj dd::Table object describing the table
7289 to be created. Implicit columns and
7290 indexes are to be added to this object.
7291 Adjusted table description will be
7292 saved into the data-dictionary.
7293
7294 @retval 0 Success.
7295 @retval non-0 Error.
7296 */
7298 const HA_CREATE_INFO *create_info [[maybe_unused]],
7299 const List<Create_field> *create_list [[maybe_unused]],
7300 const KEY *key_info [[maybe_unused]], uint key_count [[maybe_unused]],
7301 dd::Table *table_obj [[maybe_unused]]) {
7302 return 0;
7303 }
7304
7305 virtual bool set_ha_share_ref(Handler_share **arg_ha_share) {
7306 ha_share = arg_ha_share;
7307 return false;
7308 }
7309
7310 void set_ha_table(TABLE *table_arg) { table = table_arg; }
7311
7312 int get_lock_type() const { return m_lock_type; }
7313
7314 /**
7315 Callback function that will be called by my_prepare_gcolumn_template
7316 once the table has been opened.
7317 */
7318 typedef void (*my_gcolumn_template_callback_t)(const TABLE *, void *);
7319 static bool my_prepare_gcolumn_template(THD *thd, const char *db_name,
7320 const char *table_name,
7322 void *ib_table);
7323 static bool my_eval_gcolumn_expr_with_open(THD *thd, const char *db_name,
7324 const char *table_name,
7325 const MY_BITMAP *const fields,
7326 uchar *record,
7327 const char **mv_data_ptr,
7328 ulong *mv_length);
7329
7330 /**
7331 Callback for computing generated column values.
7332
7333 Storage engines that need to have virtual column values for a row
7334 can use this function to get the values computed. The storage
7335 engine must have filled in the values for the base columns that
7336 the virtual columns depend on.
7337
7338 @param thd thread handle
7339 @param table table object
7340 @param fields bitmap of field index of evaluated generated
7341 column
7342 @param[in,out] record buff of base columns generated column depends.
7343 After calling this function, it will be
7344 used to return the value of the generated
7345 columns.
7346 @param[out] mv_data_ptr When given (not null) and the field
7347 needs to be calculated is a typed array field, it
7348 will contain pointer to field's calculated value.
7349 @param[out] mv_length Length of the data above
7350 @param[in] include_stored_gcols if true, evaluate both stored and virtual
7351 gcols. if false, evaluate only virtual gcol.
7352
7353 @retval true in case of error
7354 @retval false on success
7355 */
7356 static bool my_eval_gcolumn_expr(THD *thd, TABLE *table,
7357 const MY_BITMAP *const fields, uchar *record,
7358 const char **mv_data_ptr, ulong *mv_length,
7359 bool include_stored_gcols);
7360
7361 /* This must be implemented if the handlerton's partition_flags() is set. */
7362 virtual Partition_handler *get_partition_handler() { return nullptr; }
7363
7364 /**
7365 Set se_private_id and se_private_data during upgrade
7366
7367 @param thd Pointer of THD
7368 @param dbname Database name
7369 @param table_name Table name
7370 @param dd_table dd::Table for the table
7371 @param table_arg TABLE object for the table.
7372
7373 @return Operation status
7374 @retval false Success
7375 @retval true Error
7376 */
7377
7378 bool ha_upgrade_table(THD *thd, const char *dbname, const char *table_name,
7379 dd::Table *dd_table, TABLE *table_arg);
7380
7381 /**
7382 Store a pointer to the handler of the primary table that
7383 corresponds to the secondary table in this handler.
7384 */
7385 void ha_set_primary_handler(handler *primary_handler);
7386
7387 /**
7388 Get a pointer to a handler for the table in the primary storage
7389 engine, if this handler is for a table in a secondary storage
7390 engine.
7391 */
7393
7394 /**
7395 Return max limits for a single set of multi-valued keys
7396
7397 @param[out] num_keys number of keys to store
7398 @param[out] keys_length total length of keys, bytes
7399 */
7400 void ha_mv_key_capacity(uint *num_keys, size_t *keys_length) const {
7401 return mv_key_capacity(num_keys, keys_length);
7402 }
7403
7404 /**
7405 Propagates the secondary storage engine offload failure reason for a query
7406 to the external engine when the offloaded query fails in the secondary
7407 storage engine.
7408 */
7409 virtual void set_external_table_offload_error(const char * /*reason*/) {}
7410
7411 /**
7412 Identifies and throws the propagated external engine query offload or exec
7413 failure reason given by the external engine handler.
7414 */
7415 virtual void external_table_offload_error() const {}
7416
7417 private:
7418 /**
7419 Engine-specific function for ha_can_store_mv_keys().
7420 Dummy function. SE's overloaded method is used instead.
7421 */
7422 /* purecov: begin inspected */
7423 virtual void mv_key_capacity(uint *num_keys, size_t *keys_length) const {
7424 *num_keys = 0;
7425 *keys_length = 0;
7426 }
7427 /* purecov: end */
7428
7429 /**
7430 Filter duplicate records when multi-valued index is used for retrieval
7431
7432 @returns
7433 true duplicate, such row id was already seen
7434 false row id is seen for the first time
7435 */
7436 bool filter_dup_records();
7437
7438 protected:
7440 void set_ha_share_ptr(Handler_share *arg_ha_share);
7441 void lock_shared_ha_data();
7442 void unlock_shared_ha_data();
7443
7444 friend class DsMrr_impl;
7445};
7446
7447/* Temporary Table handle for opening uncached table */
7449 public:
7451
7452 /** Open the table handler
7453 @param[in] thd Thread object
7454 @param[in] db_name Database name
7455 @param[in] table_name Table name
7456 @return table object or nullptr */
7457 TABLE *open(THD *thd, const char *db_name, const char *table_name);
7458
7460
7461 private:
7463};
7464
7465/**
7466 Function identifies any old data type present in table.
7467
7468 This function was handler::check_old_types().
7469 Function is not part of SE API. It is now converted to
7470 auxiliary standalone function.
7471
7472 @param[in] table TABLE object
7473
7474 @retval 0 ON SUCCESS
7475 @retval error code ON FAILURE
7476*/
7477
7479
7480/*
7481 A Disk-Sweep MRR interface implementation
7482
7483 This implementation makes range (and, in the future, 'ref') scans to read
7484 table rows in disk sweeps.
7485
7486 Currently it is used by MyISAM and InnoDB. Potentially it can be used with
7487 any table handler that has non-clustered indexes and on-disk rows.
7488*/
7489
7491 public:
7492 DsMrr_impl(handler *owner) : h(owner), table(nullptr), h2(nullptr) {}
7493
7495 /*
7496 If ha_reset() has not been called then the h2 dialog might still
7497 exist. This must be closed and deleted (this is the case for
7498 internally created temporary tables).
7499 */
7500 if (h2) reset();
7501 assert(h2 == nullptr);
7502 }
7503
7504 private:
7505 /*
7506 The "owner" handler object (the one that calls dsmrr_XXX functions.
7507 It is used to retrieve full table rows by calling rnd_pos().
7508 */
7509 handler *const h;
7510 TABLE *table; /* Always equal to h->table */
7511
7512 /* Secondary handler object. It is used for scanning the index */
7514
7515 /* Buffer to store rowids, or (rowid, range_id) pairs */
7517 uchar *rowids_buf_cur; /* Current position when reading/writing */
7518 uchar *rowids_buf_last; /* When reading: end of used buffer space */
7519 uchar *rowids_buf_end; /* End of the buffer */
7520
7521 bool dsmrr_eof; /* true <=> We have reached EOF when reading index tuples */
7522
7523 /* true <=> need range association, buffer holds {rowid, range_id} pairs */
7525
7526 bool use_default_impl; /* true <=> shortcut all calls to default MRR impl */
7527 public:
7528 /**
7529 Initialize the DsMrr_impl object.
7530
7531 This object is used for both doing default MRR scans and DS-MRR scans.
7532 This function just initializes the object. To do a DS-MRR scan,
7533 this must also be initialized by calling dsmrr_init().
7534
7535 @param table_arg pointer to the TABLE that owns the handler
7536 */
7537
7538 void init(TABLE *table_arg) {
7539 assert(table_arg != nullptr);
7540 table = table_arg;
7541 }
7542
7543 int dsmrr_init(RANGE_SEQ_IF *seq_funcs, void *seq_init_param, uint n_ranges,
7544 uint mode, HANDLER_BUFFER *buf);
7545 void dsmrr_close();
7546
7547 /**
7548 Resets the DS-MRR object to the state it had after being initialized.
7549
7550 If there is an open scan then it will be closed.
7551
7552 This function should be called by handler::ha_reset() which is called
7553 when a statement is completed in order to make the handler object ready
7554 for re-use by a different statement.
7555 */
7556
7557 void reset();
7558 int dsmrr_fill_buffer();
7559 int dsmrr_next(char **range_info);
7560
7561 ha_rows dsmrr_info(uint keyno, uint n_ranges, uint keys, uint *bufsz,
7562 uint *flags, Cost_estimate *cost);
7563
7564 ha_rows dsmrr_info_const(uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param,
7565 uint n_ranges, uint *bufsz, uint *flags,
7566 Cost_estimate *cost);
7567
7568 private:
7569 bool choose_mrr_impl(uint keyno, ha_rows rows, uint *flags, uint *bufsz,
7570 Cost_estimate *cost);
7571 bool get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags,
7572 uint *buffer_size, Cost_estimate *cost);
7573};
7574
7575/* lookups */
7579/**
7580 Resolve handlerton plugin by name, without checking for "DEFAULT" or
7581 HTON_NOT_USER_SELECTABLE.
7582
7583 @param thd Thread context.
7584 @param name Plugin name.
7585
7586 @return plugin or NULL if not found.
7587*/
7590 bool is_temp_table);
7591plugin_ref ha_lock_engine(THD *thd, const handlerton *hton);
7593handler *get_new_handler(TABLE_SHARE *share, bool partitioned, MEM_ROOT *alloc,
7594 handlerton *db_type);
7595handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type,
7596 bool no_substitute, bool report_error);
7597
7599 THD *thd, const LEX_CSTRING &secondary_engine) noexcept;
7600
7601/**
7602 Get default handlerton, if handler supplied is null.
7603
7604 @param thd Thread context.
7605 @param hton The handlerton passed.
7606
7607 @returns pointer to handlerton.
7608*/
7610 if (!hton) {
7611 hton = ha_checktype(thd, DB_TYPE_UNKNOWN, false, false);
7612 assert(hton);
7613 }
7614 return hton;
7615}
7616
7617static inline enum legacy_db_type ha_legacy_type(const handlerton *db_type) {
7618 return (db_type == nullptr) ? DB_TYPE_UNKNOWN : db_type->db_type;
7619}
7620
7621const char *ha_resolve_storage_engine_name(const handlerton *db_type);
7622
7623static inline bool ha_check_storage_engine_flag(const handlerton *db_type,
7624 uint32 flag) {
7625 return db_type == nullptr ? false : (db_type->flags & flag);
7626}
7627
7628/**
7629 Predicate to determine if a storage engine, represented by a handlerton*, is
7630 enabled.
7631 @note "Enabled" in this context refers only the state of the handlerton
7632 object, and does not consider the disabled_storage_engines system variable.
7633 This leads to the very counter-intuitive and confusing situation that it is
7634 possible for a storage engine to be enabled, but at the same time also be
7635 disabled.
7636 */
7637inline bool ha_storage_engine_is_enabled(const handlerton *db_type) {
7638 return (db_type && db_type->create) ? (db_type->state == SHOW_OPTION_YES)
7639 : false;
7640}
7641
7642/* basic stuff */
7643int ha_init_errors(void);
7644int ha_init(void);
7645void ha_end();
7648
7651void ha_reset_plugin_vars(THD *thd);
7652void ha_close_connection(THD *thd);
7653void ha_kill_connection(THD *thd);
7654/** Invoke handlerton::pre_dd_shutdown() on every storage engine plugin. */
7655void ha_pre_dd_shutdown(void);
7656
7657/**
7658 Flush the log(s) of storage engine(s).
7659
7660 @param binlog_group_flush true if we got invoked by binlog group
7661 commit during flush stage, false in other cases.
7662 @retval false Succeed
7663 @retval true Error
7664*/
7665bool ha_flush_logs(bool binlog_group_flush = false);
7666
7667/**
7668 Call the "drop_database_t" handlerton API for storage engines that
7669 implemented it to drop the database.
7670
7671 @param schema_name name of the database to be dropped.
7672*/
7673void ha_drop_database(const char *schema_name);
7674
7675/**
7676 Call "log_ddl_drop_schema" handletron for
7677 storage engines who implement it.
7678
7679 @param schema_name name of the database to be dropped.
7680 @retval false Succeed
7681 @retval true Error
7682*/
7683bool ha_log_ddl_drop_schema(const char *schema_name);
7684
7685/**
7686 Call "log_ddl_create_schema" handletron for
7687 storage engines who implement it.
7688
7689 @param schema_name name of the database to be dropped.
7690 @retval false Succeed
7691 @retval true Error
7692*/
7693bool ha_log_ddl_create_schema(const char *schema_name);
7694
7695int ha_create_table(THD *thd, const char *path, const char *db,
7696 const char *table_name, HA_CREATE_INFO *create_info,
7697 bool update_create_info, bool is_temp_table,
7699
7700int ha_delete_table(THD *thd, handlerton *db_type, const char *path,
7701 const char *db, const char *alias,
7702 const dd::Table *table_def, bool generate_warning);
7703bool ha_check_reserved_db_name(const char *name);
7704
7705/* statistics and info */
7706bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat);
7707
7708typedef bool Log_func(THD *, TABLE *, bool, const uchar *, const uchar *);
7709
7710int binlog_log_row(TABLE *table, const uchar *before_record,
7711 const uchar *after_record, Log_func *log_func);
7712
7713/* discovery */
7714int ha_create_table_from_engine(THD *thd, const char *db, const char *name);
7715bool ha_check_if_table_exists(THD *thd, const char *db, const char *name,
7716 bool *exists);
7717int ha_find_files(THD *thd, const char *db, const char *path, const char *wild,
7718 bool dir, List<LEX_STRING> *files);
7719int ha_table_exists_in_engine(THD *thd, const char *db, const char *name);
7720bool ha_check_if_supported_system_table(handlerton *hton, const char *db,
7721 const char *table_name);
7722bool ha_rm_tmp_tables(THD *thd, List<LEX_STRING> *files);
7723bool default_rm_tmp_tables(handlerton *hton, THD *thd, List<LEX_STRING> *files);
7724
7725/* key cache */
7726int ha_init_key_cache(std::string_view name, KEY_CACHE *key_cache);
7727int ha_resize_key_cache(KEY_CACHE *key_cache);
7728int ha_change_key_cache(KEY_CACHE *old_key_cache, KEY_CACHE *new_key_cache);
7729
7730/* transactions: interface to handlerton functions */
7732int ha_commit_trans(THD *thd, bool all, bool ignore_global_read_lock = false);
7733int ha_commit_attachable(THD *thd);
7734int ha_rollback_trans(THD *thd, bool all);
7735
7736/**
7737 Stage of the recovery process where information is collected from the
7738 storage engines (SE), merged with information from the transaction
7739 coordinator (TC) and transactions states are determined and enforced.
7740
7741 Implemented heuristics is as follows:
7742
7743 1. The `commit_list` parameter contains the set of internally coordinated
7744 transactions that the TC ensures were marked as committed.
7745
7746 2. The `xa_state_list` parameter contains the list of externally
7747 coordinated transactions and their states, as recorded by the TC.
7748
7749 3. For each SE:
7750 a. Collect list of transactions found in `PREPARED_IN_TC` state in the
7751 SE and merge it with the information collected from the TC, in
7752 `xa_state_list`.
7753 b. Retrieve the list of transactions found in prepared state in the
7754 SE.
7755
7756 c. For each internally coordinated transactions found in prepared
7757 state:
7758 1. If the transaction is found in `commit_list`, commit it.
7759 2. If the transaction is NOT found in `commit_list` but
7760 `tc_heuristic_recover = TC_HEURISTIC_RECOVER_COMMIT`, commit it.
7761 3. Otherwise, roll it back.
7762
7763 d. For each externally coordinated transactions found in prepared
7764 state:
7765 1. If the transaction isn't found in `xa_state_list`, roll it back.
7766 2. If the transaction is found in `xa_state_list` in `COMMITTED`
7767 state, commit it.
7768 3. If the transaction is found in `xa_state_list` in `ROLLEDBACK`
7769 state, roll it back.
7770 4. If the transaction is found in `xa_state_list` in `PREPARED`
7771 state, ensure that the transaction state in the SE is
7772 `PREPARED_IN_TC`.
7773
7774 @param commit_list Set of XIDs of internally coordinated transactions
7775 found as been committed in the transaction coordinator
7776 state.
7777 @param xa_state_list Map between XIDs and states of externally
7778 coordinated transactions as found in the internal
7779 transaction coordinator state.
7780
7781 @return 0 if recovery was successful, non-zero otherwise.
7782*/
7783int ha_recover(Xid_commit_list *commit_list = nullptr,
7784 Xa_state_list *xa_state_list = nullptr);
7785
7786/**
7787 Perform SE-specific cleanup after recovery of transactions.
7788
7789 @note SE supporting atomic DDL can use this method to perform
7790 post-DDL actions for DDL statements which were committed
7791 or rolled back during recovery stage.
7792*/
7793void ha_post_recover();
7794
7795/*
7796 transactions: interface to low-level handlerton functions. These are
7797 intended to be used by the transaction coordinators to
7798 commit/prepare/rollback transactions in the engines.
7799*/
7800int ha_commit_low(THD *thd, bool all, bool run_after_commit = true);
7801/**
7802 Prepares the underlying transaction of the THD session object parameter
7803 in the storage engines that participate in the transaction.
7804
7805 In case of failure, an error will be emitted by the function in the case
7806 of internally coordinated transactions. In the case of externally
7807 coordinated transactions (XA), the error treatment must follow the
7808 XA/Open specification and is handled by the `Sql_cmd_xa_prepare` class.
7809
7810 @param thd The THD session object holding the transaction to be prepared.
7811 @param all Whether or not the prepare regards a full transaction or the
7812 statement being executed..
7813
7814 @return 0 if the transaction was successfully prepared, non-zero
7815 otherwise.
7816 */
7817int ha_prepare_low(THD *thd, bool all);
7818int ha_rollback_low(THD *thd, bool all);
7819
7820/* transactions: these functions never call handlerton functions directly */
7821int ha_enable_transaction(THD *thd, bool on);
7822
7823/* savepoints */
7826int ha_savepoint(THD *thd, SAVEPOINT *sv);
7827int ha_release_savepoint(THD *thd, SAVEPOINT *sv);
7828
7829/* these are called by storage engines */
7830void trans_register_ha(THD *thd, bool all, handlerton *ht,
7831 const ulonglong *trxid);
7832
7833int ha_reset_logs(THD *thd);
7834
7835/**
7836 Inform storage engine(s) that a binary log file will be purged and any
7837 references to it should be removed.
7838
7839 The function is called for all purged files, regardless if it is an explicit
7840 PURGE BINARY LOGS statement, or an automatic purge performed by the server.
7841
7842 @note Since function is called with the LOCK_index mutex held the work
7843 performed in this callback should be kept at minimum. One way to defer work is
7844 to schedule work and use the `ha_binlog_index_purge_wait` callback to wait for
7845 completion.
7846
7847 @param thd Thread handle of session purging file. The nullptr value indicates
7848 that purge is done at server startup.
7849 @param file Name of file being purged.
7850 @return Always 0, return value are ignored by caller.
7851*/
7852int ha_binlog_index_purge_file(THD *thd, const char *file);
7853
7854/**
7855 Request the storage engine to complete any operations that were initiated
7856 by `ha_binlog_index_purge_file` and which need to complete
7857 before PURGE BINARY LOGS completes.
7858
7859 The function is called only from PURGE BINARY LOGS. Each PURGE BINARY LOGS
7860 statement will result in 0, 1 or more calls to `ha_binlog_index_purge_file`,
7861 followed by exactly 1 call to `ha_binlog_index_purge_wait`.
7862
7863 @note This function is called without LOCK_index mutex held and thus any
7864 waiting performed will only affect the current session.
7865
7866 @param thd Thread handle of session.
7867*/
7869
7870void ha_reset_slave(THD *thd);
7871void ha_binlog_log_query(THD *thd, handlerton *db_type,
7872 enum_binlog_command binlog_command, const char *query,
7873 size_t query_length, const char *db,
7874 const char *table_name);
7875void ha_acl_notify(THD *thd, class Acl_change_notification *);
7876void ha_binlog_wait(THD *thd);
7877
7878/* It is required by basic binlog features on both MySQL server and libmysqld */
7879int ha_binlog_end(THD *thd);
7880
7881const char *get_canonical_filename(handler *file, const char *path,
7882 char *tmp_path);
7883
7884const char *table_case_name(const HA_CREATE_INFO *info, const char *name);
7885
7886void print_keydup_error(TABLE *table, KEY *key, const char *msg, myf errflag,
7887 const char *org_table_name);
7888void print_keydup_error(TABLE *table, KEY *key, myf errflag,
7889 const char *org_table_name);
7890
7891inline void print_keydup_error(TABLE *table, KEY *key, const char *msg,
7892 myf errflag) {
7893 print_keydup_error(table, key, msg, errflag, nullptr);
7894}
7895inline void print_keydup_error(TABLE *table, KEY *key, myf errflag) {
7896 print_keydup_error(table, key, errflag, nullptr);
7897}
7898
7900
7901bool ha_notify_exclusive_mdl(THD *thd, const MDL_key *mdl_key,
7902 ha_notification_type notification_type,
7903 bool *victimized);
7904bool ha_notify_table_ddl(THD *thd, const MDL_key *mdl_key,
7905 ha_notification_type notification_type,
7906 ha_ddl_type ddl_type, const char *old_db_name,
7907 const char *old_table_name, const char *new_db_name,
7908 const char *new_table_name);
7909
7910std::pair<int, bool> commit_owned_gtids(THD *thd, bool all);
7911bool set_tx_isolation(THD *thd, enum_tx_isolation tx_isolation, bool one_shot);
7913
7914/*
7915 This class is used by INFORMATION_SCHEMA.FILES to read SE specific
7916 tablespace dynamic metadata. Some member like m_type and id, is not
7917 really dynamic, but as this information is not stored in data dictionary
7918 in a generic format and still is SE specific Some member like m_type and
7919 id, is not really dynamic, but as this information is not stored in data
7920 dictionary in a generic format and still needs SE specific decision, we
7921 are requesting the same from SE.
7922*/
7923
7925 public:
7927 : m_id(0),
7929 m_free_extents(0),
7930 m_total_extents(0),
7931 m_extent_size(0),
7932 m_initial_size(0),
7933 m_maximum_size(0),
7935 m_version(~0ULL),
7936 m_data_free(0) {}
7937
7953};
7954
7955#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:3516
static const HA_ALTER_FLAGS COALESCE_PARTITION
Definition: handler.h:3633
Alter_info * alter_info
Alter options, fields and keys for the new version of table.
Definition: handler.h:3733
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:3675
uint key_count
Size of key_info_buffer array.
Definition: handler.h:3769
static const HA_ALTER_FLAGS ALTER_VIRTUAL_COLUMN_TYPE
Definition: handler.h:3575
static const HA_ALTER_FLAGS DROP_PARTITION
Definition: handler.h:3627
static const HA_ALTER_FLAGS ADD_VIRTUAL_COLUMN
Definition: handler.h:3556
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:3869
KEY * key_info_buffer
Array of KEYs for new version of table - including KEYs to be added.
Definition: handler.h:3766
static const HA_ALTER_FLAGS ADD_FOREIGN_KEY
Definition: handler.h:3606
static const HA_ALTER_FLAGS DROP_COLUMN
Definition: handler.h:3568
static const HA_ALTER_FLAGS ALTER_COLUMN_INDEX_LENGTH
Change in index length such that it does not require index rebuild.
Definition: handler.h:3685
static const HA_ALTER_FLAGS ADD_STORED_GENERATED_COLUMN
Definition: handler.h:3560
static const HA_ALTER_FLAGS ALTER_TABLE_REORG
Definition: handler.h:3639
static const HA_ALTER_FLAGS VALIDATE_VIRTUAL_COLUMN
Definition: handler.h:3668
static const HA_ALTER_FLAGS ADD_SPATIAL_INDEX
Definition: handler.h:3662
static const HA_ALTER_FLAGS DROP_CHECK_CONSTRAINT
Definition: handler.h:3703
static const HA_ALTER_FLAGS ALTER_STORED_GCOL_EXPR
Definition: handler.h:3603
uint virtual_column_add_count
Number of virtual columns to be added.
Definition: handler.h:3807
static const HA_ALTER_FLAGS RECREATE_TABLE
Recreate the table for ALTER TABLE FORCE, ALTER TABLE ENGINE and OPTIMIZE TABLE operations.
Definition: handler.h:3659
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:3697
static const HA_ALTER_FLAGS ADD_PARTITION
Definition: handler.h:3624
static const HA_ALTER_FLAGS ADD_STORED_BASE_COLUMN
Definition: handler.h:3558
static const HA_ALTER_FLAGS ADD_PK_INDEX
Definition: handler.h:3548
uint index_drop_count
Size of index_drop_buffer array.
Definition: handler.h:3772
ulonglong HA_ALTER_FLAGS
Bits to show in detail what operations the storage engine is to execute.
Definition: handler.h:3533
static const HA_ALTER_FLAGS ALTER_COLUMN_STORAGE_TYPE
Definition: handler.h:3618
static const HA_ALTER_FLAGS ALTER_COLUMN_NAME
Definition: handler.h:3572
static const HA_ALTER_FLAGS ALTER_COLUMN_COLUMN_FORMAT
Definition: handler.h:3621
static const HA_ALTER_FLAGS ADD_COLUMN
Definition: handler.h:3562
static const HA_ALTER_FLAGS ALTER_REBUILD_PARTITION
Definition: handler.h:3678
static const HA_ALTER_FLAGS ALTER_INDEX_COMMENT
Definition: handler.h:3665
KEY_PAIR * index_rename_buffer
Array of KEY_PAIR objects describing indexes being renamed.
Definition: handler.h:3803
uint index_altered_visibility_count
Size of index_rename_buffer array.
Definition: handler.h:3793
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:3749
static const HA_ALTER_FLAGS ADD_CHECK_CONSTRAINT
Definition: handler.h:3700
static const HA_ALTER_FLAGS ALTER_RENAME
Definition: handler.h:3615
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:3914
static const HA_ALTER_FLAGS SUSPEND_CHECK_CONSTRAINT
Definition: handler.h:3706
static const HA_ALTER_FLAGS ALTER_REMOVE_PARTITIONING
Definition: handler.h:3642
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:3584
uint index_add_count
Size of index_add_buffer array.
Definition: handler.h:3781
static const HA_ALTER_FLAGS REORGANIZE_PARTITION
Definition: handler.h:3636
inplace_alter_handler_ctx * handler_ctx
Context information to allow handlers to keep context between in-place alter API calls.
Definition: handler.h:3818
static const HA_ALTER_FLAGS ALTER_VIRTUAL_GCOL_EXPR
Definition: handler.h:3602
static const HA_ALTER_FLAGS ADD_INDEX
Definition: handler.h:3536
static const HA_ALTER_FLAGS DROP_FOREIGN_KEY
Definition: handler.h:3609
uint index_rename_count
Size of index_rename_buffer array.
Definition: handler.h:3790
static const HA_ALTER_FLAGS ADD_UNIQUE_INDEX
Definition: handler.h:3542
HA_CREATE_INFO * create_info
Create options (like MAX_ROWS) for the new version of table.
Definition: handler.h:3720
uint handler_trivial_ctx
Can be set by handler along with handler_ctx.
Definition: handler.h:3855
KEY_PAIR * index_altered_visibility_buffer
Definition: handler.h:3804
static const HA_ALTER_FLAGS DROP_INDEX
Definition: handler.h:3539
static const HA_ALTER_FLAGS ALTER_COLUMN_NOT_NULLABLE
Definition: handler.h:3596
static const HA_ALTER_FLAGS DROP_UNIQUE_INDEX
Definition: handler.h:3545
static const HA_ALTER_FLAGS ALTER_PARTITION
Definition: handler.h:3630
static const HA_ALTER_FLAGS ALTER_COLUMN_NULLABLE
Definition: handler.h:3593
partition_info * modified_part_info
Partition_info taking into account the partition changes to be performed.
Definition: handler.h:3844
HA_ALTER_FLAGS handler_flags
Flags describing in detail which operations the storage engine is to execute.
Definition: handler.h:3836
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:3871
~Alter_inplace_info()
Definition: handler.h:3897
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:3691
void add_added_key(KEY *new_key)
Add key to array of indexes to be added.
Definition: handler.h:3948
void add_altered_index_visibility(KEY *old_key, KEY *new_key)
Definition: handler.h:3922
static const HA_ALTER_FLAGS ALTER_VIRTUAL_COLUMN_ORDER
A virtual column has changed its position.
Definition: handler.h:3587
static const HA_ALTER_FLAGS RENAME_INDEX
Rename index.
Definition: handler.h:3653
uint virtual_column_drop_count
number of virtual columns to be dropped.
Definition: handler.h:3810
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:3935
static const HA_ALTER_FLAGS DROP_PK_INDEX
Definition: handler.h:3551
static const HA_ALTER_FLAGS ALTER_STORED_COLUMN_ORDER
A stored column has changed its position (disregarding virtual columns)
Definition: handler.h:3590
bool online
true for online operation (LOCK=NONE)
Definition: handler.h:3847
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:3778
uint * index_add_buffer
Array of indexes into key_info_buffer for KEYs to be added, sorted in increasing order.
Definition: handler.h:3787
void add_dropped_key(KEY *old_key)
Drop key to array of indexes to be dropped.
Definition: handler.h:3942
static const HA_ALTER_FLAGS CHANGE_CREATE_OPTION
Definition: handler.h:3612
static const HA_ALTER_FLAGS DROP_VIRTUAL_COLUMN
Definition: handler.h:3566
static const HA_ALTER_FLAGS ALTER_COLUMN_VISIBILITY
Definition: handler.h:3709
static const HA_ALTER_FLAGS ALTER_STORED_COLUMN_TYPE
Definition: handler.h:3576
inplace_alter_handler_ctx ** group_commit_ctx
If the table uses several handlers, like ha_partition uses one handler per partition,...
Definition: handler.h:3830
static const HA_ALTER_FLAGS ALTER_COLUMN_DEFAULT
Definition: handler.h:3599
static const HA_ALTER_FLAGS DROP_STORED_COLUMN
Definition: handler.h:3567
static const HA_ALTER_FLAGS ALTER_ALL_PARTITION
Definition: handler.h:3645
Used to store optimizer cost estimates.
Definition: handler.h:4028
Cost_estimate & operator+=(const Cost_estimate &other)
Definition: handler.h:4077
Cost_estimate operator-(const Cost_estimate &other)
Definition: handler.h:4095
void add_import(double add_import_cost)
Add to import cost.
Definition: handler.h:4128
void reset()
Reset all costs to zero.
Definition: handler.h:4060
void set_max_cost()
Set current cost to the maximal double.
Definition: handler.h:4062
Cost_estimate()
Definition: handler.h:4036
void add_cpu(double add_cpu_cost)
Add to CPU cost.
Definition: handler.h:4122
double mem_cost
memory used (bytes)
Definition: handler.h:4033
double io_cost
cost of I/O operations
Definition: handler.h:4030
bool is_max_cost() const
Whether or not the total cost is the maximal double.
Definition: handler.h:4058
void add_mem(double add_mem_cost)
Add to memory cost.
Definition: handler.h:4134
bool operator<(const Cost_estimate &other) const
Definition: handler.h:4111
double get_cpu_cost() const
Definition: handler.h:4041
double get_mem_cost() const
Definition: handler.h:4043
double total_cost() const
Returns sum of time-consuming costs, i.e., not counting memory cost.
Definition: handler.h:4039
double get_io_cost() const
Definition: handler.h:4040
void add_io(double add_io_cost)
Add to IO cost.
Definition: handler.h:4116
double import_cost
cost of remote operations
Definition: handler.h:4032
double cpu_cost
cost of CPU operations
Definition: handler.h:4031
double get_import_cost() const
Definition: handler.h:4042
void multiply(double m)
Multiply io, cpu and import costs by parameter.
Definition: handler.h:4068
bool is_zero() const
Whether or not all costs in the object are zero.
Definition: handler.h:4050
bool operator>(const Cost_estimate &other) const
Definition: handler.h:4107
Cost_estimate operator+(const Cost_estimate &other)
Definition: handler.h:4088
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:7490
DsMrr_impl(handler *owner)
Definition: handler.h:7492
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:7519
uchar * rowids_buf_cur
Definition: handler.h:7517
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:7516
handler * h2
Definition: handler.h:7513
handler *const h
Definition: handler.h:7509
~DsMrr_impl()
Definition: handler.h:7494
bool use_default_impl
Definition: handler.h:7526
void init(TABLE *table_arg)
Initialize the DsMrr_impl object.
Definition: handler.h:7538
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:7521
bool is_mrr_assoc
Definition: handler.h:7524
uchar * rowids_buf_last
Definition: handler.h:7518
TABLE * table
Definition: handler.h:7510
int dsmrr_next(char **range_info)
Definition: handler.cc:7011
Definition: field.h:570
Wrapper for struct ft_hints.
Definition: handler.h:4295
uint get_flags() const
Get Ft_hints flags.
Definition: handler.h:4358
void set_hint_flag(uint ft_flag)
Set Ft_hints flag.
Definition: handler.h:4323
double get_op_value() const
Get Ft_hints operation value.
Definition: handler.h:4344
struct ft_hints * get_hints()
Get ft_hints struct.
Definition: handler.h:4365
Ft_hints(uint ft_flags)
Definition: handler.h:4300
ha_rows get_limit() const
Get Ft_hints limit.
Definition: handler.h:4337
enum ft_operation get_op_type() const
Get Ft_hints operation type.
Definition: handler.h:4351
void set_hint_limit(ha_rows ft_limit)
Set Ft_hints limit.
Definition: handler.h:4330
void set_hint_op(enum ft_operation type, double value)
Set comparison operation type and and value for master MATCH function.
Definition: handler.h:4313
struct ft_hints hints
Definition: handler.h:4297
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:4285
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:3037
Definition: parse_tree_nodes.h:3060
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:302
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:2933
Data structure that contains the information about shared tablespaces.
Definition: fsp0space.h:47
Definition: handler.h:7448
Temp_table_handle()
Definition: handler.h:7450
~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:7462
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:4253
ha_rows num_distinct_values
Definition: handler.h:4255
ha_column_statistics()
Definition: handler.h:4257
Definition: handler.h:4199
ulonglong index_file_length
Definition: handler.h:4203
uint block_size
Definition: handler.h:4222
ulonglong data_file_length
Definition: handler.h:4201
ulong update_time
Definition: handler.h:4221
ha_rows records
Definition: handler.h:4215
ulonglong max_data_file_length
Definition: handler.h:4202
ulong check_time
Definition: handler.h:4220
time_t create_time
Definition: handler.h:4219
ulonglong max_index_file_length
Definition: handler.h:4204
ulong mean_rec_length
Definition: handler.h:4217
ulonglong auto_increment_value
Definition: handler.h:4206
ha_statistics()
Definition: handler.h:4237
double table_in_mem_estimate
Estimate for how much of the table that is available in a memory buffer.
Definition: handler.h:4235
ulonglong delete_length
Definition: handler.h:4205
uint mrr_length_per_rec
Definition: handler.h:4227
ha_rows deleted
Definition: handler.h:4216
Definition: handler.h:7924
ulonglong m_id
Definition: handler.h:7938
ulonglong m_initial_size
Definition: handler.h:7945
dd::String_type m_row_format
Definition: handler.h:7949
ulonglong m_data_free
Definition: handler.h:7950
ulonglong m_version
Definition: handler.h:7948
dd::String_type m_status
Definition: handler.h:7951
ulonglong m_maximum_size
Definition: handler.h:7946
ulonglong m_logfile_group_number
Definition: handler.h:7941
ulonglong m_free_extents
Definition: handler.h:7942
ha_tablespace_statistics()
Definition: handler.h:7926
ulonglong m_autoextend_size
Definition: handler.h:7947
ulonglong m_total_extents
Definition: handler.h:7943
ulonglong m_extent_size
Definition: handler.h:7944
dd::String_type m_logfile_group_name
Definition: handler.h:7940
dd::String_type m_type
Definition: handler.h:7939
dd::String_type m_extra
Definition: handler.h:7952
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4741
virtual int sample_end(void *scan_ctx)
End sampling.
Definition: handler.cc:3242
KEY_PART_INFO * range_key_part
Definition: handler.h:4801
virtual int ft_read(uchar *)
Definition: handler.h:5916
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:6996
ulonglong insert_id_for_cur_row
insert id for the current row (autogenerated; if not autogenerated, it's 0).
Definition: handler.h:4851
virtual bool is_index_algorithm_supported(enum ha_key_alg key_alg) const
Check if SE supports specific key algorithm.
Definition: handler.h:5773
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:7409
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:5421
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:4798
void * Blob_context
Definition: handler.h:4746
virtual ~handler(void)
Definition: handler.h:5002
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:5282
int ha_index_init(uint idx, bool sorted)
Initialize use of index.
Definition: handler.cc:3019
virtual int index_prev(uchar *)
Definition: handler.h:5860
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:7415
virtual uint max_supported_key_length() const
Definition: handler.h:6226
enum handler::@60 inited
const Item * pushed_cond
Definition: handler.h:4830
void set_ha_table(TABLE *table_arg)
Definition: handler.h:7310
Unique_on_insert * m_unique
Definition: handler.h:4966
virtual int reset()
Reset state of file to after 'open'.
Definition: handler.h:6946
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:5863
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:4963
batch_mode_t
Internal state of the batch instrumentation.
Definition: handler.h:4875
@ PSI_BATCH_MODE_STARTING
Batch mode used, before first table io.
Definition: handler.h:4879
@ PSI_BATCH_MODE_STARTED
Batch mode used, after first table io.
Definition: handler.h:4881
@ PSI_BATCH_MODE_NONE
Batch mode not used.
Definition: handler.h:4877
Discrete_interval auto_inc_interval_for_cur_row
Interval returned by get_auto_increment() and being consumed by the inserter.
Definition: handler.h:4856
void restore_auto_increment(ulonglong prev_insert_id)
Definition: handler.h:6154
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:5762
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:4807
uint ranges_in_seq
Definition: handler.h:4768
uint max_key_parts() const
Definition: handler.h:6213
virtual bool primary_key_is_clustered() const
Check if the primary key is clustered or not.
Definition: handler.h:6313
bool m_virt_gcol_in_end_range
Flag which tells if end_range contains a virtual generated column.
Definition: handler.h:4821
int ha_index_next_pushed(uchar *buf)
Definition: handler.cc:3725
ha_statistics stats
Definition: handler.h:4762
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:6883
virtual int enable_indexes(uint mode)
Enable indexes again.
Definition: handler.h:7224
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:6269
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:5202
virtual int bulk_load_end(THD *thd, void *load_ctx, bool is_error)
End bulk load operation.
Definition: handler.h:5328
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:6407
virtual uint max_supported_key_parts() const
Definition: handler.h:6225
enum_range_scan_direction range_scan_direction
Definition: handler.h:4791
bool eq_range
Definition: handler.h:4802
virtual int disable_indexes(uint mode)
Disable indexes for a while.
Definition: handler.h:7211
virtual uint extra_rec_buf_length() const
Definition: handler.h:5635
key_range * end_range
End value for a range scan.
Definition: handler.h:4816
virtual void init_table_handle_for_HANDLER()
Definition: handler.h:6199
uint active_index
Definition: handler.h:4824
RANGE_SEQ_IF mrr_funcs
Definition: handler.h:4766
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:5388
virtual int extra(enum ha_extra_function operation)
Storage engine specific implementation of ha_extra()
Definition: handler.h:6021
virtual void end_bulk_update()
Perform any needed clean-up, no outstanding updates are there at the moment.
Definition: handler.h:5816
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:4822
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:5953
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:6933
virtual int index_read_pushed(uchar *, const uchar *, key_part_map)
Definition: handler.h:6419
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:6429
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:4942
handlerton * ht
Definition: handler.h:4756
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:4749
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 start_read_removal(void)
Start read (before write) removal on the current table.
Definition: handler.h:6053
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:6385
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:5241
virtual void append_create_info(String *packet)
Definition: handler.h:6198
virtual uint max_supported_key_part_length(HA_CREATE_INFO *create_info) const
Definition: handler.h:6227
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:6989
virtual const Item * cond_push(const Item *cond)
Push condition down to the table handler.
Definition: handler.h:6350
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:5532
virtual int rnd_next(uchar *buf)=0
virtual void unlock_row()
Unlock last accessed row.
Definition: handler.h:6127
virtual int preload_keys(THD *, HA_CHECK_OPT *)
Definition: handler.h:6185
uint max_keys() const
Definition: handler.h:6210
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
double m_sampling_percentage
Definition: handler.h:4871
virtual FT_INFO * ft_init_ext_with_hints(uint inx, String *key, Ft_hints *hints)
Definition: handler.h:5903
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:7097
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:4833
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:5314
virtual Partition_handler * get_partition_handler()
Definition: handler.h:7362
virtual ha_rows end_read_removal(void)
End read (before write) removal and return the number of rows really written.
Definition: handler.h:6063
HANDLER_BUFFER * multi_range_buffer
Definition: handler.h:4767
const TABLE * get_table() const
Definition: handler.h:5393
uchar * ref
Pointer to current row.
Definition: handler.h:4758
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:6111
int ha_records(ha_rows *num_rows, uint index)
Wrapper function to call records_from_index() in storage engine.
Definition: handler.h:5731
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:7067
virtual int index_next(uchar *)
Definition: handler.h:5857
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:6180
virtual int rnd_end()
Definition: handler.h:6899
uint key_used_on_scan
Definition: handler.h:4823
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:4828
@ NONE
Definition: handler.h:4828
@ INDEX
Definition: handler.h:4828
@ RND
Definition: handler.h:4828
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:6982
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:5152
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:4844
virtual bool low_byte_first() const
Definition: handler.h:6235
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:4826
virtual double scan_time()
Definition: handler.h:5402
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:6223
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:4745
virtual void parallel_scan_end(void *scan_ctx)
End of the parallel scan.
Definition: handler.h:5229
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:7312
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:5180
Table_flags ha_table_flags() const
The cached_table_flags is set at ha_open and ha_external_lock.
Definition: handler.h:5088
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:6026
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:5082
virtual bool is_crashed() const
Check if the table is crashed.
Definition: handler.h:6245
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:6182
virtual bool start_bulk_update()
Definition: handler.h:5791
uchar * dup_ref
Pointer to duplicate row.
Definition: handler.h:4760
bool end_psi_batch_mode_if_started()
If a PSI batch was started, turn if off.
Definition: handler.h:4929
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:7392
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:5994
uint max_record_length() const
Definition: handler.h:6207
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:6395
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:4868
virtual int discard_or_import_tablespace(bool discard, dd::Table *table_def)
Discard or import tablespace.
Definition: handler.h:7243
virtual int exec_bulk_update(uint *dup_key_found)
After this call all outstanding updates must be performed.
Definition: handler.h:5808
int update_auto_increment()
Definition: handler.cc:3896
virtual int indexes_are_disabled(void)
Check if indexes are disabled.
Definition: handler.h:6197
Record_buffer * ha_get_record_buffer() const
Get the record buffer that was set with ha_set_record_buffer().
Definition: handler.h:5037
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:4888
virtual int index_read_last(uchar *buf, const uchar *key, uint key_len)
Definition: handler.h:7103
virtual int start_stmt(THD *thd, thr_lock_type lock_type)
Start a statement when table is locked.
Definition: handler.h:6142
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:6401
virtual int index_next_pushed(uchar *)
Definition: handler.h:6423
FT_INFO * ft_handler
Definition: handler.h:4827
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:6045
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:7019
Handler_share ** ha_share
Pointer where to store/retrieve the Handler_share pointer.
Definition: handler.h:4947
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:4751
virtual int analyze(THD *, HA_CHECK_OPT *)
Definition: handler.h:7185
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:6804
handler(handlerton *ht_arg, TABLE_SHARE *share_arg)
Definition: handler.h:4969
virtual uint max_supported_keys() const
Definition: handler.h:6224
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:6216
range_seq_t mrr_iter
Definition: handler.h:4765
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:5719
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:4900
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:7000
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:6716
virtual bool bulk_load_check(THD *thd) const
Check if the table is ready for bulk load.
Definition: handler.h:5234
uint get_index(void) const
Definition: handler.h:5785
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:5251
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:6679
std::mt19937 * m_random_number_engine
Definition: handler.h:4870
virtual uint min_record_length(uint options) const
Definition: handler.h:6231
void init()
This is called after create to allow us to set up cached variables.
Definition: handler.h:5020
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:5013
virtual int write_row(uchar *buf)
Write a row.
Definition: handler.h:6921
virtual void try_semi_consistent_read(bool)
Tell the engine whether it should avoid unnecessary lock waits.
Definition: handler.h:6118
enum_range_scan_direction
Definition: handler.h:4782
@ RANGE_SCAN_ASC
Definition: handler.h:4782
@ RANGE_SCAN_DESC
Definition: handler.h:4782
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:6150
virtual int ft_init()
Definition: handler.h:5901
int compare_key_icp(const key_range *range) const
Definition: handler.cc:7710
TABLE * table
Definition: handler.h:4750
void ha_notify_table_changed(Alter_inplace_info *ha_alter_info)
Public function wrapping the actual handler call.
Definition: handler.h:6637
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:6613
Record_buffer * m_record_buffer
Buffer for multi-row reads.
Definition: handler.h:4785
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:7179
virtual int index_end()
Definition: handler.h:6887
virtual table_map tables_in_pushed_join() const
Definition: handler.h:6411
virtual int delete_all_rows()
Delete all rows in a table.
Definition: handler.h:7144
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:5924
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:7087
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:7400
virtual int optimize(THD *, HA_CHECK_OPT *)
Definition: handler.h:7182
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:7127
virtual bool check_and_repair(THD *thd)
Check and repair the table if necessary.
Definition: handler.h:7200
virtual bool auto_repair() const
Check if the table can be automatically repaired.
Definition: handler.h:6254
virtual int end_bulk_insert()
Definition: handler.h:7001
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:5796
uint auto_inc_intervals_count
Number of reserved auto-increment intervals.
Definition: handler.h:4863
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:5030
virtual ha_checksum checksum() const
Definition: handler.h:6236
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:7423
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:7274
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:7318
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:7025
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:7297
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:4790
PSI_table_locker_state m_psi_locker_state
Storage for the event in a batch.
Definition: handler.h:4906
ha_rows estimation_rows_to_insert
Definition: handler.h:4753
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:5266
bool mrr_is_output_sorted
Definition: handler.h:4770
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:5876
int ha_close(void)
Close handler.
Definition: handler.cc:2988
uint max_key_part_length(HA_CREATE_INFO *create_info) const
Definition: handler.h:6219
virtual bool set_ha_share_ref(Handler_share **arg_ha_share)
Definition: handler.h:7305
virtual void release_auto_increment()
Definition: handler.h:6986
const TABLE_SHARE * get_table_share() const
Definition: handler.h:5392
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:5741
bool has_transactions()
Definition: handler.h:5632
virtual int delete_row(const uchar *buf)
Definition: handler.h:6938
Item * pushed_idx_cond
Definition: handler.h:4832
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:5217
virtual int check_for_upgrade(HA_CHECK_OPT *)
admin commands - called from mysql_admin_table
Definition: handler.h:6988
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:5866
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:6380
int key_compare_result_on_equal
Definition: handler.h:4792
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:4775
bool mrr_have_range
Definition: handler.h:4773
virtual int cmp_ref(const uchar *ref1, const uchar *ref2) const
Compare two positions.
Definition: handler.h:6326
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:5054
ulonglong m_psi_numrows
The number of rows in the batch.
Definition: handler.h:4894
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:6774
virtual int end_bulk_delete()
Execute all outstanding deletes and close down the bulk delete.
Definition: handler.h:5823
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:5749
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:5836
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:5195
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:4829
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:5298
In-place alter handler context.
Definition: handler.h:3499
virtual void set_shared_data(const inplace_alter_handler_ctx *ctx)
Definition: handler.h:3503
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:290
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:47
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:603
#define rows2double(A)
Definition: my_base.h:1216
ha_panic_function
Definition: my_base.h:432
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:931
ha_rkey_function
Definition: my_base.h:78
ulong key_part_map
Definition: my_base.h:1084
my_off_t ha_rows
Definition: my_base.h:1217
ha_extra_function
Definition: my_base.h:185
#define HA_POS_ERROR
Definition: my_base.h:1219
#define HA_ERR_WRONG_COMMAND
Command not supported.
Definition: my_base.h:917
#define HA_OPTION_COMPRESS_RECORD
Flag indicating that table is compressed.
Definition: my_base.h:629
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:43
unsigned long long Object_id
Definition: object_id.h:31
enum_column_types
Definition: column.h:53
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
Definition: os0file.h: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
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:1789
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:1923
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:2561
#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:3297
int(*)(uint64_t *purge_id) page_track_purge_t
Purge page tracking data.
Definition: handler.h:2775
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:1804
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:1976
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:2266
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:3234
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:2335
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:2750
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:3321
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:2604
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:2394
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:2061
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:1931
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:1826
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:2137
#define HA_MAX_REC_LENGTH
Definition: handler.h:632
#define HTON_SUPPORTS_ATOMIC_DDL
Engine supports atomic DDL.
Definition: handler.h:3188
void(*)(void *arg) se_before_rollback_t
Definition: handler.h:2664
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:2521
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:2290
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:1691
bool(* redo_log_set_state_t)(THD *thd, bool enable)
Enable or Disable SE write ahead logging.
Definition: handler.h:2116
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:1685
constexpr const decltype(handlerton::flags) HTON_SUPPORTS_BULK_LOAD
Definition: handler.h:3226
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:2279
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:2347
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:7617
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:2252
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:2762
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:2341
constexpr const uint64_t HA_CREATE_USED_ENGINE_ATTRIBUTE
Definition: handler.h:804
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:2801
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:3229
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:1732
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:2380
#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:1743
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:1919
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:7623
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:2607
int(* finish_upgrade_t)(THD *thd, bool failed_upgrade)
Finish upgrade process inside storage engines.
Definition: handler.h:1627
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:2828
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:1841
static const uint32 HTON_FKS_WITH_SUPPORTING_HASH_KEYS
Storage engine supports hash keys as supporting keys for foreign keys.
Definition: handler.h:3284
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:3213
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:2176
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:2511
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:3202
bool Log_func(THD *, TABLE *, bool, const uchar *, const uchar *)
Definition: handler.h:7708
bool hton_is_secondary_engine(const handlerton *hton)
Definition: handler.h:3241
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:2681
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:1752
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:3246
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:1671
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:2660
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:2608
@ 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:3208
bool(* get_tablespace_type_t)(const dd::Tablespace &space, Tablespace_type *space_type)
Get the tablespace type from the SE.
Definition: handler.h:1659
bool(* rotate_encryption_master_key_t)(void)
Initiate master key rotation.
Definition: handler.h:2105
void(* post_recover_t)(void)
Perform SE-specific cleanup after recovery of transactions.
Definition: handler.h:2329
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:2078
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:3194
int(* start_consistent_snapshot_t)(handlerton *hton, THD *thd)
Definition: handler.h:1524
enum_stats_auto_recalc
Definition: handler.h:3338
@ HA_STATS_AUTO_RECALC_DEFAULT
Definition: handler.h:3339
@ HA_STATS_AUTO_RECALC_OFF
Definition: handler.h:3341
@ HA_STATS_AUTO_RECALC_ON
Definition: handler.h:3340
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:1680
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:1883
constexpr const uint64_t HA_CREATE_USED_READ_ONLY
ALTER SCHEMA|DATABASE has an explicit READ_ONLY clause.
Definition: handler.h:812
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:1817
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:2547
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:2196
SecondaryEngineGraphSimplificationRequest
Definition: handler.h:2563
@ 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:1688
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:1695
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:3304
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:2535
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:2153
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:3331
@ ISO_READ_UNCOMMITTED
Definition: handler.h:3332
@ ISO_REPEATABLE_READ
Definition: handler.h:3334
@ ISO_READ_COMMITTED
Definition: handler.h:3333
@ ISO_SERIALIZABLE
Definition: handler.h:3335
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:2095
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:1996
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:1715
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:3315
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:3329
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:2675
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:2217
int(* upgrade_logs_t)(THD *thd)
Upgrade logs after the checkpoint from where upgrade process can only roll forward.
Definition: handler.h:1639
bool(*)(THD *thd, std::string_view db_name, std::string_view table_name, std::string_view view_def, MDL_ticket *mdl_ticket) notify_materialized_view_usage_t
Notify plugins when a materialized view is referenced in a query.
Definition: handler.h:2701
bool(* is_reserved_db_name_t)(handlerton *hton, const char *name)
Definition: handler.h:2366
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:2204
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:2714
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:2729
const char * binlog_format_names[]
Definition: mysqld.cc:1349
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:2822
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:2228
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:1988
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:2241
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:2471
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:1602
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:2029
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:1955
@ DICT_RECOVERY_RESTART_SERVER
Restart of an existing server.
Definition: handler.h:1958
@ DICT_RECOVERY_INITIALIZE_TABLESPACES
First start, create tablespaces.
Definition: handler.h:1957
@ DICT_RECOVERY_INITIALIZE_SERVER
First start of a new server.
Definition: handler.h:1956
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:1761
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:1674
int(* binlog_func_t)(handlerton *hton, THD *thd, enum_binlog_func fn, void *arg)
Definition: handler.h:1677
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:2656
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:1943
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:3973
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:2417
handlerton * get_default_handlerton(THD *thd, handlerton *hton)
Get default handlerton, if handler supplied is null.
Definition: handler.h:7609
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:2724
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:7637
dict_init_mode_t
Mode for initializing the data dictionary.
Definition: handler.h:1887
@ DICT_INIT_CREATE_FILES
Create all required SE files.
Definition: handler.h:1888
@ DICT_INIT_CHECK_FILES
Verify existence of expected files.
Definition: handler.h:1889
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:2362
constexpr SecondaryEngineFlags MakeSecondaryEngineFlags()
Creates an empty bitmap of access path types.
Definition: handler.h:2628
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:3273
bool secondary_engine_supports_temporary_tables(const handlerton *hton)
Definition: handler.h:3252
void(* dict_cache_reset_tables_and_tablespaces_t)()
Invalidate all table and tablespace entries in the local dictionary cache.
Definition: handler.h:1952
#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:2320
bool ddl_is_atomic(const handlerton *hton)
Definition: handler.h:3257
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:1613
Tablespace_type
Definition: handler.h:1641
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:1868
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:860
Definition: m_ctype.h:421
Definition: handler.h:2292
Clone_apply_t clone_apply
Definition: handler.h:2304
Clone_end_t clone_end
Definition: handler.h:2300
Clone_capability_t clone_capability
Definition: handler.h:2294
Clone_apply_begin_t clone_apply_begin
Definition: handler.h:2303
Clone_begin_t clone_begin
Definition: handler.h:2297
Clone_copy_t clone_copy
Definition: handler.h:2298
Clone_apply_end_t clone_apply_end
Definition: handler.h:2305
Clone_ack_t clone_ack
Definition: handler.h:2299
Definition: ft_global.h:72
Definition: handler.h:3967
uchar * buffer_end
Definition: handler.h:3969
uchar * buffer
Definition: handler.h:3968
uchar * end_of_used_area
Definition: handler.h:3970
Definition: handler.h:3954
KEY_CACHE * key_cache
Definition: handler.h:3957
uint sql_flags
Definition: handler.h:3956
uint flags
Definition: handler.h:3955
Struct to hold information about the table that should be created.
Definition: handler.h:3347
ulonglong auto_increment_value
Definition: handler.h:3390
bool m_hidden
Definition: handler.h:3422
bool m_transactional_ddl
Definition: handler.h:3428
PT_create_external_file_format * file_format
Definition: handler.h:3437
bool m_implicit_tablespace_autoextend_size_change
Definition: handler.h:3435
handlerton * db_type
Definition: handler.h:3401
LEX_STRING compress
Algorithm (and possible options) to be used for InnoDB's transparent page compression.
Definition: handler.h:3363
LEX_STRING encrypt_type
This attribute is used for InnoDB's transparent page encryption.
Definition: handler.h:3371
LEX_CSTRING engine_attribute
Definition: handler.h:3430
ulong avg_row_length
Definition: handler.h:3392
size_t create_table_columns_end_pos
Definition: handler.h:3442
const CHARSET_INFO * table_charset
Definition: handler.h:3348
PT_create_external_files * external_files
Definition: handler.h:3438
const char * data_file_name
Definition: handler.h:3385
LEX_CSTRING auto_refresh_event_source
Definition: handler.h:3439
ulonglong m_implicit_tablespace_autoextend_size
Definition: handler.h:3433
bool secondary_load
Secondary engine load status.
Definition: handler.h:3379
const CHARSET_INFO * default_table_charset
Definition: handler.h:3349
uint stats_sample_pages
Definition: handler.h:3397
const char * alias
Definition: handler.h:3387
uint null_bits
Definition: handler.h:3412
uint merge_insert_method
Definition: handler.h:3414
LEX_STRING connect_string
Definition: handler.h:3351
partition_info * part_info
Part info in order to maintain in HA_CREATE_INFO the per-partition secondary_load status.
Definition: handler.h:3383
const char * tablespace
Definition: handler.h:3353
ulonglong max_rows
Definition: handler.h:3388
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:3352
ha_storage_media storage_media
Definition: handler.h:3415
LEX_STRING comment
Definition: handler.h:3354
const char * index_file_name
Definition: handler.h:3386
SQL_I_List< Table_ref > merge_list
Definition: handler.h:3400
std::uint32_t key_block_size
Definition: handler.h:3396
uint64_t table_options
Definition: handler.h:3391
LEX_CSTRING secondary_engine_attribute
Definition: handler.h:3431
LEX_CSTRING secondary_engine
Secondary engine of the table.
Definition: handler.h:3377
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:3389
uint64_t used_fields
Definition: handler.h:3393
bool schema_read_only
Definition: handler.h:3350
enum_stats_auto_recalc stats_auto_recalc
Definition: handler.h:3399
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:1208
Structure describing changes to an index to be caused by ALTER TABLE.
Definition: handler.h:3471
KEY * new_key
Pointer to KEY object describing new version of index in Alter_inplace_info::key_info_buffer array.
Definition: handler.h:3482
KEY * old_key
Pointer to KEY object describing old version of index in TABLE::key_info array for TABLE instance rep...
Definition: handler.h:3477
The LEX object currently serves three different purposes:
Definition: sql_lex.h:3999
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:2831
page_track_get_num_page_ids_t get_num_page_ids
Definition: handler.h:2836
page_track_purge_t purge
Definition: handler.h:2834
page_track_start_t start
Definition: handler.h:2832
page_track_stop_t stop
Definition: handler.h:2833
page_track_get_status_t get_status
Definition: handler.h:2837
page_track_get_page_ids_t get_page_ids
Definition: handler.h:2835
Definition: handler.h:3975
range_seq_t(* init)(void *init_params, uint n_ranges, uint flags)
Definition: handler.h:3988
uint(* next)(range_seq_t seq, KEY_MULTI_RANGE *range)
Definition: handler.h:4002
bool(* skip_record)(range_seq_t seq, char *range_info, uchar *rowid)
Definition: handler.h:4019
Definition: transaction_info.h:46
bool is_enabled
Indicates if simplification is guided using secondary engine.
Definition: handler.h:2576
int subgraph_pair_limit
Subgraph pairs requested by the secondary engine.
Definition: handler.h:2574
SecondaryEngineGraphSimplificationRequest secondary_engine_optimizer_request
Optimizer request from the secondary engine.
Definition: handler.h:2572
Type for signature generation and for retrieving nrows estimate from secondary engine for current Acc...
Definition: handler.h:2477
bool to_force_resign
if ap->signature generation should be forced.
Definition: handler.h:2491
OverflowBitset applied_predicates
Predicates actually applied for AccessPath::REF and other parameterized types.
Definition: handler.h:2486
SecondaryEngineNrowsParameters(THD *thd)
Definition: handler.h:2499
THD * thd
The thread context.
Definition: handler.h:2479
AccessPath * access_path
The AccessPath to retrieve Nrows for.
Definition: handler.h:2481
const JoinHypergraph * graph
Hypergraph for current query block.
Definition: handler.h:2483
size_t * extra_sig
if nonnull, an additional signature should be combined with current AP.
Definition: handler.h:2493
SecondaryEngineNrowsParameters(THD *thd, AccessPath *access_path, const JoinHypergraph *graph)
Definition: handler.h:2495
bool to_update_rows
if ap->nrows should be acually updated.
Definition: handler.h:2488
Per thread status variables.
Definition: system_variables.h:533
This structure is shared between different table objects.
Definition: table.h:716
Definition: table.h:1435
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:2851
sdi_get_keys_t sdi_get_keys
Definition: handler.h:2955
sdi_drop_t sdi_drop
Definition: handler.h:2954
unlock_hton_log_t unlock_hton_log
Definition: handler.h:3013
notify_alter_table_t notify_alter_table
Definition: handler.h:2986
dict_cache_reset_t dict_cache_reset
Definition: handler.h:2924
void * data
Location for engines to keep personal structures.
Definition: handler.h:3006
set_prepared_in_tc_by_xid_t set_prepared_in_tc_by_xid
Definition: handler.h:2901
se_before_rollback_t se_before_rollback
Definition: handler.h:3124
sdi_set_t sdi_set
Definition: handler.h:2957
lock_hton_log_t lock_hton_log
Definition: handler.h:3012
is_dict_readonly_t is_dict_readonly
Definition: handler.h:2981
alter_tablespace_t alter_tablespace
Definition: handler.h:2912
finish_upgrade_t finish_upgrade
Definition: handler.h:2919
create_t create
Definition: handler.h:2902
collect_hton_log_info_t collect_hton_log_info
Definition: handler.h:3014
secondary_engine_pre_prepare_hook_t secondary_engine_pre_prepare_hook
Definition: handler.h:3116
notify_materialized_view_usage_t notify_materialized_view_usage
Definition: handler.h:3131
dict_register_dd_table_id_t dict_register_dd_table_id
Definition: handler.h:2923
redo_log_set_state_t redo_log_set_state
Definition: handler.h:2990
find_files_t find_files
Definition: handler.h:2944
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:3066
ddse_dict_init_t ddse_dict_init
Definition: handler.h:2922
replace_native_transaction_in_thd_t replace_native_transaction_in_thd
Definition: handler.h:2984
LEX_CSTRING fk_name_suffix
Suffix for auto-generated foreign key names for tables using this storage engine.
Definition: handler.h:3029
pre_dd_shutdown_t pre_dd_shutdown
Definition: handler.h:2887
check_fk_column_compat_t check_fk_column_compat
Definition: handler.h:3019
cardinality_estimation_hook_t cardinality_estimation_hook
Definition: handler.h:3120
SecondaryEngineFlags secondary_engine_flags
Bitmap which contains the supported join types and other flags for a secondary storage engine when us...
Definition: handler.h:3060
uint32 license
Flag for Engine License.
Definition: handler.h:3004
is_supported_system_table_t is_supported_system_table
Definition: handler.h:2947
commit_t commit
Definition: handler.h:2893
get_tablespace_statistics_t get_tablespace_statistics
Definition: handler.h:2995
se_after_commit_t se_after_commit
Definition: handler.h:3123
savepoint_set_t savepoint_set
Definition: handler.h:2889
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:2881
drop_database_t drop_database
Definition: handler.h:2903
savepoint_release_t savepoint_release
Definition: handler.h:2892
enum legacy_db_type db_type
Historical number used for frm file to determine the correct storage engine.
Definition: handler.h:2861
is_valid_tablespace_name_t is_valid_tablespace_name
Definition: handler.h:2911
se_before_commit_t se_before_commit
Definition: handler.h:3122
flush_logs_t flush_logs
Definition: handler.h:2908
log_ddl_create_schema_t log_ddl_create_schema
Definition: handler.h:2905
uint slot
Each storage engine has it's own memory area (actually a pointer) in the thd, for storing per-connect...
Definition: handler.h:2871
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:3096
dict_get_server_version_t dict_get_server_version
Definition: handler.h:2928
get_tablespace_type_t get_tablespace_type
Definition: handler.h:2916
close_connection_t close_connection
Definition: handler.h:2885
rotate_encryption_master_key_t rotate_encryption_master_key
Definition: handler.h:2989
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:3111
notify_truncate_table_t notify_truncate_table
Definition: handler.h:2988
start_consistent_snapshot_t start_consistent_snapshot
Definition: handler.h:2907
savepoint_rollback_t savepoint_rollback
Definition: handler.h:2890
fill_is_table_t fill_is_table
Definition: handler.h:2920
binlog_func_t binlog_func
Definition: handler.h:2940
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:3046
log_ddl_drop_schema_t log_ddl_drop_schema
Definition: handler.h:2904
notify_exclusive_mdl_t notify_exclusive_mdl
Definition: handler.h:2985
get_cost_constants_t get_cost_constants
Definition: handler.h:2983
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:3104
notify_create_table_t notify_create_table
Definition: handler.h:3128
rollback_by_xid_t rollback_by_xid
Definition: handler.h:2899
sdi_delete_t sdi_delete
Definition: handler.h:2958
get_index_column_cardinality_t get_index_column_cardinality
Definition: handler.h:2994
rollback_t rollback
Definition: handler.h:2894
dict_recover_t dict_recover
Definition: handler.h:2927
rm_tmp_tables_t rm_tmp_tables
Definition: handler.h:2982
prepare_secondary_engine_t prepare_secondary_engine
Pointer to a function that prepares a secondary engine for executing a statement.
Definition: handler.h:3037
get_table_statistics_t get_table_statistics
Definition: handler.h:2992
Page_track_t page_track
Page tracking interface.
Definition: handler.h:3134
sdi_create_t sdi_create
Definition: handler.h:2953
notify_drop_table_t notify_drop_table
Definition: handler.h:3129
dict_init_t dict_init
Definition: handler.h:2921
uint32 foreign_keys_flags
Flags describing details of foreign key support by storage engine.
Definition: handler.h:3017
binlog_log_query_t binlog_log_query
Definition: handler.h:2941
get_tablespace_filename_ext_t get_tablespace_filename_ext
Definition: handler.h:2913
upgrade_logs_t upgrade_logs
Definition: handler.h:2918
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:3087
partition_flags_t partition_flags
Definition: handler.h:2910
const char ** file_extensions
Null-ended array of file extensions that exist for the storage engine.
Definition: handler.h:2979
dict_cache_reset_tables_and_tablespaces_t dict_cache_reset_tables_and_tablespaces
Definition: handler.h:2926
push_to_engine_t push_to_engine
Definition: handler.h:2946
Clone_interface_t clone_interface
Clone data transfer interfaces.
Definition: handler.h:3001
recover_prepared_in_tc_t recover_prepared_in_tc
Definition: handler.h:2897
discover_t discover
Definition: handler.h:2943
table_exists_in_engine_t table_exists_in_engine
Definition: handler.h:2945
upgrade_tablespace_t upgrade_tablespace
Definition: handler.h:2914
sdi_get_t sdi_get
Definition: handler.h:2956
reset_plugin_vars_t reset_plugin_vars
Definition: handler.h:2888
get_tablespace_type_by_name_t get_tablespace_type_by_name
Definition: handler.h:2917
dict_set_server_version_t dict_set_server_version
Definition: handler.h:2929
recover_t recover
Definition: handler.h:2896
SHOW_COMP_OPTION state
Historical marker for if the engine is available or not.
Definition: handler.h:2855
post_recover_t post_recover
Definition: handler.h:2998
uint32 flags
Global handler flags.
Definition: handler.h:2933
upgrade_space_version_t upgrade_space_version
Definition: handler.h:2915
kill_connection_t kill_connection
Definition: handler.h:2886
get_column_statistics_t get_column_statistics
Definition: handler.h:2993
prepare_t prepare
Definition: handler.h:2895
panic_t panic
Definition: handler.h:2906
post_ddl_t post_ddl
Definition: handler.h:2997
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:3054
notify_after_select_t notify_after_select
Definition: handler.h:3126
commit_by_xid_t commit_by_xid
Definition: handler.h:2898
set_prepared_in_tc_t set_prepared_in_tc
Definition: handler.h:2900
acl_notify_t acl_notify
Definition: handler.h:2942
show_status_t show_status
Definition: handler.h:2909
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:3072
is_reserved_db_name_t is_reserved_db_name
Definition: handler.h:2930
savepoint_rollback_can_release_mdl_t savepoint_rollback_can_release_mdl
Definition: handler.h:2891
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:3078
notify_rename_table_t notify_rename_table
Definition: handler.h:2987
Definition: my_base.h:1201
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