1997-08-31 13:42:21 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* trigger.h--
|
|
|
|
* prototypes for trigger.c.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef TRIGGER_H
|
|
|
|
#define TRIGGER_H
|
|
|
|
|
1997-09-01 10:10:12 +02:00
|
|
|
#include "access/tupdesc.h"
|
|
|
|
#include "access/htup.h"
|
|
|
|
#include "utils/rel.h"
|
|
|
|
|
1997-09-04 15:26:19 +02:00
|
|
|
typedef uint32 TriggerEvent;
|
1997-09-01 10:10:12 +02:00
|
|
|
|
1997-09-04 15:26:19 +02:00
|
|
|
typedef struct TriggerData {
|
|
|
|
TriggerEvent tg_event;
|
|
|
|
Relation tg_relation;
|
|
|
|
HeapTuple tg_trigtuple;
|
|
|
|
HeapTuple tg_newtuple;
|
|
|
|
Trigger *tg_trigger;
|
|
|
|
} TriggerData;
|
1997-09-01 10:10:12 +02:00
|
|
|
|
1997-09-04 15:26:19 +02:00
|
|
|
extern TriggerData *CurrentTriggerData;
|
1997-09-01 10:10:12 +02:00
|
|
|
|
1997-09-04 15:26:19 +02:00
|
|
|
#define TRIGGER_EVENT_INSERT 0x00000000
|
|
|
|
#define TRIGGER_EVENT_DELETE 0x00000001
|
|
|
|
#define TRIGGER_EVENT_UPDATE 0x00000002
|
|
|
|
#define TRIGGER_EVENT_OPMASK 0x00000003
|
|
|
|
#define TRIGGER_EVENT_ROW 0x00000004
|
|
|
|
#define TRIGGER_EVENT_BEFORE 0x00000008
|
1997-09-01 10:10:12 +02:00
|
|
|
|
1997-09-04 15:26:19 +02:00
|
|
|
#define TRIGGER_FIRED_BY_INSERT(event) \
|
|
|
|
(((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == \
|
|
|
|
TRIGGER_EVENT_INSERT)
|
1997-09-01 10:10:12 +02:00
|
|
|
|
1997-09-04 15:26:19 +02:00
|
|
|
#define TRIGGER_FIRED_BY_DELETE(event) \
|
|
|
|
(((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == \
|
|
|
|
TRIGGER_EVENT_DELETE)
|
1997-09-01 10:10:12 +02:00
|
|
|
|
1997-09-04 15:26:19 +02:00
|
|
|
#define TRIGGER_FIRED_BY_UPDATE(event) \
|
|
|
|
(((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == \
|
|
|
|
TRIGGER_EVENT_UPDATE)
|
|
|
|
|
|
|
|
#define TRIGGER_FIRED_FOR_ROW(event) \
|
|
|
|
((TriggerEvent) (event) & TRIGGER_EVENT_ROW)
|
|
|
|
|
|
|
|
#define TRIGGER_FIRED_FOR_STATEMENT(event) \
|
|
|
|
(!TRIGGER_FIRED_FOR_ROW (event))
|
|
|
|
|
|
|
|
#define TRIGGER_FIRED_BEFORE(event) \
|
|
|
|
((TriggerEvent) (event) & TRIGGER_EVENT_BEFORE)
|
|
|
|
|
|
|
|
#define TRIGGER_FIRED_AFTER(event) \
|
|
|
|
(!TRIGGER_FIRED_BEFORE (event))
|
1997-09-01 10:10:12 +02:00
|
|
|
|
|
|
|
|
1997-08-31 13:42:21 +02:00
|
|
|
extern void CreateTrigger (CreateTrigStmt *stmt);
|
|
|
|
extern void DropTrigger (DropTrigStmt *stmt);
|
1997-09-04 15:26:19 +02:00
|
|
|
extern void RelationRemoveTriggers (Relation rel);
|
1997-08-31 13:42:21 +02:00
|
|
|
|
1997-09-01 10:10:12 +02:00
|
|
|
extern HeapTuple ExecBRInsertTriggers (Relation rel, HeapTuple tuple);
|
|
|
|
extern void ExecARInsertTriggers (Relation rel, HeapTuple tuple);
|
|
|
|
extern bool ExecBRDeleteTriggers (Relation rel, ItemPointer tupleid);
|
|
|
|
extern void ExecARDeleteTriggers (Relation rel, ItemPointer tupleid);
|
|
|
|
extern HeapTuple ExecBRUpdateTriggers (Relation rel, ItemPointer tupleid, HeapTuple tuple);
|
|
|
|
extern void ExecARUpdateTriggers (Relation rel, ItemPointer tupleid, HeapTuple tuple);
|
|
|
|
|
1997-08-31 13:42:21 +02:00
|
|
|
#endif /* TRIGGER_H */
|