on placeholder entries in view rule action query's range table
Per Alvaro's advice, forking this from [1]/messages/by-id/CA+HiwqGjJDmUhDSfv-U2qhKJjt9ST7Xh9JXC_irsAQ1TAUsJYg@mail.gmail.com.
In light of my proposed changes to decouple permission checking from
the range table on that thread (now committed as a61b1f7482), I had
also been posting a patch there to rethink commands/view.c's
editorializing of a view rule action query' range table to add the
placeholder RTEs for checking the permissions of the view relation
among other things.
That patch came to life after Tom's comment in the same thread, where
he wondered if we could do away with those placeholder entries [2]/messages/by-id/697679.1625154303@sss.pgh.pa.us if
permission checking details were to go elsewhere.
All but very recent versions of the patch were simply removing the
function UpdateRangeTableOfViewParse() that added those entries, such
that a view rule's action query would be stored with only the RTEs of
the relations mentioned in the view's query, with no trace whatsoever
of the view relation. ApplyRetrieveRule() working with a given user
query on the view would add a placeholder entry for the view for the
purpose served by those no-longer-present placeholder RTEs in the rule
action query's range table. It would accomplish that by adding a copy
of the query's view RTE with appropriate permission details filled in
before converting the latter into a RTE_SUBQUERY entry. However, this
approach of not storing the placeholder in the stored rule would lead
to a whole lot of regression test output changes, because the stored
view queries of many regression tests involving views would now end up
with only 1 entry in the range table instead of 3, causing ruleutils.c
to no longer qualify the column names in the deparsed representation
of those queries appearing in those regression test expected outputs.
To avoid that churn (not sure if really a goal to strive for in this
case!), I thought it might be better to keep the OLD entry in the
stored action query while getting rid of the NEW entry. Other than
avoiding the regression test output churn, this also makes the changes
of ApplyRetrieveRule unnecessary. Actually, as I was addressing
Alvaro's comments on the now-committed patch, I was starting to get
concerned about the implications of the change in position of the view
relation RTE in the query's range table if ApplyRetrieveRule() adds
one from scratch instead of simply recycling the OLD entry from stored
rule action query, even though I could see that there are no
*user-visible* changes, especially after decoupling permission
checking from the range table.
Anyway, the attached patch implements this 2nd approach.
I'll add this to the January CF.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com
[1]: /messages/by-id/CA+HiwqGjJDmUhDSfv-U2qhKJjt9ST7Xh9JXC_irsAQ1TAUsJYg@mail.gmail.com
[2]: /messages/by-id/697679.1625154303@sss.pgh.pa.us
Attachments:
v1-0001-Do-not-add-the-NEW-entry-to-view-rule-action-s-ra.patchapplication/octet-stream; name=v1-0001-Do-not-add-the-NEW-entry-to-view-rule-action-s-ra.patchDownload
From 8f7d8e8220bcb6fb7fa0ae29bdcade1927a86971 Mon Sep 17 00:00:00 2001
From: amitlan <amitlangote09@gmail.com>
Date: Mon, 21 Nov 2022 15:27:56 +0900
Subject: [PATCH v1] Do not add the NEW entry to view rule action's range table
The OLD entry suffices as a placeholder for the view relation when
it is queried, such as for checking its permissions during a query's
execution, but the NEW entry has no role whatsoever, so stop adding
it.
With there now being fewer entries in the view query's range table,
this change affects how the deparsed queries involving views look,
especially in the cases where the output of deparsing depends on using
RT indexs (such as automatically generated RTE alias names in
postgres_fdw deparser). To wit, some postgres_fdw regression tests
whose expected output changes due to this have been updated to match.
---
.../postgres_fdw/expected/postgres_fdw.out | 4 +-
src/backend/commands/lockcmds.c | 6 +-
src/backend/commands/view.c | 81 +++++++------------
src/backend/rewrite/rewriteDefine.c | 6 +-
src/backend/rewrite/rewriteHandler.c | 4 +-
5 files changed, 38 insertions(+), 63 deletions(-)
diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out
index 2ab3f1efaa..ccf36a3f67 100644
--- a/contrib/postgres_fdw/expected/postgres_fdw.out
+++ b/contrib/postgres_fdw/expected/postgres_fdw.out
@@ -2606,7 +2606,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1
Foreign Scan
Output: ft4.c1, ft5.c2, ft5.c1
Relations: (public.ft4) LEFT JOIN (public.ft5)
- Remote SQL: SELECT r6.c1, r9.c2, r9.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r9 ON (((r6.c1 = r9.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r9.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r5.c1, r7.c2, r7.c1 FROM ("S 1"."T 3" r5 LEFT JOIN "S 1"."T 4" r7 ON (((r5.c1 = r7.c1)))) ORDER BY r5.c1 ASC NULLS LAST, r7.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
@@ -2669,7 +2669,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c
Foreign Scan
Output: ft4.c1, t2.c2, t2.c1
Relations: (public.ft4) LEFT JOIN (public.ft5 t2)
- Remote SQL: SELECT r6.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r2 ON (((r6.c1 = r2.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r5.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r5 LEFT JOIN "S 1"."T 4" r2 ON (((r5.c1 = r2.c1)))) ORDER BY r5.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index b0747ce291..ce0e6ac112 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -195,12 +195,10 @@ LockViewRecurse_walker(Node *node, LockViewRecurse_context *context)
char *relname = get_rel_name(relid);
/*
- * The OLD and NEW placeholder entries in the view's rtable are
- * skipped.
+ * The OLD placeholder entry in the view's rtable is skipped.
*/
if (relid == context->viewoid &&
- (strcmp(rte->eref->aliasname, "old") == 0 ||
- strcmp(rte->eref->aliasname, "new") == 0))
+ (strcmp(rte->eref->aliasname, "old") == 0))
continue;
/* Currently, we only allow plain tables or views to be locked. */
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index 8e3c1efae4..97ad8ad663 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -356,29 +356,24 @@ DefineViewRules(Oid viewOid, Query *viewParse, bool replace)
/*---------------------------------------------------------------
* UpdateRangeTableOfViewParse
*
- * Update the range table of the given parsetree.
- * This update consists of adding two new entries IN THE BEGINNING
- * of the range table (otherwise the rule system will die a slow,
- * horrible and painful death, and we do not want that now, do we?)
- * one for the OLD relation and one for the NEW one (both of
- * them refer in fact to the "view" relation).
+ * Update the range table of the given parsetree to add a placeholder entry
+ * for the view relation and increase the 'varnos' of all the Var nodes
+ * by 1 to account for its addition.
*
- * Of course we must also increase the 'varnos' of all the Var nodes
- * by 2...
- *
- * These extra RT entries are not actually used in the query,
- * except for run-time locking.
+ * This extra RT entry for the view relation is not actually used in the query
+ * but it is needed so that 1) the executor can checks the view relation's
+ * permissions via the RTEPermissionInfo that is also added in this function,
+ * 2) the executor can lock the view relation, and 3) the planner can record
+ * the view relation's OID in PlannedStmt.relationOids.
*---------------------------------------------------------------
*/
static Query *
UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
{
Relation viewRel;
- List *new_rt;
ParseNamespaceItem *nsitem;
- RangeTblEntry *rt_entry1,
- *rt_entry2;
- RTEPermissionInfo *rte_perminfo1;
+ RangeTblEntry *rt_entry;
+ RTEPermissionInfo *rte_perminfo;
ParseState *pstate;
ListCell *lc;
@@ -399,31 +394,25 @@ UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
viewRel = relation_open(viewOid, AccessShareLock);
/*
- * Create the 2 new range table entries and form the new range table...
- * OLD first, then NEW....
+ * Create a placeholder RTE for the view relation named "OLD" and add it
+ * as the 1st entry of the new range table, followed by the entries in the
+ * view query's range table. Do the same for the corresponding
+ * RTEPermissionInfo, which means we must adjust the view query's RTEs'
+ * perminfoindex to cope.
+ *
+ * Note that when rewriting a query on the view, ApplyRetrieveRule() will
+ * transfer the view relation's permission details into this
+ * placeholder RTEPermissionInfo. That's needed because the view's RTE
+ * itself in that query will be transposed into a subquery RTE that can't
+ * be made to any RTEPermissionInfo; see the code stanza at the end of
+ * ApplyRetrieveRule() for more details.
*/
nsitem = addRangeTableEntryForRelation(pstate, viewRel,
AccessShareLock,
makeAlias("old", NIL),
false, false);
- rt_entry1 = nsitem->p_rte;
- rte_perminfo1 = nsitem->p_perminfo;
- nsitem = addRangeTableEntryForRelation(pstate, viewRel,
- AccessShareLock,
- makeAlias("new", NIL),
- false, false);
- rt_entry2 = nsitem->p_rte;
-
- /*
- * Add only the "old" RTEPermissionInfo at the head of view query's list
- * and update the other RTEs' perminfoindex accordingly. When rewriting a
- * query on the view, ApplyRetrieveRule() will transfer the view
- * relation's permission details into this RTEPermissionInfo. That's
- * needed because the view's RTE itself will be transposed into a subquery
- * RTE that can't carry the permission details; see the code stanza toward
- * the end of ApplyRetrieveRule() for how that's done.
- */
- viewParse->rteperminfos = lcons(rte_perminfo1, viewParse->rteperminfos);
+ rt_entry = nsitem->p_rte;
+ rte_perminfo = nsitem->p_perminfo;
foreach(lc, viewParse->rtable)
{
RangeTblEntry *rte = lfirst(lc);
@@ -431,23 +420,13 @@ UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
if (rte->perminfoindex > 0)
rte->perminfoindex += 1;
}
+ viewParse->rtable = lcons(rt_entry, viewParse->rtable);
+ viewParse->rteperminfos = lcons(rte_perminfo, viewParse->rteperminfos);
/*
- * Also make the "new" RTE's RTEPermissionInfo undiscoverable. This is a
- * bit of a hack given that all the non-child RTE_RELATION entries really
- * should have a RTEPermissionInfo, but this dummy "new" RTE is going to
- * go away anyway in the very near future.
- */
- rt_entry2->perminfoindex = 0;
-
- new_rt = lcons(rt_entry1, lcons(rt_entry2, viewParse->rtable));
-
- viewParse->rtable = new_rt;
-
- /*
- * Now offset all var nodes by 2, and jointree RT indexes too.
+ * Now offset all var nodes by 1, and jointree RT indexes too.
*/
- OffsetVarNodes((Node *) viewParse, 2, 0);
+ OffsetVarNodes((Node *) viewParse, 1, 0);
relation_close(viewRel, AccessShareLock);
@@ -617,8 +596,8 @@ void
StoreViewQuery(Oid viewOid, Query *viewParse, bool replace)
{
/*
- * The range table of 'viewParse' does not contain entries for the "OLD"
- * and "NEW" relations. So... add them!
+ * Add a placeholder entry for the "OLD" relation to the range table of
+ * 'viewParse'; see the header comment for why it's needed.
*/
viewParse = UpdateRangeTableOfViewParse(viewOid, viewParse);
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index 9f3afe965a..8bfaefd098 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -636,10 +636,8 @@ checkRuleResultList(List *targetList, TupleDesc resultDesc, bool isSelect,
*
* Note: for a view (ON SELECT rule), the checkAsUser field of the OLD
* RTE entry's RTEPermissionInfo will be overridden when the view rule is
- * expanded, and the checkAsUser for the NEW RTE entry's RTEPermissionInfo is
- * irrelevant because its requiredPerms bits will always be zero. However, for
- * other types of rules it's important to set these fields to match the rule
- * owner. So we just set them always.
+ * expanded. However, for other types of rules it's important to set these
+ * fields to match the rule owner. So we just set them always.
*/
void
setRuleCheckAsUser(Node *node, Oid userid)
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index ea56ff79c8..11b8e449bd 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -1907,8 +1907,8 @@ ApplyRetrieveRule(Query *parsetree,
*
* NB: this must agree with the parser's transformLockingClause() routine.
* However, unlike the parser we have to be careful not to mark a view's
- * OLD and NEW rels for updating. The best way to handle that seems to be
- * to scan the jointree to determine which rels are used.
+ * OLD rel for updating. The best way to handle that seems to be to scan
+ * the jointree to determine which rels are used.
*/
static void
markQueryForLocking(Query *qry, Node *jtnode,
--
2.35.3
On Wed, Dec 7, 2022 at 6:42 PM Amit Langote <amitlangote09@gmail.com> wrote:
Per Alvaro's advice, forking this from [1].
Forgot to add Alvaro.
In light of my proposed changes to decouple permission checking from
the range table on that thread (now committed as a61b1f7482), I had
also been posting a patch there to rethink commands/view.c's
editorializing of a view rule action query' range table to add the
placeholder RTEs for checking the permissions of the view relation
among other things.That patch came to life after Tom's comment in the same thread, where
he wondered if we could do away with those placeholder entries [2] if
permission checking details were to go elsewhere.All but very recent versions of the patch were simply removing the
function UpdateRangeTableOfViewParse() that added those entries, such
that a view rule's action query would be stored with only the RTEs of
the relations mentioned in the view's query, with no trace whatsoever
of the view relation. ApplyRetrieveRule() working with a given user
query on the view would add a placeholder entry for the view for the
purpose served by those no-longer-present placeholder RTEs in the rule
action query's range table. It would accomplish that by adding a copy
of the query's view RTE with appropriate permission details filled in
before converting the latter into a RTE_SUBQUERY entry. However, this
approach of not storing the placeholder in the stored rule would lead
to a whole lot of regression test output changes, because the stored
view queries of many regression tests involving views would now end up
with only 1 entry in the range table instead of 3, causing ruleutils.c
to no longer qualify the column names in the deparsed representation
of those queries appearing in those regression test expected outputs.To avoid that churn (not sure if really a goal to strive for in this
case!), I thought it might be better to keep the OLD entry in the
stored action query while getting rid of the NEW entry. Other than
avoiding the regression test output churn, this also makes the changes
of ApplyRetrieveRule unnecessary. Actually, as I was addressing
Alvaro's comments on the now-committed patch, I was starting to get
concerned about the implications of the change in position of the view
relation RTE in the query's range table if ApplyRetrieveRule() adds
one from scratch instead of simply recycling the OLD entry from stored
rule action query, even though I could see that there are no
*user-visible* changes, especially after decoupling permission
checking from the range table.Anyway, the attached patch implements this 2nd approach.
I'll add this to the January CF.
Done.
https://commitfest.postgresql.org/41/4048/
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com
On 2022-Dec-07, Amit Langote wrote:
However, this
approach of not storing the placeholder in the stored rule would lead
to a whole lot of regression test output changes, because the stored
view queries of many regression tests involving views would now end up
with only 1 entry in the range table instead of 3, causing ruleutils.c
to no longer qualify the column names in the deparsed representation
of those queries appearing in those regression test expected outputs.To avoid that churn (not sure if really a goal to strive for in this
case!), I thought it might be better to keep the OLD entry in the
stored action query while getting rid of the NEW entry.
If the *only* argument for keeping the RTE for OLD is to avoid
regression test churn, then definitely it is not worth doing and it
should be ripped out.
Other than avoiding the regression test output churn, this also makes
the changes of ApplyRetrieveRule unnecessary.
But do these changes mean the code is worse afterwards? Changing stuff,
per se, is not bad. Also, since you haven't posted the "complete" patch
since Nov 7th, it's not easy to tell what those changes are.
Maybe you should post both versions of the patch -- one that removes
just NEW, and one that removes both OLD and NEW, so that we can judge.
Actually, as I was addressing Alvaro's comments on the now-committed
patch, I was starting to get concerned about the implications of the
change in position of the view relation RTE in the query's range table
if ApplyRetrieveRule() adds one from scratch instead of simply
recycling the OLD entry from stored rule action query, even though I
could see that there are no *user-visible* changes, especially after
decoupling permission checking from the range table.
Hmm, I think I see the point, though I don't necessarily agree that
there is a problem.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
On Thu, Dec 8, 2022 at 6:12 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
On 2022-Dec-07, Amit Langote wrote:
However, this
approach of not storing the placeholder in the stored rule would lead
to a whole lot of regression test output changes, because the stored
view queries of many regression tests involving views would now end up
with only 1 entry in the range table instead of 3, causing ruleutils.c
to no longer qualify the column names in the deparsed representation
of those queries appearing in those regression test expected outputs.To avoid that churn (not sure if really a goal to strive for in this
case!), I thought it might be better to keep the OLD entry in the
stored action query while getting rid of the NEW entry.If the *only* argument for keeping the RTE for OLD is to avoid
regression test churn, then definitely it is not worth doing and it
should be ripped out.Other than avoiding the regression test output churn, this also makes
the changes of ApplyRetrieveRule unnecessary.But do these changes mean the code is worse afterwards? Changing stuff,
per se, is not bad. Also, since you haven't posted the "complete" patch
since Nov 7th, it's not easy to tell what those changes are.Maybe you should post both versions of the patch -- one that removes
just NEW, and one that removes both OLD and NEW, so that we can judge.
OK, I gave the previous approach another try to see if I can change
ApplyRetrieveRule() in a bit more convincing way this time around, now
that the RTEPermissionInfo patch is in.
I would say I'm more satisfied with how it turned out this time. Let
me know what you think.
Actually, as I was addressing Alvaro's comments on the now-committed
patch, I was starting to get concerned about the implications of the
change in position of the view relation RTE in the query's range table
if ApplyRetrieveRule() adds one from scratch instead of simply
recycling the OLD entry from stored rule action query, even though I
could see that there are no *user-visible* changes, especially after
decoupling permission checking from the range table.Hmm, I think I see the point, though I don't necessarily agree that
there is a problem.
Yeah, I'm not worried as much with the new version. That is helped by
the fact that I've made ApplyRetrieveRule() now do basically what
UpdateRangeTableOfViewParse() would do with the stored rule query.
Also, our making add_rtes_to_flat_rtable() add perminfos in the RTE
order helped find the bug with the last version.
Attaching both patches.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com
Attachments:
v1-0001-Do-not-add-the-NEW-entry-to-view-rule-action-s-ra.patchapplication/octet-stream; name=v1-0001-Do-not-add-the-NEW-entry-to-view-rule-action-s-ra.patchDownload
From 8f7d8e8220bcb6fb7fa0ae29bdcade1927a86971 Mon Sep 17 00:00:00 2001
From: amitlan <amitlangote09@gmail.com>
Date: Mon, 21 Nov 2022 15:27:56 +0900
Subject: [PATCH v1] Do not add the NEW entry to view rule action's range table
The OLD entry suffices as a placeholder for the view relation when
it is queried, such as for checking its permissions during a query's
execution, but the NEW entry has no role whatsoever, so stop adding
it.
With there now being fewer entries in the view query's range table,
this change affects how the deparsed queries involving views look,
especially in the cases where the output of deparsing depends on using
RT indexs (such as automatically generated RTE alias names in
postgres_fdw deparser). To wit, some postgres_fdw regression tests
whose expected output changes due to this have been updated to match.
---
.../postgres_fdw/expected/postgres_fdw.out | 4 +-
src/backend/commands/lockcmds.c | 6 +-
src/backend/commands/view.c | 81 +++++++------------
src/backend/rewrite/rewriteDefine.c | 6 +-
src/backend/rewrite/rewriteHandler.c | 4 +-
5 files changed, 38 insertions(+), 63 deletions(-)
diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out
index 2ab3f1efaa..ccf36a3f67 100644
--- a/contrib/postgres_fdw/expected/postgres_fdw.out
+++ b/contrib/postgres_fdw/expected/postgres_fdw.out
@@ -2606,7 +2606,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1
Foreign Scan
Output: ft4.c1, ft5.c2, ft5.c1
Relations: (public.ft4) LEFT JOIN (public.ft5)
- Remote SQL: SELECT r6.c1, r9.c2, r9.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r9 ON (((r6.c1 = r9.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r9.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r5.c1, r7.c2, r7.c1 FROM ("S 1"."T 3" r5 LEFT JOIN "S 1"."T 4" r7 ON (((r5.c1 = r7.c1)))) ORDER BY r5.c1 ASC NULLS LAST, r7.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
@@ -2669,7 +2669,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c
Foreign Scan
Output: ft4.c1, t2.c2, t2.c1
Relations: (public.ft4) LEFT JOIN (public.ft5 t2)
- Remote SQL: SELECT r6.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r2 ON (((r6.c1 = r2.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r5.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r5 LEFT JOIN "S 1"."T 4" r2 ON (((r5.c1 = r2.c1)))) ORDER BY r5.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index b0747ce291..ce0e6ac112 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -195,12 +195,10 @@ LockViewRecurse_walker(Node *node, LockViewRecurse_context *context)
char *relname = get_rel_name(relid);
/*
- * The OLD and NEW placeholder entries in the view's rtable are
- * skipped.
+ * The OLD placeholder entry in the view's rtable is skipped.
*/
if (relid == context->viewoid &&
- (strcmp(rte->eref->aliasname, "old") == 0 ||
- strcmp(rte->eref->aliasname, "new") == 0))
+ (strcmp(rte->eref->aliasname, "old") == 0))
continue;
/* Currently, we only allow plain tables or views to be locked. */
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index 8e3c1efae4..97ad8ad663 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -356,29 +356,24 @@ DefineViewRules(Oid viewOid, Query *viewParse, bool replace)
/*---------------------------------------------------------------
* UpdateRangeTableOfViewParse
*
- * Update the range table of the given parsetree.
- * This update consists of adding two new entries IN THE BEGINNING
- * of the range table (otherwise the rule system will die a slow,
- * horrible and painful death, and we do not want that now, do we?)
- * one for the OLD relation and one for the NEW one (both of
- * them refer in fact to the "view" relation).
+ * Update the range table of the given parsetree to add a placeholder entry
+ * for the view relation and increase the 'varnos' of all the Var nodes
+ * by 1 to account for its addition.
*
- * Of course we must also increase the 'varnos' of all the Var nodes
- * by 2...
- *
- * These extra RT entries are not actually used in the query,
- * except for run-time locking.
+ * This extra RT entry for the view relation is not actually used in the query
+ * but it is needed so that 1) the executor can checks the view relation's
+ * permissions via the RTEPermissionInfo that is also added in this function,
+ * 2) the executor can lock the view relation, and 3) the planner can record
+ * the view relation's OID in PlannedStmt.relationOids.
*---------------------------------------------------------------
*/
static Query *
UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
{
Relation viewRel;
- List *new_rt;
ParseNamespaceItem *nsitem;
- RangeTblEntry *rt_entry1,
- *rt_entry2;
- RTEPermissionInfo *rte_perminfo1;
+ RangeTblEntry *rt_entry;
+ RTEPermissionInfo *rte_perminfo;
ParseState *pstate;
ListCell *lc;
@@ -399,31 +394,25 @@ UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
viewRel = relation_open(viewOid, AccessShareLock);
/*
- * Create the 2 new range table entries and form the new range table...
- * OLD first, then NEW....
+ * Create a placeholder RTE for the view relation named "OLD" and add it
+ * as the 1st entry of the new range table, followed by the entries in the
+ * view query's range table. Do the same for the corresponding
+ * RTEPermissionInfo, which means we must adjust the view query's RTEs'
+ * perminfoindex to cope.
+ *
+ * Note that when rewriting a query on the view, ApplyRetrieveRule() will
+ * transfer the view relation's permission details into this
+ * placeholder RTEPermissionInfo. That's needed because the view's RTE
+ * itself in that query will be transposed into a subquery RTE that can't
+ * be made to any RTEPermissionInfo; see the code stanza at the end of
+ * ApplyRetrieveRule() for more details.
*/
nsitem = addRangeTableEntryForRelation(pstate, viewRel,
AccessShareLock,
makeAlias("old", NIL),
false, false);
- rt_entry1 = nsitem->p_rte;
- rte_perminfo1 = nsitem->p_perminfo;
- nsitem = addRangeTableEntryForRelation(pstate, viewRel,
- AccessShareLock,
- makeAlias("new", NIL),
- false, false);
- rt_entry2 = nsitem->p_rte;
-
- /*
- * Add only the "old" RTEPermissionInfo at the head of view query's list
- * and update the other RTEs' perminfoindex accordingly. When rewriting a
- * query on the view, ApplyRetrieveRule() will transfer the view
- * relation's permission details into this RTEPermissionInfo. That's
- * needed because the view's RTE itself will be transposed into a subquery
- * RTE that can't carry the permission details; see the code stanza toward
- * the end of ApplyRetrieveRule() for how that's done.
- */
- viewParse->rteperminfos = lcons(rte_perminfo1, viewParse->rteperminfos);
+ rt_entry = nsitem->p_rte;
+ rte_perminfo = nsitem->p_perminfo;
foreach(lc, viewParse->rtable)
{
RangeTblEntry *rte = lfirst(lc);
@@ -431,23 +420,13 @@ UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
if (rte->perminfoindex > 0)
rte->perminfoindex += 1;
}
+ viewParse->rtable = lcons(rt_entry, viewParse->rtable);
+ viewParse->rteperminfos = lcons(rte_perminfo, viewParse->rteperminfos);
/*
- * Also make the "new" RTE's RTEPermissionInfo undiscoverable. This is a
- * bit of a hack given that all the non-child RTE_RELATION entries really
- * should have a RTEPermissionInfo, but this dummy "new" RTE is going to
- * go away anyway in the very near future.
- */
- rt_entry2->perminfoindex = 0;
-
- new_rt = lcons(rt_entry1, lcons(rt_entry2, viewParse->rtable));
-
- viewParse->rtable = new_rt;
-
- /*
- * Now offset all var nodes by 2, and jointree RT indexes too.
+ * Now offset all var nodes by 1, and jointree RT indexes too.
*/
- OffsetVarNodes((Node *) viewParse, 2, 0);
+ OffsetVarNodes((Node *) viewParse, 1, 0);
relation_close(viewRel, AccessShareLock);
@@ -617,8 +596,8 @@ void
StoreViewQuery(Oid viewOid, Query *viewParse, bool replace)
{
/*
- * The range table of 'viewParse' does not contain entries for the "OLD"
- * and "NEW" relations. So... add them!
+ * Add a placeholder entry for the "OLD" relation to the range table of
+ * 'viewParse'; see the header comment for why it's needed.
*/
viewParse = UpdateRangeTableOfViewParse(viewOid, viewParse);
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index 9f3afe965a..8bfaefd098 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -636,10 +636,8 @@ checkRuleResultList(List *targetList, TupleDesc resultDesc, bool isSelect,
*
* Note: for a view (ON SELECT rule), the checkAsUser field of the OLD
* RTE entry's RTEPermissionInfo will be overridden when the view rule is
- * expanded, and the checkAsUser for the NEW RTE entry's RTEPermissionInfo is
- * irrelevant because its requiredPerms bits will always be zero. However, for
- * other types of rules it's important to set these fields to match the rule
- * owner. So we just set them always.
+ * expanded. However, for other types of rules it's important to set these
+ * fields to match the rule owner. So we just set them always.
*/
void
setRuleCheckAsUser(Node *node, Oid userid)
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index ea56ff79c8..11b8e449bd 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -1907,8 +1907,8 @@ ApplyRetrieveRule(Query *parsetree,
*
* NB: this must agree with the parser's transformLockingClause() routine.
* However, unlike the parser we have to be careful not to mark a view's
- * OLD and NEW rels for updating. The best way to handle that seems to be
- * to scan the jointree to determine which rels are used.
+ * OLD rel for updating. The best way to handle that seems to be to scan
+ * the jointree to determine which rels are used.
*/
static void
markQueryForLocking(Query *qry, Node *jtnode,
--
2.35.3
v1-0001-Remove-UpdateRangeTableOfViewParse.patchapplication/octet-stream; name=v1-0001-Remove-UpdateRangeTableOfViewParse.patchDownload
From 4a1d0288f3bca325b0288d9d75774cc27d7eb227 Mon Sep 17 00:00:00 2001
From: amitlan <amitlangote09@gmail.com>
Date: Fri, 9 Dec 2022 10:33:59 +0900
Subject: [PATCH v1] Remove UpdateRangeTableOfViewParse()
And with it, the OLD and the NEW placeholder RTEs that are stored in
a view's stored rule action query.
The OLD RTE is needed currently as a placeholder for carrying view
relation info when querying a given view, because the view relation's
RTE in the query's range table is transposed into a subquery RTE for
converting the view's query into a subselect of the user query.
The NEW RTE is currently not needed for anything.
The purpose served by the OLD RTE doesn't really require it to be
present in the stored view rule query's range table though.
ApplyRetrieveRule(), which would so far look up the OLD RTE from the
view query and repurpose it for carrying the view relation info, can
create the placeholder entries (RTE and RTEPermissionInfo) by itself,
which this commit teaches it to do.
This changes the format of the store rule for views, especially the
range table length, so a bunch of regression tests that show deparsed
view queries need to be adjusted to cope.
---
.../postgres_fdw/expected/postgres_fdw.out | 16 +-
src/backend/commands/lockcmds.c | 9 -
src/backend/commands/view.c | 107 ---
src/backend/rewrite/rewriteDefine.c | 10 +-
src/backend/rewrite/rewriteHandler.c | 59 +-
src/bin/pg_dump/t/002_pg_dump.pl | 12 +-
src/test/regress/expected/aggregates.out | 26 +-
src/test/regress/expected/alter_table.out | 16 +-
.../regress/expected/collate.icu.utf8.out | 24 +-
.../regress/expected/collate.linux.utf8.out | 24 +-
src/test/regress/expected/collate.out | 26 +-
src/test/regress/expected/create_view.out | 222 +++---
src/test/regress/expected/expressions.out | 24 +-
src/test/regress/expected/groupingsets.out | 20 +-
src/test/regress/expected/limit.out | 24 +-
src/test/regress/expected/matview.out | 24 +-
src/test/regress/expected/polymorphism.out | 8 +-
src/test/regress/expected/rangefuncs.out | 34 +-
src/test/regress/expected/rules.out | 748 +++++++++---------
src/test/regress/expected/tablesample.out | 4 +-
src/test/regress/expected/triggers.out | 4 +-
src/test/regress/expected/updatable_views.out | 78 +-
src/test/regress/expected/window.out | 56 +-
src/test/regress/expected/with.out | 32 +-
src/test/regress/expected/xml_2.out | 6 +-
25 files changed, 757 insertions(+), 856 deletions(-)
diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out
index 2ab3f1efaa..e98e64cedc 100644
--- a/contrib/postgres_fdw/expected/postgres_fdw.out
+++ b/contrib/postgres_fdw/expected/postgres_fdw.out
@@ -2606,7 +2606,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1
Foreign Scan
Output: ft4.c1, ft5.c2, ft5.c1
Relations: (public.ft4) LEFT JOIN (public.ft5)
- Remote SQL: SELECT r6.c1, r9.c2, r9.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r9 ON (((r6.c1 = r9.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r9.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r5.c1, r7.c2, r7.c1 FROM ("S 1"."T 3" r5 LEFT JOIN "S 1"."T 4" r7 ON (((r5.c1 = r7.c1)))) ORDER BY r5.c1 ASC NULLS LAST, r7.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
@@ -2669,7 +2669,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c
Foreign Scan
Output: ft4.c1, t2.c2, t2.c1
Relations: (public.ft4) LEFT JOIN (public.ft5 t2)
- Remote SQL: SELECT r6.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r2 ON (((r6.c1 = r2.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r5.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r5 LEFT JOIN "S 1"."T 4" r2 ON (((r5.c1 = r2.c1)))) ORDER BY r5.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
@@ -6555,10 +6555,10 @@ CREATE VIEW rw_view AS SELECT * FROM foreign_tbl
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT foreign_tbl.a,
- foreign_tbl.b
+ SELECT a,
+ b
FROM foreign_tbl
- WHERE foreign_tbl.a < foreign_tbl.b;
+ WHERE a < b;
Options: check_option=cascaded
EXPLAIN (VERBOSE, COSTS OFF)
@@ -6672,10 +6672,10 @@ CREATE VIEW rw_view AS SELECT * FROM parent_tbl
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT parent_tbl.a,
- parent_tbl.b
+ SELECT a,
+ b
FROM parent_tbl
- WHERE parent_tbl.a < parent_tbl.b;
+ WHERE a < b;
Options: check_option=cascaded
EXPLAIN (VERBOSE, COSTS OFF)
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index b0747ce291..1d5f30443b 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -194,15 +194,6 @@ LockViewRecurse_walker(Node *node, LockViewRecurse_context *context)
char relkind = rte->relkind;
char *relname = get_rel_name(relid);
- /*
- * The OLD and NEW placeholder entries in the view's rtable are
- * skipped.
- */
- if (relid == context->viewoid &&
- (strcmp(rte->eref->aliasname, "old") == 0 ||
- strcmp(rte->eref->aliasname, "new") == 0))
- continue;
-
/* Currently, we only allow plain tables or views to be locked. */
if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE &&
relkind != RELKIND_VIEW)
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index 8e3c1efae4..7e3d5e79bc 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -353,107 +353,6 @@ DefineViewRules(Oid viewOid, Query *viewParse, bool replace)
*/
}
-/*---------------------------------------------------------------
- * UpdateRangeTableOfViewParse
- *
- * Update the range table of the given parsetree.
- * This update consists of adding two new entries IN THE BEGINNING
- * of the range table (otherwise the rule system will die a slow,
- * horrible and painful death, and we do not want that now, do we?)
- * one for the OLD relation and one for the NEW one (both of
- * them refer in fact to the "view" relation).
- *
- * Of course we must also increase the 'varnos' of all the Var nodes
- * by 2...
- *
- * These extra RT entries are not actually used in the query,
- * except for run-time locking.
- *---------------------------------------------------------------
- */
-static Query *
-UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
-{
- Relation viewRel;
- List *new_rt;
- ParseNamespaceItem *nsitem;
- RangeTblEntry *rt_entry1,
- *rt_entry2;
- RTEPermissionInfo *rte_perminfo1;
- ParseState *pstate;
- ListCell *lc;
-
- /*
- * Make a copy of the given parsetree. It's not so much that we don't
- * want to scribble on our input, it's that the parser has a bad habit of
- * outputting multiple links to the same subtree for constructs like
- * BETWEEN, and we mustn't have OffsetVarNodes increment the varno of a
- * Var node twice. copyObject will expand any multiply-referenced subtree
- * into multiple copies.
- */
- viewParse = copyObject(viewParse);
-
- /* Create a dummy ParseState for addRangeTableEntryForRelation */
- pstate = make_parsestate(NULL);
-
- /* need to open the rel for addRangeTableEntryForRelation */
- viewRel = relation_open(viewOid, AccessShareLock);
-
- /*
- * Create the 2 new range table entries and form the new range table...
- * OLD first, then NEW....
- */
- nsitem = addRangeTableEntryForRelation(pstate, viewRel,
- AccessShareLock,
- makeAlias("old", NIL),
- false, false);
- rt_entry1 = nsitem->p_rte;
- rte_perminfo1 = nsitem->p_perminfo;
- nsitem = addRangeTableEntryForRelation(pstate, viewRel,
- AccessShareLock,
- makeAlias("new", NIL),
- false, false);
- rt_entry2 = nsitem->p_rte;
-
- /*
- * Add only the "old" RTEPermissionInfo at the head of view query's list
- * and update the other RTEs' perminfoindex accordingly. When rewriting a
- * query on the view, ApplyRetrieveRule() will transfer the view
- * relation's permission details into this RTEPermissionInfo. That's
- * needed because the view's RTE itself will be transposed into a subquery
- * RTE that can't carry the permission details; see the code stanza toward
- * the end of ApplyRetrieveRule() for how that's done.
- */
- viewParse->rteperminfos = lcons(rte_perminfo1, viewParse->rteperminfos);
- foreach(lc, viewParse->rtable)
- {
- RangeTblEntry *rte = lfirst(lc);
-
- if (rte->perminfoindex > 0)
- rte->perminfoindex += 1;
- }
-
- /*
- * Also make the "new" RTE's RTEPermissionInfo undiscoverable. This is a
- * bit of a hack given that all the non-child RTE_RELATION entries really
- * should have a RTEPermissionInfo, but this dummy "new" RTE is going to
- * go away anyway in the very near future.
- */
- rt_entry2->perminfoindex = 0;
-
- new_rt = lcons(rt_entry1, lcons(rt_entry2, viewParse->rtable));
-
- viewParse->rtable = new_rt;
-
- /*
- * Now offset all var nodes by 2, and jointree RT indexes too.
- */
- OffsetVarNodes((Node *) viewParse, 2, 0);
-
- relation_close(viewRel, AccessShareLock);
-
- return viewParse;
-}
-
/*
* DefineView
* Execute a CREATE VIEW command.
@@ -616,12 +515,6 @@ DefineView(ViewStmt *stmt, const char *queryString,
void
StoreViewQuery(Oid viewOid, Query *viewParse, bool replace)
{
- /*
- * The range table of 'viewParse' does not contain entries for the "OLD"
- * and "NEW" relations. So... add them!
- */
- viewParse = UpdateRangeTableOfViewParse(viewOid, viewParse);
-
/*
* Now create the rules associated with the view.
*/
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index 9f3afe965a..3eaa62df4a 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -634,12 +634,10 @@ checkRuleResultList(List *targetList, TupleDesc resultDesc, bool isSelect,
* Recursively scan a query or expression tree and set the checkAsUser
* field to the given userid in all RTEPermissionInfos of the query.
*
- * Note: for a view (ON SELECT rule), the checkAsUser field of the OLD
- * RTE entry's RTEPermissionInfo will be overridden when the view rule is
- * expanded, and the checkAsUser for the NEW RTE entry's RTEPermissionInfo is
- * irrelevant because its requiredPerms bits will always be zero. However, for
- * other types of rules it's important to set these fields to match the rule
- * owner. So we just set them always.
+ * Note: for a view (ON SELECT rule), the checkAsUser field of the view RTE's
+ * RTEPermissionInfo will be overridden when the view rule is expanded; see
+ * ApplyRetrieveRule(). However, for other types of rules it's important to
+ * set these fields to match the rule owner. So we just set them always.
*/
void
setRuleCheckAsUser(Node *node, Oid userid)
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index 7cf0ceacc3..46d5d96d9d 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -1757,9 +1757,9 @@ ApplyRetrieveRule(Query *parsetree,
Query *rule_action;
RangeTblEntry *rte,
*subrte;
- RTEPermissionInfo *perminfo,
- *sub_perminfo;
+ RTEPermissionInfo *perminfo;
RowMarkClause *rc;
+ ListCell *lc;
if (list_length(rule->actions) != 1)
elog(ERROR, "expected just one rule action");
@@ -1868,10 +1868,46 @@ ApplyRetrieveRule(Query *parsetree,
/*
* Now, plug the view query in as a subselect, converting the relation's
* original RTE to a subquery RTE.
+ *
+ * Before doing that, move the view's permission check data down into the
+ * view query by adding both a copy of the view relation RTE and of the
+ * corresponding RTEPermissionInfo to the view query's lists. The RTE is
+ * not referenced anywhere in the query but still needed for 1) the
+ * executor to be able to lock the view relation, and 2) the planner to be
+ * able to record the view relation's OID in PlannedStmt.relationOids.
+ *
+ * Add the view relation's RTE and the perminfo such that they each appear
+ * before other RTEs and perminfos, respectively, to ensure that its
+ * permissions are checked before those of others.
*/
rte = rt_fetch(rt_index, parsetree->rtable);
perminfo = getRTEPermissionInfo(parsetree->rteperminfos, rte);
+ /*
+ * Must adjust varnos of the view query to account for the existing RTE's
+ * indexes increasing by 1 due to view relation RTE's addition.
+ */
+ OffsetVarNodes((Node *) rule_action, 1, 0);
+
+ /* Also their perminfoindexes. */
+ foreach(lc, rule_action->rtable)
+ {
+ RangeTblEntry *action_rte = lfirst(lc);
+
+ if (action_rte->perminfoindex > 0)
+ action_rte->perminfoindex += 1;
+ }
+ subrte = copyObject(rte);
+ rule_action->rtable = lcons(subrte, rule_action->rtable);
+ rule_action->rteperminfos = lcons(copyObject(perminfo),
+ rule_action->rteperminfos);
+ /*
+ * Finally, adjust the view relation's RTE in the view query to point to
+ * the just added perminfo.
+ */
+ subrte->perminfoindex = 1;
+
+ /* Free to convert the original RTE into a subselect. */
rte->rtekind = RTE_SUBQUERY;
rte->subquery = rule_action;
rte->security_barrier = RelationIsSecurityView(relation);
@@ -1880,23 +1916,9 @@ ApplyRetrieveRule(Query *parsetree,
rte->relkind = 0;
rte->rellockmode = 0;
rte->tablesample = NULL;
- rte->perminfoindex = 0; /* no permission checking for this RTE */
+ rte->perminfoindex = 0; /* should no longer point to any perminfo! */
rte->inh = false; /* must not be set for a subquery */
- /*
- * We move the view's permission check data down to its RTEPermissionInfo
- * contained in the view query, which the OLD entry in its range table
- * points to.
- */
- subrte = rt_fetch(PRS2_OLD_VARNO, rule_action->rtable);
- Assert(subrte->relid == relation->rd_id);
- sub_perminfo = getRTEPermissionInfo(rule_action->rteperminfos, subrte);
- sub_perminfo->requiredPerms = perminfo->requiredPerms;
- sub_perminfo->checkAsUser = perminfo->checkAsUser;
- sub_perminfo->selectedCols = perminfo->selectedCols;
- sub_perminfo->insertedCols = perminfo->insertedCols;
- sub_perminfo->updatedCols = perminfo->updatedCols;
-
return parsetree;
}
@@ -1907,9 +1929,6 @@ ApplyRetrieveRule(Query *parsetree,
* aggregate. We leave it to the planner to detect that.
*
* NB: this must agree with the parser's transformLockingClause() routine.
- * However, unlike the parser we have to be careful not to mark a view's
- * OLD and NEW rels for updating. The best way to handle that seems to be
- * to scan the jointree to determine which rels are used.
*/
static void
markQueryForLocking(Query *qry, Node *jtnode,
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 6656222363..518a885610 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -2280,7 +2280,7 @@ my %tests = (
SELECT col1 FROM dump_test.test_table;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview AS\E
- \n\s+\QSELECT test_table.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2296,7 +2296,7 @@ my %tests = (
SELECT * FROM dump_test.matview;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_second AS\E
- \n\s+\QSELECT matview.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2312,7 +2312,7 @@ my %tests = (
SELECT * FROM dump_test.matview_second WITH NO DATA;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_third AS\E
- \n\s+\QSELECT matview_second.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview_second\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2328,7 +2328,7 @@ my %tests = (
SELECT * FROM dump_test.matview_third WITH NO DATA;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_fourth AS\E
- \n\s+\QSELECT matview_third.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview_third\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2346,7 +2346,7 @@ my %tests = (
ALTER COLUMN col2 SET COMPRESSION lz4;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_compression AS\E
- \n\s+\QSELECT test_table.col2\E
+ \n\s+\QSELECT col2\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH NO DATA;\E
.*
@@ -3342,7 +3342,7 @@ my %tests = (
SELECT col1 FROM dump_test.test_table;',
regexp => qr/^
\QCREATE VIEW dump_test.test_view WITH (security_barrier='true') AS\E
- \n\s+\QSELECT test_table.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH LOCAL CHECK OPTION;\E/xm,
like =>
diff --git a/src/test/regress/expected/aggregates.out b/src/test/regress/expected/aggregates.out
index fc2bd40be2..564a7ba1aa 100644
--- a/src/test/regress/expected/aggregates.out
+++ b/src/test/regress/expected/aggregates.out
@@ -1623,7 +1623,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.b, v.c) AS aggfns +
+ SELECT aggfns(a, b, c) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -1675,7 +1675,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.b, v.c ORDER BY (v.b + 1)) AS aggfns +
+ SELECT aggfns(a, b, c ORDER BY (b + 1)) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -1691,7 +1691,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.a, v.c ORDER BY v.b) AS aggfns +
+ SELECT aggfns(a, a, c ORDER BY b) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -1707,7 +1707,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.b, v.c ORDER BY v.c USING ~<~ NULLS LAST) AS aggfns +
+ SELECT aggfns(a, b, c ORDER BY c USING ~<~ NULLS LAST) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -2192,15 +2192,15 @@ select ten,
from tenk1
group by ten order by ten;
select pg_get_viewdef('aggordview1');
- pg_get_viewdef
--------------------------------------------------------------------------------------------------------------------------------
- SELECT tenk1.ten, +
- percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY tenk1.thousand) AS p50, +
- percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY tenk1.thousand) FILTER (WHERE (tenk1.hundred = 1)) AS px,+
- rank(5, 'AZZZZ'::name, 50) WITHIN GROUP (ORDER BY tenk1.hundred, tenk1.string4 DESC, tenk1.hundred) AS rank +
- FROM tenk1 +
- GROUP BY tenk1.ten +
- ORDER BY tenk1.ten;
+ pg_get_viewdef
+-------------------------------------------------------------------------------------------------------------------
+ SELECT ten, +
+ percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY thousand) AS p50, +
+ percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY thousand) FILTER (WHERE (hundred = 1)) AS px,+
+ rank(5, 'AZZZZ'::name, 50) WITHIN GROUP (ORDER BY hundred, string4 DESC, hundred) AS rank +
+ FROM tenk1 +
+ GROUP BY ten +
+ ORDER BY ten;
(1 row)
select * from aggordview1 order by ten;
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 600e603bdf..9e5f6c1a80 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -2493,8 +2493,8 @@ create view at_view_2 as select *, to_json(v1) as j from at_view_1 v1;
id | integer | | | | plain |
stuff | text | | | | extended |
View definition:
- SELECT bt.id,
- bt.stuff
+ SELECT id,
+ stuff
FROM at_base_table bt;
\d+ at_view_2
@@ -2505,8 +2505,8 @@ View definition:
stuff | text | | | | extended |
j | json | | | | extended |
View definition:
- SELECT v1.id,
- v1.stuff,
+ SELECT id,
+ stuff,
to_json(v1.*) AS j
FROM at_view_1 v1;
@@ -2532,8 +2532,8 @@ create or replace view at_view_1 as select *, 2+2 as more from at_base_table bt;
stuff | text | | | | extended |
more | integer | | | | plain |
View definition:
- SELECT bt.id,
- bt.stuff,
+ SELECT id,
+ stuff,
2 + 2 AS more
FROM at_base_table bt;
@@ -2545,8 +2545,8 @@ View definition:
stuff | text | | | | extended |
j | json | | | | extended |
View definition:
- SELECT v1.id,
- v1.stuff,
+ SELECT id,
+ stuff,
to_json(v1.*) AS j
FROM at_view_1 v1;
diff --git a/src/test/regress/expected/collate.icu.utf8.out b/src/test/regress/expected/collate.icu.utf8.out
index d4c8c6de38..4354dc07b8 100644
--- a/src/test/regress/expected/collate.icu.utf8.out
+++ b/src/test/regress/expected/collate.icu.utf8.out
@@ -446,18 +446,18 @@ CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10;
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name | view_definition
-------------+--------------------------------------------------------------------------
- collview1 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | ORDER BY (collate_test1.b COLLATE "C");
- collview3 | SELECT collate_test10.a, +
- | lower(((collate_test10.x || collate_test10.x) COLLATE "C")) AS lower+
+ table_name | view_definition
+------------+--------------------------------------------
+ collview1 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | WHERE ((b COLLATE "C") >= 'bbc'::text);
+ collview2 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | ORDER BY (b COLLATE "C");
+ collview3 | SELECT a, +
+ | lower(((x || x) COLLATE "C")) AS lower+
| FROM collate_test10;
(3 rows)
diff --git a/src/test/regress/expected/collate.linux.utf8.out b/src/test/regress/expected/collate.linux.utf8.out
index f2d0eb94f2..2098696ec2 100644
--- a/src/test/regress/expected/collate.linux.utf8.out
+++ b/src/test/regress/expected/collate.linux.utf8.out
@@ -483,18 +483,18 @@ CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10;
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name | view_definition
-------------+--------------------------------------------------------------------------
- collview1 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | ORDER BY (collate_test1.b COLLATE "C");
- collview3 | SELECT collate_test10.a, +
- | lower(((collate_test10.x || collate_test10.x) COLLATE "C")) AS lower+
+ table_name | view_definition
+------------+--------------------------------------------
+ collview1 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | WHERE ((b COLLATE "C") >= 'bbc'::text);
+ collview2 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | ORDER BY (b COLLATE "C");
+ collview3 | SELECT a, +
+ | lower(((x || x) COLLATE "C")) AS lower+
| FROM collate_test10;
(3 rows)
diff --git a/src/test/regress/expected/collate.out b/src/test/regress/expected/collate.out
index 246832575c..0649564485 100644
--- a/src/test/regress/expected/collate.out
+++ b/src/test/regress/expected/collate.out
@@ -194,18 +194,18 @@ CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "POSIX") FROM collate_test10;
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name | view_definition
-------------+------------------------------------------------------------------------------
- collview1 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | ORDER BY (collate_test1.b COLLATE "C");
- collview3 | SELECT collate_test10.a, +
- | lower(((collate_test10.x || collate_test10.x) COLLATE "POSIX")) AS lower+
+ table_name | view_definition
+------------+------------------------------------------------
+ collview1 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | WHERE ((b COLLATE "C") >= 'bbc'::text);
+ collview2 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | ORDER BY (b COLLATE "C");
+ collview3 | SELECT a, +
+ | lower(((x || x) COLLATE "POSIX")) AS lower+
| FROM collate_test10;
(3 rows)
@@ -698,7 +698,7 @@ SELECT c1+1 AS c1p FROM
--------+---------+-----------+----------+---------+---------+-------------
c1p | integer | | | | plain |
View definition:
- SELECT ss.c1 + 1 AS c1p
+ SELECT c1 + 1 AS c1p
FROM ( SELECT 4 AS c1) ss;
-- Check conflicting or redundant options in CREATE COLLATION
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out
index 17ca29ddbf..61825ef7d4 100644
--- a/src/test/regress/expected/create_view.out
+++ b/src/test/regress/expected/create_view.out
@@ -395,10 +395,10 @@ CREATE VIEW tt1 AS
c | numeric | | | | main |
d | character varying(4) | | | | extended |
View definition:
- SELECT vv.a,
- vv.b,
- vv.c,
- vv.d
+ SELECT a,
+ b,
+ c,
+ d
FROM ( VALUES ('abc'::character varying(3),'0123456789'::character varying,42,'abcd'::character varying(4)), ('0123456789'::character varying,'abc'::character varying(3),42.12,'abc'::character varying(4))) vv(a, b, c, d);
SELECT * FROM tt1;
@@ -440,9 +440,9 @@ CREATE VIEW aliased_view_4 AS
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM tx1
@@ -456,9 +456,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1 a1
WHERE (EXISTS ( SELECT 1
FROM tx1
@@ -472,9 +472,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM tx1 a2
@@ -488,9 +488,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM tt1 tt1_1
@@ -505,9 +505,9 @@ ALTER TABLE tx1 RENAME TO a1;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM a1
@@ -521,9 +521,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1 a1
WHERE (EXISTS ( SELECT 1
FROM a1 a1_1
@@ -537,9 +537,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM a1 a2
@@ -553,9 +553,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM tt1 tt1_1
@@ -570,9 +570,9 @@ ALTER TABLE tt1 RENAME TO a2;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM a1
@@ -586,9 +586,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2 a1
WHERE (EXISTS ( SELECT 1
FROM a1 a1_1
@@ -602,9 +602,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM a1 a2_1
@@ -618,9 +618,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM a2
@@ -635,9 +635,9 @@ ALTER TABLE a1 RENAME TO tt1;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -651,9 +651,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2 a1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -667,9 +667,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM tt1 a2_1
@@ -683,9 +683,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM a2
@@ -701,9 +701,9 @@ ALTER TABLE tx1 SET SCHEMA temp_view_test;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -717,9 +717,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1 a1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -733,9 +733,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1 a2
@@ -749,9 +749,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM temp_view_test.tx1
@@ -768,9 +768,9 @@ ALTER TABLE tmp1 RENAME TO tx1;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -784,9 +784,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1 a1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -800,9 +800,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1 a2
@@ -816,9 +816,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.y1,
- tx1.f2,
- tx1.f3
+ SELECT y1,
+ f2,
+ f3
FROM tx1
WHERE (EXISTS ( SELECT 1
FROM temp_view_test.tx1 tx1_1
@@ -1305,10 +1305,10 @@ select pg_get_viewdef('v1', true);
select pg_get_viewdef('v4', true);
pg_get_viewdef
----------------
- SELECT v1.b, +
- v1.c, +
- v1.x AS a,+
- v1.ax +
+ SELECT b, +
+ c, +
+ x AS a, +
+ ax +
FROM v1;
(1 row)
@@ -1585,9 +1585,9 @@ create view tt14v as select t.* from tt14f() t;
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
--------------------------------
- SELECT t.f1, +
- t.f3, +
- t.f4 +
+ SELECT f1, +
+ f3, +
+ f4 +
FROM tt14f() t(f1, f3, f4);
(1 row)
@@ -1623,11 +1623,11 @@ returning pg_describe_object(classid, objid, objsubid) as obj,
alter table tt14t drop column f3;
-- column f3 is still in the view, sort of ...
select pg_get_viewdef('tt14v', true);
- pg_get_viewdef
----------------------------------
- SELECT t.f1, +
- t."?dropped?column?" AS f3,+
- t.f4 +
+ pg_get_viewdef
+-------------------------------
+ SELECT f1, +
+ "?dropped?column?" AS f3,+
+ f4 +
FROM tt14f() t(f1, f4);
(1 row)
@@ -1675,9 +1675,9 @@ alter table tt14t alter column f4 type integer using f4::integer;
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
--------------------------------
- SELECT t.f1, +
- t.f3, +
- t.f4 +
+ SELECT f1, +
+ f3, +
+ f4 +
FROM tt14f() t(f1, f3, f4);
(1 row)
@@ -1697,8 +1697,8 @@ create view tt14v as select t.f1, t.f4 from tt14f() t;
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
--------------------------------
- SELECT t.f1, +
- t.f4 +
+ SELECT f1, +
+ f4 +
FROM tt14f() t(f1, f3, f4);
(1 row)
@@ -1712,8 +1712,8 @@ alter table tt14t drop column f3; -- ok
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
----------------------------
- SELECT t.f1, +
- t.f4 +
+ SELECT f1, +
+ f4 +
FROM tt14f() t(f1, f4);
(1 row)
@@ -1806,8 +1806,8 @@ select * from tt17v;
select pg_get_viewdef('tt17v', true);
pg_get_viewdef
---------------------------------------------
- SELECT i.q1, +
- i.q2 +
+ SELECT q1, +
+ q2 +
FROM int8_tbl i +
WHERE (i.* IN ( VALUES (i.*::int8_tbl)));
(1 row)
@@ -2134,7 +2134,7 @@ select pg_get_viewdef('tt25v', true);
WITH cte AS MATERIALIZED ( +
SELECT pg_get_keywords() AS k+
) +
- SELECT (cte.k).word AS word +
+ SELECT (k).word AS word +
FROM cte;
(1 row)
@@ -2186,19 +2186,19 @@ select x + y + z as c1,
(x,y) <= ANY (values(1,2),(3,4)) as c11
from (values(1,2,3)) v(x,y,z);
select pg_get_viewdef('tt26v', true);
- pg_get_viewdef
---------------------------------------------------------
- SELECT v.x + v.y + v.z AS c1, +
- v.x * v.y + v.z AS c2, +
- v.x + v.y * v.z AS c3, +
- (v.x + v.y) * v.z AS c4, +
- v.x * (v.y + v.z) AS c5, +
- v.x + (v.y + v.z) AS c6, +
- v.x + (v.y # v.z) AS c7, +
- v.x > v.y AND (v.y > v.z OR v.x > v.z) AS c8, +
- v.x > v.y OR v.y > v.z AND NOT v.x > v.z AS c9, +
- ((v.x, v.y) <> ALL ( VALUES (1,2), (3,4))) AS c10,+
- ((v.x, v.y) <= ANY ( VALUES (1,2), (3,4))) AS c11 +
+ pg_get_viewdef
+----------------------------------------------------
+ SELECT x + y + z AS c1, +
+ x * y + z AS c2, +
+ x + y * z AS c3, +
+ (x + y) * z AS c4, +
+ x * (y + z) AS c5, +
+ x + (y + z) AS c6, +
+ x + (y # z) AS c7, +
+ x > y AND (y > z OR x > z) AS c8, +
+ x > y OR y > z AND NOT x > z AS c9, +
+ ((x, y) <> ALL ( VALUES (1,2), (3,4))) AS c10,+
+ ((x, y) <= ANY ( VALUES (1,2), (3,4))) AS c11 +
FROM ( VALUES (1,2,3)) v(x, y, z);
(1 row)
diff --git a/src/test/regress/expected/expressions.out b/src/test/regress/expected/expressions.out
index 28a20900f1..7c599fd27b 100644
--- a/src/test/regress/expected/expressions.out
+++ b/src/test/regress/expected/expressions.out
@@ -108,12 +108,12 @@ create view numeric_view as
f2164 | numeric(16,4) | | | | main |
f2n | numeric | | | | main |
View definition:
- SELECT numeric_tbl.f1,
- numeric_tbl.f1::numeric(16,4) AS f1164,
- numeric_tbl.f1::numeric AS f1n,
- numeric_tbl.f2,
- numeric_tbl.f2::numeric(16,4) AS f2164,
- numeric_tbl.f2 AS f2n
+ SELECT f1,
+ f1::numeric(16,4) AS f1164,
+ f1::numeric AS f1n,
+ f2,
+ f2::numeric(16,4) AS f2164,
+ f2 AS f2n
FROM numeric_tbl;
explain (verbose, costs off) select * from numeric_view;
@@ -142,12 +142,12 @@ create view bpchar_view as
f214 | character(14) | | | | extended |
f2n | bpchar | | | | extended |
View definition:
- SELECT bpchar_tbl.f1,
- bpchar_tbl.f1::character(14) AS f114,
- bpchar_tbl.f1::bpchar AS f1n,
- bpchar_tbl.f2,
- bpchar_tbl.f2::character(14) AS f214,
- bpchar_tbl.f2 AS f2n
+ SELECT f1,
+ f1::character(14) AS f114,
+ f1::bpchar AS f1n,
+ f2,
+ f2::character(14) AS f214,
+ f2 AS f2n
FROM bpchar_tbl;
explain (verbose, costs off) select * from bpchar_view
diff --git a/src/test/regress/expected/groupingsets.out b/src/test/regress/expected/groupingsets.out
index fcad5c4093..8e75bfe92a 100644
--- a/src/test/regress/expected/groupingsets.out
+++ b/src/test/regress/expected/groupingsets.out
@@ -570,16 +570,16 @@ CREATE VIEW gstest_view AS select a, b, grouping(a,b), sum(c), count(*), max(c)
from gstest2 group by rollup ((a,b,c),(c,d));
NOTICE: view "gstest_view" will be a temporary view
select pg_get_viewdef('gstest_view'::regclass, true);
- pg_get_viewdef
--------------------------------------------------------------------------------
- SELECT gstest2.a, +
- gstest2.b, +
- GROUPING(gstest2.a, gstest2.b) AS "grouping", +
- sum(gstest2.c) AS sum, +
- count(*) AS count, +
- max(gstest2.c) AS max +
- FROM gstest2 +
- GROUP BY ROLLUP((gstest2.a, gstest2.b, gstest2.c), (gstest2.c, gstest2.d));
+ pg_get_viewdef
+---------------------------------------
+ SELECT a, +
+ b, +
+ GROUPING(a, b) AS "grouping", +
+ sum(c) AS sum, +
+ count(*) AS count, +
+ max(c) AS max +
+ FROM gstest2 +
+ GROUP BY ROLLUP((a, b, c), (c, d));
(1 row)
-- Nested queries with 3 or more levels of nesting
diff --git a/src/test/regress/expected/limit.out b/src/test/regress/expected/limit.out
index 8a98bbea8e..a2cd0f9f5b 100644
--- a/src/test/regress/expected/limit.out
+++ b/src/test/regress/expected/limit.out
@@ -638,10 +638,10 @@ CREATE VIEW limit_thousand_v_1 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
OFFSET 10
FETCH FIRST 5 ROWS WITH TIES;
@@ -653,10 +653,10 @@ CREATE VIEW limit_thousand_v_2 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
OFFSET 10
LIMIT 5;
@@ -671,10 +671,10 @@ CREATE VIEW limit_thousand_v_3 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
FETCH FIRST (NULL::integer + 1) ROWS WITH TIES;
CREATE VIEW limit_thousand_v_4 AS SELECT thousand FROM onek WHERE thousand < 995
@@ -685,10 +685,10 @@ CREATE VIEW limit_thousand_v_4 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
LIMIT ALL;
-- leave these views
diff --git a/src/test/regress/expected/matview.out b/src/test/regress/expected/matview.out
index c109d97635..87b6e569a5 100644
--- a/src/test/regress/expected/matview.out
+++ b/src/test/regress/expected/matview.out
@@ -100,10 +100,10 @@ CREATE INDEX mvtest_aa ON mvtest_bb (grandtot);
type | text | | | | extended | |
totamt | numeric | | | | main | |
View definition:
- SELECT mvtest_tv.type,
- mvtest_tv.totamt
+ SELECT type,
+ totamt
FROM mvtest_tv
- ORDER BY mvtest_tv.type;
+ ORDER BY type;
\d+ mvtest_tvm
Materialized view "public.mvtest_tvm"
@@ -112,10 +112,10 @@ View definition:
type | text | | | | extended | |
totamt | numeric | | | | main | |
View definition:
- SELECT mvtest_tv.type,
- mvtest_tv.totamt
+ SELECT type,
+ totamt
FROM mvtest_tv
- ORDER BY mvtest_tv.type;
+ ORDER BY type;
\d+ mvtest_tvvm
Materialized view "public.mvtest_tvvm"
@@ -123,7 +123,7 @@ View definition:
----------+---------+-----------+----------+---------+---------+--------------+-------------
grandtot | numeric | | | | main | |
View definition:
- SELECT mvtest_tvv.grandtot
+ SELECT grandtot
FROM mvtest_tvv;
\d+ mvtest_bb
@@ -134,7 +134,7 @@ View definition:
Indexes:
"mvtest_aa" btree (grandtot)
View definition:
- SELECT mvtest_tvvmv.grandtot
+ SELECT grandtot
FROM mvtest_tvvmv;
-- test schema behavior
@@ -150,7 +150,7 @@ Indexes:
"mvtest_tvmm_expr" UNIQUE, btree ((grandtot > 0::numeric))
"mvtest_tvmm_pred" UNIQUE, btree (grandtot) WHERE grandtot < 0::numeric
View definition:
- SELECT sum(mvtest_tvm.totamt) AS grandtot
+ SELECT sum(totamt) AS grandtot
FROM mvtest_mvschema.mvtest_tvm;
SET search_path = mvtest_mvschema, public;
@@ -161,10 +161,10 @@ SET search_path = mvtest_mvschema, public;
type | text | | | | extended | |
totamt | numeric | | | | main | |
View definition:
- SELECT mvtest_tv.type,
- mvtest_tv.totamt
+ SELECT type,
+ totamt
FROM mvtest_tv
- ORDER BY mvtest_tv.type;
+ ORDER BY type;
-- modify the underlying table data
INSERT INTO mvtest_t VALUES (6, 'z', 13);
diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out
index 1cd558d668..bf08e40ed8 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -1801,10 +1801,10 @@ select * from dfview;
c3 | bigint | | | | plain |
c4 | bigint | | | | plain |
View definition:
- SELECT int8_tbl.q1,
- int8_tbl.q2,
- dfunc(int8_tbl.q1, int8_tbl.q2, flag => int8_tbl.q1 > int8_tbl.q2) AS c3,
- dfunc(int8_tbl.q1, flag => int8_tbl.q1 < int8_tbl.q2, b => int8_tbl.q2) AS c4
+ SELECT q1,
+ q2,
+ dfunc(q1, q2, flag => q1 > q2) AS c3,
+ dfunc(q1, flag => q1 < q2, b => q2) AS c4
FROM int8_tbl;
drop view dfview;
diff --git a/src/test/regress/expected/rangefuncs.out b/src/test/regress/expected/rangefuncs.out
index e2e62db6a2..fbb840e848 100644
--- a/src/test/regress/expected/rangefuncs.out
+++ b/src/test/regress/expected/rangefuncs.out
@@ -149,9 +149,9 @@ select * from vw_ord;
select definition from pg_views where viewname='vw_ord';
definition
----------------------------------------------------------------------------------------
- SELECT z.a, +
- z.b, +
- z.c +
+ SELECT a, +
+ b, +
+ c +
FROM UNNEST(ARRAY[10, 20], ARRAY['foo'::text, 'bar'::text], ARRAY[1.0]) z(a, b, c);
(1 row)
@@ -167,9 +167,9 @@ select * from vw_ord;
select definition from pg_views where viewname='vw_ord';
definition
----------------------------------------------------------------------------------------
- SELECT z.a, +
- z.b, +
- z.c +
+ SELECT a, +
+ b, +
+ c +
FROM UNNEST(ARRAY[10, 20], ARRAY['foo'::text, 'bar'::text], ARRAY[1.0]) z(a, b, c);
(1 row)
@@ -185,9 +185,9 @@ select * from vw_ord;
select definition from pg_views where viewname='vw_ord';
definition
----------------------------------------------------------------------------------------------------------------------
- SELECT z.a, +
- z.b, +
- z.c +
+ SELECT a, +
+ b, +
+ c +
FROM ROWS FROM(unnest(ARRAY[10, 20]), unnest(ARRAY['foo'::text, 'bar'::text]), generate_series(1, 2)) z(a, b, c);
(1 row)
@@ -669,14 +669,14 @@ select * from vw_rngfunc;
select pg_get_viewdef('vw_rngfunc');
pg_get_viewdef
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- SELECT t1.a, +
- t1.b, +
- t1.c, +
- t1.d, +
- t1.e, +
- t1.f, +
- t1.g, +
- t1.n +
+ SELECT a, +
+ b, +
+ c, +
+ d, +
+ e, +
+ f, +
+ g, +
+ n +
FROM ROWS FROM(getrngfunc9(1), getrngfunc7(1) AS (rngfuncid integer, rngfuncsubid integer, rngfuncname text), getrngfunc1(1)) WITH ORDINALITY t1(a, b, c, d, e, f, g, n);
(1 row)
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index fb9f936d43..6a21ce90ac 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -1303,60 +1303,60 @@ pg_available_extensions| SELECT e.name,
e.comment
FROM (pg_available_extensions() e(name, default_version, comment)
LEFT JOIN pg_extension x ON ((e.name = x.extname)));
-pg_backend_memory_contexts| SELECT pg_get_backend_memory_contexts.name,
- pg_get_backend_memory_contexts.ident,
- pg_get_backend_memory_contexts.parent,
- pg_get_backend_memory_contexts.level,
- pg_get_backend_memory_contexts.total_bytes,
- pg_get_backend_memory_contexts.total_nblocks,
- pg_get_backend_memory_contexts.free_bytes,
- pg_get_backend_memory_contexts.free_chunks,
- pg_get_backend_memory_contexts.used_bytes
+pg_backend_memory_contexts| SELECT name,
+ ident,
+ parent,
+ level,
+ total_bytes,
+ total_nblocks,
+ free_bytes,
+ free_chunks,
+ used_bytes
FROM pg_get_backend_memory_contexts() pg_get_backend_memory_contexts(name, ident, parent, level, total_bytes, total_nblocks, free_bytes, free_chunks, used_bytes);
-pg_config| SELECT pg_config.name,
- pg_config.setting
+pg_config| SELECT name,
+ setting
FROM pg_config() pg_config(name, setting);
-pg_cursors| SELECT c.name,
- c.statement,
- c.is_holdable,
- c.is_binary,
- c.is_scrollable,
- c.creation_time
+pg_cursors| SELECT name,
+ statement,
+ is_holdable,
+ is_binary,
+ is_scrollable,
+ creation_time
FROM pg_cursor() c(name, statement, is_holdable, is_binary, is_scrollable, creation_time);
-pg_file_settings| SELECT a.sourcefile,
- a.sourceline,
- a.seqno,
- a.name,
- a.setting,
- a.applied,
- a.error
+pg_file_settings| SELECT sourcefile,
+ sourceline,
+ seqno,
+ name,
+ setting,
+ applied,
+ error
FROM pg_show_all_file_settings() a(sourcefile, sourceline, seqno, name, setting, applied, error);
-pg_group| SELECT pg_authid.rolname AS groname,
- pg_authid.oid AS grosysid,
+pg_group| SELECT rolname AS groname,
+ oid AS grosysid,
ARRAY( SELECT pg_auth_members.member
FROM pg_auth_members
WHERE (pg_auth_members.roleid = pg_authid.oid)) AS grolist
FROM pg_authid
- WHERE (NOT pg_authid.rolcanlogin);
-pg_hba_file_rules| SELECT a.rule_number,
- a.file_name,
- a.line_number,
- a.type,
- a.database,
- a.user_name,
- a.address,
- a.netmask,
- a.auth_method,
- a.options,
- a.error
+ WHERE (NOT rolcanlogin);
+pg_hba_file_rules| SELECT rule_number,
+ file_name,
+ line_number,
+ type,
+ database,
+ user_name,
+ address,
+ netmask,
+ auth_method,
+ options,
+ error
FROM pg_hba_file_rules() a(rule_number, file_name, line_number, type, database, user_name, address, netmask, auth_method, options, error);
-pg_ident_file_mappings| SELECT a.map_number,
- a.file_name,
- a.line_number,
- a.map_name,
- a.sys_name,
- a.pg_username,
- a.error
+pg_ident_file_mappings| SELECT map_number,
+ file_name,
+ line_number,
+ map_name,
+ sys_name,
+ pg_username,
+ error
FROM pg_ident_file_mappings() a(map_number, file_name, line_number, map_name, sys_name, pg_username, error);
pg_indexes| SELECT n.nspname AS schemaname,
c.relname AS tablename,
@@ -1369,22 +1369,22 @@ pg_indexes| SELECT n.nspname AS schemaname,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
LEFT JOIN pg_tablespace t ON ((t.oid = i.reltablespace)))
WHERE ((c.relkind = ANY (ARRAY['r'::"char", 'm'::"char", 'p'::"char"])) AND (i.relkind = ANY (ARRAY['i'::"char", 'I'::"char"])));
-pg_locks| SELECT l.locktype,
- l.database,
- l.relation,
- l.page,
- l.tuple,
- l.virtualxid,
- l.transactionid,
- l.classid,
- l.objid,
- l.objsubid,
- l.virtualtransaction,
- l.pid,
- l.mode,
- l.granted,
- l.fastpath,
- l.waitstart
+pg_locks| SELECT locktype,
+ database,
+ relation,
+ page,
+ tuple,
+ virtualxid,
+ transactionid,
+ classid,
+ objid,
+ objsubid,
+ virtualtransaction,
+ pid,
+ mode,
+ granted,
+ fastpath,
+ waitstart
FROM pg_lock_status() l(locktype, database, relation, page, tuple, virtualxid, transactionid, classid, objid, objsubid, virtualtransaction, pid, mode, granted, fastpath, waitstart);
pg_matviews| SELECT n.nspname AS schemaname,
c.relname AS matviewname,
@@ -1424,14 +1424,14 @@ pg_policies| SELECT n.nspname AS schemaname,
FROM ((pg_policy pol
JOIN pg_class c ON ((c.oid = pol.polrelid)))
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)));
-pg_prepared_statements| SELECT p.name,
- p.statement,
- p.prepare_time,
- p.parameter_types,
- p.result_types,
- p.from_sql,
- p.generic_plans,
- p.custom_plans
+pg_prepared_statements| SELECT name,
+ statement,
+ prepare_time,
+ parameter_types,
+ result_types,
+ from_sql,
+ generic_plans,
+ custom_plans
FROM pg_prepared_statement() p(name, statement, prepare_time, parameter_types, result_types, from_sql, generic_plans, custom_plans);
pg_prepared_xacts| SELECT p.transaction,
p.gid,
@@ -1453,10 +1453,10 @@ pg_publication_tables| SELECT p.pubname,
(pg_class c
JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.oid = gpt.relid);
-pg_replication_origin_status| SELECT pg_show_replication_origin_status.local_id,
- pg_show_replication_origin_status.external_id,
- pg_show_replication_origin_status.remote_lsn,
- pg_show_replication_origin_status.local_lsn
+pg_replication_origin_status| SELECT local_id,
+ external_id,
+ remote_lsn,
+ local_lsn
FROM pg_show_replication_origin_status() pg_show_replication_origin_status(local_id, external_id, remote_lsn, local_lsn);
pg_replication_slots| SELECT l.slot_name,
l.plugin,
@@ -1702,23 +1702,23 @@ pg_sequences| SELECT n.nspname AS schemaname,
JOIN pg_class c ON ((c.oid = s.seqrelid)))
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE ((NOT pg_is_other_temp_schema(n.oid)) AND (c.relkind = 'S'::"char"));
-pg_settings| SELECT a.name,
- a.setting,
- a.unit,
- a.category,
- a.short_desc,
- a.extra_desc,
- a.context,
- a.vartype,
- a.source,
- a.min_val,
- a.max_val,
- a.enumvals,
- a.boot_val,
- a.reset_val,
- a.sourcefile,
- a.sourceline,
- a.pending_restart
+pg_settings| SELECT name,
+ setting,
+ unit,
+ category,
+ short_desc,
+ extra_desc,
+ context,
+ vartype,
+ source,
+ min_val,
+ max_val,
+ enumvals,
+ boot_val,
+ reset_val,
+ sourcefile,
+ sourceline,
+ pending_restart
FROM pg_show_all_settings() a(name, setting, unit, category, short_desc, extra_desc, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, sourcefile, sourceline, pending_restart);
pg_shadow| SELECT pg_authid.rolname AS usename,
pg_authid.oid AS usesysid,
@@ -1732,10 +1732,10 @@ pg_shadow| SELECT pg_authid.rolname AS usename,
FROM (pg_authid
LEFT JOIN pg_db_role_setting s ON (((pg_authid.oid = s.setrole) AND (s.setdatabase = (0)::oid))))
WHERE pg_authid.rolcanlogin;
-pg_shmem_allocations| SELECT pg_get_shmem_allocations.name,
- pg_get_shmem_allocations.off,
- pg_get_shmem_allocations.size,
- pg_get_shmem_allocations.allocated_size
+pg_shmem_allocations| SELECT name,
+ off,
+ size,
+ allocated_size
FROM pg_get_shmem_allocations() pg_get_shmem_allocations(name, off, size, allocated_size);
pg_stat_activity| SELECT s.datid,
d.datname,
@@ -1806,13 +1806,13 @@ pg_stat_all_tables| SELECT c.oid AS relid,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char", 'p'::"char"]))
GROUP BY c.oid, n.nspname, c.relname;
-pg_stat_archiver| SELECT s.archived_count,
- s.last_archived_wal,
- s.last_archived_time,
- s.failed_count,
- s.last_failed_wal,
- s.last_failed_time,
- s.stats_reset
+pg_stat_archiver| SELECT archived_count,
+ last_archived_wal,
+ last_archived_time,
+ failed_count,
+ last_failed_wal,
+ last_failed_time,
+ stats_reset
FROM pg_stat_get_archiver() s(archived_count, last_archived_wal, last_archived_time, failed_count, last_failed_wal, last_failed_time, stats_reset);
pg_stat_bgwriter| SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints_timed,
pg_stat_get_bgwriter_requested_checkpoints() AS checkpoints_req,
@@ -1825,57 +1825,57 @@ pg_stat_bgwriter| SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints
pg_stat_get_buf_fsync_backend() AS buffers_backend_fsync,
pg_stat_get_buf_alloc() AS buffers_alloc,
pg_stat_get_bgwriter_stat_reset_time() AS stats_reset;
-pg_stat_database| SELECT d.oid AS datid,
- d.datname,
+pg_stat_database| SELECT oid AS datid,
+ datname,
CASE
- WHEN (d.oid = (0)::oid) THEN 0
- ELSE pg_stat_get_db_numbackends(d.oid)
+ WHEN (oid = (0)::oid) THEN 0
+ ELSE pg_stat_get_db_numbackends(oid)
END AS numbackends,
- pg_stat_get_db_xact_commit(d.oid) AS xact_commit,
- pg_stat_get_db_xact_rollback(d.oid) AS xact_rollback,
- (pg_stat_get_db_blocks_fetched(d.oid) - pg_stat_get_db_blocks_hit(d.oid)) AS blks_read,
- pg_stat_get_db_blocks_hit(d.oid) AS blks_hit,
- pg_stat_get_db_tuples_returned(d.oid) AS tup_returned,
- pg_stat_get_db_tuples_fetched(d.oid) AS tup_fetched,
- pg_stat_get_db_tuples_inserted(d.oid) AS tup_inserted,
- pg_stat_get_db_tuples_updated(d.oid) AS tup_updated,
- pg_stat_get_db_tuples_deleted(d.oid) AS tup_deleted,
- pg_stat_get_db_conflict_all(d.oid) AS conflicts,
- pg_stat_get_db_temp_files(d.oid) AS temp_files,
- pg_stat_get_db_temp_bytes(d.oid) AS temp_bytes,
- pg_stat_get_db_deadlocks(d.oid) AS deadlocks,
- pg_stat_get_db_checksum_failures(d.oid) AS checksum_failures,
- pg_stat_get_db_checksum_last_failure(d.oid) AS checksum_last_failure,
- pg_stat_get_db_blk_read_time(d.oid) AS blk_read_time,
- pg_stat_get_db_blk_write_time(d.oid) AS blk_write_time,
- pg_stat_get_db_session_time(d.oid) AS session_time,
- pg_stat_get_db_active_time(d.oid) AS active_time,
- pg_stat_get_db_idle_in_transaction_time(d.oid) AS idle_in_transaction_time,
- pg_stat_get_db_sessions(d.oid) AS sessions,
- pg_stat_get_db_sessions_abandoned(d.oid) AS sessions_abandoned,
- pg_stat_get_db_sessions_fatal(d.oid) AS sessions_fatal,
- pg_stat_get_db_sessions_killed(d.oid) AS sessions_killed,
- pg_stat_get_db_stat_reset_time(d.oid) AS stats_reset
+ pg_stat_get_db_xact_commit(oid) AS xact_commit,
+ pg_stat_get_db_xact_rollback(oid) AS xact_rollback,
+ (pg_stat_get_db_blocks_fetched(oid) - pg_stat_get_db_blocks_hit(oid)) AS blks_read,
+ pg_stat_get_db_blocks_hit(oid) AS blks_hit,
+ pg_stat_get_db_tuples_returned(oid) AS tup_returned,
+ pg_stat_get_db_tuples_fetched(oid) AS tup_fetched,
+ pg_stat_get_db_tuples_inserted(oid) AS tup_inserted,
+ pg_stat_get_db_tuples_updated(oid) AS tup_updated,
+ pg_stat_get_db_tuples_deleted(oid) AS tup_deleted,
+ pg_stat_get_db_conflict_all(oid) AS conflicts,
+ pg_stat_get_db_temp_files(oid) AS temp_files,
+ pg_stat_get_db_temp_bytes(oid) AS temp_bytes,
+ pg_stat_get_db_deadlocks(oid) AS deadlocks,
+ pg_stat_get_db_checksum_failures(oid) AS checksum_failures,
+ pg_stat_get_db_checksum_last_failure(oid) AS checksum_last_failure,
+ pg_stat_get_db_blk_read_time(oid) AS blk_read_time,
+ pg_stat_get_db_blk_write_time(oid) AS blk_write_time,
+ pg_stat_get_db_session_time(oid) AS session_time,
+ pg_stat_get_db_active_time(oid) AS active_time,
+ pg_stat_get_db_idle_in_transaction_time(oid) AS idle_in_transaction_time,
+ pg_stat_get_db_sessions(oid) AS sessions,
+ pg_stat_get_db_sessions_abandoned(oid) AS sessions_abandoned,
+ pg_stat_get_db_sessions_fatal(oid) AS sessions_fatal,
+ pg_stat_get_db_sessions_killed(oid) AS sessions_killed,
+ pg_stat_get_db_stat_reset_time(oid) AS stats_reset
FROM ( SELECT 0 AS oid,
NULL::name AS datname
UNION ALL
SELECT pg_database.oid,
pg_database.datname
FROM pg_database) d;
-pg_stat_database_conflicts| SELECT d.oid AS datid,
- d.datname,
- pg_stat_get_db_conflict_tablespace(d.oid) AS confl_tablespace,
- pg_stat_get_db_conflict_lock(d.oid) AS confl_lock,
- pg_stat_get_db_conflict_snapshot(d.oid) AS confl_snapshot,
- pg_stat_get_db_conflict_bufferpin(d.oid) AS confl_bufferpin,
- pg_stat_get_db_conflict_startup_deadlock(d.oid) AS confl_deadlock
+pg_stat_database_conflicts| SELECT oid AS datid,
+ datname,
+ pg_stat_get_db_conflict_tablespace(oid) AS confl_tablespace,
+ pg_stat_get_db_conflict_lock(oid) AS confl_lock,
+ pg_stat_get_db_conflict_snapshot(oid) AS confl_snapshot,
+ pg_stat_get_db_conflict_bufferpin(oid) AS confl_bufferpin,
+ pg_stat_get_db_conflict_startup_deadlock(oid) AS confl_deadlock
FROM pg_database d;
-pg_stat_gssapi| SELECT s.pid,
- s.gss_auth AS gss_authenticated,
- s.gss_princ AS principal,
- s.gss_enc AS encrypted
+pg_stat_gssapi| SELECT pid,
+ gss_auth AS gss_authenticated,
+ gss_princ AS principal,
+ gss_enc AS encrypted
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid, query_id)
- WHERE (s.client_port IS NOT NULL);
+ WHERE (client_port IS NOT NULL);
pg_stat_progress_analyze| SELECT s.pid,
s.datid,
d.datname,
@@ -1898,8 +1898,8 @@ pg_stat_progress_analyze| SELECT s.pid,
(s.param8)::oid AS current_child_table_relid
FROM (pg_stat_get_progress_info('ANALYZE'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
LEFT JOIN pg_database d ON ((s.datid = d.oid)));
-pg_stat_progress_basebackup| SELECT s.pid,
- CASE s.param1
+pg_stat_progress_basebackup| SELECT pid,
+ CASE param1
WHEN 0 THEN 'initializing'::text
WHEN 1 THEN 'waiting for checkpoint to finish'::text
WHEN 2 THEN 'estimating backup size'::text
@@ -1908,13 +1908,13 @@ pg_stat_progress_basebackup| SELECT s.pid,
WHEN 5 THEN 'transferring wal files'::text
ELSE NULL::text
END AS phase,
- CASE s.param2
+ CASE param2
WHEN '-1'::integer THEN NULL::bigint
- ELSE s.param2
+ ELSE param2
END AS backup_total,
- s.param3 AS backup_streamed,
- s.param4 AS tablespaces_total,
- s.param5 AS tablespaces_streamed
+ param3 AS backup_streamed,
+ param4 AS tablespaces_total,
+ param5 AS tablespaces_streamed
FROM pg_stat_get_progress_info('BASEBACKUP'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20);
pg_stat_progress_cluster| SELECT s.pid,
s.datid,
@@ -2024,16 +2024,16 @@ pg_stat_progress_vacuum| SELECT s.pid,
s.param7 AS num_dead_tuples
FROM (pg_stat_get_progress_info('VACUUM'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
LEFT JOIN pg_database d ON ((s.datid = d.oid)));
-pg_stat_recovery_prefetch| SELECT s.stats_reset,
- s.prefetch,
- s.hit,
- s.skip_init,
- s.skip_new,
- s.skip_fpw,
- s.skip_rep,
- s.wal_distance,
- s.block_distance,
- s.io_depth
+pg_stat_recovery_prefetch| SELECT stats_reset,
+ prefetch,
+ hit,
+ skip_init,
+ skip_new,
+ skip_fpw,
+ skip_rep,
+ wal_distance,
+ block_distance,
+ io_depth
FROM pg_stat_get_recovery_prefetch() s(stats_reset, prefetch, hit, skip_init, skip_new, skip_fpw, skip_rep, wal_distance, block_distance, io_depth);
pg_stat_replication| SELECT s.pid,
s.usesysid,
@@ -2071,26 +2071,26 @@ pg_stat_replication_slots| SELECT s.slot_name,
FROM pg_replication_slots r,
LATERAL pg_stat_get_replication_slot((r.slot_name)::text) s(slot_name, spill_txns, spill_count, spill_bytes, stream_txns, stream_count, stream_bytes, total_txns, total_bytes, stats_reset)
WHERE (r.datoid IS NOT NULL);
-pg_stat_slru| SELECT s.name,
- s.blks_zeroed,
- s.blks_hit,
- s.blks_read,
- s.blks_written,
- s.blks_exists,
- s.flushes,
- s.truncates,
- s.stats_reset
+pg_stat_slru| SELECT name,
+ blks_zeroed,
+ blks_hit,
+ blks_read,
+ blks_written,
+ blks_exists,
+ flushes,
+ truncates,
+ stats_reset
FROM pg_stat_get_slru() s(name, blks_zeroed, blks_hit, blks_read, blks_written, blks_exists, flushes, truncates, stats_reset);
-pg_stat_ssl| SELECT s.pid,
- s.ssl,
- s.sslversion AS version,
- s.sslcipher AS cipher,
- s.sslbits AS bits,
- s.ssl_client_dn AS client_dn,
- s.ssl_client_serial AS client_serial,
- s.ssl_issuer_dn AS issuer_dn
+pg_stat_ssl| SELECT pid,
+ ssl,
+ sslversion AS version,
+ sslcipher AS cipher,
+ sslbits AS bits,
+ ssl_client_dn AS client_dn,
+ ssl_client_serial AS client_serial,
+ ssl_issuer_dn AS issuer_dn
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid, query_id)
- WHERE (s.client_port IS NOT NULL);
+ WHERE (client_port IS NOT NULL);
pg_stat_subscription| SELECT su.oid AS subid,
su.subname,
st.pid,
@@ -2109,44 +2109,44 @@ pg_stat_subscription_stats| SELECT ss.subid,
ss.stats_reset
FROM pg_subscription s,
LATERAL pg_stat_get_subscription_stats(s.oid) ss(subid, apply_error_count, sync_error_count, stats_reset);
-pg_stat_sys_indexes| SELECT pg_stat_all_indexes.relid,
- pg_stat_all_indexes.indexrelid,
- pg_stat_all_indexes.schemaname,
- pg_stat_all_indexes.relname,
- pg_stat_all_indexes.indexrelname,
- pg_stat_all_indexes.idx_scan,
- pg_stat_all_indexes.last_idx_scan,
- pg_stat_all_indexes.idx_tup_read,
- pg_stat_all_indexes.idx_tup_fetch
+pg_stat_sys_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_read,
+ idx_tup_fetch
FROM pg_stat_all_indexes
- WHERE ((pg_stat_all_indexes.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_all_indexes.schemaname ~ '^pg_toast'::text));
-pg_stat_sys_tables| SELECT pg_stat_all_tables.relid,
- pg_stat_all_tables.schemaname,
- pg_stat_all_tables.relname,
- pg_stat_all_tables.seq_scan,
- pg_stat_all_tables.last_seq_scan,
- pg_stat_all_tables.seq_tup_read,
- pg_stat_all_tables.idx_scan,
- pg_stat_all_tables.last_idx_scan,
- pg_stat_all_tables.idx_tup_fetch,
- pg_stat_all_tables.n_tup_ins,
- pg_stat_all_tables.n_tup_upd,
- pg_stat_all_tables.n_tup_del,
- pg_stat_all_tables.n_tup_hot_upd,
- pg_stat_all_tables.n_live_tup,
- pg_stat_all_tables.n_dead_tup,
- pg_stat_all_tables.n_mod_since_analyze,
- pg_stat_all_tables.n_ins_since_vacuum,
- pg_stat_all_tables.last_vacuum,
- pg_stat_all_tables.last_autovacuum,
- pg_stat_all_tables.last_analyze,
- pg_stat_all_tables.last_autoanalyze,
- pg_stat_all_tables.vacuum_count,
- pg_stat_all_tables.autovacuum_count,
- pg_stat_all_tables.analyze_count,
- pg_stat_all_tables.autoanalyze_count
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_stat_sys_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ last_seq_scan,
+ seq_tup_read,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd,
+ n_live_tup,
+ n_dead_tup,
+ n_mod_since_analyze,
+ n_ins_since_vacuum,
+ last_vacuum,
+ last_autovacuum,
+ last_analyze,
+ last_autoanalyze,
+ vacuum_count,
+ autovacuum_count,
+ analyze_count,
+ autoanalyze_count
FROM pg_stat_all_tables
- WHERE ((pg_stat_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_all_tables.schemaname ~ '^pg_toast'::text));
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
pg_stat_user_functions| SELECT p.oid AS funcid,
n.nspname AS schemaname,
p.proname AS funcname,
@@ -2156,71 +2156,71 @@ pg_stat_user_functions| SELECT p.oid AS funcid,
FROM (pg_proc p
LEFT JOIN pg_namespace n ON ((n.oid = p.pronamespace)))
WHERE ((p.prolang <> (12)::oid) AND (pg_stat_get_function_calls(p.oid) IS NOT NULL));
-pg_stat_user_indexes| SELECT pg_stat_all_indexes.relid,
- pg_stat_all_indexes.indexrelid,
- pg_stat_all_indexes.schemaname,
- pg_stat_all_indexes.relname,
- pg_stat_all_indexes.indexrelname,
- pg_stat_all_indexes.idx_scan,
- pg_stat_all_indexes.last_idx_scan,
- pg_stat_all_indexes.idx_tup_read,
- pg_stat_all_indexes.idx_tup_fetch
+pg_stat_user_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_read,
+ idx_tup_fetch
FROM pg_stat_all_indexes
- WHERE ((pg_stat_all_indexes.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_all_indexes.schemaname !~ '^pg_toast'::text));
-pg_stat_user_tables| SELECT pg_stat_all_tables.relid,
- pg_stat_all_tables.schemaname,
- pg_stat_all_tables.relname,
- pg_stat_all_tables.seq_scan,
- pg_stat_all_tables.last_seq_scan,
- pg_stat_all_tables.seq_tup_read,
- pg_stat_all_tables.idx_scan,
- pg_stat_all_tables.last_idx_scan,
- pg_stat_all_tables.idx_tup_fetch,
- pg_stat_all_tables.n_tup_ins,
- pg_stat_all_tables.n_tup_upd,
- pg_stat_all_tables.n_tup_del,
- pg_stat_all_tables.n_tup_hot_upd,
- pg_stat_all_tables.n_live_tup,
- pg_stat_all_tables.n_dead_tup,
- pg_stat_all_tables.n_mod_since_analyze,
- pg_stat_all_tables.n_ins_since_vacuum,
- pg_stat_all_tables.last_vacuum,
- pg_stat_all_tables.last_autovacuum,
- pg_stat_all_tables.last_analyze,
- pg_stat_all_tables.last_autoanalyze,
- pg_stat_all_tables.vacuum_count,
- pg_stat_all_tables.autovacuum_count,
- pg_stat_all_tables.analyze_count,
- pg_stat_all_tables.autoanalyze_count
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_stat_user_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ last_seq_scan,
+ seq_tup_read,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd,
+ n_live_tup,
+ n_dead_tup,
+ n_mod_since_analyze,
+ n_ins_since_vacuum,
+ last_vacuum,
+ last_autovacuum,
+ last_analyze,
+ last_autoanalyze,
+ vacuum_count,
+ autovacuum_count,
+ analyze_count,
+ autoanalyze_count
FROM pg_stat_all_tables
- WHERE ((pg_stat_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_all_tables.schemaname !~ '^pg_toast'::text));
-pg_stat_wal| SELECT w.wal_records,
- w.wal_fpi,
- w.wal_bytes,
- w.wal_buffers_full,
- w.wal_write,
- w.wal_sync,
- w.wal_write_time,
- w.wal_sync_time,
- w.stats_reset
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_stat_wal| SELECT wal_records,
+ wal_fpi,
+ wal_bytes,
+ wal_buffers_full,
+ wal_write,
+ wal_sync,
+ wal_write_time,
+ wal_sync_time,
+ stats_reset
FROM pg_stat_get_wal() w(wal_records, wal_fpi, wal_bytes, wal_buffers_full, wal_write, wal_sync, wal_write_time, wal_sync_time, stats_reset);
-pg_stat_wal_receiver| SELECT s.pid,
- s.status,
- s.receive_start_lsn,
- s.receive_start_tli,
- s.written_lsn,
- s.flushed_lsn,
- s.received_tli,
- s.last_msg_send_time,
- s.last_msg_receipt_time,
- s.latest_end_lsn,
- s.latest_end_time,
- s.slot_name,
- s.sender_host,
- s.sender_port,
- s.conninfo
+pg_stat_wal_receiver| SELECT pid,
+ status,
+ receive_start_lsn,
+ receive_start_tli,
+ written_lsn,
+ flushed_lsn,
+ received_tli,
+ last_msg_send_time,
+ last_msg_receipt_time,
+ latest_end_lsn,
+ latest_end_time,
+ slot_name,
+ sender_host,
+ sender_port,
+ conninfo
FROM pg_stat_get_wal_receiver() s(pid, status, receive_start_lsn, receive_start_tli, written_lsn, flushed_lsn, received_tli, last_msg_send_time, last_msg_receipt_time, latest_end_lsn, latest_end_time, slot_name, sender_host, sender_port, conninfo)
- WHERE (s.pid IS NOT NULL);
+ WHERE (pid IS NOT NULL);
pg_stat_xact_all_tables| SELECT c.oid AS relid,
n.nspname AS schemaname,
c.relname,
@@ -2237,19 +2237,19 @@ pg_stat_xact_all_tables| SELECT c.oid AS relid,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char", 'p'::"char"]))
GROUP BY c.oid, n.nspname, c.relname;
-pg_stat_xact_sys_tables| SELECT pg_stat_xact_all_tables.relid,
- pg_stat_xact_all_tables.schemaname,
- pg_stat_xact_all_tables.relname,
- pg_stat_xact_all_tables.seq_scan,
- pg_stat_xact_all_tables.seq_tup_read,
- pg_stat_xact_all_tables.idx_scan,
- pg_stat_xact_all_tables.idx_tup_fetch,
- pg_stat_xact_all_tables.n_tup_ins,
- pg_stat_xact_all_tables.n_tup_upd,
- pg_stat_xact_all_tables.n_tup_del,
- pg_stat_xact_all_tables.n_tup_hot_upd
+pg_stat_xact_sys_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ seq_tup_read,
+ idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd
FROM pg_stat_xact_all_tables
- WHERE ((pg_stat_xact_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_xact_all_tables.schemaname ~ '^pg_toast'::text));
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
pg_stat_xact_user_functions| SELECT p.oid AS funcid,
n.nspname AS schemaname,
p.proname AS funcname,
@@ -2259,19 +2259,19 @@ pg_stat_xact_user_functions| SELECT p.oid AS funcid,
FROM (pg_proc p
LEFT JOIN pg_namespace n ON ((n.oid = p.pronamespace)))
WHERE ((p.prolang <> (12)::oid) AND (pg_stat_get_xact_function_calls(p.oid) IS NOT NULL));
-pg_stat_xact_user_tables| SELECT pg_stat_xact_all_tables.relid,
- pg_stat_xact_all_tables.schemaname,
- pg_stat_xact_all_tables.relname,
- pg_stat_xact_all_tables.seq_scan,
- pg_stat_xact_all_tables.seq_tup_read,
- pg_stat_xact_all_tables.idx_scan,
- pg_stat_xact_all_tables.idx_tup_fetch,
- pg_stat_xact_all_tables.n_tup_ins,
- pg_stat_xact_all_tables.n_tup_upd,
- pg_stat_xact_all_tables.n_tup_del,
- pg_stat_xact_all_tables.n_tup_hot_upd
+pg_stat_xact_user_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ seq_tup_read,
+ idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd
FROM pg_stat_xact_all_tables
- WHERE ((pg_stat_xact_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_xact_all_tables.schemaname !~ '^pg_toast'::text));
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
pg_statio_all_indexes| SELECT c.oid AS relid,
i.oid AS indexrelid,
n.nspname AS schemaname,
@@ -2315,64 +2315,64 @@ pg_statio_all_tables| SELECT c.oid AS relid,
FROM pg_index
WHERE (pg_index.indrelid = t.oid)) x ON (true))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char"]));
-pg_statio_sys_indexes| SELECT pg_statio_all_indexes.relid,
- pg_statio_all_indexes.indexrelid,
- pg_statio_all_indexes.schemaname,
- pg_statio_all_indexes.relname,
- pg_statio_all_indexes.indexrelname,
- pg_statio_all_indexes.idx_blks_read,
- pg_statio_all_indexes.idx_blks_hit
+pg_statio_sys_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_blks_read,
+ idx_blks_hit
FROM pg_statio_all_indexes
- WHERE ((pg_statio_all_indexes.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_indexes.schemaname ~ '^pg_toast'::text));
-pg_statio_sys_sequences| SELECT pg_statio_all_sequences.relid,
- pg_statio_all_sequences.schemaname,
- pg_statio_all_sequences.relname,
- pg_statio_all_sequences.blks_read,
- pg_statio_all_sequences.blks_hit
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_statio_sys_sequences| SELECT relid,
+ schemaname,
+ relname,
+ blks_read,
+ blks_hit
FROM pg_statio_all_sequences
- WHERE ((pg_statio_all_sequences.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_sequences.schemaname ~ '^pg_toast'::text));
-pg_statio_sys_tables| SELECT pg_statio_all_tables.relid,
- pg_statio_all_tables.schemaname,
- pg_statio_all_tables.relname,
- pg_statio_all_tables.heap_blks_read,
- pg_statio_all_tables.heap_blks_hit,
- pg_statio_all_tables.idx_blks_read,
- pg_statio_all_tables.idx_blks_hit,
- pg_statio_all_tables.toast_blks_read,
- pg_statio_all_tables.toast_blks_hit,
- pg_statio_all_tables.tidx_blks_read,
- pg_statio_all_tables.tidx_blks_hit
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_statio_sys_tables| SELECT relid,
+ schemaname,
+ relname,
+ heap_blks_read,
+ heap_blks_hit,
+ idx_blks_read,
+ idx_blks_hit,
+ toast_blks_read,
+ toast_blks_hit,
+ tidx_blks_read,
+ tidx_blks_hit
FROM pg_statio_all_tables
- WHERE ((pg_statio_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_tables.schemaname ~ '^pg_toast'::text));
-pg_statio_user_indexes| SELECT pg_statio_all_indexes.relid,
- pg_statio_all_indexes.indexrelid,
- pg_statio_all_indexes.schemaname,
- pg_statio_all_indexes.relname,
- pg_statio_all_indexes.indexrelname,
- pg_statio_all_indexes.idx_blks_read,
- pg_statio_all_indexes.idx_blks_hit
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_statio_user_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_blks_read,
+ idx_blks_hit
FROM pg_statio_all_indexes
- WHERE ((pg_statio_all_indexes.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_indexes.schemaname !~ '^pg_toast'::text));
-pg_statio_user_sequences| SELECT pg_statio_all_sequences.relid,
- pg_statio_all_sequences.schemaname,
- pg_statio_all_sequences.relname,
- pg_statio_all_sequences.blks_read,
- pg_statio_all_sequences.blks_hit
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_statio_user_sequences| SELECT relid,
+ schemaname,
+ relname,
+ blks_read,
+ blks_hit
FROM pg_statio_all_sequences
- WHERE ((pg_statio_all_sequences.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_sequences.schemaname !~ '^pg_toast'::text));
-pg_statio_user_tables| SELECT pg_statio_all_tables.relid,
- pg_statio_all_tables.schemaname,
- pg_statio_all_tables.relname,
- pg_statio_all_tables.heap_blks_read,
- pg_statio_all_tables.heap_blks_hit,
- pg_statio_all_tables.idx_blks_read,
- pg_statio_all_tables.idx_blks_hit,
- pg_statio_all_tables.toast_blks_read,
- pg_statio_all_tables.toast_blks_hit,
- pg_statio_all_tables.tidx_blks_read,
- pg_statio_all_tables.tidx_blks_hit
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_statio_user_tables| SELECT relid,
+ schemaname,
+ relname,
+ heap_blks_read,
+ heap_blks_hit,
+ idx_blks_read,
+ idx_blks_hit,
+ toast_blks_read,
+ toast_blks_hit,
+ tidx_blks_read,
+ tidx_blks_hit
FROM pg_statio_all_tables
- WHERE ((pg_statio_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_tables.schemaname !~ '^pg_toast'::text));
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
pg_stats| SELECT n.nspname AS schemaname,
c.relname AS tablename,
a.attname,
@@ -2557,24 +2557,24 @@ pg_tables| SELECT n.nspname AS schemaname,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
LEFT JOIN pg_tablespace t ON ((t.oid = c.reltablespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 'p'::"char"]));
-pg_timezone_abbrevs| SELECT pg_timezone_abbrevs.abbrev,
- pg_timezone_abbrevs.utc_offset,
- pg_timezone_abbrevs.is_dst
+pg_timezone_abbrevs| SELECT abbrev,
+ utc_offset,
+ is_dst
FROM pg_timezone_abbrevs() pg_timezone_abbrevs(abbrev, utc_offset, is_dst);
-pg_timezone_names| SELECT pg_timezone_names.name,
- pg_timezone_names.abbrev,
- pg_timezone_names.utc_offset,
- pg_timezone_names.is_dst
+pg_timezone_names| SELECT name,
+ abbrev,
+ utc_offset,
+ is_dst
FROM pg_timezone_names() pg_timezone_names(name, abbrev, utc_offset, is_dst);
-pg_user| SELECT pg_shadow.usename,
- pg_shadow.usesysid,
- pg_shadow.usecreatedb,
- pg_shadow.usesuper,
- pg_shadow.userepl,
- pg_shadow.usebypassrls,
+pg_user| SELECT usename,
+ usesysid,
+ usecreatedb,
+ usesuper,
+ userepl,
+ usebypassrls,
'********'::text AS passwd,
- pg_shadow.valuntil,
- pg_shadow.useconfig
+ valuntil,
+ useconfig
FROM pg_shadow;
pg_user_mappings| SELECT u.oid AS umid,
s.oid AS srvid,
@@ -3079,7 +3079,7 @@ SELECT * FROM rule_v1;
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rule_t1.a
+ SELECT a
FROM rule_t1;
Rules:
newinsertrule AS
@@ -3118,8 +3118,8 @@ alter table rule_v1 rename column column2 to q2;
column1 | integer | | | | plain |
q2 | integer | | | | plain |
View definition:
- SELECT "*VALUES*".column1,
- "*VALUES*".column2 AS q2
+ SELECT column1,
+ column2 AS q2
FROM (VALUES (1,2)) "*VALUES*";
drop view rule_v1;
@@ -3131,8 +3131,8 @@ create view rule_v1(x) as values(1,2);
x | integer | | | | plain |
column2 | integer | | | | plain |
View definition:
- SELECT "*VALUES*".column1 AS x,
- "*VALUES*".column2
+ SELECT column1 AS x,
+ column2
FROM (VALUES (1,2)) "*VALUES*";
drop view rule_v1;
@@ -3144,8 +3144,8 @@ create view rule_v1(x) as select * from (values(1,2)) v;
x | integer | | | | plain |
column2 | integer | | | | plain |
View definition:
- SELECT v.column1 AS x,
- v.column2
+ SELECT column1 AS x,
+ column2
FROM ( VALUES (1,2)) v;
drop view rule_v1;
@@ -3157,8 +3157,8 @@ create view rule_v1(x) as select * from (values(1,2)) v(q,w);
x | integer | | | | plain |
w | integer | | | | plain |
View definition:
- SELECT v.q AS x,
- v.w
+ SELECT q AS x,
+ w
FROM ( VALUES (1,2)) v(q, w);
drop view rule_v1;
diff --git a/src/test/regress/expected/tablesample.out b/src/test/regress/expected/tablesample.out
index 60bb4e8e3e..9ff4611640 100644
--- a/src/test/regress/expected/tablesample.out
+++ b/src/test/regress/expected/tablesample.out
@@ -74,7 +74,7 @@ CREATE VIEW test_tablesample_v2 AS
--------+---------+-----------+----------+---------+---------+-------------
id | integer | | | | plain |
View definition:
- SELECT test_tablesample.id
+ SELECT id
FROM test_tablesample TABLESAMPLE system ((10 * 2)) REPEATABLE (2);
\d+ test_tablesample_v2
@@ -83,7 +83,7 @@ View definition:
--------+---------+-----------+----------+---------+---------+-------------
id | integer | | | | plain |
View definition:
- SELECT test_tablesample.id
+ SELECT id
FROM test_tablesample TABLESAMPLE system (99);
-- check a sampled query doesn't affect cursor in progress
diff --git a/src/test/regress/expected/triggers.out b/src/test/regress/expected/triggers.out
index 6d80ab1a6d..7dbeced570 100644
--- a/src/test/regress/expected/triggers.out
+++ b/src/test/regress/expected/triggers.out
@@ -1277,8 +1277,8 @@ DROP TRIGGER instead_of_delete_trig ON main_view;
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT main_table.a,
- main_table.b
+ SELECT a,
+ b
FROM main_table;
Triggers:
after_del_stmt_trig AFTER DELETE ON main_view FOR EACH STATEMENT EXECUTE FUNCTION view_trigger('after_view_del_stmt')
diff --git a/src/test/regress/expected/updatable_views.out b/src/test/regress/expected/updatable_views.out
index 5a47dacad9..2b578cced1 100644
--- a/src/test/regress/expected/updatable_views.out
+++ b/src/test/regress/expected/updatable_views.out
@@ -1925,19 +1925,19 @@ CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a < b
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT base_tbl.a,
- base_tbl.b
+ SELECT a,
+ b
FROM base_tbl
- WHERE base_tbl.a < base_tbl.b;
+ WHERE a < b;
Options: check_option=local
SELECT * FROM information_schema.views WHERE table_name = 'rw_view1';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+------------------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view1 | SELECT base_tbl.a, +| LOCAL | YES | YES | NO | NO | NO
- | | | base_tbl.b +| | | | | |
- | | | FROM base_tbl +| | | | | |
- | | | WHERE (base_tbl.a < base_tbl.b); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view1 | SELECT a, +| LOCAL | YES | YES | NO | NO | NO
+ | | | b +| | | | | |
+ | | | FROM base_tbl+| | | | | |
+ | | | WHERE (a < b); | | | | | |
(1 row)
INSERT INTO rw_view1 VALUES(3,4); -- ok
@@ -1978,17 +1978,17 @@ CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rw_view1.a
+ SELECT a
FROM rw_view1
- WHERE rw_view1.a < 10;
+ WHERE a < 10;
Options: check_option=cascaded
SELECT * FROM information_schema.views WHERE table_name = 'rw_view2';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+----------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view2 | SELECT rw_view1.a +| CASCADED | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a < 10); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view2 | SELECT a +| CASCADED | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a < 10); | | | | | |
(1 row)
INSERT INTO rw_view2 VALUES (-5); -- should fail
@@ -2018,17 +2018,17 @@ CREATE OR REPLACE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rw_view1.a
+ SELECT a
FROM rw_view1
- WHERE rw_view1.a < 10;
+ WHERE a < 10;
Options: check_option=local
SELECT * FROM information_schema.views WHERE table_name = 'rw_view2';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+----------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view2 | SELECT rw_view1.a +| LOCAL | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a < 10); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view2 | SELECT a +| LOCAL | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a < 10); | | | | | |
(1 row)
INSERT INTO rw_view2 VALUES (-10); -- ok, but not in view
@@ -2059,16 +2059,16 @@ ALTER VIEW rw_view2 RESET (check_option);
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rw_view1.a
+ SELECT a
FROM rw_view1
- WHERE rw_view1.a < 10;
+ WHERE a < 10;
SELECT * FROM information_schema.views WHERE table_name = 'rw_view2';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+----------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view2 | SELECT rw_view1.a +| NONE | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a < 10); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view2 | SELECT a +| NONE | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a < 10); | | | | | |
(1 row)
INSERT INTO rw_view2 VALUES (30); -- ok, but not in view
@@ -2090,15 +2090,15 @@ CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WITH CHECK OPTION;
CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a > 0;
CREATE VIEW rw_view3 AS SELECT * FROM rw_view2 WITH CHECK OPTION;
SELECT * FROM information_schema.views WHERE table_name LIKE E'rw\\_view_' ORDER BY table_name;
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+---------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view1 | SELECT base_tbl.a +| CASCADED | YES | YES | NO | NO | NO
- | | | FROM base_tbl; | | | | | |
- regression | public | rw_view2 | SELECT rw_view1.a +| NONE | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a > 0); | | | | | |
- regression | public | rw_view3 | SELECT rw_view2.a +| CASCADED | YES | YES | NO | NO | NO
- | | | FROM rw_view2; | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view1 | SELECT a +| CASCADED | YES | YES | NO | NO | NO
+ | | | FROM base_tbl; | | | | | |
+ regression | public | rw_view2 | SELECT a +| NONE | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a > 0); | | | | | |
+ regression | public | rw_view3 | SELECT a +| CASCADED | YES | YES | NO | NO | NO
+ | | | FROM rw_view2; | | | | | |
(3 rows)
INSERT INTO rw_view1 VALUES (-1); -- ok
diff --git a/src/test/regress/expected/window.out b/src/test/regress/expected/window.out
index 170bea23c2..3d1d26aa39 100644
--- a/src/test/regress/expected/window.out
+++ b/src/test/regress/expected/window.out
@@ -1212,10 +1212,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
----------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1238,10 +1238,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
------------------------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) AS sum_rows+
+ pg_get_viewdef
+-------------------------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1264,10 +1264,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
------------------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE GROUP) AS sum_rows+
+ pg_get_viewdef
+-------------------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE GROUP) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1290,10 +1290,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
-----------------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE TIES) AS sum_rows+
+ pg_get_viewdef
+------------------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE TIES) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1316,10 +1316,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
----------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1341,10 +1341,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
+ pg_get_viewdef
+-------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1353,10 +1353,10 @@ CREATE TEMP VIEW v_window AS
SELECT i, min(i) over (order by i range between '1 day' preceding and '10 days' following) as min_i
FROM generate_series(now(), now()+'100 days'::interval, '1 hour') i;
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
----------------------------------------------------------------------------------------------------------------------------
- SELECT i.i, +
- min(i.i) OVER (ORDER BY i.i RANGE BETWEEN '@ 1 day'::interval PRECEDING AND '@ 10 days'::interval FOLLOWING) AS min_i+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------------------------------------------
+ SELECT i, +
+ min(i) OVER (ORDER BY i RANGE BETWEEN '@ 1 day'::interval PRECEDING AND '@ 10 days'::interval FOLLOWING) AS min_i+
FROM generate_series(now(), (now() + '@ 100 days'::interval), '@ 1 hour'::interval) i(i);
(1 row)
diff --git a/src/test/regress/expected/with.out b/src/test/regress/expected/with.out
index f3fd1cd32a..008a8a9781 100644
--- a/src/test/regress/expected/with.out
+++ b/src/test/regress/expected/with.out
@@ -396,9 +396,9 @@ SELECT pg_get_viewdef('vsubdepartment'::regclass);
subdepartment sd +
WHERE (d.parent_department = sd.id)+
) +
- SELECT subdepartment.id, +
- subdepartment.parent_department, +
- subdepartment.name +
+ SELECT id, +
+ parent_department, +
+ name +
FROM subdepartment;
(1 row)
@@ -419,9 +419,9 @@ SELECT pg_get_viewdef('vsubdepartment'::regclass, true);
subdepartment sd +
WHERE d.parent_department = sd.id+
) +
- SELECT subdepartment.id, +
- subdepartment.parent_department, +
- subdepartment.name +
+ SELECT id, +
+ parent_department, +
+ name +
FROM subdepartment;
(1 row)
@@ -446,7 +446,7 @@ View definition:
FROM t t_1
WHERE t_1.n < 100
)
- SELECT sum(t.n) AS sum
+ SELECT sum(n) AS sum
FROM t;
-- corner case in which sub-WITH gets initialized first
@@ -959,9 +959,9 @@ select pg_get_viewdef('v_search');
search_graph sg +
WHERE (g.f = sg.t) +
) SEARCH DEPTH FIRST BY f, t SET seq +
- SELECT search_graph.f, +
- search_graph.t, +
- search_graph.label +
+ SELECT f, +
+ t, +
+ label +
FROM search_graph;
(1 row)
@@ -1524,9 +1524,9 @@ select pg_get_viewdef('v_cycle1');
search_graph sg +
WHERE (g.f = sg.t) +
) CYCLE f, t SET is_cycle USING path +
- SELECT search_graph.f, +
- search_graph.t, +
- search_graph.label +
+ SELECT f, +
+ t, +
+ label +
FROM search_graph;
(1 row)
@@ -1546,9 +1546,9 @@ select pg_get_viewdef('v_cycle2');
search_graph sg +
WHERE (g.f = sg.t) +
) CYCLE f, t SET is_cycle TO 'Y'::text DEFAULT 'N'::text USING path+
- SELECT search_graph.f, +
- search_graph.t, +
- search_graph.label +
+ SELECT f, +
+ t, +
+ label +
FROM search_graph;
(1 row)
diff --git a/src/test/regress/expected/xml_2.out b/src/test/regress/expected/xml_2.out
index 5fd3886b5e..3986fc1706 100644
--- a/src/test/regress/expected/xml_2.out
+++ b/src/test/regress/expected/xml_2.out
@@ -583,12 +583,12 @@ CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'xmlview%' ORDER BY 1;
- table_name | view_definition
-------------+-------------------------------------------------------------------------------------------------------------------
+ table_name | view_definition
+------------+------------------------------------------------------------------------------------------------------------
xmlview1 | SELECT xmlcomment('test'::text) AS xmlcomment;
xmlview2 | SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat";
xmlview3 | SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement";
- xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(emp.name AS name, emp.age AS age, emp.salary AS pay)) AS "xmlelement"+
+ xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(name AS name, age AS age, salary AS pay)) AS "xmlelement" +
| FROM emp;
xmlview5 | SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
xmlview6 | SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi";
--
2.35.3
On Fri, Dec 9, 2022 at 3:07 PM Amit Langote <amitlangote09@gmail.com> wrote:
On Thu, Dec 8, 2022 at 6:12 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
On 2022-Dec-07, Amit Langote wrote:
However, this
approach of not storing the placeholder in the stored rule would lead
to a whole lot of regression test output changes, because the stored
view queries of many regression tests involving views would now end up
with only 1 entry in the range table instead of 3, causing ruleutils.c
to no longer qualify the column names in the deparsed representation
of those queries appearing in those regression test expected outputs.To avoid that churn (not sure if really a goal to strive for in this
case!), I thought it might be better to keep the OLD entry in the
stored action query while getting rid of the NEW entry.If the *only* argument for keeping the RTE for OLD is to avoid
regression test churn, then definitely it is not worth doing and it
should be ripped out.Other than avoiding the regression test output churn, this also makes
the changes of ApplyRetrieveRule unnecessary.But do these changes mean the code is worse afterwards? Changing stuff,
per se, is not bad. Also, since you haven't posted the "complete" patch
since Nov 7th, it's not easy to tell what those changes are.Maybe you should post both versions of the patch -- one that removes
just NEW, and one that removes both OLD and NEW, so that we can judge.OK, I gave the previous approach another try to see if I can change
ApplyRetrieveRule() in a bit more convincing way this time around, now
that the RTEPermissionInfo patch is in.I would say I'm more satisfied with how it turned out this time. Let
me know what you think.Actually, as I was addressing Alvaro's comments on the now-committed
patch, I was starting to get concerned about the implications of the
change in position of the view relation RTE in the query's range table
if ApplyRetrieveRule() adds one from scratch instead of simply
recycling the OLD entry from stored rule action query, even though I
could see that there are no *user-visible* changes, especially after
decoupling permission checking from the range table.Hmm, I think I see the point, though I don't necessarily agree that
there is a problem.Yeah, I'm not worried as much with the new version. That is helped by
the fact that I've made ApplyRetrieveRule() now do basically what
UpdateRangeTableOfViewParse() would do with the stored rule query.
Also, our making add_rtes_to_flat_rtable() add perminfos in the RTE
order helped find the bug with the last version.Attaching both patches.
Looks like I forgot to update some expected output files.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com
Attachments:
v1-0001-Do-not-add-the-NEW-entry-to-view-rule-action-s-ra.patchapplication/octet-stream; name=v1-0001-Do-not-add-the-NEW-entry-to-view-rule-action-s-ra.patchDownload
From 8f7d8e8220bcb6fb7fa0ae29bdcade1927a86971 Mon Sep 17 00:00:00 2001
From: amitlan <amitlangote09@gmail.com>
Date: Mon, 21 Nov 2022 15:27:56 +0900
Subject: [PATCH v1] Do not add the NEW entry to view rule action's range table
The OLD entry suffices as a placeholder for the view relation when
it is queried, such as for checking its permissions during a query's
execution, but the NEW entry has no role whatsoever, so stop adding
it.
With there now being fewer entries in the view query's range table,
this change affects how the deparsed queries involving views look,
especially in the cases where the output of deparsing depends on using
RT indexs (such as automatically generated RTE alias names in
postgres_fdw deparser). To wit, some postgres_fdw regression tests
whose expected output changes due to this have been updated to match.
---
.../postgres_fdw/expected/postgres_fdw.out | 4 +-
src/backend/commands/lockcmds.c | 6 +-
src/backend/commands/view.c | 81 +++++++------------
src/backend/rewrite/rewriteDefine.c | 6 +-
src/backend/rewrite/rewriteHandler.c | 4 +-
5 files changed, 38 insertions(+), 63 deletions(-)
diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out
index 2ab3f1efaa..ccf36a3f67 100644
--- a/contrib/postgres_fdw/expected/postgres_fdw.out
+++ b/contrib/postgres_fdw/expected/postgres_fdw.out
@@ -2606,7 +2606,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1
Foreign Scan
Output: ft4.c1, ft5.c2, ft5.c1
Relations: (public.ft4) LEFT JOIN (public.ft5)
- Remote SQL: SELECT r6.c1, r9.c2, r9.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r9 ON (((r6.c1 = r9.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r9.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r5.c1, r7.c2, r7.c1 FROM ("S 1"."T 3" r5 LEFT JOIN "S 1"."T 4" r7 ON (((r5.c1 = r7.c1)))) ORDER BY r5.c1 ASC NULLS LAST, r7.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
@@ -2669,7 +2669,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c
Foreign Scan
Output: ft4.c1, t2.c2, t2.c1
Relations: (public.ft4) LEFT JOIN (public.ft5 t2)
- Remote SQL: SELECT r6.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r2 ON (((r6.c1 = r2.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r5.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r5 LEFT JOIN "S 1"."T 4" r2 ON (((r5.c1 = r2.c1)))) ORDER BY r5.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index b0747ce291..ce0e6ac112 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -195,12 +195,10 @@ LockViewRecurse_walker(Node *node, LockViewRecurse_context *context)
char *relname = get_rel_name(relid);
/*
- * The OLD and NEW placeholder entries in the view's rtable are
- * skipped.
+ * The OLD placeholder entry in the view's rtable is skipped.
*/
if (relid == context->viewoid &&
- (strcmp(rte->eref->aliasname, "old") == 0 ||
- strcmp(rte->eref->aliasname, "new") == 0))
+ (strcmp(rte->eref->aliasname, "old") == 0))
continue;
/* Currently, we only allow plain tables or views to be locked. */
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index 8e3c1efae4..97ad8ad663 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -356,29 +356,24 @@ DefineViewRules(Oid viewOid, Query *viewParse, bool replace)
/*---------------------------------------------------------------
* UpdateRangeTableOfViewParse
*
- * Update the range table of the given parsetree.
- * This update consists of adding two new entries IN THE BEGINNING
- * of the range table (otherwise the rule system will die a slow,
- * horrible and painful death, and we do not want that now, do we?)
- * one for the OLD relation and one for the NEW one (both of
- * them refer in fact to the "view" relation).
+ * Update the range table of the given parsetree to add a placeholder entry
+ * for the view relation and increase the 'varnos' of all the Var nodes
+ * by 1 to account for its addition.
*
- * Of course we must also increase the 'varnos' of all the Var nodes
- * by 2...
- *
- * These extra RT entries are not actually used in the query,
- * except for run-time locking.
+ * This extra RT entry for the view relation is not actually used in the query
+ * but it is needed so that 1) the executor can checks the view relation's
+ * permissions via the RTEPermissionInfo that is also added in this function,
+ * 2) the executor can lock the view relation, and 3) the planner can record
+ * the view relation's OID in PlannedStmt.relationOids.
*---------------------------------------------------------------
*/
static Query *
UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
{
Relation viewRel;
- List *new_rt;
ParseNamespaceItem *nsitem;
- RangeTblEntry *rt_entry1,
- *rt_entry2;
- RTEPermissionInfo *rte_perminfo1;
+ RangeTblEntry *rt_entry;
+ RTEPermissionInfo *rte_perminfo;
ParseState *pstate;
ListCell *lc;
@@ -399,31 +394,25 @@ UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
viewRel = relation_open(viewOid, AccessShareLock);
/*
- * Create the 2 new range table entries and form the new range table...
- * OLD first, then NEW....
+ * Create a placeholder RTE for the view relation named "OLD" and add it
+ * as the 1st entry of the new range table, followed by the entries in the
+ * view query's range table. Do the same for the corresponding
+ * RTEPermissionInfo, which means we must adjust the view query's RTEs'
+ * perminfoindex to cope.
+ *
+ * Note that when rewriting a query on the view, ApplyRetrieveRule() will
+ * transfer the view relation's permission details into this
+ * placeholder RTEPermissionInfo. That's needed because the view's RTE
+ * itself in that query will be transposed into a subquery RTE that can't
+ * be made to any RTEPermissionInfo; see the code stanza at the end of
+ * ApplyRetrieveRule() for more details.
*/
nsitem = addRangeTableEntryForRelation(pstate, viewRel,
AccessShareLock,
makeAlias("old", NIL),
false, false);
- rt_entry1 = nsitem->p_rte;
- rte_perminfo1 = nsitem->p_perminfo;
- nsitem = addRangeTableEntryForRelation(pstate, viewRel,
- AccessShareLock,
- makeAlias("new", NIL),
- false, false);
- rt_entry2 = nsitem->p_rte;
-
- /*
- * Add only the "old" RTEPermissionInfo at the head of view query's list
- * and update the other RTEs' perminfoindex accordingly. When rewriting a
- * query on the view, ApplyRetrieveRule() will transfer the view
- * relation's permission details into this RTEPermissionInfo. That's
- * needed because the view's RTE itself will be transposed into a subquery
- * RTE that can't carry the permission details; see the code stanza toward
- * the end of ApplyRetrieveRule() for how that's done.
- */
- viewParse->rteperminfos = lcons(rte_perminfo1, viewParse->rteperminfos);
+ rt_entry = nsitem->p_rte;
+ rte_perminfo = nsitem->p_perminfo;
foreach(lc, viewParse->rtable)
{
RangeTblEntry *rte = lfirst(lc);
@@ -431,23 +420,13 @@ UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
if (rte->perminfoindex > 0)
rte->perminfoindex += 1;
}
+ viewParse->rtable = lcons(rt_entry, viewParse->rtable);
+ viewParse->rteperminfos = lcons(rte_perminfo, viewParse->rteperminfos);
/*
- * Also make the "new" RTE's RTEPermissionInfo undiscoverable. This is a
- * bit of a hack given that all the non-child RTE_RELATION entries really
- * should have a RTEPermissionInfo, but this dummy "new" RTE is going to
- * go away anyway in the very near future.
- */
- rt_entry2->perminfoindex = 0;
-
- new_rt = lcons(rt_entry1, lcons(rt_entry2, viewParse->rtable));
-
- viewParse->rtable = new_rt;
-
- /*
- * Now offset all var nodes by 2, and jointree RT indexes too.
+ * Now offset all var nodes by 1, and jointree RT indexes too.
*/
- OffsetVarNodes((Node *) viewParse, 2, 0);
+ OffsetVarNodes((Node *) viewParse, 1, 0);
relation_close(viewRel, AccessShareLock);
@@ -617,8 +596,8 @@ void
StoreViewQuery(Oid viewOid, Query *viewParse, bool replace)
{
/*
- * The range table of 'viewParse' does not contain entries for the "OLD"
- * and "NEW" relations. So... add them!
+ * Add a placeholder entry for the "OLD" relation to the range table of
+ * 'viewParse'; see the header comment for why it's needed.
*/
viewParse = UpdateRangeTableOfViewParse(viewOid, viewParse);
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index 9f3afe965a..8bfaefd098 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -636,10 +636,8 @@ checkRuleResultList(List *targetList, TupleDesc resultDesc, bool isSelect,
*
* Note: for a view (ON SELECT rule), the checkAsUser field of the OLD
* RTE entry's RTEPermissionInfo will be overridden when the view rule is
- * expanded, and the checkAsUser for the NEW RTE entry's RTEPermissionInfo is
- * irrelevant because its requiredPerms bits will always be zero. However, for
- * other types of rules it's important to set these fields to match the rule
- * owner. So we just set them always.
+ * expanded. However, for other types of rules it's important to set these
+ * fields to match the rule owner. So we just set them always.
*/
void
setRuleCheckAsUser(Node *node, Oid userid)
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index ea56ff79c8..11b8e449bd 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -1907,8 +1907,8 @@ ApplyRetrieveRule(Query *parsetree,
*
* NB: this must agree with the parser's transformLockingClause() routine.
* However, unlike the parser we have to be careful not to mark a view's
- * OLD and NEW rels for updating. The best way to handle that seems to be
- * to scan the jointree to determine which rels are used.
+ * OLD rel for updating. The best way to handle that seems to be to scan
+ * the jointree to determine which rels are used.
*/
static void
markQueryForLocking(Query *qry, Node *jtnode,
--
2.35.3
v2-0001-Remove-UpdateRangeTableOfViewParse.patchapplication/octet-stream; name=v2-0001-Remove-UpdateRangeTableOfViewParse.patchDownload
From 53a6803141fd78afff13b261732ef4a44a1ff19d Mon Sep 17 00:00:00 2001
From: amitlan <amitlangote09@gmail.com>
Date: Fri, 9 Dec 2022 10:33:59 +0900
Subject: [PATCH v2] Remove UpdateRangeTableOfViewParse()
And with it, the OLD and the NEW placeholder RTEs that are stored in
a view's stored rule action query.
The OLD RTE is needed currently as a placeholder for carrying view
relation info when querying a given view, because the view relation's
RTE in the query's range table is transposed into a subquery RTE for
converting the view's query into a subselect of the user query.
The NEW RTE is currently not needed for anything.
The purpose served by the OLD RTE doesn't really require it to be
present in the stored view rule query's range table though.
ApplyRetrieveRule(), which would so far look up the OLD RTE from the
view query and repurpose it for carrying the view relation info, can
create the placeholder entries (RTE and RTEPermissionInfo) by itself,
which this commit teaches it to do.
This changes the format of the store rule for views, especially the
range table length, so a bunch of regression tests that show deparsed
view queries need to be adjusted to cope.
---
.../postgres_fdw/expected/postgres_fdw.out | 16 +-
src/backend/commands/lockcmds.c | 9 -
src/backend/commands/view.c | 107 ---
src/backend/rewrite/rewriteDefine.c | 10 +-
src/backend/rewrite/rewriteHandler.c | 59 +-
src/bin/pg_dump/t/002_pg_dump.pl | 12 +-
src/test/regress/expected/aggregates.out | 26 +-
src/test/regress/expected/alter_table.out | 16 +-
.../regress/expected/collate.icu.utf8.out | 24 +-
.../regress/expected/collate.linux.utf8.out | 24 +-
src/test/regress/expected/collate.out | 26 +-
src/test/regress/expected/compression.out | 4 +-
src/test/regress/expected/create_view.out | 222 +++---
src/test/regress/expected/expressions.out | 24 +-
src/test/regress/expected/groupingsets.out | 20 +-
src/test/regress/expected/limit.out | 24 +-
src/test/regress/expected/matview.out | 24 +-
src/test/regress/expected/polymorphism.out | 8 +-
src/test/regress/expected/rangefuncs.out | 34 +-
src/test/regress/expected/rules.out | 748 +++++++++---------
src/test/regress/expected/tablesample.out | 4 +-
src/test/regress/expected/triggers.out | 4 +-
src/test/regress/expected/updatable_views.out | 78 +-
src/test/regress/expected/window.out | 56 +-
src/test/regress/expected/with.out | 32 +-
src/test/regress/expected/xml.out | 6 +-
src/test/regress/expected/xml_2.out | 6 +-
27 files changed, 762 insertions(+), 861 deletions(-)
diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out
index 2ab3f1efaa..e98e64cedc 100644
--- a/contrib/postgres_fdw/expected/postgres_fdw.out
+++ b/contrib/postgres_fdw/expected/postgres_fdw.out
@@ -2606,7 +2606,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1
Foreign Scan
Output: ft4.c1, ft5.c2, ft5.c1
Relations: (public.ft4) LEFT JOIN (public.ft5)
- Remote SQL: SELECT r6.c1, r9.c2, r9.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r9 ON (((r6.c1 = r9.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r9.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r5.c1, r7.c2, r7.c1 FROM ("S 1"."T 3" r5 LEFT JOIN "S 1"."T 4" r7 ON (((r5.c1 = r7.c1)))) ORDER BY r5.c1 ASC NULLS LAST, r7.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
@@ -2669,7 +2669,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c
Foreign Scan
Output: ft4.c1, t2.c2, t2.c1
Relations: (public.ft4) LEFT JOIN (public.ft5 t2)
- Remote SQL: SELECT r6.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r2 ON (((r6.c1 = r2.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r5.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r5 LEFT JOIN "S 1"."T 4" r2 ON (((r5.c1 = r2.c1)))) ORDER BY r5.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
@@ -6555,10 +6555,10 @@ CREATE VIEW rw_view AS SELECT * FROM foreign_tbl
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT foreign_tbl.a,
- foreign_tbl.b
+ SELECT a,
+ b
FROM foreign_tbl
- WHERE foreign_tbl.a < foreign_tbl.b;
+ WHERE a < b;
Options: check_option=cascaded
EXPLAIN (VERBOSE, COSTS OFF)
@@ -6672,10 +6672,10 @@ CREATE VIEW rw_view AS SELECT * FROM parent_tbl
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT parent_tbl.a,
- parent_tbl.b
+ SELECT a,
+ b
FROM parent_tbl
- WHERE parent_tbl.a < parent_tbl.b;
+ WHERE a < b;
Options: check_option=cascaded
EXPLAIN (VERBOSE, COSTS OFF)
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index b0747ce291..1d5f30443b 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -194,15 +194,6 @@ LockViewRecurse_walker(Node *node, LockViewRecurse_context *context)
char relkind = rte->relkind;
char *relname = get_rel_name(relid);
- /*
- * The OLD and NEW placeholder entries in the view's rtable are
- * skipped.
- */
- if (relid == context->viewoid &&
- (strcmp(rte->eref->aliasname, "old") == 0 ||
- strcmp(rte->eref->aliasname, "new") == 0))
- continue;
-
/* Currently, we only allow plain tables or views to be locked. */
if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE &&
relkind != RELKIND_VIEW)
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index 8e3c1efae4..7e3d5e79bc 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -353,107 +353,6 @@ DefineViewRules(Oid viewOid, Query *viewParse, bool replace)
*/
}
-/*---------------------------------------------------------------
- * UpdateRangeTableOfViewParse
- *
- * Update the range table of the given parsetree.
- * This update consists of adding two new entries IN THE BEGINNING
- * of the range table (otherwise the rule system will die a slow,
- * horrible and painful death, and we do not want that now, do we?)
- * one for the OLD relation and one for the NEW one (both of
- * them refer in fact to the "view" relation).
- *
- * Of course we must also increase the 'varnos' of all the Var nodes
- * by 2...
- *
- * These extra RT entries are not actually used in the query,
- * except for run-time locking.
- *---------------------------------------------------------------
- */
-static Query *
-UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
-{
- Relation viewRel;
- List *new_rt;
- ParseNamespaceItem *nsitem;
- RangeTblEntry *rt_entry1,
- *rt_entry2;
- RTEPermissionInfo *rte_perminfo1;
- ParseState *pstate;
- ListCell *lc;
-
- /*
- * Make a copy of the given parsetree. It's not so much that we don't
- * want to scribble on our input, it's that the parser has a bad habit of
- * outputting multiple links to the same subtree for constructs like
- * BETWEEN, and we mustn't have OffsetVarNodes increment the varno of a
- * Var node twice. copyObject will expand any multiply-referenced subtree
- * into multiple copies.
- */
- viewParse = copyObject(viewParse);
-
- /* Create a dummy ParseState for addRangeTableEntryForRelation */
- pstate = make_parsestate(NULL);
-
- /* need to open the rel for addRangeTableEntryForRelation */
- viewRel = relation_open(viewOid, AccessShareLock);
-
- /*
- * Create the 2 new range table entries and form the new range table...
- * OLD first, then NEW....
- */
- nsitem = addRangeTableEntryForRelation(pstate, viewRel,
- AccessShareLock,
- makeAlias("old", NIL),
- false, false);
- rt_entry1 = nsitem->p_rte;
- rte_perminfo1 = nsitem->p_perminfo;
- nsitem = addRangeTableEntryForRelation(pstate, viewRel,
- AccessShareLock,
- makeAlias("new", NIL),
- false, false);
- rt_entry2 = nsitem->p_rte;
-
- /*
- * Add only the "old" RTEPermissionInfo at the head of view query's list
- * and update the other RTEs' perminfoindex accordingly. When rewriting a
- * query on the view, ApplyRetrieveRule() will transfer the view
- * relation's permission details into this RTEPermissionInfo. That's
- * needed because the view's RTE itself will be transposed into a subquery
- * RTE that can't carry the permission details; see the code stanza toward
- * the end of ApplyRetrieveRule() for how that's done.
- */
- viewParse->rteperminfos = lcons(rte_perminfo1, viewParse->rteperminfos);
- foreach(lc, viewParse->rtable)
- {
- RangeTblEntry *rte = lfirst(lc);
-
- if (rte->perminfoindex > 0)
- rte->perminfoindex += 1;
- }
-
- /*
- * Also make the "new" RTE's RTEPermissionInfo undiscoverable. This is a
- * bit of a hack given that all the non-child RTE_RELATION entries really
- * should have a RTEPermissionInfo, but this dummy "new" RTE is going to
- * go away anyway in the very near future.
- */
- rt_entry2->perminfoindex = 0;
-
- new_rt = lcons(rt_entry1, lcons(rt_entry2, viewParse->rtable));
-
- viewParse->rtable = new_rt;
-
- /*
- * Now offset all var nodes by 2, and jointree RT indexes too.
- */
- OffsetVarNodes((Node *) viewParse, 2, 0);
-
- relation_close(viewRel, AccessShareLock);
-
- return viewParse;
-}
-
/*
* DefineView
* Execute a CREATE VIEW command.
@@ -616,12 +515,6 @@ DefineView(ViewStmt *stmt, const char *queryString,
void
StoreViewQuery(Oid viewOid, Query *viewParse, bool replace)
{
- /*
- * The range table of 'viewParse' does not contain entries for the "OLD"
- * and "NEW" relations. So... add them!
- */
- viewParse = UpdateRangeTableOfViewParse(viewOid, viewParse);
-
/*
* Now create the rules associated with the view.
*/
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index 9f3afe965a..3eaa62df4a 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -634,12 +634,10 @@ checkRuleResultList(List *targetList, TupleDesc resultDesc, bool isSelect,
* Recursively scan a query or expression tree and set the checkAsUser
* field to the given userid in all RTEPermissionInfos of the query.
*
- * Note: for a view (ON SELECT rule), the checkAsUser field of the OLD
- * RTE entry's RTEPermissionInfo will be overridden when the view rule is
- * expanded, and the checkAsUser for the NEW RTE entry's RTEPermissionInfo is
- * irrelevant because its requiredPerms bits will always be zero. However, for
- * other types of rules it's important to set these fields to match the rule
- * owner. So we just set them always.
+ * Note: for a view (ON SELECT rule), the checkAsUser field of the view RTE's
+ * RTEPermissionInfo will be overridden when the view rule is expanded; see
+ * ApplyRetrieveRule(). However, for other types of rules it's important to
+ * set these fields to match the rule owner. So we just set them always.
*/
void
setRuleCheckAsUser(Node *node, Oid userid)
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index 7cf0ceacc3..46d5d96d9d 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -1757,9 +1757,9 @@ ApplyRetrieveRule(Query *parsetree,
Query *rule_action;
RangeTblEntry *rte,
*subrte;
- RTEPermissionInfo *perminfo,
- *sub_perminfo;
+ RTEPermissionInfo *perminfo;
RowMarkClause *rc;
+ ListCell *lc;
if (list_length(rule->actions) != 1)
elog(ERROR, "expected just one rule action");
@@ -1868,10 +1868,46 @@ ApplyRetrieveRule(Query *parsetree,
/*
* Now, plug the view query in as a subselect, converting the relation's
* original RTE to a subquery RTE.
+ *
+ * Before doing that, move the view's permission check data down into the
+ * view query by adding both a copy of the view relation RTE and of the
+ * corresponding RTEPermissionInfo to the view query's lists. The RTE is
+ * not referenced anywhere in the query but still needed for 1) the
+ * executor to be able to lock the view relation, and 2) the planner to be
+ * able to record the view relation's OID in PlannedStmt.relationOids.
+ *
+ * Add the view relation's RTE and the perminfo such that they each appear
+ * before other RTEs and perminfos, respectively, to ensure that its
+ * permissions are checked before those of others.
*/
rte = rt_fetch(rt_index, parsetree->rtable);
perminfo = getRTEPermissionInfo(parsetree->rteperminfos, rte);
+ /*
+ * Must adjust varnos of the view query to account for the existing RTE's
+ * indexes increasing by 1 due to view relation RTE's addition.
+ */
+ OffsetVarNodes((Node *) rule_action, 1, 0);
+
+ /* Also their perminfoindexes. */
+ foreach(lc, rule_action->rtable)
+ {
+ RangeTblEntry *action_rte = lfirst(lc);
+
+ if (action_rte->perminfoindex > 0)
+ action_rte->perminfoindex += 1;
+ }
+ subrte = copyObject(rte);
+ rule_action->rtable = lcons(subrte, rule_action->rtable);
+ rule_action->rteperminfos = lcons(copyObject(perminfo),
+ rule_action->rteperminfos);
+ /*
+ * Finally, adjust the view relation's RTE in the view query to point to
+ * the just added perminfo.
+ */
+ subrte->perminfoindex = 1;
+
+ /* Free to convert the original RTE into a subselect. */
rte->rtekind = RTE_SUBQUERY;
rte->subquery = rule_action;
rte->security_barrier = RelationIsSecurityView(relation);
@@ -1880,23 +1916,9 @@ ApplyRetrieveRule(Query *parsetree,
rte->relkind = 0;
rte->rellockmode = 0;
rte->tablesample = NULL;
- rte->perminfoindex = 0; /* no permission checking for this RTE */
+ rte->perminfoindex = 0; /* should no longer point to any perminfo! */
rte->inh = false; /* must not be set for a subquery */
- /*
- * We move the view's permission check data down to its RTEPermissionInfo
- * contained in the view query, which the OLD entry in its range table
- * points to.
- */
- subrte = rt_fetch(PRS2_OLD_VARNO, rule_action->rtable);
- Assert(subrte->relid == relation->rd_id);
- sub_perminfo = getRTEPermissionInfo(rule_action->rteperminfos, subrte);
- sub_perminfo->requiredPerms = perminfo->requiredPerms;
- sub_perminfo->checkAsUser = perminfo->checkAsUser;
- sub_perminfo->selectedCols = perminfo->selectedCols;
- sub_perminfo->insertedCols = perminfo->insertedCols;
- sub_perminfo->updatedCols = perminfo->updatedCols;
-
return parsetree;
}
@@ -1907,9 +1929,6 @@ ApplyRetrieveRule(Query *parsetree,
* aggregate. We leave it to the planner to detect that.
*
* NB: this must agree with the parser's transformLockingClause() routine.
- * However, unlike the parser we have to be careful not to mark a view's
- * OLD and NEW rels for updating. The best way to handle that seems to be
- * to scan the jointree to determine which rels are used.
*/
static void
markQueryForLocking(Query *qry, Node *jtnode,
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 6656222363..518a885610 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -2280,7 +2280,7 @@ my %tests = (
SELECT col1 FROM dump_test.test_table;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview AS\E
- \n\s+\QSELECT test_table.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2296,7 +2296,7 @@ my %tests = (
SELECT * FROM dump_test.matview;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_second AS\E
- \n\s+\QSELECT matview.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2312,7 +2312,7 @@ my %tests = (
SELECT * FROM dump_test.matview_second WITH NO DATA;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_third AS\E
- \n\s+\QSELECT matview_second.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview_second\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2328,7 +2328,7 @@ my %tests = (
SELECT * FROM dump_test.matview_third WITH NO DATA;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_fourth AS\E
- \n\s+\QSELECT matview_third.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview_third\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2346,7 +2346,7 @@ my %tests = (
ALTER COLUMN col2 SET COMPRESSION lz4;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_compression AS\E
- \n\s+\QSELECT test_table.col2\E
+ \n\s+\QSELECT col2\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH NO DATA;\E
.*
@@ -3342,7 +3342,7 @@ my %tests = (
SELECT col1 FROM dump_test.test_table;',
regexp => qr/^
\QCREATE VIEW dump_test.test_view WITH (security_barrier='true') AS\E
- \n\s+\QSELECT test_table.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH LOCAL CHECK OPTION;\E/xm,
like =>
diff --git a/src/test/regress/expected/aggregates.out b/src/test/regress/expected/aggregates.out
index fc2bd40be2..564a7ba1aa 100644
--- a/src/test/regress/expected/aggregates.out
+++ b/src/test/regress/expected/aggregates.out
@@ -1623,7 +1623,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.b, v.c) AS aggfns +
+ SELECT aggfns(a, b, c) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -1675,7 +1675,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.b, v.c ORDER BY (v.b + 1)) AS aggfns +
+ SELECT aggfns(a, b, c ORDER BY (b + 1)) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -1691,7 +1691,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.a, v.c ORDER BY v.b) AS aggfns +
+ SELECT aggfns(a, a, c ORDER BY b) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -1707,7 +1707,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.b, v.c ORDER BY v.c USING ~<~ NULLS LAST) AS aggfns +
+ SELECT aggfns(a, b, c ORDER BY c USING ~<~ NULLS LAST) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -2192,15 +2192,15 @@ select ten,
from tenk1
group by ten order by ten;
select pg_get_viewdef('aggordview1');
- pg_get_viewdef
--------------------------------------------------------------------------------------------------------------------------------
- SELECT tenk1.ten, +
- percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY tenk1.thousand) AS p50, +
- percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY tenk1.thousand) FILTER (WHERE (tenk1.hundred = 1)) AS px,+
- rank(5, 'AZZZZ'::name, 50) WITHIN GROUP (ORDER BY tenk1.hundred, tenk1.string4 DESC, tenk1.hundred) AS rank +
- FROM tenk1 +
- GROUP BY tenk1.ten +
- ORDER BY tenk1.ten;
+ pg_get_viewdef
+-------------------------------------------------------------------------------------------------------------------
+ SELECT ten, +
+ percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY thousand) AS p50, +
+ percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY thousand) FILTER (WHERE (hundred = 1)) AS px,+
+ rank(5, 'AZZZZ'::name, 50) WITHIN GROUP (ORDER BY hundred, string4 DESC, hundred) AS rank +
+ FROM tenk1 +
+ GROUP BY ten +
+ ORDER BY ten;
(1 row)
select * from aggordview1 order by ten;
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 600e603bdf..9e5f6c1a80 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -2493,8 +2493,8 @@ create view at_view_2 as select *, to_json(v1) as j from at_view_1 v1;
id | integer | | | | plain |
stuff | text | | | | extended |
View definition:
- SELECT bt.id,
- bt.stuff
+ SELECT id,
+ stuff
FROM at_base_table bt;
\d+ at_view_2
@@ -2505,8 +2505,8 @@ View definition:
stuff | text | | | | extended |
j | json | | | | extended |
View definition:
- SELECT v1.id,
- v1.stuff,
+ SELECT id,
+ stuff,
to_json(v1.*) AS j
FROM at_view_1 v1;
@@ -2532,8 +2532,8 @@ create or replace view at_view_1 as select *, 2+2 as more from at_base_table bt;
stuff | text | | | | extended |
more | integer | | | | plain |
View definition:
- SELECT bt.id,
- bt.stuff,
+ SELECT id,
+ stuff,
2 + 2 AS more
FROM at_base_table bt;
@@ -2545,8 +2545,8 @@ View definition:
stuff | text | | | | extended |
j | json | | | | extended |
View definition:
- SELECT v1.id,
- v1.stuff,
+ SELECT id,
+ stuff,
to_json(v1.*) AS j
FROM at_view_1 v1;
diff --git a/src/test/regress/expected/collate.icu.utf8.out b/src/test/regress/expected/collate.icu.utf8.out
index d4c8c6de38..4354dc07b8 100644
--- a/src/test/regress/expected/collate.icu.utf8.out
+++ b/src/test/regress/expected/collate.icu.utf8.out
@@ -446,18 +446,18 @@ CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10;
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name | view_definition
-------------+--------------------------------------------------------------------------
- collview1 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | ORDER BY (collate_test1.b COLLATE "C");
- collview3 | SELECT collate_test10.a, +
- | lower(((collate_test10.x || collate_test10.x) COLLATE "C")) AS lower+
+ table_name | view_definition
+------------+--------------------------------------------
+ collview1 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | WHERE ((b COLLATE "C") >= 'bbc'::text);
+ collview2 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | ORDER BY (b COLLATE "C");
+ collview3 | SELECT a, +
+ | lower(((x || x) COLLATE "C")) AS lower+
| FROM collate_test10;
(3 rows)
diff --git a/src/test/regress/expected/collate.linux.utf8.out b/src/test/regress/expected/collate.linux.utf8.out
index f2d0eb94f2..2098696ec2 100644
--- a/src/test/regress/expected/collate.linux.utf8.out
+++ b/src/test/regress/expected/collate.linux.utf8.out
@@ -483,18 +483,18 @@ CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10;
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name | view_definition
-------------+--------------------------------------------------------------------------
- collview1 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | ORDER BY (collate_test1.b COLLATE "C");
- collview3 | SELECT collate_test10.a, +
- | lower(((collate_test10.x || collate_test10.x) COLLATE "C")) AS lower+
+ table_name | view_definition
+------------+--------------------------------------------
+ collview1 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | WHERE ((b COLLATE "C") >= 'bbc'::text);
+ collview2 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | ORDER BY (b COLLATE "C");
+ collview3 | SELECT a, +
+ | lower(((x || x) COLLATE "C")) AS lower+
| FROM collate_test10;
(3 rows)
diff --git a/src/test/regress/expected/collate.out b/src/test/regress/expected/collate.out
index 246832575c..0649564485 100644
--- a/src/test/regress/expected/collate.out
+++ b/src/test/regress/expected/collate.out
@@ -194,18 +194,18 @@ CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "POSIX") FROM collate_test10;
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name | view_definition
-------------+------------------------------------------------------------------------------
- collview1 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | ORDER BY (collate_test1.b COLLATE "C");
- collview3 | SELECT collate_test10.a, +
- | lower(((collate_test10.x || collate_test10.x) COLLATE "POSIX")) AS lower+
+ table_name | view_definition
+------------+------------------------------------------------
+ collview1 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | WHERE ((b COLLATE "C") >= 'bbc'::text);
+ collview2 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | ORDER BY (b COLLATE "C");
+ collview3 | SELECT a, +
+ | lower(((x || x) COLLATE "POSIX")) AS lower+
| FROM collate_test10;
(3 rows)
@@ -698,7 +698,7 @@ SELECT c1+1 AS c1p FROM
--------+---------+-----------+----------+---------+---------+-------------
c1p | integer | | | | plain |
View definition:
- SELECT ss.c1 + 1 AS c1p
+ SELECT c1 + 1 AS c1p
FROM ( SELECT 4 AS c1) ss;
-- Check conflicting or redundant options in CREATE COLLATION
diff --git a/src/test/regress/expected/compression.out b/src/test/regress/expected/compression.out
index 4c997e2602..e06ac93a36 100644
--- a/src/test/regress/expected/compression.out
+++ b/src/test/regress/expected/compression.out
@@ -187,7 +187,7 @@ CREATE MATERIALIZED VIEW compressmv(x) AS SELECT * FROM cmdata1;
--------+------+-----------+----------+---------+----------+-------------+--------------+-------------
x | text | | | | extended | | |
View definition:
- SELECT cmdata1.f1 AS x
+ SELECT f1 AS x
FROM cmdata1;
SELECT pg_column_compression(f1) FROM cmdata1;
@@ -274,7 +274,7 @@ ALTER MATERIALIZED VIEW compressmv ALTER COLUMN x SET COMPRESSION lz4;
--------+------+-----------+----------+---------+----------+-------------+--------------+-------------
x | text | | | | extended | lz4 | |
View definition:
- SELECT cmdata1.f1 AS x
+ SELECT f1 AS x
FROM cmdata1;
-- test alter compression method for partitioned tables
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out
index 17ca29ddbf..61825ef7d4 100644
--- a/src/test/regress/expected/create_view.out
+++ b/src/test/regress/expected/create_view.out
@@ -395,10 +395,10 @@ CREATE VIEW tt1 AS
c | numeric | | | | main |
d | character varying(4) | | | | extended |
View definition:
- SELECT vv.a,
- vv.b,
- vv.c,
- vv.d
+ SELECT a,
+ b,
+ c,
+ d
FROM ( VALUES ('abc'::character varying(3),'0123456789'::character varying,42,'abcd'::character varying(4)), ('0123456789'::character varying,'abc'::character varying(3),42.12,'abc'::character varying(4))) vv(a, b, c, d);
SELECT * FROM tt1;
@@ -440,9 +440,9 @@ CREATE VIEW aliased_view_4 AS
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM tx1
@@ -456,9 +456,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1 a1
WHERE (EXISTS ( SELECT 1
FROM tx1
@@ -472,9 +472,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM tx1 a2
@@ -488,9 +488,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM tt1 tt1_1
@@ -505,9 +505,9 @@ ALTER TABLE tx1 RENAME TO a1;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM a1
@@ -521,9 +521,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1 a1
WHERE (EXISTS ( SELECT 1
FROM a1 a1_1
@@ -537,9 +537,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM a1 a2
@@ -553,9 +553,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM tt1 tt1_1
@@ -570,9 +570,9 @@ ALTER TABLE tt1 RENAME TO a2;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM a1
@@ -586,9 +586,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2 a1
WHERE (EXISTS ( SELECT 1
FROM a1 a1_1
@@ -602,9 +602,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM a1 a2_1
@@ -618,9 +618,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM a2
@@ -635,9 +635,9 @@ ALTER TABLE a1 RENAME TO tt1;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -651,9 +651,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2 a1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -667,9 +667,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM tt1 a2_1
@@ -683,9 +683,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM a2
@@ -701,9 +701,9 @@ ALTER TABLE tx1 SET SCHEMA temp_view_test;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -717,9 +717,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1 a1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -733,9 +733,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1 a2
@@ -749,9 +749,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM temp_view_test.tx1
@@ -768,9 +768,9 @@ ALTER TABLE tmp1 RENAME TO tx1;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -784,9 +784,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1 a1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -800,9 +800,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1 a2
@@ -816,9 +816,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.y1,
- tx1.f2,
- tx1.f3
+ SELECT y1,
+ f2,
+ f3
FROM tx1
WHERE (EXISTS ( SELECT 1
FROM temp_view_test.tx1 tx1_1
@@ -1305,10 +1305,10 @@ select pg_get_viewdef('v1', true);
select pg_get_viewdef('v4', true);
pg_get_viewdef
----------------
- SELECT v1.b, +
- v1.c, +
- v1.x AS a,+
- v1.ax +
+ SELECT b, +
+ c, +
+ x AS a, +
+ ax +
FROM v1;
(1 row)
@@ -1585,9 +1585,9 @@ create view tt14v as select t.* from tt14f() t;
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
--------------------------------
- SELECT t.f1, +
- t.f3, +
- t.f4 +
+ SELECT f1, +
+ f3, +
+ f4 +
FROM tt14f() t(f1, f3, f4);
(1 row)
@@ -1623,11 +1623,11 @@ returning pg_describe_object(classid, objid, objsubid) as obj,
alter table tt14t drop column f3;
-- column f3 is still in the view, sort of ...
select pg_get_viewdef('tt14v', true);
- pg_get_viewdef
----------------------------------
- SELECT t.f1, +
- t."?dropped?column?" AS f3,+
- t.f4 +
+ pg_get_viewdef
+-------------------------------
+ SELECT f1, +
+ "?dropped?column?" AS f3,+
+ f4 +
FROM tt14f() t(f1, f4);
(1 row)
@@ -1675,9 +1675,9 @@ alter table tt14t alter column f4 type integer using f4::integer;
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
--------------------------------
- SELECT t.f1, +
- t.f3, +
- t.f4 +
+ SELECT f1, +
+ f3, +
+ f4 +
FROM tt14f() t(f1, f3, f4);
(1 row)
@@ -1697,8 +1697,8 @@ create view tt14v as select t.f1, t.f4 from tt14f() t;
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
--------------------------------
- SELECT t.f1, +
- t.f4 +
+ SELECT f1, +
+ f4 +
FROM tt14f() t(f1, f3, f4);
(1 row)
@@ -1712,8 +1712,8 @@ alter table tt14t drop column f3; -- ok
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
----------------------------
- SELECT t.f1, +
- t.f4 +
+ SELECT f1, +
+ f4 +
FROM tt14f() t(f1, f4);
(1 row)
@@ -1806,8 +1806,8 @@ select * from tt17v;
select pg_get_viewdef('tt17v', true);
pg_get_viewdef
---------------------------------------------
- SELECT i.q1, +
- i.q2 +
+ SELECT q1, +
+ q2 +
FROM int8_tbl i +
WHERE (i.* IN ( VALUES (i.*::int8_tbl)));
(1 row)
@@ -2134,7 +2134,7 @@ select pg_get_viewdef('tt25v', true);
WITH cte AS MATERIALIZED ( +
SELECT pg_get_keywords() AS k+
) +
- SELECT (cte.k).word AS word +
+ SELECT (k).word AS word +
FROM cte;
(1 row)
@@ -2186,19 +2186,19 @@ select x + y + z as c1,
(x,y) <= ANY (values(1,2),(3,4)) as c11
from (values(1,2,3)) v(x,y,z);
select pg_get_viewdef('tt26v', true);
- pg_get_viewdef
---------------------------------------------------------
- SELECT v.x + v.y + v.z AS c1, +
- v.x * v.y + v.z AS c2, +
- v.x + v.y * v.z AS c3, +
- (v.x + v.y) * v.z AS c4, +
- v.x * (v.y + v.z) AS c5, +
- v.x + (v.y + v.z) AS c6, +
- v.x + (v.y # v.z) AS c7, +
- v.x > v.y AND (v.y > v.z OR v.x > v.z) AS c8, +
- v.x > v.y OR v.y > v.z AND NOT v.x > v.z AS c9, +
- ((v.x, v.y) <> ALL ( VALUES (1,2), (3,4))) AS c10,+
- ((v.x, v.y) <= ANY ( VALUES (1,2), (3,4))) AS c11 +
+ pg_get_viewdef
+----------------------------------------------------
+ SELECT x + y + z AS c1, +
+ x * y + z AS c2, +
+ x + y * z AS c3, +
+ (x + y) * z AS c4, +
+ x * (y + z) AS c5, +
+ x + (y + z) AS c6, +
+ x + (y # z) AS c7, +
+ x > y AND (y > z OR x > z) AS c8, +
+ x > y OR y > z AND NOT x > z AS c9, +
+ ((x, y) <> ALL ( VALUES (1,2), (3,4))) AS c10,+
+ ((x, y) <= ANY ( VALUES (1,2), (3,4))) AS c11 +
FROM ( VALUES (1,2,3)) v(x, y, z);
(1 row)
diff --git a/src/test/regress/expected/expressions.out b/src/test/regress/expected/expressions.out
index 28a20900f1..7c599fd27b 100644
--- a/src/test/regress/expected/expressions.out
+++ b/src/test/regress/expected/expressions.out
@@ -108,12 +108,12 @@ create view numeric_view as
f2164 | numeric(16,4) | | | | main |
f2n | numeric | | | | main |
View definition:
- SELECT numeric_tbl.f1,
- numeric_tbl.f1::numeric(16,4) AS f1164,
- numeric_tbl.f1::numeric AS f1n,
- numeric_tbl.f2,
- numeric_tbl.f2::numeric(16,4) AS f2164,
- numeric_tbl.f2 AS f2n
+ SELECT f1,
+ f1::numeric(16,4) AS f1164,
+ f1::numeric AS f1n,
+ f2,
+ f2::numeric(16,4) AS f2164,
+ f2 AS f2n
FROM numeric_tbl;
explain (verbose, costs off) select * from numeric_view;
@@ -142,12 +142,12 @@ create view bpchar_view as
f214 | character(14) | | | | extended |
f2n | bpchar | | | | extended |
View definition:
- SELECT bpchar_tbl.f1,
- bpchar_tbl.f1::character(14) AS f114,
- bpchar_tbl.f1::bpchar AS f1n,
- bpchar_tbl.f2,
- bpchar_tbl.f2::character(14) AS f214,
- bpchar_tbl.f2 AS f2n
+ SELECT f1,
+ f1::character(14) AS f114,
+ f1::bpchar AS f1n,
+ f2,
+ f2::character(14) AS f214,
+ f2 AS f2n
FROM bpchar_tbl;
explain (verbose, costs off) select * from bpchar_view
diff --git a/src/test/regress/expected/groupingsets.out b/src/test/regress/expected/groupingsets.out
index fcad5c4093..8e75bfe92a 100644
--- a/src/test/regress/expected/groupingsets.out
+++ b/src/test/regress/expected/groupingsets.out
@@ -570,16 +570,16 @@ CREATE VIEW gstest_view AS select a, b, grouping(a,b), sum(c), count(*), max(c)
from gstest2 group by rollup ((a,b,c),(c,d));
NOTICE: view "gstest_view" will be a temporary view
select pg_get_viewdef('gstest_view'::regclass, true);
- pg_get_viewdef
--------------------------------------------------------------------------------
- SELECT gstest2.a, +
- gstest2.b, +
- GROUPING(gstest2.a, gstest2.b) AS "grouping", +
- sum(gstest2.c) AS sum, +
- count(*) AS count, +
- max(gstest2.c) AS max +
- FROM gstest2 +
- GROUP BY ROLLUP((gstest2.a, gstest2.b, gstest2.c), (gstest2.c, gstest2.d));
+ pg_get_viewdef
+---------------------------------------
+ SELECT a, +
+ b, +
+ GROUPING(a, b) AS "grouping", +
+ sum(c) AS sum, +
+ count(*) AS count, +
+ max(c) AS max +
+ FROM gstest2 +
+ GROUP BY ROLLUP((a, b, c), (c, d));
(1 row)
-- Nested queries with 3 or more levels of nesting
diff --git a/src/test/regress/expected/limit.out b/src/test/regress/expected/limit.out
index 8a98bbea8e..a2cd0f9f5b 100644
--- a/src/test/regress/expected/limit.out
+++ b/src/test/regress/expected/limit.out
@@ -638,10 +638,10 @@ CREATE VIEW limit_thousand_v_1 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
OFFSET 10
FETCH FIRST 5 ROWS WITH TIES;
@@ -653,10 +653,10 @@ CREATE VIEW limit_thousand_v_2 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
OFFSET 10
LIMIT 5;
@@ -671,10 +671,10 @@ CREATE VIEW limit_thousand_v_3 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
FETCH FIRST (NULL::integer + 1) ROWS WITH TIES;
CREATE VIEW limit_thousand_v_4 AS SELECT thousand FROM onek WHERE thousand < 995
@@ -685,10 +685,10 @@ CREATE VIEW limit_thousand_v_4 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
LIMIT ALL;
-- leave these views
diff --git a/src/test/regress/expected/matview.out b/src/test/regress/expected/matview.out
index c109d97635..87b6e569a5 100644
--- a/src/test/regress/expected/matview.out
+++ b/src/test/regress/expected/matview.out
@@ -100,10 +100,10 @@ CREATE INDEX mvtest_aa ON mvtest_bb (grandtot);
type | text | | | | extended | |
totamt | numeric | | | | main | |
View definition:
- SELECT mvtest_tv.type,
- mvtest_tv.totamt
+ SELECT type,
+ totamt
FROM mvtest_tv
- ORDER BY mvtest_tv.type;
+ ORDER BY type;
\d+ mvtest_tvm
Materialized view "public.mvtest_tvm"
@@ -112,10 +112,10 @@ View definition:
type | text | | | | extended | |
totamt | numeric | | | | main | |
View definition:
- SELECT mvtest_tv.type,
- mvtest_tv.totamt
+ SELECT type,
+ totamt
FROM mvtest_tv
- ORDER BY mvtest_tv.type;
+ ORDER BY type;
\d+ mvtest_tvvm
Materialized view "public.mvtest_tvvm"
@@ -123,7 +123,7 @@ View definition:
----------+---------+-----------+----------+---------+---------+--------------+-------------
grandtot | numeric | | | | main | |
View definition:
- SELECT mvtest_tvv.grandtot
+ SELECT grandtot
FROM mvtest_tvv;
\d+ mvtest_bb
@@ -134,7 +134,7 @@ View definition:
Indexes:
"mvtest_aa" btree (grandtot)
View definition:
- SELECT mvtest_tvvmv.grandtot
+ SELECT grandtot
FROM mvtest_tvvmv;
-- test schema behavior
@@ -150,7 +150,7 @@ Indexes:
"mvtest_tvmm_expr" UNIQUE, btree ((grandtot > 0::numeric))
"mvtest_tvmm_pred" UNIQUE, btree (grandtot) WHERE grandtot < 0::numeric
View definition:
- SELECT sum(mvtest_tvm.totamt) AS grandtot
+ SELECT sum(totamt) AS grandtot
FROM mvtest_mvschema.mvtest_tvm;
SET search_path = mvtest_mvschema, public;
@@ -161,10 +161,10 @@ SET search_path = mvtest_mvschema, public;
type | text | | | | extended | |
totamt | numeric | | | | main | |
View definition:
- SELECT mvtest_tv.type,
- mvtest_tv.totamt
+ SELECT type,
+ totamt
FROM mvtest_tv
- ORDER BY mvtest_tv.type;
+ ORDER BY type;
-- modify the underlying table data
INSERT INTO mvtest_t VALUES (6, 'z', 13);
diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out
index 1cd558d668..bf08e40ed8 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -1801,10 +1801,10 @@ select * from dfview;
c3 | bigint | | | | plain |
c4 | bigint | | | | plain |
View definition:
- SELECT int8_tbl.q1,
- int8_tbl.q2,
- dfunc(int8_tbl.q1, int8_tbl.q2, flag => int8_tbl.q1 > int8_tbl.q2) AS c3,
- dfunc(int8_tbl.q1, flag => int8_tbl.q1 < int8_tbl.q2, b => int8_tbl.q2) AS c4
+ SELECT q1,
+ q2,
+ dfunc(q1, q2, flag => q1 > q2) AS c3,
+ dfunc(q1, flag => q1 < q2, b => q2) AS c4
FROM int8_tbl;
drop view dfview;
diff --git a/src/test/regress/expected/rangefuncs.out b/src/test/regress/expected/rangefuncs.out
index e2e62db6a2..fbb840e848 100644
--- a/src/test/regress/expected/rangefuncs.out
+++ b/src/test/regress/expected/rangefuncs.out
@@ -149,9 +149,9 @@ select * from vw_ord;
select definition from pg_views where viewname='vw_ord';
definition
----------------------------------------------------------------------------------------
- SELECT z.a, +
- z.b, +
- z.c +
+ SELECT a, +
+ b, +
+ c +
FROM UNNEST(ARRAY[10, 20], ARRAY['foo'::text, 'bar'::text], ARRAY[1.0]) z(a, b, c);
(1 row)
@@ -167,9 +167,9 @@ select * from vw_ord;
select definition from pg_views where viewname='vw_ord';
definition
----------------------------------------------------------------------------------------
- SELECT z.a, +
- z.b, +
- z.c +
+ SELECT a, +
+ b, +
+ c +
FROM UNNEST(ARRAY[10, 20], ARRAY['foo'::text, 'bar'::text], ARRAY[1.0]) z(a, b, c);
(1 row)
@@ -185,9 +185,9 @@ select * from vw_ord;
select definition from pg_views where viewname='vw_ord';
definition
----------------------------------------------------------------------------------------------------------------------
- SELECT z.a, +
- z.b, +
- z.c +
+ SELECT a, +
+ b, +
+ c +
FROM ROWS FROM(unnest(ARRAY[10, 20]), unnest(ARRAY['foo'::text, 'bar'::text]), generate_series(1, 2)) z(a, b, c);
(1 row)
@@ -669,14 +669,14 @@ select * from vw_rngfunc;
select pg_get_viewdef('vw_rngfunc');
pg_get_viewdef
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- SELECT t1.a, +
- t1.b, +
- t1.c, +
- t1.d, +
- t1.e, +
- t1.f, +
- t1.g, +
- t1.n +
+ SELECT a, +
+ b, +
+ c, +
+ d, +
+ e, +
+ f, +
+ g, +
+ n +
FROM ROWS FROM(getrngfunc9(1), getrngfunc7(1) AS (rngfuncid integer, rngfuncsubid integer, rngfuncname text), getrngfunc1(1)) WITH ORDINALITY t1(a, b, c, d, e, f, g, n);
(1 row)
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index fb9f936d43..6a21ce90ac 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -1303,60 +1303,60 @@ pg_available_extensions| SELECT e.name,
e.comment
FROM (pg_available_extensions() e(name, default_version, comment)
LEFT JOIN pg_extension x ON ((e.name = x.extname)));
-pg_backend_memory_contexts| SELECT pg_get_backend_memory_contexts.name,
- pg_get_backend_memory_contexts.ident,
- pg_get_backend_memory_contexts.parent,
- pg_get_backend_memory_contexts.level,
- pg_get_backend_memory_contexts.total_bytes,
- pg_get_backend_memory_contexts.total_nblocks,
- pg_get_backend_memory_contexts.free_bytes,
- pg_get_backend_memory_contexts.free_chunks,
- pg_get_backend_memory_contexts.used_bytes
+pg_backend_memory_contexts| SELECT name,
+ ident,
+ parent,
+ level,
+ total_bytes,
+ total_nblocks,
+ free_bytes,
+ free_chunks,
+ used_bytes
FROM pg_get_backend_memory_contexts() pg_get_backend_memory_contexts(name, ident, parent, level, total_bytes, total_nblocks, free_bytes, free_chunks, used_bytes);
-pg_config| SELECT pg_config.name,
- pg_config.setting
+pg_config| SELECT name,
+ setting
FROM pg_config() pg_config(name, setting);
-pg_cursors| SELECT c.name,
- c.statement,
- c.is_holdable,
- c.is_binary,
- c.is_scrollable,
- c.creation_time
+pg_cursors| SELECT name,
+ statement,
+ is_holdable,
+ is_binary,
+ is_scrollable,
+ creation_time
FROM pg_cursor() c(name, statement, is_holdable, is_binary, is_scrollable, creation_time);
-pg_file_settings| SELECT a.sourcefile,
- a.sourceline,
- a.seqno,
- a.name,
- a.setting,
- a.applied,
- a.error
+pg_file_settings| SELECT sourcefile,
+ sourceline,
+ seqno,
+ name,
+ setting,
+ applied,
+ error
FROM pg_show_all_file_settings() a(sourcefile, sourceline, seqno, name, setting, applied, error);
-pg_group| SELECT pg_authid.rolname AS groname,
- pg_authid.oid AS grosysid,
+pg_group| SELECT rolname AS groname,
+ oid AS grosysid,
ARRAY( SELECT pg_auth_members.member
FROM pg_auth_members
WHERE (pg_auth_members.roleid = pg_authid.oid)) AS grolist
FROM pg_authid
- WHERE (NOT pg_authid.rolcanlogin);
-pg_hba_file_rules| SELECT a.rule_number,
- a.file_name,
- a.line_number,
- a.type,
- a.database,
- a.user_name,
- a.address,
- a.netmask,
- a.auth_method,
- a.options,
- a.error
+ WHERE (NOT rolcanlogin);
+pg_hba_file_rules| SELECT rule_number,
+ file_name,
+ line_number,
+ type,
+ database,
+ user_name,
+ address,
+ netmask,
+ auth_method,
+ options,
+ error
FROM pg_hba_file_rules() a(rule_number, file_name, line_number, type, database, user_name, address, netmask, auth_method, options, error);
-pg_ident_file_mappings| SELECT a.map_number,
- a.file_name,
- a.line_number,
- a.map_name,
- a.sys_name,
- a.pg_username,
- a.error
+pg_ident_file_mappings| SELECT map_number,
+ file_name,
+ line_number,
+ map_name,
+ sys_name,
+ pg_username,
+ error
FROM pg_ident_file_mappings() a(map_number, file_name, line_number, map_name, sys_name, pg_username, error);
pg_indexes| SELECT n.nspname AS schemaname,
c.relname AS tablename,
@@ -1369,22 +1369,22 @@ pg_indexes| SELECT n.nspname AS schemaname,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
LEFT JOIN pg_tablespace t ON ((t.oid = i.reltablespace)))
WHERE ((c.relkind = ANY (ARRAY['r'::"char", 'm'::"char", 'p'::"char"])) AND (i.relkind = ANY (ARRAY['i'::"char", 'I'::"char"])));
-pg_locks| SELECT l.locktype,
- l.database,
- l.relation,
- l.page,
- l.tuple,
- l.virtualxid,
- l.transactionid,
- l.classid,
- l.objid,
- l.objsubid,
- l.virtualtransaction,
- l.pid,
- l.mode,
- l.granted,
- l.fastpath,
- l.waitstart
+pg_locks| SELECT locktype,
+ database,
+ relation,
+ page,
+ tuple,
+ virtualxid,
+ transactionid,
+ classid,
+ objid,
+ objsubid,
+ virtualtransaction,
+ pid,
+ mode,
+ granted,
+ fastpath,
+ waitstart
FROM pg_lock_status() l(locktype, database, relation, page, tuple, virtualxid, transactionid, classid, objid, objsubid, virtualtransaction, pid, mode, granted, fastpath, waitstart);
pg_matviews| SELECT n.nspname AS schemaname,
c.relname AS matviewname,
@@ -1424,14 +1424,14 @@ pg_policies| SELECT n.nspname AS schemaname,
FROM ((pg_policy pol
JOIN pg_class c ON ((c.oid = pol.polrelid)))
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)));
-pg_prepared_statements| SELECT p.name,
- p.statement,
- p.prepare_time,
- p.parameter_types,
- p.result_types,
- p.from_sql,
- p.generic_plans,
- p.custom_plans
+pg_prepared_statements| SELECT name,
+ statement,
+ prepare_time,
+ parameter_types,
+ result_types,
+ from_sql,
+ generic_plans,
+ custom_plans
FROM pg_prepared_statement() p(name, statement, prepare_time, parameter_types, result_types, from_sql, generic_plans, custom_plans);
pg_prepared_xacts| SELECT p.transaction,
p.gid,
@@ -1453,10 +1453,10 @@ pg_publication_tables| SELECT p.pubname,
(pg_class c
JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.oid = gpt.relid);
-pg_replication_origin_status| SELECT pg_show_replication_origin_status.local_id,
- pg_show_replication_origin_status.external_id,
- pg_show_replication_origin_status.remote_lsn,
- pg_show_replication_origin_status.local_lsn
+pg_replication_origin_status| SELECT local_id,
+ external_id,
+ remote_lsn,
+ local_lsn
FROM pg_show_replication_origin_status() pg_show_replication_origin_status(local_id, external_id, remote_lsn, local_lsn);
pg_replication_slots| SELECT l.slot_name,
l.plugin,
@@ -1702,23 +1702,23 @@ pg_sequences| SELECT n.nspname AS schemaname,
JOIN pg_class c ON ((c.oid = s.seqrelid)))
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE ((NOT pg_is_other_temp_schema(n.oid)) AND (c.relkind = 'S'::"char"));
-pg_settings| SELECT a.name,
- a.setting,
- a.unit,
- a.category,
- a.short_desc,
- a.extra_desc,
- a.context,
- a.vartype,
- a.source,
- a.min_val,
- a.max_val,
- a.enumvals,
- a.boot_val,
- a.reset_val,
- a.sourcefile,
- a.sourceline,
- a.pending_restart
+pg_settings| SELECT name,
+ setting,
+ unit,
+ category,
+ short_desc,
+ extra_desc,
+ context,
+ vartype,
+ source,
+ min_val,
+ max_val,
+ enumvals,
+ boot_val,
+ reset_val,
+ sourcefile,
+ sourceline,
+ pending_restart
FROM pg_show_all_settings() a(name, setting, unit, category, short_desc, extra_desc, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, sourcefile, sourceline, pending_restart);
pg_shadow| SELECT pg_authid.rolname AS usename,
pg_authid.oid AS usesysid,
@@ -1732,10 +1732,10 @@ pg_shadow| SELECT pg_authid.rolname AS usename,
FROM (pg_authid
LEFT JOIN pg_db_role_setting s ON (((pg_authid.oid = s.setrole) AND (s.setdatabase = (0)::oid))))
WHERE pg_authid.rolcanlogin;
-pg_shmem_allocations| SELECT pg_get_shmem_allocations.name,
- pg_get_shmem_allocations.off,
- pg_get_shmem_allocations.size,
- pg_get_shmem_allocations.allocated_size
+pg_shmem_allocations| SELECT name,
+ off,
+ size,
+ allocated_size
FROM pg_get_shmem_allocations() pg_get_shmem_allocations(name, off, size, allocated_size);
pg_stat_activity| SELECT s.datid,
d.datname,
@@ -1806,13 +1806,13 @@ pg_stat_all_tables| SELECT c.oid AS relid,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char", 'p'::"char"]))
GROUP BY c.oid, n.nspname, c.relname;
-pg_stat_archiver| SELECT s.archived_count,
- s.last_archived_wal,
- s.last_archived_time,
- s.failed_count,
- s.last_failed_wal,
- s.last_failed_time,
- s.stats_reset
+pg_stat_archiver| SELECT archived_count,
+ last_archived_wal,
+ last_archived_time,
+ failed_count,
+ last_failed_wal,
+ last_failed_time,
+ stats_reset
FROM pg_stat_get_archiver() s(archived_count, last_archived_wal, last_archived_time, failed_count, last_failed_wal, last_failed_time, stats_reset);
pg_stat_bgwriter| SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints_timed,
pg_stat_get_bgwriter_requested_checkpoints() AS checkpoints_req,
@@ -1825,57 +1825,57 @@ pg_stat_bgwriter| SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints
pg_stat_get_buf_fsync_backend() AS buffers_backend_fsync,
pg_stat_get_buf_alloc() AS buffers_alloc,
pg_stat_get_bgwriter_stat_reset_time() AS stats_reset;
-pg_stat_database| SELECT d.oid AS datid,
- d.datname,
+pg_stat_database| SELECT oid AS datid,
+ datname,
CASE
- WHEN (d.oid = (0)::oid) THEN 0
- ELSE pg_stat_get_db_numbackends(d.oid)
+ WHEN (oid = (0)::oid) THEN 0
+ ELSE pg_stat_get_db_numbackends(oid)
END AS numbackends,
- pg_stat_get_db_xact_commit(d.oid) AS xact_commit,
- pg_stat_get_db_xact_rollback(d.oid) AS xact_rollback,
- (pg_stat_get_db_blocks_fetched(d.oid) - pg_stat_get_db_blocks_hit(d.oid)) AS blks_read,
- pg_stat_get_db_blocks_hit(d.oid) AS blks_hit,
- pg_stat_get_db_tuples_returned(d.oid) AS tup_returned,
- pg_stat_get_db_tuples_fetched(d.oid) AS tup_fetched,
- pg_stat_get_db_tuples_inserted(d.oid) AS tup_inserted,
- pg_stat_get_db_tuples_updated(d.oid) AS tup_updated,
- pg_stat_get_db_tuples_deleted(d.oid) AS tup_deleted,
- pg_stat_get_db_conflict_all(d.oid) AS conflicts,
- pg_stat_get_db_temp_files(d.oid) AS temp_files,
- pg_stat_get_db_temp_bytes(d.oid) AS temp_bytes,
- pg_stat_get_db_deadlocks(d.oid) AS deadlocks,
- pg_stat_get_db_checksum_failures(d.oid) AS checksum_failures,
- pg_stat_get_db_checksum_last_failure(d.oid) AS checksum_last_failure,
- pg_stat_get_db_blk_read_time(d.oid) AS blk_read_time,
- pg_stat_get_db_blk_write_time(d.oid) AS blk_write_time,
- pg_stat_get_db_session_time(d.oid) AS session_time,
- pg_stat_get_db_active_time(d.oid) AS active_time,
- pg_stat_get_db_idle_in_transaction_time(d.oid) AS idle_in_transaction_time,
- pg_stat_get_db_sessions(d.oid) AS sessions,
- pg_stat_get_db_sessions_abandoned(d.oid) AS sessions_abandoned,
- pg_stat_get_db_sessions_fatal(d.oid) AS sessions_fatal,
- pg_stat_get_db_sessions_killed(d.oid) AS sessions_killed,
- pg_stat_get_db_stat_reset_time(d.oid) AS stats_reset
+ pg_stat_get_db_xact_commit(oid) AS xact_commit,
+ pg_stat_get_db_xact_rollback(oid) AS xact_rollback,
+ (pg_stat_get_db_blocks_fetched(oid) - pg_stat_get_db_blocks_hit(oid)) AS blks_read,
+ pg_stat_get_db_blocks_hit(oid) AS blks_hit,
+ pg_stat_get_db_tuples_returned(oid) AS tup_returned,
+ pg_stat_get_db_tuples_fetched(oid) AS tup_fetched,
+ pg_stat_get_db_tuples_inserted(oid) AS tup_inserted,
+ pg_stat_get_db_tuples_updated(oid) AS tup_updated,
+ pg_stat_get_db_tuples_deleted(oid) AS tup_deleted,
+ pg_stat_get_db_conflict_all(oid) AS conflicts,
+ pg_stat_get_db_temp_files(oid) AS temp_files,
+ pg_stat_get_db_temp_bytes(oid) AS temp_bytes,
+ pg_stat_get_db_deadlocks(oid) AS deadlocks,
+ pg_stat_get_db_checksum_failures(oid) AS checksum_failures,
+ pg_stat_get_db_checksum_last_failure(oid) AS checksum_last_failure,
+ pg_stat_get_db_blk_read_time(oid) AS blk_read_time,
+ pg_stat_get_db_blk_write_time(oid) AS blk_write_time,
+ pg_stat_get_db_session_time(oid) AS session_time,
+ pg_stat_get_db_active_time(oid) AS active_time,
+ pg_stat_get_db_idle_in_transaction_time(oid) AS idle_in_transaction_time,
+ pg_stat_get_db_sessions(oid) AS sessions,
+ pg_stat_get_db_sessions_abandoned(oid) AS sessions_abandoned,
+ pg_stat_get_db_sessions_fatal(oid) AS sessions_fatal,
+ pg_stat_get_db_sessions_killed(oid) AS sessions_killed,
+ pg_stat_get_db_stat_reset_time(oid) AS stats_reset
FROM ( SELECT 0 AS oid,
NULL::name AS datname
UNION ALL
SELECT pg_database.oid,
pg_database.datname
FROM pg_database) d;
-pg_stat_database_conflicts| SELECT d.oid AS datid,
- d.datname,
- pg_stat_get_db_conflict_tablespace(d.oid) AS confl_tablespace,
- pg_stat_get_db_conflict_lock(d.oid) AS confl_lock,
- pg_stat_get_db_conflict_snapshot(d.oid) AS confl_snapshot,
- pg_stat_get_db_conflict_bufferpin(d.oid) AS confl_bufferpin,
- pg_stat_get_db_conflict_startup_deadlock(d.oid) AS confl_deadlock
+pg_stat_database_conflicts| SELECT oid AS datid,
+ datname,
+ pg_stat_get_db_conflict_tablespace(oid) AS confl_tablespace,
+ pg_stat_get_db_conflict_lock(oid) AS confl_lock,
+ pg_stat_get_db_conflict_snapshot(oid) AS confl_snapshot,
+ pg_stat_get_db_conflict_bufferpin(oid) AS confl_bufferpin,
+ pg_stat_get_db_conflict_startup_deadlock(oid) AS confl_deadlock
FROM pg_database d;
-pg_stat_gssapi| SELECT s.pid,
- s.gss_auth AS gss_authenticated,
- s.gss_princ AS principal,
- s.gss_enc AS encrypted
+pg_stat_gssapi| SELECT pid,
+ gss_auth AS gss_authenticated,
+ gss_princ AS principal,
+ gss_enc AS encrypted
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid, query_id)
- WHERE (s.client_port IS NOT NULL);
+ WHERE (client_port IS NOT NULL);
pg_stat_progress_analyze| SELECT s.pid,
s.datid,
d.datname,
@@ -1898,8 +1898,8 @@ pg_stat_progress_analyze| SELECT s.pid,
(s.param8)::oid AS current_child_table_relid
FROM (pg_stat_get_progress_info('ANALYZE'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
LEFT JOIN pg_database d ON ((s.datid = d.oid)));
-pg_stat_progress_basebackup| SELECT s.pid,
- CASE s.param1
+pg_stat_progress_basebackup| SELECT pid,
+ CASE param1
WHEN 0 THEN 'initializing'::text
WHEN 1 THEN 'waiting for checkpoint to finish'::text
WHEN 2 THEN 'estimating backup size'::text
@@ -1908,13 +1908,13 @@ pg_stat_progress_basebackup| SELECT s.pid,
WHEN 5 THEN 'transferring wal files'::text
ELSE NULL::text
END AS phase,
- CASE s.param2
+ CASE param2
WHEN '-1'::integer THEN NULL::bigint
- ELSE s.param2
+ ELSE param2
END AS backup_total,
- s.param3 AS backup_streamed,
- s.param4 AS tablespaces_total,
- s.param5 AS tablespaces_streamed
+ param3 AS backup_streamed,
+ param4 AS tablespaces_total,
+ param5 AS tablespaces_streamed
FROM pg_stat_get_progress_info('BASEBACKUP'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20);
pg_stat_progress_cluster| SELECT s.pid,
s.datid,
@@ -2024,16 +2024,16 @@ pg_stat_progress_vacuum| SELECT s.pid,
s.param7 AS num_dead_tuples
FROM (pg_stat_get_progress_info('VACUUM'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
LEFT JOIN pg_database d ON ((s.datid = d.oid)));
-pg_stat_recovery_prefetch| SELECT s.stats_reset,
- s.prefetch,
- s.hit,
- s.skip_init,
- s.skip_new,
- s.skip_fpw,
- s.skip_rep,
- s.wal_distance,
- s.block_distance,
- s.io_depth
+pg_stat_recovery_prefetch| SELECT stats_reset,
+ prefetch,
+ hit,
+ skip_init,
+ skip_new,
+ skip_fpw,
+ skip_rep,
+ wal_distance,
+ block_distance,
+ io_depth
FROM pg_stat_get_recovery_prefetch() s(stats_reset, prefetch, hit, skip_init, skip_new, skip_fpw, skip_rep, wal_distance, block_distance, io_depth);
pg_stat_replication| SELECT s.pid,
s.usesysid,
@@ -2071,26 +2071,26 @@ pg_stat_replication_slots| SELECT s.slot_name,
FROM pg_replication_slots r,
LATERAL pg_stat_get_replication_slot((r.slot_name)::text) s(slot_name, spill_txns, spill_count, spill_bytes, stream_txns, stream_count, stream_bytes, total_txns, total_bytes, stats_reset)
WHERE (r.datoid IS NOT NULL);
-pg_stat_slru| SELECT s.name,
- s.blks_zeroed,
- s.blks_hit,
- s.blks_read,
- s.blks_written,
- s.blks_exists,
- s.flushes,
- s.truncates,
- s.stats_reset
+pg_stat_slru| SELECT name,
+ blks_zeroed,
+ blks_hit,
+ blks_read,
+ blks_written,
+ blks_exists,
+ flushes,
+ truncates,
+ stats_reset
FROM pg_stat_get_slru() s(name, blks_zeroed, blks_hit, blks_read, blks_written, blks_exists, flushes, truncates, stats_reset);
-pg_stat_ssl| SELECT s.pid,
- s.ssl,
- s.sslversion AS version,
- s.sslcipher AS cipher,
- s.sslbits AS bits,
- s.ssl_client_dn AS client_dn,
- s.ssl_client_serial AS client_serial,
- s.ssl_issuer_dn AS issuer_dn
+pg_stat_ssl| SELECT pid,
+ ssl,
+ sslversion AS version,
+ sslcipher AS cipher,
+ sslbits AS bits,
+ ssl_client_dn AS client_dn,
+ ssl_client_serial AS client_serial,
+ ssl_issuer_dn AS issuer_dn
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid, query_id)
- WHERE (s.client_port IS NOT NULL);
+ WHERE (client_port IS NOT NULL);
pg_stat_subscription| SELECT su.oid AS subid,
su.subname,
st.pid,
@@ -2109,44 +2109,44 @@ pg_stat_subscription_stats| SELECT ss.subid,
ss.stats_reset
FROM pg_subscription s,
LATERAL pg_stat_get_subscription_stats(s.oid) ss(subid, apply_error_count, sync_error_count, stats_reset);
-pg_stat_sys_indexes| SELECT pg_stat_all_indexes.relid,
- pg_stat_all_indexes.indexrelid,
- pg_stat_all_indexes.schemaname,
- pg_stat_all_indexes.relname,
- pg_stat_all_indexes.indexrelname,
- pg_stat_all_indexes.idx_scan,
- pg_stat_all_indexes.last_idx_scan,
- pg_stat_all_indexes.idx_tup_read,
- pg_stat_all_indexes.idx_tup_fetch
+pg_stat_sys_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_read,
+ idx_tup_fetch
FROM pg_stat_all_indexes
- WHERE ((pg_stat_all_indexes.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_all_indexes.schemaname ~ '^pg_toast'::text));
-pg_stat_sys_tables| SELECT pg_stat_all_tables.relid,
- pg_stat_all_tables.schemaname,
- pg_stat_all_tables.relname,
- pg_stat_all_tables.seq_scan,
- pg_stat_all_tables.last_seq_scan,
- pg_stat_all_tables.seq_tup_read,
- pg_stat_all_tables.idx_scan,
- pg_stat_all_tables.last_idx_scan,
- pg_stat_all_tables.idx_tup_fetch,
- pg_stat_all_tables.n_tup_ins,
- pg_stat_all_tables.n_tup_upd,
- pg_stat_all_tables.n_tup_del,
- pg_stat_all_tables.n_tup_hot_upd,
- pg_stat_all_tables.n_live_tup,
- pg_stat_all_tables.n_dead_tup,
- pg_stat_all_tables.n_mod_since_analyze,
- pg_stat_all_tables.n_ins_since_vacuum,
- pg_stat_all_tables.last_vacuum,
- pg_stat_all_tables.last_autovacuum,
- pg_stat_all_tables.last_analyze,
- pg_stat_all_tables.last_autoanalyze,
- pg_stat_all_tables.vacuum_count,
- pg_stat_all_tables.autovacuum_count,
- pg_stat_all_tables.analyze_count,
- pg_stat_all_tables.autoanalyze_count
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_stat_sys_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ last_seq_scan,
+ seq_tup_read,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd,
+ n_live_tup,
+ n_dead_tup,
+ n_mod_since_analyze,
+ n_ins_since_vacuum,
+ last_vacuum,
+ last_autovacuum,
+ last_analyze,
+ last_autoanalyze,
+ vacuum_count,
+ autovacuum_count,
+ analyze_count,
+ autoanalyze_count
FROM pg_stat_all_tables
- WHERE ((pg_stat_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_all_tables.schemaname ~ '^pg_toast'::text));
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
pg_stat_user_functions| SELECT p.oid AS funcid,
n.nspname AS schemaname,
p.proname AS funcname,
@@ -2156,71 +2156,71 @@ pg_stat_user_functions| SELECT p.oid AS funcid,
FROM (pg_proc p
LEFT JOIN pg_namespace n ON ((n.oid = p.pronamespace)))
WHERE ((p.prolang <> (12)::oid) AND (pg_stat_get_function_calls(p.oid) IS NOT NULL));
-pg_stat_user_indexes| SELECT pg_stat_all_indexes.relid,
- pg_stat_all_indexes.indexrelid,
- pg_stat_all_indexes.schemaname,
- pg_stat_all_indexes.relname,
- pg_stat_all_indexes.indexrelname,
- pg_stat_all_indexes.idx_scan,
- pg_stat_all_indexes.last_idx_scan,
- pg_stat_all_indexes.idx_tup_read,
- pg_stat_all_indexes.idx_tup_fetch
+pg_stat_user_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_read,
+ idx_tup_fetch
FROM pg_stat_all_indexes
- WHERE ((pg_stat_all_indexes.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_all_indexes.schemaname !~ '^pg_toast'::text));
-pg_stat_user_tables| SELECT pg_stat_all_tables.relid,
- pg_stat_all_tables.schemaname,
- pg_stat_all_tables.relname,
- pg_stat_all_tables.seq_scan,
- pg_stat_all_tables.last_seq_scan,
- pg_stat_all_tables.seq_tup_read,
- pg_stat_all_tables.idx_scan,
- pg_stat_all_tables.last_idx_scan,
- pg_stat_all_tables.idx_tup_fetch,
- pg_stat_all_tables.n_tup_ins,
- pg_stat_all_tables.n_tup_upd,
- pg_stat_all_tables.n_tup_del,
- pg_stat_all_tables.n_tup_hot_upd,
- pg_stat_all_tables.n_live_tup,
- pg_stat_all_tables.n_dead_tup,
- pg_stat_all_tables.n_mod_since_analyze,
- pg_stat_all_tables.n_ins_since_vacuum,
- pg_stat_all_tables.last_vacuum,
- pg_stat_all_tables.last_autovacuum,
- pg_stat_all_tables.last_analyze,
- pg_stat_all_tables.last_autoanalyze,
- pg_stat_all_tables.vacuum_count,
- pg_stat_all_tables.autovacuum_count,
- pg_stat_all_tables.analyze_count,
- pg_stat_all_tables.autoanalyze_count
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_stat_user_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ last_seq_scan,
+ seq_tup_read,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd,
+ n_live_tup,
+ n_dead_tup,
+ n_mod_since_analyze,
+ n_ins_since_vacuum,
+ last_vacuum,
+ last_autovacuum,
+ last_analyze,
+ last_autoanalyze,
+ vacuum_count,
+ autovacuum_count,
+ analyze_count,
+ autoanalyze_count
FROM pg_stat_all_tables
- WHERE ((pg_stat_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_all_tables.schemaname !~ '^pg_toast'::text));
-pg_stat_wal| SELECT w.wal_records,
- w.wal_fpi,
- w.wal_bytes,
- w.wal_buffers_full,
- w.wal_write,
- w.wal_sync,
- w.wal_write_time,
- w.wal_sync_time,
- w.stats_reset
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_stat_wal| SELECT wal_records,
+ wal_fpi,
+ wal_bytes,
+ wal_buffers_full,
+ wal_write,
+ wal_sync,
+ wal_write_time,
+ wal_sync_time,
+ stats_reset
FROM pg_stat_get_wal() w(wal_records, wal_fpi, wal_bytes, wal_buffers_full, wal_write, wal_sync, wal_write_time, wal_sync_time, stats_reset);
-pg_stat_wal_receiver| SELECT s.pid,
- s.status,
- s.receive_start_lsn,
- s.receive_start_tli,
- s.written_lsn,
- s.flushed_lsn,
- s.received_tli,
- s.last_msg_send_time,
- s.last_msg_receipt_time,
- s.latest_end_lsn,
- s.latest_end_time,
- s.slot_name,
- s.sender_host,
- s.sender_port,
- s.conninfo
+pg_stat_wal_receiver| SELECT pid,
+ status,
+ receive_start_lsn,
+ receive_start_tli,
+ written_lsn,
+ flushed_lsn,
+ received_tli,
+ last_msg_send_time,
+ last_msg_receipt_time,
+ latest_end_lsn,
+ latest_end_time,
+ slot_name,
+ sender_host,
+ sender_port,
+ conninfo
FROM pg_stat_get_wal_receiver() s(pid, status, receive_start_lsn, receive_start_tli, written_lsn, flushed_lsn, received_tli, last_msg_send_time, last_msg_receipt_time, latest_end_lsn, latest_end_time, slot_name, sender_host, sender_port, conninfo)
- WHERE (s.pid IS NOT NULL);
+ WHERE (pid IS NOT NULL);
pg_stat_xact_all_tables| SELECT c.oid AS relid,
n.nspname AS schemaname,
c.relname,
@@ -2237,19 +2237,19 @@ pg_stat_xact_all_tables| SELECT c.oid AS relid,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char", 'p'::"char"]))
GROUP BY c.oid, n.nspname, c.relname;
-pg_stat_xact_sys_tables| SELECT pg_stat_xact_all_tables.relid,
- pg_stat_xact_all_tables.schemaname,
- pg_stat_xact_all_tables.relname,
- pg_stat_xact_all_tables.seq_scan,
- pg_stat_xact_all_tables.seq_tup_read,
- pg_stat_xact_all_tables.idx_scan,
- pg_stat_xact_all_tables.idx_tup_fetch,
- pg_stat_xact_all_tables.n_tup_ins,
- pg_stat_xact_all_tables.n_tup_upd,
- pg_stat_xact_all_tables.n_tup_del,
- pg_stat_xact_all_tables.n_tup_hot_upd
+pg_stat_xact_sys_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ seq_tup_read,
+ idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd
FROM pg_stat_xact_all_tables
- WHERE ((pg_stat_xact_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_xact_all_tables.schemaname ~ '^pg_toast'::text));
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
pg_stat_xact_user_functions| SELECT p.oid AS funcid,
n.nspname AS schemaname,
p.proname AS funcname,
@@ -2259,19 +2259,19 @@ pg_stat_xact_user_functions| SELECT p.oid AS funcid,
FROM (pg_proc p
LEFT JOIN pg_namespace n ON ((n.oid = p.pronamespace)))
WHERE ((p.prolang <> (12)::oid) AND (pg_stat_get_xact_function_calls(p.oid) IS NOT NULL));
-pg_stat_xact_user_tables| SELECT pg_stat_xact_all_tables.relid,
- pg_stat_xact_all_tables.schemaname,
- pg_stat_xact_all_tables.relname,
- pg_stat_xact_all_tables.seq_scan,
- pg_stat_xact_all_tables.seq_tup_read,
- pg_stat_xact_all_tables.idx_scan,
- pg_stat_xact_all_tables.idx_tup_fetch,
- pg_stat_xact_all_tables.n_tup_ins,
- pg_stat_xact_all_tables.n_tup_upd,
- pg_stat_xact_all_tables.n_tup_del,
- pg_stat_xact_all_tables.n_tup_hot_upd
+pg_stat_xact_user_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ seq_tup_read,
+ idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd
FROM pg_stat_xact_all_tables
- WHERE ((pg_stat_xact_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_xact_all_tables.schemaname !~ '^pg_toast'::text));
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
pg_statio_all_indexes| SELECT c.oid AS relid,
i.oid AS indexrelid,
n.nspname AS schemaname,
@@ -2315,64 +2315,64 @@ pg_statio_all_tables| SELECT c.oid AS relid,
FROM pg_index
WHERE (pg_index.indrelid = t.oid)) x ON (true))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char"]));
-pg_statio_sys_indexes| SELECT pg_statio_all_indexes.relid,
- pg_statio_all_indexes.indexrelid,
- pg_statio_all_indexes.schemaname,
- pg_statio_all_indexes.relname,
- pg_statio_all_indexes.indexrelname,
- pg_statio_all_indexes.idx_blks_read,
- pg_statio_all_indexes.idx_blks_hit
+pg_statio_sys_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_blks_read,
+ idx_blks_hit
FROM pg_statio_all_indexes
- WHERE ((pg_statio_all_indexes.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_indexes.schemaname ~ '^pg_toast'::text));
-pg_statio_sys_sequences| SELECT pg_statio_all_sequences.relid,
- pg_statio_all_sequences.schemaname,
- pg_statio_all_sequences.relname,
- pg_statio_all_sequences.blks_read,
- pg_statio_all_sequences.blks_hit
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_statio_sys_sequences| SELECT relid,
+ schemaname,
+ relname,
+ blks_read,
+ blks_hit
FROM pg_statio_all_sequences
- WHERE ((pg_statio_all_sequences.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_sequences.schemaname ~ '^pg_toast'::text));
-pg_statio_sys_tables| SELECT pg_statio_all_tables.relid,
- pg_statio_all_tables.schemaname,
- pg_statio_all_tables.relname,
- pg_statio_all_tables.heap_blks_read,
- pg_statio_all_tables.heap_blks_hit,
- pg_statio_all_tables.idx_blks_read,
- pg_statio_all_tables.idx_blks_hit,
- pg_statio_all_tables.toast_blks_read,
- pg_statio_all_tables.toast_blks_hit,
- pg_statio_all_tables.tidx_blks_read,
- pg_statio_all_tables.tidx_blks_hit
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_statio_sys_tables| SELECT relid,
+ schemaname,
+ relname,
+ heap_blks_read,
+ heap_blks_hit,
+ idx_blks_read,
+ idx_blks_hit,
+ toast_blks_read,
+ toast_blks_hit,
+ tidx_blks_read,
+ tidx_blks_hit
FROM pg_statio_all_tables
- WHERE ((pg_statio_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_tables.schemaname ~ '^pg_toast'::text));
-pg_statio_user_indexes| SELECT pg_statio_all_indexes.relid,
- pg_statio_all_indexes.indexrelid,
- pg_statio_all_indexes.schemaname,
- pg_statio_all_indexes.relname,
- pg_statio_all_indexes.indexrelname,
- pg_statio_all_indexes.idx_blks_read,
- pg_statio_all_indexes.idx_blks_hit
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_statio_user_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_blks_read,
+ idx_blks_hit
FROM pg_statio_all_indexes
- WHERE ((pg_statio_all_indexes.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_indexes.schemaname !~ '^pg_toast'::text));
-pg_statio_user_sequences| SELECT pg_statio_all_sequences.relid,
- pg_statio_all_sequences.schemaname,
- pg_statio_all_sequences.relname,
- pg_statio_all_sequences.blks_read,
- pg_statio_all_sequences.blks_hit
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_statio_user_sequences| SELECT relid,
+ schemaname,
+ relname,
+ blks_read,
+ blks_hit
FROM pg_statio_all_sequences
- WHERE ((pg_statio_all_sequences.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_sequences.schemaname !~ '^pg_toast'::text));
-pg_statio_user_tables| SELECT pg_statio_all_tables.relid,
- pg_statio_all_tables.schemaname,
- pg_statio_all_tables.relname,
- pg_statio_all_tables.heap_blks_read,
- pg_statio_all_tables.heap_blks_hit,
- pg_statio_all_tables.idx_blks_read,
- pg_statio_all_tables.idx_blks_hit,
- pg_statio_all_tables.toast_blks_read,
- pg_statio_all_tables.toast_blks_hit,
- pg_statio_all_tables.tidx_blks_read,
- pg_statio_all_tables.tidx_blks_hit
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_statio_user_tables| SELECT relid,
+ schemaname,
+ relname,
+ heap_blks_read,
+ heap_blks_hit,
+ idx_blks_read,
+ idx_blks_hit,
+ toast_blks_read,
+ toast_blks_hit,
+ tidx_blks_read,
+ tidx_blks_hit
FROM pg_statio_all_tables
- WHERE ((pg_statio_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_tables.schemaname !~ '^pg_toast'::text));
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
pg_stats| SELECT n.nspname AS schemaname,
c.relname AS tablename,
a.attname,
@@ -2557,24 +2557,24 @@ pg_tables| SELECT n.nspname AS schemaname,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
LEFT JOIN pg_tablespace t ON ((t.oid = c.reltablespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 'p'::"char"]));
-pg_timezone_abbrevs| SELECT pg_timezone_abbrevs.abbrev,
- pg_timezone_abbrevs.utc_offset,
- pg_timezone_abbrevs.is_dst
+pg_timezone_abbrevs| SELECT abbrev,
+ utc_offset,
+ is_dst
FROM pg_timezone_abbrevs() pg_timezone_abbrevs(abbrev, utc_offset, is_dst);
-pg_timezone_names| SELECT pg_timezone_names.name,
- pg_timezone_names.abbrev,
- pg_timezone_names.utc_offset,
- pg_timezone_names.is_dst
+pg_timezone_names| SELECT name,
+ abbrev,
+ utc_offset,
+ is_dst
FROM pg_timezone_names() pg_timezone_names(name, abbrev, utc_offset, is_dst);
-pg_user| SELECT pg_shadow.usename,
- pg_shadow.usesysid,
- pg_shadow.usecreatedb,
- pg_shadow.usesuper,
- pg_shadow.userepl,
- pg_shadow.usebypassrls,
+pg_user| SELECT usename,
+ usesysid,
+ usecreatedb,
+ usesuper,
+ userepl,
+ usebypassrls,
'********'::text AS passwd,
- pg_shadow.valuntil,
- pg_shadow.useconfig
+ valuntil,
+ useconfig
FROM pg_shadow;
pg_user_mappings| SELECT u.oid AS umid,
s.oid AS srvid,
@@ -3079,7 +3079,7 @@ SELECT * FROM rule_v1;
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rule_t1.a
+ SELECT a
FROM rule_t1;
Rules:
newinsertrule AS
@@ -3118,8 +3118,8 @@ alter table rule_v1 rename column column2 to q2;
column1 | integer | | | | plain |
q2 | integer | | | | plain |
View definition:
- SELECT "*VALUES*".column1,
- "*VALUES*".column2 AS q2
+ SELECT column1,
+ column2 AS q2
FROM (VALUES (1,2)) "*VALUES*";
drop view rule_v1;
@@ -3131,8 +3131,8 @@ create view rule_v1(x) as values(1,2);
x | integer | | | | plain |
column2 | integer | | | | plain |
View definition:
- SELECT "*VALUES*".column1 AS x,
- "*VALUES*".column2
+ SELECT column1 AS x,
+ column2
FROM (VALUES (1,2)) "*VALUES*";
drop view rule_v1;
@@ -3144,8 +3144,8 @@ create view rule_v1(x) as select * from (values(1,2)) v;
x | integer | | | | plain |
column2 | integer | | | | plain |
View definition:
- SELECT v.column1 AS x,
- v.column2
+ SELECT column1 AS x,
+ column2
FROM ( VALUES (1,2)) v;
drop view rule_v1;
@@ -3157,8 +3157,8 @@ create view rule_v1(x) as select * from (values(1,2)) v(q,w);
x | integer | | | | plain |
w | integer | | | | plain |
View definition:
- SELECT v.q AS x,
- v.w
+ SELECT q AS x,
+ w
FROM ( VALUES (1,2)) v(q, w);
drop view rule_v1;
diff --git a/src/test/regress/expected/tablesample.out b/src/test/regress/expected/tablesample.out
index 60bb4e8e3e..9ff4611640 100644
--- a/src/test/regress/expected/tablesample.out
+++ b/src/test/regress/expected/tablesample.out
@@ -74,7 +74,7 @@ CREATE VIEW test_tablesample_v2 AS
--------+---------+-----------+----------+---------+---------+-------------
id | integer | | | | plain |
View definition:
- SELECT test_tablesample.id
+ SELECT id
FROM test_tablesample TABLESAMPLE system ((10 * 2)) REPEATABLE (2);
\d+ test_tablesample_v2
@@ -83,7 +83,7 @@ View definition:
--------+---------+-----------+----------+---------+---------+-------------
id | integer | | | | plain |
View definition:
- SELECT test_tablesample.id
+ SELECT id
FROM test_tablesample TABLESAMPLE system (99);
-- check a sampled query doesn't affect cursor in progress
diff --git a/src/test/regress/expected/triggers.out b/src/test/regress/expected/triggers.out
index 6d80ab1a6d..7dbeced570 100644
--- a/src/test/regress/expected/triggers.out
+++ b/src/test/regress/expected/triggers.out
@@ -1277,8 +1277,8 @@ DROP TRIGGER instead_of_delete_trig ON main_view;
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT main_table.a,
- main_table.b
+ SELECT a,
+ b
FROM main_table;
Triggers:
after_del_stmt_trig AFTER DELETE ON main_view FOR EACH STATEMENT EXECUTE FUNCTION view_trigger('after_view_del_stmt')
diff --git a/src/test/regress/expected/updatable_views.out b/src/test/regress/expected/updatable_views.out
index 5a47dacad9..2b578cced1 100644
--- a/src/test/regress/expected/updatable_views.out
+++ b/src/test/regress/expected/updatable_views.out
@@ -1925,19 +1925,19 @@ CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a < b
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT base_tbl.a,
- base_tbl.b
+ SELECT a,
+ b
FROM base_tbl
- WHERE base_tbl.a < base_tbl.b;
+ WHERE a < b;
Options: check_option=local
SELECT * FROM information_schema.views WHERE table_name = 'rw_view1';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+------------------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view1 | SELECT base_tbl.a, +| LOCAL | YES | YES | NO | NO | NO
- | | | base_tbl.b +| | | | | |
- | | | FROM base_tbl +| | | | | |
- | | | WHERE (base_tbl.a < base_tbl.b); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view1 | SELECT a, +| LOCAL | YES | YES | NO | NO | NO
+ | | | b +| | | | | |
+ | | | FROM base_tbl+| | | | | |
+ | | | WHERE (a < b); | | | | | |
(1 row)
INSERT INTO rw_view1 VALUES(3,4); -- ok
@@ -1978,17 +1978,17 @@ CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rw_view1.a
+ SELECT a
FROM rw_view1
- WHERE rw_view1.a < 10;
+ WHERE a < 10;
Options: check_option=cascaded
SELECT * FROM information_schema.views WHERE table_name = 'rw_view2';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+----------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view2 | SELECT rw_view1.a +| CASCADED | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a < 10); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view2 | SELECT a +| CASCADED | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a < 10); | | | | | |
(1 row)
INSERT INTO rw_view2 VALUES (-5); -- should fail
@@ -2018,17 +2018,17 @@ CREATE OR REPLACE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rw_view1.a
+ SELECT a
FROM rw_view1
- WHERE rw_view1.a < 10;
+ WHERE a < 10;
Options: check_option=local
SELECT * FROM information_schema.views WHERE table_name = 'rw_view2';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+----------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view2 | SELECT rw_view1.a +| LOCAL | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a < 10); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view2 | SELECT a +| LOCAL | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a < 10); | | | | | |
(1 row)
INSERT INTO rw_view2 VALUES (-10); -- ok, but not in view
@@ -2059,16 +2059,16 @@ ALTER VIEW rw_view2 RESET (check_option);
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rw_view1.a
+ SELECT a
FROM rw_view1
- WHERE rw_view1.a < 10;
+ WHERE a < 10;
SELECT * FROM information_schema.views WHERE table_name = 'rw_view2';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+----------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view2 | SELECT rw_view1.a +| NONE | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a < 10); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view2 | SELECT a +| NONE | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a < 10); | | | | | |
(1 row)
INSERT INTO rw_view2 VALUES (30); -- ok, but not in view
@@ -2090,15 +2090,15 @@ CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WITH CHECK OPTION;
CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a > 0;
CREATE VIEW rw_view3 AS SELECT * FROM rw_view2 WITH CHECK OPTION;
SELECT * FROM information_schema.views WHERE table_name LIKE E'rw\\_view_' ORDER BY table_name;
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+---------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view1 | SELECT base_tbl.a +| CASCADED | YES | YES | NO | NO | NO
- | | | FROM base_tbl; | | | | | |
- regression | public | rw_view2 | SELECT rw_view1.a +| NONE | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a > 0); | | | | | |
- regression | public | rw_view3 | SELECT rw_view2.a +| CASCADED | YES | YES | NO | NO | NO
- | | | FROM rw_view2; | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view1 | SELECT a +| CASCADED | YES | YES | NO | NO | NO
+ | | | FROM base_tbl; | | | | | |
+ regression | public | rw_view2 | SELECT a +| NONE | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a > 0); | | | | | |
+ regression | public | rw_view3 | SELECT a +| CASCADED | YES | YES | NO | NO | NO
+ | | | FROM rw_view2; | | | | | |
(3 rows)
INSERT INTO rw_view1 VALUES (-1); -- ok
diff --git a/src/test/regress/expected/window.out b/src/test/regress/expected/window.out
index 170bea23c2..3d1d26aa39 100644
--- a/src/test/regress/expected/window.out
+++ b/src/test/regress/expected/window.out
@@ -1212,10 +1212,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
----------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1238,10 +1238,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
------------------------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) AS sum_rows+
+ pg_get_viewdef
+-------------------------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1264,10 +1264,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
------------------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE GROUP) AS sum_rows+
+ pg_get_viewdef
+-------------------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE GROUP) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1290,10 +1290,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
-----------------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE TIES) AS sum_rows+
+ pg_get_viewdef
+------------------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE TIES) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1316,10 +1316,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
----------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1341,10 +1341,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
+ pg_get_viewdef
+-------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1353,10 +1353,10 @@ CREATE TEMP VIEW v_window AS
SELECT i, min(i) over (order by i range between '1 day' preceding and '10 days' following) as min_i
FROM generate_series(now(), now()+'100 days'::interval, '1 hour') i;
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
----------------------------------------------------------------------------------------------------------------------------
- SELECT i.i, +
- min(i.i) OVER (ORDER BY i.i RANGE BETWEEN '@ 1 day'::interval PRECEDING AND '@ 10 days'::interval FOLLOWING) AS min_i+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------------------------------------------
+ SELECT i, +
+ min(i) OVER (ORDER BY i RANGE BETWEEN '@ 1 day'::interval PRECEDING AND '@ 10 days'::interval FOLLOWING) AS min_i+
FROM generate_series(now(), (now() + '@ 100 days'::interval), '@ 1 hour'::interval) i(i);
(1 row)
diff --git a/src/test/regress/expected/with.out b/src/test/regress/expected/with.out
index f3fd1cd32a..008a8a9781 100644
--- a/src/test/regress/expected/with.out
+++ b/src/test/regress/expected/with.out
@@ -396,9 +396,9 @@ SELECT pg_get_viewdef('vsubdepartment'::regclass);
subdepartment sd +
WHERE (d.parent_department = sd.id)+
) +
- SELECT subdepartment.id, +
- subdepartment.parent_department, +
- subdepartment.name +
+ SELECT id, +
+ parent_department, +
+ name +
FROM subdepartment;
(1 row)
@@ -419,9 +419,9 @@ SELECT pg_get_viewdef('vsubdepartment'::regclass, true);
subdepartment sd +
WHERE d.parent_department = sd.id+
) +
- SELECT subdepartment.id, +
- subdepartment.parent_department, +
- subdepartment.name +
+ SELECT id, +
+ parent_department, +
+ name +
FROM subdepartment;
(1 row)
@@ -446,7 +446,7 @@ View definition:
FROM t t_1
WHERE t_1.n < 100
)
- SELECT sum(t.n) AS sum
+ SELECT sum(n) AS sum
FROM t;
-- corner case in which sub-WITH gets initialized first
@@ -959,9 +959,9 @@ select pg_get_viewdef('v_search');
search_graph sg +
WHERE (g.f = sg.t) +
) SEARCH DEPTH FIRST BY f, t SET seq +
- SELECT search_graph.f, +
- search_graph.t, +
- search_graph.label +
+ SELECT f, +
+ t, +
+ label +
FROM search_graph;
(1 row)
@@ -1524,9 +1524,9 @@ select pg_get_viewdef('v_cycle1');
search_graph sg +
WHERE (g.f = sg.t) +
) CYCLE f, t SET is_cycle USING path +
- SELECT search_graph.f, +
- search_graph.t, +
- search_graph.label +
+ SELECT f, +
+ t, +
+ label +
FROM search_graph;
(1 row)
@@ -1546,9 +1546,9 @@ select pg_get_viewdef('v_cycle2');
search_graph sg +
WHERE (g.f = sg.t) +
) CYCLE f, t SET is_cycle TO 'Y'::text DEFAULT 'N'::text USING path+
- SELECT search_graph.f, +
- search_graph.t, +
- search_graph.label +
+ SELECT f, +
+ t, +
+ label +
FROM search_graph;
(1 row)
diff --git a/src/test/regress/expected/xml.out b/src/test/regress/expected/xml.out
index 948b4e702c..cc213523c0 100644
--- a/src/test/regress/expected/xml.out
+++ b/src/test/regress/expected/xml.out
@@ -603,12 +603,12 @@ CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'xmlview%' ORDER BY 1;
- table_name | view_definition
-------------+-------------------------------------------------------------------------------------------------------------------
+ table_name | view_definition
+------------+------------------------------------------------------------------------------------------------------------
xmlview1 | SELECT xmlcomment('test'::text) AS xmlcomment;
xmlview2 | SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat";
xmlview3 | SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement";
- xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(emp.name AS name, emp.age AS age, emp.salary AS pay)) AS "xmlelement"+
+ xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(name AS name, age AS age, salary AS pay)) AS "xmlelement" +
| FROM emp;
xmlview5 | SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
xmlview6 | SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi";
diff --git a/src/test/regress/expected/xml_2.out b/src/test/regress/expected/xml_2.out
index 5fd3886b5e..3986fc1706 100644
--- a/src/test/regress/expected/xml_2.out
+++ b/src/test/regress/expected/xml_2.out
@@ -583,12 +583,12 @@ CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'xmlview%' ORDER BY 1;
- table_name | view_definition
-------------+-------------------------------------------------------------------------------------------------------------------
+ table_name | view_definition
+------------+------------------------------------------------------------------------------------------------------------
xmlview1 | SELECT xmlcomment('test'::text) AS xmlcomment;
xmlview2 | SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat";
xmlview3 | SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement";
- xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(emp.name AS name, emp.age AS age, emp.salary AS pay)) AS "xmlelement"+
+ xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(name AS name, age AS age, salary AS pay)) AS "xmlelement" +
| FROM emp;
xmlview5 | SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
xmlview6 | SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi";
--
2.35.3
On Fri, 9 Dec 2022 at 12:20, Amit Langote <amitlangote09@gmail.com> wrote:
On Fri, Dec 9, 2022 at 3:07 PM Amit Langote <amitlangote09@gmail.com> wrote:
On Thu, Dec 8, 2022 at 6:12 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
On 2022-Dec-07, Amit Langote wrote:
However, this
approach of not storing the placeholder in the stored rule would lead
to a whole lot of regression test output changes, because the stored
view queries of many regression tests involving views would now end up
with only 1 entry in the range table instead of 3, causing ruleutils.c
to no longer qualify the column names in the deparsed representation
of those queries appearing in those regression test expected outputs.To avoid that churn (not sure if really a goal to strive for in this
case!), I thought it might be better to keep the OLD entry in the
stored action query while getting rid of the NEW entry.If the *only* argument for keeping the RTE for OLD is to avoid
regression test churn, then definitely it is not worth doing and it
should be ripped out.Other than avoiding the regression test output churn, this also makes
the changes of ApplyRetrieveRule unnecessary.But do these changes mean the code is worse afterwards? Changing stuff,
per se, is not bad. Also, since you haven't posted the "complete" patch
since Nov 7th, it's not easy to tell what those changes are.Maybe you should post both versions of the patch -- one that removes
just NEW, and one that removes both OLD and NEW, so that we can judge.OK, I gave the previous approach another try to see if I can change
ApplyRetrieveRule() in a bit more convincing way this time around, now
that the RTEPermissionInfo patch is in.I would say I'm more satisfied with how it turned out this time. Let
me know what you think.Actually, as I was addressing Alvaro's comments on the now-committed
patch, I was starting to get concerned about the implications of the
change in position of the view relation RTE in the query's range table
if ApplyRetrieveRule() adds one from scratch instead of simply
recycling the OLD entry from stored rule action query, even though I
could see that there are no *user-visible* changes, especially after
decoupling permission checking from the range table.Hmm, I think I see the point, though I don't necessarily agree that
there is a problem.Yeah, I'm not worried as much with the new version. That is helped by
the fact that I've made ApplyRetrieveRule() now do basically what
UpdateRangeTableOfViewParse() would do with the stored rule query.
Also, our making add_rtes_to_flat_rtable() add perminfos in the RTE
order helped find the bug with the last version.Attaching both patches.
Looks like I forgot to update some expected output files.
The patch does not apply on top of HEAD as in [1]http://cfbot.cputube.org/patch_41_4048.log, please post a rebased patch:
=== Applying patches on top of PostgreSQL commit ID
54afdcd6182af709cb0ab775c11b90decff166eb ===
=== applying patch
./v1-0001-Do-not-add-the-NEW-entry-to-view-rule-action-s-ra.patch
Hunk #1 succeeded at 1908 (offset 1 line).
=== applying patch ./v2-0001-Remove-UpdateRangeTableOfViewParse.patch
patching file contrib/postgres_fdw/expected/postgres_fdw.out
Hunk #1 FAILED at 2606.
Hunk #2 FAILED at 2669.
2 out of 4 hunks FAILED -- saving rejects to file
contrib/postgres_fdw/expected/postgres_fdw.out.rej
[1]: http://cfbot.cputube.org/patch_41_4048.log
Regards,
Vignesh
On Wed, Jan 4, 2023 at 7:17 PM vignesh C <vignesh21@gmail.com> wrote:
On Fri, 9 Dec 2022 at 12:20, Amit Langote <amitlangote09@gmail.com> wrote:
On Fri, Dec 9, 2022 at 3:07 PM Amit Langote <amitlangote09@gmail.com> wrote:
On Thu, Dec 8, 2022 at 6:12 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
On 2022-Dec-07, Amit Langote wrote:
However, this
approach of not storing the placeholder in the stored rule would lead
to a whole lot of regression test output changes, because the stored
view queries of many regression tests involving views would now end up
with only 1 entry in the range table instead of 3, causing ruleutils.c
to no longer qualify the column names in the deparsed representation
of those queries appearing in those regression test expected outputs.To avoid that churn (not sure if really a goal to strive for in this
case!), I thought it might be better to keep the OLD entry in the
stored action query while getting rid of the NEW entry.If the *only* argument for keeping the RTE for OLD is to avoid
regression test churn, then definitely it is not worth doing and it
should be ripped out.Other than avoiding the regression test output churn, this also makes
the changes of ApplyRetrieveRule unnecessary.But do these changes mean the code is worse afterwards? Changing stuff,
per se, is not bad. Also, since you haven't posted the "complete" patch
since Nov 7th, it's not easy to tell what those changes are.Maybe you should post both versions of the patch -- one that removes
just NEW, and one that removes both OLD and NEW, so that we can judge.OK, I gave the previous approach another try to see if I can change
ApplyRetrieveRule() in a bit more convincing way this time around, now
that the RTEPermissionInfo patch is in.I would say I'm more satisfied with how it turned out this time. Let
me know what you think.Actually, as I was addressing Alvaro's comments on the now-committed
patch, I was starting to get concerned about the implications of the
change in position of the view relation RTE in the query's range table
if ApplyRetrieveRule() adds one from scratch instead of simply
recycling the OLD entry from stored rule action query, even though I
could see that there are no *user-visible* changes, especially after
decoupling permission checking from the range table.Hmm, I think I see the point, though I don't necessarily agree that
there is a problem.Yeah, I'm not worried as much with the new version. That is helped by
the fact that I've made ApplyRetrieveRule() now do basically what
UpdateRangeTableOfViewParse() would do with the stored rule query.
Also, our making add_rtes_to_flat_rtable() add perminfos in the RTE
order helped find the bug with the last version.Attaching both patches.
Looks like I forgot to update some expected output files.
The patch does not apply on top of HEAD as in [1], please post a rebased patch:
=== Applying patches on top of PostgreSQL commit ID
54afdcd6182af709cb0ab775c11b90decff166eb ===
=== applying patch
./v1-0001-Do-not-add-the-NEW-entry-to-view-rule-action-s-ra.patch
Hunk #1 succeeded at 1908 (offset 1 line).
=== applying patch ./v2-0001-Remove-UpdateRangeTableOfViewParse.patch
patching file contrib/postgres_fdw/expected/postgres_fdw.out
Hunk #1 FAILED at 2606.
Hunk #2 FAILED at 2669.
2 out of 4 hunks FAILED -- saving rejects to file
contrib/postgres_fdw/expected/postgres_fdw.out.rej
Thanks for the heads up. cfbot fails because it's applying both the
patches which, being alternative approaches to address $subject, are
mutually conflicting.
I've attached just the patch that we should move forward with, as
Alvaro might agree.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com
Attachments:
v2-0001-Remove-UpdateRangeTableOfViewParse.patchapplication/octet-stream; name=v2-0001-Remove-UpdateRangeTableOfViewParse.patchDownload
From 53a6803141fd78afff13b261732ef4a44a1ff19d Mon Sep 17 00:00:00 2001
From: amitlan <amitlangote09@gmail.com>
Date: Fri, 9 Dec 2022 10:33:59 +0900
Subject: [PATCH v2] Remove UpdateRangeTableOfViewParse()
And with it, the OLD and the NEW placeholder RTEs that are stored in
a view's stored rule action query.
The OLD RTE is needed currently as a placeholder for carrying view
relation info when querying a given view, because the view relation's
RTE in the query's range table is transposed into a subquery RTE for
converting the view's query into a subselect of the user query.
The NEW RTE is currently not needed for anything.
The purpose served by the OLD RTE doesn't really require it to be
present in the stored view rule query's range table though.
ApplyRetrieveRule(), which would so far look up the OLD RTE from the
view query and repurpose it for carrying the view relation info, can
create the placeholder entries (RTE and RTEPermissionInfo) by itself,
which this commit teaches it to do.
This changes the format of the store rule for views, especially the
range table length, so a bunch of regression tests that show deparsed
view queries need to be adjusted to cope.
---
.../postgres_fdw/expected/postgres_fdw.out | 16 +-
src/backend/commands/lockcmds.c | 9 -
src/backend/commands/view.c | 107 ---
src/backend/rewrite/rewriteDefine.c | 10 +-
src/backend/rewrite/rewriteHandler.c | 59 +-
src/bin/pg_dump/t/002_pg_dump.pl | 12 +-
src/test/regress/expected/aggregates.out | 26 +-
src/test/regress/expected/alter_table.out | 16 +-
.../regress/expected/collate.icu.utf8.out | 24 +-
.../regress/expected/collate.linux.utf8.out | 24 +-
src/test/regress/expected/collate.out | 26 +-
src/test/regress/expected/compression.out | 4 +-
src/test/regress/expected/create_view.out | 222 +++---
src/test/regress/expected/expressions.out | 24 +-
src/test/regress/expected/groupingsets.out | 20 +-
src/test/regress/expected/limit.out | 24 +-
src/test/regress/expected/matview.out | 24 +-
src/test/regress/expected/polymorphism.out | 8 +-
src/test/regress/expected/rangefuncs.out | 34 +-
src/test/regress/expected/rules.out | 748 +++++++++---------
src/test/regress/expected/tablesample.out | 4 +-
src/test/regress/expected/triggers.out | 4 +-
src/test/regress/expected/updatable_views.out | 78 +-
src/test/regress/expected/window.out | 56 +-
src/test/regress/expected/with.out | 32 +-
src/test/regress/expected/xml.out | 6 +-
src/test/regress/expected/xml_2.out | 6 +-
27 files changed, 762 insertions(+), 861 deletions(-)
diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out
index 2ab3f1efaa..e98e64cedc 100644
--- a/contrib/postgres_fdw/expected/postgres_fdw.out
+++ b/contrib/postgres_fdw/expected/postgres_fdw.out
@@ -2606,7 +2606,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1
Foreign Scan
Output: ft4.c1, ft5.c2, ft5.c1
Relations: (public.ft4) LEFT JOIN (public.ft5)
- Remote SQL: SELECT r6.c1, r9.c2, r9.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r9 ON (((r6.c1 = r9.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r9.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r5.c1, r7.c2, r7.c1 FROM ("S 1"."T 3" r5 LEFT JOIN "S 1"."T 4" r7 ON (((r5.c1 = r7.c1)))) ORDER BY r5.c1 ASC NULLS LAST, r7.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
@@ -2669,7 +2669,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c
Foreign Scan
Output: ft4.c1, t2.c2, t2.c1
Relations: (public.ft4) LEFT JOIN (public.ft5 t2)
- Remote SQL: SELECT r6.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r2 ON (((r6.c1 = r2.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r5.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r5 LEFT JOIN "S 1"."T 4" r2 ON (((r5.c1 = r2.c1)))) ORDER BY r5.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
@@ -6555,10 +6555,10 @@ CREATE VIEW rw_view AS SELECT * FROM foreign_tbl
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT foreign_tbl.a,
- foreign_tbl.b
+ SELECT a,
+ b
FROM foreign_tbl
- WHERE foreign_tbl.a < foreign_tbl.b;
+ WHERE a < b;
Options: check_option=cascaded
EXPLAIN (VERBOSE, COSTS OFF)
@@ -6672,10 +6672,10 @@ CREATE VIEW rw_view AS SELECT * FROM parent_tbl
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT parent_tbl.a,
- parent_tbl.b
+ SELECT a,
+ b
FROM parent_tbl
- WHERE parent_tbl.a < parent_tbl.b;
+ WHERE a < b;
Options: check_option=cascaded
EXPLAIN (VERBOSE, COSTS OFF)
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index b0747ce291..1d5f30443b 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -194,15 +194,6 @@ LockViewRecurse_walker(Node *node, LockViewRecurse_context *context)
char relkind = rte->relkind;
char *relname = get_rel_name(relid);
- /*
- * The OLD and NEW placeholder entries in the view's rtable are
- * skipped.
- */
- if (relid == context->viewoid &&
- (strcmp(rte->eref->aliasname, "old") == 0 ||
- strcmp(rte->eref->aliasname, "new") == 0))
- continue;
-
/* Currently, we only allow plain tables or views to be locked. */
if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE &&
relkind != RELKIND_VIEW)
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index 8e3c1efae4..7e3d5e79bc 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -353,107 +353,6 @@ DefineViewRules(Oid viewOid, Query *viewParse, bool replace)
*/
}
-/*---------------------------------------------------------------
- * UpdateRangeTableOfViewParse
- *
- * Update the range table of the given parsetree.
- * This update consists of adding two new entries IN THE BEGINNING
- * of the range table (otherwise the rule system will die a slow,
- * horrible and painful death, and we do not want that now, do we?)
- * one for the OLD relation and one for the NEW one (both of
- * them refer in fact to the "view" relation).
- *
- * Of course we must also increase the 'varnos' of all the Var nodes
- * by 2...
- *
- * These extra RT entries are not actually used in the query,
- * except for run-time locking.
- *---------------------------------------------------------------
- */
-static Query *
-UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
-{
- Relation viewRel;
- List *new_rt;
- ParseNamespaceItem *nsitem;
- RangeTblEntry *rt_entry1,
- *rt_entry2;
- RTEPermissionInfo *rte_perminfo1;
- ParseState *pstate;
- ListCell *lc;
-
- /*
- * Make a copy of the given parsetree. It's not so much that we don't
- * want to scribble on our input, it's that the parser has a bad habit of
- * outputting multiple links to the same subtree for constructs like
- * BETWEEN, and we mustn't have OffsetVarNodes increment the varno of a
- * Var node twice. copyObject will expand any multiply-referenced subtree
- * into multiple copies.
- */
- viewParse = copyObject(viewParse);
-
- /* Create a dummy ParseState for addRangeTableEntryForRelation */
- pstate = make_parsestate(NULL);
-
- /* need to open the rel for addRangeTableEntryForRelation */
- viewRel = relation_open(viewOid, AccessShareLock);
-
- /*
- * Create the 2 new range table entries and form the new range table...
- * OLD first, then NEW....
- */
- nsitem = addRangeTableEntryForRelation(pstate, viewRel,
- AccessShareLock,
- makeAlias("old", NIL),
- false, false);
- rt_entry1 = nsitem->p_rte;
- rte_perminfo1 = nsitem->p_perminfo;
- nsitem = addRangeTableEntryForRelation(pstate, viewRel,
- AccessShareLock,
- makeAlias("new", NIL),
- false, false);
- rt_entry2 = nsitem->p_rte;
-
- /*
- * Add only the "old" RTEPermissionInfo at the head of view query's list
- * and update the other RTEs' perminfoindex accordingly. When rewriting a
- * query on the view, ApplyRetrieveRule() will transfer the view
- * relation's permission details into this RTEPermissionInfo. That's
- * needed because the view's RTE itself will be transposed into a subquery
- * RTE that can't carry the permission details; see the code stanza toward
- * the end of ApplyRetrieveRule() for how that's done.
- */
- viewParse->rteperminfos = lcons(rte_perminfo1, viewParse->rteperminfos);
- foreach(lc, viewParse->rtable)
- {
- RangeTblEntry *rte = lfirst(lc);
-
- if (rte->perminfoindex > 0)
- rte->perminfoindex += 1;
- }
-
- /*
- * Also make the "new" RTE's RTEPermissionInfo undiscoverable. This is a
- * bit of a hack given that all the non-child RTE_RELATION entries really
- * should have a RTEPermissionInfo, but this dummy "new" RTE is going to
- * go away anyway in the very near future.
- */
- rt_entry2->perminfoindex = 0;
-
- new_rt = lcons(rt_entry1, lcons(rt_entry2, viewParse->rtable));
-
- viewParse->rtable = new_rt;
-
- /*
- * Now offset all var nodes by 2, and jointree RT indexes too.
- */
- OffsetVarNodes((Node *) viewParse, 2, 0);
-
- relation_close(viewRel, AccessShareLock);
-
- return viewParse;
-}
-
/*
* DefineView
* Execute a CREATE VIEW command.
@@ -616,12 +515,6 @@ DefineView(ViewStmt *stmt, const char *queryString,
void
StoreViewQuery(Oid viewOid, Query *viewParse, bool replace)
{
- /*
- * The range table of 'viewParse' does not contain entries for the "OLD"
- * and "NEW" relations. So... add them!
- */
- viewParse = UpdateRangeTableOfViewParse(viewOid, viewParse);
-
/*
* Now create the rules associated with the view.
*/
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index 9f3afe965a..3eaa62df4a 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -634,12 +634,10 @@ checkRuleResultList(List *targetList, TupleDesc resultDesc, bool isSelect,
* Recursively scan a query or expression tree and set the checkAsUser
* field to the given userid in all RTEPermissionInfos of the query.
*
- * Note: for a view (ON SELECT rule), the checkAsUser field of the OLD
- * RTE entry's RTEPermissionInfo will be overridden when the view rule is
- * expanded, and the checkAsUser for the NEW RTE entry's RTEPermissionInfo is
- * irrelevant because its requiredPerms bits will always be zero. However, for
- * other types of rules it's important to set these fields to match the rule
- * owner. So we just set them always.
+ * Note: for a view (ON SELECT rule), the checkAsUser field of the view RTE's
+ * RTEPermissionInfo will be overridden when the view rule is expanded; see
+ * ApplyRetrieveRule(). However, for other types of rules it's important to
+ * set these fields to match the rule owner. So we just set them always.
*/
void
setRuleCheckAsUser(Node *node, Oid userid)
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index 7cf0ceacc3..46d5d96d9d 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -1757,9 +1757,9 @@ ApplyRetrieveRule(Query *parsetree,
Query *rule_action;
RangeTblEntry *rte,
*subrte;
- RTEPermissionInfo *perminfo,
- *sub_perminfo;
+ RTEPermissionInfo *perminfo;
RowMarkClause *rc;
+ ListCell *lc;
if (list_length(rule->actions) != 1)
elog(ERROR, "expected just one rule action");
@@ -1868,10 +1868,46 @@ ApplyRetrieveRule(Query *parsetree,
/*
* Now, plug the view query in as a subselect, converting the relation's
* original RTE to a subquery RTE.
+ *
+ * Before doing that, move the view's permission check data down into the
+ * view query by adding both a copy of the view relation RTE and of the
+ * corresponding RTEPermissionInfo to the view query's lists. The RTE is
+ * not referenced anywhere in the query but still needed for 1) the
+ * executor to be able to lock the view relation, and 2) the planner to be
+ * able to record the view relation's OID in PlannedStmt.relationOids.
+ *
+ * Add the view relation's RTE and the perminfo such that they each appear
+ * before other RTEs and perminfos, respectively, to ensure that its
+ * permissions are checked before those of others.
*/
rte = rt_fetch(rt_index, parsetree->rtable);
perminfo = getRTEPermissionInfo(parsetree->rteperminfos, rte);
+ /*
+ * Must adjust varnos of the view query to account for the existing RTE's
+ * indexes increasing by 1 due to view relation RTE's addition.
+ */
+ OffsetVarNodes((Node *) rule_action, 1, 0);
+
+ /* Also their perminfoindexes. */
+ foreach(lc, rule_action->rtable)
+ {
+ RangeTblEntry *action_rte = lfirst(lc);
+
+ if (action_rte->perminfoindex > 0)
+ action_rte->perminfoindex += 1;
+ }
+ subrte = copyObject(rte);
+ rule_action->rtable = lcons(subrte, rule_action->rtable);
+ rule_action->rteperminfos = lcons(copyObject(perminfo),
+ rule_action->rteperminfos);
+ /*
+ * Finally, adjust the view relation's RTE in the view query to point to
+ * the just added perminfo.
+ */
+ subrte->perminfoindex = 1;
+
+ /* Free to convert the original RTE into a subselect. */
rte->rtekind = RTE_SUBQUERY;
rte->subquery = rule_action;
rte->security_barrier = RelationIsSecurityView(relation);
@@ -1880,23 +1916,9 @@ ApplyRetrieveRule(Query *parsetree,
rte->relkind = 0;
rte->rellockmode = 0;
rte->tablesample = NULL;
- rte->perminfoindex = 0; /* no permission checking for this RTE */
+ rte->perminfoindex = 0; /* should no longer point to any perminfo! */
rte->inh = false; /* must not be set for a subquery */
- /*
- * We move the view's permission check data down to its RTEPermissionInfo
- * contained in the view query, which the OLD entry in its range table
- * points to.
- */
- subrte = rt_fetch(PRS2_OLD_VARNO, rule_action->rtable);
- Assert(subrte->relid == relation->rd_id);
- sub_perminfo = getRTEPermissionInfo(rule_action->rteperminfos, subrte);
- sub_perminfo->requiredPerms = perminfo->requiredPerms;
- sub_perminfo->checkAsUser = perminfo->checkAsUser;
- sub_perminfo->selectedCols = perminfo->selectedCols;
- sub_perminfo->insertedCols = perminfo->insertedCols;
- sub_perminfo->updatedCols = perminfo->updatedCols;
-
return parsetree;
}
@@ -1907,9 +1929,6 @@ ApplyRetrieveRule(Query *parsetree,
* aggregate. We leave it to the planner to detect that.
*
* NB: this must agree with the parser's transformLockingClause() routine.
- * However, unlike the parser we have to be careful not to mark a view's
- * OLD and NEW rels for updating. The best way to handle that seems to be
- * to scan the jointree to determine which rels are used.
*/
static void
markQueryForLocking(Query *qry, Node *jtnode,
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 6656222363..518a885610 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -2280,7 +2280,7 @@ my %tests = (
SELECT col1 FROM dump_test.test_table;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview AS\E
- \n\s+\QSELECT test_table.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2296,7 +2296,7 @@ my %tests = (
SELECT * FROM dump_test.matview;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_second AS\E
- \n\s+\QSELECT matview.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2312,7 +2312,7 @@ my %tests = (
SELECT * FROM dump_test.matview_second WITH NO DATA;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_third AS\E
- \n\s+\QSELECT matview_second.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview_second\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2328,7 +2328,7 @@ my %tests = (
SELECT * FROM dump_test.matview_third WITH NO DATA;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_fourth AS\E
- \n\s+\QSELECT matview_third.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview_third\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2346,7 +2346,7 @@ my %tests = (
ALTER COLUMN col2 SET COMPRESSION lz4;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_compression AS\E
- \n\s+\QSELECT test_table.col2\E
+ \n\s+\QSELECT col2\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH NO DATA;\E
.*
@@ -3342,7 +3342,7 @@ my %tests = (
SELECT col1 FROM dump_test.test_table;',
regexp => qr/^
\QCREATE VIEW dump_test.test_view WITH (security_barrier='true') AS\E
- \n\s+\QSELECT test_table.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH LOCAL CHECK OPTION;\E/xm,
like =>
diff --git a/src/test/regress/expected/aggregates.out b/src/test/regress/expected/aggregates.out
index fc2bd40be2..564a7ba1aa 100644
--- a/src/test/regress/expected/aggregates.out
+++ b/src/test/regress/expected/aggregates.out
@@ -1623,7 +1623,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.b, v.c) AS aggfns +
+ SELECT aggfns(a, b, c) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -1675,7 +1675,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.b, v.c ORDER BY (v.b + 1)) AS aggfns +
+ SELECT aggfns(a, b, c ORDER BY (b + 1)) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -1691,7 +1691,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.a, v.c ORDER BY v.b) AS aggfns +
+ SELECT aggfns(a, a, c ORDER BY b) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -1707,7 +1707,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.b, v.c ORDER BY v.c USING ~<~ NULLS LAST) AS aggfns +
+ SELECT aggfns(a, b, c ORDER BY c USING ~<~ NULLS LAST) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -2192,15 +2192,15 @@ select ten,
from tenk1
group by ten order by ten;
select pg_get_viewdef('aggordview1');
- pg_get_viewdef
--------------------------------------------------------------------------------------------------------------------------------
- SELECT tenk1.ten, +
- percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY tenk1.thousand) AS p50, +
- percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY tenk1.thousand) FILTER (WHERE (tenk1.hundred = 1)) AS px,+
- rank(5, 'AZZZZ'::name, 50) WITHIN GROUP (ORDER BY tenk1.hundred, tenk1.string4 DESC, tenk1.hundred) AS rank +
- FROM tenk1 +
- GROUP BY tenk1.ten +
- ORDER BY tenk1.ten;
+ pg_get_viewdef
+-------------------------------------------------------------------------------------------------------------------
+ SELECT ten, +
+ percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY thousand) AS p50, +
+ percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY thousand) FILTER (WHERE (hundred = 1)) AS px,+
+ rank(5, 'AZZZZ'::name, 50) WITHIN GROUP (ORDER BY hundred, string4 DESC, hundred) AS rank +
+ FROM tenk1 +
+ GROUP BY ten +
+ ORDER BY ten;
(1 row)
select * from aggordview1 order by ten;
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 600e603bdf..9e5f6c1a80 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -2493,8 +2493,8 @@ create view at_view_2 as select *, to_json(v1) as j from at_view_1 v1;
id | integer | | | | plain |
stuff | text | | | | extended |
View definition:
- SELECT bt.id,
- bt.stuff
+ SELECT id,
+ stuff
FROM at_base_table bt;
\d+ at_view_2
@@ -2505,8 +2505,8 @@ View definition:
stuff | text | | | | extended |
j | json | | | | extended |
View definition:
- SELECT v1.id,
- v1.stuff,
+ SELECT id,
+ stuff,
to_json(v1.*) AS j
FROM at_view_1 v1;
@@ -2532,8 +2532,8 @@ create or replace view at_view_1 as select *, 2+2 as more from at_base_table bt;
stuff | text | | | | extended |
more | integer | | | | plain |
View definition:
- SELECT bt.id,
- bt.stuff,
+ SELECT id,
+ stuff,
2 + 2 AS more
FROM at_base_table bt;
@@ -2545,8 +2545,8 @@ View definition:
stuff | text | | | | extended |
j | json | | | | extended |
View definition:
- SELECT v1.id,
- v1.stuff,
+ SELECT id,
+ stuff,
to_json(v1.*) AS j
FROM at_view_1 v1;
diff --git a/src/test/regress/expected/collate.icu.utf8.out b/src/test/regress/expected/collate.icu.utf8.out
index d4c8c6de38..4354dc07b8 100644
--- a/src/test/regress/expected/collate.icu.utf8.out
+++ b/src/test/regress/expected/collate.icu.utf8.out
@@ -446,18 +446,18 @@ CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10;
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name | view_definition
-------------+--------------------------------------------------------------------------
- collview1 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | ORDER BY (collate_test1.b COLLATE "C");
- collview3 | SELECT collate_test10.a, +
- | lower(((collate_test10.x || collate_test10.x) COLLATE "C")) AS lower+
+ table_name | view_definition
+------------+--------------------------------------------
+ collview1 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | WHERE ((b COLLATE "C") >= 'bbc'::text);
+ collview2 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | ORDER BY (b COLLATE "C");
+ collview3 | SELECT a, +
+ | lower(((x || x) COLLATE "C")) AS lower+
| FROM collate_test10;
(3 rows)
diff --git a/src/test/regress/expected/collate.linux.utf8.out b/src/test/regress/expected/collate.linux.utf8.out
index f2d0eb94f2..2098696ec2 100644
--- a/src/test/regress/expected/collate.linux.utf8.out
+++ b/src/test/regress/expected/collate.linux.utf8.out
@@ -483,18 +483,18 @@ CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10;
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name | view_definition
-------------+--------------------------------------------------------------------------
- collview1 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | ORDER BY (collate_test1.b COLLATE "C");
- collview3 | SELECT collate_test10.a, +
- | lower(((collate_test10.x || collate_test10.x) COLLATE "C")) AS lower+
+ table_name | view_definition
+------------+--------------------------------------------
+ collview1 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | WHERE ((b COLLATE "C") >= 'bbc'::text);
+ collview2 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | ORDER BY (b COLLATE "C");
+ collview3 | SELECT a, +
+ | lower(((x || x) COLLATE "C")) AS lower+
| FROM collate_test10;
(3 rows)
diff --git a/src/test/regress/expected/collate.out b/src/test/regress/expected/collate.out
index 246832575c..0649564485 100644
--- a/src/test/regress/expected/collate.out
+++ b/src/test/regress/expected/collate.out
@@ -194,18 +194,18 @@ CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "POSIX") FROM collate_test10;
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name | view_definition
-------------+------------------------------------------------------------------------------
- collview1 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | ORDER BY (collate_test1.b COLLATE "C");
- collview3 | SELECT collate_test10.a, +
- | lower(((collate_test10.x || collate_test10.x) COLLATE "POSIX")) AS lower+
+ table_name | view_definition
+------------+------------------------------------------------
+ collview1 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | WHERE ((b COLLATE "C") >= 'bbc'::text);
+ collview2 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | ORDER BY (b COLLATE "C");
+ collview3 | SELECT a, +
+ | lower(((x || x) COLLATE "POSIX")) AS lower+
| FROM collate_test10;
(3 rows)
@@ -698,7 +698,7 @@ SELECT c1+1 AS c1p FROM
--------+---------+-----------+----------+---------+---------+-------------
c1p | integer | | | | plain |
View definition:
- SELECT ss.c1 + 1 AS c1p
+ SELECT c1 + 1 AS c1p
FROM ( SELECT 4 AS c1) ss;
-- Check conflicting or redundant options in CREATE COLLATION
diff --git a/src/test/regress/expected/compression.out b/src/test/regress/expected/compression.out
index 4c997e2602..e06ac93a36 100644
--- a/src/test/regress/expected/compression.out
+++ b/src/test/regress/expected/compression.out
@@ -187,7 +187,7 @@ CREATE MATERIALIZED VIEW compressmv(x) AS SELECT * FROM cmdata1;
--------+------+-----------+----------+---------+----------+-------------+--------------+-------------
x | text | | | | extended | | |
View definition:
- SELECT cmdata1.f1 AS x
+ SELECT f1 AS x
FROM cmdata1;
SELECT pg_column_compression(f1) FROM cmdata1;
@@ -274,7 +274,7 @@ ALTER MATERIALIZED VIEW compressmv ALTER COLUMN x SET COMPRESSION lz4;
--------+------+-----------+----------+---------+----------+-------------+--------------+-------------
x | text | | | | extended | lz4 | |
View definition:
- SELECT cmdata1.f1 AS x
+ SELECT f1 AS x
FROM cmdata1;
-- test alter compression method for partitioned tables
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out
index 17ca29ddbf..61825ef7d4 100644
--- a/src/test/regress/expected/create_view.out
+++ b/src/test/regress/expected/create_view.out
@@ -395,10 +395,10 @@ CREATE VIEW tt1 AS
c | numeric | | | | main |
d | character varying(4) | | | | extended |
View definition:
- SELECT vv.a,
- vv.b,
- vv.c,
- vv.d
+ SELECT a,
+ b,
+ c,
+ d
FROM ( VALUES ('abc'::character varying(3),'0123456789'::character varying,42,'abcd'::character varying(4)), ('0123456789'::character varying,'abc'::character varying(3),42.12,'abc'::character varying(4))) vv(a, b, c, d);
SELECT * FROM tt1;
@@ -440,9 +440,9 @@ CREATE VIEW aliased_view_4 AS
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM tx1
@@ -456,9 +456,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1 a1
WHERE (EXISTS ( SELECT 1
FROM tx1
@@ -472,9 +472,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM tx1 a2
@@ -488,9 +488,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM tt1 tt1_1
@@ -505,9 +505,9 @@ ALTER TABLE tx1 RENAME TO a1;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM a1
@@ -521,9 +521,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1 a1
WHERE (EXISTS ( SELECT 1
FROM a1 a1_1
@@ -537,9 +537,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM a1 a2
@@ -553,9 +553,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM tt1 tt1_1
@@ -570,9 +570,9 @@ ALTER TABLE tt1 RENAME TO a2;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM a1
@@ -586,9 +586,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2 a1
WHERE (EXISTS ( SELECT 1
FROM a1 a1_1
@@ -602,9 +602,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM a1 a2_1
@@ -618,9 +618,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM a2
@@ -635,9 +635,9 @@ ALTER TABLE a1 RENAME TO tt1;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -651,9 +651,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2 a1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -667,9 +667,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM tt1 a2_1
@@ -683,9 +683,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM a2
@@ -701,9 +701,9 @@ ALTER TABLE tx1 SET SCHEMA temp_view_test;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -717,9 +717,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1 a1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -733,9 +733,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1 a2
@@ -749,9 +749,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM temp_view_test.tx1
@@ -768,9 +768,9 @@ ALTER TABLE tmp1 RENAME TO tx1;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -784,9 +784,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1 a1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -800,9 +800,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1 a2
@@ -816,9 +816,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.y1,
- tx1.f2,
- tx1.f3
+ SELECT y1,
+ f2,
+ f3
FROM tx1
WHERE (EXISTS ( SELECT 1
FROM temp_view_test.tx1 tx1_1
@@ -1305,10 +1305,10 @@ select pg_get_viewdef('v1', true);
select pg_get_viewdef('v4', true);
pg_get_viewdef
----------------
- SELECT v1.b, +
- v1.c, +
- v1.x AS a,+
- v1.ax +
+ SELECT b, +
+ c, +
+ x AS a, +
+ ax +
FROM v1;
(1 row)
@@ -1585,9 +1585,9 @@ create view tt14v as select t.* from tt14f() t;
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
--------------------------------
- SELECT t.f1, +
- t.f3, +
- t.f4 +
+ SELECT f1, +
+ f3, +
+ f4 +
FROM tt14f() t(f1, f3, f4);
(1 row)
@@ -1623,11 +1623,11 @@ returning pg_describe_object(classid, objid, objsubid) as obj,
alter table tt14t drop column f3;
-- column f3 is still in the view, sort of ...
select pg_get_viewdef('tt14v', true);
- pg_get_viewdef
----------------------------------
- SELECT t.f1, +
- t."?dropped?column?" AS f3,+
- t.f4 +
+ pg_get_viewdef
+-------------------------------
+ SELECT f1, +
+ "?dropped?column?" AS f3,+
+ f4 +
FROM tt14f() t(f1, f4);
(1 row)
@@ -1675,9 +1675,9 @@ alter table tt14t alter column f4 type integer using f4::integer;
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
--------------------------------
- SELECT t.f1, +
- t.f3, +
- t.f4 +
+ SELECT f1, +
+ f3, +
+ f4 +
FROM tt14f() t(f1, f3, f4);
(1 row)
@@ -1697,8 +1697,8 @@ create view tt14v as select t.f1, t.f4 from tt14f() t;
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
--------------------------------
- SELECT t.f1, +
- t.f4 +
+ SELECT f1, +
+ f4 +
FROM tt14f() t(f1, f3, f4);
(1 row)
@@ -1712,8 +1712,8 @@ alter table tt14t drop column f3; -- ok
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
----------------------------
- SELECT t.f1, +
- t.f4 +
+ SELECT f1, +
+ f4 +
FROM tt14f() t(f1, f4);
(1 row)
@@ -1806,8 +1806,8 @@ select * from tt17v;
select pg_get_viewdef('tt17v', true);
pg_get_viewdef
---------------------------------------------
- SELECT i.q1, +
- i.q2 +
+ SELECT q1, +
+ q2 +
FROM int8_tbl i +
WHERE (i.* IN ( VALUES (i.*::int8_tbl)));
(1 row)
@@ -2134,7 +2134,7 @@ select pg_get_viewdef('tt25v', true);
WITH cte AS MATERIALIZED ( +
SELECT pg_get_keywords() AS k+
) +
- SELECT (cte.k).word AS word +
+ SELECT (k).word AS word +
FROM cte;
(1 row)
@@ -2186,19 +2186,19 @@ select x + y + z as c1,
(x,y) <= ANY (values(1,2),(3,4)) as c11
from (values(1,2,3)) v(x,y,z);
select pg_get_viewdef('tt26v', true);
- pg_get_viewdef
---------------------------------------------------------
- SELECT v.x + v.y + v.z AS c1, +
- v.x * v.y + v.z AS c2, +
- v.x + v.y * v.z AS c3, +
- (v.x + v.y) * v.z AS c4, +
- v.x * (v.y + v.z) AS c5, +
- v.x + (v.y + v.z) AS c6, +
- v.x + (v.y # v.z) AS c7, +
- v.x > v.y AND (v.y > v.z OR v.x > v.z) AS c8, +
- v.x > v.y OR v.y > v.z AND NOT v.x > v.z AS c9, +
- ((v.x, v.y) <> ALL ( VALUES (1,2), (3,4))) AS c10,+
- ((v.x, v.y) <= ANY ( VALUES (1,2), (3,4))) AS c11 +
+ pg_get_viewdef
+----------------------------------------------------
+ SELECT x + y + z AS c1, +
+ x * y + z AS c2, +
+ x + y * z AS c3, +
+ (x + y) * z AS c4, +
+ x * (y + z) AS c5, +
+ x + (y + z) AS c6, +
+ x + (y # z) AS c7, +
+ x > y AND (y > z OR x > z) AS c8, +
+ x > y OR y > z AND NOT x > z AS c9, +
+ ((x, y) <> ALL ( VALUES (1,2), (3,4))) AS c10,+
+ ((x, y) <= ANY ( VALUES (1,2), (3,4))) AS c11 +
FROM ( VALUES (1,2,3)) v(x, y, z);
(1 row)
diff --git a/src/test/regress/expected/expressions.out b/src/test/regress/expected/expressions.out
index 28a20900f1..7c599fd27b 100644
--- a/src/test/regress/expected/expressions.out
+++ b/src/test/regress/expected/expressions.out
@@ -108,12 +108,12 @@ create view numeric_view as
f2164 | numeric(16,4) | | | | main |
f2n | numeric | | | | main |
View definition:
- SELECT numeric_tbl.f1,
- numeric_tbl.f1::numeric(16,4) AS f1164,
- numeric_tbl.f1::numeric AS f1n,
- numeric_tbl.f2,
- numeric_tbl.f2::numeric(16,4) AS f2164,
- numeric_tbl.f2 AS f2n
+ SELECT f1,
+ f1::numeric(16,4) AS f1164,
+ f1::numeric AS f1n,
+ f2,
+ f2::numeric(16,4) AS f2164,
+ f2 AS f2n
FROM numeric_tbl;
explain (verbose, costs off) select * from numeric_view;
@@ -142,12 +142,12 @@ create view bpchar_view as
f214 | character(14) | | | | extended |
f2n | bpchar | | | | extended |
View definition:
- SELECT bpchar_tbl.f1,
- bpchar_tbl.f1::character(14) AS f114,
- bpchar_tbl.f1::bpchar AS f1n,
- bpchar_tbl.f2,
- bpchar_tbl.f2::character(14) AS f214,
- bpchar_tbl.f2 AS f2n
+ SELECT f1,
+ f1::character(14) AS f114,
+ f1::bpchar AS f1n,
+ f2,
+ f2::character(14) AS f214,
+ f2 AS f2n
FROM bpchar_tbl;
explain (verbose, costs off) select * from bpchar_view
diff --git a/src/test/regress/expected/groupingsets.out b/src/test/regress/expected/groupingsets.out
index fcad5c4093..8e75bfe92a 100644
--- a/src/test/regress/expected/groupingsets.out
+++ b/src/test/regress/expected/groupingsets.out
@@ -570,16 +570,16 @@ CREATE VIEW gstest_view AS select a, b, grouping(a,b), sum(c), count(*), max(c)
from gstest2 group by rollup ((a,b,c),(c,d));
NOTICE: view "gstest_view" will be a temporary view
select pg_get_viewdef('gstest_view'::regclass, true);
- pg_get_viewdef
--------------------------------------------------------------------------------
- SELECT gstest2.a, +
- gstest2.b, +
- GROUPING(gstest2.a, gstest2.b) AS "grouping", +
- sum(gstest2.c) AS sum, +
- count(*) AS count, +
- max(gstest2.c) AS max +
- FROM gstest2 +
- GROUP BY ROLLUP((gstest2.a, gstest2.b, gstest2.c), (gstest2.c, gstest2.d));
+ pg_get_viewdef
+---------------------------------------
+ SELECT a, +
+ b, +
+ GROUPING(a, b) AS "grouping", +
+ sum(c) AS sum, +
+ count(*) AS count, +
+ max(c) AS max +
+ FROM gstest2 +
+ GROUP BY ROLLUP((a, b, c), (c, d));
(1 row)
-- Nested queries with 3 or more levels of nesting
diff --git a/src/test/regress/expected/limit.out b/src/test/regress/expected/limit.out
index 8a98bbea8e..a2cd0f9f5b 100644
--- a/src/test/regress/expected/limit.out
+++ b/src/test/regress/expected/limit.out
@@ -638,10 +638,10 @@ CREATE VIEW limit_thousand_v_1 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
OFFSET 10
FETCH FIRST 5 ROWS WITH TIES;
@@ -653,10 +653,10 @@ CREATE VIEW limit_thousand_v_2 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
OFFSET 10
LIMIT 5;
@@ -671,10 +671,10 @@ CREATE VIEW limit_thousand_v_3 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
FETCH FIRST (NULL::integer + 1) ROWS WITH TIES;
CREATE VIEW limit_thousand_v_4 AS SELECT thousand FROM onek WHERE thousand < 995
@@ -685,10 +685,10 @@ CREATE VIEW limit_thousand_v_4 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
LIMIT ALL;
-- leave these views
diff --git a/src/test/regress/expected/matview.out b/src/test/regress/expected/matview.out
index c109d97635..87b6e569a5 100644
--- a/src/test/regress/expected/matview.out
+++ b/src/test/regress/expected/matview.out
@@ -100,10 +100,10 @@ CREATE INDEX mvtest_aa ON mvtest_bb (grandtot);
type | text | | | | extended | |
totamt | numeric | | | | main | |
View definition:
- SELECT mvtest_tv.type,
- mvtest_tv.totamt
+ SELECT type,
+ totamt
FROM mvtest_tv
- ORDER BY mvtest_tv.type;
+ ORDER BY type;
\d+ mvtest_tvm
Materialized view "public.mvtest_tvm"
@@ -112,10 +112,10 @@ View definition:
type | text | | | | extended | |
totamt | numeric | | | | main | |
View definition:
- SELECT mvtest_tv.type,
- mvtest_tv.totamt
+ SELECT type,
+ totamt
FROM mvtest_tv
- ORDER BY mvtest_tv.type;
+ ORDER BY type;
\d+ mvtest_tvvm
Materialized view "public.mvtest_tvvm"
@@ -123,7 +123,7 @@ View definition:
----------+---------+-----------+----------+---------+---------+--------------+-------------
grandtot | numeric | | | | main | |
View definition:
- SELECT mvtest_tvv.grandtot
+ SELECT grandtot
FROM mvtest_tvv;
\d+ mvtest_bb
@@ -134,7 +134,7 @@ View definition:
Indexes:
"mvtest_aa" btree (grandtot)
View definition:
- SELECT mvtest_tvvmv.grandtot
+ SELECT grandtot
FROM mvtest_tvvmv;
-- test schema behavior
@@ -150,7 +150,7 @@ Indexes:
"mvtest_tvmm_expr" UNIQUE, btree ((grandtot > 0::numeric))
"mvtest_tvmm_pred" UNIQUE, btree (grandtot) WHERE grandtot < 0::numeric
View definition:
- SELECT sum(mvtest_tvm.totamt) AS grandtot
+ SELECT sum(totamt) AS grandtot
FROM mvtest_mvschema.mvtest_tvm;
SET search_path = mvtest_mvschema, public;
@@ -161,10 +161,10 @@ SET search_path = mvtest_mvschema, public;
type | text | | | | extended | |
totamt | numeric | | | | main | |
View definition:
- SELECT mvtest_tv.type,
- mvtest_tv.totamt
+ SELECT type,
+ totamt
FROM mvtest_tv
- ORDER BY mvtest_tv.type;
+ ORDER BY type;
-- modify the underlying table data
INSERT INTO mvtest_t VALUES (6, 'z', 13);
diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out
index 1cd558d668..bf08e40ed8 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -1801,10 +1801,10 @@ select * from dfview;
c3 | bigint | | | | plain |
c4 | bigint | | | | plain |
View definition:
- SELECT int8_tbl.q1,
- int8_tbl.q2,
- dfunc(int8_tbl.q1, int8_tbl.q2, flag => int8_tbl.q1 > int8_tbl.q2) AS c3,
- dfunc(int8_tbl.q1, flag => int8_tbl.q1 < int8_tbl.q2, b => int8_tbl.q2) AS c4
+ SELECT q1,
+ q2,
+ dfunc(q1, q2, flag => q1 > q2) AS c3,
+ dfunc(q1, flag => q1 < q2, b => q2) AS c4
FROM int8_tbl;
drop view dfview;
diff --git a/src/test/regress/expected/rangefuncs.out b/src/test/regress/expected/rangefuncs.out
index e2e62db6a2..fbb840e848 100644
--- a/src/test/regress/expected/rangefuncs.out
+++ b/src/test/regress/expected/rangefuncs.out
@@ -149,9 +149,9 @@ select * from vw_ord;
select definition from pg_views where viewname='vw_ord';
definition
----------------------------------------------------------------------------------------
- SELECT z.a, +
- z.b, +
- z.c +
+ SELECT a, +
+ b, +
+ c +
FROM UNNEST(ARRAY[10, 20], ARRAY['foo'::text, 'bar'::text], ARRAY[1.0]) z(a, b, c);
(1 row)
@@ -167,9 +167,9 @@ select * from vw_ord;
select definition from pg_views where viewname='vw_ord';
definition
----------------------------------------------------------------------------------------
- SELECT z.a, +
- z.b, +
- z.c +
+ SELECT a, +
+ b, +
+ c +
FROM UNNEST(ARRAY[10, 20], ARRAY['foo'::text, 'bar'::text], ARRAY[1.0]) z(a, b, c);
(1 row)
@@ -185,9 +185,9 @@ select * from vw_ord;
select definition from pg_views where viewname='vw_ord';
definition
----------------------------------------------------------------------------------------------------------------------
- SELECT z.a, +
- z.b, +
- z.c +
+ SELECT a, +
+ b, +
+ c +
FROM ROWS FROM(unnest(ARRAY[10, 20]), unnest(ARRAY['foo'::text, 'bar'::text]), generate_series(1, 2)) z(a, b, c);
(1 row)
@@ -669,14 +669,14 @@ select * from vw_rngfunc;
select pg_get_viewdef('vw_rngfunc');
pg_get_viewdef
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- SELECT t1.a, +
- t1.b, +
- t1.c, +
- t1.d, +
- t1.e, +
- t1.f, +
- t1.g, +
- t1.n +
+ SELECT a, +
+ b, +
+ c, +
+ d, +
+ e, +
+ f, +
+ g, +
+ n +
FROM ROWS FROM(getrngfunc9(1), getrngfunc7(1) AS (rngfuncid integer, rngfuncsubid integer, rngfuncname text), getrngfunc1(1)) WITH ORDINALITY t1(a, b, c, d, e, f, g, n);
(1 row)
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index fb9f936d43..6a21ce90ac 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -1303,60 +1303,60 @@ pg_available_extensions| SELECT e.name,
e.comment
FROM (pg_available_extensions() e(name, default_version, comment)
LEFT JOIN pg_extension x ON ((e.name = x.extname)));
-pg_backend_memory_contexts| SELECT pg_get_backend_memory_contexts.name,
- pg_get_backend_memory_contexts.ident,
- pg_get_backend_memory_contexts.parent,
- pg_get_backend_memory_contexts.level,
- pg_get_backend_memory_contexts.total_bytes,
- pg_get_backend_memory_contexts.total_nblocks,
- pg_get_backend_memory_contexts.free_bytes,
- pg_get_backend_memory_contexts.free_chunks,
- pg_get_backend_memory_contexts.used_bytes
+pg_backend_memory_contexts| SELECT name,
+ ident,
+ parent,
+ level,
+ total_bytes,
+ total_nblocks,
+ free_bytes,
+ free_chunks,
+ used_bytes
FROM pg_get_backend_memory_contexts() pg_get_backend_memory_contexts(name, ident, parent, level, total_bytes, total_nblocks, free_bytes, free_chunks, used_bytes);
-pg_config| SELECT pg_config.name,
- pg_config.setting
+pg_config| SELECT name,
+ setting
FROM pg_config() pg_config(name, setting);
-pg_cursors| SELECT c.name,
- c.statement,
- c.is_holdable,
- c.is_binary,
- c.is_scrollable,
- c.creation_time
+pg_cursors| SELECT name,
+ statement,
+ is_holdable,
+ is_binary,
+ is_scrollable,
+ creation_time
FROM pg_cursor() c(name, statement, is_holdable, is_binary, is_scrollable, creation_time);
-pg_file_settings| SELECT a.sourcefile,
- a.sourceline,
- a.seqno,
- a.name,
- a.setting,
- a.applied,
- a.error
+pg_file_settings| SELECT sourcefile,
+ sourceline,
+ seqno,
+ name,
+ setting,
+ applied,
+ error
FROM pg_show_all_file_settings() a(sourcefile, sourceline, seqno, name, setting, applied, error);
-pg_group| SELECT pg_authid.rolname AS groname,
- pg_authid.oid AS grosysid,
+pg_group| SELECT rolname AS groname,
+ oid AS grosysid,
ARRAY( SELECT pg_auth_members.member
FROM pg_auth_members
WHERE (pg_auth_members.roleid = pg_authid.oid)) AS grolist
FROM pg_authid
- WHERE (NOT pg_authid.rolcanlogin);
-pg_hba_file_rules| SELECT a.rule_number,
- a.file_name,
- a.line_number,
- a.type,
- a.database,
- a.user_name,
- a.address,
- a.netmask,
- a.auth_method,
- a.options,
- a.error
+ WHERE (NOT rolcanlogin);
+pg_hba_file_rules| SELECT rule_number,
+ file_name,
+ line_number,
+ type,
+ database,
+ user_name,
+ address,
+ netmask,
+ auth_method,
+ options,
+ error
FROM pg_hba_file_rules() a(rule_number, file_name, line_number, type, database, user_name, address, netmask, auth_method, options, error);
-pg_ident_file_mappings| SELECT a.map_number,
- a.file_name,
- a.line_number,
- a.map_name,
- a.sys_name,
- a.pg_username,
- a.error
+pg_ident_file_mappings| SELECT map_number,
+ file_name,
+ line_number,
+ map_name,
+ sys_name,
+ pg_username,
+ error
FROM pg_ident_file_mappings() a(map_number, file_name, line_number, map_name, sys_name, pg_username, error);
pg_indexes| SELECT n.nspname AS schemaname,
c.relname AS tablename,
@@ -1369,22 +1369,22 @@ pg_indexes| SELECT n.nspname AS schemaname,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
LEFT JOIN pg_tablespace t ON ((t.oid = i.reltablespace)))
WHERE ((c.relkind = ANY (ARRAY['r'::"char", 'm'::"char", 'p'::"char"])) AND (i.relkind = ANY (ARRAY['i'::"char", 'I'::"char"])));
-pg_locks| SELECT l.locktype,
- l.database,
- l.relation,
- l.page,
- l.tuple,
- l.virtualxid,
- l.transactionid,
- l.classid,
- l.objid,
- l.objsubid,
- l.virtualtransaction,
- l.pid,
- l.mode,
- l.granted,
- l.fastpath,
- l.waitstart
+pg_locks| SELECT locktype,
+ database,
+ relation,
+ page,
+ tuple,
+ virtualxid,
+ transactionid,
+ classid,
+ objid,
+ objsubid,
+ virtualtransaction,
+ pid,
+ mode,
+ granted,
+ fastpath,
+ waitstart
FROM pg_lock_status() l(locktype, database, relation, page, tuple, virtualxid, transactionid, classid, objid, objsubid, virtualtransaction, pid, mode, granted, fastpath, waitstart);
pg_matviews| SELECT n.nspname AS schemaname,
c.relname AS matviewname,
@@ -1424,14 +1424,14 @@ pg_policies| SELECT n.nspname AS schemaname,
FROM ((pg_policy pol
JOIN pg_class c ON ((c.oid = pol.polrelid)))
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)));
-pg_prepared_statements| SELECT p.name,
- p.statement,
- p.prepare_time,
- p.parameter_types,
- p.result_types,
- p.from_sql,
- p.generic_plans,
- p.custom_plans
+pg_prepared_statements| SELECT name,
+ statement,
+ prepare_time,
+ parameter_types,
+ result_types,
+ from_sql,
+ generic_plans,
+ custom_plans
FROM pg_prepared_statement() p(name, statement, prepare_time, parameter_types, result_types, from_sql, generic_plans, custom_plans);
pg_prepared_xacts| SELECT p.transaction,
p.gid,
@@ -1453,10 +1453,10 @@ pg_publication_tables| SELECT p.pubname,
(pg_class c
JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.oid = gpt.relid);
-pg_replication_origin_status| SELECT pg_show_replication_origin_status.local_id,
- pg_show_replication_origin_status.external_id,
- pg_show_replication_origin_status.remote_lsn,
- pg_show_replication_origin_status.local_lsn
+pg_replication_origin_status| SELECT local_id,
+ external_id,
+ remote_lsn,
+ local_lsn
FROM pg_show_replication_origin_status() pg_show_replication_origin_status(local_id, external_id, remote_lsn, local_lsn);
pg_replication_slots| SELECT l.slot_name,
l.plugin,
@@ -1702,23 +1702,23 @@ pg_sequences| SELECT n.nspname AS schemaname,
JOIN pg_class c ON ((c.oid = s.seqrelid)))
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE ((NOT pg_is_other_temp_schema(n.oid)) AND (c.relkind = 'S'::"char"));
-pg_settings| SELECT a.name,
- a.setting,
- a.unit,
- a.category,
- a.short_desc,
- a.extra_desc,
- a.context,
- a.vartype,
- a.source,
- a.min_val,
- a.max_val,
- a.enumvals,
- a.boot_val,
- a.reset_val,
- a.sourcefile,
- a.sourceline,
- a.pending_restart
+pg_settings| SELECT name,
+ setting,
+ unit,
+ category,
+ short_desc,
+ extra_desc,
+ context,
+ vartype,
+ source,
+ min_val,
+ max_val,
+ enumvals,
+ boot_val,
+ reset_val,
+ sourcefile,
+ sourceline,
+ pending_restart
FROM pg_show_all_settings() a(name, setting, unit, category, short_desc, extra_desc, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, sourcefile, sourceline, pending_restart);
pg_shadow| SELECT pg_authid.rolname AS usename,
pg_authid.oid AS usesysid,
@@ -1732,10 +1732,10 @@ pg_shadow| SELECT pg_authid.rolname AS usename,
FROM (pg_authid
LEFT JOIN pg_db_role_setting s ON (((pg_authid.oid = s.setrole) AND (s.setdatabase = (0)::oid))))
WHERE pg_authid.rolcanlogin;
-pg_shmem_allocations| SELECT pg_get_shmem_allocations.name,
- pg_get_shmem_allocations.off,
- pg_get_shmem_allocations.size,
- pg_get_shmem_allocations.allocated_size
+pg_shmem_allocations| SELECT name,
+ off,
+ size,
+ allocated_size
FROM pg_get_shmem_allocations() pg_get_shmem_allocations(name, off, size, allocated_size);
pg_stat_activity| SELECT s.datid,
d.datname,
@@ -1806,13 +1806,13 @@ pg_stat_all_tables| SELECT c.oid AS relid,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char", 'p'::"char"]))
GROUP BY c.oid, n.nspname, c.relname;
-pg_stat_archiver| SELECT s.archived_count,
- s.last_archived_wal,
- s.last_archived_time,
- s.failed_count,
- s.last_failed_wal,
- s.last_failed_time,
- s.stats_reset
+pg_stat_archiver| SELECT archived_count,
+ last_archived_wal,
+ last_archived_time,
+ failed_count,
+ last_failed_wal,
+ last_failed_time,
+ stats_reset
FROM pg_stat_get_archiver() s(archived_count, last_archived_wal, last_archived_time, failed_count, last_failed_wal, last_failed_time, stats_reset);
pg_stat_bgwriter| SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints_timed,
pg_stat_get_bgwriter_requested_checkpoints() AS checkpoints_req,
@@ -1825,57 +1825,57 @@ pg_stat_bgwriter| SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints
pg_stat_get_buf_fsync_backend() AS buffers_backend_fsync,
pg_stat_get_buf_alloc() AS buffers_alloc,
pg_stat_get_bgwriter_stat_reset_time() AS stats_reset;
-pg_stat_database| SELECT d.oid AS datid,
- d.datname,
+pg_stat_database| SELECT oid AS datid,
+ datname,
CASE
- WHEN (d.oid = (0)::oid) THEN 0
- ELSE pg_stat_get_db_numbackends(d.oid)
+ WHEN (oid = (0)::oid) THEN 0
+ ELSE pg_stat_get_db_numbackends(oid)
END AS numbackends,
- pg_stat_get_db_xact_commit(d.oid) AS xact_commit,
- pg_stat_get_db_xact_rollback(d.oid) AS xact_rollback,
- (pg_stat_get_db_blocks_fetched(d.oid) - pg_stat_get_db_blocks_hit(d.oid)) AS blks_read,
- pg_stat_get_db_blocks_hit(d.oid) AS blks_hit,
- pg_stat_get_db_tuples_returned(d.oid) AS tup_returned,
- pg_stat_get_db_tuples_fetched(d.oid) AS tup_fetched,
- pg_stat_get_db_tuples_inserted(d.oid) AS tup_inserted,
- pg_stat_get_db_tuples_updated(d.oid) AS tup_updated,
- pg_stat_get_db_tuples_deleted(d.oid) AS tup_deleted,
- pg_stat_get_db_conflict_all(d.oid) AS conflicts,
- pg_stat_get_db_temp_files(d.oid) AS temp_files,
- pg_stat_get_db_temp_bytes(d.oid) AS temp_bytes,
- pg_stat_get_db_deadlocks(d.oid) AS deadlocks,
- pg_stat_get_db_checksum_failures(d.oid) AS checksum_failures,
- pg_stat_get_db_checksum_last_failure(d.oid) AS checksum_last_failure,
- pg_stat_get_db_blk_read_time(d.oid) AS blk_read_time,
- pg_stat_get_db_blk_write_time(d.oid) AS blk_write_time,
- pg_stat_get_db_session_time(d.oid) AS session_time,
- pg_stat_get_db_active_time(d.oid) AS active_time,
- pg_stat_get_db_idle_in_transaction_time(d.oid) AS idle_in_transaction_time,
- pg_stat_get_db_sessions(d.oid) AS sessions,
- pg_stat_get_db_sessions_abandoned(d.oid) AS sessions_abandoned,
- pg_stat_get_db_sessions_fatal(d.oid) AS sessions_fatal,
- pg_stat_get_db_sessions_killed(d.oid) AS sessions_killed,
- pg_stat_get_db_stat_reset_time(d.oid) AS stats_reset
+ pg_stat_get_db_xact_commit(oid) AS xact_commit,
+ pg_stat_get_db_xact_rollback(oid) AS xact_rollback,
+ (pg_stat_get_db_blocks_fetched(oid) - pg_stat_get_db_blocks_hit(oid)) AS blks_read,
+ pg_stat_get_db_blocks_hit(oid) AS blks_hit,
+ pg_stat_get_db_tuples_returned(oid) AS tup_returned,
+ pg_stat_get_db_tuples_fetched(oid) AS tup_fetched,
+ pg_stat_get_db_tuples_inserted(oid) AS tup_inserted,
+ pg_stat_get_db_tuples_updated(oid) AS tup_updated,
+ pg_stat_get_db_tuples_deleted(oid) AS tup_deleted,
+ pg_stat_get_db_conflict_all(oid) AS conflicts,
+ pg_stat_get_db_temp_files(oid) AS temp_files,
+ pg_stat_get_db_temp_bytes(oid) AS temp_bytes,
+ pg_stat_get_db_deadlocks(oid) AS deadlocks,
+ pg_stat_get_db_checksum_failures(oid) AS checksum_failures,
+ pg_stat_get_db_checksum_last_failure(oid) AS checksum_last_failure,
+ pg_stat_get_db_blk_read_time(oid) AS blk_read_time,
+ pg_stat_get_db_blk_write_time(oid) AS blk_write_time,
+ pg_stat_get_db_session_time(oid) AS session_time,
+ pg_stat_get_db_active_time(oid) AS active_time,
+ pg_stat_get_db_idle_in_transaction_time(oid) AS idle_in_transaction_time,
+ pg_stat_get_db_sessions(oid) AS sessions,
+ pg_stat_get_db_sessions_abandoned(oid) AS sessions_abandoned,
+ pg_stat_get_db_sessions_fatal(oid) AS sessions_fatal,
+ pg_stat_get_db_sessions_killed(oid) AS sessions_killed,
+ pg_stat_get_db_stat_reset_time(oid) AS stats_reset
FROM ( SELECT 0 AS oid,
NULL::name AS datname
UNION ALL
SELECT pg_database.oid,
pg_database.datname
FROM pg_database) d;
-pg_stat_database_conflicts| SELECT d.oid AS datid,
- d.datname,
- pg_stat_get_db_conflict_tablespace(d.oid) AS confl_tablespace,
- pg_stat_get_db_conflict_lock(d.oid) AS confl_lock,
- pg_stat_get_db_conflict_snapshot(d.oid) AS confl_snapshot,
- pg_stat_get_db_conflict_bufferpin(d.oid) AS confl_bufferpin,
- pg_stat_get_db_conflict_startup_deadlock(d.oid) AS confl_deadlock
+pg_stat_database_conflicts| SELECT oid AS datid,
+ datname,
+ pg_stat_get_db_conflict_tablespace(oid) AS confl_tablespace,
+ pg_stat_get_db_conflict_lock(oid) AS confl_lock,
+ pg_stat_get_db_conflict_snapshot(oid) AS confl_snapshot,
+ pg_stat_get_db_conflict_bufferpin(oid) AS confl_bufferpin,
+ pg_stat_get_db_conflict_startup_deadlock(oid) AS confl_deadlock
FROM pg_database d;
-pg_stat_gssapi| SELECT s.pid,
- s.gss_auth AS gss_authenticated,
- s.gss_princ AS principal,
- s.gss_enc AS encrypted
+pg_stat_gssapi| SELECT pid,
+ gss_auth AS gss_authenticated,
+ gss_princ AS principal,
+ gss_enc AS encrypted
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid, query_id)
- WHERE (s.client_port IS NOT NULL);
+ WHERE (client_port IS NOT NULL);
pg_stat_progress_analyze| SELECT s.pid,
s.datid,
d.datname,
@@ -1898,8 +1898,8 @@ pg_stat_progress_analyze| SELECT s.pid,
(s.param8)::oid AS current_child_table_relid
FROM (pg_stat_get_progress_info('ANALYZE'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
LEFT JOIN pg_database d ON ((s.datid = d.oid)));
-pg_stat_progress_basebackup| SELECT s.pid,
- CASE s.param1
+pg_stat_progress_basebackup| SELECT pid,
+ CASE param1
WHEN 0 THEN 'initializing'::text
WHEN 1 THEN 'waiting for checkpoint to finish'::text
WHEN 2 THEN 'estimating backup size'::text
@@ -1908,13 +1908,13 @@ pg_stat_progress_basebackup| SELECT s.pid,
WHEN 5 THEN 'transferring wal files'::text
ELSE NULL::text
END AS phase,
- CASE s.param2
+ CASE param2
WHEN '-1'::integer THEN NULL::bigint
- ELSE s.param2
+ ELSE param2
END AS backup_total,
- s.param3 AS backup_streamed,
- s.param4 AS tablespaces_total,
- s.param5 AS tablespaces_streamed
+ param3 AS backup_streamed,
+ param4 AS tablespaces_total,
+ param5 AS tablespaces_streamed
FROM pg_stat_get_progress_info('BASEBACKUP'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20);
pg_stat_progress_cluster| SELECT s.pid,
s.datid,
@@ -2024,16 +2024,16 @@ pg_stat_progress_vacuum| SELECT s.pid,
s.param7 AS num_dead_tuples
FROM (pg_stat_get_progress_info('VACUUM'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
LEFT JOIN pg_database d ON ((s.datid = d.oid)));
-pg_stat_recovery_prefetch| SELECT s.stats_reset,
- s.prefetch,
- s.hit,
- s.skip_init,
- s.skip_new,
- s.skip_fpw,
- s.skip_rep,
- s.wal_distance,
- s.block_distance,
- s.io_depth
+pg_stat_recovery_prefetch| SELECT stats_reset,
+ prefetch,
+ hit,
+ skip_init,
+ skip_new,
+ skip_fpw,
+ skip_rep,
+ wal_distance,
+ block_distance,
+ io_depth
FROM pg_stat_get_recovery_prefetch() s(stats_reset, prefetch, hit, skip_init, skip_new, skip_fpw, skip_rep, wal_distance, block_distance, io_depth);
pg_stat_replication| SELECT s.pid,
s.usesysid,
@@ -2071,26 +2071,26 @@ pg_stat_replication_slots| SELECT s.slot_name,
FROM pg_replication_slots r,
LATERAL pg_stat_get_replication_slot((r.slot_name)::text) s(slot_name, spill_txns, spill_count, spill_bytes, stream_txns, stream_count, stream_bytes, total_txns, total_bytes, stats_reset)
WHERE (r.datoid IS NOT NULL);
-pg_stat_slru| SELECT s.name,
- s.blks_zeroed,
- s.blks_hit,
- s.blks_read,
- s.blks_written,
- s.blks_exists,
- s.flushes,
- s.truncates,
- s.stats_reset
+pg_stat_slru| SELECT name,
+ blks_zeroed,
+ blks_hit,
+ blks_read,
+ blks_written,
+ blks_exists,
+ flushes,
+ truncates,
+ stats_reset
FROM pg_stat_get_slru() s(name, blks_zeroed, blks_hit, blks_read, blks_written, blks_exists, flushes, truncates, stats_reset);
-pg_stat_ssl| SELECT s.pid,
- s.ssl,
- s.sslversion AS version,
- s.sslcipher AS cipher,
- s.sslbits AS bits,
- s.ssl_client_dn AS client_dn,
- s.ssl_client_serial AS client_serial,
- s.ssl_issuer_dn AS issuer_dn
+pg_stat_ssl| SELECT pid,
+ ssl,
+ sslversion AS version,
+ sslcipher AS cipher,
+ sslbits AS bits,
+ ssl_client_dn AS client_dn,
+ ssl_client_serial AS client_serial,
+ ssl_issuer_dn AS issuer_dn
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid, query_id)
- WHERE (s.client_port IS NOT NULL);
+ WHERE (client_port IS NOT NULL);
pg_stat_subscription| SELECT su.oid AS subid,
su.subname,
st.pid,
@@ -2109,44 +2109,44 @@ pg_stat_subscription_stats| SELECT ss.subid,
ss.stats_reset
FROM pg_subscription s,
LATERAL pg_stat_get_subscription_stats(s.oid) ss(subid, apply_error_count, sync_error_count, stats_reset);
-pg_stat_sys_indexes| SELECT pg_stat_all_indexes.relid,
- pg_stat_all_indexes.indexrelid,
- pg_stat_all_indexes.schemaname,
- pg_stat_all_indexes.relname,
- pg_stat_all_indexes.indexrelname,
- pg_stat_all_indexes.idx_scan,
- pg_stat_all_indexes.last_idx_scan,
- pg_stat_all_indexes.idx_tup_read,
- pg_stat_all_indexes.idx_tup_fetch
+pg_stat_sys_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_read,
+ idx_tup_fetch
FROM pg_stat_all_indexes
- WHERE ((pg_stat_all_indexes.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_all_indexes.schemaname ~ '^pg_toast'::text));
-pg_stat_sys_tables| SELECT pg_stat_all_tables.relid,
- pg_stat_all_tables.schemaname,
- pg_stat_all_tables.relname,
- pg_stat_all_tables.seq_scan,
- pg_stat_all_tables.last_seq_scan,
- pg_stat_all_tables.seq_tup_read,
- pg_stat_all_tables.idx_scan,
- pg_stat_all_tables.last_idx_scan,
- pg_stat_all_tables.idx_tup_fetch,
- pg_stat_all_tables.n_tup_ins,
- pg_stat_all_tables.n_tup_upd,
- pg_stat_all_tables.n_tup_del,
- pg_stat_all_tables.n_tup_hot_upd,
- pg_stat_all_tables.n_live_tup,
- pg_stat_all_tables.n_dead_tup,
- pg_stat_all_tables.n_mod_since_analyze,
- pg_stat_all_tables.n_ins_since_vacuum,
- pg_stat_all_tables.last_vacuum,
- pg_stat_all_tables.last_autovacuum,
- pg_stat_all_tables.last_analyze,
- pg_stat_all_tables.last_autoanalyze,
- pg_stat_all_tables.vacuum_count,
- pg_stat_all_tables.autovacuum_count,
- pg_stat_all_tables.analyze_count,
- pg_stat_all_tables.autoanalyze_count
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_stat_sys_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ last_seq_scan,
+ seq_tup_read,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd,
+ n_live_tup,
+ n_dead_tup,
+ n_mod_since_analyze,
+ n_ins_since_vacuum,
+ last_vacuum,
+ last_autovacuum,
+ last_analyze,
+ last_autoanalyze,
+ vacuum_count,
+ autovacuum_count,
+ analyze_count,
+ autoanalyze_count
FROM pg_stat_all_tables
- WHERE ((pg_stat_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_all_tables.schemaname ~ '^pg_toast'::text));
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
pg_stat_user_functions| SELECT p.oid AS funcid,
n.nspname AS schemaname,
p.proname AS funcname,
@@ -2156,71 +2156,71 @@ pg_stat_user_functions| SELECT p.oid AS funcid,
FROM (pg_proc p
LEFT JOIN pg_namespace n ON ((n.oid = p.pronamespace)))
WHERE ((p.prolang <> (12)::oid) AND (pg_stat_get_function_calls(p.oid) IS NOT NULL));
-pg_stat_user_indexes| SELECT pg_stat_all_indexes.relid,
- pg_stat_all_indexes.indexrelid,
- pg_stat_all_indexes.schemaname,
- pg_stat_all_indexes.relname,
- pg_stat_all_indexes.indexrelname,
- pg_stat_all_indexes.idx_scan,
- pg_stat_all_indexes.last_idx_scan,
- pg_stat_all_indexes.idx_tup_read,
- pg_stat_all_indexes.idx_tup_fetch
+pg_stat_user_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_read,
+ idx_tup_fetch
FROM pg_stat_all_indexes
- WHERE ((pg_stat_all_indexes.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_all_indexes.schemaname !~ '^pg_toast'::text));
-pg_stat_user_tables| SELECT pg_stat_all_tables.relid,
- pg_stat_all_tables.schemaname,
- pg_stat_all_tables.relname,
- pg_stat_all_tables.seq_scan,
- pg_stat_all_tables.last_seq_scan,
- pg_stat_all_tables.seq_tup_read,
- pg_stat_all_tables.idx_scan,
- pg_stat_all_tables.last_idx_scan,
- pg_stat_all_tables.idx_tup_fetch,
- pg_stat_all_tables.n_tup_ins,
- pg_stat_all_tables.n_tup_upd,
- pg_stat_all_tables.n_tup_del,
- pg_stat_all_tables.n_tup_hot_upd,
- pg_stat_all_tables.n_live_tup,
- pg_stat_all_tables.n_dead_tup,
- pg_stat_all_tables.n_mod_since_analyze,
- pg_stat_all_tables.n_ins_since_vacuum,
- pg_stat_all_tables.last_vacuum,
- pg_stat_all_tables.last_autovacuum,
- pg_stat_all_tables.last_analyze,
- pg_stat_all_tables.last_autoanalyze,
- pg_stat_all_tables.vacuum_count,
- pg_stat_all_tables.autovacuum_count,
- pg_stat_all_tables.analyze_count,
- pg_stat_all_tables.autoanalyze_count
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_stat_user_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ last_seq_scan,
+ seq_tup_read,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd,
+ n_live_tup,
+ n_dead_tup,
+ n_mod_since_analyze,
+ n_ins_since_vacuum,
+ last_vacuum,
+ last_autovacuum,
+ last_analyze,
+ last_autoanalyze,
+ vacuum_count,
+ autovacuum_count,
+ analyze_count,
+ autoanalyze_count
FROM pg_stat_all_tables
- WHERE ((pg_stat_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_all_tables.schemaname !~ '^pg_toast'::text));
-pg_stat_wal| SELECT w.wal_records,
- w.wal_fpi,
- w.wal_bytes,
- w.wal_buffers_full,
- w.wal_write,
- w.wal_sync,
- w.wal_write_time,
- w.wal_sync_time,
- w.stats_reset
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_stat_wal| SELECT wal_records,
+ wal_fpi,
+ wal_bytes,
+ wal_buffers_full,
+ wal_write,
+ wal_sync,
+ wal_write_time,
+ wal_sync_time,
+ stats_reset
FROM pg_stat_get_wal() w(wal_records, wal_fpi, wal_bytes, wal_buffers_full, wal_write, wal_sync, wal_write_time, wal_sync_time, stats_reset);
-pg_stat_wal_receiver| SELECT s.pid,
- s.status,
- s.receive_start_lsn,
- s.receive_start_tli,
- s.written_lsn,
- s.flushed_lsn,
- s.received_tli,
- s.last_msg_send_time,
- s.last_msg_receipt_time,
- s.latest_end_lsn,
- s.latest_end_time,
- s.slot_name,
- s.sender_host,
- s.sender_port,
- s.conninfo
+pg_stat_wal_receiver| SELECT pid,
+ status,
+ receive_start_lsn,
+ receive_start_tli,
+ written_lsn,
+ flushed_lsn,
+ received_tli,
+ last_msg_send_time,
+ last_msg_receipt_time,
+ latest_end_lsn,
+ latest_end_time,
+ slot_name,
+ sender_host,
+ sender_port,
+ conninfo
FROM pg_stat_get_wal_receiver() s(pid, status, receive_start_lsn, receive_start_tli, written_lsn, flushed_lsn, received_tli, last_msg_send_time, last_msg_receipt_time, latest_end_lsn, latest_end_time, slot_name, sender_host, sender_port, conninfo)
- WHERE (s.pid IS NOT NULL);
+ WHERE (pid IS NOT NULL);
pg_stat_xact_all_tables| SELECT c.oid AS relid,
n.nspname AS schemaname,
c.relname,
@@ -2237,19 +2237,19 @@ pg_stat_xact_all_tables| SELECT c.oid AS relid,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char", 'p'::"char"]))
GROUP BY c.oid, n.nspname, c.relname;
-pg_stat_xact_sys_tables| SELECT pg_stat_xact_all_tables.relid,
- pg_stat_xact_all_tables.schemaname,
- pg_stat_xact_all_tables.relname,
- pg_stat_xact_all_tables.seq_scan,
- pg_stat_xact_all_tables.seq_tup_read,
- pg_stat_xact_all_tables.idx_scan,
- pg_stat_xact_all_tables.idx_tup_fetch,
- pg_stat_xact_all_tables.n_tup_ins,
- pg_stat_xact_all_tables.n_tup_upd,
- pg_stat_xact_all_tables.n_tup_del,
- pg_stat_xact_all_tables.n_tup_hot_upd
+pg_stat_xact_sys_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ seq_tup_read,
+ idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd
FROM pg_stat_xact_all_tables
- WHERE ((pg_stat_xact_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_xact_all_tables.schemaname ~ '^pg_toast'::text));
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
pg_stat_xact_user_functions| SELECT p.oid AS funcid,
n.nspname AS schemaname,
p.proname AS funcname,
@@ -2259,19 +2259,19 @@ pg_stat_xact_user_functions| SELECT p.oid AS funcid,
FROM (pg_proc p
LEFT JOIN pg_namespace n ON ((n.oid = p.pronamespace)))
WHERE ((p.prolang <> (12)::oid) AND (pg_stat_get_xact_function_calls(p.oid) IS NOT NULL));
-pg_stat_xact_user_tables| SELECT pg_stat_xact_all_tables.relid,
- pg_stat_xact_all_tables.schemaname,
- pg_stat_xact_all_tables.relname,
- pg_stat_xact_all_tables.seq_scan,
- pg_stat_xact_all_tables.seq_tup_read,
- pg_stat_xact_all_tables.idx_scan,
- pg_stat_xact_all_tables.idx_tup_fetch,
- pg_stat_xact_all_tables.n_tup_ins,
- pg_stat_xact_all_tables.n_tup_upd,
- pg_stat_xact_all_tables.n_tup_del,
- pg_stat_xact_all_tables.n_tup_hot_upd
+pg_stat_xact_user_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ seq_tup_read,
+ idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd
FROM pg_stat_xact_all_tables
- WHERE ((pg_stat_xact_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_xact_all_tables.schemaname !~ '^pg_toast'::text));
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
pg_statio_all_indexes| SELECT c.oid AS relid,
i.oid AS indexrelid,
n.nspname AS schemaname,
@@ -2315,64 +2315,64 @@ pg_statio_all_tables| SELECT c.oid AS relid,
FROM pg_index
WHERE (pg_index.indrelid = t.oid)) x ON (true))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char"]));
-pg_statio_sys_indexes| SELECT pg_statio_all_indexes.relid,
- pg_statio_all_indexes.indexrelid,
- pg_statio_all_indexes.schemaname,
- pg_statio_all_indexes.relname,
- pg_statio_all_indexes.indexrelname,
- pg_statio_all_indexes.idx_blks_read,
- pg_statio_all_indexes.idx_blks_hit
+pg_statio_sys_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_blks_read,
+ idx_blks_hit
FROM pg_statio_all_indexes
- WHERE ((pg_statio_all_indexes.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_indexes.schemaname ~ '^pg_toast'::text));
-pg_statio_sys_sequences| SELECT pg_statio_all_sequences.relid,
- pg_statio_all_sequences.schemaname,
- pg_statio_all_sequences.relname,
- pg_statio_all_sequences.blks_read,
- pg_statio_all_sequences.blks_hit
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_statio_sys_sequences| SELECT relid,
+ schemaname,
+ relname,
+ blks_read,
+ blks_hit
FROM pg_statio_all_sequences
- WHERE ((pg_statio_all_sequences.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_sequences.schemaname ~ '^pg_toast'::text));
-pg_statio_sys_tables| SELECT pg_statio_all_tables.relid,
- pg_statio_all_tables.schemaname,
- pg_statio_all_tables.relname,
- pg_statio_all_tables.heap_blks_read,
- pg_statio_all_tables.heap_blks_hit,
- pg_statio_all_tables.idx_blks_read,
- pg_statio_all_tables.idx_blks_hit,
- pg_statio_all_tables.toast_blks_read,
- pg_statio_all_tables.toast_blks_hit,
- pg_statio_all_tables.tidx_blks_read,
- pg_statio_all_tables.tidx_blks_hit
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_statio_sys_tables| SELECT relid,
+ schemaname,
+ relname,
+ heap_blks_read,
+ heap_blks_hit,
+ idx_blks_read,
+ idx_blks_hit,
+ toast_blks_read,
+ toast_blks_hit,
+ tidx_blks_read,
+ tidx_blks_hit
FROM pg_statio_all_tables
- WHERE ((pg_statio_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_tables.schemaname ~ '^pg_toast'::text));
-pg_statio_user_indexes| SELECT pg_statio_all_indexes.relid,
- pg_statio_all_indexes.indexrelid,
- pg_statio_all_indexes.schemaname,
- pg_statio_all_indexes.relname,
- pg_statio_all_indexes.indexrelname,
- pg_statio_all_indexes.idx_blks_read,
- pg_statio_all_indexes.idx_blks_hit
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_statio_user_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_blks_read,
+ idx_blks_hit
FROM pg_statio_all_indexes
- WHERE ((pg_statio_all_indexes.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_indexes.schemaname !~ '^pg_toast'::text));
-pg_statio_user_sequences| SELECT pg_statio_all_sequences.relid,
- pg_statio_all_sequences.schemaname,
- pg_statio_all_sequences.relname,
- pg_statio_all_sequences.blks_read,
- pg_statio_all_sequences.blks_hit
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_statio_user_sequences| SELECT relid,
+ schemaname,
+ relname,
+ blks_read,
+ blks_hit
FROM pg_statio_all_sequences
- WHERE ((pg_statio_all_sequences.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_sequences.schemaname !~ '^pg_toast'::text));
-pg_statio_user_tables| SELECT pg_statio_all_tables.relid,
- pg_statio_all_tables.schemaname,
- pg_statio_all_tables.relname,
- pg_statio_all_tables.heap_blks_read,
- pg_statio_all_tables.heap_blks_hit,
- pg_statio_all_tables.idx_blks_read,
- pg_statio_all_tables.idx_blks_hit,
- pg_statio_all_tables.toast_blks_read,
- pg_statio_all_tables.toast_blks_hit,
- pg_statio_all_tables.tidx_blks_read,
- pg_statio_all_tables.tidx_blks_hit
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_statio_user_tables| SELECT relid,
+ schemaname,
+ relname,
+ heap_blks_read,
+ heap_blks_hit,
+ idx_blks_read,
+ idx_blks_hit,
+ toast_blks_read,
+ toast_blks_hit,
+ tidx_blks_read,
+ tidx_blks_hit
FROM pg_statio_all_tables
- WHERE ((pg_statio_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_tables.schemaname !~ '^pg_toast'::text));
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
pg_stats| SELECT n.nspname AS schemaname,
c.relname AS tablename,
a.attname,
@@ -2557,24 +2557,24 @@ pg_tables| SELECT n.nspname AS schemaname,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
LEFT JOIN pg_tablespace t ON ((t.oid = c.reltablespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 'p'::"char"]));
-pg_timezone_abbrevs| SELECT pg_timezone_abbrevs.abbrev,
- pg_timezone_abbrevs.utc_offset,
- pg_timezone_abbrevs.is_dst
+pg_timezone_abbrevs| SELECT abbrev,
+ utc_offset,
+ is_dst
FROM pg_timezone_abbrevs() pg_timezone_abbrevs(abbrev, utc_offset, is_dst);
-pg_timezone_names| SELECT pg_timezone_names.name,
- pg_timezone_names.abbrev,
- pg_timezone_names.utc_offset,
- pg_timezone_names.is_dst
+pg_timezone_names| SELECT name,
+ abbrev,
+ utc_offset,
+ is_dst
FROM pg_timezone_names() pg_timezone_names(name, abbrev, utc_offset, is_dst);
-pg_user| SELECT pg_shadow.usename,
- pg_shadow.usesysid,
- pg_shadow.usecreatedb,
- pg_shadow.usesuper,
- pg_shadow.userepl,
- pg_shadow.usebypassrls,
+pg_user| SELECT usename,
+ usesysid,
+ usecreatedb,
+ usesuper,
+ userepl,
+ usebypassrls,
'********'::text AS passwd,
- pg_shadow.valuntil,
- pg_shadow.useconfig
+ valuntil,
+ useconfig
FROM pg_shadow;
pg_user_mappings| SELECT u.oid AS umid,
s.oid AS srvid,
@@ -3079,7 +3079,7 @@ SELECT * FROM rule_v1;
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rule_t1.a
+ SELECT a
FROM rule_t1;
Rules:
newinsertrule AS
@@ -3118,8 +3118,8 @@ alter table rule_v1 rename column column2 to q2;
column1 | integer | | | | plain |
q2 | integer | | | | plain |
View definition:
- SELECT "*VALUES*".column1,
- "*VALUES*".column2 AS q2
+ SELECT column1,
+ column2 AS q2
FROM (VALUES (1,2)) "*VALUES*";
drop view rule_v1;
@@ -3131,8 +3131,8 @@ create view rule_v1(x) as values(1,2);
x | integer | | | | plain |
column2 | integer | | | | plain |
View definition:
- SELECT "*VALUES*".column1 AS x,
- "*VALUES*".column2
+ SELECT column1 AS x,
+ column2
FROM (VALUES (1,2)) "*VALUES*";
drop view rule_v1;
@@ -3144,8 +3144,8 @@ create view rule_v1(x) as select * from (values(1,2)) v;
x | integer | | | | plain |
column2 | integer | | | | plain |
View definition:
- SELECT v.column1 AS x,
- v.column2
+ SELECT column1 AS x,
+ column2
FROM ( VALUES (1,2)) v;
drop view rule_v1;
@@ -3157,8 +3157,8 @@ create view rule_v1(x) as select * from (values(1,2)) v(q,w);
x | integer | | | | plain |
w | integer | | | | plain |
View definition:
- SELECT v.q AS x,
- v.w
+ SELECT q AS x,
+ w
FROM ( VALUES (1,2)) v(q, w);
drop view rule_v1;
diff --git a/src/test/regress/expected/tablesample.out b/src/test/regress/expected/tablesample.out
index 60bb4e8e3e..9ff4611640 100644
--- a/src/test/regress/expected/tablesample.out
+++ b/src/test/regress/expected/tablesample.out
@@ -74,7 +74,7 @@ CREATE VIEW test_tablesample_v2 AS
--------+---------+-----------+----------+---------+---------+-------------
id | integer | | | | plain |
View definition:
- SELECT test_tablesample.id
+ SELECT id
FROM test_tablesample TABLESAMPLE system ((10 * 2)) REPEATABLE (2);
\d+ test_tablesample_v2
@@ -83,7 +83,7 @@ View definition:
--------+---------+-----------+----------+---------+---------+-------------
id | integer | | | | plain |
View definition:
- SELECT test_tablesample.id
+ SELECT id
FROM test_tablesample TABLESAMPLE system (99);
-- check a sampled query doesn't affect cursor in progress
diff --git a/src/test/regress/expected/triggers.out b/src/test/regress/expected/triggers.out
index 6d80ab1a6d..7dbeced570 100644
--- a/src/test/regress/expected/triggers.out
+++ b/src/test/regress/expected/triggers.out
@@ -1277,8 +1277,8 @@ DROP TRIGGER instead_of_delete_trig ON main_view;
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT main_table.a,
- main_table.b
+ SELECT a,
+ b
FROM main_table;
Triggers:
after_del_stmt_trig AFTER DELETE ON main_view FOR EACH STATEMENT EXECUTE FUNCTION view_trigger('after_view_del_stmt')
diff --git a/src/test/regress/expected/updatable_views.out b/src/test/regress/expected/updatable_views.out
index 5a47dacad9..2b578cced1 100644
--- a/src/test/regress/expected/updatable_views.out
+++ b/src/test/regress/expected/updatable_views.out
@@ -1925,19 +1925,19 @@ CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a < b
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT base_tbl.a,
- base_tbl.b
+ SELECT a,
+ b
FROM base_tbl
- WHERE base_tbl.a < base_tbl.b;
+ WHERE a < b;
Options: check_option=local
SELECT * FROM information_schema.views WHERE table_name = 'rw_view1';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+------------------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view1 | SELECT base_tbl.a, +| LOCAL | YES | YES | NO | NO | NO
- | | | base_tbl.b +| | | | | |
- | | | FROM base_tbl +| | | | | |
- | | | WHERE (base_tbl.a < base_tbl.b); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view1 | SELECT a, +| LOCAL | YES | YES | NO | NO | NO
+ | | | b +| | | | | |
+ | | | FROM base_tbl+| | | | | |
+ | | | WHERE (a < b); | | | | | |
(1 row)
INSERT INTO rw_view1 VALUES(3,4); -- ok
@@ -1978,17 +1978,17 @@ CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rw_view1.a
+ SELECT a
FROM rw_view1
- WHERE rw_view1.a < 10;
+ WHERE a < 10;
Options: check_option=cascaded
SELECT * FROM information_schema.views WHERE table_name = 'rw_view2';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+----------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view2 | SELECT rw_view1.a +| CASCADED | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a < 10); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view2 | SELECT a +| CASCADED | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a < 10); | | | | | |
(1 row)
INSERT INTO rw_view2 VALUES (-5); -- should fail
@@ -2018,17 +2018,17 @@ CREATE OR REPLACE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rw_view1.a
+ SELECT a
FROM rw_view1
- WHERE rw_view1.a < 10;
+ WHERE a < 10;
Options: check_option=local
SELECT * FROM information_schema.views WHERE table_name = 'rw_view2';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+----------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view2 | SELECT rw_view1.a +| LOCAL | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a < 10); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view2 | SELECT a +| LOCAL | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a < 10); | | | | | |
(1 row)
INSERT INTO rw_view2 VALUES (-10); -- ok, but not in view
@@ -2059,16 +2059,16 @@ ALTER VIEW rw_view2 RESET (check_option);
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rw_view1.a
+ SELECT a
FROM rw_view1
- WHERE rw_view1.a < 10;
+ WHERE a < 10;
SELECT * FROM information_schema.views WHERE table_name = 'rw_view2';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+----------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view2 | SELECT rw_view1.a +| NONE | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a < 10); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view2 | SELECT a +| NONE | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a < 10); | | | | | |
(1 row)
INSERT INTO rw_view2 VALUES (30); -- ok, but not in view
@@ -2090,15 +2090,15 @@ CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WITH CHECK OPTION;
CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a > 0;
CREATE VIEW rw_view3 AS SELECT * FROM rw_view2 WITH CHECK OPTION;
SELECT * FROM information_schema.views WHERE table_name LIKE E'rw\\_view_' ORDER BY table_name;
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+---------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view1 | SELECT base_tbl.a +| CASCADED | YES | YES | NO | NO | NO
- | | | FROM base_tbl; | | | | | |
- regression | public | rw_view2 | SELECT rw_view1.a +| NONE | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a > 0); | | | | | |
- regression | public | rw_view3 | SELECT rw_view2.a +| CASCADED | YES | YES | NO | NO | NO
- | | | FROM rw_view2; | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view1 | SELECT a +| CASCADED | YES | YES | NO | NO | NO
+ | | | FROM base_tbl; | | | | | |
+ regression | public | rw_view2 | SELECT a +| NONE | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a > 0); | | | | | |
+ regression | public | rw_view3 | SELECT a +| CASCADED | YES | YES | NO | NO | NO
+ | | | FROM rw_view2; | | | | | |
(3 rows)
INSERT INTO rw_view1 VALUES (-1); -- ok
diff --git a/src/test/regress/expected/window.out b/src/test/regress/expected/window.out
index 170bea23c2..3d1d26aa39 100644
--- a/src/test/regress/expected/window.out
+++ b/src/test/regress/expected/window.out
@@ -1212,10 +1212,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
----------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1238,10 +1238,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
------------------------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) AS sum_rows+
+ pg_get_viewdef
+-------------------------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1264,10 +1264,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
------------------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE GROUP) AS sum_rows+
+ pg_get_viewdef
+-------------------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE GROUP) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1290,10 +1290,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
-----------------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE TIES) AS sum_rows+
+ pg_get_viewdef
+------------------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE TIES) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1316,10 +1316,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
----------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1341,10 +1341,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
+ pg_get_viewdef
+-------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1353,10 +1353,10 @@ CREATE TEMP VIEW v_window AS
SELECT i, min(i) over (order by i range between '1 day' preceding and '10 days' following) as min_i
FROM generate_series(now(), now()+'100 days'::interval, '1 hour') i;
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
----------------------------------------------------------------------------------------------------------------------------
- SELECT i.i, +
- min(i.i) OVER (ORDER BY i.i RANGE BETWEEN '@ 1 day'::interval PRECEDING AND '@ 10 days'::interval FOLLOWING) AS min_i+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------------------------------------------
+ SELECT i, +
+ min(i) OVER (ORDER BY i RANGE BETWEEN '@ 1 day'::interval PRECEDING AND '@ 10 days'::interval FOLLOWING) AS min_i+
FROM generate_series(now(), (now() + '@ 100 days'::interval), '@ 1 hour'::interval) i(i);
(1 row)
diff --git a/src/test/regress/expected/with.out b/src/test/regress/expected/with.out
index f3fd1cd32a..008a8a9781 100644
--- a/src/test/regress/expected/with.out
+++ b/src/test/regress/expected/with.out
@@ -396,9 +396,9 @@ SELECT pg_get_viewdef('vsubdepartment'::regclass);
subdepartment sd +
WHERE (d.parent_department = sd.id)+
) +
- SELECT subdepartment.id, +
- subdepartment.parent_department, +
- subdepartment.name +
+ SELECT id, +
+ parent_department, +
+ name +
FROM subdepartment;
(1 row)
@@ -419,9 +419,9 @@ SELECT pg_get_viewdef('vsubdepartment'::regclass, true);
subdepartment sd +
WHERE d.parent_department = sd.id+
) +
- SELECT subdepartment.id, +
- subdepartment.parent_department, +
- subdepartment.name +
+ SELECT id, +
+ parent_department, +
+ name +
FROM subdepartment;
(1 row)
@@ -446,7 +446,7 @@ View definition:
FROM t t_1
WHERE t_1.n < 100
)
- SELECT sum(t.n) AS sum
+ SELECT sum(n) AS sum
FROM t;
-- corner case in which sub-WITH gets initialized first
@@ -959,9 +959,9 @@ select pg_get_viewdef('v_search');
search_graph sg +
WHERE (g.f = sg.t) +
) SEARCH DEPTH FIRST BY f, t SET seq +
- SELECT search_graph.f, +
- search_graph.t, +
- search_graph.label +
+ SELECT f, +
+ t, +
+ label +
FROM search_graph;
(1 row)
@@ -1524,9 +1524,9 @@ select pg_get_viewdef('v_cycle1');
search_graph sg +
WHERE (g.f = sg.t) +
) CYCLE f, t SET is_cycle USING path +
- SELECT search_graph.f, +
- search_graph.t, +
- search_graph.label +
+ SELECT f, +
+ t, +
+ label +
FROM search_graph;
(1 row)
@@ -1546,9 +1546,9 @@ select pg_get_viewdef('v_cycle2');
search_graph sg +
WHERE (g.f = sg.t) +
) CYCLE f, t SET is_cycle TO 'Y'::text DEFAULT 'N'::text USING path+
- SELECT search_graph.f, +
- search_graph.t, +
- search_graph.label +
+ SELECT f, +
+ t, +
+ label +
FROM search_graph;
(1 row)
diff --git a/src/test/regress/expected/xml.out b/src/test/regress/expected/xml.out
index 948b4e702c..cc213523c0 100644
--- a/src/test/regress/expected/xml.out
+++ b/src/test/regress/expected/xml.out
@@ -603,12 +603,12 @@ CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'xmlview%' ORDER BY 1;
- table_name | view_definition
-------------+-------------------------------------------------------------------------------------------------------------------
+ table_name | view_definition
+------------+------------------------------------------------------------------------------------------------------------
xmlview1 | SELECT xmlcomment('test'::text) AS xmlcomment;
xmlview2 | SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat";
xmlview3 | SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement";
- xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(emp.name AS name, emp.age AS age, emp.salary AS pay)) AS "xmlelement"+
+ xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(name AS name, age AS age, salary AS pay)) AS "xmlelement" +
| FROM emp;
xmlview5 | SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
xmlview6 | SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi";
diff --git a/src/test/regress/expected/xml_2.out b/src/test/regress/expected/xml_2.out
index 5fd3886b5e..3986fc1706 100644
--- a/src/test/regress/expected/xml_2.out
+++ b/src/test/regress/expected/xml_2.out
@@ -583,12 +583,12 @@ CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'xmlview%' ORDER BY 1;
- table_name | view_definition
-------------+-------------------------------------------------------------------------------------------------------------------
+ table_name | view_definition
+------------+------------------------------------------------------------------------------------------------------------
xmlview1 | SELECT xmlcomment('test'::text) AS xmlcomment;
xmlview2 | SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat";
xmlview3 | SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement";
- xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(emp.name AS name, emp.age AS age, emp.salary AS pay)) AS "xmlelement"+
+ xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(name AS name, age AS age, salary AS pay)) AS "xmlelement" +
| FROM emp;
xmlview5 | SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
xmlview6 | SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi";
--
2.35.3
Amit Langote <amitlangote09@gmail.com> writes:
I've attached just the patch that we should move forward with, as
Alvaro might agree.
I've looked at this briefly but don't like it very much, specifically
the business about retroactively adding an RTE and RTEPermissionInfo
into the view's replacement subquery. That seems expensive and bug-prone:
if you're going to do that you might as well just leave the OLD entry
in place, as the earlier patch did, because you're just reconstructing
that same state of the parsetree a bit later on.
Furthermore, if that's where we end up then I'm not really sure this is
worth doing at all. The idea driving this was that if we could get rid
of *both* OLD and NEW RTE entries then we'd not have O(N^2) behavior in
deep subquery pull-ups due to the rangetable getting longer with each one.
But getting it down from two extra entries to one extra entry isn't going
to fix that big-O problem. (The patch as presented still has O(N^2)
planning time for the nested-views example discussed earlier.)
Conceivably we could make it work by allowing RTE_SUBQUERY RTEs to
carry a relation OID and associated RTEPermissionInfo, so that when a
view's RTE_RELATION RTE is transmuted to an RTE_SUBQUERY RTE it still
carries the info needed to let us lock and permission-check the view.
That might be a bridge too far from the ugliness perspective ...
although certainly the business with OLD and/or NEW RTEs isn't very
pretty either.
Anyway, if you don't feel like tackling that then I'd go back to the
patch version that kept the OLD RTE. (Maybe we could rename that to
something else, though, such as "*VIEW*"?)
BTW, I don't entirely understand why this patch is passing regression
tests, because it's failed to deal with numerous places that have
hard-wired knowledge about these extra RTEs. Look for references to
PRS2_OLD_VARNO and PRS2_NEW_VARNO. I think the original rationale
for UpdateRangeTableOfViewParse was that we needed to keep the rtables
of ON SELECT rules looking similar to those of other types of rules.
Maybe we've cleaned up all the places that used to depend on that,
but I'm not convinced.
regards, tom lane
On Mon, Jan 9, 2023 at 5:58 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Amit Langote <amitlangote09@gmail.com> writes:
I've attached just the patch that we should move forward with, as
Alvaro might agree.I've looked at this briefly but don't like it very much, specifically
the business about retroactively adding an RTE and RTEPermissionInfo
into the view's replacement subquery. That seems expensive and bug-prone:
if you're going to do that you might as well just leave the OLD entry
in place, as the earlier patch did, because you're just reconstructing
that same state of the parsetree a bit later on.Furthermore, if that's where we end up then I'm not really sure this is
worth doing at all. The idea driving this was that if we could get rid
of *both* OLD and NEW RTE entries then we'd not have O(N^2) behavior in
deep subquery pull-ups due to the rangetable getting longer with each one.
But getting it down from two extra entries to one extra entry isn't going
to fix that big-O problem. (The patch as presented still has O(N^2)
planning time for the nested-views example discussed earlier.)
Hmm, that's true.
Conceivably we could make it work by allowing RTE_SUBQUERY RTEs to
carry a relation OID and associated RTEPermissionInfo, so that when a
view's RTE_RELATION RTE is transmuted to an RTE_SUBQUERY RTE it still
carries the info needed to let us lock and permission-check the view.
That might be a bridge too far from the ugliness perspective ...
although certainly the business with OLD and/or NEW RTEs isn't very
pretty either.
I had thought about that idea but was a bit scared of trying it,
because it does sound like something that might become a maintenance
burden in the future. Though I gave that a try today given that it
sounds like I may have your permission. ;-)
So, in the attached updated version, I removed the bits of
ApplyRetrieveRule() that would add the placeholder entry (OLD) and
also the existing lines that would reset relid, rellockmode, and
perminfoindex of the view RTE that's converted into a RTE_SUBQUERY
one. Then I fixed places to deal with subquery RTEs sometimes having
the relid, etc. set, just enough to pass make check-world. I was
surprised that nothing failed with a -DWRITE_READ_PARSE_PLAN_TREES
build, because of the way RTEs are written and read -- relid,
rellockmode are not written/read for RTE_SUBQUERY RTEs.
BTW, I don't entirely understand why this patch is passing regression
tests, because it's failed to deal with numerous places that have
hard-wired knowledge about these extra RTEs. Look for references to
PRS2_OLD_VARNO and PRS2_NEW_VARNO. I think the original rationale
for UpdateRangeTableOfViewParse was that we needed to keep the rtables
of ON SELECT rules looking similar to those of other types of rules.
Maybe we've cleaned up all the places that used to depend on that,
but I'm not convinced.
AFAICS, the places that still have hard-wired knowledge of these
placeholder RTEs only manipulate non-SELECT rules, so don't care about
views.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com
Attachments:
v3-0001-Remove-UpdateRangeTableOfViewParse.patchapplication/x-patch; name=v3-0001-Remove-UpdateRangeTableOfViewParse.patchDownload
From 4fb53528ccaab3c8b82e887419ead3141b2fc342 Mon Sep 17 00:00:00 2001
From: amitlan <amitlangote09@gmail.com>
Date: Fri, 9 Dec 2022 10:33:59 +0900
Subject: [PATCH v3] Remove UpdateRangeTableOfViewParse()
And with it, the OLD and the NEW placeholder RTEs that are stored in
a view's stored rule action query.
The OLD RTE is needed currently as a placeholder for carrying view
relation info when querying a given view, because the view relation's
RTE in the query's range table is transposed into a subquery RTE for
converting the view's query into a subselect of the user query.
The NEW RTE is currently not needed for anything.
The purpose served by the OLD RTE will now be served by the view's
converted subquery RTE by making the latter carry the locking info
(view OID and lockmode) and point to the RTEPermissionInfo of the
original relation RTE of the view.
This changes the format of the store rule for views, especially the
range table length, so a bunch of regression tests that show deparsed
view queries need to be adjusted to cope.
---
.../postgres_fdw/expected/postgres_fdw.out | 16 +-
src/backend/commands/lockcmds.c | 9 -
src/backend/commands/view.c | 107 ---
src/backend/optimizer/plan/setrefs.c | 10 +-
src/backend/parser/parse_relation.c | 2 +-
src/backend/rewrite/rewriteDefine.c | 7 -
src/backend/rewrite/rewriteHandler.c | 35 +-
src/backend/utils/cache/plancache.c | 3 +-
src/bin/pg_dump/t/002_pg_dump.pl | 12 +-
src/include/nodes/parsenodes.h | 4 +
src/test/regress/expected/aggregates.out | 26 +-
src/test/regress/expected/alter_table.out | 16 +-
.../regress/expected/collate.icu.utf8.out | 24 +-
.../regress/expected/collate.linux.utf8.out | 24 +-
src/test/regress/expected/collate.out | 26 +-
src/test/regress/expected/compression.out | 4 +-
src/test/regress/expected/create_view.out | 222 +++---
src/test/regress/expected/expressions.out | 24 +-
src/test/regress/expected/groupingsets.out | 20 +-
src/test/regress/expected/limit.out | 24 +-
src/test/regress/expected/matview.out | 24 +-
src/test/regress/expected/polymorphism.out | 8 +-
src/test/regress/expected/rangefuncs.out | 34 +-
src/test/regress/expected/rules.out | 748 +++++++++---------
src/test/regress/expected/tablesample.out | 4 +-
src/test/regress/expected/triggers.out | 4 +-
src/test/regress/expected/updatable_views.out | 78 +-
src/test/regress/expected/window.out | 56 +-
src/test/regress/expected/with.out | 32 +-
src/test/regress/expected/xml.out | 6 +-
src/test/regress/expected/xml_2.out | 6 +-
31 files changed, 741 insertions(+), 874 deletions(-)
diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out
index c0267a99d2..9d3c9becf3 100644
--- a/contrib/postgres_fdw/expected/postgres_fdw.out
+++ b/contrib/postgres_fdw/expected/postgres_fdw.out
@@ -2606,7 +2606,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1
Foreign Scan
Output: ft4.c1, ft5.c2, ft5.c1
Relations: (public.ft4) LEFT JOIN (public.ft5)
- Remote SQL: SELECT r6.c1, r9.c2, r9.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r9 ON (((r6.c1 = r9.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r9.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r4.c1, r5.c2, r5.c1 FROM ("S 1"."T 3" r4 LEFT JOIN "S 1"."T 4" r5 ON (((r4.c1 = r5.c1)))) ORDER BY r4.c1 ASC NULLS LAST, r5.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
@@ -2669,7 +2669,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c
Foreign Scan
Output: ft4.c1, t2.c2, t2.c1
Relations: (public.ft4) LEFT JOIN (public.ft5 t2)
- Remote SQL: SELECT r6.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r6 LEFT JOIN "S 1"."T 4" r2 ON (((r6.c1 = r2.c1)))) ORDER BY r6.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
+ Remote SQL: SELECT r4.c1, r2.c2, r2.c1 FROM ("S 1"."T 3" r4 LEFT JOIN "S 1"."T 4" r2 ON (((r4.c1 = r2.c1)))) ORDER BY r4.c1 ASC NULLS LAST, r2.c1 ASC NULLS LAST LIMIT 10::bigint OFFSET 10::bigint
(4 rows)
SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
@@ -6557,10 +6557,10 @@ CREATE VIEW rw_view AS SELECT * FROM foreign_tbl
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT foreign_tbl.a,
- foreign_tbl.b
+ SELECT a,
+ b
FROM foreign_tbl
- WHERE foreign_tbl.a < foreign_tbl.b;
+ WHERE a < b;
Options: check_option=cascaded
EXPLAIN (VERBOSE, COSTS OFF)
@@ -6674,10 +6674,10 @@ CREATE VIEW rw_view AS SELECT * FROM parent_tbl
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT parent_tbl.a,
- parent_tbl.b
+ SELECT a,
+ b
FROM parent_tbl
- WHERE parent_tbl.a < parent_tbl.b;
+ WHERE a < b;
Options: check_option=cascaded
EXPLAIN (VERBOSE, COSTS OFF)
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index 99e68bff85..9755d6ed13 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -194,15 +194,6 @@ LockViewRecurse_walker(Node *node, LockViewRecurse_context *context)
char relkind = rte->relkind;
char *relname = get_rel_name(relid);
- /*
- * The OLD and NEW placeholder entries in the view's rtable are
- * skipped.
- */
- if (relid == context->viewoid &&
- (strcmp(rte->eref->aliasname, "old") == 0 ||
- strcmp(rte->eref->aliasname, "new") == 0))
- continue;
-
/* Currently, we only allow plain tables or views to be locked. */
if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE &&
relkind != RELKIND_VIEW)
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index 0bacb819e5..ff98c773f5 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -353,107 +353,6 @@ DefineViewRules(Oid viewOid, Query *viewParse, bool replace)
*/
}
-/*---------------------------------------------------------------
- * UpdateRangeTableOfViewParse
- *
- * Update the range table of the given parsetree.
- * This update consists of adding two new entries IN THE BEGINNING
- * of the range table (otherwise the rule system will die a slow,
- * horrible and painful death, and we do not want that now, do we?)
- * one for the OLD relation and one for the NEW one (both of
- * them refer in fact to the "view" relation).
- *
- * Of course we must also increase the 'varnos' of all the Var nodes
- * by 2...
- *
- * These extra RT entries are not actually used in the query,
- * except for run-time locking.
- *---------------------------------------------------------------
- */
-static Query *
-UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
-{
- Relation viewRel;
- List *new_rt;
- ParseNamespaceItem *nsitem;
- RangeTblEntry *rt_entry1,
- *rt_entry2;
- RTEPermissionInfo *rte_perminfo1;
- ParseState *pstate;
- ListCell *lc;
-
- /*
- * Make a copy of the given parsetree. It's not so much that we don't
- * want to scribble on our input, it's that the parser has a bad habit of
- * outputting multiple links to the same subtree for constructs like
- * BETWEEN, and we mustn't have OffsetVarNodes increment the varno of a
- * Var node twice. copyObject will expand any multiply-referenced subtree
- * into multiple copies.
- */
- viewParse = copyObject(viewParse);
-
- /* Create a dummy ParseState for addRangeTableEntryForRelation */
- pstate = make_parsestate(NULL);
-
- /* need to open the rel for addRangeTableEntryForRelation */
- viewRel = relation_open(viewOid, AccessShareLock);
-
- /*
- * Create the 2 new range table entries and form the new range table...
- * OLD first, then NEW....
- */
- nsitem = addRangeTableEntryForRelation(pstate, viewRel,
- AccessShareLock,
- makeAlias("old", NIL),
- false, false);
- rt_entry1 = nsitem->p_rte;
- rte_perminfo1 = nsitem->p_perminfo;
- nsitem = addRangeTableEntryForRelation(pstate, viewRel,
- AccessShareLock,
- makeAlias("new", NIL),
- false, false);
- rt_entry2 = nsitem->p_rte;
-
- /*
- * Add only the "old" RTEPermissionInfo at the head of view query's list
- * and update the other RTEs' perminfoindex accordingly. When rewriting a
- * query on the view, ApplyRetrieveRule() will transfer the view
- * relation's permission details into this RTEPermissionInfo. That's
- * needed because the view's RTE itself will be transposed into a subquery
- * RTE that can't carry the permission details; see the code stanza toward
- * the end of ApplyRetrieveRule() for how that's done.
- */
- viewParse->rteperminfos = lcons(rte_perminfo1, viewParse->rteperminfos);
- foreach(lc, viewParse->rtable)
- {
- RangeTblEntry *rte = lfirst(lc);
-
- if (rte->perminfoindex > 0)
- rte->perminfoindex += 1;
- }
-
- /*
- * Also make the "new" RTE's RTEPermissionInfo undiscoverable. This is a
- * bit of a hack given that all the non-child RTE_RELATION entries really
- * should have a RTEPermissionInfo, but this dummy "new" RTE is going to
- * go away anyway in the very near future.
- */
- rt_entry2->perminfoindex = 0;
-
- new_rt = lcons(rt_entry1, lcons(rt_entry2, viewParse->rtable));
-
- viewParse->rtable = new_rt;
-
- /*
- * Now offset all var nodes by 2, and jointree RT indexes too.
- */
- OffsetVarNodes((Node *) viewParse, 2, 0);
-
- relation_close(viewRel, AccessShareLock);
-
- return viewParse;
-}
-
/*
* DefineView
* Execute a CREATE VIEW command.
@@ -616,12 +515,6 @@ DefineView(ViewStmt *stmt, const char *queryString,
void
StoreViewQuery(Oid viewOid, Query *viewParse, bool replace)
{
- /*
- * The range table of 'viewParse' does not contain entries for the "OLD"
- * and "NEW" relations. So... add them!
- */
- viewParse = UpdateRangeTableOfViewParse(viewOid, viewParse);
-
/*
* Now create the rules associated with the view.
*/
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c
index ed9c1e6187..cc7c09d953 100644
--- a/src/backend/optimizer/plan/setrefs.c
+++ b/src/backend/optimizer/plan/setrefs.c
@@ -411,7 +411,8 @@ add_rtes_to_flat_rtable(PlannerInfo *root, bool recursing)
{
RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
- if (!recursing || rte->rtekind == RTE_RELATION)
+ if (!recursing || rte->rtekind == RTE_RELATION ||
+ (rte->rtekind == RTE_SUBQUERY && OidIsValid(rte->relid)))
add_rte_to_flat_rtable(glob, root->parse->rteperminfos, rte);
}
@@ -502,7 +503,7 @@ flatten_rtes_walker(Node *node, flatten_rtes_walker_context *cxt)
RangeTblEntry *rte = (RangeTblEntry *) node;
/* As above, we need only save relation RTEs */
- if (rte->rtekind == RTE_RELATION)
+ if (rte->rtekind == RTE_RELATION || OidIsValid(rte->relid))
add_rte_to_flat_rtable(cxt->glob, cxt->query->rteperminfos, rte);
return false;
}
@@ -570,7 +571,7 @@ add_rte_to_flat_rtable(PlannerGlobal *glob, List *rteperminfos,
* Note we don't bother to avoid making duplicate list entries. We could,
* but it would probably cost more cycles than it would save.
*/
- if (newrte->rtekind == RTE_RELATION)
+ if (OidIsValid(newrte->relid))
glob->relationOids = lappend_oid(glob->relationOids, newrte->relid);
/*
@@ -3411,6 +3412,9 @@ extract_query_dependencies_walker(Node *node, PlannerInfo *context)
context->glob->relationOids =
lappend_oid(context->glob->relationOids,
rte->relid);
+ else if (rte->rtekind == RTE_SUBQUERY && OidIsValid(rte->relid))
+ context->glob->relationOids =
+ lappend_oid(context->glob->relationOids, rte->relid);
}
/* And recurse into the query's subexpressions */
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 5389a0eddb..b490541f03 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -3834,7 +3834,7 @@ addRTEPermissionInfo(List **rteperminfos, RangeTblEntry *rte)
{
RTEPermissionInfo *perminfo;
- Assert(rte->rtekind == RTE_RELATION);
+ Assert(OidIsValid(rte->relid));
Assert(rte->perminfoindex == 0);
/* Nope, so make one and add to the list. */
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index 5227220288..e36fc72e1e 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -633,13 +633,6 @@ checkRuleResultList(List *targetList, TupleDesc resultDesc, bool isSelect,
* setRuleCheckAsUser
* Recursively scan a query or expression tree and set the checkAsUser
* field to the given userid in all RTEPermissionInfos of the query.
- *
- * Note: for a view (ON SELECT rule), the checkAsUser field of the OLD
- * RTE entry's RTEPermissionInfo will be overridden when the view rule is
- * expanded, and the checkAsUser for the NEW RTE entry's RTEPermissionInfo is
- * irrelevant because its requiredPerms bits will always be zero. However, for
- * other types of rules it's important to set these fields to match the rule
- * owner. So we just set them always.
*/
void
setRuleCheckAsUser(Node *node, Oid userid)
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index 1960dad701..493fbc0d88 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -1715,10 +1715,7 @@ ApplyRetrieveRule(Query *parsetree,
List *activeRIRs)
{
Query *rule_action;
- RangeTblEntry *rte,
- *subrte;
- RTEPermissionInfo *perminfo,
- *sub_perminfo;
+ RangeTblEntry *rte;
RowMarkClause *rc;
if (list_length(rule->actions) != 1)
@@ -1827,36 +1824,23 @@ ApplyRetrieveRule(Query *parsetree,
/*
* Now, plug the view query in as a subselect, converting the relation's
- * original RTE to a subquery RTE.
+ * original RTE to a subquery RTE, while keeping the relid, rtelockmode,
+ * and perminfoindex set, so that the view relation is appropriately
+ * locked before execution and its permissions checked.
*/
rte = rt_fetch(rt_index, parsetree->rtable);
- perminfo = getRTEPermissionInfo(parsetree->rteperminfos, rte);
rte->rtekind = RTE_SUBQUERY;
rte->subquery = rule_action;
rte->security_barrier = RelationIsSecurityView(relation);
- /* Clear fields that should not be set in a subquery RTE */
- rte->relid = InvalidOid;
+ /*
+ * Clear fields that should not be set in a subquery RTE, except those
+ * mentioned above.
+ */
rte->relkind = 0;
- rte->rellockmode = 0;
rte->tablesample = NULL;
- rte->perminfoindex = 0; /* no permission checking for this RTE */
rte->inh = false; /* must not be set for a subquery */
- /*
- * We move the view's permission check data down to its RTEPermissionInfo
- * contained in the view query, which the OLD entry in its range table
- * points to.
- */
- subrte = rt_fetch(PRS2_OLD_VARNO, rule_action->rtable);
- Assert(subrte->relid == relation->rd_id);
- sub_perminfo = getRTEPermissionInfo(rule_action->rteperminfos, subrte);
- sub_perminfo->requiredPerms = perminfo->requiredPerms;
- sub_perminfo->checkAsUser = perminfo->checkAsUser;
- sub_perminfo->selectedCols = perminfo->selectedCols;
- sub_perminfo->insertedCols = perminfo->insertedCols;
- sub_perminfo->updatedCols = perminfo->updatedCols;
-
return parsetree;
}
@@ -1867,9 +1851,6 @@ ApplyRetrieveRule(Query *parsetree,
* aggregate. We leave it to the planner to detect that.
*
* NB: this must agree with the parser's transformLockingClause() routine.
- * However, unlike the parser we have to be careful not to mark a view's
- * OLD and NEW rels for updating. The best way to handle that seems to be
- * to scan the jointree to determine which rels are used.
*/
static void
markQueryForLocking(Query *qry, Node *jtnode,
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c
index 92f6d5795f..86b54cdf66 100644
--- a/src/backend/utils/cache/plancache.c
+++ b/src/backend/utils/cache/plancache.c
@@ -1769,7 +1769,8 @@ AcquireExecutorLocks(List *stmt_list, bool acquire)
{
RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc2);
- if (rte->rtekind != RTE_RELATION)
+ if (rte->rtekind != RTE_RELATION ||
+ (rte->rtekind == RTE_SUBQUERY && !OidIsValid(rte->relid)))
continue;
/*
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 2eeef2a478..d92247c915 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -2280,7 +2280,7 @@ my %tests = (
SELECT col1 FROM dump_test.test_table;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview AS\E
- \n\s+\QSELECT test_table.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2296,7 +2296,7 @@ my %tests = (
SELECT * FROM dump_test.matview;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_second AS\E
- \n\s+\QSELECT matview.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2312,7 +2312,7 @@ my %tests = (
SELECT * FROM dump_test.matview_second WITH NO DATA;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_third AS\E
- \n\s+\QSELECT matview_second.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview_second\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2328,7 +2328,7 @@ my %tests = (
SELECT * FROM dump_test.matview_third WITH NO DATA;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_fourth AS\E
- \n\s+\QSELECT matview_third.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview_third\E
\n\s+\QWITH NO DATA;\E
/xm,
@@ -2346,7 +2346,7 @@ my %tests = (
ALTER COLUMN col2 SET COMPRESSION lz4;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_compression AS\E
- \n\s+\QSELECT test_table.col2\E
+ \n\s+\QSELECT col2\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH NO DATA;\E
.*
@@ -3342,7 +3342,7 @@ my %tests = (
SELECT col1 FROM dump_test.test_table;',
regexp => qr/^
\QCREATE VIEW dump_test.test_view WITH (security_barrier='true') AS\E
- \n\s+\QSELECT test_table.col1\E
+ \n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH LOCAL CHECK OPTION;\E/xm,
like =>
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index cfeca96d53..0d1b0fc5ba 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -1025,6 +1025,10 @@ typedef struct RangeTblEntry
* target table. We leave such RTEs with their original lockmode so as to
* avoid getting an additional, lesser lock.
*
+ * Note: There's a hack in ApplyRetrieveRule() that converts a view
+ * relation's RTE_RELATION entry to become an RTE_SUBQUERY entry, while
+ * still keeping relid and perminfoindex set.
+ *
* perminfoindex is 1-based index of the RTEPermissionInfo belonging to
* this RTE in the containing struct's list of same; 0 if permissions need
* not be checked for this RTE.
diff --git a/src/test/regress/expected/aggregates.out b/src/test/regress/expected/aggregates.out
index 309c2dc865..ea6dcd1c48 100644
--- a/src/test/regress/expected/aggregates.out
+++ b/src/test/regress/expected/aggregates.out
@@ -1634,7 +1634,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.b, v.c) AS aggfns +
+ SELECT aggfns(a, b, c) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -1686,7 +1686,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.b, v.c ORDER BY (v.b + 1)) AS aggfns +
+ SELECT aggfns(a, b, c ORDER BY (b + 1)) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -1702,7 +1702,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.a, v.c ORDER BY v.b) AS aggfns +
+ SELECT aggfns(a, a, c ORDER BY b) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -1718,7 +1718,7 @@ select * from agg_view1;
select pg_get_viewdef('agg_view1'::regclass);
pg_get_viewdef
---------------------------------------------------------------------------------------------------------------------
- SELECT aggfns(v.a, v.b, v.c ORDER BY v.c USING ~<~ NULLS LAST) AS aggfns +
+ SELECT aggfns(a, b, c ORDER BY c USING ~<~ NULLS LAST) AS aggfns +
FROM ( VALUES (1,3,'foo'::text), (0,NULL::integer,NULL::text), (2,2,'bar'::text), (3,1,'baz'::text)) v(a, b, c);
(1 row)
@@ -2203,15 +2203,15 @@ select ten,
from tenk1
group by ten order by ten;
select pg_get_viewdef('aggordview1');
- pg_get_viewdef
--------------------------------------------------------------------------------------------------------------------------------
- SELECT tenk1.ten, +
- percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY tenk1.thousand) AS p50, +
- percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY tenk1.thousand) FILTER (WHERE (tenk1.hundred = 1)) AS px,+
- rank(5, 'AZZZZ'::name, 50) WITHIN GROUP (ORDER BY tenk1.hundred, tenk1.string4 DESC, tenk1.hundred) AS rank +
- FROM tenk1 +
- GROUP BY tenk1.ten +
- ORDER BY tenk1.ten;
+ pg_get_viewdef
+-------------------------------------------------------------------------------------------------------------------
+ SELECT ten, +
+ percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY thousand) AS p50, +
+ percentile_disc((0.5)::double precision) WITHIN GROUP (ORDER BY thousand) FILTER (WHERE (hundred = 1)) AS px,+
+ rank(5, 'AZZZZ'::name, 50) WITHIN GROUP (ORDER BY hundred, string4 DESC, hundred) AS rank +
+ FROM tenk1 +
+ GROUP BY ten +
+ ORDER BY ten;
(1 row)
select * from aggordview1 order by ten;
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 600e603bdf..9e5f6c1a80 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -2493,8 +2493,8 @@ create view at_view_2 as select *, to_json(v1) as j from at_view_1 v1;
id | integer | | | | plain |
stuff | text | | | | extended |
View definition:
- SELECT bt.id,
- bt.stuff
+ SELECT id,
+ stuff
FROM at_base_table bt;
\d+ at_view_2
@@ -2505,8 +2505,8 @@ View definition:
stuff | text | | | | extended |
j | json | | | | extended |
View definition:
- SELECT v1.id,
- v1.stuff,
+ SELECT id,
+ stuff,
to_json(v1.*) AS j
FROM at_view_1 v1;
@@ -2532,8 +2532,8 @@ create or replace view at_view_1 as select *, 2+2 as more from at_base_table bt;
stuff | text | | | | extended |
more | integer | | | | plain |
View definition:
- SELECT bt.id,
- bt.stuff,
+ SELECT id,
+ stuff,
2 + 2 AS more
FROM at_base_table bt;
@@ -2545,8 +2545,8 @@ View definition:
stuff | text | | | | extended |
j | json | | | | extended |
View definition:
- SELECT v1.id,
- v1.stuff,
+ SELECT id,
+ stuff,
to_json(v1.*) AS j
FROM at_view_1 v1;
diff --git a/src/test/regress/expected/collate.icu.utf8.out b/src/test/regress/expected/collate.icu.utf8.out
index d4c8c6de38..4354dc07b8 100644
--- a/src/test/regress/expected/collate.icu.utf8.out
+++ b/src/test/regress/expected/collate.icu.utf8.out
@@ -446,18 +446,18 @@ CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10;
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name | view_definition
-------------+--------------------------------------------------------------------------
- collview1 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | ORDER BY (collate_test1.b COLLATE "C");
- collview3 | SELECT collate_test10.a, +
- | lower(((collate_test10.x || collate_test10.x) COLLATE "C")) AS lower+
+ table_name | view_definition
+------------+--------------------------------------------
+ collview1 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | WHERE ((b COLLATE "C") >= 'bbc'::text);
+ collview2 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | ORDER BY (b COLLATE "C");
+ collview3 | SELECT a, +
+ | lower(((x || x) COLLATE "C")) AS lower+
| FROM collate_test10;
(3 rows)
diff --git a/src/test/regress/expected/collate.linux.utf8.out b/src/test/regress/expected/collate.linux.utf8.out
index f2d0eb94f2..2098696ec2 100644
--- a/src/test/regress/expected/collate.linux.utf8.out
+++ b/src/test/regress/expected/collate.linux.utf8.out
@@ -483,18 +483,18 @@ CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10;
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name | view_definition
-------------+--------------------------------------------------------------------------
- collview1 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | ORDER BY (collate_test1.b COLLATE "C");
- collview3 | SELECT collate_test10.a, +
- | lower(((collate_test10.x || collate_test10.x) COLLATE "C")) AS lower+
+ table_name | view_definition
+------------+--------------------------------------------
+ collview1 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | WHERE ((b COLLATE "C") >= 'bbc'::text);
+ collview2 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | ORDER BY (b COLLATE "C");
+ collview3 | SELECT a, +
+ | lower(((x || x) COLLATE "C")) AS lower+
| FROM collate_test10;
(3 rows)
diff --git a/src/test/regress/expected/collate.out b/src/test/regress/expected/collate.out
index 246832575c..0649564485 100644
--- a/src/test/regress/expected/collate.out
+++ b/src/test/regress/expected/collate.out
@@ -194,18 +194,18 @@ CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C";
CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "POSIX") FROM collate_test10;
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'collview%' ORDER BY 1;
- table_name | view_definition
-------------+------------------------------------------------------------------------------
- collview1 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | WHERE ((collate_test1.b COLLATE "C") >= 'bbc'::text);
- collview2 | SELECT collate_test1.a, +
- | collate_test1.b +
- | FROM collate_test1 +
- | ORDER BY (collate_test1.b COLLATE "C");
- collview3 | SELECT collate_test10.a, +
- | lower(((collate_test10.x || collate_test10.x) COLLATE "POSIX")) AS lower+
+ table_name | view_definition
+------------+------------------------------------------------
+ collview1 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | WHERE ((b COLLATE "C") >= 'bbc'::text);
+ collview2 | SELECT a, +
+ | b +
+ | FROM collate_test1 +
+ | ORDER BY (b COLLATE "C");
+ collview3 | SELECT a, +
+ | lower(((x || x) COLLATE "POSIX")) AS lower+
| FROM collate_test10;
(3 rows)
@@ -698,7 +698,7 @@ SELECT c1+1 AS c1p FROM
--------+---------+-----------+----------+---------+---------+-------------
c1p | integer | | | | plain |
View definition:
- SELECT ss.c1 + 1 AS c1p
+ SELECT c1 + 1 AS c1p
FROM ( SELECT 4 AS c1) ss;
-- Check conflicting or redundant options in CREATE COLLATION
diff --git a/src/test/regress/expected/compression.out b/src/test/regress/expected/compression.out
index 4c997e2602..e06ac93a36 100644
--- a/src/test/regress/expected/compression.out
+++ b/src/test/regress/expected/compression.out
@@ -187,7 +187,7 @@ CREATE MATERIALIZED VIEW compressmv(x) AS SELECT * FROM cmdata1;
--------+------+-----------+----------+---------+----------+-------------+--------------+-------------
x | text | | | | extended | | |
View definition:
- SELECT cmdata1.f1 AS x
+ SELECT f1 AS x
FROM cmdata1;
SELECT pg_column_compression(f1) FROM cmdata1;
@@ -274,7 +274,7 @@ ALTER MATERIALIZED VIEW compressmv ALTER COLUMN x SET COMPRESSION lz4;
--------+------+-----------+----------+---------+----------+-------------+--------------+-------------
x | text | | | | extended | lz4 | |
View definition:
- SELECT cmdata1.f1 AS x
+ SELECT f1 AS x
FROM cmdata1;
-- test alter compression method for partitioned tables
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out
index 17ca29ddbf..61825ef7d4 100644
--- a/src/test/regress/expected/create_view.out
+++ b/src/test/regress/expected/create_view.out
@@ -395,10 +395,10 @@ CREATE VIEW tt1 AS
c | numeric | | | | main |
d | character varying(4) | | | | extended |
View definition:
- SELECT vv.a,
- vv.b,
- vv.c,
- vv.d
+ SELECT a,
+ b,
+ c,
+ d
FROM ( VALUES ('abc'::character varying(3),'0123456789'::character varying,42,'abcd'::character varying(4)), ('0123456789'::character varying,'abc'::character varying(3),42.12,'abc'::character varying(4))) vv(a, b, c, d);
SELECT * FROM tt1;
@@ -440,9 +440,9 @@ CREATE VIEW aliased_view_4 AS
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM tx1
@@ -456,9 +456,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1 a1
WHERE (EXISTS ( SELECT 1
FROM tx1
@@ -472,9 +472,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM tx1 a2
@@ -488,9 +488,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM tt1 tt1_1
@@ -505,9 +505,9 @@ ALTER TABLE tx1 RENAME TO a1;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM a1
@@ -521,9 +521,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1 a1
WHERE (EXISTS ( SELECT 1
FROM a1 a1_1
@@ -537,9 +537,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.f1,
- tt1.f2,
- tt1.f3
+ SELECT f1,
+ f2,
+ f3
FROM tt1
WHERE (EXISTS ( SELECT 1
FROM a1 a2
@@ -553,9 +553,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM tt1 tt1_1
@@ -570,9 +570,9 @@ ALTER TABLE tt1 RENAME TO a2;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM a1
@@ -586,9 +586,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2 a1
WHERE (EXISTS ( SELECT 1
FROM a1 a1_1
@@ -602,9 +602,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM a1 a2_1
@@ -618,9 +618,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM a2
@@ -635,9 +635,9 @@ ALTER TABLE a1 RENAME TO tt1;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -651,9 +651,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2 a1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -667,9 +667,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a2.f1,
- a2.f2,
- a2.f3
+ SELECT f1,
+ f2,
+ f3
FROM a2
WHERE (EXISTS ( SELECT 1
FROM tt1 a2_1
@@ -683,9 +683,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM a2
@@ -701,9 +701,9 @@ ALTER TABLE tx1 SET SCHEMA temp_view_test;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -717,9 +717,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1 a1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -733,9 +733,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1 a2
@@ -749,9 +749,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tt1.y1,
- tt1.f2,
- tt1.f3
+ SELECT y1,
+ f2,
+ f3
FROM temp_view_test.tt1
WHERE (EXISTS ( SELECT 1
FROM temp_view_test.tx1
@@ -768,9 +768,9 @@ ALTER TABLE tmp1 RENAME TO tx1;
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -784,9 +784,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT a1.f1,
- a1.f2,
- a1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1 a1
WHERE (EXISTS ( SELECT 1
FROM tt1
@@ -800,9 +800,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.f1,
- tx1.f2,
- tx1.f3
+ SELECT f1,
+ f2,
+ f3
FROM temp_view_test.tx1
WHERE (EXISTS ( SELECT 1
FROM tt1 a2
@@ -816,9 +816,9 @@ View definition:
f2 | integer | | | | plain |
f3 | text | | | | extended |
View definition:
- SELECT tx1.y1,
- tx1.f2,
- tx1.f3
+ SELECT y1,
+ f2,
+ f3
FROM tx1
WHERE (EXISTS ( SELECT 1
FROM temp_view_test.tx1 tx1_1
@@ -1305,10 +1305,10 @@ select pg_get_viewdef('v1', true);
select pg_get_viewdef('v4', true);
pg_get_viewdef
----------------
- SELECT v1.b, +
- v1.c, +
- v1.x AS a,+
- v1.ax +
+ SELECT b, +
+ c, +
+ x AS a, +
+ ax +
FROM v1;
(1 row)
@@ -1585,9 +1585,9 @@ create view tt14v as select t.* from tt14f() t;
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
--------------------------------
- SELECT t.f1, +
- t.f3, +
- t.f4 +
+ SELECT f1, +
+ f3, +
+ f4 +
FROM tt14f() t(f1, f3, f4);
(1 row)
@@ -1623,11 +1623,11 @@ returning pg_describe_object(classid, objid, objsubid) as obj,
alter table tt14t drop column f3;
-- column f3 is still in the view, sort of ...
select pg_get_viewdef('tt14v', true);
- pg_get_viewdef
----------------------------------
- SELECT t.f1, +
- t."?dropped?column?" AS f3,+
- t.f4 +
+ pg_get_viewdef
+-------------------------------
+ SELECT f1, +
+ "?dropped?column?" AS f3,+
+ f4 +
FROM tt14f() t(f1, f4);
(1 row)
@@ -1675,9 +1675,9 @@ alter table tt14t alter column f4 type integer using f4::integer;
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
--------------------------------
- SELECT t.f1, +
- t.f3, +
- t.f4 +
+ SELECT f1, +
+ f3, +
+ f4 +
FROM tt14f() t(f1, f3, f4);
(1 row)
@@ -1697,8 +1697,8 @@ create view tt14v as select t.f1, t.f4 from tt14f() t;
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
--------------------------------
- SELECT t.f1, +
- t.f4 +
+ SELECT f1, +
+ f4 +
FROM tt14f() t(f1, f3, f4);
(1 row)
@@ -1712,8 +1712,8 @@ alter table tt14t drop column f3; -- ok
select pg_get_viewdef('tt14v', true);
pg_get_viewdef
----------------------------
- SELECT t.f1, +
- t.f4 +
+ SELECT f1, +
+ f4 +
FROM tt14f() t(f1, f4);
(1 row)
@@ -1806,8 +1806,8 @@ select * from tt17v;
select pg_get_viewdef('tt17v', true);
pg_get_viewdef
---------------------------------------------
- SELECT i.q1, +
- i.q2 +
+ SELECT q1, +
+ q2 +
FROM int8_tbl i +
WHERE (i.* IN ( VALUES (i.*::int8_tbl)));
(1 row)
@@ -2134,7 +2134,7 @@ select pg_get_viewdef('tt25v', true);
WITH cte AS MATERIALIZED ( +
SELECT pg_get_keywords() AS k+
) +
- SELECT (cte.k).word AS word +
+ SELECT (k).word AS word +
FROM cte;
(1 row)
@@ -2186,19 +2186,19 @@ select x + y + z as c1,
(x,y) <= ANY (values(1,2),(3,4)) as c11
from (values(1,2,3)) v(x,y,z);
select pg_get_viewdef('tt26v', true);
- pg_get_viewdef
---------------------------------------------------------
- SELECT v.x + v.y + v.z AS c1, +
- v.x * v.y + v.z AS c2, +
- v.x + v.y * v.z AS c3, +
- (v.x + v.y) * v.z AS c4, +
- v.x * (v.y + v.z) AS c5, +
- v.x + (v.y + v.z) AS c6, +
- v.x + (v.y # v.z) AS c7, +
- v.x > v.y AND (v.y > v.z OR v.x > v.z) AS c8, +
- v.x > v.y OR v.y > v.z AND NOT v.x > v.z AS c9, +
- ((v.x, v.y) <> ALL ( VALUES (1,2), (3,4))) AS c10,+
- ((v.x, v.y) <= ANY ( VALUES (1,2), (3,4))) AS c11 +
+ pg_get_viewdef
+----------------------------------------------------
+ SELECT x + y + z AS c1, +
+ x * y + z AS c2, +
+ x + y * z AS c3, +
+ (x + y) * z AS c4, +
+ x * (y + z) AS c5, +
+ x + (y + z) AS c6, +
+ x + (y # z) AS c7, +
+ x > y AND (y > z OR x > z) AS c8, +
+ x > y OR y > z AND NOT x > z AS c9, +
+ ((x, y) <> ALL ( VALUES (1,2), (3,4))) AS c10,+
+ ((x, y) <= ANY ( VALUES (1,2), (3,4))) AS c11 +
FROM ( VALUES (1,2,3)) v(x, y, z);
(1 row)
diff --git a/src/test/regress/expected/expressions.out b/src/test/regress/expected/expressions.out
index 2d5342ab28..d2c6db1bd5 100644
--- a/src/test/regress/expected/expressions.out
+++ b/src/test/regress/expected/expressions.out
@@ -137,12 +137,12 @@ create view numeric_view as
f2164 | numeric(16,4) | | | | main |
f2n | numeric | | | | main |
View definition:
- SELECT numeric_tbl.f1,
- numeric_tbl.f1::numeric(16,4) AS f1164,
- numeric_tbl.f1::numeric AS f1n,
- numeric_tbl.f2,
- numeric_tbl.f2::numeric(16,4) AS f2164,
- numeric_tbl.f2 AS f2n
+ SELECT f1,
+ f1::numeric(16,4) AS f1164,
+ f1::numeric AS f1n,
+ f2,
+ f2::numeric(16,4) AS f2164,
+ f2 AS f2n
FROM numeric_tbl;
explain (verbose, costs off) select * from numeric_view;
@@ -171,12 +171,12 @@ create view bpchar_view as
f214 | character(14) | | | | extended |
f2n | bpchar | | | | extended |
View definition:
- SELECT bpchar_tbl.f1,
- bpchar_tbl.f1::character(14) AS f114,
- bpchar_tbl.f1::bpchar AS f1n,
- bpchar_tbl.f2,
- bpchar_tbl.f2::character(14) AS f214,
- bpchar_tbl.f2 AS f2n
+ SELECT f1,
+ f1::character(14) AS f114,
+ f1::bpchar AS f1n,
+ f2,
+ f2::character(14) AS f214,
+ f2 AS f2n
FROM bpchar_tbl;
explain (verbose, costs off) select * from bpchar_view
diff --git a/src/test/regress/expected/groupingsets.out b/src/test/regress/expected/groupingsets.out
index fcad5c4093..8e75bfe92a 100644
--- a/src/test/regress/expected/groupingsets.out
+++ b/src/test/regress/expected/groupingsets.out
@@ -570,16 +570,16 @@ CREATE VIEW gstest_view AS select a, b, grouping(a,b), sum(c), count(*), max(c)
from gstest2 group by rollup ((a,b,c),(c,d));
NOTICE: view "gstest_view" will be a temporary view
select pg_get_viewdef('gstest_view'::regclass, true);
- pg_get_viewdef
--------------------------------------------------------------------------------
- SELECT gstest2.a, +
- gstest2.b, +
- GROUPING(gstest2.a, gstest2.b) AS "grouping", +
- sum(gstest2.c) AS sum, +
- count(*) AS count, +
- max(gstest2.c) AS max +
- FROM gstest2 +
- GROUP BY ROLLUP((gstest2.a, gstest2.b, gstest2.c), (gstest2.c, gstest2.d));
+ pg_get_viewdef
+---------------------------------------
+ SELECT a, +
+ b, +
+ GROUPING(a, b) AS "grouping", +
+ sum(c) AS sum, +
+ count(*) AS count, +
+ max(c) AS max +
+ FROM gstest2 +
+ GROUP BY ROLLUP((a, b, c), (c, d));
(1 row)
-- Nested queries with 3 or more levels of nesting
diff --git a/src/test/regress/expected/limit.out b/src/test/regress/expected/limit.out
index 8a98bbea8e..a2cd0f9f5b 100644
--- a/src/test/regress/expected/limit.out
+++ b/src/test/regress/expected/limit.out
@@ -638,10 +638,10 @@ CREATE VIEW limit_thousand_v_1 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
OFFSET 10
FETCH FIRST 5 ROWS WITH TIES;
@@ -653,10 +653,10 @@ CREATE VIEW limit_thousand_v_2 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
OFFSET 10
LIMIT 5;
@@ -671,10 +671,10 @@ CREATE VIEW limit_thousand_v_3 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
FETCH FIRST (NULL::integer + 1) ROWS WITH TIES;
CREATE VIEW limit_thousand_v_4 AS SELECT thousand FROM onek WHERE thousand < 995
@@ -685,10 +685,10 @@ CREATE VIEW limit_thousand_v_4 AS SELECT thousand FROM onek WHERE thousand < 995
----------+---------+-----------+----------+---------+---------+-------------
thousand | integer | | | | plain |
View definition:
- SELECT onek.thousand
+ SELECT thousand
FROM onek
- WHERE onek.thousand < 995
- ORDER BY onek.thousand
+ WHERE thousand < 995
+ ORDER BY thousand
LIMIT ALL;
-- leave these views
diff --git a/src/test/regress/expected/matview.out b/src/test/regress/expected/matview.out
index c109d97635..87b6e569a5 100644
--- a/src/test/regress/expected/matview.out
+++ b/src/test/regress/expected/matview.out
@@ -100,10 +100,10 @@ CREATE INDEX mvtest_aa ON mvtest_bb (grandtot);
type | text | | | | extended | |
totamt | numeric | | | | main | |
View definition:
- SELECT mvtest_tv.type,
- mvtest_tv.totamt
+ SELECT type,
+ totamt
FROM mvtest_tv
- ORDER BY mvtest_tv.type;
+ ORDER BY type;
\d+ mvtest_tvm
Materialized view "public.mvtest_tvm"
@@ -112,10 +112,10 @@ View definition:
type | text | | | | extended | |
totamt | numeric | | | | main | |
View definition:
- SELECT mvtest_tv.type,
- mvtest_tv.totamt
+ SELECT type,
+ totamt
FROM mvtest_tv
- ORDER BY mvtest_tv.type;
+ ORDER BY type;
\d+ mvtest_tvvm
Materialized view "public.mvtest_tvvm"
@@ -123,7 +123,7 @@ View definition:
----------+---------+-----------+----------+---------+---------+--------------+-------------
grandtot | numeric | | | | main | |
View definition:
- SELECT mvtest_tvv.grandtot
+ SELECT grandtot
FROM mvtest_tvv;
\d+ mvtest_bb
@@ -134,7 +134,7 @@ View definition:
Indexes:
"mvtest_aa" btree (grandtot)
View definition:
- SELECT mvtest_tvvmv.grandtot
+ SELECT grandtot
FROM mvtest_tvvmv;
-- test schema behavior
@@ -150,7 +150,7 @@ Indexes:
"mvtest_tvmm_expr" UNIQUE, btree ((grandtot > 0::numeric))
"mvtest_tvmm_pred" UNIQUE, btree (grandtot) WHERE grandtot < 0::numeric
View definition:
- SELECT sum(mvtest_tvm.totamt) AS grandtot
+ SELECT sum(totamt) AS grandtot
FROM mvtest_mvschema.mvtest_tvm;
SET search_path = mvtest_mvschema, public;
@@ -161,10 +161,10 @@ SET search_path = mvtest_mvschema, public;
type | text | | | | extended | |
totamt | numeric | | | | main | |
View definition:
- SELECT mvtest_tv.type,
- mvtest_tv.totamt
+ SELECT type,
+ totamt
FROM mvtest_tv
- ORDER BY mvtest_tv.type;
+ ORDER BY type;
-- modify the underlying table data
INSERT INTO mvtest_t VALUES (6, 'z', 13);
diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out
index 1cd558d668..bf08e40ed8 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -1801,10 +1801,10 @@ select * from dfview;
c3 | bigint | | | | plain |
c4 | bigint | | | | plain |
View definition:
- SELECT int8_tbl.q1,
- int8_tbl.q2,
- dfunc(int8_tbl.q1, int8_tbl.q2, flag => int8_tbl.q1 > int8_tbl.q2) AS c3,
- dfunc(int8_tbl.q1, flag => int8_tbl.q1 < int8_tbl.q2, b => int8_tbl.q2) AS c4
+ SELECT q1,
+ q2,
+ dfunc(q1, q2, flag => q1 > q2) AS c3,
+ dfunc(q1, flag => q1 < q2, b => q2) AS c4
FROM int8_tbl;
drop view dfview;
diff --git a/src/test/regress/expected/rangefuncs.out b/src/test/regress/expected/rangefuncs.out
index e2e62db6a2..fbb840e848 100644
--- a/src/test/regress/expected/rangefuncs.out
+++ b/src/test/regress/expected/rangefuncs.out
@@ -149,9 +149,9 @@ select * from vw_ord;
select definition from pg_views where viewname='vw_ord';
definition
----------------------------------------------------------------------------------------
- SELECT z.a, +
- z.b, +
- z.c +
+ SELECT a, +
+ b, +
+ c +
FROM UNNEST(ARRAY[10, 20], ARRAY['foo'::text, 'bar'::text], ARRAY[1.0]) z(a, b, c);
(1 row)
@@ -167,9 +167,9 @@ select * from vw_ord;
select definition from pg_views where viewname='vw_ord';
definition
----------------------------------------------------------------------------------------
- SELECT z.a, +
- z.b, +
- z.c +
+ SELECT a, +
+ b, +
+ c +
FROM UNNEST(ARRAY[10, 20], ARRAY['foo'::text, 'bar'::text], ARRAY[1.0]) z(a, b, c);
(1 row)
@@ -185,9 +185,9 @@ select * from vw_ord;
select definition from pg_views where viewname='vw_ord';
definition
----------------------------------------------------------------------------------------------------------------------
- SELECT z.a, +
- z.b, +
- z.c +
+ SELECT a, +
+ b, +
+ c +
FROM ROWS FROM(unnest(ARRAY[10, 20]), unnest(ARRAY['foo'::text, 'bar'::text]), generate_series(1, 2)) z(a, b, c);
(1 row)
@@ -669,14 +669,14 @@ select * from vw_rngfunc;
select pg_get_viewdef('vw_rngfunc');
pg_get_viewdef
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- SELECT t1.a, +
- t1.b, +
- t1.c, +
- t1.d, +
- t1.e, +
- t1.f, +
- t1.g, +
- t1.n +
+ SELECT a, +
+ b, +
+ c, +
+ d, +
+ e, +
+ f, +
+ g, +
+ n +
FROM ROWS FROM(getrngfunc9(1), getrngfunc7(1) AS (rngfuncid integer, rngfuncsubid integer, rngfuncname text), getrngfunc1(1)) WITH ORDINALITY t1(a, b, c, d, e, f, g, n);
(1 row)
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index fb9f936d43..6a21ce90ac 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -1303,60 +1303,60 @@ pg_available_extensions| SELECT e.name,
e.comment
FROM (pg_available_extensions() e(name, default_version, comment)
LEFT JOIN pg_extension x ON ((e.name = x.extname)));
-pg_backend_memory_contexts| SELECT pg_get_backend_memory_contexts.name,
- pg_get_backend_memory_contexts.ident,
- pg_get_backend_memory_contexts.parent,
- pg_get_backend_memory_contexts.level,
- pg_get_backend_memory_contexts.total_bytes,
- pg_get_backend_memory_contexts.total_nblocks,
- pg_get_backend_memory_contexts.free_bytes,
- pg_get_backend_memory_contexts.free_chunks,
- pg_get_backend_memory_contexts.used_bytes
+pg_backend_memory_contexts| SELECT name,
+ ident,
+ parent,
+ level,
+ total_bytes,
+ total_nblocks,
+ free_bytes,
+ free_chunks,
+ used_bytes
FROM pg_get_backend_memory_contexts() pg_get_backend_memory_contexts(name, ident, parent, level, total_bytes, total_nblocks, free_bytes, free_chunks, used_bytes);
-pg_config| SELECT pg_config.name,
- pg_config.setting
+pg_config| SELECT name,
+ setting
FROM pg_config() pg_config(name, setting);
-pg_cursors| SELECT c.name,
- c.statement,
- c.is_holdable,
- c.is_binary,
- c.is_scrollable,
- c.creation_time
+pg_cursors| SELECT name,
+ statement,
+ is_holdable,
+ is_binary,
+ is_scrollable,
+ creation_time
FROM pg_cursor() c(name, statement, is_holdable, is_binary, is_scrollable, creation_time);
-pg_file_settings| SELECT a.sourcefile,
- a.sourceline,
- a.seqno,
- a.name,
- a.setting,
- a.applied,
- a.error
+pg_file_settings| SELECT sourcefile,
+ sourceline,
+ seqno,
+ name,
+ setting,
+ applied,
+ error
FROM pg_show_all_file_settings() a(sourcefile, sourceline, seqno, name, setting, applied, error);
-pg_group| SELECT pg_authid.rolname AS groname,
- pg_authid.oid AS grosysid,
+pg_group| SELECT rolname AS groname,
+ oid AS grosysid,
ARRAY( SELECT pg_auth_members.member
FROM pg_auth_members
WHERE (pg_auth_members.roleid = pg_authid.oid)) AS grolist
FROM pg_authid
- WHERE (NOT pg_authid.rolcanlogin);
-pg_hba_file_rules| SELECT a.rule_number,
- a.file_name,
- a.line_number,
- a.type,
- a.database,
- a.user_name,
- a.address,
- a.netmask,
- a.auth_method,
- a.options,
- a.error
+ WHERE (NOT rolcanlogin);
+pg_hba_file_rules| SELECT rule_number,
+ file_name,
+ line_number,
+ type,
+ database,
+ user_name,
+ address,
+ netmask,
+ auth_method,
+ options,
+ error
FROM pg_hba_file_rules() a(rule_number, file_name, line_number, type, database, user_name, address, netmask, auth_method, options, error);
-pg_ident_file_mappings| SELECT a.map_number,
- a.file_name,
- a.line_number,
- a.map_name,
- a.sys_name,
- a.pg_username,
- a.error
+pg_ident_file_mappings| SELECT map_number,
+ file_name,
+ line_number,
+ map_name,
+ sys_name,
+ pg_username,
+ error
FROM pg_ident_file_mappings() a(map_number, file_name, line_number, map_name, sys_name, pg_username, error);
pg_indexes| SELECT n.nspname AS schemaname,
c.relname AS tablename,
@@ -1369,22 +1369,22 @@ pg_indexes| SELECT n.nspname AS schemaname,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
LEFT JOIN pg_tablespace t ON ((t.oid = i.reltablespace)))
WHERE ((c.relkind = ANY (ARRAY['r'::"char", 'm'::"char", 'p'::"char"])) AND (i.relkind = ANY (ARRAY['i'::"char", 'I'::"char"])));
-pg_locks| SELECT l.locktype,
- l.database,
- l.relation,
- l.page,
- l.tuple,
- l.virtualxid,
- l.transactionid,
- l.classid,
- l.objid,
- l.objsubid,
- l.virtualtransaction,
- l.pid,
- l.mode,
- l.granted,
- l.fastpath,
- l.waitstart
+pg_locks| SELECT locktype,
+ database,
+ relation,
+ page,
+ tuple,
+ virtualxid,
+ transactionid,
+ classid,
+ objid,
+ objsubid,
+ virtualtransaction,
+ pid,
+ mode,
+ granted,
+ fastpath,
+ waitstart
FROM pg_lock_status() l(locktype, database, relation, page, tuple, virtualxid, transactionid, classid, objid, objsubid, virtualtransaction, pid, mode, granted, fastpath, waitstart);
pg_matviews| SELECT n.nspname AS schemaname,
c.relname AS matviewname,
@@ -1424,14 +1424,14 @@ pg_policies| SELECT n.nspname AS schemaname,
FROM ((pg_policy pol
JOIN pg_class c ON ((c.oid = pol.polrelid)))
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)));
-pg_prepared_statements| SELECT p.name,
- p.statement,
- p.prepare_time,
- p.parameter_types,
- p.result_types,
- p.from_sql,
- p.generic_plans,
- p.custom_plans
+pg_prepared_statements| SELECT name,
+ statement,
+ prepare_time,
+ parameter_types,
+ result_types,
+ from_sql,
+ generic_plans,
+ custom_plans
FROM pg_prepared_statement() p(name, statement, prepare_time, parameter_types, result_types, from_sql, generic_plans, custom_plans);
pg_prepared_xacts| SELECT p.transaction,
p.gid,
@@ -1453,10 +1453,10 @@ pg_publication_tables| SELECT p.pubname,
(pg_class c
JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.oid = gpt.relid);
-pg_replication_origin_status| SELECT pg_show_replication_origin_status.local_id,
- pg_show_replication_origin_status.external_id,
- pg_show_replication_origin_status.remote_lsn,
- pg_show_replication_origin_status.local_lsn
+pg_replication_origin_status| SELECT local_id,
+ external_id,
+ remote_lsn,
+ local_lsn
FROM pg_show_replication_origin_status() pg_show_replication_origin_status(local_id, external_id, remote_lsn, local_lsn);
pg_replication_slots| SELECT l.slot_name,
l.plugin,
@@ -1702,23 +1702,23 @@ pg_sequences| SELECT n.nspname AS schemaname,
JOIN pg_class c ON ((c.oid = s.seqrelid)))
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE ((NOT pg_is_other_temp_schema(n.oid)) AND (c.relkind = 'S'::"char"));
-pg_settings| SELECT a.name,
- a.setting,
- a.unit,
- a.category,
- a.short_desc,
- a.extra_desc,
- a.context,
- a.vartype,
- a.source,
- a.min_val,
- a.max_val,
- a.enumvals,
- a.boot_val,
- a.reset_val,
- a.sourcefile,
- a.sourceline,
- a.pending_restart
+pg_settings| SELECT name,
+ setting,
+ unit,
+ category,
+ short_desc,
+ extra_desc,
+ context,
+ vartype,
+ source,
+ min_val,
+ max_val,
+ enumvals,
+ boot_val,
+ reset_val,
+ sourcefile,
+ sourceline,
+ pending_restart
FROM pg_show_all_settings() a(name, setting, unit, category, short_desc, extra_desc, context, vartype, source, min_val, max_val, enumvals, boot_val, reset_val, sourcefile, sourceline, pending_restart);
pg_shadow| SELECT pg_authid.rolname AS usename,
pg_authid.oid AS usesysid,
@@ -1732,10 +1732,10 @@ pg_shadow| SELECT pg_authid.rolname AS usename,
FROM (pg_authid
LEFT JOIN pg_db_role_setting s ON (((pg_authid.oid = s.setrole) AND (s.setdatabase = (0)::oid))))
WHERE pg_authid.rolcanlogin;
-pg_shmem_allocations| SELECT pg_get_shmem_allocations.name,
- pg_get_shmem_allocations.off,
- pg_get_shmem_allocations.size,
- pg_get_shmem_allocations.allocated_size
+pg_shmem_allocations| SELECT name,
+ off,
+ size,
+ allocated_size
FROM pg_get_shmem_allocations() pg_get_shmem_allocations(name, off, size, allocated_size);
pg_stat_activity| SELECT s.datid,
d.datname,
@@ -1806,13 +1806,13 @@ pg_stat_all_tables| SELECT c.oid AS relid,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char", 'p'::"char"]))
GROUP BY c.oid, n.nspname, c.relname;
-pg_stat_archiver| SELECT s.archived_count,
- s.last_archived_wal,
- s.last_archived_time,
- s.failed_count,
- s.last_failed_wal,
- s.last_failed_time,
- s.stats_reset
+pg_stat_archiver| SELECT archived_count,
+ last_archived_wal,
+ last_archived_time,
+ failed_count,
+ last_failed_wal,
+ last_failed_time,
+ stats_reset
FROM pg_stat_get_archiver() s(archived_count, last_archived_wal, last_archived_time, failed_count, last_failed_wal, last_failed_time, stats_reset);
pg_stat_bgwriter| SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints_timed,
pg_stat_get_bgwriter_requested_checkpoints() AS checkpoints_req,
@@ -1825,57 +1825,57 @@ pg_stat_bgwriter| SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints
pg_stat_get_buf_fsync_backend() AS buffers_backend_fsync,
pg_stat_get_buf_alloc() AS buffers_alloc,
pg_stat_get_bgwriter_stat_reset_time() AS stats_reset;
-pg_stat_database| SELECT d.oid AS datid,
- d.datname,
+pg_stat_database| SELECT oid AS datid,
+ datname,
CASE
- WHEN (d.oid = (0)::oid) THEN 0
- ELSE pg_stat_get_db_numbackends(d.oid)
+ WHEN (oid = (0)::oid) THEN 0
+ ELSE pg_stat_get_db_numbackends(oid)
END AS numbackends,
- pg_stat_get_db_xact_commit(d.oid) AS xact_commit,
- pg_stat_get_db_xact_rollback(d.oid) AS xact_rollback,
- (pg_stat_get_db_blocks_fetched(d.oid) - pg_stat_get_db_blocks_hit(d.oid)) AS blks_read,
- pg_stat_get_db_blocks_hit(d.oid) AS blks_hit,
- pg_stat_get_db_tuples_returned(d.oid) AS tup_returned,
- pg_stat_get_db_tuples_fetched(d.oid) AS tup_fetched,
- pg_stat_get_db_tuples_inserted(d.oid) AS tup_inserted,
- pg_stat_get_db_tuples_updated(d.oid) AS tup_updated,
- pg_stat_get_db_tuples_deleted(d.oid) AS tup_deleted,
- pg_stat_get_db_conflict_all(d.oid) AS conflicts,
- pg_stat_get_db_temp_files(d.oid) AS temp_files,
- pg_stat_get_db_temp_bytes(d.oid) AS temp_bytes,
- pg_stat_get_db_deadlocks(d.oid) AS deadlocks,
- pg_stat_get_db_checksum_failures(d.oid) AS checksum_failures,
- pg_stat_get_db_checksum_last_failure(d.oid) AS checksum_last_failure,
- pg_stat_get_db_blk_read_time(d.oid) AS blk_read_time,
- pg_stat_get_db_blk_write_time(d.oid) AS blk_write_time,
- pg_stat_get_db_session_time(d.oid) AS session_time,
- pg_stat_get_db_active_time(d.oid) AS active_time,
- pg_stat_get_db_idle_in_transaction_time(d.oid) AS idle_in_transaction_time,
- pg_stat_get_db_sessions(d.oid) AS sessions,
- pg_stat_get_db_sessions_abandoned(d.oid) AS sessions_abandoned,
- pg_stat_get_db_sessions_fatal(d.oid) AS sessions_fatal,
- pg_stat_get_db_sessions_killed(d.oid) AS sessions_killed,
- pg_stat_get_db_stat_reset_time(d.oid) AS stats_reset
+ pg_stat_get_db_xact_commit(oid) AS xact_commit,
+ pg_stat_get_db_xact_rollback(oid) AS xact_rollback,
+ (pg_stat_get_db_blocks_fetched(oid) - pg_stat_get_db_blocks_hit(oid)) AS blks_read,
+ pg_stat_get_db_blocks_hit(oid) AS blks_hit,
+ pg_stat_get_db_tuples_returned(oid) AS tup_returned,
+ pg_stat_get_db_tuples_fetched(oid) AS tup_fetched,
+ pg_stat_get_db_tuples_inserted(oid) AS tup_inserted,
+ pg_stat_get_db_tuples_updated(oid) AS tup_updated,
+ pg_stat_get_db_tuples_deleted(oid) AS tup_deleted,
+ pg_stat_get_db_conflict_all(oid) AS conflicts,
+ pg_stat_get_db_temp_files(oid) AS temp_files,
+ pg_stat_get_db_temp_bytes(oid) AS temp_bytes,
+ pg_stat_get_db_deadlocks(oid) AS deadlocks,
+ pg_stat_get_db_checksum_failures(oid) AS checksum_failures,
+ pg_stat_get_db_checksum_last_failure(oid) AS checksum_last_failure,
+ pg_stat_get_db_blk_read_time(oid) AS blk_read_time,
+ pg_stat_get_db_blk_write_time(oid) AS blk_write_time,
+ pg_stat_get_db_session_time(oid) AS session_time,
+ pg_stat_get_db_active_time(oid) AS active_time,
+ pg_stat_get_db_idle_in_transaction_time(oid) AS idle_in_transaction_time,
+ pg_stat_get_db_sessions(oid) AS sessions,
+ pg_stat_get_db_sessions_abandoned(oid) AS sessions_abandoned,
+ pg_stat_get_db_sessions_fatal(oid) AS sessions_fatal,
+ pg_stat_get_db_sessions_killed(oid) AS sessions_killed,
+ pg_stat_get_db_stat_reset_time(oid) AS stats_reset
FROM ( SELECT 0 AS oid,
NULL::name AS datname
UNION ALL
SELECT pg_database.oid,
pg_database.datname
FROM pg_database) d;
-pg_stat_database_conflicts| SELECT d.oid AS datid,
- d.datname,
- pg_stat_get_db_conflict_tablespace(d.oid) AS confl_tablespace,
- pg_stat_get_db_conflict_lock(d.oid) AS confl_lock,
- pg_stat_get_db_conflict_snapshot(d.oid) AS confl_snapshot,
- pg_stat_get_db_conflict_bufferpin(d.oid) AS confl_bufferpin,
- pg_stat_get_db_conflict_startup_deadlock(d.oid) AS confl_deadlock
+pg_stat_database_conflicts| SELECT oid AS datid,
+ datname,
+ pg_stat_get_db_conflict_tablespace(oid) AS confl_tablespace,
+ pg_stat_get_db_conflict_lock(oid) AS confl_lock,
+ pg_stat_get_db_conflict_snapshot(oid) AS confl_snapshot,
+ pg_stat_get_db_conflict_bufferpin(oid) AS confl_bufferpin,
+ pg_stat_get_db_conflict_startup_deadlock(oid) AS confl_deadlock
FROM pg_database d;
-pg_stat_gssapi| SELECT s.pid,
- s.gss_auth AS gss_authenticated,
- s.gss_princ AS principal,
- s.gss_enc AS encrypted
+pg_stat_gssapi| SELECT pid,
+ gss_auth AS gss_authenticated,
+ gss_princ AS principal,
+ gss_enc AS encrypted
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid, query_id)
- WHERE (s.client_port IS NOT NULL);
+ WHERE (client_port IS NOT NULL);
pg_stat_progress_analyze| SELECT s.pid,
s.datid,
d.datname,
@@ -1898,8 +1898,8 @@ pg_stat_progress_analyze| SELECT s.pid,
(s.param8)::oid AS current_child_table_relid
FROM (pg_stat_get_progress_info('ANALYZE'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
LEFT JOIN pg_database d ON ((s.datid = d.oid)));
-pg_stat_progress_basebackup| SELECT s.pid,
- CASE s.param1
+pg_stat_progress_basebackup| SELECT pid,
+ CASE param1
WHEN 0 THEN 'initializing'::text
WHEN 1 THEN 'waiting for checkpoint to finish'::text
WHEN 2 THEN 'estimating backup size'::text
@@ -1908,13 +1908,13 @@ pg_stat_progress_basebackup| SELECT s.pid,
WHEN 5 THEN 'transferring wal files'::text
ELSE NULL::text
END AS phase,
- CASE s.param2
+ CASE param2
WHEN '-1'::integer THEN NULL::bigint
- ELSE s.param2
+ ELSE param2
END AS backup_total,
- s.param3 AS backup_streamed,
- s.param4 AS tablespaces_total,
- s.param5 AS tablespaces_streamed
+ param3 AS backup_streamed,
+ param4 AS tablespaces_total,
+ param5 AS tablespaces_streamed
FROM pg_stat_get_progress_info('BASEBACKUP'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20);
pg_stat_progress_cluster| SELECT s.pid,
s.datid,
@@ -2024,16 +2024,16 @@ pg_stat_progress_vacuum| SELECT s.pid,
s.param7 AS num_dead_tuples
FROM (pg_stat_get_progress_info('VACUUM'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
LEFT JOIN pg_database d ON ((s.datid = d.oid)));
-pg_stat_recovery_prefetch| SELECT s.stats_reset,
- s.prefetch,
- s.hit,
- s.skip_init,
- s.skip_new,
- s.skip_fpw,
- s.skip_rep,
- s.wal_distance,
- s.block_distance,
- s.io_depth
+pg_stat_recovery_prefetch| SELECT stats_reset,
+ prefetch,
+ hit,
+ skip_init,
+ skip_new,
+ skip_fpw,
+ skip_rep,
+ wal_distance,
+ block_distance,
+ io_depth
FROM pg_stat_get_recovery_prefetch() s(stats_reset, prefetch, hit, skip_init, skip_new, skip_fpw, skip_rep, wal_distance, block_distance, io_depth);
pg_stat_replication| SELECT s.pid,
s.usesysid,
@@ -2071,26 +2071,26 @@ pg_stat_replication_slots| SELECT s.slot_name,
FROM pg_replication_slots r,
LATERAL pg_stat_get_replication_slot((r.slot_name)::text) s(slot_name, spill_txns, spill_count, spill_bytes, stream_txns, stream_count, stream_bytes, total_txns, total_bytes, stats_reset)
WHERE (r.datoid IS NOT NULL);
-pg_stat_slru| SELECT s.name,
- s.blks_zeroed,
- s.blks_hit,
- s.blks_read,
- s.blks_written,
- s.blks_exists,
- s.flushes,
- s.truncates,
- s.stats_reset
+pg_stat_slru| SELECT name,
+ blks_zeroed,
+ blks_hit,
+ blks_read,
+ blks_written,
+ blks_exists,
+ flushes,
+ truncates,
+ stats_reset
FROM pg_stat_get_slru() s(name, blks_zeroed, blks_hit, blks_read, blks_written, blks_exists, flushes, truncates, stats_reset);
-pg_stat_ssl| SELECT s.pid,
- s.ssl,
- s.sslversion AS version,
- s.sslcipher AS cipher,
- s.sslbits AS bits,
- s.ssl_client_dn AS client_dn,
- s.ssl_client_serial AS client_serial,
- s.ssl_issuer_dn AS issuer_dn
+pg_stat_ssl| SELECT pid,
+ ssl,
+ sslversion AS version,
+ sslcipher AS cipher,
+ sslbits AS bits,
+ ssl_client_dn AS client_dn,
+ ssl_client_serial AS client_serial,
+ ssl_issuer_dn AS issuer_dn
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid, query_id)
- WHERE (s.client_port IS NOT NULL);
+ WHERE (client_port IS NOT NULL);
pg_stat_subscription| SELECT su.oid AS subid,
su.subname,
st.pid,
@@ -2109,44 +2109,44 @@ pg_stat_subscription_stats| SELECT ss.subid,
ss.stats_reset
FROM pg_subscription s,
LATERAL pg_stat_get_subscription_stats(s.oid) ss(subid, apply_error_count, sync_error_count, stats_reset);
-pg_stat_sys_indexes| SELECT pg_stat_all_indexes.relid,
- pg_stat_all_indexes.indexrelid,
- pg_stat_all_indexes.schemaname,
- pg_stat_all_indexes.relname,
- pg_stat_all_indexes.indexrelname,
- pg_stat_all_indexes.idx_scan,
- pg_stat_all_indexes.last_idx_scan,
- pg_stat_all_indexes.idx_tup_read,
- pg_stat_all_indexes.idx_tup_fetch
+pg_stat_sys_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_read,
+ idx_tup_fetch
FROM pg_stat_all_indexes
- WHERE ((pg_stat_all_indexes.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_all_indexes.schemaname ~ '^pg_toast'::text));
-pg_stat_sys_tables| SELECT pg_stat_all_tables.relid,
- pg_stat_all_tables.schemaname,
- pg_stat_all_tables.relname,
- pg_stat_all_tables.seq_scan,
- pg_stat_all_tables.last_seq_scan,
- pg_stat_all_tables.seq_tup_read,
- pg_stat_all_tables.idx_scan,
- pg_stat_all_tables.last_idx_scan,
- pg_stat_all_tables.idx_tup_fetch,
- pg_stat_all_tables.n_tup_ins,
- pg_stat_all_tables.n_tup_upd,
- pg_stat_all_tables.n_tup_del,
- pg_stat_all_tables.n_tup_hot_upd,
- pg_stat_all_tables.n_live_tup,
- pg_stat_all_tables.n_dead_tup,
- pg_stat_all_tables.n_mod_since_analyze,
- pg_stat_all_tables.n_ins_since_vacuum,
- pg_stat_all_tables.last_vacuum,
- pg_stat_all_tables.last_autovacuum,
- pg_stat_all_tables.last_analyze,
- pg_stat_all_tables.last_autoanalyze,
- pg_stat_all_tables.vacuum_count,
- pg_stat_all_tables.autovacuum_count,
- pg_stat_all_tables.analyze_count,
- pg_stat_all_tables.autoanalyze_count
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_stat_sys_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ last_seq_scan,
+ seq_tup_read,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd,
+ n_live_tup,
+ n_dead_tup,
+ n_mod_since_analyze,
+ n_ins_since_vacuum,
+ last_vacuum,
+ last_autovacuum,
+ last_analyze,
+ last_autoanalyze,
+ vacuum_count,
+ autovacuum_count,
+ analyze_count,
+ autoanalyze_count
FROM pg_stat_all_tables
- WHERE ((pg_stat_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_all_tables.schemaname ~ '^pg_toast'::text));
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
pg_stat_user_functions| SELECT p.oid AS funcid,
n.nspname AS schemaname,
p.proname AS funcname,
@@ -2156,71 +2156,71 @@ pg_stat_user_functions| SELECT p.oid AS funcid,
FROM (pg_proc p
LEFT JOIN pg_namespace n ON ((n.oid = p.pronamespace)))
WHERE ((p.prolang <> (12)::oid) AND (pg_stat_get_function_calls(p.oid) IS NOT NULL));
-pg_stat_user_indexes| SELECT pg_stat_all_indexes.relid,
- pg_stat_all_indexes.indexrelid,
- pg_stat_all_indexes.schemaname,
- pg_stat_all_indexes.relname,
- pg_stat_all_indexes.indexrelname,
- pg_stat_all_indexes.idx_scan,
- pg_stat_all_indexes.last_idx_scan,
- pg_stat_all_indexes.idx_tup_read,
- pg_stat_all_indexes.idx_tup_fetch
+pg_stat_user_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_read,
+ idx_tup_fetch
FROM pg_stat_all_indexes
- WHERE ((pg_stat_all_indexes.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_all_indexes.schemaname !~ '^pg_toast'::text));
-pg_stat_user_tables| SELECT pg_stat_all_tables.relid,
- pg_stat_all_tables.schemaname,
- pg_stat_all_tables.relname,
- pg_stat_all_tables.seq_scan,
- pg_stat_all_tables.last_seq_scan,
- pg_stat_all_tables.seq_tup_read,
- pg_stat_all_tables.idx_scan,
- pg_stat_all_tables.last_idx_scan,
- pg_stat_all_tables.idx_tup_fetch,
- pg_stat_all_tables.n_tup_ins,
- pg_stat_all_tables.n_tup_upd,
- pg_stat_all_tables.n_tup_del,
- pg_stat_all_tables.n_tup_hot_upd,
- pg_stat_all_tables.n_live_tup,
- pg_stat_all_tables.n_dead_tup,
- pg_stat_all_tables.n_mod_since_analyze,
- pg_stat_all_tables.n_ins_since_vacuum,
- pg_stat_all_tables.last_vacuum,
- pg_stat_all_tables.last_autovacuum,
- pg_stat_all_tables.last_analyze,
- pg_stat_all_tables.last_autoanalyze,
- pg_stat_all_tables.vacuum_count,
- pg_stat_all_tables.autovacuum_count,
- pg_stat_all_tables.analyze_count,
- pg_stat_all_tables.autoanalyze_count
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_stat_user_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ last_seq_scan,
+ seq_tup_read,
+ idx_scan,
+ last_idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd,
+ n_live_tup,
+ n_dead_tup,
+ n_mod_since_analyze,
+ n_ins_since_vacuum,
+ last_vacuum,
+ last_autovacuum,
+ last_analyze,
+ last_autoanalyze,
+ vacuum_count,
+ autovacuum_count,
+ analyze_count,
+ autoanalyze_count
FROM pg_stat_all_tables
- WHERE ((pg_stat_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_all_tables.schemaname !~ '^pg_toast'::text));
-pg_stat_wal| SELECT w.wal_records,
- w.wal_fpi,
- w.wal_bytes,
- w.wal_buffers_full,
- w.wal_write,
- w.wal_sync,
- w.wal_write_time,
- w.wal_sync_time,
- w.stats_reset
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_stat_wal| SELECT wal_records,
+ wal_fpi,
+ wal_bytes,
+ wal_buffers_full,
+ wal_write,
+ wal_sync,
+ wal_write_time,
+ wal_sync_time,
+ stats_reset
FROM pg_stat_get_wal() w(wal_records, wal_fpi, wal_bytes, wal_buffers_full, wal_write, wal_sync, wal_write_time, wal_sync_time, stats_reset);
-pg_stat_wal_receiver| SELECT s.pid,
- s.status,
- s.receive_start_lsn,
- s.receive_start_tli,
- s.written_lsn,
- s.flushed_lsn,
- s.received_tli,
- s.last_msg_send_time,
- s.last_msg_receipt_time,
- s.latest_end_lsn,
- s.latest_end_time,
- s.slot_name,
- s.sender_host,
- s.sender_port,
- s.conninfo
+pg_stat_wal_receiver| SELECT pid,
+ status,
+ receive_start_lsn,
+ receive_start_tli,
+ written_lsn,
+ flushed_lsn,
+ received_tli,
+ last_msg_send_time,
+ last_msg_receipt_time,
+ latest_end_lsn,
+ latest_end_time,
+ slot_name,
+ sender_host,
+ sender_port,
+ conninfo
FROM pg_stat_get_wal_receiver() s(pid, status, receive_start_lsn, receive_start_tli, written_lsn, flushed_lsn, received_tli, last_msg_send_time, last_msg_receipt_time, latest_end_lsn, latest_end_time, slot_name, sender_host, sender_port, conninfo)
- WHERE (s.pid IS NOT NULL);
+ WHERE (pid IS NOT NULL);
pg_stat_xact_all_tables| SELECT c.oid AS relid,
n.nspname AS schemaname,
c.relname,
@@ -2237,19 +2237,19 @@ pg_stat_xact_all_tables| SELECT c.oid AS relid,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char", 'p'::"char"]))
GROUP BY c.oid, n.nspname, c.relname;
-pg_stat_xact_sys_tables| SELECT pg_stat_xact_all_tables.relid,
- pg_stat_xact_all_tables.schemaname,
- pg_stat_xact_all_tables.relname,
- pg_stat_xact_all_tables.seq_scan,
- pg_stat_xact_all_tables.seq_tup_read,
- pg_stat_xact_all_tables.idx_scan,
- pg_stat_xact_all_tables.idx_tup_fetch,
- pg_stat_xact_all_tables.n_tup_ins,
- pg_stat_xact_all_tables.n_tup_upd,
- pg_stat_xact_all_tables.n_tup_del,
- pg_stat_xact_all_tables.n_tup_hot_upd
+pg_stat_xact_sys_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ seq_tup_read,
+ idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd
FROM pg_stat_xact_all_tables
- WHERE ((pg_stat_xact_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_xact_all_tables.schemaname ~ '^pg_toast'::text));
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
pg_stat_xact_user_functions| SELECT p.oid AS funcid,
n.nspname AS schemaname,
p.proname AS funcname,
@@ -2259,19 +2259,19 @@ pg_stat_xact_user_functions| SELECT p.oid AS funcid,
FROM (pg_proc p
LEFT JOIN pg_namespace n ON ((n.oid = p.pronamespace)))
WHERE ((p.prolang <> (12)::oid) AND (pg_stat_get_xact_function_calls(p.oid) IS NOT NULL));
-pg_stat_xact_user_tables| SELECT pg_stat_xact_all_tables.relid,
- pg_stat_xact_all_tables.schemaname,
- pg_stat_xact_all_tables.relname,
- pg_stat_xact_all_tables.seq_scan,
- pg_stat_xact_all_tables.seq_tup_read,
- pg_stat_xact_all_tables.idx_scan,
- pg_stat_xact_all_tables.idx_tup_fetch,
- pg_stat_xact_all_tables.n_tup_ins,
- pg_stat_xact_all_tables.n_tup_upd,
- pg_stat_xact_all_tables.n_tup_del,
- pg_stat_xact_all_tables.n_tup_hot_upd
+pg_stat_xact_user_tables| SELECT relid,
+ schemaname,
+ relname,
+ seq_scan,
+ seq_tup_read,
+ idx_scan,
+ idx_tup_fetch,
+ n_tup_ins,
+ n_tup_upd,
+ n_tup_del,
+ n_tup_hot_upd
FROM pg_stat_xact_all_tables
- WHERE ((pg_stat_xact_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_stat_xact_all_tables.schemaname !~ '^pg_toast'::text));
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
pg_statio_all_indexes| SELECT c.oid AS relid,
i.oid AS indexrelid,
n.nspname AS schemaname,
@@ -2315,64 +2315,64 @@ pg_statio_all_tables| SELECT c.oid AS relid,
FROM pg_index
WHERE (pg_index.indrelid = t.oid)) x ON (true))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char"]));
-pg_statio_sys_indexes| SELECT pg_statio_all_indexes.relid,
- pg_statio_all_indexes.indexrelid,
- pg_statio_all_indexes.schemaname,
- pg_statio_all_indexes.relname,
- pg_statio_all_indexes.indexrelname,
- pg_statio_all_indexes.idx_blks_read,
- pg_statio_all_indexes.idx_blks_hit
+pg_statio_sys_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_blks_read,
+ idx_blks_hit
FROM pg_statio_all_indexes
- WHERE ((pg_statio_all_indexes.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_indexes.schemaname ~ '^pg_toast'::text));
-pg_statio_sys_sequences| SELECT pg_statio_all_sequences.relid,
- pg_statio_all_sequences.schemaname,
- pg_statio_all_sequences.relname,
- pg_statio_all_sequences.blks_read,
- pg_statio_all_sequences.blks_hit
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_statio_sys_sequences| SELECT relid,
+ schemaname,
+ relname,
+ blks_read,
+ blks_hit
FROM pg_statio_all_sequences
- WHERE ((pg_statio_all_sequences.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_sequences.schemaname ~ '^pg_toast'::text));
-pg_statio_sys_tables| SELECT pg_statio_all_tables.relid,
- pg_statio_all_tables.schemaname,
- pg_statio_all_tables.relname,
- pg_statio_all_tables.heap_blks_read,
- pg_statio_all_tables.heap_blks_hit,
- pg_statio_all_tables.idx_blks_read,
- pg_statio_all_tables.idx_blks_hit,
- pg_statio_all_tables.toast_blks_read,
- pg_statio_all_tables.toast_blks_hit,
- pg_statio_all_tables.tidx_blks_read,
- pg_statio_all_tables.tidx_blks_hit
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_statio_sys_tables| SELECT relid,
+ schemaname,
+ relname,
+ heap_blks_read,
+ heap_blks_hit,
+ idx_blks_read,
+ idx_blks_hit,
+ toast_blks_read,
+ toast_blks_hit,
+ tidx_blks_read,
+ tidx_blks_hit
FROM pg_statio_all_tables
- WHERE ((pg_statio_all_tables.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_statio_all_tables.schemaname ~ '^pg_toast'::text));
-pg_statio_user_indexes| SELECT pg_statio_all_indexes.relid,
- pg_statio_all_indexes.indexrelid,
- pg_statio_all_indexes.schemaname,
- pg_statio_all_indexes.relname,
- pg_statio_all_indexes.indexrelname,
- pg_statio_all_indexes.idx_blks_read,
- pg_statio_all_indexes.idx_blks_hit
+ WHERE ((schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (schemaname ~ '^pg_toast'::text));
+pg_statio_user_indexes| SELECT relid,
+ indexrelid,
+ schemaname,
+ relname,
+ indexrelname,
+ idx_blks_read,
+ idx_blks_hit
FROM pg_statio_all_indexes
- WHERE ((pg_statio_all_indexes.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_indexes.schemaname !~ '^pg_toast'::text));
-pg_statio_user_sequences| SELECT pg_statio_all_sequences.relid,
- pg_statio_all_sequences.schemaname,
- pg_statio_all_sequences.relname,
- pg_statio_all_sequences.blks_read,
- pg_statio_all_sequences.blks_hit
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_statio_user_sequences| SELECT relid,
+ schemaname,
+ relname,
+ blks_read,
+ blks_hit
FROM pg_statio_all_sequences
- WHERE ((pg_statio_all_sequences.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_sequences.schemaname !~ '^pg_toast'::text));
-pg_statio_user_tables| SELECT pg_statio_all_tables.relid,
- pg_statio_all_tables.schemaname,
- pg_statio_all_tables.relname,
- pg_statio_all_tables.heap_blks_read,
- pg_statio_all_tables.heap_blks_hit,
- pg_statio_all_tables.idx_blks_read,
- pg_statio_all_tables.idx_blks_hit,
- pg_statio_all_tables.toast_blks_read,
- pg_statio_all_tables.toast_blks_hit,
- pg_statio_all_tables.tidx_blks_read,
- pg_statio_all_tables.tidx_blks_hit
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
+pg_statio_user_tables| SELECT relid,
+ schemaname,
+ relname,
+ heap_blks_read,
+ heap_blks_hit,
+ idx_blks_read,
+ idx_blks_hit,
+ toast_blks_read,
+ toast_blks_hit,
+ tidx_blks_read,
+ tidx_blks_hit
FROM pg_statio_all_tables
- WHERE ((pg_statio_all_tables.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (pg_statio_all_tables.schemaname !~ '^pg_toast'::text));
+ WHERE ((schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND (schemaname !~ '^pg_toast'::text));
pg_stats| SELECT n.nspname AS schemaname,
c.relname AS tablename,
a.attname,
@@ -2557,24 +2557,24 @@ pg_tables| SELECT n.nspname AS schemaname,
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
LEFT JOIN pg_tablespace t ON ((t.oid = c.reltablespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 'p'::"char"]));
-pg_timezone_abbrevs| SELECT pg_timezone_abbrevs.abbrev,
- pg_timezone_abbrevs.utc_offset,
- pg_timezone_abbrevs.is_dst
+pg_timezone_abbrevs| SELECT abbrev,
+ utc_offset,
+ is_dst
FROM pg_timezone_abbrevs() pg_timezone_abbrevs(abbrev, utc_offset, is_dst);
-pg_timezone_names| SELECT pg_timezone_names.name,
- pg_timezone_names.abbrev,
- pg_timezone_names.utc_offset,
- pg_timezone_names.is_dst
+pg_timezone_names| SELECT name,
+ abbrev,
+ utc_offset,
+ is_dst
FROM pg_timezone_names() pg_timezone_names(name, abbrev, utc_offset, is_dst);
-pg_user| SELECT pg_shadow.usename,
- pg_shadow.usesysid,
- pg_shadow.usecreatedb,
- pg_shadow.usesuper,
- pg_shadow.userepl,
- pg_shadow.usebypassrls,
+pg_user| SELECT usename,
+ usesysid,
+ usecreatedb,
+ usesuper,
+ userepl,
+ usebypassrls,
'********'::text AS passwd,
- pg_shadow.valuntil,
- pg_shadow.useconfig
+ valuntil,
+ useconfig
FROM pg_shadow;
pg_user_mappings| SELECT u.oid AS umid,
s.oid AS srvid,
@@ -3079,7 +3079,7 @@ SELECT * FROM rule_v1;
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rule_t1.a
+ SELECT a
FROM rule_t1;
Rules:
newinsertrule AS
@@ -3118,8 +3118,8 @@ alter table rule_v1 rename column column2 to q2;
column1 | integer | | | | plain |
q2 | integer | | | | plain |
View definition:
- SELECT "*VALUES*".column1,
- "*VALUES*".column2 AS q2
+ SELECT column1,
+ column2 AS q2
FROM (VALUES (1,2)) "*VALUES*";
drop view rule_v1;
@@ -3131,8 +3131,8 @@ create view rule_v1(x) as values(1,2);
x | integer | | | | plain |
column2 | integer | | | | plain |
View definition:
- SELECT "*VALUES*".column1 AS x,
- "*VALUES*".column2
+ SELECT column1 AS x,
+ column2
FROM (VALUES (1,2)) "*VALUES*";
drop view rule_v1;
@@ -3144,8 +3144,8 @@ create view rule_v1(x) as select * from (values(1,2)) v;
x | integer | | | | plain |
column2 | integer | | | | plain |
View definition:
- SELECT v.column1 AS x,
- v.column2
+ SELECT column1 AS x,
+ column2
FROM ( VALUES (1,2)) v;
drop view rule_v1;
@@ -3157,8 +3157,8 @@ create view rule_v1(x) as select * from (values(1,2)) v(q,w);
x | integer | | | | plain |
w | integer | | | | plain |
View definition:
- SELECT v.q AS x,
- v.w
+ SELECT q AS x,
+ w
FROM ( VALUES (1,2)) v(q, w);
drop view rule_v1;
diff --git a/src/test/regress/expected/tablesample.out b/src/test/regress/expected/tablesample.out
index 60bb4e8e3e..9ff4611640 100644
--- a/src/test/regress/expected/tablesample.out
+++ b/src/test/regress/expected/tablesample.out
@@ -74,7 +74,7 @@ CREATE VIEW test_tablesample_v2 AS
--------+---------+-----------+----------+---------+---------+-------------
id | integer | | | | plain |
View definition:
- SELECT test_tablesample.id
+ SELECT id
FROM test_tablesample TABLESAMPLE system ((10 * 2)) REPEATABLE (2);
\d+ test_tablesample_v2
@@ -83,7 +83,7 @@ View definition:
--------+---------+-----------+----------+---------+---------+-------------
id | integer | | | | plain |
View definition:
- SELECT test_tablesample.id
+ SELECT id
FROM test_tablesample TABLESAMPLE system (99);
-- check a sampled query doesn't affect cursor in progress
diff --git a/src/test/regress/expected/triggers.out b/src/test/regress/expected/triggers.out
index 6d80ab1a6d..7dbeced570 100644
--- a/src/test/regress/expected/triggers.out
+++ b/src/test/regress/expected/triggers.out
@@ -1277,8 +1277,8 @@ DROP TRIGGER instead_of_delete_trig ON main_view;
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT main_table.a,
- main_table.b
+ SELECT a,
+ b
FROM main_table;
Triggers:
after_del_stmt_trig AFTER DELETE ON main_view FOR EACH STATEMENT EXECUTE FUNCTION view_trigger('after_view_del_stmt')
diff --git a/src/test/regress/expected/updatable_views.out b/src/test/regress/expected/updatable_views.out
index 5a47dacad9..2b578cced1 100644
--- a/src/test/regress/expected/updatable_views.out
+++ b/src/test/regress/expected/updatable_views.out
@@ -1925,19 +1925,19 @@ CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a < b
a | integer | | | | plain |
b | integer | | | | plain |
View definition:
- SELECT base_tbl.a,
- base_tbl.b
+ SELECT a,
+ b
FROM base_tbl
- WHERE base_tbl.a < base_tbl.b;
+ WHERE a < b;
Options: check_option=local
SELECT * FROM information_schema.views WHERE table_name = 'rw_view1';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+------------------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view1 | SELECT base_tbl.a, +| LOCAL | YES | YES | NO | NO | NO
- | | | base_tbl.b +| | | | | |
- | | | FROM base_tbl +| | | | | |
- | | | WHERE (base_tbl.a < base_tbl.b); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view1 | SELECT a, +| LOCAL | YES | YES | NO | NO | NO
+ | | | b +| | | | | |
+ | | | FROM base_tbl+| | | | | |
+ | | | WHERE (a < b); | | | | | |
(1 row)
INSERT INTO rw_view1 VALUES(3,4); -- ok
@@ -1978,17 +1978,17 @@ CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rw_view1.a
+ SELECT a
FROM rw_view1
- WHERE rw_view1.a < 10;
+ WHERE a < 10;
Options: check_option=cascaded
SELECT * FROM information_schema.views WHERE table_name = 'rw_view2';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+----------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view2 | SELECT rw_view1.a +| CASCADED | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a < 10); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view2 | SELECT a +| CASCADED | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a < 10); | | | | | |
(1 row)
INSERT INTO rw_view2 VALUES (-5); -- should fail
@@ -2018,17 +2018,17 @@ CREATE OR REPLACE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rw_view1.a
+ SELECT a
FROM rw_view1
- WHERE rw_view1.a < 10;
+ WHERE a < 10;
Options: check_option=local
SELECT * FROM information_schema.views WHERE table_name = 'rw_view2';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+----------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view2 | SELECT rw_view1.a +| LOCAL | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a < 10); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view2 | SELECT a +| LOCAL | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a < 10); | | | | | |
(1 row)
INSERT INTO rw_view2 VALUES (-10); -- ok, but not in view
@@ -2059,16 +2059,16 @@ ALTER VIEW rw_view2 RESET (check_option);
--------+---------+-----------+----------+---------+---------+-------------
a | integer | | | | plain |
View definition:
- SELECT rw_view1.a
+ SELECT a
FROM rw_view1
- WHERE rw_view1.a < 10;
+ WHERE a < 10;
SELECT * FROM information_schema.views WHERE table_name = 'rw_view2';
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+----------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view2 | SELECT rw_view1.a +| NONE | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a < 10); | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view2 | SELECT a +| NONE | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a < 10); | | | | | |
(1 row)
INSERT INTO rw_view2 VALUES (30); -- ok, but not in view
@@ -2090,15 +2090,15 @@ CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WITH CHECK OPTION;
CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a > 0;
CREATE VIEW rw_view3 AS SELECT * FROM rw_view2 WITH CHECK OPTION;
SELECT * FROM information_schema.views WHERE table_name LIKE E'rw\\_view_' ORDER BY table_name;
- table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
----------------+--------------+------------+---------------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
- regression | public | rw_view1 | SELECT base_tbl.a +| CASCADED | YES | YES | NO | NO | NO
- | | | FROM base_tbl; | | | | | |
- regression | public | rw_view2 | SELECT rw_view1.a +| NONE | YES | YES | NO | NO | NO
- | | | FROM rw_view1 +| | | | | |
- | | | WHERE (rw_view1.a > 0); | | | | | |
- regression | public | rw_view3 | SELECT rw_view2.a +| CASCADED | YES | YES | NO | NO | NO
- | | | FROM rw_view2; | | | | | |
+ table_catalog | table_schema | table_name | view_definition | check_option | is_updatable | is_insertable_into | is_trigger_updatable | is_trigger_deletable | is_trigger_insertable_into
+---------------+--------------+------------+-------------------+--------------+--------------+--------------------+----------------------+----------------------+----------------------------
+ regression | public | rw_view1 | SELECT a +| CASCADED | YES | YES | NO | NO | NO
+ | | | FROM base_tbl; | | | | | |
+ regression | public | rw_view2 | SELECT a +| NONE | YES | YES | NO | NO | NO
+ | | | FROM rw_view1 +| | | | | |
+ | | | WHERE (a > 0); | | | | | |
+ regression | public | rw_view3 | SELECT a +| CASCADED | YES | YES | NO | NO | NO
+ | | | FROM rw_view2; | | | | | |
(3 rows)
INSERT INTO rw_view1 VALUES (-1); -- ok
diff --git a/src/test/regress/expected/window.out b/src/test/regress/expected/window.out
index b2c6605e60..26e2df6da5 100644
--- a/src/test/regress/expected/window.out
+++ b/src/test/regress/expected/window.out
@@ -1212,10 +1212,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
----------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1238,10 +1238,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
------------------------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) AS sum_rows+
+ pg_get_viewdef
+-------------------------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1264,10 +1264,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
------------------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE GROUP) AS sum_rows+
+ pg_get_viewdef
+-------------------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE GROUP) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1290,10 +1290,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
-----------------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE TIES) AS sum_rows+
+ pg_get_viewdef
+------------------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE TIES) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1316,10 +1316,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
----------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1341,10 +1341,10 @@ SELECT * FROM v_window;
(10 rows)
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
------------------------------------------------------------------------------------------
- SELECT i.i, +
- sum(i.i) OVER (ORDER BY i.i GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
+ pg_get_viewdef
+-------------------------------------------------------------------------------------
+ SELECT i, +
+ sum(i) OVER (ORDER BY i GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS sum_rows+
FROM generate_series(1, 10) i(i);
(1 row)
@@ -1353,10 +1353,10 @@ CREATE TEMP VIEW v_window AS
SELECT i, min(i) over (order by i range between '1 day' preceding and '10 days' following) as min_i
FROM generate_series(now(), now()+'100 days'::interval, '1 hour') i;
SELECT pg_get_viewdef('v_window');
- pg_get_viewdef
----------------------------------------------------------------------------------------------------------------------------
- SELECT i.i, +
- min(i.i) OVER (ORDER BY i.i RANGE BETWEEN '@ 1 day'::interval PRECEDING AND '@ 10 days'::interval FOLLOWING) AS min_i+
+ pg_get_viewdef
+-----------------------------------------------------------------------------------------------------------------------
+ SELECT i, +
+ min(i) OVER (ORDER BY i RANGE BETWEEN '@ 1 day'::interval PRECEDING AND '@ 10 days'::interval FOLLOWING) AS min_i+
FROM generate_series(now(), (now() + '@ 100 days'::interval), '@ 1 hour'::interval) i(i);
(1 row)
diff --git a/src/test/regress/expected/with.out b/src/test/regress/expected/with.out
index 30f2574c88..d0ad7900e8 100644
--- a/src/test/regress/expected/with.out
+++ b/src/test/regress/expected/with.out
@@ -396,9 +396,9 @@ SELECT pg_get_viewdef('vsubdepartment'::regclass);
subdepartment sd +
WHERE (d.parent_department = sd.id)+
) +
- SELECT subdepartment.id, +
- subdepartment.parent_department, +
- subdepartment.name +
+ SELECT id, +
+ parent_department, +
+ name +
FROM subdepartment;
(1 row)
@@ -419,9 +419,9 @@ SELECT pg_get_viewdef('vsubdepartment'::regclass, true);
subdepartment sd +
WHERE d.parent_department = sd.id+
) +
- SELECT subdepartment.id, +
- subdepartment.parent_department, +
- subdepartment.name +
+ SELECT id, +
+ parent_department, +
+ name +
FROM subdepartment;
(1 row)
@@ -446,7 +446,7 @@ View definition:
FROM t t_1
WHERE t_1.n < 100
)
- SELECT sum(t.n) AS sum
+ SELECT sum(n) AS sum
FROM t;
-- corner case in which sub-WITH gets initialized first
@@ -959,9 +959,9 @@ select pg_get_viewdef('v_search');
search_graph sg +
WHERE (g.f = sg.t) +
) SEARCH DEPTH FIRST BY f, t SET seq +
- SELECT search_graph.f, +
- search_graph.t, +
- search_graph.label +
+ SELECT f, +
+ t, +
+ label +
FROM search_graph;
(1 row)
@@ -1547,9 +1547,9 @@ select pg_get_viewdef('v_cycle1');
search_graph sg +
WHERE (g.f = sg.t) +
) CYCLE f, t SET is_cycle USING path +
- SELECT search_graph.f, +
- search_graph.t, +
- search_graph.label +
+ SELECT f, +
+ t, +
+ label +
FROM search_graph;
(1 row)
@@ -1569,9 +1569,9 @@ select pg_get_viewdef('v_cycle2');
search_graph sg +
WHERE (g.f = sg.t) +
) CYCLE f, t SET is_cycle TO 'Y'::text DEFAULT 'N'::text USING path+
- SELECT search_graph.f, +
- search_graph.t, +
- search_graph.label +
+ SELECT f, +
+ t, +
+ label +
FROM search_graph;
(1 row)
diff --git a/src/test/regress/expected/xml.out b/src/test/regress/expected/xml.out
index a672e24dae..3c357a9c7e 100644
--- a/src/test/regress/expected/xml.out
+++ b/src/test/regress/expected/xml.out
@@ -634,12 +634,12 @@ CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'xmlview%' ORDER BY 1;
- table_name | view_definition
-------------+-------------------------------------------------------------------------------------------------------------------
+ table_name | view_definition
+------------+------------------------------------------------------------------------------------------------------------
xmlview1 | SELECT xmlcomment('test'::text) AS xmlcomment;
xmlview2 | SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat";
xmlview3 | SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement";
- xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(emp.name AS name, emp.age AS age, emp.salary AS pay)) AS "xmlelement"+
+ xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(name AS name, age AS age, salary AS pay)) AS "xmlelement" +
| FROM emp;
xmlview5 | SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
xmlview6 | SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi";
diff --git a/src/test/regress/expected/xml_2.out b/src/test/regress/expected/xml_2.out
index c55ea9a593..42055c5003 100644
--- a/src/test/regress/expected/xml_2.out
+++ b/src/test/regress/expected/xml_2.out
@@ -614,12 +614,12 @@ CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
SELECT table_name, view_definition FROM information_schema.views
WHERE table_name LIKE 'xmlview%' ORDER BY 1;
- table_name | view_definition
-------------+-------------------------------------------------------------------------------------------------------------------
+ table_name | view_definition
+------------+------------------------------------------------------------------------------------------------------------
xmlview1 | SELECT xmlcomment('test'::text) AS xmlcomment;
xmlview2 | SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat";
xmlview3 | SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement";
- xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(emp.name AS name, emp.age AS age, emp.salary AS pay)) AS "xmlelement"+
+ xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(name AS name, age AS age, salary AS pay)) AS "xmlelement" +
| FROM emp;
xmlview5 | SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
xmlview6 | SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi";
--
2.35.3
Amit Langote <amitlangote09@gmail.com> writes:
On Mon, Jan 9, 2023 at 5:58 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Conceivably we could make it work by allowing RTE_SUBQUERY RTEs to
carry a relation OID and associated RTEPermissionInfo, so that when a
view's RTE_RELATION RTE is transmuted to an RTE_SUBQUERY RTE it still
carries the info needed to let us lock and permission-check the view.
That might be a bridge too far from the ugliness perspective ...
although certainly the business with OLD and/or NEW RTEs isn't very
pretty either.
I had thought about that idea but was a bit scared of trying it,
because it does sound like something that might become a maintenance
burden in the future. Though I gave that a try today given that it
sounds like I may have your permission. ;-)
Given the small number of places that need to be touched, I don't
think it's a maintenance problem. I agree with your fear that you
might have missed some, but I also searched and found no more.
I was
surprised that nothing failed with a -DWRITE_READ_PARSE_PLAN_TREES
build, because of the way RTEs are written and read -- relid,
rellockmode are not written/read for RTE_SUBQUERY RTEs.
I think that's mostly accidental, stemming from the facts that:
(1) Stored rules wouldn't have these fields populated yet anyway.
(2) The regression tests haven't got any good way to check that a
needed lock was actually acquired. It looks to me like with the
patch as you have it, when a plan tree is copied into the plan
cache the view relid is lost (if pg_plan_query stripped it thanks
to -DWRITE_READ_PARSE_PLAN_TREES) and thus we won't re-acquire the
view lock in AcquireExecutorLocks during later plan uses. But
that would have no useful effect unless it forced a re-plan due to
a concurrent view replacement, which is a scenario I'm pretty sure
we don't actually exercise in the tests.
(3) The executor doesn't look at these fields after startup, so
failure to transmit them to parallel workers doesn't hurt.
In any case, it would clearly be very foolish not to fix
outfuncs/readfuncs to preserve all the fields we're using.
BTW, I don't entirely understand why this patch is passing regression
tests, because it's failed to deal with numerous places that have
hard-wired knowledge about these extra RTEs. Look for references to
PRS2_OLD_VARNO and PRS2_NEW_VARNO.
AFAICS, the places that still have hard-wired knowledge of these
placeholder RTEs only manipulate non-SELECT rules, so don't care about
views.
Yeah, I looked through them too and didn't find any problems.
I've pushed this with some cleanup --- aside from fixing
outfuncs/readfuncs, I did some more work on the comments, which
I think you were too sloppy about.
Sadly, the original nested-views test case still has O(N^2)
planning time :-(. I dug into that harder and now see where
the problem really lies. The rewriter recursively replaces
the view RTE_RELATION RTEs with RTE_SUBQUERY all the way down,
which takes it only linear time. However, then we have a deep
nest of RTE_SUBQUERYs, and the initial copyObject in
pull_up_simple_subquery repeatedly copies everything below the
current pullup recursion level, so that it's still O(N^2)
even though the final rtable will have only N entries.
I'm afraid to remove the copyObject step, because that would
cause problems in the cases where we try to perform pullup
and have to abandon it later. (Maybe we could get rid of
all such cases, but I'm not sanguine about that succeeding.)
I'm tempted to try to fix it by taking view replacement out
of the rewriter altogether and making prepjointree.c handle
it during the same recursive scan that does subquery pullup,
so that we aren't applying copyObject to already-expanded
RTE_SUBQUERY nests. However, that's more work than I care to
put into the problem right now.
regards, tom lane
On Thu, Jan 12, 2023 at 10:06 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Amit Langote <amitlangote09@gmail.com> writes:
On Mon, Jan 9, 2023 at 5:58 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Conceivably we could make it work by allowing RTE_SUBQUERY RTEs to
carry a relation OID and associated RTEPermissionInfo, so that when a
view's RTE_RELATION RTE is transmuted to an RTE_SUBQUERY RTE it still
carries the info needed to let us lock and permission-check the view.
That might be a bridge too far from the ugliness perspective ...
although certainly the business with OLD and/or NEW RTEs isn't very
pretty either.I had thought about that idea but was a bit scared of trying it,
because it does sound like something that might become a maintenance
burden in the future. Though I gave that a try today given that it
sounds like I may have your permission. ;-)Given the small number of places that need to be touched, I don't
think it's a maintenance problem. I agree with your fear that you
might have missed some, but I also searched and found no more.
OK, thanks.
I was
surprised that nothing failed with a -DWRITE_READ_PARSE_PLAN_TREES
build, because of the way RTEs are written and read -- relid,
rellockmode are not written/read for RTE_SUBQUERY RTEs.I think that's mostly accidental, stemming from the facts that:
(1) Stored rules wouldn't have these fields populated yet anyway.
(2) The regression tests haven't got any good way to check that a
needed lock was actually acquired. It looks to me like with the
patch as you have it, when a plan tree is copied into the plan
cache the view relid is lost (if pg_plan_query stripped it thanks
to -DWRITE_READ_PARSE_PLAN_TREES) and thus we won't re-acquire the
view lock in AcquireExecutorLocks during later plan uses. But
that would have no useful effect unless it forced a re-plan due to
a concurrent view replacement, which is a scenario I'm pretty sure
we don't actually exercise in the tests.
Ah, does it make sense to have isolation tests cover this?
(3) The executor doesn't look at these fields after startup, so
failure to transmit them to parallel workers doesn't hurt.In any case, it would clearly be very foolish not to fix
outfuncs/readfuncs to preserve all the fields we're using.I've pushed this with some cleanup --- aside from fixing
outfuncs/readfuncs, I did some more work on the comments, which
I think you were too sloppy about.
Thanks a lot for the fixes.
Sadly, the original nested-views test case still has O(N^2)
planning time :-(. I dug into that harder and now see where
the problem really lies. The rewriter recursively replaces
the view RTE_RELATION RTEs with RTE_SUBQUERY all the way down,
which takes it only linear time. However, then we have a deep
nest of RTE_SUBQUERYs, and the initial copyObject in
pull_up_simple_subquery repeatedly copies everything below the
current pullup recursion level, so that it's still O(N^2)
even though the final rtable will have only N entries.
That makes sense.
I'm afraid to remove the copyObject step, because that would
cause problems in the cases where we try to perform pullup
and have to abandon it later. (Maybe we could get rid of
all such cases, but I'm not sanguine about that succeeding.)
I'm tempted to try to fix it by taking view replacement out
of the rewriter altogether and making prepjointree.c handle
it during the same recursive scan that does subquery pullup,
so that we aren't applying copyObject to already-expanded
RTE_SUBQUERY nests. However, that's more work than I care to
put into the problem right now.
OK, I will try to give your idea a shot sometime later.
BTW, I noticed that we could perhaps remove the following in the
fireRIRrules()'s loop that calls ApplyRetrieveRule(), because we no
longer put any unreferenced OLD/NEW RTEs in the view queries.
/*
* If the table is not referenced in the query, then we ignore it.
* This prevents infinite expansion loop due to new rtable entries
* inserted by expansion of a rule. A table is referenced if it is
* part of the join set (a source table), or is referenced by any Var
* nodes, or is the result table.
*/
if (rt_index != parsetree->resultRelation &&
!rangeTableEntry_used((Node *) parsetree, rt_index, 0))
continue;
Commenting this out doesn't break make check.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com
Amit Langote <amitlangote09@gmail.com> writes:
On Thu, Jan 12, 2023 at 10:06 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
I've pushed this with some cleanup --- aside from fixing
outfuncs/readfuncs, I did some more work on the comments, which
I think you were too sloppy about.
Thanks a lot for the fixes.
It looks like we're not out of the woods on this: the buildfarm
members that run cross-version-upgrade tests are all unhappy.
Most of them are not reporting any useful details, but I suspect
that they are barfing because dumps from the old server include
table-qualified variable names in some CREATE VIEW commands while
dumps from HEAD omit the qualifications. I don't see any
mechanism in TestUpgradeXversion.pm that could deal with that
conveniently, and in any case we'd have to roll out a client
script update to the affected animals. I fear we may have to
revert this pending development of better TestUpgradeXversion.pm
support.
regards, tom lane
On Thu, Jan 12, 2023 at 12:45 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Amit Langote <amitlangote09@gmail.com> writes:
On Thu, Jan 12, 2023 at 10:06 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
I've pushed this with some cleanup --- aside from fixing
outfuncs/readfuncs, I did some more work on the comments, which
I think you were too sloppy about.Thanks a lot for the fixes.
It looks like we're not out of the woods on this: the buildfarm
members that run cross-version-upgrade tests are all unhappy.
Most of them are not reporting any useful details, but I suspect
that they are barfing because dumps from the old server include
table-qualified variable names in some CREATE VIEW commands while
dumps from HEAD omit the qualifications. I don't see any
mechanism in TestUpgradeXversion.pm that could deal with that
conveniently, and in any case we'd have to roll out a client
script update to the affected animals. I fear we may have to
revert this pending development of better TestUpgradeXversion.pm
support.
Ah, OK, no problem.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com
On Wed, Jan 11, 2023 at 10:45:33PM -0500, Tom Lane wrote:
Amit Langote <amitlangote09@gmail.com> writes:
On Thu, Jan 12, 2023 at 10:06 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
I've pushed this with some cleanup --- aside from fixing
outfuncs/readfuncs, I did some more work on the comments, which
I think you were too sloppy about.Thanks a lot for the fixes.
It looks like we're not out of the woods on this: the buildfarm
members that run cross-version-upgrade tests are all unhappy.
Most of them are not reporting any useful details, but I suspect
that they are barfing because dumps from the old server include
table-qualified variable names in some CREATE VIEW commands while
dumps from HEAD omit the qualifications. I don't see any
mechanism in TestUpgradeXversion.pm that could deal with that
conveniently, and in any case we'd have to roll out a client
script update to the affected animals. I fear we may have to
revert this pending development of better TestUpgradeXversion.pm
support.
There's a diffs available for several of them:
- SELECT citext_table.id,
- citext_table.name
+ SELECT id,
+ name
It looks like TestUpgradeXversion.pm is using the diff command I sent to
get tigher bounds on allowable changes.
20210415153722.GL6091@telsasoft.com
It's ugly and a terrible hack, and I don't know whether anyone would say
it's good enough, but one could can probably avoid the diff like:
sed -r '/CREATE/,/^$/{ s/\w+\.//g }'
You'd still have to wait for it to be deployed, though.
--
Justin
On 2023-01-12 Th 00:12, Justin Pryzby wrote:
On Wed, Jan 11, 2023 at 10:45:33PM -0500, Tom Lane wrote:
Amit Langote <amitlangote09@gmail.com> writes:
On Thu, Jan 12, 2023 at 10:06 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
I've pushed this with some cleanup --- aside from fixing
outfuncs/readfuncs, I did some more work on the comments, which
I think you were too sloppy about.Thanks a lot for the fixes.
It looks like we're not out of the woods on this: the buildfarm
members that run cross-version-upgrade tests are all unhappy.
Most of them are not reporting any useful details, but I suspect
that they are barfing because dumps from the old server include
table-qualified variable names in some CREATE VIEW commands while
dumps from HEAD omit the qualifications. I don't see any
mechanism in TestUpgradeXversion.pm that could deal with that
conveniently, and in any case we'd have to roll out a client
script update to the affected animals. I fear we may have to
revert this pending development of better TestUpgradeXversion.pm
support.There's a diffs available for several of them:
- SELECT citext_table.id, - citext_table.name + SELECT id, + nameIt looks like TestUpgradeXversion.pm is using the diff command I sent to
get tigher bounds on allowable changes.20210415153722.GL6091@telsasoft.com
It's ugly and a terrible hack, and I don't know whether anyone would say
it's good enough, but one could can probably avoid the diff like:sed -r '/CREATE/,/^$/{ s/\w+\.//g }'
You'd still have to wait for it to be deployed, though.
That looks quite awful. I don't think you could persuade me to deploy it
(We don't use sed anyway). It might be marginally better if the pattern
were /CREATE.*VIEW/ and we ignored that first line, but it still seems
awful to me.
Another approach might be simply to increase the latitude allowed for
old versions <= 15 with new versions >= 16. Currently we allow 90 for
cases where the versions differ, but we could increase it to, say, 200
in such cases (we'd need to experiment a bit to find the right limit).
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
Andrew Dunstan <andrew@dunslane.net> writes:
On 2023-01-12 Th 00:12, Justin Pryzby wrote:
It's ugly and a terrible hack, and I don't know whether anyone would say
it's good enough, but one could can probably avoid the diff like:
sed -r '/CREATE/,/^$/{ s/\w+\.//g }'
That looks quite awful. I don't think you could persuade me to deploy it
(We don't use sed anyway). It might be marginally better if the pattern
were /CREATE.*VIEW/ and we ignored that first line, but it still seems
awful to me.
Yeah, does not sound workable: it would risk ignoring actual problems.
I was wondering whether we could store a per-version patch or Perl
script that edits the old dump file to remove known discrepancies
from HEAD. If well-maintained, that could eliminate the need for the
arbitrary "fuzz factors" that are in TestUpgradeXversion.pm right now.
I'd really want these files to be kept in the community source tree,
though, so that we do not need a new BF client release to change them.
This isn't the first time this has come up, but now we have a case
where it's actually blocking development, so maybe it's time to
make something happen. If you want I can work on a patch for the
BF client.
regards, tom lane
On Thu, Jan 12, 2023 at 09:54:09AM -0500, Tom Lane wrote:
Andrew Dunstan <andrew@dunslane.net> writes:
On 2023-01-12 Th 00:12, Justin Pryzby wrote:
It's ugly and a terrible hack, and I don't know whether anyone would say
it's good enough, but one could can probably avoid the diff like:
sed -r '/CREATE/,/^$/{ s/\w+\.//g }'That looks quite awful. I don't think you could persuade me to deploy it
(We don't use sed anyway). It might be marginally better if the pattern
were /CREATE.*VIEW/ and we ignored that first line, but it still seems
awful to me.Yeah, does not sound workable: it would risk ignoring actual problems.
I was wondering whether we could store a per-version patch or Perl
script that edits the old dump file to remove known discrepancies
from HEAD. If well-maintained, that could eliminate the need for the
arbitrary "fuzz factors" that are in TestUpgradeXversion.pm right now.
I'd really want these files to be kept in the community source tree,
though, so that we do not need a new BF client release to change them.This isn't the first time this has come up, but now we have a case
where it's actually blocking development, so maybe it's time to
make something happen. If you want I can work on a patch for the
BF client.
What about also including a dump from an old version, too ?
Then the upgrade test can test actual upgrades.
A new dump file would need to be updated at every release; the old ones
could stick around, maybe forever.
--
Justin
Justin Pryzby <pryzby@telsasoft.com> writes:
What about also including a dump from an old version, too ?
Then the upgrade test can test actual upgrades.
The BF clients already do that (if enabled), but they work from
up-to-date installations of the respective branch tips. I'd not
want to have some branches including hypothetical output of
other branches, because it'd be too easy for those files to get
out of sync and deliver misleading answers.
regards, tom lane
On 2023-01-12 Th 09:54, Tom Lane wrote:
I was wondering whether we could store a per-version patch or Perl
script that edits the old dump file to remove known discrepancies
from HEAD. If well-maintained, that could eliminate the need for the
arbitrary "fuzz factors" that are in TestUpgradeXversion.pm right now.
I'd really want these files to be kept in the community source tree,
though, so that we do not need a new BF client release to change them.This isn't the first time this has come up, but now we have a case
where it's actually blocking development, so maybe it's time to
make something happen. If you want I can work on a patch for the
BF client.
I wouldn't worry too much about the client for now. What we'd need is a)
a place in the source code where we know to find the module b) a module
name c) one or more functions to call to make the adjustment(s).
so, say in src/test/perl we have PostgreSQL/AdjustUpgrade.pm with a
subroutine adjust_dumpfile($oldversion, $dumpfile).
That would be fairly easy to look for and call, and a good place to
start. More ambitiously we might also provide a function do do most of
the pre_upgrade adjustments made in TestUpgradeXversion.pm at lines
405-604. But let's walk before we try to run. This is probably a good
time to be doing this as I want to push out a new release pretty soon to
deal with the up-to-date check issues.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
Andrew Dunstan <andrew@dunslane.net> writes:
On 2023-01-12 Th 09:54, Tom Lane wrote:
I was wondering whether we could store a per-version patch or Perl
script that edits the old dump file to remove known discrepancies
from HEAD.
so, say in src/test/perl we have PostgreSQL/AdjustUpgrade.pm with a
subroutine adjust_dumpfile($oldversion, $dumpfile).
Seems reasonable. I was imagining per-old-version .pm files, but
there's likely to be a fair amount of commonality between what to
do for different old versions, so probably that approach would be
too duplicative.
That would be fairly easy to look for and call, and a good place to
start. More ambitiously we might also provide a function do do most of
the pre_upgrade adjustments made in TestUpgradeXversion.pm at lines
405-604. But let's walk before we try to run.
I think that part is also very very important to abstract out of the
BF client. We've been burnt on that before too. So, perhaps one
subroutine that can apply updates to the source DB just before
we dump it, and then a second that can edit the dump file after?
We could imagine a third custom subroutine that abstracts the
actual dump file comparison, but I'd prefer to get to a place
where we just expect exact match after the edit step.
I'll work on a straw-man patch.
regards, tom lane
On Thu, Jan 12, 2023 at 10:06 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Amit Langote <amitlangote09@gmail.com> writes:
On Mon, Jan 9, 2023 at 5:58 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Conceivably we could make it work by allowing RTE_SUBQUERY RTEs to
carry a relation OID and associated RTEPermissionInfo, so that when a
view's RTE_RELATION RTE is transmuted to an RTE_SUBQUERY RTE it still
carries the info needed to let us lock and permission-check the view.
That might be a bridge too far from the ugliness perspective ...
although certainly the business with OLD and/or NEW RTEs isn't very
pretty either.I had thought about that idea but was a bit scared of trying it,
because it does sound like something that might become a maintenance
burden in the future. Though I gave that a try today given that it
sounds like I may have your permission. ;-)Given the small number of places that need to be touched, I don't
think it's a maintenance problem. I agree with your fear that you
might have missed some, but I also searched and found no more.
While thinking about query view locking in context of [1]https://commitfest.postgresql.org/42/3478/, I realized
that we have missed also fixing AcquirePlannerLocks() /
ScanQueryForLocks() to consider that an RTE_SUBQUERY rte may belong to
a view, which must be locked the same as RTE_RELATION entries. Note
we did fix AcquireExecutorLocks() in 47bb9db75 as follows:
@@ -1769,7 +1769,8 @@ AcquireExecutorLocks(List *stmt_list, bool acquire)
{
RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc2);
- if (rte->rtekind != RTE_RELATION)
+ if (!(rte->rtekind == RTE_RELATION ||
+ (rte->rtekind == RTE_SUBQUERY && OidIsValid(rte->relid))))
Attached a patch to fix.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com
Attachments:
ScanQueryForLocks-lock-views.patchapplication/octet-stream; name=ScanQueryForLocks-lock-views.patchDownload
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index 5f3ffd98af..d71810b65f 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -527,7 +527,7 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
result->partPruneInfos = glob->partPruneInfos;
result->rtable = glob->finalrtable;
result->permInfos = glob->finalrteperminfos;
- result->viewRelations = glob->viewRelations;
+ result->viewRelations = NIL;
result->resultRelations = glob->resultRelations;
result->appendRelations = glob->appendRelations;
result->subplans = glob->subplans;
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c
index 4e455d815f..20b0f026e0 100644
--- a/src/backend/utils/cache/plancache.c
+++ b/src/backend/utils/cache/plancache.c
@@ -1784,6 +1784,18 @@ ScanQueryForLocks(Query *parsetree, bool acquire)
break;
case RTE_SUBQUERY:
+ /*
+ * If subquery belongs to a view, we must acquire or release
+ * the appropriate type of lock on the view.
+ */
+ if (OidIsValid(rte->relid))
+ {
+ Assert(rte->rellockmode != NoLock);
+ if (acquire)
+ LockRelationOid(rte->relid, rte->rellockmode);
+ else
+ UnlockRelationOid(rte->relid, rte->rellockmode);
+ }
/* Recurse into subquery-in-FROM */
ScanQueryForLocks(rte->subquery, acquire);
break;
Amit Langote <amitlangote09@gmail.com> writes:
While thinking about query view locking in context of [1], I realized
that we have missed also fixing AcquirePlannerLocks() /
ScanQueryForLocks() to consider that an RTE_SUBQUERY rte may belong to
a view, which must be locked the same as RTE_RELATION entries.
I think you're right about that, because AcquirePlannerLocks is supposed
to reacquire whatever locks parsing+rewriting would have gotten.
However, what's with this hunk?
@@ -527,7 +527,7 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
result->partPruneInfos = glob->partPruneInfos;
result->rtable = glob->finalrtable;
result->permInfos = glob->finalrteperminfos;
- result->viewRelations = glob->viewRelations;
+ result->viewRelations = NIL;
result->resultRelations = glob->resultRelations;
result->appendRelations = glob->appendRelations;
result->subplans = glob->subplans;
regards, tom lane
I wrote:
Amit Langote <amitlangote09@gmail.com> writes:
While thinking about query view locking in context of [1], I realized
that we have missed also fixing AcquirePlannerLocks() /
ScanQueryForLocks() to consider that an RTE_SUBQUERY rte may belong to
a view, which must be locked the same as RTE_RELATION entries.
I think you're right about that, because AcquirePlannerLocks is supposed
to reacquire whatever locks parsing+rewriting would have gotten.
After poking at this a bit more, I'm not sure there is any observable bug,
because we still notice the view change in AcquireExecutorLocks and
loop back to re-plan after that. It still seems like a good idea to
notice such changes sooner not later to reduce wasted work, so I went
ahead and pushed the patch.
The only way it'd be a live bug is if the planner actually fails because
it's working with a stale view definition. I tried to make it fail by
adjusting the view to no longer use an underlying table and then
dropping that table ... but AcquirePlannerLocks still detected that,
because of course it recurses and locks the table reference it finds
in the view subquery. Maybe you could make a failure case involving
dropping a user-defined function instead, but I thought that was getting
pretty far afield, so I didn't pursue it.
regards, tom lane
On Thu, Apr 6, 2023 at 3:33 Tom Lane <tgl@sss.pgh.pa.us> wrote:
Amit Langote <amitlangote09@gmail.com> writes:
While thinking about query view locking in context of [1], I realized
that we have missed also fixing AcquirePlannerLocks() /
ScanQueryForLocks() to consider that an RTE_SUBQUERY rte may belong to
a view, which must be locked the same as RTE_RELATION entries.I think you're right about that, because AcquirePlannerLocks is supposed
to reacquire whatever locks parsing+rewriting would have gotten.
However, what's with this hunk?@@ -527,7 +527,7 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions, result->partPruneInfos = glob->partPruneInfos; result->rtable = glob->finalrtable; result->permInfos = glob->finalrteperminfos; - result->viewRelations = glob->viewRelations; + result->viewRelations = NIL; result->resultRelations = glob->resultRelations; result->appendRelations = glob->appendRelations; result->subplans = glob->subplans;
Oops, I was working in the wrong local branch.
Thanks for pushing. I agree that there’s no live bug as such right now,
but still good to be consistent.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com