summaryrefslogtreecommitdiff
path: root/src/test/regress
diff options
context:
space:
mode:
authorTom Lane2012-10-12 20:14:11 +0000
committerTom Lane2012-10-12 20:14:43 +0000
commit8b728e5c6e0ce6b6d6f54b92b390f14aa1aca6db (patch)
treea07e99c61279eaabbd740744dc860bf3e298d971 /src/test/regress
parent49ec613201b2e9debdf9e9ad9a2ad7c6c8083729 (diff)
Fix oversight in new code for printing rangetable aliases.
In commit 11e131854f8231a21613f834c40fe9d046926387, I missed the case of a CTE RTE that doesn't have a user-defined alias, but does have an alias assigned by set_rtable_names(). Per report from Peter Eisentraut. While at it, refactor slightly to reduce code duplication.
Diffstat (limited to 'src/test/regress')
-rw-r--r--src/test/regress/expected/with.out24
-rw-r--r--src/test/regress/sql/with.sql11
2 files changed, 35 insertions, 0 deletions
diff --git a/src/test/regress/expected/with.out b/src/test/regress/expected/with.out
index 671f293b68d..b98ca630ee9 100644
--- a/src/test/regress/expected/with.out
+++ b/src/test/regress/expected/with.out
@@ -292,6 +292,30 @@ SELECT pg_get_viewdef('vsubdepartment'::regclass, true);
FROM subdepartment;
(1 row)
+-- Another reverse-listing example
+CREATE VIEW sums_1_100 AS
+WITH RECURSIVE t(n) AS (
+ VALUES (1)
+UNION ALL
+ SELECT n+1 FROM t WHERE n < 100
+)
+SELECT sum(n) FROM t;
+\d+ sums_1_100
+ View "public.sums_1_100"
+ Column | Type | Modifiers | Storage | Description
+--------+--------+-----------+---------+-------------
+ sum | bigint | | plain |
+View definition:
+ WITH RECURSIVE t(n) AS (
+ VALUES (1)
+ UNION ALL
+ SELECT t_1.n + 1
+ FROM t t_1
+ WHERE t_1.n < 100
+ )
+ SELECT sum(t.n) AS sum
+ FROM t;
+
-- corner case in which sub-WITH gets initialized first
with recursive q as (
select * from department
diff --git a/src/test/regress/sql/with.sql b/src/test/regress/sql/with.sql
index 609f51b0c95..4ff852736bc 100644
--- a/src/test/regress/sql/with.sql
+++ b/src/test/regress/sql/with.sql
@@ -178,6 +178,17 @@ SELECT * FROM vsubdepartment ORDER BY name;
SELECT pg_get_viewdef('vsubdepartment'::regclass);
SELECT pg_get_viewdef('vsubdepartment'::regclass, true);
+-- Another reverse-listing example
+CREATE VIEW sums_1_100 AS
+WITH RECURSIVE t(n) AS (
+ VALUES (1)
+UNION ALL
+ SELECT n+1 FROM t WHERE n < 100
+)
+SELECT sum(n) FROM t;
+
+\d+ sums_1_100
+
-- corner case in which sub-WITH gets initialized first
with recursive q as (
select * from department