|
PostgreSQL Source Code git master
|
#include "postgres.h"#include <tcl.h>#include <unistd.h>#include <fcntl.h>#include "access/htup_details.h"#include "access/xact.h"#include "catalog/objectaccess.h"#include "catalog/pg_proc.h"#include "catalog/pg_type.h"#include "commands/event_trigger.h"#include "commands/trigger.h"#include "executor/spi.h"#include "fmgr.h"#include "funcapi.h"#include "mb/pg_wchar.h"#include "miscadmin.h"#include "parser/parse_func.h"#include "parser/parse_type.h"#include "pgstat.h"#include "utils/acl.h"#include "utils/builtins.h"#include "utils/guc.h"#include "utils/lsyscache.h"#include "utils/memutils.h"#include "utils/regproc.h"#include "utils/rel.h"#include "utils/syscache.h"#include "utils/typcache.h"#include "pltclerrcodes.h"
Go to the source code of this file.
Data Structures | |
| struct | pltcl_interp_desc |
| struct | pltcl_proc_desc |
| struct | pltcl_query_desc |
| struct | pltcl_proc_key |
| struct | pltcl_proc_ptr |
| struct | pltcl_call_state |
| struct | TclExceptionNameMap |
Macros | |
| #define | HAVE_TCL_VERSION(maj, min) |
| #define | CONST86 |
| #define | TEXTDOMAIN PG_TEXTDOMAIN("pltcl") |
| #define | UTF_BEGIN |
| #define | UTF_END |
| #define | UTF_U2E(x) (_pltcl_utf_dst = utf_u2e(_pltcl_utf_src = (x))) |
| #define | UTF_E2U(x) (_pltcl_utf_dst = utf_e2u(_pltcl_utf_src = (x))) |
Definition at line 47 of file pltcl.c.
| #define TEXTDOMAIN PG_TEXTDOMAIN("pltcl") |
| #define UTF_BEGIN |
| #define UTF_E2U | ( | x | ) | (_pltcl_utf_dst = utf_e2u(_pltcl_utf_src = (x))) |
| #define UTF_END |
| #define UTF_U2E | ( | x | ) | (_pltcl_utf_dst = utf_u2e(_pltcl_utf_src = (x))) |
Definition at line 408 of file pltcl.c.
References DefineCustomStringVariable(), elog, ERROR, fb(), gettext_noop, HASH_BLOBS, hash_create(), HASH_ELEM, MarkGUCPrefixReserved(), pg_bindtextdomain(), PGC_SUSET, pltcl_AlertNotifier(), pltcl_CreateFileHandler(), pltcl_DeleteFileHandler(), pltcl_FinalizeNotifier(), pltcl_hold_interp, pltcl_InitNotifier(), pltcl_interp_htab, pltcl_pm_init_done, pltcl_proc_htab, pltcl_ServiceModeHook(), pltcl_SetTimer(), pltcl_start_proc, pltcl_WaitForEvent(), pltclu_start_proc, and TEXTDOMAIN.
Definition at line 597 of file pltcl.c.
References ACL_EXECUTE, aclcheck_error(), ACLCHECK_OK, ErrorContextCallback::arg, ErrorContextCallback::callback, elog, ereport, errcode(), errmsg(), ERROR, error_context_stack, fb(), fmgr_info(), FunctionCallInvoke, GETSTRUCT(), GetUserId(), HeapTupleIsValid, InitFunctionCallInfoData, InvalidOid, InvokeFunctionExecuteHook, LOCAL_FCINFO, LookupFuncName(), object_aclcheck(), OBJECT_FUNCTION, ObjectIdGetDatum(), pgstat_end_function_usage(), pgstat_init_function_usage(), pltcl_start_proc, pltclu_start_proc, ErrorContextCallback::previous, ReleaseSysCache(), SearchSysCache1(), start_proc_error_callback(), stringToQualifiedNameList(), and unconstify.
Referenced by pltcl_init_interp().
|
static |
Definition at line 1417 of file pltcl.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, pltcl_proc_desc::arg_is_rowtype, pltcl_proc_desc::arg_out_func, Assert, buf, pltcl_proc_desc::domain_info, elog, ereport, errcode(), errmsg(), ERROR, fb(), fmgr_info_cxt(), pltcl_proc_desc::fn_cxt, pltcl_proc_desc::fn_readonly, pltcl_proc_desc::fn_refcount, pltcl_proc_desc::fn_retisdomain, pltcl_proc_desc::fn_retisset, pltcl_proc_desc::fn_retistuple, pltcl_proc_desc::fn_tid, pltcl_proc_desc::fn_xmin, format_procedure(), format_type_be(), FUNC_MAX_ARGS, GETSTRUCT(), getTypeIOParam(), GetUserId(), HASH_ENTER, hash_search(), HeapTupleHeaderGetRawXmin(), HeapTupleIsValid, i, pltcl_proc_desc::internal_proname, pltcl_interp_desc::interp, pltcl_proc_desc::interp_desc, InvalidOid, pltcl_proc_key::is_trigger, ItemPointerEquals(), pltcl_proc_desc::lanpltrusted, MemoryContextDelete(), MemoryContextSetIdentifier(), MemoryContextSwitchTo(), pltcl_proc_desc::nargs, ObjectIdGetDatum(), OidIsValid, palloc0(), palloc0_object, pfree(), PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, pltcl_fetch_interp(), pltcl_proc_htab, pltcl_proc_key::proc_id, pltcl_proc_ptr::proc_ptr, pstrdup(), ReleaseSysCache(), pltcl_proc_desc::result_in_func, pltcl_proc_desc::result_typid, pltcl_proc_desc::result_typioparam, SearchSysCache1(), snprintf, SysCacheGetAttrNotNull(), TextDatumGetCString, TopMemoryContext, type_is_rowtype(), pltcl_proc_key::user_id, pltcl_proc_desc::user_proname, UTF_BEGIN, UTF_E2U, UTF_END, and utf_u2e().
Referenced by pltcl_event_trigger_handler(), pltcl_func_handler(), and pltcl_trigger_handler().
| PG_FUNCTION_INFO_V1 | ( | pltcl_call_handler | ) |
| PG_FUNCTION_INFO_V1 | ( | pltclu_call_handler | ) |
| PG_MODULE_MAGIC_EXT | ( | . | name = "pltcl", |
| . | version = PG_VERSION |
||
| ) |
|
static |
|
static |
Definition at line 2147 of file pltcl.c.
References fb(), pltcl_call_state::fcinfo, FunctionCallInfoBaseData::nargs, PG_ARGISNULL, and pltcl_current_call_state.
Referenced by pltcl_init_interp().
|
static |
Definition at line 3188 of file pltcl.c.
References attname, fb(), getTypeOutputInfo(), heap_getattr(), i, NameStr, TupleDescData::natts, OidOutputFunctionCall(), pfree(), TupleDescAttr(), UTF_BEGIN, UTF_E2U, and UTF_END.
Referenced by pltcl_func_handler(), and pltcl_trigger_handler().
|
static |
Definition at line 3267 of file pltcl.c.
References BuildTupleFromCStrings(), domain_check(), elog, ereport, errcode(), errmsg(), ERROR, fb(), HeapTupleGetDatum(), i, TupleDescData::natts, palloc0(), RelationGetDescr, SPI_ERROR_NOATTRIBUTE, SPI_fnumber(), TupleDescAttr(), TupleDescGetAttInMetadata(), utf_u2e(), and values.
Referenced by pltcl_func_handler(), pltcl_returnnext(), and pltcl_trigger_handler().
| Datum pltcl_call_handler | ( | PG_FUNCTION_ARGS | ) |
Definition at line 704 of file pltcl.c.
References pltcl_handler().
|
static |
Definition at line 3023 of file pltcl.c.
References CopyErrorData(), CurrentMemoryContext, fb(), FlushErrorState(), FreeErrorData(), MemoryContextSwitchTo(), PG_CATCH, PG_END_TRY, PG_TRY, pltcl_construct_errorCode(), SPI_commit(), UTF_BEGIN, UTF_E2U, and UTF_END.
Referenced by pltcl_init_interp().
|
static |
Definition at line 1930 of file pltcl.c.
References fb(), pltcl_get_condition_name(), unpack_sql_state(), UTF_BEGIN, UTF_E2U, and UTF_END.
Referenced by pltcl_commit(), pltcl_elog(), pltcl_rollback(), and pltcl_subtrans_abort().
|
static |
|
static |
Definition at line 1843 of file pltcl.c.
References CopyErrorData(), CurrentMemoryContext, DEBUG2, ereport, errcode(), errmsg(), ERROR, FATAL, fb(), FlushErrorState(), FreeErrorData(), INFO, LOG, MemoryContextSwitchTo(), NOTICE, PG_CATCH, PG_END_TRY, PG_TRY, pltcl_construct_errorCode(), UTF_BEGIN, UTF_E2U, UTF_END, UTF_U2E, and WARNING.
Referenced by pltcl_init_interp().
|
static |
Definition at line 1318 of file pltcl.c.
References compile_pltcl_function(), elog, ERROR, fb(), pltcl_proc_desc::fn_refcount, GetCommandTagName(), pltcl_proc_desc::internal_proname, pltcl_interp_desc::interp, pltcl_proc_desc::interp_desc, InvalidOid, SPI_connect(), SPI_finish(), SPI_OK_FINISH, throw_tcl_error(), pltcl_proc_desc::user_proname, and utf_e2u().
Referenced by pltcl_handler().
|
static |
Definition at line 567 of file pltcl.c.
References fb(), GetUserId(), HASH_ENTER, hash_search(), pltcl_interp_desc::interp, InvalidOid, pltcl_init_interp(), and pltcl_interp_htab.
Referenced by compile_pltcl_function().
|
static |
|
static |
Definition at line 801 of file pltcl.c.
References ReturnSetInfo::allowedModes, pltcl_proc_desc::arg_is_rowtype, pltcl_proc_desc::arg_out_func, Assert, castNode, compile_pltcl_function(), CreateTupleDescCopy(), CurrentResourceOwner, DatumGetHeapTupleHeader, ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, elog, ereport, errcode(), errmsg(), ERROR, fb(), pltcl_proc_desc::fn_refcount, pltcl_proc_desc::fn_retisdomain, pltcl_proc_desc::fn_retisset, pltcl_proc_desc::fn_retistuple, get_call_result_type(), HeapTupleGetDatum(), HeapTupleHeaderGetDatumLength(), HeapTupleHeaderGetTypeId(), HeapTupleHeaderGetTypMod(), i, InputFunctionCall(), pltcl_proc_desc::internal_proname, pltcl_interp_desc::interp, pltcl_proc_desc::interp_desc, InvalidOid, IsA, lookup_rowtype_tupdesc(), MemoryContextSwitchTo(), pltcl_proc_desc::nargs, OutputFunctionCall(), pfree(), PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, pltcl_build_tuple_argument(), pltcl_build_tuple_result(), ReleaseTupleDesc, pltcl_proc_desc::result_in_func, pltcl_proc_desc::result_typioparam, ReturnSetInfo::returnMode, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, SPI_connect_ext(), SPI_finish(), SPI_OK_FINISH, SPI_OPT_NONATOMIC, throw_tcl_error(), TupleDescGetAttInMetadata(), TYPEFUNC_COMPOSITE, TYPEFUNC_COMPOSITE_DOMAIN, TYPEFUNC_RECORD, pltcl_proc_desc::user_proname, UTF_BEGIN, UTF_E2U, UTF_END, and utf_u2e().
Referenced by pltcl_handler().
Definition at line 2075 of file pltcl.c.
References exception_name_map, fb(), i, and TclExceptionNameMap::label.
Referenced by pltcl_construct_errorCode().
|
static |
Definition at line 727 of file pltcl.c.
References Assert, CALLED_AS_EVENT_TRIGGER, CALLED_AS_TRIGGER, fb(), MemoryContextDelete(), PG_END_TRY, PG_FINALLY, PG_TRY, pltcl_current_call_state, pltcl_event_trigger_handler(), pltcl_func_handler(), pltcl_trigger_handler(), and PointerGetDatum().
Referenced by pltcl_call_handler(), and pltclu_call_handler().
|
static |
Definition at line 494 of file pltcl.c.
References call_pltcl_start_proc(), elog, ERROR, fb(), pltcl_interp_desc::interp, PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, pltcl_argisnull(), pltcl_commit(), pltcl_elog(), pltcl_hold_interp, pltcl_quote(), pltcl_returnnext(), pltcl_returnnull(), pltcl_rollback(), pltcl_SPI_execute(), pltcl_SPI_execute_plan(), pltcl_SPI_prepare(), pltcl_subtransaction(), pltcl_interp_desc::query_hash, snprintf, and pltcl_interp_desc::user_id.
Referenced by pltcl_fetch_interp().
|
static |
Definition at line 3351 of file pltcl.c.
References ReturnSetInfo::allowedModes, Assert, CurrentResourceOwner, ReturnSetInfo::expectedDesc, fb(), MemoryContextSwitchTo(), SFRM_Materialize_Random, TupleDescGetAttInMetadata(), tuplestore_begin_heap(), and work_mem.
Referenced by pltcl_returnnext().
|
static |
|
static |
Definition at line 2518 of file pltcl.c.
References fb(), i, pltcl_set_tuple_values(), SPI_freetuptable(), SPI_OK_DELETE, SPI_OK_DELETE_RETURNING, SPI_OK_INSERT, SPI_OK_INSERT_RETURNING, SPI_OK_MERGE, SPI_OK_MERGE_RETURNING, SPI_OK_REWRITTEN, SPI_OK_SELECT, SPI_OK_SELINTO, SPI_OK_UPDATE, SPI_OK_UPDATE_RETURNING, SPI_OK_UTILITY, SPI_result_code_string(), SPITupleTable::tupdesc, and SPITupleTable::vals.
Referenced by pltcl_SPI_execute(), and pltcl_SPI_execute_plan().
|
static |
Definition at line 2093 of file pltcl.c.
References fb(), palloc(), and pfree().
Referenced by pltcl_init_interp().
|
static |
Definition at line 2239 of file pltcl.c.
References BeginInternalSubTransaction(), CurrentMemoryContext, CurrentResourceOwner, elog, ERROR, fb(), pltcl_proc_desc::fn_retisset, pltcl_proc_desc::fn_retistuple, InputFunctionCall(), PG_CATCH, PG_END_TRY, PG_TRY, pltcl_build_tuple_result(), pltcl_current_call_state, pltcl_init_tuple_store(), pltcl_subtrans_abort(), pltcl_subtrans_commit(), pltcl_proc_desc::result_in_func, pltcl_proc_desc::result_typioparam, tuplestore_puttuple(), tuplestore_putvalues(), and utf_u2e().
Referenced by pltcl_init_interp().
|
static |
Definition at line 2201 of file pltcl.c.
References fb(), pltcl_call_state::fcinfo, FunctionCallInfoBaseData::isnull, and pltcl_current_call_state.
Referenced by pltcl_init_interp().
|
static |
Definition at line 3062 of file pltcl.c.
References CopyErrorData(), CurrentMemoryContext, fb(), FlushErrorState(), FreeErrorData(), MemoryContextSwitchTo(), PG_CATCH, PG_END_TRY, PG_TRY, pltcl_construct_errorCode(), SPI_rollback(), UTF_BEGIN, UTF_E2U, and UTF_END.
Referenced by pltcl_init_interp().
|
static |
Definition at line 3102 of file pltcl.c.
References attname, fb(), getTypeOutputInfo(), heap_getattr(), i, NameStr, TupleDescData::natts, OidOutputFunctionCall(), pfree(), pstrdup(), TupleDescAttr(), unconstify, UTF_BEGIN, UTF_E2U, and UTF_END.
Referenced by pltcl_process_SPI_result().
|
static |
Definition at line 2409 of file pltcl.c.
References CurrentMemoryContext, CurrentResourceOwner, fb(), pltcl_proc_desc::fn_readonly, i, PG_CATCH, PG_END_TRY, PG_TRY, pltcl_current_call_state, pltcl_process_SPI_result(), pltcl_subtrans_abort(), pltcl_subtrans_begin(), pltcl_subtrans_commit(), pltcl_call_state::prodesc, SPI_execute(), SPI_processed, SPI_tuptable, UTF_BEGIN, UTF_END, and UTF_U2E.
Referenced by pltcl_init_interp().
|
static |
Definition at line 2759 of file pltcl.c.
References CurrentMemoryContext, CurrentResourceOwner, fb(), pltcl_proc_desc::fn_readonly, i, InputFunctionCall(), pltcl_proc_desc::interp_desc, j, palloc(), PG_CATCH, PG_END_TRY, PG_TRY, pltcl_current_call_state, pltcl_process_SPI_result(), pltcl_subtrans_abort(), pltcl_subtrans_begin(), pltcl_subtrans_commit(), pltcl_call_state::prodesc, pltcl_interp_desc::query_hash, SPI_execute_plan(), SPI_processed, SPI_tuptable, UTF_BEGIN, UTF_END, and UTF_U2E.
Referenced by pltcl_init_interp().
|
static |
Definition at line 2631 of file pltcl.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, CurrentMemoryContext, CurrentResourceOwner, elog, ERROR, fb(), fmgr_info_cxt(), getTypeInputInfo(), i, pltcl_proc_desc::interp_desc, MemoryContextDelete(), MemoryContextSwitchTo(), palloc(), palloc0_object, parseTypeString(), PG_CATCH, PG_END_TRY, PG_TRY, pltcl_current_call_state, pltcl_subtrans_abort(), pltcl_subtrans_begin(), pltcl_subtrans_commit(), pltcl_call_state::prodesc, pltcl_interp_desc::query_hash, snprintf, SPI_keepplan(), SPI_prepare(), TopMemoryContext, UTF_BEGIN, UTF_END, and UTF_U2E.
Referenced by pltcl_init_interp().
|
static |
Definition at line 2380 of file pltcl.c.
References CopyErrorData(), CurrentResourceOwner, fb(), FlushErrorState(), FreeErrorData(), MemoryContextSwitchTo(), pltcl_construct_errorCode(), RollbackAndReleaseCurrentSubTransaction(), UTF_BEGIN, UTF_E2U, and UTF_END.
Referenced by pltcl_returnnext(), pltcl_SPI_execute(), pltcl_SPI_execute_plan(), and pltcl_SPI_prepare().
|
static |
Definition at line 2362 of file pltcl.c.
References BeginInternalSubTransaction(), fb(), and MemoryContextSwitchTo().
Referenced by pltcl_SPI_execute(), pltcl_SPI_execute_plan(), and pltcl_SPI_prepare().
|
static |
Definition at line 2371 of file pltcl.c.
References CurrentResourceOwner, MemoryContextSwitchTo(), and ReleaseCurrentSubTransaction().
Referenced by pltcl_returnnext(), pltcl_SPI_execute(), pltcl_SPI_execute_plan(), and pltcl_SPI_prepare().
|
static |
Definition at line 2975 of file pltcl.c.
References BeginInternalSubTransaction(), CurrentMemoryContext, CurrentResourceOwner, fb(), MemoryContextSwitchTo(), ReleaseCurrentSubTransaction(), and RollbackAndReleaseCurrentSubTransaction().
Referenced by pltcl_init_interp().
|
static |
Definition at line 1059 of file pltcl.c.
References Assert, compile_pltcl_function(), DatumGetCString(), DirectFunctionCall1, elog, ereport, errcode(), errmsg(), ERROR, fb(), pltcl_proc_desc::fn_refcount, i, pltcl_proc_desc::internal_proname, pltcl_interp_desc::interp, pltcl_proc_desc::interp_desc, NameStr, TupleDescData::natts, ObjectIdGetDatum(), oidout(), pfree(), PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, PG_USED_FOR_ASSERTS_ONLY, pltcl_build_tuple_argument(), pltcl_build_tuple_result(), RelationData::rd_id, RelationGetDescr, RelationGetRelid, SPI_connect(), SPI_finish(), SPI_getnspname(), SPI_getrelname(), SPI_OK_FINISH, SPI_register_trigger_data(), TriggerData::tg_event, TriggerData::tg_newtuple, TriggerData::tg_relation, TriggerData::tg_trigger, TriggerData::tg_trigtuple, Trigger::tgargs, Trigger::tgname, Trigger::tgnargs, throw_tcl_error(), TRIGGER_FIRED_AFTER, TRIGGER_FIRED_BEFORE, TRIGGER_FIRED_BY_DELETE, TRIGGER_FIRED_BY_INSERT, TRIGGER_FIRED_BY_TRUNCATE, TRIGGER_FIRED_BY_UPDATE, TRIGGER_FIRED_FOR_ROW, TRIGGER_FIRED_FOR_STATEMENT, TRIGGER_FIRED_INSTEAD, TupleDescAttr(), pltcl_proc_desc::user_proname, utf_e2u(), and utf_u2e().
Referenced by pltcl_handler().
| Datum pltclu_call_handler | ( | PG_FUNCTION_ARGS | ) |
Definition at line 716 of file pltcl.c.
References pltcl_handler().
Definition at line 684 of file pltcl.c.
References arg, and errcontext.
Referenced by call_pltcl_start_proc().
|
static |
Definition at line 1372 of file pltcl.c.
References ereport, errcode(), errcontext, errmsg(), ERROR, fb(), proname, pstrdup(), and utf_u2e().
Referenced by pltcl_event_trigger_handler(), pltcl_func_handler(), and pltcl_trigger_handler().
Definition at line 87 of file pltcl.c.
References fb(), pg_server_to_any(), and PG_UTF8.
Referenced by pltcl_event_trigger_handler(), and pltcl_trigger_handler().
Definition at line 81 of file pltcl.c.
References fb(), pg_any_to_server(), and PG_UTF8.
Referenced by compile_pltcl_function(), pltcl_build_tuple_result(), pltcl_func_handler(), pltcl_returnnext(), pltcl_trigger_handler(), and throw_tcl_error().
|
static |
Definition at line 264 of file pltcl.c.
Referenced by pltcl_get_condition_name().
|
static |
Definition at line 253 of file pltcl.c.
Referenced by pltcl_argisnull(), pltcl_handler(), pltcl_returnnext(), pltcl_returnnull(), pltcl_SPI_execute(), pltcl_SPI_execute_plan(), and pltcl_SPI_prepare().
|
static |
Definition at line 248 of file pltcl.c.
Referenced by _PG_init(), and pltcl_init_interp().
Definition at line 249 of file pltcl.c.
Referenced by _PG_init(), and pltcl_fetch_interp().
Definition at line 247 of file pltcl.c.
Referenced by _PG_init().
Definition at line 250 of file pltcl.c.
Referenced by _PG_init(), and compile_pltcl_function().
Definition at line 245 of file pltcl.c.
Referenced by _PG_init(), and call_pltcl_start_proc().
Definition at line 246 of file pltcl.c.
Referenced by _PG_init(), and call_pltcl_start_proc().