Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
47f63805
Commit
47f63805
authored
Oct 18, 2004
by
bar@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #6139 UNION doesn't understand collate in the column of second select
parent
f687608e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
152 additions
and
2 deletions
+152
-2
mysql-test/r/union.result
mysql-test/r/union.result
+78
-0
mysql-test/t/union.test
mysql-test/t/union.test
+55
-0
sql/item.cc
sql/item.cc
+2
-2
sql/sql_union.cc
sql/sql_union.cc
+17
-0
No files found.
mysql-test/r/union.result
View file @
47f63805
...
@@ -1033,3 +1033,81 @@ a
...
@@ -1033,3 +1033,81 @@ a
No
No
aaa,bbb
aaa,bbb
drop table t1,t2,t3,t4;
drop table t1,t2,t3,t4;
create table t1 as
(select _latin1'test') union
(select _latin1'TEST') union
(select _latin1'TeST');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`test` char(4) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select count(*) from t1;
count(*)
1
drop table t1;
create table t1 as
(select _latin1'test' collate latin1_bin) union
(select _latin1'TEST') union
(select _latin1'TeST');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`_latin1'test' collate latin1_bin` char(4) character set latin1 collate latin1_bin NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select count(*) from t1;
count(*)
3
drop table t1;
create table t1 as
(select _latin1'test') union
(select _latin1'TEST' collate latin1_bin) union
(select _latin1'TeST');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`test` char(4) character set latin1 collate latin1_bin NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select count(*) from t1;
count(*)
3
drop table t1;
create table t1 as
(select _latin1'test') union
(select _latin1'TEST') union
(select _latin1'TeST' collate latin1_bin);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`test` char(4) character set latin1 collate latin1_bin NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select count(*) from t1;
count(*)
3
drop table t1;
create table t2 (
a char character set latin1 collate latin1_swedish_ci,
b char character set latin1 collate latin1_bin);
create table t1 as
(select a from t2) union
(select b from t2);
ERROR HY000: Illegal mix of collations for operation 'UNION'
create table t1 as
(select a collate latin1_german1_ci from t2) union
(select b from t2);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a collate latin1_german1_ci` char(1) character set latin1 collate latin1_german1_ci default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 as
(select a from t2) union
(select b collate latin1_german1_ci from t2);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` char(1) character set latin1 collate latin1_german1_ci default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
drop table t2;
mysql-test/t/union.test
View file @
47f63805
...
@@ -595,3 +595,58 @@ select a as a from t3 union select "1";
...
@@ -595,3 +595,58 @@ select a as a from t3 union select "1";
select
a
as
a
from
t4
union
select
a
from
t3
;
select
a
as
a
from
t4
union
select
a
from
t3
;
select
a
as
a
from
t1
union
select
a
from
t4
;
select
a
as
a
from
t1
union
select
a
from
t4
;
drop
table
t1
,
t2
,
t3
,
t4
;
drop
table
t1
,
t2
,
t3
,
t4
;
#
# Bug #6139 UNION doesn't understand collate in the column of second select
#
create
table
t1
as
(
select
_latin1
'test'
)
union
(
select
_latin1
'TEST'
)
union
(
select
_latin1
'TeST'
);
show
create
table
t1
;
select
count
(
*
)
from
t1
;
drop
table
t1
;
create
table
t1
as
(
select
_latin1
'test'
collate
latin1_bin
)
union
(
select
_latin1
'TEST'
)
union
(
select
_latin1
'TeST'
);
show
create
table
t1
;
select
count
(
*
)
from
t1
;
drop
table
t1
;
create
table
t1
as
(
select
_latin1
'test'
)
union
(
select
_latin1
'TEST'
collate
latin1_bin
)
union
(
select
_latin1
'TeST'
);
show
create
table
t1
;
select
count
(
*
)
from
t1
;
drop
table
t1
;
create
table
t1
as
(
select
_latin1
'test'
)
union
(
select
_latin1
'TEST'
)
union
(
select
_latin1
'TeST'
collate
latin1_bin
);
show
create
table
t1
;
select
count
(
*
)
from
t1
;
drop
table
t1
;
create
table
t2
(
a
char
character
set
latin1
collate
latin1_swedish_ci
,
b
char
character
set
latin1
collate
latin1_bin
);
--
error
1271
create
table
t1
as
(
select
a
from
t2
)
union
(
select
b
from
t2
);
create
table
t1
as
(
select
a
collate
latin1_german1_ci
from
t2
)
union
(
select
b
from
t2
);
show
create
table
t1
;
drop
table
t1
;
create
table
t1
as
(
select
a
from
t2
)
union
(
select
b
collate
latin1_german1_ci
from
t2
);
show
create
table
t1
;
drop
table
t1
;
drop
table
t2
;
sql/item.cc
View file @
47f63805
...
@@ -2558,8 +2558,8 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
...
@@ -2558,8 +2558,8 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
if
(
use_new_field
||
use_expression_type
||
if
(
use_new_field
||
use_expression_type
||
(
new_result_type
!=
item_type
)
||
(
new_length
>
max_length
)
||
(
new_result_type
!=
item_type
)
||
(
new_length
>
max_length
)
||
(
!
maybe_null
&&
item
->
maybe_null
)
||
(
!
maybe_null
&&
item
->
maybe_null
)
||
(
item_type
==
STRING_RESULT
&&
(
item_type
==
STRING_RESULT
&&
!
my_charset_same
(
collation
.
collation
,
item
->
collation
.
collation
)
))
collation
.
collation
!=
item
->
collation
.
collation
))
{
{
if
(
use_expression_type
||
item
->
type
()
!=
Item
::
FIELD_ITEM
)
if
(
use_expression_type
||
item
->
type
()
!=
Item
::
FIELD_ITEM
)
field_example
=
0
;
field_example
=
0
;
...
...
sql/sql_union.cc
View file @
47f63805
...
@@ -264,6 +264,23 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
...
@@ -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
// it is not single select
if
(
first_select
->
next_select
())
if
(
first_select
->
next_select
())
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment