MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TcKeyConf.hpp
1 /*
2  Copyright (C) 2003-2007 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 as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef TC_KEY_CONF_H
20 #define TC_KEY_CONF_H
21 
22 #include "SignalData.hpp"
23 
27 class TcKeyConf {
31  friend class Ndb;
32  friend class NdbTransaction;
33  friend class Ndbcntr;
34  friend class DbUtil;
35 
39  friend class Dbtc;
40  friend class Dbspj;
41 
45  friend bool printTCKEYCONF(FILE *, const Uint32 *, Uint32, Uint16);
46 
47 public:
51  STATIC_CONST( StaticLength = 5 );
52  STATIC_CONST( OperationLength = 2 );
53  STATIC_CONST( DirtyReadBit = (((Uint32)1) << 31) );
54 
55 private:
56 
60  //-------------------------------------------------------------
61  // Unconditional part. First 5 words
62  //-------------------------------------------------------------
63 
64  Uint32 apiConnectPtr; // if RNIL, transaction is found from op
65  Uint32 gci_hi; // gci_lo is stored after operations...
66  Uint32 confInfo;
67  Uint32 transId1;
68  Uint32 transId2;
69 
70  struct OperationConf {
71  Uint32 apiOperationPtr;
72  Uint32 attrInfoLen;
73  };
74  //-------------------------------------------------------------
75  // Operations confirmations,
76  // No of actually sent = getNoOfOperations(confInfo)
77  //-------------------------------------------------------------
78  OperationConf operations[10];
79 
83  static Uint32 getNoOfOperations(const Uint32 & confInfo);
84  static Uint32 getCommitFlag(const Uint32 & confInfo);
85  static bool getMarkerFlag(const Uint32 & confInfo);
86 
90  static void setCommitFlag(Uint32 & confInfo, Uint8 flag);
91  static void setNoOfOperations(Uint32 & confInfo, Uint32 noOfOps);
92  static void setMarkerFlag(Uint32 & confInfo, Uint32 flag);
93 };
94 
95 inline
96 Uint32
97 TcKeyConf::getNoOfOperations(const Uint32 & confInfo){
98  return confInfo & 65535;
99 }
100 
101 inline
102 Uint32
103 TcKeyConf::getCommitFlag(const Uint32 & confInfo){
104  return ((confInfo >> 16) & 1);
105 }
106 
107 inline
108 bool
109 TcKeyConf::getMarkerFlag(const Uint32 & confInfo){
110  const Uint32 bits = 3 << 16; // Marker only valid when doing commit
111  return (confInfo & bits) == bits;
112 }
113 
114 inline
115 void
116 TcKeyConf::setNoOfOperations(Uint32 & confInfo, Uint32 noOfOps){
117  ASSERT_MAX(noOfOps, 65535, "TcKeyConf::setNoOfOperations");
118  confInfo = (confInfo & 0xFFFF0000) | noOfOps;
119 }
120 
121 inline
122 void
123 TcKeyConf::setCommitFlag(Uint32 & confInfo, Uint8 flag){
124  ASSERT_BOOL(flag, "TcKeyConf::setCommitFlag");
125  confInfo |= (flag << 16);
126 }
127 
128 inline
129 void
130 TcKeyConf::setMarkerFlag(Uint32 & confInfo, Uint32 flag){
131  ASSERT_BOOL(flag, "TcKeyConf::setMarkerFlag");
132  confInfo |= (flag << 17);
133 }
134 
135 #endif