From 01fd5d0d0e527ed5da5d6d2dcf91f74162bb4ad1 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Mon, 23 Jun 2014 19:59:15 +0400 Subject: Bug #18978946: BACKPORT TO 5.6: BUGFIX FOR 18017820 "BISON 3 BREAKS MYSQL BUILD" Backport of the fix: : Bug 18017820: BISON 3 BREAKS MYSQL BUILD : ======================================== : : The source of the reported problem is a removal of a few deprecated : things from Bison 3.x: : * YYPARSE_PARAM macro (use the %parse-param bison directive instead), : * YYLEX_PARAM macro (use %lex-param instead), : : The fix removes obsolete macro calls and introduces use of : %parse-param and %lex-param directives. --- sql/sql_yacc.yy | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'sql/sql_yacc.yy') diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 3af964db731..bd5d4dc5604 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -22,13 +22,9 @@ */ %{ -/* thd is passed as an argument to yyparse(), and subsequently to yylex(). -** The type will be void*, so it must be cast to (THD*) when used. -** Use the YYTHD macro for this. +/* +Note: YYTHD is passed as an argument to yyparse(), and subsequently to yylex(). */ -#define YYPARSE_PARAM yythd -#define YYLEX_PARAM yythd -#define YYTHD ((THD *)yythd) #define YYLIP (& YYTHD->m_parser_state->m_lip) #define YYPS (& YYTHD->m_parser_state->m_yacc) @@ -76,7 +72,7 @@ int yylex(void *yylval, void *yythd); ulong val= *(F); \ if (my_yyoverflow((B), (D), &val)) \ { \ - yyerror((char*) (A)); \ + yyerror(YYTHD, (char*) (A)); \ return 2; \ } \ else \ @@ -174,10 +170,8 @@ void my_parse_error(const char *s) to abort from the parser. */ -void MYSQLerror(const char *s) +void MYSQLerror(THD *thd, const char *s) { - THD *thd= current_thd; - /* Restore the original LEX if it was replaced when parsing a stored procedure. We must ensure that a parsing error @@ -787,7 +781,9 @@ static bool add_create_index (LEX *lex, Key::Keytype type, bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %} -%pure_parser /* We have threads */ +%parse-param { class THD *YYTHD } +%lex-param { class THD *YYTHD } +%pure-parser /* We have threads */ /* Currently there are 168 shift/reduce conflicts. We should not introduce new conflicts any more. -- cgit v1.2.1 From cdf72d51c631aecb46505ff94cdb9ef667d4444c Mon Sep 17 00:00:00 2001 From: Raghav Kapoor Date: Wed, 25 Jun 2014 18:06:28 +0530 Subject: BUG#17665767 - FAILING ASSERTION: PRIMARY_KEY_NO == -1 || PRIMARY_KEY_NO == 0 BACKGROUND: This bug is a followup on Bug#16368875. The assertion failure happens because in SQL layer the key does not get promoted to PRIMARY KEY but InnoDB takes it as PRIMARY KEY. ANALYSIS: Here we are trying to create an index on POINT (GEOMETRY) data type which is a type of BLOB (since GEOMETRY is a subclass of BLOB). In general, we can't create an index over GEOMETRY family type field unless we specify the length of the keypart (similar to BLOB fields). Only exception is the POINT field type. The POINT column max size is 25. The problem is that the field is not treated as PRIMARY KEY when we create a index on POINT column using its max column size as key part prefix. The fix would allow index on POINT column to be treated as PRIMARY KEY. FIX: Patch for Bug#16368875 is extended to take into account GEOMETRY datatype, POINT in particular to consider it as PRIMARY KEY in SQL layer. --- sql/sql_yacc.yy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/sql_yacc.yy') diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index bd5d4dc5604..74a21c9f6b6 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5603,7 +5603,8 @@ spatial_type: | GEOMETRYCOLLECTION { $$= Field::GEOM_GEOMETRYCOLLECTION; } | POINT_SYM { - Lex->length= (char*)"25"; + Lex->length= const_cast(STRINGIFY_ARG + (MAX_LEN_GEOM_POINT_FIELD)); $$= Field::GEOM_POINT; } | MULTIPOINT { $$= Field::GEOM_MULTIPOINT; } -- cgit v1.2.1 From 1427e1db99ac44dedbc78e8655742a8ed9bfd755 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 1 Sep 2014 20:57:32 +0400 Subject: MDEV-6661 PI() does not work well in UCS2/UTF16/UTF32 context MDEV-6666 Malformed result for CONCAT(utf8_column, binary_string) Item_static_string_func::safe_charset_converter() and Item_hex_string::safe_charset_converter() did not handle character sets with mbminlen>1 properly, as well as did not handle conversion from binary to multi-byte well. Introducing Item::const_charset_converter(), to reuse it in a number of Item_*::safe_charset_converter(). --- sql/sql_yacc.yy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_yacc.yy') diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7aaa8d31ee5..19df69289ac 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -13432,7 +13432,7 @@ literal: str ? str->length() : 0, $1); if (!item_str || - !item_str->check_well_formed_result(&item_str->str_value, TRUE)) + !item_str->check_well_formed_result(true)) { MYSQL_YYABORT; } @@ -13461,7 +13461,7 @@ literal: str ? str->length() : 0, $1); if (!item_str || - !item_str->check_well_formed_result(&item_str->str_value, TRUE)) + !item_str->check_well_formed_result(true)) { MYSQL_YYABORT; } -- cgit v1.2.1 From fbaaf3688d5fac4b1b867155a9f09575367c0f98 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 3 Sep 2014 01:56:21 +0400 Subject: Moving Item::str_value from public to protected. --- sql/sql_yacc.yy | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'sql/sql_yacc.yy') diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 19df69289ac..ef71369ac66 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -9195,7 +9195,6 @@ simple_expr: } | '{' ident expr '}' { - Item_string *item; $$= NULL; /* If "expr" is reasonably short pure ASCII string literal, @@ -9205,31 +9204,13 @@ simple_expr: SELECT {t'10:20:30'}; SELECT {ts'2001-01-01 10:20:30'}; */ - if ($3->type() == Item::STRING_ITEM && - (item= (Item_string *) $3) && - item->collation.repertoire == MY_REPERTOIRE_ASCII && - item->str_value.length() < MAX_DATE_STRING_REP_LENGTH * 4) - { - enum_field_types type= MYSQL_TYPE_STRING; - LEX_STRING *ls= &$2; - if (ls->length == 1) - { - if (ls->str[0] == 'd') /* {d'2001-01-01'} */ - type= MYSQL_TYPE_DATE; - else if (ls->str[0] == 't') /* {t'10:20:30'} */ - type= MYSQL_TYPE_TIME; - } - else if (ls->length == 2) /* {ts'2001-01-01 10:20:30'} */ - { - if (ls->str[0] == 't' && ls->str[1] == 's') - type= MYSQL_TYPE_DATETIME; - } + if ($3->type() == Item::STRING_ITEM) + { + Item_string *item= (Item_string *) $3; + enum_field_types type= item->odbc_temporal_literal_type(&$2); if (type != MYSQL_TYPE_STRING) { - $$= create_temporal_literal(thd, - item->str_value.ptr(), - item->str_value.length(), - item->str_value.charset(), + $$= create_temporal_literal(thd, item->val_str(NULL), type, false); } } -- cgit v1.2.1 From e42f4e31990d7741e7c375f1102c4584a507c05f Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 3 Sep 2014 16:31:47 +0400 Subject: MDEV-6688 Illegal mix of collation with bit string B'01100001' --- sql/sql_yacc.yy | 80 ++++++++++----------------------------------------------- 1 file changed, 14 insertions(+), 66 deletions(-) (limited to 'sql/sql_yacc.yy') diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ef71369ac66..ecef9d8841a 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1648,7 +1648,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %type IDENT IDENT_QUOTED TEXT_STRING DECIMAL_NUM FLOAT_NUM NUM LONG_NUM - HEX_NUM HEX_STRING hex_num_or_string + HEX_NUM HEX_STRING LEX_HOSTNAME ULONGLONG_NUM field_ident select_alias ident ident_or_text IDENT_sys TEXT_STRING_sys TEXT_STRING_literal NCHAR_STRING opt_component key_cache_name @@ -1666,7 +1666,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); remember_name remember_end opt_db text_or_password %type - text_string opt_gconcat_separator + text_string hex_or_bin_String opt_gconcat_separator %type type type_with_opt_collate int_type real_type order_dir lock_option @@ -6517,11 +6517,6 @@ now_or_signed_literal: { $$=$1; } ; -hex_num_or_string: - HEX_NUM {} - | HEX_STRING {} - ; - charset: CHAR_SYM SET {} | CHARSET {} @@ -13253,14 +13248,10 @@ text_literal: } | UNDERSCORE_CHARSET TEXT_STRING { - Item_string *str= new (thd->mem_root) Item_string($2.str, + $$= new (thd->mem_root) Item_string_with_introducer($2.str, $2.length, $1); - if (str == NULL) + if ($$ == NULL) MYSQL_YYABORT; - str->set_repertoire_from_value(); - str->set_cs_specified(TRUE); - - $$= str; } | text_literal TEXT_STRING_literal { @@ -13289,7 +13280,12 @@ text_string: if ($$ == NULL) MYSQL_YYABORT; } - | HEX_NUM + | hex_or_bin_String { $$= $1; } + ; + + +hex_or_bin_String: + HEX_NUM { Item *tmp= new (thd->mem_root) Item_hex_hybrid($1.str, $1.length); if (tmp == NULL) @@ -13394,60 +13390,12 @@ literal: if ($$ == NULL) MYSQL_YYABORT; } - | UNDERSCORE_CHARSET hex_num_or_string + | UNDERSCORE_CHARSET hex_or_bin_String { - Item *tmp= new (thd->mem_root) Item_hex_string($2.str, $2.length); - if (tmp == NULL) + Item_string_with_introducer *item_str; + item_str= new (thd->mem_root) Item_string_with_introducer($2, $1); + if (!item_str || !item_str->check_well_formed_result(true)) MYSQL_YYABORT; - /* - it is OK only emulate fix_fieds, because we need only - value of constant - */ - tmp->quick_fix_field(); - String *str= tmp->val_str((String*) 0); - - Item_string *item_str; - item_str= new (thd->mem_root) - Item_string(NULL, /* name will be set in select_item */ - str ? str->ptr() : "", - str ? str->length() : 0, - $1); - if (!item_str || - !item_str->check_well_formed_result(true)) - { - MYSQL_YYABORT; - } - - item_str->set_repertoire_from_value(); - item_str->set_cs_specified(TRUE); - - $$= item_str; - } - | UNDERSCORE_CHARSET BIN_NUM - { - Item *tmp= new (thd->mem_root) Item_bin_string($2.str, $2.length); - if (tmp == NULL) - MYSQL_YYABORT; - /* - it is OK only emulate fix_fieds, because we need only - value of constant - */ - tmp->quick_fix_field(); - String *str= tmp->val_str((String*) 0); - - Item_string *item_str; - item_str= new (thd->mem_root) - Item_string(NULL, /* name will be set in select_item */ - str ? str->ptr() : "", - str ? str->length() : 0, - $1); - if (!item_str || - !item_str->check_well_formed_result(true)) - { - MYSQL_YYABORT; - } - - item_str->set_cs_specified(TRUE); $$= item_str; } -- cgit v1.2.1 From 1e66871713b7196daf1e9416823d57d5bbac85a1 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 3 Sep 2014 18:24:31 +0400 Subject: Adding Item_string_sys and Item_string_ascii to reduce duplicate code --- sql/sql_yacc.yy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sql/sql_yacc.yy') diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ecef9d8841a..7777853e7c5 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -11124,8 +11124,8 @@ opt_escape: { Lex->escape_used= FALSE; $$= ((thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) ? - new (thd->mem_root) Item_string("", 0, &my_charset_latin1) : - new (thd->mem_root) Item_string("\\", 1, &my_charset_latin1)); + new (thd->mem_root) Item_string_ascii("", 0) : + new (thd->mem_root) Item_string_ascii("\\", 1)); if ($$ == NULL) MYSQL_YYABORT; } @@ -14792,19 +14792,19 @@ set_expr_or_default: | DEFAULT { $$=0; } | ON { - $$=new (thd->mem_root) Item_string("ON", 2, system_charset_info); + $$=new (thd->mem_root) Item_string_sys("ON", 2); if ($$ == NULL) MYSQL_YYABORT; } | ALL { - $$=new (thd->mem_root) Item_string("ALL", 3, system_charset_info); + $$=new (thd->mem_root) Item_string_sys("ALL", 3); if ($$ == NULL) MYSQL_YYABORT; } | BINARY { - $$=new (thd->mem_root) Item_string("binary", 6, system_charset_info); + $$=new (thd->mem_root) Item_string_sys("binary", 6); if ($$ == NULL) MYSQL_YYABORT; } -- cgit v1.2.1