diff --git a/=6 b/=6 deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/heap/hp_clear.c b/heap/hp_clear.c index 702c2e09d2936b9ddee7c3974f1a2ba5c8980ee4..dcab35acd4e4a79ceaed8deca48e3838140dd8a8 100644 --- a/heap/hp_clear.c +++ b/heap/hp_clear.c @@ -44,7 +44,7 @@ void _hp_clear(HP_SHARE *info) block->levels=0; block->last_allocated=0; } - info->records=info->deleted=info->data_length=info->index_length=0;; + info->records=info->deleted=info->data_length=info->index_length=0; info->blength=1; info->changed=0; info->del_link=0; diff --git a/heap/hp_close.c b/heap/hp_close.c index 583602e98cb9ce52c3d0259f0dbf2cfa54a791ad..267a068350b9e123f322162438b96bb26ff55147 100644 --- a/heap/hp_close.c +++ b/heap/hp_close.c @@ -19,7 +19,7 @@ #include "heapdef.h" /* Close a database open by hp_open() */ - /* Data is not deallocated */ + /* Data is normally not deallocated */ int heap_close(HP_INFO *info) { @@ -43,8 +43,9 @@ int _hp_close(register HP_INFO *info) } #endif info->s->changed=0; - info->s->open_count--; heap_open_list=list_delete(heap_open_list,&info->open_list); + if (!--info->s->open_count && info->s->delete_on_close) + _hp_free(info->s); /* Table was deleted */ my_free((gptr) info,MYF(0)); DBUG_RETURN(error); } diff --git a/heap/hp_create.c b/heap/hp_create.c index 01c5f43adfd6140c8173a7a5811b6bdd39640826..da91e4121803a93b38b379b190012563ce5a1df6 100644 --- a/heap/hp_create.c +++ b/heap/hp_create.c @@ -21,33 +21,49 @@ #include "heapdef.h" + int heap_create(const char *name) { + reg1 HP_SHARE *share; DBUG_ENTER("heap_create"); - (void) heap_delete_all(name); + pthread_mutex_lock(&THR_LOCK_heap); + if ((share=_hp_find_named_heap(name))) + { + if (share->open_count == 0) + _hp_free(share); + } + else + { + my_errno=ENOENT; + } + pthread_mutex_unlock(&THR_LOCK_heap); DBUG_RETURN(0); } -int heap_delete_all(const char *name) +int heap_delete_table(const char *name) { - reg1 HP_SHARE *info; - int found; - DBUG_ENTER("heap_delete_all"); + int result; + reg1 HP_SHARE *share; + DBUG_ENTER("heap_delete_table"); + pthread_mutex_lock(&THR_LOCK_heap); - if ((info=_hp_find_named_heap(name))) + if ((share=_hp_find_named_heap(name))) { - if (info->open_count == 0) - _hp_free(info); - found=0; + if (share->open_count == 0) + _hp_free(share); + else + share->delete_on_close=1; + result=0; } else { - found=my_errno=ENOENT; + result=my_errno=ENOENT; } pthread_mutex_unlock(&THR_LOCK_heap); - DBUG_RETURN(found); + DBUG_RETURN(result); } + void _hp_free(HP_SHARE *share) { heap_share_list=list_delete(heap_share_list,&share->open_list); diff --git a/heap/hp_delete.c b/heap/hp_delete.c index a6e77fe5f27b63845e30f54271e5adb4f492f948..921b6cf36e6f1109b5ec3447b2466fc07c5555d9 100644 --- a/heap/hp_delete.c +++ b/heap/hp_delete.c @@ -50,7 +50,8 @@ int heap_delete(HP_INFO *info, const byte *record) info->current_hash_ptr=0; DBUG_RETURN(0); err: - if( ++(share->records) == share->blength) share->blength+= share->blength; + if (++(share->records) == share->blength) + share->blength+= share->blength; DBUG_RETURN(my_errno); } @@ -66,7 +67,8 @@ int _hp_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo, DBUG_ENTER("_hp_delete_key"); blength=share->blength; - if (share->records+1 == blength) blength+= blength; + if (share->records+1 == blength) + blength+= blength; lastpos=hp_find_hash(&keyinfo->block,share->records); last_ptr=0; diff --git a/heap/hp_test2.c b/heap/hp_test2.c index e3ed7a90df53635eb103f8d5aae9a6173240ef00..0f7afca5a932da187d0c00162893208344be50ac 100644 --- a/heap/hp_test2.c +++ b/heap/hp_test2.c @@ -574,7 +574,7 @@ char *argv[]; heap_clear(file); if (heap_close(file) || (file2 && heap_close(file2))) goto err; - heap_delete_all(filename2); + heap_delete_table(filename2); heap_panic(HA_PANIC_CLOSE); my_end(MY_GIVE_INFO); return(0); diff --git a/include/heap.h b/include/heap.h index 8cbb500fa86b8de337fe40a9260451acf2e9db00..9c67a84a2dd416b04d279409b6d4bc733705ba06 100644 --- a/include/heap.h +++ b/include/heap.h @@ -109,6 +109,7 @@ typedef struct st_heap_share THR_LOCK lock; pthread_mutex_t intern_lock; /* Locking for use with _locking */ #endif + my_bool delete_on_close; LIST open_list; } HP_SHARE; @@ -144,7 +145,7 @@ extern int heap_scan(register HP_INFO *info, byte *record); extern int heap_delete(HP_INFO *info,const byte *buff); extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag); extern int heap_create(const char *name); -extern int heap_delete_all(const char *name); +extern int heap_delete_table(const char *name); extern int heap_extra(HP_INFO *info,enum ha_extra_function function); extern int heap_rename(const char *old_name,const char *new_name); extern int heap_panic(enum ha_panic_function flag); diff --git a/include/my_base.h b/include/my_base.h index f1d6c005262c8650dfbaa561b573107ab3d0b081..e677f448c57fe4aab94d7f4b6868ff56344147f0 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -93,7 +93,8 @@ enum ha_extra_function { HA_EXTRA_NO_IGNORE_DUP_KEY, HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE, /* Cursor will not be used for update */ HA_EXTRA_BULK_INSERT_BEGIN, - HA_EXTRA_BULK_INSERT_END + HA_EXTRA_BULK_INSERT_END, + HA_EXTRA_PREPARE_FOR_DELETE }; /* The following is parameter to ha_panic() */ diff --git a/include/my_sys.h b/include/my_sys.h index 303ae03c9031e6d1c1ced894c172e47ef2516b43..591c3237c056f3d290b38a73bbc9e18b28f67024 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -246,7 +246,8 @@ typedef struct st_record_cache /* Used when cacheing records */ } RECORD_CACHE; enum file_type { UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, - STREAM_BY_FOPEN, STREAM_BY_FDOPEN, FILE_BY_MKSTEMP }; + STREAM_BY_FOPEN, STREAM_BY_FDOPEN, FILE_BY_MKSTEMP, + FILE_BY_DUP }; extern struct my_file_info { @@ -387,6 +388,7 @@ extern File my_register_filename(File fd, const char *FileName, extern File my_create(const char *FileName,int CreateFlags, int AccsesFlags, myf MyFlags); extern int my_close(File Filedes,myf MyFlags); +extern File my_dup(File file, myf MyFlags); extern int my_mkdir(const char *dir, int Flags, myf MyFlags); extern int my_readlink(char *to, const char *filename, myf MyFlags); extern int my_realpath(char *to, const char *filename, myf MyFlags); @@ -588,6 +590,7 @@ extern void my_free_lock(byte *ptr,myf flags); void init_alloc_root(MEM_ROOT *mem_root, uint block_size, uint pre_alloc_size); gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size); void free_root(MEM_ROOT *root, myf MyFLAGS); +void set_prealloc_root(MEM_ROOT *root, char *ptr); char *strdup_root(MEM_ROOT *root,const char *str); char *memdup_root(MEM_ROOT *root,const char *str,uint len); void load_defaults(const char *conf_file, const char **groups, diff --git a/isam/extra.c b/isam/extra.c index 1d333fa372f67f41c42d78029ff1b00c641e69f9..d5769101b8f184653ee553903aeb988423c9eeac 100644 --- a/isam/extra.c +++ b/isam/extra.c @@ -204,6 +204,7 @@ int nisam_extra(N_INFO *info, enum ha_extra_function function) info->s->changed=1; /* Update on close */ break; case HA_EXTRA_FORCE_REOPEN: + case HA_EXTRA_PREPARE_FOR_DELETE: pthread_mutex_lock(&THR_LOCK_isam); info->s->last_version= 0L; /* Impossible version */ #ifdef __WIN__ diff --git a/myisam/mi_check.c b/myisam/mi_check.c index a02652f0b481b897820b55f9254da975f5222b0e..e5557e5f842b5a031069f991cf30f6e903fa6422 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1321,7 +1321,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, DATA_TMP_EXT, share->base.raid_chunks, (param->testflag & T_BACKUP_DATA ? MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) || - mi_open_datafile(info,share)) + mi_open_datafile(info,share,-1)) got_error=1; } } @@ -2039,7 +2039,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, DATA_TMP_EXT, share->base.raid_chunks, (param->testflag & T_BACKUP_DATA ? MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) || - mi_open_datafile(info,share)) + mi_open_datafile(info,share,-1)) got_error=1; } } diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index d7f3e4dc04aa9cb164750ce196f8fce63ce82d32..eb7285491eddf11ca17ecd4747dc21d0e3ec0f94 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -245,12 +245,15 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function) } break; case HA_EXTRA_FORCE_REOPEN: + case HA_EXTRA_PREPARE_FOR_DELETE: pthread_mutex_lock(&THR_LOCK_myisam); share->last_version= 0L; /* Impossible version */ #ifdef __WIN__ /* Close the isam and data files as Win32 can't drop an open table */ pthread_mutex_lock(&share->intern_lock); - if (flush_key_blocks(share->kfile,FLUSH_RELEASE)) + if (flush_key_blocks(share->kfile, + (function == HA_EXTRA_FORCE_REOPEN ? + FLUSH_RELEASE : FLUSH_IGNORE_CHANGED))) { error=my_errno; share->changed=1; diff --git a/myisam/mi_open.c b/myisam/mi_open.c index 4d8a5c2a1d68e6f3150dd1f0cff1d340481ae180..36cf8cfd6bd119528ede08e126560d5ff74ee78d 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -366,7 +366,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) lock_error=1; /* Database unlocked */ } - if (mi_open_datafile(&info, share)) + if (mi_open_datafile(&info, share, -1)) goto err; errpos=5; @@ -439,7 +439,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) my_errno=EACCES; /* Can't open in write mode */ goto err; } - if (mi_open_datafile(&info, share)) + if (mi_open_datafile(&info, share, old_info->dfile)) goto err; errpos=5; } @@ -1012,25 +1012,26 @@ char *mi_recinfo_read(char *ptr, MI_COLUMNDEF *recinfo) ** Help functions for recover *************************************************************************/ -int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share) +int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup) { #ifdef USE_RAID if (share->base.raid_type) { - if ((info->dfile=my_raid_open(share->data_file_name, - share->mode | O_SHARE, - share->base.raid_type, - share->base.raid_chunks, - share->base.raid_chunksize, - MYF(MY_WME | MY_RAID))) < 0) - return 1; + info->dfile=my_raid_open(share->data_file_name, + share->mode | O_SHARE, + share->base.raid_type, + share->base.raid_chunks, + share->base.raid_chunksize, + MYF(MY_WME | MY_RAID)); } else #endif - if ((info->dfile=my_open(share->data_file_name, share->mode | O_SHARE, - MYF(MY_WME))) < 0) - return 1; - return 0; + if (file_to_dup >= 0) + info->dfile=my_dup(file_to_dup,MYF(MY_WME)); + else + info->dfile=my_open(share->data_file_name, share->mode | O_SHARE, + MYF(MY_WME)); + return info->dfile >= 0 ? 0 : 1; } diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index f650e4312f7b499212d939b80367befc4fbf0404..fa07d19ddbdac23dad5f67fc0f17e3b9e0896ccb 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -712,7 +712,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) error|=change_to_newfile(filename,MI_NAME_DEXT,DATA_TMP_EXT, raid_chunks, MYF(0)); - if (mi_open_datafile(info,info->s)) + if (mi_open_datafile(info,info->s, -1)) error=1; param->out_flag&= ~O_NEW_DATA; /* We are using new datafile */ param->read_cache.file=info->dfile; diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index 865c47fb7ea9167231686a44d052f783c1ced4d8..9da669e843885e7d52cbe52306caec68d6997d55 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -169,8 +169,8 @@ typedef struct st_mi_isam_share { /* Shared between opens */ ulong last_version; /* Version on start */ ulong options; /* Options used */ uint rec_reflength; /* rec_reflength in use now */ - int kfile; /* Shared keyfile */ - int data_file; /* Shared data file */ + File kfile; /* Shared keyfile */ + File data_file; /* Shared data file */ int mode; /* mode of file on open */ uint reopen; /* How many times reopened */ uint w_locks,r_locks; /* Number of read/write locks */ @@ -642,7 +642,7 @@ my_bool mi_check_status(void* param); void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows); my_bool check_table_is_closed(const char *name, const char *where); -int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share); +int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup); int mi_open_keyfile(MYISAM_SHARE *share); int _mi_init_bulk_insert(MI_INFO *info); diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 6dd9bb06fe9f9dc76a83243faef788aa0e0895e3..9a44d569e45acfe6ef60f399e9a267a8b93cf249 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -24,7 +24,7 @@ LDADD = libmysys.a ../dbug/libdbug.a \ noinst_HEADERS = mysys_priv.h my_static.h libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\ mf_path.c mf_loadpath.c\ - my_open.c my_create.c my_seek.c my_read.c \ + my_open.c my_create.c my_dup.c my_seek.c my_read.c \ my_pread.c my_write.c \ mf_keycache.c \ mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \ diff --git a/mysys/hash.c b/mysys/hash.c index 66fa91811b526370405ef87a182e147203d8a87f..dba910ee4ae01a40b8b884e3946d1d10cd44bc20 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -148,9 +148,7 @@ static uint calc_hashnr_caseup(const byte *key,uint length) * * The magic is in the interesting relationship between the special prime * 16777619 (2^24 + 403) and 2^32 and 2^8. - * - * This hash produces the fewest collisions of any function that we've seen so - * far, and works well on both numbers and strings. + * This works well on both numbers and strings. */ uint calc_hashnr(const byte *key, uint len) @@ -514,8 +512,8 @@ my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length) /* Search after record with key */ idx=hash_mask((*hash->calc_hashnr)(old_key,(old_key_length ? - old_key_length : - hash->key_length)), + old_key_length : + hash->key_length)), blength,records); new_index=hash_mask(rec_hashnr(hash,record),blength,records); if (idx == new_index) @@ -575,6 +573,17 @@ byte *hash_element(HASH *hash,uint idx) } +/* + Replace old row with new row. This should only be used when key + isn't changed +*/ + +void hash_replace(HASH *hash, uint idx, byte *new_row) +{ + dynamic_element(&hash->array,idx,HASH_LINK*)->data=new_row; +} + + #ifndef DBUG_OFF my_bool hash_check(HASH *hash) diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index b442af7e9e5af5cea8292fc9e1c148678da58a24..6239405026139982cc33bcc4517a179878fdf3da 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -40,6 +40,7 @@ void pack_dirname(my_string to, const char *from) char buff[FN_REFLEN]; DBUG_ENTER("pack_dirname"); + LINT_INIT(buff_length); (void) intern_filename(to,from); /* Change to intern name */ #ifdef FN_DEVCHAR @@ -49,7 +50,6 @@ void pack_dirname(my_string to, const char *from) #endif start=to; - LINT_INIT(buff_length); if (!(cwd_err= my_getwd(buff,FN_REFLEN,MYF(0)))) { buff_length= (uint) strlen(buff); diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index ffbed38122687c615775f10a10fabb377de8a977..0c61d2ede3cc44837df064bfc1e50e944d5d428d 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -55,6 +55,7 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size) return((gptr) 0); /* purecov: inspected */ } next->next=mem_root->used; + next->size= Size; mem_root->used=next; return (gptr) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM))); #else @@ -166,6 +167,31 @@ void free_root(MEM_ROOT *root, myf MyFlags) DBUG_VOID_RETURN; } +/* + Find block that contains an object and set the pre_alloc to it +*/ + +void set_prealloc_root(MEM_ROOT *root, char *ptr) +{ + USED_MEM *next; + for (next=root->used; next ; next=next->next) + { + if ((char*) next <= ptr && (char*) next + next->size > ptr) + { + root->pre_alloc=next; + return; + } + } + for (next=root->free ; next ; next=next->next) + { + if ((char*) next <= ptr && (char*) next + next->size > ptr) + { + root->pre_alloc=next; + return; + } + } +} + char *strdup_root(MEM_ROOT *root,const char *str) { diff --git a/mysys/my_dup.c b/mysys/my_dup.c new file mode 100644 index 0000000000000000000000000000000000000000..2b3f8f9dd0607cacdf75d14d6f89f49244fe76ce --- /dev/null +++ b/mysys/my_dup.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA */ + +#define USES_TYPES +#include "mysys_priv.h" +#include "mysys_err.h" +#include <my_dir.h> +#include <errno.h> +#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) +#include <share.h> +#endif + + /* Open a file */ + +File my_dup(File file, myf MyFlags) +{ + File fd; + char *filename; + DBUG_ENTER("my_dup"); + DBUG_PRINT("my",("file: %d MyFlags: %d", MyFlags)); + fd = dup(file); + filename= (((int) file < MY_NFILE) ? + my_file_info[(int) file].name : "Unknown"); + DBUG_RETURN(my_register_filename(fd, filename, FILE_BY_DUP, + EE_FILENOTFOUND, MyFlags)); +} /* my_open */ diff --git a/mysys/my_fstream.c b/mysys/my_fstream.c index d93caadbcdc4c059bc80086b6393a861f0e63b90..a38e1334bcaaa953ec21231e05dde2771c4c1469 100644 --- a/mysys/my_fstream.c +++ b/mysys/my_fstream.c @@ -147,7 +147,8 @@ uint my_fwrite(FILE *stream, const byte *Buffer, uint Count, myf MyFlags) /* Seek to position in file */ /* ARGSUSED */ -my_off_t my_fseek(FILE *stream, my_off_t pos, int whence, myf MyFlags) +my_off_t my_fseek(FILE *stream, my_off_t pos, int whence, + myf MyFlags __attribute__((unused))) { DBUG_ENTER("my_fseek"); DBUG_PRINT("my",("stream: %lx pos: %lu whence: %d MyFlags: %d", @@ -160,7 +161,7 @@ my_off_t my_fseek(FILE *stream, my_off_t pos, int whence, myf MyFlags) /* Tell current position of file */ /* ARGSUSED */ -my_off_t my_ftell(FILE *stream, myf MyFlags) +my_off_t my_ftell(FILE *stream, myf MyFlags __attribute__((unused))) { off_t pos; DBUG_ENTER("my_ftell"); diff --git a/mysys/my_lib.c b/mysys/my_lib.c index 0f4a5261fba70cdf8cc5d99748ad15752c53bfce..bb4474b9ce7013d8fbd9a17ea6bbf81971cb8b85 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -577,13 +577,15 @@ myf MyFlags; ** Note that MY_STAT is assumed to be same as struct stat ****************************************************************************/ -int my_fstat(int Filedes, MY_STAT *stat_area, myf MyFlags ) +int my_fstat(int Filedes, MY_STAT *stat_area, + myf MyFlags __attribute__((unused))) { DBUG_ENTER("my_fstat"); DBUG_PRINT("my",("fd: %d MyFlags: %d",Filedes,MyFlags)); DBUG_RETURN(fstat(Filedes, (struct stat *) stat_area)); } + MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags) { int m_used; diff --git a/mysys/my_seek.c b/mysys/my_seek.c index d8e8cf83b6df9bb3d9b1fde8ff9256acbca73f49..39d376c1eaed797f0fcc5e78910591cd3ffc31c9 100644 --- a/mysys/my_seek.c +++ b/mysys/my_seek.c @@ -20,7 +20,7 @@ /* Seek to position in file */ /*ARGSUSED*/ -my_off_t my_seek(File fd, my_off_t pos, int whence, myf MyFlags) +my_off_t my_seek(File fd, my_off_t pos, int whence, myf MyFlags __attribute__((unused))) { reg1 os_off_t newpos; DBUG_ENTER("my_seek"); @@ -40,7 +40,7 @@ my_off_t my_seek(File fd, my_off_t pos, int whence, myf MyFlags) /* Tell current position of file */ /* ARGSUSED */ -my_off_t my_tell(File fd, myf MyFlags) +my_off_t my_tell(File fd, myf MyFlags __attribute__((unused))) { os_off_t pos; DBUG_ENTER("my_tell"); diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 13dccc2bf647692701110e8d1f8ca48e9d4568bd..eff69893502c7ef2507089d66a25ec368622da97 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -247,7 +247,7 @@ THR_LOCK_DATA **ha_heap::store_lock(THD *thd, int ha_heap::delete_table(const char *name) { - int error=heap_delete_all(name); + int error=heap_delete_table(name); return error == ENOENT ? 0 : error; } @@ -272,7 +272,6 @@ ha_rows ha_heap::records_in_range(int inx, return 10; // Good guess } -/* We can just delete the heap on creation */ int ha_heap::create(const char *name, TABLE *form, HA_CREATE_INFO *create_info) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e3670ff980336b0585bc90be7a154a40aa9e973c..c719da389615643216e2253e809ca5fa91425fa3 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1406,7 +1406,10 @@ static void *signal_hand(void *arg __attribute__((unused))) } break; case SIGHUP: - reload_acl_and_cache((THD*) 0,REFRESH_LOG, + reload_acl_and_cache((THD*) 0, + (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST | + REFRESH_STATUS | REFRESH_GRANT | REFRESH_THREADS | + REFRESH_HOSTS), (TABLE_LIST*) 0); // Flush logs mysql_print_status((THD*) 0); // Send debug some info break; @@ -2613,7 +2616,9 @@ static struct option long_options[] = { {"safemalloc-mem-limit", required_argument, 0, (int) OPT_SAFEMALLOC_MEM_LIMIT}, {"new", no_argument, 0, 'n'}, +#ifdef NOT_YET {"no-mix-table-types", no_argument, 0, (int)OPT_NO_MIX_TYPE}, +#endif {"old-protocol", no_argument, 0, 'o'}, {"old-rpl-compat", no_argument, 0, (int)OPT_OLD_RPL_COMPAT}, #ifdef ONE_THREAD diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 39c9fb8f030e35ffc6a3fc9b2890aaa11670c0e5..4ae227763448d311f595bc8233290d59631ab8be 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -228,3 +228,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 70f9e0f1088941472fcaac6ef31d13bb39eb1b7b..f511a5d177cfd3f3f4ecbfd0146625f211881534 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -222,3 +222,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index bd19abe99b1b27d0a844adea5f26952ddd06c441..91237c691c04ca2729ca84d0e3cf53b2cc503611 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -223,3 +223,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index b2b298d62a88150bb3f31adc3cb54a5e8434f460..d120575d9afefd2cf52d0f697502faba0ffa61c9 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -219,4 +219,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", -"Mixing transactional and non-transactional tables disabled by option", \ No newline at end of file +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index a4f9fa2223fb45e9ab7c66d802b168cd8767e2d7..929b97e6146ab702d9bf07ef8a75a35c50676eeb 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -223,3 +223,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index edc2495329665985952bae5a93c127f57eeee481..03589a91c776693b0a83096aca61799601c23bca 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -219,3 +219,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 43f77d698f4e5410221dec48d6f1db2155fe1b81..deded79640332325578d1ab14cb27984bd25f917 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -222,3 +222,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 7466abea5b40b6a69c73d02bfdd8d7c9105c4e77..c6255689ee461622dfaa5a099b5bed84f9f7fc3b 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -219,3 +219,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 6eabaf1fbd9fa0ca7896c099e3f25ca020d47353..fbedda7e32995fd75d685b12c3bf3c63d1562324 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -221,3 +221,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 036b59fe320f6b073bbef4d40e1273a23c4134bb..f419ddb7e0c839336342e8103499d6b0eda0db2c 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -219,3 +219,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 0ee0e80a541246f3eeacf9ccd628d56961818c0c..2f4b72f8cc16ac42ef0dfda476b7a333d9d3a711 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -221,3 +221,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 8864acb5e7ef4cba2d6434fc1e28f0fc29c7e0e3..f5f5539b8a2e365828a2b009f4b7ec4e77b35aa9 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -219,3 +219,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 29b9c260fb977642721a7eeb3d8b79b71d5380be..d87da1875770e39acb3d8f415f1ae0e7a4685737 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -221,3 +221,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index c2cad5de0672349d19baca57898ff8cde082a226..1d54c9aec039d8c8f6e000d834f48f70ff0d6cbc 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -221,3 +221,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 38515256a3cf9da53fc1f28bf61738265b7848da..1c93fcc7f8f58e8e2094530259cabe5e9aefb5b1 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -223,3 +223,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 0d907aa4f142d5d0eb4c91abd0b4dceeeca7cbd9..29a52900b24955db7bacd49ea7d8e9090f4b3638 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -219,3 +219,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 3c47a149e3a74feabb65570ff6ad3ec03a611fd2..8f957302f304972a2717703c9f3e3a397ab0aade 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -223,3 +223,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index e030072c6863899d75fa2e0e244867d3218967f7..dc350a242a3179c42e811dc90e6648265a416206 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -222,3 +222,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 22360c08c9b16bd632cef90b9d0db1f7e55c4cf4..f7db353db3f7f283d1e6844768ba4f477ed18877 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -227,3 +227,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 237e1d2716fd27c783f87863d5b6cdca8e990890..f10908a33ba1ddc5fd937db71ae3d65aa75098d7 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -220,3 +220,4 @@ "Wrong usage of %s and %s", "The used SELECT statements have a different number of columns", "Can't execute the query because you have a conflicting read lock", +"Mixing of transactional and non-transactional tables is disabled", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 3dd14c8b613e0968754d392f8c049af4c73d16f1..5bdbf78e6cf9c06be3ca10b9897bb5eb0a0bea60 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -219,3 +219,4 @@ "Felaktig använding av %s and %s", "SELECT kommandona har olika antal kolumner" "Kan inte utföra kommandot emedan du har ett READ lås", +"Blandning av transaktionella och icke-transaktionella tabeller är stoppat", diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 0198f0ce1763509a97c786d0df7ecf10122848cc..2a9043cc0d7841f44cb989f075c5d4e11d0d6ebb 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1368,18 +1368,6 @@ int open_tables(THD *thd,TABLE_LIST *start) tables->table->reginfo.lock_type=tables->lock_type; tables->table->grant= tables->grant; } - if (opt_no_mix_types && start) - { - bool checking; TABLE_LIST *tl; - for (tl=start, checking = tl->table->file->has_transactions(), tl=tl->next; tl ; tl=tl->next) - { - if (((tl->table->file->has_transactions()) ^ checking)) - { - send_error(&thd->net,ER_MIXING_NOT_ALLOWED); - DBUG_RETURN(-1); - } - } - } thd->proc_info=0; DBUG_RETURN(result); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 386fd61c61e646fe7ec4b1a33a791a526a247b89..c43540d77e6645d827ede7b3f14510fb4697f512 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -47,7 +47,7 @@ static void mysql_init_query(THD *thd); static void remove_escape(char *name); static void refresh_status(void); static bool append_file_to_dir(char **filename_ptr, char *table_name); -static int create_total_list(THD *thd, LEX *lex, TABLE_LIST **result); +static bool create_total_list(THD *thd, LEX *lex, TABLE_LIST **result); const char *any_db="*any*"; // Special symbol for check_access @@ -1075,11 +1075,10 @@ mysql_execute_command(void) /* Skip if we are in the slave thread, some table rules have been given and the table list says the query should not be replicated - TODO: UPDATE this for UNION. Updated by Sinisa !!!!!!!!!!!!!!!!!!!!!! */ - if (lex->select_lex.next && tables && (res = create_total_list(thd,lex,&tables))) - DBUG_VOID_RETURN; - if (table_rules_on && thd->slave_thread && tables && !tables_ok(thd,tables)) + if ((lex->select_lex.next && create_total_list(thd,lex,&tables)) || + (table_rules_on && tables && thd->slave_thread && + !tables_ok(thd,tables))) DBUG_VOID_RETURN; switch (lex->sql_command) { @@ -1088,7 +1087,6 @@ mysql_execute_command(void) select_result *result; if (select_lex->options & SELECT_DESCRIBE) lex->exchange=0; - /* Save a call, as it's very uncomon that we use unions */ if (tables) { res=check_table_access(thd, @@ -2364,6 +2362,7 @@ mysql_init_query(THD *thd) thd->lex.select = &thd->lex.select_lex; thd->lex.select_lex.table_list.first=0; thd->lex.select_lex.table_list.next= (byte**) &thd->lex.select_lex.table_list.first; + thd->lex.select_lex.next=0; thd->fatal_error=0; // Safety thd->last_insert_id_used=thd->query_start_used=thd->insert_id_used=0; thd->sent_row_count=thd->examined_row_count=0; @@ -2836,7 +2835,7 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias, ** to the entries in this list. */ -static int create_total_list(THD *thd, LEX *lex, TABLE_LIST **result) +static bool create_total_list(THD *thd, LEX *lex, TABLE_LIST **result) { /* Handle the case when we are not using union */ if (!lex->select_lex.next) @@ -2853,8 +2852,8 @@ static int create_total_list(THD *thd, LEX *lex, TABLE_LIST **result) { if (sl->order_list.first && sl->next) { - my_error(ER_WRONG_USAGE,MYF(0),"UNION","ORDER BY"); - return -1; + net_printf(&thd->net,ER_WRONG_USAGE,"UNION","ORDER BY"); + return 1; } if ((aux= (TABLE_LIST*) sl->table_list.first)) { @@ -2874,7 +2873,10 @@ static int create_total_list(THD *thd, LEX *lex, TABLE_LIST **result) aux->lock_type= lex->lock_option; if (!(cursor = (TABLE_LIST *) thd->memdup((byte*) aux, sizeof(*aux)))) - return -1; + { + send_error(&thd->net,0); + return 1; + } *new_table_list= cursor; new_table_list= &cursor->next; *new_table_list=0; // end result list