List:Commits« Previous MessageNext Message »
From:marko.makela Date:March 21 2011 7:56am
Subject:bzr commit into mysql-5.5-innodb branch (marko.makela:3349) Bug#11766305
View as plain text  
#At file:///home/marko/innobase/dev/mysql2a/5.5-innodb/ based on revid:marko.makela@strippedty03jh6yremg

 3349 Marko Mäkelä	2011-03-21
      Bug#11766305 - 59392: Remove thr0loc.c and ibuf_inside() [part 2]
      Add some const qualifiers to accessor and validator functions.
      
      btr_pcur_get_up_match(), btr_pcur_get_low_match(): Add const qualifiers.
      
      btr_pcur_get_page(), btr_pcur_get_block(), btr_pcur_get_rec(),
      rec_get_start(), rec_get_end(): Define as constness-preserving macros.
      In debug builds, discard the const qualifier.
      
      page_rec_validate(), page_simple_validate_old(), page_simple_validate_new(),
      page_dir_slot_check(), page_validate(): Add const qualifiers.
      
      rb:626 approved by Sunny Bains

    modified:
      storage/innobase/include/btr0pcur.h
      storage/innobase/include/btr0pcur.ic
      storage/innobase/include/page0page.h
      storage/innobase/include/rem0rec.h
      storage/innobase/include/rem0rec.ic
      storage/innobase/page/page0page.c
=== modified file 'storage/innobase/include/btr0pcur.h'
--- a/storage/innobase/include/btr0pcur.h	revid:marko.makela@stripped72758-s31dty03jh6yremg
+++ b/storage/innobase/include/btr0pcur.h	revid:marko.makela@strippedz7g8he5g4qcg
@@ -150,7 +150,7 @@ UNIV_INLINE
 ulint
 btr_pcur_get_up_match(
 /*==================*/
-	btr_pcur_t*	cursor); /*!< in: memory buffer for persistent cursor */
+	const btr_pcur_t*	cursor); /*!< in: persistent cursor */
 /**************************************************************//**
 Gets the low_match value for a pcur after a search.
 @return number of matched fields at the cursor or to the right if
@@ -159,7 +159,7 @@ UNIV_INLINE
 ulint
 btr_pcur_get_low_match(
 /*===================*/
-	btr_pcur_t*	cursor); /*!< in: memory buffer for persistent cursor */
+	const btr_pcur_t*	cursor); /*!< in: persistent cursor */
 /**************************************************************//**
 If mode is PAGE_CUR_G or PAGE_CUR_GE, opens a persistent cursor on the first
 user record satisfying the search condition, in the case PAGE_CUR_L or
@@ -371,10 +371,6 @@ page_cur_t*
 btr_pcur_get_page_cur(
 /*==================*/
 	const btr_pcur_t*	cursor);	/*!< in: persistent cursor */
-#else /* UNIV_DEBUG */
-# define btr_pcur_get_btr_cur(cursor) (&(cursor)->btr_cur)
-# define btr_pcur_get_page_cur(cursor) (&(cursor)->btr_cur.page_cur)
-#endif /* UNIV_DEBUG */
 /*********************************************************//**
 Returns the page of a persistent cursor.
 @return	pointer to the page */
@@ -382,7 +378,7 @@ UNIV_INLINE
 page_t*
 btr_pcur_get_page(
 /*==============*/
-	btr_pcur_t*	cursor);/*!< in: persistent cursor */
+	const btr_pcur_t*	cursor);/*!< in: persistent cursor */
 /*********************************************************//**
 Returns the buffer block of a persistent cursor.
 @return	pointer to the block */
@@ -390,7 +386,7 @@ UNIV_INLINE
 buf_block_t*
 btr_pcur_get_block(
 /*===============*/
-	btr_pcur_t*	cursor);/*!< in: persistent cursor */
+	const btr_pcur_t*	cursor);/*!< in: persistent cursor */
 /*********************************************************//**
 Returns the record of a persistent cursor.
 @return	pointer to the record */
@@ -398,7 +394,14 @@ UNIV_INLINE
 rec_t*
 btr_pcur_get_rec(
 /*=============*/
-	btr_pcur_t*	cursor);/*!< in: persistent cursor */
+	const btr_pcur_t*	cursor);/*!< in: persistent cursor */
+#else /* UNIV_DEBUG */
+# define btr_pcur_get_btr_cur(cursor) (&(cursor)->btr_cur)
+# define btr_pcur_get_page_cur(cursor) (&(cursor)->btr_cur.page_cur)
+# define btr_pcur_get_page(cursor) ((cursor)->btr_cur.page_cur.block->frame)
+# define btr_pcur_get_block(cursor) ((cursor)->btr_cur.page_cur.block)
+# define btr_pcur_get_rec(cursor) ((cursor)->btr_cur.page_cur.rec)
+#endif /* UNIV_DEBUG */
 /*********************************************************//**
 Checks if the persistent cursor is on a user record. */
 UNIV_INLINE

=== modified file 'storage/innobase/include/btr0pcur.ic'
--- a/storage/innobase/include/btr0pcur.ic	revid:marko.makela@stripped1072758-s31dty03jh6yremg
+++ b/storage/innobase/include/btr0pcur.ic	revid:marko.makela@stripped4i8z7g8he5g4qcg
@@ -67,7 +67,7 @@ btr_pcur_get_page_cur(
 {
 	return(btr_cur_get_page_cur(btr_pcur_get_btr_cur(cursor)));
 }
-#endif /* UNIV_DEBUG */
+
 /*********************************************************//**
 Returns the page of a persistent cursor.
 @return	pointer to the page */
@@ -75,7 +75,7 @@ UNIV_INLINE
 page_t*
 btr_pcur_get_page(
 /*==============*/
-	btr_pcur_t*	cursor)	/*!< in: persistent cursor */
+	const btr_pcur_t*	cursor)	/*!< in: persistent cursor */
 {
 	ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
 
@@ -89,7 +89,7 @@ UNIV_INLINE
 buf_block_t*
 btr_pcur_get_block(
 /*===============*/
-	btr_pcur_t*	cursor)	/*!< in: persistent cursor */
+	const btr_pcur_t*	cursor)	/*!< in: persistent cursor */
 {
 	ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
 
@@ -103,13 +103,14 @@ UNIV_INLINE
 rec_t*
 btr_pcur_get_rec(
 /*=============*/
-	btr_pcur_t*	cursor)	/*!< in: persistent cursor */
+	const btr_pcur_t*	cursor)	/*!< in: persistent cursor */
 {
 	ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
 	ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
 
 	return(btr_cur_get_rec(btr_pcur_get_btr_cur(cursor)));
 }
+#endif /* UNIV_DEBUG */
 
 /**************************************************************//**
 Gets the up_match value for a pcur after a search.
@@ -119,9 +120,9 @@ UNIV_INLINE
 ulint
 btr_pcur_get_up_match(
 /*==================*/
-	btr_pcur_t*	cursor) /*!< in: memory buffer for persistent cursor */
+	const btr_pcur_t*	cursor) /*!< in: persistent cursor */
 {
-	btr_cur_t*	btr_cursor;
+	const btr_cur_t*	btr_cursor;
 
 	ut_ad((cursor->pos_state == BTR_PCUR_WAS_POSITIONED)
 	      || (cursor->pos_state == BTR_PCUR_IS_POSITIONED));
@@ -141,9 +142,9 @@ UNIV_INLINE
 ulint
 btr_pcur_get_low_match(
 /*===================*/
-	btr_pcur_t*	cursor) /*!< in: memory buffer for persistent cursor */
+	const btr_pcur_t*	cursor) /*!< in: persistent cursor */
 {
-	btr_cur_t*	btr_cursor;
+	const btr_cur_t*	btr_cursor;
 
 	ut_ad((cursor->pos_state == BTR_PCUR_WAS_POSITIONED)
 	      || (cursor->pos_state == BTR_PCUR_IS_POSITIONED));

=== modified file 'storage/innobase/include/page0page.h'
--- a/storage/innobase/include/page0page.h	revid:marko.makela@stripped8-s31dty03jh6yremg
+++ b/storage/innobase/include/page0page.h	revid:marko.makela@stripped8he5g4qcg
@@ -952,7 +952,7 @@ UNIV_INTERN
 ibool
 page_rec_validate(
 /*==============*/
-	rec_t*		rec,	/*!< in: physical record */
+	const rec_t*	rec,	/*!< in: physical record */
 	const ulint*	offsets);/*!< in: array returned by rec_get_offsets() */
 /***************************************************************//**
 Checks that the first directory slot points to the infimum record and
@@ -972,7 +972,7 @@ UNIV_INTERN
 ibool
 page_simple_validate_old(
 /*=====================*/
-	page_t*	page);	/*!< in: old-style index page */
+	const page_t*	page);	/*!< in: index page in ROW_FORMAT=REDUNDANT */
 /***************************************************************//**
 This function checks the consistency of an index page when we do not
 know the index. This is also resilient so that this should never crash
@@ -982,7 +982,7 @@ UNIV_INTERN
 ibool
 page_simple_validate_new(
 /*=====================*/
-	page_t*	block);	/*!< in: new-style index page */
+	const page_t*	page);	/*!< in: index page in ROW_FORMAT!=REDUNDANT */
 /***************************************************************//**
 This function checks the consistency of an index page.
 @return	TRUE if ok */
@@ -990,7 +990,7 @@ UNIV_INTERN
 ibool
 page_validate(
 /*==========*/
-	page_t*		page,	/*!< in: index page */
+	const page_t*	page,	/*!< in: index page */
 	dict_index_t*	index);	/*!< in: data dictionary index containing
 				the page record type definition */
 /***************************************************************//**

=== modified file 'storage/innobase/include/rem0rec.h'
--- a/storage/innobase/include/rem0rec.h	revid:marko.makela@stripped58-s31dty03jh6yremg
+++ b/storage/innobase/include/rem0rec.h	revid:marko.makela@strippedhe5g4qcg
@@ -600,6 +600,7 @@ ulint
 rec_offs_size(
 /*==========*/
 	const ulint*	offsets);/*!< in: array returned by rec_get_offsets() */
+#ifdef UNIV_DEBUG
 /**********************************************************//**
 Returns a pointer to the start of the record.
 @return	pointer to start */
@@ -607,7 +608,7 @@ UNIV_INLINE
 byte*
 rec_get_start(
 /*==========*/
-	rec_t*		rec,	/*!< in: pointer to record */
+	const rec_t*	rec,	/*!< in: pointer to record */
 	const ulint*	offsets);/*!< in: array returned by rec_get_offsets() */
 /**********************************************************//**
 Returns a pointer to the end of the record.
@@ -616,8 +617,12 @@ UNIV_INLINE
 byte*
 rec_get_end(
 /*========*/
-	rec_t*		rec,	/*!< in: pointer to record */
+	const rec_t*	rec,	/*!< in: pointer to record */
 	const ulint*	offsets);/*!< in: array returned by rec_get_offsets() */
+#else /* UNIV_DEBUG */
+# define rec_get_start(rec, offsets) ((rec) - rec_offs_extra_size(offsets))
+# define rec_get_end(rec, offsets) ((rec) + rec_offs_data_size(offsets))
+#endif /* UNIV_DEBUG */
 /***************************************************************//**
 Copies a physical record to a buffer.
 @return	pointer to the origin of the copy */

=== modified file 'storage/innobase/include/rem0rec.ic'
--- a/storage/innobase/include/rem0rec.ic	revid:marko.makela@stripped110321072758-s31dty03jh6yremg
+++ b/storage/innobase/include/rem0rec.ic	revid:marko.makela@stripped38-u4i8z7g8he5g4qcg
@@ -1462,6 +1462,7 @@ rec_offs_size(
 	return(rec_offs_data_size(offsets) + rec_offs_extra_size(offsets));
 }
 
+#ifdef UNIV_DEBUG
 /**********************************************************//**
 Returns a pointer to the end of the record.
 @return	pointer to end */
@@ -1469,11 +1470,11 @@ UNIV_INLINE
 byte*
 rec_get_end(
 /*========*/
-	rec_t*		rec,	/*!< in: pointer to record */
+	const rec_t*	rec,	/*!< in: pointer to record */
 	const ulint*	offsets)/*!< in: array returned by rec_get_offsets() */
 {
 	ut_ad(rec_offs_validate(rec, NULL, offsets));
-	return(rec + rec_offs_data_size(offsets));
+	return((rec_t*) rec + rec_offs_data_size(offsets));
 }
 
 /**********************************************************//**
@@ -1483,12 +1484,13 @@ UNIV_INLINE
 byte*
 rec_get_start(
 /*==========*/
-	rec_t*		rec,	/*!< in: pointer to record */
+	const rec_t*	rec,	/*!< in: pointer to record */
 	const ulint*	offsets)/*!< in: array returned by rec_get_offsets() */
 {
 	ut_ad(rec_offs_validate(rec, NULL, offsets));
-	return(rec - rec_offs_extra_size(offsets));
+	return((rec_t*) rec - rec_offs_extra_size(offsets));
 }
+#endif /* UNIV_DEBUG */
 
 /***************************************************************//**
 Copies a physical record to a buffer.

=== modified file 'storage/innobase/page/page0page.c'
--- a/storage/innobase/page/page0page.c	revid:marko.makela@strippedjh6yremg
+++ b/storage/innobase/page/page0page.c	revid:marko.makela@stripped
@@ -166,11 +166,11 @@ static
 ibool
 page_dir_slot_check(
 /*================*/
-	page_dir_slot_t*	slot)	/*!< in: slot */
+	const page_dir_slot_t*	slot)	/*!< in: slot */
 {
-	page_t*	page;
-	ulint	n_slots;
-	ulint	n_owned;
+	const page_t*	page;
+	ulint		n_slots;
+	ulint		n_owned;
 
 	ut_a(slot);
 
@@ -1803,12 +1803,12 @@ UNIV_INTERN
 ibool
 page_rec_validate(
 /*==============*/
-	rec_t*		rec,	/*!< in: physical record */
+	const rec_t*	rec,	/*!< in: physical record */
 	const ulint*	offsets)/*!< in: array returned by rec_get_offsets() */
 {
-	ulint	n_owned;
-	ulint	heap_no;
-	page_t*	page;
+	ulint		n_owned;
+	ulint		heap_no;
+	const page_t*	page;
 
 	page = page_align(rec);
 	ut_a(!page_is_comp(page) == !rec_offs_comp(offsets));
@@ -1889,16 +1889,16 @@ UNIV_INTERN
 ibool
 page_simple_validate_old(
 /*=====================*/
-	page_t*	page)	/*!< in: old-style index page */
+	const page_t*	page)	/*!< in: index page in ROW_FORMAT=REDUNDANT */
 {
-	page_dir_slot_t* slot;
-	ulint		slot_no;
-	ulint		n_slots;
-	rec_t*		rec;
-	byte*		rec_heap_top;
-	ulint		count;
-	ulint		own_count;
-	ibool		ret	= FALSE;
+	const page_dir_slot_t*	slot;
+	ulint			slot_no;
+	ulint			n_slots;
+	const rec_t*		rec;
+	const byte*		rec_heap_top;
+	ulint			count;
+	ulint			own_count;
+	ibool			ret	= FALSE;
 
 	ut_a(!page_is_comp(page));
 
@@ -2011,7 +2011,7 @@ page_simple_validate_old(
 			goto func_exit;
 		}
 
-		rec = page_rec_get_next(rec);
+		rec = page_rec_get_next_const(rec);
 		own_count++;
 	}
 
@@ -2072,7 +2072,7 @@ page_simple_validate_old(
 			goto func_exit;
 		}
 
-		rec = page_rec_get_next(rec);
+		rec = page_rec_get_next_const(rec);
 	}
 
 	if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) {
@@ -2099,16 +2099,16 @@ UNIV_INTERN
 ibool
 page_simple_validate_new(
 /*=====================*/
-	page_t*	page)	/*!< in: new-style index page */
+	const page_t*	page)	/*!< in: index page in ROW_FORMAT!=REDUNDANT */
 {
-	page_dir_slot_t* slot;
-	ulint		slot_no;
-	ulint		n_slots;
-	rec_t*		rec;
-	byte*		rec_heap_top;
-	ulint		count;
-	ulint		own_count;
-	ibool		ret	= FALSE;
+	const page_dir_slot_t*	slot;
+	ulint			slot_no;
+	ulint			n_slots;
+	const rec_t*		rec;
+	const byte*		rec_heap_top;
+	ulint			count;
+	ulint			own_count;
+	ibool			ret	= FALSE;
 
 	ut_a(page_is_comp(page));
 
@@ -2221,7 +2221,7 @@ page_simple_validate_new(
 			goto func_exit;
 		}
 
-		rec = page_rec_get_next(rec);
+		rec = page_rec_get_next_const(rec);
 		own_count++;
 	}
 
@@ -2283,7 +2283,7 @@ page_simple_validate_new(
 			goto func_exit;
 		}
 
-		rec = page_rec_get_next(rec);
+		rec = page_rec_get_next_const(rec);
 	}
 
 	if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) {
@@ -2308,26 +2308,26 @@ UNIV_INTERN
 ibool
 page_validate(
 /*==========*/
-	page_t*		page,	/*!< in: index page */
+	const page_t*	page,	/*!< in: index page */
 	dict_index_t*	index)	/*!< in: data dictionary index containing
 				the page record type definition */
 {
-	page_dir_slot_t*slot;
-	mem_heap_t*	heap;
-	byte*		buf;
-	ulint		count;
-	ulint		own_count;
-	ulint		rec_own_count;
-	ulint		slot_no;
-	ulint		data_size;
-	rec_t*		rec;
-	rec_t*		old_rec		= NULL;
-	ulint		offs;
-	ulint		n_slots;
-	ibool		ret		= FALSE;
-	ulint		i;
-	ulint*		offsets		= NULL;
-	ulint*		old_offsets	= NULL;
+	const page_dir_slot_t*	slot;
+	mem_heap_t*		heap;
+	byte*			buf;
+	ulint			count;
+	ulint			own_count;
+	ulint			rec_own_count;
+	ulint			slot_no;
+	ulint			data_size;
+	const rec_t*		rec;
+	const rec_t*		old_rec		= NULL;
+	ulint			offs;
+	ulint			n_slots;
+	ibool			ret		= FALSE;
+	ulint			i;
+	ulint*			offsets		= NULL;
+	ulint*			old_offsets	= NULL;
 
 	if (UNIV_UNLIKELY((ibool) !!page_is_comp(page)
 			  != dict_table_is_comp(index->table))) {
@@ -2482,7 +2482,7 @@ page_validate(
 		count++;
 		own_count++;
 		old_rec = rec;
-		rec = page_rec_get_next(rec);
+		rec = page_rec_get_next_const(rec);
 
 		/* set old_offsets to offsets; recycle offsets */
 		{
@@ -2556,7 +2556,7 @@ n_owned_zero:
 			buf[offs + i] = 1;
 		}
 
-		rec = page_rec_get_next(rec);
+		rec = page_rec_get_next_const(rec);
 	}
 
 	if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) {

Attachment: [text/bzr-bundle] bzr/marko.makela@oracle.com-20110321075638-u4i8z7g8he5g4qcg.bundle
Thread
bzr commit into mysql-5.5-innodb branch (marko.makela:3349) Bug#11766305marko.makela21 Mar