#include <ndb_global.h>#include "records.hpp"Include dependency graph for redoLogFileReader.cpp:

Go to the source code of this file.
Defines | |
| #define | RETURN_ERROR 1 |
| #define | RETURN_OK 0 |
| #define | FROM_BEGINNING 0 |
Functions | |
| void | usage (const char *prg) |
| Uint32 | readFromFile (FILE *f, Uint32 *toPtr, Uint32 sizeInWords) |
| void | readArguments (int argc, const char **argv) |
| void | doExit () |
| NDB_COMMAND (redoLogFileReader,"redoLogFileReader","redoLogFileReader","Read a redo log file", 16384) | |
Variables | |
| FILE * | f = 0 |
| char | fileName [256] |
| bool | theDumpFlag = false |
| bool | thePrintFlag = true |
| bool | theCheckFlag = true |
| bool | onlyPageHeaders = false |
| bool | onlyMbyteHeaders = false |
| bool | onlyFileDesc = false |
| bool | firstLap = true |
| Uint32 | startAtMbyte = 0 |
| Uint32 | startAtPage = 0 |
| Uint32 | startAtPageIndex = 0 |
| Uint32 * | redoLogPage |
| #define FROM_BEGINNING 0 |
| #define RETURN_ERROR 1 |
| #define RETURN_OK 0 |
| void doExit | ( | ) |
Definition at line 411 of file redoLogFileReader.cpp.
References exit, f, ndbout(), redoLogPage, and RETURN_ERROR.
Referenced by NDB_COMMAND(), readArguments(), and readFromFile().
00411 { 00412 ndbout << "Error in redoLogReader(). Exiting!" << endl; 00413 if (f) fclose(f); 00414 delete [] redoLogPage; 00415 exit(RETURN_ERROR); 00416 }
Here is the call graph for this function:

Here is the caller graph for this function:

| NDB_COMMAND | ( | redoLogFileReader | , | |
| "redoLogFileReader" | , | |||
| "redoLogFileReader" | , | |||
| "Read a redo log file" | , | |||
| 16384 | ||||
| ) |
Definition at line 56 of file redoLogFileReader.cpp.
References PageHeader::check(), doExit(), exit, f, fileName, FROM_BEGINNING, AbortTransactionRecord::getLogRecordSize(), InvalidCommitTransactionRecord::getLogRecordSize(), CommitTransactionRecord::getLogRecordSize(), PrepareOperationRecord::getLogRecordSize(), CompletedGCIRecord::getLogRecordSize(), NextLogRecord::getLogRecordSize(), PageHeader::getLogRecordSize(), PageHeader::lastPage(), PageHeader::lastWord(), memmove, ndbout(), ndbout_c(), NO_MBYTE_IN_FILE, NO_PAGES_IN_MBYTE, onlyFileDesc, onlyMbyteHeaders, onlyPageHeaders, PAGESIZE, perror(), readArguments(), readFromFile(), redoLogPage, RETURN_ERROR, RETURN_OK, startAtMbyte, theCheckFlag, theDumpFlag, thePrintFlag, ZABORT_TYPE, ZCOMMIT_TYPE, ZCOMPLETED_GCI_TYPE, ZFD_TYPE, ZFRAG_SPLIT_TYPE, ZINVALID_COMMIT_TYPE, ZNEW_PREP_OP_TYPE, ZNEXT_LOG_RECORD_TYPE, ZNEXT_MBYTE_TYPE, and ZPREP_OP_TYPE.
00056 { 00057 int wordIndex = 0; 00058 int oldWordIndex = 0; 00059 Uint32 recordType = 1234567890; 00060 00061 PageHeader *thePageHeader; 00062 CompletedGCIRecord *cGCIrecord; 00063 PrepareOperationRecord *poRecord; 00064 NextLogRecord *nlRecord; 00065 FileDescriptor *fdRecord; 00066 CommitTransactionRecord *ctRecord; 00067 InvalidCommitTransactionRecord *ictRecord; 00068 NextMbyteRecord *nmRecord; 00069 AbortTransactionRecord *atRecord; 00070 00071 readArguments(argc, argv); 00072 00073 f = fopen(fileName, "rb"); 00074 if(!f){ 00075 perror("Error: open file"); 00076 exit(RETURN_ERROR); 00077 } 00078 00079 Uint32 tmpFileOffset = startAtMbyte * PAGESIZE * NO_PAGES_IN_MBYTE * sizeof(Uint32); 00080 if (fseek(f, tmpFileOffset, FROM_BEGINNING)) { 00081 perror("Error: Move in file"); 00082 exit(RETURN_ERROR); 00083 } 00084 00085 redoLogPage = new Uint32[PAGESIZE*NO_PAGES_IN_MBYTE]; 00086 Uint32 words_from_previous_page = 0; 00087 00088 // Loop for every mbyte. 00089 bool lastPage = false; 00090 for (Uint32 j = startAtMbyte; j < NO_MBYTE_IN_FILE && !lastPage; j++) { 00091 00092 readFromFile(f, redoLogPage, PAGESIZE*NO_PAGES_IN_MBYTE); 00093 00094 words_from_previous_page = 0; 00095 00096 // Loop for every page. 00097 for (int i = 0; i < NO_PAGES_IN_MBYTE; i++) { 00098 wordIndex = 0; 00099 thePageHeader = (PageHeader *) &redoLogPage[i*PAGESIZE]; 00100 // Print out mbyte number, page number and page index. 00101 ndbout << j << ":" << i << ":" << wordIndex << endl 00102 << " " << j*32 + i << ":" << wordIndex << " "; 00103 if (thePrintFlag) ndbout << (*thePageHeader); 00104 if (theCheckFlag) { 00105 if(!thePageHeader->check()) { 00106 ndbout << "Error in thePageHeader->check()" << endl; 00107 doExit(); 00108 } 00109 00110 Uint32 checkSum = 37; 00111 for (int ps = 1; ps < PAGESIZE; ps++) 00112 checkSum = redoLogPage[i*PAGESIZE+ps] ^ checkSum; 00113 00114 if (checkSum != redoLogPage[i*PAGESIZE]){ 00115 ndbout << "WRONG CHECKSUM: checksum = " << redoLogPage[i*PAGESIZE] 00116 << " expected = " << checkSum << endl; 00117 doExit(); 00118 } 00119 else 00120 ndbout << "expected checksum: " << checkSum << endl; 00121 00122 } 00123 00124 lastPage = i != 0 && thePageHeader->lastPage(); 00125 Uint32 lastWord = thePageHeader->lastWord(); 00126 00127 if (onlyMbyteHeaders) { 00128 // Show only the first page header in every mbyte of the file. 00129 break; 00130 } 00131 00132 if (onlyPageHeaders) { 00133 // Show only page headers. Continue with the next page in this for loop. 00134 continue; 00135 } 00136 00137 00138 wordIndex = thePageHeader->getLogRecordSize() - words_from_previous_page; 00139 Uint32 *redoLogPagePos = redoLogPage + i*PAGESIZE; 00140 if (words_from_previous_page) 00141 { 00142 memmove(redoLogPagePos + wordIndex , 00143 redoLogPagePos - words_from_previous_page, 00144 words_from_previous_page*4); 00145 } 00146 00147 do { 00148 if (words_from_previous_page) 00149 { 00150 // Print out mbyte number, page number and word index. 00151 ndbout << j << ":" << i-1 << ":" << PAGESIZE-words_from_previous_page << endl 00152 << j << ":" << i << ":" << wordIndex+words_from_previous_page << endl 00153 << " " << j*32 + i-1 << ":" << PAGESIZE-words_from_previous_page << " "; 00154 words_from_previous_page = 0; 00155 } 00156 else 00157 { 00158 // Print out mbyte number, page number and word index. 00159 ndbout << j << ":" << i << ":" << wordIndex << endl 00160 << " " << j*32 + i << ":" << wordIndex << " "; 00161 } 00162 redoLogPagePos = redoLogPage + i*PAGESIZE + wordIndex; 00163 oldWordIndex = wordIndex; 00164 recordType = *redoLogPagePos; 00165 switch(recordType) { 00166 case ZFD_TYPE: 00167 fdRecord = (FileDescriptor *) redoLogPagePos; 00168 if (thePrintFlag) ndbout << (*fdRecord); 00169 if (theCheckFlag) { 00170 if(!fdRecord->check()) { 00171 ndbout << "Error in fdRecord->check()" << endl; 00172 doExit(); 00173 } 00174 } 00175 if (onlyFileDesc) { 00176 delete [] redoLogPage; 00177 exit(RETURN_OK); 00178 } 00179 wordIndex += fdRecord->getLogRecordSize(); 00180 break; 00181 00182 case ZNEXT_LOG_RECORD_TYPE: 00183 nlRecord = (NextLogRecord *) redoLogPagePos; 00184 wordIndex += nlRecord->getLogRecordSize(wordIndex); 00185 if (wordIndex <= PAGESIZE) { 00186 if (thePrintFlag) ndbout << (*nlRecord); 00187 if (theCheckFlag) { 00188 if(!nlRecord->check()) { 00189 ndbout << "Error in nlRecord->check()" << endl; 00190 doExit(); 00191 } 00192 } 00193 } 00194 break; 00195 00196 case ZCOMPLETED_GCI_TYPE: 00197 cGCIrecord = (CompletedGCIRecord *) redoLogPagePos; 00198 wordIndex += cGCIrecord->getLogRecordSize(); 00199 if (wordIndex <= PAGESIZE) { 00200 if (thePrintFlag) ndbout << (*cGCIrecord); 00201 if (theCheckFlag) { 00202 if(!cGCIrecord->check()) { 00203 ndbout << "Error in cGCIrecord->check()" << endl; 00204 doExit(); 00205 } 00206 } 00207 } 00208 break; 00209 00210 case ZPREP_OP_TYPE: 00211 poRecord = (PrepareOperationRecord *) redoLogPagePos; 00212 wordIndex += poRecord->getLogRecordSize(PAGESIZE-wordIndex); 00213 if (wordIndex <= PAGESIZE) { 00214 if (thePrintFlag) ndbout << (*poRecord); 00215 if (theCheckFlag) { 00216 if(!poRecord->check()) { 00217 ndbout << "Error in poRecord->check()" << endl; 00218 doExit(); 00219 } 00220 } 00221 } 00222 break; 00223 00224 case ZCOMMIT_TYPE: 00225 ctRecord = (CommitTransactionRecord *) redoLogPagePos; 00226 wordIndex += ctRecord->getLogRecordSize(); 00227 if (wordIndex <= PAGESIZE) { 00228 if (thePrintFlag) ndbout << (*ctRecord); 00229 if (theCheckFlag) { 00230 if(!ctRecord->check()) { 00231 ndbout << "Error in ctRecord->check()" << endl; 00232 doExit(); 00233 } 00234 } 00235 } 00236 break; 00237 00238 case ZINVALID_COMMIT_TYPE: 00239 ictRecord = (InvalidCommitTransactionRecord *) redoLogPagePos; 00240 wordIndex += ictRecord->getLogRecordSize(); 00241 if (wordIndex <= PAGESIZE) { 00242 if (thePrintFlag) ndbout << (*ictRecord); 00243 if (theCheckFlag) { 00244 if(!ictRecord->check()) { 00245 ndbout << "Error in ictRecord->check()" << endl; 00246 doExit(); 00247 } 00248 } 00249 } 00250 break; 00251 00252 case ZNEXT_MBYTE_TYPE: 00253 nmRecord = (NextMbyteRecord *) redoLogPagePos; 00254 if (thePrintFlag) ndbout << (*nmRecord); 00255 i = NO_PAGES_IN_MBYTE; 00256 break; 00257 00258 case ZABORT_TYPE: 00259 atRecord = (AbortTransactionRecord *) redoLogPagePos; 00260 wordIndex += atRecord->getLogRecordSize(); 00261 if (wordIndex <= PAGESIZE) { 00262 if (thePrintFlag) ndbout << (*atRecord); 00263 if (theCheckFlag) { 00264 if(!atRecord->check()) { 00265 ndbout << "Error in atRecord->check()" << endl; 00266 doExit(); 00267 } 00268 } 00269 } 00270 break; 00271 00272 case ZNEW_PREP_OP_TYPE: 00273 case ZFRAG_SPLIT_TYPE: 00274 ndbout << endl << "Record type = " << recordType << " not implemented." << endl; 00275 doExit(); 00276 00277 default: 00278 ndbout << " ------ERROR: UNKNOWN RECORD TYPE------" << endl; 00279 00280 // Print out remaining data in this page 00281 for (int k = wordIndex; k < PAGESIZE; k++){ 00282 Uint32 unknown = redoLogPage[i*PAGESIZE + k]; 00283 ndbout_c("%-30d%-12u%-12x", k, unknown, unknown); 00284 } 00285 00286 doExit(); 00287 } 00288 } while(wordIndex < lastWord && i < NO_PAGES_IN_MBYTE); 00289 00290 00291 if (lastPage) 00292 { 00293 if (theDumpFlag) 00294 { 00295 ndbout << " ------PAGE END: DUMPING REST OF PAGE------" << endl; 00296 for (int k = wordIndex > PAGESIZE ? oldWordIndex : wordIndex; 00297 k < PAGESIZE; k++) 00298 { 00299 Uint32 word = redoLogPage[i*PAGESIZE + k]; 00300 ndbout_c("%-30d%-12u%-12x", k, word, word); 00301 } 00302 } 00303 break; 00304 } 00305 if (wordIndex > PAGESIZE) { 00306 words_from_previous_page = PAGESIZE - oldWordIndex; 00307 ndbout << " ----------- Record continues on next page -----------" << endl; 00308 } else { 00309 wordIndex = 0; 00310 words_from_previous_page = 0; 00311 } 00312 ndbout << endl; 00313 }//for 00314 ndbout << endl; 00315 if (startAtMbyte != 0) { 00316 break; 00317 } 00318 }//for 00319 fclose(f); 00320 delete [] redoLogPage; 00321 exit(RETURN_OK); 00322 }
Here is the call graph for this function:

| int readArguments | ( | int | argc, | |
| const char ** | argv | |||
| ) |
Definition at line 352 of file redoLogFileReader.cpp.
References atoi(), doExit(), fileName, onlyFileDesc, onlyMbyteHeaders, onlyPageHeaders, startAtMbyte, startAtPage, startAtPageIndex, strcmp(), theCheckFlag, theDumpFlag, thePrintFlag, and usage().
Referenced by main(), and NDB_COMMAND().
00353 { 00354 if(argc < 2 || argc > 9){ 00355 usage(argv[0]); 00356 doExit(); 00357 } 00358 00359 strcpy(fileName, argv[1]); 00360 argc--; 00361 00362 int i = 2; 00363 while (argc > 1) 00364 { 00365 if (strcmp(argv[i], "-noprint") == 0) { 00366 thePrintFlag = false; 00367 } else if (strcmp(argv[i], "-dump") == 0) { 00368 theDumpFlag = true; 00369 } else if (strcmp(argv[i], "-nocheck") == 0) { 00370 theCheckFlag = false; 00371 } else if (strcmp(argv[i], "-mbyteheaders") == 0) { 00372 onlyMbyteHeaders = true; 00373 } else if (strcmp(argv[i], "-pageheaders") == 0) { 00374 onlyPageHeaders = true; 00375 } else if (strcmp(argv[i], "-filedescriptors") == 0) { 00376 onlyFileDesc = true; 00377 } else if (strcmp(argv[i], "-mbyte") == 0) { 00378 startAtMbyte = atoi(argv[i+1]); 00379 if (startAtMbyte > 15) { 00380 usage(argv[0]); 00381 doExit(); 00382 } 00383 argc--; 00384 i++; 00385 } else if (strcmp(argv[i], "-page") == 0) { 00386 startAtPage = atoi(argv[i+1]); 00387 if (startAtPage > 31) { 00388 usage(argv[0]); 00389 doExit(); 00390 } 00391 argc--; 00392 i++; 00393 } else if (strcmp(argv[i], "-pageindex") == 0) { 00394 startAtPageIndex = atoi(argv[i+1]); 00395 if (startAtPageIndex > 8191 || startAtPageIndex < 12) { 00396 usage(argv[0]); 00397 doExit(); 00398 } 00399 argc--; 00400 i++; 00401 } else { 00402 usage(argv[0]); 00403 doExit(); 00404 } 00405 argc--; 00406 i++; 00407 } 00408 00409 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 328 of file redoLogFileReader.cpp.
References doExit(), and ndbout().
00328 { 00329 Uint32 noOfReadWords; 00330 if ( !(noOfReadWords = fread(toPtr, sizeof(Uint32), sizeInWords, f)) ) { 00331 ndbout << "Error reading file" << endl; 00332 doExit(); 00333 } 00334 00335 return noOfReadWords; 00336 }
Here is the call graph for this function:

| void usage | ( | const char * | prg | ) |
Definition at line 26 of file printConfig.cpp.
References buf, ndbout(), and strlen().
00026 { 00027 ndbout << "Usage " << prg 00028 << " host <mgm host> <mgm port> <node id> [<ver id>]" << endl; 00029 00030 char buf[255]; 00031 for(unsigned i = 0; i<strlen(prg); i++) 00032 buf[i] = ' '; 00033 buf[strlen(prg)] = 0; 00034 ndbout << " " << buf << " file <filename> <node id> [<ver id>]" 00035 << endl; 00036 }
Here is the call graph for this function:

| FILE* f = 0 |
Definition at line 42 of file redoLogFileReader.cpp.
Referenced by Item_func_group_concat::add(), Item_equal::add(), Hybrid_type_traits_integer::add(), Hybrid_type_traits::add(), Hybrid_type_traits_decimal::add(), TaoCrypt::AlmostInverse(), NdbDictionary::Dictionary::alterTableGlobal(), bmove512(), chcmp(), check_if_key_used(), Dbtup::checkUpdateOfPrimaryKey(), composite_key_cmp(), NdbDictInterface::create_file(), Dbdict::create_file_prepare_start(), debug_find_named_type(), debug_find_tagged_type(), debug_make_field(), debug_make_function_type(), debug_make_static_member(), debug_record_function(), debug_start_source(), debug_write(), debug_write_class_type(), debug_write_type(), CPCD::Process::do_exec(), doExit(), analyse::end_of_records(), Item_func_sp::execute(), SimulatedBlock::executeFunction(), fill_record(), find_debug_function_t(), gen_bitlen(), get_mm_tree(), get_one_option(), ConfigRetriever::getConfig(), getTps(), insert_file(), Item_equal::Item_equal(), Item_field::Item_field(), CPCD::loadProcessList(), main(), my_crawl(), mysql_checksum_table(), mysql_table_grant(), NDB_COMMAND(), ndb_mgm_call(), Dbdict::packFileIntoPages(), parse_stab(), NdbDictInterface::parseFileInfo(), pr_function_parameter(), pr_lineno(), print_arrays_for(), randRange(), read_section_stabs_debugging_info(), read_symbol_stabs_debugging_info(), Dbtup::readAttributes(), readFromFile(), CPCD::Process::readPid(), regress(), Item_field::reset_field(), rint(), MgmtSrvr::saveConfig(), CPCD::saveProcessList(), select_describe(), Item_sum_count_distinct::setup(), simple_str_key_cmp(), test_bug4172(), FileUnitTest::testRead(), FileUnitTest::testRemove(), FileUnitTest::testSize(), FileUnitTest::testWrite(), Item_func_like::turboBM_compute_suffixes(), Dbtup::updateAttributes(), CPCD::Process::writePid(), writeToFile(), xps(), and analyse::~analyse().
| char fileName[256] |
Definition at line 43 of file redoLogFileReader.cpp.
Referenced by main(), NDB_COMMAND(), and readArguments().
Definition at line 50 of file redoLogFileReader.cpp.
| bool onlyFileDesc = false |
Definition at line 49 of file redoLogFileReader.cpp.
Referenced by NDB_COMMAND(), and readArguments().
| bool onlyMbyteHeaders = false |
Definition at line 48 of file redoLogFileReader.cpp.
Referenced by NDB_COMMAND(), and readArguments().
| bool onlyPageHeaders = false |
Definition at line 47 of file redoLogFileReader.cpp.
Referenced by NDB_COMMAND(), and readArguments().
| Uint32 startAtMbyte = 0 |
Definition at line 51 of file redoLogFileReader.cpp.
Referenced by NDB_COMMAND(), and readArguments().
| Uint32 startAtPage = 0 |
| bool theCheckFlag = true |
Definition at line 46 of file redoLogFileReader.cpp.
Referenced by NDB_COMMAND(), and readArguments().
| bool theDumpFlag = false |
Definition at line 44 of file redoLogFileReader.cpp.
Referenced by NDB_COMMAND(), and readArguments().
| bool thePrintFlag = true |
Definition at line 45 of file redoLogFileReader.cpp.
Referenced by NDB_COMMAND(), and readArguments().
1.4.7

