Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PG_TRIGGER_H
00020 #define PG_TRIGGER_H
00021
00022 #include "catalog/genbki.h"
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #define TriggerRelationId 2620
00035
00036 CATALOG(pg_trigger,2620)
00037 {
00038 Oid tgrelid;
00039 NameData tgname;
00040 Oid tgfoid;
00041 int16 tgtype;
00042
00043 char tgenabled;
00044
00045 bool tgisinternal;
00046 Oid tgconstrrelid;
00047 Oid tgconstrindid;
00048 Oid tgconstraint;
00049 bool tgdeferrable;
00050 bool tginitdeferred;
00051 int16 tgnargs;
00052
00053
00054
00055
00056
00057 int2vector tgattr;
00058
00059 #ifdef CATALOG_VARLEN
00060 bytea tgargs;
00061 pg_node_tree tgqual;
00062 #endif
00063 } FormData_pg_trigger;
00064
00065
00066
00067
00068
00069
00070 typedef FormData_pg_trigger *Form_pg_trigger;
00071
00072
00073
00074
00075
00076 #define Natts_pg_trigger 15
00077 #define Anum_pg_trigger_tgrelid 1
00078 #define Anum_pg_trigger_tgname 2
00079 #define Anum_pg_trigger_tgfoid 3
00080 #define Anum_pg_trigger_tgtype 4
00081 #define Anum_pg_trigger_tgenabled 5
00082 #define Anum_pg_trigger_tgisinternal 6
00083 #define Anum_pg_trigger_tgconstrrelid 7
00084 #define Anum_pg_trigger_tgconstrindid 8
00085 #define Anum_pg_trigger_tgconstraint 9
00086 #define Anum_pg_trigger_tgdeferrable 10
00087 #define Anum_pg_trigger_tginitdeferred 11
00088 #define Anum_pg_trigger_tgnargs 12
00089 #define Anum_pg_trigger_tgattr 13
00090 #define Anum_pg_trigger_tgargs 14
00091 #define Anum_pg_trigger_tgqual 15
00092
00093
00094 #define TRIGGER_TYPE_ROW (1 << 0)
00095 #define TRIGGER_TYPE_BEFORE (1 << 1)
00096 #define TRIGGER_TYPE_INSERT (1 << 2)
00097 #define TRIGGER_TYPE_DELETE (1 << 3)
00098 #define TRIGGER_TYPE_UPDATE (1 << 4)
00099 #define TRIGGER_TYPE_TRUNCATE (1 << 5)
00100 #define TRIGGER_TYPE_INSTEAD (1 << 6)
00101
00102 #define TRIGGER_TYPE_LEVEL_MASK (TRIGGER_TYPE_ROW)
00103 #define TRIGGER_TYPE_STATEMENT 0
00104
00105
00106 #define TRIGGER_TYPE_TIMING_MASK \
00107 (TRIGGER_TYPE_BEFORE | TRIGGER_TYPE_INSTEAD)
00108 #define TRIGGER_TYPE_AFTER 0
00109
00110 #define TRIGGER_TYPE_EVENT_MASK \
00111 (TRIGGER_TYPE_INSERT | TRIGGER_TYPE_DELETE | TRIGGER_TYPE_UPDATE | TRIGGER_TYPE_TRUNCATE)
00112
00113
00114 #define TRIGGER_CLEAR_TYPE(type) ((type) = 0)
00115
00116 #define TRIGGER_SETT_ROW(type) ((type) |= TRIGGER_TYPE_ROW)
00117 #define TRIGGER_SETT_STATEMENT(type) ((type) |= TRIGGER_TYPE_STATEMENT)
00118 #define TRIGGER_SETT_BEFORE(type) ((type) |= TRIGGER_TYPE_BEFORE)
00119 #define TRIGGER_SETT_AFTER(type) ((type) |= TRIGGER_TYPE_AFTER)
00120 #define TRIGGER_SETT_INSTEAD(type) ((type) |= TRIGGER_TYPE_INSTEAD)
00121 #define TRIGGER_SETT_INSERT(type) ((type) |= TRIGGER_TYPE_INSERT)
00122 #define TRIGGER_SETT_DELETE(type) ((type) |= TRIGGER_TYPE_DELETE)
00123 #define TRIGGER_SETT_UPDATE(type) ((type) |= TRIGGER_TYPE_UPDATE)
00124 #define TRIGGER_SETT_TRUNCATE(type) ((type) |= TRIGGER_TYPE_TRUNCATE)
00125
00126 #define TRIGGER_FOR_ROW(type) ((type) & TRIGGER_TYPE_ROW)
00127 #define TRIGGER_FOR_BEFORE(type) (((type) & TRIGGER_TYPE_TIMING_MASK) == TRIGGER_TYPE_BEFORE)
00128 #define TRIGGER_FOR_AFTER(type) (((type) & TRIGGER_TYPE_TIMING_MASK) == TRIGGER_TYPE_AFTER)
00129 #define TRIGGER_FOR_INSTEAD(type) (((type) & TRIGGER_TYPE_TIMING_MASK) == TRIGGER_TYPE_INSTEAD)
00130 #define TRIGGER_FOR_INSERT(type) ((type) & TRIGGER_TYPE_INSERT)
00131 #define TRIGGER_FOR_DELETE(type) ((type) & TRIGGER_TYPE_DELETE)
00132 #define TRIGGER_FOR_UPDATE(type) ((type) & TRIGGER_TYPE_UPDATE)
00133 #define TRIGGER_FOR_TRUNCATE(type) ((type) & TRIGGER_TYPE_TRUNCATE)
00134
00135
00136
00137
00138
00139
00140
00141
00142 #define TRIGGER_TYPE_MATCHES(type, level, timing, event) \
00143 (((type) & (TRIGGER_TYPE_LEVEL_MASK | TRIGGER_TYPE_TIMING_MASK | (event))) == ((level) | (timing) | (event)))
00144
00145 #endif