22#include "utils/fmgrprotos.h"
138 errmsg(
"unsupported set function return mode"),
139 errdetail(
"PL/Python set-returning functions only support returning one value per call.")));
152 errmsg(
"returned object cannot be iterated"),
153 errdetail(
"PL/Python set-returning functions must return an iterable object.")));
210 errmsg(
"PL/Python procedure did not return None")));
214 errmsg(
"PL/Python function with return type \"void\" did not return None")));
245 errmsg(
"function returning record called in context "
246 "that cannot accept type record")));
391 errmsg(
"unexpected return value from trigger procedure"),
392 errdetail(
"Expected None or a string.")));
405 (
errmsg(
"PL/Python trigger function returned \"MODIFY\" in a DELETE trigger -- ignored")));
415 errmsg(
"unexpected return value from trigger procedure"),
416 errdetail(
"Expected None, \"OK\", \"SKIP\", or \"MODIFY\".")));
508 PLy_elog(
ERROR,
"PyList_SetItem() failed, while setting up arguments");
512 PLy_elog(
ERROR,
"PyDict_SetItemString() failed, while setting up arguments");
591 for (
i = 0;
i < savedargs->
nargs;
i++)
629 for (
i = 0;
i < savedargs->
nargs;
i++)
771 if (
tdata->tg_trigger->tgnargs)
847 *rv =
tdata->tg_trigtuple;
860 *rv =
tdata->tg_trigtuple;
878 *rv =
tdata->tg_newtuple;
919 if (
tdata->tg_trigger->tgnargs)
930 for (
i = 0;
i <
tdata->tg_trigger->tgnargs;
i++)
992 errmsg(
"TD[\"new\"] deleted, cannot modify row")));
997 errmsg(
"TD[\"new\"] is not a dictionary")));
1008 for (
i = 0;
i < nkeys;
i++)
1022 errmsg(
"TD[\"new\"] dictionary key at ordinal position %d is not a string",
i)));
1029 errmsg(
"key \"%s\" found in TD[\"new\"] does not exist as a column in the triggering row",
1034 errmsg(
"cannot set system attribute \"%s\"",
1039 errmsg(
"cannot set generated column \"%s\"",
1044 elog(
FATAL,
"Python interpreter is probably corrupted");
1149 (
errmsg(
"forcibly aborting a subtransaction that has not been exited")));
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
const char * GetCommandTagName(CommandTag commandTag)
int errdetail(const char *fmt,...)
ErrorContextCallback * error_context_stack
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define CALLED_AS_EVENT_TRIGGER(fcinfo)
#define DirectFunctionCall1(func, arg1)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
#define SRF_IS_FIRSTCALL()
#define SRF_RETURN_NEXT_NULL(_funcctx)
#define SRF_PERCALL_SETUP()
#define SRF_RETURN_NEXT(_funcctx, _result)
#define SRF_FIRSTCALL_INIT()
#define SRF_RETURN_DONE(_funcctx)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
List * list_delete_first(List *list)
void * MemoryContextAllocZero(MemoryContext context, Size size)
void MemoryContextRegisterResetCallback(MemoryContext context, MemoryContextCallback *cb)
void pfree(void *pointer)
void * palloc0(Size size)
#define IsA(nodeptr, _type_)
Datum oidout(PG_FUNCTION_ARGS)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static int list_length(const List *l)
void PLy_exec_event_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc)
static void PLy_function_drop_args(PLySavedArgs *savedargs)
static void PLy_global_args_push(PLyProcedure *proc)
Datum PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc)
static PyObject * PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc)
static void PLy_function_restore_args(PLyProcedure *proc, PLySavedArgs *savedargs)
static PyObject * PLy_procedure_call(PLyProcedure *proc, const char *kargs, PyObject *vargs)
static void plpython_trigger_error_callback(void *arg)
static void PLy_global_args_pop(PLyProcedure *proc)
static PyObject * PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *rv)
static HeapTuple PLy_modify_tuple(PLyProcedure *proc, PyObject *pltd, TriggerData *tdata, HeapTuple otup)
static void plpython_srf_cleanup_callback(void *arg)
static PLySavedArgs * PLy_function_save_args(PLyProcedure *proc)
static void PLy_abort_open_subtransactions(int save_subxact_level)
static void plpython_return_error_callback(void *arg)
HeapTuple PLy_exec_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc)
PLyExecutionContext * PLy_current_execution_context(void)
List * explicit_subtransactions
void PLy_output_setup_func(PLyObToDatum *arg, MemoryContext arg_mcxt, Oid typeOid, int32 typmod, PLyProcedure *proc)
void PLy_input_setup_func(PLyDatumToOb *arg, MemoryContext arg_mcxt, Oid typeOid, int32 typmod, PLyProcedure *proc)
PyObject * PLy_input_from_tuple(PLyDatumToOb *arg, HeapTuple tuple, TupleDesc desc, bool include_generated)
void PLy_input_setup_tuple(PLyDatumToOb *arg, TupleDesc desc, PLyProcedure *proc)
PyObject * PLy_input_convert(PLyDatumToOb *arg, Datum val)
void PLy_output_setup_record(PLyObToDatum *arg, TupleDesc desc, PLyProcedure *proc)
void PLy_output_setup_tuple(PLyObToDatum *arg, TupleDesc desc, PLyProcedure *proc)
Datum PLy_output_convert(PLyObToDatum *arg, PyObject *val, bool *isnull)
char * PLyUnicode_AsString(PyObject *unicode)
PyObject * PLyUnicode_FromString(const char *s)
int pg_strcasecmp(const char *s1, const char *s2)
static Datum ObjectIdGetDatum(Oid X)
static char * DatumGetCString(Datum X)
#define RelationGetDescr(relation)
ResourceOwner CurrentResourceOwner
int SPI_fnumber(TupleDesc tupdesc, const char *fname)
int SPI_register_trigger_data(TriggerData *tdata)
char * SPI_getnspname(Relation rel)
char * SPI_getrelname(Relation rel)
#define SPI_ERROR_NOATTRIBUTE
struct ErrorContextCallback * previous
void(* callback)(void *arg)
NullableDatum args[FLEXIBLE_ARRAY_MEMBER]
MemoryContextCallback callback
struct PLySavedArgs * next
PyObject * namedargs[FLEXIBLE_ARRAY_MEMBER]
SetFunctionReturnMode returnMode
#define TRIGGER_FIRED_FOR_STATEMENT(event)
#define TRIGGER_FIRED_BY_DELETE(event)
#define TRIGGER_FIRED_BEFORE(event)
#define CALLED_AS_TRIGGER(fcinfo)
#define TRIGGER_FIRED_FOR_ROW(event)
#define TRIGGER_FIRED_AFTER(event)
#define TRIGGER_FIRED_BY_TRUNCATE(event)
#define TRIGGER_FIRED_BY_INSERT(event)
#define TRIGGER_FIRED_BY_UPDATE(event)
#define TRIGGER_FIRED_INSTEAD(event)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
void RollbackAndReleaseCurrentSubTransaction(void)