summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2004-10-18 17:56:25 +0500
committerunknown <bar@mysql.com>2004-10-18 17:56:25 +0500
commit1412365a3f277d562d016e353ad0240eba4697e5 (patch)
treec0ae693067fb8f1e887906a373c442dafb8c1123 /sql
parentf8f7e4591918dbada386d4f6b2afc527d5df29ac (diff)
downloadmariadb-git-1412365a3f277d562d016e353ad0240eba4697e5.tar.gz
Bug #6139 UNION doesn't understand collate in the column of second select
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc4
-rw-r--r--sql/sql_union.cc17
2 files changed, 19 insertions, 2 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 0366ea29485..304579d65a2 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2558,8 +2558,8 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
if (use_new_field || use_expression_type ||
(new_result_type != item_type) || (new_length > max_length) ||
(!maybe_null && item->maybe_null) ||
- (item_type == STRING_RESULT &&
- !my_charset_same(collation.collation, item->collation.collation)))
+ (item_type == STRING_RESULT &&
+ collation.collation != item->collation.collation))
{
if (use_expression_type || item->type() != Item::FIELD_ITEM)
field_example= 0;
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index b46cfc05538..6b5d27270c9 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -264,6 +264,23 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
}
}
+ {
+ /*
+ Check that it was possible to aggregate all collations together.
+ */
+ List_iterator_fast<Item> tp(types);
+ Item *type;
+ while ((type= tp++))
+ {
+ if (type->result_type() == STRING_RESULT &&
+ type->collation.derivation == DERIVATION_NONE)
+ {
+ my_error(ER_CANT_AGGREGATE_NCOLLATIONS, MYF(0), "UNION");
+ goto err;
+ }
+ }
+ }
+
// it is not single select
if (first_select->next_select())
{