Skip to content

Commit 13b79f4

Browse files
committed
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
1 parent b404b23 commit 13b79f4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

storage/maria/ma_bitmap.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ static my_bool allocate_head(MARIA_FILE_BITMAP *bitmap, uint size,
12491249

12501250
DBUG_ASSERT(size <= FULL_PAGE_SIZE(share));
12511251

1252-
if (insert_order)
1252+
if (insert_order && bitmap->page == share->last_insert_bitmap)
12531253
{
12541254
uint last_insert_page= share->last_insert_page;
12551255
uint byte= 6 * (last_insert_page / 16);
@@ -1315,6 +1315,7 @@ static my_bool allocate_head(MARIA_FILE_BITMAP *bitmap, uint size,
13151315
{
13161316
share->last_insert_page=
13171317
((uint) (best_data - bitmap->map)) / 6 * 16 + best_pos;
1318+
share->last_insert_bitmap= bitmap->page;
13181319
}
13191320
fill_block(bitmap, block, best_data, best_pos, best_bits, FULL_HEAD_PAGE);
13201321
DBUG_RETURN(0);
@@ -1614,6 +1615,16 @@ static my_bool find_head(MARIA_HA *info, uint length, uint position)
16141615
*/
16151616
block= dynamic_element(&info->bitmap_blocks, position, MARIA_BITMAP_BLOCK *);
16161617

1618+
if (info->s->base.extra_options & MA_EXTRA_OPTIONS_INSERT_ORDER)
1619+
{
1620+
if (bitmap->page != info->s->last_insert_bitmap &&
1621+
_ma_change_bitmap_page(info, bitmap,
1622+
info->s->last_insert_bitmap))
1623+
return 1;
1624+
/* Don't allocate any blocks from earlier pages */
1625+
info->s->state.first_bitmap_with_space= info->s->last_insert_bitmap;
1626+
}
1627+
16171628
/*
16181629
We need to have DIRENTRY_SIZE here to take into account that we may
16191630
need an extra directory entry for the row
@@ -3115,6 +3126,10 @@ static my_bool _ma_bitmap_create_missing(MARIA_HA *info,
31153126
bzero(bitmap->map, bitmap->block_size);
31163127
bitmap->used_size= 0;
31173128
#ifndef DBUG_OFF
3129+
/*
3130+
Make a copy of the page to be able to print out bitmap changes during
3131+
debugging
3132+
*/
31183133
memcpy(bitmap->map + bitmap->block_size, bitmap->map, bitmap->block_size);
31193134
#endif
31203135

storage/maria/maria_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ typedef struct st_maria_share
523523
Keep of track of last insert page, used to implement insert order
524524
*/
525525
uint last_insert_page;
526+
pgcache_page_no_t last_insert_bitmap;
526527
} MARIA_SHARE;
527528

528529

0 commit comments

Comments
 (0)