List:Internals« Previous MessageNext Message »
From:igor Date:August 11 2005 11:10pm
Subject:bk commit into 5.0 tree (igor:1.1982) BUG#12382
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.1982 05/08/11 16:10:34 igor@stripped +3 -0
  sql_base.cc:
    Fixed bug #12382.
    INSERT statement effectively changed thd->set_query_id to 0,
    while SELECT statement changed it to 0. As a result
    the insert_fields function that expanded '*' was called
    with different values of thd->set_query_id for the query
    SELECT * FROM view depending on whether it was run after
    an INSERT or after a SELECT statement. This was corrected
    by restoring the old value of thd->set_query_id when
    returning from the function setup_fields where possible
    reset could occur.
    If the value of thd->set_query_id == 0 then the fields
    substituted instead of '*' were not registered as used
    for bitmaps used_keys. This caused selection of an invalid
    execution plan for the query SELECT * from <view>.
  view.result, view.test:
    Added a test case for bug #12382.

  sql/sql_base.cc
    1.278 05/08/11 15:45:52 igor@stripped +4 -1
    Fixed bug #12382.
    INSERT statement effectively changed thd->set_query_id to 0,
    while SELECT statement changed it to 0. As a result
    the insert_fields function that expanded '*' was called
    with different values of thd->set_query_id for the query
    SELECT * FROM view depending on whether it was run after
    an INSERT or after a SELECT statement. This was corrected
    by restoring the old value of thd->set_query_id when
    returning from the function setup_fields where possible
    reset could occur.
    If the value of thd->set_query_id == 0 then the fields
    substituted instead of '*' were not registered as used
    for bitmaps used_keys. This caused selection of an invalid
    execution plan for the query SELECT * from <view>.

  mysql-test/r/view.result
    1.101 05/08/11 15:45:26 igor@stripped +14 -0
    Added a test case for bug #12382.

  mysql-test/t/view.test
    1.95 05/08/11 15:44:09 igor@stripped +19 -0
    Added a test case for bug #12382.

# 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

--- 1.277/sql/sql_base.cc	Thu Aug 11 04:18:37 2005
+++ 1.278/sql/sql_base.cc	Thu Aug 11 15:45:52 2005
@@ -3181,6 +3181,7 @@
                   List<Item> *sum_func_list, bool allow_sum_func)
 {
   reg2 Item *item;
+  bool save_set_query_id= thd->set_query_id;
   List_iterator<Item> it(fields);
   DBUG_ENTER("setup_fields");
 
@@ -3208,6 +3209,7 @@
     if (!item->fixed && item->fix_fields(thd, it.ref()) ||
 	(item= *(it.ref()))->check_cols(1))
     {
+      thd->set_query_id= save_set_query_id;
       DBUG_RETURN(TRUE); /* purecov: inspected */
     }
     if (ref)
@@ -3215,8 +3217,9 @@
     if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM &&
 	sum_func_list)
       item->split_sum_func(thd, ref_pointer_array, *sum_func_list);
-    thd->used_tables|=item->used_tables();
+    thd->used_tables|= item->used_tables();
   }
+  thd->set_query_id= save_set_query_id;
   DBUG_RETURN(test(thd->net.report_error));
 }
 

--- 1.100/mysql-test/r/view.result	Mon Aug  8 16:23:29 2005
+++ 1.101/mysql-test/r/view.result	Thu Aug 11 15:45:26 2005
@@ -2065,3 +2065,17 @@
 2	c d
 DROP VIEW v1;
 DROP TABLE t1,t2;
+CREATE TABLE t1 (id int PRIMARY KEY, f varchar(255));
+CREATE VIEW v1 AS SELECT id, f FROM t1 WHERE id <= 2;
+INSERT INTO t1 VALUES (2, 'foo2');
+INSERT INTO t1 VALUES (1, 'foo1');
+SELECT * FROM v1;
+id	f
+1	foo1
+2	foo2
+SELECT * FROM v1;
+id	f
+1	foo1
+2	foo2
+DROP VIEW v1;
+DROP TABLE t1;

--- 1.94/mysql-test/t/view.test	Mon Aug  8 16:23:29 2005
+++ 1.95/mysql-test/t/view.test	Thu Aug 11 15:44:09 2005
@@ -1901,3 +1901,22 @@
 
 DROP VIEW v1;
 DROP TABLE t1,t2;
+
+#
+# Test for bug #12382: SELECT * FROM view after INSERT command
+#
+
+CREATE TABLE t1 (id int PRIMARY KEY, f varchar(255));
+CREATE VIEW v1 AS SELECT id, f FROM t1 WHERE id <= 2;
+INSERT INTO t1 VALUES (2, 'foo2');
+INSERT INTO t1 VALUES (1, 'foo1');
+
+SELECT * FROM v1;
+SELECT * FROM v1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+
+
+
Thread
bk commit into 5.0 tree (igor:1.1982) BUG#12382igor12 Aug