diff options
author | unknown <monty@mysql.com> | 2004-12-31 03:47:56 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-12-31 03:47:56 +0200 |
commit | 45199f545cafb15687b4aae4d127d552a8dcf27a (patch) | |
tree | dd3c89af5e01f80d9172adc65e8df542cd91cb5b | |
parent | 12a215b0833d9aa688ba16fe56eb3411a83e7d4f (diff) | |
download | mariadb-git-45199f545cafb15687b4aae4d127d552a8dcf27a.tar.gz |
After merge fixes
Cleanup of mi_print_error() handling
Deleted 'merge' directory
BitKeeper/deleted/.del-mrg_close.c~1fa9230422daa62a:
Delete: merge/mrg_close.c
BitKeeper/deleted/.del-mrg_create.c~b747c8ec2b801f6:
Delete: merge/mrg_create.c
BitKeeper/deleted/.del-mrg_delete.c~38b4156885bb4537:
Delete: merge/mrg_delete.c
BitKeeper/deleted/.del-mrg_extra.c~7eb6181e1761907e:
Delete: merge/mrg_extra.c
BitKeeper/deleted/.del-mrg_info.c~37728e7238cc5a11:
Delete: merge/mrg_info.c
BitKeeper/deleted/.del-mrg_locking.c~112756a2d581e1d0:
Delete: merge/mrg_locking.c
BitKeeper/deleted/.del-mrg_open.c~6e1d5c8bfa62a519:
Delete: merge/mrg_open.c
BitKeeper/deleted/.del-mrg_panic.c~e204e43cd6d55406:
Delete: merge/mrg_panic.c
BitKeeper/deleted/.del-mrg_rrnd.c~6087c3dd7ecb77:
Delete: merge/mrg_rrnd.c
BitKeeper/deleted/.del-mrg_rsame.c~3e8ed4be2a0952b1:
Delete: merge/mrg_rsame.c
BitKeeper/deleted/.del-mrg_static.c~75a4b78a165dbd0:
Delete: merge/mrg_static.c
BitKeeper/deleted/.del-mrg_update.c~4110a4f1fbf1ab45:
Delete: merge/mrg_update.c
BitKeeper/deleted/.del-Makefile.am~41238af048e60515:
Delete: merge/Makefile.am
BitKeeper/deleted/.del-make-ccc~4f1acbfc127e25d5:
Delete: merge/make-ccc
BitKeeper/deleted/.del-mrg_def.h~a10557d12a87ef1c:
Delete: merge/mrg_def.h
BitKeeper/deleted/.del-.cvsignore~2f287ba794db3da7:
Delete: merge/.cvsignore
include/myisam.h:
Added 'share' to st_mi_keydef' to not have to pass 'st_myisam_info' to functions
myisam/ft_static.c:
Removed compiler warning
myisam/mi_delete.c:
Cleanup of mi_print_error() handling
Break if get_key() return 0
Don't test for HA_ERR_CRASHED; Print errors when my_errno is set
myisam/mi_extra.c:
Cleanup of mi_print_error() handling
myisam/mi_key.c:
Cleanup of mi_print_error() handling
myisam/mi_keycache.c:
Cleanup of mi_print_error() handling
myisam/mi_locking.c:
Cleanup of mi_print_error() handling
myisam/mi_open.c:
Added 'my_isam_share' to MI_KEYDEF
myisam/mi_page.c:
Cleanup of mi_print_error() handling
myisam/mi_range.c:
get_key() calls mi_print_error() if needed
myisam/mi_rkey.c:
Cleanup of mi_print_error() handling
myisam/mi_search.c:
Cleanup of mi_print_error() handling
Break if get_key() return 0
Don't test for HA_ERR_CRASHED; Print errors when my_errno is set
myisam/mi_update.c:
Cleanup of mi_print_error() handling
myisam/mi_write.c:
Cleanup of mi_print_error() handling
Break if get_key() return 0
Don't test for HA_ERR_CRASHED; Print errors when my_errno is set
myisam/myisamdef.h:
Cleanup of mi_print_error() handling
mysql-test/r/grant.result:
Update results after merge
mysql-test/r/timezone2.result:
Update results after merge
mysql-test/t/grant.test:
New error numbers
mysql-test/t/timezone2.test:
New error numbers
sql/item_func.cc:
Remove duplicate include file
sql/sql_acl.cc:
Remove warnings from valgrind
sql/tztime.cc:
Print wrong timezone names to log
38 files changed, 89 insertions, 838 deletions
diff --git a/include/myisam.h b/include/myisam.h index 6d097770646..fd75af2d997 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -107,12 +107,13 @@ typedef struct st_mi_create_info } MI_CREATE_INFO; struct st_myisam_info; /* For referense */ +struct st_mi_isam_share; typedef struct st_myisam_info MI_INFO; - struct st_mi_s_param; typedef struct st_mi_keydef /* Key definition with open & info */ { + struct st_mi_isam_share *share; /* Pointer to base (set in mi_open) */ uint16 keysegs; /* Number of key-segment */ uint16 flag; /* NOSAME, PACK_USED */ diff --git a/merge/.cvsignore b/merge/.cvsignore deleted file mode 100644 index e9955884756..00000000000 --- a/merge/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -.deps -Makefile -Makefile.in diff --git a/merge/Makefile.am b/merge/Makefile.am deleted file mode 100644 index 25e15e9c6ec..00000000000 --- a/merge/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -# 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 - -INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include -pkglib_LIBRARIES = libmerge.a -noinst_HEADERS = mrg_def.h -libmerge_a_SOURCES = mrg_open.c mrg_extra.c mrg_info.c mrg_locking.c \ - mrg_rrnd.c mrg_update.c mrg_delete.c mrg_rsame.c \ - mrg_panic.c mrg_close.c mrg_create.c mrg_static.c - -# Don't update the files from bitkeeper -%::SCCS/s.% diff --git a/merge/make-ccc b/merge/make-ccc deleted file mode 100755 index 3f37c33638f..00000000000 --- a/merge/make-ccc +++ /dev/null @@ -1,3 +0,0 @@ -ccc -I./../include -I../include -DDBUG_OFF -fast -O3 -c _locking.c close.c create.c delete.c extra.c info.c open.c panic.c rrnd.c rsame.c static.c update.c -rm libmerge.a -ar -cr libmerge.a _locking.o diff --git a/merge/mrg_close.c b/merge/mrg_close.c deleted file mode 100644 index e835fd06e47..00000000000 --- a/merge/mrg_close.c +++ /dev/null @@ -1,40 +0,0 @@ -/* 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 "mrg_def.h" - -int mrg_close(register MRG_INFO *info) -{ - int error=0,new_error; - MRG_TABLE *file; - DBUG_ENTER("mrg_close"); - - for (file=info->open_tables ; file != info->end_table ; file++) - if ((new_error=nisam_close(file->table))) - error=new_error; - pthread_mutex_lock(&THR_LOCK_open); - mrg_open_list=list_delete(mrg_open_list,&info->open_list); - pthread_mutex_unlock(&THR_LOCK_open); - my_free((gptr) info,MYF(0)); - if (error) - { - my_errno=error; - DBUG_RETURN(-1); - } - DBUG_RETURN(0); -} diff --git a/merge/mrg_create.c b/merge/mrg_create.c deleted file mode 100644 index d55a1421647..00000000000 --- a/merge/mrg_create.c +++ /dev/null @@ -1,61 +0,0 @@ -/* 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 MERGE-file */ - -#include "mrg_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 mrg_create(const char *name, const char**table_names) -{ - int save_errno; - uint errpos; - File file; - char buff[FN_REFLEN],*end; - DBUG_ENTER("mrg_create"); - - errpos=0; - if ((file = my_create(fn_format(buff,name,"",MRG_NAME_EXT,4),0, - O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) - goto err; - errpos=1; - if (table_names) - for ( ; *table_names ; table_names++) - { - strmov(buff,*table_names); - fn_same(buff,name,4); - *(end=strend(buff))='\n'; - if (my_write(file,*table_names,(uint) (end-buff+1), - MYF(MY_WME | MY_NABP))) - goto err; - } - if (my_close(file,MYF(0))) - goto err; - DBUG_RETURN(0); - -err: - save_errno=my_errno; - switch (errpos) { - case 1: - VOID(my_close(file,MYF(0))); - } - my_errno=save_errno; /* Return right errocode */ - DBUG_RETURN(-1); -} /* mrg_create */ diff --git a/merge/mrg_def.h b/merge/mrg_def.h deleted file mode 100644 index 8b6be08c32d..00000000000 --- a/merge/mrg_def.h +++ /dev/null @@ -1,29 +0,0 @@ -/* 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 */ - -/* Denna fil includeras i alla merge-filer */ - -#ifndef N_MAXKEY -#include "../isam/isamdef.h" -#endif - -#include "merge.h" - -extern LIST *mrg_open_list; - -#ifdef THREAD -extern pthread_mutex_t THR_LOCK_open; -#endif diff --git a/merge/mrg_delete.c b/merge/mrg_delete.c deleted file mode 100644 index 920156be01e..00000000000 --- a/merge/mrg_delete.c +++ /dev/null @@ -1,29 +0,0 @@ -/* 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 "mrg_def.h" - -int mrg_delete(MRG_INFO *info,const byte *record) -{ - if (!info->current_table) - { - my_errno=HA_ERR_NO_ACTIVE_RECORD; - return(-1); - } - return nisam_delete(info->current_table->table,record); -} diff --git a/merge/mrg_extra.c b/merge/mrg_extra.c deleted file mode 100644 index d37b1aaa03c..00000000000 --- a/merge/mrg_extra.c +++ /dev/null @@ -1,46 +0,0 @@ -/* 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 */ - -/* - Extra functions we want to do with a database - - All flags, exept record-cache-flags, are set in all used databases - record-cache-flags are set in mrg_rrnd when we are changing database. -*/ - -#include "mrg_def.h" - -int mrg_extra( -MRG_INFO *info, -enum ha_extra_function function) -{ - MRG_TABLE *file; - - if (function == HA_EXTRA_CACHE) - info->cache_in_use=1; - else - { - if (function == HA_EXTRA_NO_CACHE || function == HA_EXTRA_RESET) - info->cache_in_use=0; - if (function == HA_EXTRA_RESET || function == HA_EXTRA_RESET_STATE) - { - info->current_table=0; - info->last_used_table=info->open_tables; - } - for (file=info->open_tables ; file != info->end_table ; file++) - nisam_extra(file->table,function); - } - return 0; -} diff --git a/merge/mrg_info.c b/merge/mrg_info.c deleted file mode 100644 index 57f22276487..00000000000 --- a/merge/mrg_info.c +++ /dev/null @@ -1,60 +0,0 @@ -/* 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 "mrg_def.h" - -ulong mrg_position(MRG_INFO *info) -{ - MRG_TABLE *current_table; - - if (!(current_table = info->current_table) && - info->open_tables != info->end_table) - current_table = info->open_tables; - return (current_table ? - (ulong) (current_table->table->lastpos + - current_table->file_offset) : - ~(ulong) 0); -} - - /* If flag != 0 one only gets pos of last record */ - -int mrg_info(MRG_INFO *info,register MERGE_INFO *x,int flag) -{ - MRG_TABLE *current_table; - DBUG_ENTER("mrg_info"); - - if (!(current_table = info->current_table) && - info->open_tables != info->end_table) - current_table = info->open_tables; - x->recpos = info->current_table ? - info->current_table->table->lastpos + info->current_table->file_offset : - (ulong) -1L; - if (flag != HA_STATUS_POS) - { - x->records = info->records; - x->deleted = info->del; - x->data_file_length = info->data_file_length; - x->reclength = info->reclength; - if (current_table) - x->errkey = current_table->table->errkey; - else - { /* No tables in MRG */ - x->errkey=0; - } - x->options = info->options; - } - DBUG_RETURN(0); -} diff --git a/merge/mrg_locking.c b/merge/mrg_locking.c deleted file mode 100644 index bd33e047091..00000000000 --- a/merge/mrg_locking.c +++ /dev/null @@ -1,33 +0,0 @@ -/* 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 */ - -/* - Lock databases against read or write. -*/ - -#include "mrg_def.h" - -int mrg_lock_database(MRG_INFO *info,int lock_type) -{ - int error,new_error; - MRG_TABLE *file; - - error=0; - for (file=info->open_tables ; file != info->end_table ; file++) - if ((new_error=nisam_lock_database(file->table,lock_type))) - error=new_error; - return(error); -} diff --git a/merge/mrg_open.c b/merge/mrg_open.c deleted file mode 100644 index 6bf75392131..00000000000 --- a/merge/mrg_open.c +++ /dev/null @@ -1,150 +0,0 @@ -/* 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 */ - -/* open a MERGE-database */ - -#include "mrg_def.h" -#include <stddef.h> -#include <errno.h> -#ifdef VMS -#include "static.c" -#endif - -/* open a MERGE-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 -*/ - - -MRG_INFO *mrg_open( -const char *name, -int mode, -int handle_locking) -{ - int save_errno,i,errpos; - uint files,dir_length,length, options; - ulonglong file_offset; - char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; - MRG_INFO info,*m_info; - File fd; - IO_CACHE file; - N_INFO *isam,*last_isam; - DBUG_ENTER("mrg_open"); - - LINT_INIT(last_isam); - isam=0; - errpos=files=0; - bzero((gptr) &info,sizeof(info)); - bzero((char*) &file,sizeof(file)); - if ((fd=my_open(fn_format(name_buff,name,"",MRG_NAME_EXT,4), - O_RDONLY | O_SHARE,MYF(0))) < 0 || - init_io_cache(&file, fd, IO_SIZE, READ_CACHE, 0, 0, - MYF(MY_WME | MY_NABP))) - goto err; - errpos=1; - dir_length=dirname_part(name_buff,name); - info.reclength=0; - while ((length=my_b_gets(&file,buff,FN_REFLEN-1))) - { - if ((end=buff+length)[-1] == '\n') - end[-1]='\0'; - if (buff[0] && buff[0] != '#') /* Skip empty lines and comments */ - { - last_isam=isam; - 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=nisam_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; - goto err; - } - info.reclength=isam->s->base.reclength; - } - if (!(m_info= (MRG_INFO*) my_malloc(sizeof(MRG_INFO)+files*sizeof(MRG_TABLE), - MYF(MY_WME)))) - goto err; - *m_info=info; - m_info->open_tables=(MRG_TABLE *) (m_info+1); - m_info->tables=files; - - options= (uint) ~0; - for (i=files ; i-- > 0 ; ) - { - m_info->open_tables[i].table=isam; - m_info->options|=isam->s->base.options; - options&=isam->s->base.options; - m_info->records+=isam->s->state.records; - m_info->del+=isam->s->state.del; - m_info->data_file_length=isam->s->state.data_file_length; - if (i) - isam=(N_INFO*) (isam->open_list.next->data); - } - /* Don't force readonly if not all tables are readonly */ - if (! (options & (HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA))) - 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++) - { - m_info->open_tables[i].file_offset=(my_off_t) file_offset; - file_offset+=m_info->open_tables[i].table->s->state.data_file_length; - } - if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L) - { - my_errno=HA_ERR_RECORD_FILE_FULL; - my_free((char*) m_info,MYF(0)); - goto err; - } - - m_info->end_table=m_info->open_tables+files; - m_info->last_used_table=m_info->open_tables; - - VOID(my_close(fd,MYF(0))); - end_io_cache(&file); - m_info->open_list.data=(void*) m_info; - pthread_mutex_lock(&THR_LOCK_open); - mrg_open_list=list_add(mrg_open_list,&m_info->open_list); - pthread_mutex_unlock(&THR_LOCK_open); - DBUG_RETURN(m_info); - -err: - save_errno=my_errno; - switch (errpos) { - case 1: - VOID(my_close(fd,MYF(0))); - end_io_cache(&file); - for (i=files ; i-- > 0 ; ) - { - isam=last_isam; - if (i) - last_isam=(N_INFO*) (isam->open_list.next->data); - nisam_close(isam); - } - } - my_errno=save_errno; - DBUG_RETURN (NULL); -} diff --git a/merge/mrg_panic.c b/merge/mrg_panic.c deleted file mode 100644 index e9ad1974d8f..00000000000 --- a/merge/mrg_panic.c +++ /dev/null @@ -1,47 +0,0 @@ -/* 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 "mrg_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 - all changed data in single user misam is written to file */ - /* if flag == HA_PANIC_READ then all misam files that was locked when - nisam_panic(HA_PANIC_WRITE) was done is locked. A ni_readinfo() is - done for all single user files to get changes in database */ - - -int mrg_panic( -enum ha_panic_function flag) -{ - int error=0; - LIST *list_element,*next_open; - MRG_INFO *info; - DBUG_ENTER("mrg_panic"); - - for (list_element=mrg_open_list ; list_element ; list_element=next_open) - { - next_open=list_element->next; /* Save if close */ - info=(MRG_INFO*) list_element->data; - if (flag == HA_PANIC_CLOSE && mrg_close(info)) - error=my_errno; - } - if (mrg_open_list && flag != HA_PANIC_CLOSE) - DBUG_RETURN(nisam_panic(flag)); - if (!error) DBUG_RETURN(0); - my_errno=error; - DBUG_RETURN(-1); -} diff --git a/merge/mrg_rrnd.c b/merge/mrg_rrnd.c deleted file mode 100644 index 206427d74d4..00000000000 --- a/merge/mrg_rrnd.c +++ /dev/null @@ -1,110 +0,0 @@ -/* 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 */ - -/* - Read a record with random-access. The position to the record must - get by mrg_info(). The next record can be read with pos= -1 */ - - -#include "mrg_def.h" - -static MRG_TABLE *find_table(MRG_TABLE *start,MRG_TABLE *end,mrg_off_t pos); - -/* - If filepos == -1, read next - Returns same as nisam_rrnd: - 0 = Ok. - 1 = Record deleted. - -1 = EOF (or something, errno should be HA_ERR_END_OF_FILE) -*/ - -int mrg_rrnd(MRG_INFO *info,byte *buf,mrg_off_t filepos) -{ - int error; - N_INFO *isam_info; - - if (filepos == ~(mrg_off_t) 0) /* Can't use HA_POS_ERROR */ - { - if (!info->current_table) - { - if (info->open_tables == info->end_table) - { /* No tables */ - my_errno=HA_ERR_END_OF_FILE; - return -1; - } - isam_info=(info->current_table=info->open_tables)->table; - if (info->cache_in_use) - nisam_extra(isam_info,HA_EXTRA_CACHE); - filepos=isam_info->s->pack.header_length; - isam_info->lastinx= (uint) -1; /* Can't forward or backward */ - } - else - { - isam_info=info->current_table->table; - filepos= isam_info->nextpos; - } - - for (;;) - { - isam_info->update&= HA_STATE_CHANGED; - if ((error=(*isam_info->s->read_rnd)(isam_info,(byte*) buf, - filepos,1)) >= 0 || - my_errno != HA_ERR_END_OF_FILE) - return (error); - if (info->cache_in_use) - nisam_extra(info->current_table->table,HA_EXTRA_NO_CACHE); - if (info->current_table+1 == info->end_table) - return(-1); - info->current_table++; - info->last_used_table=info->current_table; - if (info->cache_in_use) - nisam_extra(info->current_table->table,HA_EXTRA_CACHE); - info->current_table->file_offset= - info->current_table[-1].file_offset+ - info->current_table[-1].table->s->state.data_file_length; - - isam_info=info->current_table->table; - filepos=isam_info->s->pack.header_length; - isam_info->lastinx= (uint) -1; - } - } - info->current_table=find_table(info->open_tables, - info->end_table-1,filepos); - isam_info=info->current_table->table; - isam_info->update&= HA_STATE_CHANGED; - return ((*isam_info->s->read_rnd)(isam_info,(byte*) buf, - (ulong) (filepos - - info->current_table->file_offset), - 0)); -} - - - /* Find which table to use according to file-pos */ - -static MRG_TABLE *find_table(MRG_TABLE *start,MRG_TABLE *end,mrg_off_t pos) -{ - MRG_TABLE *mid; - - while (start != end) - { - mid=start+((uint) (end-start)+1)/2; - if (mid->file_offset > pos) - end=mid-1; - else - start=mid; - } - return start; -} diff --git a/merge/mrg_rsame.c b/merge/mrg_rsame.c deleted file mode 100644 index ee840bc3060..00000000000 --- a/merge/mrg_rsame.c +++ /dev/null @@ -1,36 +0,0 @@ -/* 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 "mrg_def.h" - - -int mrg_rsame( -MRG_INFO *info, -byte *record, -int inx) /* not used, should be 0 */ -{ - if (inx) - { - my_errno=HA_ERR_WRONG_INDEX; - return(-1); - } - if (!info->current_table) - { - my_errno=HA_ERR_NO_ACTIVE_RECORD; - return(-1); - } - return nisam_rsame(info->current_table->table,record,inx); -} diff --git a/merge/mrg_static.c b/merge/mrg_static.c deleted file mode 100644 index 1b7327c870f..00000000000 --- a/merge/mrg_static.c +++ /dev/null @@ -1,26 +0,0 @@ -/* 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 */ - -/* - Static variables for pisam library. All definied here for easy making of - a shared library -*/ - -#ifndef stdin -#include "mrg_def.h" -#endif - -LIST *mrg_open_list=0; diff --git a/merge/mrg_update.c b/merge/mrg_update.c deleted file mode 100644 index a6650267f36..00000000000 --- a/merge/mrg_update.c +++ /dev/null @@ -1,31 +0,0 @@ -/* 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 "mrg_def.h" - -int mrg_update( -register MRG_INFO *info, -const byte *oldrec, const byte *newrec) -{ - if (!info->current_table) - { - my_errno=HA_ERR_NO_ACTIVE_RECORD; - return(-1); - } - return nisam_update(info->current_table->table,oldrec,newrec); -} diff --git a/myisam/ft_static.c b/myisam/ft_static.c index 5241a492f58..cf4a8dd2a73 100644 --- a/myisam/ft_static.c +++ b/myisam/ft_static.c @@ -25,7 +25,7 @@ char ft_boolean_syntax[]="+ -><()~*:\"\"&|"; const HA_KEYSEG ft_keysegs[FT_SEGS]={ { - NullS, /* charset */ + 0, /* charset */ HA_FT_WLEN, /* start */ 0, /* null_pos */ 0, /* Bit pos */ @@ -42,7 +42,7 @@ const HA_KEYSEG ft_keysegs[FT_SEGS]={ be packed in any way, otherwise w_search() won't be able to update key entry 'in vivo' */ - NullS, 0, 0, 0, HA_NO_SORT, HA_FT_WLEN, HA_FT_WTYPE, 63, 0, 0, 0, 0 + 0, 0, 0, 0, HA_NO_SORT, HA_FT_WLEN, HA_FT_WTYPE, 63, 0, 0, 0, 0 } }; diff --git a/myisam/mi_delete.c b/myisam/mi_delete.c index d79d9040ee7..cc4a17182f7 100644 --- a/myisam/mi_delete.c +++ b/myisam/mi_delete.c @@ -46,10 +46,10 @@ int mi_delete(MI_INFO *info,const byte *record) /* Test if record is in datafile */ DBUG_EXECUTE_IF("myisam_pretend_crashed_table_on_usage", - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); DBUG_RETURN(my_errno= HA_ERR_CRASHED);); DBUG_EXECUTE_IF("my_error_test_undefined_error", - mi_print_error(info, INT_MAX); + mi_print_error(info->s, INT_MAX); DBUG_RETURN(my_errno= INT_MAX);); if (!(info->update & HA_STATE_AKTIV)) { @@ -116,7 +116,7 @@ err: myisam_log_command(MI_LOG_DELETE,info,(byte*) lastpos, sizeof(lastpos),0); if (save_errno != HA_ERR_RECORD_CHANGED) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); /* mark table crashed */ } VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE)); @@ -125,7 +125,7 @@ err: my_errno=save_errno; if (save_errno == HA_ERR_KEY_NOT_FOUND) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; } @@ -154,7 +154,7 @@ static int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo, if ((old_root=*root) == HA_OFFSET_ERROR) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); DBUG_RETURN(my_errno=HA_ERR_CRASHED); } if (!(root_buff= (uchar*) my_alloca((uint) keyinfo->block_length+ @@ -266,9 +266,12 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, my_off_t root; uchar *kpos=keypos; - if (!(tmp_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&kpos,lastkey)) - && (my_errno == HA_ERR_CRASHED)) - mi_print_error(info, HA_ERR_CRASHED); + if (!(tmp_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&kpos,lastkey))) + { + mi_print_error(info->s, HA_ERR_CRASHED); + my_errno= HA_ERR_CRASHED; + DBUG_RETURN(-1); + } root=_mi_dpos(info,nod_flag,kpos); if (subkeys == -1) { @@ -317,7 +320,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (!nod_flag) { DBUG_PRINT("error",("Didn't find key")); - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; /* This should newer happend */ goto err; } @@ -329,15 +332,10 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, { /* Found key */ uint tmp; length=mi_getint(anc_buff); - tmp=remove_key(keyinfo,nod_flag,keypos,lastkey,anc_buff+length, - &next_block); - if (tmp == 0) - { - if (my_errno == HA_ERR_CRASHED) - mi_print_error(info, HA_ERR_CRASHED); - DBUG_PRINT("exit",("Return: %d",0)); - DBUG_RETURN(0); - } + if (!(tmp= remove_key(keyinfo,nod_flag,keypos,lastkey,anc_buff+length, + &next_block))) + goto err; + length-= tmp; mi_putint(anc_buff,length,nod_flag); @@ -386,6 +384,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, my_afree((byte*) leaf_buff); DBUG_PRINT("exit",("Return: %d",ret_value)); DBUG_RETURN(ret_value); + err: my_afree((byte*) leaf_buff); DBUG_PRINT("exit",("Error: %d",my_errno)); @@ -491,8 +490,6 @@ static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, (info->quick_mode ? MI_MIN_KEYBLOCK_LENGTH : (uint) keyinfo->underflow_block_length)); err: - if (my_errno == HA_ERR_CRASHED) - mi_print_error(info, HA_ERR_CRASHED); DBUG_RETURN(-1); } /* del */ @@ -579,14 +576,10 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, /* remove key from anc_buff */ - s_length=remove_key(keyinfo,key_reflength,keypos,anc_key, - anc_buff+anc_length,(my_off_t *) 0); - if (!s_length) - { - if (my_errno == HA_ERR_CRASHED) - mi_print_error(info, HA_ERR_CRASHED); + if (!(s_length=remove_key(keyinfo,key_reflength,keypos,anc_key, + anc_buff+anc_length,(my_off_t *) 0))) goto err; - } + anc_length-=s_length; mi_putint(anc_buff,anc_length,key_reflength); @@ -692,14 +685,10 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, mi_putint(buff,buff_length,nod_flag); /* remove key from anc_buff */ - s_length=remove_key(keyinfo,key_reflength,keypos,anc_key, - anc_buff+anc_length,(my_off_t *) 0); - if (!s_length) - { - if (my_errno == HA_ERR_CRASHED) - mi_print_error(info, HA_ERR_CRASHED); + if (!(s_length= remove_key(keyinfo,key_reflength,keypos,anc_key, + anc_buff+anc_length,(my_off_t *) 0))) goto err; - } + anc_length-=s_length; mi_putint(anc_buff,anc_length,key_reflength); @@ -759,9 +748,8 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (_mi_write_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff)) goto err; DBUG_RETURN(anc_length <= (uint) keyinfo->block_length/2); + err: - if (my_errno == HA_ERR_CRASHED) - mi_print_error(info, HA_ERR_CRASHED); DBUG_RETURN(-1); } /* underflow */ @@ -798,6 +786,7 @@ static uint remove_key(MI_KEYDEF *keyinfo, uint nod_flag, /* Calculate length of key */ if (!(*keyinfo->get_key)(keyinfo,nod_flag,&keypos,lastkey)) DBUG_RETURN(0); /* Error */ + if (next_block && nod_flag) *next_block= _mi_kpos(nod_flag,keypos); s_length=(int) (keypos-start); diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index 999c4ba8f3d..9023fe26f9e 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -187,7 +187,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) { if ((error=flush_io_cache(&info->rec_cache))) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); /* Fatal error found */ } } @@ -288,7 +288,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) { error=my_errno; share->changed=1; - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); /* Fatal error found */ } if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) @@ -343,7 +343,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) if (error) { share->changed=1; - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); /* Fatal error found */ } } diff --git a/myisam/mi_key.c b/myisam/mi_key.c index eaaee617f32..6ac04d562e0 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -477,7 +477,7 @@ int _mi_read_key_record(MI_INFO *info, my_off_t filepos, byte *buf) { /* Read only key */ if (_mi_put_key_in_record(info,(uint) info->lastinx,buf)) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return -1; } diff --git a/myisam/mi_keycache.c b/myisam/mi_keycache.c index 33d0ac4f6bc..fb13f3703a2 100644 --- a/myisam/mi_keycache.c +++ b/myisam/mi_keycache.c @@ -79,7 +79,7 @@ int mi_assign_to_key_cache(MI_INFO *info, if (flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE)) { error= my_errno; - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); /* Mark that table must be checked */ } diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c index 91e9f09b9fb..789d74680ef 100644 --- a/myisam/mi_locking.c +++ b/myisam/mi_locking.c @@ -66,7 +66,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) share->kfile,FLUSH_KEEP)) { error=my_errno; - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); /* Mark that table must be checked */ } if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) @@ -74,7 +74,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) if (end_io_cache(&info->rec_cache)) { error=my_errno; - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); } } @@ -101,7 +101,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) share->not_flushed=1; if (error) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); } } @@ -290,7 +290,7 @@ void mi_update_status(void* param) { if (end_io_cache(&info->rec_cache)) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); } info->opt_flag&= ~WRITE_CACHE_USED; diff --git a/myisam/mi_open.c b/myisam/mi_open.c index 03364ea7c29..ab76235e6ef 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -309,6 +309,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) HA_KEYSEG *pos=share->keyparts; for (i=0 ; i < keys ; i++) { + share->keyinfo[i].share= share; disk_pos=mi_keydef_read(disk_pos, &share->keyinfo[i]); disk_pos_assert(disk_pos + share->keyinfo[i].keysegs * HA_KEYSEG_SIZE, end_pos); @@ -1236,7 +1237,7 @@ int mi_enable_indexes(MI_INFO *info) if (share->state.state.data_file_length || (share->state.state.key_file_length != share->base.keystart)) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); error= HA_ERR_CRASHED; } else diff --git a/myisam/mi_page.c b/myisam/mi_page.c index dc2bc75f1a0..5240c063fba 100644 --- a/myisam/mi_page.c +++ b/myisam/mi_page.c @@ -40,7 +40,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, { DBUG_PRINT("error",("Got errno: %d from key_cache_read",my_errno)); info->last_keypage=HA_OFFSET_ERROR; - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_RETURN(0); } @@ -52,7 +52,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, (ulong) page, page_size)); DBUG_DUMP("page", (char*) tmp, keyinfo->block_length); info->last_keypage = HA_OFFSET_ERROR; - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno = HA_ERR_CRASHED; tmp = 0; } diff --git a/myisam/mi_range.c b/myisam/mi_range.c index 0d8f8763b92..e78f3b11625 100644 --- a/myisam/mi_range.c +++ b/myisam/mi_range.c @@ -213,7 +213,8 @@ err: /* Get keynummer of current key and max number of keys in nod */ -static uint _mi_keynr(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, uchar *keypos, uint *ret_max_key) +static uint _mi_keynr(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, + uchar *keypos, uint *ret_max_key) { uint nod_flag,keynr,max_key; uchar t_buff[MI_MAX_KEY_BUFF],*end; @@ -222,7 +223,7 @@ static uint _mi_keynr(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, u nod_flag=mi_test_if_nod(page); page+=2+nod_flag; - if (!(keyinfo->flag & (HA_VAR_LENGTH_KEY| HA_BINARY_PACK_KEY))) + if (!(keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY))) { *ret_max_key= (uint) (end-page)/(keyinfo->keylength+nod_flag); return (uint) (keypos-page)/(keyinfo->keylength+nod_flag); @@ -233,11 +234,7 @@ static uint _mi_keynr(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, u while (page < end) { if (!(*keyinfo->get_key)(keyinfo,nod_flag,&page,t_buff)) - { - if (my_errno == HA_ERR_CRASHED) - mi_print_error(info, HA_ERR_CRASHED); return 0; /* Error */ - } max_key++; if (page == keypos) keynr=max_key; diff --git a/myisam/mi_rkey.c b/myisam/mi_rkey.c index d564c672f19..635a7eb2c48 100644 --- a/myisam/mi_rkey.c +++ b/myisam/mi_rkey.c @@ -78,7 +78,7 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len, case HA_KEY_ALG_RTREE: if (rtree_find_first(info,inx,key_buff,use_key_length,nextflag) < 0) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; goto err; } diff --git a/myisam/mi_search.c b/myisam/mi_search.c index f252719d29c..0c82a4c4502 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -159,10 +159,9 @@ int _mi_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, DBUG_PRINT("exit",("found key at %lu",(ulong) info->lastpos)); DBUG_RETURN(0); + err: DBUG_PRINT("exit",("Error: %d",my_errno)); - if (my_errno == HA_ERR_CRASHED) - mi_print_error(info, HA_ERR_CRASHED); info->lastpos= HA_OFFSET_ERROR; info->page_changed=1; DBUG_RETURN (-1); @@ -236,7 +235,7 @@ int _mi_seq_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,t_buff); if (length == 0 || page > end) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_PRINT("error",("Found wrong key: length: %u page: %p end: %p", length, page, end)); @@ -383,7 +382,7 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, if (page > end) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_PRINT("error",("Found wrong key: length: %u page: %p end: %p", length, page, end)); @@ -752,6 +751,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, { if (length > (uint) keyseg->length) { + mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; /* Error */ } @@ -767,6 +767,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, ("Found too long null packed key: %u of %u at %p", length, keyseg->length, *page_pos)); DBUG_DUMP("key",(char*) *page_pos,16); + mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; } @@ -823,6 +824,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, DBUG_PRINT("error",("Found too long packed key: %u of %u at %p", length, keyseg->length, *page_pos)); DBUG_DUMP("key",(char*) *page_pos,16); + mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; /* Error */ } @@ -878,6 +880,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, DBUG_PRINT("error",("Found too long binary packed key: %u of %u at %p", length, keyinfo->maxlength, *page_pos)); DBUG_DUMP("key",(char*) *page_pos,16); + mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; /* Wrong key */ } @@ -939,6 +942,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, if (from_end != page_end) { DBUG_PRINT("error",("Error when unpacking key")); + mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; return 0; /* Error */ } @@ -973,7 +977,7 @@ uchar *_mi_get_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, *return_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,key); if (*return_key_length == 0) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_RETURN(0); } @@ -1011,7 +1015,7 @@ static my_bool _mi_get_prev_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, *return_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,key); if (*return_key_length == 0) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_RETURN(1); } @@ -1052,7 +1056,7 @@ uchar *_mi_get_last_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, if (*return_key_length == 0) { DBUG_PRINT("error",("Couldn't find last key: page: %p", page)); - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_RETURN(0); } @@ -1185,11 +1189,7 @@ int _mi_search_next(register MI_INFO *info, register MI_KEYDEF *keyinfo, memcpy(lastkey,key,key_length); if (!(info->lastkey_length=(*keyinfo->get_key)(keyinfo,nod_flag, &info->int_keypos,lastkey))) - { - if (my_errno == HA_ERR_CRASHED) - mi_print_error(info, HA_ERR_CRASHED); DBUG_RETURN(-1); - } } else /* Previous key */ { @@ -1248,9 +1248,9 @@ int _mi_search_first(register MI_INFO *info, register MI_KEYDEF *keyinfo, } while ((pos=_mi_kpos(nod_flag,page)) != HA_OFFSET_ERROR); if (!(info->lastkey_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page, - info->lastkey)) && - (my_errno == HA_ERR_CRASHED)) - mi_print_error(info, HA_ERR_CRASHED); + info->lastkey))) + DBUG_RETURN(-1); /* Crashed */ + info->int_keypos=page; info->int_maxpos=info->buff+mi_getint(info->buff)-1; info->int_nod_flag=nod_flag; info->int_keytree_version=keyinfo->version; diff --git a/myisam/mi_update.c b/myisam/mi_update.c index 2936e29a01c..cda60694008 100644 --- a/myisam/mi_update.c +++ b/myisam/mi_update.c @@ -35,7 +35,7 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec) LINT_INIT(old_checksum); DBUG_EXECUTE_IF("myisam_pretend_crashed_table_on_usage", - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); DBUG_RETURN(my_errno= HA_ERR_CRASHED);); if (!(info->update & HA_STATE_AKTIV)) { @@ -209,7 +209,7 @@ err: } else { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); } info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_ROW_CHANGED | @@ -221,7 +221,7 @@ err: allow_break(); /* Allow SIGHUP & SIGINT */ if (save_errno == HA_ERR_KEY_NOT_FOUND) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); save_errno=HA_ERR_CRASHED; } DBUG_RETURN(my_errno=save_errno); diff --git a/myisam/mi_write.c b/myisam/mi_write.c index 76d066ee845..768258a0c82 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -53,7 +53,7 @@ int mi_write(MI_INFO *info, byte *record) DBUG_PRINT("enter",("isam: %d data: %d",info->s->kfile,info->dfile)); DBUG_EXECUTE_IF("myisam_pretend_crashed_table_on_usage", - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); DBUG_RETURN(my_errno= HA_ERR_CRASHED);); if (share->options & HA_OPTION_READ_ONLY_DATA) { @@ -207,7 +207,7 @@ err: } else { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); } info->update= (HA_STATE_CHANGED | HA_STATE_WRITTEN | HA_STATE_ROW_CHANGED); @@ -353,11 +353,8 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (tmp_key_length) dupp_key_pos=_mi_dpos(info,0,keybuff+tmp_key_length); else - { - if (my_errno == HA_ERR_CRASHED) - mi_print_error(info, HA_ERR_CRASHED); dupp_key_pos= HA_OFFSET_ERROR; - } + if (keyinfo->flag & HA_FULLTEXT) { uint off; @@ -466,7 +463,7 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo, { if (t_length >= keyinfo->maxlength*2+MAX_POINTER_LENGTH) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_RETURN(-1); } @@ -476,7 +473,7 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo, { if (-t_length >= keyinfo->maxlength*2+MAX_POINTER_LENGTH) { - mi_print_error(info, HA_ERR_CRASHED); + mi_print_error(info->s, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_RETURN(-1); } @@ -571,11 +568,8 @@ int _mi_split_page(register MI_INFO *info, register MI_KEYDEF *keyinfo, key_pos=_mi_find_half_pos(nod_flag,keyinfo,buff,key_buff, &key_length, &after_key); if (!key_pos) - { - if (my_errno == HA_ERR_CRASHED) - mi_print_error(info, HA_ERR_CRASHED); DBUG_RETURN(-1); - } + length=(uint) (key_pos-buff); a_length=mi_getint(buff); mi_putint(buff,length,nod_flag); @@ -595,11 +589,8 @@ int _mi_split_page(register MI_INFO *info, register MI_KEYDEF *keyinfo, /* Store new page */ if (!(*keyinfo->get_key)(keyinfo,nod_flag,&key_pos,key_buff)) - { - if (my_errno == HA_ERR_CRASHED) - mi_print_error(info, HA_ERR_CRASHED); DBUG_RETURN(-1); - } + t_length=(*keyinfo->pack_key)(keyinfo,nod_flag,(uchar *) 0, (uchar*) 0, (uchar*) 0, key_buff, &s_temp); @@ -706,6 +697,7 @@ static uchar *_mi_find_last_pos(MI_KEYDEF *keyinfo, uchar *page, memcpy(key, key_buff, length); /* previous key */ if (!(length=(*keyinfo->get_key)(keyinfo,0,&page,key_buff))) { + mi_print_error(keyinfo->share, HA_ERR_CRASHED); my_errno=HA_ERR_CRASHED; DBUG_RETURN(0); } diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index c0f56a7b720..9a92a916558 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -356,8 +356,8 @@ typedef struct st_mi_sort_param #define mi_mark_crashed_on_repair(x) { (x)->s->state.changed|=STATE_CRASHED|STATE_CRASHED_ON_REPAIR ; (x)->update|= HA_STATE_CHANGED; } #define mi_is_crashed(x) ((x)->s->state.changed & STATE_CRASHED) #define mi_is_crashed_on_repair(x) ((x)->s->state.changed & STATE_CRASHED_ON_REPAIR) -#define mi_print_error(INFO, ERRNO) \ - mi_report_error((ERRNO), (INFO)->s->index_file_name) +#define mi_print_error(SHARE, ERRNO) \ + mi_report_error((ERRNO), (SHARE)->index_file_name) /* Functions to store length of space packed keys, VARCHAR or BLOB keys */ diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index bd219e36b53..9ff48974ed4 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -389,14 +389,14 @@ flush privileges; use mysqltest_1; update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600; update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200; -ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysqltest_1' +ERROR 42000: update command denied to user 'mysqltest_3'@'localhost' for table 't1' use mysqltest_2; update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200; -ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysqltest_1' +ERROR 42000: update command denied to user 'mysqltest_3'@'localhost' for table 't1' update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200; -ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysqltest_1' +ERROR 42000: update command denied to user 'mysqltest_3'@'localhost' for table 't2' update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200; -ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysqltest_1' +ERROR 42000: update command denied to user 'mysqltest_3'@'localhost' for table 't1' select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2; a q b r 10 2 1 2 diff --git a/mysql-test/r/timezone2.result b/mysql-test/r/timezone2.result index 56702306b14..040ec866080 100644 --- a/mysql-test/r/timezone2.result +++ b/mysql-test/r/timezone2.result @@ -273,9 +273,9 @@ convert_tz(b, 'Europe/Moscow', 'UTC') update t1, t2 set t1.b = convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC') where t1.a = t2.c and t2.d = (select max(d) from t2); select * from mysql.time_zone_name; -ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysql' +ERROR 42000: select command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name' select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name; -ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysql' +ERROR 42000: select command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name' delete from mysql.db where user like 'mysqltest\_%'; flush privileges; grant all privileges on test.t1 to mysqltest_1@localhost; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index b204c23b82e..c05bed4b701 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -337,15 +337,15 @@ connection conn2; use mysqltest_1; update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600; # the following failed before, should fail now. ---error 1044 +--error 1142 update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200; use mysqltest_2; #the following used to succeed, it must fail now. ---error 1044 +--error 1142 update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200; ---error 1044 +--error 1142 update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200; ---error 1044 +--error 1142 update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200; #lets see the result connection master; diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test index d185a647921..5b5d2aa774e 100644 --- a/mysql-test/t/timezone2.test +++ b/mysql-test/t/timezone2.test @@ -226,9 +226,9 @@ select convert_tz(b, 'Europe/Moscow', 'UTC') from t1; update t1, t2 set t1.b = convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC') where t1.a = t2.c and t2.d = (select max(d) from t2); # But still these two statements should not work: ---error 1044 +--error 1142 select * from mysql.time_zone_name; ---error 1044 +--error 1142 select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name; # diff --git a/sql/item_func.cc b/sql/item_func.cc index 9d599c08e0c..f2d78fdb9e8 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -22,7 +22,6 @@ #endif #include "mysql_priv.h" -#include "sql_acl.h" #include "slave.h" // for wait_for_master_pos #include <m_ctype.h> #include <hash.h> diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index fc68f503117..a913bce6704 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -4835,7 +4835,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list) rw_unlock(&LOCK_grant); close_thread_tables(thd); if (result) - my_error(ER_CANNOT_USER, MYF(0), "DROP USER", wrong_users.c_ptr()); + my_error(ER_CANNOT_USER, MYF(0), "DROP USER", wrong_users.c_ptr_safe()); DBUG_RETURN(result); } diff --git a/sql/tztime.cc b/sql/tztime.cc index 2c25c647a19..dc38580f3b6 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1807,7 +1807,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) 0, HA_READ_KEY_EXACT)) { #ifdef EXTRA_DEBUG - sql_print_error("Can't find description of time zone."); + sql_print_error("Can't find description of time zone '%.*s'", tz_name->length(), + tz_name->ptr()); #endif goto end; } @@ -1829,7 +1830,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, 0, HA_READ_KEY_EXACT)) { - sql_print_error("Can't find description of time zone."); + sql_print_error("Can't find description of time zone '%u'", tzid); goto end; } |