Commit b635df55 authored by unknown's avatar unknown

very minor comments and merges from MyISAM into Maria.


storage/maria/ma_checkpoint.c:
  comments
storage/maria/ma_close.c:
  comments
storage/maria/ma_write.c:
  merge from myisam
storage/maria/maria_def.h:
  typo
storage/myisam/mi_delete.c:
  unneeded {}, making it identical to Maria
parent ba7a2a9a
...@@ -216,14 +216,27 @@ my_bool execute_checkpoint_indirect() ...@@ -216,14 +216,27 @@ my_bool execute_checkpoint_indirect()
if (NULL == (strings[4].str= my_malloc(strings[4].length))) if (NULL == (strings[4].str= my_malloc(strings[4].length)))
goto err; goto err;
ptr= string3.str; ptr= string3.str;
/* possibly latch each MARIA_SHARE, one by one, like this: */ /*
Note that maria_open_list is a list of MARIA_HA*, while we would prefer
a list of MARIA_SHARE* here (we are interested in the short id,
unique file name, members of MARIA_SHARE*, and in file descriptors,
which will in the end be in MARIA_SHARE*).
*/
for (iterate on the maria_open_list)
{
/* latch each MARIA_SHARE, one by one, like this: */
pthread_mutex_lock(&share->intern_lock); pthread_mutex_lock(&share->intern_lock);
/* /*
We'll copy the file id (a bit like share->kfile), the file name TODO:
(like share->unique_file_name[_length]). we need to prevent the share from going away while we later flush and
force it without holding THR_LOCK_maria. For example if the share is
free()d by maria_close() we'll have a problem. Or if the share's file
descriptor is closed by maria_close() we will not be able to my_sync()
it.
*/ */
make_copy_of_global_share_list_to_array;
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);
store the share pointer into a private array;
}
unlock(global_share_list_mutex); unlock(global_share_list_mutex);
/* work on copy */ /* work on copy */
...@@ -231,15 +244,15 @@ my_bool execute_checkpoint_indirect() ...@@ -231,15 +244,15 @@ my_bool execute_checkpoint_indirect()
ptr+= 8; ptr+= 8;
for (el in array) for (el in array)
{ {
int8store(ptr, array[...].file_id); int8store(ptr, array[...].short_id);
ptr+= 8; ptr+= 8;
memcpy(ptr, array[...].file_name, ...); memcpy(ptr, array[...].unique_file_name[_length], ...);
ptr+= ...; ptr+= ...;
/* maybe we need to lock share->intern_lock here */
/* /*
these two are long ops (involving disk I/O) that's why we copied the these two are long ops (involving disk I/O) that's why we copied the
list, to not keep the list locked for long: list, to not keep the list locked for long:
*/ */
/* TODO: what if the table pointer is gone/reused now? */
flush_bitmap_pages(el); flush_bitmap_pages(el);
/* TODO: and also autoinc counter, logical file end, free page list */ /* TODO: and also autoinc counter, logical file end, free page list */
...@@ -267,6 +280,19 @@ my_bool execute_checkpoint_indirect() ...@@ -267,6 +280,19 @@ my_bool execute_checkpoint_indirect()
if (0 != control_file_write_and_force(checkpoint_lsn, NULL)) if (0 != control_file_write_and_force(checkpoint_lsn, NULL))
goto err; goto err;
/*
Note that we should not alter memory structures until we have successfully
written the checkpoint record and control file.
Btw, a log write failure is serious:
- if we know how many bytes we managed to write, we should try to write
more, keeping the log's mutex (MY_FULL_IO)
- if we don't know, this log record is corrupted and we have no way to
"de-corrupt" it, so it will stay corrupted, and as the log is sequential,
any log record written after it will not be reachable (for example if we
would write UNDOs and crash, we would not be able to read the log and so
not be able to rollback), so we should stop the engine now (holding the
log's mutex) and do a recovery.
*/
goto end; goto end;
err: err:
......
...@@ -60,9 +60,11 @@ int maria_close(register MARIA_HA *info) ...@@ -60,9 +60,11 @@ int maria_close(register MARIA_HA *info)
flag= !--share->reopen; flag= !--share->reopen;
/* /*
RECOVERYTODO: RECOVERYTODO:
Below we are going to make the table unknown to future checkpoints, so it If "flag" is TRUE, in the line below we are going to make the table
needs to have fsync'ed itself entirely (bitmap, pages, etc) at this unknown to future checkpoints, so it needs to have fsync'ed itself
point. entirely (bitmap, pages, etc) at this point.
The flushing is currently done a few lines further (which is ok, as we
still hold THR_LOCK_maria), but syncing is missing.
*/ */
maria_open_list=list_delete(maria_open_list,&info->open_list); maria_open_list=list_delete(maria_open_list,&info->open_list);
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);
......
...@@ -345,7 +345,7 @@ static int w_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -345,7 +345,7 @@ static int w_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
my_bool was_last_key; my_bool was_last_key;
my_off_t next_page, dupp_key_pos; my_off_t next_page, dupp_key_pos;
DBUG_ENTER("w_search"); DBUG_ENTER("w_search");
DBUG_PRINT("enter",("page: %ld",page)); DBUG_PRINT("enter",("page: %ld", (long) page));
search_key_length= (comp_flag & SEARCH_FIND) ? key_length : USE_WHOLE_KEY; search_key_length= (comp_flag & SEARCH_FIND) ? key_length : USE_WHOLE_KEY;
if (!(temp_buff= (uchar*) my_alloca((uint) keyinfo->block_length+ if (!(temp_buff= (uchar*) my_alloca((uint) keyinfo->block_length+
...@@ -468,7 +468,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -468,7 +468,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
uchar *endpos, *prev_key; uchar *endpos, *prev_key;
MARIA_KEY_PARAM s_temp; MARIA_KEY_PARAM s_temp;
DBUG_ENTER("_ma_insert"); DBUG_ENTER("_ma_insert");
DBUG_PRINT("enter",("key_pos: %lx",key_pos)); DBUG_PRINT("enter",("key_pos: %lx", (long) key_pos));
DBUG_EXECUTE("key", _ma_print_key(DBUG_FILE,keyinfo->seg,key, DBUG_EXECUTE("key", _ma_print_key(DBUG_FILE,keyinfo->seg,key,
USE_WHOLE_KEY);); USE_WHOLE_KEY););
...@@ -490,8 +490,8 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -490,8 +490,8 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
{ {
DBUG_PRINT("test",("t_length: %d ref_len: %d", DBUG_PRINT("test",("t_length: %d ref_len: %d",
t_length,s_temp.ref_length)); t_length,s_temp.ref_length));
DBUG_PRINT("test",("n_ref_len: %d n_length: %d key_pos: %lx", DBUG_PRINT("test",("n_ref_len: %d n_length: %d key_pos: 0x%lx",
s_temp.n_ref_length,s_temp.n_length,s_temp.key)); s_temp.n_ref_length,s_temp.n_length, (long) s_temp.key));
} }
#endif #endif
if (t_length > 0) if (t_length > 0)
...@@ -684,7 +684,8 @@ uchar *_ma_find_half_pos(uint nod_flag, MARIA_KEYDEF *keyinfo, uchar *page, ...@@ -684,7 +684,8 @@ uchar *_ma_find_half_pos(uint nod_flag, MARIA_KEYDEF *keyinfo, uchar *page,
} while (page < end); } while (page < end);
*return_key_length=length; *return_key_length=length;
*after_key=page; *after_key=page;
DBUG_PRINT("exit",("returns: %lx page: %lx half: %lx",lastpos,page,end)); DBUG_PRINT("exit",("returns: 0x%lx page: 0x%lx half: 0x%lx",
(long) lastpos, (long) page, (long) end));
DBUG_RETURN(lastpos); DBUG_RETURN(lastpos);
} /* _ma_find_half_pos */ } /* _ma_find_half_pos */
...@@ -739,7 +740,8 @@ static uchar *_ma_find_last_pos(MARIA_KEYDEF *keyinfo, uchar *page, ...@@ -739,7 +740,8 @@ static uchar *_ma_find_last_pos(MARIA_KEYDEF *keyinfo, uchar *page,
} }
*return_key_length=last_length; *return_key_length=last_length;
*after_key=lastpos; *after_key=lastpos;
DBUG_PRINT("exit",("returns: %lx page: %lx end: %lx",prevpos,page,end)); DBUG_PRINT("exit",("returns: 0x%lx page: 0x%lx end: 0x%lx",
(long) prevpos,(long) page,(long) end));
DBUG_RETURN(prevpos); DBUG_RETURN(prevpos);
} /* _ma_find_last_pos */ } /* _ma_find_last_pos */
...@@ -775,7 +777,7 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -775,7 +777,7 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
next_page= _ma_kpos(info->s->base.key_reflength, next_page= _ma_kpos(info->s->base.key_reflength,
father_key_pos+father_keylength); father_key_pos+father_keylength);
buff=info->buff; buff=info->buff;
DBUG_PRINT("test",("use right page: %lu",next_page)); DBUG_PRINT("test",("use right page: %lu", (ulong) next_page));
} }
else else
{ {
...@@ -784,7 +786,7 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -784,7 +786,7 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
next_page= _ma_kpos(info->s->base.key_reflength,father_key_pos); next_page= _ma_kpos(info->s->base.key_reflength,father_key_pos);
/* Fix that curr_buff is to left */ /* Fix that curr_buff is to left */
buff=curr_buff; curr_buff=info->buff; buff=curr_buff; curr_buff=info->buff;
DBUG_PRINT("test",("use left page: %lu",next_page)); DBUG_PRINT("test",("use left page: %lu", (ulong) next_page));
} /* father_key_pos ptr to parting key */ } /* father_key_pos ptr to parting key */
if (!_ma_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,info->buff,0)) if (!_ma_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,info->buff,0))
......
...@@ -662,7 +662,7 @@ typedef struct st_maria_block_info ...@@ -662,7 +662,7 @@ typedef struct st_maria_block_info
extern uint _ma_get_block_info(MARIA_BLOCK_INFO *, File, my_off_t); extern uint _ma_get_block_info(MARIA_BLOCK_INFO *, File, my_off_t);
extern uint _ma_rec_pack(MARIA_HA *info, byte *to, const byte *from); extern uint _ma_rec_pack(MARIA_HA *info, byte *to, const byte *from);
extern uint _ma_pack_get_block_info(MARIA_HA *mari, MARIA_BIT_BUFF *bit_buff, extern uint _ma_pack_get_block_info(MARIA_HA *maria, MARIA_BIT_BUFF *bit_buff,
MARIA_BLOCK_INFO *info, byte **rec_buff_p, MARIA_BLOCK_INFO *info, byte **rec_buff_p,
File file, my_off_t filepos); File file, my_off_t filepos);
extern void _ma_store_blob_length(byte *pos, uint pack_length, uint length); extern void _ma_store_blob_length(byte *pos, uint pack_length, uint length);
......
...@@ -366,9 +366,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, ...@@ -366,9 +366,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
{ /* This happens only with packed keys */ { /* This happens only with packed keys */
DBUG_PRINT("test",("Enlarging of key when deleting")); DBUG_PRINT("test",("Enlarging of key when deleting"));
if (!_mi_get_last_key(info,keyinfo,anc_buff,lastkey,keypos,&length)) if (!_mi_get_last_key(info,keyinfo,anc_buff,lastkey,keypos,&length))
{
goto err; goto err;
}
ret_value=_mi_insert(info,keyinfo,key,anc_buff,keypos,lastkey, ret_value=_mi_insert(info,keyinfo,key,anc_buff,keypos,lastkey,
(uchar*) 0,(uchar*) 0,(my_off_t) 0,(my_bool) 0); (uchar*) 0,(uchar*) 0,(my_off_t) 0,(my_bool) 0);
} }
......
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