summaryrefslogtreecommitdiff
path: root/mysql-test/t/ps.test
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2006-11-29 14:52:11 +0300
committerunknown <evgen@moonbone.local>2006-11-29 14:52:11 +0300
commitfe499575af62bebdc42f804645da089f8e268bc4 (patch)
tree58303856c94bb03ed386d11976cdfba64c839b12 /mysql-test/t/ps.test
parenta5975941a43885579b86e511248d2dde1cebdb3d (diff)
downloadmariadb-git-fe499575af62bebdc42f804645da089f8e268bc4.tar.gz
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. sql/sql_base.cc: 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. mysql-test/r/ps.result: 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: 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.
Diffstat (limited to 'mysql-test/t/ps.test')
-rw-r--r--mysql-test/t/ps.test22
1 files changed, 22 insertions, 0 deletions
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index f1e8e77d94e..be77c2533e9 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -1437,4 +1437,26 @@ DEALLOCATE PREPARE stmt;
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.