diff options
author | unknown <serg@sergbook.mysql.com> | 2002-07-26 14:42:51 +0200 |
---|---|---|
committer | unknown <serg@sergbook.mysql.com> | 2002-07-26 14:42:51 +0200 |
commit | b0f2b107f912a898aed4a0ce82add12f6df801a3 (patch) | |
tree | 0ec06db644f83dcda914d46e0e1ecad40ea13ab4 /myisam | |
parent | 520e95898e360cf2495c664dcfd3ad7aed893551 (diff) | |
download | mariadb-git-b0f2b107f912a898aed4a0ce82add12f6df801a3.tar.gz |
MyISAM: always store alloced_rec_buff_length with the buffer itself
include/myisam.h:
always store alloced_rec_buff_length with the buffer itself
myisam/mi_check.c:
always store alloced_rec_buff_length with the buffer itself
myisam/mi_dynrec.c:
always store alloced_rec_buff_length with the buffer itself
myisam/mi_extra.c:
always store alloced_rec_buff_length with the buffer itself
myisam/mi_key.c:
always store alloced_rec_buff_length with the buffer itself
myisam/mi_open.c:
always store alloced_rec_buff_length with the buffer itself
myisam/mi_packrec.c:
always store alloced_rec_buff_length with the buffer itself
myisam/myisamdef.h:
always store alloced_rec_buff_length with the buffer itself
Diffstat (limited to 'myisam')
-rw-r--r-- | myisam/mi_check.c | 8 | ||||
-rw-r--r-- | myisam/mi_dynrec.c | 11 | ||||
-rw-r--r-- | myisam/mi_extra.c | 3 | ||||
-rw-r--r-- | myisam/mi_key.c | 3 | ||||
-rw-r--r-- | myisam/mi_open.c | 25 | ||||
-rw-r--r-- | myisam/mi_packrec.c | 6 | ||||
-rw-r--r-- | myisam/myisamdef.h | 13 |
7 files changed, 24 insertions, 45 deletions
diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 91990dc3b66..0ac0917e8cd 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -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)); diff --git a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c index 4ef4f80d137..8a9ca8aab34 100644 --- a/myisam/mi_dynrec.c +++ b/myisam/mi_dynrec.c @@ -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 diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index 8ac65975a5c..519cc5bc2b8 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -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; diff --git a/myisam/mi_key.c b/myisam/mi_key.c index 3cee1f301e1..9ec1ca99e0e 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -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; diff --git a/myisam/mi_open.c b/myisam/mi_open.c index feed8f29df8..f621e4b760c 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -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; @@ -588,10 +577,10 @@ byte *mi_alloc_rec_buff(MI_INFO *info, ulong length, byte **buf, uint *buf_len) 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; + MYF(MY_ALLOW_ZERO_PTR)))) + return newptr; + *((uint *)newptr)=length; *buf= newptr+(extra ? MI_REC_BUFF_OFFSET : 0); - *buf_len= length; } return *buf; } diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c index 07abde07644..818788a5e74 100644 --- a/myisam/mi_packrec.c +++ b/myisam/mi_packrec.c @@ -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; } diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index 73b9a1280a4..f0d6f740661 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -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); |