summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-02-22 14:43:14 +0200
committerunknown <monty@mysql.com>2005-02-22 14:43:14 +0200
commit1c172c3bc4cfefb4ad91a6a39311cc4ca80ca4ed (patch)
tree833bfe7812814acfe44666ceaa8014eb02a06c46
parent7e028f994a3d72fa6c85322b4718424b4f3ca7aa (diff)
parentfe471dfd0f65e7cb6b4091ec0d23fcfc1cb1ff73 (diff)
downloadmariadb-git-1c172c3bc4cfefb4ad91a6a39311cc4ca80ca4ed.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/my/mysql-4.1
-rw-r--r--BitKeeper/etc/logging_ok1
-rw-r--r--mysql-test/r/derived.result19
-rw-r--r--mysql-test/r/user_var.result16
-rw-r--r--mysql-test/t/derived.test12
-rw-r--r--mysql-test/t/user_var.test2
-rw-r--r--sql/item_func.cc10
-rw-r--r--sql/sql_derived.cc10
7 files changed, 54 insertions, 16 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index 940af9510b2..a37994b7791 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -26,6 +26,7 @@ bar@deer.(none)
bar@gw.udmsearch.izhnet.ru
bar@mysql.com
bar@noter.intranet.mysql.r18.ru
+bell@51.0.168.192.in-addr.arpa
bell@laptop.sanja.is.com.ua
bell@sanja.is.com.ua
bk@admin.bk
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index 61d745d0236..b4d9a921178 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -339,3 +339,22 @@ select distinct sum(b) from (select a,b from t1) y group by a;
sum(b)
4
drop table t1;
+create table t1(a int);
+create table t2(a int);
+create table t3(a int);
+insert into t1 values(1),(1);
+insert into t2 values(2),(2);
+insert into t3 values(3),(3);
+select * from t1 union distinct select * from t2 union all select * from t3;
+a
+1
+2
+3
+3
+select * from (select * from t1 union distinct select * from t2 union all select * from t3) X;
+a
+1
+2
+3
+3
+drop table t1, t2, t3;
diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result
index 81846391795..d82c17b0fe0 100644
--- a/mysql-test/r/user_var.result
+++ b/mysql-test/r/user_var.result
@@ -123,7 +123,7 @@ drop table t1;
set @a=_latin2'test';
select charset(@a),collation(@a),coercibility(@a);
charset(@a) collation(@a) coercibility(@a)
-latin2 latin2_general_ci 3
+latin2 latin2_general_ci 2
select @a=_latin2'TEST';
@a=_latin2'TEST'
1
@@ -133,12 +133,13 @@ select @a=_latin2'TEST' collate latin2_bin;
set @a=_latin2'test' collate latin2_general_ci;
select charset(@a),collation(@a),coercibility(@a);
charset(@a) collation(@a) coercibility(@a)
-latin2 latin2_general_ci 0
+latin2 latin2_general_ci 2
select @a=_latin2'TEST';
@a=_latin2'TEST'
1
select @a=_latin2'TEST' collate latin2_bin;
-ERROR HY000: Illegal mix of collations (latin2_general_ci,EXPLICIT) and (latin2_bin,EXPLICIT) for operation '='
+@a=_latin2'TEST' collate latin2_bin
+0
select charset(@a:=_latin2'test');
charset(@a:=_latin2'test')
latin2
@@ -147,21 +148,22 @@ collation(@a:=_latin2'test')
latin2_general_ci
select coercibility(@a:=_latin2'test');
coercibility(@a:=_latin2'test')
-3
+2
select collation(@a:=_latin2'test' collate latin2_bin);
collation(@a:=_latin2'test' collate latin2_bin)
latin2_bin
select coercibility(@a:=_latin2'test' collate latin2_bin);
coercibility(@a:=_latin2'test' collate latin2_bin)
-0
+2
select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST';
(@a:=_latin2'test' collate latin2_bin) = _latin2'TEST'
0
select charset(@a),collation(@a),coercibility(@a);
charset(@a) collation(@a) coercibility(@a)
-latin2 latin2_bin 0
+latin2 latin2_bin 2
select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci;
-ERROR HY000: Illegal mix of collations (latin2_bin,EXPLICIT) and (latin2_general_ci,EXPLICIT) for operation '='
+(@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci
+1
create table t1 (a varchar(50));
reset master;
SET TIMESTAMP=10000;
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index 8b322746ed6..bd27e0654e0 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -224,3 +224,15 @@ select distinct sum(b) from t1 group by a;
select distinct sum(b) from (select a,b from t1) y group by a;
drop table t1;
+#
+# test of union subquery in the FROM clause with complex distinct/all (BUG#6565)
+#
+create table t1(a int);
+create table t2(a int);
+create table t3(a int);
+insert into t1 values(1),(1);
+insert into t2 values(2),(2);
+insert into t3 values(3),(3);
+select * from t1 union distinct select * from t2 union all select * from t3;
+select * from (select * from t1 union distinct select * from t2 union all select * from t3) X;
+drop table t1, t2, t3;
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index 81788ce8d73..2f526dc9a46 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -84,7 +84,6 @@ select @a=_latin2'TEST' collate latin2_bin;
set @a=_latin2'test' collate latin2_general_ci;
select charset(@a),collation(@a),coercibility(@a);
select @a=_latin2'TEST';
---error 1267
select @a=_latin2'TEST' collate latin2_bin;
#
@@ -97,7 +96,6 @@ select collation(@a:=_latin2'test' collate latin2_bin);
select coercibility(@a:=_latin2'test' collate latin2_bin);
select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST';
select charset(@a),collation(@a),coercibility(@a);
---error 1267
select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci;
# Check that user variables are binlogged correctly (BUG#3875)
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 34c8732a9f2..895740d2e5e 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2361,7 +2361,7 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
entry->value=0;
entry->length=0;
entry->update_query_id=0;
- entry->collation.set(NULL, DERIVATION_NONE);
+ entry->collation.set(NULL, DERIVATION_IMPLICIT);
/*
If we are here, we were called from a SET or a query which sets a
variable. Imagine it is this:
@@ -2419,8 +2419,8 @@ bool Item_func_set_user_var::fix_fields(THD *thd, TABLE_LIST *tables,
and the variable has previously been initialized.
*/
if (!entry->collation.collation || !args[0]->null_value)
- entry->collation.set(args[0]->collation);
- collation.set(entry->collation);
+ entry->collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT);
+ collation.set(entry->collation.collation, DERIVATION_IMPLICIT);
cached_result_type= args[0]->result_type();
return 0;
}
@@ -2432,7 +2432,7 @@ Item_func_set_user_var::fix_length_and_dec()
maybe_null=args[0]->maybe_null;
max_length=args[0]->max_length;
decimals=args[0]->decimals;
- collation.set(args[0]->collation);
+ collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT);
}
@@ -2659,7 +2659,7 @@ Item_func_set_user_var::update()
res= update_hash((void*) save_result.vstr->ptr(),
save_result.vstr->length(), STRING_RESULT,
save_result.vstr->charset(),
- args[0]->collation.derivation);
+ DERIVATION_IMPLICIT);
break;
}
case ROW_RESULT:
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 9475ec08c96..3e627243b9f 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -132,10 +132,16 @@ static int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
/*
Temp table is created so that it hounours if UNION without ALL is to be
processed
+
+ As 'distinct' parameter we always pass FALSE (0), because underlying
+ query will control distinct condition by itself. Correct test of
+ distinct underlying query will be is_union &&
+ !unit->union_distinct->next_select() (i.e. it is union and last distinct
+ SELECT is last SELECT of UNION).
*/
if (!(table= create_tmp_table(thd, &derived_result->tmp_table_param,
- unit->types, (ORDER*) 0,
- is_union && unit->union_distinct, 1,
+ unit->types, (ORDER*) 0,
+ FALSE, 1,
(first_select->options | thd->options |
TMP_TABLE_ALL_COLUMNS),
HA_POS_ERROR,