diff options
-rw-r--r-- | .bzrignore | 1 | ||||
-rwxr-xr-x | BUILD/compile-pentium | 6 | ||||
-rwxr-xr-x | BUILD/compile-pentium-debug | 6 | ||||
-rwxr-xr-x | BUILD/compile-pentium-symbols | 15 | ||||
-rw-r--r-- | Docs/internals.texi | 145 | ||||
-rw-r--r-- | Docs/manual.texi | 14 | ||||
-rw-r--r-- | client/mysql.cc | 6 | ||||
-rw-r--r-- | client/mysqltest.c | 3 | ||||
-rw-r--r-- | heap/_check.c | 16 | ||||
-rw-r--r-- | heap/hp_close.c | 2 | ||||
-rw-r--r-- | heap/hp_hash.c | 93 | ||||
-rw-r--r-- | heap/hp_test1.c | 4 | ||||
-rw-r--r-- | heap/hp_test2.c | 21 | ||||
-rw-r--r-- | include/heap.h | 2 | ||||
-rw-r--r-- | mysql-test/r/key_diff.result | 6 | ||||
-rw-r--r-- | mysql-test/r/type_blob.result | 6 | ||||
-rw-r--r-- | mysql-test/t/key_diff.test | 2 | ||||
-rw-r--r-- | mysql-test/t/type_blob.test | 2 | ||||
-rw-r--r-- | mysys/hash.c | 45 | ||||
-rw-r--r-- | scripts/safe_mysqld.sh | 18 | ||||
-rw-r--r-- | sql/ha_innobase.cc | 16 | ||||
-rw-r--r-- | sql/mysqld.cc | 21 |
22 files changed, 384 insertions, 66 deletions
diff --git a/.bzrignore b/.bzrignore index b012c553da2..b4a8e798fe9 100644 --- a/.bzrignore +++ b/.bzrignore @@ -184,3 +184,4 @@ mysqld.sym .snprj/* sql-bench/output/* sql-bench/Results-linux/ATIS-mysql_bdb-Linux_2.2.14_my_SMP_i686 +Docs/my_sys.doc diff --git a/BUILD/compile-pentium b/BUILD/compile-pentium index cdbc7e773eb..5d197b48882 100755 --- a/BUILD/compile-pentium +++ b/BUILD/compile-pentium @@ -7,4 +7,10 @@ extra_flags="$pentium_cflags $fast_cflags" extra_configs="$pentium_configs" strip=yes +# Use the optimized version if it exists +if test -d /usr/local/BerkeleyDB-opt/ +then + extra_configs="$extra_configs --with-berkeley-db=/usr/local/BerkeleyDB-opt/" +fi + . "$path/FINISH.sh" diff --git a/BUILD/compile-pentium-debug b/BUILD/compile-pentium-debug index 094c4e9ca86..45305661806 100755 --- a/BUILD/compile-pentium-debug +++ b/BUILD/compile-pentium-debug @@ -8,4 +8,10 @@ c_warnings="$c_warnings $debug_extra_warnings" cxx_warnings="$cxx_warnings $debug_extra_warnings" extra_configs="$pentium_configs $debug_configs" +# Use the debug version if it exists +if test -d /usr/local/BerkeleyDB-dbug/ +then + extra_configs="$extra_configs --with-berkeley-db=/usr/local/BerkeleyDB-dbug/" +fi + . "$path/FINISH.sh" diff --git a/BUILD/compile-pentium-symbols b/BUILD/compile-pentium-symbols new file mode 100755 index 00000000000..4f63763606f --- /dev/null +++ b/BUILD/compile-pentium-symbols @@ -0,0 +1,15 @@ +#! /bin/sh + +path=`dirname $0` +. "$path/SETUP.sh" + +extra_flags="$pentium_cflags $fast_cflags -g" +extra_configs="$pentium_configs" + +# Use the optimized version if it exists +if test -d /usr/local/BerkeleyDB-opt/ +then + extra_configs="$extra_configs --with-berkeley-db=/usr/local/BerkeleyDB-opt/" +fi + +. "$path/FINISH.sh" diff --git a/Docs/internals.texi b/Docs/internals.texi index 109946e75b6..9bbd90a7a3a 100644 --- a/Docs/internals.texi +++ b/Docs/internals.texi @@ -289,6 +289,151 @@ Use pointers rather than array indexing when operating on strings. @end itemize +@node mysys functions +@chapter mysys functions + +Functions i mysys: (For flags se my_sys.h) + + int my_copy _A((const char *from,const char *to,myf MyFlags)); + - Copy file + + int my_delete _A((const char *name,myf MyFlags)); + - Delete file + + int my_getwd _A((string buf,uint size,myf MyFlags)); + int my_setwd _A((const char *dir,myf MyFlags)); + - Get and set working directory + + string my_tempnam _A((const char *pfx,myf MyFlags)); + - Make a uniq temp file name by using dir and adding something after + pfx to make name uniq. Name is made by adding a uniq 6 length-string + and TMP_EXT after pfx. + Returns pointer to malloced area for filename. Should be freed by + free(). + + File my_open _A((const char *FileName,int Flags,myf MyFlags)); + File my_create _A((const char *FileName,int CreateFlags, + int AccsesFlags, myf MyFlags)); + int my_close _A((File Filedes,myf MyFlags)); + uint my_read _A((File Filedes,byte *Buffer,uint Count,myf MyFlags)); + uint my_write _A((File Filedes,const byte *Buffer,uint Count, + myf MyFlags)); + ulong my_seek _A((File fd,ulong pos,int whence,myf MyFlags)); + ulong my_tell _A((File fd,myf MyFlags)); + - Use instead of open,open-with-create-flag, close read and write + to get automatic error-messages (flag: MYF_WME) and only have + to test for != 0 if error (flag: MY_NABP). + + int my_rename _A((const char *from,const char *to,myf MyFlags)); + - Rename file + + FILE *my_fopen _A((const char *FileName,int Flags,myf MyFlags)); + FILE *my_fdopen _A((File Filedes,int Flags,myf MyFlags)); + int my_fclose _A((FILE *fd,myf MyFlags)); + uint my_fread _A((FILE *stream,byte *Buffer,uint Count,myf MyFlags)); + uint my_fwrite _A((FILE *stream,const byte *Buffer,uint Count, + myf MyFlags)); + ulong my_fseek _A((FILE *stream,ulong pos,int whence,myf MyFlags)); + ulong my_ftell _A((FILE *stream,myf MyFlags)); + - Same read-interface for streams as for files + + gptr _mymalloc _A((uint uSize,const char *sFile, + uint uLine, myf MyFlag)); + gptr _myrealloc _A((string pPtr,uint uSize,const char *sFile, + uint uLine, myf MyFlag)); + void _myfree _A((gptr pPtr,const char *sFile,uint uLine)); + int _sanity _A((const char *sFile,unsigned int uLine)); + gptr _myget_copy_of_memory _A((const byte *from,uint length, + const char *sFile, uint uLine, + myf MyFlag)); + - malloc(size,myflag) is mapped to this functions if not compiled + with -DSAFEMALLOC + + void TERMINATE _A((void)); + - Writes malloc-info on stdout if compiled with -DSAFEMALLOC. + + int my_chsize _A((File fd,ulong newlength,myf MyFlags)); + - Change size of file + + void my_error _D((int nr,myf MyFlags, ...)); + - Writes message using error number (se mysys/errors.h) on + stdout or curses if MYSYS_PROGRAM_USES_CURSES() is called. + + void my_message _A((const char *str,myf MyFlags)); + - Writes message-string on + stdout or curses if MYSYS_PROGRAM_USES_CURSES() is called. + + void my_init _A((void )); + - Start each program (in main) with this. + void my_end _A((int infoflag)); + - Gives info about program. + - If infoflag & MY_CHECK_ERROR prints if some files are left open + - If infoflag & MY_GIVE_INFO prints timing info and malloc info + about prog. + + int my_redel _A((const char *from, const char *to, int MyFlags)); + - Delete from before rename of to to from. Copyes state from old + file to new file. If MY_COPY_TIME is set sets old time. + + int my_copystat _A((const char *from, const char *to, int MyFlags)); + - Copye state from old file to new file. + If MY_COPY_TIME is set sets copy also time. + + string my_filename _A((File fd)); + - Give filename of open file. + + int dirname _A((string to,const char *name)); + - Copy name of directory from filename. + + int test_if_hard_path _A((const char *dir_name)); + - Test if dirname is a hard path (Starts from root) + + void convert_dirname _A((string name)); + - Convert dirname acording to system. + - In MSDOS changes all caracters to capitals and changes '/' to + '\' + string fn_ext _A((const char *name)); + - Returns pointer to extension in filename + string fn_format _A((string to,const char *name,const char *dsk, + const char *form,int flag)); + format a filename with replace of library and extension and + converts between different systems. + params to and name may be identicall + function dosn't change name if name != to + Flag may be: 1 force replace filnames library with 'dsk' + 2 force replace extension with 'form' */ + 4 force Unpack filename (replace ~ with home) + 8 Pack filename as short as possibly for output to + user. + All open requests should allways use at least: + "open(fn_format(temp_buffe,name,"","",4),...)" to unpack home and + convert filename to system-form. + + string fn_same _A((string toname,const char *name,int flag)); + - Copys directory and extension from name to toname if neaded. + copy can be forced by same flags that in fn_format. + + int wild_compare _A((const char *str,const char *wildstr)); + - Compare if str matches wildstr. Wildstr can contain "*" and "?" + as match-characters. + Returns 0 if match. + + void get_date _A((string to,int timeflag)); + - Get current date in a form ready for printing. + + void soundex _A((string out_pntr, string in_pntr)) + - Makes in_pntr to a 5 chars long string. All words that sounds + alike have the same string. + + int init_key_cache _A((ulong use_mem,ulong leave_this_much_mem)); + - Use cacheing of keys in MISAM, PISAM, and ISAM. + KEY_CACHE_SIZE is a good size. + - Remember to lock databases for optimal cacheing + + void end_key_cache _A((void)); + - End key-cacheing. + + @c The Index was empty, and ugly, so I removed it. (jcole, Sep 7, 2000) @c @node Index diff --git a/Docs/manual.texi b/Docs/manual.texi index dd097cca22a..e6d8f210b80 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -28445,20 +28445,20 @@ Most of the options to @code{safe_mysqld} are the same as the options to @table @code @item --basedir=path @item --core-file-size=# +@item --datadir=path @item --defaults-extra-file=path @item --defaults-file=path -@item --open-files=# -Size of the core file @code{mysqld} should be able to create. Passed to -@code{ulimit -c}. -@item --datadir=path @item --err-log=path @item --ledir=path Path to @code{mysqld} @item --log=path +@item --mysqld=mysqld-version +Name of the mysqld version in the @code{ledir} directory you want to start. @item --no-defaults @item --open-files=# -Number of files @code{mysqld} should be able to open. Passed to -@code{ulimit -n}. +Number of files @code{mysqld} should be able to open. Passed to @code{ulimit -n}. +@item --open-files=# +Size of the core file @code{mysqld} should be able to create. Passed to @code{ulimit -c}. @item --pid-file=path @item --port=# @item --socket=path @@ -40057,6 +40057,8 @@ though, so Version 3.23 is not released as a stable version yet. @appendixsubsec Changes in release 3.23.30 @itemize @bullet @item +Added option @code{--mysqld=#} to @code{safe_mysqld} +@item Allow hex constants in the @code{--fields-*-by} and @code{--lines-terminated-by} options to @code{mysqldump} and @code{mysqlimport}. By Paul DuBois. diff --git a/client/mysql.cc b/client/mysql.cc index e3cc17e23cd..dbd7bfbf899 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -39,7 +39,7 @@ #include "my_readline.h" #include <signal.h> -const char *VER="11.9"; +const char *VER="11.10"; gptr sql_alloc(unsigned size); // Don't use mysqld alloc for these void sql_element_free(void *ptr); @@ -2162,7 +2162,9 @@ com_status(String *buffer __attribute__((unused)), tee_fprintf(stdout, "Server version:\t\t%s\n", mysql_get_server_info(&mysql)); tee_fprintf(stdout, "Protocol version:\t%d\n", mysql_get_proto_info(&mysql)); tee_fprintf(stdout, "Connection:\t\t%s\n", mysql_get_host_info(&mysql)); - tee_fprintf(stdout, "Language:\t\t%s\n", mysql.charset->name); + tee_fprintf(stdout, "Client characterset:\t%s\n", + default_charset_info->name); + tee_fprintf(stdout, "Server characterset:\t%s\n", mysql.charset->name); if (strstr(mysql_get_host_info(&mysql),"TCP/IP") || ! mysql.unix_socket) tee_fprintf(stdout, "TCP port:\t\t%d\n", mysql.port); else diff --git a/client/mysqltest.c b/client/mysqltest.c index 5896c655d22..535822d80fd 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1277,9 +1277,6 @@ int main(int argc, char** argv) if (!( mysql_init(&cur_con->mysql))) die("Failed in mysql_init()"); - - mysql_options(&cur_con->mysql, MYSQL_READ_DEFAULT_GROUP, "mysql"); - cur_con->name = my_strdup("default", MYF(MY_WME)); if (!cur_con->name) die("Out of memory"); diff --git a/heap/_check.c b/heap/_check.c index 77fa0262732..e22eb5e7e4a 100644 --- a/heap/_check.c +++ b/heap/_check.c @@ -18,11 +18,12 @@ #include "heapdef.h" -static int check_one_key(HP_KEYDEF *keydef,ulong records,ulong blength); +static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records, + ulong blength, my_bool print_status); /* Returns 0 if the HEAP is ok */ -int heap_check_heap(HP_INFO *info) +int heap_check_heap(HP_INFO *info,my_bool print_status) { int error; uint key; @@ -30,13 +31,15 @@ int heap_check_heap(HP_INFO *info) DBUG_ENTER("heap_check_keys"); for (error=key=0 ; key < share->keys ; key++) - error|=check_one_key(share->keydef+key,share->records,share->blength); + error|=check_one_key(share->keydef+key,key, share->records,share->blength, + print_status); DBUG_RETURN(error); } -static int check_one_key(HP_KEYDEF *keydef, ulong records, ulong blength) +static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records, + ulong blength, my_bool print_status) { int error; uint i,found,max_links,seek,links; @@ -76,6 +79,9 @@ static int check_one_key(HP_KEYDEF *keydef, ulong records, ulong blength) } DBUG_PRINT("info", ("records: %ld seeks: %d max links: %d hitrate: %.2f", - records,seek,max_links,(float) seek / (float) records)); + records,seek,max_links,(float) seek / (float) (records ? records : 1))); + if (print_status) + printf("Key: %d records: %ld seeks: %d max links: %d hitrate: %.2f\n", + keynr, records, seek, max_links, (float) seek / (float) records); return error; } diff --git a/heap/hp_close.c b/heap/hp_close.c index b1797d2e92f..583602e98cb 100644 --- a/heap/hp_close.c +++ b/heap/hp_close.c @@ -37,7 +37,7 @@ int _hp_close(register HP_INFO *info) int error=0; DBUG_ENTER("_hp_close"); #ifndef DBUG_OFF - if (info->s->changed && heap_check_heap(info)) + if (info->s->changed && heap_check_heap(info,0)) { error=my_errno=HA_ERR_CRASHED; } diff --git a/heap/hp_hash.c b/heap/hp_hash.c index 28647ab7c94..eb35b947871 100644 --- a/heap/hp_hash.c +++ b/heap/hp_hash.c @@ -145,6 +145,7 @@ void _hp_movelink(HASH_INFO *pos, HASH_INFO *next_link, HASH_INFO *newlink) return; } +#ifndef NEW_HASH_FUNCTION /* Calc hashvalue for a key */ @@ -152,13 +153,14 @@ ulong _hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) { register ulong nr=1, nr2=4; HP_KEYSEG *seg,*endseg; - uchar *pos; for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++) { + uchar *pos=(uchar*) key; + key+=seg->length; if (seg->type == HA_KEYTYPE_TEXT) { - for (pos=(uchar*) key,key+=seg->length ; pos < (uchar*) key ; pos++) + for (; pos < (uchar*) key ; pos++) { nr^=(ulong) ((((uint) nr & 63)+nr2)*((uint) my_sort_order[(uint) *pos]))+ (nr << 8); nr2+=3; @@ -166,7 +168,7 @@ ulong _hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) } else { - for (pos=(uchar*) key,key+=seg->length ; pos < (uchar*) key ; pos++) + for (; pos < (uchar*) key ; pos++) { nr^=(ulong) ((((uint) nr & 63)+nr2)*((uint) *pos))+ (nr << 8); nr2+=3; @@ -182,13 +184,13 @@ ulong _hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) { register ulong nr=1, nr2=4; HP_KEYSEG *seg,*endseg; - uchar *pos,*end; for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++) { + uchar *pos=(uchar*) rec+seg->start,*end=pos+seg->length; if (seg->type == HA_KEYTYPE_TEXT) { - for (pos=(uchar*) rec+seg->start,end=pos+seg->length ; pos < end ; pos++) + for (; pos < end ; pos++) { nr^=(ulong) ((((uint) nr & 63)+nr2)*((uint) my_sort_order[(uint) *pos]))+ (nr << 8); nr2+=3; @@ -196,7 +198,7 @@ ulong _hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) } else { - for (pos=(uchar*) rec+seg->start,end=pos+seg->length ; pos < end ; pos++) + for (; pos < end ; pos++) { nr^=(ulong) ((((uint) nr & 63)+nr2)*((uint) *pos))+ (nr << 8); nr2+=3; @@ -206,6 +208,85 @@ ulong _hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) return((ulong) nr); } +#else + +/* + * Fowler/Noll/Vo hash + * + * The basis of the hash algorithm was taken from an idea sent by email to the + * IEEE Posix P1003.2 mailing list from Phong Vo (kpv@research.att.com) and + * Glenn Fowler (gsf@research.att.com). Landon Curt Noll (chongo@toad.com) + * later improved on their algorithm. + * + * 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. + */ + +ulong _hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) +{ + register ulong nr=0; + HP_KEYSEG *seg,*endseg; + + for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++) + { + uchar *pos=(uchar*) key; + key+=seg->length; + if (seg->type == HA_KEYTYPE_TEXT) + { + for (; pos < (uchar*) key ; pos++) + { + nr *=16777619; + nr ^=((uint) my_sort_order[(uint) *pos]); + } + } + else + { + for ( ; pos < (uchar*) key ; pos++) + { + nr *=16777619; + nr ^=(uint) *pos; + } + } + } + return((ulong) nr); +} + + /* Calc hashvalue for a key in a record */ + +ulong _hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) +{ + register ulong nr=0; + HP_KEYSEG *seg,*endseg; + + for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++) + { + uchar *pos=(uchar*) rec+seg->start,*end=pos+seg->length; + if (seg->type == HA_KEYTYPE_TEXT) + { + for ( ; pos < end ; pos++) + { + nr *=16777619; + nr ^=(uint) my_sort_order[(uint) *pos]; + } + } + else + { + for ( ; pos < end ; pos++) + { + nr *=16777619; + nr ^=(uint) *pos; + } + } + } + return((ulong) nr); +} + +#endif + + /* Compare keys for two records. Returns 0 if they are identical */ int _hp_rec_key_cmp(HP_KEYDEF *keydef, const byte *rec1, const byte *rec2) diff --git a/heap/hp_test1.c b/heap/hp_test1.c index 848157e831b..f44752af3bc 100644 --- a/heap/hp_test1.c +++ b/heap/hp_test1.c @@ -65,7 +65,7 @@ int main(int argc, char **argv) sprintf(key,"%6d",j); bmove(record+1,key,6); error=heap_write(file,record); - if (heap_check_heap(file)) + if (heap_check_heap(file,0)) { puts("Heap keys crashed"); goto err; @@ -100,7 +100,7 @@ int main(int argc, char **argv) if (! error) deleted++; } - if (heap_check_heap(file)) + if (heap_check_heap(file,0)) { puts("Heap keys crashed"); goto err; diff --git a/heap/hp_test2.c b/heap/hp_test2.c index bfb30e59622..e3ed7a90df5 100644 --- a/heap/hp_test2.c +++ b/heap/hp_test2.c @@ -133,7 +133,7 @@ char *argv[]; write_count++; key1[n1]++; key3[n3]=1; key_check+=n1; } - if (testflag == 1 && heap_check_heap(file)) + if (testflag == 1 && heap_check_heap(file,0)) { puts("Heap keys crashed"); goto err; @@ -141,7 +141,7 @@ char *argv[]; } if (testflag == 1) goto end; - if (heap_check_heap(file)) + if (heap_check_heap(file,0)) { puts("Heap keys crashed"); goto err; @@ -173,7 +173,7 @@ char *argv[]; key1[atoi(record+keyinfo[0].seg[0].start)]--; key3[atoi(record+keyinfo[2].seg[0].start)]=0; key_check-=atoi(record); - if (testflag == 2 && heap_check_heap(file)) + if (testflag == 2 && heap_check_heap(file,0)) { puts("Heap keys crashed"); goto err; @@ -183,7 +183,7 @@ char *argv[]; puts("Warning: Skipping delete test because no dupplicate keys"); } if (testflag==2) goto end; - if (heap_check_heap(file)) + if (heap_check_heap(file,0)) { puts("Heap keys crashed"); goto err; @@ -239,14 +239,14 @@ char *argv[]; update++; key_check=key_check-atoi(record)+n1; } - if (testflag == 3 && heap_check_heap(file)) + if (testflag == 3 && heap_check_heap(file,0)) { puts("Heap keys crashed"); goto err; } } if (testflag == 3) goto end; - if (heap_check_heap(file)) + if (heap_check_heap(file,0)) { puts("Heap keys crashed"); goto err; @@ -284,7 +284,7 @@ char *argv[]; goto end; } dupp_keys--; - if (heap_check_heap(file)) + if (heap_check_heap(file,0)) { puts("Heap keys crashed"); goto err; @@ -320,7 +320,7 @@ char *argv[]; goto end; } dupp_keys-=2; - if (heap_check_heap(file)) + if (heap_check_heap(file,0)) { puts("Heap keys crashed"); goto err; @@ -353,7 +353,7 @@ char *argv[]; printf("next: Found: %d records of %d\n",ant,write_count-delete); goto end; } - if (heap_check_heap(file)) + if (heap_check_heap(file,0)) { puts("Heap keys crashed"); goto err; @@ -556,7 +556,8 @@ char *argv[]; } pos++; } - if (heap_check_heap(file) || heap_check_heap(file2)) + printf("- Checking heap tables\n"); + if (heap_check_heap(file,1) || heap_check_heap(file2,1)) { puts("Heap keys crashed"); goto err; diff --git a/include/heap.h b/include/heap.h index 74b37b0c534..8cbb500fa86 100644 --- a/include/heap.h +++ b/include/heap.h @@ -156,7 +156,7 @@ extern int heap_rlast(HP_INFO *info,byte *record); extern void heap_clear(HP_INFO *info); extern int heap_rkey(HP_INFO *info,byte *record,int inx,const byte *key); extern gptr heap_find(HP_INFO *info,int inx,const byte *key); -extern int heap_check_heap(HP_INFO *info); +extern int heap_check_heap(HP_INFO *info, my_bool print_status); extern byte *heap_position(HP_INFO *info); /* The following is for programs that uses the old HEAP interface where diff --git a/mysql-test/r/key_diff.result b/mysql-test/r/key_diff.result index 5668bb01eba..ab5b9bcc0e7 100644 --- a/mysql-test/r/key_diff.result +++ b/mysql-test/r/key_diff.result @@ -28,12 +28,12 @@ table type possible_keys key key_len ref rows Extra t1 ALL a NULL NULL NULL 5 t2 ALL b NULL NULL NULL 5 where used a b a b -A B b A -a a b A A B a a +A B b A +C c C c a a a a +a a b A b A A B -C c C c a b A B a a diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index 3190c3a29e6..dcc31addc47 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -242,11 +242,11 @@ HELLO 1 HELLO MY 1 a 1 hello 1 -_field_140 min(t3._field_131) min(t3._field_135) min(t3._field_139) min(t3._field_137) min(link_alias_142._field_165) min(link_alias_133._field_72) min(t3._field_145) min(link_alias_148._field_156) min(t3._field_140) t3_id +_field_140 min(t3._field_131) min(t3._field_135) min(t3._field_139) min(t3._field_137) min(link_alias_142._field_165) min(link_alias_133._field_72) min(t3._field_145) min(link_alias_148._field_156) replace(min(t3._field_140), "\r","^M") t3_id test job -1 test job 1 0000-00-00 00:00:00 1999-02-25 22:43:32 0 High admin 0 tomato test -job +1 test job 1 0000-00-00 00:00:00 1999-02-25 22:43:32 0 High admin 0 tomato test^M +job^M 1 1 stamp 19990402000000 diff --git a/mysql-test/t/key_diff.test b/mysql-test/t/key_diff.test index d35644ae192..60afb5f81a4 100644 --- a/mysql-test/t/key_diff.test +++ b/mysql-test/t/key_diff.test @@ -14,6 +14,6 @@ INSERT INTO t1 VALUES ('A','B'),('b','A'),('C','c'),('D','E'),('a','a'); select * from t1,t1 as t2; explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B; #select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B; -select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by t1.a; +select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a; select * from t1 where a='a'; drop table t1; diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test index 8e4612195c2..82216fdd904 100644 --- a/mysql-test/t/type_blob.test +++ b/mysql-test/t/type_blob.test @@ -203,7 +203,7 @@ INSERT INTO t7 VALUES (1,0,'High',1); INSERT INTO t7 VALUES (2,0,'Medium',2); INSERT INTO t7 VALUES (3,0,'Low',3); -select t3._field_140,min(t3._field_131), min(t3._field_135), min(t3._field_139), min(t3._field_137), min(link_alias_142._field_165), min(link_alias_133._field_72), min(t3._field_145), min(link_alias_148._field_156), min(t3._field_140), t3.t3_id from t3 left join t4 on t4.seq_0_id = t3.t3_id left join t7 link_alias_142 on t4.seq_1_id = link_alias_142.t7_id left join t6 on t6.seq_0_id = t3.t3_id left join t1 link_alias_133 on t6.seq_1_id = link_alias_133.t1_id left join t2 on t2.seq_0_id = t3.t3_id left join t5 link_alias_148 on t2.seq_1_id = link_alias_148.t5_id where t3.t3_id in (1) group by t3.t3_id order by link_alias_142._field_166, _field_139, link_alias_133._field_72, _field_135, link_alias_148._field_156; +select t3._field_140,min(t3._field_131), min(t3._field_135), min(t3._field_139), min(t3._field_137), min(link_alias_142._field_165), min(link_alias_133._field_72), min(t3._field_145), min(link_alias_148._field_156), replace(min(t3._field_140), "\r","^M"),t3.t3_id from t3 left join t4 on t4.seq_0_id = t3.t3_id left join t7 link_alias_142 on t4.seq_1_id = link_alias_142.t7_id left join t6 on t6.seq_0_id = t3.t3_id left join t1 link_alias_133 on t6.seq_1_id = link_alias_133.t1_id left join t2 on t2.seq_0_id = t3.t3_id left join t5 link_alias_148 on t2.seq_1_id = link_alias_148.t5_id where t3.t3_id in (1) group by t3.t3_id order by link_alias_142._field_166, _field_139, link_alias_133._field_72, _field_135, link_alias_148._field_156; drop table t1,t2,t3,t4,t5,t6,t7; diff --git a/mysys/hash.c b/mysys/hash.c index 9c6497c7717..b366554272a 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -108,6 +108,8 @@ static uint hash_rec_mask(HASH *hash,HASH_LINK *pos,uint buffmax, return hash_mask((*hash->calc_hashnr)(key,length),buffmax,maxlength); } +#ifndef NEW_HASH_FUNCTION + /* Calc hashvalue for a key */ static uint calc_hashnr(const byte *key,uint length) @@ -134,6 +136,49 @@ static uint calc_hashnr_caseup(const byte *key,uint length) return((uint) nr); } +#else + +/* + * Fowler/Noll/Vo hash + * + * The basis of the hash algorithm was taken from an idea sent by email to the + * IEEE Posix P1003.2 mailing list from Phong Vo (kpv@research.att.com) and + * Glenn Fowler (gsf@research.att.com). Landon Curt Noll (chongo@toad.com) + * later improved on their algorithm. + * + * 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. + */ + +uint calc_hashnr(const byte *key, uint len) +{ + const byte *end=key+len; + uint hash; + for (hash = 0; key < end; key++) + { + hash *= 16777619; + hash ^= (uint) *(uchar*) key; + } + return (hash); +} + +uint calc_hashnr_caseup(const byte *key, uint len) +{ + const byte *end=key+len; + uint hash; + for (hash = 0; key < end; key++) + { + hash *= 16777619; + hash ^= (uint) (uchar) toupper(*key); + } + return (hash); +} + +#endif + static inline uint rec_hashnr(HASH *hash,const byte *record) { diff --git a/scripts/safe_mysqld.sh b/scripts/safe_mysqld.sh index 9325cee4f33..11d17f822ee 100644 --- a/scripts/safe_mysqld.sh +++ b/scripts/safe_mysqld.sh @@ -51,6 +51,7 @@ parse_arguments() { --open-files-limit=*) open_files=`echo "$arg" | sed -e "s;--open-files-limit=;;"` ;; --core-file-size=*) core_file_size=`echo "$arg" | sed -e "s;--core_file_size=;;"` ;; --timezone=*) TZ=`echo "$arg" | sed -e "s;--timezone=;;"` ; export TZ; ;; + --mysqld=*) MYSQLD=`echo "$arg" | sed -e "s;--mysqld=;;"` ;; *) if test -n "$pick_args" then @@ -87,6 +88,7 @@ fi MYSQL_UNIX_PORT=${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@} MYSQL_TCP_PORT=${MYSQL_TCP_PORT:-@MYSQL_TCP_PORT@} user=@MYSQLD_USER@ +MYSQLD=mysqld # these rely on $DATADIR by default, so we'll set them later on pid_file= @@ -111,9 +113,9 @@ args= parse_arguments `$print_defaults $defaults mysqld safe_mysqld` parse_arguments PICK-ARGS-FROM-ARGV "$@" -if test ! -x $ledir/mysqld +if test ! -x $ledir/$MYSQLD then - echo "The file $ledir/mysqld doesn't exist or is not executable" + echo "The file $ledir/$MYSQLD doesn't exist or is not executable" echo "Please do a cd to the mysql installation directory and restart" echo "this script from there as follows:" echo "./bin/safe_mysqld". @@ -195,7 +197,7 @@ fi # $MY_BASEDIR_VERSION/bin/myisamchk --silent --force --fast --medium-check -O key_buffer=64M -O sort_buffer=64M $DATADIR/*/*.MYI # $MY_BASEDIR_VERSION/bin/isamchk --silent --force -O sort_buffer=64M $DATADIR/*/*.ISM -echo "Starting mysqld daemon with databases from $DATADIR" +echo "Starting $MYSQLD daemon with databases from $DATADIR" # Does this work on all systems? #if type ulimit | grep "shell builtin" > /dev/null @@ -209,9 +211,9 @@ do rm -f $MYSQL_UNIX_PORT $pid_file # Some extra safety if test -z "$args" then - $NOHUP_NICENESS $ledir/mysqld $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR --user=$user --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1 + $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR --user=$user --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1 else - eval "$NOHUP_NICENESS $ledir/mysqld $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR --user=$user --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1" + eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR --user=$user --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1" fi if test ! -f $pid_file # This is removed if normal shutdown then @@ -225,12 +227,12 @@ do # but should work for the rest of the servers. # The only thing is ps x => redhat 5 gives warnings when using ps -x. # kill -9 is used or the process won't react on the kill. - numofproces=`ps xa | grep -v "grep" | grep -c $ledir/mysqld` + numofproces=`ps xa | grep -v "grep" | grep -c $ledir/$MYSQLD` echo -e "\nNumber of processes running now: $numofproces" | tee -a $err_log I=1 while test "$I" -le "$numofproces" do - PROC=`ps xa | grep $ledir/mysqld | grep -v "grep" | tail -1` + PROC=`ps xa | grep $ledir/$MYSQLD | grep -v "grep" | tail -1` for T in $PROC do break @@ -238,7 +240,7 @@ do # echo "TEST $I - $T **" if kill -9 $T then - echo "mysqld process hanging, pid $T - killed" | tee -a $err_log + echo "$MYSQLD process hanging, pid $T - killed" | tee -a $err_log else break fi diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 58e3d540d04..ab6bd99b819 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -1971,11 +1971,17 @@ ha_innobase::external_lock( THR_LOCK_DATA **ha_innobase::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) { - /*??????????????????*/ - - *to++= &lock; - - return(to); + if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) + { + /* If we are not doing a LOCK TABLE, then allow multiple writers */ + if ((lock_type >= TL_WRITE_CONCURRENT_INSERT && + lock_type <= TL_WRITE) && + !thd->in_lock_tables) + lock_type = TL_WRITE_ALLOW_WRITE; + lock.type=lock_type; + } + *to++= &lock; + return(to); } /********************************************************************* diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 055dceaf4d3..b788c8d122c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1082,9 +1082,10 @@ inline static __volatile__ void trace_stack() uchar **stack_bottom; uchar** ebp; LINT_INIT(ebp); - fprintf(stderr, "Attemping backtrace, please send the info below to \ -bugs@lists.mysql.com. If you see no messages after this, something \ -went terribly wrong - report this anyway\n"); + fprintf(stderr, +"Attemping backtrace. You can use the following information to find out\n\ +where mysqld died. If you see no messages after this, something went\n\ +terribly wrong\n"); THD* thd = current_thd; uint frame_count = 0; __asm __volatile__ ("movl %%ebp,%0" @@ -1092,7 +1093,7 @@ went terribly wrong - report this anyway\n"); :"r"(ebp)); if (!ebp) { - fprintf(stderr, "frame pointer (ebp) is NULL, did you compile with \ + fprintf(stderr, "frame pointer (ebp) is NULL, did you compile with\n\ -fomit-frame-pointer? Aborting backtrace\n"); return; } @@ -1143,9 +1144,9 @@ static sig_handler handle_segfault(int sig) segfaulted = 1; fprintf(stderr,"\ mysqld got signal %d;\n\ -The manual section 'Debugging a MySQL server' tells you how to use a \n\ -debugger on the core file to produce a backtrace that may help you find out\n\ -why mysqld died\n",sig); +The manual section 'Debugging a MySQL server' tells you how to use a\n\ +stack trace and/or the core file to produce a readable backtrace that may\n\ +help in finding out why mysqld died\n",sig); #if defined(HAVE_LINUXTHREADS) #ifdef __i386__ trace_stack(); @@ -1622,12 +1623,14 @@ int main(int argc, char **argv) { server_id= !master_host ? 1 : 2; switch (server_id) { +#ifdef EXTRA_DEBUG case 1: sql_print_error("\ Warning: one should set server_id to a non-0 value if log-bin is enabled.\n\ Will log updates to binary log, but will not accept connections from slaves"); break; - default: +#endif + case 2: sql_print_error("\ Warning: one should set server_id to a non-0 value if master_host is set.\n\ The server will not act as a slave"); @@ -2548,7 +2551,7 @@ CHANGEABLE_VAR changeable_vars[] = { { "lower_case_table_names", (long*) &lower_case_table_names, IF_WIN(1,0), 0, 1, 0, 1 }, { "max_allowed_packet", (long*) &max_allowed_packet, - 1024*1024L, 80, 17*1024*1024L, MALLOC_OVERHEAD, 1024 }, + 1024*1024L, 80, 64*1024*1024L, MALLOC_OVERHEAD, 1024 }, { "max_binlog_cache_size", (long*) &max_binlog_cache_size, ~0L, IO_SIZE, ~0L, 0, IO_SIZE }, { "max_connections", (long*) &max_connections, |