aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_relation.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2024-03-07 11:50:24 +0100
committerPeter Eisentraut <peter@eisentraut.org>2024-03-07 12:13:09 +0100
commit6d470211e54f7a617783b99b27c9d8056a890a57 (patch)
tree09101a6e43c2cfe1b5a423f113ce0db05e1abe85 /src/backend/parser/parse_relation.c
parent1f1d73a8b83fb6de929af36eb9d3cd590875daf5 (diff)
downloadpostgresql-6d470211e54f7a617783b99b27c9d8056a890a57.tar.gz
postgresql-6d470211e54f7a617783b99b27c9d8056a890a57.zip
Fix description and grouping of RangeTblEntry.inh
The inh field of RangeTblEntry was doubly confusingly documented. Some parts of the code insisted that it was only valid for RTE_RELATION entries, other parts said the field was valid for all entries. Neither was quite correct. More correctly, the field is valid for RTE_RELATION entries but is also used in the planner for RTE_SUBQUERY entries. So it makes more sense to group it with other fields that are primarily for RTE_RELATION but borrowed by RTE_SUBQUERY. (The exact position was chosen so that it is next to relkind for better struct packing, and next to relid, since relid and inh are sort of the input fields and the others are filled in later.) Also add documentation for the planner's use at the struct definition. Discussion: https://www.postgresql.org/message-id/6c1fbccc-85c8-40d3-b08b-4f47f2093711@eisentraut.org
Diffstat (limited to 'src/backend/parser/parse_relation.c')
-rw-r--r--src/backend/parser/parse_relation.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 34a0ec59019..6f5d9e26925 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -1500,6 +1500,7 @@ addRangeTableEntry(ParseState *pstate,
*/
rel = parserOpenTable(pstate, relation, lockmode);
rte->relid = RelationGetRelid(rel);
+ rte->inh = inh;
rte->relkind = rel->rd_rel->relkind;
rte->rellockmode = lockmode;
@@ -1517,7 +1518,6 @@ addRangeTableEntry(ParseState *pstate,
* which is the right thing for all except target tables.
*/
rte->lateral = false;
- rte->inh = inh;
rte->inFromCl = inFromCl;
perminfo = addRTEPermissionInfo(&pstate->p_rteperminfos, rte);
@@ -1585,6 +1585,7 @@ addRangeTableEntryForRelation(ParseState *pstate,
rte->rtekind = RTE_RELATION;
rte->alias = alias;
rte->relid = RelationGetRelid(rel);
+ rte->inh = inh;
rte->relkind = rel->rd_rel->relkind;
rte->rellockmode = lockmode;
@@ -1602,7 +1603,6 @@ addRangeTableEntryForRelation(ParseState *pstate,
* which is the right thing for all except target tables.
*/
rte->lateral = false;
- rte->inh = inh;
rte->inFromCl = inFromCl;
perminfo = addRTEPermissionInfo(&pstate->p_rteperminfos, rte);
@@ -1700,7 +1700,6 @@ addRangeTableEntryForSubquery(ParseState *pstate,
* addRTEPermissionInfo().
*/
rte->lateral = lateral;
- rte->inh = false; /* never true for subqueries */
rte->inFromCl = inFromCl;
/*
@@ -2023,7 +2022,6 @@ addRangeTableEntryForFunction(ParseState *pstate,
* ExecCheckPermissions()), so no need to perform addRTEPermissionInfo().
*/
rte->lateral = lateral;
- rte->inh = false; /* never true for functions */
rte->inFromCl = inFromCl;
/*
@@ -2108,7 +2106,6 @@ addRangeTableEntryForTableFunc(ParseState *pstate,
* ExecCheckPermissions()), so no need to perform addRTEPermissionInfo().
*/
rte->lateral = lateral;
- rte->inh = false; /* never true for tablefunc RTEs */
rte->inFromCl = inFromCl;
/*
@@ -2189,7 +2186,6 @@ addRangeTableEntryForValues(ParseState *pstate,
* addRTEPermissionInfo().
*/
rte->lateral = lateral;
- rte->inh = false; /* never true for values RTEs */
rte->inFromCl = inFromCl;
/*
@@ -2280,7 +2276,6 @@ addRangeTableEntryForJoin(ParseState *pstate,
* addRTEPermissionInfo().
*/
rte->lateral = false;
- rte->inh = false; /* never true for joins */
rte->inFromCl = inFromCl;
/*
@@ -2425,7 +2420,6 @@ addRangeTableEntryForCTE(ParseState *pstate,
* addRTEPermissionInfo().
*/
rte->lateral = false;
- rte->inh = false; /* never true for subqueries */
rte->inFromCl = inFromCl;
/*
@@ -2545,7 +2539,6 @@ addRangeTableEntryForENR(ParseState *pstate,
* addRTEPermissionInfo().
*/
rte->lateral = false;
- rte->inh = false; /* never true for ENRs */
rte->inFromCl = inFromCl;
/*