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