Commit 4b39d33c authored by serg@sergbook.mysql.com's avatar serg@sergbook.mysql.com

Merge work:/home/bk/mysql-4.0

into sergbook.mysql.com:/usr/home/serg/Abk/mysql-4.0
parents bdc0ff6b 43ef1198
......@@ -379,7 +379,6 @@ typedef struct st_mi_sort_param
my_off_t pos,max_pos,filepos,start_recpos;
uint key, key_length,real_key_length,sortbuff_size;
uint maxbuffers, keys, find_length, sort_keys_length;
uint alloced_rec_buff_length;
my_bool fix_datafile, master;
MI_KEYDEF *keyinfo;
SORT_INFO *sort_info;
......
......@@ -841,8 +841,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
if (info->s->base.blobs)
{
if (!(to= mi_alloc_rec_buff(info, block_info.rec_len,
&info->rec_buff,
&info->alloced_rec_buff_length)))
&info->rec_buff)))
{
mi_check_print_error(param,"Not enough memory for blob at %s",
llstr(start_recpos,llbuff));
......@@ -1146,7 +1145,6 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
goto err;
info->opt_flag|=WRITE_CACHE_USED;
sort_param.rec_buff=info->rec_buff;
sort_param.alloced_rec_buff_length=info->alloced_rec_buff_length;
if (!(sort_param.record=(byte*) my_malloc((uint) share->base.pack_reclength,
MYF(0))))
{
......@@ -1810,7 +1808,6 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
info->rec_cache.file=info->dfile; /* for sort_delete_record */
sort_param.rec_buff=info->rec_buff;
sort_param.alloced_rec_buff_length=info->alloced_rec_buff_length;
if (!(sort_param.record=(byte*) my_malloc((uint) share->base.pack_reclength,
MYF(0))))
{
......@@ -2793,8 +2790,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param)
if (share->base.blobs)
{
if (!(to=mi_alloc_rec_buff(info,block_info.rec_len,
&(sort_param->rec_buff),
&(sort_param->alloced_rec_buff_length))))
&(sort_param->rec_buff))))
{
mi_check_print_error(param,"Not enough memory for blob at %s",
llstr(sort_param->start_recpos,llbuff));
......
......@@ -1060,8 +1060,7 @@ int _mi_read_dynamic_record(MI_INFO *info, my_off_t filepos, byte *buf)
if (info->s->base.blobs)
{
if (!(to=mi_alloc_rec_buff(info, block_info.rec_len,
&info->rec_buff,
&info->alloced_rec_buff_length)))
&info->rec_buff)))
goto err;
}
else
......@@ -1107,12 +1106,8 @@ int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def,
/* Don't let the compare destroy blobs that may be in use */
rec_buff=info->rec_buff;
alloced_rec_buff_length=info->alloced_rec_buff_length;
if (info->s->base.blobs)
{
info->rec_buff=0;
info->alloced_rec_buff_length=0;
}
error=_mi_read_dynamic_record(info,pos,old_record);
if (!error)
error=mi_unique_comp(def, record, old_record, def->null_are_equal);
......@@ -1120,7 +1115,6 @@ int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def,
{
my_free(mi_get_rec_buff_ptr(info, info->rec_buff), MYF(MY_ALLOW_ZERO_PTR));
info->rec_buff=rec_buff;
info->alloced_rec_buff_length=alloced_rec_buff_length;
}
my_afree(old_record);
DBUG_RETURN(error);
......@@ -1331,8 +1325,7 @@ int _mi_read_rnd_dynamic_record(MI_INFO *info, byte *buf,
if (share->base.blobs)
{
if (!(to= mi_alloc_rec_buff(info, block_info.rec_len,
&info->rec_buff,
&info->alloced_rec_buff_length)))
&info->rec_buff)))
goto err;
}
else
......
......@@ -344,8 +344,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
}
}
if (share->base.blobs)
mi_alloc_rec_buff(info, -1, &info->rec_buff,
&info->alloced_rec_buff_length);
mi_alloc_rec_buff(info, -1, &info->rec_buff);
break;
case HA_EXTRA_NORMAL: /* Theese isn't in use */
info->quick_mode=0;
......
......@@ -251,8 +251,7 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr,
{
if (!(blob_ptr=
mi_alloc_rec_buff(info, info->s->keyinfo[keynr].keylength,
&info->rec_buff,
&info->alloced_rec_buff_length)))
&info->rec_buff)))
goto err;
}
key=(byte*) info->lastkey;
......
......@@ -507,10 +507,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
/* Allocate buffer for one record */
/* prerequisites: bzero(info) && info->s=share; are met. */
if (!mi_alloc_rec_buff(&info, -1, &info.rec_buff,
&info.alloced_rec_buff_length))
if (!mi_alloc_rec_buff(&info, -1, &info.rec_buff))
goto err;
bzero(info.rec_buff, info.alloced_rec_buff_length);
bzero(info.rec_buff, mi_get_rec_buff_len(&info, info.rec_buff));
*m_info=info;
#ifdef THREAD
......@@ -560,21 +559,11 @@ err:
DBUG_RETURN (NULL);
} /* mi_open */
gptr mi_get_rec_buff_ptr(MI_INFO *info, byte *buf)
{
if (info->s->options & HA_OPTION_PACK_RECORD && buf)
return buf - MI_REC_BUFF_OFFSET;
else
return buf;
}
byte *mi_alloc_rec_buff(MI_INFO *info, ulong length, byte **buf, uint *buf_len)
byte *mi_alloc_rec_buff(MI_INFO *info, ulong length, byte **buf)
{
uint extra;
if (! *buf || length > *buf_len)
if (! *buf || length > mi_get_rec_buff_len(info, *buf))
{
byte *newptr = *buf;
......@@ -589,9 +578,9 @@ byte *mi_alloc_rec_buff(MI_INFO *info, ulong length, byte **buf, uint *buf_len)
newptr-=MI_REC_BUFF_OFFSET;
if (!(newptr=(byte*) my_realloc((gptr)newptr, length+extra+8,
MYF(MY_ALLOW_ZERO_PTR))))
return 0;
return newptr;
*((uint *)newptr)=length;
*buf= newptr+(extra ? MI_REC_BUFF_OFFSET : 0);
*buf_len= length;
}
return *buf;
}
......
......@@ -1058,8 +1058,7 @@ uint _mi_pack_get_block_info(MI_INFO *myisam, MI_BLOCK_INFO *info, File file,
head_length+=4;
}
if (!(mi_alloc_rec_buff(myisam,info->rec_len + info->blob_len,
&myisam->rec_buff,
&myisam->alloced_rec_buff_length)))
&myisam->rec_buff)))
return BLOCK_FATAL_ERROR; /* not enough memory */
myisam->bit_buff.blob_pos=(uchar*) myisam->rec_buff+info->rec_len;
myisam->blob_length=info->blob_len;
......@@ -1235,8 +1234,7 @@ static uchar *_mi_mempack_get_block_info(MI_INFO *myisam,MI_BLOCK_INFO *info,
}
/* mi_alloc_rec_buff sets my_errno on error */
if (!(mi_alloc_rec_buff(myisam, info->blob_len,
&myisam->rec_buff,
&myisam->alloced_rec_buff_length)))
&myisam->rec_buff)))
return 0; /* not enough memory */
myisam->bit_buff.blob_pos=(uchar*) myisam->rec_buff;
}
......
......@@ -247,7 +247,6 @@ struct st_myisam_info {
int dfile; /* The datafile */
uint opt_flag; /* Optim. for space/speed */
uint update; /* If file changed since open */
uint alloced_rec_buff_length; /* Max recordlength malloced */
uint int_nod_flag; /* -""- */
int lastinx; /* Last used index */
uint lastkey_length; /* Length of key in lastkey */
......@@ -359,7 +358,7 @@ struct st_myisam_info {
#define MI_DYN_ALIGN_SIZE 4 /* Align blocks on this */
#define MI_MAX_DYN_HEADER_BYTE 13 /* max header byte for dynamic rows */
#define MI_MAX_BLOCK_LENGTH ((((ulong) 1 << 24)-1) & (~ (ulong) (MI_DYN_ALIGN_SIZE-1)))
#define MI_REC_BUFF_OFFSET ALIGN_SIZE(MI_DYN_DELETE_BLOCK_HEADER)
#define MI_REC_BUFF_OFFSET ALIGN_SIZE(MI_DYN_DELETE_BLOCK_HEADER+sizeof(uint))
#define MEMMAP_EXTRA_MARGIN 7 /* Write this as a suffix for file */
......@@ -523,8 +522,14 @@ extern int _mi_read_key_record(MI_INFO *info,my_off_t filepos,byte *buf);
extern int _mi_read_cache(IO_CACHE *info,byte *buff,my_off_t pos,
uint length,int re_read_if_possibly);
extern void update_auto_increment(MI_INFO *info,const byte *record);
extern byte *mi_alloc_rec_buff(MI_INFO *,ulong, byte**, uint*);
extern gptr mi_get_rec_buff_ptr(MI_INFO *, byte *);
extern byte *mi_alloc_rec_buff(MI_INFO *,ulong, byte**);
#define mi_get_rec_buff_ptr(info,buf) \
((((info)->s->options & HA_OPTION_PACK_RECORD) && (buf)) ? \
(buf) - MI_REC_BUFF_OFFSET : (buf))
#define mi_get_rec_buff_len(info,buf) \
(*((uint *)(mi_get_rec_buff_ptr(info,buf))))
extern ulong _mi_rec_unpack(MI_INFO *info,byte *to,byte *from,
ulong reclength);
extern my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *packpos);
......
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