MySQL  8.0.21
Source Code Documentation
ha_innopart.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 2014, 2020, 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 /* The InnoDB Partition handler: the interface between MySQL and InnoDB. */
28 
29 #ifndef ha_innopart_h
30 #define ha_innopart_h
31 
32 #include <stddef.h>
33 #include <sys/types.h>
34 
35 #include "ha_innodb.h"
36 #include "my_compiler.h"
38 #include "row0mysql.h"
39 #include "ut0bitset.h"
40 
41 /* Forward declarations */
42 class Altered_partitions;
43 class partition_info;
44 
45 /* Error Text */
46 static constexpr auto PARTITION_IN_SHARED_TABLESPACE =
47  "InnoDB : A partitioned table"
48  " is not allowed in a shared tablespace.";
49 
50 /** HA_DUPLICATE_POS and HA_READ_BEFORE_WRITE_REMOVAL is not
51 set from ha_innobase, but cannot yet be supported in ha_innopart.
52 Full text and geometry is not yet supported. */
56 
58 
59 /** InnoDB partition specific Handler_share. */
61  private:
62  /** Array of all included table definitions (one per partition). */
64 
65  /** Instead of INNOBASE_SHARE::idx_trans_tbl. Maps MySQL index number
66  to InnoDB index per partition. */
68 
69  /** Total number of partitions. */
71 
72  /** Number of indexes. */
74 
75  /** Reference count. */
77 
78  /** Pointer back to owning TABLE_SHARE. */
80 
81  public:
82  Ha_innopart_share(TABLE_SHARE *table_share);
83 
85 
86  /** Set innodb table for given partition.
87  @param[in] part_id Partition number.
88  @param[in] table Table. */
89  inline void set_table_part(uint part_id, dict_table_t *table) {
90  ut_ad(m_table_parts != nullptr);
91  ut_ad(part_id < m_tot_parts);
92  m_table_parts[part_id] = table;
93  }
94  /** Get table reference for given partition.
95  @param[in] part_id Partition number
96  @return InnoDB table reference. */
97  inline dict_table_t **get_table_part_ref(uint part_id) {
98  return (&m_table_parts[part_id]);
99  }
100 
101  /** Return innodb table for given partition.
102  @param[in] part_id Partition number.
103  @return InnoDB table. */
104  inline dict_table_t *get_table_part(uint part_id) const {
105  ut_ad(m_table_parts != nullptr);
106  ut_ad(part_id < m_tot_parts);
107  return (m_table_parts[part_id]);
108  }
109 
110  /** Return innodb index for given partition and key number.
111  @param[in] part_id Partition number.
112  @param[in] keynr Key number.
113  @return InnoDB index. */
114  dict_index_t *get_index(uint part_id, uint keynr);
115 
116  /** Get MySQL key number corresponding to InnoDB index.
117  @param[in] part_id Partition number.
118  @param[in] index InnoDB index.
119  @return MySQL key number or MAX_KEY if non-existent. */
120  uint get_mysql_key(uint part_id, const dict_index_t *index);
121 
122  /** Return whether share has opened InnoDB tables for partitions. */
123  bool has_table_parts() const { return (m_table_parts != nullptr); }
124 
125  /** Increment share and InnoDB tables reference counters. */
126  void increment_ref_counts();
127 
128  /** Open InnoDB tables for partitions and return them as array.
129  @param[in,out] thd Thread context
130  @param[in] table MySQL table definition
131  @param[in] dd_table Global DD table object
132  @param[in] part_info Partition info (partition names to use)
133  @param[in] table_name Table name (db/table_name)
134  @return Array on InnoDB tables on success else nullptr. */
135  static dict_table_t **open_table_parts(THD *thd, const TABLE *table,
136  const dd::Table *dd_table,
137  partition_info *part_info,
138  const char *table_name);
139 
140  /** Initialize the share with table and indexes per partition.
141  @param[in] table MySQL table definition
142  @param[in] part_info Partition info (partition names to use)
143  @param[in] table_parts Array of InnoDB tables for partitions.
144  @return false on success else true. */
145  bool set_table_parts_and_indexes(const TABLE *table,
146  partition_info *part_info,
147  dict_table_t **table_parts);
148 
149  /** Close the table partitions.
150  If all instances are closed, also release the resources.*/
151  void close_table_parts();
152 
153  /** Close InnoDB tables for partitions.
154  @param[in] table_parts Array of InnoDB tables for partitions.
155  @param[in] tot_parts Number of partitions. */
156  static void close_table_parts(dict_table_t **table_parts, uint tot_parts);
157 
158  /** @return the TABLE SHARE object */
159  const TABLE_SHARE *get_table_share() const { return (m_table_share); }
160 
161  /** Get the number of partitions
162  @return number of partitions */
163  uint get_num_parts() const {
164  ut_ad(m_tot_parts != 0);
165  return (m_tot_parts);
166  }
167 
168  /** Set up the virtual column template for partition table, and points
169  all m_table_parts[]->vc_templ to it.
170  @param[in] table MySQL TABLE object
171  @param[in] ib_table InnoDB dict_table_t
172  @param[in] name Table name (db/table_name) */
173  void set_v_templ(TABLE *table, dict_table_t *ib_table, const char *name);
174 
175  private:
176  /** Disable default constructor. */
178 
179  /** Open one partition
180  @param[in,out] client Data dictionary client
181  @param[in] thd Thread THD
182  @param[in] table MySQL table definition
183  @param[in] dd_part dd::Partition
184  @param[in] part_name Table name of this partition
185  @param[out] part_dict_table InnoDB table for partition
186  @retval False On success
187  @retval True On failure */
189  THD *thd, const TABLE *table,
190  const dd::Partition *dd_part,
191  const char *part_name,
192  dict_table_t **part_dict_table);
193 };
194 
195 /** Get explicit specified tablespace for one (sub)partition, checking
196 from lowest level
197 @param[in] tablespace table-level tablespace if specified
198 @param[in] part Partition to check
199 @param[in] sub_part Sub-partition to check, if no, just NULL
200 @return Tablespace name, if nullptr or [0] = '\0' then nothing specified */
201 const char *partition_get_tablespace(const char *tablespace,
202  const partition_element *part,
203  const partition_element *sub_part);
204 
205 /** The class defining a partitioning aware handle to an InnoDB table.
206 Based on ha_innobase and extended with
207 - Partition_helper for re-using common partitioning functionality
208 - Partition_handler for providing partitioning specific api calls.
209 Generic partitioning functions are implemented in Partition_helper.
210 Lower level storage functions are implemented in ha_innobase.
211 Partition_handler is inherited for implementing the handler level interface
212 for partitioning specific functions, like truncate_partition.
213 InnoDB specific functions related to partitioning is implemented here. */
214 class ha_innopart : public ha_innobase,
215  public Partition_helper,
216  public Partition_handler {
217  public:
218  ha_innopart(handlerton *hton, TABLE_SHARE *table_arg);
219 
220  ~ha_innopart() override;
221 
222  /** Clone this handler, used when needing more than one cursor
223  to the same table.
224  @param[in] name Table name.
225  @param[in] mem_root mem_root to allocate from.
226  @retval Pointer to clone or NULL if error. */
227  handler *clone(const char *name, MEM_ROOT *mem_root) override;
228 
229  /** On-line ALTER TABLE interface @see handler0alter.cc @{ */
230 
231  /** Check if InnoDB supports a particular alter table in-place.
232  @param[in] altered_table TABLE object for new version of table.
233  @param[in,out] ha_alter_info Structure describing changes to be done
234  by ALTER TABLE and holding data used during in-place alter.
235  @retval HA_ALTER_INPLACE_NOT_SUPPORTED Not supported
236  @retval HA_ALTER_INPLACE_NO_LOCK Supported
237  @retval HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE Supported, but
238  requires lock during main phase and exclusive lock during prepare
239  phase.
240  @retval HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE Supported, prepare
241  phase requires exclusive lock. */
242  enum_alter_inplace_result check_if_supported_inplace_alter(
243  TABLE *altered_table, Alter_inplace_info *ha_alter_info) override;
244 
245  /** Prepare in-place ALTER for table.
246  Allows InnoDB to update internal structures with concurrent
247  writes blocked (provided that check_if_supported_inplace_alter()
248  did not return HA_ALTER_INPLACE_NO_LOCK).
249  This will be invoked before inplace_alter_table().
250  @param[in] altered_table TABLE object for new version of table.
251  @param[in,out] ha_alter_info Structure describing changes to be done
252  by ALTER TABLE and holding data used during in-place alter.
253  @param[in] old_table_def dd::Table object describing old
254  version of the table.
255  @param[in,out] new_table_def dd::Table object for the new version
256  of the table. Can be adjusted by this call. Changes to the table
257  definition will be persisted in the data-dictionary at statement
258  commit time.
259  @retval true Failure.
260  @retval false Success. */
261  bool prepare_inplace_alter_table(TABLE *altered_table,
262  Alter_inplace_info *ha_alter_info,
263  const dd::Table *old_table_def,
264  dd::Table *new_table_def) override;
265 
266  /** Alter the table structure in-place.
267  Alter the table structure in-place with operations
268  specified using HA_ALTER_FLAGS and Alter_inplace_information.
269  The level of concurrency allowed during this operation depends
270  on the return value from check_if_supported_inplace_alter().
271  @param[in] altered_table TABLE object for new version of table.
272  @param[in,out] ha_alter_info Structure describing changes to be done
273  by ALTER TABLE and holding data used during in-place alter.
274  @param[in] old_table_def dd::Table object describing old
275  version of the table.
276  @param[in,out] new_table_def dd::Table object for the new version
277  of the table. Can be adjusted by this call. Changes to the table
278  definition will be persisted in the data-dictionary at statement
279  commit time.
280  @retval true Failure.
281  @retval false Success. */
282  bool inplace_alter_table(TABLE *altered_table,
283  Alter_inplace_info *ha_alter_info,
284  const dd::Table *old_table_def,
285  dd::Table *new_table_def) override;
286 
287  /** Commit or rollback.
288  Commit or rollback the changes made during
289  prepare_inplace_alter_table() and inplace_alter_table() inside
290  the storage engine. Note that the allowed level of concurrency
291  during this operation will be the same as for
292  inplace_alter_table() and thus might be higher than during
293  prepare_inplace_alter_table(). (E.g concurrent writes were
294  blocked during prepare, but might not be during commit).
295  @param[in] altered_table TABLE object for new version of table.
296  @param[in,out] ha_alter_info Structure describing changes to be done
297  by ALTER TABLE and holding data used
298  during in-place alter.
299  @param[in] commit true => Commit, false => Rollback.
300  @param[in] old_table_def dd::Table object describing old
301  version of the table.
302  @param[in,out] new_table_def dd::Table object for the new version
303  of the table. Can be adjusted by this call. Changes to the table
304  definition will be persisted in the data-dictionary at statement
305  commit time.
306  @retval true Failure.
307  @retval false Success. */
308  bool commit_inplace_alter_table(TABLE *altered_table,
309  Alter_inplace_info *ha_alter_info,
310  bool commit, const dd::Table *old_table_def,
311  dd::Table *new_table_def) override;
312  /** @} */
313 
314  /** Allows InnoDB to update internal structures with concurrent
315  writes blocked (given that check_if_supported_inplace_alter()
316  did not return HA_ALTER_INPLACE_NO_LOCK).
317  This is for 'ALTER TABLE ... PARTITION' and a corresponding function
318  to prepare_inplace_alter_table().
319  This will be invoked before inplace_alter_partition().
320 
321  @param[in,out] altered_table TABLE object for new version of table
322  @param[in,out] ha_alter_info Structure describing changes to be done
323  by ALTER TABLE and holding data used
324  during in-place alter.
325  @param[in] old_dd_tab Table definition before the ALTER
326  @param[in,out] new_dd_tab Table definition after the ALTER
327  @retval true Failure
328  @retval false Success */
329  bool prepare_inplace_alter_partition(TABLE *altered_table,
330  Alter_inplace_info *ha_alter_info,
331  const dd::Table *old_dd_tab,
332  dd::Table *new_dd_tab);
333 
334  /** Alter the table structure in-place with operations
335  specified using HA_ALTER_FLAGS and Alter_inplace_information.
336  This is for 'ALTER TABLE ... PARTITION' and a corresponding function
337  to inplace_alter_table().
338  The level of concurrency allowed during this operation depends
339  on the return value from check_if_supported_inplace_alter().
340 
341  @param[in,out] altered_table TABLE object for new version of table
342  @param[in,out] ha_alter_info Structure describing changes to be done
343  by ALTER TABLE and holding data used
344  during in-place alter.
345  @param[in] old_dd_tab Table definition before the ALTER
346  @param[in,out] new_dd_tab Table definition after the ALTER
347  @retval true Failure
348  @retval false Success */
349  bool inplace_alter_partition(TABLE *altered_table,
350  Alter_inplace_info *ha_alter_info,
351  const dd::Table *old_dd_tab,
352  dd::Table *new_dd_tab);
353 
354  /** Prepare to commit or roll back ALTER TABLE...ALGORITHM=INPLACE.
355  This is for 'ALTER TABLE ... PARTITION' and a corresponding function
356  to commit_inplace_alter_table().
357  @param[in,out] altered_table TABLE object for new version of table.
358  @param[in,out] ha_alter_info ALGORITHM=INPLACE metadata
359  @param[in] commit true=Commit, false=Rollback.
360  @param[in] old_dd_tab old table
361  @param[in,out] new_dd_tab new table
362  @retval true on failure (my_error() will have been called)
363  @retval false on success */
364  bool commit_inplace_alter_partition(TABLE *altered_table,
365  Alter_inplace_info *ha_alter_info,
366  bool commit, const dd::Table *old_dd_tab,
367  dd::Table *new_dd_tab);
368 
369  // TODO: should we implement init_table_handle_for_HANDLER() ?
370  // (or is sql_stat_start handled correctly anyway?)
371  int optimize(THD *thd, HA_CHECK_OPT *check_opt) override;
372 
373  /** Set DD discard attribute for tablespace.
374  @param[in] table_def dd table
375  @param[in] discard True if this table is discarded
376  @return 0 or error number. */
377  int set_dd_discard_attribute(dd::Table *table_def, bool discard);
378 
379  int discard_or_import_tablespace(bool discard, dd::Table *table_def) override;
380 
381  /** Compare key and rowid.
382  Helper function for sorting records in the priority queue.
383  a/b points to table->record[0] rows which must have the
384  key fields set. The bytes before a and b store the rowid.
385  This is used for comparing/sorting rows first according to
386  KEY and if same KEY, by rowid (ref).
387 
388  @param[in] key_info Null terminated array of index
389  information.
390  @param[in] a Pointer to record+ref in first record.
391  @param[in] b Pointer to record+ref in second record.
392  @return Return value is SIGN(first_rec - second_rec)
393  @retval 0 Keys are equal.
394  @retval -1 second_rec is greater than first_rec.
395  @retval +1 first_rec is greater than second_rec. */
396  static int key_and_rowid_cmp(KEY **key_info, uchar *a, uchar *b);
397 
398  int extra(enum ha_extra_function operation) override;
399 
400  void print_error(int error, myf errflag) override;
401 
402  bool is_ignorable_error(int error) override;
403 
404  int start_stmt(THD *thd, thr_lock_type lock_type) override;
405 
406  ha_rows records_in_range(uint inx, key_range *min_key,
407  key_range *max_key) override;
408 
409  ha_rows estimate_rows_upper_bound() override;
410 
411  uint alter_table_flags(uint flags);
412 
413  void update_create_info(HA_CREATE_INFO *create_info) override;
414 
415  int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info,
416  dd::Table *table_def) override;
417 
418  /** Drop a table.
419  @param[in] name table name
420  @param[in,out] dd_table data dictionary table
421  @return error number
422  @retval 0 on success */
423  int delete_table(const char *name, const dd::Table *dd_table) override;
424 
425  /** Rename a table.
426  @param[in] from table name before rename
427  @param[in] to table name after rename
428  @param[in] from_table data dictionary table before rename
429  @param[in,out] to_table data dictionary table after rename
430  @return error number
431  @retval 0 on success */
432  int rename_table(const char *from, const char *to,
433  const dd::Table *from_table, dd::Table *to_table) override;
434 
435  int check(THD *thd, HA_CHECK_OPT *check_opt) override;
436 
437  /** Repair table.
438  Will only handle records in wrong partition, not repairing
439  corrupt innodb indexes.
440  @param[in] thd Thread context.
441  @param[in] repair_opt Repair options.
442  @return 0 or error code. */
443  int repair(THD *thd, HA_CHECK_OPT *repair_opt) override;
444 
445  void get_auto_increment(ulonglong offset, ulonglong increment,
446  ulonglong nb_desired_values, ulonglong *first_value,
447  ulonglong *nb_reserved_values) override;
448 
449  /* Get partition row type
450  @param[in] partition_table partition table
451  @param[in] part_id Id of partition for which row type to be retrieved
452  @return Partition row type. */
453  enum row_type get_partition_row_type(const dd::Table *partition_table,
454  uint part_id) override;
455 
456  int cmp_ref(const uchar *ref1, const uchar *ref2) const override;
457 
458  int read_range_first(const key_range *start_key, const key_range *end_key,
459  bool eq_range_arg, bool sorted) override {
460  return (Partition_helper::ph_read_range_first(start_key, end_key,
461  eq_range_arg, sorted));
462  }
463 
464  void position(const uchar *record) override {
466  }
467 
468  /* TODO: Implement these! */
470  uint table_changes) override {
471  ut_ad(0);
472  return (COMPATIBLE_DATA_NO);
473  }
474 
475  int delete_all_rows() override { return (handler::delete_all_rows()); }
476 
477  int disable_indexes(uint mode) override { return (HA_ERR_WRONG_COMMAND); }
478 
479  int enable_indexes(uint mode) override { return (HA_ERR_WRONG_COMMAND); }
480 
481  int ft_init() override {
482  ut_ad(0);
483  return (HA_ERR_WRONG_COMMAND);
484  }
485 
486  FT_INFO *ft_init_ext(uint flags, uint inx, String *key) override {
487  ut_ad(0);
488  return (nullptr);
489  }
490 
492  Ft_hints *hints) override {
493  ut_ad(0);
494  return (nullptr);
495  }
496 
497  int ft_read(uchar *buf) override {
498  ut_ad(0);
499  return (HA_ERR_WRONG_COMMAND);
500  }
501 
502  bool get_foreign_dup_key(char *child_table_name, uint child_table_name_len,
503  char *child_key_name,
504  uint child_key_name_len) override {
505  ut_ad(0);
506  return (false);
507  }
508 
509  int read_range_next() override {
511  }
512 
513  uint32 calculate_key_hash_value(Field **field_array) override {
514  return (Partition_helper::ph_calculate_key_hash_value(field_array));
515  }
516 
517  Table_flags table_flags() const override {
519  }
520 
521  void release_auto_increment() override {
523  }
524 
525  /** Implementing Partition_handler interface @see partition_handler.h
526  @{ */
527 
528  /** See Partition_handler. */
530  ha_checksum *check_sum,
531  uint part_id) override {
533  part_id);
534  }
535 
536  uint alter_flags(uint flags MY_ATTRIBUTE((unused))) const override {
538  }
539 
541  return (static_cast<Partition_handler *>(this));
542  }
543 
544  void set_part_info(partition_info *part_info, bool early) override {
545  Partition_helper::set_part_info_low(part_info, early);
546  }
547 
548  void initialize_partitioning(partition_info *part_info, bool early) {
549  Partition_helper::set_part_info_low(part_info, early);
550  }
551 
552  handler *get_handler() override { return (static_cast<handler *>(this)); }
553  /** @} */
554 
555  /** Get number of threads that would be spawned for parallel read.
556  @param[out] scan_ctx a scan context created by this method that is
557  used in parallel_scan
558  @param[out] num_threads number of threads to be spawned
559  @return error code
560  @return 0 on success */
561  int parallel_scan_init(void *&scan_ctx, size_t &num_threads) override;
562 
564 
565  /** Start parallel read of data.
566  @param[in] scan_ctx Scan context created by parallel_scan_init
567  @param[in] thread_ctxs context for each of the spawned threads
568  @param[in] init_fn callback called by each parallel load
569  thread at the beginning of the parallel load.
570  @param[in] load_fn callback called by each parallel load
571  thread when processing of rows is required.
572  @param[in] end_fn callback called by each parallel load
573  thread when processing of rows has ended.
574  @return error code
575  @return 0 on success */
576  int parallel_scan(void *scan_ctx, void **thread_ctxs, Reader::Init_fn init_fn,
577  Reader::Load_fn load_fn, Reader::End_fn end_fn) override;
578  /** Run the parallel read of data.
579  @param[in] parallel_scan_ctx a scan context created by
580  parallel_scan_init
581  */
582  void parallel_scan_end(void *parallel_scan_ctx) override;
583 
584  private:
585  /** Pointer to Ha_innopart_share on the TABLE_SHARE. */
587 
588  /** ins_node per partition. Synchronized with prebuilt->ins_node
589  when changing partitions. */
591 
592  /** upd_node per partition. Synchronized with prebuilt->upd_node
593  when changing partitions. */
595 
596  /** blob_heap per partition. Synchronized with prebuilt->blob_heap
597  when changing partitions. */
599 
600  /** trx_id from the partitions table->def_trx_id. Keep in sync
601  with prebuilt->trx_id when changing partitions.
602  prebuilt only reflects the current partition! */
604 
605  /** row_read_type per partition. */
607 
608  /** byte array for sql_stat_start bitset */
610 
611  /** sql_stat_start per partition. */
613 
614  /** persistent cursors per partition. */
616 
617  /** persistent cluster cursors per partition. */
619 
620  /** map from part_id to offset in above two arrays. */
621  uint16_t *m_pcur_map;
622 
623  /** Original m_prebuilt->pcur. */
625 
626  /** Original m_prebuilt->clust_pcur. */
628 
629  /** New partitions during ADD/REORG/... PARTITION. */
631 
632  /** Clear used ins_nodes and upd_nodes. */
633  void clear_ins_upd_nodes();
634 
635  /** Clear the blob heaps for all partitions */
636  void clear_blob_heaps();
637 
638  /** Reset state of file to after 'open'. This function is called
639  after every statement for all tables used by that statement. */
640  int reset() override;
641 
642  /** Allocate the array to hold blob heaps for all partitions */
643  mem_heap_t **alloc_blob_heap_array();
644 
645  /** Free the array that holds blob heaps for all partitions */
646  void free_blob_heap_array();
647 
648  /** Changes the active index of a handle.
649  @param[in] part_id Use this partition.
650  @param[in] keynr Use this index; MAX_KEY means always
651  clustered index, even if it was internally generated by InnoDB.
652  @return 0 or error code. */
653  int change_active_index(uint part_id, uint keynr);
654 
655  /** Move to next partition and set its index.
656  @return 0 for success else error number. */
657  int next_partition_index();
658 
659  /** Internally called for initializing auto increment value.
660  Should never be called, but defined to catch such errors.
661  @return 0 on success else error code. */
662  int innobase_initialize_autoinc();
663 
664  /** Get the index for the current partition
665  @param[in] keynr MySQL index number.
666  @return InnoDB index or NULL. */
667  dict_index_t *innobase_get_index(uint keynr) override;
668 
669  /** Get the index for a handle.
670  Does not change active index.
671  @param[in] keynr use this index; MAX_KEY means always clustered
672  index, even if it was internally generated by InnoDB.
673  @param[in] part_id From this partition.
674  @return NULL or index instance. */
675  dict_index_t *innopart_get_index(uint part_id, uint keynr);
676 
677  /** Change active partition.
678  Copies needed info into m_prebuilt from the partition specific memory.
679  @param[in] part_id Partition to set as active. */
680  void set_partition(uint part_id);
681 
682  /** Update active partition.
683  Copies needed info from m_prebuilt into the partition specific memory.
684  @param[in] part_id Partition to set as active. */
685  void update_partition(uint part_id);
686 
687  /** TRUNCATE an InnoDB partitioned table.
688  @param[in] name table name
689  @param[in] form table definition
690  @param[in,out] table_def dd::Table describing table to be
691  truncated. Can be adjusted by SE, the changes will be saved into
692  the data-dictionary at statement commit time.
693  @return error number
694  @retval 0 on success */
695  int truncate_impl(const char *name, TABLE *form, dd::Table *table_def);
696 
697  /** Helpers needed by Partition_helper, @see partition_handler.h @{ */
698 
699  /** Set the autoinc column max value.
700  This should only be called once from ha_innobase::open().
701  Therefore there's no need for a covering lock.
702  @param[in] no_lock If locking should be skipped. Not used!
703  @return 0 on success else error code. */
704  int initialize_auto_increment(bool no_lock MY_ATTRIBUTE((unused))) override;
705 
706  /** Save currently highest auto increment value.
707  @param[in] nr Auto increment value to save. */
708  void save_auto_increment(ulonglong nr) override;
709 
710  /** Setup the ordered record buffer and the priority queue.
711  @param[in] used_parts Number of used partitions in query.
712  @return false for success, else true. */
713  int init_record_priority_queue_for_parts(uint used_parts) override;
714 
715  /** Destroy the ordered record buffer and the priority queue. */
716  void destroy_record_priority_queue_for_parts() override;
717 
718  /** Create the Altered_partitoins object
719  @param[in] ha_alter_info thd DDL operation
720  @retval true On failure
721  @retval false On success */
722  bool prepare_for_copy_partitions(Alter_inplace_info *ha_alter_info);
723 
724  /** write row to new partition.
725  @param[in] new_part New partition to write to.
726  @return 0 for success else error code. */
727  int write_row_in_new_part(uint new_part) override;
728 
729  /** Write a row in specific partition.
730  Stores a row in an InnoDB database, to the table specified in this
731  handle.
732  @param[in] part_id Partition to write to.
733  @param[in] record A row in MySQL format.
734  @return error code. */
735  int write_row_in_part(uint part_id, uchar *record) override;
736 
737  /** Update a row in partition.
738  Updates a row given as a parameter to a new value.
739  @param[in] part_id Partition to update row in.
740  @param[in] old_row Old row in MySQL format.
741  @param[in] new_row New row in MySQL format.
742  @return error number or 0. */
743  int update_row_in_part(uint part_id, const uchar *old_row,
744  uchar *new_row) override;
745 
746  /** Deletes a row in partition.
747  @param[in] part_id Partition to delete from.
748  @param[in] record Row to delete in MySQL format.
749  @return error number or 0. */
750  int delete_row_in_part(uint part_id, const uchar *record) override;
751 
752  /** Return first record in index from a partition.
753  @param[in] part Partition to read from.
754  @param[out] record First record in index in the partition.
755  @return error number or 0. */
756  int index_first_in_part(uint part, uchar *record) override;
757 
758  /** Return last record in index from a partition.
759  @param[in] part Partition to read from.
760  @param[out] record Last record in index in the partition.
761  @return error number or 0. */
762  int index_last_in_part(uint part, uchar *record) override;
763 
764  /** Return previous record in index from a partition.
765  @param[in] part Partition to read from.
766  @param[out] record Last record in index in the partition.
767  @return error number or 0. */
768  int index_prev_in_part(uint part, uchar *record) override;
769 
770  /** Return next record in index from a partition.
771  @param[in] part Partition to read from.
772  @param[out] record Last record in index in the partition.
773  @return error number or 0. */
774  int index_next_in_part(uint part, uchar *record) override;
775 
776  /** Return next same record in index from a partition.
777  This routine is used to read the next record, but only if the key is
778  the same as supplied in the call.
779  @param[in] part Partition to read from.
780  @param[out] record Last record in index in the partition.
781  @param[in] key Key to match.
782  @param[in] length Length of key.
783  @return error number or 0. */
784  int index_next_same_in_part(uint part, uchar *record, const uchar *key,
785  uint length) override;
786 
787  /** Start index scan and return first record from a partition.
788  This routine starts an index scan using a start key. The calling
789  function will check the end key on its own.
790  @param[in] part Partition to read from.
791  @param[out] record First matching record in index in the partition.
792  @param[in] key Key to match.
793  @param[in] keypart_map Which part of the key to use.
794  @param[in] find_flag Key condition/direction to use.
795  @return error number or 0. */
796  int index_read_map_in_part(uint part, uchar *record, const uchar *key,
797  key_part_map keypart_map,
798  enum ha_rkey_function find_flag) override;
799 
800  /** Return last matching record in index from a partition.
801  @param[in] part Partition to read from.
802  @param[out] record Last matching record in index in the partition.
803  @param[in] key Key to match.
804  @param[in] keypart_map Which part of the key to use.
805  @return error number or 0. */
806  int index_read_last_map_in_part(uint part, uchar *record, const uchar *key,
807  key_part_map keypart_map) override;
808 
809  /** Start index scan and return first record from a partition.
810  This routine starts an index scan using a start and end key.
811  @param[in] part Partition to read from.
812  @param[out] record First matching record in index in the partition.
813  if NULL use table->record[0] as return buffer.
814  @param[in] start_key Start key to match.
815  @param[in] end_key End key to match.
816  @param[in] sorted Return rows in sorted order.
817  @return error number or 0. */
818  int read_range_first_in_part(uint part, uchar *record,
819  const key_range *start_key,
820  const key_range *end_key, bool sorted) override;
821 
822  /** Return next record in index range scan from a partition.
823  @param[in] part Partition to read from.
824  @param[out] record First matching record in index in the partition.
825  if NULL use table->record[0] as return buffer.
826  @return error number or 0. */
827  int read_range_next_in_part(uint part, uchar *record) override;
828 
829  /** Start index scan and return first record from a partition.
830  This routine starts an index scan using a start key. The calling
831  function will check the end key on its own.
832  @param[in] part Partition to read from.
833  @param[out] record First matching record in index in the partition.
834  @param[in] index Index to read from.
835  @param[in] key Key to match.
836  @param[in] keypart_map Which part of the key to use.
837  @param[in] find_flag Key condition/direction to use.
838  @return error number or 0. */
839  int index_read_idx_map_in_part(uint part, uchar *record, uint index,
840  const uchar *key, key_part_map keypart_map,
841  enum ha_rkey_function find_flag) override;
842 
843  /** Initialize sampling.
844  @param[out] scan_ctx A scan context created by this method that has to be
845  used in sample_next
846  @param[in] sampling_percentage percentage of records that need to be
847  sampled
848  @param[in] sampling_seed random seed that the random generator will
849  use
850  @param[in] sampling_method sampling method to be used; currently only
851  SYSTEM sampling is supported
852  @return 0 for success, else one of the HA_xxx values in case of error. */
853  int sample_init(void *&scan_ctx, double sampling_percentage,
854  int sampling_seed,
855  enum_sampling_method sampling_method) override;
856 
857  /** Get the next record for sampling.
858  @param[in] scan_ctx Scan context of the sampling
859  @param[in] buf buffer to place the read record
860  @return 0 for success, else one of the HA_xxx values in case of error. */
861  int sample_next(void *scan_ctx, uchar *buf) override;
862 
863  /** End sampling.
864  @param[in] scan_ctx Scan context of the sampling
865  @return 0 for success, else one of the HA_xxx values in case of error. */
866  int sample_end(void *scan_ctx) override;
867 
868  /** Initialize random read/scan of a specific partition.
869  @param[in] part_id Partition to initialize.
870  @param[in] scan True for scan else random access.
871  @return error number or 0. */
872  int rnd_init_in_part(uint part_id, bool scan) override;
873 
874  /** Get next row during scan of a specific partition.
875  @param[in] part_id Partition to read from.
876  @param[out] buf Next row.
877  @return error number or 0. */
878  int rnd_next_in_part(uint part_id, uchar *buf) override;
879 
880  /** End random read/scan of a specific partition.
881  @param[in] part_id Partition to end random read/scan.
882  @param[in] scan True for scan else random access.
883  @return error number or 0. */
884  int rnd_end_in_part(uint part_id, bool scan) override;
885 
886  /** Get a reference to the current cursor position in the last used
887  partition.
888  @param[out] ref_arg Reference (PK if exists else row_id).
889  @param[in] record Record to position. */
890  void position_in_last_part(uchar *ref_arg, const uchar *record) override;
891 
892  /** Read row using position using given record to find.
893  Only useful when position is based on primary key
894  @param[in] record Current record in MySQL Row Format.
895  @return error number or 0. */
896  int rnd_pos_by_record(uchar *record) override;
897 
898  /** Copy a cached MySQL record.
899  @param[out] buf Where to copy the MySQL record.
900  @param[in] cached_row Which record to copy. */
901  void copy_cached_row(uchar *buf, const uchar *cached_row) override;
902  /** @} */
903 
904  /* Private handler:: functions specific for native InnoDB partitioning.
905  @see handler.h @{ */
906 
907  /** Open an InnoDB table.
908  @param[in] name table name
909  @param[in] mode access mode
910  @param[in] test_if_locked test if the file to be opened is locked
911  @param[in] table_def dd::Table describing table to be opened
912  @retval 1 if error
913  @retval 0 if success */
914  int open(const char *name, int mode, uint test_if_locked,
915  const dd::Table *table_def) override;
916 
917  int close() override;
918 
919  double scan_time() override;
920 
921  /** Was the last returned row semi consistent read.
922  In an UPDATE or DELETE, if the row under the cursor was locked by
923  another transaction, and the engine used an optimistic read of the last
924  committed row value under the cursor, then the engine returns 1 from
925  this function. MySQL must NOT try to update this optimistic value. If
926  the optimistic value does not match the WHERE condition, MySQL can
927  decide to skip over this row. This can be used to avoid unnecessary
928  lock waits.
929 
930  If this method returns true, it will also signal the storage
931  engine that the next read will be a locking re-read of the row.
932  @see handler.h and row0mysql.h
933  @return true if last read was semi consistent else false. */
934  bool was_semi_consistent_read() override;
935 
936  /** Try semi consistent read.
937  Tell the engine whether it should avoid unnecessary lock waits.
938  If yes, in an UPDATE or DELETE, if the row under the cursor was locked
939  by another transaction, the engine may try an optimistic read of
940  the last committed row value under the cursor.
941  @see handler.h and row0mysql.h
942  @param[in] yes Should semi-consistent read be used. */
943  void try_semi_consistent_read(bool yes) override;
944 
945  /** Removes a lock on a row.
946  Removes a new lock set on a row, if it was not read optimistically.
947  This can be called after a row has been read in the processing of
948  an UPDATE or a DELETE query. @see ha_innobase::unlock_row(). */
949  void unlock_row() override;
950 
951  int index_init(uint index, bool sorted) override;
952 
953  int index_end() override;
954 
955  int rnd_init(bool scan) override {
956  return (Partition_helper::ph_rnd_init(scan));
957  }
958 
959  int rnd_end() override { return (Partition_helper::ph_rnd_end()); }
960 
961  int external_lock(THD *thd, int lock_type) override;
962 
963  THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
964  thr_lock_type lock_type) override;
965 
966  int write_row(uchar *record) override {
967  bool entered = false;
968  auto trx = m_prebuilt->trx;
969 
970  /* Enter innodb to order Auto INC partition lock after Innodb. No need to
971  enter if there are tickets left. Currently we cannot handle re-enter
972  without exit if no more tickets left.
973 
974  1. We avoid consuming the last ticket as there could be another enter
975  call from innobase.
976 
977  2. If we enter innodb here, there is at least one more ticket left as
978  the minimum value for "innodb_concurrency_tickets" is 1 */
979 
980  if (!trx->declared_to_be_inside_innodb) {
981  auto err = srv_concurrency_enter();
982  if (err != 0) {
983  return (err);
984  }
985  entered = true;
986  }
987 
988  auto err = Partition_helper::ph_write_row(record);
989 
990  if (entered) {
991  srv_concurrency_exit();
992  }
993 
994  return (err);
995  }
996 
997  int update_row(const uchar *old_record, uchar *new_record) override {
998  return (Partition_helper::ph_update_row(old_record, new_record));
999  }
1000 
1001  int delete_row(const uchar *record) override {
1002  return (Partition_helper::ph_delete_row(record));
1003  }
1004  /** @} */
1005 
1006  /** Truncate partition.
1007  Called from Partition_handler::trunctate_partition() or truncate().
1008  @param[in,out] dd_table data dictionary table
1009  @retval error number
1010  @retval 0 on success */
1011  int truncate_partition_low(dd::Table *dd_table) override;
1012 
1013  /** Exchange partition.
1014  Low-level primitive which implementation is provided here.
1015  @param[in] part_id The id of the partition to
1016  be exchanged
1017  @param[in,out] part_table partitioned table to be
1018  exchanged
1019  @param[in,out] swap_table table to be exchanged
1020  @return error number
1021  @retval 0 on success */
1022  int exchange_partition_low(uint part_id, dd::Table *part_table,
1023  dd::Table *swap_table) override;
1024 
1025  /** Access methods to protected areas in handler to avoid adding
1026  friend class Partition_helper in class handler.
1027  @see partition_handler.h @{ */
1028 
1029  THD *get_thd() const override { return ha_thd(); }
1030 
1031  TABLE *get_table() const override { return table; }
1032 
1033  bool get_eq_range() const override { return eq_range; }
1034 
1035  void set_eq_range(bool eq_range_arg) override { eq_range = eq_range_arg; }
1036 
1037  void set_range_key_part(KEY_PART_INFO *key_part) override {
1038  range_key_part = key_part;
1039  }
1040  /** @} */
1041 
1042  /** Fill in data_dir_path and tablespace name from internal data
1043  dictionary.
1044  @param[in,out] part_elem Partition element to fill.
1045  @param[in] ib_table InnoDB table to copy from.
1046  @param[in] display_tablespace Display tablespace name if
1047  set. */
1048  void update_part_elem(partition_element *part_elem, dict_table_t *ib_table,
1049  bool display_tablespace);
1050 
1051  protected:
1052  /* Protected handler:: functions specific for native InnoDB partitioning.
1053  @see handler.h @{ */
1054 
1055  int rnd_next(uchar *record) override {
1056  return (Partition_helper::ph_rnd_next(record));
1057  }
1058 
1059  int rnd_pos(uchar *record, uchar *pos) override;
1060 
1061  int records(ha_rows *num_rows) override;
1062 
1063  int records_from_index(ha_rows *num_rows, uint) override {
1064  /* Force use of cluster index until we implement sec index parallel scan. */
1065  return ha_innopart::records(num_rows);
1066  }
1067 
1068  int index_next(uchar *record) override {
1069  return (Partition_helper::ph_index_next(record));
1070  }
1071 
1072  int index_next_same(uchar *record, const uchar *, uint keylen) override {
1073  return (Partition_helper::ph_index_next_same(record, keylen));
1074  }
1075 
1076  int index_prev(uchar *record) override {
1077  return (Partition_helper::ph_index_prev(record));
1078  }
1079 
1080  int index_first(uchar *record) override {
1081  return (Partition_helper::ph_index_first(record));
1082  }
1083 
1084  int index_last(uchar *record) override {
1085  return (Partition_helper::ph_index_last(record));
1086  }
1087 
1088  int index_read_last_map(uchar *record, const uchar *key,
1089  key_part_map keypart_map) override {
1090  return (Partition_helper::ph_index_read_last_map(record, key, keypart_map));
1091  }
1092 
1093  int index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map,
1094  enum ha_rkey_function find_flag) override {
1095  return (
1096  Partition_helper::ph_index_read_map(buf, key, keypart_map, find_flag));
1097  }
1098 
1099  int index_read_idx_map(uchar *buf, uint index, const uchar *key,
1100  key_part_map keypart_map,
1101  enum ha_rkey_function find_flag) override {
1102  return (Partition_helper::ph_index_read_idx_map(buf, index, key,
1103  keypart_map, find_flag));
1104  }
1105  /** @} */
1106 
1107  /** Updates and return statistics.
1108  Returns statistics information of the table to the MySQL interpreter,
1109  in various fields of the handle object.
1110  @param[in] flag Flags for what to update and return.
1111  @param[in] is_analyze True if called from "::analyze()".
1112  @return HA_ERR_* error code or 0. */
1113  int info_low(uint flag, bool is_analyze) override;
1114 };
1115 #endif /* ha_innopart_h */
bool get_foreign_dup_key(char *child_table_name, uint child_table_name_len, char *child_key_name, uint child_key_name_len) override
Retrieves the names of the table and the key for which there was a duplicate entry in the case of HA_...
Definition: ha_innopart.h:502
Table_flags table_flags() const override
Get the table flags to use for the statement.
Definition: ha_innopart.h:517
uint16_t * m_pcur_map
map from part_id to offset in above two arrays.
Definition: ha_innopart.h:621
byte * m_bitset
byte array for sql_stat_start bitset
Definition: ha_innopart.h:609
Wrapper for struct ft_hints.
Definition: handler.h:3575
unsigned long long int ulonglong
Definition: my_inttypes.h:55
uint m_tot_parts
Total number of partitions.
Definition: ha_innopart.h:70
Partition specific Handler_share.
Definition: partition_handler.h:102
Definition: partition_info.h:208
Definition: thr_lock.h:123
Class for partitioning specific operations.
Definition: partition_handler.h:192
unsigned char uchar
Definition: my_inttypes.h:51
Definition: partition.h:50
static void save_auto_increment(TABLE *table, ulonglong *value)
Definition: ha_archive.cc:270
ins_node_t ** m_ins_node_parts
ins_node per partition.
Definition: ha_innopart.h:590
#define HA_INPLACE_CHANGE_PARTITION
Definition: partition_handler.h:75
const TABLE_SHARE * get_table_share() const
Definition: ha_innopart.h:159
int rnd_end() override
Ends a table scan.
Definition: ha_innopart.h:959
int ph_rnd_end()
End of a table scan.
Definition: partition_handler.cc:1539
Definition: handler.h:3228
virtual int delete_all_rows()
Delete all rows in a table.
Definition: handler.h:6289
int ft_read(uchar *buf) override
Fetch next result from the FT result set.
Definition: ha_innopart.h:497
bool get_eq_range() const override
Definition: ha_innopart.h:1033
uint m_index_count
Number of indexes.
Definition: ha_innopart.h:73
Definition: mi_test3.cc:54
static bool commit(THD *thd)
Commit the current statement and transaction.
Definition: sql_cmd_srs.cc:151
void set_table_part(uint part_id, dict_table_t *table)
Set innodb table for given partition.
Definition: ha_innopart.h:89
This structure is shared between different table objects.
Definition: table.h:658
int records(ha_rows *num_rows) override
Total number of rows in all used partitions.
Definition: ha_innopart.cc:3175
uint32 calculate_key_hash_value(Field **field_array) override
Definition: ha_innopart.h:513
ulong key_part_map
Definition: my_base.h:1003
#define HA_DUPLICATE_POS
Definition: handler.h:248
void release_auto_increment() override
Do cleanup for auto increment calculation.
Definition: ha_innopart.h:521
void initialize_partitioning(partition_info *part_info, bool early)
Definition: ha_innopart.h:548
ulint * m_row_read_type_parts
row_read_type per partition.
Definition: ha_innopart.h:606
#define HA_ERR_WRONG_COMMAND
Command not supported.
Definition: my_base.h:838
btr_pcur_t * m_pcur
Original m_prebuilt->pcur.
Definition: ha_innopart.h:624
TABLE_SHARE * m_table_share
Pointer back to owning TABLE_SHARE.
Definition: ha_innopart.h:79
Definition: field.h:694
Altered_partitions * m_new_partitions
New partitions during ADD/REORG/...
Definition: ha_innopart.h:630
int ph_index_next(uchar *buf)
Read next record in a forward index scan.
Definition: partition_handler.cc:2153
dict_table_t ** m_table_parts
Array of all included table definitions (one per partition).
Definition: ha_innopart.h:63
void position(const uchar *record) override
Store a reference to the current row to &#39;ref&#39; field of the handle.
Definition: ha_innopart.h:464
static uint32 ph_calculate_key_hash_value(Field **field_array)
Calculate key hash value from an null terminated array of fields.
Definition: partition_handler.cc:854
Ha_innopart_share * m_part_share
Pointer to Ha_innopart_share on the TABLE_SHARE.
Definition: ha_innopart.h:586
int index_prev(uchar *record) override
Reads the previous row from a cursor, which must have previously been positioned using index_read...
Definition: ha_innopart.h:1076
mode
Definition: file_handle.h:58
void close_table_parts()
Close the table partitions.
Definition: ha_innopart.cc:449
Definition: partition_element.h:107
int disable_indexes(uint mode) override
Disable indexes.
Definition: ha_innopart.h:477
#define HA_CAN_GEOMETRY
Definition: handler.h:225
int ph_index_first(uchar *buf)
Start an index scan from leftmost record and return first record.
Definition: partition_handler.cc:1985
Data structure for a database table.
Definition: dict0mem.h:1524
int ph_index_prev(uchar *buf)
Read next record when performing index scan backwards.
Definition: partition_handler.cc:2207
Helper class for encapsulating new/altered partitions during ADD(HASH/KEY)/COALESCE/REORGANIZE PARTIT...
Definition: handler0alter.cc:7815
handler * get_handler() override
Return the table handler.
Definition: ha_innopart.h:552
Definition: row0ins.h:168
int ph_update_row(const uchar *old_data, uchar *new_data)
Update an existing row in the partitioned table.
Definition: partition_handler.cc:571
FT_INFO * ft_init_ext_with_hints(uint inx, String *key, Ft_hints *hints) override
Initialize FT index scan.
Definition: ha_innopart.h:491
int ph_index_read_idx_map(uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag)
Read index by key and keymap.
Definition: partition_handler.cc:2092
static dict_table_t ** open_table_parts(THD *thd, const TABLE *table, const dd::Table *dd_table, partition_info *part_info, const char *table_name)
Open InnoDB tables for partitions and return them as array.
Definition: ha_innopart.cc:257
int ph_index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag)
Read one record in an index scan and start an index scan.
Definition: partition_handler.cc:1880
ha_rkey_function
Definition: my_base.h:77
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4023
btr_pcur_t * m_pcur_parts
persistent cursors per partition.
Definition: ha_innopart.h:615
#define close(s)
Definition: win32.h:103
uint32 ha_checksum
Definition: my_sys.h:539
handler::Load_end_cbk End_fn
Definition: row0pread-adapter.h:52
dict_index_t * get_index(uint part_id, uint keynr)
Return innodb index for given partition and key number.
Definition: ha_innopart.cc:496
Sql_stat_start_parts m_sql_stat_start_parts
sql_stat_start per partition.
Definition: ha_innopart.h:612
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:164
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:347
void print_error(const char *fmt,...)
Definition: btr0pcur.h:177
static ORDER * clone(THD *thd, ORDER *order)
Shallow clone the list of ORDER objects using mem_root and return the cloned list.
Definition: window.cc:76
Definition: table.h:1313
Table_flags table_flags() const override
Get the table flags to use for the statement.
Definition: ha_innodb.cc:5828
~Ha_innopart_share()
Definition: ha_innopart.cc:95
upd_node_t ** m_upd_node_parts
upd_node per partition.
Definition: ha_innopart.h:594
virtual void set_part_info_low(partition_info *part_info, bool early)
Set partition info.
Definition: partition_handler.cc:382
int ph_index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map)
Read last using key.
Definition: partition_handler.cc:2060
#define HA_READ_BEFORE_WRITE_REMOVAL
The handler supports read before write removal optimization.
Definition: handler.h:408
handler::Load_cbk Load_fn
Definition: row0pread-adapter.h:50
InnoDB partition specific Handler_share.
Definition: ha_innopart.h:60
#define HA_CAN_FULLTEXT
Definition: handler.h:302
btr_pcur_t * m_clust_pcur
Original m_prebuilt->clust_pcur.
Definition: ha_innopart.h:627
Ha_innopart_share()
Disable default constructor.
Definition: ha_innopart.h:177
char * pos
Definition: do_ctype.cc:76
thr_lock_type
Definition: thr_lock.h:50
Interface between Innobase row operations and MySQL.
dict_table_t ** get_table_part_ref(uint part_id)
Get table reference for given partition.
Definition: ha_innopart.h:97
int delete_all_rows() override
Delete all rows from the table.
Definition: ha_innopart.h:475
Definition: key.h:55
void set_range_key_part(KEY_PART_INFO *key_part) override
Definition: ha_innopart.h:1037
Definition: dictionary_client.h:145
enum_alter_inplace_result
Return values for check_if_supported_inplace_alter().
Definition: handler.h:194
void set_part_info(partition_info *part_info, bool early) override
Set the partition info object to be used by the handler.
Definition: ha_innopart.h:544
#define HA_CAN_REPAIR
Definition: handler.h:366
Partition_handler * get_partition_handler() override
Definition: ha_innopart.h:540
dberr_t create() noexcept
Create the dblwr data structures in the system tablespace.
Definition: buf0dblwr.cc:1835
Header for compiler-dependent features.
unsigned int uint
Definition: uca-dump.cc:29
handler::Load_init_cbk Init_fn
Definition: row0pread-adapter.h:54
int ph_read_range_next()
Read next record in read of a range with start and end key.
Definition: partition_handler.cc:2270
case opt name
Definition: sslopt-case.h:32
dict_index_t ** m_index_mapping
Instead of INNOBASE_SHARE::idx_trans_tbl.
Definition: ha_innopart.h:67
int index_read_last_map(uchar *record, const uchar *key, key_part_map keypart_map) override
The following functions works like index_read, but it find the last row with the current key value or...
Definition: ha_innopart.h:1088
int ph_read_range_first(const key_range *start_key, const key_range *end_key, bool eq_range_arg, bool sorted)
Start a read of one range with start and end key.
Definition: partition_handler.cc:2234
The class defining a handle to an InnoDB table.
Definition: ha_innodb.h:79
uint32_t uint32
Definition: my_inttypes.h:66
TABLE * get_table() const override
Definition: ha_innopart.h:1031
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:908
int enable_indexes(uint mode) override
Enable indexes.
Definition: ha_innopart.h:479
Class describing changes to be done by ALTER TABLE.
Definition: handler.h:2795
int index_last(uchar *record) override
Positions a cursor on the last record in an index and reads the corresponding row to buf...
Definition: ha_innopart.h:1084
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2293
Bitset Sql_stat_start_parts
Definition: ha_innopart.h:57
void get_dynamic_partition_info(ha_statistics *stat_info, ha_checksum *check_sum, uint part_id) override
Implementing Partition_handler interface.
Definition: ha_innopart.h:529
bool has_table_parts() const
Return whether share has opened InnoDB tables for partitions.
Definition: ha_innopart.h:123
int index_first(uchar *record) override
Positions a cursor on the first record in an index and reads the corresponding row to buf...
Definition: ha_innopart.h:1080
int index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) override
Positions an index cursor to the index specified in the handle (&#39;active_index&#39;).
Definition: ha_innopart.h:1093
int ft_init() override
Initialize FT index scan.
Definition: ha_innopart.h:481
uint alter_flags(uint flags) const override
Alter flags.
Definition: ha_innopart.h:536
std::string HARNESS_EXPORT reset()
get &#39;reset attributes&#39; ESC sequence.
Definition: vt100.cc:36
void ph_release_auto_increment()
Release unused auto increment values.
Definition: partition_handler.cc:819
Definition: my_base.h:1119
static const char * key
Definition: suite_stubs.c:14
dict_table_t * get_table_part(uint part_id) const
Return innodb table for given partition.
Definition: ha_innopart.h:104
static MEM_ROOT mem_root
Definition: client_plugin.cc:109
trx_id_t * m_trx_id_parts
trx_id from the partitions table->def_trx_id.
Definition: ha_innopart.h:603
qep_row::extra extra
Definition: opt_explain.cc:107
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:65
A simple bitset wrapper class, whose size can be specified after the object has been defined...
Definition: ut0bitset.h:38
const char * partition_get_tablespace(const char *tablespace, const partition_element *part, const partition_element *sub_part)
Get explicit specified tablespace for one (sub)partition, checking from lowest level.
Definition: ha_innopart.cc:566
int ph_write_row(uchar *buf)
INSERT/UPDATE/DELETE functions.
Definition: partition_handler.cc:466
int ph_index_next_same(uchar *buf, uint keylen)
Read next same record.
Definition: partition_handler.cc:2185
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:144
static int flag
Definition: hp_test1.cc:39
stdx::expected< int, std::error_code > open(const char *fname, int flags, mode_t mode) noexcept
Definition: file_handle.cc:81
int index_read_idx_map(uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) override
Positions an index cursor to the index specified in argument.
Definition: ha_innopart.h:1099
Traverse an index in the leaf page block list order and send records to adapter.
Definition: row0pread-adapter.h:42
#define COMPATIBLE_DATA_NO
Definition: handler.h:798
int myf
Definition: my_inttypes.h:93
Definition: row0upd.h:672
Definition: key.h:111
const handler::Table_flags HA_INNOPART_DISABLED_TABLE_FLAGS
HA_DUPLICATE_POS and HA_READ_BEFORE_WRITE_REMOVAL is not set from ha_innobase, but cannot yet be supp...
Definition: ha_innopart.h:53
Utilities for bitset operations.
uint get_mysql_key(uint part_id, const dict_index_t *index)
Get MySQL key number corresponding to InnoDB index.
Definition: ha_innopart.cc:525
int update_row(const uchar *old_record, uchar *new_record) override
Updates a row given as a parameter to a new value.
Definition: ha_innopart.h:997
static constexpr auto PARTITION_IN_SHARED_TABLESPACE
Definition: ha_innopart.h:46
ulonglong Table_flags
Definition: handler.h:4027
uint get_num_parts() const
Get the number of partitions.
Definition: ha_innopart.h:163
int ph_index_last(uchar *buf)
Start an index scan from rightmost record and return first record.
Definition: partition_handler.cc:2008
int rnd_next(uchar *record) override
Reads the next row in a table scan (also used to read the FIRST row in a table scan).
Definition: ha_innopart.h:1055
void increment_ref_counts()
Increment share and InnoDB tables reference counters.
Definition: ha_innopart.cc:227
uint m_ref_count
Reference count.
Definition: ha_innopart.h:76
Definition: handler.h:2653
bool set_table_parts_and_indexes(const TABLE *table, partition_info *part_info, dict_table_t **table_parts)
Initialize the share with table and indexes per partition.
Definition: ha_innopart.cc:313
enum_sampling_method
Definition: handler.h:696
mem_heap_t ** m_blob_heap_parts
blob_heap per partition.
Definition: ha_innopart.h:598
void set_eq_range(bool eq_range_arg) override
Definition: ha_innopart.h:1035
The class defining a partitioning aware handle to an InnoDB table.
Definition: ha_innopart.h:214
int rnd_init(bool scan) override
Initialize a table scan.
Definition: ha_innopart.h:955
void set_v_templ(TABLE *table, dict_table_t *ib_table, const char *name)
Set up the virtual column template for partition table, and points all m_table_parts[]->vc_templ to i...
Definition: ha_innopart.cc:203
Definition: ft_global.h:71
int index_next_same(uchar *record, const uchar *, uint keylen) override
Reads the next row matching to the key value given as the parameter.
Definition: ha_innopart.h:1072
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_innopart.h:1063
static bool open_one_table_part(dd::cache::Dictionary_client *client, THD *thd, const TABLE *table, const dd::Partition *dd_part, const char *part_name, dict_table_t **part_dict_table)
Open one partition.
Definition: ha_innopart.cc:128
Log info(cout, "NOTE")
int ph_rnd_next(uchar *buf)
Read next row during full table scan (scan in random row order).
Definition: partition_handler.cc:1586
A table definition from the master.
Definition: rpl_utility.h:247
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:77
THD * get_thd() const override
Access methods to protected areas in handler to avoid adding friend class Partition_helper in class h...
Definition: ha_innopart.h:1029
bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes) override
Part of old, deprecated in-place ALTER API.
Definition: ha_innopart.h:469
static int flags[50]
Definition: hp_test1.cc:39
unsigned char byte
Blob class.
Definition: common.h:159
int write_row(uchar *record) override
Stores a row in an InnoDB database, to the table specified in this handle.
Definition: ha_innopart.h:966
int ph_delete_row(const uchar *buf)
Delete an existing row in the partitioned table.
Definition: partition_handler.cc:677
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_innopart.h:458
Definition: handler.h:3486
Definition: table.h:46
FT_INFO * ft_init_ext(uint flags, uint inx, String *key) override
Initialize FT index scan.
Definition: ha_innopart.h:486
#define HA_PARTITION_FUNCTION_SUPPORTED
bits in Partition_handler::alter_flags():
Definition: partition_handler.h:74
int delete_row(const uchar *record) override
Deletes a row given as the parameter.
Definition: ha_innopart.h:1001
Partition_helper is a helper class that implements most generic partitioning functionality such as: t...
Definition: partition_handler.h:390
int index_next(uchar *record) override
Reads the next row from a cursor, which must have previously been positioned using index_read...
Definition: ha_innopart.h:1068
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
virtual void get_dynamic_partition_info_low(ha_statistics *stat_info, ha_checksum *check_sum, uint part_id)
Functions matching Partition_handler API.
Definition: partition_handler.cc:2947
void ph_position(const uchar *record)
Save position of current row.
Definition: partition_handler.cc:1654
int ph_rnd_init(bool scan)
MODULE full table scan.
Definition: partition_handler.cc:1478
my_off_t ha_rows
Definition: my_base.h:1135
btr_pcur_t * m_clust_pcur_parts
persistent cluster cursors per partition.
Definition: ha_innopart.h:618
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:799
ha_extra_function
Definition: my_base.h:183
row_type
Definition: handler.h:666
int read_range_next() override
Read next row between two endpoints.
Definition: ha_innopart.h:509
const char * table_name
Definition: rules_table_service.cc:55
#define HA_CAN_FULLTEXT_EXT
Definition: handler.h:413
Data structure for an index.
Definition: dict0mem.h:883