1 /* 2 Copyright (C) 2003, 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. 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 #include <NdbMain.h> 27 #include <NdbOut.hpp> 28 #include <ndb_types.h> 29 30 #define ZNEW_PREP_OP_TYPE 0 31 #define ZPREP_OP_TYPE 1 32 #define ZCOMMIT_TYPE 2 33 #define ZABORT_TYPE 3 34 #define ZFD_TYPE 4 35 #define ZFRAG_SPLIT_TYPE 5 36 #define ZNEXT_LOG_RECORD_TYPE 6 37 #define ZNEXT_MBYTE_TYPE 7 38 #define ZCOMPLETED_GCI_TYPE 8 39 #define ZINVALID_COMMIT_TYPE 9 40 41 #define MAX_FILE_DESCRIPTORS 40 42 43 #define PAGESIZE 8192 44 #define NO_PAGES_IN_MBYTE 32 45 46 #define COMMITTRANSACTIONRECORDSIZE 9 47 #define COMPLETEDGCIRECORDSIZE 2 48 #define PAGEHEADERSIZE 32 49 #define FILEDESCRIPTORHEADERSIZE 3 50 #define FILEDESCRIPTORENTRYSIZE 3 51 #define NEXTMBYTERECORDSIZE 1 52 #define ABORTTRANSACTIONRECORDSIZE 3 53 54 extern unsigned NO_MBYTE_IN_FILE; 55 56 //---------------------------------------------------------------- 57 // 58 //---------------------------------------------------------------- 59 60 class AbortTransactionRecord { 61 friend NdbOut& operator<<(NdbOut&, const AbortTransactionRecord&); 62 public: 63 bool check(); 64 Uint32 getLogRecordSize(); 65 protected: 66 Uint32 m_recordType; 67 Uint32 m_transactionId1; 68 Uint32 m_transactionId2; 69 }; 70 71 72 //---------------------------------------------------------------- 73 // 74 //---------------------------------------------------------------- 75 76 class NextMbyteRecord { 77 friend NdbOut& operator<<(NdbOut&, const NextMbyteRecord&); 78 public: 79 bool check(); 80 Uint32 getLogRecordSize(); 81 protected: 82 Uint32 m_recordType; 83 }; 84 85 //---------------------------------------------------------------- 86 // 87 //---------------------------------------------------------------- 88 89 90 class PrepareOperationRecord { 91 friend NdbOut& operator<<(NdbOut&, const PrepareOperationRecord&); 92 public: 93 bool check(); 94 Uint32 getLogRecordSize(Uint32 wordsRead); 95 96 protected: 97 Uint32 m_recordType; 98 Uint32 m_logRecordSize; 99 Uint32 m_hashValue; 100 Uint32 m_operationType; // 0 READ, 1 UPDATE, 2 INSERT, 3 DELETE 101 Uint32 m_attributeLength; 102 Uint32 m_keyLength; 103 Uint32 m_page_no; 104 Uint32 m_page_idx; 105 Uint32 *m_keyInfo; // In this order 106 Uint32 *m_attrInfo;// In this order 107 }; 108 109 //---------------------------------------------------------------- 110 // 111 //---------------------------------------------------------------- 112 113 class CompletedGCIRecord { 114 friend NdbOut& operator<<(NdbOut&, const CompletedGCIRecord&); 115 public: 116 bool check(); 117 Uint32 getLogRecordSize(); 118 protected: 119 Uint32 m_recordType; 120 Uint32 m_theCompletedGCI; 121 }; 122 123 //---------------------------------------------------------------- 124 // 125 //---------------------------------------------------------------- 126 127 class NextLogRecord { 128 friend NdbOut& operator<<(NdbOut&, const NextLogRecord&); 129 public: 130 bool check(); 131 Uint32 getLogRecordSize(Uint32); 132 protected: 133 Uint32 m_recordType; 134 }; 135 136 //---------------------------------------------------------------- 137 // 138 //---------------------------------------------------------------- 139 140 class PageHeader { 141 friend NdbOut& operator<<(NdbOut&, const PageHeader&); 142 public: 143 bool check(); 144 Uint32 getLogRecordSize(); 145 bool lastPage(); 146 Uint32 lastWord(); 147 //protected: 148 Uint32 m_checksum; 149 Uint32 m_lap; 150 Uint32 m_max_gci_completed; 151 Uint32 m_max_gci_started; 152 Uint32 m_next_page; 153 Uint32 m_previous_page; 154 Uint32 m_ndb_version; 155 Uint32 m_number_of_logfiles; 156 Uint32 m_current_page_index; 157 Uint32 m_old_prepare_file_number; 158 Uint32 m_old_prepare_page_reference; 159 Uint32 m_dirty_flag; 160 /* Debug info Start */ 161 Uint32 m_log_timer; 162 Uint32 m_page_i_value; 163 Uint32 m_place_written_from; 164 Uint32 m_page_no; 165 Uint32 m_file_no; 166 Uint32 m_word_written; 167 Uint32 m_in_writing_flag; 168 Uint32 m_prev_page_no; 169 Uint32 m_in_free_list; 170 /* Debug info End */ 171 }; 172 173 //---------------------------------------------------------------- 174 // File descriptor. 175 //---------------------------------------------------------------- 176 177 class FileDescriptorHeader { 178 public: 179 Uint32 m_recordType; 180 Uint32 m_noOfDescriptors; 181 Uint32 m_fileNo; 182 }; 183 184 class FileDescriptor 185 { 186 friend NdbOut& operator<<(NdbOut&, const FileDescriptor&); 187 public: 188 bool check(); 189 Uint32 getLogRecordSize(); 190 protected: 191 void printARecord( Uint32 ) const; 192 FileDescriptorHeader m_fdHeader; 193 Uint32 m_fdRecord[1]; 194 }; 195 196 197 //---------------------------------------------------------------- 198 // 199 //---------------------------------------------------------------- 200 201 class CommitTransactionRecord { 202 friend NdbOut& operator<<(NdbOut&, const CommitTransactionRecord&); 203 public: 204 bool check(); 205 Uint32 getLogRecordSize(); 206 protected: 207 Uint32 m_recordType; 208 Uint32 m_tableId; 209 Uint32 m_schemaVersion; 210 Uint32 m_fragmentId; 211 Uint32 m_fileNumberOfPrepareOperation; 212 Uint32 m_startPageNumberOfPrepareOperation; 213 Uint32 m_startPageIndexOfPrepareOperation; 214 Uint32 m_stopPageNumberOfPrepareOperation; 215 Uint32 m_globalCheckpoint; 216 }; 217 218 //---------------------------------------------------------------- 219 // 220 //---------------------------------------------------------------- 221 222 class InvalidCommitTransactionRecord { 223 friend NdbOut& operator<<(NdbOut&, const InvalidCommitTransactionRecord&); 224 public: 225 bool check(); 226 Uint32 getLogRecordSize(); 227 protected: 228 Uint32 m_recordType; 229 Uint32 m_tableId; 230 Uint32 m_fragmentId; 231 Uint32 m_fileNumberOfPrepareOperation; 232 Uint32 m_startPageNumberOfPrepareOperation; 233 Uint32 m_startPageIndexOfPrepareOperation; 234 Uint32 m_stopPageNumberOfPrepareOperation; 235 Uint32 m_globalCheckpoint; 236 }; 237 238 //---------------------------------------------------------------- 239 // 240 //---------------------------------------------------------------- 241 242 struct NextLogRec { 243 244 }; 245 246 struct NewPrepareOperation { 247 248 }; 249 250 struct FragmentSplit { 251 252 }; 253