|
9 | 9 | #ifndef TRIGGER_H
|
10 | 10 | #define TRIGGER_H
|
11 | 11 |
|
| 12 | +#include "access/tupdesc.h" |
| 13 | +#include "access/htup.h" |
| 14 | +#include "utils/rel.h" |
| 15 | + |
| 16 | +typedef uint32 TriggerAction; |
| 17 | + |
| 18 | +#define TRIGGER_ACTION_INSERT 0x00000000 |
| 19 | +#define TRIGGER_ACTION_DELETE 0x00000001 |
| 20 | +#define TRIGGER_ACTION_UPDATE 0x00000010 |
| 21 | +#define TRIGGER_ACTION_OPMASK 0x00000011 |
| 22 | +#define TRIGGER_ACTION_ROW 4 |
| 23 | + |
| 24 | +#define TRIGGER_FIRED_BY_INSERT (action) \ |
| 25 | + (((TriggerAction) action & TRIGGER_ACTION_OPMASK) == \ |
| 26 | + TRIGGER_ACTION_INSERT) |
| 27 | + |
| 28 | +#define TRIGGER_FIRED_BY_DELETE (action) \ |
| 29 | + (((TriggerAction) action & TRIGGER_ACTION_OPMASK) == \ |
| 30 | + TRIGGER_ACTION_DELETE) |
| 31 | + |
| 32 | +#define TRIGGER_FIRED_BY_UPDATE (action) \ |
| 33 | + (((TriggerAction) action & TRIGGER_ACTION_OPMASK) == \ |
| 34 | + TRIGGER_ACTION_UPDATE) |
| 35 | + |
| 36 | +#define TRIGGER_FIRED_FOR_ROW (action) \ |
| 37 | + ((TriggerAction) action & TRIGGER_ACTION_ROW) |
| 38 | + |
| 39 | +#define TRIGGER_FIRED_FOR_STATEMENT (action) \ |
| 40 | + (!TRIGGER_FIRED_FOR_ROW (action)) |
| 41 | + |
| 42 | + |
12 | 43 | extern void CreateTrigger (CreateTrigStmt *stmt);
|
13 | 44 | extern void DropTrigger (DropTrigStmt *stmt);
|
14 | 45 |
|
| 46 | +extern HeapTuple ExecBRInsertTriggers (Relation rel, HeapTuple tuple); |
| 47 | +extern void ExecARInsertTriggers (Relation rel, HeapTuple tuple); |
| 48 | +extern bool ExecBRDeleteTriggers (Relation rel, ItemPointer tupleid); |
| 49 | +extern void ExecARDeleteTriggers (Relation rel, ItemPointer tupleid); |
| 50 | +extern HeapTuple ExecBRUpdateTriggers (Relation rel, ItemPointer tupleid, HeapTuple tuple); |
| 51 | +extern void ExecARUpdateTriggers (Relation rel, ItemPointer tupleid, HeapTuple tuple); |
| 52 | + |
15 | 53 | #endif /* TRIGGER_H */
|
0 commit comments