Skip to content

Commit 5886090

Browse files
PART I: Keys support for MyMERGE tables myisammrg/ | Makefile.am | mymrgdef.h | support for keys myrg_open.c | & myrg_queue.c | bugfixes myrg_rfirst.c | myrg_rkey.c | myrg_rlast.c | myrg_rnext.c | myrg_rprev.c | myrg_rrnd.c | include/myisammrg.h | rkey/rnext/etc prototyped sql/ | ha_myisammrg.cc | support for keys ha_myisammrg.h | myisam/ | mi_rkey.c | buf==NULL extension, _mi_rkey() mi_rnext.c | mi_rprev.c | include/queues.h | reinit_queue() - same as init_queue, but w/o malloc mysys/queues.c | PART II: Miscellaneous myisam/common_words | deleted (looks like I checked it in by mistake) some files (like acconfig.h, Makefile.am, COPYING.LIB, etc) | Change mode to -rw-r--r-- (by `chmod a-x ')
1 parent 807460b commit 5886090

27 files changed

Lines changed: 519 additions & 38 deletions

Makefile.am

100755100644
File mode changed.

acconfig.h

100755100644
File mode changed.

include/myisammrg.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
2-
2+
33
This library is free software; you can redistribute it and/or
44
modify it under the terms of the GNU Library General Public
55
License as published by the Free Software Foundation; either
66
version 2 of the License, or (at your option) any later version.
7-
7+
88
This library is distributed in the hope that it will be useful,
99
but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1111
Library General Public License for more details.
12-
12+
1313
You should have received a copy of the GNU Library General Public
1414
License along with this library; if not, write to the Free
1515
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
@@ -30,6 +30,8 @@ extern "C" {
3030
#include <myisam.h>
3131
#endif
3232

33+
#include <queues.h>
34+
3335
#define MYRG_NAME_EXT ".MRG"
3436

3537
/* Param to/from myrg_info */
@@ -60,6 +62,7 @@ typedef struct st_myrg_info
6062
uint tables,options,reclength;
6163
my_bool cache_in_use;
6264
LIST open_list;
65+
QUEUE by_key;
6366
} MYRG_INFO;
6467

6568

@@ -70,6 +73,9 @@ extern int myrg_delete(MYRG_INFO *file,const byte *buff);
7073
extern MYRG_INFO *myrg_open(const char *name,int mode,int wait_if_locked);
7174
extern int myrg_panic(enum ha_panic_function function);
7275
extern int myrg_rfirst(MYRG_INFO *file,byte *buf,int inx);
76+
extern int myrg_rlast(MYRG_INFO *file,byte *buf,int inx);
77+
extern int myrg_rnext(MYRG_INFO *file,byte *buf,int inx);
78+
extern int myrg_rprev(MYRG_INFO *file,byte *buf,int inx);
7379
extern int myrg_rkey(MYRG_INFO *file,byte *buf,int inx,const byte *key,
7480
uint key_len, enum ha_rkey_function search_flag);
7581
extern int myrg_rrnd(MYRG_INFO *file,byte *buf,ulonglong pos);

include/mysql_version.h.in

100755100644
File mode changed.

include/queues.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ typedef struct st_queue {
4646
int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
4747
pbool max_at_top, int (*compare)(void *,byte *, byte *),
4848
void *first_cmp_arg);
49+
int reinit_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
50+
pbool max_at_top, int (*compare)(void *,byte *, byte *),
51+
void *first_cmp_arg);
4952
void delete_queue(QUEUE *queue);
5053
void queue_insert(QUEUE *queue,byte *element);
5154
byte *queue_remove(QUEUE *queue,uint idx);

myisam/mi_rkey.c

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
2-
2+
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
55
the Free Software Foundation; either version 2 of the License, or
66
(at your option) any later version.
7-
7+
88
This program is distributed in the hope that it will be useful,
99
but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111
GNU General Public License for more details.
12-
12+
1313
You should have received a copy of the GNU General Public License
1414
along with this program; if not, write to the Free Software
1515
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
@@ -22,27 +22,38 @@
2222
/* Read a record using key */
2323
/* Ordinary search_flag is 0 ; Give error if no record with key */
2424

25-
int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
26-
enum ha_rkey_function search_flag)
25+
int _mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
26+
enum ha_rkey_function search_flag, bool raw_key)
2727
{
2828
uchar *key_buff;
2929
MYISAM_SHARE *share=info->s;
3030
uint pack_key_length;
31-
DBUG_ENTER("mi_rkey");
31+
DBUG_ENTER("_mi_rkey");
3232
DBUG_PRINT("enter",("base: %lx inx: %d search_flag: %d",
3333
info,inx,search_flag));
3434

3535
if ((inx = _mi_check_index(info,inx)) < 0)
3636
DBUG_RETURN(my_errno);
3737

3838
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
39+
40+
if (raw_key)
41+
{
3942
if (key_len == 0)
4043
key_len=USE_WHOLE_KEY;
4144
key_buff=info->lastkey+info->s->base.max_key_length;
4245
pack_key_length=_mi_pack_key(info,(uint) inx,key_buff,(uchar*) key,key_len);
4346
info->last_rkey_length=pack_key_length;
4447
DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,share->keyinfo[inx].seg,
4548
key_buff,pack_key_length););
49+
}
50+
else
51+
{
52+
/* key is already packed! */
53+
key_buff=info->lastkey+info->s->base.max_key_length;
54+
info->last_rkey_length=pack_key_length=key_len;
55+
bmove(key_buff,key,key_len);
56+
}
4657

4758
if (_mi_readinfo(info,F_RDLCK,1))
4859
goto err;
@@ -69,6 +80,9 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
6980
if (share->concurrent_insert)
7081
rw_unlock(&share->key_root_lock[inx]);
7182

83+
if (!buf)
84+
DBUG_RETURN(info->lastpos==HA_OFFSET_ERROR ? my_errno : 0);
85+
7286
if (!(*info->read_record)(info,info->lastpos,buf))
7387
{
7488
info->update|= HA_STATE_AKTIV; /* Record is read */
@@ -86,4 +100,12 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
86100
info->update|=HA_STATE_NEXT_FOUND; /* Previous gives last row */
87101
err:
88102
DBUG_RETURN(my_errno);
89-
} /* mi_rkey */
103+
} /* _mi_rkey */
104+
105+
/* shouldn't forget to do it inline sometime */
106+
int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
107+
enum ha_rkey_function search_flag)
108+
{
109+
return _mi_rkey(info,buf,inx,key,key_len,search_flag,TRUE);
110+
}
111+

myisam/mi_rnext.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
2-
2+
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
55
the Free Software Foundation; either version 2 of the License, or
66
(at your option) any later version.
7-
7+
88
This program is distributed in the hope that it will be useful,
99
but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111
GNU General Public License for more details.
12-
12+
1313
You should have received a copy of the GNU General Public License
1414
along with this program; if not, write to the Free Software
1515
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
@@ -74,6 +74,10 @@ int mi_rnext(MI_INFO *info, byte *buf, int inx)
7474
if (my_errno == HA_ERR_KEY_NOT_FOUND)
7575
my_errno=HA_ERR_END_OF_FILE;
7676
}
77+
else if (!buf)
78+
{
79+
DBUG_RETURN(info->lastpos==HA_OFFSET_ERROR ? my_errno : 0);
80+
}
7781
else if (!(*info->read_record)(info,info->lastpos,buf))
7882
{
7983
info->update|= HA_STATE_AKTIV; /* Record is read */

myisam/mi_rprev.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
2-
2+
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
55
the Free Software Foundation; either version 2 of the License, or
66
(at your option) any later version.
7-
7+
88
This program is distributed in the hope that it will be useful,
99
but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111
GNU General Public License for more details.
12-
12+
1313
You should have received a copy of the GNU General Public License
1414
along with this program; if not, write to the Free Software
1515
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
@@ -73,6 +73,10 @@ int mi_rprev(MI_INFO *info, byte *buf, int inx)
7373
if (my_errno == HA_ERR_KEY_NOT_FOUND)
7474
my_errno=HA_ERR_END_OF_FILE;
7575
}
76+
else if (!buf)
77+
{
78+
DBUG_RETURN(info->lastpos==HA_OFFSET_ERROR ? my_errno : 0);
79+
}
7680
else if (!(*info->read_record)(info,info->lastpos,buf))
7781
{
7882
info->update|= HA_STATE_AKTIV; /* Record is read */

myisammrg/Makefile.am

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ pkglib_LIBRARIES = libmyisammrg.a
1919
noinst_HEADERS = mymrgdef.h
2020
libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
2121
myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
22-
myrg_panic.c myrg_close.c myrg_create.c myrg_static.c
23-
22+
myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
23+
myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
24+
myrg_rprev.c myrg_queue.c
2425
OMIT_DEPENDENCIES = pthread.h stdio.h __stdio.h stdlib.h __stdlib.h math.h\
2526
__math.h time.h __time.h unistd.h __unistd.h types.h \
2627
xtypes.h ac-types.h posix.h string.h __string.h \

myisammrg/mymrgdef.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ extern LIST *myrg_open_list;
2727
#ifdef THREAD
2828
extern pthread_mutex_t THR_LOCK_open;
2929
#endif
30+
31+
int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag);
32+

0 commit comments

Comments
 (0)