|
13 | 13 | #include"access/htup.h"
|
14 | 14 | #include"utils/rel.h"
|
15 | 15 |
|
16 |
| -typedefuint32TriggerAction; |
| 16 | +typedefuint32TriggerEvent; |
17 | 17 |
|
18 |
| -#defineTRIGGER_ACTION_INSERT0x00000000 |
19 |
| -#defineTRIGGER_ACTION_DELETE0x00000001 |
20 |
| -#defineTRIGGER_ACTION_UPDATE0x00000010 |
21 |
| -#defineTRIGGER_ACTION_OPMASK0x00000011 |
22 |
| -#defineTRIGGER_ACTION_ROW4 |
| 18 | +typedefstructTriggerData { |
| 19 | +TriggerEventtg_event; |
| 20 | +Relationtg_relation; |
| 21 | +HeapTupletg_trigtuple; |
| 22 | +HeapTupletg_newtuple; |
| 23 | +Trigger*tg_trigger; |
| 24 | +}TriggerData; |
23 | 25 |
|
24 |
| -#defineTRIGGER_FIRED_BY_INSERT (action)\ |
25 |
| -(((TriggerAction) action & TRIGGER_ACTION_OPMASK) == \ |
26 |
| -TRIGGER_ACTION_INSERT) |
| 26 | +externTriggerData*CurrentTriggerData; |
27 | 27 |
|
28 |
| -#defineTRIGGER_FIRED_BY_DELETE (action)\ |
29 |
| -(((TriggerAction) action & TRIGGER_ACTION_OPMASK) == \ |
30 |
| -TRIGGER_ACTION_DELETE) |
| 28 | +#defineTRIGGER_EVENT_INSERT0x00000000 |
| 29 | +#defineTRIGGER_EVENT_DELETE0x00000001 |
| 30 | +#defineTRIGGER_EVENT_UPDATE0x00000002 |
| 31 | +#defineTRIGGER_EVENT_OPMASK0x00000003 |
| 32 | +#defineTRIGGER_EVENT_ROW0x00000004 |
| 33 | +#defineTRIGGER_EVENT_BEFORE0x00000008 |
31 | 34 |
|
32 |
| -#defineTRIGGER_FIRED_BY_UPDATE (action)\ |
33 |
| -(((TriggerAction) action &TRIGGER_ACTION_OPMASK) == \ |
34 |
| -TRIGGER_ACTION_UPDATE) |
| 35 | +#defineTRIGGER_FIRED_BY_INSERT(event)\ |
| 36 | +(((TriggerEvent) (event) &TRIGGER_EVENT_OPMASK) == \ |
| 37 | +TRIGGER_EVENT_INSERT) |
35 | 38 |
|
36 |
| -#defineTRIGGER_FIRED_FOR_ROW (action)\ |
37 |
| -((TriggerAction) action & TRIGGER_ACTION_ROW) |
| 39 | +#defineTRIGGER_FIRED_BY_DELETE(event)\ |
| 40 | +(((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == \ |
| 41 | +TRIGGER_EVENT_DELETE) |
38 | 42 |
|
39 |
| -#defineTRIGGER_FIRED_FOR_STATEMENT (action)\ |
40 |
| -(!TRIGGER_FIRED_FOR_ROW (action)) |
| 43 | +#defineTRIGGER_FIRED_BY_UPDATE(event)\ |
| 44 | +(((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == \ |
| 45 | +TRIGGER_EVENT_UPDATE) |
| 46 | + |
| 47 | +#defineTRIGGER_FIRED_FOR_ROW(event)\ |
| 48 | +((TriggerEvent) (event) & TRIGGER_EVENT_ROW) |
| 49 | + |
| 50 | +#defineTRIGGER_FIRED_FOR_STATEMENT(event)\ |
| 51 | +(!TRIGGER_FIRED_FOR_ROW (event)) |
| 52 | + |
| 53 | +#defineTRIGGER_FIRED_BEFORE(event)\ |
| 54 | +((TriggerEvent) (event) & TRIGGER_EVENT_BEFORE) |
| 55 | + |
| 56 | +#defineTRIGGER_FIRED_AFTER(event)\ |
| 57 | +(!TRIGGER_FIRED_BEFORE (event)) |
41 | 58 |
|
42 | 59 |
|
43 | 60 | externvoidCreateTrigger (CreateTrigStmt*stmt);
|
44 | 61 | externvoidDropTrigger (DropTrigStmt*stmt);
|
| 62 | +externvoidRelationRemoveTriggers (Relationrel); |
45 | 63 |
|
46 | 64 | externHeapTupleExecBRInsertTriggers (Relationrel,HeapTupletuple);
|
47 | 65 | externvoidExecARInsertTriggers (Relationrel,HeapTupletuple);
|
|