diff options
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r-- | sql/sql_yacc.yy | 149 |
1 files changed, 100 insertions, 49 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d792d144545..bdda1f6fa07 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -917,14 +917,14 @@ prepare_src: THD *thd=YYTHD; LEX *lex= thd->lex; lex->prepared_stmt_code= $1; - lex->prepared_stmt_code_is_varref= false; + lex->prepared_stmt_code_is_varref= FALSE; } | '@' ident_or_text { THD *thd=YYTHD; LEX *lex= thd->lex; lex->prepared_stmt_code= $2; - lex->prepared_stmt_code_is_varref= true; + lex->prepared_stmt_code_is_varref= TRUE; }; execute: @@ -2388,20 +2388,20 @@ trg_event: ; create2: - '(' create2a {} - | opt_create_table_options create3 {} - | LIKE table_ident - { - LEX *lex=Lex; - if (!(lex->name= (char *)$2)) + '(' create2a {} + | opt_create_table_options create3 {} + | LIKE table_ident + { + LEX *lex=Lex; + if (!(lex->name= (char *)$2)) YYABORT; - } - | '(' LIKE table_ident ')' - { - LEX *lex=Lex; - if (!(lex->name= (char *)$3)) + } + | '(' LIKE table_ident ')' + { + LEX *lex=Lex; + if (!(lex->name= (char *)$3)) YYABORT; - } + } ; create2a: @@ -2739,10 +2739,21 @@ type: if (YYTHD->variables.sql_mode & MODE_MAXDB) $$=FIELD_TYPE_DATETIME; else + { + /* + Unlike other types TIMESTAMP fields are NOT NULL by default. + */ + Lex->type|= NOT_NULL_FLAG; $$=FIELD_TYPE_TIMESTAMP; + } } - | TIMESTAMP '(' NUM ')' { Lex->length=$3.str; - $$=FIELD_TYPE_TIMESTAMP; } + | TIMESTAMP '(' NUM ')' + { + LEX *lex= Lex; + lex->length= $3.str; + lex->type|= NOT_NULL_FLAG; + $$= FIELD_TYPE_TIMESTAMP; + } | DATETIME { $$=FIELD_TYPE_DATETIME; } | TINYBLOB { Lex->charset=&my_charset_bin; $$=FIELD_TYPE_TINY_BLOB; } @@ -3130,7 +3141,17 @@ key_list: key_part: ident { $$=new key_part_spec($1.str); } - | ident '(' NUM ')' { $$=new key_part_spec($1.str,(uint) atoi($3.str)); }; + | ident '(' NUM ')' + { + int key_part_len= atoi($3.str); + if (!key_part_len) + { + my_printf_error(ER_UNKNOWN_ERROR, + "Key part '%s' length cannot be 0", + MYF(0), $1.str); + } + $$=new key_part_spec($1.str,(uint) key_part_len); + }; opt_ident: /* empty */ { $$=(char*) 0; } /* Defaultlength */ @@ -4242,7 +4263,7 @@ simple_expr: | CONCAT '(' expr_list ')' { $$= new Item_func_concat(* $3); } | CONCAT_WS '(' expr ',' expr_list ')' - { $$= new Item_func_concat_ws($3, *$5); } + { $5->push_front($3); $$= new Item_func_concat_ws(*$5); } | CONTAINS_SYM '(' expr ',' expr ')' { $$= create_func_contains($3, $5); } | CONVERT_TZ_SYM '(' expr ',' expr ',' expr ')' @@ -5395,15 +5416,11 @@ select_var_ident: into: INTO OUTFILE TEXT_STRING_sys { - LEX *lex=Lex; - if (!lex->describe) - { - lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - if (!(lex->exchange= new sql_exchange($3.str,0))) - YYABORT; - if (!(lex->result= new select_export(lex->exchange))) - YYABORT; - } + LEX *lex= Lex; + lex->uncacheable(UNCACHEABLE_SIDEEFFECT); + if (!(lex->exchange= new sql_exchange($3.str, 0)) || + !(lex->result= new select_export(lex->exchange))) + YYABORT; } opt_field_term opt_line_term | INTO DUMPFILE TEXT_STRING_sys @@ -5702,14 +5719,18 @@ expr_or_default: opt_insert_update: /* empty */ | ON DUPLICATE_SYM - { /* for simplisity, let's forget about - INSERT ... SELECT ... UPDATE - for a moment */ - if (Lex->sql_command != SQLCOM_INSERT) + { + LEX *lex= Lex; + /* + For simplicity, let's forget about INSERT ... SELECT ... UPDATE + for a moment. + */ + if (lex->sql_command != SQLCOM_INSERT) { yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } + lex->duplicates= DUP_UPDATE; } KEY_SYM UPDATE_SYM update_list ; @@ -5725,12 +5746,14 @@ update: lex->lock_option= TL_UNLOCK; /* Will be set later */ } opt_low_priority opt_ignore join_table_list - SET update_list where_clause opt_order_clause delete_limit_clause + SET update_list { LEX *lex= Lex; - Select->set_lock_for_tables($3); if (lex->select_lex.table_list.elements > 1) + { lex->sql_command= SQLCOM_UPDATE_MULTI; + lex->multi_lock_option= $3; + } else if (lex->select_lex.get_table_list()->derived) { /* it is single table update and it is update of derived table */ @@ -5738,7 +5761,10 @@ update: lex->select_lex.get_table_list()->alias, "UPDATE"); YYABORT; } + else + Select->set_lock_for_tables($3); } + where_clause opt_order_clause delete_limit_clause {} ; update_list: @@ -6319,15 +6345,28 @@ field_term_list: | field_term; field_term: - TERMINATED BY text_string { Lex->exchange->field_term= $3;} + TERMINATED BY text_string + { + DBUG_ASSERT(Lex->exchange); + Lex->exchange->field_term= $3; + } | OPTIONALLY ENCLOSED BY text_string { - LEX *lex=Lex; - lex->exchange->enclosed= $4; - lex->exchange->opt_enclosed=1; + LEX *lex= Lex; + DBUG_ASSERT(lex->exchange); + lex->exchange->enclosed= $4; + lex->exchange->opt_enclosed= 1; } - | ENCLOSED BY text_string { Lex->exchange->enclosed= $3;} - | ESCAPED BY text_string { Lex->exchange->escaped= $3;}; + | ENCLOSED BY text_string + { + DBUG_ASSERT(Lex->exchange); + Lex->exchange->enclosed= $3; + } + | ESCAPED BY text_string + { + DBUG_ASSERT(Lex->exchange); + Lex->exchange->escaped= $3; + }; opt_line_term: /* empty */ @@ -6338,13 +6377,24 @@ line_term_list: | line_term; line_term: - TERMINATED BY text_string { Lex->exchange->line_term= $3;} - | STARTING BY text_string { Lex->exchange->line_start= $3;}; + TERMINATED BY text_string + { + DBUG_ASSERT(Lex->exchange); + Lex->exchange->line_term= $3; + } + | STARTING BY text_string + { + DBUG_ASSERT(Lex->exchange); + Lex->exchange->line_start= $3; + }; opt_ignore_lines: /* empty */ - | IGNORE_SYM NUM LINES - { Lex->exchange->skip_lines=atol($2.str); }; + | IGNORE_SYM NUM LINES + { + DBUG_ASSERT(Lex->exchange); + Lex->exchange->skip_lines= atol($2.str); + }; /* Common definitions */ @@ -6505,7 +6555,7 @@ simple_ident: $$= (sel->parsing_place != IN_HAVING || sel->get_in_sum_expr() > 0) ? (Item*) new Item_field(NullS,NullS,$1.str) : - (Item*) new Item_ref(0,0, NullS,NullS,$1.str); + (Item*) new Item_ref(NullS,NullS,$1.str); } } | simple_ident_q { $$= $1; } @@ -6518,7 +6568,7 @@ simple_ident_nospvar: $$= (sel->parsing_place != IN_HAVING || sel->get_in_sum_expr() > 0) ? (Item*) new Item_field(NullS,NullS,$1.str) : - (Item*) new Item_ref(0,0,NullS,NullS,$1.str); + (Item*) new Item_ref(NullS,NullS,$1.str); } | simple_ident_q { $$= $1; } ; @@ -6588,7 +6638,7 @@ simple_ident_q: $$= (sel->parsing_place != IN_HAVING || sel->get_in_sum_expr() > 0) ? (Item*) new Item_field(NullS,$1.str,$3.str) : - (Item*) new Item_ref(0,0,NullS,$1.str,$3.str); + (Item*) new Item_ref(NullS,$1.str,$3.str); } } | '.' ident '.' ident @@ -6605,7 +6655,7 @@ simple_ident_q: $$= (sel->parsing_place != IN_HAVING || sel->get_in_sum_expr() > 0) ? (Item*) new Item_field(NullS,$2.str,$4.str) : - (Item*) new Item_ref(0,0,NullS,$2.str,$4.str); + (Item*) new Item_ref(NullS, $2.str, $4.str); } | ident '.' ident '.' ident { @@ -6623,8 +6673,8 @@ simple_ident_q: (Item*) new Item_field((YYTHD->client_capabilities & CLIENT_NO_SCHEMA ? NullS : $1.str), $3.str, $5.str) : - (Item*) new Item_ref(0,0,(YYTHD->client_capabilities & - CLIENT_NO_SCHEMA ? NullS : $1.str), + (Item*) new Item_ref((YYTHD->client_capabilities & + CLIENT_NO_SCHEMA ? NullS : $1.str), $3.str, $5.str); }; @@ -6958,6 +7008,7 @@ keyword: | TIME_SYM {} | TYPE_SYM {} | TYPES_SYM {} + | UDF_RETURNS_SYM {} | FUNCTION_SYM {} | UNCOMMITTED_SYM {} | UNDEFINED_SYM {} |