Commit 72ec03c2 authored by Marko Mäkelä's avatar Marko Mäkelä

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
parent 30a28cfb
...@@ -150,7 +150,7 @@ UNIV_INLINE ...@@ -150,7 +150,7 @@ UNIV_INLINE
ulint ulint
btr_pcur_get_up_match( 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. Gets the low_match value for a pcur after a search.
@return number of matched fields at the cursor or to the right if @return number of matched fields at the cursor or to the right if
...@@ -159,7 +159,7 @@ UNIV_INLINE ...@@ -159,7 +159,7 @@ UNIV_INLINE
ulint ulint
btr_pcur_get_low_match( 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 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 user record satisfying the search condition, in the case PAGE_CUR_L or
...@@ -371,10 +371,6 @@ page_cur_t* ...@@ -371,10 +371,6 @@ page_cur_t*
btr_pcur_get_page_cur( btr_pcur_get_page_cur(
/*==================*/ /*==================*/
const 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)
#endif /* UNIV_DEBUG */
/*********************************************************//** /*********************************************************//**
Returns the page of a persistent cursor. Returns the page of a persistent cursor.
@return pointer to the page */ @return pointer to the page */
...@@ -382,7 +378,7 @@ UNIV_INLINE ...@@ -382,7 +378,7 @@ UNIV_INLINE
page_t* page_t*
btr_pcur_get_page( 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. Returns the buffer block of a persistent cursor.
@return pointer to the block */ @return pointer to the block */
...@@ -390,7 +386,7 @@ UNIV_INLINE ...@@ -390,7 +386,7 @@ UNIV_INLINE
buf_block_t* buf_block_t*
btr_pcur_get_block( 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. Returns the record of a persistent cursor.
@return pointer to the record */ @return pointer to the record */
...@@ -398,7 +394,14 @@ UNIV_INLINE ...@@ -398,7 +394,14 @@ UNIV_INLINE
rec_t* rec_t*
btr_pcur_get_rec( 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. */ Checks if the persistent cursor is on a user record. */
UNIV_INLINE UNIV_INLINE
......
...@@ -67,7 +67,7 @@ btr_pcur_get_page_cur( ...@@ -67,7 +67,7 @@ btr_pcur_get_page_cur(
{ {
return(btr_cur_get_page_cur(btr_pcur_get_btr_cur(cursor))); return(btr_cur_get_page_cur(btr_pcur_get_btr_cur(cursor)));
} }
#endif /* UNIV_DEBUG */
/*********************************************************//** /*********************************************************//**
Returns the page of a persistent cursor. Returns the page of a persistent cursor.
@return pointer to the page */ @return pointer to the page */
...@@ -75,7 +75,7 @@ UNIV_INLINE ...@@ -75,7 +75,7 @@ UNIV_INLINE
page_t* page_t*
btr_pcur_get_page( 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); ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
...@@ -89,7 +89,7 @@ UNIV_INLINE ...@@ -89,7 +89,7 @@ UNIV_INLINE
buf_block_t* buf_block_t*
btr_pcur_get_block( 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); ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
...@@ -103,13 +103,14 @@ UNIV_INLINE ...@@ -103,13 +103,14 @@ UNIV_INLINE
rec_t* rec_t*
btr_pcur_get_rec( 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->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
return(btr_cur_get_rec(btr_pcur_get_btr_cur(cursor))); 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. Gets the up_match value for a pcur after a search.
...@@ -119,9 +120,9 @@ UNIV_INLINE ...@@ -119,9 +120,9 @@ UNIV_INLINE
ulint ulint
btr_pcur_get_up_match( 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) ut_ad((cursor->pos_state == BTR_PCUR_WAS_POSITIONED)
|| (cursor->pos_state == BTR_PCUR_IS_POSITIONED)); || (cursor->pos_state == BTR_PCUR_IS_POSITIONED));
...@@ -141,9 +142,9 @@ UNIV_INLINE ...@@ -141,9 +142,9 @@ UNIV_INLINE
ulint ulint
btr_pcur_get_low_match( 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) ut_ad((cursor->pos_state == BTR_PCUR_WAS_POSITIONED)
|| (cursor->pos_state == BTR_PCUR_IS_POSITIONED)); || (cursor->pos_state == BTR_PCUR_IS_POSITIONED));
......
...@@ -952,7 +952,7 @@ UNIV_INTERN ...@@ -952,7 +952,7 @@ UNIV_INTERN
ibool ibool
page_rec_validate( 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() */ const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
/***************************************************************//** /***************************************************************//**
Checks that the first directory slot points to the infimum record and Checks that the first directory slot points to the infimum record and
...@@ -972,7 +972,7 @@ UNIV_INTERN ...@@ -972,7 +972,7 @@ UNIV_INTERN
ibool ibool
page_simple_validate_old( 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 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 know the index. This is also resilient so that this should never crash
...@@ -982,7 +982,7 @@ UNIV_INTERN ...@@ -982,7 +982,7 @@ UNIV_INTERN
ibool ibool
page_simple_validate_new( 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. This function checks the consistency of an index page.
@return TRUE if ok */ @return TRUE if ok */
...@@ -990,7 +990,7 @@ UNIV_INTERN ...@@ -990,7 +990,7 @@ UNIV_INTERN
ibool ibool
page_validate( page_validate(
/*==========*/ /*==========*/
page_t* page, /*!< in: index page */ const page_t* page, /*!< in: index page */
dict_index_t* index); /*!< in: data dictionary index containing dict_index_t* index); /*!< in: data dictionary index containing
the page record type definition */ the page record type definition */
/***************************************************************//** /***************************************************************//**
......
...@@ -600,6 +600,7 @@ ulint ...@@ -600,6 +600,7 @@ ulint
rec_offs_size( rec_offs_size(
/*==========*/ /*==========*/
const ulint* offsets);/*!< in: array returned by rec_get_offsets() */ const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
#ifdef UNIV_DEBUG
/**********************************************************//** /**********************************************************//**
Returns a pointer to the start of the record. Returns a pointer to the start of the record.
@return pointer to start */ @return pointer to start */
...@@ -607,7 +608,7 @@ UNIV_INLINE ...@@ -607,7 +608,7 @@ UNIV_INLINE
byte* byte*
rec_get_start( 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() */ const ulint* offsets);/*!< in: array returned by rec_get_offsets() */
/**********************************************************//** /**********************************************************//**
Returns a pointer to the end of the record. Returns a pointer to the end of the record.
...@@ -616,8 +617,12 @@ UNIV_INLINE ...@@ -616,8 +617,12 @@ UNIV_INLINE
byte* byte*
rec_get_end( 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() */ 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. Copies a physical record to a buffer.
@return pointer to the origin of the copy */ @return pointer to the origin of the copy */
......
...@@ -1462,6 +1462,7 @@ rec_offs_size( ...@@ -1462,6 +1462,7 @@ rec_offs_size(
return(rec_offs_data_size(offsets) + rec_offs_extra_size(offsets)); return(rec_offs_data_size(offsets) + rec_offs_extra_size(offsets));
} }
#ifdef UNIV_DEBUG
/**********************************************************//** /**********************************************************//**
Returns a pointer to the end of the record. Returns a pointer to the end of the record.
@return pointer to end */ @return pointer to end */
...@@ -1469,11 +1470,11 @@ UNIV_INLINE ...@@ -1469,11 +1470,11 @@ UNIV_INLINE
byte* byte*
rec_get_end( 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() */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
{ {
ut_ad(rec_offs_validate(rec, NULL, 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 ...@@ -1483,12 +1484,13 @@ UNIV_INLINE
byte* byte*
rec_get_start( 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() */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
{ {
ut_ad(rec_offs_validate(rec, NULL, 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. Copies a physical record to a buffer.
......
...@@ -166,11 +166,11 @@ static ...@@ -166,11 +166,11 @@ static
ibool ibool
page_dir_slot_check( page_dir_slot_check(
/*================*/ /*================*/
page_dir_slot_t* slot) /*!< in: slot */ const page_dir_slot_t* slot) /*!< in: slot */
{ {
page_t* page; const page_t* page;
ulint n_slots; ulint n_slots;
ulint n_owned; ulint n_owned;
ut_a(slot); ut_a(slot);
...@@ -1803,12 +1803,12 @@ UNIV_INTERN ...@@ -1803,12 +1803,12 @@ UNIV_INTERN
ibool ibool
page_rec_validate( 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() */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
{ {
ulint n_owned; ulint n_owned;
ulint heap_no; ulint heap_no;
page_t* page; const page_t* page;
page = page_align(rec); page = page_align(rec);
ut_a(!page_is_comp(page) == !rec_offs_comp(offsets)); ut_a(!page_is_comp(page) == !rec_offs_comp(offsets));
...@@ -1889,16 +1889,16 @@ UNIV_INTERN ...@@ -1889,16 +1889,16 @@ UNIV_INTERN
ibool ibool
page_simple_validate_old( 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; const page_dir_slot_t* slot;
ulint slot_no; ulint slot_no;
ulint n_slots; ulint n_slots;
rec_t* rec; const rec_t* rec;
byte* rec_heap_top; const byte* rec_heap_top;
ulint count; ulint count;
ulint own_count; ulint own_count;
ibool ret = FALSE; ibool ret = FALSE;
ut_a(!page_is_comp(page)); ut_a(!page_is_comp(page));
...@@ -2011,7 +2011,7 @@ page_simple_validate_old( ...@@ -2011,7 +2011,7 @@ page_simple_validate_old(
goto func_exit; goto func_exit;
} }
rec = page_rec_get_next(rec); rec = page_rec_get_next_const(rec);
own_count++; own_count++;
} }
...@@ -2072,7 +2072,7 @@ page_simple_validate_old( ...@@ -2072,7 +2072,7 @@ page_simple_validate_old(
goto func_exit; 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)) { if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) {
...@@ -2099,16 +2099,16 @@ UNIV_INTERN ...@@ -2099,16 +2099,16 @@ UNIV_INTERN
ibool ibool
page_simple_validate_new( 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; const page_dir_slot_t* slot;
ulint slot_no; ulint slot_no;
ulint n_slots; ulint n_slots;
rec_t* rec; const rec_t* rec;
byte* rec_heap_top; const byte* rec_heap_top;
ulint count; ulint count;
ulint own_count; ulint own_count;
ibool ret = FALSE; ibool ret = FALSE;
ut_a(page_is_comp(page)); ut_a(page_is_comp(page));
...@@ -2221,7 +2221,7 @@ page_simple_validate_new( ...@@ -2221,7 +2221,7 @@ page_simple_validate_new(
goto func_exit; goto func_exit;
} }
rec = page_rec_get_next(rec); rec = page_rec_get_next_const(rec);
own_count++; own_count++;
} }
...@@ -2283,7 +2283,7 @@ page_simple_validate_new( ...@@ -2283,7 +2283,7 @@ page_simple_validate_new(
goto func_exit; 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)) { if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) {
...@@ -2308,26 +2308,26 @@ UNIV_INTERN ...@@ -2308,26 +2308,26 @@ UNIV_INTERN
ibool ibool
page_validate( page_validate(
/*==========*/ /*==========*/
page_t* page, /*!< in: index page */ const page_t* page, /*!< in: index page */
dict_index_t* index) /*!< in: data dictionary index containing dict_index_t* index) /*!< in: data dictionary index containing
the page record type definition */ the page record type definition */
{ {
page_dir_slot_t*slot; const page_dir_slot_t* slot;
mem_heap_t* heap; mem_heap_t* heap;
byte* buf; byte* buf;
ulint count; ulint count;
ulint own_count; ulint own_count;
ulint rec_own_count; ulint rec_own_count;
ulint slot_no; ulint slot_no;
ulint data_size; ulint data_size;
rec_t* rec; const rec_t* rec;
rec_t* old_rec = NULL; const rec_t* old_rec = NULL;
ulint offs; ulint offs;
ulint n_slots; ulint n_slots;
ibool ret = FALSE; ibool ret = FALSE;
ulint i; ulint i;
ulint* offsets = NULL; ulint* offsets = NULL;
ulint* old_offsets = NULL; ulint* old_offsets = NULL;
if (UNIV_UNLIKELY((ibool) !!page_is_comp(page) if (UNIV_UNLIKELY((ibool) !!page_is_comp(page)
!= dict_table_is_comp(index->table))) { != dict_table_is_comp(index->table))) {
...@@ -2482,7 +2482,7 @@ page_validate( ...@@ -2482,7 +2482,7 @@ page_validate(
count++; count++;
own_count++; own_count++;
old_rec = rec; old_rec = rec;
rec = page_rec_get_next(rec); rec = page_rec_get_next_const(rec);
/* set old_offsets to offsets; recycle offsets */ /* set old_offsets to offsets; recycle offsets */
{ {
...@@ -2556,7 +2556,7 @@ page_validate( ...@@ -2556,7 +2556,7 @@ page_validate(
buf[offs + i] = 1; 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)) { if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) {
......
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