MDEV-31918: Optimize check on sequences earlier for alter - #2729
Open
an3l wants to merge 1 commit into
Open
Conversation
an3l
force-pushed
the
bb-11.2-anel-fix-early-check-sequence
branch
2 times, most recently
from
August 17, 2023 14:53
4f4b929 to
5fce99d
Compare
an3l
force-pushed
the
bb-11.2-anel-fix-early-check-sequence
branch
3 times, most recently
from
March 13, 2024 08:34
a6db639 to
519413d
Compare
- When `alter` table is perfomed there is no reason to go to function `create_table_impl->mysql_create_frm_image->mysql_prepare_create_table`, (as code is currently doing, and what is happening for the `create` statement), but instead do check on the directly on created altered fields from function `mysql_prepare_alter_table`, that is called earlier than `create_table_impl`, from `mysql_alter_table`. - In that way benefit would be to do error check for the `alter` query only, on `mysql_prepare_alter_table` and to generate error earlier in the stack frame. The check will be done only once, and second check we are bypassing with newly created `alter_info->seq_checked` bit, so there will be no double calls of function `check_sequence_fields`. - For the `create` table statements error check will be done only once, from function `mysql_prepare_create_table` as it is intended and the patch is not related to `create` statement. - Reviewer: <>
an3l
force-pushed
the
bb-11.2-anel-fix-early-check-sequence
branch
from
March 14, 2024 11:09
519413d to
d6ede79
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
TODO: fill description here
How can this PR be tested?
Run the test case and check in gdb backtrace.
Result bt before the patch backtrace
#0 my_message_sql (error=21845, str=0x7ffff1f2e570 "\240\345\362\361\377\177", MyFlags=93825015206591) at /home/anel/GitHub/mariadb/server/src/10.5/sql/mysqld.cc:3094 #1 0x0000555556b2f5a6 in my_error (nr=4086, MyFlags=0) at /home/anel/GitHub/mariadb/server/src/10.5/mysys/my_error.c:124 #2 0x000055555612f898 in check_sequence_fields (lex=0x7fffe0004e30, fields=0x7ffff1f31270) at /home/anel/GitHub/mariadb/server/src/10.5/sql/sql_sequence.cc:237 #3 0x0000555555f92b67 in mysql_prepare_create_table (thd=0x7fffe0000d48, create_info=0x7ffff1f312e0, alter_info=0x7ffff1f311f0, db_options=0x7ffff1f2ec4c, file=0x7fffe0017760, key_info_buffer=0x7ffff1f2f5f8, key_count=0x7ffff1f2f5d8, create_table_mode=-2) at /home/anel/GitHub/mariadb/server/src/10.5/sql/sql_table.cc:3621 #4 0x0000555555f979d9 in mysql_create_frm_image (thd=0x7fffe0000d48, create_info=0x7ffff1f312e0, alter_info=0x7ffff1f311f0, create_table_mode=-2, key_info=0x7ffff1f2f5f8, key_count=0x7ffff1f2f5d8, frm=0x7ffff1f2f670) at /home/anel/GitHub/mariadb/server/src/10.5/sql/sql_table.cc:5069 #5 0x0000555555f98600 in create_table_impl (thd=0x7fffe0000d48, orig_db=@0x7ffff1f306b0: {str = 0x7fffe0016d10 "test", length = 4}, orig_table_name=@0x7ffff1f306c0: {str = 0x7fffe00165d0 "seq1", length = 4}, db=@0x7ffff1f306e0: {str = 0x7fffe0016d10 "test", length = 4}, table_name=@0x7ffff1f30710: {str = 0x7ffff1f30a4b "#sql-alter-9696-3", length = 17}, path=0x7ffff1f30f0e "/home/anel/GitHub/mariadb/server/build/10.5/mysql-test/var/tmp/mysqld.1/#sql-temptable-9696-3-1", options={m_options = DDL_options_st::OPT_NONE}, create_info=0x7ffff1f312e0, alter_info=0x7ffff1f311f0, create_table_mode=-2, is_trans=0x0, key_info=0x7ffff1f2f5f8, key_count=0x7ffff1f2f5d8, frm=0x7ffff1f2f670) at /home/anel/GitHub/mariadb/server/src/10.5/sql/sql_table.cc:5349 #6 0x0000555555fa8b43 in mysql_alter_table (thd=0x7fffe0000d48, new_db=0x7fffe00057d8, new_name=0x7fffe0005c28, create_info=0x7ffff1f312e0, table_list=0x7fffe0016610, recreate_info=0x7ffff1f311b0, alter_info=0x7ffff1f311f0, order_num=0, order=0x0, ignore=false, if_exists=false) at /home/anel/GitHub/mariadb/server/src/10.5/sql/sql_table.cc:10753Result bt after the patch (both for temporary and normal sequences):
Basing the PR against the correct MariaDB version
PR quality check