Commit dd8e57af authored by unknown's avatar unknown

_ma_state_info_write numeric flags changed with constants.

storage/maria/maria_def.h:
  Constants for _ma_state_info_write added.
parent 6aa97fb6
......@@ -7089,7 +7089,10 @@ my_bool _ma_apply_undo_bulk_insert(MARIA_HA *info, LSN undo_lsn)
error= (maria_delete_all_rows(info) ||
maria_enable_indexes(info) ||
/* 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,
FALSE, 0, &lsn, NULL));
DBUG_RETURN(error);
......
......@@ -2204,7 +2204,11 @@ static my_bool protect_against_repair_crash(MARIA_HA *info,
FLUSH_FORCE_WRITE,
discard_index ? FLUSH_IGNORE_CHANGED :
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;
/* In maria_chk this is not needed: */
if (maria_multi_threaded && share->base.born_transactional)
......@@ -2213,7 +2217,9 @@ static my_bool protect_against_repair_crash(MARIA_HA *info,
{
/* this can be true only for a transactional table */
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;
}
if (translog_status == TRANSLOG_OK &&
......@@ -5960,7 +5966,9 @@ int maria_update_state_info(HA_CHECK *param, MARIA_HA *info,uint update)
if (!share->state.create_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;
share->changed=0;
}
......
......@@ -368,7 +368,9 @@ static void flush_all_tables(int what_to_flush)
FLUSH_KEEP, FLUSH_KEEP);
break;
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",
("is_of_horizon: LSN (%lu,0x%lx)",
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)
state_copies_horizon;
if (kfile.file >= 0)
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
concurrent _ma_writeinfo() doing share->changed=1 (cancel its
......
......@@ -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
unlocking.
*/
if (_ma_state_info_write(share, 1))
if (_ma_state_info_write(share, MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET))
error= my_errno;
}
/*
......
......@@ -846,7 +846,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
errpos=1;
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))
goto err;
DBUG_PRINT("info", ("base_pos: %d base_info_size: %d",
......
......@@ -116,7 +116,9 @@ int maria_delete_all_rows(MARIA_HA *info)
To avoid this, we need to set skip_redo_lsn now, and thus need to sync
files.
*/
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_sync_table_files(info);
info->trn->rec_lsn= LSN_IMPOSSIBLE;
......
......@@ -272,7 +272,9 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
for the posterity is by writing it to disk.
*/
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);
break;
......@@ -289,7 +291,9 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
if (!error && share->changed)
{
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;
pthread_mutex_unlock(&share->intern_lock);
}
......@@ -347,7 +351,10 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
if (do_flush)
{
/* 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)))
error= my_errno;
else
......
......@@ -192,7 +192,9 @@ my_bool write_hook_for_clr_end(enum translog_record_type type
safe_mutex_assert_owner(&share->intern_lock);
error= (maria_enable_indexes(tbl_info) ||
/* 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 */
break;
default:
......
......@@ -112,7 +112,8 @@ int maria_lock_database(MARIA_HA *info, int lock_type)
/* transactional tables rather flush their state at Checkpoint */
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;
else
{
......@@ -316,8 +317,10 @@ int _ma_writeinfo(register MARIA_HA *info, uint operation)
share->state.update_count= info->last_loop= ++info->this_loop;
#endif
if ((error= _ma_state_info_write_sub(share->kfile.file,
&share->state, 1)))
if ((error=
_ma_state_info_write_sub(share->kfile.file,
&share->state,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET)))
olderror=my_errno;
#ifdef __WIN__
if (maria_flush)
......
......@@ -1172,11 +1172,13 @@ static void setup_key_functions(register MARIA_KEYDEF *keyinfo)
Then calls _ma_state_info_write_sub().
@param share table
@param pWrite bitmap: if 1 is set my_pwrite() is used otherwise
my_write(); if 2 is set, info about keys is written
(should only be needed after ALTER TABLE
ENABLE/DISABLE KEYS, and REPAIR/OPTIMIZE); if 4 is
set, MARIA_SHARE::intern_lock is taken.
@param pWrite bitmap: if 1 (MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET)
is set my_pwrite() is used otherwise my_write();
if 2 (MA_STATE_INFO_WRITE_FULL_INFO) is set, info
about keys is written (should only be needed
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
@retval 0 OK
......@@ -1189,7 +1191,7 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite)
if (share->options & HA_OPTION_READ_ONLY_DATA)
return 0;
if (pWrite & 4)
if (pWrite & MA_STATE_INFO_WRITE_LOCK)
pthread_mutex_lock(&share->intern_lock);
else if (maria_multi_threaded)
{
......@@ -1208,7 +1210,7 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite)
LSN_IN_PARTS(share->state.is_of_horizon)));
}
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);
share->changed= 0;
return res;
......@@ -1222,10 +1224,12 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite)
@param file descriptor of the index file to write
@param state state information to write to the file
@param pWrite bitmap: if 1 is set my_pwrite() is used otherwise
my_write(); if 2 is set, info about keys is written
(should only be needed after ALTER TABLE
ENABLE/DISABLE KEYS, and REPAIR/OPTIMIZE).
@param pWrite bitmap: if 1 (MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET)
is set my_pwrite() is used otherwise my_write();
if 2 (MA_STATE_INFO_WRITE_FULL_INFO) is set, info
about keys is written (should only be needed
after ALTER TABLE ENABLE/DISABLE KEYS, and
REPAIR/OPTIMIZE).
@notes
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)
mi_sizestore(ptr,state->key_root[i]); 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);
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)
}
}
res= (pWrite & 1) ?
res= (pWrite & MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET) ?
my_pwrite(file, buff, (size_t) (ptr-buff), 0L,
MYF(MY_NABP | MY_THREADSAFE)) :
my_write(file, buff, (size_t) (ptr-buff),
......
......@@ -2760,7 +2760,8 @@ static void prepare_table_for_close(MARIA_HA *info, TRANSLOG_ADDRESS horizon)
cmp_translog_addr(share->lsn_of_file_id, horizon) < 0)
{
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);
}
/*
......@@ -3315,7 +3316,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,
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))
DBUG_RETURN(1);
}
......
......@@ -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,
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_sub(File file, MARIA_STATE_INFO *state, uint pWrite);
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,
if (share->base.keys)
isamchk_neaded=1;
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,
if (isam_file->s->base.keys)
isamchk_neaded=1;
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