summaryrefslogtreecommitdiff
path: root/sql/partition_info.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.8 into 10.9Marko Mäkelä2023-02-161-1/+1
|\
| * Merge 10.6 into 10.8Marko Mäkelä2023-02-101-1/+1
| |\
| | * Merge 10.4 into 10.5Marko Mäkelä2023-02-101-1/+1
| | |\
| | | * Apply clang-tidy to remove empty constructors / destructorsVicențiu Ciorbaru2023-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is the result of running run-clang-tidy -fix -header-filter=.* -checks='-*,modernize-use-equals-default' . Code style changes have been done on top. The result of this change leads to the following improvements: 1. Binary size reduction. * For a -DBUILD_CONFIG=mysql_release build, the binary size is reduced by ~400kb. * A raw -DCMAKE_BUILD_TYPE=Release reduces the binary size by ~1.4kb. 2. Compiler can better understand the intent of the code, thus it leads to more optimization possibilities. Additionally it enabled detecting unused variables that had an empty default constructor but not marked so explicitly. Particular change required following this patch in sql/opt_range.cc result_keys, an unused template class Bitmap now correctly issues unused variable warnings. Setting Bitmap template class constructor to default allows the compiler to identify that there are no side-effects when instantiating the class. Previously the compiler could not issue the warning as it assumed Bitmap class (being a template) would not be performing a NO-OP for its default constructor. This prevented the "unused variable warning".
* | | | Merge 10.8 into 10.9Marko Mäkelä2022-12-131-1/+0
|\ \ \ \ | |/ / /
| * | | Merge 10.6 into 10.7Marko Mäkelä2022-12-131-1/+0
| |\ \ \ | | |/ /
| | * | Merge 10.4 into 10.5Marko Mäkelä2022-12-131-1/+0
| | |\ \ | | | |/
| | | * Merge 10.3 into 10.4Marko Mäkelä2022-12-131-1/+0
| | | |\
| | | | * MDEV-30036 NULL pointer dereference in ↵Sergei Golubchik2022-12-021-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | partition_info::set_partition_bitmaps_from_table remove dead code
* | | | | Merge 10.8 into 10.9Marko Mäkelä2022-11-211-0/+5
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-29841 More descriptive text for ER_PARTITION_WRONG_TYPEbb-10.7-midenokAleksey Midenkov2022-11-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For commands (1) alter table t1 add partition (partition p2); (2) alter table t1 add partition (partition px history); It printed the same error message: Wrong partitioning type, expected type: `SYSTEM_TIME` For (1) it is not clear from the syntax that we are trying to add HASH partition. For (2) it is not clear that the table partitioning is different than SYSTEM_TIME. Now it prints what type we are trying to add to what type of partitioning. Fixed warning unused function rename_field_in_list() for compilation without partitioning.
| * | | | Revert "MDEV-29841 More descriptive text for ER_PARTITION_WRONG_TYPE"Marko Mäkelä2022-11-101-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 6f8fb41f213dd34b43ef6f3819b4be12f6b26c01 because it broke cmake -DPLUGIN_PARTITION=NO
| * | | | MDEV-29841 More descriptive text for ER_PARTITION_WRONG_TYPEAleksey Midenkov2022-10-311-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For commands (1) alter table t1 add partition (partition p2); (2) alter table t1 add partition (partition px history); It printed the same error message: Wrong partitioning type, expected type: `SYSTEM_TIME` For (1) it is not clear from the syntax that we are trying to add HASH partition. For (2) it is not clear that the table partitioning is different than SYSTEM_TIME. Now it prints what type we are trying to add to what type of partitioning.
* | | | | Merge 10.8 into 10.9Marko Mäkelä2022-10-131-0/+8
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.6 into 10.7Marko Mäkelä2022-10-131-0/+8
| |\ \ \ \ | | |/ / /
| | * | | MDEV-28576 RENAME COLUMN with NOCOPY algorithm leads to corrupt partitioned ↵Aleksey Midenkov2022-10-071-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | table 10.5 part: test cases and comments. The code is in the merge commit 74fe1c44aa1 When f.ex. table is partitioned by HASH(a) and we rename column `a' to `b' partitioning filter stays unchanged: HASH(a). That's the wrong behavior. The patch updates partitioning filter in accordance to the new columns names. That includes partition/subpartition expression and partition/subpartition field list.
* | | | | Merge branch '10.8' into 10.9mariadb-10.9.1Sergei Golubchik2022-05-191-0/+6
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.6' into 10.7Sergei Golubchik2022-05-111-0/+6
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.4' into 10.5Sergei Golubchik2022-05-091-0/+6
| | |\ \ \ | | | |/ /
| | | * | Merge branch '10.3' into 10.4Sergei Golubchik2022-05-081-0/+6
| | | |\ \ | | | | |/
| | | | * MDEV-20077 Warning on full history partition is delayed until next DML statementAleksey Midenkov2022-04-291-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Moved LIMIT warning from vers_set_hist_part() to new call vers_check_limit() at table unlock phase. At that point read_partitions bitmap is already pruned by DML code (see prune_partitions(), find_used_partitions()) so we have to set corresponding bits for working history partition. Also we don't do my_error(ME_WARNING|ME_ERROR_LOG), because at that point it doesn't update warnings number, so command reports 0 warnings (but warning list is still updated). Instead we do push_warning_printf() and sql_print_warning() separately. Under LOCK TABLES external_lock(F_UNLCK) is not executed. There is start_stmt(), but no corresponding "stop_stmt()". So for that mode we call vers_check_limit() directly from close_thread_tables(). Test result has been changed according to new LIMIT and warning printing algorithm. For convenience all LIMIT warnings are marked with "You see warning above ^". TODO MDEV-20345 fixed. Now vers_history_generating() contains fine-grained list of DML-commands that can generate history (and TODO mechanism worked well).
* | | | | MDEV-17554 Auto-create new partition for system versioned tables with ↵Aleksey Midenkov2022-05-061-15/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | history partitioned by INTERVAL/LIMIT :: Syntax change :: Keyword AUTO enables history partition auto-creation. Examples: CREATE TABLE t1 (x int) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR AUTO; CREATE TABLE t1 (x int) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME INTERVAL 1 MONTH STARTS '2021-01-01 00:00:00' AUTO PARTITIONS 12; CREATE TABLE t1 (x int) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME LIMIT 1000 AUTO; Or with explicit partitions: CREATE TABLE t1 (x int) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR AUTO (PARTITION p0 HISTORY, PARTITION pn CURRENT); To disable or enable auto-creation one can use ALTER TABLE by adding or removing AUTO from partitioning specification: CREATE TABLE t1 (x int) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR AUTO; # Disables auto-creation: ALTER TABLE t1 PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR; # Enables auto-creation: ALTER TABLE t1 PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR AUTO; If the rest of partitioning specification is identical to CREATE TABLE no repartitioning will be done (for details see MDEV-27328). :: Description :: Before executing history-generating DML command (see the list of commands below) add N history partitions, so that N would be sufficient for potentially generated history. N > 1 may be required when history partitions are switched by INTERVAL and current_timestamp is N times further than the interval boundary of the last history partition. If the last history partition equals or exceeds LIMIT records then new history partition is created and selected as the working partition. According to MDEV-28411 partitions cannot be switched (or created) while the command is running. Thus LIMIT does not carry strict limitation and the history partition size must be planned as LIMIT value plus average number of history one DML command can generate. Auto-creation is implemented by synchronous fast_alter_partition_table() call from the thread of the executed DML command before the command itself is run (by the fallback and retry mechanism similar to Discovery feature, see Open_table_context). The name for newly added partitions are generated like default partition names with extension of MDEV-22155 (which avoids name clashes by extending assignment counter to next free-enough gap). These DML commands can trigger auto-creation: DELETE (including multitable DELETE, excluding DELETE HISTORY) UPDATE (including multitable UPDATE) REPLACE (including REPLACE .. SELECT) INSERT .. ON DUPLICATE KEY UPDATE (including INSERT .. SELECT .. ODKU) LOAD DATA .. REPLACE :: Bug fixes :: MDEV-23642 Locking timeout caused by auto-creation affects original DML The reasons for this are: - Do not disrupt main business process (the history is auxiliary service); - Consequences are non-fatal (history is not lost, but comes into wrong partition; fixed by partitioning rebuild); - There is more freedom for application to fail in this case or not: it may read warning info and find corresponding error number. - While non-failing command is easy to handle by an application and fail it, the opposite is hard to handle: there is no automatic actions to fix failed command and retry, DBA intervention is required and until then application is non-functioning. MDEV-23639 Auto-create does not work under LOCK TABLES or inside triggers Don't do tdc_remove_table() for OT_ADD_HISTORY_PARTITION because it is not possible in locked tables mode. LTM_LOCK_TABLES mode (and LTM_PRELOCKED_UNDER_LOCK_TABLES) works out of the box as fast_alter_partition_table() can reopen tables via locked_tables_list. In LTM_PRELOCKED we reopen and relock table manually. :: More fixes :: * some_table_marked_for_reopen flag fix some_table_marked_for_reopen affets only reopen of m_locked_tables. I.e. Locked_tables_list::reopen_tables() reopens only tables from m_locked_tables. * Unused can_recover_from_failed_open() condition Is recover_from_failed_open() can be really used after open_and_process_routine()? :: Reviewed by :: Sergei Golubchik <serg@mariadb.org>
* | | | | MDEV-27328 Change of SYSTEM_TIME partitioning options is not possible ↵Aleksey Midenkov2022-05-061-1/+10
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | without data copy When we need to add/remove or change LIMIT, INTERVAL, AUTO we have to recreate partitioning from scratch (via data copy). Such operations should be done fast. To remove options like LIMIT or INTERVAL one should write: alter table t1 partition by system_time; The command checks whether it is new or existing SYSTEM_TIME partitioning. And in the case of new it behaves as CREATE would do: adds default number of partitions (2). If SYSTEM_TIME partitioning already existed it just changes its options: removes unspecified ones and adds/changes those specified explicitly. In case when partitions list was supplied it behaves as usual: does full repartitioning. Examples: create or replace table t1 (x int) with system versioning partition by system_time limit 100 partitions 4; # Change LIMIT alter table t1 partition by system_time limit 33; # Remove LIMIT alter table t1 partition by system_time; # This does full repartitioning alter table t1 partition by system_time limit 33 partitions 4; # This does data copy as pruning will require records in correct partitions alter table t1 partition by system_time interval 1 hour starts '2000-01-01 00:00:00'; # But this works fast, LIMIT will apply to DML commands alter table t1 partition by system_time limit 33; To sum up, ALTER for SYSTEM_TIME partitioning does full repartitioning when: - INTERVAL was added or changed; - partition list or partition number was specified; Otherwise it does fast alter table. Cleaned up dead condition in set_up_default_partitions(). Reviewed by: Oleksandr Byelkin <sanja@mariadb.com> Nikita Malyavin <nikitamalyavin@gmail.com>
* | | | Merge branch '10.6' into 10.7Oleksandr Byelkin2022-02-041-2/+2
|\ \ \ \ | |/ / /
| * | | Merge branch '10.4' into 10.5Oleksandr Byelkin2022-02-011-2/+2
| |\ \ \ | | |/ /
| | * | Merge branch '10.3' into 10.4Oleksandr Byelkin2022-01-301-2/+2
| | |\ \ | | | |/
| | | * Merge branch '10.2' into 10.3mariadb-10.3.33Oleksandr Byelkin2022-01-291-1/+1
| | | |\
| | | | * MDEV-25917 create table like fails if source table is partitioned and engine ↵Alexey Botchkov2022-01-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | is myisam or aria with data directory. Create table like removes data_file_path/index_file_path from the thd->work_partition_info.
| | | * | MDEV-27217 DELETE partition selection doesn't work for history partitionsAleksey Midenkov2022-01-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LIMIT history switching requires the number of history partitions to be marked for read: from first to last non-empty plus one empty. The least we can do is to fail with error message if the needed partition was not marked for read. As this is handler interface we require new handler error code to display user-friendly error message. Switching by INTERVAL works out-of-the-box with ER_ROW_DOES_NOT_MATCH_GIVEN_PARTITION_SET error.
* | | | | Vanilla cleanups and refactoringsAleksey Midenkov2021-10-261-6/+2
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Dead code cleanup: part_info->num_parts usage was wrong and working incorrectly in mysql_drop_partitions() because num_parts is already updated in prep_alter_part_table(). We don't have to update part_info->partitions because part_info is destroyed at alter_partition_lock_handling(). Cleanups: - DBUG_EVALUATE_IF() macro replaced by shorter form DBUG_IF(); - Typo in ER_KEY_COLUMN_DOES_NOT_EXITS. Refactorings: - Splitted write_log_replace_delete_frm() into write_log_delete_frm() and write_log_replace_frm(); - partition_info via DDL_LOG_STATE; - set_part_info_exec_log_entry() removed. DBUG_EVALUATE removed DBUG_EVALUTATE was only added for consistency together with DBUG_EVALUATE_IF. It is not used anywhere in the code. DBUG_SUICIDE() fix on release build On release DBUG_SUICIDE() was statement. It was wrong as DBUG_SUICIDE() is used in expression context.
* | | | Compilation fixbb-10.5-6915-extAleksey Midenkov2020-04-271-0/+2
| | | |
* | | | MDEV-22155 ALTER add default history partitions name clash on non-default ↵Aleksey Midenkov2020-04-271-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | partitions If any of default names clashes with existing names find next large enough name gap for the requested number of partitions.
* | | | Revert "MDEV-17554 Auto-create new partition for system versioned tables ↵Sergei Golubchik2020-02-271-38/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | with history partitioned by INTERVAL/LIMIT" This reverts commit 9894751a2a61ef952ac6ac556fd683e53fc150e2. This reverts commit f707c83fff4fa3f5291684e6226542fdb75bbdeb.
* | | | MDEV-17554 Auto-create new partition for system versioned tables with ↵Aleksey Midenkov2020-02-251-3/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | history partitioned by INTERVAL/LIMIT When there are E empty partitions left, auto-create N new empty partitions for SYSTEM_TIME partitioning rotated by INTERVAL/LIMIT and marked by AUTO_INCREMENT keyword. Syntax change: AUTO_INCREMENT keyword (or shorter AUTO may be used instead) after LIMIT/INTERVAL clause. CREATE OR REPLACE TABLE t (x INT) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME LIMIT 100000 AUTO_INCREMENT; CREATE OR REPLACE TABLE t (x INT) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME INTERVAL 1 WEEK AUTO_INCREMENT; The current revision implements hard-coded values of 1 for E and N. As well as auto-creation threshold MinInterval = 1 hour, MinLimit = 1000. The name for newly added partition will be first chosen as "pX", where X is partition number and "p" is hard-coded name prefix. If this name is already occupied, the X will be incremented until the resulting name will be free to use. ALTER TABLE ADD PARTITION is now always fast. If there some history partition overflow occurs manual ALTER TABLE REBUILD PARTITION is needed.
* | | | MDEV-17554 history partitioning cleanupsAleksey Midenkov2019-12-031-4/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fixed missed warning on condition boundary * REORGANIZE cases * vers_utils.h removed * test cases cleanup
* | | | MDEV-17553 Enable setting start datetime for interval partitioned history of ↵Aleksey Midenkov2019-11-071-21/+3
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | system versioned tables * Explicit STARTS syntax * SHOW CREATE * Default STARTS rounding depending on INTERVAL type * Warn when STARTS timestamp is later than query time * Fix uninitialized Lex->create_last_non_select_table under mysql_unpack_partition() Default STARTS rounding depending on INTERVAL type If STARTS clause is omitted, default one is assigned with value derived from query timestamp. The rounding is done on STARTS value depending on INTERVAL type: SECOND: no rounding is done; MINUTE: timestamp seconds is set to 0; HOUR: timestamp seconds and minutes are set to 0; DAY, WEEK, MONTH and YEAR: timestamp seconds, minutes and hours are set to 0 (the date of rotation is kept as current date).
* | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-09-021-4/+3
|\ \ \ | |/ /
| * | MDEV-18501 Partition pruning doesn't work for historical queries (refactoring)Aleksey Midenkov2019-09-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | SYSTEM_TYPE partitioning: COLUMN properties removed. Partitioning is now pure RANGE based on UNIX_TIMESTAMP(row_end). DECIMAL type is now allowed as RANGE partitioning, we can partition by UNIX_TIMESTAMP() (but not for DATETIME which depends on local timezone of course).
| * | MDEV-18501 Partition pruning doesn't work for historical queries (cleanup)Aleksey Midenkov2019-09-011-2/+1
| | | | | | | | | | | | Cleanup removes useless allocation.
* | | Merge 10.3 into 10.4Marko Mäkelä2019-05-221-1/+10
|\ \ \ | |/ /
| * | MDEV-18136 Server crashes in Item_func_dyncol_create::prepare_argumentsAleksey Midenkov2019-05-201-2/+12
| | | | | | | | | | | | [Closes tempesta-tech/mariadb#572]
* | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-1/+1
|\ \ \ | |/ /
| * | Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
| |\ \ | | |/
| | * Merge 10.1 into 10.2Marko Mäkelä2019-05-131-1/+1
| | |\
| | | * Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-111-1/+1
| | | |\
| | | | * Update FSF AddressVicențiu Ciorbaru2019-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | * Update wrong zip-code
* | | | | Merge 10.3 into 10.4Marko Mäkelä2018-12-121-0/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.2 into 10.3Marko Mäkelä2018-12-121-0/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.1 into 10.2Marko Mäkelä2018-12-121-0/+1
| | |\ \ \ | | | |/ /
| | | * | Merge 10.0 into 10.1Marko Mäkelä2018-12-121-0/+1
| | | |\ \