70 elog(
DEBUG4,
"check_primary_key: Enter Function");
80 elog(
ERROR,
"check_primary_key: not fired by trigger manager");
85 elog(
ERROR,
"check_primary_key: must be fired for row");
89 elog(
ERROR,
"check_primary_key: must be fired by AFTER trigger");
98 elog(
ERROR,
"check_primary_key: cannot process DELETE events");
110 elog(
ERROR,
"check_primary_key: odd number of arguments should be specified");
134 if (
plan->nplans <= 0)
138 for (
i = 0;
i < nkeys;
i++)
147 errmsg(
"there is no attribute \"%s\" in relation \"%s\"",
164 if (
plan->nplans <= 0)
171 if (
plan->nplans <= 0)
183 for (
i = 1;
i <= nkeys;
i++)
202 elog(
ERROR,
"check_primary_key: SPI_keepplan failed");
219 elog(
ERROR,
"check_primary_key: SPI_execp returned %d", ret);
227 errmsg(
"tuple references non-existent key"),
277 elog(
DEBUG4,
"check_foreign_key: Enter Function");
287 elog(
ERROR,
"check_foreign_key: not fired by trigger manager");
292 elog(
ERROR,
"check_foreign_key: must be fired for row");
297 elog(
ERROR,
"check_foreign_key: cannot process INSERT events");
301 elog(
ERROR,
"check_foreign_key: must be fired by AFTER trigger");
323 elog(
ERROR,
"check_foreign_key: too short %d (< 5) list of arguments", nargs);
328 elog(
ERROR,
"check_foreign_key: %d (< 1) number of references specified",
nrefs);
330 if (action !=
'r' && action !=
'c' && action !=
's')
332 elog(
ERROR,
"check_foreign_key: invalid action %s", args[1]);
336 if (nkeys <= 0 || nargs != (
nrefs + nkeys * (
nrefs + 1)))
338 elog(
ERROR,
"check_foreign_key: invalid number of arguments %d for %d references",
361 if (
plan->nplans <= 0)
369 elog(
ERROR,
"%s: check_foreign_key: # of plans changed in meantime",
373 for (
i = 0;
i < nkeys;
i++)
382 errmsg(
"there is no attribute \"%s\" in relation \"%s\"",
404 if (newtuple !=
NULL)
418 if (
plan->nplans <= 0)
428 if (
plan->nplans <= 0)
436 for (r = 0; r <
nrefs; r++)
474 else if (action ==
'c')
483 for (k = 1; k <= nkeys; k++)
508 else if (action ==
's')
511 for (
i = 1;
i <= nkeys;
i++)
521 for (
i = 1;
i <= nkeys;
i++)
540 elog(
ERROR,
"check_foreign_key: SPI_keepplan failed");
567 for (r = 0; r <
nrefs; r++)
573 int tcount = (action ==
'r') ? 1 : 0;
583 errmsg(
"SPI_execp returned %d", ret)));
592 errmsg(
"\"%s\": tuple is referenced in \"%s\"",
632 for (
i = 0;
i < *nplans;
i++)
#define Assert(condition)
static DataChecksumsWorkerOperation operation
int errcode(int sqlerrcode)
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
#define palloc_object(type)
#define PG_MODULE_MAGIC_EXT(...)
#define PG_FUNCTION_INFO_V1(funcname)
void * MemoryContextAlloc(MemoryContext context, Size size)
char * pstrdup(const char *in)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
MemoryContext TopMemoryContext
int32 pg_strtoint32(const char *s)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static unsigned char pg_ascii_tolower(unsigned char ch)
#define PointerGetDatum(X)
char * quote_literal_cstr(const char *rawstr)
Datum check_foreign_key(PG_FUNCTION_ARGS)
Datum check_primary_key(PG_FUNCTION_ARGS)
static EPlan * find_plan(char *ident, EPlan **eplan, int *nplans)
int SPI_fnumber(TupleDesc tupdesc, const char *fname)
Oid SPI_gettypeid(TupleDesc tupdesc, int fnumber)
const char * SPI_result_code_string(int code)
SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes)
int SPI_keepplan(SPIPlanPtr plan)
int SPI_execp(SPIPlanPtr plan, Datum *Values, const char *Nulls, long tcount)
char * SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
Datum SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull)
char * SPI_getrelname(Relation rel)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void initStringInfo(StringInfo str)
static void * fn(void *arg)
#define TRIGGER_FIRED_BY_DELETE(event)
#define CALLED_AS_TRIGGER(fcinfo)
#define TRIGGER_FIRED_FOR_ROW(event)
#define TRIGGER_FIRED_AFTER(event)
#define TRIGGER_FIRED_BY_INSERT(event)
#define TRIGGER_FIRED_BY_UPDATE(event)