1 /* 2 Copyright (c) 2003, 2013, 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_EVNT_HPP 26 #define CREATE_EVNT_HPP 27 28 #include <ndberror.h> 29 #include "SignalData.hpp" 30 #include <NodeBitmask.hpp> 31 #include <signaldata/DictTabInfo.hpp> 32 #include <AttributeList.hpp> 33 34 #define JAM_FILE_ID 103 35 36 37 typedef BitmaskPOD<MAXNROFATTRIBUTESINWORDS_OLD> AttributeMask_OLD; 38 39 /** 40 * DropEvntReq. 41 */ 42 class DropEvntReq { 43 friend bool printDROP_EVNT_REQ(FILE*, const Uint32*, Uint32, Uint16); 44 45 public: 46 STATIC_CONST( SignalLength = 2 ); 47 SECTION( EVENT_NAME_SECTION = 0 ); 48 49 union { // user block reference 50 Uint32 senderRef; 51 Uint32 m_userRef; 52 }; 53 union { 54 Uint32 senderData; 55 Uint32 m_userData; // user 56 }; 57 getUserRef() const58 Uint32 getUserRef() const { 59 return m_userRef; 60 } setUserRef(Uint32 val)61 void setUserRef(Uint32 val) { 62 m_userRef = val; 63 } getUserData() const64 Uint32 getUserData() const { 65 return m_userData; 66 } setUserData(Uint32 val)67 void setUserData(Uint32 val) { 68 m_userData = val; 69 } 70 }; 71 72 /** 73 * DropEvntConf. 74 */ 75 class DropEvntConf { 76 friend bool printDROP_EVNT_CONF(FILE*, const Uint32*, Uint32, Uint16); 77 78 public: 79 STATIC_CONST( SignalLength = 2 ); 80 81 union { // user block reference 82 Uint32 senderRef; 83 Uint32 m_userRef; 84 }; 85 union { 86 Uint32 senderData; 87 Uint32 m_userData; // user 88 }; 89 getUserRef() const90 Uint32 getUserRef() const { 91 return m_userRef; 92 } setUserRef(Uint32 val)93 void setUserRef(Uint32 val) { 94 m_userRef = val; 95 } getUserData() const96 Uint32 getUserData() const { 97 return m_userData; 98 } setUserData(Uint32 val)99 void setUserData(Uint32 val) { 100 m_userData = val; 101 } 102 }; 103 104 /** 105 * DropEvntRef. 106 */ 107 class DropEvntRef { 108 friend bool printDROP_EVNT_REF(FILE*, const Uint32*, Uint32, Uint16); 109 110 public: 111 enum ErrorCode { 112 NoError = 0, 113 Undefined = 1, 114 NF_FakeErrorREF = 11, 115 Busy = 701, 116 NotMaster = 702 117 }; 118 STATIC_CONST( SignalLength = 7 ); 119 STATIC_CONST( SignalLength2 = SignalLength+1 ); 120 121 union { // user block reference 122 Uint32 senderRef; 123 Uint32 m_userRef; 124 }; 125 union { 126 Uint32 senderData; 127 Uint32 m_userData; // user 128 }; 129 union { 130 Uint32 errorCode; 131 Uint32 m_errorCode; 132 }; 133 Uint32 m_errorLine; 134 Uint32 m_errorNode; 135 // with SignalLength2 136 Uint32 m_masterNodeId; getUserRef() const137 Uint32 getUserRef() const { 138 return m_userRef; 139 } setUserRef(Uint32 val)140 void setUserRef(Uint32 val) { 141 m_userRef = val; 142 } getUserData() const143 Uint32 getUserData() const { 144 return m_userData; 145 } setUserData(Uint32 val)146 void setUserData(Uint32 val) { 147 m_userData = val; 148 } getErrorCode() const149 Uint32 getErrorCode() const { 150 return m_errorCode; 151 } setErrorCode(Uint32 val)152 void setErrorCode(Uint32 val) { 153 m_errorCode = val; 154 } getErrorLine() const155 Uint32 getErrorLine() const { 156 return m_errorLine; 157 } setErrorLine(Uint32 val)158 void setErrorLine(Uint32 val) { 159 m_errorLine = val; 160 } getErrorNode() const161 Uint32 getErrorNode() const { 162 return m_errorNode; 163 } setErrorNode(Uint32 val)164 void setErrorNode(Uint32 val) { 165 m_errorNode = val; 166 } getMasterNode() const167 Uint32 getMasterNode() const { 168 return m_masterNodeId; 169 } setMasterNode(Uint32 val)170 void setMasterNode(Uint32 val) { 171 m_masterNodeId = val; 172 } 173 }; 174 175 /** 176 * CreateEvntReq. 177 */ 178 struct CreateEvntReq { 179 friend bool printCREATE_EVNT_REQ(FILE*, const Uint32*, Uint32, Uint16); 180 181 enum RequestType { 182 RT_UNDEFINED = 0, 183 RT_USER_CREATE = 1, 184 RT_USER_GET = 2, 185 186 RT_DICT_AFTER_GET = 0x1 << 4 187 // RT_DICT_MASTER = 0x2 << 4, 188 189 // RT_DICT_COMMIT = 0xC << 4, 190 // RT_DICT_ABORT = 0xF << 4, 191 // RT_TC = 5 << 8 192 }; 193 enum EventFlags { 194 EF_REPORT_ALL = 0x1 << 16, 195 EF_REPORT_SUBSCRIBE = 0x2 << 16, 196 EF_NO_REPORT_DDL = 0x4 << 16, 197 EF_ALL = 0xFFFF << 16 198 }; 199 STATIC_CONST( SignalLengthGet = 3 ); 200 STATIC_CONST( SignalLengthCreate = 6+MAXNROFATTRIBUTESINWORDS_OLD ); 201 STATIC_CONST( SignalLength = 8+MAXNROFATTRIBUTESINWORDS_OLD ); 202 203 SECTION( EVENT_NAME_SECTION = 0 ); 204 SECTION( ATTRIBUTE_MASK = 1 ); 205 206 union { 207 Uint32 m_userRef; // user block reference 208 Uint32 senderRef; // user block reference 209 }; 210 union { 211 Uint32 m_userData; // user 212 Uint32 senderData; // user 213 }; 214 Uint32 m_requestInfo; 215 Uint32 m_tableId; // table to event 216 Uint32 m_tableVersion; // table version 217 AttributeMask_OLD::Data m_attrListBitmask; 218 Uint32 m_eventType; // EventFlags (16 bits) + from DictTabInfo::TableType (16 bits) 219 Uint32 m_eventId; // event table id set by DICT/SUMA 220 Uint32 m_eventKey; // event table key set by DICT/SUMA getUserRefCreateEvntReq221 Uint32 getUserRef() const { 222 return m_userRef; 223 } setUserRefCreateEvntReq224 void setUserRef(Uint32 val) { 225 m_userRef = val; 226 } getUserDataCreateEvntReq227 Uint32 getUserData() const { 228 return m_userData; 229 } setUserDataCreateEvntReq230 void setUserData(Uint32 val) { 231 m_userData = val; 232 } getRequestTypeCreateEvntReq233 CreateEvntReq::RequestType getRequestType() const { 234 const Uint32 val = BitmaskImpl::getField(1, &m_requestInfo, 0, 16); 235 return (CreateEvntReq::RequestType)val; 236 } setRequestTypeCreateEvntReq237 void setRequestType(CreateEvntReq::RequestType val) { 238 m_requestInfo = (Uint32)val; 239 } getRequestFlagCreateEvntReq240 Uint32 getRequestFlag() const { 241 return BitmaskImpl::getField(1, &m_requestInfo, 16, 16); 242 }; addRequestFlagCreateEvntReq243 void addRequestFlag(Uint32 val) { 244 val |= BitmaskImpl::getField(1, &m_requestInfo, 16, 16); 245 BitmaskImpl::setField(1, &m_requestInfo, 16, 16, val); 246 }; getTableIdCreateEvntReq247 Uint32 getTableId() const { 248 return m_tableId; 249 } setTableIdCreateEvntReq250 void setTableId(Uint32 val) { 251 m_tableId = val; 252 } getTableVersionCreateEvntReq253 Uint32 getTableVersion() const { 254 return m_tableVersion; 255 } setTableVersionCreateEvntReq256 void setTableVersion(Uint32 val) { 257 m_tableVersion = val; 258 } getAttrListBitmaskCreateEvntReq259 AttributeMask_OLD getAttrListBitmask() const { 260 AttributeMask_OLD tmp; 261 tmp.assign(m_attrListBitmask); 262 return tmp; 263 } setAttrListBitmaskCreateEvntReq264 void setAttrListBitmask(const AttributeMask & val) { 265 setAttrListBitmask(val.getSizeInWords(), val.rep.data); 266 } setAttrListBitmaskCreateEvntReq267 void setAttrListBitmask(const AttributeMask_OLD & val) { 268 setAttrListBitmask(val.getSizeInWords(), val.rep.data); 269 } setAttrListBitmaskCreateEvntReq270 void setAttrListBitmask(Uint32 sz, const Uint32 data[]){ 271 bzero(m_attrListBitmask.data, sizeof(m_attrListBitmask.data)); 272 if (sz >= AttributeMask_OLD::Size) 273 { 274 AttributeMask_OLD::assign(m_attrListBitmask.data, data); 275 } 276 else 277 { 278 BitmaskImpl::assign(sz, m_attrListBitmask.data, data); 279 } 280 } getEventTypeCreateEvntReq281 Uint32 getEventType() const { 282 return m_eventType & ~EF_ALL; 283 } setEventTypeCreateEvntReq284 void setEventType(Uint32 val) { 285 m_eventType = (m_eventType & EF_ALL) | (~EF_ALL & (Uint32)val); 286 } getEventIdCreateEvntReq287 Uint32 getEventId() const { 288 return m_eventId; 289 } setEventIdCreateEvntReq290 void setEventId(Uint32 val) { 291 m_eventId = val; 292 } getEventKeyCreateEvntReq293 Uint32 getEventKey() const { 294 return m_eventKey; 295 } setEventKeyCreateEvntReq296 void setEventKey(Uint32 val) { 297 m_eventKey = val; 298 } clearFlagsCreateEvntReq299 void clearFlags() { 300 m_eventType&= ~EF_ALL; 301 } getReportFlagsCreateEvntReq302 Uint32 getReportFlags() const { 303 return m_eventType & EF_ALL; 304 } setReportFlagsCreateEvntReq305 void setReportFlags(Uint32 val) { 306 m_eventType = (val & EF_ALL) | (m_eventType & ~EF_ALL); 307 } getReportAllCreateEvntReq308 Uint32 getReportAll() const { 309 return m_eventType & EF_REPORT_ALL ; 310 } setReportAllCreateEvntReq311 void setReportAll() { 312 m_eventType|= EF_REPORT_ALL; 313 } getReportSubscribeCreateEvntReq314 Uint32 getReportSubscribe() const { 315 return m_eventType & EF_REPORT_SUBSCRIBE ; 316 } setReportSubscribeCreateEvntReq317 void setReportSubscribe() { 318 m_eventType|= EF_REPORT_SUBSCRIBE; 319 } getReportDDLCreateEvntReq320 Uint32 getReportDDL() const { 321 return (m_eventType & EF_NO_REPORT_DDL) == 0; 322 } setReportDDLCreateEvntReq323 void setReportDDL() { 324 m_eventType &= ~(Uint32)EF_NO_REPORT_DDL; 325 } clearReportDDLCreateEvntReq326 void clearReportDDL() { 327 m_eventType |= EF_NO_REPORT_DDL; 328 } 329 }; 330 331 /** 332 * CreateEvntConf. 333 */ 334 class CreateEvntConf { 335 friend bool printCREATE_EVNT_CONF(FILE*, const Uint32*, Uint32, Uint16); 336 337 public: 338 // STATIC_CONST( InternalLength = 3 ); 339 STATIC_CONST( SignalLength = 8+MAXNROFATTRIBUTESINWORDS_OLD ); 340 341 union { 342 Uint32 m_userRef; // user block reference 343 Uint32 senderRef; // user block reference 344 }; 345 union { 346 Uint32 m_userData; // user 347 Uint32 senderData; // user 348 }; 349 Uint32 m_requestInfo; 350 Uint32 m_tableId; 351 Uint32 m_tableVersion; // table version 352 AttributeMask_OLD m_attrListBitmask; 353 Uint32 m_eventType; 354 Uint32 m_eventId; 355 Uint32 m_eventKey; 356 getUserRef() const357 Uint32 getUserRef() const { 358 return m_userRef; 359 } setUserRef(Uint32 val)360 void setUserRef(Uint32 val) { 361 m_userRef = val; 362 } getUserData() const363 Uint32 getUserData() const { 364 return m_userData; 365 } setUserData(Uint32 val)366 void setUserData(Uint32 val) { 367 m_userData = val; 368 } getRequestType() const369 CreateEvntReq::RequestType getRequestType() const { 370 return (CreateEvntReq::RequestType)m_requestInfo; 371 } setRequestType(CreateEvntReq::RequestType val)372 void setRequestType(CreateEvntReq::RequestType val) { 373 m_requestInfo = (Uint32)val; 374 } getTableId() const375 Uint32 getTableId() const { 376 return m_tableId; 377 } setTableId(Uint32 val)378 void setTableId(Uint32 val) { 379 m_tableId = val; 380 } getTableVersion() const381 Uint32 getTableVersion() const { 382 return m_tableVersion; 383 } setTableVersion(Uint32 val)384 void setTableVersion(Uint32 val) { 385 m_tableVersion = val; 386 } getAttrListBitmask() const387 AttributeMask_OLD getAttrListBitmask() const { 388 return m_attrListBitmask; 389 } setAttrListBitmask(const AttributeMask_OLD & val)390 void setAttrListBitmask(const AttributeMask_OLD & val) { 391 m_attrListBitmask = val; 392 } getEventType() const393 Uint32 getEventType() const { 394 return m_eventType; 395 } setEventType(Uint32 val)396 void setEventType(Uint32 val) { 397 m_eventType = (Uint32)val; 398 } getEventId() const399 Uint32 getEventId() const { 400 return m_eventId; 401 } setEventId(Uint32 val)402 void setEventId(Uint32 val) { 403 m_eventId = val; 404 } getEventKey() const405 Uint32 getEventKey() const { 406 return m_eventKey; 407 } setEventKey(Uint32 val)408 void setEventKey(Uint32 val) { 409 m_eventKey = val; 410 } 411 }; 412 413 /** 414 * CreateEvntRef. 415 */ 416 struct CreateEvntRef { 417 friend class SafeCounter; 418 friend bool printCREATE_EVNT_REF(FILE*, const Uint32*, Uint32, Uint16); 419 420 STATIC_CONST( SignalLength = 11 ); 421 STATIC_CONST( SignalLength2 = SignalLength + 1 ); 422 enum ErrorCode { 423 NoError = 0, 424 Undefined = 1, 425 NF_FakeErrorREF = 11, 426 Busy = 701, 427 NotMaster = 702 428 }; 429 union { 430 Uint32 m_userRef; // user block reference 431 Uint32 senderRef; // user block reference 432 }; 433 union { 434 Uint32 m_userData; // user 435 Uint32 senderData; // user 436 }; 437 438 Uint32 m_requestInfo; 439 Uint32 m_tableId; 440 Uint32 m_tableVersion; // table version 441 Uint32 m_eventType; 442 Uint32 m_eventId; 443 Uint32 m_eventKey; 444 Uint32 errorCode; 445 Uint32 m_errorLine; 446 Uint32 m_errorNode; 447 // with SignalLength2 448 Uint32 m_masterNodeId; getUserRefCreateEvntRef449 Uint32 getUserRef() const { 450 return m_userRef; 451 } setUserRefCreateEvntRef452 void setUserRef(Uint32 val) { 453 m_userRef = val; 454 } getUserDataCreateEvntRef455 Uint32 getUserData() const { 456 return m_userData; 457 } setUserDataCreateEvntRef458 void setUserData(Uint32 val) { 459 m_userData = val; 460 } getRequestTypeCreateEvntRef461 CreateEvntReq::RequestType getRequestType() const { 462 return (CreateEvntReq::RequestType)m_requestInfo; 463 } setRequestTypeCreateEvntRef464 void setRequestType(CreateEvntReq::RequestType val) { 465 m_requestInfo = (Uint32)val; 466 } getTableIdCreateEvntRef467 Uint32 getTableId() const { 468 return m_tableId; 469 } setTableIdCreateEvntRef470 void setTableId(Uint32 val) { 471 m_tableId = val; 472 } getTableVersionCreateEvntRef473 Uint32 getTableVersion() const { 474 return m_tableVersion; 475 } setTableVersionCreateEvntRef476 void setTableVersion(Uint32 val) { 477 m_tableVersion = val; 478 } 479 getEventTypeCreateEvntRef480 Uint32 getEventType() const { 481 return m_eventType; 482 } setEventTypeCreateEvntRef483 void setEventType(Uint32 val) { 484 m_eventType = (Uint32)val; 485 } getEventIdCreateEvntRef486 Uint32 getEventId() const { 487 return m_eventId; 488 } setEventIdCreateEvntRef489 void setEventId(Uint32 val) { 490 m_eventId = val; 491 } getEventKeyCreateEvntRef492 Uint32 getEventKey() const { 493 return m_eventKey; 494 } setEventKeyCreateEvntRef495 void setEventKey(Uint32 val) { 496 m_eventKey = val; 497 } 498 getErrorCodeCreateEvntRef499 Uint32 getErrorCode() const { 500 return errorCode; 501 } setErrorCodeCreateEvntRef502 void setErrorCode(Uint32 val) { 503 errorCode = val; 504 } getErrorLineCreateEvntRef505 Uint32 getErrorLine() const { 506 return m_errorLine; 507 } setErrorLineCreateEvntRef508 void setErrorLine(Uint32 val) { 509 m_errorLine = val; 510 } getErrorNodeCreateEvntRef511 Uint32 getErrorNode() const { 512 return m_errorNode; 513 } setErrorNodeCreateEvntRef514 void setErrorNode(Uint32 val) { 515 m_errorNode = val; 516 } getMasterNodeCreateEvntRef517 Uint32 getMasterNode() const { 518 return m_masterNodeId; 519 } setMasterNodeCreateEvntRef520 void setMasterNode(Uint32 val) { 521 m_masterNodeId = val; 522 } 523 }; 524 525 #undef JAM_FILE_ID 526 527 #endif 528