Commit fdcaa6cb authored by Sergei Golubchik's avatar Sergei Golubchik

clarify CREATE grammar

parent e7036ec1
...@@ -1461,7 +1461,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1461,7 +1461,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <table> %type <table>
table_ident table_ident_nodb references xid table_ident table_ident_nodb references xid
table_ident_opt_wild table_ident_opt_wild create_like
%type <simple_string> %type <simple_string>
remember_name remember_end opt_db text_or_password remember_name remember_end opt_db text_or_password
...@@ -2115,7 +2115,7 @@ create: ...@@ -2115,7 +2115,7 @@ create:
lex->name.length= 0; lex->name.length= 0;
lex->create_last_non_select_table= lex->last_table(); lex->create_last_non_select_table= lex->last_table();
} }
create2 create_body
{ {
LEX *lex= YYTHD->lex; LEX *lex= YYTHD->lex;
lex->current_select= &lex->select_lex; lex->current_select= &lex->select_lex;
...@@ -4290,36 +4290,23 @@ size_number: ...@@ -4290,36 +4290,23 @@ size_number:
End tablespace part End tablespace part
*/ */
create2: create_body:
'(' create2a {} '(' create_field_list ')'
| opt_create_table_options { Lex->create_info.option_list= NULL; }
opt_create_partitioning opt_create_table_options opt_create_partitioning opt_create_select {}
create3 {} | opt_create_table_options opt_create_partitioning opt_create_select {}
| LIKE table_ident /*
{ the following rule is redundant, but there's a shift/reduce
THD *thd= YYTHD; conflict that prevents the rule above from parsing a syntax like
TABLE_LIST *src_table; CREATE TABLE t1 (SELECT 1);
LEX *lex= thd->lex; */
| '(' create_select ')' { Select->set_braces(1);} union_opt {}
lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE; | create_like
src_table= lex->select_lex.add_table_to_list(thd, $2, NULL, 0,
TL_READ,
MDL_SHARED_READ);
if (! src_table)
MYSQL_YYABORT;
/* CREATE TABLE ... LIKE is not allowed for views. */
src_table->required_type= FRMTYPE_TABLE;
}
| '(' LIKE table_ident ')'
{ {
THD *thd= YYTHD;
TABLE_LIST *src_table;
LEX *lex= thd->lex;
lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE; Lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
src_table= lex->select_lex.add_table_to_list(thd, $3, NULL, 0, TABLE_LIST *src_table= Lex->select_lex.add_table_to_list(YYTHD,
TL_READ, $1, NULL, 0, TL_READ, MDL_SHARED_READ);
MDL_SHARED_READ);
if (! src_table) if (! src_table)
MYSQL_YYABORT; MYSQL_YYABORT;
/* CREATE TABLE ... LIKE is not allowed for views. */ /* CREATE TABLE ... LIKE is not allowed for views. */
...@@ -4327,21 +4314,12 @@ create2: ...@@ -4327,21 +4314,12 @@ create2:
} }
; ;
create2a: create_like:
create_field_list ')' LIKE table_ident { $$= $2; }
{ | '(' LIKE table_ident ')' { $$= $3; }
Lex->create_info.option_list= NULL;
}
opt_create_table_options
opt_create_partitioning
create3 {}
| opt_create_partitioning
create_select ')'
{ Select->set_braces(1);}
union_opt {}
; ;
create3: opt_create_select:
/* empty */ {} /* empty */ {}
| opt_duplicate opt_as create_select | opt_duplicate opt_as create_select
{ Select->set_braces(0);} { Select->set_braces(0);}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment