PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/htup_details.h"
#include "access/xact.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "executor/functions.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "parser/parse_coerce.h"
#include "parser/parse_func.h"
#include "storage/proc.h"
#include "tcop/utility.h"
#include "utils/builtins.h"
#include "utils/datum.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
Go to the source code of this file.
Data Structures | |
struct | DR_sqlfunction |
struct | execution_state |
struct | SQLFunctionCache |
struct | SQLFunctionParseInfo |
Typedefs | |
typedef struct execution_state | execution_state |
typedef SQLFunctionCache * | SQLFunctionCachePtr |
typedef struct SQLFunctionParseInfo | SQLFunctionParseInfo |
Enumerations | |
enum | ExecStatus { F_EXEC_START, F_EXEC_RUN, F_EXEC_DONE } |
typedef struct execution_state execution_state |
typedef SQLFunctionCache* SQLFunctionCachePtr |
Definition at line 128 of file functions.c.
typedef struct SQLFunctionParseInfo SQLFunctionParseInfo |
enum ExecStatus |
Enumerator | |
---|---|
F_EXEC_START | |
F_EXEC_RUN | |
F_EXEC_DONE |
Definition at line 58 of file functions.c.
bool check_sql_fn_retval | ( | Oid | func_id, |
Oid | rettype, | ||
List * | queryTreeList, | ||
bool * | modifyTargetList, | ||
JunkFilter ** | junkFilter | ||
) |
Definition at line 1574 of file functions.c.
References Assert, AssertArg, Query::canSetTag, CMD_DELETE, CMD_INSERT, CMD_SELECT, CMD_UPDATE, COERCE_IMPLICIT_CAST, Query::commandType, CreateTupleDescCopy(), ereport, errcode(), errdetail(), errmsg(), ERROR, ExecCleanTargetListLength(), ExecInitJunkFilter(), ExecInitJunkFilterConversion(), TargetEntry::expr, exprType(), format_type_be(), get_func_result_type(), get_typcollation(), get_typtype(), InvalidOid, IsBinaryCoercible(), lappend(), lfirst, lfirst_node, linitial, list_concat(), makeConst(), makeRelabelType(), MakeSingleTupleTableSlot(), makeTargetEntry(), TupleDescData::natts, NIL, parse(), TargetEntry::resjunk, TargetEntry::resno, TargetEntry::ressortgroupref, Query::returningList, Query::setOperations, Query::targetList, TTSOpsMinimalTuple, TupleDescAttr, and TYPEFUNC_COMPOSITE.
Referenced by fmgr_sql_validator(), init_sql_fcache(), inline_function(), and inline_set_returning_function().
void check_sql_fn_statements | ( | List * | queryTreeList | ) |
Definition at line 1488 of file functions.c.
References castNode, CMD_UTILITY, Query::commandType, elog, ereport, errcode(), errmsg(), ERROR, CallStmt::funcexpr, FuncExpr::funcid, get_func_arg_info(), HeapTupleIsValid, i, IsA, lfirst_node, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), SearchSysCache1(), execution_state::stmt, and Query::utilityStmt.
Referenced by fmgr_sql_validator(), and init_sql_fcache().
DestReceiver* CreateSQLFunctionDestReceiver | ( | void | ) |
Definition at line 1955 of file functions.c.
References DestSQLFunction, palloc0(), sqlfunction_destroy(), sqlfunction_receive(), sqlfunction_shutdown(), and sqlfunction_startup().
Referenced by CreateDestReceiver().
Datum fmgr_sql | ( | PG_FUNCTION_ARGS | ) |
Definition at line 983 of file functions.c.
References ReturnSetInfo::allowedModes, ErrorContextCallback::arg, Assert, ErrorContextCallback::callback, CommandCounterIncrement(), CreateTupleDescCopy(), ReturnSetInfo::econtext, elog, ereport, errcode(), errmsg(), ERROR, error_context_stack, ExprEndResult, ExprMultipleResult, F_EXEC_DONE, F_EXEC_START, SQLFunctionCache::fcontext, SQLFunctionCache::func_state, GetTransactionSnapshot(), init_sql_fcache(), IsA, ReturnSetInfo::isDone, JunkFilter::jf_cleanTupType, JunkFilter::jf_resultSlot, SQLFunctionCache::junkFilter, execution_state::lazyEval, SQLFunctionCache::lazyEval, lfirst, lnext(), PGPROC::lxid, SQLFunctionCache::lxid, MemoryContextDelete(), MemoryContextSwitchTo(), MyProc, execution_state::next, PG_GET_COLLATION, PointerGetDatum, PopActiveSnapshot(), postquel_end(), postquel_get_single_result(), postquel_getnext(), postquel_start(), postquel_sub_params(), ErrorContextCallback::previous, PushActiveSnapshot(), execution_state::qd, SQLFunctionCache::readonly_func, RegisterExprContextCallback(), SQLFunctionCache::rettype, ReturnSetInfo::returnMode, SQLFunctionCache::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, SubTransactionIsActive(), SQLFunctionCache::subxid, SQLFunctionCache::tstore, tuplestore_begin_heap(), tuplestore_clear(), tuplestore_gettupleslot(), UnregisterExprContextCallback(), UpdateActiveSnapshotCommandId(), and work_mem.
Referenced by fmgr_info_cxt_security().
|
static |
Definition at line 474 of file functions.c.
References PlannedStmt::canSetTag, Query::canSetTag, CMD_SELECT, CMD_UTILITY, CommandIsReadOnly(), PlannedStmt::commandType, Query::commandType, CreateCommandTag(), CURSOR_OPT_PARALLEL_OK, ereport, errcode(), errmsg(), ERROR, F_EXEC_START, PlannedStmt::hasModifyingCTE, IsA, IsInParallelMode(), SQLFunctionCache::junkFilter, lappend(), execution_state::lazyEval, SQLFunctionCache::lazyEval, lfirst_node, makeNode, execution_state::next, NIL, palloc(), pg_plan_query(), PreventCommandIfParallelMode(), execution_state::qd, SQLFunctionCache::readonly_func, execution_state::setsResult, execution_state::status, execution_state::stmt, PlannedStmt::stmt_len, Query::stmt_len, PlannedStmt::stmt_location, Query::stmt_location, PlannedStmt::utilityStmt, and Query::utilityStmt.
Referenced by init_sql_fcache().
Definition at line 594 of file functions.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, BlessTupleDesc(), check_sql_fn_retval(), check_sql_fn_statements(), elog, ereport, errcode(), errmsg(), ERROR, SQLFunctionCache::fcontext, FmgrInfo::fn_expr, FmgrInfo::fn_extra, FmgrInfo::fn_mcxt, FmgrInfo::fn_oid, SQLFunctionCache::fname, format_type_be(), SQLFunctionCache::func_state, get_fn_expr_rettype(), get_typlenbyval(), GetCurrentSubTransactionId(), GETSTRUCT, HeapTupleIsValid, init_execution_state(), InvalidOid, JunkFilter::jf_resultSlot, SQLFunctionCache::junkFilter, lappend(), lfirst_node, list_concat(), PGPROC::lxid, SQLFunctionCache::lxid, MemoryContextSetIdentifier(), MemoryContextSwitchTo(), MyProc, NameStr, NIL, ObjectIdGetDatum, palloc0(), pg_analyze_and_rewrite_params(), pg_parse_query(), SQLFunctionCache::pinfo, prepare_sql_fn_parse_info(), PROCOID, pstrdup(), SQLFunctionCache::readonly_func, ReleaseSysCache(), SQLFunctionCache::rettype, SQLFunctionCache::returnsSet, SQLFunctionCache::returnsTuple, SearchSysCache1(), sql_fn_parser_setup(), SQLFunctionCache::src, SQLFunctionCache::subxid, SysCacheGetAttr(), TextDatumGetCString, TupleTableSlot::tts_tupleDescriptor, SQLFunctionCache::typbyval, type_is_rowtype(), and SQLFunctionCache::typlen.
Referenced by fmgr_sql().
|
static |
Definition at line 880 of file functions.c.
References CMD_UTILITY, QueryDesc::dest, ExecutorEnd(), ExecutorFinish(), F_EXEC_DONE, FreeQueryDesc(), QueryDesc::operation, execution_state::qd, _DestReceiver::rDestroy, and execution_state::status.
Referenced by fmgr_sql(), and ShutdownSQLFunction().
|
static |
Definition at line 940 of file functions.c.
References datumCopy(), ExecFetchSlotHeapTupleDatum(), FunctionCallInfoBaseData::isnull, MemoryContextSwitchTo(), SQLFunctionCache::returnsTuple, slot_getattr(), SQLFunctionCache::typbyval, SQLFunctionCache::typlen, and value.
Referenced by fmgr_sql().
|
static |
Definition at line 846 of file functions.c.
References CMD_UTILITY, QueryDesc::dest, EState::es_processed, QueryDesc::estate, ExecutorRun(), ForwardScanDirection, execution_state::lazyEval, QueryDesc::operation, QueryDesc::params, QueryDesc::plannedstmt, PROCESS_UTILITY_QUERY, ProcessUtility(), execution_state::qd, QueryDesc::queryEnv, SQLFunctionCache::returnsSet, and SQLFunctionCache::src.
Referenced by fmgr_sql().
|
static |
Definition at line 784 of file functions.c.
References ActiveSnapshotSet(), Assert, CMD_UTILITY, CreateDestReceiver(), CreateQueryDesc(), CurrentMemoryContext, DR_sqlfunction::cxt, generate_unaccent_rules::dest, DestSQLFunction, EXEC_FLAG_SKIP_TRIGGERS, ExecutorStart(), F_EXEC_RUN, DR_sqlfunction::filter, GetActiveSnapshot(), InvalidSnapshot, SQLFunctionCache::junkFilter, execution_state::lazyEval, _DestReceiver::mydest, None_Receiver, QueryDesc::operation, SQLFunctionCache::paramLI, DR_sqlfunction::pub, execution_state::qd, QueryDesc::queryEnv, execution_state::setsResult, SQLFunctionCache::src, execution_state::status, execution_state::stmt, DR_sqlfunction::tstore, and SQLFunctionCache::tstore.
Referenced by fmgr_sql().
|
static |
Definition at line 900 of file functions.c.
References FunctionCallInfoBaseData::args, SQLFunctionParseInfo::argtypes, Assert, i, ParamExternData::isnull, NullableDatum::isnull, makeParamList(), FunctionCallInfoBaseData::nargs, ParamListInfoData::numParams, SQLFunctionCache::paramLI, ParamListInfoData::params, ParamExternData::pflags, SQLFunctionCache::pinfo, ParamExternData::ptype, ParamExternData::value, and NullableDatum::value.
Referenced by fmgr_sql().
SQLFunctionParseInfoPtr prepare_sql_fn_parse_info | ( | HeapTuple | procedureTuple, |
Node * | call_expr, | ||
Oid | inputCollation | ||
) |
Definition at line 184 of file functions.c.
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, PROCNAMEARGSNSP, pstrdup(), and SysCacheGetAttr().
Referenced by fmgr_sql_validator(), init_sql_fcache(), inline_function(), and inline_set_returning_function().
|
static |
Definition at line 1442 of file functions.c.
References DatumGetPointer, F_EXEC_RUN, F_EXEC_START, SQLFunctionCache::func_state, lfirst, execution_state::next, PopActiveSnapshot(), postquel_end(), PushActiveSnapshot(), execution_state::qd, SQLFunctionCache::readonly_func, SQLFunctionCache::shutdown_reg, QueryDesc::snapshot, execution_state::status, SQLFunctionCache::tstore, and tuplestore_end().
Referenced by fmgr_sql().
|
static |
Definition at line 1360 of file functions.c.
References errcontext, errposition(), FmgrInfo::fn_extra, SQLFunctionCache::fname, SQLFunctionCache::func_state, geterrposition(), internalerrposition(), internalerrquery(), lfirst, execution_state::next, execution_state::qd, and SQLFunctionCache::src.
Referenced by fmgr_sql().
|
static |
Definition at line 420 of file functions.c.
References SQLFunctionParseInfo::argtypes, SQLFunctionParseInfo::collation, get_typcollation(), Param::location, makeNode, OidIsValid, PARAM_EXTERN, Param::paramcollid, Param::paramid, Param::paramkind, Param::paramtype, and Param::paramtypmod.
Referenced by sql_fn_param_ref(), and sql_fn_resolve_param_name().
|
static |
Definition at line 404 of file functions.c.
References ParamRef::location, SQLFunctionParseInfo::nargs, ParamRef::number, ParseState::p_ref_hook_state, and sql_fn_make_param().
Referenced by sql_fn_parser_setup().
void sql_fn_parser_setup | ( | struct ParseState * | pstate, |
SQLFunctionParseInfoPtr | pinfo | ||
) |
Definition at line 273 of file functions.c.
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(), init_sql_fcache(), inline_function(), and inline_set_returning_function().
|
static |
Definition at line 286 of file functions.c.
References Assert, ColumnRef::fields, SQLFunctionParseInfo::fname, IsA, linitial, list_length(), list_make1, llast, ColumnRef::location, lsecond, lthird, ParseState::p_last_srf, ParseState::p_ref_hook_state, ParseFuncOrColumn(), sql_fn_resolve_param_name(), and strVal.
Referenced by sql_fn_parser_setup().
|
static |
Definition at line 450 of file functions.c.
References SQLFunctionParseInfo::argnames, i, SQLFunctionParseInfo::nargs, and sql_fn_make_param().
Referenced by sql_fn_post_column_ref().
|
static |
Definition at line 2009 of file functions.c.
References pfree().
Referenced by CreateSQLFunctionDestReceiver().
|
static |
Definition at line 1983 of file functions.c.
References ExecFilterJunk(), DR_sqlfunction::filter, DR_sqlfunction::tstore, and tuplestore_puttupleslot().
Referenced by CreateSQLFunctionDestReceiver().
|
static |
Definition at line 2000 of file functions.c.
Referenced by CreateSQLFunctionDestReceiver().
|
static |
Definition at line 1974 of file functions.c.
Referenced by CreateSQLFunctionDestReceiver().