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