Skip to content

Commit

Permalink
Fixed MDEV-9347 Not all rows returned by the C API
Browse files Browse the repository at this point in the history
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
  • Loading branch information
montywi committed Jan 27, 2016
1 parent b404b23 commit 13b79f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion storage/maria/ma_bitmap.c
Expand Up @@ -1249,7 +1249,7 @@ static my_bool allocate_head(MARIA_FILE_BITMAP *bitmap, uint size,

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 byte= 6 * (last_insert_page / 16);
Expand Down Expand Up @@ -1315,6 +1315,7 @@ static my_bool allocate_head(MARIA_FILE_BITMAP *bitmap, uint size,
{
share->last_insert_page=
((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);
DBUG_RETURN(0);
Expand Down Expand Up @@ -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 *);

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
need an extra directory entry for the row
Expand Down Expand Up @@ -3115,6 +3126,10 @@ static my_bool _ma_bitmap_create_missing(MARIA_HA *info,
bzero(bitmap->map, bitmap->block_size);
bitmap->used_size= 0;
#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);
#endif

Expand Down
1 change: 1 addition & 0 deletions storage/maria/maria_def.h
Expand Up @@ -523,6 +523,7 @@ typedef struct st_maria_share
Keep of track of last insert page, used to implement insert order
*/
uint last_insert_page;
pgcache_page_no_t last_insert_bitmap;
} MARIA_SHARE;


Expand Down

0 comments on commit 13b79f4

Please sign in to comment.