1 /*
2    Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23 */
24 
25 #ifndef CREATE_TRIG_HPP
26 #define CREATE_TRIG_HPP
27 
28 #include "SignalData.hpp"
29 #include <Bitmask.hpp>
30 #include <trigger_definitions.h>
31 #include <AttributeList.hpp>
32 
33 struct CreateTrigReq
34 {
35   enum OnlineFlag
36   {
37     CreateTriggerOnline = 1,
38     CreateTriggerOffline = 2
39   };
40 
41   enum EndpointFlag
42   {
43     MainTrigger = 0,
44     TriggerDst = 1, // TC  "consuming" block(s)
45     TriggerSrc = 2  // LQH "producing" block(s)
46   };
47 
48   STATIC_CONST( SignalLength = 13 );
49   SECTION( TRIGGER_NAME_SECTION = 0 );
50   SECTION( ATTRIBUTE_MASK_SECTION = 1 );
51 
getOnlineFlagCreateTrigReq52   static Uint32 getOnlineFlag(Uint32 i) { return i & 3; }
setOnlineFlagCreateTrigReq53   static void setOnlineFlag(Uint32 & i, Uint32 v) { i |= (v & 3); }
getEndpointFlagCreateTrigReq54   static Uint32 getEndpointFlag(Uint32 i) { return (i >> 2) & 3;}
setEndpointFlagCreateTrigReq55   static void setEndpointFlag(Uint32 & i, Uint32 v) { i |= ((v & 3) << 2); }
56 
57   Uint32 clientRef;
58   Uint32 clientData;
59 
60   Uint32 transId;
61   Uint32 transKey;
62   Uint32 requestInfo;
63   Uint32 tableId;
64   Uint32 tableVersion;
65   Uint32 indexId;       // only for index trigger
66   Uint32 indexVersion;
67   Uint32 triggerNo;     // only for index trigger
68   Uint32 forceTriggerId;// only for NR/SR
69   Uint32 triggerInfo;   // type | timing | event | flags
70   Uint32 receiverRef;   // receiver for subscription trigger
71 };
72 
73 struct CreateTrigConf {
74   STATIC_CONST( SignalLength = 7 );
75 
76   Uint32 senderRef;
77   union { Uint32 clientData, senderData; };
78   Uint32 transId;
79   Uint32 tableId;
80   Uint32 indexId;
81   Uint32 triggerId;
82   Uint32 triggerInfo;
83 };
84 
85 struct CreateTrigRef
86 {
87   enum ErrorCode {
88     NoError = 0,
89     Busy = 701,
90     NotMaster = 702,
91     TriggerNameTooLong = 4236,
92     TooManyTriggers = 4237,
93     TriggerNotFound = 4238,
94     TriggerExists = 4239,
95     UnsupportedTriggerType = 4240,
96     BadRequestType = 4247,
97     InvalidName = 4248,
98     InvalidTable = 4249,
99     OutOfStringBuffer = 773,
100     OutOfSectionMemory = 795
101   };
102 
103   STATIC_CONST( SignalLength = 10 );
104 
105   Uint32 senderRef;
106   union { Uint32 clientData, senderData; };
107   Uint32 transId;
108   Uint32 tableId;
109   Uint32 indexId;
110   Uint32 triggerInfo;
111   Uint32 errorCode;
112   Uint32 errorLine;
113   Uint32 errorNodeId;
114   Uint32 masterNodeId;
115 };
116 
117 #endif
118