diff options
Diffstat (limited to 'myisammrg')
-rw-r--r-- | myisammrg/Makefile.am | 4 | ||||
-rw-r--r-- | myisammrg/myrg_close.c | 8 | ||||
-rw-r--r-- | myisammrg/myrg_create.c | 18 | ||||
-rw-r--r-- | myisammrg/myrg_def.h (renamed from myisammrg/mymrgdef.h) | 8 | ||||
-rw-r--r-- | myisammrg/myrg_delete.c | 17 | ||||
-rw-r--r-- | myisammrg/myrg_extra.c | 28 | ||||
-rw-r--r-- | myisammrg/myrg_info.c | 19 | ||||
-rw-r--r-- | myisammrg/myrg_locking.c | 12 | ||||
-rw-r--r-- | myisammrg/myrg_open.c | 80 | ||||
-rw-r--r-- | myisammrg/myrg_panic.c | 8 | ||||
-rw-r--r-- | myisammrg/myrg_queue.c | 14 | ||||
-rw-r--r-- | myisammrg/myrg_range.c | 41 | ||||
-rw-r--r-- | myisammrg/myrg_rfirst.c | 4 | ||||
-rw-r--r-- | myisammrg/myrg_rkey.c | 6 | ||||
-rw-r--r-- | myisammrg/myrg_rlast.c | 4 | ||||
-rw-r--r-- | myisammrg/myrg_rnext.c | 4 | ||||
-rw-r--r-- | myisammrg/myrg_rprev.c | 4 | ||||
-rw-r--r-- | myisammrg/myrg_rrnd.c | 12 | ||||
-rw-r--r-- | myisammrg/myrg_rsame.c | 18 | ||||
-rw-r--r-- | myisammrg/myrg_static.c | 12 | ||||
-rw-r--r-- | myisammrg/myrg_update.c | 11 | ||||
-rw-r--r-- | myisammrg/myrg_write.c | 30 |
22 files changed, 247 insertions, 115 deletions
diff --git a/myisammrg/Makefile.am b/myisammrg/Makefile.am index 04fa1c9ec13..6a6824affba 100644 --- a/myisammrg/Makefile.am +++ b/myisammrg/Makefile.am @@ -16,12 +16,12 @@ INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include pkglib_LIBRARIES = libmyisammrg.a -noinst_HEADERS = mymrgdef.h +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_rprev.c myrg_queue.c myrg_write.c myrg_range.c # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/myisammrg/myrg_close.c b/myisammrg/myrg_close.c index 7ab73c5ded4..897020c6865 100644 --- a/myisammrg/myrg_close.c +++ b/myisammrg/myrg_close.c @@ -1,22 +1,22 @@ /* 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 */ /* close a isam-database */ -#include "mymrgdef.h" +#include "myrg_def.h" int myrg_close(MYRG_INFO *info) { diff --git a/myisammrg/myrg_create.c b/myisammrg/myrg_create.c index 113831b9d7f..5fc3c60ff32 100644 --- a/myisammrg/myrg_create.c +++ b/myisammrg/myrg_create.c @@ -1,29 +1,30 @@ /* 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 */ /* Create a MYMERGE_-file */ -#include "mymrgdef.h" +#include "myrg_def.h" /* create file named 'name' and save filenames in it table_names should be NULL or a vector of string-pointers with a NULL-pointer last */ -int myrg_create(const char *name, const char **table_names, my_bool fix_names) +int myrg_create(const char *name, const char **table_names, + uint insert_method, my_bool fix_names) { int save_errno; uint errpos; @@ -50,6 +51,13 @@ int myrg_create(const char *name, const char **table_names, my_bool fix_names) goto err; } } + if (insert_method != MERGE_INSERT_DISABLED) + { + end=strxmov(buff,"#INSERT_METHOD=", + get_type(&merge_insert_method,insert_method-1),"\n",NullS); + if (my_write(file,buff,(uint) (end-buff),MYF(MY_WME | MY_NABP))) + goto err; + } if (my_close(file,MYF(0))) goto err; DBUG_RETURN(0); diff --git a/myisammrg/mymrgdef.h b/myisammrg/myrg_def.h index aae1d07cd64..00e7950bccf 100644 --- a/myisammrg/mymrgdef.h +++ b/myisammrg/myrg_def.h @@ -1,15 +1,15 @@ /* 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 */ @@ -29,3 +29,5 @@ extern pthread_mutex_t THR_LOCK_open; #endif int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag); +int _myrg_mi_read_record(MI_INFO *info, byte *buf); + diff --git a/myisammrg/myrg_delete.c b/myisammrg/myrg_delete.c index 9ac32655172..8b89ed62ac1 100644 --- a/myisammrg/myrg_delete.c +++ b/myisammrg/myrg_delete.c @@ -1,30 +1,27 @@ /* 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 */ /* Delete last read record */ -#include "mymrgdef.h" +#include "myrg_def.h" -int myrg_delete( -MYRG_INFO *info, -const byte *record) +int myrg_delete(MYRG_INFO *info, const byte *record) { if (!info->current_table) - { - return(my_errno=HA_ERR_NO_ACTIVE_RECORD); - } + return (my_errno= HA_ERR_NO_ACTIVE_RECORD); + return mi_delete(info->current_table->table,record); } diff --git a/myisammrg/myrg_extra.c b/myisammrg/myrg_extra.c index c8a634e748f..62cf5f01aba 100644 --- a/myisammrg/myrg_extra.c +++ b/myisammrg/myrg_extra.c @@ -20,9 +20,10 @@ record-cache-flags are set in myrg_rrnd when we are changing database. */ -#include "mymrgdef.h" +#include "myrg_def.h" -int myrg_extra(MYRG_INFO *info,enum ha_extra_function function) +int myrg_extra(MYRG_INFO *info,enum ha_extra_function function, + void *extra_arg) { int error,save_error=0; MYRG_TABLE *file; @@ -30,10 +31,15 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function) DBUG_PRINT("info",("function: %d",(ulong) function)); if (function == HA_EXTRA_CACHE) + { info->cache_in_use=1; + info->cache_size= (extra_arg ? *(ulong*) extra_arg : + my_default_record_cache_size); + } else { - if (function == HA_EXTRA_NO_CACHE || function == HA_EXTRA_RESET) + if (function == HA_EXTRA_NO_CACHE || function == HA_EXTRA_RESET || + function == HA_EXTRA_PREPARE_FOR_UPDATE) info->cache_in_use=0; if (function == HA_EXTRA_RESET || function == HA_EXTRA_RESET_STATE) { @@ -41,8 +47,22 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function) info->last_used_table=info->open_tables; } for (file=info->open_tables ; file != info->end_table ; file++) - if ((error=mi_extra(file->table,function))) + { + if ((error=mi_extra(file->table, function, extra_arg))) save_error=error; + } } DBUG_RETURN(save_error); } + + +void myrg_extrafunc(MYRG_INFO *info, invalidator_by_filename inv) +{ + MYRG_TABLE *file; + DBUG_ENTER("myrg_extrafunc"); + + for (file=info->open_tables ; file != info->end_table ; file++) + file->table->s->invalidator = inv; + + DBUG_VOID_RETURN; +} diff --git a/myisammrg/myrg_info.c b/myisammrg/myrg_info.c index 8ca830339b9..ba840ac444b 100644 --- a/myisammrg/myrg_info.c +++ b/myisammrg/myrg_info.c @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mymrgdef.h" +#include "myrg_def.h" ulonglong myrg_position(MYRG_INFO *info) { @@ -28,8 +28,6 @@ ulonglong myrg_position(MYRG_INFO *info) ~(ulonglong) 0; } - /* If flag != 0 one only gets pos of last record */ - int myrg_status(MYRG_INFO *info,register MYMERGE_INFO *x,int flag) { MYRG_TABLE *current_table; @@ -55,15 +53,16 @@ int myrg_status(MYRG_INFO *info,register MYMERGE_INFO *x,int flag) DBUG_PRINT("info2",("table: %s, offset: %lu", file->table->filename,(ulong) file->file_offset)); } - x->records = info->records; - x->deleted = info->del; - x->data_file_length = info->data_file_length; - x->reclength = info->reclength; - x->options = info->options; + x->records= info->records; + x->deleted= info->del; + x->data_file_length= info->data_file_length; + x->reclength= info->reclength; + x->options= info->options; if (current_table) - x->errkey = current_table->table->errkey; + x->errkey= current_table->table->errkey; else - x->errkey=0; + x->errkey= 0; + x->rec_per_key = info->rec_per_key_part; } DBUG_RETURN(0); } diff --git a/myisammrg/myrg_locking.c b/myisammrg/myrg_locking.c index c89acca3918..e5a8d3f3d9d 100644 --- a/myisammrg/myrg_locking.c +++ b/myisammrg/myrg_locking.c @@ -1,15 +1,15 @@ /* 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 */ @@ -18,11 +18,9 @@ Lock databases against read or write. */ -#include "mymrgdef.h" +#include "myrg_def.h" -int myrg_lock_database( -MYRG_INFO *info, -int lock_type) +int myrg_lock_database(MYRG_INFO *info, int lock_type) { int error,new_error; MYRG_TABLE *file; diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c index df94fb680cb..5188669cad1 100644 --- a/myisammrg/myrg_open.c +++ b/myisammrg/myrg_open.c @@ -14,29 +14,26 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* open a MYMERGE_-database */ +/* open a MyISAM MERGE table */ -#include "mymrgdef.h" +#include "myrg_def.h" #include <stddef.h> #include <errno.h> #ifdef VMS #include "mrg_static.c" #endif -/* open a MYMERGE_-database. - - if handle_locking is 0 then exit with error if some database is locked - if handle_locking is 1 then wait if database is locked +/* + open a MyISAM MERGE table + if handle_locking is 0 then exit with error if some table is locked + if handle_locking is 1 then wait if table is locked */ -MYRG_INFO *myrg_open( -const char *name, -int mode, -int handle_locking) +MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) { int save_errno,i,errpos; - uint files,dir_length,length; + uint files,dir_length,length,key_parts; ulonglong file_offset; char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; MYRG_INFO info,*m_info; @@ -63,45 +60,72 @@ int handle_locking) { if ((end=buff+length)[-1] == '\n') end[-1]='\0'; - if (buff[0] && buff[0] != '#') /* Skipp empty lines and comments */ + if (!buff[0]) + continue; /* Skip empty lines */ + if (buff[0] == '#') { - if (!test_if_hard_path(buff)) - { - VOID(strmake(name_buff+dir_length,buff, - sizeof(name_buff)-1-dir_length)); - VOID(cleanup_dirname(buff,name_buff)); + if( !strncmp(buff+1,"INSERT_METHOD=",14)) + { /* Lookup insert method */ + int tmp=find_type(buff+15,&merge_insert_method,2); + info.merge_insert_method = (uint) (tmp >= 0 ? tmp : 0); } - if (!(isam=mi_open(buff,mode,test(handle_locking)))) - goto err; - files++; - last_isam=isam; - if (info.reclength && info.reclength != isam->s->base.reclength) - { - my_errno=HA_ERR_WRONG_IN_RECORD; + continue; /* Skip comments */ + } + + if (!test_if_hard_path(buff)) + { + VOID(strmake(name_buff+dir_length,buff, + sizeof(name_buff)-1-dir_length)); + VOID(cleanup_dirname(buff,name_buff)); + } + if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0)))) goto err; - } - info.reclength=isam->s->base.reclength; + files++; + last_isam=isam; + if (info.reclength && info.reclength != isam->s->base.reclength) + { + my_errno=HA_ERR_WRONG_MRG_TABLE_DEF; + goto err; } + info.reclength=isam->s->base.reclength; } + key_parts=(isam ? isam->s->base.key_parts : 0); if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO)+ - files*sizeof(MYRG_TABLE), + files*sizeof(MYRG_TABLE)+ + sizeof(long)*key_parts, MYF(MY_WME)))) goto err; *m_info=info; - m_info->open_tables=(files) ? (MYRG_TABLE *) (m_info+1) : 0; m_info->tables=files; + if (files) + { + m_info->open_tables=(MYRG_TABLE *) (m_info+1); + m_info->rec_per_key_part=(ulong *) (m_info->open_tables+files); + bzero((char*) m_info->rec_per_key_part,sizeof(long)*key_parts); + } + else + { + m_info->open_tables=0; + m_info->rec_per_key_part=0; + } errpos=2; for (i=files ; i-- > 0 ; ) { + uint j; m_info->open_tables[i].table=isam; m_info->options|=isam->s->options; m_info->records+=isam->state->records; m_info->del+=isam->state->del; m_info->data_file_length+=isam->state->data_file_length; + for (j=0; j < key_parts; j++) + m_info->rec_per_key_part[j]+=isam->s->state.rec_per_key_part[j] / files; if (i) isam=(MI_INFO*) (isam->open_list.next->data); } + /* Don't mark table readonly, for ALTER TABLE ... UNION=(...) to work */ + m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA); + /* Fix fileinfo for easyer debugging (actually set by rrnd) */ file_offset=0; for (i=0 ; (uint) i < files ; i++) diff --git a/myisammrg/myrg_panic.c b/myisammrg/myrg_panic.c index 99a1f6828d1..ab08b8082c3 100644 --- a/myisammrg/myrg_panic.c +++ b/myisammrg/myrg_panic.c @@ -1,20 +1,20 @@ /* 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 "mymrgdef.h" +#include "myrg_def.h" /* if flag == HA_PANIC_CLOSE then all misam files are closed */ /* if flag == HA_PANIC_WRITE then all misam files are unlocked and diff --git a/myisammrg/myrg_queue.c b/myisammrg/myrg_queue.c index d6f831db48c..5ec382feb91 100644 --- a/myisammrg/myrg_queue.c +++ b/myisammrg/myrg_queue.c @@ -14,9 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Read record based on a key */ - -#include "mymrgdef.h" +#include "myrg_def.h" static int queue_key_cmp(void *keyseg, byte *a, byte *b) { @@ -55,3 +53,13 @@ int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag) } return error; } + +int _myrg_mi_read_record(MI_INFO *info, byte *buf) +{ + if (!(*info->read_record)(info,info->lastpos,buf)) + { + info->update|= HA_STATE_AKTIV; /* Record is read */ + return 0; + } + return my_errno; +} diff --git a/myisammrg/myrg_range.c b/myisammrg/myrg_range.c new file mode 100644 index 00000000000..7644ae40c7b --- /dev/null +++ b/myisammrg/myrg_range.c @@ -0,0 +1,41 @@ +/* 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" + +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 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); + if (res == HA_POS_ERROR) + return HA_POS_ERROR; + if (records > HA_POS_ERROR - res) + return HA_POS_ERROR-1; + records+=res; + } + return records; +} + diff --git a/myisammrg/myrg_rfirst.c b/myisammrg/myrg_rfirst.c index 0625e848660..9ba07686c47 100644 --- a/myisammrg/myrg_rfirst.c +++ b/myisammrg/myrg_rfirst.c @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mymrgdef.h" +#include "myrg_def.h" /* Read first row according to specific key */ @@ -45,5 +45,5 @@ int myrg_rfirst(MYRG_INFO *info, byte *buf, int inx) return HA_ERR_END_OF_FILE; mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table; - return mi_rrnd(mi,buf,mi->lastpos); + return _myrg_mi_read_record(mi,buf); } diff --git a/myisammrg/myrg_rkey.c b/myisammrg/myrg_rkey.c index cd2c73c8ec2..fbfa7f24921 100644 --- a/myisammrg/myrg_rkey.c +++ b/myisammrg/myrg_rkey.c @@ -27,7 +27,7 @@ */ -#include "mymrgdef.h" +#include "myrg_def.h" /* todo: we could store some additional info to speedup lookups: column (key, keyseg) can be constant per table @@ -36,7 +36,7 @@ SerG */ -int myrg_rkey(MYRG_INFO *info,byte *record,int inx, const byte *key, +int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key, uint key_len, enum ha_rkey_function search_flag) { byte *key_buff; @@ -83,5 +83,5 @@ int myrg_rkey(MYRG_INFO *info,byte *record,int inx, const byte *key, return HA_ERR_KEY_NOT_FOUND; mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table; - return mi_rrnd(mi,record,mi->lastpos); + return _myrg_mi_read_record(mi,buf); } diff --git a/myisammrg/myrg_rlast.c b/myisammrg/myrg_rlast.c index f41844dfd5c..96bb798bd4f 100644 --- a/myisammrg/myrg_rlast.c +++ b/myisammrg/myrg_rlast.c @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mymrgdef.h" +#include "myrg_def.h" /* Read last row with the same key as the previous read. */ @@ -45,6 +45,6 @@ int myrg_rlast(MYRG_INFO *info, byte *buf, int inx) return HA_ERR_END_OF_FILE; mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table; - return mi_rrnd(mi,buf,mi->lastpos); + return _myrg_mi_read_record(mi,buf); } diff --git a/myisammrg/myrg_rnext.c b/myisammrg/myrg_rnext.c index 703ca29632b..0929c63fc1d 100644 --- a/myisammrg/myrg_rnext.c +++ b/myisammrg/myrg_rnext.c @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mymrgdef.h" +#include "myrg_def.h" /* Read next row with the same key as previous read @@ -49,5 +49,5 @@ int myrg_rnext(MYRG_INFO *info, byte *buf, int inx) /* 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 mi_rrnd(mi,buf,mi->lastpos); + return _myrg_mi_read_record(mi,buf); } diff --git a/myisammrg/myrg_rprev.c b/myisammrg/myrg_rprev.c index 8c43b40035a..797993e903d 100644 --- a/myisammrg/myrg_rprev.c +++ b/myisammrg/myrg_rprev.c @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mymrgdef.h" +#include "myrg_def.h" /* Read previous row with the same key as previous read @@ -49,5 +49,5 @@ int myrg_rprev(MYRG_INFO *info, byte *buf, int inx) /* now, mymerge's read_prev is as simple as one queue_top */ mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table; - return mi_rrnd(mi,buf,mi->lastpos); + return _myrg_mi_read_record(mi,buf); } diff --git a/myisammrg/myrg_rrnd.c b/myisammrg/myrg_rrnd.c index de731e58d5b..d623ea8ea9c 100644 --- a/myisammrg/myrg_rrnd.c +++ b/myisammrg/myrg_rrnd.c @@ -19,12 +19,12 @@ get by myrg_info(). The next record can be read with pos= -1 */ -#include "mymrgdef.h" +#include "myrg_def.h" static MYRG_TABLE *find_table(MYRG_TABLE *start,MYRG_TABLE *end,ulonglong pos); /* - If filepos == HA_OFFSET_ERROR, read next + If filepos == HA_OFFSET_ERROR, read next Returns same as mi_rrnd: 0 = Ok. HA_ERR_RECORD_DELETED = Record is deleted. @@ -48,7 +48,7 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos) } isam_info=(info->current_table=info->open_tables)->table; if (info->cache_in_use) - mi_extra(isam_info,HA_EXTRA_CACHE); + mi_extra(isam_info,HA_EXTRA_CACHE,(byte*) &info->cache_size); filepos=isam_info->s->pack.header_length; isam_info->lastinx= (uint) -1; /* Can't forward or backward */ } @@ -66,13 +66,15 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos) HA_ERR_END_OF_FILE) DBUG_RETURN(error); if (info->cache_in_use) - mi_extra(info->current_table->table,HA_EXTRA_NO_CACHE); + mi_extra(info->current_table->table, HA_EXTRA_NO_CACHE, + (byte*) &info->cache_size); if (info->current_table+1 == info->end_table) DBUG_RETURN(HA_ERR_END_OF_FILE); info->current_table++; info->last_used_table=info->current_table; if (info->cache_in_use) - mi_extra(info->current_table->table,HA_EXTRA_CACHE); + mi_extra(info->current_table->table, HA_EXTRA_CACHE, + (byte*) &info->cache_size); info->current_table->file_offset= info->current_table[-1].file_offset+ info->current_table[-1].table->state->data_file_length; diff --git a/myisammrg/myrg_rsame.c b/myisammrg/myrg_rsame.c index 301b96e667b..f6b2164dc21 100644 --- a/myisammrg/myrg_rsame.c +++ b/myisammrg/myrg_rsame.c @@ -1,30 +1,28 @@ /* 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 "mymrgdef.h" +#include "myrg_def.h" int myrg_rsame(MYRG_INFO *info,byte *record,int inx) { if (inx) /* not yet used, should be 0 */ - { - return(my_errno=HA_ERR_WRONG_INDEX); - } + return (my_errno=HA_ERR_WRONG_INDEX); + if (!info->current_table) - { - return(my_errno=HA_ERR_NO_ACTIVE_RECORD); - } + return (my_errno=HA_ERR_NO_ACTIVE_RECORD); + return mi_rsame(info->current_table->table,record,inx); } diff --git a/myisammrg/myrg_static.c b/myisammrg/myrg_static.c index 88eb095382b..b21b834ac24 100644 --- a/myisammrg/myrg_static.c +++ b/myisammrg/myrg_static.c @@ -1,15 +1,15 @@ /* 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 */ @@ -20,7 +20,11 @@ */ #ifndef stdin -#include "mymrgdef.h" +#include "myrg_def.h" #endif 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}; diff --git a/myisammrg/myrg_update.c b/myisammrg/myrg_update.c index b75c6ea6f9b..7b9f614b965 100644 --- a/myisammrg/myrg_update.c +++ b/myisammrg/myrg_update.c @@ -1,26 +1,27 @@ /* 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 */ /* Update last read record */ -#include "mymrgdef.h" +#include "myrg_def.h" int myrg_update(register MYRG_INFO *info,const byte *oldrec, byte *newrec) { if (!info->current_table) - return(my_errno=HA_ERR_NO_ACTIVE_RECORD); + return (my_errno=HA_ERR_NO_ACTIVE_RECORD); + return mi_update(info->current_table->table,oldrec,newrec); } diff --git a/myisammrg/myrg_write.c b/myisammrg/myrg_write.c new file mode 100644 index 00000000000..0f191edc23c --- /dev/null +++ b/myisammrg/myrg_write.c @@ -0,0 +1,30 @@ +/* Copyright (C) 2001 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 */ + +/* Write a row to a MyISAM MERGE table */ + +#include "myrg_def.h" + +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); + else if (info->merge_insert_method == MERGE_INSERT_TO_LAST) + return mi_write(info->end_table[-1].table,rec); + else /* unsupported insertion method */ + return (my_errno= HA_ERR_WRONG_COMMAND); +} |