From be44b822734abb710cad26a620b6300794834cae Mon Sep 17 00:00:00 2001
From: marko <>
Date: Wed, 9 Aug 2006 08:55:00 +0000
Subject: [PATCH] branches/zip: Improve diagnostics.

buf_LRU_get_free_block(): When zip_size changes, initialize all fields
of page_zip.  This avoids an assertion failure in page_create_zip() when
a block with an originally larger zip_size is reallocated.

fsp_get_space_header(): Assert that the stored space id matches.

xdes_get_state(): Assert that the state is valid.
---
 buf/buf0lru.c | 3 +++
 fsp/fsp0fsp.c | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/buf/buf0lru.c b/buf/buf0lru.c
index 3800f6ff539..9abe4219d34 100644
--- a/buf/buf0lru.c
+++ b/buf/buf0lru.c
@@ -419,6 +419,9 @@ buf_LRU_get_free_block(
 
 		if (block->page_zip.size != zip_size) {
 			block->page_zip.size = zip_size;
+			block->page_zip.n_blobs = 0;
+			block->page_zip.m_start = 0;
+			block->page_zip.m_end = 0;
 			if (block->page_zip.data) {
 				ut_free(block->page_zip.data);
 			}
diff --git a/fsp/fsp0fsp.c b/fsp/fsp0fsp.c
index 5c43b4b5509..cd66a557b1d 100644
--- a/fsp/fsp0fsp.c
+++ b/fsp/fsp0fsp.c
@@ -330,6 +330,7 @@ fsp_get_space_header(
 #ifdef UNIV_SYNC_DEBUG
 	buf_page_dbg_add_level(header, SYNC_FSP_PAGE);
 #endif /* UNIV_SYNC_DEBUG */
+	ut_ad(id == mach_read_from_4(FSP_SPACE_ID + header));
 	return(header);
 }
 
@@ -571,11 +572,15 @@ xdes_get_state(
 	xdes_t*	descr,	/* in: descriptor */
 	mtr_t*	mtr)	/* in: mtr handle */
 {
+	ulint	state;
+
 	ut_ad(descr && mtr);
 	ut_ad(mtr_memo_contains(mtr, buf_block_align(descr),
 							MTR_MEMO_PAGE_X_FIX));
 
-	return(mtr_read_ulint(descr + XDES_STATE, MLOG_4BYTES, mtr));
+	state = mtr_read_ulint(descr + XDES_STATE, MLOG_4BYTES, mtr);
+	ut_ad(state - 1 < XDES_FSEG);
+	return(state);
 }
 
 /**************************************************************************
-- 
2.30.9