summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorunknown <guilhem@gbichot2.(none)>2007-01-03 12:41:51 +0100
committerunknown <guilhem@gbichot2.(none)>2007-01-03 12:41:51 +0100
commitb635df555adec7ebdc4cd40e102d51006c802639 (patch)
tree334aeb2223aef37379f49180b4b65377e4823806 /storage
parentba7a2a9ab788748b2dffa8526fd4aa1d9396a26e (diff)
downloadmariadb-git-b635df555adec7ebdc4cd40e102d51006c802639.tar.gz
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
Diffstat (limited to 'storage')
-rw-r--r--storage/maria/ma_checkpoint.c44
-rw-r--r--storage/maria/ma_close.c8
-rw-r--r--storage/maria/ma_write.c18
-rw-r--r--storage/maria/maria_def.h2
-rw-r--r--storage/myisam/mi_delete.c2
5 files changed, 51 insertions, 23 deletions
diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c
index 4294acb5627..02d887f758a 100644
--- a/storage/maria/ma_checkpoint.c
+++ b/storage/maria/ma_checkpoint.c
@@ -216,14 +216,27 @@ my_bool execute_checkpoint_indirect()
if (NULL == (strings[4].str= my_malloc(strings[4].length)))
goto err;
ptr= string3.str;
- /* possibly latch each MARIA_SHARE, one by one, like this: */
- pthread_mutex_lock(&share->intern_lock);
/*
- We'll copy the file id (a bit like share->kfile), the file name
- (like share->unique_file_name[_length]).
+ 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*).
*/
- make_copy_of_global_share_list_to_array;
- pthread_mutex_unlock(&share->intern_lock);
+ for (iterate on the maria_open_list)
+ {
+ /* latch each MARIA_SHARE, one by one, like this: */
+ pthread_mutex_lock(&share->intern_lock);
+ /*
+ TODO:
+ 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.
+ */
+ pthread_mutex_unlock(&share->intern_lock);
+ store the share pointer into a private array;
+ }
unlock(global_share_list_mutex);
/* work on copy */
@@ -231,15 +244,15 @@ my_bool execute_checkpoint_indirect()
ptr+= 8;
for (el in array)
{
- int8store(ptr, array[...].file_id);
+ int8store(ptr, array[...].short_id);
ptr+= 8;
- memcpy(ptr, array[...].file_name, ...);
+ memcpy(ptr, array[...].unique_file_name[_length], ...);
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
list, to not keep the list locked for long:
*/
- /* TODO: what if the table pointer is gone/reused now? */
flush_bitmap_pages(el);
/* TODO: and also autoinc counter, logical file end, free page list */
@@ -267,6 +280,19 @@ my_bool execute_checkpoint_indirect()
if (0 != control_file_write_and_force(checkpoint_lsn, NULL))
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;
err:
diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c
index 5d7b24cc314..e1a4bb08301 100644
--- a/storage/maria/ma_close.c
+++ b/storage/maria/ma_close.c
@@ -60,9 +60,11 @@ int maria_close(register MARIA_HA *info)
flag= !--share->reopen;
/*
RECOVERYTODO:
- Below we are going to make the table unknown to future checkpoints, so it
- needs to have fsync'ed itself entirely (bitmap, pages, etc) at this
- point.
+ If "flag" is TRUE, in the line below we are going to make the table
+ unknown to future checkpoints, so it needs to have fsync'ed itself
+ 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);
pthread_mutex_unlock(&share->intern_lock);
diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c
index c56a26fefff..55c0bf27259 100644
--- a/storage/maria/ma_write.c
+++ b/storage/maria/ma_write.c
@@ -345,7 +345,7 @@ static int w_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
my_bool was_last_key;
my_off_t next_page, dupp_key_pos;
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;
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,
uchar *endpos, *prev_key;
MARIA_KEY_PARAM s_temp;
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,
USE_WHOLE_KEY););
@@ -490,8 +490,8 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
{
DBUG_PRINT("test",("t_length: %d ref_len: %d",
t_length,s_temp.ref_length));
- DBUG_PRINT("test",("n_ref_len: %d n_length: %d key_pos: %lx",
- s_temp.n_ref_length,s_temp.n_length,s_temp.key));
+ DBUG_PRINT("test",("n_ref_len: %d n_length: %d key_pos: 0x%lx",
+ s_temp.n_ref_length,s_temp.n_length, (long) s_temp.key));
}
#endif
if (t_length > 0)
@@ -684,7 +684,8 @@ uchar *_ma_find_half_pos(uint nod_flag, MARIA_KEYDEF *keyinfo, uchar *page,
} while (page < end);
*return_key_length=length;
*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);
} /* _ma_find_half_pos */
@@ -739,7 +740,8 @@ static uchar *_ma_find_last_pos(MARIA_KEYDEF *keyinfo, uchar *page,
}
*return_key_length=last_length;
*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);
} /* _ma_find_last_pos */
@@ -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,
father_key_pos+father_keylength);
buff=info->buff;
- DBUG_PRINT("test",("use right page: %lu",next_page));
+ DBUG_PRINT("test",("use right page: %lu", (ulong) next_page));
}
else
{
@@ -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);
/* Fix that curr_buff is to left */
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 */
if (!_ma_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,info->buff,0))
diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h
index 5fb25512d4c..9585ecad292 100644
--- a/storage/maria/maria_def.h
+++ b/storage/maria/maria_def.h
@@ -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_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,
File file, my_off_t filepos);
extern void _ma_store_blob_length(byte *pos, uint pack_length, uint length);
diff --git a/storage/myisam/mi_delete.c b/storage/myisam/mi_delete.c
index 7972ef614a0..1a683e2ac30 100644
--- a/storage/myisam/mi_delete.c
+++ b/storage/myisam/mi_delete.c
@@ -366,9 +366,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
{ /* This happens only with packed keys */
DBUG_PRINT("test",("Enlarging of key when deleting"));
if (!_mi_get_last_key(info,keyinfo,anc_buff,lastkey,keypos,&length))
- {
goto err;
- }
ret_value=_mi_insert(info,keyinfo,key,anc_buff,keypos,lastkey,
(uchar*) 0,(uchar*) 0,(my_off_t) 0,(my_bool) 0);
}