Commit 13b79f48 authored by Monty's avatar Monty

Fixed MDEV-9347 Not all rows returned by the C API

Problem was that insert-order (enforced by the optimizer) did not handle
the case where the bitmap changed to a new one.

Fixed by remembering the last bitmap page used and to force usage of this when inserting new rows
parent b404b236
...@@ -1249,7 +1249,7 @@ static my_bool allocate_head(MARIA_FILE_BITMAP *bitmap, uint size, ...@@ -1249,7 +1249,7 @@ static my_bool allocate_head(MARIA_FILE_BITMAP *bitmap, uint size,
DBUG_ASSERT(size <= FULL_PAGE_SIZE(share)); DBUG_ASSERT(size <= FULL_PAGE_SIZE(share));
if (insert_order) if (insert_order && bitmap->page == share->last_insert_bitmap)
{ {
uint last_insert_page= share->last_insert_page; uint last_insert_page= share->last_insert_page;
uint byte= 6 * (last_insert_page / 16); uint byte= 6 * (last_insert_page / 16);
...@@ -1315,6 +1315,7 @@ static my_bool allocate_head(MARIA_FILE_BITMAP *bitmap, uint size, ...@@ -1315,6 +1315,7 @@ static my_bool allocate_head(MARIA_FILE_BITMAP *bitmap, uint size,
{ {
share->last_insert_page= share->last_insert_page=
((uint) (best_data - bitmap->map)) / 6 * 16 + best_pos; ((uint) (best_data - bitmap->map)) / 6 * 16 + best_pos;
share->last_insert_bitmap= bitmap->page;
} }
fill_block(bitmap, block, best_data, best_pos, best_bits, FULL_HEAD_PAGE); fill_block(bitmap, block, best_data, best_pos, best_bits, FULL_HEAD_PAGE);
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -1614,6 +1615,16 @@ static my_bool find_head(MARIA_HA *info, uint length, uint position) ...@@ -1614,6 +1615,16 @@ static my_bool find_head(MARIA_HA *info, uint length, uint position)
*/ */
block= dynamic_element(&info->bitmap_blocks, position, MARIA_BITMAP_BLOCK *); block= dynamic_element(&info->bitmap_blocks, position, MARIA_BITMAP_BLOCK *);
if (info->s->base.extra_options & MA_EXTRA_OPTIONS_INSERT_ORDER)
{
if (bitmap->page != info->s->last_insert_bitmap &&
_ma_change_bitmap_page(info, bitmap,
info->s->last_insert_bitmap))
return 1;
/* Don't allocate any blocks from earlier pages */
info->s->state.first_bitmap_with_space= info->s->last_insert_bitmap;
}
/* /*
We need to have DIRENTRY_SIZE here to take into account that we may We need to have DIRENTRY_SIZE here to take into account that we may
need an extra directory entry for the row need an extra directory entry for the row
...@@ -3115,6 +3126,10 @@ static my_bool _ma_bitmap_create_missing(MARIA_HA *info, ...@@ -3115,6 +3126,10 @@ static my_bool _ma_bitmap_create_missing(MARIA_HA *info,
bzero(bitmap->map, bitmap->block_size); bzero(bitmap->map, bitmap->block_size);
bitmap->used_size= 0; bitmap->used_size= 0;
#ifndef DBUG_OFF #ifndef DBUG_OFF
/*
Make a copy of the page to be able to print out bitmap changes during
debugging
*/
memcpy(bitmap->map + bitmap->block_size, bitmap->map, bitmap->block_size); memcpy(bitmap->map + bitmap->block_size, bitmap->map, bitmap->block_size);
#endif #endif
......
...@@ -523,6 +523,7 @@ typedef struct st_maria_share ...@@ -523,6 +523,7 @@ typedef struct st_maria_share
Keep of track of last insert page, used to implement insert order Keep of track of last insert page, used to implement insert order
*/ */
uint last_insert_page; uint last_insert_page;
pgcache_page_no_t last_insert_bitmap;
} MARIA_SHARE; } MARIA_SHARE;
......
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