/* Copyright (C) 2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "diskpage.hpp" #include #include static void print_usage(const char*); static int print_zero_page(int, void *, Uint32 sz); static int print_extent_page(int, void*, Uint32 sz); static int print_undo_page(int, void*, Uint32 sz); static int print_data_page(int, void*, Uint32 sz); static bool print_page(int page_no) { return false; } int g_verbosity = 1; int g_page_size = File_formats::NDB_PAGE_SIZE; int (* g_print_page)(int count, void*, Uint32 sz) = print_zero_page; File_formats::Undofile::Zero_page g_uf_zero; File_formats::Datafile::Zero_page g_df_zero; int main(int argc, char ** argv) { for(int i = 1; i+" << endl; } int print_zero_page(int i, void * ptr, Uint32 sz){ File_formats::Zero_page_header* page = (File_formats::Zero_page_header*)ptr; if(memcmp(page->m_magic, "NDBDISK", 8) != 0) { ndbout << "Invalid magic: file is not ndb disk data file" << endl; return 1; } if(page->m_byte_order != 0x12345678) { ndbout << "Unhandled byteorder" << endl; return 1; } switch(page->m_file_type) { case File_formats::FT_Datafile: { g_df_zero = (* (File_formats::Datafile::Zero_page*)ptr); ndbout << "-- Datafile -- " << endl; ndbout << g_df_zero << endl; g_print_page = print_extent_page; return 0; } break; case File_formats::FT_Undofile: { g_uf_zero = (* (File_formats::Undofile::Zero_page*)ptr); ndbout << "-- Undofile -- " << endl; ndbout << g_uf_zero << endl; g_print_page = print_undo_page; return 0; } break; default: ndbout << "Unhandled file type: " << page->m_file_type << endl; return 1; } if(page->m_page_size !=g_page_size) { /** * Todo * lseek * g_page_size = page->m_page_size; */ ndbout << "Unhandled page size: " << page->m_page_size << endl; return 1; } return 0; } NdbOut& operator<<(NdbOut& out, const File_formats::Datafile::Extent_header& obj) { if(obj.m_table == RNIL) { if(obj.m_next_free_extent != RNIL) out << " FREE, next free: " << obj.m_next_free_extent; else out << " FREE, next free: RNIL"; } else { out << "table: " << obj.m_table << " fragment: " << obj.m_fragment_id << " "; for(Uint32 i = 0; im_page_header.m_page_lsn_hi << " " << page->m_page_header.m_page_lsn_lo << "]" << endl; for(int i = 0; iget_header(i, g_df_zero.m_extent_size)) << endl; } return 0; } int print_data_page(int count, void* ptr, Uint32 sz){ File_formats::Datafile::Data_page * page = (File_formats::Datafile::Data_page*)ptr; ndbout << "Data page: " << count << ", lsn = [ " << page->m_page_header.m_page_lsn_hi << " " << page->m_page_header.m_page_lsn_lo << "]" ; if(g_verbosity > 1 || print_page(count)) { switch(page->m_page_header.m_page_type){ case File_formats::PT_Unallocated: break; case File_formats::PT_Tup_fixsize_page: ndbout << " fix "; if(g_verbosity > 2 || print_page(count)) ndbout << (* (Tup_fixsize_page*)page); break; case File_formats::PT_Tup_varsize_page: ndbout << " var "; if(g_verbosity > 2 || print_page(count)) ndbout << endl << (* (Tup_varsize_page*)page); break; default: ndbout << " unknown page type: %d" << page->m_page_header.m_page_type; } } ndbout << endl; return 0; } #define DBTUP_C #include "dbtup/Dbtup.hpp" int print_undo_page(int count, void* ptr, Uint32 sz){ if(count > g_uf_zero.m_undo_pages + 1) { ndbout_c(" ERROR to many pages in file!!"); return 1; } File_formats::Undofile::Undo_page * page = (File_formats::Undofile::Undo_page*)ptr; if(page->m_page_header.m_page_lsn_hi != 0 || page->m_page_header.m_page_lsn_lo != 0) { ndbout << "Undo page: " << count << ", lsn = [ " << page->m_page_header.m_page_lsn_hi << " " << page->m_page_header.m_page_lsn_lo << "] " << "words used: " << page->m_words_used << endl; Uint64 lsn= 0; lsn += page->m_page_header.m_page_lsn_hi; lsn <<= 32; lsn += page->m_page_header.m_page_lsn_lo; lsn++; if(g_verbosity >= 3) { Uint32 pos= page->m_words_used - 1; while(pos + 1 != 0) { Uint32 len= page->m_data[pos] & 0xFFFF; Uint32 type= page->m_data[pos] >> 16; const Uint32* src= page->m_data + pos - len + 1; Uint32 next_pos= pos - len; if(type & File_formats::Undofile::UNDO_NEXT_LSN) { type &= ~(Uint32)File_formats::Undofile::UNDO_NEXT_LSN; lsn--; } else { lsn = 0; lsn += * (src - 2); lsn <<= 32; lsn += * (src - 1); next_pos -= 2; } if(g_verbosity > 3) printf(" %.4d - %.4d : ", pos - len + 1, pos); switch(type){ case File_formats::Undofile::UNDO_LCP_FIRST: case File_formats::Undofile::UNDO_LCP: printf("[ %lld LCP %d tab: %d frag: %d ]", lsn, src[0], src[1] >> 16, src[1] & 0xFFFF); break; case File_formats::Undofile::UNDO_TUP_ALLOC: if(g_verbosity > 3) { Dbtup::Disk_undo::Alloc *req= (Dbtup::Disk_undo::Alloc*)src; printf("[ %lld A %d %d %d ]", lsn, req->m_file_no_page_idx >> 16, req->m_file_no_page_idx & 0xFFFF, req->m_page_no); } break; case File_formats::Undofile::UNDO_TUP_UPDATE: if(g_verbosity > 3) { Dbtup::Disk_undo::Update *req= (Dbtup::Disk_undo::Update*)src; printf("[ %lld U %d %d %d gci: %d ]", lsn, req->m_file_no_page_idx >> 16, req->m_file_no_page_idx & 0xFFFF, req->m_page_no, req->m_gci); } break; case File_formats::Undofile::UNDO_TUP_FREE: if(g_verbosity > 3) { Dbtup::Disk_undo::Free *req= (Dbtup::Disk_undo::Free*)src; printf("[ %lld F %d %d %d gci: %d ]", lsn, req->m_file_no_page_idx >> 16, req->m_file_no_page_idx & 0xFFFF, req->m_page_no, req->m_gci); } break; default: ndbout_c("[ Unknown type %d len: %d, pos: %d ]", type, len, pos); if(!(len && type)) { pos= 0; while(pos < page->m_words_used) { printf("%.8x ", page->m_data[pos]); if((pos + 1) % 7 == 0) ndbout_c(""); pos++; } } assert(len && type); } pos = next_pos; if(g_verbosity > 3) printf("\n"); } } } if(count == g_uf_zero.m_undo_pages + 1) { } return 0; } // hp3750 Signal::Signal(){}