MySQL 8.2.0
Source Code Documentation
ha_innodb.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2000, 2023, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is also distributed with certain software (including but not
10limited to OpenSSL) that is licensed under separate terms, as designated in a
11particular file or component or in included license documentation. The authors
12of MySQL hereby grant you an additional permission to link the program and
13your derivative works with the separately licensed software that they have
14included with MySQL.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19for more details.
20
21You should have received a copy of the GNU General Public License along with
22this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
25*****************************************************************************/
26
27#ifndef ha_innodb_h
28#define ha_innodb_h
29
30/* The InnoDB handler: the interface between MySQL and InnoDB. */
31
32#include <assert.h>
33#include <sys/types.h>
34#include "create_field.h"
35#include "field.h"
36#include "handler.h"
38
39#include "row0pread-adapter.h"
40#include "row0pread-histogram.h"
41#include "trx0trx.h"
42
43/** "GEN_CLUST_INDEX" is the name reserved for InnoDB default
44system clustered index when there is no primary key. */
45extern const char innobase_index_reserve_name[];
46
47/** Clone protocol service. */
48extern SERVICE_TYPE(clone_protocol) * clone_protocol_svc;
49
50/* Structure defines translation table between mysql index and InnoDB
51index structures */
53 ulint index_count; /*!< number of valid index entries
54 in the index_mapping array */
55
56 ulint array_size; /*!< array size of index_mapping */
57
58 dict_index_t **index_mapping; /*!< index pointer array directly
59 maps to index in InnoDB from MySQL
60 array index */
61};
62
63/** InnoDB table share */
65 const char *table_name; /*!< InnoDB table name */
66 uint use_count; /*!< reference count,
67 incremented in get_share()
68 and decremented in
69 free_share() */
71 /*!< hash table chain node */
72 innodb_idx_translate_t idx_trans_tbl; /*!< index translation table between
73 MySQL and InnoDB */
74};
75
76/** Prebuilt structures in an InnoDB table handle used within MySQL */
77struct row_prebuilt_t;
78
79namespace dd {
80namespace cache {
81class Dictionary_client;
82}
83} // namespace dd
84
85/** The class defining a handle to an InnoDB table */
86class ha_innobase : public handler {
87 public:
88 ha_innobase(handlerton *hton, TABLE_SHARE *table_arg);
89 ~ha_innobase() override = default;
90
91 row_type get_real_row_type(const HA_CREATE_INFO *create_info) const override;
92
93 const char *table_type() const override;
94
96 return HA_KEY_ALG_BTREE;
97 }
98
99 /** Check if SE supports specific key algorithm. */
100 bool is_index_algorithm_supported(enum ha_key_alg key_alg) const override {
101 /* This method is never used for FULLTEXT or SPATIAL keys.
102 We rely on handler::ha_table_flags() to check if such keys
103 are supported. */
104 assert(key_alg != HA_KEY_ALG_FULLTEXT && key_alg != HA_KEY_ALG_RTREE);
105 return key_alg == HA_KEY_ALG_BTREE;
106 }
107
108 Table_flags table_flags() const override;
109
110 ulong index_flags(uint idx, uint part, bool all_parts) const override;
111
112 uint max_supported_keys() const override;
113
114 uint max_supported_key_length() const override;
115
117 HA_CREATE_INFO *create_info) const override;
118
119 int open(const char *name, int, uint open_flags,
120 const dd::Table *table_def) override;
121
122 handler *clone(const char *name, MEM_ROOT *mem_root) override;
123
124 int close(void) override;
125
126 double scan_time() override;
127
128 double read_time(uint index, uint ranges, ha_rows rows) override;
129
130 longlong get_memory_buffer_size() const override;
131
132 int write_row(uchar *buf) override;
133
134 int update_row(const uchar *old_data, uchar *new_data) override;
135
136 int delete_row(const uchar *buf) override;
137
138 /** Delete all rows from the table.
139 @retval HA_ERR_WRONG_COMMAND if the table is transactional
140 @retval 0 on success */
141 int delete_all_rows() override;
142
143 bool was_semi_consistent_read() override;
144
145 void try_semi_consistent_read(bool yes) override;
146
147 void unlock_row() override;
148
149 int index_init(uint index, bool sorted) override;
150
151 int index_end() override;
152
153 int index_read(uchar *buf, const uchar *key, uint key_len,
154 ha_rkey_function find_flag) override;
155
156 int index_read_last(uchar *buf, const uchar *key, uint key_len) override;
157
158 int index_next(uchar *buf) override;
159
160 int index_next_same(uchar *buf, const uchar *key, uint keylen) override;
161
162 int index_prev(uchar *buf) override;
163
164 int index_first(uchar *buf) override;
165
166 int index_last(uchar *buf) override;
167
168 int read_range_first(const key_range *start_key, const key_range *end_key,
169 bool eq_range_arg, bool sorted) override;
170
171 int read_range_next() override;
172
173 int rnd_init(bool scan) override;
174
175 int rnd_end() override;
176
177 int rnd_next(uchar *buf) override;
178
179 int rnd_pos(uchar *buf, uchar *pos) override;
180
181 int ft_init() override;
182
183 void ft_end();
184
185 FT_INFO *ft_init_ext(uint flags, uint inx, String *key) override;
186
188 Ft_hints *hints) override;
189
190 int ft_read(uchar *buf) override;
191
192 void position(const uchar *record) override;
193
194 int info(uint) override;
195
196 int enable_indexes(uint mode) override;
197
198 int disable_indexes(uint mode) override;
199
200 int analyze(THD *thd, HA_CHECK_OPT *check_opt) override;
201
202 int optimize(THD *thd, HA_CHECK_OPT *check_opt) override;
203
204 int discard_or_import_tablespace(bool discard, dd::Table *table_def) override;
205
206 int extra(ha_extra_function operation) override;
207
208 int reset() override;
209
210 int external_lock(THD *thd, int lock_type) override;
211
212 /** Initialize sampling.
213 @param[out] scan_ctx A scan context created by this method that has to be
214 used in sample_next
215 @param[in] sampling_percentage percentage of records that need to be sampled
216 @param[in] sampling_seed random seed that the random generator will use
217 @param[in] sampling_method sampling method to be used; currently only
218 SYSTEM sampling is supported
219 @param[in] tablesample true if the sampling is for tablesample
220 @return 0 for success, else one of the HA_xxx values in case of error. */
221 int sample_init(void *&scan_ctx, double sampling_percentage,
222 int sampling_seed, enum_sampling_method sampling_method,
223 const bool tablesample) override;
224
225 /** Get the next record for sampling.
226 @param[in] scan_ctx Scan context of the sampling
227 @param[in] buf buffer to place the read record
228 @return 0 for success, else one of the HA_xxx values in case of error. */
229 int sample_next(void *scan_ctx, uchar *buf) override;
230
231 /** End sampling.
232 @param[in] scan_ctx Scan context of the sampling
233 @return 0 for success, else one of the HA_xxx values in case of error. */
234 int sample_end(void *scan_ctx) override;
235
236 /** MySQL calls this function at the start of each SQL statement
237 inside LOCK TABLES. Inside LOCK TABLES the "::external_lock" method
238 does not work to mark SQL statement borders. Note also a special case:
239 if a temporary table is created inside LOCK TABLES, MySQL has not
240 called external_lock() at all on that table.
241 MySQL-5.0 also calls this before each statement in an execution of a
242 stored procedure. To make the execution more deterministic for
243 binlogging, MySQL-5.0 locks all tables involved in a stored procedure
244 with full explicit table locks (thd_in_lock_tables(thd) holds in
245 store_lock()) before executing the procedure.
246 @param[in] thd handle to the user thread
247 @param[in] lock_type lock type
248 @return 0 or error code */
249 int start_stmt(THD *thd, thr_lock_type lock_type) override;
250
252
253 int records(ha_rows *num_rows) override;
254
255 int records_from_index(ha_rows *num_rows, uint) override {
256 /* Force use of cluster index until we implement sec index parallel scan. */
257 return ha_innobase::records(num_rows);
258 }
259
260 ha_rows records_in_range(uint inx, key_range *min_key,
261 key_range *max_key) override;
262
264
265 void update_create_info(HA_CREATE_INFO *create_info) override;
266
267 /** Get storage-engine private data for a data dictionary table.
268 @param[in,out] dd_table data dictionary table definition
269 @param reset reset counters
270 @retval true an error occurred
271 @retval false success */
272 bool get_se_private_data(dd::Table *dd_table, bool reset) override;
273
274 /** Add hidden columns and indexes to an InnoDB table definition.
275 @param[in,out] dd_table data dictionary cache object
276 @return error number
277 @retval 0 on success */
279 const List<Create_field> *, const KEY *, uint,
280 dd::Table *dd_table) override;
281
282 /** Set Engine specific data to dd::Table object for upgrade.
283 @param[in,out] thd thread handle
284 @param[in] db_name database name
285 @param[in] table_name table name
286 @param[in,out] dd_table data dictionary cache object
287 @return 0 on success, non-zero on failure */
288 bool upgrade_table(THD *thd, const char *db_name, const char *table_name,
289 dd::Table *dd_table) override;
290
291 /** Create an InnoDB table.
292 @param[in] name table name in filename-safe encoding
293 @param[in] form table structure
294 @param[in] create_info more information on the table
295 @param[in,out] table_def dd::Table describing table to be
296 created. Can be adjusted by SE, the changes will be saved into data-dictionary
297 at statement commit time.
298 @return error number
299 @retval 0 on success */
300 int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info,
301 dd::Table *table_def) override;
302
303 /** Drop a table.
304 @param[in] name table name
305 @param[in] table_def dd::Table describing table to
306 be dropped
307 @return error number
308 @retval 0 on success */
309 int delete_table(const char *name, const dd::Table *table_def) override;
310
311 protected:
312 /** Drop a table.
313 @param[in] name table name
314 @param[in] table_def dd::Table describing table to
315 be dropped
316 @param[in] sqlcom type of operation that the DROP is part of
317 @return error number
318 @retval 0 on success */
319 int delete_table(const char *name, const dd::Table *table_def,
320 enum enum_sql_command sqlcom);
321
322 public:
323 int rename_table(const char *from, const char *to,
324 const dd::Table *from_table, dd::Table *to_table) override;
325
326 int check(THD *thd, HA_CHECK_OPT *check_opt) override;
327
328 uint lock_count(void) const override;
329
331 thr_lock_type lock_type) override;
332
333 void init_table_handle_for_HANDLER() override;
334
335 void get_auto_increment(ulonglong offset, ulonglong increment,
336 ulonglong nb_desired_values, ulonglong *first_value,
337 ulonglong *nb_reserved_values) override;
338
339 /** Do cleanup for auto increment calculation. */
340 void release_auto_increment() override;
341
342 bool get_error_message(int error, String *buf) override;
343
344 bool get_foreign_dup_key(char *, uint, char *, uint) override;
345
346 bool primary_key_is_clustered() const override;
347
348 int cmp_ref(const uchar *ref1, const uchar *ref2) const override;
349
350 /** @defgroup ALTER_TABLE_INTERFACE On-line ALTER TABLE interface
351 @see handler0alter.cc
352 @{ */
353
354 /** Check if InnoDB supports a particular alter table in-place
355 @param altered_table TABLE object for new version of table.
356 @param ha_alter_info Structure describing changes to be done
357 by ALTER TABLE and holding data used during in-place alter.
358
359 @retval HA_ALTER_INPLACE_NOT_SUPPORTED Not supported
360 @retval HA_ALTER_INPLACE_NO_LOCK Supported
361 @retval HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE Supported, but requires
362 lock during main phase and exclusive lock during prepare phase.
363 @retval HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE Supported, prepare phase
364 requires exclusive lock (any transactions that have accessed the table
365 must commit or roll back first, and no transactions can access the table
366 while prepare_inplace_alter_table() is executing)
367 */
369 TABLE *altered_table, Alter_inplace_info *ha_alter_info) override;
370
371 /** Allows InnoDB to update internal structures with concurrent
372 writes blocked (provided that check_if_supported_inplace_alter()
373 did not return HA_ALTER_INPLACE_NO_LOCK).
374 This will be invoked before inplace_alter_table().
375 @param[in] altered_table TABLE object for new version of table.
376 @param[in,out] ha_alter_info Structure describing changes to be done
377 by ALTER TABLE and holding data used during in-place alter.
378 @param[in] old_dd_tab dd::Table object describing old version
379 of the table.
380 @param[in,out] new_dd_tab dd::Table object for the new version of
381 the table. Can be adjusted by this call. Changes to the table definition will
382 be persisted in the data-dictionary at statement commit time.
383 @retval true Failure
384 @retval false Success
385 */
386 bool prepare_inplace_alter_table(TABLE *altered_table,
387 Alter_inplace_info *ha_alter_info,
388 const dd::Table *old_dd_tab,
389 dd::Table *new_dd_tab) override;
390
391 /** Alter the table structure in-place with operations
392 specified using HA_ALTER_FLAGS and Alter_inplace_information.
393 The level of concurrency allowed during this operation depends
394 on the return value from check_if_supported_inplace_alter().
395 @param[in] altered_table TABLE object for new version of table.
396 @param[in,out] ha_alter_info Structure describing changes to be done
397 by ALTER TABLE and holding data used during in-place alter.
398 @param[in] old_dd_tab dd::Table object describing old version
399 of the table.
400 @param[in,out] new_dd_tab dd::Table object for the new version of
401 the table. Can be adjusted by this call. Changes to the table definition will
402 be persisted in the data-dictionary at statement commit time.
403 @retval true Failure
404 @retval false Success
405 */
406 bool inplace_alter_table(TABLE *altered_table,
407 Alter_inplace_info *ha_alter_info,
408 const dd::Table *old_dd_tab,
409 dd::Table *new_dd_tab) override;
410
411 /** Commit or rollback the changes made during
412 prepare_inplace_alter_table() and inplace_alter_table() inside
413 the storage engine. Note that the allowed level of concurrency
414 during this operation will be the same as for
415 inplace_alter_table() and thus might be higher than during
416 prepare_inplace_alter_table(). (E.g concurrent writes were
417 blocked during prepare, but might not be during commit).
418 @param[in] altered_table TABLE object for new version of table.
419 @param[in,out] ha_alter_info Structure describing changes to be done
420 by ALTER TABLE and holding data used during in-place alter.
421 @param[in] commit True to commit or false to rollback.
422 @param[in] old_dd_tab dd::Table object representing old
423 version of the table
424 @param[in,out] new_dd_tab dd::Table object representing new
425 version of the table. Can be adjusted by this call. Changes to the table
426 definition will be persisted in the data-dictionary at statement
427 commit time.
428 @retval true Failure
429 @retval false Success */
430 bool commit_inplace_alter_table(TABLE *altered_table,
431 Alter_inplace_info *ha_alter_info,
432 bool commit, const dd::Table *old_dd_tab,
433 dd::Table *new_dd_tab) override;
434 /** @} */
435
437
438 /** Initializes a parallel scan. It creates a scan_ctx that has to
439 be used across all parallel_scan methods. Also, gets the number of threads
440 that would be spawned for parallel scan.
441 @param[out] scan_ctx A scan context created by this method
442 that has to be used in parallel_scan
443 @param[out] num_threads Number of threads to be spawned
444 @param[in] use_reserved_threads true if reserved threads are to be used
445 if we exhaust the max cap of number of
446 parallel read threads that can be
447 spawned at a time
448 @param[in] max_desired_threads Maximum number of desired read threads;
449 passing 0 has no effect, it is ignored;
450 upper-limited by the current value of
451 innodb_parallel_read_threads.
452 @return error code
453 @retval 0 on success */
454 int parallel_scan_init(void *&scan_ctx, size_t *num_threads,
455 bool use_reserved_threads,
456 size_t max_desired_threads) override;
457
458 /** Start parallel read of InnoDB records.
459 @param[in] scan_ctx A scan context created by parallel_scan_init
460 @param[in] thread_ctxs Context for each of the spawned threads
461 @param[in] init_fn Callback called by each parallel load
462 thread at the beginning of the parallel load.
463 @param[in] load_fn Callback called by each parallel load
464 thread when processing of rows is required.
465 @param[in] end_fn Callback called by each parallel load
466 thread when processing of rows has ended.
467 @return error code
468 @retval 0 on success */
469 int parallel_scan(void *scan_ctx, void **thread_ctxs, Reader::Init_fn init_fn,
470 Reader::Load_fn load_fn, Reader::End_fn end_fn) override;
471
472 /** End of the parallel scan.
473 @param[in] scan_ctx A scan context created by parallel_scan_init. */
474 void parallel_scan_end(void *scan_ctx) override;
475
476 /** Check if the table is ready for bulk load
477 @param[in] thd user session
478 @return true iff bulk load can be done on the table. */
479 bool bulk_load_check(THD *thd) const override;
480
481 /** Get the total memory available for bulk load in innodb buffer pool.
482 @param[in] thd user session
483 @return available memory for bulk load */
484 size_t bulk_load_available_memory(THD *thd) const override;
485
486 /** Begin parallel bulk data load to the table.
487 @param[in] thd user session
488 @param[in] data_size total data size in bytes
489 @param[in] memory buffer pool memory to be used
490 @param[in] num_threads Number of concurrent threads used for load.
491 @return bulk load context or nullptr if unsuccessful. */
492 void *bulk_load_begin(THD *thd, size_t data_size, size_t memory,
493 size_t num_threads) override;
494
495 /** Execute bulk load operation. To be called by each of the concurrent
496 threads idenified by thread index.
497 @param[in,out] thd user session
498 @param[in,out] load_ctx load execution context
499 @param[in] thread_idx index of the thread executing
500 @param[in] rows rows to be loaded to the table
501 @param[in] wait_cbk Stat callbacks
502 @return error code. */
503 int bulk_load_execute(THD *thd, void *load_ctx, size_t thread_idx,
504 const Rows_mysql &rows,
505 Bulk_load::Stat_callbacks &wait_cbk) override;
506
507 /** End bulk load operation. Must be called after all execution threads have
508 completed. Must be called even if the bulk load execution failed.
509 @param[in,out] thd user session
510 @param[in,out] load_ctx load execution context
511 @param[in] is_error true, if bulk load execution have failed
512 @return error code. */
513 int bulk_load_end(THD *thd, void *load_ctx, bool is_error) override;
514
516 uint table_changes) override;
517
518 private:
519 /** @name Multi Range Read interface
520 @{ */
521
522 /** Initialize multi range read @see DsMrr_impl::dsmrr_init */
523 int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
524 uint n_ranges, uint mode,
525 HANDLER_BUFFER *buf) override;
526
527 /** Process next multi range read @see DsMrr_impl::dsmrr_next */
528 int multi_range_read_next(char **range_info) override;
529
530 /** Initialize multi range read and get information.
531 @see ha_myisam::multi_range_read_info_const
532 @see DsMrr_impl::dsmrr_info_const */
534 void *seq_init_param, uint n_ranges,
535 uint *bufsz, uint *flags,
536 Cost_estimate *cost) override;
537
538 /** Initialize multi range read and get information.
539 @see DsMrr_impl::dsmrr_info */
540 ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
541 uint *bufsz, uint *flags,
542 Cost_estimate *cost) override;
543
544 /** Attempt to push down an index condition.
545 @param[in] keyno MySQL key number
546 @param[in] idx_cond Index condition to be checked
547 @return idx_cond if pushed; NULL if not pushed */
548 Item *idx_cond_push(uint keyno, Item *idx_cond) override;
549 /** @} */
550
551 private:
552 void update_thd();
553
554 int change_active_index(uint keynr);
555
557
559
561
563
564 /** Resets a query execution 'template'.
565 @see build_template() */
566 void reset_template();
567
568 /** Write Row Interface optimized for Intrinsic table. */
570
571 /** Find out if a Record_buffer is wanted by this handler, and what is
572 the maximum buffer size the handler wants.
573
574 @param[out] max_rows gets set to the maximum number of records to
575 allocate space for in the buffer
576 @retval true if the handler wants a buffer
577 @retval false if the handler does not want a buffer */
578 bool is_record_buffer_wanted(ha_rows *const max_rows) const override;
579
580 /** TRUNCATE an InnoDB table.
581 @param[in] name table name
582 @param[in] form table definition
583 @param[in,out] table_def dd::Table describing table to be
584 truncated. Can be adjusted by SE, the changes will be saved into
585 the data-dictionary at statement commit time.
586 @return error number
587 @retval 0 on success */
588 int truncate_impl(const char *name, TABLE *form, dd::Table *table_def);
589
590 protected:
591 /** Enter InnoDB engine after checking max allowed threads.
592 @return mysql error code. */
594
595 /** Leave Innodb, if no more tickets are left */
597
598 void update_thd(THD *thd);
599
600 int general_fetch(uchar *buf, uint direction, uint match_mode);
601
602 virtual dict_index_t *innobase_get_index(uint keynr);
603
604 /** Builds a 'template' to the m_prebuilt struct. The template is used in fast
605 retrieval of just those column values MySQL needs in its processing.
606 @param[in] whole_row true if access is needed to a whole row, false if
607 accessing individual fields is enough */
608 void build_template(bool whole_row);
609
610 /** Returns statistics information of the table to the MySQL interpreter, in
611 various fields of the handle object.
612 @param[in] flag what information is requested
613 @param[in] is_analyze True if called from "::analyze()".
614 @return HA_ERR_* error code or 0 */
615 virtual int info_low(uint flag, bool is_analyze);
616
617 /**
618 MySQL calls this method at the end of each statement. This method
619 exists for readability only, called from reset(). The name reset()
620 doesn't give any clue that it is called at the end of a statement. */
621 int end_stmt();
622
623 /** Implementation of prepare_inplace_alter_table()
624 @tparam Table dd::Table or dd::Partition
625 @param[in] altered_table TABLE object for new version of table.
626 @param[in,out] ha_alter_info Structure describing changes to be done
627 by ALTER TABLE and holding data used
628 during in-place alter.
629 @param[in] old_dd_tab dd::Table object representing old
630 version of the table
631 @param[in,out] new_dd_tab dd::Table object representing new
632 version of the table
633 @retval true Failure
634 @retval false Success */
635 template <typename Table>
636 bool prepare_inplace_alter_table_impl(TABLE *altered_table,
637 Alter_inplace_info *ha_alter_info,
638 const Table *old_dd_tab,
639 Table *new_dd_tab);
640
641 /** Implementation of inplace_alter_table()
642 @tparam Table dd::Table or dd::Partition
643 @param[in] altered_table TABLE object for new version of table.
644 @param[in,out] ha_alter_info Structure describing changes to be done
645 by ALTER TABLE and holding data used
646 during in-place alter.
647 the table. Can be adjusted by this call. Changes to the table definition will
648 be persisted in the data-dictionary at statement commit time.
649 @retval true Failure
650 @retval false Success
651 */
652 template <typename Table>
653 bool inplace_alter_table_impl(TABLE *altered_table,
654 Alter_inplace_info *ha_alter_info);
655
656 /** Implementation of commit_inplace_alter_table()
657 @tparam Table dd::Table or dd::Partition
658 @param[in] altered_table TABLE object for new version of table.
659 @param[in,out] ha_alter_info Structure describing changes to be done
660 by ALTER TABLE and holding data used
661 during in-place alter.
662 @param[in] commit True to commit or false to rollback.
663 @param[in,out] new_dd_tab Table object for the new version of the
664 table. Can be adjusted by this call.
665 Changes to the table definition
666 will be persisted in the data-dictionary
667 at statement version of it.
668 @retval true Failure
669 @retval false Success */
670 template <typename Table>
671 bool commit_inplace_alter_table_impl(TABLE *altered_table,
672 Alter_inplace_info *ha_alter_info,
673 bool commit, Table *new_dd_tab);
674
675 /**
676 Return max limits for a single set of multi-valued keys
677
678 @param[out] num_keys number of keys to store
679 @param[out] keys_length total length of keys, bytes
680 */
681 void mv_key_capacity(uint *num_keys, size_t *keys_length) const override;
682
683 /** Can reuse the template. Mainly used for partition.
684 @retval true Can reuse the mysql_template */
685 virtual bool can_reuse_mysql_template() const { return false; }
686
687 /** The multi range read session object */
689
690 /** Save CPU time with prebuilt/cached data structures */
692
693 /** Thread handle of the user currently using the handler;
694 this is set in external_lock function */
696
697 /** information for MySQL table locking */
699
700 /** buffer used in updates */
702
703 /** the size of upd_buf in bytes */
705
706 /** Flags that specify the handler instance (table) capability. */
708
709 /** this is set to 1 when we are starting a table scan but have
710 not yet fetched any row, else false */
712
713 /*!< match mode of the latest search: ROW_SEL_EXACT,
714 ROW_SEL_EXACT_PREFIX, or undefined */
716
717 /** this field is used to remember the original select_lock_type that
718 was decided in ha_innodb.cc,":: store_lock()", "::external_lock()",
719 etc. */
721
722 /** If mysql has locked with external_lock() */
724};
725
726struct trx_t;
727
728extern const struct _ft_vft ft_vft_result;
729
730/** Return the number of read threads for this session.
731@param[in] thd Session instance, or nullptr to query the global
732 innodb_parallel_read_threads value. */
734
735/** Structure Returned by ha_innobase::ft_init_ext() */
736typedef struct new_ft_info {
742
743/** Allocates an InnoDB transaction for a MySQL handler object for DML.
744@param[in] hton Innobase handlerton.
745@param[in] thd MySQL thd (connection) object.
746@param[in] trx transaction to register. */
747void innobase_register_trx(handlerton *hton, THD *thd, trx_t *trx);
748
749/**
750Allocates an InnoDB transaction for a MySQL handler object.
751@return InnoDB transaction handle */
752trx_t *innobase_trx_allocate(THD *thd); /*!< in: user thread handle */
753
754/** Maps a MySQL trx isolation level code to the InnoDB isolation level code.
755@param[in] iso MySQL isolation level code
756@return InnoDB isolation level */
759
760/** Match index columns between MySQL and InnoDB.
761This function checks whether the index column information
762is consistent between KEY info from mysql and that from innodb index.
763@param[in] key_info Index info from mysql
764@param[in] index_info Index info from InnoDB
765@return true if all column types match. */
766bool innobase_match_index_columns(const KEY *key_info,
767 const dict_index_t *index_info);
768
769/** This function checks each index name for a table against reserved
770 system default primary index name 'GEN_CLUST_INDEX'. If a name
771 matches, this function pushes an warning message to the client,
772 and returns true.
773 @return true if the index name matches the reserved name */
774[[nodiscard]] bool innobase_index_name_is_reserved(
775 THD *thd, /*!< in/out: MySQL connection */
776 const KEY *key_info, /*!< in: Indexes to be
777 created */
778 ulint num_of_keys); /*!< in: Number of indexes to
779 be created. */
780
781/** Check if the explicit tablespace targeted is file_per_table.
782@param[in] create_info Metadata for the table to create.
783@return true if the table is intended to use a file_per_table tablespace. */
785 const HA_CREATE_INFO *create_info) {
786 return (create_info->tablespace != nullptr &&
787 (0 ==
788 strcmp(create_info->tablespace, dict_sys_t::s_file_per_table_name)));
789}
790
791/** Check if table will be explicitly put in an existing shared general
792or system tablespace.
793@param[in] create_info Metadata for the table to create.
794@return true if the table will use a shared general or system tablespace. */
795static inline bool tablespace_is_shared_space(
796 const HA_CREATE_INFO *create_info) {
797 return (create_info->tablespace != nullptr &&
798 create_info->tablespace[0] != '\0' &&
799 (0 !=
800 strcmp(create_info->tablespace, dict_sys_t::s_file_per_table_name)));
801}
802
803/** Check if table will be explicitly put in a general tablespace.
804@param[in] create_info Metadata for the table to create.
805@return true if the table will use a general tablespace. */
807 const HA_CREATE_INFO *create_info) {
808 return (
809 create_info->tablespace != nullptr &&
810 create_info->tablespace[0] != '\0' &&
811 (0 !=
812 strcmp(create_info->tablespace, dict_sys_t::s_file_per_table_name)) &&
813 (0 != strcmp(create_info->tablespace, dict_sys_t::s_temp_space_name)) &&
814 (0 != strcmp(create_info->tablespace, dict_sys_t::s_sys_space_name)));
815}
816
817/** Check if tablespace is shared tablespace.
818@param[in] tablespace_name Name of the tablespace
819@return true if tablespace is a shared tablespace. */
820static inline bool is_shared_tablespace(const char *tablespace_name) {
821 if (tablespace_name != nullptr && tablespace_name[0] != '\0' &&
822 (strcmp(tablespace_name, dict_sys_t::s_file_per_table_name) != 0)) {
823 return true;
824 }
825 return false;
826}
827
828constexpr uint32_t SIZE_MB = 1024 * 1024;
829
830/** Validate AUTOEXTEND_SIZE attribute for a tablespace.
831@param[in] ext_size Value of autoextend_size attribute
832@return DB_SUCCESS if the value of AUTOEXTEND_SIZE is valid. */
833static inline int validate_autoextend_size_value(uint64_t ext_size) {
834 ut_ad(ext_size > 0);
835
836 page_no_t extent_size_pages = fsp_get_extent_size_in_pages(
837 {static_cast<uint32_t>(srv_page_size),
838 static_cast<uint32_t>(srv_page_size), false});
839
840 /* Validate following for the AUTOEXTEND_SIZE attribute
841 1. The autoextend_size should be a multiple of size of 4 extents
842 2. The autoextend_size value should be between size of 4 extents and 4G */
843 if (ext_size < (FSP_FREE_ADD * extent_size_pages * srv_page_size) ||
844 ext_size > FSP_MAX_AUTOEXTEND_SIZE) {
845 my_error(ER_INNODB_AUTOEXTEND_SIZE_OUT_OF_RANGE, MYF(0),
846 (FSP_FREE_ADD * extent_size_pages * srv_page_size) / SIZE_MB,
848 return ER_INNODB_AUTOEXTEND_SIZE_OUT_OF_RANGE;
849 }
850
851 if ((ext_size / srv_page_size) % (FSP_FREE_ADD * extent_size_pages) != 0) {
852 my_error(ER_INNODB_INVALID_AUTOEXTEND_SIZE_VALUE, MYF(0),
853 FSP_FREE_ADD * extent_size_pages * srv_page_size / SIZE_MB);
854 return ER_INNODB_INVALID_AUTOEXTEND_SIZE_VALUE;
855 }
856
857 return DB_SUCCESS;
858}
859
860/** Parse hint for table and its indexes, and update the information
861in dictionary.
862@param[in] thd Connection thread
863@param[in,out] table Target table
864@param[in] table_share Table definition */
866 const TABLE_SHARE *table_share);
867
868/** Obtain the InnoDB transaction of a MySQL thread.
869@param[in,out] thd MySQL thread handler.
870@return reference to transaction pointer */
871trx_t *&thd_to_trx(THD *thd);
872
873/** Class for handling create table information. */
875 public:
876 /** Constructor.
877 Used in two ways:
878 - all but file_per_table is used, when creating the table.
879 - all but name/path is used, when validating options and using flags. */
881 char *table_name, char *remote_path, char *tablespace,
882 bool file_per_table, bool skip_strict, uint32_t old_flags,
883 uint32_t old_flags2, bool is_partition)
884 : m_thd(thd),
886 m_form(form),
887 m_create_info(create_info),
889 m_remote_path(remote_path),
890 m_tablespace(tablespace),
891 m_innodb_file_per_table(file_per_table),
892 m_flags(old_flags),
893 m_flags2(old_flags2),
896
897 /** Initialize the object. */
898 int initialize();
899
900 /** Set m_tablespace_type. */
901 void set_tablespace_type(bool table_being_altered_is_file_per_table);
902
903 /** Create the internal innodb table.
904 @param[in] dd_table dd::Table or nullptr for intrinsic table
905 @param[in] old_part_table dd::Table from an old partition for partitioned
906 table, NULL otherwise.
907 @return 0 or error number */
908 int create_table(const dd::Table *dd_table, const dd::Table *old_part_table);
909
910 /** Update the internal data dictionary. */
912
913 /** Update the global data dictionary.
914 @param[in] dd_table dd::Table or dd::Partition
915 @retval 0 On success
916 @retval error number On failure */
917 template <typename Table>
918 int create_table_update_global_dd(Table *dd_table);
919
920 /** Validates the create options. Checks that the options
921 KEY_BLOCK_SIZE, ROW_FORMAT, DATA DIRECTORY, TEMPORARY & TABLESPACE
922 are compatible with each other and other settings.
923 These CREATE OPTIONS are not validated here unless innodb_strict_mode
924 is on. With strict mode, this function will report each problem it
925 finds using a custom message with error code
926 ER_ILLEGAL_HA_CREATE_OPTION, not its built-in message.
927 @return NULL if valid, string name of bad option if not. */
928 const char *create_options_are_invalid();
929
930 private:
931 /** Put a warning or error message to the error log for the
932 DATA DIRECTORY option.
933 @param[in] msg The reason that data directory is wrong.
934 @param[in] ignore If true, append a message about ignoring
935 the data directory location. */
936 void log_error_invalid_location(std::string &msg, bool ignore);
937
938 public:
939 /** Validate DATA DIRECTORY option. */
941
942 /** Validate TABLESPACE option. */
944
945 /** Validate COMPRESSION option. */
947
948 /** Prepare to create a table. */
949 int prepare_create_table(const char *name);
950
951 /** Determine InnoDB table flags.
952 If strict_mode=OFF, this will adjust the flags to what should be assumed.
953 However, if an existing general tablespace is being targeted, we will NOT
954 assume anything or adjust these flags.
955 @retval true if successful, false if error */
957
958 /** Set flags and append '/' to remote path if necessary. */
960
961 /** Get table flags. */
962 uint32_t flags() const { return (m_flags); }
963
964 /** Get table flags2. */
965 uint32_t flags2() const { return (m_flags2); }
966
967 /** Reset table flags. */
968 void flags_reset() { m_flags = 0; }
969
970 /** Reset table flags2. */
971 void flags2_reset() { m_flags2 = 0; }
972
973 /** whether to skip strict check. */
974 bool skip_strict() const { return (m_skip_strict); }
975
976 /** Return table name. */
977 const char *table_name() const { return (m_table_name); }
978
979 THD *thd() const { return (m_thd); }
980
981 inline bool is_intrinsic_temp_table() const {
982 /* DICT_TF2_INTRINSIC implies DICT_TF2_TEMPORARY */
984 return ((m_flags2 & DICT_TF2_INTRINSIC) != 0);
985 }
986
987 /** @return true only if table is temporary and not intrinsic */
988 inline bool is_temp_table() const {
989 return (((m_flags2 & DICT_TF2_TEMPORARY) != 0) &&
990 ((m_flags2 & DICT_TF2_INTRINSIC) == 0));
991 }
992
993 /** Detach the just created table and its auxiliary tables if exist. */
994 void detach();
995
996 /** Normalizes a table name string.
997 A normalized name consists of the database name catenated to '/' and
998 table name. An example: test/mytable. On case insensitive file system
999 normalization converts name to lower case.
1000 @param[in,out] norm_name Buffer to return the normalized name in.
1001 @param[in] name Table name string.
1002 @return true if successful. */
1003 static bool normalize_table_name(char *norm_name, const char *name);
1004
1005 private:
1006 /** Parses the table name into normal name and either temp path or
1007 remote path if needed.*/
1008 int parse_table_name(const char *name);
1009
1010 /** Create a table definition to an InnoDB database.
1011 @param[in] dd_table dd::Table or nullptr for intrinsic table
1012 @param[in] old_part_table dd::Table from an old partition for partitioned
1013 table, NULL otherwise.
1014 @return HA_* level error */
1015 int create_table_def(const dd::Table *dd_table,
1016 const dd::Table *old_part_table);
1017
1018 /** Initialize the autoinc of this table if necessary, which should
1019 be called before we flush logs, so autoinc counter can be persisted. */
1020 void initialize_autoinc();
1021
1022 /** Connection thread handle. */
1024
1025 /** InnoDB transaction handle. */
1027
1028 /** Information on table columns and indexes. */
1030
1031 /** Create options. */
1033
1034 /** Table name */
1036 /** Remote path (DATA DIRECTORY) or zero length-string */
1038 /** Tablespace name or zero length-string. */
1040
1041 /** The newly created InnoDB table object. This is currently only
1042 used in this class, since the new table is not evictable until
1043 final success/failure, it can be accessed directly. */
1045
1046 /** Local copy of srv_file_per_table. */
1048
1049 /** Allow file_per_table for this table either because:
1050 1) the setting innodb_file_per_table=on,
1051 2) it was explicitly requested by tablespace=innodb_file_per_table.
1052 3) the table being altered is currently file_per_table */
1054
1055 /** After all considerations, this shows whether we will actually
1056 create a table and tablespace using file-per-table. */
1058
1059 /** Using DATA DIRECTORY */
1061
1062 /** Using a Shared General Tablespace */
1064
1065 /** Table flags */
1066 uint32_t m_flags;
1067
1068 /** Table flags2 */
1069 uint32_t m_flags2;
1070
1071 /** Skip strict check */
1073
1074 /** True if this table is a partition */
1076};
1077
1078/** Class of basic DDL implementation, for CREATE/DROP/RENAME TABLE */
1080 public:
1081 /** Create an InnoDB table.
1082 @tparam Table dd::Table or dd::Partition
1083 @param[in,out] thd THD object
1084 @param[in] name Table name, format: "db/table_name"
1085 @param[in] form Table format; columns and index
1086 information
1087 @param[in] create_info Create info(including create statement
1088 string)
1089 @param[in,out] dd_tab dd::Table describing table to be created
1090 @param[in] file_per_table whether to create a tablespace too
1091 @param[in] evictable whether the caller wants the
1092 dict_table_t to be kept in memory
1093 @param[in] skip_strict whether to skip strict check for create
1094 option
1095 @param[in] old_flags old Table flags
1096 @param[in] old_flags2 old Table flags2
1097 @param[in] old_dd_table Table def for old table. Used in truncate or
1098 while adding a new partition
1099 @return error number
1100 @retval 0 on success */
1101 template <typename Table>
1102 static int create_impl(THD *thd, const char *name, TABLE *form,
1103 HA_CREATE_INFO *create_info, Table *dd_tab,
1104 bool file_per_table, bool evictable, bool skip_strict,
1105 uint32_t old_flags, uint32_t old_flags2,
1106 const dd::Table *old_dd_table);
1107
1108 /** Drop an InnoDB table.
1109 @tparam Table dd::Table or dd::Partition
1110 @param[in,out] thd THD object
1111 @param[in] name table name
1112 @param[in] dd_tab dd::Table describing table to be dropped
1113 @param[in] td MySQL table definition
1114 @return error number
1115 @retval 0 on success */
1116
1117 template <typename Table>
1118 static int delete_impl(THD *thd, const char *name, const Table *dd_tab,
1119 const TABLE *td);
1120
1121 /** Renames an InnoDB table.
1122 @tparam Table dd::Table or dd::Partition
1123 @param[in,out] thd THD object
1124 @param[in] from old name of the table
1125 @param[in] to new name of the table
1126 @param[in] from_table dd::Table or dd::Partition of the table
1127 with old name
1128 @param[in] to_table dd::Table or dd::Partition of the table
1129 with new name
1130 @param[in] td MySQL table definition
1131 @return error number
1132 @retval 0 on success */
1133
1134 template <typename Table>
1135 static int rename_impl(THD *thd, const char *from, const char *to,
1136 const Table *from_table, const Table *to_table,
1137 const TABLE *td);
1138};
1139
1140/** Class to handle TRUNCATE for one InnoDB table or one partition */
1141template <typename Table>
1143 public:
1144 /** Constructor
1145 @param[in] thd THD object
1146 @param[in] name normalized table name
1147 @param[in] form Table format; columns and index information
1148 @param[in] dd_table dd::Table or dd::Partition
1149 @param[in] keep_autoinc true to remember original autoinc counter
1150 @param[in] table_truncate true if this is full table truncate */
1151 innobase_truncate(THD *thd, const char *name, TABLE *form, Table *dd_table,
1152 bool keep_autoinc, bool table_truncate)
1153 : m_thd(thd),
1154 m_name(name),
1155 m_dd_table(dd_table),
1156 m_trx(nullptr),
1158 m_form(form),
1159 m_create_info(),
1160 m_file_per_table(false),
1161 m_keep_autoinc(keep_autoinc),
1162 m_table_truncate(table_truncate),
1163 m_flags(0),
1164 m_flags2(0) {}
1165
1166 /** Destructor */
1168
1169 /** Open the table/partition to be truncated
1170 @param[out] innodb_table InnoDB table object opened
1171 @return error number or 0 on success */
1172 int open_table(dict_table_t *&innodb_table);
1173
1174 /** Do the truncate of the table/partition
1175 @return error number or 0 on success */
1176 int exec();
1177
1178 private:
1179 /** Prepare for truncate
1180 @return error number or 0 on success */
1181 int prepare();
1182
1183 /** Do the real truncation
1184 @return error number or 0 on success */
1185 int truncate();
1186
1187 /** Rename tablespace file name
1188 @return error number or 0 on success */
1189 int rename_tablespace();
1190
1191 /** Cleanup */
1192 void cleanup();
1193
1194 /** Reload the FK related information
1195 @return error number or 0 on success */
1196 int load_fk();
1197
1198 private:
1199 /** THD object */
1201
1202 /** Normalized table name */
1203 const char *m_name;
1204
1205 /** dd::Table or dd::Partition */
1207
1208 /** Transaction attached to current thd */
1210
1211 /** InnoDB table object for the table/partition */
1213
1214 /** Table format */
1216
1217 /** Create information */
1219
1220 /** True if this table/partition is file per table */
1222
1223 /** True if the original autoinc counter should be kept. It's
1224 specified by caller, however if the table has no AUTOINC column,
1225 it would be reset to false internally */
1227
1228 /** For a prtition table, this is true if full table is truncated. If only
1229 a partition is truncated, it is set to false. */
1231
1232 /** flags of the table to be truncated, which should not change */
1233 uint32_t m_flags;
1234
1235 /** flags2 of the table to be truncated, which should not change */
1236 uint32_t m_flags2;
1237};
1238
1239/**
1240Initialize the table FTS stopword list
1241@return true if success */
1242[[nodiscard]] bool innobase_fts_load_stopword(
1243 dict_table_t *table, /*!< in: Table has the FTS */
1244 trx_t *trx, /*!< in: transaction */
1245 THD *thd); /*!< in: current thread */
1246
1247/** Some defines for innobase_fts_check_doc_id_index() return value */
1253
1254/**
1255Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME
1256on the Doc ID column.
1257@return the status of the FTS_DOC_ID index */
1259 const dict_table_t *table, /*!< in: table definition */
1260 const TABLE *altered_table, /*!< in: MySQL table
1261 that is being altered */
1262 ulint *fts_doc_col_no); /*!< out: The column number for
1263 Doc ID */
1264
1265/**
1266Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME
1267on the Doc ID column in MySQL create index definition.
1268@return FTS_EXIST_DOC_ID_INDEX if there exists the FTS_DOC_ID index,
1269FTS_INCORRECT_DOC_ID_INDEX if the FTS_DOC_ID index is of wrong format */
1271 ulint n_key, /*!< in: Number of keys */
1272 const KEY *key_info); /*!< in: Key definitions */
1273
1274/**
1275Copy table flags from MySQL's TABLE_SHARE into an InnoDB table object.
1276Those flags are stored in .frm file and end up in the MySQL table object,
1277but are frequently used inside InnoDB so we keep their copies into the
1278InnoDB table object. */
1280 dict_table_t *innodb_table, /*!< in/out: InnoDB table */
1281 const TABLE_SHARE *table_share); /*!< in: table share */
1282
1283/** Set up base columns for virtual column
1284@param[in] table the InnoDB table
1285@param[in] field MySQL field
1286@param[in,out] v_col virtual column to be set up */
1287void innodb_base_col_setup(dict_table_t *table, const Field *field,
1288 dict_v_col_t *v_col);
1289
1290/** Set up base columns for stored column
1291@param[in] table InnoDB table
1292@param[in] field MySQL field
1293@param[in,out] s_col stored column */
1295 const Field *field, dict_s_col_t *s_col);
1296
1297/** whether this is a stored column */
1298static inline bool innobase_is_s_fld(const Field *field) {
1299 return field->gcol_info && field->stored_in_db;
1300}
1301
1302/** Whether this is a computed multi-value virtual column.
1303This condition check should be equal to the following one:
1304(innobase_is_v_fld(field) && (field)->gcol_info->expr_item &&
1305 field->gcol_info->expr_item->returns_array())
1306*/
1307static inline bool innobase_is_multi_value_fld(const Field *field) {
1308 return field->is_array();
1309}
1310
1311static inline bool normalize_table_name(char *norm_name, const char *name) {
1313}
1314
1315/** Note that a transaction has been registered with MySQL.
1316@param[in] trx Transaction.
1317@return true if transaction is registered with MySQL 2PC coordinator */
1318inline bool trx_is_registered_for_2pc(const trx_t *trx) {
1319 return (trx->is_registered == 1);
1320}
1321
1322/** Converts an InnoDB error code to a MySQL error code.
1323Also tells to MySQL about a possible transaction rollback inside InnoDB caused
1324by a lock wait timeout or a deadlock.
1325@param[in] error InnoDB error code.
1326@param[in] flags InnoDB table flags or 0.
1327@param[in] thd MySQL thread or NULL.
1328@return MySQL error code */
1330
1331/** Converts a search mode flag understood by MySQL to a flag understood
1332by InnoDB.
1333@param[in] find_flag MySQL search mode flag.
1334@return InnoDB search mode flag. */
1336 enum ha_rkey_function find_flag);
1337
1338extern bool innobase_stats_on_metadata;
1339
1340/** Calculate Record Per Key value.
1341Need to exclude the NULL value if innodb_stats_method is set to "nulls_ignored"
1342@param[in] index InnoDB index.
1343@param[in] i The column we are calculating rec per key.
1344@param[in] records Estimated total records.
1345@return estimated record per key value */
1347 ha_rows records);
1348
1349/** Build template for the virtual columns and their base columns. This
1350is done when the table first opened.
1351@param[in] table MySQL TABLE
1352@param[in] ib_table InnoDB dict_table_t
1353@param[in,out] s_templ InnoDB template structure
1354@param[in] add_v new virtual columns added along with
1355 add index call
1356@param[in] locked true if dict_sys mutex is held
1357@param[in] share_tbl_name original MySQL table name */
1358void innobase_build_v_templ(const TABLE *table, const dict_table_t *ib_table,
1359 dict_vcol_templ_t *s_templ,
1360 const dict_add_v_col_t *add_v, bool locked,
1361 const char *share_tbl_name);
1362
1363/** Callback used by MySQL server layer to initialize
1364the table virtual columns' template
1365@param[in] table MySQL TABLE
1366@param[in,out] ib_table InnoDB table */
1367void innobase_build_v_templ_callback(const TABLE *table, void *ib_table);
1368
1369/** Callback function definition, used by MySQL server layer to initialized
1370the table virtual columns' template */
1371typedef void (*my_gcolumn_templatecallback_t)(const TABLE *, void *);
1372
1373/** Drop the statistics for a specified table, and mark it as discard
1374after DDL
1375@param[in,out] thd THD object
1376@param[in,out] table InnoDB table object */
1378#endif /* ha_innodb_h */
uint32_t page_no_t
Page number.
Definition: api0api.h:48
app_data_ptr new_data(u_int n, char *val, cons_type consensus)
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:250
Class describing changes to be done by ALTER TABLE.
Definition: handler.h:3283
Used to store optimizer cost estimates.
Definition: handler.h:3793
Definition: handler.h:7199
Definition: field.h:576
virtual bool is_array() const
Whether the field is a typed array.
Definition: field.h:1793
Value_generator * gcol_info
Definition: field.h:805
bool stored_in_db
Indication that the field is physically stored in tables rather than just generated on SQL queries.
Definition: field.h:811
Wrapper for struct ft_hints.
Definition: handler.h:4053
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:932
Definition: key.h:112
Definition: sql_list.h:433
Traverse an index in the leaf page block list order and send records to adapter.
Definition: row0pread-adapter.h:42
handler::Load_init_cbk Init_fn
Definition: row0pread-adapter.h:54
handler::Load_end_cbk End_fn
Definition: row0pread-adapter.h:52
handler::Load_cbk Load_fn
Definition: row0pread-adapter.h:50
Implements the row and column memory management for parse and load operations.
Definition: bulk_data_service.h:85
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
Class for handling create table information.
Definition: ha_innodb.h:874
bool is_intrinsic_temp_table() const
Definition: ha_innodb.h:981
bool m_use_file_per_table
After all considerations, this shows whether we will actually create a table and tablespace using fil...
Definition: ha_innodb.h:1057
int prepare_create_table(const char *name)
Prepare to create a table.
Definition: ha_innodb.cc:13959
const char * table_name() const
Return table name.
Definition: ha_innodb.h:977
uint32_t m_flags
Table flags.
Definition: ha_innodb.h:1066
THD * m_thd
Connection thread handle.
Definition: ha_innodb.h:1023
bool create_option_tablespace_is_valid()
Validate TABLESPACE option.
Definition: ha_innodb.cc:12697
char * m_remote_path
Remote path (DATA DIRECTORY) or zero length-string.
Definition: ha_innodb.h:1037
int create_table_update_global_dd(Table *dd_table)
Update the global data dictionary.
Definition: ha_innodb.cc:14332
bool create_option_compression_is_valid()
Validate COMPRESSION option.
Definition: ha_innodb.cc:12940
void flags2_reset()
Reset table flags2.
Definition: ha_innodb.h:971
void initialize_autoinc()
Initialize the autoinc of this table if necessary, which should be called before we flush logs,...
Definition: ha_innodb.cc:13896
HA_CREATE_INFO * m_create_info
Create options.
Definition: ha_innodb.h:1032
bool is_temp_table() const
Definition: ha_innodb.h:988
int initialize()
Initialize the object.
Definition: ha_innodb.cc:13868
dict_table_t * m_table
The newly created InnoDB table object.
Definition: ha_innodb.h:1044
void detach()
Detach the just created table and its auxiliary tables if exist.
Definition: ha_innodb.cc:13707
trx_t * m_trx
InnoDB transaction handle.
Definition: ha_innodb.h:1026
bool m_partition
True if this table is a partition.
Definition: ha_innodb.h:1075
uint32_t flags2() const
Get table flags2.
Definition: ha_innodb.h:965
int create_table(const dd::Table *dd_table, const dd::Table *old_part_table)
Create the internal innodb table.
Definition: ha_innodb.cc:14073
static bool normalize_table_name(char *norm_name, const char *name)
Normalizes a table name string.
Definition: ha_innodb.cc:6757
bool m_use_data_dir
Using DATA DIRECTORY.
Definition: ha_innodb.h:1060
char * m_tablespace
Tablespace name or zero length-string.
Definition: ha_innodb.h:1039
bool m_allow_file_per_table
Allow file_per_table for this table either because: 1) the setting innodb_file_per_table=on,...
Definition: ha_innodb.h:1053
bool m_use_shared_space
Using a Shared General Tablespace.
Definition: ha_innodb.h:1063
uint32_t m_flags2
Table flags2.
Definition: ha_innodb.h:1069
bool m_skip_strict
Skip strict check.
Definition: ha_innodb.h:1072
int parse_table_name(const char *name)
Parses the table name into normal name and either temp path or remote path if needed.
Definition: ha_innodb.cc:13373
create_table_info_t(THD *thd, TABLE *form, HA_CREATE_INFO *create_info, char *table_name, char *remote_path, char *tablespace, bool file_per_table, bool skip_strict, uint32_t old_flags, uint32_t old_flags2, bool is_partition)
Constructor.
Definition: ha_innodb.h:880
int create_table_update_dict()
Update the internal data dictionary.
Definition: ha_innodb.cc:14281
void set_tablespace_type(bool table_being_altered_is_file_per_table)
Set m_tablespace_type.
Definition: ha_innodb.cc:13837
bool m_innodb_file_per_table
Local copy of srv_file_per_table.
Definition: ha_innodb.h:1047
bool innobase_table_flags()
Determine InnoDB table flags.
Definition: ha_innodb.cc:13441
const TABLE * m_form
Information on table columns and indexes.
Definition: ha_innodb.h:1029
void set_remote_path_flags()
Set flags and append '/' to remote path if necessary.
Definition: ha_innopart.cc:2371
char * m_table_name
Table name.
Definition: ha_innodb.h:1035
void log_error_invalid_location(std::string &msg, bool ignore)
Put a warning or error message to the error log for the DATA DIRECTORY option.
Definition: ha_innodb.cc:12509
uint32_t flags() const
Get table flags.
Definition: ha_innodb.h:962
bool skip_strict() const
whether to skip strict check.
Definition: ha_innodb.h:974
void flags_reset()
Reset table flags.
Definition: ha_innodb.h:968
THD * thd() const
Definition: ha_innodb.h:979
const char * create_options_are_invalid()
Validates the create options.
Definition: ha_innodb.cc:13004
bool create_option_data_directory_is_valid(bool ignore=false)
Validate DATA DIRECTORY option.
Definition: ha_innodb.cc:12530
int create_table_def(const dd::Table *dd_table, const dd::Table *old_part_table)
Create a table definition to an InnoDB database.
Definition: ha_innodb.cc:11662
Definition: table.h:46
The class defining a handle to an InnoDB table.
Definition: ha_innodb.h:86
THD * m_user_thd
Thread handle of the user currently using the handler; this is set in external_lock function.
Definition: ha_innodb.h:695
void mv_key_capacity(uint *num_keys, size_t *keys_length) const override
Return max limits for a single set of multi-valued keys.
Definition: ha_innodb.cc:24135
int reset() override
MySQL calls this method at the end of each statement.
Definition: ha_innodb.cc:18771
int ft_init() override
Initialize FT index scan.
Definition: ha_innodb.cc:11205
int parallel_scan_init(void *&scan_ctx, size_t *num_threads, bool use_reserved_threads, size_t max_desired_threads) override
Initializes a parallel scan.
Definition: handler0alter.cc:1457
Table_flags table_flags() const override
Get the table flags to use for the statement.
Definition: ha_innodb.cc:6646
DsMrr_impl m_ds_mrr
The multi range read session object.
Definition: ha_innodb.h:688
int disable_indexes(uint mode) override
Disable indexes.
Definition: ha_innodb.cc:18378
int sample_init(void *&scan_ctx, double sampling_percentage, int sampling_seed, enum_sampling_method sampling_method, const bool tablesample) override
Initialize sampling.
Definition: ha_innodb.cc:11000
int delete_table(const char *name, const dd::Table *table_def, enum enum_sql_command sqlcom)
Drop a table.
uchar * m_upd_buf
buffer used in updates
Definition: ha_innodb.h:701
Item * idx_cond_push(uint keyno, Item *idx_cond) override
Attempt to push down an index condition.
Definition: ha_innodb.cc:24093
int general_fetch(uchar *buf, uint direction, uint match_mode)
Reads the next or previous row from a cursor, which must have previously been positioned using index_...
Definition: ha_innodb.cc:10842
int records_from_index(ha_rows *num_rows, uint) override
Number of rows in table counted using the secondary index chosen by optimizer.
Definition: ha_innodb.h:255
uint m_last_match_mode
Definition: ha_innodb.h:715
int rnd_pos(uchar *buf, uchar *pos) override
Fetches a row from the table based on a row reference.
Definition: ha_innodb.cc:11174
int extra(ha_extra_function operation) override
Tells something additional to the handler about how to do things.
Definition: ha_innodb.cc:18652
void build_template(bool whole_row)
Builds a 'template' to the m_prebuilt struct.
Definition: ha_innodb.cc:8694
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info, dd::Table *table_def) override
Create an InnoDB table.
Definition: ha_innodb.cc:15409
bool is_record_buffer_wanted(ha_rows *const max_rows) const override
Find out if a Record_buffer is wanted by this handler, and what is the maximum buffer size the handle...
Definition: ha_innodb.cc:24112
double scan_time() override
How many seeks it will take to read through the table.
Definition: ha_innodb.cc:17169
void innobase_initialize_autoinc()
Set the autoinc column max value.
Definition: ha_innodb.cc:7374
int discard_or_import_tablespace(bool discard, dd::Table *table_def) override
Discards or imports an InnoDB tablespace.
Definition: ha_innodb.cc:15442
handler * clone(const char *name, MEM_ROOT *mem_root) override
Definition: ha_innodb.cc:7963
void srv_concurrency_exit()
Leave Innodb, if no more tickets are left.
Definition: ha_innodb.cc:2966
ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys, uint *bufsz, uint *flags, Cost_estimate *cost) override
Initialize multi range read and get information.
Definition: ha_innodb.cc:23765
bool primary_key_is_clustered() const override
Determines if the primary key is clustered index.
Definition: ha_innodb.cc:6755
int intrinsic_table_write_row(uchar *record)
Write Row Interface optimized for Intrinsic table.
Definition: ha_innodb.cc:9086
int start_stmt(THD *thd, thr_lock_type lock_type) override
MySQL calls this function at the start of each SQL statement inside LOCK TABLES.
Definition: ha_innodb.cc:18785
ulong index_flags(uint idx, uint part, bool all_parts) const override
Returns the operations supported for indexes.
Definition: ha_innodb.cc:6685
int rnd_end() override
Ends a table scan.
Definition: ha_innodb.cc:11139
int update_row(const uchar *old_data, uchar *new_data) override
Updates a row given as a parameter to a new value.
Definition: ha_innodb.cc:10074
int index_end() override
Currently does nothing.
Definition: ha_innodb.cc:10384
ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key) override
Estimates the number of index records in a range.
Definition: ha_innodb.cc:17002
virtual dict_index_t * innobase_get_index(uint keynr)
Get the index for a handle.
Definition: ha_innodb.cc:10697
uint max_supported_key_part_length(HA_CREATE_INFO *create_info) const override
Definition: ha_innodb.cc:7980
int get_extra_columns_and_keys(const HA_CREATE_INFO *, const List< Create_field > *, const KEY *, uint, dd::Table *dd_table) override
Add hidden columns and indexes to an InnoDB table definition.
Definition: ha_innodb.cc:15097
int multi_range_read_next(char **range_info) override
Process next multi range read.
Definition: ha_innodb.cc:23749
row_prebuilt_t * m_prebuilt
Save CPU time with prebuilt/cached data structures.
Definition: ha_innodb.h:691
bool m_mysql_has_locked
If mysql has locked with external_lock()
Definition: ha_innodb.h:723
int index_next_same(uchar *buf, const uchar *key, uint keylen) override
Reads the next row matching to the key value given as the parameter.
Definition: ha_innodb.cc:10937
int rnd_next(uchar *buf) override
Reads the next row in a table scan (also used to read the FIRST row in a table scan).
Definition: ha_innodb.cc:11145
bool prepare_inplace_alter_table_impl(TABLE *altered_table, Alter_inplace_info *ha_alter_info, const Table *old_dd_tab, Table *new_dd_tab)
Implementation of prepare_inplace_alter_table()
Definition: handler0alter.cc:5439
int enable_indexes(uint mode) override
Enable indexes.
Definition: ha_innodb.cc:18352
ha_innobase(handlerton *hton, TABLE_SHARE *table_arg)
Construct ha_innobase handler.
Definition: ha_innodb.cc:2972
void update_thd()
Updates the user_thd field in a handle and also allocates a new InnoDB transaction handle if needed,...
Definition: ha_innodb.cc:3022
int rnd_init(bool scan) override
Initialize a table scan.
Definition: ha_innodb.cc:11118
int index_next(uchar *buf) override
Reads the next row from a cursor, which must have previously been positioned using index_read.
Definition: ha_innodb.cc:10926
INNOBASE_SHARE * m_share
information for MySQL table locking
Definition: ha_innodb.h:698
int parallel_scan(void *scan_ctx, void **thread_ctxs, Reader::Init_fn init_fn, Reader::Load_fn load_fn, Reader::End_fn end_fn) override
Start parallel read of InnoDB records.
Definition: handler0alter.cc:1526
int bulk_load_end(THD *thd, void *load_ctx, bool is_error) override
End bulk load operation.
Definition: handler0alter.cc:11227
ulint m_stored_select_lock_type
this field is used to remember the original select_lock_type that was decided in ha_innodb....
Definition: ha_innodb.h:720
dberr_t innobase_set_max_autoinc(ulonglong auto_inc)
Store the autoinc value in the table.
Definition: ha_innodb.cc:9067
virtual bool can_reuse_mysql_template() const
Can reuse the template.
Definition: ha_innodb.h:685
void position(const uchar *record) override
Store a reference to the current row to 'ref' field of the handle.
Definition: ha_innodb.cc:11560
int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint mode, HANDLER_BUFFER *buf) override
Initialize multi range read.
Definition: ha_innodb.cc:23741
void unlock_row() override
Removes a new lock set on a row, if it was not read optimistically.
Definition: ha_innodb.cc:10304
bool commit_inplace_alter_table_impl(TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit, Table *new_dd_tab)
Implementation of commit_inplace_alter_table()
Definition: handler0alter.cc:7434
bool m_start_of_scan
this is set to 1 when we are starting a table scan but have not yet fetched any row,...
Definition: ha_innodb.h:711
int rename_table(const char *from, const char *to, const dd::Table *from_table, dd::Table *to_table) override
Renames an InnoDB table.
Definition: ha_innodb.cc:16873
void position(uchar *record)
bool was_semi_consistent_read() override
Definition: ha_innodb.cc:10352
int close(void) override
Closes a handle to an InnoDB table.
Definition: ha_innodb.cc:7997
int srv_concurrency_enter()
Enter InnoDB engine after checking max allowed threads.
Definition: ha_innodb.cc:2959
int end_stmt()
MySQL calls this method at the end of each statement.
Definition: ha_innodb.cc:18729
bool get_se_private_data(dd::Table *dd_table, bool reset) override
Get storage-engine private data for a data dictionary table.
Definition: ha_innodb.cc:15331
bool is_index_algorithm_supported(enum ha_key_alg key_alg) const override
Check if SE supports specific key algorithm.
Definition: ha_innodb.h:100
ha_rows estimate_rows_upper_bound() override
Gives an UPPER BOUND to the number of rows in a table.
Definition: ha_innodb.cc:17122
void ft_end()
Definition: ha_innodb.cc:11545
bool get_error_message(int error, String *buf) override
See comment in handler.cc.
Definition: ha_innodb.cc:20108
int open(const char *name, int, uint open_flags, const dd::Table *table_def) override
Open an InnoDB table.
Definition: ha_innodb.cc:7495
uint max_supported_key_length() const override
Returns the maximum key length.
Definition: ha_innodb.cc:6729
longlong get_memory_buffer_size() const override
Return the size of the InnoDB memory buffer.
Definition: ha_innodb.cc:17233
int change_active_index(uint keynr)
Changes the active index of a handle.
Definition: ha_innodb.cc:10741
int records(ha_rows *num_rows) override
Returns the exact number of records that this client can see using this handler object.
Definition: ha_innodb.cc:16911
THR_LOCK_DATA ** store_lock(THD *thd, THR_LOCK_DATA **to, thr_lock_type lock_type) override
Supposed to convert a MySQL table lock stored in the 'lock' field of the handle to a proper type befo...
Definition: ha_innodb.cc:19753
uint lock_count(void) const override
Returns number of THR_LOCK locks used for one instance of InnoDB table.
Definition: ha_innodb.cc:19737
bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes) override
Part of old, deprecated in-place ALTER API.
Definition: ha_innodb.cc:20506
dberr_t innobase_get_autoinc(ulonglong *value)
Read the next autoinc value.
Definition: ha_innodb.cc:19931
void reset_template()
Resets a query execution 'template'.
Definition: ha_innodb.cc:3172
ulint m_upd_buf_size
the size of upd_buf in bytes
Definition: ha_innodb.h:704
void get_auto_increment(ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong *first_value, ulonglong *nb_reserved_values) override
Returns the value of the auto-inc counter in *first_value and ~0 on failure.
Definition: ha_innodb.cc:19969
size_t bulk_load_available_memory(THD *thd) const override
Get the total memory available for bulk load in innodb buffer pool.
Definition: handler0alter.cc:11156
int info(uint) override
Returns statistics information of the table to the MySQL interpreter, in various fields of the handle...
Definition: ha_innodb.cc:17824
int delete_table(const char *name, const dd::Table *table_def) override
Drop a table.
Definition: ha_innodb.cc:15642
FT_INFO * ft_init_ext(uint flags, uint inx, String *key) override
Initialize FT index scan.
Definition: ha_innodb.cc:11225
uint max_supported_keys() const override
Returns the maximum number of keys.
Definition: ha_innodb.cc:6724
int external_lock(THD *thd, int lock_type) override
As MySQL will execute an external lock for every new table it uses when it starts to process an SQL s...
Definition: ha_innodb.cc:18929
int cmp_ref(const uchar *ref1, const uchar *ref2) const override
Compares two 'refs'.
Definition: ha_innodb.cc:20176
int analyze(THD *thd, HA_CHECK_OPT *check_opt) override
Updates index cardinalities of the table, based on random dives into each index tree.
Definition: ha_innodb.cc:18406
int index_first(uchar *buf) override
Positions a cursor on the first record in an index and reads the corresponding row to buf.
Definition: ha_innodb.cc:10962
bool inplace_alter_table_impl(TABLE *altered_table, Alter_inplace_info *ha_alter_info)
Implementation of inplace_alter_table()
Definition: handler0alter.cc:6136
int ft_read(uchar *buf) override
Fetch next result from the FT result set.
Definition: ha_innodb.cc:11409
bool upgrade_table(THD *thd, const char *db_name, const char *table_name, dd::Table *dd_table) override
Set Engine specific data to dd::Table object for upgrade.
Definition: ha_innodb.cc:15321
void init_table_handle_for_HANDLER() override
Call this when you have opened a new table handle in HANDLER, before you call index_read_map() etc.
Definition: ha_innodb.cc:3202
int index_last(uchar *buf) override
Positions a cursor on the last record in an index and reads the corresponding row to buf.
Definition: ha_innodb.cc:10983
int truncate_impl(const char *name, TABLE *form, dd::Table *table_def)
TRUNCATE an InnoDB table.
Definition: ha_innodb.cc:15568
int sample_end(void *scan_ctx) override
End sampling.
Definition: ha_innodb.cc:11094
int index_init(uint index, bool sorted) override
Initializes a handle to use an index.
Definition: ha_innodb.cc:10371
int read_range_next() override
Read next row between two endpoints.
Definition: ha_innodb.cc:11109
Table_flags m_int_table_flags
Flags that specify the handler instance (table) capability.
Definition: ha_innodb.h:707
int index_read_last(uchar *buf, const uchar *key, uint key_len) override
The following functions works like index_read, but it find the last row with the current key value or...
Definition: ha_innodb.cc:10684
void try_semi_consistent_read(bool yes) override
Tell the engine whether it should avoid unnecessary lock waits.
Definition: ha_innodb.cc:10358
dberr_t innobase_lock_autoinc()
This special handling is really to overcome the limitations of MySQL's binlogging.
Definition: ha_innodb.cc:9001
row_type get_real_row_type(const HA_CREATE_INFO *create_info) const override
Get real row type for the table created based on one specified by user, CREATE TABLE options and SE c...
Definition: ha_innodb.cc:6596
FT_INFO * ft_init_ext_with_hints(uint inx, String *key, Ft_hints *hints) override
Initialize FT index scan.
Definition: ha_innodb.cc:11353
int index_read(uchar *buf, const uchar *key, uint key_len, ha_rkey_function find_flag) override
Positions an index cursor to the index specified in the handle.
Definition: ha_innodb.cc:10492
void parallel_scan_end(void *scan_ctx) override
End of the parallel scan.
Definition: handler0alter.cc:1549
void update_create_info(HA_CREATE_INFO *create_info) override
Update create_info.
Definition: ha_innodb.cc:13175
void release_auto_increment() override
Do cleanup for auto increment calculation.
Definition: ha_innodb.cc:19952
int index_prev(uchar *buf) override
Reads the previous row from a cursor, which must have previously been positioned using index_read.
Definition: ha_innodb.cc:10950
ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint *bufsz, uint *flags, Cost_estimate *cost) override
Initialize multi range read and get information.
Definition: ha_innodb.cc:23753
int write_row(uchar *buf) override
Stores a row in an InnoDB database, to the table specified in this handle.
Definition: ha_innodb.cc:9321
enum ha_key_alg get_default_index_algorithm() const override
Get default key algorithm for SE.
Definition: ha_innodb.h:95
int check(THD *thd, HA_CHECK_OPT *check_opt) override
Tries to check that an InnoDB table is not corrupted.
Definition: ha_innodb.cc:18455
int read_range_first(const key_range *start_key, const key_range *end_key, bool eq_range_arg, bool sorted) override
Read first row between two ranges.
Definition: ha_innodb.cc:11102
int delete_all_rows() override
Delete all rows from the table.
Definition: ha_innodb.cc:10285
bool bulk_load_check(THD *thd) const override
Check if the table is ready for bulk load.
Definition: handler0alter.cc:11115
int bulk_load_execute(THD *thd, void *load_ctx, size_t thread_idx, const Rows_mysql &rows, Bulk_load::Stat_callbacks &wait_cbk) override
Execute bulk load operation.
Definition: handler0alter.cc:11205
virtual int info_low(uint flag, bool is_analyze)
Returns statistics information of the table to the MySQL interpreter, in various fields of the handle...
Definition: ha_innodb.cc:17508
int sample_next(void *scan_ctx, uchar *buf) override
Get the next record for sampling.
Definition: ha_innodb.cc:11077
const char * table_type() const override
Returns the table type (storage engine name).
Definition: ha_innodb.cc:6680
double read_time(uint index, uint ranges, ha_rows rows) override
Calculate the time it takes to read a set of ranges through an index This enables us to optimise read...
Definition: ha_innodb.cc:17203
int optimize(THD *thd, HA_CHECK_OPT *check_opt) override
This is mapped to "ALTER TABLE tablename ENGINE=InnoDB", which rebuilds the table in MySQL.
Definition: ha_innodb.cc:18424
bool get_foreign_dup_key(char *, uint, char *, uint) override
Retrieves the names of the table and the key for which there was a duplicate entry in the case of HA_...
Definition: ha_innodb.cc:20132
~ha_innobase() override=default
int delete_row(const uchar *buf) override
Deletes a row given as the parameter.
Definition: ha_innodb.cc:10232
void * bulk_load_begin(THD *thd, size_t data_size, size_t memory, size_t num_threads) override
Begin parallel bulk data load to the table.
Definition: handler0alter.cc:11162
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4501
ulonglong Table_flags
Definition: handler.h:4505
Class of basic DDL implementation, for CREATE/DROP/RENAME TABLE.
Definition: ha_innodb.h:1079
static int rename_impl(THD *thd, const char *from, const char *to, const Table *from_table, const Table *to_table, const TABLE *td)
Renames an InnoDB table.
Definition: ha_innodb.cc:14639
static int create_impl(THD *thd, const char *name, TABLE *form, HA_CREATE_INFO *create_info, Table *dd_tab, bool file_per_table, bool evictable, bool skip_strict, uint32_t old_flags, uint32_t old_flags2, const dd::Table *old_dd_table)
Create an InnoDB table.
Definition: ha_innodb.cc:14421
static int delete_impl(THD *thd, const char *name, const Table *dd_tab, const TABLE *td)
Drop an InnoDB table.
Definition: ha_innodb.cc:14536
Class to handle TRUNCATE for one InnoDB table or one partition.
Definition: ha_innodb.h:1142
dict_table_t * m_table
InnoDB table object for the table/partition.
Definition: ha_innodb.h:1212
trx_t * m_trx
Transaction attached to current thd.
Definition: ha_innodb.h:1209
int open_table(dict_table_t *&innodb_table)
Open the table/partition to be truncated.
Definition: ha_innodb.cc:14770
bool m_keep_autoinc
True if the original autoinc counter should be kept.
Definition: ha_innodb.h:1226
Table * m_dd_table
dd::Table or dd::Partition
Definition: ha_innodb.h:1206
int truncate()
Do the real truncation.
Definition: ha_innodb.cc:14868
uint32_t m_flags2
flags2 of the table to be truncated, which should not change
Definition: ha_innodb.h:1236
TABLE * m_form
Table format.
Definition: ha_innodb.h:1215
HA_CREATE_INFO m_create_info
Create information.
Definition: ha_innodb.h:1218
int rename_tablespace()
Rename tablespace file name.
Definition: ha_innodb.cc:14963
bool m_file_per_table
True if this table/partition is file per table.
Definition: ha_innodb.h:1221
int load_fk()
Reload the FK related information.
Definition: ha_innodb.cc:15027
int prepare()
Prepare for truncate.
Definition: ha_innodb.cc:14801
int exec()
Do the truncate of the table/partition.
Definition: ha_innodb.cc:15058
innobase_truncate(THD *thd, const char *name, TABLE *form, Table *dd_table, bool keep_autoinc, bool table_truncate)
Constructor.
Definition: ha_innodb.h:1151
~innobase_truncate()
Destructor.
Definition: ha_innodb.cc:14759
uint32_t m_flags
flags of the table to be truncated, which should not change
Definition: ha_innodb.h:1233
void cleanup()
Cleanup.
Definition: ha_innodb.cc:15010
bool m_table_truncate
For a prtition table, this is true if full table is truncated.
Definition: ha_innodb.h:1230
THD * m_thd
THD object.
Definition: ha_innodb.h:1200
const char * m_name
Normalized table name.
Definition: ha_innodb.h:1203
A table definition from the master.
Definition: rpl_utility.h:247
static MEM_ROOT mem_root
Definition: client_plugin.cc:113
This service provides functions for clone plugin to connect and interact with remote server's clone p...
dberr_t
Definition: db0err.h:38
@ DB_SUCCESS
Definition: db0err.h:42
constexpr uint32_t DICT_TF2_TEMPORARY
TEMPORARY; true for tables from CREATE TEMPORARY TABLE.
Definition: dict0mem.h:268
constexpr uint32_t DICT_TF2_INTRINSIC
Intrinsic table bit Intrinsic table is table created internally by MySQL modules viz.
Definition: dict0mem.h:291
static page_no_t fsp_get_extent_size_in_pages(const page_size_t &page_size)
Calculate the number of physical pages in an extent for this file.
Definition: fsp0fsp.h:355
constexpr uint64_t FSP_MAX_AUTOEXTEND_SIZE
Definition: fsp0fsp.h:180
bool commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit, const dd::Table *old_dd_tab, dd::Table *new_dd_tab) override
Commit or rollback the changes made during prepare_inplace_alter_table() and inplace_alter_table() in...
Definition: handler0alter.cc:1591
enum_alter_inplace_result check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_info *ha_alter_info) override
Check if InnoDB supports a particular alter table in-place.
Definition: handler0alter.cc:963
bool inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, const dd::Table *old_dd_tab, dd::Table *new_dd_tab) override
Alter the table structure in-place with operations specified using HA_ALTER_FLAGS and Alter_inplace_i...
Definition: handler0alter.cc:1555
bool prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, const dd::Table *old_dd_tab, dd::Table *new_dd_tab) override
Allows InnoDB to update internal structures with concurrent writes blocked (provided that check_if_su...
Definition: handler0alter.cc:1431
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:215
constexpr uint32_t FSP_FREE_ADD
This many free extents are added to the free list from above FSP_FREE_LIMIT at a time.
Definition: fsp0fsp.h:175
bool innobase_match_index_columns(const KEY *key_info, const dict_index_t *index_info)
Match index columns between MySQL and InnoDB.
Definition: ha_innodb.cc:6944
void innodb_base_col_setup_for_stored(const dict_table_t *table, const Field *field, dict_s_col_t *s_col)
Set up base columns for stored column.
Definition: ha_innodb.cc:11628
const struct _ft_vft ft_vft_result
Definition: ha_innodb.cc:610
static bool normalize_table_name(char *norm_name, const char *name)
Definition: ha_innodb.h:1311
static bool tablespace_is_shared_space(const HA_CREATE_INFO *create_info)
Check if table will be explicitly put in an existing shared general or system tablespace.
Definition: ha_innodb.h:795
rec_per_key_t innodb_rec_per_key(const dict_index_t *index, ulint i, ha_rows records)
Calculate Record Per Key value.
Definition: ha_innodb.cc:17334
static bool is_shared_tablespace(const char *tablespace_name)
Check if tablespace is shared tablespace.
Definition: ha_innodb.h:820
void innobase_discard_table(THD *thd, dict_table_t *table)
Drop the statistics for a specified table, and mark it as discard after DDL.
Definition: handler0alter.cc:704
int convert_error_code_to_mysql(dberr_t error, uint32_t flags, THD *thd)
Converts an InnoDB error code to a MySQL error code.
Definition: ha_innodb.cc:2110
const char innobase_index_reserve_name[]
"GEN_CLUST_INDEX" is the name reserved for InnoDB default system clustered index when there is no pri...
Definition: dict0mem.h:1029
void innobase_build_v_templ_callback(const TABLE *table, void *ib_table)
Callback used by MySQL server layer to initialize the table virtual columns' template.
Definition: ha_innodb.cc:7091
bool trx_is_registered_for_2pc(const trx_t *trx)
Note that a transaction has been registered with MySQL.
Definition: ha_innodb.h:1318
static int validate_autoextend_size_value(uint64_t ext_size)
Validate AUTOEXTEND_SIZE attribute for a tablespace.
Definition: ha_innodb.h:833
void innobase_parse_hint_from_comment(THD *thd, dict_table_t *table, const TABLE_SHARE *table_share)
Parse hint for table and its indexes, and update the information in dictionary.
Definition: ha_innodb.cc:13763
static bool tablespace_is_file_per_table(const HA_CREATE_INFO *create_info)
Check if the explicit tablespace targeted is file_per_table.
Definition: ha_innodb.h:784
void innodb_base_col_setup(dict_table_t *table, const Field *field, dict_v_col_t *v_col)
Set up base columns for virtual column.
Definition: ha_innodb.cc:11597
fts_doc_id_index_enum
Some defines for innobase_fts_check_doc_id_index() return value.
Definition: ha_innodb.h:1248
@ FTS_EXIST_DOC_ID_INDEX
Definition: ha_innodb.h:1250
@ FTS_INCORRECT_DOC_ID_INDEX
Definition: ha_innodb.h:1249
@ FTS_NOT_EXIST_DOC_ID_INDEX
Definition: ha_innodb.h:1251
trx_t * innobase_trx_allocate(THD *thd)
Allocates an InnoDB transaction for a MySQL handler object.
Definition: ha_innodb.cc:2785
void innobase_build_v_templ(const TABLE *table, const dict_table_t *ib_table, dict_vcol_templ_t *s_templ, const dict_add_v_col_t *add_v, bool locked, const char *share_tbl_name)
Build template for the virtual columns and their base columns.
Definition: ha_innodb.cc:7107
const mysql_service_clone_protocol_t * clone_protocol_svc
Clone protocol service.
Definition: ha_innodb.cc:275
static bool tablespace_is_general_space(const HA_CREATE_INFO *create_info)
Check if table will be explicitly put in a general tablespace.
Definition: ha_innodb.h:806
fts_doc_id_index_enum innobase_fts_check_doc_id_index(const dict_table_t *table, const TABLE *altered_table, ulint *fts_doc_col_no)
Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME on the Doc ID column.
Definition: handler0alter.cc:2844
void innobase_register_trx(handlerton *hton, THD *thd, trx_t *trx)
Allocates an InnoDB transaction for a MySQL handler object for DML.
Definition: ha_innodb.cc:3035
static bool innobase_is_s_fld(const Field *field)
whether this is a stored column
Definition: ha_innodb.h:1298
static bool innobase_is_multi_value_fld(const Field *field)
Whether this is a computed multi-value virtual column.
Definition: ha_innodb.h:1307
void innobase_copy_frm_flags_from_table_share(dict_table_t *innodb_table, const TABLE_SHARE *table_share)
Copy table flags from MySQL's TABLE_SHARE into an InnoDB table object.
Definition: ha_innodb.cc:2934
bool innobase_fts_load_stopword(dict_table_t *table, trx_t *trx, THD *thd)
Initialize the table FTS stopword list.
Definition: ha_innodb.cc:13205
void(* my_gcolumn_templatecallback_t)(const TABLE *, void *)
Callback function definition, used by MySQL server layer to initialized the table virtual columns' te...
Definition: ha_innodb.h:1371
trx_t *& thd_to_trx(THD *thd)
Obtain the InnoDB transaction of a MySQL thread.
Definition: ha_innodb.cc:2043
page_cur_mode_t convert_search_mode_to_innobase(enum ha_rkey_function find_flag)
Converts a search mode flag understood by MySQL to a flag understood by InnoDB.
Definition: ha_innodb.cc:10402
fts_doc_id_index_enum innobase_fts_check_doc_id_index_in_def(ulint n_key, const KEY *key_info)
Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME on the Doc ID column in MySQL c...
Definition: handler0alter.cc:2930
struct new_ft_info NEW_FT_INFO
Structure Returned by ha_innobase::ft_init_ext()
trx_t::isolation_level_t innobase_trx_map_isolation_level(enum_tx_isolation iso)
Maps a MySQL trx isolation level code to the InnoDB isolation level code.
Definition: ha_innodb.cc:18896
bool innobase_index_name_is_reserved(THD *thd, const KEY *key_info, ulint num_of_keys)
This function checks each index name for a table against reserved system default primary index name '...
Definition: ha_innodb.cc:21812
constexpr uint32_t SIZE_MB
Definition: ha_innodb.h:828
bool innobase_stats_on_metadata
Definition: ha_innodb.cc:343
ulong thd_parallel_read_threads(THD *thd)
Return the number of read threads for this session.
Definition: ha_innodb.cc:2050
static int flags[50]
Definition: hp_test1.cc:39
static int flag
Definition: hp_test1.cc:39
static uint keys
Definition: hp_test2.cc:48
float rec_per_key_t
Data type for records per key estimates that are stored in the KEY::rec_per_key_float[] array.
Definition: key.h:95
ha_key_alg
Definition: my_base.h:96
@ HA_KEY_ALG_RTREE
Definition: my_base.h:107
@ HA_KEY_ALG_BTREE
Definition: my_base.h:106
@ HA_KEY_ALG_FULLTEXT
Definition: my_base.h:109
ha_rkey_function
Definition: my_base.h:77
my_off_t ha_rows
Definition: my_base.h:1139
ha_extra_function
Definition: my_base.h:183
unsigned long long int ulonglong
Definition: my_inttypes.h:55
unsigned char uchar
Definition: my_inttypes.h:51
long long int longlong
Definition: my_inttypes.h:54
#define MYF(v)
Definition: my_inttypes.h:96
enum_sql_command
Definition: my_sqlcommand.h:45
Log error(cerr, "ERROR")
static bool ignore
Definition: mysqlimport.cc:69
static int record
Definition: mysqltest.cc:194
static PFS_engine_table_share_proxy table
Definition: pfs.cc:60
Definition: buf0block_hint.cc:29
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
bool is_partition(const std::string &dict_name)
Check if it is a table partition.
Definition: dict0dd.cc:7290
Definition: aligned_atomic.h:43
const char * table_name
Definition: rules_table_service.cc:55
const char * db_name
Definition: rules_table_service.cc:54
mode
Definition: file_handle.h:59
page_cur_mode_t
Definition: page0types.h:175
required string key
Definition: replication_asynchronous_connection_failover.proto:59
Parallel read adapter interface.
Parallel read histogram interface.
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:75
enum_alter_inplace_result
Return values for check_if_supported_inplace_alter().
Definition: handler.h:198
enum_tx_isolation
Definition: handler.h:3116
row_type
Definition: handler.h:682
enum_sampling_method
Definition: handler.h:712
static bool commit(THD *thd)
Commit the current statement and transaction.
Definition: sql_cmd_srs.cc:151
case opt name
Definition: sslopt-case.h:32
TempTable public handler API declaration.
Callbacks for collecting time statistics.
Definition: bulk_data_service.h:323
Definition: ft_global.h:71
Definition: handler.h:3732
Definition: handler.h:3719
Struct to hold information about the table that should be created.
Definition: handler.h:3132
const char * tablespace
Definition: handler.h:3138
InnoDB table share.
Definition: ha_innodb.h:64
const char * table_name
InnoDB table name.
Definition: ha_innodb.h:65
innodb_idx_translate_t idx_trans_tbl
index translation table between MySQL and InnoDB
Definition: ha_innodb.h:72
void * table_name_hash
hash table chain node
Definition: ha_innodb.h:70
uint use_count
reference count, incremented in get_share() and decremented in free_share()
Definition: ha_innodb.h:66
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
Definition: handler.h:3740
This structure is shared between different table objects.
Definition: table.h:691
Definition: table.h:1396
Definition: thr_lock.h:123
Definition: ft_global.h:56
Definition: ft_global.h:47
Data structure for newly added virtual column in a table.
Definition: dict0mem.h:834
Data structure for an index.
Definition: dict0mem.h:1045
Data structure for a stored column in a table.
Definition: dict0mem.h:846
static const char * s_file_per_table_name
The hard-coded tablespace name innodb_file_per_table.
Definition: dict0dict.h:1150
static const char * s_sys_space_name
The name of the hard-coded system tablespace.
Definition: dict0dict.h:1141
static const char * s_temp_space_name
The name of the predefined temporary tablespace.
Definition: dict0dict.h:1144
Data structure for a database table.
Definition: dict0mem.h:1908
Data structure for a virtual column in a table.
Definition: dict0mem.h:814
Structure defines template related to virtual columns and their base columns.
Definition: dict0mem.h:1845
Query result.
Definition: fts0fts.h:313
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2692
Definition: ha_innodb.h:52
dict_index_t ** index_mapping
index pointer array directly maps to index in InnoDB from MySQL array index
Definition: ha_innodb.h:58
ulint array_size
array size of index_mapping
Definition: ha_innodb.h:56
ulint index_count
number of valid index entries in the index_mapping array
Definition: ha_innodb.h:53
Definition: my_base.h:1123
Structure Returned by ha_innobase::ft_init_ext()
Definition: ha_innodb.h:736
struct _ft_vft_ext * could_you
Definition: ha_innodb.h:738
row_prebuilt_t * ft_prebuilt
Definition: ha_innodb.h:739
fts_result_t * ft_result
Definition: ha_innodb.h:740
struct _ft_vft * please
Definition: ha_innodb.h:737
A struct for (sometimes lazily) prebuilt structures in an Innobase table handle used within MySQL; th...
Definition: row0mysql.h:514
Definition: trx0trx.h:683
bool is_registered
Definition: trx0trx.h:875
isolation_level_t
Definition: trx0trx.h:684
thr_lock_type
Definition: thr_lock.h:50
The transaction.
ulong srv_page_size
Definition: srv0srv.cc:396
unsigned long int ulint
Definition: univ.i:405
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:68