PostgreSQL Source Code: contrib/spi/moddatetime.c File Reference (original) (raw)
#include "[postgres.h](postgres%5F8h%5Fsource.html)"
#include "[access/htup_details.h](htup%5F%5Fdetails%5F8h%5Fsource.html)"
#include "[catalog/pg_type.h](pg%5F%5Ftype%5F8h%5Fsource.html)"
#include "[commands/trigger.h](trigger%5F8h%5Fsource.html)"
#include "[executor/spi.h](spi%5F8h%5Fsource.html)"
#include "utils/fmgrprotos.h"
#include "[utils/rel.h](rel%5F8h%5Fsource.html)"
Go to the source code of this file.
Functions | |
---|---|
PG_MODULE_MAGIC_EXT (.name="moddatetime",.version=PG_VERSION) | |
PG_FUNCTION_INFO_V1 (moddatetime) | |
Datum | moddatetime (PG_FUNCTION_ARGS) |
Definition at line 33 of file moddatetime.c.
34{
36 Trigger *trigger;
37 int nargs;
38 int attnum;
39 Oid atttypid;
40 Datum newdt;
41 bool newdtnull;
42 char **args;
43 char *relname;
44 Relation rel;
46 TupleDesc tupdesc;
47
49
50 elog(ERROR, "moddatetime: not fired by trigger manager");
51
53
54 elog(ERROR, "moddatetime: must be fired for row");
55
57
58 elog(ERROR, "moddatetime: must be fired before event");
59
61
62 elog(ERROR, "moddatetime: cannot process INSERT events");
65 else
66
67 elog(ERROR, "moddatetime: cannot process DELETE events");
68
71
73
75
76 if (nargs != 1)
77
78 elog(ERROR, "moddatetime (%s): A single argument was expected", relname);
79
80 args = trigger->tgargs;
81
82 tupdesc = rel->rd_att;
83
84
85
86
87
89
90
91
92
93
96 (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
97 errmsg("\"%s\" has no attribute \"%s\"",
99
100
101
102
103
105 if (atttypid == TIMESTAMPOID)
110 else if (atttypid == TIMESTAMPTZOID)
115 else
116 {
118 (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
119 errmsg("attribute \"%s\" of \"%s\" must be type TIMESTAMP or TIMESTAMPTZ",
121 newdt = (Datum) 0;
122 }
123 newdtnull = false;
124
125
127 1, &attnum, &newdt, &newdtnull);
128
129
131
133}
Datum timestamp_in(PG_FUNCTION_ARGS)
Datum timestamptz_in(PG_FUNCTION_ARGS)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define DirectFunctionCall3(func, arg1, arg2, arg3)
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 Datum PointerGetDatum(const void *X)
static Datum ObjectIdGetDatum(Oid X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
int SPI_fnumber(TupleDesc tupdesc, const char *fname)
Oid SPI_gettypeid(TupleDesc tupdesc, int fnumber)
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)
References generate_unaccent_rules::args, attnum, CALLED_AS_TRIGGER, CStringGetDatum(), DirectFunctionCall3, elog, ereport, errcode(), errmsg(), ERROR, heap_modify_tuple_by_cols(), if(), Int32GetDatum(), InvalidOid, ObjectIdGetDatum(), pfree(), PointerGetDatum(), relname, SPI_fnumber(), SPI_getrelname(), SPI_gettypeid(), TriggerData::tg_event, TriggerData::tg_newtuple, TriggerData::tg_relation, TriggerData::tg_trigger, Trigger::tgnargs, timestamp_in(), timestamptz_in(), TRIGGER_FIRED_BEFORE, TRIGGER_FIRED_BY_INSERT, TRIGGER_FIRED_BY_UPDATE, and TRIGGER_FIRED_FOR_ROW.
◆ PG_FUNCTION_INFO_V1()
◆ PG_MODULE_MAGIC_EXT()
PG_MODULE_MAGIC_EXT | ( | . | name = "moddatetime", |
---|---|---|---|
. | version = PG_VERSION | ||
) |