MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:eugene Date:November 20 2006 8:32pm
Subject:bk commit into 5.0 tree (evgen:1.2302) BUG#20327
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen 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-20 23:32:10+03:00, evgen@stripped +2 -0
  Bug#20327: Marking of a wrong field leads to a wrong result on select with view,
  prepared statement and subquery.
  
  When a field of a view from an outer select is resolved the find_field_in_view
  function creates an Item_direct_view_ref object that references the 
  corresponding view underlying field. After that the view_ref is marked
  as a dependent one. While resolving view underlying field it also get
  marked as a dependent one due to current_select still points to the subselect.
  Marking the view underlying field is wrong and lead to attaching conditions
  to a wrong table and thus to the wrong result of the whole statement.
  
  Now mark_select_range_as_dependent() function isn't called for fields from a 
  view underlying table.

  mysql-test/t/ps.test@stripped, 2006-11-20 23:24:44+03:00, evgen@stripped +2 -2
    Added a test case for bug#20327: Marking of a wrong field leads to a wrong result on select with view,prepared statement and subquery.

  mysql-test/t/ps.test@stripped, 2006-11-20 23:22:51+03:00, evgen@stripped +22 -0
    Added a test case for bug#20327: Marking of a wrong field leads to a wrong result on select with view,prepared statement and subquery.

  sql/sql_base.cc@stripped, 2006-11-20 23:31:31+03:00, evgen@stripped +6 -0
    Bug#20327: Marking of a wrong field leads to a wrong result on select with view, prepared statement and subquery.
    
    Now mark_select_range_as_dependent() function isn't called for fields from a
    view underlying table.

# 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:	evgen
# Host:	moonbone.local
# Root:	/work/20327-bug-5.0-opt-mysql

--- 1.358/sql/sql_base.cc	2006-11-02 01:50:06 +03:00
+++ 1.359/sql/sql_base.cc	2006-11-20 23:31:31 +03:00
@@ -3303,6 +3303,12 @@
     {
       if (found == WRONG_GRANT)
 	return (Field*) 0;
+
+      /*
+        Only views fields should be marked as dependent, not an underlying
+        fields.
+      */
+      if (!table_ref->belong_to_view)
       {
         SELECT_LEX *current_sel= thd->lex->current_select;
         SELECT_LEX *last_select= table_ref->select_lex;

--- 1.72/mysql-test/t/ps.test	2006-10-02 22:53:06 +04:00
+++ 1.74/mysql-test/t/ps.test	2006-11-20 23:24:44 +03:00
@@ -1437,4 +1437,26 @@
 DROP TABLE t1, t2;
 
 
+#
+# BUG#20327: Marking of a wrong field leads to a wrong result on select with
+#            view, prepared statement and subquery.
+#
+CREATE TABLE t1 (i INT);
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+INSERT INTO t1 VALUES (1), (2);
+
+let $query = SELECT t1.i FROM t1 JOIN v1 ON t1.i = v1.i
+             WHERE EXISTS (SELECT * FROM t1 WHERE v1.i = 1);
+eval $query;
+eval PREPARE stmt FROM "$query";
+# Statement execution should return '1'.
+EXECUTE stmt;
+# Check re-execution.
+EXECUTE stmt;
+
+DEALLOCATE PREPARE stmt;
+DROP VIEW v1;
+DROP TABLE t1;
+
 --echo End of 5.0 tests.
Thread
bk commit into 5.0 tree (evgen:1.2302) BUG#20327eugene20 Nov