Commit 33ff1862 authored by Vlad Lesin's avatar Vlad Lesin

MDEV-27835 innochecksum -S crashes for encrypted .ibd tablespace

As main() invokes parse_page() when -S or -D are set, it can be a case
when parse_page() is invoked when -D filename is not set, that is why
any attempt to write to page dump file must be done only if the file
name is set with -D.

The bug is caused by 2ef7a5a1
(MDEV-13443).
parent 303448bc
...@@ -886,7 +886,7 @@ parse_page( ...@@ -886,7 +886,7 @@ parse_page(
is_leaf = (!*(const uint16*) (page + (PAGE_HEADER + PAGE_LEVEL))); is_leaf = (!*(const uint16*) (page + (PAGE_HEADER + PAGE_LEVEL)));
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tIndex page\t\t\t|" fprintf(file, "#::" UINT32PF "\t\t|\t\tIndex page\t\t\t|"
"\tindex id=%llu,", cur_page_num, id); "\tindex id=%llu,", cur_page_num, id);
...@@ -939,7 +939,7 @@ parse_page( ...@@ -939,7 +939,7 @@ parse_page(
index.total_data_bytes += data_bytes; index.total_data_bytes += data_bytes;
index.pages_in_size_range[size_range_id] ++; index.pages_in_size_range[size_range_id] ++;
} }
} else { } else if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tEncrypted Index page\t\t\t|" fprintf(file, "#::" UINT32PF "\t\t|\t\tEncrypted Index page\t\t\t|"
"\tkey_version " UINT32PF ",%s\n", cur_page_num, key_version, str); "\tkey_version " UINT32PF ",%s\n", cur_page_num, key_version, str);
} }
...@@ -950,20 +950,20 @@ parse_page( ...@@ -950,20 +950,20 @@ parse_page(
page_type.n_fil_page_undo_log++; page_type.n_fil_page_undo_log++;
undo_page_type = mach_read_from_2(page + undo_page_type = mach_read_from_2(page +
TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE); TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE);
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tUndo log page\t\t\t|", fprintf(file, "#::" UINT32PF "\t\t|\t\tUndo log page\t\t\t|",
cur_page_num); cur_page_num);
} }
if (undo_page_type == TRX_UNDO_INSERT) { if (undo_page_type == TRX_UNDO_INSERT) {
page_type.n_undo_insert++; page_type.n_undo_insert++;
if (page_type_dump) { if (file) {
fprintf(file, "\t%s", fprintf(file, "\t%s",
"Insert Undo log page"); "Insert Undo log page");
} }
} else if (undo_page_type == TRX_UNDO_UPDATE) { } else if (undo_page_type == TRX_UNDO_UPDATE) {
page_type.n_undo_update++; page_type.n_undo_update++;
if (page_type_dump) { if (file) {
fprintf(file, "\t%s", fprintf(file, "\t%s",
"Update undo log page"); "Update undo log page");
} }
...@@ -974,7 +974,7 @@ parse_page( ...@@ -974,7 +974,7 @@ parse_page(
switch (undo_page_type) { switch (undo_page_type) {
case TRX_UNDO_ACTIVE: case TRX_UNDO_ACTIVE:
page_type.n_undo_state_active++; page_type.n_undo_state_active++;
if (page_type_dump) { if (file) {
fprintf(file, ", %s", "Undo log of " fprintf(file, ", %s", "Undo log of "
"an active transaction"); "an active transaction");
} }
...@@ -982,7 +982,7 @@ parse_page( ...@@ -982,7 +982,7 @@ parse_page(
case TRX_UNDO_CACHED: case TRX_UNDO_CACHED:
page_type.n_undo_state_cached++; page_type.n_undo_state_cached++;
if (page_type_dump) { if (file) {
fprintf(file, ", %s", "Page is " fprintf(file, ", %s", "Page is "
"cached for quick reuse"); "cached for quick reuse");
} }
...@@ -990,7 +990,7 @@ parse_page( ...@@ -990,7 +990,7 @@ parse_page(
case TRX_UNDO_TO_FREE: case TRX_UNDO_TO_FREE:
page_type.n_undo_state_to_free++; page_type.n_undo_state_to_free++;
if (page_type_dump) { if (file) {
fprintf(file, ", %s", "Insert undo " fprintf(file, ", %s", "Insert undo "
"segment that can be freed"); "segment that can be freed");
} }
...@@ -998,7 +998,7 @@ parse_page( ...@@ -998,7 +998,7 @@ parse_page(
case TRX_UNDO_TO_PURGE: case TRX_UNDO_TO_PURGE:
page_type.n_undo_state_to_purge++; page_type.n_undo_state_to_purge++;
if (page_type_dump) { if (file) {
fprintf(file, ", %s", "Will be " fprintf(file, ", %s", "Will be "
"freed in purge when all undo" "freed in purge when all undo"
"data in it is removed"); "data in it is removed");
...@@ -1007,7 +1007,7 @@ parse_page( ...@@ -1007,7 +1007,7 @@ parse_page(
case TRX_UNDO_PREPARED: case TRX_UNDO_PREPARED:
page_type.n_undo_state_prepared++; page_type.n_undo_state_prepared++;
if (page_type_dump) { if (file) {
fprintf(file, ", %s", "Undo log of " fprintf(file, ", %s", "Undo log of "
"an prepared transaction"); "an prepared transaction");
} }
...@@ -1017,14 +1017,14 @@ parse_page( ...@@ -1017,14 +1017,14 @@ parse_page(
page_type.n_undo_state_other++; page_type.n_undo_state_other++;
break; break;
} }
if(page_type_dump) { if(file) {
fprintf(file, ", %s\n", str); fprintf(file, ", %s\n", str);
} }
break; break;
case FIL_PAGE_INODE: case FIL_PAGE_INODE:
page_type.n_fil_page_inode++; page_type.n_fil_page_inode++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tInode page\t\t\t|" fprintf(file, "#::" UINT32PF "\t\t|\t\tInode page\t\t\t|"
"\t%s\n",cur_page_num, str); "\t%s\n",cur_page_num, str);
} }
...@@ -1032,7 +1032,7 @@ parse_page( ...@@ -1032,7 +1032,7 @@ parse_page(
case FIL_PAGE_IBUF_FREE_LIST: case FIL_PAGE_IBUF_FREE_LIST:
page_type.n_fil_page_ibuf_free_list++; page_type.n_fil_page_ibuf_free_list++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tInsert buffer free list" fprintf(file, "#::" UINT32PF "\t\t|\t\tInsert buffer free list"
" page\t|\t%s\n", cur_page_num, str); " page\t|\t%s\n", cur_page_num, str);
} }
...@@ -1040,7 +1040,7 @@ parse_page( ...@@ -1040,7 +1040,7 @@ parse_page(
case FIL_PAGE_TYPE_ALLOCATED: case FIL_PAGE_TYPE_ALLOCATED:
page_type.n_fil_page_type_allocated++; page_type.n_fil_page_type_allocated++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tFreshly allocated " fprintf(file, "#::" UINT32PF "\t\t|\t\tFreshly allocated "
"page\t\t|\t%s\n", cur_page_num, str); "page\t\t|\t%s\n", cur_page_num, str);
} }
...@@ -1048,7 +1048,7 @@ parse_page( ...@@ -1048,7 +1048,7 @@ parse_page(
case FIL_PAGE_IBUF_BITMAP: case FIL_PAGE_IBUF_BITMAP:
page_type.n_fil_page_ibuf_bitmap++; page_type.n_fil_page_ibuf_bitmap++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tInsert Buffer " fprintf(file, "#::" UINT32PF "\t\t|\t\tInsert Buffer "
"Bitmap\t\t|\t%s\n", cur_page_num, str); "Bitmap\t\t|\t%s\n", cur_page_num, str);
} }
...@@ -1056,7 +1056,7 @@ parse_page( ...@@ -1056,7 +1056,7 @@ parse_page(
case FIL_PAGE_TYPE_SYS: case FIL_PAGE_TYPE_SYS:
page_type.n_fil_page_type_sys++; page_type.n_fil_page_type_sys++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tSystem page\t\t\t|" fprintf(file, "#::" UINT32PF "\t\t|\t\tSystem page\t\t\t|"
"\t%s\n", cur_page_num, str); "\t%s\n", cur_page_num, str);
} }
...@@ -1064,7 +1064,7 @@ parse_page( ...@@ -1064,7 +1064,7 @@ parse_page(
case FIL_PAGE_TYPE_TRX_SYS: case FIL_PAGE_TYPE_TRX_SYS:
page_type.n_fil_page_type_trx_sys++; page_type.n_fil_page_type_trx_sys++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tTransaction system " fprintf(file, "#::" UINT32PF "\t\t|\t\tTransaction system "
"page\t\t|\t%s\n", cur_page_num, str); "page\t\t|\t%s\n", cur_page_num, str);
} }
...@@ -1072,7 +1072,7 @@ parse_page( ...@@ -1072,7 +1072,7 @@ parse_page(
case FIL_PAGE_TYPE_FSP_HDR: case FIL_PAGE_TYPE_FSP_HDR:
page_type.n_fil_page_type_fsp_hdr++; page_type.n_fil_page_type_fsp_hdr++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tFile Space " fprintf(file, "#::" UINT32PF "\t\t|\t\tFile Space "
"Header\t\t|\t%s\n", cur_page_num, str); "Header\t\t|\t%s\n", cur_page_num, str);
} }
...@@ -1080,7 +1080,7 @@ parse_page( ...@@ -1080,7 +1080,7 @@ parse_page(
case FIL_PAGE_TYPE_XDES: case FIL_PAGE_TYPE_XDES:
page_type.n_fil_page_type_xdes++; page_type.n_fil_page_type_xdes++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tExtent descriptor " fprintf(file, "#::" UINT32PF "\t\t|\t\tExtent descriptor "
"page\t\t|\t%s\n", cur_page_num, str); "page\t\t|\t%s\n", cur_page_num, str);
} }
...@@ -1088,7 +1088,7 @@ parse_page( ...@@ -1088,7 +1088,7 @@ parse_page(
case FIL_PAGE_TYPE_BLOB: case FIL_PAGE_TYPE_BLOB:
page_type.n_fil_page_type_blob++; page_type.n_fil_page_type_blob++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tBLOB page\t\t\t|\t%s\n", fprintf(file, "#::" UINT32PF "\t\t|\t\tBLOB page\t\t\t|\t%s\n",
cur_page_num, str); cur_page_num, str);
} }
...@@ -1096,7 +1096,7 @@ parse_page( ...@@ -1096,7 +1096,7 @@ parse_page(
case FIL_PAGE_TYPE_ZBLOB: case FIL_PAGE_TYPE_ZBLOB:
page_type.n_fil_page_type_zblob++; page_type.n_fil_page_type_zblob++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tCompressed BLOB " fprintf(file, "#::" UINT32PF "\t\t|\t\tCompressed BLOB "
"page\t\t|\t%s\n", cur_page_num, str); "page\t\t|\t%s\n", cur_page_num, str);
} }
...@@ -1104,7 +1104,7 @@ parse_page( ...@@ -1104,7 +1104,7 @@ parse_page(
case FIL_PAGE_TYPE_ZBLOB2: case FIL_PAGE_TYPE_ZBLOB2:
page_type.n_fil_page_type_zblob2++; page_type.n_fil_page_type_zblob2++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tSubsequent Compressed " fprintf(file, "#::" UINT32PF "\t\t|\t\tSubsequent Compressed "
"BLOB page\t|\t%s\n", cur_page_num, str); "BLOB page\t|\t%s\n", cur_page_num, str);
} }
...@@ -1112,7 +1112,7 @@ parse_page( ...@@ -1112,7 +1112,7 @@ parse_page(
case FIL_PAGE_PAGE_COMPRESSED: case FIL_PAGE_PAGE_COMPRESSED:
page_type.n_fil_page_type_page_compressed++; page_type.n_fil_page_type_page_compressed++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tPage compressed " fprintf(file, "#::" UINT32PF "\t\t|\t\tPage compressed "
"page\t|\t%s\n", cur_page_num, str); "page\t|\t%s\n", cur_page_num, str);
} }
...@@ -1120,7 +1120,7 @@ parse_page( ...@@ -1120,7 +1120,7 @@ parse_page(
case FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED: case FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED:
page_type.n_fil_page_type_page_compressed_encrypted++; page_type.n_fil_page_type_page_compressed_encrypted++;
if (page_type_dump) { if (file) {
fprintf(file, "#::" UINT32PF "\t\t|\t\tPage compressed encrypted " fprintf(file, "#::" UINT32PF "\t\t|\t\tPage compressed encrypted "
"page\t|\t%s\n", cur_page_num, str); "page\t|\t%s\n", cur_page_num, str);
} }
......
...@@ -14,7 +14,7 @@ CREATE TABLE t6 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB; ...@@ -14,7 +14,7 @@ CREATE TABLE t6 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
# to redo apply the pages of t1.ibd at the time of recovery. # to redo apply the pages of t1.ibd at the time of recovery.
# We want SQL to initiate the first access to t1.ibd. # We want SQL to initiate the first access to t1.ibd.
# Wait until disconnected. # Wait until disconnected.
# Run innochecksum on t1 # Run innochecksum on t1, check -S does not cause crash for encrypted file
# Run innochecksum on t2 # Run innochecksum on t2
# Run innochecksum on t3 # Run innochecksum on t3
# Run innochecksum on t4 # Run innochecksum on t4
......
...@@ -68,9 +68,9 @@ shutdown_server; ...@@ -68,9 +68,9 @@ shutdown_server;
--echo # Wait until disconnected. --echo # Wait until disconnected.
--source include/wait_until_disconnected.inc --source include/wait_until_disconnected.inc
--echo # Run innochecksum on t1
-- disable_result_log -- disable_result_log
--exec $INNOCHECKSUM $t1_IBD --echo # Run innochecksum on t1, check -S does not cause crash for encrypted file
--exec $INNOCHECKSUM -S $t1_IBD
--echo # Run innochecksum on t2 --echo # Run innochecksum on t2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment