List:Commits« Previous MessageNext Message »
From:Alexander Barkov Date:May 3 2012 10:23am
Subject:bzr push into mysql-trunk branch (alexander.barkov:3778 to 3779) Bug#11765016
View as plain text  
 3779 Alexander Barkov	2012-05-03
      Bug#11765016 / 57926: ILLEGAL MIX OF COLLATIONS FOR OPERATION 'UNION' .. USING CONCAT/FUNCTION/
      Not a bug. Adding coverage tests.

    modified:
      mysql-test/r/ctype_collate.result
      mysql-test/t/ctype_collate.test
      sql/sql_union.cc
 3778 Frazer Clement	2012-05-03
      Don't remove man pages for ndb* binaries in MySQL Cluster

    modified:
      man/CMakeLists.txt
=== modified file 'mysql-test/r/ctype_collate.result'
--- a/mysql-test/r/ctype_collate.result	2011-07-19 15:11:15 +0000
+++ b/mysql-test/r/ctype_collate.result	2012-05-03 10:22:59 +0000
@@ -660,3 +660,62 @@ latin5_turkish_ci then 2 else 3 end
 select concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
 concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci)
 abc
+#
+# Bug#11765016 57926: ILLEGAL MIX OF COLLATIONS FOR OPERATION 'UNION' .. USING CONCAT/FUNCTION/
+# Not a bug: only adding coverage tests
+#
+SET NAMES latin1 COLLATE latin1_german2_ci;
+CREATE DATABASE test1 DEFAULT CHARACTER SET latin1 COLLATE latin1_german2_ci;
+USE test1;
+#
+# Using "COLLATE latin1_swedish_ci" as the default collation for latin1
+#
+CREATE FUNCTION `getText`() RETURNS varchar(20) CHARSET latin1
+BEGIN
+RETURN "Testtext";
+END;//
+SELECT getText(), CHARSET(getText()), COLLATION(getText()), COERCIBILITY(getText());
+getText()	CHARSET(getText())	COLLATION(getText())	COERCIBILITY(getText())
+Testtext	latin1	latin1_swedish_ci	4
+CREATE TABLE t1 AS SELECT ' - ' AS a UNION SELECT getText();
+ERROR HY000: Illegal mix of collations for operation 'UNION'
+DROP FUNCTION getText;
+#
+# Using "CHARACTER SET latin1 COLLATE latin1_german2_ci" as the database defaults
+#
+CREATE FUNCTION `getText`() RETURNS varchar(20)
+BEGIN
+RETURN "Testtext";
+END;//
+SELECT getText(), CHARSET(getText()), COLLATION(getText()), COERCIBILITY(getText());
+getText()	CHARSET(getText())	COLLATION(getText())	COERCIBILITY(getText())
+Testtext	latin1	latin1_german2_ci	4
+CREATE TABLE t1 AS SELECT ' - ' AS a UNION SELECT getText();
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` varchar(20) COLLATE latin1_german2_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci
+DROP TABLE t1;
+DROP FUNCTION getText;
+#
+# Using explicit "CHARACTER SET latin1 COLLATE latin1_german2_ci"
+#
+CREATE FUNCTION `getText`() RETURNS varchar(20) CHARACTER SET latin1 COLLATE latin1_german2_ci
+BEGIN
+RETURN "Testtext";
+END;//
+SELECT getText(), CHARSET(getText()), COLLATION(getText()), COERCIBILITY(getText());
+getText()	CHARSET(getText())	COLLATION(getText())	COERCIBILITY(getText())
+Testtext	latin1	latin1_german2_ci	4
+CREATE TABLE t1 AS SELECT ' - ' AS a UNION SELECT getText();
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` varchar(20) COLLATE latin1_german2_ci DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci
+DROP TABLE t1;
+DROP FUNCTION getText;
+DROP DATABASE test1;
+USE test;
+SET NAMES latin1;

=== modified file 'mysql-test/t/ctype_collate.test'
--- a/mysql-test/t/ctype_collate.test	2009-11-06 10:49:27 +0000
+++ b/mysql-test/t/ctype_collate.test	2012-05-03 10:22:59 +0000
@@ -255,3 +255,56 @@ select case _latin1'a' when _latin2'b' t
 latin5_turkish_ci then 2 else 3 end;
 
 select concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
+
+
+--echo #
+--echo # Bug#11765016 57926: ILLEGAL MIX OF COLLATIONS FOR OPERATION 'UNION' .. USING CONCAT/FUNCTION/
+--echo # Not a bug: only adding coverage tests
+--echo #
+SET NAMES latin1 COLLATE latin1_german2_ci;
+CREATE DATABASE test1 DEFAULT CHARACTER SET latin1 COLLATE latin1_german2_ci;
+USE test1;
+DELIMITER //;
+--echo #
+--echo # Using "COLLATE latin1_swedish_ci" as the default collation for latin1
+--echo #
+CREATE FUNCTION `getText`() RETURNS varchar(20) CHARSET latin1
+BEGIN
+  RETURN "Testtext";
+END;//
+DELIMITER ;//
+SELECT getText(), CHARSET(getText()), COLLATION(getText()), COERCIBILITY(getText());
+--error ER_CANT_AGGREGATE_NCOLLATIONS
+CREATE TABLE t1 AS SELECT ' - ' AS a UNION SELECT getText();
+DROP FUNCTION getText;
+--echo #
+--echo # Using "CHARACTER SET latin1 COLLATE latin1_german2_ci" as the database defaults
+--echo #
+DELIMITER //;
+CREATE FUNCTION `getText`() RETURNS varchar(20)
+BEGIN
+  RETURN "Testtext";
+END;//
+DELIMITER ;//
+SELECT getText(), CHARSET(getText()), COLLATION(getText()), COERCIBILITY(getText());
+CREATE TABLE t1 AS SELECT ' - ' AS a UNION SELECT getText();
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+DROP FUNCTION getText;
+--echo #
+--echo # Using explicit "CHARACTER SET latin1 COLLATE latin1_german2_ci"
+--echo #
+DELIMITER //;
+CREATE FUNCTION `getText`() RETURNS varchar(20) CHARACTER SET latin1 COLLATE latin1_german2_ci
+BEGIN
+  RETURN "Testtext";
+END;//
+DELIMITER ;//
+SELECT getText(), CHARSET(getText()), COLLATION(getText()), COERCIBILITY(getText());
+CREATE TABLE t1 AS SELECT ' - ' AS a UNION SELECT getText();
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+DROP FUNCTION getText;
+DROP DATABASE test1;
+USE test;
+SET NAMES latin1;

=== modified file 'sql/sql_union.cc'
--- a/sql/sql_union.cc	2012-03-06 14:29:42 +0000
+++ b/sql/sql_union.cc	2012-05-03 10:22:59 +0000
@@ -379,6 +379,10 @@ bool st_select_lex_unit::prepare(THD *th
     /*
       Check that it was possible to aggregate
       all collations together for UNION.
+      We need this in case of UNION DISTINCT, to filter
+      out duplicates using the proper collation.
+
+      TODO: consider removing this test in case of UNION ALL.
     */
     List_iterator_fast<Item> tp(types);
     Item *type;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (alexander.barkov:3778 to 3779) Bug#11765016Alexander Barkov3 May