mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
Merge work:/my/mysql-4.0 into mashka.mysql.fi:/home/my/mysql-4.0
This commit is contained in:
commit
cf2ef3c68f
17 changed files with 207 additions and 52 deletions
|
|
@ -601,7 +601,8 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
|
|||
if (*keys != 1L) /* not first_key */
|
||||
{
|
||||
uint diff;
|
||||
_mi_key_cmp(keyinfo->seg,info->lastkey,key,USE_WHOLE_KEY,SEARCH_FIND,
|
||||
_mi_key_cmp(keyinfo->seg,info->lastkey,key,USE_WHOLE_KEY,
|
||||
SEARCH_FIND | SEARCH_NULL_ARE_NOT_EQUAL,
|
||||
&diff);
|
||||
param->unique_count[diff-1]++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,12 +55,17 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
|
|||
/*
|
||||
Free buffers and reset the following flags:
|
||||
EXTRA_CACHE, EXTRA_WRITE_CACHE, EXTRA_KEYREAD, EXTRA_QUICK
|
||||
|
||||
If the row buffer cache is large (for dynamic tables), reduce it
|
||||
to save memory.
|
||||
*/
|
||||
if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
|
||||
{
|
||||
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
|
||||
error=end_io_cache(&info->rec_cache);
|
||||
}
|
||||
if (share->base.blobs)
|
||||
mi_alloc_rec_buff(info, -1, &info->rec_buff);
|
||||
#if defined(HAVE_MMAP) && defined(HAVE_MADVICE)
|
||||
if (info->opt_flag & MEMMAP_USED)
|
||||
madvise(share->file_map,share->state.state.data_file_length,MADV_RANDOM);
|
||||
|
|
|
|||
|
|
@ -559,28 +559,36 @@ err:
|
|||
DBUG_RETURN (NULL);
|
||||
} /* mi_open */
|
||||
|
||||
|
||||
byte *mi_alloc_rec_buff(MI_INFO *info, ulong length, byte **buf)
|
||||
{
|
||||
uint extra;
|
||||
uint32 old_length;
|
||||
LINT_INIT(old_length);
|
||||
|
||||
if (! *buf || length > mi_get_rec_buff_len(info, *buf))
|
||||
if (! *buf || length > (old_length=mi_get_rec_buff_len(info, *buf)))
|
||||
{
|
||||
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.pack_bits,
|
||||
info->s->base.max_key_length);
|
||||
/* Avoid unnecessary realloc */
|
||||
if (newptr && length == old_length)
|
||||
return newptr;
|
||||
}
|
||||
|
||||
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;
|
||||
newptr-= MI_REC_BUFF_OFFSET;
|
||||
if (!(newptr=(byte*) my_realloc((gptr)newptr, length+extra+8,
|
||||
MYF(MY_ALLOW_ZERO_PTR))))
|
||||
return newptr;
|
||||
*((uint *)newptr)=length;
|
||||
*((uint32 *) newptr)= (uint32) length;
|
||||
*buf= newptr+(extra ? MI_REC_BUFF_OFFSET : 0);
|
||||
}
|
||||
return *buf;
|
||||
|
|
|
|||
|
|
@ -260,9 +260,11 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
|
|||
uchar *key, uint key_len, uint nextflag, uchar **ret_pos,
|
||||
uchar *buff, my_bool *last_key)
|
||||
{
|
||||
/* my_flag is raw comparison result to be changed according to
|
||||
SEARCH_NO_FIND,SEARCH_LAST and HA_REVERSE_SORT flags.
|
||||
flag is the value returned by _mi_key_cmp and as treated as final */
|
||||
/*
|
||||
my_flag is raw comparison result to be changed according to
|
||||
SEARCH_NO_FIND,SEARCH_LAST and HA_REVERSE_SORT flags.
|
||||
flag is the value returned by _mi_key_cmp and as treated as final
|
||||
*/
|
||||
int flag=0, my_flag=-1;
|
||||
uint nod_flag, length, len, matched, cmplen, kseg_len;
|
||||
uint prefix_len,suffix_len;
|
||||
|
|
@ -695,13 +697,29 @@ static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
** Compare two keys
|
||||
** Returns <0, 0, >0 acording to which is bigger
|
||||
** Key_length specifies length of key to use. Number-keys can't
|
||||
** be splited
|
||||
** If flag <> SEARCH_FIND compare also position
|
||||
*/
|
||||
/*
|
||||
Compare two keys
|
||||
|
||||
SYNOPSIS
|
||||
_mi_key_cmp()
|
||||
keyseg Key segments of key to compare
|
||||
a First key to compare, in format from _mi_pack_key()
|
||||
This is normally key specified by user
|
||||
b Second key to compare. This is always from a row
|
||||
key_length Length of key to compare. This can be shorter than
|
||||
a to just compare sub keys
|
||||
next_flag How keys should be compared
|
||||
If bit SEARCH_FIND is not set the keys includes the row
|
||||
position and this should also be compared
|
||||
|
||||
NOTES
|
||||
Number-keys can't be splited
|
||||
|
||||
RETURN VALUES
|
||||
<0 If a < b
|
||||
0 If a == b
|
||||
>0 If a > b
|
||||
*/
|
||||
|
||||
#define FCMP(A,B) ((int) (A) - (int) (B))
|
||||
|
||||
|
|
@ -738,6 +756,15 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a,
|
|||
{
|
||||
if (nextflag == (SEARCH_FIND | SEARCH_UPDATE))
|
||||
nextflag=SEARCH_SAME; /* Allow duplicate keys */
|
||||
else if (nextflag & SEARCH_NULL_ARE_NOT_EQUAL)
|
||||
{
|
||||
/*
|
||||
This is only used from mi_check() to calculate cardinality.
|
||||
It can't be used when searching for a key as this would cause
|
||||
compare of (a,b) and (b,a) to return the same value.
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
next_key_length=key_length;
|
||||
continue; /* To next key part */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -358,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+sizeof(uint))
|
||||
#define MI_REC_BUFF_OFFSET ALIGN_SIZE(MI_DYN_DELETE_BLOCK_HEADER+sizeof(uint32))
|
||||
|
||||
#define MEMMAP_EXTRA_MARGIN 7 /* Write this as a suffix for file */
|
||||
|
||||
|
|
@ -529,7 +529,7 @@ extern byte *mi_alloc_rec_buff(MI_INFO *,ulong, byte**);
|
|||
((((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))))
|
||||
(*((uint32 *)(mi_get_rec_buff_ptr(info,buf))))
|
||||
|
||||
extern ulong _mi_rec_unpack(MI_INFO *info,byte *to,byte *from,
|
||||
ulong reclength);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue