Commit 5564e53c authored by unknown's avatar unknown

merge

parents a9376429 dd8e57af
...@@ -7115,7 +7115,10 @@ my_bool _ma_apply_undo_bulk_insert(MARIA_HA *info, LSN undo_lsn) ...@@ -7115,7 +7115,10 @@ my_bool _ma_apply_undo_bulk_insert(MARIA_HA *info, LSN undo_lsn)
error= (maria_delete_all_rows(info) || error= (maria_delete_all_rows(info) ||
maria_enable_indexes(info) || maria_enable_indexes(info) ||
/* we enabled indices so need '2' below */ /* we enabled indices so need '2' below */
_ma_state_info_write(info->s, 1|2|4) || _ma_state_info_write(info->s,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_FULL_INFO |
MA_STATE_INFO_WRITE_LOCK) ||
_ma_write_clr(info, undo_lsn, LOGREC_UNDO_BULK_INSERT, _ma_write_clr(info, undo_lsn, LOGREC_UNDO_BULK_INSERT,
FALSE, 0, &lsn, NULL)); FALSE, 0, &lsn, NULL));
DBUG_RETURN(error); DBUG_RETURN(error);
......
...@@ -2204,7 +2204,11 @@ static my_bool protect_against_repair_crash(MARIA_HA *info, ...@@ -2204,7 +2204,11 @@ static my_bool protect_against_repair_crash(MARIA_HA *info,
FLUSH_FORCE_WRITE, FLUSH_FORCE_WRITE,
discard_index ? FLUSH_IGNORE_CHANGED : discard_index ? FLUSH_IGNORE_CHANGED :
FLUSH_FORCE_WRITE) || FLUSH_FORCE_WRITE) ||
(share->changed && _ma_state_info_write(share, 1|2|4))) (share->changed &&
_ma_state_info_write(share,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_FULL_INFO |
MA_STATE_INFO_WRITE_LOCK)))
return TRUE; return TRUE;
/* In maria_chk this is not needed: */ /* In maria_chk this is not needed: */
if (maria_multi_threaded && share->base.born_transactional) if (maria_multi_threaded && share->base.born_transactional)
...@@ -2213,7 +2217,9 @@ static my_bool protect_against_repair_crash(MARIA_HA *info, ...@@ -2213,7 +2217,9 @@ static my_bool protect_against_repair_crash(MARIA_HA *info,
{ {
/* this can be true only for a transactional table */ /* this can be true only for a transactional table */
maria_mark_crashed_on_repair(info); maria_mark_crashed_on_repair(info);
if (_ma_state_info_write(share, 1|4)) if (_ma_state_info_write(share,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_LOCK))
return TRUE; return TRUE;
} }
if (translog_status == TRANSLOG_OK && if (translog_status == TRANSLOG_OK &&
...@@ -5960,7 +5966,9 @@ int maria_update_state_info(HA_CHECK *param, MARIA_HA *info,uint update) ...@@ -5960,7 +5966,9 @@ int maria_update_state_info(HA_CHECK *param, MARIA_HA *info,uint update)
if (!share->state.create_time) if (!share->state.create_time)
share->state.create_time= share->state.check_time; share->state.create_time= share->state.check_time;
} }
if (_ma_state_info_write(share, 1|2)) if (_ma_state_info_write(share,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_FULL_INFO))
goto err; goto err;
share->changed=0; share->changed=0;
} }
......
...@@ -368,7 +368,9 @@ static void flush_all_tables(int what_to_flush) ...@@ -368,7 +368,9 @@ static void flush_all_tables(int what_to_flush)
FLUSH_KEEP, FLUSH_KEEP); FLUSH_KEEP, FLUSH_KEEP);
break; break;
case 1: case 1:
res= _ma_state_info_write(info->s, 1|4); res= _ma_state_info_write(info->s,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET|
MA_STATE_INFO_WRITE_LOCK);
DBUG_PRINT("maria_flush_states", DBUG_PRINT("maria_flush_states",
("is_of_horizon: LSN (%lu,0x%lx)", ("is_of_horizon: LSN (%lu,0x%lx)",
LSN_IN_PARTS(info->s->state.is_of_horizon))); LSN_IN_PARTS(info->s->state.is_of_horizon)));
...@@ -1046,7 +1048,8 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon) ...@@ -1046,7 +1048,8 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
state_copies_horizon; state_copies_horizon;
if (kfile.file >= 0) if (kfile.file >= 0)
sync_error|= sync_error|=
_ma_state_info_write_sub(kfile.file, &state_copy->state, 1); _ma_state_info_write_sub(kfile.file, &state_copy->state,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET);
/* /*
We don't set share->changed=0 because it may interfere with a We don't set share->changed=0 because it may interfere with a
concurrent _ma_writeinfo() doing share->changed=1 (cancel its concurrent _ma_writeinfo() doing share->changed=1 (cancel its
......
...@@ -101,7 +101,7 @@ int maria_close(register MARIA_HA *info) ...@@ -101,7 +101,7 @@ int maria_close(register MARIA_HA *info)
State must be written to file as it was not done at table's State must be written to file as it was not done at table's
unlocking. unlocking.
*/ */
if (_ma_state_info_write(share, 1)) if (_ma_state_info_write(share, MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET))
error= my_errno; error= my_errno;
} }
/* /*
......
...@@ -854,7 +854,8 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -854,7 +854,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
errpos=1; errpos=1;
DBUG_PRINT("info", ("write state info and base info")); DBUG_PRINT("info", ("write state info and base info"));
if (_ma_state_info_write_sub(file, &share.state, 2) || if (_ma_state_info_write_sub(file, &share.state,
MA_STATE_INFO_WRITE_FULL_INFO) ||
_ma_base_info_write(file, &share.base)) _ma_base_info_write(file, &share.base))
goto err; goto err;
DBUG_PRINT("info", ("base_pos: %d base_info_size: %d", DBUG_PRINT("info", ("base_pos: %d base_info_size: %d",
......
...@@ -122,7 +122,9 @@ int maria_delete_all_rows(MARIA_HA *info) ...@@ -122,7 +122,9 @@ int maria_delete_all_rows(MARIA_HA *info)
and fail, saying that it sees that the first page has to be created and fail, saying that it sees that the first page has to be created
though the inserted row has rownr>0. though the inserted row has rownr>0.
*/ */
my_bool error= _ma_state_info_write(share, 1|4) || my_bool error= _ma_state_info_write(share,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_LOCK) ||
_ma_update_state_lsns(share, lsn, trnman_get_min_trid(), FALSE, FALSE) || _ma_update_state_lsns(share, lsn, trnman_get_min_trid(), FALSE, FALSE) ||
_ma_sync_table_files(info); _ma_sync_table_files(info);
info->trn->rec_lsn= LSN_IMPOSSIBLE; info->trn->rec_lsn= LSN_IMPOSSIBLE;
......
...@@ -272,7 +272,9 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, ...@@ -272,7 +272,9 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
for the posterity is by writing it to disk. for the posterity is by writing it to disk.
*/ */
DBUG_ASSERT(!maria_in_recovery); DBUG_ASSERT(!maria_in_recovery);
error= _ma_state_info_write(share, 1|2); error= _ma_state_info_write(share,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_FULL_INFO);
} }
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);
break; break;
...@@ -289,7 +291,9 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, ...@@ -289,7 +291,9 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
if (!error && share->changed) if (!error && share->changed)
{ {
pthread_mutex_lock(&share->intern_lock); pthread_mutex_lock(&share->intern_lock);
if (!(error= _ma_state_info_write(share, 1|2))) if (!(error= _ma_state_info_write(share,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET|
MA_STATE_INFO_WRITE_FULL_INFO)))
share->changed= 0; share->changed= 0;
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);
} }
...@@ -347,7 +351,10 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, ...@@ -347,7 +351,10 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
if (do_flush) if (do_flush)
{ {
/* Save the state so that others can find it from disk. */ /* Save the state so that others can find it from disk. */
if ((share->changed && _ma_state_info_write(share, 1 | 2)) || if ((share->changed &&
_ma_state_info_write(share,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_FULL_INFO)) ||
my_sync(share->kfile.file, MYF(0))) my_sync(share->kfile.file, MYF(0)))
error= my_errno; error= my_errno;
else else
......
...@@ -192,7 +192,9 @@ my_bool write_hook_for_clr_end(enum translog_record_type type ...@@ -192,7 +192,9 @@ my_bool write_hook_for_clr_end(enum translog_record_type type
safe_mutex_assert_owner(&share->intern_lock); safe_mutex_assert_owner(&share->intern_lock);
error= (maria_enable_indexes(tbl_info) || error= (maria_enable_indexes(tbl_info) ||
/* we enabled indices, need '2' below */ /* we enabled indices, need '2' below */
_ma_state_info_write(share, 1|2)); _ma_state_info_write(share,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_FULL_INFO));
/* no need for _ma_reset_status(): REDO_DELETE_ALL is just before us */ /* no need for _ma_reset_status(): REDO_DELETE_ALL is just before us */
break; break;
default: default:
......
...@@ -112,7 +112,8 @@ int maria_lock_database(MARIA_HA *info, int lock_type) ...@@ -112,7 +112,8 @@ int maria_lock_database(MARIA_HA *info, int lock_type)
/* transactional tables rather flush their state at Checkpoint */ /* transactional tables rather flush their state at Checkpoint */
if (!share->base.born_transactional) if (!share->base.born_transactional)
{ {
if (_ma_state_info_write_sub(share->kfile.file, &share->state, 1)) if (_ma_state_info_write_sub(share->kfile.file, &share->state,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET))
error= my_errno; error= my_errno;
else else
{ {
...@@ -316,8 +317,10 @@ int _ma_writeinfo(register MARIA_HA *info, uint operation) ...@@ -316,8 +317,10 @@ int _ma_writeinfo(register MARIA_HA *info, uint operation)
share->state.update_count= info->last_loop= ++info->this_loop; share->state.update_count= info->last_loop= ++info->this_loop;
#endif #endif
if ((error= _ma_state_info_write_sub(share->kfile.file, if ((error=
&share->state, 1))) _ma_state_info_write_sub(share->kfile.file,
&share->state,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET)))
olderror=my_errno; olderror=my_errno;
#ifdef __WIN__ #ifdef __WIN__
if (maria_flush) if (maria_flush)
......
...@@ -1172,11 +1172,13 @@ static void setup_key_functions(register MARIA_KEYDEF *keyinfo) ...@@ -1172,11 +1172,13 @@ static void setup_key_functions(register MARIA_KEYDEF *keyinfo)
Then calls _ma_state_info_write_sub(). Then calls _ma_state_info_write_sub().
@param share table @param share table
@param pWrite bitmap: if 1 is set my_pwrite() is used otherwise @param pWrite bitmap: if 1 (MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET)
my_write(); if 2 is set, info about keys is written is set my_pwrite() is used otherwise my_write();
(should only be needed after ALTER TABLE if 2 (MA_STATE_INFO_WRITE_FULL_INFO) is set, info
ENABLE/DISABLE KEYS, and REPAIR/OPTIMIZE); if 4 is about keys is written (should only be needed
set, MARIA_SHARE::intern_lock is taken. after ALTER TABLE ENABLE/DISABLE KEYS, and
REPAIR/OPTIMIZE); if 4 (MA_STATE_INFO_WRITE_LOCK)
is set, MARIA_SHARE::intern_lock is taken.
@return Operation status @return Operation status
@retval 0 OK @retval 0 OK
...@@ -1189,7 +1191,7 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite) ...@@ -1189,7 +1191,7 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite)
if (share->options & HA_OPTION_READ_ONLY_DATA) if (share->options & HA_OPTION_READ_ONLY_DATA)
return 0; return 0;
if (pWrite & 4) if (pWrite & MA_STATE_INFO_WRITE_LOCK)
pthread_mutex_lock(&share->intern_lock); pthread_mutex_lock(&share->intern_lock);
else if (maria_multi_threaded) else if (maria_multi_threaded)
{ {
...@@ -1208,7 +1210,7 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite) ...@@ -1208,7 +1210,7 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite)
LSN_IN_PARTS(share->state.is_of_horizon))); LSN_IN_PARTS(share->state.is_of_horizon)));
} }
res= _ma_state_info_write_sub(share->kfile.file, &share->state, pWrite); res= _ma_state_info_write_sub(share->kfile.file, &share->state, pWrite);
if (pWrite & 4) if (pWrite & MA_STATE_INFO_WRITE_LOCK)
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);
share->changed= 0; share->changed= 0;
return res; return res;
...@@ -1222,10 +1224,12 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite) ...@@ -1222,10 +1224,12 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite)
@param file descriptor of the index file to write @param file descriptor of the index file to write
@param state state information to write to the file @param state state information to write to the file
@param pWrite bitmap: if 1 is set my_pwrite() is used otherwise @param pWrite bitmap: if 1 (MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET)
my_write(); if 2 is set, info about keys is written is set my_pwrite() is used otherwise my_write();
(should only be needed after ALTER TABLE if 2 (MA_STATE_INFO_WRITE_FULL_INFO) is set, info
ENABLE/DISABLE KEYS, and REPAIR/OPTIMIZE). about keys is written (should only be needed
after ALTER TABLE ENABLE/DISABLE KEYS, and
REPAIR/OPTIMIZE).
@notes @notes
For transactional multiuser tables, this function is called For transactional multiuser tables, this function is called
...@@ -1285,7 +1289,7 @@ uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite) ...@@ -1285,7 +1289,7 @@ uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite)
mi_sizestore(ptr,state->key_root[i]); ptr+= 8; mi_sizestore(ptr,state->key_root[i]); ptr+= 8;
} }
mi_sizestore(ptr,state->key_del); ptr+= 8; mi_sizestore(ptr,state->key_del); ptr+= 8;
if (pWrite & 2) /* From maria_chk */ if (pWrite & MA_STATE_INFO_WRITE_FULL_INFO) /* From maria_chk */
{ {
uint key_parts= mi_uint2korr(state->header.key_parts); uint key_parts= mi_uint2korr(state->header.key_parts);
mi_int4store(ptr,state->sec_index_changed); ptr+= 4; mi_int4store(ptr,state->sec_index_changed); ptr+= 4;
...@@ -1305,7 +1309,7 @@ uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite) ...@@ -1305,7 +1309,7 @@ uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite)
} }
} }
res= (pWrite & 1) ? res= (pWrite & MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET) ?
my_pwrite(file, buff, (size_t) (ptr-buff), 0L, my_pwrite(file, buff, (size_t) (ptr-buff), 0L,
MYF(MY_NABP | MY_THREADSAFE)) : MYF(MY_NABP | MY_THREADSAFE)) :
my_write(file, buff, (size_t) (ptr-buff), my_write(file, buff, (size_t) (ptr-buff),
......
...@@ -2809,7 +2809,8 @@ static void prepare_table_for_close(MARIA_HA *info, TRANSLOG_ADDRESS horizon) ...@@ -2809,7 +2809,8 @@ static void prepare_table_for_close(MARIA_HA *info, TRANSLOG_ADDRESS horizon)
cmp_translog_addr(share->lsn_of_file_id, horizon) < 0) cmp_translog_addr(share->lsn_of_file_id, horizon) < 0)
{ {
share->state.is_of_horizon= horizon; share->state.is_of_horizon= horizon;
_ma_state_info_write_sub(share->kfile.file, &share->state, 1); _ma_state_info_write_sub(share->kfile.file, &share->state,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET);
} }
/* /*
...@@ -3364,7 +3365,9 @@ my_bool _ma_reenable_logging_for_table(MARIA_HA *info, my_bool flush_pages) ...@@ -3364,7 +3365,9 @@ my_bool _ma_reenable_logging_for_table(MARIA_HA *info, my_bool flush_pages)
*/ */
if (_ma_flush_table_files(info, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX, if (_ma_flush_table_files(info, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX,
FLUSH_RELEASE, FLUSH_RELEASE) || FLUSH_RELEASE, FLUSH_RELEASE) ||
_ma_state_info_write(share, 1|4) || _ma_state_info_write(share,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_LOCK) ||
_ma_sync_table_files(info)) _ma_sync_table_files(info))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
......
...@@ -1076,6 +1076,12 @@ extern size_t _ma_nommap_pread(MARIA_HA *info, uchar *Buffer, ...@@ -1076,6 +1076,12 @@ extern size_t _ma_nommap_pread(MARIA_HA *info, uchar *Buffer,
extern size_t _ma_nommap_pwrite(MARIA_HA *info, const uchar *Buffer, extern size_t _ma_nommap_pwrite(MARIA_HA *info, const uchar *Buffer,
size_t Count, my_off_t offset, myf MyFlags); size_t Count, my_off_t offset, myf MyFlags);
/* my_pwrite instead of my_write used */
#define MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET 1
/* info should be written */
#define MA_STATE_INFO_WRITE_FULL_INFO 2
/* intern_lock taking is needed */
#define MA_STATE_INFO_WRITE_LOCK 4
uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite); uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite);
uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite); uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite);
uint _ma_state_info_read_dsk(File file, MARIA_STATE_INFO *state); uint _ma_state_info_read_dsk(File file, MARIA_STATE_INFO *state);
......
...@@ -3006,7 +3006,9 @@ static int save_state(MARIA_HA *isam_file,PACK_MRG_INFO *mrg, ...@@ -3006,7 +3006,9 @@ static int save_state(MARIA_HA *isam_file,PACK_MRG_INFO *mrg,
if (share->base.keys) if (share->base.keys)
isamchk_neaded=1; isamchk_neaded=1;
DBUG_RETURN(_ma_state_info_write_sub(share->kfile.file, DBUG_RETURN(_ma_state_info_write_sub(share->kfile.file,
&share->state, (1 + 2))); &share->state,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_FULL_INFO));
} }
...@@ -3046,7 +3048,9 @@ static int save_state_mrg(File file,PACK_MRG_INFO *mrg,my_off_t new_length, ...@@ -3046,7 +3048,9 @@ static int save_state_mrg(File file,PACK_MRG_INFO *mrg,my_off_t new_length,
if (isam_file->s->base.keys) if (isam_file->s->base.keys)
isamchk_neaded=1; isamchk_neaded=1;
state.changed=STATE_CHANGED | STATE_NOT_ANALYZED; /* Force check of table */ state.changed=STATE_CHANGED | STATE_NOT_ANALYZED; /* Force check of table */
DBUG_RETURN (_ma_state_info_write_sub(file,&state,1+2)); DBUG_RETURN (_ma_state_info_write_sub(file, &state,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_FULL_INFO));
} }
......
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