List:Commits« Previous MessageNext Message »
From:igor Date:April 12 2007 12:12am
Subject:bk commit into 5.1 tree (igor:1.2570)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of igor. When igor 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-11 15:12:49-07:00, igor@stripped +9 -0
  Merge olga.mysql.com:/home/igor/mysql-5.0-opt
  into  olga.mysql.com:/home/igor/mysql-5.1-opt
  MERGE: 1.1810.2374.122

  mysql-test/r/distinct.result@stripped, 2007-04-11 14:42:20-07:00, igor@stripped +0 -0
    Auto merged
    MERGE: 1.46.1.6

  mysql-test/r/row.result@stripped, 2007-04-11 14:42:20-07:00, igor@stripped +0 -0
    Auto merged
    MERGE: 1.23.1.4

  mysql-test/r/select.result@stripped, 2007-04-11 14:42:20-07:00, igor@stripped +0 -0
    Auto merged
    MERGE: 1.121.1.34

  mysql-test/r/strict.result@stripped, 2007-04-11 14:42:20-07:00, igor@stripped +0 -0
    Auto merged
    MERGE: 1.25.1.9

  mysql-test/t/select.test@stripped, 2007-04-11 14:42:21-07:00, igor@stripped +0 -0
    Auto merged
    MERGE: 1.102.1.27

  mysql-test/t/strict.test@stripped, 2007-04-11 14:42:21-07:00, igor@stripped +0 -0
    Auto merged
    MERGE: 1.19.1.8

  sql/item_cmpfunc.cc@stripped, 2007-04-11 15:12:46-07:00, igor@stripped +19 -41
    Manual merge
    MERGE: 1.187.1.57

  sql/sql_select.cc@stripped, 2007-04-11 14:42:21-07:00, igor@stripped +0 -0
    Auto merged
    MERGE: 1.312.1.196

  sql/sql_table.cc@stripped, 2007-04-11 14:42:22-07:00, igor@stripped +0 -0
    Auto merged
    MERGE: 1.239.1.101

# 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:	igor
# Host:	olga.mysql.com
# Root:	/home/igor/mysql-5.1-opt/RESYNC

--- 1.258/sql/item_cmpfunc.cc	2007-04-11 15:12:58 -07:00
+++ 1.259/sql/item_cmpfunc.cc	2007-04-11 15:12:58 -07:00
@@ -69,56 +69,80 @@
 
 
 /*
-  Aggregates result types from the array of items.
+  Compare row signature of two expressions
 
-  SYNOPSIS
-    agg_cmp_type()
-      items        array of items to aggregate the type from
-      nitems       number of items in the array
+  SYNOPSIS:
+    cmp_row_type()
+    item1          the first expression
+    item2         the second expression
 
   DESCRIPTION
-    This function aggregates result types from the array of items. Found type
-    supposed to be used later for comparison of values of these items.
-    Aggregation itself is performed by the item_cmp_type() function.
+    The function checks that two expressions have compatible row signatures
+    i.e. that the number of columns they return are the same and that if they
+    are both row expressions then each component from the first expression has 
+    a row signature compatible with the signature of the corresponding component
+    of the second expression.
+
+  RETURN VALUES
+    1  type incompatibility has been detected
+    0  otherwise
 */
 
-static Item_result agg_cmp_type(Item **items, uint nitems)
+static int cmp_row_type(Item* item1, Item* item2)
 {
-  uint i;
-  Item_result type= items[0]->result_type();
-  for (i= 1 ; i < nitems ; i++)
-    type= item_cmp_type(type, items[i]->result_type());
-  return type;
+  uint n= item1->cols();
+  if (item2->check_cols(n))
+    return 1;
+  for (uint i=0; i<n; i++)
+  {
+    if (item2->element_index(i)->check_cols(item1->element_index(i)->cols()) ||
+        (item1->element_index(i)->result_type() == ROW_RESULT &&
+         cmp_row_type(item1->element_index(i), item2->element_index(i))))
+      return 1;
+  }
+  return 0;
 }
 
 
 /*
-  Collects different types for comparison of first item with each other items
+  Aggregates result types from the array of items.
 
-  SYNOPSIS
-    collect_cmp_types()
-      items             Array of items to collect types from
-      nitems            Number of items in the array
+  SYNOPSIS:
+    agg_cmp_type()
+    type   [out] the aggregated type
+    items        array of items to aggregate the type from
+    nitems       number of items in the array
 
   DESCRIPTION
-    This function collects different result types for comparison of the first
-    item in the list with each of the remaining items in the 'items' array.
+    This function aggregates result types from the array of items. Found type
+    supposed to be used later for comparison of values of these items.
+    Aggregation itself is performed by the item_cmp_type() function.
+    The function also checks compatibility of row signatures for the
+    submitted items (see the spec for the cmp_row_type function). 
 
-  RETURN
-    Bitmap of collected types
+  RETURN VALUES
+    1  type incompatibility has been detected
+    0  otherwise
 */
 
-static uint collect_cmp_types(Item **items, uint nitems)
+static int agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
 {
   uint i;
-  uint found_types;
-  Item_result left_result= items[0]->result_type();
-  DBUG_ASSERT(nitems > 1);
-  found_types= 0;
-  for (i= 1; i < nitems ; i++)
-    found_types|= 1<< (uint)item_cmp_type(left_result,
-                                           items[i]->result_type());
-  return found_types;
+  type[0]= items[0]->result_type();
+  for (i= 1 ; i < nitems ; i++)
+  {
+    type[0]= item_cmp_type(type[0], items[i]->result_type());
+    /*
+      When aggregating types of two row expressions we have to check
+      that they have the same cardinality and that each component
+      of the first row expression has a compatible row signature with
+      the signature of the corresponding component of the second row
+      expression.
+    */ 
+    if (type[0] == ROW_RESULT && cmp_row_type(items[0], items[i]))
+      return 1;     // error found: invalid usage of rows
+  }
+  return 0;
 }
 
 
@@ -1355,7 +1379,8 @@
   */
   if (!args[0] || !args[1] || !args[2])
     return;
-  cmp_type= agg_cmp_type(args, 3);
+  if ( agg_cmp_type(&cmp_type, args, 3))
+    return;
   if (cmp_type == STRING_RESULT &&
       agg_arg_charsets(cmp_collation, args, 3, MY_COLL_CMP_CONV, 1))
    return;
@@ -2044,6 +2069,23 @@
     for (nagg= 0; nagg < ncases/2 ; nagg++)
       agg[nagg+1]= args[nagg*2];
     nagg++;
+    found_types= collect_cmp_types(agg, nagg);
+
+    for (i= 0; i <= (uint)DECIMAL_RESULT; i++)
+    {
+      if (found_types & (1 << i) && !cmp_items[i])
+      {
+        DBUG_ASSERT((Item_result)i != ROW_RESULT);
+        if ((Item_result)i == STRING_RESULT &&
+            agg_arg_charsets(cmp_collation, agg, nagg, MY_COLL_CMP_CONV, 1))
+          return;
+        if (!(cmp_items[i]=
+            cmp_item::get_comparator((Item_result)i,
+                                     cmp_collation.collation)))
+          return;
+      }
+    }
+
     found_types= collect_cmp_types(agg, nagg);
 
     for (i= 0; i <= (uint)DECIMAL_RESULT; i++)

--- 1.509/sql/sql_select.cc	2007-04-11 15:12:58 -07:00
+++ 1.510/sql/sql_select.cc	2007-04-11 15:12:58 -07:00
@@ -13799,9 +13799,7 @@
       ORDER *ord_iter;
       for (ord_iter= group; ord_iter; ord_iter= ord_iter->next)
         if ((*ord_iter->item)->eq(item, 1))
-          break;
-      if (ord_iter)
-        continue;
+          goto next_item;
       
       ORDER *ord=(ORDER*) thd->calloc(sizeof(ORDER));
       if (!ord)
@@ -13816,6 +13814,7 @@
       *prev=ord;
       prev= &ord->next;
     }
+next_item:
     ref_pointer_array++;
   }
   *prev=0;

--- 1.406/sql/sql_table.cc	2007-04-11 15:12:58 -07:00
+++ 1.407/sql/sql_table.cc	2007-04-11 15:12:58 -07:00
@@ -1929,10 +1929,11 @@
     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)
 {
@@ -1948,6 +1949,13 @@
     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),
@@ -1955,6 +1963,7 @@
       (*dup_val_count)++;
     }
   }
+  return 0;
 }
 
 
@@ -2090,9 +2099,10 @@
     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 MYSQL_TYPE_SET:
     sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
@@ -2100,9 +2110,10 @@
     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.27/mysql-test/r/row.result	2007-04-11 15:12:58 -07:00
+++ 1.28/mysql-test/r/row.result	2007-04-11 15:12:58 -07:00
@@ -175,6 +175,24 @@
 SELECT ROW(NULL,10) <=> ROW(3,NULL);
 ROW(NULL,10) <=> ROW(3,NULL)
 0
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1));
+ERROR 21000: Operand should contain 2 column(s)
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,1),ROW(1,ROW(2,3)));
+ERROR 21000: Operand should contain 2 column(s)
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),ROW(1,ROW(2,2,2)));
+ERROR 21000: Operand should contain 2 column(s)
+SELECT ROW(1,ROW(2,3,4)) IN (ROW(1,ROW(2,3,4)),ROW(1,ROW(2,2)));
+ERROR 21000: Operand should contain 3 column(s)
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1));
+ERROR 21000: Operand should contain 2 column(s)
+SELECT ROW(1,ROW(2,3)) IN (ROW(1,ROW(2,3)),(SELECT 1,1),ROW(1,ROW(2,4)));
+ERROR 21000: Operand should contain 2 column(s)
+SELECT ROW(1,ROW(2,3)) IN ((SELECT 1,1),ROW(1,ROW(2,3)));
+ERROR 21000: Operand should contain 2 column(s)
+SELECT ROW(2,1) IN (ROW(21,2),ROW(ROW(1,1,3),0));
+ERROR 21000: Operand should contain 1 column(s)
+SELECT ROW(2,1) IN (ROW(ROW(1,1,3),0),ROW(21,2));
+ERROR 21000: Operand should contain 1 column(s)
 SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NULL,1) = ROW(2,2,1) as `0`, ROW(1,NULL,1) = ROW(1,2,2) as `0`, ROW(1,NULL,1) = ROW(1,2,1) as `null` ;
 1	0	0	0	null
 1	0	0	0	NULL

--- 1.51/mysql-test/r/distinct.result	2007-04-11 15:12:58 -07:00
+++ 1.52/mysql-test/r/distinct.result	2007-04-11 15:12:58 -07:00
@@ -668,3 +668,17 @@
 3
 4
 DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES(1,1),(1,2),(1,3);
+SELECT DISTINCT a, b FROM t1;
+a	b
+1	1
+1	2
+1	3
+SELECT DISTINCT a, a, b FROM t1;
+a	a	b
+1	1	1
+1	1	2
+1	1	3
+DROP TABLE t1;
+End of 5.0 tests

--- 1.156/mysql-test/r/select.result	2007-04-11 15:12:58 -07:00
+++ 1.157/mysql-test/r/select.result	2007-04-11 15:12:58 -07:00
@@ -3971,4 +3971,13 @@
 faq_id
 265
 DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT, b INT, KEY inx (b,a));
+INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7);
+EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2
+ON ( f1.b=f2.b AND f1.a<f2.a ) 
+WHERE 1 AND f1.b NOT IN (100,2232,3343,51111);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	f1	index	inx	inx	10	NULL	7	Using where; Using index
+1	SIMPLE	f2	ref	inx	inx	5	test.f1.b	1	Using where; Using index
+DROP TABLE t1;
 End of 5.0 tests

--- 1.126/mysql-test/t/select.test	2007-04-11 15:12:58 -07:00
+++ 1.127/mysql-test/t/select.test	2007-04-11 15:12:58 -07:00
@@ -3346,4 +3346,17 @@
 
 DROP TABLE t1,t2;
 
+
+#
+# Bug #19372: Optimizer does not use index anymore when WHERE index NOT IN
+# () is added
+#
+CREATE TABLE t1 (a INT, b INT, KEY inx (b,a));
+
+INSERT INTO t1 VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1, 6), (1,7);
+EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2
+    ON ( f1.b=f2.b AND f1.a<f2.a ) 
+    WHERE 1 AND f1.b NOT IN (100,2232,3343,51111);
+DROP TABLE t1;    
+
 --echo End of 5.0 tests

--- 1.44/mysql-test/r/strict.result	2007-04-11 15:12:58 -07:00
+++ 1.45/mysql-test/r/strict.result	2007-04-11 15:12:58 -07:00
@@ -1386,4 +1386,9 @@
 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.29/mysql-test/t/strict.test	2007-04-11 15:12:58 -07:00
+++ 1.30/mysql-test/t/strict.test	2007-04-11 15:12:58 -07:00
@@ -1249,4 +1249,13 @@
 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.1 tree (igor:1.2570)igor12 Apr