1 /*
2    Copyright (C) 2003, 2005, 2006 MySQL AB
3     All rights reserved. Use is subject to license terms.
4 
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License, version 2.0,
7    as published by the Free Software Foundation.
8 
9    This program is also distributed with certain software (including
10    but not limited to OpenSSL) that is licensed under separate terms,
11    as designated in a particular file or component or in included license
12    documentation.  The authors of MySQL hereby grant you an additional
13    permission to link the program and your derivative works with the
14    separately licensed software that they have included with MySQL.
15 
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19    GNU General Public License, version 2.0, for more details.
20 
21    You should have received a copy of the GNU General Public License
22    along with this program; if not, write to the Free Software
23    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
24 */
25 
26 #ifndef TRIG_ATTRINFO_HPP
27 #define TRIG_ATTRINFO_HPP
28 
29 #include "SignalData.hpp"
30 #include <NodeBitmask.hpp>
31 #include <trigger_definitions.h>
32 #include <string.h>
33 
34 /**
35  * TrigAttrInfo
36  *
37  * This signal is sent by TUP to signal
38  * that a trigger has fired
39  */
40 class TrigAttrInfo {
41   /**
42    * Sender(s)
43    */
44   // API
45 
46   /**
47    * Sender(s) / Reciver(s)
48    */
49   friend class Dbtup;
50 
51   /**
52    * Reciver(s)
53    */
54   friend class Dbtc;
55   friend class Backup;
56   friend class SumaParticipant;
57 
58   /**
59    * For printing
60    */
61   friend bool printTRIG_ATTRINFO(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);
62 
63 public:
64 enum AttrInfoType {
65   PRIMARY_KEY = 0,
66   BEFORE_VALUES = 1,
67   AFTER_VALUES = 2
68 };
69 
70   STATIC_CONST( DataLength = 22 );
71   STATIC_CONST( StaticLength = 3 );
72 
73 private:
74   Uint32 m_connectionPtr;
75   Uint32 m_trigId;
76   Uint32 m_type;
77   Uint32 m_data[DataLength];
78 
79   // Public methods
80 public:
81   Uint32 getConnectionPtr() const;
82   void setConnectionPtr(Uint32);
83   AttrInfoType getAttrInfoType() const;
84   void setAttrInfoType(AttrInfoType anAttrType);
85   Uint32 getTriggerId() const;
86   void setTriggerId(Uint32 aTriggerId);
87   Uint32 getTransactionId1() const;
88   void setTransactionId1(Uint32 aTransId);
89   Uint32 getTransactionId2() const;
90   void setTransactionId2(Uint32 aTransId);
91   Uint32* getData() const;
92   int setData(Uint32* aDataBuf, Uint32 aDataLen);
93 };
94 
95 inline
getConnectionPtr() const96 Uint32 TrigAttrInfo::getConnectionPtr() const
97 {
98   return m_connectionPtr;
99 }
100 
101 inline
setConnectionPtr(Uint32 aConnectionPtr)102 void TrigAttrInfo::setConnectionPtr(Uint32 aConnectionPtr)
103 {
104   m_connectionPtr = aConnectionPtr;
105 }
106 
107 inline
getAttrInfoType() const108 TrigAttrInfo::AttrInfoType TrigAttrInfo::getAttrInfoType() const
109 {
110   return  (TrigAttrInfo::AttrInfoType) m_type;
111 }
112 
113 inline
setAttrInfoType(TrigAttrInfo::AttrInfoType anAttrType)114 void TrigAttrInfo::setAttrInfoType(TrigAttrInfo::AttrInfoType anAttrType)
115 {
116   m_type = (Uint32) anAttrType;
117 }
118 
119 inline
getTriggerId() const120 Uint32 TrigAttrInfo::getTriggerId() const
121 {
122   return m_trigId;
123 }
124 
125 inline
setTriggerId(Uint32 aTriggerId)126 void TrigAttrInfo::setTriggerId(Uint32 aTriggerId)
127 {
128   m_trigId = aTriggerId;
129 }
130 
131 inline
getData() const132 Uint32* TrigAttrInfo::getData() const
133 {
134   return (Uint32*)&m_data[0];
135 }
136 
137 inline
setData(Uint32 * aDataBuf,Uint32 aDataLen)138 int TrigAttrInfo::setData(Uint32* aDataBuf, Uint32 aDataLen)
139 {
140   if (aDataLen > DataLength)
141     return -1;
142   memcpy(m_data, aDataBuf, aDataLen*sizeof(Uint32));
143 
144   return 0;
145 }
146 
147 #endif
148