diff options
author | Konstantin Osipov <kostja@sun.com> | 2009-12-15 22:59:07 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2009-12-15 22:59:07 +0300 |
commit | 391b5246fef4110bc73227c67f77eec5611a612e (patch) | |
tree | 43a14c6ad76010ee31038173e53da44517c84dbe /sql/sql_yacc.yy | |
parent | 92b1c2f3caafe6529a08992d7f134476c7b9ff70 (diff) | |
parent | 27fca0ab1775a8c1dfe699c978b6448a7aa8f47b (diff) | |
download | mariadb-git-391b5246fef4110bc73227c67f77eec5611a612e.tar.gz |
Merge next-mr -> next-4284.
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r-- | sql/sql_yacc.yy | 144 |
1 files changed, 105 insertions, 39 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 1e6a7c4d50f..738745b918c 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -519,10 +519,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %pure_parser /* We have threads */ /* - Currently there are 169 shift/reduce conflicts. + Currently there are 167 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 168 +%expect 167 /* Comments for TOKENS. @@ -1115,6 +1115,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token WHERE /* SQL-2003-R */ %token WHILE_SYM %token WITH /* SQL-2003-R */ +%token WITH_CUBE_SYM /* INTERNAL */ +%token WITH_ROLLUP_SYM /* INTERNAL */ %token WORK_SYM /* SQL-2003-N */ %token WRAPPER_SYM %token WRITE_SYM /* SQL-2003-N */ @@ -1167,7 +1169,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); text_string opt_gconcat_separator %type <num> - type int_type real_type order_dir lock_option + type type_with_opt_collate int_type real_type order_dir lock_option udf_type if_exists opt_local opt_table_options table_options table_option opt_if_not_exists opt_no_write_to_binlog delete_option opt_temporary all_or_any opt_distinct @@ -1289,7 +1291,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); handler opt_precision opt_ignore opt_column opt_restrict grant revoke set lock unlock string_list field_options field_option - field_opt_list opt_binary table_lock_list table_lock + field_opt_list opt_binary ascii unicode table_lock_list table_lock ref_list opt_on_delete opt_on_delete_list opt_on_delete_item use opt_delete_options opt_delete_option varchar nchar nvarchar opt_outer table_list table_name table_alias_ref_list table_alias_ref @@ -2253,7 +2255,7 @@ sp_init_param: ; sp_fdparam: - ident sp_init_param type + ident sp_init_param type_with_opt_collate { LEX *lex= Lex; sp_pcontext *spc= lex->spcont; @@ -2290,7 +2292,7 @@ sp_pdparams: ; sp_pdparam: - sp_opt_inout sp_init_param ident type + sp_opt_inout sp_init_param ident type_with_opt_collate { LEX *lex= Lex; sp_pcontext *spc= lex->spcont; @@ -2370,7 +2372,7 @@ sp_decl: lex->sphead->reset_lex(YYTHD); lex->spcont->declare_var_boundary($2); } - type + type_with_opt_collate sp_opt_default { THD *thd= YYTHD; @@ -4904,14 +4906,14 @@ default_collation: HA_CREATE_INFO *cinfo= &Lex->create_info; if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) && cinfo->default_table_charset && $4 && - !my_charset_same(cinfo->default_table_charset,$4)) - { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - $4->name, cinfo->default_table_charset->csname); - MYSQL_YYABORT; - } - Lex->create_info.default_table_charset= $4; - Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; + !($4= merge_charset_and_collation(cinfo->default_table_charset, + $4))) + { + MYSQL_YYABORT; + } + + Lex->create_info.default_table_charset= $4; + Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; } ; @@ -5434,6 +5436,28 @@ attribute: } ; + +type_with_opt_collate: + type opt_collate + { + $$= $1; + + if (Lex->charset) /* Lex->charset is scanned in "type" */ + { + if (!(Lex->charset= merge_charset_and_collation(Lex->charset, $2))) + MYSQL_YYABORT; + } + else if ($2) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), + "COLLATE with no CHARACTER SET " + "in SP parameters, RETURNS, DECLARE"); + MYSQL_YYABORT; + } + } + ; + + now_or_signed_literal: NOW_SYM optional_braces { @@ -5516,11 +5540,21 @@ opt_default: | DEFAULT {} ; -opt_binary: - /* empty */ { Lex->charset=NULL; } - | ASCII_SYM opt_bin_mod { Lex->charset=&my_charset_latin1; } - | BYTE_SYM { Lex->charset=&my_charset_bin; } - | UNICODE_SYM opt_bin_mod + +ascii: + ASCII_SYM { Lex->charset= &my_charset_latin1; } + | BINARY ASCII_SYM + { + Lex->charset= &my_charset_latin1_bin; + } + | ASCII_SYM BINARY + { + Lex->charset= &my_charset_latin1_bin; + } + ; + +unicode: + UNICODE_SYM { if (!(Lex->charset=get_charset_by_csname("ucs2", MY_CS_PRIMARY,MYF(0)))) @@ -5529,8 +5563,40 @@ opt_binary: MYSQL_YYABORT; } } + | UNICODE_SYM BINARY + { + if (!(Lex->charset=get_charset_by_name("ucs2_bin", MYF(0)))) + { + my_error(ER_UNKNOWN_COLLATION, MYF(0), "ucs2_bin"); + MYSQL_YYABORT; + } + } + | BINARY UNICODE_SYM + { + if (!(Lex->charset=get_charset_by_name("ucs2_bin", MYF(0)))) + { + my_error(ER_UNKNOWN_COLLATION, MYF(0), "ucs2_bin"); + MYSQL_YYABORT; + } + } + ; + +opt_binary: + /* empty */ { Lex->charset=NULL; } + | ascii + | unicode + | BYTE_SYM { Lex->charset=&my_charset_bin; } | charset charset_name opt_bin_mod { Lex->charset=$2; } - | BINARY opt_bin_charset { Lex->type|= BINCMP_FLAG; } + | BINARY + { + Lex->charset= NULL; + Lex->type|= BINCMP_FLAG; + } + | BINARY charset charset_name + { + Lex->charset= $3; + Lex->type|= BINCMP_FLAG; + } ; opt_bin_mod: @@ -5538,20 +5604,6 @@ opt_bin_mod: | BINARY { Lex->type|= BINCMP_FLAG; } ; -opt_bin_charset: - /* empty */ { Lex->charset= NULL; } - | ASCII_SYM { Lex->charset=&my_charset_latin1; } - | UNICODE_SYM - { - if (!(Lex->charset=get_charset_by_csname("ucs2", - MY_CS_PRIMARY,MYF(0)))) - { - my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), "ucs2"); - MYSQL_YYABORT; - } - } - | charset charset_name { Lex->charset=$2; } - ; opt_primary: /* empty */ @@ -9220,8 +9272,15 @@ group_list: olap_opt: /* empty */ {} - | WITH CUBE_SYM + | WITH_CUBE_SYM { + /* + 'WITH CUBE' is reserved in the MySQL syntax, but not implemented, + and cause LALR(2) conflicts. + This syntax is not standard. + MySQL syntax: GROUP BY col1, col2, col3 WITH CUBE + SQL-2003: GROUP BY ... CUBE(col1, col2, col3) + */ LEX *lex=Lex; if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE) { @@ -9231,10 +9290,17 @@ olap_opt: } lex->current_select->olap= CUBE_TYPE; my_error(ER_NOT_SUPPORTED_YET, MYF(0), "CUBE"); - MYSQL_YYABORT; /* To be deleted in 5.1 */ + MYSQL_YYABORT; } - | WITH ROLLUP_SYM + | WITH_ROLLUP_SYM { + /* + 'WITH ROLLUP' is needed for backward compatibility, + and cause LALR(2) conflicts. + This syntax is not standard. + MySQL syntax: GROUP BY col1, col2, col3 WITH ROLLUP + SQL-2003: GROUP BY ... ROLLUP(col1, col2, col3) + */ LEX *lex= Lex; if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE) { @@ -13647,7 +13713,7 @@ sf_tail: lex->interval_list.empty(); lex->type= 0; } - type /* $11 */ + type_with_opt_collate /* $11 */ { /* $12 */ LEX *lex= Lex; sp_head *sp= lex->sphead; |