summaryrefslogtreecommitdiff
path: root/myisam/mi_open.c
diff options
context:
space:
mode:
Diffstat (limited to 'myisam/mi_open.c')
-rw-r--r--myisam/mi_open.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index c417186de6a..c9ecdaab47f 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -507,9 +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_fix_rec_buff_for_blob(&info, 0))
+ if (!mi_fix_rec_buff_for_blob(&info, -1))
goto err;
- bzero(info.rec_alloc, info.alloced_rec_buff_length);
+ bzero(info.rec_buff, info.alloced_rec_buff_length);
*m_info=info;
#ifdef THREAD
@@ -559,6 +559,39 @@ 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)
+{
+ uint extra;
+
+ if (! *buf || length > *buf_len)
+ {
+ byte *newptr = *buf;
+
+ /* to simplify initial init of info->rec_buf in mi_open and mi_extra */
+ if (length == (ulong)-1)
+ length=max(info->s->base.pack_reclength,info->s->base.max_key_length);
+
+ extra= ((info->s->options & HA_OPTION_PACK_RECORD) ?
+ ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+
+ MI_REC_BUFF_OFFSET : 0);
+ if (extra && newptr)
+ newptr-=MI_REC_BUFF_OFFSET;
+ if (!(newptr=(byte*) my_realloc((gptr)newptr, length+extra+8,
+ MYF(MY_ALLOW_ZERO_PTR))))
+ return 0;
+ *buf=newptr+(extra ? MI_REC_BUFF_OFFSET : 0);
+ *buf_len=length;
+ }
+ return *buf;
+}
ulonglong mi_safe_mul(ulonglong a, ulonglong b)
{