diff options
| author | Tom Lane | 2002-03-12 00:52:10 +0000 |
|---|---|---|
| committer | Tom Lane | 2002-03-12 00:52:10 +0000 |
| commit | 6eeb95f0f56bb5e8a0a9328aeec04c9e6de87272 (patch) | |
| tree | 5f209c5926768472f9d4fd7210065c18831dbd9c /src/test | |
| parent | 66b6bf67a197db73a880d2a4d9dab05168cde8e0 (diff) | |
Restructure representation of join alias variables. An explicit JOIN
now has an RTE of its own, and references to its outputs now are Vars
referencing the JOIN RTE, rather than CASE-expressions. This allows
reverse-listing in ruleutils.c to use the correct alias easily, rather
than painfully reverse-engineering the alias namespace as it used to do.
Also, nested FULL JOINs work correctly, because the result of the inner
joins are simple Vars that the planner can cope with. This fixes a bug
reported a couple times now, notably by Tatsuo on 18-Nov-01. The alias
Vars are expanded into COALESCE expressions where needed at the very end
of planning, rather than during parsing.
Also, beginnings of support for showing plan qualifier expressions in
EXPLAIN. There are probably still cases that need work.
initdb forced due to change of stored-rule representation.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/join.out | 25 | ||||
| -rw-r--r-- | src/test/regress/sql/join.sql | 23 |
2 files changed, 47 insertions, 1 deletions
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out index 6774390046e..cfe7ded08d9 100644 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@ -1847,7 +1847,32 @@ SELECT '' AS "xxx", * FROM J1_TBL UNION JOIN J2_TBL; ERROR: UNION JOIN is not implemented yet -- +-- Multiway full join +-- +CREATE TABLE t1 (name TEXT, n INTEGER); +CREATE TABLE t2 (name TEXT, n INTEGER); +CREATE TABLE t3 (name TEXT, n INTEGER); +INSERT INTO t1 VALUES ( 'aa', 11 ); +INSERT INTO t2 VALUES ( 'aa', 12 ); +INSERT INTO t2 VALUES ( 'bb', 22 ); +INSERT INTO t2 VALUES ( 'dd', 42 ); +INSERT INTO t3 VALUES ( 'aa', 13 ); +INSERT INTO t3 VALUES ( 'bb', 23 ); +INSERT INTO t3 VALUES ( 'cc', 33 ); +SELECT * FROM t1 FULL JOIN t2 USING (name) FULL JOIN t3 USING (name); + name | n | n | n +------+----+----+---- + aa | 11 | 12 | 13 + bb | | 22 | 23 + cc | | | 33 + dd | | 42 | +(4 rows) + +-- -- Clean up -- +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; DROP TABLE J1_TBL; DROP TABLE J2_TBL; diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql index ae63a61c01f..91e64adfc94 100644 --- a/src/test/regress/sql/join.sql +++ b/src/test/regress/sql/join.sql @@ -199,9 +199,30 @@ SELECT '' AS "xxx", * FROM J1_TBL UNION JOIN J2_TBL; -- +-- Multiway full join +-- + +CREATE TABLE t1 (name TEXT, n INTEGER); +CREATE TABLE t2 (name TEXT, n INTEGER); +CREATE TABLE t3 (name TEXT, n INTEGER); + +INSERT INTO t1 VALUES ( 'aa', 11 ); +INSERT INTO t2 VALUES ( 'aa', 12 ); +INSERT INTO t2 VALUES ( 'bb', 22 ); +INSERT INTO t2 VALUES ( 'dd', 42 ); +INSERT INTO t3 VALUES ( 'aa', 13 ); +INSERT INTO t3 VALUES ( 'bb', 23 ); +INSERT INTO t3 VALUES ( 'cc', 33 ); + +SELECT * FROM t1 FULL JOIN t2 USING (name) FULL JOIN t3 USING (name); + +-- -- Clean up -- +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; + DROP TABLE J1_TBL; DROP TABLE J2_TBL; - |
