MCPcopy Create free account
hub / github.com/apache/cloudberry / addRangeTableEntryForRelation

Function addRangeTableEntryForRelation

src/backend/parser/parse_relation.c:1582–1645  ·  view source on GitHub ↗

* Add an entry for a relation to the pstate's range table (p_rtable). * Then, construct and return a ParseNamespaceItem for the new RTE. * * This is just like addRangeTableEntry() except that it makes an RTE * given an already-open relation instead of a RangeVar reference. * * lockmode is the lock type required for query execution; it must be one * of AccessShareLock, RowShareLock, RowExclu

Source from the content-addressed store, hash-verified

1580 * LOCKMODE is typedef'd as int anyway, that seems like overkill.
1581 */
1582ParseNamespaceItem *
1583addRangeTableEntryForRelation(ParseState *pstate,
1584 Relation rel,
1585 int lockmode,
1586 Alias *alias,
1587 bool inh,
1588 bool inFromCl)
1589{
1590 RangeTblEntry *rte = makeNode(RangeTblEntry);
1591 char *refname = alias ? alias->aliasname : RelationGetRelationName(rel);
1592
1593 Assert(pstate != NULL);
1594
1595 Assert(lockmode == AccessShareLock ||
1596 lockmode == RowShareLock ||
1597 lockmode == RowExclusiveLock ||
1598 lockmode == ExclusiveLock); /* GPDB: we might upgrade lock level */
1599 Assert(CheckRelationLockedByMe(rel, lockmode, true));
1600
1601 rte->rtekind = RTE_RELATION;
1602 rte->alias = alias;
1603 rte->relid = RelationGetRelid(rel);
1604 rte->relkind = rel->rd_rel->relkind;
1605 rte->rellockmode = lockmode;
1606 rte->relisivm = rel->rd_rel->relisivm;
1607
1608 /*
1609 * Build the list of effective column names using user-supplied aliases
1610 * and/or actual column names.
1611 */
1612 rte->eref = makeAlias(refname, NIL);
1613 buildRelationAliases(rel->rd_att, alias, rte->eref);
1614
1615 /*
1616 * Set flags and access permissions.
1617 *
1618 * The initial default on access checks is always check-for-READ-access,
1619 * which is the right thing for all except target tables.
1620 */
1621 rte->lateral = false;
1622 rte->inh = inh;
1623 rte->inFromCl = inFromCl;
1624
1625 rte->requiredPerms = ACL_SELECT;
1626 rte->checkAsUser = InvalidOid; /* not set-uid by default, either */
1627 rte->selectedCols = NULL;
1628 rte->insertedCols = NULL;
1629 rte->updatedCols = NULL;
1630 rte->extraUpdatedCols = NULL;
1631
1632 /*
1633 * Add completed RTE to pstate's range table list, so that we know its
1634 * index. But we don't add it to the join list --- caller must do that if
1635 * appropriate.
1636 */
1637 pstate->p_rtable = lappend(pstate->p_rtable, rte);
1638
1639 /*

Callers 15

rewriteTargetViewFunction · 0.85
DoCopyFunction · 0.85
CreateTriggerFiringOnFunction · 0.85
CreatePolicyFunction · 0.85
AlterPolicyFunction · 0.85
DefineRelationFunction · 0.85
transformPartitionSpecFunction · 0.85
transformIndexStmtFunction · 0.85
transformStatsStmtFunction · 0.85
transformRuleStmtFunction · 0.85
transformAlterTableStmtFunction · 0.85

Calls 6

CheckRelationLockedByMeFunction · 0.85
makeAliasFunction · 0.85
buildRelationAliasesFunction · 0.85
lappendFunction · 0.85
buildNSItemFromTupleDescFunction · 0.85
list_lengthFunction · 0.85

Tested by 2