trigger.h
上传用户:blenddy
上传日期:2007-01-07
资源大小:6495k
文件大小:2k
源码类别:

数据库系统

开发平台:

Unix_Linux

  1. /*-------------------------------------------------------------------------
  2.  *
  3.  * trigger.h
  4.  *   prototypes for trigger.c.
  5.  *
  6.  *
  7.  *-------------------------------------------------------------------------
  8.  */
  9. #ifndef TRIGGER_H
  10. #define TRIGGER_H
  11. #include "access/tupdesc.h"
  12. #include "access/htup.h"
  13. #include "nodes/parsenodes.h"
  14. #include "nodes/execnodes.h"
  15. #include "utils/rel.h"
  16. typedef uint32 TriggerEvent;
  17. typedef struct TriggerData
  18. {
  19. TriggerEvent tg_event;
  20. Relation tg_relation;
  21. HeapTuple tg_trigtuple;
  22. HeapTuple tg_newtuple;
  23. Trigger    *tg_trigger;
  24. } TriggerData;
  25. extern DLLIMPORT TriggerData *CurrentTriggerData;
  26. #define TRIGGER_EVENT_INSERT 0x00000000
  27. #define TRIGGER_EVENT_DELETE 0x00000001
  28. #define TRIGGER_EVENT_UPDATE 0x00000002
  29. #define TRIGGER_EVENT_OPMASK 0x00000003
  30. #define TRIGGER_EVENT_ROW 0x00000004
  31. #define TRIGGER_EVENT_BEFORE 0x00000008
  32. #define TRIGGER_FIRED_BY_INSERT(event)
  33. (((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == 
  34. TRIGGER_EVENT_INSERT)
  35. #define TRIGGER_FIRED_BY_DELETE(event)
  36. (((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == 
  37. TRIGGER_EVENT_DELETE)
  38. #define TRIGGER_FIRED_BY_UPDATE(event)
  39. (((TriggerEvent) (event) & TRIGGER_EVENT_OPMASK) == 
  40. TRIGGER_EVENT_UPDATE)
  41. #define TRIGGER_FIRED_FOR_ROW(event)
  42. ((TriggerEvent) (event) & TRIGGER_EVENT_ROW)
  43. #define TRIGGER_FIRED_FOR_STATEMENT(event)
  44. (!TRIGGER_FIRED_FOR_ROW (event))
  45. #define TRIGGER_FIRED_BEFORE(event)
  46. ((TriggerEvent) (event) & TRIGGER_EVENT_BEFORE)
  47. #define TRIGGER_FIRED_AFTER(event)
  48. (!TRIGGER_FIRED_BEFORE (event))
  49. extern void CreateTrigger(CreateTrigStmt *stmt);
  50. extern void DropTrigger(DropTrigStmt *stmt);
  51. extern void RelationRemoveTriggers(Relation rel);
  52. extern HeapTuple ExecBRInsertTriggers(Relation rel, HeapTuple tuple);
  53. extern void ExecARInsertTriggers(Relation rel, HeapTuple tuple);
  54. extern bool ExecBRDeleteTriggers(EState *estate, ItemPointer tupleid);
  55. extern void ExecARDeleteTriggers(EState *estate, ItemPointer tupleid);
  56. extern HeapTuple ExecBRUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple tuple);
  57. extern void ExecARUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple tuple);
  58. #endif  /* TRIGGER_H */