|
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_collate.h"#include "parser/parse_func.h"#include "rewrite/rewriteHandler.h"#include "storage/proc.h"#include "tcop/utility.h"#include "utils/builtins.h"#include "utils/datum.h"#include "utils/funccache.h"#include "utils/lsyscache.h"#include "utils/memutils.h"#include "utils/plancache.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 | SQLFunctionHashEntry |
| struct | SQLFunctionCache |
Enumerations | |
| enum | ExecStatus { F_EXEC_START , F_EXEC_RUN , F_EXEC_DONE } |
Definition at line 192 of file functions.c.
| Enumerator | |
|---|---|
| F_EXEC_START | |
| F_EXEC_RUN | |
| F_EXEC_DONE | |
Definition at line 63 of file functions.c.
| bool check_sql_fn_retval | ( | List * | queryTreeLists, |
| Oid | rettype, | ||
| TupleDesc | rettupdesc, | ||
| char | prokind, | ||
| bool | insertDroppedCols | ||
| ) |
Definition at line 2116 of file functions.c.
References check_sql_stmt_retval(), fb(), llast_node, and NIL.
Referenced by fmgr_sql_validator(), inline_function(), and inline_sql_function_in_from().
Definition at line 2052 of file functions.c.
References CMD_UTILITY, Query::commandType, ereport, errcode(), errmsg(), ERROR, fb(), IsA, lfirst_node, NIL, stmt, and Query::utilityStmt.
Referenced by check_sql_fn_statements(), prepare_next_query(), and sql_postrewrite_callback().
Definition at line 2035 of file functions.c.
References check_sql_fn_statement(), fb(), and lfirst_node.
Referenced by fmgr_sql_validator().
|
static |
Definition at line 2150 of file functions.c.
References Assert, CMD_DELETE, CMD_INSERT, CMD_MERGE, CMD_SELECT, CMD_UPDATE, coerce_fn_result_column(), ereport, errcode(), errdetail(), errmsg(), ERROR, ExecCleanTargetListLength(), exprType(), fb(), format_type_be(), get_typtype(), InvalidOid, lappend(), lfirst, lfirst_node, linitial, list_length(), list_make1, makeAlias(), makeConst(), makeFromExpr(), makeNode, makeString(), makeTargetEntry(), TupleDescData::natts, NIL, parse(), RTE_SUBQUERY, TupleDescAttr(), and TupleDescCompactAttr().
Referenced by check_sql_fn_retval(), prepare_next_query(), and sql_postrewrite_callback().
|
static |
Definition at line 2520 of file functions.c.
References assign_expr_collations(), COERCE_IMPLICIT_CAST, coerce_to_target_type(), COERCION_ASSIGNMENT, exprType(), fb(), lappend(), list_length(), makeTargetEntry(), and makeVarFromTargetEntry().
Referenced by check_sql_stmt_retval().
| DestReceiver * CreateSQLFunctionDestReceiver | ( | void | ) |
Definition at line 2617 of file functions.c.
References DestSQLFunction, _DestReceiver::mydest, palloc0_object, DR_sqlfunction::pub, _DestReceiver::rDestroy, _DestReceiver::receiveSlot, _DestReceiver::rShutdown, _DestReceiver::rStartup, sqlfunction_destroy(), sqlfunction_receive(), sqlfunction_shutdown(), and sqlfunction_startup().
Referenced by CreateDestReceiver().
| Datum fmgr_sql | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1576 of file functions.c.
References ReturnSetInfo::allowedModes, Assert, CommandCounterIncrement(), CreateTupleDescCopy(), ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, ereport, errcode(), errmsg(), ERROR, error_context_stack, ExprEndResult, ExprMultipleResult, F_EXEC_DONE, F_EXEC_START, fb(), GetTransactionSnapshot(), init_execution_state(), init_sql_fcache(), IsA, ReturnSetInfo::isDone, execution_state::lazyEval, execution_state::next, PointerGetDatum(), PopActiveSnapshot(), postquel_end(), postquel_get_single_result(), postquel_getnext(), postquel_start(), ErrorContextCallback::previous, PushActiveSnapshot(), execution_state::qd, RegisterExprContextCallback(), ReturnSetInfo::returnMode, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, SFRM_Materialize_Preferred, SFRM_Materialize_Random, SFRM_ValuePerCall, ShutdownSQLFunction(), QueryDesc::snapshot, sql_exec_error_callback(), execution_state::status, TTS_EMPTY, UnregisterExprContextCallback(), and UpdateActiveSnapshotCommandId().
Referenced by fmgr_info_cxt_security().
Definition at line 2586 of file functions.c.
References CMD_DELETE, CMD_INSERT, CMD_MERGE, CMD_SELECT, CMD_UPDATE, fb(), lfirst_node, NIL, and parse().
Referenced by init_execution_state().
|
static |
Definition at line 653 of file functions.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, BlessTupleDesc(), CMD_SELECT, CMD_UTILITY, CommandIsReadOnly(), CreateCommandName(), CurrentResourceOwner, ereport, errcode(), errmsg(), ERROR, ExecInitJunkFilter(), ExecInitJunkFilterConversion(), F_EXEC_START, fb(), foreach_current_index, get_sql_fn_result_tlist(), GetCachedPlan(), IsA, lfirst_node, list_length(), list_nth(), MakeSingleTupleTableSlot(), MemoryContextAlloc(), MemoryContextReset(), MemoryContextSwitchTo(), NIL, prepare_next_query(), CachedPlanSource::query_list, ReleaseCachedPlan(), repalloc_array, stmt, TTSOpsMinimalTuple, and type_is_rowtype().
Referenced by fmgr_sql().
|
static |
Definition at line 536 of file functions.c.
References Assert, cached_function_compile(), SQLFunctionHashEntry::cfunc, fb(), FunctionCallInfoBaseData::flinfo, FmgrInfo::fn_extra, FmgrInfo::fn_mcxt, MemoryContextAllocZero(), MemoryContextRegisterResetCallback(), postquel_sub_params(), RemoveSQLFunctionCache(), sql_compile_callback(), sql_delete_callback(), and CachedFunction::use_count.
Referenced by fmgr_sql().
|
static |
Definition at line 1441 of file functions.c.
References CMD_UTILITY, QueryDesc::dest, ExecutorEnd(), ExecutorFinish(), F_EXEC_DONE, fb(), FreeQueryDesc(), MemoryContextDelete(), MemoryContextSwitchTo(), QueryDesc::operation, execution_state::qd, _DestReceiver::rDestroy, and execution_state::status.
Referenced by fmgr_sql(), and ShutdownSQLFunction().
|
static |
Definition at line 1536 of file functions.c.
References datumCopy(), ExecClearTuple(), ExecFetchSlotHeapTupleDatum(), fb(), FunctionCallInfoBaseData::isnull, slot_getattr(), and value.
Referenced by fmgr_sql().
|
static |
Definition at line 1400 of file functions.c.
References CMD_UTILITY, QueryDesc::dest, EState::es_processed, QueryDesc::estate, ExecutorRun(), fb(), ForwardScanDirection, execution_state::lazyEval, MemoryContextSwitchTo(), QueryDesc::operation, QueryDesc::params, QueryDesc::plannedstmt, PROCESS_UTILITY_QUERY, ProcessUtility(), execution_state::qd, and QueryDesc::queryEnv.
Referenced by fmgr_sql().
|
static |
Definition at line 1276 of file functions.c.
References ActiveSnapshotSet(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, CMD_UTILITY, PlannedStmt::commandType, CreateDestReceiver(), CreateQueryDesc(), CurrentMemoryContext, DestSQLFunction, EXEC_FLAG_SKIP_TRIGGERS, ExecClearTuple(), ExecutorStart(), F_EXEC_RUN, fb(), GetActiveSnapshot(), InvalidSnapshot, execution_state::lazyEval, MemoryContextSwitchTo(), None_Receiver, QueryDesc::operation, execution_state::qd, QueryDesc::queryEnv, execution_state::setsResult, execution_state::status, execution_state::stmt, tuplestore_begin_heap(), and work_mem.
Referenced by fmgr_sql().
|
static |
Definition at line 1473 of file functions.c.
References FunctionCallInfoBaseData::args, Assert, fb(), i, ParamExternData::isnull, NullableDatum::isnull, MakeExpandedObjectReadOnly, makeParamList(), MemoryContextSwitchTo(), FunctionCallInfoBaseData::nargs, ParamListInfoData::numParams, PARAM_FLAG_CONST, ParamListInfoData::params, and NullableDatum::value.
Referenced by init_sql_fcache().
|
static |
Definition at line 900 of file functions.c.
References AcquireRewriteLocks(), Assert, check_sql_fn_statement(), check_sql_stmt_retval(), CompleteCachedPlan(), copyObject, CreateCachedPlan(), CreateCachedPlanForQuery(), CreateCommandTag(), CURSOR_OPT_NO_SCROLL, CURSOR_OPT_PARALLEL_OK, fb(), SQLFunctionHashEntry::hcontext, lappend(), list_length(), list_nth_node, MemoryContextDelete(), MemoryContextSwitchTo(), NIL, SQLFunctionHashEntry::num_queries, SQLFunctionHashEntry::pcontext, pg_analyze_and_rewrite_withcb(), pg_rewrite_query(), SQLFunctionHashEntry::pinfo, SQLFunctionHashEntry::plansource_list, SQLFunctionHashEntry::prokind, SQLFunctionHashEntry::raw_source, SQLFunctionHashEntry::rettupdesc, SQLFunctionHashEntry::rettype, SQLFunctionHashEntry::returnsTuple, SaveCachedPlan(), SetPostRewriteHook(), SQLFunctionHashEntry::source_list, sql_fn_parser_setup(), sql_postrewrite_callback(), SQLFunctionHashEntry::src, and RawStmt::stmt.
Referenced by init_execution_state().
| SQLFunctionParseInfoPtr prepare_sql_fn_parse_info | ( | HeapTuple | procedureTuple, |
| Node * | call_expr, | ||
| Oid | inputCollation | ||
| ) |
Definition at line 251 of file functions.c.
References SQLFunctionParseInfo::argnames, SQLFunctionParseInfo::argtypes, SQLFunctionParseInfo::collation, ereport, errcode(), errmsg(), ERROR, fb(), SQLFunctionParseInfo::fname, format_type_be(), get_call_expr_argtype(), get_func_input_arg_names(), GETSTRUCT(), InvalidOid, NameStr, SQLFunctionParseInfo::nargs, palloc(), palloc0_object, PointerGetDatum(), pstrdup(), and SysCacheGetAttr().
Referenced by fmgr_sql_validator(), inline_function(), inline_sql_function_in_from(), sql_compile_callback(), and test_inline_in_from_support_func().
Definition at line 2014 of file functions.c.
References arg, Assert, and fb().
Referenced by init_sql_fcache().
Definition at line 1967 of file functions.c.
References arg, DatumGetPointer(), F_EXEC_RUN, fb(), execution_state::next, PopActiveSnapshot(), postquel_end(), PushActiveSnapshot(), execution_state::qd, ReleaseCachedPlan(), QueryDesc::snapshot, execution_state::status, and tuplestore_end().
Referenced by fmgr_sql().
|
static |
Definition at line 1040 of file functions.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, SQLFunctionParseInfo::argtypes, SQLFunctionHashEntry::argtyplen, CacheMemoryContext, castNode, copyObject, CreateTupleDescCopy(), CurrentMemoryContext, ereport, errcode(), errdetail(), errmsg(), ERROR, error_context_stack, fb(), FunctionCallInfoBaseData::flinfo, FmgrInfo::fn_expr, SQLFunctionHashEntry::fname, format_type_be(), get_call_result_type(), get_typlen(), get_typlenbyval(), GETSTRUCT(), SQLFunctionHashEntry::hcontext, i, IsA, linitial_node, list_length(), list_make1, MemoryContextAlloc(), MemoryContextSetIdentifier(), MemoryContextSetParent(), MemoryContextStrdup(), MemoryContextSwitchTo(), NameStr, SQLFunctionParseInfo::nargs, SQLFunctionHashEntry::num_queries, SQLFunctionHashEntry::pcontext, PG_GET_COLLATION, pg_parse_query(), SQLFunctionHashEntry::pinfo, prepare_sql_fn_parse_info(), ErrorContextCallback::previous, SQLFunctionHashEntry::prokind, SQLFunctionHashEntry::raw_source, SQLFunctionHashEntry::readonly_func, SQLFunctionHashEntry::rettupdesc, SQLFunctionHashEntry::rettype, SQLFunctionHashEntry::returnsSet, SQLFunctionHashEntry::source_list, sql_compile_error_callback(), SQLFunctionHashEntry::src, stringToNode(), SysCacheGetAttr(), SysCacheGetAttrNotNull(), TextDatumGetCString, SQLFunctionHashEntry::typbyval, and SQLFunctionHashEntry::typlen.
Referenced by init_sql_fcache().
Definition at line 1895 of file functions.c.
References arg, errcontext, errposition(), fb(), SQLFunctionHashEntry::fname, geterrposition(), internalerrposition(), internalerrquery(), and SQLFunctionHashEntry::src.
Referenced by sql_compile_callback().
|
static |
Definition at line 1213 of file functions.c.
References DropCachedPlan(), fb(), SQLFunctionHashEntry::hcontext, lfirst, MemoryContextDelete(), NIL, and SQLFunctionHashEntry::plansource_list.
Referenced by init_sql_fcache().
Definition at line 1929 of file functions.c.
References arg, errcontext, errposition(), fb(), geterrposition(), internalerrposition(), and internalerrquery().
Referenced by fmgr_sql().
|
static |
Definition at line 485 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 469 of file functions.c.
References fb(), SQLFunctionParseInfo::nargs, 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 340 of file functions.c.
References fb(), 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_sql_function_in_from(), interpret_AS_clause(), prepare_next_query(), and test_inline_in_from_support_func().
|
static |
Definition at line 353 of file functions.c.
References Assert, fb(), SQLFunctionParseInfo::fname, IsA, linitial, list_length(), list_make1, llast, 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 515 of file functions.c.
References SQLFunctionParseInfo::argnames, fb(), i, SQLFunctionParseInfo::nargs, and sql_fn_make_param().
Referenced by sql_fn_post_column_ref().
Definition at line 1243 of file functions.c.
References arg, check_sql_fn_statement(), check_sql_stmt_retval(), ereport, errcode(), errmsg(), ERROR, fb(), SQLFunctionHashEntry::prokind, SQLFunctionHashEntry::rettupdesc, SQLFunctionHashEntry::rettype, and SQLFunctionHashEntry::returnsTuple.
Referenced by prepare_next_query().
|
static |
Definition at line 2692 of file functions.c.
References pfree().
Referenced by CreateSQLFunctionDestReceiver().
|
static |
Definition at line 2645 of file functions.c.
References Assert, ExecFilterJunk(), ExecMaterializeSlot(), fb(), TTS_EMPTY, and tuplestore_puttupleslot().
Referenced by CreateSQLFunctionDestReceiver().
|
static |
Definition at line 2683 of file functions.c.
Referenced by CreateSQLFunctionDestReceiver().
|
static |
Definition at line 2636 of file functions.c.
Referenced by CreateSQLFunctionDestReceiver().