summaryrefslogtreecommitdiff
path: root/storage/myisam/mi_packrec.c
diff options
context:
space:
mode:
authorunknown <istruewing@chilla.local>2006-10-09 22:24:55 +0200
committerunknown <istruewing@chilla.local>2006-10-09 22:24:55 +0200
commit1cb23de93fb2176e2d2bbef8e8e0f0d91edc11a4 (patch)
tree4a97bea85241a7f8e5d5684115f780d44d4bd93a /storage/myisam/mi_packrec.c
parenta7f8da2904525096fd6cf9c7999ce087ee4d9d4d (diff)
parent8f8340ab65e55dd0a7d2899728c6e0e707fca241 (diff)
downloadmariadb-git-1cb23de93fb2176e2d2bbef8e8e0f0d91edc11a4.tar.gz
Merge chilla.local:/home/mydev/mysql-5.0-bug8283
into chilla.local:/home/mydev/mysql-5.1-bug8283 include/my_sys.h: Auto merged include/myisam.h: Auto merged mysql-test/r/myisam.result: Auto merged mysql-test/t/myisam.test: Auto merged storage/myisam/mi_open.c: Auto merged storage/myisam/mi_packrec.c: Auto merged storage/myisam/myisamdef.h: Auto merged storage/myisam/mi_check.c: SCCS merged storage/myisam/sort.c: SCCS merged
Diffstat (limited to 'storage/myisam/mi_packrec.c')
-rw-r--r--storage/myisam/mi_packrec.c76
1 files changed, 44 insertions, 32 deletions
diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c
index 67c8b25878f..e743ac9006f 100644
--- a/storage/myisam/mi_packrec.c
+++ b/storage/myisam/mi_packrec.c
@@ -103,7 +103,8 @@ static uint fill_and_get_bits(MI_BIT_BUFF *bit_buff,uint count);
static void fill_buffer(MI_BIT_BUFF *bit_buff);
static uint max_bit(uint value);
#ifdef HAVE_MMAP
-static uchar *_mi_mempack_get_block_info(MI_INFO *myisam,MI_BLOCK_INFO *info,
+static uchar *_mi_mempack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff,
+ MI_BLOCK_INFO *info, byte **rec_buff_p,
uchar *header);
#endif
@@ -449,13 +450,15 @@ int _mi_read_pack_record(MI_INFO *info, my_off_t filepos, byte *buf)
DBUG_RETURN(-1); /* _search() didn't find record */
file=info->dfile;
- if (_mi_pack_get_block_info(info, &block_info, file, filepos))
+ if (_mi_pack_get_block_info(info, &info->bit_buff, &block_info,
+ &info->rec_buff, file, filepos))
goto err;
if (my_read(file,(byte*) info->rec_buff + block_info.offset ,
block_info.rec_len - block_info.offset, MYF(MY_NABP)))
goto panic;
info->update|= HA_STATE_AKTIV;
- DBUG_RETURN(_mi_pack_rec_unpack(info,buf,info->rec_buff,block_info.rec_len));
+ DBUG_RETURN(_mi_pack_rec_unpack(info, &info->bit_buff, buf,
+ info->rec_buff, block_info.rec_len));
panic:
my_errno=HA_ERR_WRONG_IN_RECORD;
err:
@@ -464,8 +467,8 @@ err:
-int _mi_pack_rec_unpack(register MI_INFO *info, register byte *to, byte *from,
- ulong reclength)
+int _mi_pack_rec_unpack(register MI_INFO *info, MI_BIT_BUFF *bit_buff,
+ register byte *to, byte *from, ulong reclength)
{
byte *end_field;
reg3 MI_COLUMNDEF *end;
@@ -473,18 +476,18 @@ int _mi_pack_rec_unpack(register MI_INFO *info, register byte *to, byte *from,
MYISAM_SHARE *share=info->s;
DBUG_ENTER("_mi_pack_rec_unpack");
- init_bit_buffer(&info->bit_buff, (uchar*) from,reclength);
+ init_bit_buffer(bit_buff, (uchar*) from, reclength);
for (current_field=share->rec, end=current_field+share->base.fields ;
current_field < end ;
current_field++,to=end_field)
{
end_field=to+current_field->length;
- (*current_field->unpack)(current_field,&info->bit_buff,(uchar*) to,
+ (*current_field->unpack)(current_field, bit_buff, (uchar*) to,
(uchar*) end_field);
}
- if (! info->bit_buff.error &&
- info->bit_buff.pos - info->bit_buff.bits/8 == info->bit_buff.end)
+ if (!bit_buff->error &&
+ bit_buff->pos - bit_buff->bits / 8 == bit_buff->end)
DBUG_RETURN(0);
info->update&= ~HA_STATE_AKTIV;
DBUG_RETURN(my_errno=HA_ERR_WRONG_IN_RECORD);
@@ -1015,13 +1018,16 @@ int _mi_read_rnd_pack_record(MI_INFO *info, byte *buf,
if (info->opt_flag & READ_CACHE_USED)
{
- if (_mi_read_cache(&info->rec_cache,(byte*) block_info.header,filepos,
- share->pack.ref_length, skip_deleted_blocks))
+ if (_mi_read_cache(&info->rec_cache, (byte*) block_info.header,
+ filepos, share->pack.ref_length,
+ skip_deleted_blocks ? READING_NEXT : 0))
goto err;
- b_type=_mi_pack_get_block_info(info,&block_info,-1, filepos);
+ b_type=_mi_pack_get_block_info(info, &info->bit_buff, &block_info,
+ &info->rec_buff, -1, filepos);
}
else
- b_type=_mi_pack_get_block_info(info,&block_info,info->dfile,filepos);
+ b_type=_mi_pack_get_block_info(info, &info->bit_buff, &block_info,
+ &info->rec_buff, info->dfile, filepos);
if (b_type)
goto err; /* Error code is already set */
#ifndef DBUG_OFF
@@ -1034,9 +1040,9 @@ int _mi_read_rnd_pack_record(MI_INFO *info, byte *buf,
if (info->opt_flag & READ_CACHE_USED)
{
- if (_mi_read_cache(&info->rec_cache,(byte*) info->rec_buff,
- block_info.filepos, block_info.rec_len,
- skip_deleted_blocks))
+ if (_mi_read_cache(&info->rec_cache, (byte*) info->rec_buff,
+ block_info.filepos, block_info.rec_len,
+ skip_deleted_blocks ? READING_NEXT : 0))
goto err;
}
else
@@ -1051,8 +1057,8 @@ int _mi_read_rnd_pack_record(MI_INFO *info, byte *buf,
info->nextpos=block_info.filepos+block_info.rec_len;
info->update|= HA_STATE_AKTIV | HA_STATE_KEY_CHANGED;
- DBUG_RETURN (_mi_pack_rec_unpack(info,buf,info->rec_buff,
- block_info.rec_len));
+ DBUG_RETURN (_mi_pack_rec_unpack(info, &info->bit_buff, buf,
+ info->rec_buff, block_info.rec_len));
err:
DBUG_RETURN(my_errno);
}
@@ -1060,8 +1066,9 @@ int _mi_read_rnd_pack_record(MI_INFO *info, byte *buf,
/* Read and process header from a huff-record-file */
-uint _mi_pack_get_block_info(MI_INFO *myisam, MI_BLOCK_INFO *info, File file,
- my_off_t filepos)
+uint _mi_pack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff,
+ MI_BLOCK_INFO *info, byte **rec_buff_p,
+ File file, my_off_t filepos)
{
uchar *header=info->header;
uint head_length,ref_length;
@@ -1086,17 +1093,17 @@ uint _mi_pack_get_block_info(MI_INFO *myisam, MI_BLOCK_INFO *info, File file,
head_length+= read_pack_length((uint) myisam->s->pack.version,
header + head_length, &info->blob_len);
if (!(mi_alloc_rec_buff(myisam,info->rec_len + info->blob_len,
- &myisam->rec_buff)))
+ rec_buff_p)))
return BLOCK_FATAL_ERROR; /* not enough memory */
- myisam->bit_buff.blob_pos=(uchar*) myisam->rec_buff+info->rec_len;
- myisam->bit_buff.blob_end= myisam->bit_buff.blob_pos+info->blob_len;
+ bit_buff->blob_pos= (uchar*) *rec_buff_p + info->rec_len;
+ bit_buff->blob_end= bit_buff->blob_pos + info->blob_len;
myisam->blob_length=info->blob_len;
}
info->filepos=filepos+head_length;
if (file > 0)
{
info->offset=min(info->rec_len, ref_length - head_length);
- memcpy(myisam->rec_buff, header+head_length, info->offset);
+ memcpy(*rec_buff_p, header + head_length, info->offset);
}
return 0;
}
@@ -1214,7 +1221,8 @@ void _mi_unmap_file(MI_INFO *info)
}
-static uchar *_mi_mempack_get_block_info(MI_INFO *myisam,MI_BLOCK_INFO *info,
+static uchar *_mi_mempack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff,
+ MI_BLOCK_INFO *info, byte **rec_buff_p,
uchar *header)
{
header+= read_pack_length((uint) myisam->s->pack.version, header,
@@ -1225,10 +1233,10 @@ static uchar *_mi_mempack_get_block_info(MI_INFO *myisam,MI_BLOCK_INFO *info,
&info->blob_len);
/* mi_alloc_rec_buff sets my_errno on error */
if (!(mi_alloc_rec_buff(myisam, info->blob_len,
- &myisam->rec_buff)))
+ rec_buff_p)))
return 0; /* not enough memory */
- myisam->bit_buff.blob_pos=(uchar*) myisam->rec_buff;
- myisam->bit_buff.blob_end= (uchar*) myisam->rec_buff + info->blob_len;
+ bit_buff->blob_pos= (uchar*) *rec_buff_p;
+ bit_buff->blob_end= (uchar*) *rec_buff_p + info->blob_len;
}
return header;
}
@@ -1244,11 +1252,13 @@ static int _mi_read_mempack_record(MI_INFO *info, my_off_t filepos, byte *buf)
if (filepos == HA_OFFSET_ERROR)
DBUG_RETURN(-1); /* _search() didn't find record */
- if (!(pos= (byte*) _mi_mempack_get_block_info(info,&block_info,
+ if (!(pos= (byte*) _mi_mempack_get_block_info(info, &info->bit_buff,
+ &block_info, &info->rec_buff,
(uchar*) share->file_map+
filepos)))
DBUG_RETURN(-1);
- DBUG_RETURN(_mi_pack_rec_unpack(info, buf, pos, block_info.rec_len));
+ DBUG_RETURN(_mi_pack_rec_unpack(info, &info->bit_buff, buf,
+ pos, block_info.rec_len));
}
@@ -1268,7 +1278,8 @@ static int _mi_read_rnd_mempack_record(MI_INFO *info, byte *buf,
my_errno=HA_ERR_END_OF_FILE;
goto err;
}
- if (!(pos= (byte*) _mi_mempack_get_block_info(info,&block_info,
+ if (!(pos= (byte*) _mi_mempack_get_block_info(info, &info->bit_buff,
+ &block_info, &info->rec_buff,
(uchar*)
(start=share->file_map+
filepos))))
@@ -1285,7 +1296,8 @@ static int _mi_read_rnd_mempack_record(MI_INFO *info, byte *buf,
info->nextpos=filepos+(uint) (pos-start)+block_info.rec_len;
info->update|= HA_STATE_AKTIV | HA_STATE_KEY_CHANGED;
- DBUG_RETURN (_mi_pack_rec_unpack(info,buf,pos, block_info.rec_len));
+ DBUG_RETURN (_mi_pack_rec_unpack(info, &info->bit_buff, buf,
+ pos, block_info.rec_len));
err:
DBUG_RETURN(my_errno);
}