summaryrefslogtreecommitdiff
path: root/mysql-test/t/view.test
diff options
context:
space:
mode:
authorunknown <igor@olga.mysql.com>2007-06-20 12:43:14 -0700
committerunknown <igor@olga.mysql.com>2007-06-20 12:43:14 -0700
commit39bf2b966214eebc79ca13a255c63e9685eab164 (patch)
treee16bea457d724c836492e5aa3d3a87b7ed9ee845 /mysql-test/t/view.test
parentccae0cf8b203e1e36b0f8b526ef21ee545ea8bac (diff)
downloadmariadb-git-39bf2b966214eebc79ca13a255c63e9685eab164.tar.gz
Fixed bug #29104: assertion abort for grouping queries using views.
The abort happened when a query contained a conjunctive predicate of the form 'view column = constant' in the WHERE condition and the grouping list also contained a reference to a view column yet a different one. Removed the failing assertion as invalid in a general case. Also fixed a bug that prevented applying some optimization for grouping queries using views. If the WHERE condition of such a query contains a conjunctive condition of the form 'view column = constant' and this view column is used in the grouping list then grouping by this column can be eliminated. The bug blocked performing this elimination. mysql-test/r/view.result: Added a test case for bug #29104. mysql-test/t/view.test: Added a test case for bug #29104. sql/item.cc: Fixed bug #29104: assertion abort for grouping queries using views. The abort happened when a query contained a conjunctive predicate of the form 'view column = constant' in the WHERE condition and the grouping list also contained a reference to a view column yet a different one. Removed the failing assertion as invalid in a general case. Also fixed a bug that prevented applying some optimization for grouping queries using views. If the WHERE condition of such a query contains a conjunctive condition of the form 'view column = constant' and this view column is used in the grouping list then grouping by this column can be eliminated. The bug blocked performing this elimination. This bug was in the function Item_field::eq while the failing assertion was in the function Item_direct_view_ref::eq.
Diffstat (limited to 'mysql-test/t/view.test')
-rw-r--r--mysql-test/t/view.test24
1 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 3c370da4139..f670ac8a49d 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -3324,4 +3324,28 @@ SELECT * FROM t1;
DROP VIEW v1,v2;
DROP TABLE t1,t2,t3,t4;
+#
+# Bug #29104: assertion abort for a query with a view column reference
+# in the GROUP BY list and a condition requiring the value
+# of another view column to be equal to a constant
+#
+
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (1,2), (2,2), (1,3), (1,2);
+
+CREATE VIEW v1 AS SELECT a, b+1 as b FROM t1;
+
+
+SELECT b, SUM(a) FROM v1 WHERE b=3 GROUP BY b;
+EXPLAIN SELECT b, SUM(a) FROM v1 WHERE b=3 GROUP BY b;
+
+SELECT a, SUM(b) FROM v1 WHERE b=3 GROUP BY a;
+EXPLAIN SELECT a, SUM(b) FROM v1 WHERE b=3 GROUP BY a;
+
+SELECT a, SUM(b) FROM v1 WHERE a=1 GROUP BY a;
+EXPLAIN SELECT a, SUM(b) FROM v1 WHERE a=1 GROUP BY a;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
--echo End of 5.0 tests.