20{
23 int nargs;
24 int *chattrs;
25 int chnattrs = 0;
27 bool *newnulls;
33 bool isnull;
35
37
38 elog(
ERROR,
"not fired by trigger manager");
40
43
44 elog(
ERROR,
"must be fired before event");
45
50 else
51
52 elog(
ERROR,
"cannot process DELETE events");
53
56
58
60 if (nargs <= 0 || nargs % 2 != 0)
61
62 elog(
ERROR,
"autoinc (%s): even number gt 0 of arguments was expected",
relname);
63
64 args = trigger->tgargs;
65 tupdesc = rel->rd_att;
66
67 chattrs = (
int *)
palloc(nargs / 2 *
sizeof(
int));
69 newnulls = (
bool *)
palloc(nargs / 2 *
sizeof(
bool));
70
71 for (
i = 0;
i < nargs;)
72 {
76
79 (
errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
80 errmsg(
"\"%s\" has no attribute \"%s\"",
82
85 (
errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
86 errmsg(
"attribute \"%s\" of \"%s\" must be type INT4",
88
90
91 if (!isnull &&
val != 0)
92 {
94 continue;
95 }
96
98 chattrs[chnattrs] =
attnum;
101
104 {
107 }
108 newnulls[chnattrs] = false;
110 chnattrs++;
112 }
113
114 if (chnattrs > 0)
115 {
117 chnattrs, chattrs,
118 newvals, newnulls);
119 }
120
125
127}
#define CStringGetTextDatum(s)
Datum nextval(PG_FUNCTION_ARGS)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define DatumGetTextPP(X)
#define DirectFunctionCall1(func, arg1)
HeapTuple heap_modify_tuple_by_cols(HeapTuple tuple, TupleDesc tupleDesc, int nCols, const int *replCols, const Datum *replValues, const bool *replIsnull)
if(TABLE==NULL||TABLE_index==NULL)
void pfree(void *pointer)
static int64 DatumGetInt64(Datum X)
static Datum PointerGetDatum(const void *X)
static Datum Int32GetDatum(int32 X)
static int32 DatumGetInt32(Datum X)
int SPI_fnumber(TupleDesc tupdesc, const char *fname)
Oid SPI_gettypeid(TupleDesc tupdesc, int fnumber)
Datum SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull)
char * SPI_getrelname(Relation rel)
#define TRIGGER_FIRED_BEFORE(event)
#define CALLED_AS_TRIGGER(fcinfo)
#define TRIGGER_FIRED_FOR_ROW(event)
#define TRIGGER_FIRED_BY_INSERT(event)
#define TRIGGER_FIRED_BY_UPDATE(event)