Commit 9a1ff13e authored by unknown's avatar unknown

mi_fix_rec_buff_for_blob() generalized a bit


myisam/mi_extra.c:
  make use of new mi_fix_rec_buff_for_blob(), and fix a (possible) bug
myisam/mi_open.c:
  make use of new mi_fix_rec_buff_for_blob()
parent 79bdeb9d
...@@ -1094,16 +1094,23 @@ int _mi_read_dynamic_record(MI_INFO *info, my_off_t filepos, byte *buf) ...@@ -1094,16 +1094,23 @@ int _mi_read_dynamic_record(MI_INFO *info, my_off_t filepos, byte *buf)
byte *mi_fix_rec_buff_for_blob(MI_INFO *info, ulong length) byte *mi_fix_rec_buff_for_blob(MI_INFO *info, ulong length)
{ {
uint extra; uint extra;
/* to simplify initial init of info->rec_buf in mi_open and mi_extra */
if (!length)
length=max(info->s->base.pack_reclength,info->s->base.max_key_length);
if (! info->rec_buff || length > info->alloced_rec_buff_length) if (! info->rec_buff || length > info->alloced_rec_buff_length)
{ {
byte *newptr; byte *newptr;
extra=ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+ extra= ((info->s->options & HA_OPTION_PACK_RECORD) ?
MI_DYN_DELETE_BLOCK_HEADER; ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+
if (!(newptr=(byte*) my_realloc((gptr) info->rec_alloc,length+extra, MI_DYN_DELETE_BLOCK_HEADER : 0);
if (!(newptr=(byte*) my_realloc((gptr) info->rec_alloc,length+extra+8,
MYF(MY_ALLOW_ZERO_PTR)))) MYF(MY_ALLOW_ZERO_PTR))))
return newptr; return (byte *)0;
info->rec_alloc=newptr; info->rec_alloc=newptr;
info->rec_buff=newptr+ALIGN_SIZE(MI_DYN_DELETE_BLOCK_HEADER); info->rec_buff=newptr+(extra ?
ALIGN_SIZE(MI_DYN_DELETE_BLOCK_HEADER) : 0);
info->alloced_rec_buff_length=length; info->alloced_rec_buff_length=length;
} }
return info->rec_buff; return info->rec_buff;
......
...@@ -331,7 +331,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function) ...@@ -331,7 +331,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function)
{ {
my_free(info->rec_alloc,MYF(MY_ALLOW_ZERO_PTR)); my_free(info->rec_alloc,MYF(MY_ALLOW_ZERO_PTR));
info->rec_alloc=info->rec_buff=0; info->rec_alloc=info->rec_buff=0;
mi_fix_rec_buff_for_blob(info,info->s->base.pack_reclength); mi_fix_rec_buff_for_blob(info, 0);
} }
break; break;
case HA_EXTRA_NORMAL: /* Theese isn't in use */ case HA_EXTRA_NORMAL: /* Theese isn't in use */
......
...@@ -506,20 +506,10 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -506,20 +506,10 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
/* Allocate buffer for one record */ /* Allocate buffer for one record */
extra=0; /* prerequisites: bzero(info) && info->s=share; are met. */
if (share->options & HA_OPTION_PACK_RECORD) if (!mi_fix_rec_buff_for_blob(&info, 0))
extra=ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+
MI_DYN_DELETE_BLOCK_HEADER;
tmp_length=max(share->base.pack_reclength,share->base.max_key_length);
info.alloced_rec_buff_length=tmp_length;
if (!(info.rec_alloc=(byte*) my_malloc(tmp_length+extra+8,
MYF(MY_WME | MY_ZEROFILL))))
goto err; goto err;
if (extra) bzero(info.rec_alloc, info.alloced_rec_buff_length);
info.rec_buff=info.rec_alloc+ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER);
else
info.rec_buff=info.rec_alloc;
*m_info=info; *m_info=info;
#ifdef THREAD #ifdef THREAD
......
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