diff options
author | Michael Widenius <monty@askmonty.org> | 2011-06-24 10:08:09 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-06-24 10:08:09 +0300 |
commit | 6a9ac86cd374185918a0398c56d101ac7e1fddf8 (patch) | |
tree | d1cbfdde25f2ce155ebf00ec8c29b22fd7eb8b6e /mysql-test/t | |
parent | 135ce0ba6c9457c4c968b420a16e5bda69f222e0 (diff) | |
download | mariadb-git-6a9ac86cd374185918a0398c56d101ac7e1fddf8.tar.gz |
Fix for bug lp:798597 Incorrect "Duplicate entry" error with views and GROUP BY
mysql-test/r/join.result:
Test case for LP:798597
mysql-test/t/join.test:
Test case for LP:798597
sql/sql_select.cc:
In simplify_joins we reset table->maybe_null for outer join tables that can't ever be NULL.
This caused a conflict between the previously calculated items and the group_buffer against the fields
in the temporary table that are created as not null thanks to the optimization.
The fix is to correct the group by items to also be not_null so that they match the used fields and keys.
Diffstat (limited to 'mysql-test/t')
-rw-r--r-- | mysql-test/t/join.test | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 05d630edfb2..0a573e7cd4f 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -2,6 +2,7 @@ # Initialization --disable_warnings drop table if exists t1,t2,t3; +drop view if exists v1,v2; --enable_warnings # @@ -921,4 +922,21 @@ EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1; +--echo # +--echo # Bug LP:798597: Incorrect "Duplicate entry" error with views and +--echo # GROUP BY +--echo # + +CREATE TABLE t1 ( f1 int NOT NULL , f2 int NOT NULL ) ; +INSERT INTO t1 VALUES (214,0),(6,6); +CREATE TABLE t2 ( f2 int) ; +INSERT INTO t2 VALUES (88),(88); +CREATE ALGORITHM=MERGE VIEW v1 AS SELECT t1.f1, t2.f2 FROM (t2 LEFT JOIN t1 ON (t2.f2 <> t1.f1)) WHERE (t1.f2 <= 0) ; +CREATE ALGORITHM=MERGE VIEW v2 AS SELECT t1.f1, t2.f2 FROM (t2 LEFT JOIN t1 ON (t2.f2 <> t1.f1)) WHERE (t1.f2 <= 0 or t1.f2 is null) ; +SELECT f1 , MIN(f2) FROM v1 GROUP BY f1; +SELECT f1 , MIN(f2) FROM v2 GROUP BY f1; +drop table t1,t2; +drop view v1,v2; + + --echo End of 5.1 tests |