Merge remote-tracking branch '5.5' into 10.0

This commit is contained in:
Vicențiu Ciorbaru 2018-01-24 12:29:31 +02:00
commit d833bb65d5
153 changed files with 1984 additions and 677 deletions

View file

@ -2136,11 +2136,16 @@ void ha_maria::start_bulk_insert(ha_rows rows, uint flags)
safety net for now, we don't remove the test of
file->state->records, because there is uncertainty on what will
happen during repair if the two states disagree.
We also have to check in case of transactional tables that the
user has not used LOCK TABLE on the table twice.
*/
if ((file->state->records == 0) &&
(share->state.state.records == 0) && can_enable_indexes &&
(!rows || rows >= MARIA_MIN_ROWS_TO_DISABLE_INDEXES) &&
(file->lock.type == TL_WRITE || file->lock.type == TL_UNLOCK))
(file->lock.type == TL_WRITE || file->lock.type == TL_UNLOCK) &&
(!share->have_versioning || !share->now_transactional ||
file->used_tables->use_count == 1))
{
/**
@todo for a single-row INSERT SELECT, we will go into repair, which

View file

@ -6129,7 +6129,7 @@ my_bool write_hook_for_undo_row_insert(enum translog_record_type type
/**
@brief Upates "records" and calls the generic UNDO hook
@brief Updates "records" and calls the generic UNDO hook
@return Operation status, always 0 (success)
*/
@ -6279,8 +6279,8 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn,
uchar *buff, *dir;
uint result;
MARIA_PINNED_PAGE page_link;
enum pagecache_page_lock unlock_method;
enum pagecache_page_pin unpin_method;
enum pagecache_page_lock lock_method;
enum pagecache_page_pin pin_method;
my_off_t end_of_page;
uint error;
DBUG_ENTER("_ma_apply_redo_insert_row_head_or_tail");
@ -6308,8 +6308,8 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn,
fill it entirely with zeroes, then the REDO will put correct data on
it.
*/
unlock_method= PAGECACHE_LOCK_WRITE;
unpin_method= PAGECACHE_PIN;
lock_method= PAGECACHE_LOCK_WRITE;
pin_method= PAGECACHE_PIN;
DBUG_ASSERT(rownr == 0 && new_page);
if (rownr != 0 || !new_page)
@ -6324,8 +6324,8 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn,
}
else
{
unlock_method= PAGECACHE_LOCK_LEFT_WRITELOCKED;
unpin_method= PAGECACHE_PIN_LEFT_PINNED;
lock_method= PAGECACHE_LOCK_LEFT_WRITELOCKED;
pin_method= PAGECACHE_PIN_LEFT_PINNED;
share->pagecache->readwrite_flags&= ~MY_WME;
buff= pagecache_read(share->pagecache, &info->dfile,
@ -6427,11 +6427,11 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn,
this group, for this page, would be skipped) and unpin then.
*/
result= 0;
if (unlock_method == PAGECACHE_LOCK_WRITE &&
if (lock_method == PAGECACHE_LOCK_WRITE &&
pagecache_write(share->pagecache,
&info->dfile, page, 0,
buff, PAGECACHE_PLAIN_PAGE,
unlock_method, unpin_method,
lock_method, pin_method,
PAGECACHE_WRITE_DELAY, &page_link.link,
LSN_IMPOSSIBLE))
result= my_errno;
@ -6452,7 +6452,7 @@ crashed_file:
_ma_set_fatal_error(share, HA_ERR_WRONG_IN_RECORD);
err:
error= my_errno;
if (unlock_method == PAGECACHE_LOCK_LEFT_WRITELOCKED)
if (lock_method == PAGECACHE_LOCK_LEFT_WRITELOCKED)
pagecache_unlock_by_link(share->pagecache, page_link.link,
PAGECACHE_LOCK_WRITE_UNLOCK,
PAGECACHE_UNPIN, LSN_IMPOSSIBLE,

View file

@ -229,17 +229,35 @@ my_bool _ma_write_keypage(MARIA_PAGE *page, enum pagecache_page_lock lock,
#endif
page_cleanup(share, page);
res= pagecache_write(share->pagecache,
&share->kfile,
(pgcache_page_no_t) (page->pos / block_size),
level, buff, share->page_type,
lock,
lock == PAGECACHE_LOCK_LEFT_WRITELOCKED ?
PAGECACHE_PIN_LEFT_PINNED :
(lock == PAGECACHE_LOCK_WRITE_UNLOCK ?
PAGECACHE_UNPIN : PAGECACHE_PIN),
PAGECACHE_WRITE_DELAY, &page_link.link,
LSN_IMPOSSIBLE);
{
PAGECACHE_BLOCK_LINK **link;
enum pagecache_page_pin pin;
if (lock == PAGECACHE_LOCK_LEFT_WRITELOCKED)
{
pin= PAGECACHE_PIN_LEFT_PINNED;
link= &page_link.link;
}
else if (lock == PAGECACHE_LOCK_WRITE_UNLOCK)
{
pin= PAGECACHE_UNPIN;
/*
We unlock this page so link should be 0 to prevent it usage
even accidentally
*/
link= NULL;
}
else
{
pin= PAGECACHE_PIN;
link= &page_link.link;
}
res= pagecache_write(share->pagecache,
&share->kfile,
(pgcache_page_no_t) (page->pos / block_size),
level, buff, share->page_type,
lock, pin, PAGECACHE_WRITE_DELAY, link,
LSN_IMPOSSIBLE);
}
if (lock == PAGECACHE_LOCK_WRITE)
{

View file

@ -58,6 +58,7 @@ my_bool _ma_setup_live_state(MARIA_HA *info)
MARIA_USED_TABLES *tables;
MARIA_STATE_HISTORY *history;
DBUG_ENTER("_ma_setup_live_state");
DBUG_PRINT("enter", ("info: %p", info));
DBUG_ASSERT(share->lock_key_trees);
@ -110,6 +111,8 @@ my_bool _ma_setup_live_state(MARIA_HA *info)
end:
info->state_start= &tables->state_start;
info->state= &tables->state_current;
info->used_tables= tables;
tables->use_count++;
/*
Mark in transaction state if we are not using transid (versioning)
@ -118,6 +121,7 @@ end:
*/
tables->state_current.no_transid|= !(info->row_flag & ROW_FLAG_TRANSID);
DBUG_PRINT("exit", ("tables: %p info->state: %p", tables, info->state));
DBUG_RETURN(0);
}
@ -241,9 +245,10 @@ void _ma_reset_state(MARIA_HA *info)
DBUG_ENTER("_ma_reset_state");
/* Always true if share->now_transactional is set */
if (history)
if (history && share->have_versioning)
{
MARIA_STATE_HISTORY *next;
DBUG_PRINT("info", ("resetting history"));
/* Set the current history to current state */
share->state_history->state= share->state.state;
@ -255,7 +260,7 @@ void _ma_reset_state(MARIA_HA *info)
my_free(history);
}
share->state_history->next= 0;
share->state_history->trid= 0; /* Visibile for all */
share->state_history->trid= 0; /* Visible for all */
}
DBUG_VOID_RETURN;
}
@ -597,7 +602,7 @@ void _ma_remove_table_from_trnman(MARIA_SHARE *share, TRN *trn)
SYNOPSIS
_ma_get_status()
param Pointer to Myisam handler
param Pointer to Aria handler
concurrent_insert Set to 1 if we are going to do concurrent inserts
(THR_WRITE_CONCURRENT_INSERT was used)
*/
@ -627,6 +632,8 @@ void _ma_block_get_status(void* param, my_bool concurrent_insert)
my_bool _ma_block_start_trans(void* param)
{
MARIA_HA *info=(MARIA_HA*) param;
DBUG_ENTER("_ma_block_start_trans");
if (info->s->lock_key_trees)
{
/*
@ -634,7 +641,7 @@ my_bool _ma_block_start_trans(void* param)
out of memory conditions)
TODO: Fix this by having one extra state pre-allocated
*/
return _ma_setup_live_state(info);
DBUG_RETURN(_ma_setup_live_state(info));
}
else
{
@ -663,9 +670,9 @@ my_bool _ma_block_start_trans(void* param)
Assume for now that this doesn't fail (It can only fail in
out of memory conditions)
*/
return maria_create_trn_hook(info) != 0;
DBUG_RETURN(maria_create_trn_hook(info) != 0);
}
return 0;
DBUG_RETURN(0);
}
@ -697,7 +704,7 @@ my_bool _ma_block_check_status(void *param __attribute__((unused)))
my_bool _ma_block_start_trans_no_versioning(void* param)
{
MARIA_HA *info=(MARIA_HA*) param;
DBUG_ENTER("_ma_block_get_status_no_version");
DBUG_ENTER("_ma_block_start_trans_no_versioning");
DBUG_ASSERT(info->s->base.born_transactional && !info->s->lock_key_trees);
info->state->changed= 0; /* from _ma_reset_update_flag() */
@ -722,6 +729,8 @@ my_bool _ma_block_start_trans_no_versioning(void* param)
void maria_versioning(MARIA_HA *info, my_bool versioning)
{
MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_versioning");
/* For now, this is a hack */
if (share->have_versioning)
{
@ -738,6 +747,7 @@ void maria_versioning(MARIA_HA *info, my_bool versioning)
info->state= &share->state.state; /* Change global values by default */
info->state_start= info->state; /* Initial values */
}
DBUG_VOID_RETURN;
}

View file

@ -34,6 +34,7 @@ typedef struct st_used_tables {
struct st_maria_share *share;
MARIA_STATUS_INFO state_current;
MARIA_STATUS_INFO state_start;
uint use_count;
} MARIA_USED_TABLES;

View file

@ -578,6 +578,7 @@ struct st_maria_handler
struct st_ma_transaction *trn; /* Pointer to active transaction */
MARIA_STATUS_INFO *state, state_save;
MARIA_STATUS_INFO *state_start; /* State at start of transaction */
MARIA_USED_TABLES *used_tables;
MARIA_ROW cur_row; /* The active row that we just read */
MARIA_ROW new_row; /* Storage for a row during update */
MARIA_KEY last_key; /* Last found key */
@ -1147,7 +1148,7 @@ extern ulonglong transid_get_packed(MARIA_SHARE *share, const uchar *from);
#ifdef IDENTICAL_PAGES_AFTER_RECOVERY
void page_cleanup(MARIA_SHARE *share, MARIA_PAGE *page)
#else
#define page_cleanup(A,B) while (0)
#define page_cleanup(A,B) do { } while (0)
#endif
extern MARIA_KEY *_ma_make_key(MARIA_HA *info, MARIA_KEY *int_key, uint keynr,

View file

@ -233,7 +233,7 @@ int main(int argc __attribute__((unused)), char *argv[])
0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA,
0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55
};
uchar *long_buffer= malloc(LONG_BUFFER_SIZE + LSN_STORE_SIZE * 2 + 2);
uchar *long_buffer;
char **default_argv;
PAGECACHE pagecache;
LSN lsn, lsn_base, first_lsn;
@ -255,6 +255,7 @@ int main(int argc __attribute__((unused)), char *argv[])
}
#endif
long_buffer= malloc(LONG_BUFFER_SIZE + LSN_STORE_SIZE * 2 + 2);
load_defaults("my", load_default_groups, &argc, &argv);
default_argv= argv;
get_options(&argc, &argv);
@ -758,9 +759,12 @@ err:
if (maria_log_remove(maria_data_root))
exit(1);
free(long_buffer);
my_uuid_end();
my_free_open_file_info();
my_end(0);
return (MY_TEST(exit_status()));
}

View file

@ -191,6 +191,8 @@ int main(int argc __attribute__((unused)), char *argv[])
if (maria_log_remove(maria_data_root))
exit(1);
free(long_buffer);
my_uuid_end();
my_free_open_file_info();
my_end(0);