List:Commits« Previous MessageNext Message »
From:bar Date:November 9 2006 11:41am
Subject:bk commit into 5.0 tree (bar:1.2297) BUG#21505
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of bar. When bar does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-11-09 14:41:34+04:00, bar@stripped +8 -0
   Bug#21505 Create view - illegal mix of collation for operation 'UNION'
    
    The problem was that any VIEW columns had always implicit derivation.
    Fix: derivation is now copied from the original expression
    given in VIEW definition.
    For example:
    - a VIEW column which comes from a string constant
      in CREATE VIEW definition have now coercible derivation.
    - a VIEW column having COLLATE clause
      in CREATE VIEW definition have now explicit derivation.

  mysql-test/r/ctype_utf8.result@stripped, 2006-11-09 14:41:21+04:00, bar@stripped +26 -0
    Adding test case

  mysql-test/t/ctype_utf8.test@stripped, 2006-11-09 14:41:21+04:00, bar@stripped +24 -0
    Adding test case

  sql/field.cc@stripped, 2006-11-09 14:41:21+04:00, bar@stripped +1 -0
    Copying derivation from item to field.

  sql/field.h@stripped, 2006-11-09 14:41:22+04:00, bar@stripped +7 -0
    Adding derivation and methods to get/set it into Field.
    

  sql/item.cc@stripped, 2006-11-09 14:41:22+04:00, bar@stripped +1 -1
    Copying derivation from field to item.

  sql/item.h@stripped, 2006-11-09 14:41:22+04:00, bar@stripped +0 -12
    Moving "enum Derivation" declaration from item.h to mysql_priv.h
    

  sql/mysql_priv.h@stripped, 2006-11-09 14:41:22+04:00, bar@stripped +11 -0
    Moving "enum Derivation" declaration from item.h to mysql_priv.h

  sql/sql_select.cc@stripped, 2006-11-09 14:41:22+04:00, bar@stripped +4 -1
    Copying derivation from item to field in
    create_tmp_field_from_item() and create_tmp_field().
    

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	bar
# Host:	bar.intranet.mysql.r18.ru
# Root:	/usr/home/bar/mysql-5.0.b21505

--- 1.329/sql/field.cc	2006-11-09 14:41:44 +04:00
+++ 1.330/sql/field.cc	2006-11-09 14:41:44 +04:00
@@ -1399,6 +1399,7 @@ Field_str::Field_str(char *ptr_arg,uint3
   field_charset=charset;
   if (charset->state & MY_CS_BINSORT)
     flags|=BINARY_FLAG;
+  field_derivation= DERIVATION_IMPLICIT;
 }
 
 

--- 1.189/sql/field.h	2006-11-09 14:41:44 +04:00
+++ 1.190/sql/field.h	2006-11-09 14:41:44 +04:00
@@ -302,6 +302,9 @@ public:
   virtual CHARSET_INFO *sort_charset(void) const { return charset(); }
   virtual bool has_charset(void) const { return FALSE; }
   virtual void set_charset(CHARSET_INFO *charset) { }
+  virtual enum Derivation derivation(void) const
+  { return DERIVATION_IMPLICIT; }
+  virtual void set_derivation(enum Derivation derivation) { }
   bool set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code,
                    int cuted_increment);
   bool check_int(const char *str, int length, const char *int_end,
@@ -373,6 +376,7 @@ public:
 class Field_str :public Field {
 protected:
   CHARSET_INFO *field_charset;
+  enum Derivation field_derivation;
 public:
   Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
 	    uchar null_bit_arg, utype unireg_check_arg,
@@ -387,6 +391,9 @@ public:
   uint size_of() const { return sizeof(*this); }
   CHARSET_INFO *charset(void) const { return field_charset; }
   void set_charset(CHARSET_INFO *charset) { field_charset=charset; }
+  enum Derivation derivation(void) const { return field_derivation; }
+  virtual void set_derivation(enum Derivation derivation_arg)
+  { field_derivation= derivation_arg; }
   bool binary() const { return field_charset == &my_charset_bin; }
   uint32 max_length() { return field_length; }
   friend class create_field;

--- 1.236/sql/item.cc	2006-11-09 14:41:44 +04:00
+++ 1.237/sql/item.cc	2006-11-09 14:41:44 +04:00
@@ -1622,7 +1622,7 @@ void Item_field::set_field(Field *field_
   db_name= field_par->table->s->db;
   alias_name_used= field_par->table->alias_name_used;
   unsigned_flag=test(field_par->flags & UNSIGNED_FLAG);
-  collation.set(field_par->charset(), DERIVATION_IMPLICIT);
+  collation.set(field_par->charset(), field_par->derivation());
   fixed= 1;
 }
 

--- 1.209/sql/item.h	2006-11-09 14:41:44 +04:00
+++ 1.210/sql/item.h	2006-11-09 14:41:44 +04:00
@@ -27,19 +27,7 @@ class Item_field;
 /*
    "Declared Type Collation"
    A combination of collation and its derivation.
-*/
 
-enum Derivation
-{
-  DERIVATION_IGNORABLE= 5,
-  DERIVATION_COERCIBLE= 4,
-  DERIVATION_SYSCONST= 3,
-  DERIVATION_IMPLICIT= 2,
-  DERIVATION_NONE= 1,
-  DERIVATION_EXPLICIT= 0
-};
-
-/*
   Flags for collation aggregation modes:
   MY_COLL_ALLOW_SUPERSET_CONV  - allow conversion to a superset
   MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value

--- 1.419/sql/mysql_priv.h	2006-11-09 14:41:44 +04:00
+++ 1.420/sql/mysql_priv.h	2006-11-09 14:41:44 +04:00
@@ -96,6 +96,17 @@ extern CHARSET_INFO *system_charset_info
 extern CHARSET_INFO *national_charset_info, *table_alias_charset;
 
 
+enum Derivation
+{
+  DERIVATION_IGNORABLE= 5,
+  DERIVATION_COERCIBLE= 4,
+  DERIVATION_SYSCONST= 3,
+  DERIVATION_IMPLICIT= 2,
+  DERIVATION_NONE= 1,
+  DERIVATION_EXPLICIT= 0
+};
+
+
 typedef struct my_locale_st
 {
   const char *name;

--- 1.472/sql/sql_select.cc	2006-11-09 14:41:44 +04:00
+++ 1.473/sql/sql_select.cc	2006-11-09 14:41:44 +04:00
@@ -8560,6 +8560,7 @@ static Field *create_tmp_field_from_item
                                      item->collation.collation);
     else
       new_field= item->make_string_field(table);
+    new_field->set_derivation(item->collation.derivation);
     break;
   case DECIMAL_RESULT:
     new_field= new Field_new_decimal(item->max_length, maybe_null, item->name,
@@ -8735,7 +8736,9 @@ Field *create_tmp_field(THD *thd, TABLE 
                                       (make_copy_field ? 0 : copy_func),
                                        modify_item, convert_blob_length);
   case Item::TYPE_HOLDER:  
-    return ((Item_type_holder *)item)->make_field_by_type(table);
+    result= ((Item_type_holder *)item)->make_field_by_type(table);
+    result->set_derivation(item->collation.derivation);
+    return result;
   default:					// Dosen't have to be stored
     return 0;
   }

--- 1.100/mysql-test/r/ctype_utf8.result	2006-11-09 14:41:44 +04:00
+++ 1.101/mysql-test/r/ctype_utf8.result	2006-11-09 14:41:44 +04:00
@@ -1536,6 +1536,32 @@ set @a:=null;
 execute my_stmt using @a;
 a	b
 drop table if exists t1;
+drop table if exists t1;
+drop view if exists v1, v2;
+set names utf8;
+create table t1(col1 varchar(12) character set utf8 collate utf8_unicode_ci);
+insert into t1 values('t1_val');
+create view v1 as select 'v1_val' as col1;
+select coercibility(col1), collation(col1) from v1;
+coercibility(col1)	collation(col1)
+4	utf8_general_ci
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1)from v2;
+coercibility(col1)	collation(col1)
+2	utf8_unicode_ci
+2	utf8_unicode_ci
+drop view v1, v2;
+create view v1 as select 'v1_val' collate utf8_swedish_ci as col1;
+select coercibility(col1), collation(col1) from v1;
+coercibility(col1)	collation(col1)
+0	utf8_swedish_ci
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1) from v2;
+coercibility(col1)	collation(col1)
+0	utf8_swedish_ci
+0	utf8_swedish_ci
+drop view v1, v2;
+drop table t1;
 CREATE TABLE t1 (
 colA int(11) NOT NULL,
 colB varchar(255) character set utf8 NOT NULL,

--- 1.92/mysql-test/t/ctype_utf8.test	2006-11-09 14:41:44 +04:00
+++ 1.93/mysql-test/t/ctype_utf8.test	2006-11-09 14:41:44 +04:00
@@ -1228,6 +1228,30 @@ set @a:=null;
 execute my_stmt using @a;
 drop table if exists t1;
 
+
+#
+# Bug#21505 Create view - illegal mix of collation for operation 'UNION'
+#
+--disable_warnings
+drop table if exists t1;
+drop view if exists v1, v2;
+--enable_warnings
+set names utf8;
+create table t1(col1 varchar(12) character set utf8 collate utf8_unicode_ci);
+insert into t1 values('t1_val');
+create view v1 as select 'v1_val' as col1;
+select coercibility(col1), collation(col1) from v1;
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1)from v2;
+drop view v1, v2;
+create view v1 as select 'v1_val' collate utf8_swedish_ci as col1;
+select coercibility(col1), collation(col1) from v1;
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1) from v2;
+drop view v1, v2;
+drop table t1;
+
+
 #
 # Bug#19960: Inconsistent results when joining
 # InnoDB tables using partial UTF8 indexes
Thread
bk commit into 5.0 tree (bar:1.2297) BUG#21505bar9 Nov