diff options
author | Nayuta Yanagisawa <nayuta.yanagisawa@hey.com> | 2021-11-05 16:39:28 +0900 |
---|---|---|
committer | Nayuta Yanagisawa <nayuta.yanagisawa@hey.com> | 2022-01-24 19:26:09 +0900 |
commit | c5d09f731ac1e7ddd18c019cf0b9cf4716c3aa3d (patch) | |
tree | 6619acb8c028e6d305ccfcb5836baf99423b1bd1 /sql/sql_yacc.yy | |
parent | 83dd7db69d73e931d1bdb4295524c4953ba38165 (diff) | |
download | mariadb-git-c5d09f731ac1e7ddd18c019cf0b9cf4716c3aa3d.tar.gz |
MDEV-5271 Support engine-defined attributes per partition
Make it possible to specify engine-defined attributes on partitions
as well as tables.
If an engine-defined attribute is only specified at the table level,
it applies to all the partitions in the table.
This is a backward-compatible behavior.
If the same attribute is specified both at the table level and the
partition level, the per-partition one takes precedence.
So, we can consider per-table attributes as default values.
One cannot specify engine-defined attributes on subpartitions.
Implementation details:
* We store per-partition attributes in the partition_element class
because we already have the part_comment field, which is for
per-partition comments.
* In the case of ALTER TABLE statements, the partition_elements in
table->part_info is set up by mysql_unpack_partition().
So, we parse per-partition attributes after the call of the function.
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r-- | sql/sql_yacc.yy | 136 |
1 files changed, 54 insertions, 82 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 8ebefbb3d82..315eba18703 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2021, MariaDB + Copyright (c) 2010, 2020, 2021, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -301,6 +301,7 @@ void _CONCAT_UNDERSCORED(turn_parser_debug_on,yyparse)() class With_element_head *with_element_head; class With_clause *with_clause; class Virtual_column_info *virtual_column; + engine_option_value *engine_option_value_ptr; handlerton *db_type; st_select_lex *select_lex; @@ -1802,6 +1803,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %type <vers_range_unit> opt_history_unit %type <vers_history_point> history_point %type <vers_column_versioning> with_or_without_system +%type <engine_option_value_ptr> engine_defined_option; %ifdef MARIADB %type <NONE> sp_tail_standalone @@ -5040,7 +5042,7 @@ sub_part_definition: part_info->use_default_num_subpartitions= FALSE; part_info->count_curr_subparts++; } - sub_name opt_part_options {} + sub_name opt_subpart_options {} ; sub_name: @@ -5054,15 +5056,34 @@ sub_name: opt_part_options: /* empty */ {} - | opt_part_option_list {} + | part_option_list {} ; -opt_part_option_list: - opt_part_option_list opt_part_option {} - | opt_part_option {} +part_option_list: + part_option_list part_option {} + | part_option {} ; -opt_part_option: +part_option: + server_part_option {} + | engine_defined_option + { + $1->link(&Lex->part_info->curr_part_elem->option_list, + &Lex->option_list_last); + } + ; + +opt_subpart_options: + /* empty */ {} + | subpart_option_list {} + ; + +subpart_option_list: + subpart_option_list server_part_option {} + | server_part_option {} + ; + +server_part_option: TABLESPACE opt_equal ident_or_text { /* Compatibility with MySQL */ } | opt_storage ENGINE_SYM opt_equal storage_engines @@ -5424,42 +5445,43 @@ create_table_option: Lex->create_info.used_fields|= HA_CREATE_USED_TRANSACTIONAL; Lex->create_info.transactional= $3; } - | IDENT_sys equal TEXT_STRING_sys + | engine_defined_option + { + $1->link(&Lex->create_info.option_list, &Lex->option_list_last); + } + | SEQUENCE_SYM opt_equal choice + { + Lex->create_info.used_fields|= HA_CREATE_USED_SEQUENCE; + Lex->create_info.sequence= ($3 == HA_CHOICE_YES); + } + | versioning_option + ; + +engine_defined_option: + IDENT_sys equal TEXT_STRING_sys { if (unlikely($3.length > ENGINE_OPTION_MAX_LENGTH)) my_yyabort_error((ER_VALUE_TOO_LONG, MYF(0), $1.str)); - (void) new (thd->mem_root) - engine_option_value($1, $3, true, - &Lex->create_info.option_list, - &Lex->option_list_last); + $$= new (thd->mem_root) engine_option_value($1, $3, true); + MYSQL_YYABORT_UNLESS($$); } | IDENT_sys equal ident { if (unlikely($3.length > ENGINE_OPTION_MAX_LENGTH)) my_yyabort_error((ER_VALUE_TOO_LONG, MYF(0), $1.str)); - (void) new (thd->mem_root) - engine_option_value($1, $3, false, - &Lex->create_info.option_list, - &Lex->option_list_last); + $$= new (thd->mem_root) engine_option_value($1, $3, false); + MYSQL_YYABORT_UNLESS($$); } | IDENT_sys equal real_ulonglong_num { - (void) new (thd->mem_root) - engine_option_value($1, $3, &Lex->create_info.option_list, - &Lex->option_list_last, thd->mem_root); + $$= new (thd->mem_root) engine_option_value($1, $3, thd->mem_root); + MYSQL_YYABORT_UNLESS($$); } | IDENT_sys equal DEFAULT { - (void) new (thd->mem_root) - engine_option_value($1, &Lex->create_info.option_list, - &Lex->option_list_last); + $$= new (thd->mem_root) engine_option_value($1); + MYSQL_YYABORT_UNLESS($$); } - | SEQUENCE_SYM opt_equal choice - { - Lex->create_info.used_fields|= HA_CREATE_USED_SEQUENCE; - Lex->create_info.sequence= ($3 == HA_CHOICE_YES); - } - | versioning_option ; opt_versioning_option: @@ -6350,35 +6372,9 @@ asrow_attribute: serial_attribute: asrow_attribute - | IDENT_sys equal TEXT_STRING_sys - { - if (unlikely($3.length > ENGINE_OPTION_MAX_LENGTH)) - my_yyabort_error((ER_VALUE_TOO_LONG, MYF(0), $1.str)); - (void) new (thd->mem_root) - engine_option_value($1, $3, true, - &Lex->last_field->option_list, - &Lex->option_list_last); - } - | IDENT_sys equal ident + | engine_defined_option { - if (unlikely($3.length > ENGINE_OPTION_MAX_LENGTH)) - my_yyabort_error((ER_VALUE_TOO_LONG, MYF(0), $1.str)); - (void) new (thd->mem_root) - engine_option_value($1, $3, false, - &Lex->last_field->option_list, - &Lex->option_list_last); - } - | IDENT_sys equal real_ulonglong_num - { - (void) new (thd->mem_root) - engine_option_value($1, $3, &Lex->last_field->option_list, - &Lex->option_list_last, thd->mem_root); - } - | IDENT_sys equal DEFAULT - { - (void) new (thd->mem_root) - engine_option_value($1, &Lex->last_field->option_list, - &Lex->option_list_last); + $1->link(&Lex->last_field->option_list, &Lex->option_list_last); } | with_or_without_system VERSIONING_SYM { @@ -6781,33 +6777,9 @@ all_key_opt: { Lex->last_key->key_create_info.is_ignored= $1; } - | IDENT_sys equal TEXT_STRING_sys - { - if (unlikely($3.length > ENGINE_OPTION_MAX_LENGTH)) - my_yyabort_error((ER_VALUE_TOO_LONG, MYF(0), $1.str)); - (void) new (thd->mem_root) - engine_option_value($1, $3, true, &Lex->option_list, - &Lex->option_list_last); - } - | IDENT_sys equal ident - { - if (unlikely($3.length > ENGINE_OPTION_MAX_LENGTH)) - my_yyabort_error((ER_VALUE_TOO_LONG, MYF(0), $1.str)); - (void) new (thd->mem_root) - engine_option_value($1, $3, false, &Lex->option_list, - &Lex->option_list_last); - } - | IDENT_sys equal real_ulonglong_num - { - (void) new (thd->mem_root) - engine_option_value($1, $3, &Lex->option_list, - &Lex->option_list_last, thd->mem_root); - } - | IDENT_sys equal DEFAULT + | engine_defined_option { - (void) new (thd->mem_root) - engine_option_value($1, &Lex->option_list, - &Lex->option_list_last); + $1->link(&Lex->option_list, &Lex->option_list_last); } ; |