Commit d4e8116b authored by marko's avatar marko

Set FIL_PAGE_TYPE for every page, so that the field can be relied on in

new tablespaces created from now on.

btr_store_big_rec_extern_fields(): Set FIL_PAGE_TYPE to FIL_PAGE_TYPE_BLOB.

buf_page_print(): Decode FIL_PAGE_TYPE.  Replace if-else with switch().

buf_page_create(): Set FIL_PAGE_PREV, FIL_PAGE_NEXT and FIL_PAGE_TYPE.

trx_sysf_create(): Set FIL_PAGE_TYPE to FIL_PAGE_TYPE_TRX_SYS.
Initialize TRX_SYS_RSEG_SPACE.

FIL_PAGE_TYPE: Document that the field cannot be relied on in older
versions of MySQL/InnoDB.  Add new type codes.

ibuf_bitmap_page_init(): Document that the rest of the page is uninitialized.

ibuf_add_free_page(): Log the setting of FIL_PAGE_TYPE.

fsp_header_init(): Set FIL_PAGE_TYPE to FIL_PAGE_TYPE_FSP_HDR.
Initialize FSP_NOT_USED.

fsp_fill_free_list(): Set FIL_PAGE_TYPE to FIL_PAGE_TYPE_XDES.

fsp_alloc_seg_inode_page(): Set FIL_PAGE_TYPE to FIL_PAGE_INODE.

fseg_create_general(): Set FIL_PAGE_TYPE to FIL_PAGE_TYPE_SYS.
parent 73d3dd79
......@@ -3392,6 +3392,9 @@ btr_store_big_rec_extern_fields(
return(DB_OUT_OF_FILE_SPACE);
}
mlog_write_ulint(page + FIL_PAGE_TYPE,
FIL_PAGE_TYPE_BLOB, MLOG_2BYTES, &mtr);
page_no = buf_frame_get_page_no(page);
if (prev_page_no != FIL_NULL) {
......
......@@ -427,7 +427,8 @@ buf_page_print(
"InnoDB: Page may be an update undo log page\n");
}
if (fil_page_get_type(read_buf) == FIL_PAGE_INDEX) {
switch (fil_page_get_type(read_buf)) {
case FIL_PAGE_INDEX:
fprintf(stderr,
"InnoDB: Page may be an index page where index id is %lu %lu\n",
(ulong) ut_dulint_get_high(btr_page_get_index_id(read_buf)),
......@@ -446,11 +447,42 @@ buf_page_print(
fputs(")\n", stderr);
}
}
} else if (fil_page_get_type(read_buf) == FIL_PAGE_INODE) {
break;
case FIL_PAGE_INODE:
fputs("InnoDB: Page may be an 'inode' page\n", stderr);
} else if (fil_page_get_type(read_buf) == FIL_PAGE_IBUF_FREE_LIST) {
break;
case FIL_PAGE_IBUF_FREE_LIST:
fputs("InnoDB: Page may be an insert buffer free list page\n",
stderr);
break;
case FIL_PAGE_TYPE_ALLOCATED:
fputs("InnoDB: Page may be a freshly allocated page\n",
stderr);
break;
case FIL_PAGE_IBUF_BITMAP:
fputs("InnoDB: Page may be an insert buffer bitmap page\n",
stderr);
break;
case FIL_PAGE_TYPE_SYS:
fputs("InnoDB: Page may be a system page\n",
stderr);
break;
case FIL_PAGE_TYPE_TRX_SYS:
fputs("InnoDB: Page may be a transaction system page\n",
stderr);
break;
case FIL_PAGE_TYPE_FSP_HDR:
fputs("InnoDB: Page may be a file space header page\n",
stderr);
break;
case FIL_PAGE_TYPE_XDES:
fputs("InnoDB: Page may be an extent descriptor page\n",
stderr);
break;
case FIL_PAGE_TYPE_BLOB:
fputs("InnoDB: Page may be a BLOB page\n",
stderr);
break;
}
}
......@@ -1784,6 +1816,10 @@ buf_page_create(
frame = block->frame;
memset(frame + FIL_PAGE_PREV, 0xff, 4);
memset(frame + FIL_PAGE_NEXT, 0xff, 4);
mach_write_to_2(frame + FIL_PAGE_TYPE, FIL_PAGE_TYPE_ALLOCATED);
/* Reset to zero the file flush lsn field in the page; if the first
page of an ibdata file is 'created' in this function into the buffer
pool then we lose the original contents of the file flush lsn stamp.
......
......@@ -893,9 +893,13 @@ fsp_header_init(
fsp_init_file_page(page, mtr);
mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_TYPE_FSP_HDR,
MLOG_2BYTES, mtr);
header = FSP_HEADER_OFFSET + page;
mlog_write_ulint(header + FSP_SPACE_ID, space, MLOG_4BYTES, mtr);
mlog_write_ulint(header + FSP_NOT_USED, 0, MLOG_4BYTES, mtr);
mlog_write_ulint(header + FSP_SIZE, size, MLOG_4BYTES, mtr);
mlog_write_ulint(header + FSP_FREE_LIMIT, 0, MLOG_4BYTES, mtr);
......@@ -1254,6 +1258,8 @@ fsp_fill_free_list(
SYNC_FSP_PAGE);
#endif /* UNIV_SYNC_DEBUG */
fsp_init_file_page(descr_page, mtr);
mlog_write_ulint(descr_page + FIL_PAGE_TYPE,
FIL_PAGE_TYPE_XDES, MLOG_2BYTES, mtr);
}
/* Initialize the ibuf bitmap page in a separate
......@@ -1720,7 +1726,8 @@ fsp_alloc_seg_inode_page(
buf_block_align(page)->check_index_page_at_flush = FALSE;
fil_page_set_type(page, FIL_PAGE_INODE);
mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_INODE,
MLOG_2BYTES, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_FSP_PAGE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -2091,6 +2098,8 @@ fseg_create_general(
header = byte_offset
+ buf_page_get(space, page, RW_X_LATCH, mtr);
mlog_write_ulint(header - byte_offset + FIL_PAGE_TYPE,
FIL_PAGE_TYPE_SYS, MLOG_2BYTES, mtr);
}
mlog_write_ulint(header + FSEG_HDR_OFFSET,
......
......@@ -574,18 +574,18 @@ ibuf_bitmap_page_init(
{
ulint bit_offset;
ulint byte_offset;
ulint i;
/* Write all zeros to the bitmap */
bit_offset = XDES_DESCRIBED_PER_PAGE * IBUF_BITS_PER_PAGE;
byte_offset = bit_offset / 8 + 1;
byte_offset = bit_offset / 8 + 1; /* better: (bit_offset + 7) / 8 */
for (i = IBUF_BITMAP; i < IBUF_BITMAP + byte_offset; i++) {
fil_page_set_type(page, FIL_PAGE_IBUF_BITMAP);
*(page + i) = (byte)0;
}
memset(page + IBUF_BITMAP, 0, byte_offset);
/* The remaining area (up to the page trailer) is uninitialized. */
mlog_write_initial_log_record(page, MLOG_IBUF_BITMAP_INIT, mtr);
}
......@@ -1680,7 +1680,8 @@ ibuf_add_free_page(
flst_add_last(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr);
fil_page_set_type(page, FIL_PAGE_IBUF_FREE_LIST);
mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_IBUF_FREE_LIST,
MLOG_2BYTES, &mtr);
ibuf_data->seg_size++;
ibuf_data->free_list_len++;
......
......@@ -63,7 +63,20 @@ extern fil_addr_t fil_addr_null;
#define FIL_PAGE_LSN 16 /* lsn of the end of the newest
modification log record to the page */
#define FIL_PAGE_TYPE 24 /* file page type: FIL_PAGE_INDEX,...,
2 bytes */
2 bytes.
The contents of this field can only
be trusted in the following case:
if the page is an uncompressed
B-tree index page, then it is
guaranteed that the value is
FIL_PAGE_INDEX.
The opposite does not hold.
In tablespaces created by
MySQL/InnoDB 5.1.19 or later, the
contents of this field is valid
for all uncompressed pages. */
#define FIL_PAGE_FILE_FLUSH_LSN 26 /* this is only defined for the
first page in a data file: the file
has been flushed to disk at least up
......@@ -79,11 +92,19 @@ extern fil_addr_t fil_addr_null;
to the last 4 bytes of FIL_PAGE_LSN */
#define FIL_PAGE_DATA_END 8
/* File page types */
#define FIL_PAGE_INDEX 17855
#define FIL_PAGE_UNDO_LOG 2
#define FIL_PAGE_INODE 3
#define FIL_PAGE_IBUF_FREE_LIST 4
/* File page types (values of FIL_PAGE_TYPE) */
#define FIL_PAGE_INDEX 17855 /* B-tree node */
#define FIL_PAGE_UNDO_LOG 2 /* Undo log page */
#define FIL_PAGE_INODE 3 /* Index node */
#define FIL_PAGE_IBUF_FREE_LIST 4 /* Insert buffer free list */
/* File page types introduced in MySQL/InnoDB 5.1.19 */
#define FIL_PAGE_TYPE_ALLOCATED 0 /* Freshly allocated page */
#define FIL_PAGE_IBUF_BITMAP 5 /* Insert buffer bitmap */
#define FIL_PAGE_TYPE_SYS 6 /* System page */
#define FIL_PAGE_TYPE_TRX_SYS 7 /* Transaction system data */
#define FIL_PAGE_TYPE_FSP_HDR 8 /* File space header */
#define FIL_PAGE_TYPE_XDES 9 /* Extent descriptor page */
#define FIL_PAGE_TYPE_BLOB 10 /* Uncompressed BLOB page */
/* Space types */
#define FIL_TABLESPACE 501
......
......@@ -16,7 +16,9 @@ typedef byte trx_sysf_rseg_t;
/* Rollback segment specification slot offsets */
/*-------------------------------------------------------------*/
#define TRX_SYS_RSEG_SPACE 0 /* space where the the segment
header is placed */
header is placed; starting with
MySQL/InnoDB 5.1.19, this is
UNIV_UNDEFINED if the slot is unused */
#define TRX_SYS_RSEG_PAGE_NO 4 /* page number where the the segment
header is placed; this is FIL_NULL
if the slot is unused */
......
......@@ -819,6 +819,9 @@ trx_sysf_create(
buf_page_dbg_add_level(page, SYNC_TRX_SYS_HEADER);
#endif /* UNIV_SYNC_DEBUG */
mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_TYPE_TRX_SYS,
MLOG_2BYTES, mtr);
sys_header = trx_sysf_get(mtr);
/* Start counting transaction ids from number 1 up */
......@@ -828,9 +831,12 @@ trx_sysf_create(
/* Reset the rollback segment slots */
for (i = 0; i < TRX_SYS_N_RSEGS; i++) {
trx_sysf_rseg_set_space(sys_header, i, ULINT_UNDEFINED, mtr);
trx_sysf_rseg_set_page_no(sys_header, i, FIL_NULL, mtr);
}
/* The remaining area (up to the page trailer) is uninitialized. */
/* Create the first rollback segment in the SYSTEM tablespace */
page_no = trx_rseg_header_create(TRX_SYS_SPACE, ULINT_MAX, &slot_no,
mtr);
......
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