/*************************************************************//** Pretty prints a dfield value according to its data type. Also the hex string is printed if a string contains non-printable characters. */ UNIV_INTERN void dfield_print_also_hex( /*==================*/ const dfield_t* dfield) /*!< in: dfield */ { const byte* data; ulint len; ulint prtype; ulint i; ibool print_also_hex; len = dfield_get_len(dfield); data = dfield_get_data(dfield); if (dfield_is_null(dfield)) { fputs("NULL", stderr); return; } prtype = dtype_get_prtype(dfield_get_type(dfield)); switch (dtype_get_mtype(dfield_get_type(dfield))) { dulint id; case DATA_INT: switch (len) { ulint val; case 1: val = mach_read_from_1(data); if (!(prtype & DATA_UNSIGNED)) { val &= ~0x80; fprintf(stderr, "%ld", (long) val); } else { fprintf(stderr, "%lu", (ulong) val); } break; case 2: val = mach_read_from_2(data); if (!(prtype & DATA_UNSIGNED)) { val &= ~0x8000; fprintf(stderr, "%ld", (long) val); } else { fprintf(stderr, "%lu", (ulong) val); } break; case 3: val = mach_read_from_3(data); if (!(prtype & DATA_UNSIGNED)) { val &= ~0x800000; fprintf(stderr, "%ld", (long) val); } else { fprintf(stderr, "%lu", (ulong) val); } break; case 4: val = mach_read_from_4(data); if (!(prtype & DATA_UNSIGNED)) { val &= ~0x80000000; fprintf(stderr, "%ld", (long) val); } else { fprintf(stderr, "%lu", (ulong) val); } break; case 6: id = mach_read_from_6(data); fprintf(stderr, "{%lu %lu}", ut_dulint_get_high(id), ut_dulint_get_low(id)); break; case 7: id = mach_read_from_7(data); fprintf(stderr, "{%lu %lu}", ut_dulint_get_high(id), ut_dulint_get_low(id)); break; case 8: id = mach_read_from_8(data); fprintf(stderr, "{%lu %lu}", ut_dulint_get_high(id), ut_dulint_get_low(id)); break; default: goto print_hex; } break; case DATA_SYS: switch (prtype & DATA_SYS_PRTYPE_MASK) { case DATA_TRX_ID: id = mach_read_from_6(data); fprintf(stderr, "trx_id " TRX_ID_FMT, TRX_ID_PREP_PRINTF(id)); break; case DATA_ROLL_PTR: id = mach_read_from_7(data); fprintf(stderr, "roll_ptr {%lu %lu}", ut_dulint_get_high(id), ut_dulint_get_low(id)); break; case DATA_ROW_ID: id = mach_read_from_6(data); fprintf(stderr, "row_id {%lu %lu}", ut_dulint_get_high(id), ut_dulint_get_low(id)); break; default: id = mach_dulint_read_compressed(data); fprintf(stderr, "mix_id {%lu %lu}", ut_dulint_get_high(id), ut_dulint_get_low(id)); } break; case DATA_CHAR: case DATA_VARCHAR: print_also_hex = FALSE; for (i = 0; i < len; i++) { int c = *data++; if (!isprint(c)) { print_also_hex = TRUE; fprintf(stderr, "\\x%02x", (unsigned char) c); } else { putc(c, stderr); } } if (dfield_is_ext(dfield)) { fputs("(external)", stderr); } if (!print_also_hex) { break; } data = dfield_get_data(dfield); /* fall through */ case DATA_BINARY: default: print_hex: fputs(" Hex: ",stderr); for (i = 0; i < len; i++) { fprintf(stderr, "%02lx", (ulint) *data++); } if (dfield_is_ext(dfield)) { fputs("(external)", stderr); } } }
static void print_page(uchar *p) { int type = mach_read_from_2(p + FIL_PAGE_TYPE); if (type == FIL_PAGE_TYPE_ALLOCATED) { return; } printf(COLUMN_NAME_FMT " %ld\n", "FIL_PAGE_OFFSET", mach_read_from_4(p + FIL_PAGE_OFFSET)); printf(COLUMN_NAME_FMT " 0x%08lX\n", "FIL_PAGE_SPACE_OR_CHKSUM", mach_read_from_4(p + FIL_PAGE_SPACE_OR_CHKSUM)); printf(COLUMN_NAME_FMT " %ld\n", "FIL_PAGE_PREV", mach_read_from_4(p + FIL_PAGE_PREV)); printf(COLUMN_NAME_FMT " %ld\n", "FIL_PAGE_NEXT", mach_read_from_4(p + FIL_PAGE_NEXT)); printf(COLUMN_NAME_FMT " %ld\n", "FIL_PAGE_LSN", mach_read_from_4(p + FIL_PAGE_LSN)); printf(COLUMN_NAME_FMT " %ld\n", "FIL_PAGE_TYPE", mach_read_from_2(p + FIL_PAGE_TYPE)); dulint flush_lsn_tuple = mach_read_from_6(p + FIL_PAGE_FILE_FLUSH_LSN); uint64_t flush_lsn = (((uint64_t) flush_lsn_tuple.high) << 32) + flush_lsn_tuple.low; printf(COLUMN_NAME_FMT " %" PRIu64 "\n", "FIL_PAGE_FILE_FLUSH_LSN", flush_lsn); printf(COLUMN_NAME_FMT " %ld\n", "FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID", mach_read_from_4(p + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID)); printf(COLUMN_NAME_FMT " 0x%08lX\n", "FIL_PAGE_END_LSN_OLD_CHKSUM", mach_read_from_4(p + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM)); uchar *pd = p + FIL_PAGE_DATA; if (type == FIL_PAGE_TYPE_FSP_HDR) { printf(COLUMN_NAME_FMT " %ld\n", "FSEG_HDR_SPACE", mach_read_from_4(pd + FSEG_HDR_SPACE)); printf(COLUMN_NAME_FMT " %ld\n", "FSEG_HDR_PAGE_NO", mach_read_from_4(pd + FSEG_HDR_PAGE_NO)); printf(COLUMN_NAME_FMT " %ld\n", "FSEG_HDR_OFFSET", mach_read_from_4(pd + FSEG_HDR_OFFSET)); } else if (type == FIL_PAGE_INDEX) { printf(COLUMN_NAME_FMT " 0x%lX\n", "PAGE_N_HEAP", mach_read_from_2(pd + PAGE_N_HEAP)); printf(COLUMN_NAME_FMT " 0x%lX\n", "PAGE_FREE", mach_read_from_2(pd + PAGE_FREE)); dulint index_id_tuple = mach_read_from_8(pd + PAGE_INDEX_ID); uint64_t index_id = (((uint64_t) index_id_tuple.high) << 32) + index_id_tuple.low; printf(COLUMN_NAME_FMT " %" PRIu64 "\n", "PAGE_INDEX_ID", index_id); printf(COLUMN_NAME_FMT " %ld\n", "PAGE_BTR_SEG_LEAF", mach_read_from_4(pd + PAGE_BTR_SEG_LEAF + FSEG_HDR_SPACE)); printf(COLUMN_NAME_FMT " %ld\n", "PAGE_BTR_SEG_TOP", mach_read_from_4(pd + PAGE_BTR_SEG_TOP + FSEG_HDR_SPACE)); #if 0 int i; for (i = 0; i < 80; i += 4) { if (i == PAGE_BTR_SEG_LEAF || i == PAGE_N_HEAP || i == PAGE_INDEX_ID || i == PAGE_INDEX_ID + 4) { continue; } char column_name[256]; snprintf(column_name, sizeof(column_name), "FIL_PAGE_DATA + %2d", i); printf(COLUMN_NAME_FMT " %ld\n", column_name, mach_read_from_4(p + FIL_PAGE_DATA + i)); } #endif } printf("\n"); }