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

Function addRangeTableEntryForFunction

src/backend/parser/parse_relation.c:1744–2179  ·  view source on GitHub ↗

* Add an entry for a function (or functions) to the pstate's range table * (p_rtable). Then, construct and return a ParseNamespaceItem for the new RTE. * * This is much like addRangeTableEntry() except that it makes a function RTE. */

Source from the content-addressed store, hash-verified

1742 * This is much like addRangeTableEntry() except that it makes a function RTE.
1743 */
1744ParseNamespaceItem *
1745addRangeTableEntryForFunction(ParseState *pstate,
1746 List *funcnames,
1747 List *funcexprs,
1748 List *coldeflists,
1749 RangeFunction *rangefunc,
1750 bool lateral,
1751 bool inFromCl)
1752{
1753 RangeTblEntry *rte = makeNode(RangeTblEntry);
1754 Oid funcDescribe = InvalidOid;
1755 Alias *alias = rangefunc->alias;
1756 Alias *eref;
1757 char *aliasname;
1758 int nfuncs = list_length(funcexprs);
1759 TupleDesc *functupdescs;
1760 TupleDesc tupdesc;
1761 ListCell *lc1,
1762 *lc2,
1763 *lc3;
1764 int i;
1765 int j;
1766 int funcno;
1767 int natts,
1768 totalatts;
1769
1770 Assert(pstate != NULL);
1771
1772 rte->rtekind = RTE_FUNCTION;
1773 rte->relid = InvalidOid;
1774 rte->subquery = NULL;
1775 rte->functions = NIL; /* we'll fill this list below */
1776 rte->funcordinality = rangefunc->ordinality;
1777 rte->alias = alias;
1778
1779 /*
1780 * Choose the RTE alias name. We default to using the first function's
1781 * name even when there's more than one; which is maybe arguable but beats
1782 * using something constant like "table".
1783 */
1784 if (alias)
1785 aliasname = alias->aliasname;
1786 else
1787 aliasname = linitial(funcnames);
1788
1789 eref = makeAlias(aliasname, NIL);
1790 rte->eref = eref;
1791
1792 /* Process each function ... */
1793 functupdescs = (TupleDesc *) palloc(nfuncs * sizeof(TupleDesc));
1794
1795 totalatts = 0;
1796 funcno = 0;
1797 forthree(lc1, funcexprs, lc2, funcnames, lc3, coldeflists)
1798 {
1799 Node *funcexpr = (Node *) lfirst(lc1);
1800 char *funcname = (char *) lfirst(lc2);
1801 List *coldeflist = (List *) lfirst(lc3);

Callers 1

transformRangeFunctionFunction · 0.85

Calls 15

list_lengthFunction · 0.85
makeAliasFunction · 0.85
get_expr_result_typeFunction · 0.85
lookupProcCallbackFunction · 0.85
fmgr_infoFunction · 0.85
lappendFunction · 0.85
makeStringFunction · 0.85
lappend_oidFunction · 0.85
lappend_intFunction · 0.85
exprTypeFunction · 0.85
parser_errpositionFunction · 0.85
exprLocationFunction · 0.85

Tested by

no test coverage detected