MySQL  8.0.16
Source Code Documentation
partition_handler.h
Go to the documentation of this file.
1 #ifndef PARTITION_HANDLER_INCLUDED
2 #define PARTITION_HANDLER_INCLUDED
3 
4 /*
5  Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License, version 2.0,
9  as published by the Free Software Foundation.
10 
11  This program is also distributed with certain software (including
12  but not limited to OpenSSL) that is licensed under separate terms,
13  as designated in a particular file or component or in included license
14  documentation. The authors of MySQL hereby grant you an additional
15  permission to link the program and your derivative works with the
16  separately licensed software that they have included with MySQL.
17 
18  This program is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  GNU General Public License, version 2.0, for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with this program; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 */
27 
28 #include <string.h>
29 #include <sys/types.h>
30 #include <memory>
31 #include <string>
32 #include <vector>
33 
34 #include "my_base.h" // ha_rows.
35 #include "my_bitmap.h"
36 #include "my_compiler.h"
37 #include "my_dbug.h"
38 #include "my_inttypes.h"
39 #include "my_sys.h"
40 #include "mysql/psi/mysql_mutex.h"
41 #include "priority_queue.h"
42 #include "sql/handler.h" // Handler_share
43 #include "sql/key.h" // key_rec_cmp
44 #include "sql/sql_partition.h" // part_id_range
45 
46 class Field;
47 class THD;
48 class partition_info;
49 struct mysql_mutex_t;
50 template <class Key, class Value>
52 
53 namespace dd {
54 class Table;
55 } // namespace dd
56 struct TABLE;
57 struct TABLE_SHARE;
58 
59 #define PARTITION_BYTES_IN_POS 2
60 
61 struct MEM_ROOT;
62 
64 
65 /**
66  bits in Partition_handler::alter_flags():
67 
68  HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
69  supported at all.
70  HA_INPLACE_CHANGE_PARTITION means that changes to partitioning can be done
71  through in-place ALTER TABLE API but special mark-up in partition_info
72  object is required for this.
73 */
74 #define HA_PARTITION_FUNCTION_SUPPORTED (1L << 0)
75 #define HA_INPLACE_CHANGE_PARTITION (1L << 1)
76 
84 };
85 
86 /** Struct used for partition_name_hash */
87 struct PART_NAME_DEF {
90  uint32 part_id;
91  bool is_subpart;
92 };
93 
94 /**
95  Initialize partitioning (currently only PSI keys).
96 */
97 void partitioning_init();
98 
99 /**
100  Partition specific Handler_share.
101 */
103  public:
104  Partition_share();
106 
107  /** Set if auto increment is used an initialized. */
109  /**
110  Mutex protecting next_auto_inc_val.
111  Initialized if table uses auto increment.
112  */
114  /** First non reserved auto increment value. */
116  /**
117  Hash of partition names. Initialized by the first handler instance of a
118  table_share calling populate_partition_name_hash().
119  After that it is read-only, i.e. no locking required for reading.
120  */
121  std::unique_ptr<
124 
125  /**
126  Initializes and sets auto_inc_mutex.
127  Only needed to be called if the table have an auto increment.
128  Must hold TABLE_SHARE::LOCK_ha_data when calling.
129  */
130  bool init_auto_inc_mutex(TABLE_SHARE *table_share);
131  /**
132  Release reserved auto increment values not used.
133  @param thd Thread.
134  @param table_share Table Share
135  @param next_insert_id Next insert id (first non used auto inc value).
136  @param max_reserved End of reserved auto inc range.
137  */
138  void release_auto_inc_if_possible(THD *thd, TABLE_SHARE *table_share,
139  const ulonglong next_insert_id,
140  const ulonglong max_reserved);
141 
142  /** lock mutex protecting auto increment value next_auto_inc_val. */
143  inline void lock_auto_inc() {
146  }
147  /** unlock mutex protecting auto increment value next_auto_inc_val. */
148  inline void unlock_auto_inc() {
151  }
152  /**
153  Populate partition_name_hash with partition and subpartition names
154  from part_info.
155  @param part_info Partition info containing all partitions metadata.
156 
157  @return Operation status.
158  @retval false Success.
159  @retval true Failure.
160  */
162  /** Get partition name.
163 
164  @param part_id Partition id (for subpartitioned table only subpartition
165  names will be returned.)
166 
167  @return partition name or NULL if error.
168  */
169  const char *get_partition_name(size_t part_id) const;
170 
171  private:
173  /**
174  Insert [sub]partition name into partition_name_hash
175  @param name Partition name.
176  @param part_id Partition id.
177  @param is_subpart True if subpartition else partition.
178 
179  @return Operation status.
180  @retval false Success.
181  @retval true Failure.
182  */
183  bool insert_partition_name_in_hash(const char *name, uint part_id,
184  bool is_subpart);
185 };
186 
187 /**
188  Class for partitioning specific operations.
189 
190  Returned from handler::get_partition_handler().
191 */
193  public:
195  virtual ~Partition_handler() {}
196 
197  /**
198  Get dynamic table information from partition.
199 
200  @param[out] stat_info Statistics struct to fill in.
201  @param[out] check_sum Check sum value to fill in if supported.
202  @param[in] part_id Partition to report for.
203 
204  @note stat_info and check_sum are initialized by caller.
205  check_sum is only expected to be updated if HA_HAS_CHECKSUM.
206  */
207  virtual void get_dynamic_partition_info(ha_statistics *stat_info,
208  ha_checksum *check_sum,
209  uint part_id) = 0;
210  /**
211  Get default number of partitions.
212 
213  Used during creating a partitioned table.
214 
215  @param info Create info.
216  @return Number of default partitions.
217  */
219  HA_CREATE_INFO *info MY_ATTRIBUTE((unused))) {
220  return 1;
221  }
222  /**
223  Setup auto partitioning.
224 
225  Called for engines with HA_USE_AUTO_PARTITION to setup the partition info
226  object
227 
228  @param[in,out] part_info Partition object to setup.
229  */
230  virtual void set_auto_partitions(
231  partition_info *part_info MY_ATTRIBUTE((unused))) {}
232  /**
233  Get number of partitions for table in SE
234 
235  @param name normalized path(same as open) to the table
236 
237  @param[out] num_parts Number of partitions
238 
239  @retval false for success
240  @retval true for failure, for example table didn't exist in engine
241  */
242  virtual bool get_num_parts(const char *name MY_ATTRIBUTE((unused)),
243  uint *num_parts) {
244  *num_parts = 0;
245  return false;
246  }
247  /**
248  Set the partition info object to be used by the handler.
249 
250  @param part_info Partition info to be used by the handler.
251  @param early True if called when part_info only created and parsed,
252  but not setup, checked or fixed.
253  */
254  virtual void set_part_info(partition_info *part_info, bool early) = 0;
255 
256  /**
257  Truncate partitions.
258 
259  Truncate all partitions matching table->part_info->read_partitions.
260  Handler level wrapper for truncating partitions, will ensure that
261  mark_trx_read_write() is called and also checks locking assertions.
262 
263  @param[in,out] table_def dd::Table object for the table. Engines
264  which support atomic DDL are allowed to
265  adjust this object. Changes will be saved
266  to the data-dictionary.
267 
268  @return Operation status.
269  @retval 0 Success.
270  @retval != 0 Error code.
271  */
273 
274  /**
275  Exchange partition.
276 
277  @param[in] part_table_path Path to partition in partitioned table
278  to be exchanged.
279  @param[in] swap_table_path Path to non-partitioned table to be
280  exchanged with partition.
281  @param[in] part_id Id of partition to be exchanged.
282  @param[in,out] part_table_def dd::Table object for partitioned table.
283  @param[in,out] swap_table_def dd::Table object for non-partitioned
284  table.
285 
286  @note Both tables are locked in exclusive mode.
287 
288  @note Changes to dd::Table object done by this method will be saved
289  to data-dictionary only if storage engine supporting atomic
290  DDL (i.e. with HTON_SUPPORTS_ATOMIC_DDL flag).
291 
292  @return Operation status.
293  @retval 0 Success.
294  @retval != 0 Error code.
295  */
296  int exchange_partition(const char *part_table_path,
297  const char *swap_table_path, uint part_id,
298  dd::Table *part_table_def, dd::Table *swap_table_def);
299 
300  /**
301  Alter flags.
302 
303  Given a set of alter table flags, return which is supported.
304 
305  @param flags Alter table operation flags.
306 
307  @return Supported alter table flags.
308  */
309  virtual uint alter_flags(uint flags MY_ATTRIBUTE((unused))) const {
310  return 0;
311  }
312 
313  private:
314  /**
315  Truncate partition.
316 
317  Low-level primitive for handler, implementing
318  Partition_handler::truncate_partition().
319 
320  @sa Partition_handler::truncate_partition().
321  */
323  return HA_ERR_WRONG_COMMAND;
324  }
325 
326  /**
327  Exchange partition.
328 
329  Low-level primitive which implementation to be provided by SE.
330 
331  @sa Partition_handler::exchange_partition().
332  */
334  const char *part_table_path MY_ATTRIBUTE((unused)),
335  const char *swap_table_path MY_ATTRIBUTE((unused)),
336  uint part_id MY_ATTRIBUTE((unused)),
337  dd::Table *part_table_def MY_ATTRIBUTE((unused)),
338  dd::Table *swap_table_def MY_ATTRIBUTE((unused))) {
339  return HA_ERR_WRONG_COMMAND;
340  }
341 
342  /**
343  Return the table handler.
344 
345  For some partitioning specific functions it is still needed to access
346  the handler directly for transaction handling (mark_trx_read_write())
347  and to assert correct locking.
348 
349  @return handler or NULL if not supported.
350  */
351  virtual handler *get_handler() { return NULL; }
352 };
353 
354 /// Maps compare function to strict weak ordering required by Priority_queue.
355 struct Key_rec_less {
356  typedef int (*key_compare_fun)(KEY **, uchar *, uchar *);
357 
358  explicit Key_rec_less(KEY **keys)
360 
361  bool operator()(uchar *first, uchar *second) {
362  const int cmpval =
363  (*m_fun)(m_keys, first + m_rec_offset, second + m_rec_offset);
364  return m_max_at_top ? cmpval < 0 : cmpval > 0;
365  }
366 
371 };
372 
373 /**
374  Partition_helper is a helper class that implements most generic partitioning
375  functionality such as:
376  table scan, index scan (both ordered and non-ordered),
377  insert (write_row()), delete and update.
378  And includes ALTER TABLE ... ADD/COALESCE/DROP/REORGANIZE/... PARTITION
379  support.
380  It also implements a cache for the auto increment value and check/repair for
381  rows in wrong partition.
382 
383  How to use it:
384  Inherit it and implement:
385  - *_in_part() functions for row operations.
386  - write_row_in_new_part() for handling 'fast' alter partition.
387 */
391 
392  public:
393  Partition_helper(handler *main_handler);
394  virtual ~Partition_helper();
395 
396  /**
397  Set partition info.
398 
399  To be called from Partition_handler.
400 
401  @param part_info Partition info to use.
402  @param early True if called when part_info only created and parsed,
403  but not setup, checked or fixed.
404  */
405  virtual void set_part_info_low(partition_info *part_info, bool early);
406  /**
407  Initialize variables used before the table is opened.
408 
409  @param mem_root Memory root to allocate things from (not yet used).
410 
411  @return Operation status.
412  @retval false success.
413  @retval true failure.
414  */
415  bool init_partitioning(MEM_ROOT *mem_root MY_ATTRIBUTE((unused))) {
416 #ifndef DBUG_OFF
418 #endif
419  return false;
420  }
421 
422  /**
423  INSERT/UPDATE/DELETE functions.
424  @see handler.h
425  @{
426  */
427 
428  /**
429  Insert a row to the partitioned table.
430 
431  @param buf The row in MySQL Row Format.
432 
433  @return Operation status.
434  @retval 0 Success
435  @retval != 0 Error code
436  */
437  int ph_write_row(uchar *buf);
438  /**
439  Update an existing row in the partitioned table.
440 
441  Yes, update_row() does what you expect, it updates a row. old_data will
442  have the previous row record in it, while new_data will have the newest
443  data in it.
444  Keep in mind that the server can do updates based on ordering if an
445  ORDER BY clause was used. Consecutive ordering is not guaranteed.
446 
447  If the new record belongs to a different partition than the old record
448  then it will be inserted into the new partition and deleted from the old.
449 
450  new_data is always record[0]
451  old_data is always record[1]
452 
453  @param old_data The old record in MySQL Row Format.
454  @param new_data The new record in MySQL Row Format.
455 
456  @return Operation status.
457  @retval 0 Success
458  @retval != 0 Error code
459  */
460  int ph_update_row(const uchar *old_data, uchar *new_data);
461  /**
462  Delete an existing row in the partitioned table.
463 
464  This will delete a row. buf will contain a copy of the row to be deleted.
465  The server will call this right after the current row has been read
466  (from either a previous rnd_xxx() or index_xxx() call).
467  If you keep a pointer to the last row or can access a primary key it will
468  make doing the deletion quite a bit easier.
469  Keep in mind that the server does no guarantee consecutive deletions.
470  ORDER BY clauses can be used.
471 
472  buf is either record[0] or record[1]
473 
474  @param buf The record in MySQL Row Format.
475 
476  @return Operation status.
477  @retval 0 Success
478  @retval != 0 Error code
479  */
480  int ph_delete_row(const uchar *buf);
481 
482  /** @} */
483 
484  /** Release unused auto increment values. */
486  /**
487  Calculate key hash value from an null terminated array of fields.
488  Support function for KEY partitioning.
489 
490  @param field_array An array of the fields in KEY partitioning
491 
492  @return hash_value calculated
493 
494  @note Uses the hash function on the character set of the field.
495  Integer and floating point fields use the binary character set by default.
496  */
497  static uint32 ph_calculate_key_hash_value(Field **field_array);
498 
499  /**
500  MODULE full table scan
501 
502  This module is used for the most basic access method for any table
503  handler. This is to fetch all data through a full table scan. No
504  indexes are needed to implement this part.
505  It contains one method to start the scan (rnd_init) that can also be
506  called multiple times (typical in a nested loop join). Then proceeding
507  to the next record (rnd_next) and closing the scan (rnd_end).
508  To remember a record for later access there is a method (position)
509  and there is a method used to retrieve the record based on the stored
510  position.
511  The position can be a file position, a primary key, a ROWID dependent
512  on the handler below.
513 
514  unlike index_init(), rnd_init() can be called two times
515  without rnd_end() in between (it only makes sense if scan=1).
516  then the second call should prepare for the new table scan
517  (e.g if rnd_init allocates the cursor, second call should
518  position it to the start of the table, no need to deallocate
519  and allocate it again.
520  @see handler.h
521  @{
522  */
523 
524  int ph_rnd_init(bool scan);
525  int ph_rnd_end();
526  int ph_rnd_next(uchar *buf);
527  void ph_position(const uchar *record);
528 
529  /** @} */
530 
531  /**
532  MODULE index scan
533 
534  This part of the handler interface is used to perform access through
535  indexes. The interface is defined as a scan interface but the handler
536  can also use key lookup if the index is a unique index or a primary
537  key index.
538  Index scans are mostly useful for SELECT queries but are an important
539  part also of UPDATE, DELETE, REPLACE and CREATE TABLE table AS SELECT
540  and so forth.
541  Naturally an index is needed for an index scan and indexes can either
542  be ordered, hash based. Some ordered indexes can return data in order
543  but not necessarily all of them.
544  There are many flags that define the behavior of indexes in the
545  various handlers. These methods are found in the optimizer module.
546  -------------------------------------------------------------------------
547 
548  index_read is called to start a scan of an index. The find_flag defines
549  the semantics of the scan. These flags are defined in
550  include/my_base.h
551  index_read_idx is the same but also initializes index before calling doing
552  the same thing as index_read. Thus it is similar to index_init followed
553  by index_read. This is also how we implement it.
554 
555  index_read/index_read_idx does also return the first row. Thus for
556  key lookups, the index_read will be the only call to the handler in
557  the index scan.
558 
559  index_init initializes an index before using it and index_end does
560  any end processing needed.
561  @{
562  */
563 
564  int ph_index_init_setup(uint key_nr, bool sorted);
565  /*
566  These methods are used to jump to next or previous entry in the index
567  scan. There are also methods to jump to first and last entry.
568  */
569  int ph_index_first(uchar *buf);
570  int ph_index_last(uchar *buf);
571  int ph_index_next(uchar *buf);
572  int ph_index_next_same(uchar *buf, uint keylen);
573  int ph_index_prev(uchar *buf);
574  int ph_index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map,
575  enum ha_rkey_function find_flag);
576  int ph_index_read_last_map(uchar *buf, const uchar *key,
577  key_part_map keypart_map);
578  int ph_index_read_idx_map(uchar *buf, uint index, const uchar *key,
579  key_part_map keypart_map,
580  enum ha_rkey_function find_flag);
581  int ph_read_range_first(const key_range *start_key, const key_range *end_key,
582  bool eq_range_arg, bool sorted);
583  int ph_read_range_next();
584  /** @} */
585 
586  /**
587  Functions matching Partition_handler API.
588  @{
589  */
590 
591  /**
592  Get statistics from a specific partition.
593  @param[out] stat_info Area to report values into.
594  @param[out] check_sum Check sum of partition.
595  @param[in] part_id Partition to report from.
596  */
597  virtual void get_dynamic_partition_info_low(ha_statistics *stat_info,
598  ha_checksum *check_sum,
599  uint part_id);
600 
601  /**
602  Prepare for reorganizing partitions by setting up
603  partition_info::read_partitions according to the partition_info
604  mark-up.
605 
606  This is helper method which can also be used by SEs implementing
607  support for reorganizing partitions through ALTER TABLE INPLACE
608  SE API.
609  */
611 
612  /** @} */
613 
614  protected:
615  /* Common helper functions to be used by inheriting engines. */
616 
617  /*
618  open/close functions.
619  */
620 
621  /**
622  Set m_part_share, Allocate internal bitmaps etc. used by open tables.
623 
624  @return Operation status.
625  @retval false success.
626  @retval true failure.
627  */
628  bool open_partitioning(Partition_share *part_share);
629  /**
630  Close partitioning for a table.
631 
632  Frees memory and release other resources.
633  */
634  void close_partitioning();
635 
636  /**
637  Lock auto increment value if needed.
638  */
639  void lock_auto_increment();
640 
641  /**
642  unlock auto increment.
643  */
644  inline void unlock_auto_increment() {
645  /*
646  If m_auto_increment_safe_stmt_log_lock is true, we have to keep the lock.
647  It will be set to false and thus unlocked at the end of the statement by
648  ha_partition::release_auto_increment.
649  */
652  m_auto_increment_lock = false;
653  }
654  }
655  /**
656  Get auto increment.
657 
658  Only to be used for auto increment values that are the first field in
659  an unique index.
660 
661  @param[in] increment Increment between generated numbers.
662  @param[in] nb_desired_values Number of values requested.
663  @param[out] first_value First reserved value (ULLONG_MAX on error).
664  @param[out] nb_reserved_values Number of values reserved.
665  */
667  ulonglong nb_desired_values,
668  ulonglong *first_value,
669  ulonglong *nb_reserved_values);
670 
671  /**
672  Initialize the record priority queue used for sorted index scans.
673  @return Operation status.
674  @retval 0 Success.
675  @retval != 0 Error code.
676  */
678  /**
679  Destroy the record priority queue used for sorted index scans.
680  */
682  /*
683  Administrative support functions.
684  */
685 
686  /** Print partitioning specific error.
687  @param error Error code.
688  @return false if error is printed else true.
689  */
690  bool print_partition_error(int error);
691  /**
692  Print a message row formatted for ANALYZE/CHECK/OPTIMIZE/REPAIR TABLE.
693 
694  Modeled after mi_check_print_msg.
695 
696  @param thd Thread context.
697  @param len Needed length for message buffer.
698  @param msg_type Message type.
699  @param db_name Database name.
700  @param table_name Table name.
701  @param op_name Operation name.
702  @param fmt Message (in printf format with additional arguments).
703 
704  @return Operation status.
705  @retval false for success else true.
706  */
707  bool print_admin_msg(THD *thd, uint len, const char *msg_type,
708  const char *db_name, const char *table_name,
709  const char *op_name, const char *fmt, ...)
710  MY_ATTRIBUTE((format(printf, 8, 9)));
711 
712  /**
713  Check/fix misplaced rows.
714 
715  @param read_part_id Partition to check/fix.
716  @param repair If true, move misplaced rows to correct partition.
717 
718  @return Operation status.
719  @retval 0 Success
720  @retval != 0 Error
721  */
722  int check_misplaced_rows(uint read_part_id, bool repair);
723  /**
724  Set used partitions bitmap from Alter_info.
725 
726  @return false if success else true.
727  */
728  bool set_altered_partitions();
729 
730  /**
731  Copy partitions as part of ALTER TABLE of partitions.
732 
733  SE and prepare_change_partitions has done all the preparations,
734  now it is time to actually copy the data from the reorganized
735  partitions to the new partitions.
736 
737  @param[out] deleted Number of records deleted.
738 
739  @return Operation status
740  @retval 0 Success
741  @retval >0 Error code
742  */
743  virtual int copy_partitions(ulonglong *const deleted);
744 
745  private:
754  };
755 
756  /** handler to use (ha_innopart etc.) */
758  /*
759  Access methods to protected areas in handler to avoid adding
760  friend class Partition_helper in class handler.
761  */
762  virtual THD *get_thd() const = 0;
763  virtual TABLE *get_table() const = 0;
764  virtual bool get_eq_range() const = 0;
765  virtual void set_eq_range(bool eq_range) = 0;
766  virtual void set_range_key_part(KEY_PART_INFO *key_part) = 0;
767 
768  /*
769  Implementation of per partition operation by instantiated engine.
770  These must be implemented in the 'real' partition_helper subclass.
771  */
772 
773  /**
774  Write a row in the specified partition.
775 
776  @see handler::write_row().
777 
778  @param part_id Partition to write to.
779  @param buf Buffer with data to write.
780 
781  @return Operation status.
782  @retval 0 Success.
783  @retval != 0 Error code.
784  */
785  virtual int write_row_in_part(uint part_id, uchar *buf) = 0;
786  /**
787  Update a row in the specified partition.
788 
789  @see handler::update_row().
790 
791  @param part_id Partition to update in.
792  @param old_data Buffer containing old row.
793  @param new_data Buffer containing new row.
794 
795  @return Operation status.
796  @retval 0 Success.
797  @retval != 0 Error code.
798  */
799  virtual int update_row_in_part(uint part_id, const uchar *old_data,
800  uchar *new_data) = 0;
801  /**
802  Delete an existing row in the specified partition.
803 
804  @see handler::delete_row().
805 
806  @param part_id Partition to delete from.
807  @param buf Buffer containing row to delete.
808 
809  @return Operation status.
810  @retval 0 Success.
811  @retval != 0 Error code.
812  */
813  virtual int delete_row_in_part(uint part_id, const uchar *buf) = 0;
814  /**
815  Initialize the shared auto increment value.
816 
817  @param no_lock If HA_STATUS_NO_LOCK should be used in info(HA_STATUS_AUTO).
818 
819  Also sets stats.auto_increment_value.
820  */
821  virtual int initialize_auto_increment(bool no_lock) = 0;
822  /** Release auto_increment in all underlying partitions. */
824  /** Save or persist the current max auto increment. */
825  virtual void save_auto_increment(ulonglong nr MY_ATTRIBUTE((unused))) {}
826  /**
827  Per partition equivalent of rnd_* and index_* functions.
828 
829  @see class handler.
830  */
831  virtual int rnd_init_in_part(uint part_id, bool table_scan) = 0;
832  int ph_rnd_next_in_part(uint part_id, uchar *buf);
833  virtual int rnd_next_in_part(uint part_id, uchar *buf) = 0;
834  virtual int rnd_end_in_part(uint part_id, bool scan) = 0;
835  virtual void position_in_last_part(uchar *ref, const uchar *row) = 0;
836  virtual int index_first_in_part(uint part, uchar *buf) = 0;
837  virtual int index_last_in_part(uint part, uchar *buf) = 0;
838  virtual int index_prev_in_part(uint part, uchar *buf) = 0;
839  virtual int index_next_in_part(uint part, uchar *buf) = 0;
840  virtual int index_next_same_in_part(uint part, uchar *buf, const uchar *key,
841  uint length) = 0;
842  virtual int index_read_map_in_part(uint part, uchar *buf, const uchar *key,
843  key_part_map keypart_map,
844  enum ha_rkey_function find_flag) = 0;
845  virtual int index_read_last_map_in_part(uint part, uchar *buf,
846  const uchar *key,
847  key_part_map keypart_map) = 0;
848  /**
849  Do read_range_first in the specified partition.
850  If buf is set, then copy the result there instead of table->record[0].
851  */
852  virtual int read_range_first_in_part(uint part, uchar *buf,
853  const key_range *start_key,
854  const key_range *end_key,
855  bool sorted) = 0;
856  /**
857  Do read_range_next in the specified partition.
858  If buf is set, then copy the result there instead of table->record[0].
859  */
860  virtual int read_range_next_in_part(uint part, uchar *buf) = 0;
861  virtual int index_read_idx_map_in_part(uint part, uchar *buf, uint index,
862  const uchar *key,
863  key_part_map keypart_map,
864  enum ha_rkey_function find_flag) = 0;
865  /**
866  Initialize engine specific resources for the record priority queue
867  used duing ordered index reads for multiple partitions.
868 
869  @param used_parts Number of partitions used in query
870  (number of set bits in m_part_info->read_partitions).
871 
872  @return Operation status.
873  @retval 0 Success.
874  @retval != 0 Error code.
875  */
877  uint used_parts MY_ATTRIBUTE((unused))) {
878  return 0;
879  }
880  /**
881  Destroy and release engine specific resources used by the record
882  priority queue.
883  */
885  /**
886  Checksum for a partition.
887 
888  @param part_id Partition to checksum.
889  */
891  uint part_id MY_ATTRIBUTE((unused))) const {
892  DBUG_ASSERT(0);
893  return 0;
894  }
895  /**
896  Copy a cached row.
897 
898  Used when copying a row from the record priority queue to the return buffer.
899  For some engines, like InnoDB, only marked columns must be copied,
900  to preserve non-read columns.
901 
902  @param[out] to_rec Buffer to copy to.
903  @param[in] from_rec Buffer to copy from.
904  */
905  virtual void copy_cached_row(uchar *to_rec, const uchar *from_rec) {
906  memcpy(to_rec, from_rec, m_rec_length);
907  }
908 
909  /**
910  write row to new partition.
911  @param new_part New partition to write to.
912 
913  @return Operation status.
914  @retval 0 Success.
915  @retval != 0 Error code.
916  */
917  virtual int write_row_in_new_part(uint new_part) = 0;
918 
919  /* Internal helper functions*/
920  /**
921  Update auto increment value if current row contains a higher value.
922  */
923  inline void set_auto_increment_if_higher();
924  /**
925  Common routine to set up index scans.
926 
927  Find out which partitions we'll need to read when scanning the specified
928  range.
929 
930  If we need to scan only one partition, set m_ordered_scan_ongoing=false
931  as we will not need to do merge ordering.
932 
933  @param buf Buffer to later return record in (this function
934  needs it to calculate partitioning function values)
935 
936  @param idx_read_flag True <=> m_start_key has range start endpoint which
937  probably can be used to determine the set of
938  partitions to scan.
939  False <=> there is no start endpoint.
940 
941  @return Operation status.
942  @retval 0 Success
943  @retval !=0 Error code
944  */
945  int partition_scan_set_up(uchar *buf, bool idx_read_flag);
946  /**
947  Common routine to handle index_next with unordered results.
948 
949  These routines are used to scan partitions without considering order.
950  This is performed in two situations.
951  1) In read_multi_range this is the normal case
952  2) When performing any type of index_read, index_first, index_last where
953  all fields in the partition function is bound. In this case the index
954  scan is performed on only one partition and thus it isn't necessary to
955  perform any sort.
956 
957  @param[out] buf Read row in MySQL Row Format.
958  @param[in] is_next_same Called from index_next_same.
959 
960  @return Operation status.
961  @retval HA_ERR_END_OF_FILE End of scan
962  @retval 0 Success
963  @retval other Error code
964  */
965  int handle_unordered_next(uchar *buf, bool is_next_same);
966  /**
967  Handle index_next when changing to new partition.
968 
969  This routine is used to start the index scan on the next partition.
970  Both initial start and after completing scan on one partition.
971 
972  @param[out] buf Read row in MySQL Row Format
973 
974  @return Operation status.
975  @retval HA_ERR_END_OF_FILE End of scan
976  @retval 0 Success
977  @retval other Error code
978  */
980  /**
981  Common routine to start index scan with ordered results.
982 
983  @param[out] buf Read row in MySQL Row Format
984 
985  @return Operation status
986  @retval HA_ERR_END_OF_FILE End of scan
987  @retval HA_ERR_KEY_NOT_FOUND End of scan
988  @retval 0 Success
989  @retval other Error code
990  */
992  /**
993  Add index_next/prev results from partitions without exact match.
994 
995  If there where any partitions that returned HA_ERR_KEY_NOT_FOUND when
996  ha_index_read_map was done, those partitions must be included in the
997  following index_next/prev call.
998 
999  @return Operation status
1000  @retval HA_ERR_END_OF_FILE End of scan
1001  @retval 0 Success
1002  @retval other Error code
1003  */
1005  /**
1006  Common routine to handle index_prev with ordered results.
1007 
1008  @param[out] buf Read row in MySQL Row Format.
1009 
1010  @return Operation status.
1011  @retval HA_ERR_END_OF_FILE End of scan
1012  @retval 0 Success
1013  @retval other Error code
1014  */
1015  int handle_ordered_prev(uchar *buf);
1016  /**
1017  Common routine to handle index_next with ordered results.
1018 
1019  @param[out] buf Read row in MySQL Row Format.
1020  @param[in] is_next_same Called from index_next_same.
1021 
1022  @return Operation status.
1023  @retval HA_ERR_END_OF_FILE End of scan
1024  @retval 0 Success
1025  @retval other Error code
1026  */
1027  int handle_ordered_next(uchar *buf, bool is_next_same);
1028  /**
1029  Common routine for a number of index_read variants.
1030 
1031  @param[out] buf Buffer where the record should be returned.
1032  @param[in] have_start_key true <=> the left endpoint is available, i.e.
1033  we're in index_read call or in read_range_first
1034  call and the range has left endpoint.
1035  false <=> there is no left endpoint (we're in
1036  read_range_first() call and the range has no
1037  left endpoint).
1038 
1039  @return Operation status
1040  @retval 0 OK
1041  @retval HA_ERR_END_OF_FILE Whole index scanned, without finding the
1042  record.
1043  @retval HA_ERR_KEY_NOT_FOUND Record not found, but index cursor
1044  positioned.
1045  @retval other Error code.
1046  */
1047  int common_index_read(uchar *buf, bool have_start_key);
1048  /**
1049  Common routine for index_first/index_last.
1050 
1051  @param[out] buf Read row in MySQL Row Format.
1052 
1053  @return Operation status.
1054  @retval 0 Success
1055  @retval != 0 Error code
1056  */
1057  int common_first_last(uchar *buf);
1058  /**
1059  Return the top record in sort order.
1060 
1061  @param[out] buf Row returned in MySQL Row Format.
1062  */
1063  void return_top_record(uchar *buf);
1064 
1065  /**
1066  Set table->read_set taking partitioning expressions into account.
1067  */
1068  void set_partition_read_set();
1069 
1070  /*
1071  These could be private as well,
1072  but easier to expose them to derived classes to use.
1073  */
1074  protected:
1075  /** Convenience pointer to table from m_handler (i.e. m_handler->table). */
1077 
1078  /** All internal partitioning data! @{ */
1079  /** Tables partitioning info (same as table->part_info) */
1081  /** Is primary key clustered. */
1083  /** Cached value of m_part_info->is_sub_partitioned(). */
1085  /** Total number of partitions. */
1087  uint m_last_part; // Last accessed partition.
1088  const uchar *m_err_rec; // record which gave error.
1091  part_id_range m_part_spec; // Which parts to scan
1092  uint m_scan_value; // Value passed in rnd_init
1093  // call
1094  key_range m_start_key; // index read key range
1095  enum partition_index_scan_type m_index_scan_type; // What type of index
1096  // scan
1097  uint m_rec_length; // Local copy of record length
1098 
1099  bool m_ordered; // Ordered/Unordered index scan.
1100  bool m_ordered_scan_ongoing; // Ordered index scan ongoing.
1101  bool m_reverse_order; // Scanning in reverse order (prev).
1102  /** Row and key buffer for ordered index scan. */
1104  /** Prio queue used by sorted read. */
1106  /** Which partition is to deliver next result. */
1108  /** Offset in m_ordered_rec_buffer from part buffer to its record buffer. */
1110  /**
1111  Current index used for sorting.
1112  If clustered PK exists, then it will be used as secondary index to
1113  sort on if the first is equal in key_rec_cmp.
1114  So if clustered pk: m_curr_key_info[0]= current index and
1115  m_curr_key_info[1]= pk and [2]= NULL.
1116  Otherwise [0]= current index, [1]= NULL, and we will
1117  sort by rowid as secondary sort key if equal first key.
1118  */
1121  /** handler::ref is not copied to the PQ. */
1123  /**
1124  handler::ref is copied to the PQ but does not need to be used in sorting.
1125  */
1127  /** handler::ref is copied to the PQ and must be used during sorting. */
1129  };
1130  /** How handler::ref is used in the priority queue. */
1132  /** Set if previous index_* call returned HA_ERR_KEY_NOT_FOUND. */
1134  /** Partitions that returned HA_ERR_KEY_NOT_FOUND. */
1136  /** @} */
1137 
1138  private:
1139  /** Partition share for auto_inc handling. */
1141 };
1142 #endif /* PARTITION_HANDLER_INCLUDED */
virtual void set_part_info(partition_info *part_info, bool early)=0
Set the partition info object to be used by the handler.
void get_auto_increment_first_field(ulonglong increment, ulonglong nb_desired_values, ulonglong *first_value, ulonglong *nb_reserved_values)
Get auto increment.
Definition: partition_handler.cc:746
bool is_subpart
Definition: partition_handler.h:91
unsigned long long int ulonglong
Definition: my_inttypes.h:69
Partition specific Handler_share.
Definition: partition_handler.h:102
Definition: partition_info.h:208
uint m_rec_length
Definition: partition_handler.h:1097
virtual void release_auto_increment_all_parts()
Release auto_increment in all underlying partitions.
Definition: partition_handler.h:823
Instrumentation helpers for mutexes.
enum_using_ref m_ref_usage
How handler::ref is used in the priority queue.
Definition: partition_handler.h:1131
Class for partitioning specific operations.
Definition: partition_handler.h:192
unsigned char uchar
Definition: my_inttypes.h:49
virtual int read_range_first_in_part(uint part, uchar *buf, const key_range *start_key, const key_range *end_key, bool sorted)=0
Do read_range_first in the specified partition.
Definition: partition_handler.h:83
Definition: partition_handler.h:79
const char * db_name
Definition: rules_table_service.cc:54
virtual int index_read_idx_map_in_part(uint part, uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag)=0
KEY * m_curr_key_info[3]
Current index used for sorting.
Definition: partition_handler.h:1119
std::unordered_map, but with my_malloc and collation-aware comparison.
Definition: map_helpers.h:236
int ph_rnd_end()
End of a table scan.
Definition: partition_handler.cc:1543
const uchar ** partition_names
Definition: partition_handler.h:172
Definition: partition_handler.h:750
bool insert_partition_name_in_hash(const char *name, uint part_id, bool is_subpart)
Insert [sub]partition name into partition_name_hash.
Definition: partition_handler.cc:290
Base class to be used by handlers different shares.
Definition: handler.h:3438
Definition: partition_handler.h:752
virtual THD * get_thd() const =0
key_range m_start_key
Definition: partition_handler.h:1094
virtual int rnd_next_in_part(uint part_id, uchar *buf)=0
virtual void position_in_last_part(uchar *ref, const uchar *row)=0
const string name("\ame\)
~Partition_share()
Definition: partition_handler.cc:127
bool print_partition_error(int error)
Print partitioning specific error.
Definition: partition_handler.cc:959
Partition_handler()
Definition: partition_handler.h:194
Definition: mi_test3.cc:54
This structure is shared between different table objects.
Definition: table.h:646
Definition: partition_handler.h:749
ulong key_part_map
Definition: my_base.h:934
key_compare_fun m_fun
Definition: partition_handler.h:368
Some integer typedefs for easier portability.
bool init_auto_inc_mutex(TABLE_SHARE *table_share)
Initializes and sets auto_inc_mutex.
Definition: partition_handler.cc:145
#define HA_ERR_WRONG_COMMAND
Definition: my_base.h:818
virtual void set_auto_partitions(partition_info *part_info)
Setup auto partitioning.
Definition: partition_handler.h:230
bool m_reverse_order
Definition: partition_handler.h:1101
virtual int index_last_in_part(uint part, uchar *buf)=0
bool m_auto_increment_lock
Definition: partition_handler.h:1090
virtual ~Partition_helper()
Definition: partition_handler.cc:372
int check_misplaced_rows(uint read_part_id, bool repair)
Check/fix misplaced rows.
Definition: partition_handler.cc:1147
partition_info * m_part_info
All internal partitioning data!
Definition: partition_handler.h:1080
Definition: field.h:707
int ph_index_next(uchar *buf)
Read next record in a forward index scan.
Definition: partition_handler.cc:2160
void unlock_auto_inc()
unlock mutex protecting auto increment value next_auto_inc_val.
Definition: partition_handler.h:148
virtual void get_dynamic_partition_info(ha_statistics *stat_info, ha_checksum *check_sum, uint part_id)=0
Get dynamic table information from partition.
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:858
virtual uint alter_flags(uint flags) const
Alter flags.
Definition: partition_handler.h:309
Sergei Dialog Client Authentication NULL
Definition: dialog.cc:352
void lock_auto_increment()
Lock auto increment value if needed.
Definition: partition_handler.cc:446
virtual void set_range_key_part(KEY_PART_INFO *key_part)=0
bool m_key_not_found
Set if previous index_* call returned HA_ERR_KEY_NOT_FOUND.
Definition: partition_handler.h:1133
uint m_top_entry
Which partition is to deliver next result.
Definition: partition_handler.h:1107
virtual bool get_eq_range() const =0
int ph_index_first(uchar *buf)
Start an index scan from leftmost record and return first record.
Definition: partition_handler.cc:1992
handler::ref is copied to the PQ and must be used during sorting.
Definition: partition_handler.h:1128
printf("== done ==\)
my_bitmap_map * bitmap
Definition: my_bitmap.h:43
bool populate_partition_name_hash(partition_info *part_info)
Populate partition_name_hash with partition and subpartition names from part_info.
Definition: partition_handler.cc:200
const char * get_partition_name(size_t part_id) const
Get partition name.
Definition: partition_handler.cc:324
int handle_ordered_prev(uchar *buf)
Common routine to handle index_prev with ordered results.
Definition: partition_handler.cc:2864
int ph_index_prev(uchar *buf)
Read next record when performing index scan backwards.
Definition: partition_handler.cc:2214
bool auto_inc_initialized
Set if auto increment is used an initialized.
Definition: partition_handler.h:108
virtual int rnd_init_in_part(uint part_id, bool table_scan)=0
Per partition equivalent of rnd_* and index_* functions.
virtual TABLE * get_table() const =0
mysql_mutex_t * auto_inc_mutex
Mutex protecting next_auto_inc_val.
Definition: partition_handler.h:113
int ph_update_row(const uchar *old_data, uchar *new_data)
Update an existing row in the partitioned table.
Definition: partition_handler.cc:573
bool init_partitioning(MEM_ROOT *mem_root)
Initialize variables used before the table is opened.
Definition: partition_handler.h:415
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:2099
Definition: sql_partition.h:87
Prio_queue * m_queue
Prio queue used by sorted read.
Definition: partition_handler.h:1105
int handle_ordered_index_scan(uchar *buf)
Common routine to start index scan with ordered results.
Definition: partition_handler.cc:2520
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:1887
ha_rkey_function
Definition: my_base.h:77
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:3913
int handle_unordered_scan_next_partition(uchar *buf)
Handle index_next when changing to new partition.
Definition: partition_handler.cc:2425
uint32 ha_checksum
Definition: my_sys.h:551
uint m_scan_value
Definition: partition_handler.h:1092
virtual int index_first_in_part(uint part, uchar *buf)=0
#define UINT_MAX32
Definition: my_inttypes.h:107
Definition: table.h:1294
uint m_last_part
Definition: partition_handler.h:1087
bool m_ordered
Definition: partition_handler.h:1099
enum partition_index_scan_type m_index_scan_type
Definition: partition_handler.h:1095
part_id_range m_part_spec
Definition: partition_handler.h:1091
int exchange_partition(const char *part_table_path, const char *swap_table_path, uint part_id, dd::Table *part_table_def, dd::Table *swap_table_def)
Exchange partition.
Definition: partition_handler.cc:342
virtual void set_part_info_low(partition_info *part_info, bool early)
Set partition info.
Definition: partition_handler.cc:386
int ph_index_read_last_map(uchar *buf, const uchar *key, key_part_map keypart_map)
Read last using key.
Definition: partition_handler.cc:2067
Definition: partition_handler.h:751
virtual ~Partition_handler()
Definition: partition_handler.h:195
This file includes constants used by all storage engines.
virtual int index_next_in_part(uint part, uchar *buf)=0
#define DBUG_ASSERT(A)
Definition: my_dbug.h:128
virtual int write_row_in_new_part(uint new_part)=0
write row to new partition.
bool open_partitioning(Partition_share *part_share)
Set m_part_share, Allocate internal bitmaps etc.
Definition: partition_handler.cc:410
handler::ref is copied to the PQ but does not need to be used in sorting.
Definition: partition_handler.h:1126
virtual int write_row_in_part(uint part_id, uchar *buf)=0
Write a row in the specified partition.
char * index(const char *, int c)
Definition: mysql.cc:2840
int ph_rnd_next_in_part(uint part_id, uchar *buf)
Read next row during full partition scan (scan in random row order).
Definition: partition_handler.cc:1315
MY_BITMAP m_key_not_found_partitions
Partitions that returned HA_ERR_KEY_NOT_FOUND.
Definition: partition_handler.h:1135
bool m_auto_increment_safe_stmt_log_lock
Definition: partition_handler.h:1089
virtual int read_range_next_in_part(uint part, uchar *buf)=0
Do read_range_next in the specified partition.
const uchar * m_err_rec
Definition: partition_handler.h:1088
Partition_share()
Definition: partition_handler.cc:121
void set_auto_increment_if_higher()
Update auto increment value if current row contains a higher value.
Definition: partition_handler.cc:806
enum_part_operation
Definition: partition_handler.h:77
TABLE * m_table
Convenience pointer to table from m_handler (i.e.
Definition: partition_handler.h:1076
Definition: key.h:55
uint m_rec_offset
Definition: partition_handler.h:369
Definition: my_bitmap.h:42
int ph_index_init_setup(uint key_nr, bool sorted)
MODULE index scan.
Definition: partition_handler.cc:1829
void unlock_auto_increment()
unlock auto increment.
Definition: partition_handler.h:644
ulonglong next_auto_inc_val
First non reserved auto increment value.
Definition: partition_handler.h:115
int handle_ordered_next(uchar *buf, bool is_next_same)
Common routine to handle index_next with ordered results.
Definition: partition_handler.cc:2749
Header for compiler-dependent features.
virtual void destroy_record_priority_queue_for_parts()
Destroy and release engine specific resources used by the record priority queue.
Definition: partition_handler.h:884
Definition: partition_handler.h:747
virtual int exchange_partition_low(const char *part_table_path, const char *swap_table_path, uint part_id, dd::Table *part_table_def, dd::Table *swap_table_def)
Exchange partition.
Definition: partition_handler.h:333
bool m_pkey_is_clustered
Is primary key clustered.
Definition: partition_handler.h:1082
bool operator()(uchar *first, uchar *second)
Definition: partition_handler.h:361
static uint keys
Definition: hp_test2.cc:43
unsigned int len
Definition: dbug_analyze.cc:216
uint32 part_id
Definition: partition_handler.h:90
unsigned int uint
Definition: uca-dump.cc:29
int ph_read_range_next()
Read next record in read of a range with start and end key.
Definition: partition_handler.cc:2277
uint m_rec_offset
Offset in m_ordered_rec_buffer from part buffer to its record buffer.
Definition: partition_handler.h:1109
virtual int rnd_end_in_part(uint part_id, bool scan)=0
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:2241
std::unique_ptr< collation_unordered_map< std::string, unique_ptr_my_free< PART_NAME_DEF > > > partition_name_hash
Hash of partition names.
Definition: partition_handler.h:123
virtual int initialize_auto_increment(bool no_lock)=0
Initialize the shared auto increment value.
virtual ha_checksum checksum_in_part(uint part_id) const
Checksum for a partition.
Definition: partition_handler.h:890
Struct used for partition_name_hash.
Definition: partition_handler.h:87
int truncate_partition(dd::Table *table_def)
Truncate partitions.
Definition: partition_handler.cc:331
bool m_max_at_top
Definition: partition_handler.h:370
bool m_ordered_scan_ongoing
Definition: partition_handler.h:1100
virtual int delete_row_in_part(uint part_id, const uchar *buf)=0
Delete an existing row in the specified partition.
Common header for many mysys elements.
int init_record_priority_queue()
Initialize the record priority queue used for sorted index scans.
Definition: partition_handler.cc:1713
void ph_release_auto_increment()
Release unused auto increment values.
Definition: partition_handler.cc:822
Definition: my_base.h:1050
static const char * key
Definition: suite_stubs.c:14
bool m_is_sub_partitioned
Cached value of m_part_info->is_sub_partitioned().
Definition: partition_handler.h:1084
static MEM_ROOT mem_root
Definition: client_plugin.cc:107
virtual void save_auto_increment(ulonglong nr)
Save or persist the current max auto increment.
Definition: partition_handler.h:825
int key_rec_cmp(KEY **key, uchar *first_rec, uchar *second_rec)
Compare two records in index order.
Definition: key.cc:583
enum_using_ref
Definition: partition_handler.h:1120
virtual int get_default_num_partitions(HA_CREATE_INFO *info)
Get default number of partitions.
Definition: partition_handler.h:218
Key_rec_less(KEY **keys)
Definition: partition_handler.h:358
KEY ** m_keys
Definition: partition_handler.h:367
void return_top_record(uchar *buf)
Return the top record in sort order.
Definition: partition_handler.cc:2652
virtual handler * get_handler()
Return the table handler.
Definition: partition_handler.h:351
int ph_write_row(uchar *buf)
INSERT/UPDATE/DELETE functions.
Definition: partition_handler.cc:470
int ph_index_next_same(uchar *buf, uint keylen)
Read next same record.
Definition: partition_handler.cc:2192
virtual int init_record_priority_queue_for_parts(uint used_parts)
Initialize engine specific resources for the record priority queue used duing ordered index reads for...
Definition: partition_handler.h:876
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
handler::ref is not copied to the PQ.
Definition: partition_handler.h:1122
bool set_altered_partitions()
Set used partitions bitmap from Alter_info.
Definition: partition_handler.cc:1329
Definition: key.h:111
virtual int update_row_in_part(uint part_id, const uchar *old_data, uchar *new_data)=0
Update a row in the specified partition.
Definition: partition_handler.h:753
int partition_scan_set_up(uchar *buf, bool idx_read_flag)
Common routine to set up index scans.
Definition: partition_handler.cc:2308
uchar * partition_name
Definition: partition_handler.h:88
int handle_unordered_next(uchar *buf, bool is_next_same)
Common routine to handle index_next with unordered results.
Definition: partition_handler.cc:2377
int common_first_last(uchar *buf)
Common routine for index_first/index_last.
Definition: partition_handler.cc:2039
Partition_share * m_part_share
Partition share for auto_inc handling.
Definition: partition_handler.h:1140
void destroy_record_priority_queue()
Destroy the record priority queue used for sorted index scans.
Definition: partition_handler.cc:1799
virtual int index_read_last_map_in_part(uint part, uchar *buf, const uchar *key, key_part_map keypart_map)=0
int ph_index_last(uchar *buf)
Start an index scan from rightmost record and return first record.
Definition: partition_handler.cc:2015
int handle_ordered_index_scan_key_not_found()
Add index_next/prev results from partitions without exact match.
Definition: partition_handler.cc:2673
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:53
void prepare_change_partitions()
Prepare for reorganizing partitions by setting up partition_info::read_partitions according to the pa...
Definition: partition_handler.cc:1026
Definition: handler.h:2541
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:44
virtual int index_read_map_in_part(uint part, uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag)=0
handler * m_handler
handler to use (ha_innopart etc.)
Definition: partition_handler.h:757
virtual bool get_num_parts(const char *name, uint *num_parts)
Get number of partitions for table in SE.
Definition: partition_handler.h:242
Definition: test_sql_stmt.cc:148
virtual int truncate_partition_low(dd::Table *)
Truncate partition.
Definition: partition_handler.h:322
Definition: partition_handler.h:82
Definition: partition_handler.h:78
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39
void close_partitioning()
Close partitioning for a table.
Definition: partition_handler.cc:440
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:1590
static const uint NO_CURRENT_PART_ID
Definition: partition_handler.h:63
A table definition from the master.
Definition: rpl_utility.h:245
virtual int index_next_same_in_part(uint part, uchar *buf, const uchar *key, uint length)=0
uint m_tot_parts
Total number of partitions.
Definition: partition_handler.h:1086
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:77
Priority_queue< uchar *, std::vector< uchar * >, Key_rec_less > Prio_queue
Definition: partition_handler.h:390
Definition: partition_handler.h:81
bool print_admin_msg(THD *thd, uint len, const char *msg_type, const char *db_name, const char *table_name, const char *op_name, const char *fmt,...)
Print a message row formatted for ANALYZE/CHECK/OPTIMIZE/REPAIR TABLE.
Definition: partition_handler.cc:1362
virtual void set_eq_range(bool eq_range)=0
int(* key_compare_fun)(KEY **, uchar *, uchar *)
Definition: partition_handler.h:356
static int flags[50]
Definition: hp_test1.cc:39
virtual int index_prev_in_part(uint part, uchar *buf)=0
void partitioning_init()
Initialize partitioning (currently only PSI keys).
Definition: partition_handler.cc:107
virtual int copy_partitions(ulonglong *const deleted)
Copy partitions as part of ALTER TABLE of partitions.
Definition: partition_handler.cc:1085
Implements a priority queue using a vector-based max-heap.
Definition: priority_queue.h:92
virtual void copy_cached_row(uchar *to_rec, const uchar *from_rec)
Copy a cached row.
Definition: partition_handler.h:905
Partition_helper(handler *main_handler)
Definition: partition_handler.cc:361
int ph_delete_row(const uchar *buf)
Delete an existing row in the partitioned table.
Definition: partition_handler.cc:679
void set_partition_read_set()
Set table->read_set taking partitioning expressions into account.
Definition: partition_handler.cc:1418
Definition: handler.h:3359
Definition: partition_handler.h:748
partition_index_scan_type
Definition: partition_handler.h:746
Definition: table.h:43
int common_index_read(uchar *buf, bool have_start_key)
Common routine for a number of index_read variants.
Definition: partition_handler.cc:1928
Partition_helper is a helper class that implements most generic partitioning functionality such as: t...
Definition: partition_handler.h:388
#define false
Definition: config_static.h:43
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
uint length
Definition: partition_handler.h:89
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:2955
void release_auto_inc_if_possible(THD *thd, TABLE_SHARE *table_share, const ulonglong next_insert_id, const ulonglong max_reserved)
Release reserved auto increment values not used.
Definition: partition_handler.cc:171
void ph_position(const uchar *record)
Save position of current row.
Definition: partition_handler.cc:1658
int ph_rnd_init(bool scan)
MODULE full table scan.
Definition: partition_handler.cc:1482
Maps compare function to strict weak ordering required by Priority_queue.
Definition: partition_handler.h:355
Definition: partition_handler.h:80
void lock_auto_inc()
lock mutex protecting auto increment value next_auto_inc_val.
Definition: partition_handler.h:143
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:776
const char * table_name
Definition: rules_table_service.cc:55
Log error(cerr, "ERROR")
uchar * m_ordered_rec_buffer
Row and key buffer for ordered index scan.
Definition: partition_handler.h:1103