MySQL  8.0.17
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 {
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  /**
314  Get partition row type from SE
315  @param table partition table
316  @param part_id Id of partition for which row type to be retrieved
317  @return Partition row type.
318  */
319  virtual enum row_type get_partition_row_type(const dd::Table *table,
320  uint part_id) = 0;
321 
322  private:
323  /**
324  Truncate partition.
325 
326  Low-level primitive for handler, implementing
327  Partition_handler::truncate_partition().
328 
329  @sa Partition_handler::truncate_partition().
330  */
332  return HA_ERR_WRONG_COMMAND;
333  }
334 
335  /**
336  Exchange partition.
337 
338  Low-level primitive which implementation to be provided by SE.
339 
340  @sa Partition_handler::exchange_partition().
341  */
343  const char *part_table_path MY_ATTRIBUTE((unused)),
344  const char *swap_table_path MY_ATTRIBUTE((unused)),
345  uint part_id MY_ATTRIBUTE((unused)),
346  dd::Table *part_table_def MY_ATTRIBUTE((unused)),
347  dd::Table *swap_table_def MY_ATTRIBUTE((unused))) {
348  return HA_ERR_WRONG_COMMAND;
349  }
350 
351  /**
352  Return the table handler.
353 
354  For some partitioning specific functions it is still needed to access
355  the handler directly for transaction handling (mark_trx_read_write())
356  and to assert correct locking.
357 
358  @return handler or NULL if not supported.
359  */
360  virtual handler *get_handler() { return NULL; }
361 };
362 
363 /// Maps compare function to strict weak ordering required by Priority_queue.
364 struct Key_rec_less {
365  typedef int (*key_compare_fun)(KEY **, uchar *, uchar *);
366 
367  explicit Key_rec_less(KEY **keys)
369 
370  bool operator()(uchar *first, uchar *second) {
371  const int cmpval =
372  (*m_fun)(m_keys, first + m_rec_offset, second + m_rec_offset);
373  return m_max_at_top ? cmpval < 0 : cmpval > 0;
374  }
375 
380 };
381 
382 /**
383  Partition_helper is a helper class that implements most generic partitioning
384  functionality such as:
385  table scan, index scan (both ordered and non-ordered),
386  insert (write_row()), delete and update.
387  And includes ALTER TABLE ... ADD/COALESCE/DROP/REORGANIZE/... PARTITION
388  support.
389  It also implements a cache for the auto increment value and check/repair for
390  rows in wrong partition.
391 
392  How to use it:
393  Inherit it and implement:
394  - *_in_part() functions for row operations.
395  - write_row_in_new_part() for handling 'fast' alter partition.
396 */
400 
401  public:
402  Partition_helper(handler *main_handler);
403  virtual ~Partition_helper();
404 
405  /**
406  Set partition info.
407 
408  To be called from Partition_handler.
409 
410  @param part_info Partition info to use.
411  @param early True if called when part_info only created and parsed,
412  but not setup, checked or fixed.
413  */
414  virtual void set_part_info_low(partition_info *part_info, bool early);
415  /**
416  Initialize variables used before the table is opened.
417 
418  @param mem_root Memory root to allocate things from (not yet used).
419 
420  @return Operation status.
421  @retval false success.
422  @retval true failure.
423  */
424  bool init_partitioning(MEM_ROOT *mem_root MY_ATTRIBUTE((unused))) {
425 #ifndef DBUG_OFF
427 #endif
428  return false;
429  }
430 
431  /**
432  INSERT/UPDATE/DELETE functions.
433  @see handler.h
434  @{
435  */
436 
437  /**
438  Insert a row to the partitioned table.
439 
440  @param buf The row in MySQL Row Format.
441 
442  @return Operation status.
443  @retval 0 Success
444  @retval != 0 Error code
445  */
446  int ph_write_row(uchar *buf);
447  /**
448  Update an existing row in the partitioned table.
449 
450  Yes, update_row() does what you expect, it updates a row. old_data will
451  have the previous row record in it, while new_data will have the newest
452  data in it.
453  Keep in mind that the server can do updates based on ordering if an
454  ORDER BY clause was used. Consecutive ordering is not guaranteed.
455 
456  If the new record belongs to a different partition than the old record
457  then it will be inserted into the new partition and deleted from the old.
458 
459  new_data is always record[0]
460  old_data is always record[1]
461 
462  @param old_data The old record in MySQL Row Format.
463  @param new_data The new record in MySQL Row Format.
464 
465  @return Operation status.
466  @retval 0 Success
467  @retval != 0 Error code
468  */
469  int ph_update_row(const uchar *old_data, uchar *new_data);
470  /**
471  Delete an existing row in the partitioned table.
472 
473  This will delete a row. buf will contain a copy of the row to be deleted.
474  The server will call this right after the current row has been read
475  (from either a previous rnd_xxx() or index_xxx() call).
476  If you keep a pointer to the last row or can access a primary key it will
477  make doing the deletion quite a bit easier.
478  Keep in mind that the server does no guarantee consecutive deletions.
479  ORDER BY clauses can be used.
480 
481  buf is either record[0] or record[1]
482 
483  @param buf The record in MySQL Row Format.
484 
485  @return Operation status.
486  @retval 0 Success
487  @retval != 0 Error code
488  */
489  int ph_delete_row(const uchar *buf);
490 
491  /** @} */
492 
493  /** Release unused auto increment values. */
495  /**
496  Calculate key hash value from an null terminated array of fields.
497  Support function for KEY partitioning.
498 
499  @param field_array An array of the fields in KEY partitioning
500 
501  @return hash_value calculated
502 
503  @note Uses the hash function on the character set of the field.
504  Integer and floating point fields use the binary character set by default.
505  */
506  static uint32 ph_calculate_key_hash_value(Field **field_array);
507 
508  /**
509  MODULE full table scan
510 
511  This module is used for the most basic access method for any table
512  handler. This is to fetch all data through a full table scan. No
513  indexes are needed to implement this part.
514  It contains one method to start the scan (rnd_init) that can also be
515  called multiple times (typical in a nested loop join). Then proceeding
516  to the next record (rnd_next) and closing the scan (rnd_end).
517  To remember a record for later access there is a method (position)
518  and there is a method used to retrieve the record based on the stored
519  position.
520  The position can be a file position, a primary key, a ROWID dependent
521  on the handler below.
522 
523  unlike index_init(), rnd_init() can be called two times
524  without rnd_end() in between (it only makes sense if scan=1).
525  then the second call should prepare for the new table scan
526  (e.g if rnd_init allocates the cursor, second call should
527  position it to the start of the table, no need to deallocate
528  and allocate it again.
529  @see handler.h
530  @{
531  */
532 
533  int ph_rnd_init(bool scan);
534  int ph_rnd_end();
535  int ph_rnd_next(uchar *buf);
536  void ph_position(const uchar *record);
537 
538  /** @} */
539 
540  /**
541  MODULE index scan
542 
543  This part of the handler interface is used to perform access through
544  indexes. The interface is defined as a scan interface but the handler
545  can also use key lookup if the index is a unique index or a primary
546  key index.
547  Index scans are mostly useful for SELECT queries but are an important
548  part also of UPDATE, DELETE, REPLACE and CREATE TABLE table AS SELECT
549  and so forth.
550  Naturally an index is needed for an index scan and indexes can either
551  be ordered, hash based. Some ordered indexes can return data in order
552  but not necessarily all of them.
553  There are many flags that define the behavior of indexes in the
554  various handlers. These methods are found in the optimizer module.
555  -------------------------------------------------------------------------
556 
557  index_read is called to start a scan of an index. The find_flag defines
558  the semantics of the scan. These flags are defined in
559  include/my_base.h
560  index_read_idx is the same but also initializes index before calling doing
561  the same thing as index_read. Thus it is similar to index_init followed
562  by index_read. This is also how we implement it.
563 
564  index_read/index_read_idx does also return the first row. Thus for
565  key lookups, the index_read will be the only call to the handler in
566  the index scan.
567 
568  index_init initializes an index before using it and index_end does
569  any end processing needed.
570  @{
571  */
572 
573  int ph_index_init_setup(uint key_nr, bool sorted);
574  /*
575  These methods are used to jump to next or previous entry in the index
576  scan. There are also methods to jump to first and last entry.
577  */
578  int ph_index_first(uchar *buf);
579  int ph_index_last(uchar *buf);
580  int ph_index_next(uchar *buf);
581  int ph_index_next_same(uchar *buf, uint keylen);
582  int ph_index_prev(uchar *buf);
583  int ph_index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map,
584  enum ha_rkey_function find_flag);
585  int ph_index_read_last_map(uchar *buf, const uchar *key,
586  key_part_map keypart_map);
587  int ph_index_read_idx_map(uchar *buf, uint index, const uchar *key,
588  key_part_map keypart_map,
589  enum ha_rkey_function find_flag);
590  int ph_read_range_first(const key_range *start_key, const key_range *end_key,
591  bool eq_range_arg, bool sorted);
592  int ph_read_range_next();
593  /** @} */
594 
595  /**
596  Functions matching Partition_handler API.
597  @{
598  */
599 
600  /**
601  Get statistics from a specific partition.
602  @param[out] stat_info Area to report values into.
603  @param[out] check_sum Check sum of partition.
604  @param[in] part_id Partition to report from.
605  */
606  virtual void get_dynamic_partition_info_low(ha_statistics *stat_info,
607  ha_checksum *check_sum,
608  uint part_id);
609 
610  /**
611  Prepare for reorganizing partitions by setting up
612  partition_info::read_partitions according to the partition_info
613  mark-up.
614 
615  This is helper method which can also be used by SEs implementing
616  support for reorganizing partitions through ALTER TABLE INPLACE
617  SE API.
618  */
620 
621  /** @} */
622 
623  protected:
624  /* Common helper functions to be used by inheriting engines. */
625 
626  /*
627  open/close functions.
628  */
629 
630  /**
631  Set m_part_share, Allocate internal bitmaps etc. used by open tables.
632 
633  @return Operation status.
634  @retval false success.
635  @retval true failure.
636  */
637  bool open_partitioning(Partition_share *part_share);
638  /**
639  Close partitioning for a table.
640 
641  Frees memory and release other resources.
642  */
643  void close_partitioning();
644 
645  /**
646  Lock auto increment value if needed.
647  */
648  void lock_auto_increment();
649 
650  /**
651  unlock auto increment.
652  */
653  inline void unlock_auto_increment() {
654  /*
655  If m_auto_increment_safe_stmt_log_lock is true, we have to keep the lock.
656  It will be set to false and thus unlocked at the end of the statement by
657  ha_partition::release_auto_increment.
658  */
661  m_auto_increment_lock = false;
662  }
663  }
664  /**
665  Get auto increment.
666 
667  Only to be used for auto increment values that are the first field in
668  an unique index.
669 
670  @param[in] increment Increment between generated numbers.
671  @param[in] nb_desired_values Number of values requested.
672  @param[out] first_value First reserved value (ULLONG_MAX on error).
673  @param[out] nb_reserved_values Number of values reserved.
674  */
676  ulonglong nb_desired_values,
677  ulonglong *first_value,
678  ulonglong *nb_reserved_values);
679 
680  /**
681  Initialize the record priority queue used for sorted index scans.
682  @return Operation status.
683  @retval 0 Success.
684  @retval != 0 Error code.
685  */
687  /**
688  Destroy the record priority queue used for sorted index scans.
689  */
691  /*
692  Administrative support functions.
693  */
694 
695  /** Print partitioning specific error.
696  @param error Error code.
697  @return false if error is printed else true.
698  */
699  bool print_partition_error(int error);
700  /**
701  Print a message row formatted for ANALYZE/CHECK/OPTIMIZE/REPAIR TABLE.
702 
703  Modeled after mi_check_print_msg.
704 
705  @param thd Thread context.
706  @param len Needed length for message buffer.
707  @param msg_type Message type.
708  @param db_name Database name.
709  @param table_name Table name.
710  @param op_name Operation name.
711  @param fmt Message (in printf format with additional arguments).
712 
713  @return Operation status.
714  @retval false for success else true.
715  */
716  bool print_admin_msg(THD *thd, uint len, const char *msg_type,
717  const char *db_name, const char *table_name,
718  const char *op_name, const char *fmt, ...)
719  MY_ATTRIBUTE((format(printf, 8, 9)));
720 
721  /**
722  Check/fix misplaced rows.
723 
724  @param read_part_id Partition to check/fix.
725  @param repair If true, move misplaced rows to correct partition.
726 
727  @return Operation status.
728  @retval 0 Success
729  @retval != 0 Error
730  */
731  int check_misplaced_rows(uint read_part_id, bool repair);
732  /**
733  Set used partitions bitmap from Alter_info.
734 
735  @return false if success else true.
736  */
737  bool set_altered_partitions();
738 
739  /**
740  Copy partitions as part of ALTER TABLE of partitions.
741 
742  SE and prepare_change_partitions has done all the preparations,
743  now it is time to actually copy the data from the reorganized
744  partitions to the new partitions.
745 
746  @param[out] deleted Number of records deleted.
747 
748  @return Operation status
749  @retval 0 Success
750  @retval >0 Error code
751  */
752  virtual int copy_partitions(ulonglong *const deleted);
753 
754  private:
763  };
764 
765  /** handler to use (ha_innopart etc.) */
767  /*
768  Access methods to protected areas in handler to avoid adding
769  friend class Partition_helper in class handler.
770  */
771  virtual THD *get_thd() const = 0;
772  virtual TABLE *get_table() const = 0;
773  virtual bool get_eq_range() const = 0;
774  virtual void set_eq_range(bool eq_range) = 0;
775  virtual void set_range_key_part(KEY_PART_INFO *key_part) = 0;
776 
777  /*
778  Implementation of per partition operation by instantiated engine.
779  These must be implemented in the 'real' partition_helper subclass.
780  */
781 
782  /**
783  Write a row in the specified partition.
784 
785  @see handler::write_row().
786 
787  @param part_id Partition to write to.
788  @param buf Buffer with data to write.
789 
790  @return Operation status.
791  @retval 0 Success.
792  @retval != 0 Error code.
793  */
794  virtual int write_row_in_part(uint part_id, uchar *buf) = 0;
795  /**
796  Update a row in the specified partition.
797 
798  @see handler::update_row().
799 
800  @param part_id Partition to update in.
801  @param old_data Buffer containing old row.
802  @param new_data Buffer containing new row.
803 
804  @return Operation status.
805  @retval 0 Success.
806  @retval != 0 Error code.
807  */
808  virtual int update_row_in_part(uint part_id, const uchar *old_data,
809  uchar *new_data) = 0;
810  /**
811  Delete an existing row in the specified partition.
812 
813  @see handler::delete_row().
814 
815  @param part_id Partition to delete from.
816  @param buf Buffer containing row to delete.
817 
818  @return Operation status.
819  @retval 0 Success.
820  @retval != 0 Error code.
821  */
822  virtual int delete_row_in_part(uint part_id, const uchar *buf) = 0;
823  /**
824  Initialize the shared auto increment value.
825 
826  @param no_lock If HA_STATUS_NO_LOCK should be used in info(HA_STATUS_AUTO).
827 
828  Also sets stats.auto_increment_value.
829  */
830  virtual int initialize_auto_increment(bool no_lock) = 0;
831  /** Release auto_increment in all underlying partitions. */
833  /** Save or persist the current max auto increment. */
834  virtual void save_auto_increment(ulonglong nr MY_ATTRIBUTE((unused))) {}
835  /**
836  Per partition equivalent of rnd_* and index_* functions.
837 
838  @see class handler.
839  */
840  virtual int rnd_init_in_part(uint part_id, bool table_scan) = 0;
841  int ph_rnd_next_in_part(uint part_id, uchar *buf);
842  virtual int rnd_next_in_part(uint part_id, uchar *buf) = 0;
843  virtual int rnd_end_in_part(uint part_id, bool scan) = 0;
844  virtual void position_in_last_part(uchar *ref, const uchar *row) = 0;
845  virtual int index_first_in_part(uint part, uchar *buf) = 0;
846  virtual int index_last_in_part(uint part, uchar *buf) = 0;
847  virtual int index_prev_in_part(uint part, uchar *buf) = 0;
848  virtual int index_next_in_part(uint part, uchar *buf) = 0;
849  virtual int index_next_same_in_part(uint part, uchar *buf, const uchar *key,
850  uint length) = 0;
851  virtual int index_read_map_in_part(uint part, uchar *buf, const uchar *key,
852  key_part_map keypart_map,
853  enum ha_rkey_function find_flag) = 0;
854  virtual int index_read_last_map_in_part(uint part, uchar *buf,
855  const uchar *key,
856  key_part_map keypart_map) = 0;
857  /**
858  Do read_range_first in the specified partition.
859  If buf is set, then copy the result there instead of table->record[0].
860  */
861  virtual int read_range_first_in_part(uint part, uchar *buf,
862  const key_range *start_key,
863  const key_range *end_key,
864  bool sorted) = 0;
865  /**
866  Do read_range_next in the specified partition.
867  If buf is set, then copy the result there instead of table->record[0].
868  */
869  virtual int read_range_next_in_part(uint part, uchar *buf) = 0;
870  virtual int index_read_idx_map_in_part(uint part, uchar *buf, uint index,
871  const uchar *key,
872  key_part_map keypart_map,
873  enum ha_rkey_function find_flag) = 0;
874  /**
875  Initialize engine specific resources for the record priority queue
876  used duing ordered index reads for multiple partitions.
877 
878  @param used_parts Number of partitions used in query
879  (number of set bits in m_part_info->read_partitions).
880 
881  @return Operation status.
882  @retval 0 Success.
883  @retval != 0 Error code.
884  */
886  uint used_parts MY_ATTRIBUTE((unused))) {
887  return 0;
888  }
889  /**
890  Destroy and release engine specific resources used by the record
891  priority queue.
892  */
894  /**
895  Checksum for a partition.
896 
897  @param part_id Partition to checksum.
898  */
900  uint part_id MY_ATTRIBUTE((unused))) const {
901  DBUG_ASSERT(0);
902  return 0;
903  }
904  /**
905  Copy a cached row.
906 
907  Used when copying a row from the record priority queue to the return buffer.
908  For some engines, like InnoDB, only marked columns must be copied,
909  to preserve non-read columns.
910 
911  @param[out] to_rec Buffer to copy to.
912  @param[in] from_rec Buffer to copy from.
913  */
914  virtual void copy_cached_row(uchar *to_rec, const uchar *from_rec) {
915  memcpy(to_rec, from_rec, m_rec_length);
916  }
917 
918  /**
919  write row to new partition.
920  @param new_part New partition to write to.
921 
922  @return Operation status.
923  @retval 0 Success.
924  @retval != 0 Error code.
925  */
926  virtual int write_row_in_new_part(uint new_part) = 0;
927 
928  /* Internal helper functions*/
929  /**
930  Update auto increment value if current row contains a higher value.
931  */
932  inline void set_auto_increment_if_higher();
933  /**
934  Common routine to set up index scans.
935 
936  Find out which partitions we'll need to read when scanning the specified
937  range.
938 
939  If we need to scan only one partition, set m_ordered_scan_ongoing=false
940  as we will not need to do merge ordering.
941 
942  @param buf Buffer to later return record in (this function
943  needs it to calculate partitioning function values)
944 
945  @param idx_read_flag True <=> m_start_key has range start endpoint which
946  probably can be used to determine the set of
947  partitions to scan.
948  False <=> there is no start endpoint.
949 
950  @return Operation status.
951  @retval 0 Success
952  @retval !=0 Error code
953  */
954  int partition_scan_set_up(uchar *buf, bool idx_read_flag);
955  /**
956  Common routine to handle index_next with unordered results.
957 
958  These routines are used to scan partitions without considering order.
959  This is performed in two situations.
960  1) In read_multi_range this is the normal case
961  2) When performing any type of index_read, index_first, index_last where
962  all fields in the partition function is bound. In this case the index
963  scan is performed on only one partition and thus it isn't necessary to
964  perform any sort.
965 
966  @param[out] buf Read row in MySQL Row Format.
967  @param[in] is_next_same Called from index_next_same.
968 
969  @return Operation status.
970  @retval HA_ERR_END_OF_FILE End of scan
971  @retval 0 Success
972  @retval other Error code
973  */
974  int handle_unordered_next(uchar *buf, bool is_next_same);
975  /**
976  Handle index_next when changing to new partition.
977 
978  This routine is used to start the index scan on the next partition.
979  Both initial start and after completing scan on one partition.
980 
981  @param[out] buf Read row in MySQL Row Format
982 
983  @return Operation status.
984  @retval HA_ERR_END_OF_FILE End of scan
985  @retval 0 Success
986  @retval other Error code
987  */
989  /**
990  Common routine to start index scan with ordered results.
991 
992  @param[out] buf Read row in MySQL Row Format
993 
994  @return Operation status
995  @retval HA_ERR_END_OF_FILE End of scan
996  @retval HA_ERR_KEY_NOT_FOUND End of scan
997  @retval 0 Success
998  @retval other Error code
999  */
1000  int handle_ordered_index_scan(uchar *buf);
1001  /**
1002  Add index_next/prev results from partitions without exact match.
1003 
1004  If there where any partitions that returned HA_ERR_KEY_NOT_FOUND when
1005  ha_index_read_map was done, those partitions must be included in the
1006  following index_next/prev call.
1007 
1008  @return Operation status
1009  @retval HA_ERR_END_OF_FILE End of scan
1010  @retval 0 Success
1011  @retval other Error code
1012  */
1014  /**
1015  Common routine to handle index_prev with ordered results.
1016 
1017  @param[out] buf Read row in MySQL Row Format.
1018 
1019  @return Operation status.
1020  @retval HA_ERR_END_OF_FILE End of scan
1021  @retval 0 Success
1022  @retval other Error code
1023  */
1024  int handle_ordered_prev(uchar *buf);
1025  /**
1026  Common routine to handle index_next with ordered results.
1027 
1028  @param[out] buf Read row in MySQL Row Format.
1029  @param[in] is_next_same Called from index_next_same.
1030 
1031  @return Operation status.
1032  @retval HA_ERR_END_OF_FILE End of scan
1033  @retval 0 Success
1034  @retval other Error code
1035  */
1036  int handle_ordered_next(uchar *buf, bool is_next_same);
1037  /**
1038  Common routine for a number of index_read variants.
1039 
1040  @param[out] buf Buffer where the record should be returned.
1041  @param[in] have_start_key true <=> the left endpoint is available, i.e.
1042  we're in index_read call or in read_range_first
1043  call and the range has left endpoint.
1044  false <=> there is no left endpoint (we're in
1045  read_range_first() call and the range has no
1046  left endpoint).
1047 
1048  @return Operation status
1049  @retval 0 OK
1050  @retval HA_ERR_END_OF_FILE Whole index scanned, without finding the
1051  record.
1052  @retval HA_ERR_KEY_NOT_FOUND Record not found, but index cursor
1053  positioned.
1054  @retval other Error code.
1055  */
1056  int common_index_read(uchar *buf, bool have_start_key);
1057  /**
1058  Common routine for index_first/index_last.
1059 
1060  @param[out] buf Read row in MySQL Row Format.
1061 
1062  @return Operation status.
1063  @retval 0 Success
1064  @retval != 0 Error code
1065  */
1066  int common_first_last(uchar *buf);
1067  /**
1068  Return the top record in sort order.
1069 
1070  @param[out] buf Row returned in MySQL Row Format.
1071  */
1072  void return_top_record(uchar *buf);
1073 
1074  /**
1075  Set table->read_set taking partitioning expressions into account.
1076  */
1077  void set_partition_read_set();
1078 
1079  /*
1080  These could be private as well,
1081  but easier to expose them to derived classes to use.
1082  */
1083  protected:
1084  /** Convenience pointer to table from m_handler (i.e. m_handler->table). */
1086 
1087  /** All internal partitioning data! @{ */
1088  /** Tables partitioning info (same as table->part_info) */
1090  /** Is primary key clustered. */
1092  /** Cached value of m_part_info->is_sub_partitioned(). */
1094  /** Total number of partitions. */
1096  uint m_last_part; // Last accessed partition.
1097  const uchar *m_err_rec; // record which gave error.
1100  part_id_range m_part_spec; // Which parts to scan
1101  uint m_scan_value; // Value passed in rnd_init
1102  // call
1103  key_range m_start_key; // index read key range
1104  enum partition_index_scan_type m_index_scan_type; // What type of index
1105  // scan
1106  uint m_rec_length; // Local copy of record length
1107 
1108  bool m_ordered; // Ordered/Unordered index scan.
1109  bool m_ordered_scan_ongoing; // Ordered index scan ongoing.
1110  bool m_reverse_order; // Scanning in reverse order (prev).
1111  /** Row and key buffer for ordered index scan. */
1113  /** Prio queue used by sorted read. */
1115  /** Which partition is to deliver next result. */
1117  /** Offset in m_ordered_rec_buffer from part buffer to its record buffer. */
1119  /**
1120  Current index used for sorting.
1121  If clustered PK exists, then it will be used as secondary index to
1122  sort on if the first is equal in key_rec_cmp.
1123  So if clustered pk: m_curr_key_info[0]= current index and
1124  m_curr_key_info[1]= pk and [2]= NULL.
1125  Otherwise [0]= current index, [1]= NULL, and we will
1126  sort by rowid as secondary sort key if equal first key.
1127  */
1130  /** handler::ref is not copied to the PQ. */
1132  /**
1133  handler::ref is copied to the PQ but does not need to be used in sorting.
1134  */
1136  /** handler::ref is copied to the PQ and must be used during sorting. */
1138  };
1139  /** How handler::ref is used in the priority queue. */
1141  /** Set if previous index_* call returned HA_ERR_KEY_NOT_FOUND. */
1143  /** Partitions that returned HA_ERR_KEY_NOT_FOUND. */
1145  /** @} */
1146 
1147  private:
1148  /** Partition share for auto_inc handling. */
1150 };
1151 #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:74
Partition specific Handler_share.
Definition: partition_handler.h:102
Definition: partition_info.h:208
uint m_rec_length
Definition: partition_handler.h:1106
virtual void release_auto_increment_all_parts()
Release auto_increment in all underlying partitions.
Definition: partition_handler.h:832
Instrumentation helpers for mutexes.
enum_using_ref m_ref_usage
How handler::ref is used in the priority queue.
Definition: partition_handler.h:1140
Class for partitioning specific operations.
Definition: partition_handler.h:192
unsigned char uchar
Definition: my_inttypes.h:51
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:1128
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:759
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:3512
Definition: partition_handler.h:761
virtual THD * get_thd() const =0
key_range m_start_key
Definition: partition_handler.h:1103
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:758
ulong key_part_map
Definition: my_base.h:998
key_compare_fun m_fun
Definition: partition_handler.h:377
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
Command not supported.
Definition: my_base.h:835
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:1110
virtual int index_last_in_part(uint part, uchar *buf)=0
bool m_auto_increment_lock
Definition: partition_handler.h:1099
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:1089
Definition: field.h:709
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:1142
uint m_top_entry
Which partition is to deliver next result.
Definition: partition_handler.h:1116
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:1137
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:424
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:1114
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:3987
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:560
uint m_scan_value
Definition: partition_handler.h:1101
virtual int index_first_in_part(uint part, uchar *buf)=0
#define UINT_MAX32
Definition: my_inttypes.h:106
Definition: table.h:1294
uint m_last_part
Definition: partition_handler.h:1096
bool m_ordered
Definition: partition_handler.h:1108
enum partition_index_scan_type m_index_scan_type
Definition: partition_handler.h:1104
part_id_range m_part_spec
Definition: partition_handler.h:1100
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:760
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:183
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:1135
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:2847
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:1144
bool m_auto_increment_safe_stmt_log_lock
Definition: partition_handler.h:1098
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:1097
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:1085
Definition: key.h:55
uint m_rec_offset
Definition: partition_handler.h:378
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:653
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:893
Definition: partition_handler.h:756
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:342
bool m_pkey_is_clustered
Is primary key clustered.
Definition: partition_handler.h:1091
bool operator()(uchar *first, uchar *second)
Definition: partition_handler.h:370
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:1118
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.
uint32_t uint32
Definition: my_inttypes.h:62
virtual ha_checksum checksum_in_part(uint part_id) const
Checksum for a partition.
Definition: partition_handler.h:899
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:379
bool m_ordered_scan_ongoing
Definition: partition_handler.h:1109
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:1114
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:1093
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:834
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:1129
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:367
KEY ** m_keys
Definition: partition_handler.h:376
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:360
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:885
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
handler::ref is not copied to the PQ.
Definition: partition_handler.h:1131
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:762
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:1149
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:2607
#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:766
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:150
virtual int truncate_partition_low(dd::Table *)
Truncate partition.
Definition: partition_handler.h:331
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:1095
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:399
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:365
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:914
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:3433
Definition: partition_handler.h:757
partition_index_scan_type
Definition: partition_handler.h:755
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:397
#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:364
Definition: partition_handler.h:80
void lock_auto_inc()
lock mutex protecting auto increment value next_auto_inc_val.
Definition: partition_handler.h:143
virtual enum row_type get_partition_row_type(const dd::Table *table, uint part_id)=0
Get partition row type from SE.
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:777
row_type
Definition: handler.h:671
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:1112