summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/item_strfunc.cc42
-rw-r--r--sql/item_strfunc.h5
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/mysqld.h2
-rw-r--r--sql/sql_yacc.yy10
-rw-r--r--sql/sql_yacc_ora.yy10
6 files changed, 15 insertions, 56 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 7c32fde72fe..89ab7a9878e 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -3437,27 +3437,13 @@ String *Item_func_set_collation::val_str(String *str)
void Item_func_set_collation::fix_length_and_dec()
{
- CHARSET_INFO *set_collation;
- const char *colname;
- String tmp, *str= args[1]->val_str(&tmp);
- colname= str->c_ptr();
- if (colname == binary_keyword)
- set_collation= get_charset_by_csname(args[0]->collation.collation->csname,
- MY_CS_BINSORT,MYF(0));
- else
- {
- if (!(set_collation= mysqld_collation_get_by_name(colname)))
- return;
- }
-
- if (!set_collation ||
- !my_charset_same(args[0]->collation.collation,set_collation))
+ if (!my_charset_same(args[0]->collation.collation, m_set_collation))
{
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
- colname, args[0]->collation.collation->csname);
+ m_set_collation->name, args[0]->collation.collation->csname);
return;
}
- collation.set(set_collation, DERIVATION_EXPLICIT,
+ collation.set(m_set_collation, DERIVATION_EXPLICIT,
args[0]->collation.repertoire);
max_length= args[0]->max_length;
}
@@ -3465,22 +3451,8 @@ void Item_func_set_collation::fix_length_and_dec()
bool Item_func_set_collation::eq(const Item *item, bool binary_cmp) const
{
- /* Assume we don't have rtti */
- if (this == item)
- return 1;
- if (item->type() != FUNC_ITEM)
- return 0;
- Item_func *item_func=(Item_func*) item;
- if (arg_count != item_func->argument_count() ||
- functype() != item_func->functype())
- return 0;
- Item_func_set_collation *item_func_sc=(Item_func_set_collation*) item;
- if (collation.collation != item_func_sc->collation.collation)
- return 0;
- for (uint i=0; i < arg_count ; i++)
- if (!args[i]->eq(item_func_sc->args[i], binary_cmp))
- return 0;
- return 1;
+ return Item_func::eq(item, binary_cmp) &&
+ collation.collation == item->collation.collation;
}
@@ -3488,9 +3460,7 @@ void Item_func_set_collation::print(String *str, enum_query_type query_type)
{
args[0]->print_parenthesised(str, query_type, precedence());
str->append(STRING_WITH_LEN(" collate "));
- DBUG_ASSERT(args[1]->basic_const_item() &&
- args[1]->type() == Item::STRING_ITEM);
- ((Item_string *)args[1])->print_value(str);
+ str->append(m_set_collation->name);
}
String *Item_func_charset::val_str(String *str)
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 4efc15338e0..da77f29f108 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -1355,9 +1355,10 @@ public:
class Item_func_set_collation :public Item_str_func
{
+ CHARSET_INFO *m_set_collation;
public:
- Item_func_set_collation(THD *thd, Item *a, Item *b):
- Item_str_func(thd, a, b) {}
+ Item_func_set_collation(THD *thd, Item *a, CHARSET_INFO *set_collation):
+ Item_str_func(thd, a), m_set_collation(set_collation) {}
String *val_str(String *);
void fix_length_and_dec();
bool eq(const Item *item, bool binary_cmp) const;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 1872db71d7a..60ad41eed39 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -302,7 +302,7 @@ static TYPELIB tc_heuristic_recover_typelib=
tc_heuristic_recover_names, NULL
};
-const char *first_keyword= "first", *binary_keyword= "BINARY";
+const char *first_keyword= "first";
const char *my_localhost= "localhost", *delayed_user= "DELAYED";
const char *quoted_string= "%`s";
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 069ad85dd16..670e136e7cf 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -267,7 +267,7 @@ extern time_t server_start_time, flush_status_time;
extern char *opt_mysql_tmpdir, mysql_charsets_dir[];
extern size_t mysql_unpacked_real_data_home_len;
extern MYSQL_PLUGIN_IMPORT MY_TMPDIR mysql_tmpdir_list;
-extern const char *first_keyword, *delayed_user, *binary_keyword;
+extern const char *first_keyword, *delayed_user;
extern MYSQL_PLUGIN_IMPORT const char *my_localhost;
extern MYSQL_PLUGIN_IMPORT const char **errmesg; /* Error messages */
extern const char *myisam_recover_options_str;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index c5ea8588a6b..393dcb8c900 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -10064,15 +10064,9 @@ column_default_non_parenthesized_expr:
simple_expr:
column_default_non_parenthesized_expr
- | simple_expr COLLATE_SYM ident_or_text %prec NEG
+ | simple_expr COLLATE_SYM collation_name %prec NEG
{
- Item *i1= new (thd->mem_root) Item_string(thd, $3.str,
- $3.length,
- thd->charset());
- if (i1 == NULL)
- MYSQL_YYABORT;
- $$= new (thd->mem_root) Item_func_set_collation(thd, $1, i1);
- if ($$ == NULL)
+ if (!($$= new (thd->mem_root) Item_func_set_collation(thd, $1, $3)))
MYSQL_YYABORT;
}
| '(' parenthesized_expr ')' { $$= $2; }
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index aaef7bffa4a..bd1e47266b0 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -9862,15 +9862,9 @@ column_default_non_parenthesized_expr:
simple_expr:
column_default_non_parenthesized_expr
| explicit_cursor_attr
- | simple_expr COLLATE_SYM ident_or_text %prec NEG
+ | simple_expr COLLATE_SYM collation_name %prec NEG
{
- Item *i1= new (thd->mem_root) Item_string(thd, $3.str,
- $3.length,
- thd->charset());
- if (i1 == NULL)
- MYSQL_YYABORT;
- $$= new (thd->mem_root) Item_func_set_collation(thd, $1, i1);
- if ($$ == NULL)
+ if (!($$= new (thd->mem_root) Item_func_set_collation(thd, $1, $3)))
MYSQL_YYABORT;
}
| '(' parenthesized_expr ')' { $$= $2; }