MCPcopy Create free account
hub / github.com/documentdb/documentdb / CreateBaseTableRteForInsert

Function CreateBaseTableRteForInsert

pg_documentdb/src/commands/insert.c:1732–1779  ·  view source on GitHub ↗

Build RangeTblEntry for base table */

Source from the content-addressed store, hash-verified

1730
1731/* Build RangeTblEntry for base table */
1732static inline RangeTblEntry *
1733CreateBaseTableRteForInsert(MongoCollection *collection, Oid shardOid,
1734 List **optionalPermInfos)
1735{
1736 RangeTblEntry *rte = makeNode(RangeTblEntry);
1737 List *colNames = list_make3(makeString("shard_key_value"), makeString("object_id"),
1738 makeString("document"));
1739
1740
1741 if (collection->mongoDataCreationTimeVarAttrNumber == 4)
1742 {
1743 colNames = lappend(colNames, makeString("creation_time"));
1744 }
1745 else if (collection->mongoDataCreationTimeVarAttrNumber == 5)
1746 {
1747 /* If "creation_time" is the fifth column, then we should include "change_description" in the RTE. */
1748 colNames = ModifyTableColumnNames(colNames);
1749 }
1750
1751 rte->rtekind = RTE_RELATION;
1752 rte->relid = collection->relationId;
1753
1754 /* If there is a shardOid and we can thunk directly to the shard,
1755 * then set it. This will point the insert to the shard directly and avoid
1756 * going through citus distributed planning.
1757 */
1758 if (shardOid != InvalidOid)
1759 {
1760 rte->relid = shardOid;
1761 }
1762
1763 rte->alias = rte->eref = makeAlias("collection", colNames);
1764 rte->lateral = false;
1765 rte->inFromCl = false;
1766 rte->relkind = RELKIND_RELATION;
1767 rte->functions = NIL;
1768 rte->inh = true;
1769 rte->rellockmode = RowExclusiveLock;
1770
1771#if PG_VERSION_NUM >= 160000
1772 RTEPermissionInfo *permInfo = addRTEPermissionInfo(optionalPermInfos, rte);
1773 permInfo->requiredPerms = ACL_INSERT;
1774#else
1775 rte->requiredPerms = ACL_INSERT;
1776#endif
1777
1778 return rte;
1779}
1780
1781
1782/* Build RangeTblEntry for values */

Callers 2

CreateInsertQueryFunction · 0.85

Calls 1

ModifyTableColumnNamesFunction · 0.85

Tested by

no test coverage detected