diff options
Diffstat (limited to 'myisammrg')
-rw-r--r-- | myisammrg/Makefile.am | 6 | ||||
-rw-r--r-- | myisammrg/myrg_open.c | 6 | ||||
-rw-r--r-- | myisammrg/myrg_queue.c | 2 | ||||
-rw-r--r-- | myisammrg/myrg_range.c | 11 | ||||
-rw-r--r-- | myisammrg/myrg_rkey.c | 4 | ||||
-rw-r--r-- | myisammrg/myrg_rnext_same.c | 51 | ||||
-rw-r--r-- | myisammrg/myrg_static.c | 2 | ||||
-rw-r--r-- | myisammrg/myrg_write.c | 4 |
8 files changed, 68 insertions, 18 deletions
diff --git a/myisammrg/Makefile.am b/myisammrg/Makefile.am index 6a6824affba..3cd8cfdedea 100644 --- a/myisammrg/Makefile.am +++ b/myisammrg/Makefile.am @@ -14,14 +14,16 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include +INCLUDES = @MT_INCLUDES@ \ + -I$(top_builddir)/include -I$(top_srcdir)/include pkglib_LIBRARIES = libmyisammrg.a noinst_HEADERS = myrg_def.h libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \ myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \ myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \ myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \ - myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c + myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c \ + myrg_rnext_same.c # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c index a59ccb7d966..f9cdc2bb205 100644 --- a/myisammrg/myrg_open.c +++ b/myisammrg/myrg_open.c @@ -67,7 +67,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) while ((length=my_b_gets(&file,buff,FN_REFLEN-1))) { if ((end=buff+length)[-1] == '\n') - end[-1]='\0'; + *--end='\0'; if (!buff[0]) continue; /* Skip empty lines */ if (buff[0] == '#') @@ -80,12 +80,14 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) continue; /* Skip comments */ } - if (!test_if_hard_path(buff)) + if (!has_path(buff)) { VOID(strmake(name_buff+dir_length,buff, sizeof(name_buff)-1-dir_length)); VOID(cleanup_dirname(buff,name_buff)); } + else + fn_format(buff, buff, "", "", 0); if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0)))) goto err; if (!m_info) /* First file */ diff --git a/myisammrg/myrg_queue.c b/myisammrg/myrg_queue.c index 5ec382feb91..dfb434d6397 100644 --- a/myisammrg/myrg_queue.c +++ b/myisammrg/myrg_queue.c @@ -21,7 +21,7 @@ static int queue_key_cmp(void *keyseg, byte *a, byte *b) MI_INFO *aa=((MYRG_TABLE *)a)->table; MI_INFO *bb=((MYRG_TABLE *)b)->table; uint not_used; - int ret= _mi_key_cmp((MI_KEYSEG *)keyseg, aa->lastkey, bb->lastkey, + int ret= ha_key_cmp((HA_KEYSEG *)keyseg, aa->lastkey, bb->lastkey, USE_WHOLE_KEY, SEARCH_FIND, ¬_used); return ret < 0 ? -1 : ret > 0 ? 1 : 0; } /* queue_key_cmp */ diff --git a/myisammrg/myrg_range.c b/myisammrg/myrg_range.c index 7644ae40c7b..aafdf70525c 100644 --- a/myisammrg/myrg_range.c +++ b/myisammrg/myrg_range.c @@ -16,20 +16,15 @@ #include "myrg_def.h" -ha_rows myrg_records_in_range(MYRG_INFO *info, int inx, const byte *start_key, - uint start_key_len, - enum ha_rkey_function start_search_flag, - const byte *end_key, uint end_key_len, - enum ha_rkey_function end_search_flag) +ha_rows myrg_records_in_range(MYRG_INFO *info, int inx, + key_range *min_key, key_range *max_key) { ha_rows records=0, res; MYRG_TABLE *table; for (table=info->open_tables ; table != info->end_table ; table++) { - res=mi_records_in_range(table->table, inx, - start_key, start_key_len, start_search_flag, - end_key, end_key_len, end_search_flag); + res= mi_records_in_range(table->table, inx, min_key, max_key); if (res == HA_POS_ERROR) return HA_POS_ERROR; if (records > HA_POS_ERROR - res) diff --git a/myisammrg/myrg_rkey.c b/myisammrg/myrg_rkey.c index 5208cb52ac2..f87b264081e 100644 --- a/myisammrg/myrg_rkey.c +++ b/myisammrg/myrg_rkey.c @@ -64,9 +64,8 @@ int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key, } else { - mi->use_packed_key=1; + mi->once_flags|= USE_PACKED_KEYS; err=mi_rkey(mi,0,inx,key_buff,pack_key_length,search_flag); - mi->use_packed_key=0; } info->last_used_table=table+1; @@ -87,6 +86,7 @@ int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key, DBUG_RETURN(HA_ERR_KEY_NOT_FOUND); mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table; + mi->once_flags|= RRND_PRESERVE_LASTINX; DBUG_PRINT("info", ("using table no: %d", info->current_table - info->open_tables + 1)); DBUG_DUMP("result key", (byte*) mi->lastkey, mi->lastkey_length); diff --git a/myisammrg/myrg_rnext_same.c b/myisammrg/myrg_rnext_same.c new file mode 100644 index 00000000000..997e4100acd --- /dev/null +++ b/myisammrg/myrg_rnext_same.c @@ -0,0 +1,51 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "myrg_def.h" + + +int myrg_rnext_same(MYRG_INFO *info, byte *buf) +{ + int err; + MI_INFO *mi; + + if (!info->current_table) + return (HA_ERR_KEY_NOT_FOUND); + + /* at first, do rnext for the table found before */ + if ((err=mi_rnext_same(info->current_table->table,NULL))) + { + if (err == HA_ERR_END_OF_FILE) + { + queue_remove(&(info->by_key),0); + if (!info->by_key.elements) + return HA_ERR_END_OF_FILE; + } + else + return err; + } + else + { + /* Found here, adding to queue */ + queue_top(&(info->by_key))=(byte *)(info->current_table); + queue_replaced(&(info->by_key)); + } + + /* now, mymerge's read_next is as simple as one queue_top */ + mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table; + return _myrg_mi_read_record(mi,buf); +} + diff --git a/myisammrg/myrg_static.c b/myisammrg/myrg_static.c index b21b834ac24..9e76cbae07b 100644 --- a/myisammrg/myrg_static.c +++ b/myisammrg/myrg_static.c @@ -27,4 +27,4 @@ LIST *myrg_open_list=0; static const char *merge_insert_methods[] = { "FIRST", "LAST", NullS }; TYPELIB merge_insert_method= { array_elements(merge_insert_methods)-1,"", - merge_insert_methods}; + merge_insert_methods, 0}; diff --git a/myisammrg/myrg_write.c b/myisammrg/myrg_write.c index 0f191edc23c..532709e361d 100644 --- a/myisammrg/myrg_write.c +++ b/myisammrg/myrg_write.c @@ -22,9 +22,9 @@ int myrg_write(register MYRG_INFO *info, byte *rec) { /* [phi] MERGE_WRITE_DISABLED is handled by the else case */ if (info->merge_insert_method == MERGE_INSERT_TO_FIRST) - return mi_write(info->open_tables[0].table,rec); + return mi_write((info->current_table=info->open_tables)->table,rec); else if (info->merge_insert_method == MERGE_INSERT_TO_LAST) - return mi_write(info->end_table[-1].table,rec); + return mi_write((info->current_table=info->end_table-1)->table,rec); else /* unsupported insertion method */ return (my_errno= HA_ERR_WRONG_COMMAND); } |