19 #ifndef NDB_TRIGGER_DEFINITIONS_H
20 #define NDB_TRIGGER_DEFINITIONS_H
22 #include <ndb_global.h>
23 #include "ndb_limits.h"
24 #include <Bitmask.hpp>
25 #include <signaldata/DictTabInfo.hpp>
27 #define ILLEGAL_TRIGGER_ID ((Uint32)(~0))
32 SECONDARY_INDEX = DictTabInfo::HashIndexTrigger,
37 SUBSCRIPTION = DictTabInfo::SubscriptionTrigger,
38 READ_ONLY_CONSTRAINT = DictTabInfo::ReadOnlyConstraint,
39 ORDERED_INDEX = DictTabInfo::IndexTrigger,
41 SUBSCRIPTION_BEFORE = 9,
42 REORG_TRIGGER = DictTabInfo::ReorgTrigger
67 TriggerType::Value triggerType;
68 TriggerActionTime::Value triggerActionTime;
71 bool monitorAllAttributes;
72 bool reportAllMonitoredAttributes;
77 static TriggerType::Value
78 getTriggerType(
const Uint32& info) {
80 return (TriggerType::Value)val;
83 setTriggerType(Uint32& info, TriggerType::Value val) {
86 static TriggerActionTime::Value
87 getTriggerActionTime(
const Uint32& info) {
89 return (TriggerActionTime::Value)val;
92 setTriggerActionTime(Uint32& info, TriggerActionTime::Value val) {
96 getTriggerEvent(
const Uint32& info) {
105 getMonitorReplicas(
const Uint32& info) {
109 setMonitorReplicas(Uint32& info,
bool val) {
113 getMonitorAllAttributes(
const Uint32& info) {
117 setMonitorAllAttributes(Uint32& info,
bool val) {
121 getReportAllMonitoredAttributes(
const Uint32& info) {
125 setReportAllMonitoredAttributes(Uint32& info,
bool val) {
131 packTriggerInfo(Uint32& val,
const TriggerInfo& str) {
133 setTriggerType(val, str.triggerType);
134 setTriggerActionTime(val, str.triggerActionTime);
135 setTriggerEvent(val, str.triggerEvent);
136 setMonitorReplicas(val, str.monitorReplicas);
137 setMonitorAllAttributes(val, str.monitorAllAttributes);
138 setReportAllMonitoredAttributes(val, str.reportAllMonitoredAttributes);
141 unpackTriggerInfo(
const Uint32& val,
TriggerInfo& str) {
142 str.triggerType = getTriggerType(val);
143 str.triggerActionTime = getTriggerActionTime(val);
144 str.triggerEvent = getTriggerEvent(val);
145 str.monitorReplicas = getMonitorReplicas(val);
146 str.monitorAllAttributes = getMonitorAllAttributes(val);
147 str.reportAllMonitoredAttributes = getReportAllMonitoredAttributes(val);
152 triggerTypeName(Uint32 val) {
154 case TriggerType::SECONDARY_INDEX:
155 return "SECONDARY_INDEX";
156 case TriggerType::SUBSCRIPTION:
157 return "SUBSCRIPTION";
158 case TriggerType::READ_ONLY_CONSTRAINT:
159 return "READ_ONLY_CONSTRAINT";
160 case TriggerType::ORDERED_INDEX:
161 return "ORDERED_INDEX";
162 case TriggerType::SUBSCRIPTION_BEFORE:
163 return "SUBSCRIPTION_BEFORE";
168 triggerActionTimeName(Uint32 val) {
170 case TriggerActionTime::TA_BEFORE:
172 case TriggerActionTime::TA_AFTER:
174 case TriggerActionTime::TA_DEFERRED:
175 return "TA_DEFERRED";
176 case TriggerActionTime::TA_DETACHED:
177 return "TA_DETACHED";
178 case TriggerActionTime::TA_CUSTOM:
184 triggerEventName(Uint32 val) {
186 case TriggerEvent::TE_INSERT:
188 case TriggerEvent::TE_DELETE:
190 case TriggerEvent::TE_UPDATE:
192 case TriggerEvent::TE_CUSTOM:
201 STATIC_CONST( DeferredBit = (Uint32(1) << 31) );
203 static Uint32 getFiredCount(Uint32 v) {
204 return v & ~(Uint32(DeferredBit));
206 static Uint32 getDeferredBit(Uint32 v) {
207 return (v & Uint32(DeferredBit)) != 0;
209 static void setDeferredBit(Uint32 & v) {
210 v |= Uint32(DeferredBit);