MySQL  8.0.18
Source Code Documentation
ha_innodb.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 2000, 2019, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 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 <sys/types.h>
33 #include "handler.h"
34 #include "my_dbug.h"
35 #include "row0pread-adapter.h"
36 #include "trx0trx.h"
37 
38 /** "GEN_CLUST_INDEX" is the name reserved for InnoDB default
39 system clustered index when there is no primary key. */
40 extern const char innobase_index_reserve_name[];
41 
42 /* Structure defines translation table between mysql index and InnoDB
43 index structures */
45  ulint index_count; /*!< number of valid index entries
46  in the index_mapping array */
47 
48  ulint array_size; /*!< array size of index_mapping */
49 
50  dict_index_t **index_mapping; /*!< index pointer array directly
51  maps to index in InnoDB from MySQL
52  array index */
53 };
54 
55 /** InnoDB table share */
57  const char *table_name; /*!< InnoDB table name */
58  uint use_count; /*!< reference count,
59  incremented in get_share()
60  and decremented in
61  free_share() */
63  /*!< hash table chain node */
64  innodb_idx_translate_t idx_trans_tbl; /*!< index translation table between
65  MySQL and InnoDB */
66 };
67 
68 /** Prebuilt structures in an InnoDB table handle used within MySQL */
69 struct row_prebuilt_t;
70 
71 namespace dd {
72 namespace cache {
73 class Dictionary_client;
74 }
75 } // namespace dd
76 
77 /** The class defining a handle to an InnoDB table */
78 class ha_innobase : public handler {
79  public:
80  ha_innobase(handlerton *hton, TABLE_SHARE *table_arg);
81  ~ha_innobase() override;
82 
83  row_type get_real_row_type(const HA_CREATE_INFO *create_info) const override;
84 
85  const char *table_type() const override;
86 
87  enum ha_key_alg get_default_index_algorithm() const override {
88  return HA_KEY_ALG_BTREE;
89  }
90 
91  /** Check if SE supports specific key algorithm. */
92  bool is_index_algorithm_supported(enum ha_key_alg key_alg) const override {
93  /* This method is never used for FULLTEXT or SPATIAL keys.
94  We rely on handler::ha_table_flags() to check if such keys
95  are supported. */
96  DBUG_ASSERT(key_alg != HA_KEY_ALG_FULLTEXT && key_alg != HA_KEY_ALG_RTREE);
97  return key_alg == HA_KEY_ALG_BTREE;
98  }
99 
100  Table_flags table_flags() const override;
101 
102  ulong index_flags(uint idx, uint part, bool all_parts) const override;
103 
104  uint max_supported_keys() const override;
105 
106  uint max_supported_key_length() const override;
107 
109  HA_CREATE_INFO *create_info) const override;
110 
111  int open(const char *name, int, uint open_flags,
112  const dd::Table *table_def) override;
113 
114  /** Opens dictionary table object using table name. For partition, we need to
115  try alternative lower/upper case names to support moving data files across
116  platforms.
117  @param[in] table_name name of the table/partition
118  @param[in] norm_name normalized name of the table/partition
119  @param[in] is_partition if this is a partition of a table
120  @param[in] ignore_err error to ignore for loading dictionary object
121  @return dictionary table object or NULL if not found */
122  static dict_table_t *open_dict_table(const char *table_name,
123  const char *norm_name, bool is_partition,
124  dict_err_ignore_t ignore_err);
125 
126  handler *clone(const char *name, MEM_ROOT *mem_root) override;
127 
128  int close(void) override;
129 
130  double scan_time() override;
131 
132  double read_time(uint index, uint ranges, ha_rows rows) override;
133 
134  longlong get_memory_buffer_size() const override;
135 
136  int write_row(uchar *buf) override;
137 
138  int update_row(const uchar *old_data, uchar *new_data) override;
139 
140  int delete_row(const uchar *buf) override;
141 
142  /** Delete all rows from the table.
143  @retval HA_ERR_WRONG_COMMAND if the table is transactional
144  @retval 0 on success */
145  int delete_all_rows() override;
146 
147  bool was_semi_consistent_read() override;
148 
149  void try_semi_consistent_read(bool yes) override;
150 
151  void unlock_row() override;
152 
153  int index_init(uint index, bool sorted) override;
154 
155  int index_end() override;
156 
157  int index_read(uchar *buf, const uchar *key, uint key_len,
158  ha_rkey_function find_flag) override;
159 
160  int index_read_last(uchar *buf, const uchar *key, uint key_len) override;
161 
162  int index_next(uchar *buf) override;
163 
164  int index_next_same(uchar *buf, const uchar *key, uint keylen) override;
165 
166  int index_prev(uchar *buf) override;
167 
168  int index_first(uchar *buf) override;
169 
170  int index_last(uchar *buf) override;
171 
172  int read_range_first(const key_range *start_key, const key_range *end_key,
173  bool eq_range_arg, bool sorted) override;
174 
175  int read_range_next() override;
176 
177  int rnd_init(bool scan) override;
178 
179  int rnd_end() override;
180 
181  int rnd_next(uchar *buf) override;
182 
183  int rnd_pos(uchar *buf, uchar *pos) override;
184 
185  int ft_init() override;
186 
187  void ft_end();
188 
189  FT_INFO *ft_init_ext(uint flags, uint inx, String *key) override;
190 
192  Ft_hints *hints) override;
193 
194  int ft_read(uchar *buf) override;
195 
196  void position(const uchar *record) override;
197 
198  int info(uint) override;
199 
200  int enable_indexes(uint mode) override;
201 
202  int disable_indexes(uint mode) override;
203 
204  int analyze(THD *thd, HA_CHECK_OPT *check_opt) override;
205 
206  int optimize(THD *thd, HA_CHECK_OPT *check_opt) override;
207 
208  int discard_or_import_tablespace(bool discard, dd::Table *table_def) override;
209 
210  int extra(ha_extra_function operation) override;
211 
212  int reset() override;
213 
214  int external_lock(THD *thd, int lock_type) override;
215 
216  /** MySQL calls this function at the start of each SQL statement
217  inside LOCK TABLES. Inside LOCK TABLES the "::external_lock" method
218  does not work to mark SQL statement borders. Note also a special case:
219  if a temporary table is created inside LOCK TABLES, MySQL has not
220  called external_lock() at all on that table.
221  MySQL-5.0 also calls this before each statement in an execution of a
222  stored procedure. To make the execution more deterministic for
223  binlogging, MySQL-5.0 locks all tables involved in a stored procedure
224  with full explicit table locks (thd_in_lock_tables(thd) holds in
225  store_lock()) before executing the procedure.
226  @param[in] thd handle to the user thread
227  @param[in] lock_type lock type
228  @return 0 or error code */
229  int start_stmt(THD *thd, thr_lock_type lock_type) override;
230 
231  void position(uchar *record);
232 
233  int records(ha_rows *num_rows) override;
234 
235  int records_from_index(ha_rows *num_rows, uint) override {
236  /* Force use of cluster index until we implement sec index parallel scan. */
237  return ha_innobase::records(num_rows);
238  }
239 
240  ha_rows records_in_range(uint inx, key_range *min_key,
241  key_range *max_key) override;
242 
244 
245  void update_create_info(HA_CREATE_INFO *create_info) override;
246 
247  /** Get storage-engine private data for a data dictionary table.
248  @param[in,out] dd_table data dictionary table definition
249  @param reset reset counters
250  @retval true an error occurred
251  @retval false success */
252  bool get_se_private_data(dd::Table *dd_table, bool reset) override;
253 
254  /** Add hidden columns and indexes to an InnoDB table definition.
255  @param[in,out] dd_table data dictionary cache object
256  @return error number
257  @retval 0 on success */
259  const List<Create_field> *, const KEY *, uint,
260  dd::Table *dd_table) override;
261 
262  /** Set Engine specific data to dd::Table object for upgrade.
263  @param[in,out] thd thread handle
264  @param[in] db_name database name
265  @param[in] table_name table name
266  @param[in,out] dd_table data dictionary cache object
267  @return 0 on success, non-zero on failure */
268  bool upgrade_table(THD *thd, const char *db_name, const char *table_name,
269  dd::Table *dd_table) override;
270 
271  /** Create an InnoDB table.
272  @param[in] name table name in filename-safe encoding
273  @param[in] form table structure
274  @param[in] create_info more information
275  @param[in,out] table_def dd::Table describing table to be
276  created. Can be adjusted by SE, the changes will be saved into data-dictionary
277  at statement commit time.
278  @return error number
279  @retval 0 on success */
280  int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info,
281  dd::Table *table_def) override;
282 
283  /** Drop a table.
284  @param[in] name table name
285  @param[in] table_def dd::Table describing table to
286  be dropped
287  @return error number
288  @retval 0 on success */
289  int delete_table(const char *name, const dd::Table *table_def) override;
290 
291  protected:
292  /** Drop a table.
293  @param[in] name table name
294  @param[in] table_def dd::Table describing table to
295  be dropped
296  @param[in] sqlcom type of operation that the DROP is part of
297  @return error number
298  @retval 0 on success */
299  int delete_table(const char *name, const dd::Table *table_def,
300  enum enum_sql_command sqlcom);
301 
302  public:
303  int rename_table(const char *from, const char *to,
304  const dd::Table *from_table, dd::Table *to_table) override;
305 
306  int check(THD *thd, HA_CHECK_OPT *check_opt) override;
307 
308  char *get_foreign_key_create_info() override;
309 
310  int get_foreign_key_list(THD *thd,
311  List<FOREIGN_KEY_INFO> *f_key_list) override;
312 
314  List<FOREIGN_KEY_INFO> *f_key_list) override;
315 
317  THD *thd, List<st_handler_tablename> *fk_table_list) override;
318 
319  uint referenced_by_foreign_key() override;
320 
321  void free_foreign_key_create_info(char *str) override;
322 
323  uint lock_count(void) const override;
324 
326  thr_lock_type lock_type) override;
327 
328  void init_table_handle_for_HANDLER() override;
329 
330  virtual void get_auto_increment(ulonglong offset, ulonglong increment,
331  ulonglong nb_desired_values,
332  ulonglong *first_value,
333  ulonglong *nb_reserved_values) override;
334 
335  virtual bool get_error_message(int error, String *buf) override;
336 
337  virtual bool get_foreign_dup_key(char *, uint, char *, uint) override;
338 
339  bool primary_key_is_clustered() const override;
340 
341  int cmp_ref(const uchar *ref1, const uchar *ref2) const override;
342 
343  /** On-line ALTER TABLE interface @see handler0alter.cc @{ */
344 
345  /** Check if InnoDB supports a particular alter table in-place
346  @param altered_table TABLE object for new version of table.
347  @param ha_alter_info Structure describing changes to be done
348  by ALTER TABLE and holding data used during in-place alter.
349 
350  @retval HA_ALTER_INPLACE_NOT_SUPPORTED Not supported
351  @retval HA_ALTER_INPLACE_NO_LOCK Supported
352  @retval HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE
353  Supported, but requires lock during main phase and
354  exclusive lock during prepare phase.
355  @retval HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE
356  Supported, prepare phase requires exclusive lock. */
358  TABLE *altered_table, Alter_inplace_info *ha_alter_info) override;
359 
360  /** Allows InnoDB to update internal structures with concurrent
361  writes blocked (provided that check_if_supported_inplace_alter()
362  did not return HA_ALTER_INPLACE_NO_LOCK).
363  This will be invoked before inplace_alter_table().
364 
365  @param[in] altered_table TABLE object for new version of table.
366  @param[in,out] ha_alter_info Structure describing changes to be done
367  by ALTER TABLE and holding data used during in-place alter.
368  @param[in] old_dd_tab dd::Table object describing old version
369  of the table.
370  @param[in,out] new_dd_tab dd::Table object for the new version of
371  the table. Can be adjusted by this call. Changes to the table definition will
372  be persisted in the data-dictionary at statement commit time.
373 
374  @retval true Failure
375  @retval false Success
376  */
377  bool prepare_inplace_alter_table(TABLE *altered_table,
378  Alter_inplace_info *ha_alter_info,
379  const dd::Table *old_dd_tab,
380  dd::Table *new_dd_tab) override;
381 
382  /** Alter the table structure in-place with operations
383  specified using HA_ALTER_FLAGS and Alter_inplace_information.
384  The level of concurrency allowed during this operation depends
385  on the return value from check_if_supported_inplace_alter().
386 
387  @param[in] altered_table TABLE object for new version of table.
388  @param[in,out] ha_alter_info Structure describing changes to be done
389  by ALTER TABLE and holding data used during in-place alter.
390  @param[in] old_dd_tab dd::Table object describing old version
391  of the table.
392  @param[in,out] new_dd_tab dd::Table object for the new version of
393  the table. Can be adjusted by this call. Changes to the table definition will
394  be persisted in the data-dictionary at statement commit time.
395 
396  @retval true Failure
397  @retval false Success
398  */
399  bool inplace_alter_table(TABLE *altered_table,
400  Alter_inplace_info *ha_alter_info,
401  const dd::Table *old_dd_tab,
402  dd::Table *new_dd_tab) override;
403 
404  /** Commit or rollback the changes made during
405  prepare_inplace_alter_table() and inplace_alter_table() inside
406  the storage engine. Note that the allowed level of concurrency
407  during this operation will be the same as for
408  inplace_alter_table() and thus might be higher than during
409  prepare_inplace_alter_table(). (E.g concurrent writes were
410  blocked during prepare, but might not be during commit).
411 
412  @param[in] altered_table TABLE object for new version of table.
413  @param[in,out] ha_alter_info Structure describing changes to be done
414  by ALTER TABLE and holding data used during in-place alter.
415  @param commit true => Commit, false => Rollback.
416  @param old_dd_tab dd::Table object describing old version
417  of the table.
418  @param new_dd_tab dd::Table object for the new version of the
419  table. Can be adjusted by this call. Changes to the table
420  definition will be persisted in the data-dictionary at statement
421  commit time.
422  @retval true Failure
423  @retval false Success
424  */
425  bool commit_inplace_alter_table(TABLE *altered_table,
426  Alter_inplace_info *ha_alter_info,
427  bool commit, const dd::Table *old_dd_tab,
428  dd::Table *new_dd_tab) override;
429  /** @} */
430 
432 
433  /** Initializes a parallel scan. It creates a scan_ctx that has to
434  be used across all parallel_scan methods. Also, gets the number of threads
435  that would be spawned for parallel scan.
436  @param[out] scan_ctx A scan context created by this method
437  that has to be used in
438  parallel_scan
439  @param[out] num_threads Number of threads to be spawned
440  @return error code
441  @retval 0 on success */
442  int parallel_scan_init(void *&scan_ctx, size_t &num_threads) override;
443 
444  /** Start parallel read of InnoDB records.
445  @param[in] scan_ctx A scan context created by parallel_scan_init
446  @param[in] thread_ctxs Context for each of the spawned threads
447  @param[in] init_fn Callback called by each parallel load
448  thread at the beginning of the parallel load.
449  @param[in] load_fn Callback called by each parallel load
450  thread when processing of rows is required.
451  @param[in] end_fn Callback called by each parallel load
452  thread when processing of rows has ended.
453  @return error code
454  @retval 0 on success */
455  int parallel_scan(void *scan_ctx, void **thread_ctxs, Reader::Init_fn init_fn,
456  Reader::Load_fn load_fn, Reader::End_fn end_fn) override;
457 
458  /** End of the parallel scan.
459  @param[in] scan_ctx A scan context created by parallel_scan_init.
460  @return error code
461  @retval 0 on success */
462  int parallel_scan_end(void *scan_ctx) override;
463 
465  uint table_changes) override;
466 
467  private:
468  /** @name Multi Range Read interface @{ */
469 
470  /** Initialize multi range read @see DsMrr_impl::dsmrr_init
471  @param seq
472  @param seq_init_param
473  @param n_ranges
474  @param mode
475  @param buf */
476  int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
477  uint n_ranges, uint mode,
478  HANDLER_BUFFER *buf) override;
479 
480  /** Process next multi range read @see DsMrr_impl::dsmrr_next
481  @param range_info */
482  int multi_range_read_next(char **range_info) override;
483 
484  /** Initialize multi range read and get information.
485  @see ha_myisam::multi_range_read_info_const
486  @see DsMrr_impl::dsmrr_info_const
487  @param keyno
488  @param seq
489  @param seq_init_param
490  @param n_ranges
491  @param bufsz
492  @param flags
493  @param cost */
495  void *seq_init_param, uint n_ranges,
496  uint *bufsz, uint *flags,
497  Cost_estimate *cost) override;
498 
499  /** Initialize multi range read and get information.
500  @see DsMrr_impl::dsmrr_info
501  @param keyno
502  @param n_ranges
503  @param keys
504  @param bufsz
505  @param flags
506  @param cost */
507  ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
508  uint *bufsz, uint *flags,
509  Cost_estimate *cost) override;
510 
511  /** Attempt to push down an index condition.
512  @param[in] keyno MySQL key number
513  @param[in] idx_cond Index condition to be checked
514  @return idx_cond if pushed; NULL if not pushed */
515  Item *idx_cond_push(uint keyno, Item *idx_cond) override;
516  /* @} */
517 
518  private:
519  void update_thd();
520 
521  int change_active_index(uint keynr);
522 
524 
526 
528 
530 
531  /** Resets a query execution 'template'.
532  @see build_template() */
533  void reset_template();
534 
535  /** Write Row Interface optimized for Intrinsic table. */
537 
538  /** Find out if a Record_buffer is wanted by this handler, and what is
539  the maximum buffer size the handler wants.
540 
541  @param[out] max_rows gets set to the maximum number of records to
542  allocate space for in the buffer
543  @retval true if the handler wants a buffer
544  @retval false if the handler does not want a buffer */
545  bool is_record_buffer_wanted(ha_rows *const max_rows) const override;
546 
547  /** TRUNCATE an InnoDB table.
548  @param[in] name table name
549  @param[in] form table definition
550  @param[in,out] table_def dd::Table describing table to be
551  truncated. Can be adjusted by SE, the changes will be saved into
552  the data-dictionary at statement commit time.
553  @return error number
554  @retval 0 on success */
555  int truncate_impl(const char *name, TABLE *form, dd::Table *table_def);
556 
557  protected:
558  /** Enter InnoDB engine after checking max allowed threads */
559  void srv_concurrency_enter();
560 
561  /** Leave Innodb, if no more tickets are left */
562  void srv_concurrency_exit();
563 
564  void update_thd(THD *thd);
565 
566  int general_fetch(uchar *buf, uint direction, uint match_mode);
567 
568  virtual dict_index_t *innobase_get_index(uint keynr);
569 
570  /** Builds a 'template' to the prebuilt struct.
571 
572  The template is used in fast retrieval of just those column
573  values MySQL needs in its processing.
574  @param whole_row true if access is needed to a whole row,
575  false if accessing individual fields is enough */
576  void build_template(bool whole_row);
577 
578  /** Returns statistics information of the table to the MySQL
579  interpreter, in various fields of the handle object.
580  @param[in] flag what information is requested
581  @param[in] is_analyze True if called from "::analyze()"
582  @return HA_ERR_* error code or 0 */
583  virtual int info_low(uint flag, bool is_analyze);
584 
585  /**
586  MySQL calls this method at the end of each statement. This method
587  exists for readability only, called from reset(). The name reset()
588  doesn't give any clue that it is called at the end of a statement. */
589  int end_stmt();
590 
591  /** Implementation of prepare_inplace_alter_table()
592  @tparam Table dd::Table or dd::Partition
593  @param[in] altered_table TABLE object for new version of table.
594  @param[in,out] ha_alter_info Structure describing changes to be done
595  by ALTER TABLE and holding data used
596  during in-place alter.
597  @param[in] old_dd_tab dd::Table object representing old
598  version of the table
599  @param[in,out] new_dd_tab dd::Table object representing new
600  version of the table
601  @retval true Failure
602  @retval false Success */
603  template <typename Table>
604  bool prepare_inplace_alter_table_impl(TABLE *altered_table,
605  Alter_inplace_info *ha_alter_info,
606  const Table *old_dd_tab,
607  Table *new_dd_tab);
608 
609  /** Implementation of inplace_alter_table()
610  @tparam Table dd::Table or dd::Partition
611  @param[in] altered_table TABLE object for new version of table.
612  @param[in,out] ha_alter_info Structure describing changes to be done
613  by ALTER TABLE and holding data used
614  during in-place alter.
615  @param[in] old_dd_tab dd::Table object representing old
616  version of the table
617  @param[in,out] new_dd_tab dd::Table object representing new
618  version of the table
619  @retval true Failure
620  @retval false Success */
621  template <typename Table>
622  bool inplace_alter_table_impl(TABLE *altered_table,
623  Alter_inplace_info *ha_alter_info,
624  const Table *old_dd_tab, Table *new_dd_tab);
625 
626  /** Implementation of commit_inplace_alter_table()
627  @tparam Table dd::Table or dd::Partition
628  @param[in] altered_table TABLE object for new version of table.
629  @param[in,out] ha_alter_info Structure describing changes to be done
630  by ALTER TABLE and holding data used
631  during in-place alter.
632  @param[in] commit True to commit or false to rollback.
633  @param[in] old_dd_tab Table object describing old version
634  of the table.
635  @param[in,out] new_dd_tab Table object for the new version of the
636  table. Can be adjusted by this call.
637  Changes to the table definition
638  will be persisted in the data-dictionary
639  at statement version of it.
640  @retval true Failure
641  @retval false Success */
642  template <typename Table>
643  bool commit_inplace_alter_table_impl(TABLE *altered_table,
644  Alter_inplace_info *ha_alter_info,
645  bool commit, const Table *old_dd_tab,
646  Table *new_dd_tab);
647 
648  /**
649  Return max limits for a single set of multi-valued keys
650 
651  @param[out] num_keys number of keys to store
652  @param[out] keys_length total length of keys, bytes
653  */
654  void mv_key_capacity(uint *num_keys, size_t *keys_length) const override;
655 
656  /** The multi range read session object */
658 
659  /** Save CPU time with prebuilt/cached data structures */
661 
662  /** Thread handle of the user currently using the handler;
663  this is set in external_lock function */
665 
666  /** information for MySQL table locking */
668 
669  /** buffer used in updates */
671 
672  /** the size of upd_buf in bytes */
674 
675  /** Flags that specificy the handler instance (table) capability. */
677 
678  /** this is set to 1 when we are starting a table scan but have
679  not yet fetched any row, else false */
681 
682  /*!< match mode of the latest search: ROW_SEL_EXACT,
683  ROW_SEL_EXACT_PREFIX, or undefined */
685 
686  /** this field is used to remember the original select_lock_type that
687  was decided in ha_innodb.cc,":: store_lock()", "::external_lock()",
688  etc. */
690 
691  /** If mysql has locked with external_lock() */
693 };
694 
695 struct trx_t;
696 
697 extern const struct _ft_vft ft_vft_result;
698 
699 /** Return the number of read threads for this session.
700 @param[in] thd Session instance, or nullptr to query the global
701  innodb_parallel_read_threads value. */
703 
704 /** Structure Returned by ha_innobase::ft_init_ext() */
705 typedef struct new_ft_info {
706  struct _ft_vft *please;
710 } NEW_FT_INFO;
711 
712 /** Allocates an InnoDB transaction for a MySQL handler object for DML.
713 @param[in] hton Innobase handlerton.
714 @param[in] thd MySQL thd (connection) object.
715 @param[in] trx transaction to register. */
716 void innobase_register_trx(handlerton *hton, THD *thd, trx_t *trx);
717 
718 /**
719 Allocates an InnoDB transaction for a MySQL handler object.
720 @return InnoDB transaction handle */
721 trx_t *innobase_trx_allocate(THD *thd); /*!< in: user thread handle */
722 
723 /** Match index columns between MySQL and InnoDB.
724 This function checks whether the index column information
725 is consistent between KEY info from mysql and that from innodb index.
726 @param[in] key_info Index info from mysql
727 @param[in] index_info Index info from InnoDB
728 @return true if all column types match. */
729 bool innobase_match_index_columns(const KEY *key_info,
730  const dict_index_t *index_info);
731 
732 /** This function checks each index name for a table against reserved
733  system default primary index name 'GEN_CLUST_INDEX'. If a name
734  matches, this function pushes an warning message to the client,
735  and returns true.
736  @return true if the index name matches the reserved name */
738  THD *thd, /*!< in/out: MySQL connection */
739  const KEY *key_info, /*!< in: Indexes to be
740  created */
741  ulint num_of_keys) /*!< in: Number of indexes to
742  be created. */
743  MY_ATTRIBUTE((warn_unused_result));
744 
745 /** Check if the explicit tablespace targeted is file_per_table.
746 @param[in] create_info Metadata for the table to create.
747 @return true if the table is intended to use a file_per_table tablespace. */
748 UNIV_INLINE
750  return (create_info->tablespace != NULL &&
751  (0 ==
752  strcmp(create_info->tablespace, dict_sys_t::s_file_per_table_name)));
753 }
754 
755 /** Check if table will be explicitly put in an existing shared general
756 or system tablespace.
757 @param[in] create_info Metadata for the table to create.
758 @return true if the table will use a shared general or system tablespace. */
759 UNIV_INLINE
760 bool tablespace_is_shared_space(const HA_CREATE_INFO *create_info) {
761  return (create_info->tablespace != NULL &&
762  create_info->tablespace[0] != '\0' &&
763  (0 !=
764  strcmp(create_info->tablespace, dict_sys_t::s_file_per_table_name)));
765 }
766 
767 /** Check if table will be explicitly put in a general tablespace.
768 @param[in] create_info Metadata for the table to create.
769 @return true if the table will use a general tablespace. */
770 UNIV_INLINE
771 bool tablespace_is_general_space(const HA_CREATE_INFO *create_info) {
772  return (
773  create_info->tablespace != NULL && create_info->tablespace[0] != '\0' &&
774  (0 !=
775  strcmp(create_info->tablespace, dict_sys_t::s_file_per_table_name)) &&
776  (0 != strcmp(create_info->tablespace, dict_sys_t::s_temp_space_name)) &&
777  (0 != strcmp(create_info->tablespace, dict_sys_t::s_sys_space_name)));
778 }
779 
780 /** Check if tablespace is shared tablespace.
781 @param[in] tablespace_name Name of the tablespace
782 @return true if tablespace is a shared tablespace. */
783 UNIV_INLINE
784 bool is_shared_tablespace(const char *tablespace_name) {
785  if (tablespace_name != NULL && tablespace_name[0] != '\0' &&
786  (strcmp(tablespace_name, dict_sys_t::s_file_per_table_name) != 0)) {
787  return true;
788  }
789  return false;
790 }
791 
792 /** Parse hint for table and its indexes, and update the information
793 in dictionary.
794 @param[in] thd Connection thread
795 @param[in,out] table Target table
796 @param[in] table_share Table definition */
798  const TABLE_SHARE *table_share);
799 
800 /** Obtain the InnoDB transaction of a MySQL thread.
801 @param[in,out] thd MySQL thread handler.
802 @return reference to transaction pointer */
803 trx_t *&thd_to_trx(THD *thd);
804 
805 /** Class for handling create table information. */
807  public:
808  /** Constructor.
809  Used in two ways:
810  - all but file_per_table is used, when creating the table.
811  - all but name/path is used, when validating options and using flags. */
813  char *table_name, char *remote_path, char *tablespace,
814  bool file_per_table, bool skip_strict, uint32_t old_flags,
815  uint32_t old_flags2)
816  : m_thd(thd),
817  m_trx(thd_to_trx(thd)),
818  m_form(form),
819  m_create_info(create_info),
821  m_remote_path(remote_path),
822  m_tablespace(tablespace),
823  m_innodb_file_per_table(file_per_table),
824  m_flags(old_flags),
825  m_flags2(old_flags2),
827 
828  /** Initialize the object. */
829  int initialize();
830 
831  /** Set m_tablespace_type. */
832  void set_tablespace_type(bool table_being_altered_is_file_per_table);
833 
834  /** Create the internal innodb table.
835  @param[in] dd_table dd::Table or nullptr for intrinsic table
836  @return 0 or error number */
837  int create_table(const dd::Table *dd_table);
838 
839  /** Update the internal data dictionary. */
841 
842  /** Update the global data dictionary.
843  @param[in] dd_table table object
844  @return 0 On success
845  @retval error number On failure*/
846  template <typename Table>
847  int create_table_update_global_dd(Table *dd_table);
848 
849  /** Validates the create options. Checks that the options
850  KEY_BLOCK_SIZE, ROW_FORMAT, DATA DIRECTORY, TEMPORARY & TABLESPACE
851  are compatible with each other and other settings.
852  These CREATE OPTIONS are not validated here unless innodb_strict_mode
853  is on. With strict mode, this function will report each problem it
854  finds using a custom message with error code
855  ER_ILLEGAL_HA_CREATE_OPTION, not its built-in message.
856  @return NULL if valid, string name of bad option if not. */
857  const char *create_options_are_invalid();
858 
859  /** Validate DATA DIRECTORY option. */
861  /** Validate TABLESPACE option. */
863 
864  /** Validate COMPRESSION option. */
866 
867  /** Prepare to create a table. */
868  int prepare_create_table(const char *name);
869 
870  /** Determines InnoDB table flags.
871  If strict_mode=OFF, this will adjust the flags to what should be assumed.
872  @retval true if successful, false if error */
873  bool innobase_table_flags();
874 
875  /** Set flags and append '/' to remote path if necessary. */
876  void set_remote_path_flags();
877 
878  /** Get table flags. */
879  uint32_t flags() const { return (m_flags); }
880 
881  /** Get table flags2. */
882  uint32_t flags2() const { return (m_flags2); }
883 
884  /** Reset table flags. */
885  void flags_reset() { m_flags = 0; }
886 
887  /** Reset table flags2. */
888  void flags2_reset() { m_flags2 = 0; }
889 
890  /** whether to skip strict check. */
891  bool skip_strict() const { return (m_skip_strict); }
892 
893  /** Return table name. */
894  const char *table_name() const { return (m_table_name); }
895 
896  THD *thd() const { return (m_thd); }
897 
898  inline bool is_intrinsic_temp_table() const {
899  /* DICT_TF2_INTRINSIC implies DICT_TF2_TEMPORARY */
901  return ((m_flags2 & DICT_TF2_INTRINSIC) != 0);
902  }
903 
904  /** @return true only if table is temporary and not intrinsic */
905  inline bool is_temp_table() const {
906  return (((m_flags2 & DICT_TF2_TEMPORARY) != 0) &&
907  ((m_flags2 & DICT_TF2_INTRINSIC) == 0));
908  }
909 
910  /** Detach the just created table and its auxiliary tables if exist. */
911  void detach();
912 
913  /** Normalizes a table name string.
914  A normalized name consists of the database name catenated to '/' and
915  table name. An example: test/mytable. On Windows normalization puts
916  both the database name and the table name always to lower case if
917  "set_lower_case" is set to true.
918  @param[in,out] norm_name Buffer to return the normalized name in.
919  @param[in] name Table name string.
920  @param[in] set_lower_case True if we want to set name to lower
921  case. */
922  static void normalize_table_name_low(char *norm_name, const char *name,
923  ibool set_lower_case);
924 
925  private:
926  /** Parses the table name into normal name and either temp path or
927  remote path if needed.*/
928  int parse_table_name(const char *name);
929 
930  /** Create the internal innodb table definition.
931  @param[in] dd_table dd::Table or nullptr for intrinsic table
932  @return ER_* level error */
933  int create_table_def(const dd::Table *dd_table);
934 
935  /** Initialize the autoinc of this table if necessary, which should
936  be called before we flush logs, so autoinc counter can be persisted. */
937  void initialize_autoinc();
938 
939  /** Connection thread handle. */
941 
942  /** InnoDB transaction handle. */
944 
945  /** Information on table columns and indexes. */
946  const TABLE *m_form;
947 
948  /** Create options. */
950 
951  /** Table name */
953  /** Remote path (DATA DIRECTORY) or zero length-string */
955  /** Tablespace name or zero length-string. */
957 
958  /** The newly created InnoDB table object. This is currently only
959  used in this class, since the new table is not evictable until
960  final success/failure, it can be accessed directly. */
962 
963  /** Local copy of srv_file_per_table. */
965 
966  /** Allow file_per_table for this table either because:
967  1) the setting innodb_file_per_table=on,
968  2) it was explicitly requested by tablespace=innodb_file_per_table.
969  3) the table being altered is currently file_per_table */
971 
972  /** After all considerations, this shows whether we will actually
973  create a table and tablespace using file-per-table. */
975 
976  /** Using DATA DIRECTORY */
978 
979  /** Using a Shared General Tablespace */
981 
982  /** Table flags */
983  uint32_t m_flags;
984 
985  /** Table flags2 */
986  uint32_t m_flags2;
987 
988  /** Skip strict check */
990 };
991 
992 /** Class of basic DDL implementation, for CREATE/DROP/RENAME TABLE */
994  public:
995  /** Create an InnoDB table.
996  @tparam Table dd::Table or dd::Partition
997  @param[in,out] thd THD object
998  @param[in] name Table name, format: "db/table_name"
999  @param[in] form Table format; columns and index
1000  information
1001  @param[in] create_info Create info(including create statement
1002  string)
1003  @param[in,out] dd_tab dd::Table describing table to be created
1004  @param[in] file_per_table whether to create a tablespace too
1005  @param[in] evictable whether the caller wants the
1006  dict_table_t to be kept in memory
1007  @param[in] skip_strict whether to skip strict check for create
1008  option
1009  @param[in] old_flags old Table flags
1010  @param[in] old_flags2 old Table flags2
1011  @return error number
1012  @retval 0 on success */
1013  template <typename Table>
1014  static int create_impl(THD *thd, const char *name, TABLE *form,
1015  HA_CREATE_INFO *create_info, Table *dd_tab,
1016  bool file_per_table, bool evictable, bool skip_strict,
1017  ulint old_flags, ulint old_flags2);
1018 
1019  /** Drop an InnoDB table.
1020  @tparam Table dd::Table or dd::Partition
1021  @param[in,out] thd THD object
1022  @param[in] name table name
1023  @param[in] dd_tab dd::Table describing table to be dropped
1024  @return error number
1025  @retval 0 on success */
1026  template <typename Table>
1027  static int delete_impl(THD *thd, const char *name, const Table *dd_tab);
1028 
1029  /** Renames an InnoDB table.
1030  @tparam Table dd::Table or dd::Partition
1031  @param[in,out] thd THD object
1032  @param[in] from old name of the table
1033  @param[in] to new name of the table
1034  @param[in] from_table dd::Table or dd::Partition of the table
1035  with old name
1036  @param[in] to_table dd::Table or dd::Partition of the table
1037  with new name
1038  @return error number
1039  @retval 0 on success */
1040  template <typename Table>
1041  static int rename_impl(THD *thd, const char *from, const char *to,
1042  const Table *from_table, const Table *to_table);
1043 };
1044 
1045 /** Class to handle TRUNCATE for one InnoDB table or one partition */
1046 template <typename Table>
1048  public:
1049  /** Constructor
1050  @param[in] thd THD object
1051  @param[in] name normalized table name
1052  @param[in] form Table format; columns and index information
1053  @param[in] dd_table dd::Table or dd::Partition
1054  @param[in] keep_autoinc true to remember original autoinc counter */
1055  innobase_truncate(THD *thd, const char *name, TABLE *form, Table *dd_table,
1056  bool keep_autoinc)
1057  : m_thd(thd),
1058  m_name(name),
1059  m_dd_table(dd_table),
1060  m_trx(nullptr),
1061  m_table(nullptr),
1062  m_form(form),
1063  m_create_info(),
1065  m_keep_autoinc(keep_autoinc),
1066  m_flags(0),
1067  m_flags2(0) {}
1068 
1069  /** Destructor */
1071 
1072  /** Open the table/partition to be truncated
1073  @param[out] innodb_table InnoDB table object opened
1074  @return error number or 0 on success */
1075  int open_table(dict_table_t *&innodb_table);
1076 
1077  /** Do the truncate of the table/partition
1078  @return error number or 0 on success */
1079  int exec();
1080 
1081  private:
1082  /** Prepare for truncate
1083  @return error number or 0 on success */
1084  int prepare();
1085 
1086  /** Do the real truncation
1087  @return error number or 0 on success */
1088  int truncate();
1089 
1090  /** Rename tablespace file name
1091  @return error number or 0 on success */
1092  int rename_tablespace();
1093 
1094  /** Cleanup */
1095  void cleanup();
1096 
1097  /** Reload the FK related information
1098  @return error number or 0 on success */
1099  int load_fk();
1100 
1101  private:
1102  /** THD object */
1104 
1105  /** Normalized table name */
1106  const char *m_name;
1107 
1108  /** dd::Table or dd::Partition */
1110 
1111  /** Transaction attached to current thd */
1113 
1114  /** InnoDB table object for the table/partition */
1116 
1117  /** Table format */
1119 
1120  /** Create information */
1122 
1123  /** True if this table/partition is file per table */
1125 
1126  /** True if the original autoinc counter should be kept. It's
1127  specified by caller, however if the table has no AUTOINC column,
1128  it would be reset to false internally */
1130 
1131  /** flags of the table to be truncated, which should not change */
1132  uint64_t m_flags;
1133 
1134  /** flags2 of the table to be truncated, which should not change */
1135  uint64_t m_flags2;
1136 };
1137 
1138 /**
1139 Initialize the table FTS stopword list
1140 @return true if success */
1142  dict_table_t *table, /*!< in: Table has the FTS */
1143  trx_t *trx, /*!< in: transaction */
1144  THD *thd) /*!< in: current thread */
1145  MY_ATTRIBUTE((warn_unused_result));
1146 
1147 /** Some defines for innobase_fts_check_doc_id_index() return value */
1152 };
1153 
1154 /**
1155 Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME
1156 on the Doc ID column.
1157 @return the status of the FTS_DOC_ID index */
1159  const dict_table_t *table, /*!< in: table definition */
1160  const TABLE *altered_table, /*!< in: MySQL table
1161  that is being altered */
1162  ulint *fts_doc_col_no) /*!< out: The column number for
1163  Doc ID */
1164  MY_ATTRIBUTE((warn_unused_result));
1165 
1166 /**
1167 Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME
1168 on the Doc ID column in MySQL create index definition.
1169 @return FTS_EXIST_DOC_ID_INDEX if there exists the FTS_DOC_ID index,
1170 FTS_INCORRECT_DOC_ID_INDEX if the FTS_DOC_ID index is of wrong format */
1172  ulint n_key, /*!< in: Number of keys */
1173  const KEY *key_info) /*!< in: Key definitions */
1174  MY_ATTRIBUTE((warn_unused_result));
1175 
1176 /**
1177 Copy table flags from MySQL's TABLE_SHARE into an InnoDB table object.
1178 Those flags are stored in .frm file and end up in the MySQL table object,
1179 but are frequently used inside InnoDB so we keep their copies into the
1180 InnoDB table object. */
1182  dict_table_t *innodb_table, /*!< in/out: InnoDB table */
1183  const TABLE_SHARE *table_share); /*!< in: table share */
1184 
1185 /** Set up base columns for virtual column
1186 @param[in] table the InnoDB table
1187 @param[in] field MySQL field
1188 @param[in,out] v_col virtual column to be set up */
1189 void innodb_base_col_setup(dict_table_t *table, const Field *field,
1190  dict_v_col_t *v_col);
1191 
1192 /** Set up base columns for stored column
1193 @param[in] table InnoDB table
1194 @param[in] field MySQL field
1195 @param[in,out] s_col stored column */
1197  const Field *field, dict_s_col_t *s_col);
1198 
1199 /** whether this is a stored column */
1200 #define innobase_is_s_fld(field) ((field)->gcol_info && (field)->stored_in_db)
1201 
1202 /** whether this is a computed virtual column */
1203 #define innobase_is_v_fld(field) ((field)->gcol_info && !(field)->stored_in_db)
1204 
1205 /** Whether this is a computed multi-value virtual column.
1206 This condition check should be equal to the following one:
1207 (innobase_is_v_fld(field) && (field)->gcol_info->expr_item &&
1208  field->gcol_info->expr_item->returns_array())
1209 */
1210 #define innobase_is_multi_value_fld(field) (field->is_array())
1211 
1212 /** Always normalize table name to lower case on Windows */
1213 #ifdef _WIN32
1214 #define normalize_table_name(norm_name, name) \
1215  create_table_info_t::normalize_table_name_low(norm_name, name, TRUE)
1216 #else
1217 #define normalize_table_name(norm_name, name) \
1218  create_table_info_t::normalize_table_name_low(norm_name, name, FALSE)
1219 #endif /* _WIN32 */
1220 
1221 /** Note that a transaction has been registered with MySQL.
1222 @param[in] trx Transaction.
1223 @return true if transaction is registered with MySQL 2PC coordinator */
1224 inline bool trx_is_registered_for_2pc(const trx_t *trx) {
1225  return (trx->is_registered == 1);
1226 }
1227 
1228 /** Converts an InnoDB error code to a MySQL error code.
1229 Also tells to MySQL about a possible transaction rollback inside InnoDB caused
1230 by a lock wait timeout or a deadlock.
1231 @param[in] error InnoDB error code.
1232 @param[in] flags InnoDB table flags or 0.
1233 @param[in] thd MySQL thread or NULL.
1234 @return MySQL error code */
1235 int convert_error_code_to_mysql(dberr_t error, uint32_t flags, THD *thd);
1236 
1237 /** Converts a search mode flag understood by MySQL to a flag understood
1238 by InnoDB.
1239 @param[in] find_flag MySQL search mode flag.
1240 @return InnoDB search mode flag. */
1242  enum ha_rkey_function find_flag);
1243 
1244 extern bool innobase_stats_on_metadata;
1245 
1246 /** Calculate Record Per Key value.
1247 Need to exclude the NULL value if innodb_stats_method is set to "nulls_ignored"
1248 @param[in] index InnoDB index.
1249 @param[in] i The column we are calculating rec per key.
1250 @param[in] records Estimated total records.
1251 @return estimated record per key value */
1253  ha_rows records);
1254 
1255 /** Build template for the virtual columns and their base columns
1256 @param[in] table MySQL TABLE
1257 @param[in] ib_table InnoDB dict_table_t
1258 @param[in,out] s_templ InnoDB template structure
1259 @param[in] add_v new virtual columns added along with
1260  add index call
1261 @param[in] locked true if innobase_share_mutex is held
1262 @param[in] share_tbl_name original MySQL table name */
1263 void innobase_build_v_templ(const TABLE *table, const dict_table_t *ib_table,
1264  dict_vcol_templ_t *s_templ,
1265  const dict_add_v_col_t *add_v, bool locked,
1266  const char *share_tbl_name);
1267 
1268 /** callback used by MySQL server layer to initialized
1269 the table virtual columns' template
1270 @param[in] table MySQL TABLE
1271 @param[in,out] ib_table InnoDB dict_table_t */
1272 void innobase_build_v_templ_callback(const TABLE *table, void *ib_table);
1273 
1274 /** Callback function definition, used by MySQL server layer to initialized
1275 the table virtual columns' template */
1276 typedef void (*my_gcolumn_templatecallback_t)(const TABLE *, void *);
1277 
1278 #endif /* ha_innodb_h */
dict_err_ignore_t
Error to ignore when we load table dictionary into memory.
Definition: dict0types.h:123
FT_INFO * ft_init_ext_with_hints(uint inx, String *key, Ft_hints *hints) override
Initialize FT index scan.
Definition: ha_innodb.cc:10365
bool create_option_compression_is_valid()
Validate COMPRESSION option.
Definition: ha_innodb.cc:11749
Wrapper for struct ft_hints.
Definition: handler.h:3544
unsigned long long int ulonglong
Definition: my_inttypes.h:55
int end_stmt()
MySQL calls this method at the end of each statement.
Definition: ha_innodb.cc:17726
Definition: ft_global.h:47
Definition: ha_innodb.h:44
bool m_use_shared_space
Using a Shared General Tablespace.
Definition: ha_innodb.h:980
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:974
Definition: thr_lock.h:123
unsigned char uchar
Definition: my_inttypes.h:51
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:235
longlong get_memory_buffer_size() const override
Return the size of the InnoDB memory buffer.
Definition: ha_innodb.cc:15832
THD * m_thd
THD object.
Definition: ha_innodb.h:1103
THD * m_user_thd
Thread handle of the user currently using the handler; this is set in external_lock function...
Definition: ha_innodb.h:664
struct new_ft_info NEW_FT_INFO
Structure Returned by ha_innobase::ft_init_ext()
int close(void) override
Closes a handle to an InnoDB table.
Definition: ha_innodb.cc:7203
int discard_or_import_tablespace(bool discard, dd::Table *table_def) override
Discards or imports an InnoDB tablespace.
Definition: ha_innodb.cc:14202
int index_init(uint index, bool sorted) override
Initializes a handle to use an index.
Definition: ha_innodb.cc:9522
void srv_concurrency_exit()
Leave Innodb, if no more tickets are left.
Definition: ha_innodb.cc:2667
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:13859
const char * db_name
Definition: rules_table_service.cc:54
uint referenced_by_foreign_key() override
Checks if a table is referenced by a foreign key.
Definition: ha_innodb.cc:17632
int parallel_scan_end(void *scan_ctx) override
End of the parallel scan.
Definition: handler0alter.cc:1242
Definition: handler.h:3195
int create_table_update_global_dd(Table *dd_table)
Update the global data dictionary.
Definition: ha_innodb.cc:13093
innodb_idx_translate_t idx_trans_tbl
index translation table between MySQL and InnoDB
Definition: ha_innodb.h:64
enum_alter_inplace_result check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_info *ha_alter_info) override
On-line ALTER TABLE interface.
Definition: handler0alter.cc:683
Query result.
Definition: fts0fts.h:312
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:2740
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:10042
bool m_use_data_dir
Using DATA DIRECTORY.
Definition: ha_innodb.h:977
int get_foreign_key_list(THD *thd, List< FOREIGN_KEY_INFO > *f_key_list) override
Gets the list of foreign keys in this table.
Definition: ha_innodb.cc:17409
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:22931
const string name("\ame\)
Class to handle TRUNCATE for one InnoDB table or one partition.
Definition: ha_innodb.h:1047
static bool commit(THD *thd)
Commit the current statement and transaction.
Definition: sql_cmd_srs.cc:151
Definition: mi_test3.cc:54
ulint m_upd_buf_size
the size of upd_buf in bytes
Definition: ha_innodb.h:673
This structure is shared between different table objects.
Definition: table.h:653
int rnd_init(bool scan) override
Initialize a table scan.
Definition: ha_innodb.cc:10132
void set_remote_path_flags()
Set flags and append &#39;/&#39; to remote path if necessary.
Definition: ha_innopart.cc:2353
Class for handling create table information.
Definition: ha_innodb.h:806
uint max_supported_keys() const override
Returns the maximum number of keys.
Definition: ha_innodb.cc:5867
trx_t * innobase_trx_allocate(THD *thd)
Allocates an InnoDB transaction for a MySQL handler object.
Definition: ha_innodb.cc:2514
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:6089
Definition: trx0trx.h:780
const char * table_name
InnoDB table name.
Definition: ha_innodb.h:57
Definition: ft_global.h:56
ibool innobase_fts_load_stopword(dict_table_t *table, trx_t *trx, THD *thd)
Initialize the table FTS stopword list
Definition: ha_innodb.cc:12014
void initialize_autoinc()
Initialize the autoinc of this table if necessary, which should be called before we flush logs...
Definition: ha_innodb.cc:12664
bool m_keep_autoinc
True if the original autoinc counter should be kept.
Definition: ha_innodb.h:1129
int index_end() override
Currently does nothing.
Definition: ha_innodb.cc:9534
char * get_foreign_key_create_info() override
Gets the foreign key create info for a table stored in InnoDB.
Definition: ha_innodb.cc:17222
INNOBASE_SHARE * m_share
information for MySQL table locking
Definition: ha_innodb.h:667
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:22525
int reset() override
MySQL calls this method at the end of each statement
Definition: ha_innodb.cc:17770
bool skip_strict() const
whether to skip strict check.
Definition: ha_innodb.h:891
int ft_read(uchar *buf) override
Fetch next result from the FT result set.
Definition: ha_innodb.cc:10421
int delete_all_rows() override
Delete all rows from the table.
Definition: ha_innodb.cc:9439
bool commit_inplace_alter_table_impl(TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit, const Table *old_dd_tab, Table *new_dd_tab)
Implementation of commit_inplace_alter_table()
Definition: handler0alter.cc:7170
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:10053
Definition: field.h:700
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:14093
THD * m_thd
Connection thread handle.
Definition: ha_innodb.h:940
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:15602
void set_tablespace_type(bool table_being_altered_is_file_per_table)
Set m_tablespace_type.
Definition: ha_innodb.cc:12605
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:1132
const TABLE * m_form
Information on table columns and indexes.
Definition: ha_innodb.h:946
enum_sql_command
Definition: my_sqlcommand.h:45
static void normalize_table_name_low(char *norm_name, const char *name, ibool set_lower_case)
Normalizes a table name string.
Definition: ha_innodb.cc:5908
const char * table_type() const override
Returns the table type (storage engine name).
Definition: ha_innodb.cc:5823
ha_innobase(handlerton *hton, TABLE_SHARE *table_arg)
Construct ha_innobase handler.
Definition: ha_innodb.cc:2673
Definition: handler.h:3210
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:22513
int load_fk()
Reload the FK related information.
Definition: ha_innodb.cc:13789
HA_CREATE_INFO m_create_info
Create information.
Definition: ha_innodb.h:1121
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:1300
~ha_innobase() override
Destruct ha_innobase handler.
Definition: ha_innodb.cc:2695
uint lock_count(void) const override
Returns number of THR_LOCK locks used for one instance of InnoDB table.
Definition: ha_innodb.cc:18693
bool m_start_of_scan
this is set to 1 when we are starting a table scan but have not yet fetched any row, else false
Definition: ha_innodb.h:680
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:10639
int disable_indexes(uint mode) override
Disable indexes.
Definition: ha_innodb.cc:16945
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:1818
Data structure for a database table.
Definition: dict0mem.h:1529
ulint m_stored_select_lock_type
this field is used to remember the original select_lock_type that was decided in ha_innodb.cc,":: store_lock()", "::external_lock()", etc.
Definition: ha_innodb.h:689
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:19391
void try_semi_consistent_read(bool yes) override
Tell the engine whether it should avoid unnecessary lock waits.
Definition: ha_innodb.cc:9508
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:17784
bool innobase_table_flags()
Determines InnoDB table flags.
Definition: ha_innodb.cc:12229
Data structure for newly added virtual column in a table.
Definition: dict0mem.h:658
uint use_count
reference count, incremented in get_share() and decremented in free_share()
Definition: ha_innodb.h:58
static const char * s_file_per_table_name
The hard-coded tablespace name innodb_file_per_table.
Definition: dict0dict.h:1240
Definition: my_base.h:107
const char * table_name() const
Return table name.
Definition: ha_innodb.h:894
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:1219
ha_rkey_function
Definition: my_base.h:77
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4009
Table_flags m_int_table_flags
Flags that specificy the handler instance (table) capability.
Definition: ha_innodb.h:676
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:15511
handler::Load_end_cbk End_fn
Definition: row0pread-adapter.h:49
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:9809
char * m_tablespace
Tablespace name or zero length-string.
Definition: ha_innodb.h:956
struct _ft_vft_ext * could_you
Definition: ha_innodb.h:707
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:161
virtual 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:18909
int ft_init() override
Initialize FT index scan.
Definition: ha_innodb.cc:10217
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:15473
app_data_ptr new_data(u_int n, char *val, cons_type consensus)
Definition: app_data.c:426
uint64_t m_flags
flags of the table to be truncated, which should not change
Definition: ha_innodb.h:1132
dberr_t innobase_lock_autoinc()
This special handling is really to overcome the limitations of MySQL&#39;s binlogging.
Definition: ha_innodb.cc:8176
int read_range_next() override
Read next row between two endpoints.
Definition: ha_innodb.cc:10123
Definition: table.h:1301
int truncate_impl(const char *name, TABLE *form, dd::Table *table_def)
TRUNCATE an InnoDB table.
Definition: ha_innodb.cc:14316
row_prebuilt_t * m_prebuilt
Save CPU time with prebuilt/cached data structures.
Definition: ha_innodb.h:660
Table * m_dd_table
dd::Table or dd::Partition
Definition: ha_innodb.h:1109
Table_flags table_flags() const override
Get the table flags to use for the statement.
Definition: ha_innodb.cc:5789
struct _ft_vft * please
Definition: ha_innodb.h:706
int rnd_end() override
Ends a table scan.
Definition: ha_innodb.cc:10153
int cmp_ref(const uchar *ref1, const uchar *ref2) const override
Compares two &#39;refs&#39;.
Definition: ha_innodb.cc:19114
void innobase_build_v_templ_callback(const TABLE *table, void *ib_table)
callback used by MySQL server layer to initialized the table virtual columns&#39; template ...
Definition: ha_innodb.cc:6234
int get_cascade_foreign_key_table_list(THD *thd, List< st_handler_tablename > *fk_table_list) override
Get the list of tables ordered by the dependency on the other tables using the &#39;CASCADE&#39; foreign key ...
Definition: ha_innodb.cc:17531
bool m_file_per_table
True if this table/partition is file per table.
Definition: ha_innodb.h:1124
bool m_allow_file_per_table
Allow file_per_table for this table either because: 1) the setting innodb_file_per_table=on, 2) it was explicitly requested by tablespace=innodb_file_per_table.
Definition: ha_innodb.h:970
double scan_time() override
How many seeks it will take to read through the table.
Definition: ha_innodb.cc:15768
fts_result_t * ft_result
Definition: ha_innodb.h:709
handler::Load_cbk Load_fn
Definition: row0pread-adapter.h:47
uint32_t flags2() const
Get table flags2.
Definition: ha_innodb.h:882
dberr_t innobase_get_autoinc(ulonglong *value)
Read the next autoinc value.
Definition: ha_innodb.cc:18885
fts_doc_id_index_enum
Some defines for innobase_fts_check_doc_id_index() return value.
Definition: ha_innodb.h:1148
#define DBUG_ASSERT(A)
Definition: my_dbug.h:197
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 ...
Definition: handler0alter.cc:2624
int create_table(const dd::Table *dd_table)
Create the internal innodb table.
Definition: ha_innodb.cc:12834
ulint index_count
number of valid index entries in the index_mapping array
Definition: ha_innodb.h:45
A struct for (sometimes lazily) prebuilt structures in an Innobase table handle used within MySQL; th...
Definition: row0mysql.h:551
~innobase_truncate()
Destructor.
Definition: ha_innodb.cc:13543
int check(THD *thd, HA_CHECK_OPT *check_opt) override
Tries to check that an InnoDB table is not corrupted.
Definition: ha_innodb.cc:17023
int info(uint) override
Returns statistics information of the table to the MySQL interpreter, in various fields of the handle...
Definition: ha_innodb.cc:16425
void flags2_reset()
Reset table flags2.
Definition: ha_innodb.h:888
int enable_indexes(uint mode) override
Enable indexes.
Definition: ha_innodb.cc:16918
void srv_concurrency_enter()
Enter InnoDB engine after checking max allowed threads.
Definition: ha_innodb.cc:2663
innobase_truncate(THD *thd, const char *name, TABLE *form, Table *dd_table, bool keep_autoinc)
Constructor.
Definition: ha_innodb.h:1055
char * index(const char *, int c)
Definition: mysql.cc:2862
dberr_t innobase_set_max_autoinc(ulonglong auto_inc)
Store the autoinc value in the table.
Definition: ha_innodb.cc:8241
UNIV_INLINE bool is_shared_tablespace(const char *tablespace_name)
Check if tablespace is shared tablespace.
Definition: ha_innodb.h:784
THD * thd() const
Definition: ha_innodb.h:896
char * pos
Definition: do_ctype.cc:76
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:867
thr_lock_type
Definition: thr_lock.h:50
static dict_table_t * open_dict_table(const char *table_name, const char *norm_name, bool is_partition, dict_err_ignore_t ignore_err)
Opens dictionary table object using table name.
Definition: ha_innodb.cc:7113
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:9233
static const char * s_temp_space_name
The name of the predefined temporary tablespace.
Definition: dict0dict.h:1234
dict_index_t ** index_mapping
index pointer array directly maps to index in InnoDB from MySQL array index
Definition: ha_innodb.h:50
void flags_reset()
Reset table flags.
Definition: ha_innodb.h:885
ulong index_flags(uint idx, uint part, bool all_parts) const override
Returns the operations supported for indexes.
Definition: ha_innodb.cc:5828
void * table_name_hash
hash table chain node
Definition: ha_innodb.h:62
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:10066
int prepare_create_table(const char *name)
Prepare to create a table.
Definition: ha_innodb.cc:12727
int open_table(dict_table_t *&innodb_table)
Open the table/partition to be truncated.
Definition: ha_innodb.cc:13554
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:10159
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:22954
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:9966
int prepare()
Prepare for truncate.
Definition: ha_innodb.cc:13585
int intrinsic_table_write_row(uchar *record)
Write Row Interface optimized for Intrinsic table.
Definition: ha_innodb.cc:8260
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:5739
Definition: ha_innodb.h:1150
int create_table_update_dict()
Update the internal data dictionary.
Definition: ha_innodb.cc:13042
enum_alter_inplace_result
Return values for check_if_supported_inplace_alter().
Definition: handler.h:194
dberr_t
Definition: db0err.h:38
const struct _ft_vft ft_vft_result
Definition: ha_innodb.cc:513
bool is_intrinsic_temp_table() const
Definition: ha_innodb.h:898
page_cur_mode_t
Definition: page0types.h:173
int truncate()
Do the real truncation.
Definition: ha_innodb.cc:13636
dict_table_t * m_table
The newly created InnoDB table object.
Definition: ha_innodb.h:961
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:10608
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:16974
uint m_last_match_mode
Definition: ha_innodb.h:684
bool was_semi_consistent_read() override
Normally, when running UPDATE or DELETE queries, we need to wait for other transactions to release ...
Definition: ha_innodb.cc:9502
UNIV_INLINE 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:760
HA_CREATE_INFO * m_create_info
Create options.
Definition: ha_innodb.h:949
int change_active_index(uint keynr)
Changes the active index of a handle.
Definition: ha_innodb.cc:9866
static uint keys
Definition: hp_test2.cc:43
uint32_t m_flags2
Table flags2.
Definition: ha_innodb.h:986
Definition: item.h:668
unsigned int uint
Definition: uca-dump.cc:29
handler::Load_init_cbk Init_fn
Definition: row0pread-adapter.h:51
handler * clone(const char *name, MEM_ROOT *mem_root) override
Definition: ha_innodb.cc:7169
long long int longlong
Definition: my_inttypes.h:54
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:22501
The class defining a handle to an InnoDB table.
Definition: ha_innodb.h:78
int delete_row(const uchar *buf) override
Deletes a row given as the parameter.
Definition: ha_innodb.cc:9387
char * m_remote_path
Remote path (DATA DIRECTORY) or zero length-string.
Definition: ha_innodb.h:954
Definition: my_base.h:106
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)
Constructor.
Definition: ha_innodb.h:812
bool is_temp_table() const
Definition: ha_innodb.h:905
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:10116
Definition: handler.h:6582
Class describing changes to be done by ALTER TABLE.
Definition: handler.h:2762
void free_foreign_key_create_info(char *str) override
Frees the foreign key create info for a table stored in InnoDB, if it is non-NULL.
Definition: ha_innodb.cc:17643
bool m_skip_strict
Skip strict check.
Definition: ha_innodb.h:989
UNIV_INLINE 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:749
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2272
FT_INFO * ft_init_ext(uint flags, uint inx, String *key) override
Initialize FT index scan.
Definition: ha_innodb.cc:10237
#define DICT_TF2_INTRINSIC
Intrinsic table bit Intrinsic table is table created internally by MySQL modules viz.
Definition: dict0mem.h:278
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:6249
Definition: my_base.h:109
bool m_innodb_file_per_table
Local copy of srv_file_per_table.
Definition: ha_innodb.h:964
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:2909
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:94
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:9642
static int rename_impl(THD *thd, const char *from, const char *to, const Table *from_table, const Table *to_table)
Renames an InnoDB table.
Definition: ha_innodb.cc:13429
bool innobase_stats_on_metadata
Definition: ha_innodb.cc:271
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:2538
void position(const uchar *record) override
Store a reference to the current row to &#39;ref&#39; field of the handle.
Definition: ha_innodb.cc:10571
const char * create_options_are_invalid()
Validates the create options.
Definition: ha_innodb.cc:11813
bool create_option_tablespace_is_valid()
Validate TABLESPACE option.
Definition: ha_innodb.cc:11551
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:2727
Definition: ha_innodb.h:1151
Definition: ha_innodb.h:1149
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:15802
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:16109
void(* my_gcolumn_templatecallback_t)(const TABLE *, void *)
Callback function definition, used by MySQL server layer to initialized the table virtual columns&#39; te...
Definition: ha_innodb.h:1276
Definition: my_base.h:1114
Parallel read adapter interface.
void innobase_initialize_autoinc()
Set the autoinc column max value.
Definition: ha_innodb.cc:6514
static const char * key
Definition: suite_stubs.c:14
static MEM_ROOT mem_root
Definition: client_plugin.cc:107
void cleanup()
Cleanup.
Definition: ha_innodb.cc:13772
bool create_option_data_directory_is_valid()
Validate DATA DIRECTORY option.
Definition: ha_innodb.cc:11413
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:12167
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:15933
ha_rows estimate_rows_upper_bound() override
Gives an UPPER BOUND to the number of rows in a table.
Definition: ha_innodb.cc:15721
const char * m_name
Normalized table name.
Definition: ha_innodb.h:1106
Structure defines template related to virtual columns and their base columns.
Definition: dict0mem.h:1471
void update_create_info(HA_CREATE_INFO *create_info) override
Update create_info.
Definition: ha_innodb.cc:11984
void ft_end()
Definition: ha_innodb.cc:10556
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:65
static const char * s_sys_space_name
The name of the hard-coded system tablespace.
Definition: dict0dict.h:1231
Definition: handler.h:3218
ulong thd_parallel_read_threads(THD *thd)
Return the number of read threads for this session.
Definition: ha_innodb.cc:1762
virtual bool get_error_message(int error, String *buf) override
See comment in handler.cc.
Definition: ha_innodb.cc:19046
int rnd_pos(uchar *buf, uchar *pos) override
Fetches a row from the table based on a row reference.
Definition: ha_innodb.cc:10186
int delete_table(const char *name, const dd::Table *table_def) override
Drop a table.
Definition: ha_innodb.cc:14382
int initialize()
Initialize the object.
Definition: ha_innodb.cc:12636
virtual 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:19070
bool primary_key_is_clustered() const override
Determines if the primary key is clustered index.
Definition: ha_innodb.cc:5898
DsMrr_impl m_ds_mrr
The multi range read session object.
Definition: ha_innodb.h:657
static int flag
Definition: hp_test1.cc:39
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:10099
int get_parent_foreign_key_list(THD *thd, List< FOREIGN_KEY_INFO > *f_key_list) override
Gets the set of foreign keys where this table is the referenced table.
Definition: ha_innodb.cc:17443
int extra(ha_extra_function operation) override
Tells something additional to the handler about how to do things.
Definition: ha_innodb.cc:17654
UNIV_INLINE 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:771
Traverse an index in the leaf page block list order and send records to adapter.
Definition: row0pread-adapter.h:42
bool inplace_alter_table_impl(TABLE *altered_table, Alter_inplace_info *ha_alter_info, const Table *old_dd_tab, Table *new_dd_tab)
Implementation of inplace_alter_table()
Definition: handler0alter.cc:5906
trx_t * m_trx
Transaction attached to current thd.
Definition: ha_innodb.h:1112
trx_t * m_trx
InnoDB transaction handle.
Definition: ha_innodb.h:943
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:1263
int create_table_def(const dd::Table *dd_table)
Create the internal innodb table definition.
Definition: ha_innodb.cc:10672
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:5180
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 &#39;...
Definition: ha_innodb.cc:20653
int parallel_scan_init(void *&scan_ctx, size_t &num_threads) override
Initializes a parallel scan.
Definition: handler0alter.cc:1158
bool trx_is_registered_for_2pc(const trx_t *trx)
Note that a transaction has been registered with MySQL.
Definition: ha_innodb.h:1224
Definition: key.h:111
ha_key_alg
Definition: my_base.h:96
int multi_range_read_next(char **range_info) override
Process next multi range read.
Definition: ha_innodb.cc:22509
Data structure for a virtual column in a table.
Definition: dict0mem.h:638
Data structure for a stored column in a table.
Definition: dict0mem.h:670
ulonglong Table_flags
Definition: handler.h:4013
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:14170
#define NULL
Definition: types.h:55
int exec()
Do the truncate of the table/partition.
Definition: ha_innodb.cc:13820
int write_row(uchar *buf) override
Stores a row in an InnoDB database, to the table specified in this handle.
Definition: ha_innodb.cc:8495
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:16992
const char * tablespace
Definition: handler.h:2634
Definition: handler.h:2629
uchar * m_upd_buf
buffer used in updates
Definition: ha_innodb.h:670
void reset_template()
Resets a query execution &#39;template&#39;.
Definition: ha_innodb.cc:2879
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 &#39;lock&#39; field of the handle to a proper type befo...
Definition: ha_innodb.cc:18709
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:9552
enum ha_key_alg get_default_index_algorithm() const override
Get default key algorithm for SE.
Definition: ha_innodb.h:87
uint max_supported_key_length() const override
Returns the maximum key length.
Definition: ha_innodb.cc:5872
void detach()
Detach the just created table and its auxiliary tables if exist.
Definition: ha_innodb.cc:12474
The transaction.
char * m_table_name
Table name.
Definition: ha_innodb.h:952
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:17915
Definition: test_sql_stmt.cc:150
const string value("\alue\)
static int delete_impl(THD *thd, const char *name, const Table *dd_tab)
Drop an InnoDB table.
Definition: ha_innodb.cc:13319
Definition: ft_global.h:71
row_prebuilt_t * ft_prebuilt
Definition: ha_innodb.h:708
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39
uint64_t m_flags2
flags2 of the table to be truncated, which should not change
Definition: ha_innodb.h:1135
int open(const char *name, int, uint open_flags, const dd::Table *table_def) override
Open an InnoDB table.
Definition: ha_innodb.cc:6635
A table definition from the master.
Definition: rpl_utility.h:245
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:77
bool is_registered
Definition: trx0trx.h:958
static int flags[50]
Definition: hp_test1.cc:39
void unlock_row() override
Removes a new lock set on a row, if it was not read optimistically.
Definition: ha_innodb.cc:9458
Item * idx_cond_push(uint keyno, Item *idx_cond) override
Attempt to push down an index condition.
Definition: ha_innodb.cc:22912
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, ulint old_flags, ulint old_flags2)
Create an InnoDB table.
Definition: ha_innodb.cc:13198
void innobase_copy_frm_flags_from_table_share(dict_table_t *innodb_table, const TABLE_SHARE *table_share)
Copy table flags from MySQL&#39;s TABLE_SHARE into an InnoDB table object.
Definition: ha_innodb.cc:2638
uint32_t flags() const
Get table flags.
Definition: ha_innodb.h:879
static int yes(xcom_port port)
Definition: xcom_base.c:981
Definition: table.h:43
dict_table_t * m_table
InnoDB table object for the table/partition.
Definition: ha_innodb.h:1115
Used to store optimizer cost estimates.
Definition: handler.h:3284
#define DICT_TF2_TEMPORARY
TEMPORARY; TRUE for tables from CREATE TEMPORARY TABLE.
Definition: dict0mem.h:255
unsigned long ulong
Definition: my_inttypes.h:48
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:10078
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:12530
#define false
Definition: config_static.h:43
trx_t *& thd_to_trx(THD *thd)
Obtain the InnoDB transaction of a MySQL thread.
Definition: ha_innodb.cc:1752
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:14083
bool is_index_algorithm_supported(enum ha_key_alg key_alg) const override
Check if SE supports specific key algorithm.
Definition: ha_innodb.h:92
int rename_tablespace()
Rename tablespace file name.
Definition: ha_innodb.cc:13723
uint max_supported_key_part_length(HA_CREATE_INFO *create_info) const override
Definition: ha_innodb.cc:7186
Structure Returned by ha_innobase::ft_init_ext()
Definition: ha_innodb.h:705
my_off_t ha_rows
Definition: my_base.h:1130
uint32_t m_flags
Table flags.
Definition: ha_innodb.h:983
Class of basic DDL implementation, for CREATE/DROP/RENAME TABLE.
Definition: ha_innodb.h:993
void build_template(bool whole_row)
Builds a &#39;template&#39; to the prebuilt struct.
Definition: ha_innodb.cc:7861
InnoDB table share.
Definition: ha_innodb.h:56
ulint array_size
array size of index_mapping
Definition: ha_innodb.h:48
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:778
virtual dict_index_t * innobase_get_index(uint keynr)
Get the index for a handle.
Definition: ha_innodb.cc:9822
ha_extra_function
Definition: my_base.h:183
row_type
Definition: handler.h:666
TABLE * m_form
Table format.
Definition: ha_innodb.h:1118
const char * table_name
Definition: rules_table_service.cc:55
Data structure for an index.
Definition: dict0mem.h:875
Log error(cerr, "ERROR")
bool m_mysql_has_locked
If mysql has locked with external_lock()
Definition: ha_innodb.h:692