From 4bf5c7c55b2033d3e8b218472550c35e2cda07f3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 Aug 2005 20:24:29 +0300 Subject: [PATCH] Test for BUG#4889 - inconsistent resilts of more than 2-way natural join due to incorrect transformation to JOIN ... ON. The bug itself is fixed by WL#2486. mysql-test/r/select.result: Test for BUG#4889. mysql-test/t/select.test: Test for BUG#4889. --- mysql-test/r/select.result | 15 +++++++++++++++ mysql-test/t/select.test | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 8d52dcc22fe..47dbdd49db9 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2860,3 +2860,18 @@ a2 c 2 2 drop table t1, t2; drop view v2; +create table t1 (a int(10), t1_val int(10)); +create table t2 (b int(10), t2_val int(10)); +create table t3 (a int(10), b int(10)); +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +select * from t1 natural join t2 natural join t3; +a b t1_val t2_val +1 1 1 1 +2 1 2 1 +select * from t1 natural join t3 natural join t2; +b a t1_val t2_val +1 1 1 1 +1 2 2 1 +drop table t1, t2, t3; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 414af3f9131..21fc4c25e61 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2426,3 +2426,20 @@ select * from v2 natural right join t2; drop table t1, t2; drop view v2; + + +# +# Bug #4789 Incosistent results of more than 2-way natural joins due to +# incorrect transformation to join ... on. +# + +create table t1 (a int(10), t1_val int(10)); +create table t2 (b int(10), t2_val int(10)); +create table t3 (a int(10), b int(10)); +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +# the following two queries must return the same result +select * from t1 natural join t2 natural join t3; +select * from t1 natural join t3 natural join t2; +drop table t1, t2, t3;