MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:gluh Date:April 10 2007 10:01am
Subject:bk commit into 5.0 tree (gluh:1.2441) BUG#27069
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of gluh. When gluh 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, 2007-04-10 15:01:04+05:00, gluh@stripped +3 -0
  Bug#27069 set with identical elements are created(additional fix)
  issue an error in strict mode
  if enum|set column has duplicates members in 'create table'

  mysql-test/r/strict.result@stripped, 2007-04-10 15:01:02+05:00, gluh@stripped +5 -0
    test case

  mysql-test/t/strict.test@stripped, 2007-04-10 15:01:02+05:00, gluh@stripped +9 -0
    test case

  sql/sql_table.cc@stripped, 2007-04-10 15:01:02+05:00, gluh@stripped +19 -8
    issue an error in strict mode
    if enum|set has duplicates members 

# 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:	gluh
# Host:	eagle.(none)
# Root:	/home/gluh/MySQL/Bugs/5.0.27069

--- 1.338/sql/sql_table.cc	2007-04-07 11:35:59 +05:00
+++ 1.339/sql/sql_table.cc	2007-04-10 15:01:02 +05:00
@@ -414,10 +414,11 @@ static int sort_keys(KEY *a, KEY *b)
     which has some duplicates on its right
 
   RETURN VALUES
-    void
+    0             ok
+    1             Error
 */
 
-void check_duplicates_in_interval(const char *set_or_name,
+bool check_duplicates_in_interval(const char *set_or_name,
                                   const char *name, TYPELIB *typelib,
                                   CHARSET_INFO *cs, unsigned int *dup_val_count)
 {
@@ -433,6 +434,13 @@ void check_duplicates_in_interval(const 
     tmp.count--;
     if (find_type2(&tmp, (const char*)*cur_value, *cur_length, cs))
     {
+      if ((current_thd->variables.sql_mode &
+         (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
+      {
+        my_error(ER_DUPLICATED_VALUE_IN_TYPE, MYF(0),
+                 name,*cur_value,set_or_name);
+        return 1;
+      }
       push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_NOTE,
 			  ER_DUPLICATED_VALUE_IN_TYPE,
 			  ER(ER_DUPLICATED_VALUE_IN_TYPE),
@@ -440,6 +448,7 @@ void check_duplicates_in_interval(const 
       (*dup_val_count)++;
     }
   }
+  return 0;
 }
 
 
@@ -575,9 +584,10 @@ int prepare_create_field(create_field *s
     if (sql_field->charset->state & MY_CS_BINSORT)
       sql_field->pack_flag|=FIELDFLAG_BINARY;
     sql_field->unireg_check=Field::INTERVAL_FIELD;
-    check_duplicates_in_interval("ENUM",sql_field->field_name,
-                                 sql_field->interval,
-                                 sql_field->charset, &dup_val_count);
+    if (check_duplicates_in_interval("ENUM",sql_field->field_name,
+                                     sql_field->interval,
+                                     sql_field->charset, &dup_val_count))
+      DBUG_RETURN(1);
     break;
   case FIELD_TYPE_SET:
     sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
@@ -585,9 +595,10 @@ int prepare_create_field(create_field *s
     if (sql_field->charset->state & MY_CS_BINSORT)
       sql_field->pack_flag|=FIELDFLAG_BINARY;
     sql_field->unireg_check=Field::BIT_FIELD;
-    check_duplicates_in_interval("SET",sql_field->field_name,
-                                 sql_field->interval,
-                                 sql_field->charset, &dup_val_count);
+    if (check_duplicates_in_interval("SET",sql_field->field_name,
+                                     sql_field->interval,
+                                     sql_field->charset, &dup_val_count))
+      DBUG_RETURN(1);
     /* Check that count of unique members is not more then 64 */
     if (sql_field->interval->count -  dup_val_count > sizeof(longlong)*8)
     {

--- 1.33/mysql-test/r/strict.result	2007-03-29 11:06:12 +05:00
+++ 1.34/mysql-test/r/strict.result	2007-04-10 15:01:02 +05:00
@@ -1386,4 +1386,9 @@ ERROR 01000: Data truncated for column '
 insert into t1 values ('2E3x');
 ERROR 01000: Data truncated for column 'a' at row 1
 drop table t1;
+set sql_mode='traditional';
+create table t1 (f1 set('a','a'));
+ERROR HY000: Column 'f1' has duplicated value 'a' in SET
+create table t1 (f1 enum('a','a'));
+ERROR HY000: Column 'f1' has duplicated value 'a' in ENUM
 End of 5.0 tests

--- 1.26/mysql-test/t/strict.test	2007-03-29 11:06:12 +05:00
+++ 1.27/mysql-test/t/strict.test	2007-04-10 15:01:02 +05:00
@@ -1249,4 +1249,13 @@ insert into t1 values ('2000a');
 insert into t1 values ('2E3x');
 drop table t1;
 
+#
+# Bug#27069 set with identical elements are created
+#
+set sql_mode='traditional';
+--error 1291
+create table t1 (f1 set('a','a'));
+--error 1291
+create table t1 (f1 enum('a','a'));
+
 --echo End of 5.0 tests
Thread
bk commit into 5.0 tree (gluh:1.2441) BUG#27069gluh10 Apr