PostgreSQL Source Code git master
Data Structures | Typedefs | Functions
functions.h File Reference
#include "nodes/execnodes.h"
#include "tcop/dest.h"
Include dependency graph for functions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

 

Typedefs

 
 

Functions

 
SQLFunctionParseInfoPtr  prepare_sql_fn_parse_info (HeapTuple procedureTuple, Node *call_expr, Oid inputCollation)
 
 
void  check_sql_fn_statements (List *queryTreeLists)
 
bool  check_sql_fn_retval (List *queryTreeLists, Oid rettype, TupleDesc rettupdesc, char prokind, bool insertDroppedCols)
 
 

Typedef Documentation

SQLFunctionParseInfo

SQLFunctionParseInfoPtr

Definition at line 35 of file functions.h.

Function Documentation

check_sql_fn_retval()

bool check_sql_fn_retval ( ListqueryTreeLists,
Oid  rettype,
TupleDesc  rettupdesc,
char  prokind,
bool  insertDroppedCols 
)

Definition at line 2116 of file functions.c.

2120{
2121 List *queryTreeList;
2122
2123 /*
2124 * We consider only the last sublist of Query nodes, so that only the last
2125 * original statement is a candidate to produce the result. This is a
2126 * change from pre-v18 versions, which would back up to the last statement
2127 * that includes a canSetTag query, thus ignoring any ending statement(s)
2128 * that rewrite to DO INSTEAD NOTHING. That behavior was undocumented and
2129 * there seems no good reason for it, except that it was an artifact of
2130 * the original coding.
2131 *
2132 * If the function body is completely empty, handle that the same as if
2133 * the last query had rewritten to nothing.
2134 */
2135 if (queryTreeLists != NIL)
2136 queryTreeList = llast_node(List, queryTreeLists);
2137 else
2138 queryTreeList = NIL;
2139
2140 return check_sql_stmt_retval(queryTreeList,
2141 rettype, rettupdesc,
2142 prokind, insertDroppedCols);
2143}
static bool check_sql_stmt_retval(List *queryTreeList, Oid rettype, TupleDesc rettupdesc, char prokind, bool insertDroppedCols)
Definition: functions.c:2150
#define NIL
Definition: pg_list.h:68
#define llast_node(type, l)
Definition: pg_list.h:202
Definition: pg_list.h:54

References check_sql_stmt_retval(), llast_node, and NIL.

Referenced by fmgr_sql_validator(), inline_function(), and inline_set_returning_function().

check_sql_fn_statements()

void check_sql_fn_statements ( ListqueryTreeLists )

Definition at line 2035 of file functions.c.

2036{
2037 ListCell *lc;
2038
2039 /* We are given a list of sublists of Queries */
2040 foreach(lc, queryTreeLists)
2041 {
2042 List *sublist = lfirst_node(List, lc);
2043
2044 check_sql_fn_statement(sublist);
2045 }
2046}
static void check_sql_fn_statement(List *queryTreeList)
Definition: functions.c:2052
#define lfirst_node(type, lc)
Definition: pg_list.h:176
Definition: pg_list.h:46

References check_sql_fn_statement(), and lfirst_node.

Referenced by fmgr_sql_validator().

CreateSQLFunctionDestReceiver()

DestReceiver * CreateSQLFunctionDestReceiver ( void  )

Definition at line 2617 of file functions.c.

2618{
2620
2625 self->pub.mydest = DestSQLFunction;
2626
2627 /* private fields will be set by postquel_start */
2628
2629 return (DestReceiver *) self;
2630}
@ DestSQLFunction
Definition: dest.h:96
static void sqlfunction_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: functions.c:2636
static bool sqlfunction_receive(TupleTableSlot *slot, DestReceiver *self)
Definition: functions.c:2645
static void sqlfunction_destroy(DestReceiver *self)
Definition: functions.c:2692
static void sqlfunction_shutdown(DestReceiver *self)
Definition: functions.c:2683
void * palloc0(Size size)
Definition: mcxt.c:1395
DestReceiver pub
Definition: functions.c:47
void(* rStartup)(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: dest.h:121
void(* rShutdown)(DestReceiver *self)
Definition: dest.h:124
bool(* receiveSlot)(TupleTableSlot *slot, DestReceiver *self)
Definition: dest.h:118
void(* rDestroy)(DestReceiver *self)
Definition: dest.h:126
CommandDest mydest
Definition: dest.h:128

References DestSQLFunction, _DestReceiver::mydest, palloc0(), DR_sqlfunction::pub, _DestReceiver::rDestroy, _DestReceiver::receiveSlot, _DestReceiver::rShutdown, _DestReceiver::rStartup, sqlfunction_destroy(), sqlfunction_receive(), sqlfunction_shutdown(), and sqlfunction_startup().

Referenced by CreateDestReceiver().

fmgr_sql()

Datum fmgr_sql ( PG_FUNCTION_ARGS  )

Definition at line 1576 of file functions.c.

1577{
1578 SQLFunctionCachePtr fcache;
1579 ErrorContextCallback sqlerrcontext;
1580 MemoryContext tscontext;
1581 bool randomAccess;
1582 bool lazyEvalOK;
1583 bool pushed_snapshot;
1584 execution_state *es;
1585 TupleTableSlot *slot;
1586 Datum result;
1587
1588 /* Check call context */
1589 if (fcinfo->flinfo->fn_retset)
1590 {
1591 ReturnSetInfo *rsi = (ReturnSetInfo *) fcinfo->resultinfo;
1592
1593 /*
1594 * For simplicity, we require callers to support both set eval modes.
1595 * There are cases where we must use one or must use the other, and
1596 * it's not really worthwhile to postpone the check till we know. But
1597 * note we do not require caller to provide an expectedDesc.
1598 */
1599 if (!rsi || !IsA(rsi, ReturnSetInfo) ||
1600 (rsi->allowedModes & SFRM_ValuePerCall) == 0 ||
1601 (rsi->allowedModes & SFRM_Materialize) == 0)
1602 ereport(ERROR,
1603 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1604 errmsg("set-valued function called in context that cannot accept a set")));
1605 randomAccess = rsi->allowedModes & SFRM_Materialize_Random;
1606 lazyEvalOK = !(rsi->allowedModes & SFRM_Materialize_Preferred);
1607 /* tuplestore, if used, must have query lifespan */
1608 tscontext = rsi->econtext->ecxt_per_query_memory;
1609 }
1610 else
1611 {
1612 randomAccess = false;
1613 lazyEvalOK = true;
1614 /* we won't need a tuplestore */
1615 tscontext = NULL;
1616 }
1617
1618 /*
1619 * Initialize fcache if starting a fresh execution.
1620 */
1621 fcache = init_sql_fcache(fcinfo, lazyEvalOK);
1622
1623 /* Mark fcache as active */
1624 fcache->active = true;
1625
1626 /* Remember info that we might need later to construct tuplestore */
1627 fcache->tscontext = tscontext;
1628 fcache->randomAccess = randomAccess;
1629
1630 /*
1631 * Now we can set up error traceback support for ereport()
1632 */
1633 sqlerrcontext.callback = sql_exec_error_callback;
1634 sqlerrcontext.arg = fcache;
1635 sqlerrcontext.previous = error_context_stack;
1636 error_context_stack = &sqlerrcontext;
1637
1638 /*
1639 * Find first unfinished execution_state. If none, advance to the next
1640 * query in function.
1641 */
1642 do
1643 {
1644 es = fcache->eslist;
1645 while (es && es->status == F_EXEC_DONE)
1646 es = es->next;
1647 if (es)
1648 break;
1649 } while (init_execution_state(fcache));
1650
1651 /*
1652 * Execute each command in the function one after another until we either
1653 * run out of commands or get a result row from a lazily-evaluated SELECT.
1654 *
1655 * Notes about snapshot management:
1656 *
1657 * In a read-only function, we just use the surrounding query's snapshot.
1658 *
1659 * In a non-read-only function, we rely on the fact that we'll never
1660 * suspend execution between queries of the function: the only reason to
1661 * suspend execution before completion is if we are returning a row from a
1662 * lazily-evaluated SELECT. So, when first entering this loop, we'll
1663 * either start a new query (and push a fresh snapshot) or re-establish
1664 * the active snapshot from the existing query descriptor. If we need to
1665 * start a new query in a subsequent execution of the loop, either we need
1666 * a fresh snapshot (and pushed_snapshot is false) or the existing
1667 * snapshot is on the active stack and we can just bump its command ID.
1668 */
1669 pushed_snapshot = false;
1670 while (es)
1671 {
1672 bool completed;
1673
1674 if (es->status == F_EXEC_START)
1675 {
1676 /*
1677 * If not read-only, be sure to advance the command counter for
1678 * each command, so that all work to date in this transaction is
1679 * visible. Take a new snapshot if we don't have one yet,
1680 * otherwise just bump the command ID in the existing snapshot.
1681 */
1682 if (!fcache->func->readonly_func)
1683 {
1685 if (!pushed_snapshot)
1686 {
1688 pushed_snapshot = true;
1689 }
1690 else
1692 }
1693
1694 postquel_start(es, fcache);
1695 }
1696 else if (!fcache->func->readonly_func && !pushed_snapshot)
1697 {
1698 /* Re-establish active snapshot when re-entering function */
1700 pushed_snapshot = true;
1701 }
1702
1703 completed = postquel_getnext(es, fcache);
1704
1705 /*
1706 * If we ran the command to completion, we can shut it down now. Any
1707 * row(s) we need to return are safely stashed in the result slot or
1708 * tuplestore, and we want to be sure that, for example, AFTER
1709 * triggers get fired before we return anything. Also, if the
1710 * function doesn't return set, we can shut it down anyway because it
1711 * must be a SELECT and we don't care about fetching any more result
1712 * rows.
1713 */
1714 if (completed || !fcache->func->returnsSet)
1715 postquel_end(es, fcache);
1716
1717 /*
1718 * Break from loop if we didn't shut down (implying we got a
1719 * lazily-evaluated row). Otherwise we'll press on till the whole
1720 * function is done, relying on the tuplestore to keep hold of the
1721 * data to eventually be returned. This is necessary since an
1722 * INSERT/UPDATE/DELETE RETURNING that sets the result might be
1723 * followed by additional rule-inserted commands, and we want to
1724 * finish doing all those commands before we return anything.
1725 */
1726 if (es->status != F_EXEC_DONE)
1727 break;
1728
1729 /*
1730 * Advance to next execution_state, and perhaps next query.
1731 */
1732 es = es->next;
1733 while (!es)
1734 {
1735 /*
1736 * Flush the current snapshot so that we will take a new one for
1737 * the new query list. This ensures that new snaps are taken at
1738 * original-query boundaries, matching the behavior of interactive
1739 * execution.
1740 */
1741 if (pushed_snapshot)
1742 {
1744 pushed_snapshot = false;
1745 }
1746
1747 if (!init_execution_state(fcache))
1748 break; /* end of function */
1749
1750 es = fcache->eslist;
1751 }
1752 }
1753
1754 /*
1755 * The result slot or tuplestore now contains whatever row(s) we are
1756 * supposed to return.
1757 */
1758 if (fcache->func->returnsSet)
1759 {
1760 ReturnSetInfo *rsi = (ReturnSetInfo *) fcinfo->resultinfo;
1761
1762 if (es)
1763 {
1764 /*
1765 * If we stopped short of being done, we must have a lazy-eval
1766 * row.
1767 */
1768 Assert(es->lazyEval);
1769 /* The junkfilter's result slot contains the query result tuple */
1770 Assert(fcache->junkFilter);
1771 slot = fcache->junkFilter->jf_resultSlot;
1772 Assert(!TTS_EMPTY(slot));
1773 /* Extract the result as a datum, and copy out from the slot */
1774 result = postquel_get_single_result(slot, fcinfo, fcache);
1775
1776 /*
1777 * Let caller know we're not finished.
1778 */
1780
1781 /*
1782 * Ensure we will get shut down cleanly if the exprcontext is not
1783 * run to completion.
1784 */
1785 if (!fcache->shutdown_reg)
1786 {
1789 PointerGetDatum(fcache));
1790 fcache->shutdown_reg = true;
1791 }
1792 }
1793 else if (fcache->lazyEval)
1794 {
1795 /*
1796 * We are done with a lazy evaluation. Let caller know we're
1797 * finished.
1798 */
1799 rsi->isDone = ExprEndResult;
1800
1801 fcinfo->isnull = true;
1802 result = (Datum) 0;
1803
1804 /* Deregister shutdown callback, if we made one */
1805 if (fcache->shutdown_reg)
1806 {
1809 PointerGetDatum(fcache));
1810 fcache->shutdown_reg = false;
1811 }
1812 }
1813 else
1814 {
1815 /*
1816 * We are done with a non-lazy evaluation. Return whatever is in
1817 * the tuplestore. (It is now caller's responsibility to free the
1818 * tuplestore when done.)
1819 *
1820 * Note an edge case: we could get here without having made a
1821 * tuplestore if the function is declared to return SETOF VOID.
1822 * ExecMakeTableFunctionResult will cope with null setResult.
1823 */
1824 Assert(fcache->tstore || fcache->func->rettype == VOIDOID);
1826 rsi->setResult = fcache->tstore;
1827 fcache->tstore = NULL;
1828 /* must copy desc because execSRF.c will free it */
1829 if (fcache->junkFilter)
1831
1832 fcinfo->isnull = true;
1833 result = (Datum) 0;
1834
1835 /* Deregister shutdown callback, if we made one */
1836 if (fcache->shutdown_reg)
1837 {
1840 PointerGetDatum(fcache));
1841 fcache->shutdown_reg = false;
1842 }
1843 }
1844 }
1845 else
1846 {
1847 /*
1848 * Non-set function. If we got a row, return it; else return NULL.
1849 */
1850 if (fcache->junkFilter)
1851 {
1852 /* The junkfilter's result slot contains the query result tuple */
1853 slot = fcache->junkFilter->jf_resultSlot;
1854 if (!TTS_EMPTY(slot))
1855 result = postquel_get_single_result(slot, fcinfo, fcache);
1856 else
1857 {
1858 fcinfo->isnull = true;
1859 result = (Datum) 0;
1860 }
1861 }
1862 else
1863 {
1864 /* Should only get here for VOID functions and procedures */
1865 Assert(fcache->func->rettype == VOIDOID);
1866 fcinfo->isnull = true;
1867 result = (Datum) 0;
1868 }
1869 }
1870
1871 /* Pop snapshot if we have pushed one */
1872 if (pushed_snapshot)
1874
1875 /*
1876 * If we've gone through every command in the function, we are done. Reset
1877 * state to start over again on next call.
1878 */
1879 if (es == NULL)
1880 fcache->eslist = NULL;
1881
1882 /* Mark fcache as inactive */
1883 fcache->active = false;
1884
1885 error_context_stack = sqlerrcontext.previous;
1886
1887 return result;
1888}
ErrorContextCallback * error_context_stack
Definition: elog.c:95
int errcode(int sqlerrcode)
Definition: elog.c:854
int errmsg(const char *fmt,...)
Definition: elog.c:1071
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:150
void UnregisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
Definition: execUtils.c:989
void RegisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
Definition: execUtils.c:963
@ ExprMultipleResult
Definition: execnodes.h:328
@ ExprEndResult
Definition: execnodes.h:329
@ SFRM_Materialize_Preferred
Definition: execnodes.h:343
@ SFRM_ValuePerCall
Definition: execnodes.h:340
@ SFRM_Materialize_Random
Definition: execnodes.h:342
@ SFRM_Materialize
Definition: execnodes.h:341
static Datum postquel_get_single_result(TupleTableSlot *slot, FunctionCallInfo fcinfo, SQLFunctionCachePtr fcache)
Definition: functions.c:1536
static bool postquel_getnext(execution_state *es, SQLFunctionCachePtr fcache)
Definition: functions.c:1400
static void postquel_start(execution_state *es, SQLFunctionCachePtr fcache)
Definition: functions.c:1276
static bool init_execution_state(SQLFunctionCachePtr fcache)
Definition: functions.c:653
static void postquel_end(execution_state *es, SQLFunctionCachePtr fcache)
Definition: functions.c:1441
static void sql_exec_error_callback(void *arg)
Definition: functions.c:1929
static void ShutdownSQLFunction(Datum arg)
Definition: functions.c:1967
@ F_EXEC_START
Definition: functions.c:65
@ F_EXEC_DONE
Definition: functions.c:65
static SQLFunctionCache * init_sql_fcache(FunctionCallInfo fcinfo, bool lazyEvalOK)
Definition: functions.c:536
Assert(PointerIsAligned(start, uint64))
if(TABLE==NULL||TABLE_index==NULL)
Definition: isn.c:81
#define IsA(nodeptr, _type_)
Definition: nodes.h:164
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:332
uint64_t Datum
Definition: postgres.h:70
Snapshot GetTransactionSnapshot(void)
Definition: snapmgr.c:271
void PushActiveSnapshot(Snapshot snapshot)
Definition: snapmgr.c:680
void UpdateActiveSnapshotCommandId(void)
Definition: snapmgr.c:742
void PopActiveSnapshot(void)
Definition: snapmgr.c:773
struct ErrorContextCallback * previous
Definition: elog.h:297
void * arg
Definition: elog.h:299
void(* callback)(void *arg)
Definition: elog.h:298
MemoryContext ecxt_per_query_memory
Definition: execnodes.h:280
TupleDesc jf_cleanTupType
Definition: execnodes.h:419
TupleTableSlot * jf_resultSlot
Definition: execnodes.h:421
Snapshot snapshot
Definition: execdesc.h:39
SetFunctionReturnMode returnMode
Definition: execnodes.h:360
ExprContext * econtext
Definition: execnodes.h:356
TupleDesc setDesc
Definition: execnodes.h:364
Tuplestorestate * setResult
Definition: execnodes.h:363
int allowedModes
Definition: execnodes.h:358
ExprDoneCond isDone
Definition: execnodes.h:361
execution_state * eslist
Definition: functions.c:175
SQLFunctionHashEntry * func
Definition: functions.c:144
bool randomAccess
Definition: functions.c:150
JunkFilter * junkFilter
Definition: functions.c:158
bool shutdown_reg
Definition: functions.c:148
Tuplestorestate * tstore
Definition: functions.c:155
MemoryContext tscontext
Definition: functions.c:156
bool lazyEval
Definition: functions.c:73
ExecStatus status
Definition: functions.c:71
struct execution_state * next
Definition: functions.c:70
QueryDesc * qd
Definition: functions.c:75
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
Definition: tupdesc.c:252
#define TTS_EMPTY(slot)
Definition: tuptable.h:95
void CommandCounterIncrement(void)
Definition: xact.c:1100

References SQLFunctionCache::active, ReturnSetInfo::allowedModes, ErrorContextCallback::arg, Assert(), ErrorContextCallback::callback, CommandCounterIncrement(), CreateTupleDescCopy(), ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, ereport, errcode(), errmsg(), ERROR, error_context_stack, SQLFunctionCache::eslist, ExprEndResult, ExprMultipleResult, F_EXEC_DONE, F_EXEC_START, SQLFunctionCache::func, GetTransactionSnapshot(), if(), init_execution_state(), init_sql_fcache(), IsA, ReturnSetInfo::isDone, JunkFilter::jf_cleanTupType, JunkFilter::jf_resultSlot, SQLFunctionCache::junkFilter, execution_state::lazyEval, SQLFunctionCache::lazyEval, execution_state::next, PointerGetDatum(), PopActiveSnapshot(), postquel_end(), postquel_get_single_result(), postquel_getnext(), postquel_start(), ErrorContextCallback::previous, PushActiveSnapshot(), execution_state::qd, SQLFunctionCache::randomAccess, SQLFunctionHashEntry::readonly_func, RegisterExprContextCallback(), SQLFunctionHashEntry::rettype, ReturnSetInfo::returnMode, SQLFunctionHashEntry::returnsSet, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, SFRM_Materialize_Preferred, SFRM_Materialize_Random, SFRM_ValuePerCall, SQLFunctionCache::shutdown_reg, ShutdownSQLFunction(), QueryDesc::snapshot, sql_exec_error_callback(), execution_state::status, SQLFunctionCache::tscontext, SQLFunctionCache::tstore, TTS_EMPTY, UnregisterExprContextCallback(), and UpdateActiveSnapshotCommandId().

Referenced by fmgr_info_cxt_security().

prepare_sql_fn_parse_info()

SQLFunctionParseInfoPtr prepare_sql_fn_parse_info ( HeapTuple  procedureTuple,
Nodecall_expr,
Oid  inputCollation 
)

Definition at line 251 of file functions.c.

254{
256 Form_pg_proc procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple);
257 int nargs;
258
260
261 /* Function's name (only) can be used to qualify argument names */
262 pinfo->fname = pstrdup(NameStr(procedureStruct->proname));
263
264 /* Save the function's input collation */
265 pinfo->collation = inputCollation;
266
267 /*
268 * Copy input argument types from the pg_proc entry, then resolve any
269 * polymorphic types.
270 */
271 pinfo->nargs = nargs = procedureStruct->pronargs;
272 if (nargs > 0)
273 {
274 Oid *argOidVect;
275 int argnum;
276
277 argOidVect = (Oid *) palloc(nargs * sizeof(Oid));
278 memcpy(argOidVect,
279 procedureStruct->proargtypes.values,
280 nargs * sizeof(Oid));
281
282 for (argnum = 0; argnum < nargs; argnum++)
283 {
284 Oid argtype = argOidVect[argnum];
285
286 if (IsPolymorphicType(argtype))
287 {
288 argtype = get_call_expr_argtype(call_expr, argnum);
289 if (argtype == InvalidOid)
291 (errcode(ERRCODE_DATATYPE_MISMATCH),
292 errmsg("could not determine actual type of argument declared %s",
293 format_type_be(argOidVect[argnum]))));
294 argOidVect[argnum] = argtype;
295 }
296 }
297
298 pinfo->argtypes = argOidVect;
299 }
300
301 /*
302 * Collect names of arguments, too, if any
303 */
304 if (nargs > 0)
305 {
306 Datum proargnames;
307 Datum proargmodes;
308 int n_arg_names;
309 bool isNull;
310
311 proargnames = SysCacheGetAttr(PROCNAMEARGSNSP, procedureTuple,
312 Anum_pg_proc_proargnames,
313 &isNull);
314 if (isNull)
315 proargnames = PointerGetDatum(NULL); /* just to be sure */
316
317 proargmodes = SysCacheGetAttr(PROCNAMEARGSNSP, procedureTuple,
318 Anum_pg_proc_proargmodes,
319 &isNull);
320 if (isNull)
321 proargmodes = PointerGetDatum(NULL); /* just to be sure */
322
323 n_arg_names = get_func_input_arg_names(proargnames, proargmodes,
324 &pinfo->argnames);
325
326 /* Paranoia: ignore the result if too few array entries */
327 if (n_arg_names < nargs)
328 pinfo->argnames = NULL;
329 }
330 else
331 pinfo->argnames = NULL;
332
333 return pinfo;
334}
#define NameStr(name)
Definition: c.h:751
Oid get_call_expr_argtype(Node *expr, int argnum)
Definition: fmgr.c:1894
char * format_type_be(Oid type_oid)
Definition: format_type.c:343
int get_func_input_arg_names(Datum proargnames, Datum proargmodes, char ***arg_names)
Definition: funcapi.c:1522
SQLFunctionParseInfo * SQLFunctionParseInfoPtr
Definition: functions.h:35
static void * GETSTRUCT(const HeapTupleData *tuple)
Definition: htup_details.h:728
char * pstrdup(const char *in)
Definition: mcxt.c:1759
void * palloc(Size size)
Definition: mcxt.c:1365
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define InvalidOid
Definition: postgres_ext.h:37
unsigned int Oid
Definition: postgres_ext.h:32
char ** argnames
Definition: functions.h:30
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:595

References SQLFunctionParseInfo::argnames, SQLFunctionParseInfo::argtypes, SQLFunctionParseInfo::collation, ereport, errcode(), errmsg(), ERROR, SQLFunctionParseInfo::fname, format_type_be(), get_call_expr_argtype(), get_func_input_arg_names(), GETSTRUCT(), InvalidOid, NameStr, SQLFunctionParseInfo::nargs, palloc(), palloc0(), PointerGetDatum(), pstrdup(), and SysCacheGetAttr().

Referenced by fmgr_sql_validator(), inline_function(), inline_set_returning_function(), and sql_compile_callback().

sql_fn_parser_setup()

void sql_fn_parser_setup ( struct ParseStatepstate,
)

Definition at line 340 of file functions.c.

341{
342 pstate->p_pre_columnref_hook = NULL;
345 /* no need to use p_coerce_param_hook */
346 pstate->p_ref_hook_state = pinfo;
347}
static Node * sql_fn_param_ref(ParseState *pstate, ParamRef *pref)
Definition: functions.c:469
static Node * sql_fn_post_column_ref(ParseState *pstate, ColumnRef *cref, Node *var)
Definition: functions.c:353
void * p_ref_hook_state
Definition: parse_node.h:242
ParseParamRefHook p_paramref_hook
Definition: parse_node.h:240
PreParseColumnRefHook p_pre_columnref_hook
Definition: parse_node.h:238
PostParseColumnRefHook p_post_columnref_hook
Definition: parse_node.h:239

References ParseState::p_paramref_hook, ParseState::p_post_columnref_hook, ParseState::p_pre_columnref_hook, ParseState::p_ref_hook_state, sql_fn_param_ref(), and sql_fn_post_column_ref().

Referenced by fmgr_sql_validator(), inline_function(), inline_set_returning_function(), interpret_AS_clause(), and prepare_next_query().

AltStyle によって変換されたページ (->オリジナル) /