List:Commits« Previous MessageNext Message »
From:igor Date:May 21 2006 4:10am
Subject:bk commit into 5.0 tree (igor:1.2134)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 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
  1.2134 06/05/20 19:10:43 igor@stripped +3 -0
  Merge rurik.mysql.com:/home/igor/mysql-5.0
  into  rurik.mysql.com:/home/igor/dev/mysql-5.0-0

  mysql-test/t/view.test
    1.146 06/05/20 19:10:38 igor@stripped +29 -31
    Manual merge

  mysql-test/r/view.result
    1.159 06/05/20 19:10:38 igor@stripped +42 -42
    Manual merge

  sql/sql_select.cc
    1.417 06/05/20 19:05:20 igor@stripped +0 -0
    Auto merged

# 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:	rurik.mysql.com
# Root:	/home/igor/dev/mysql-5.0-0/RESYNC

--- 1.416/sql/sql_select.cc	2006-05-10 06:40:15 -07:00
+++ 1.417/sql/sql_select.cc	2006-05-20 19:05:20 -07:00
@@ -8138,6 +8138,7 @@
                         bool make_copy_field,
                         uint convert_blob_length)
 {
+  Field *result;
   Item::Type orig_type= type;
   Item *orig_item= 0;
 
@@ -8154,7 +8155,7 @@
   case Item::SUM_FUNC_ITEM:
   {
     Item_sum *item_sum=(Item_sum*) item;
-    Field *result= item_sum->create_tmp_field(group, table, convert_blob_length);
+    result= item_sum->create_tmp_field(group, table, convert_blob_length);
     if (!result)
       thd->fatal_error();
     return result;
@@ -8164,7 +8165,6 @@
   {
     Item_field *field= (Item_field*) item;
     bool orig_modify= modify_item;
-    Field *result;
     if (orig_type == Item::REF_ITEM)
       modify_item= 0;
     /*
@@ -8198,6 +8198,8 @@
                                           convert_blob_length);
     if (orig_type == Item::REF_ITEM && orig_modify)
       ((Item_ref*)orig_item)->set_result_field(result);
+    if (field->field->eq_def(result))
+      result->dflt_field= field->field;
     return result;
   }
   /* Fall through */
@@ -8220,10 +8222,10 @@
       DBUG_ASSERT(((Item_result_field*)item)->result_field);
       *from_field= ((Item_result_field*)item)->result_field;
     }
-    return create_tmp_field_from_item(thd, item, table, (make_copy_field ? 0 :
-                                      copy_func), modify_item,
-                                      convert_blob_length);
-  case Item::TYPE_HOLDER:
+    return create_tmp_field_from_item(thd, item, 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);
   default:					// Dosen't have to be stored
     return 0;
@@ -8674,6 +8676,30 @@
       null_count+= (field->field_length & 7);
     }
     field->reset();
+
+    if (field->dflt_field && field->dflt_field->ptr)
+    {
+      /* 
+        field->dflt_field is set only in the cases  when 'field' can
+        inherit the default value that is defined for the field referred
+        by the Item_field object from which 'field' has been created.
+        For a field created not from a Item_field item dflt_field == 0.
+      */
+      my_ptrdiff_t diff;
+      Field *orig_field= field->dflt_field;
+      /* Get the value from default_values */
+      diff= (my_ptrdiff_t) (orig_field->table->s->default_values-
+                            orig_field->table->record[0]);
+      orig_field->move_field(diff);        // Points now at default_values
+      bool is_null= orig_field->is_real_null();
+      char *from= orig_field->ptr;
+      orig_field->move_field(-diff);       // Back to record[0]
+      if (is_null)
+        field->set_null();
+      else
+        memcpy(field->ptr, from, field->pack_length());
+    } 
+
     if (from_field[i])
     {						/* Not a table Item */
       copy->set(field,from_field[i],save_sum_fields);

--- 1.158/mysql-test/r/view.result	2006-05-18 11:30:36 -07:00
+++ 1.159/mysql-test/r/view.result	2006-05-20 19:10:38 -07:00
@@ -2694,3 +2694,45 @@
 38
 DROP VIEW v1;
 DROP TABLE t1;
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a char(6) DEFAULT 'xxx');
+INSERT INTO t1(id) VALUES (1), (2), (3), (4);
+INSERT INTO t1 VALUES (5,'yyy'), (6,'yyy');
+SELECT * FROM t1;
+id	a
+1	xxx
+2	xxx
+3	xxx
+4	xxx
+5	yyy
+6	yyy
+CREATE VIEW v1(a, m) AS SELECT a, MIN(id) FROM t1 GROUP BY a;
+SELECT * FROM v1;
+a	m
+xxx	1
+yyy	5
+CREATE TABLE t2 SELECT * FROM v1;
+INSERT INTO t2(m) VALUES (0);
+SELECT * FROM t2;
+a	m
+xxx	1
+yyy	5
+NULL	0
+DROP VIEW v1;
+DROP TABLE t1,t2;
+CREATE TABLE t1 (id int PRIMARY KEY, e ENUM('a','b') NOT NULL DEFAULT 'b');
+INSERT INTO t1(id) VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (4,'a');
+SELECT * FROM t1;
+id	e
+1	b
+2	b
+3	b
+4	a
+CREATE VIEW v1(m, e) AS SELECT MIN(id), e FROM t1 GROUP BY e;
+CREATE TABLE t2 SELECT * FROM v1;
+SELECT * FROM t2;
+m	e
+4	a
+1	b
+DROP VIEW v1;
+DROP TABLE IF EXISTS t1,t2;

--- 1.145/mysql-test/t/view.test	2006-05-18 11:30:36 -07:00
+++ 1.146/mysql-test/t/view.test	2006-05-20 19:10:38 -07:00
@@ -2566,4 +2566,33 @@
 DROP VIEW v1;
 DROP TABLE t1;
 
+#
+# Bug #19089: wrong inherited dafault values in temp table views
+#
 
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a char(6) DEFAULT 'xxx');
+INSERT INTO t1(id) VALUES (1), (2), (3), (4);
+INSERT INTO t1 VALUES (5,'yyy'), (6,'yyy');
+SELECT * FROM t1;
+
+CREATE VIEW v1(a, m) AS SELECT a, MIN(id) FROM t1 GROUP BY a;
+SELECT * FROM v1;
+
+CREATE TABLE t2 SELECT * FROM v1;
+INSERT INTO t2(m) VALUES (0);
+SELECT * FROM t2;
+
+DROP VIEW v1;
+DROP TABLE t1,t2;
+
+CREATE TABLE t1 (id int PRIMARY KEY, e ENUM('a','b') NOT NULL DEFAULT 'b');
+INSERT INTO t1(id) VALUES (1), (2), (3);
+INSERT INTO t1 VALUES (4,'a');
+SELECT * FROM t1;
+
+CREATE VIEW v1(m, e) AS SELECT MIN(id), e FROM t1 GROUP BY e;
+CREATE TABLE t2 SELECT * FROM v1;
+SELECT * FROM t2;
+
+DROP VIEW v1;
+DROP TABLE IF EXISTS t1,t2;
Thread
bk commit into 5.0 tree (igor:1.2134)igor21 May