diff options
249 files changed, 3798 insertions, 2652 deletions
diff --git a/BUILD/compile-pentium-gcov b/BUILD/compile-pentium-gcov index dc4ddcb1090..05cb0bb0d78 100755 --- a/BUILD/compile-pentium-gcov +++ b/BUILD/compile-pentium-gcov @@ -3,7 +3,7 @@ path=`dirname $0` . "$path/SETUP.sh" -extra_flags="$pentium_cflags -fprofile-arcs -ftest-coverage -fmessage-length=0 " +extra_flags="$pentium_cflags -fprofile-arcs -ftest-coverage" extra_configs="$pentium_configs $debug_configs --disable-shared $static_link" extra_configs="$extra_configs --with-innodb --with-berkeley-db" diff --git a/BUILD/compile-pentium-valgrind-max b/BUILD/compile-pentium-valgrind-max index 2e739ce9607..d1c84b93484 100755 --- a/BUILD/compile-pentium-valgrind-max +++ b/BUILD/compile-pentium-valgrind-max @@ -8,7 +8,8 @@ c_warnings="$c_warnings $debug_extra_warnings" cxx_warnings="$cxx_warnings $debug_extra_warnings" extra_configs="$pentium_configs $debug_configs" -extra_configs="$extra_configs --with-berkeley-db --with-innodb --without-isam --with-embedded-server --with-openssl" +# We want to test isam when building with valgrind +extra_configs="$extra_configs --with-berkeley-db --with-innodb --with-isam --with-embedded-server --with-openssl" . "$path/FINISH.sh" diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 00084b365f5..9fecdc743db 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -50,6 +50,7 @@ jani@janikt.pp.saunalahti.fi jani@rhols221.adsl.netsonic.fi jani@rhols221.arenanet.fi jani@ua126d19.elisa.omakaista.fi +jani@ua167d18.elisa.omakaista.fi jcole@abel.spaceapes.com jcole@main.burghcom.com jcole@mugatu.spaceapes.com @@ -111,12 +112,14 @@ root@x3.internalnet salle@banica.(none) salle@geopard.(none) salle@geopard.online.bg +salle@vafla.online.bg sasha@mysql.sashanet.com serg@build.mysql2.com serg@serg.mylan serg@serg.mysql.com serg@sergbook.mylan serg@sergbook.mysql.com +sergefp@mysql.com sinisa@rhols221.adsl.netsonic.fi tfr@beta.frontier86.ee tfr@indrek.tfr.cafe.ee diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index 94446d9880f..17b15d190b0 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -276,7 +276,7 @@ unless ($opt_skip_manual) { $msg= "Adding manual.texi"; &logger($msg); - $command= "install -m 644 $opt_docdir/Docs/{manual,reservedwords}.texi"; + $command= "install -m 644 $opt_docdir/Docs/{internals,manual,reservedwords}.texi"; $command.= " $target_dir/Docs/"; &run_command($command, "Could not update the manual in $target_dir/Docs/!"); } diff --git a/Docs/Makefile.am b/Docs/Makefile.am index cfe613c8e2e..f14aaace1bb 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -22,7 +22,7 @@ targets = manual.txt mysql.info manual.html BUILT_SOURCES = $(targets) manual_toc.html include.texi EXTRA_DIST = $(noinst_SCRIPTS) $(BUILT_SOURCES) mysqld_error.txt \ - INSTALL-BINARY reservedwords.texi + INSTALL-BINARY reservedwords.texi internals.texi all: $(targets) txt_files diff --git a/Docs/internals.texi b/Docs/internals.texi new file mode 100644 index 00000000000..e1462531270 --- /dev/null +++ b/Docs/internals.texi @@ -0,0 +1,101 @@ +\input texinfo @c -*-texinfo-*- +@c +@c ********************************************************* +@c +@c This is a dummy placeholder file for internals.texi in the +@c MySQL source trees. +@c +@c Note, that the internals documentation has been moved into a separate +@c BitKeeper source tree named "mysqldoc" - do not attempt to edit this +@c file! All changes to internals.texi should be done in the mysqldoc tree. +@c +@c See http://www.mysql.com/doc/en/Installing_source_tree.html +@c for information about how to work with BitKeeper source trees. +@c +@c This dummy file is being replaced with the actual file from the +@c mysqldoc tree when building the official source distribution. +@c +@c Please e-mail docs@mysql.com for more information or if +@c you are interested in doing a translation. +@c +@c ********************************************************* +@c +@c %**start of header + +@setfilename internals.info + +@c We want the types in the same index +@syncodeindex tp fn + +@ifclear tex-debug +@c This removes the black squares in the right margin +@finalout +@end ifclear + +@c Set background for HTML +@set _body_tags BGCOLOR=silver TEXT=#000000 LINK=#101090 VLINK=#7030B0 +@c Set some style elements for the manual in HTML form. 'suggested' +@c natural language colors: aqua, black, blue, fuchsia, gray, green, +@c lime, maroon, navy, olive, purple, red, silver, teal, white, and +@c yellow. From Steeve Buehler <ahr@YogElements.com> +@set _extra_head <style> code {color:purple} tt {color:green} samp {color:navy} pre {color:maroon} </style> + +@settitle Dummy MySQL internals documentation for version @value{mysql_version}. + +@c We want single-sided heading format, with chapters on new pages. To +@c get double-sided format change 'on' below to 'odd' +@setchapternewpage on + +@paragraphindent 0 + +@c %**end of header + +@ifinfo +@format +START-INFO-DIR-ENTRY +* mysql: (mysql). MySQL documentation. +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@titlepage +@sp 10 +@center @titlefont{Empty placeholder for the MySQL Internals Documentation} +@sp 10 +@center Copyright @copyright{} 1995-2003 MySQL AB +@c blank page after title page makes page 1 be a page front. +@c also makes the back of the title page blank. +@page +@end titlepage + +@c This should be added. The HTML conversion also needs a MySQL version +@c number somewhere. + +@iftex +@c change this to double if you want formatting for double-sided +@c printing +@headings single + +@oddheading @thischapter @| @| @thispage +@evenheading @thispage @| @| MySQL Internal Reference for Version @value{mysql_version} + +@end iftex + +@node Top, (dir), (dir), (dir) + +@ifinfo +This is an empty placeholder file for the MySQL internals documentation. + +The real version of this file is now maintained in a separate BitKeeper +source tree! Please see +@url{http://www.mysql.com/doc/en/Installing_source_tree.html} for more info +on how to work with BitKeeper. + +Please do not attempt to edit this file directly - use the one in the +@code{mysqldoc} BK tree instead. + +This file will be replaced with the current @code{internals.texi} when +building the official source distribution. +@end ifinfo + +@bye diff --git a/VC++Files/client/mysqlclient.dsp b/VC++Files/client/mysqlclient.dsp index 685c9ae1a15..4a9d52232ca 100644 --- a/VC++Files/client/mysqlclient.dsp +++ b/VC++Files/client/mysqlclient.dsp @@ -100,6 +100,10 @@ SOURCE=..\strings\bmove_upp.c # End Source File # Begin Source File +SOURCE="..\mysys\charset-def.c" +# End Source File +# Begin Source File + SOURCE=..\mysys\charset.c # End Source File # Begin Source File diff --git a/VC++Files/libmysql/libmysql.dsp b/VC++Files/libmysql/libmysql.dsp index 8ab15a03110..6b76a6147ff 100644 --- a/VC++Files/libmysql/libmysql.dsp +++ b/VC++Files/libmysql/libmysql.dsp @@ -119,6 +119,10 @@ SOURCE=..\strings\bmove_upp.c # End Source File # Begin Source File +SOURCE="..\mysys\charset-def.c" +# End Source File +# Begin Source File + SOURCE=..\mysys\charset.c # End Source File # Begin Source File diff --git a/VC++Files/myisam/myisam.dsp b/VC++Files/myisam/myisam.dsp index 38cac3a0aba..0b386997e5e 100644 --- a/VC++Files/myisam/myisam.dsp +++ b/VC++Files/myisam/myisam.dsp @@ -25,7 +25,7 @@ CFG=myisam - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "myisam - Win32 Release" @@ -47,7 +47,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_release\myisam.lib" @@ -70,7 +70,7 @@ LIB32=link.exe -lib BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_Debug\myisam.lib" @@ -169,6 +169,10 @@ SOURCE=.\mi_key.c # End Source File # Begin Source File +SOURCE=.\mi_keycache.c +# End Source File +# Begin Source File + SOURCE=.\mi_locking.c # End Source File # Begin Source File diff --git a/VC++Files/mysql.dsw b/VC++Files/mysql.dsw index 4ff8c1df3fc..ea391362b84 100644 --- a/VC++Files/mysql.dsw +++ b/VC++Files/mysql.dsw @@ -251,6 +251,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name strings End Project Dependency + Begin Project Dependency + Project_Dep_Name zlib + End Project Dependency }}} ############################################################################### @@ -275,6 +278,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name strings End Project Dependency + Begin Project Dependency + Project_Dep_Name zlib + End Project Dependency }}} ############################################################################### @@ -311,6 +317,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name strings End Project Dependency + Begin Project Dependency + Project_Dep_Name zlib + End Project Dependency }}} ############################################################################### diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp index 533d4212e2b..3f9d37b395f 100644 --- a/VC++Files/mysys/mysys.dsp +++ b/VC++Files/mysys/mysys.dsp @@ -126,6 +126,10 @@ SOURCE=.\array.c # End Source File # Begin Source File +SOURCE=".\charset-def.c" +# End Source File +# Begin Source File + SOURCE=.\charset.c # End Source File # Begin Source File @@ -190,6 +194,10 @@ SOURCE=.\mf_keycache.c # End Source File # Begin Source File +SOURCE=.\mf_keycaches.c +# End Source File +# Begin Source File + SOURCE=.\mf_loadpath.c # End Source File # Begin Source File @@ -290,6 +298,10 @@ SOURCE=.\my_copy.c # End Source File # Begin Source File +SOURCE=.\my_crc32.c +# End Source File +# Begin Source File + SOURCE=.\my_create.c # End Source File # Begin Source File diff --git a/client/mysql.cc b/client/mysql.cc index c93875a55fc..059a1ad36f5 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -44,7 +44,7 @@ #include <locale.h> #endif -const char *VER= "14.2"; +const char *VER= "14.3"; /* Don't try to make a nice table if the data is too big */ #define MAX_COLUMN_LENGTH 1024 @@ -1621,7 +1621,8 @@ com_go(String *buffer,char *line __attribute__((unused))) char buff[200], time_buff[32], *pos; MYSQL_RES *result; ulong timer, warnings; - uint error=0; + uint error= 0; + int err= 0; if (!status.batch) { @@ -1665,79 +1666,84 @@ com_go(String *buffer,char *line __attribute__((unused))) buffer->length(0); // Remove query on error return error; } - error=0; buffer->length(0); - if (quick) - { - if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql)) - return put_error(&mysql); - } - else - { - error= mysql_store_result_for_lazy(&result); - if (error) - return error; - } - - if (verbose >= 3 || !opt_silent) - mysql_end_timer(timer,time_buff); - else - time_buff[0]=0; - if (result) + do { - if (!mysql_num_rows(result) && ! quick) + if (quick) { - strmov(buff, "Empty set"); + if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql)) + return put_error(&mysql); } else { - init_pager(); - if (opt_html) - print_table_data_html(result); - else if (opt_xml) - print_table_data_xml(result); - else if (vertical) - print_table_data_vertically(result); - else if (opt_silent && verbose <= 2 && !output_tables) - print_tab_data(result); + error= mysql_store_result_for_lazy(&result); + if (error) + return error; + } + + if (verbose >= 3 || !opt_silent) + mysql_end_timer(timer,time_buff); + else + time_buff[0]=0; + if (result) + { + if (!mysql_num_rows(result) && ! quick) + { + strmov(buff, "Empty set"); + } else - print_table_data(result); - sprintf(buff,"%ld %s in set", - (long) mysql_num_rows(result), - (long) mysql_num_rows(result) == 1 ? "row" : "rows"); - end_pager(); + { + init_pager(); + if (opt_html) + print_table_data_html(result); + else if (opt_xml) + print_table_data_xml(result); + else if (vertical) + print_table_data_vertically(result); + else if (opt_silent && verbose <= 2 && !output_tables) + print_tab_data(result); + else + print_table_data(result); + sprintf(buff,"%ld %s in set", + (long) mysql_num_rows(result), + (long) mysql_num_rows(result) == 1 ? "row" : "rows"); + end_pager(); + } } - } - else if (mysql_affected_rows(&mysql) == ~(ulonglong) 0) - strmov(buff,"Query OK"); - else - sprintf(buff,"Query OK, %ld %s affected", - (long) mysql_affected_rows(&mysql), - (long) mysql_affected_rows(&mysql) == 1 ? "row" : "rows"); - - pos=strend(buff); - if ((warnings= mysql_warning_count(&mysql))) - { - *pos++= ','; - *pos++= ' '; - pos=int2str(warnings, pos, 10); - pos=strmov(pos, " warning"); - if (warnings != 1) - *pos++= 's'; - } - strmov(pos, time_buff); - put_info(buff,INFO_RESULT); - if (mysql_info(&mysql)) - put_info(mysql_info(&mysql),INFO_RESULT); - put_info("",INFO_RESULT); // Empty row - - if (result && !mysql_eof(result)) /* Something wrong when using quick */ + else if (mysql_affected_rows(&mysql) == ~(ulonglong) 0) + strmov(buff,"Query OK"); + else + sprintf(buff,"Query OK, %ld %s affected", + (long) mysql_affected_rows(&mysql), + (long) mysql_affected_rows(&mysql) == 1 ? "row" : "rows"); + + pos=strend(buff); + if ((warnings= mysql_warning_count(&mysql))) + { + *pos++= ','; + *pos++= ' '; + pos=int2str(warnings, pos, 10); + pos=strmov(pos, " warning"); + if (warnings != 1) + *pos++= 's'; + } + strmov(pos, time_buff); + put_info(buff,INFO_RESULT); + if (mysql_info(&mysql)) + put_info(mysql_info(&mysql),INFO_RESULT); + put_info("",INFO_RESULT); // Empty row + + if (result && !mysql_eof(result)) /* Something wrong when using quick */ + error= put_error(&mysql); + else if (unbuffered) + fflush(stdout); + mysql_free_result(result); + } while (!(err= mysql_next_result(&mysql))); + if (err >= 1) error= put_error(&mysql); - else if (unbuffered) - fflush(stdout); - mysql_free_result(result); + return error; /* New command follows */ } @@ -2416,6 +2422,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line) } strmake(delimiter, tmp, sizeof(delimiter) - 1); delimiter_length= strlen(delimiter); + delimiter_str= delimiter; return 0; } @@ -2571,7 +2578,7 @@ sql_real_connect(char *host,char *database,char *user,char *password, mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset); if (!mysql_real_connect(&mysql, host, user, password, database, opt_mysql_port, opt_mysql_unix_port, - connect_flag | CLIENT_MULTI_QUERIES)) + connect_flag | CLIENT_MULTI_STATEMENTS)) { if (!silent || (mysql_errno(&mysql) != CR_CONN_HOST_ERROR && diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 00767ae98a7..1768d948373 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -309,6 +309,8 @@ static int get_options(int *argc, char ***argv) else what_to_do = DO_CHECK; } + + /* TODO: This variable is not yet used */ if (!(charset_info= get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(MY_WME)))) exit(1); diff --git a/client/mysqltest.c b/client/mysqltest.c index 6a7f4ab7cac..e3e3d19984a 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -118,7 +118,6 @@ static FILE** cur_file; static FILE** file_stack_end; static uint lineno_stack[MAX_INCLUDE_DEPTH]; static char TMPDIR[FN_REFLEN]; -static int *block_ok_stack_end; static int *cur_block, *block_stack_end; static int block_stack[BLOCK_STACK_DEPTH]; @@ -1495,7 +1494,6 @@ int do_connect(struct st_query* q) char* p=q->first_argument; char buff[FN_REFLEN]; int con_port; - int con_error; int free_con_sock = 0; DBUG_ENTER("do_connect"); @@ -1560,9 +1558,9 @@ int do_connect(struct st_query* q) /* Special database to allow one to connect without a database name */ if (con_db && !strcmp(con_db,"*NO-ONE*")) con_db=0; - if ((con_error = safe_connect(&next_con->mysql, con_host, - con_user, con_pass, - con_db, con_port, con_sock ? con_sock: 0))) + if ((safe_connect(&next_con->mysql, con_host, + con_user, con_pass, + con_db, con_port, con_sock ? con_sock: 0))) die("Could not open connection '%s': %s", con_name, mysql_error(&next_con->mysql)); @@ -2018,12 +2016,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), int parse_args(int argc, char **argv) { - int ho_error; - load_defaults("my",load_default_groups,&argc,&argv); default_argv= argv; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + if ((handle_options(&argc, &argv, my_long_options, get_one_option))) exit(1); if (argc > 1) @@ -2454,7 +2450,6 @@ int main(int argc, char **argv) memset(block_stack, 0, sizeof(block_stack)); block_stack_end = block_stack + BLOCK_STACK_DEPTH; memset(block_ok_stack, 0, sizeof(block_stack)); - block_ok_stack_end = block_ok_stack + BLOCK_STACK_DEPTH; cur_block = block_stack; block_ok = block_ok_stack; *block_ok = 1; diff --git a/heap/hp_test1.c b/heap/hp_test1.c index 96399fe4f2e..dd696528eb8 100644 --- a/heap/hp_test1.c +++ b/heap/hp_test1.c @@ -91,7 +91,7 @@ int main(int argc, char **argv) { if (i == remove_ant) { VOID(heap_close(file)) ; return (0) ; } sprintf(key,"%6d",(j=(int) ((rand() & 32767)/32767.*25))); - if ((error = heap_rkey(file,record,0,key,0,6))) + if ((error = heap_rkey(file,record,0,key,6,HA_READ_KEY_EXACT))) { if (verbose || (flags[j] == 1 || (error && my_errno != HA_ERR_KEY_NOT_FOUND))) @@ -119,7 +119,7 @@ int main(int argc, char **argv) sprintf(key,"%6d",i); bmove(record+1,key,6); my_errno=0; - error=heap_rkey(file,record,0,key,0,6); + error=heap_rkey(file,record,0,key,6,HA_READ_KEY_EXACT); if (verbose || (error == 0 && flags[i] != 1) || (error && (flags[i] != 0 || my_errno != HA_ERR_KEY_NOT_FOUND))) diff --git a/heap/hp_test2.c b/heap/hp_test2.c index 97fe1471ca1..2de49bcb66b 100644 --- a/heap/hp_test2.c +++ b/heap/hp_test2.c @@ -179,7 +179,7 @@ int main(int argc, char *argv[]) if (j != 0) { sprintf(key,"%6d",j); - if (heap_rkey(file,record,0,key,6,0)) + if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT)) { printf("can't find key1: \"%s\"\n",key); goto err; @@ -239,7 +239,7 @@ int main(int argc, char *argv[]) if (!key1[j]) continue; sprintf(key,"%6d",j); - if (heap_rkey(file,record,0,key,6,0)) + if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT)) { printf("can't find key1: \"%s\"\n",key); goto err; @@ -289,7 +289,7 @@ int main(int argc, char *argv[]) printf("- Read first key - next - delete - next -> last\n"); DBUG_PRINT("progpos",("first - next - delete - next -> last")); - if (heap_rkey(file,record,0,key,6,0)) + if (heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT)) goto err; if (heap_rnext(file,record3)) goto err; if (heap_delete(file,record3)) goto err; @@ -513,7 +513,7 @@ int main(int argc, char *argv[]) } printf("- Read through all keys with first-next-last-prev\n"); ant=0; - for (error=heap_rkey(file,record,0,key,6,0); + for (error=heap_rkey(file,record,0,key,6, HA_READ_KEY_EXACT); ! error ; error=heap_rnext(file,record)) ant++; @@ -550,7 +550,8 @@ int main(int argc, char *argv[]) { if (error == 0) { - if (heap_rkey(file2,record2,2,record+keyinfo[2].seg[0].start,8,0)) + if (heap_rkey(file2,record2,2,record+keyinfo[2].seg[0].start,8, + HA_READ_KEY_EXACT)) { printf("can't find key3: \"%.8s\"\n", record+keyinfo[2].seg[0].start); diff --git a/include/hash.h b/include/hash.h index 3c2ae32c70e..c7cc118b7bd 100644 --- a/include/hash.h +++ b/include/hash.h @@ -22,14 +22,15 @@ extern "C" { #endif +/* + Overhead to store an element in hash + Can be used to approximate memory consumption for a hash + */ +#define HASH_OVERHEAD (sizeof(char*)*2) + typedef byte *(*hash_get_key)(const byte *,uint*,my_bool); typedef void (*hash_free_key)(void *); -typedef struct st_hash_info { - uint next; /* index to next key */ - byte *data; /* data for current entry */ -} HASH_LINK; - typedef struct st_hash { uint key_offset,key_length; /* Length of key if const length */ uint records,blength,current_record; diff --git a/include/keycache.h b/include/keycache.h new file mode 100644 index 00000000000..340ab881fee --- /dev/null +++ b/include/keycache.h @@ -0,0 +1,131 @@ +/* Copyright (C) 2003 MySQL 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 */ + +/* Key cache variable structures */ + +#ifndef _keycache_h +#define _keycache_h +C_MODE_START + +/* declare structures that is used by st_key_cache */ + +struct st_block_link; +typedef struct st_block_link BLOCK_LINK; +struct st_keycache_page; +typedef struct st_keycache_page KEYCACHE_PAGE; +struct st_hash_link; +typedef struct st_hash_link HASH_LINK; + +/* info about requests in a waiting queue */ +typedef struct st_keycache_wqueue +{ + struct st_my_thread_var *last_thread; /* circular list of waiting threads */ +} KEYCACHE_WQUEUE; + +#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */ + +/* + The key cache structure + It also contains read-only statistics parameters. +*/ + +typedef struct st_key_cache +{ + my_bool key_cache_inited; + uint key_cache_shift; + ulong key_cache_mem_size; /* specified size of the cache memory */ + uint key_cache_block_size; /* size of the page buffer of a cache block */ + ulong min_warm_blocks; /* min number of warm blocks; */ + ulong age_threshold; /* age threshold for hot blocks */ + ulonglong keycache_time; /* total number of block link operations */ + uint hash_entries; /* max number of entries in the hash table */ + int hash_links; /* max number of hash links */ + int hash_links_used; /* number of hash links currently used */ + int disk_blocks; /* max number of blocks in the cache */ + ulong blocks_used; /* number of currently used blocks */ + ulong blocks_changed; /* number of currently dirty blocks */ + ulong warm_blocks; /* number of blocks in warm sub-chain */ + long blocks_available; /* number of blocks available in the LRU chain */ + HASH_LINK **hash_root; /* arr. of entries into hash table buckets */ + HASH_LINK *hash_link_root; /* memory for hash table links */ + HASH_LINK *free_hash_list; /* list of free hash links */ + BLOCK_LINK *block_root; /* memory for block links */ + byte HUGE_PTR *block_mem; /* memory for block buffers */ + BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */ + BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */ + pthread_mutex_t cache_lock; /* to lock access to the cache structure */ + KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */ + KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */ + BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/ + BLOCK_LINK *file_blocks[CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/ + + /* + The following variables are and variables used to hold parameters for + initializing the key cache. + */ + + ulonglong param_buff_size; /* size the memory allocated for the cache */ + ulong param_block_size; /* size of the blocks in the key cache */ + ulong param_division_limit; /* min. percentage of warm blocks */ + ulong param_age_threshold; /* determines when hot block is downgraded */ + + /* Statistics variables */ + ulong global_blocks_used; /* number of currently used blocks */ + ulong global_blocks_changed; /* number of currently dirty blocks */ + ulong global_cache_w_requests;/* number of write requests (write hits) */ + ulong global_cache_write; /* number of writes from the cache to files */ + ulong global_cache_r_requests;/* number of read requests (read hits) */ + ulong global_cache_read; /* number of reads from files to the cache */ + int blocks; /* max number of blocks in the cache */ + my_bool in_init; /* Set to 1 in MySQL during init/resize */ +} KEY_CACHE; + +/* The default key cache */ +extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache; + +extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, + ulong use_mem, uint division_limit, + uint age_threshold); +extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, + ulong use_mem, uint division_limit, + uint age_threshold); +extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, + uint age_threshold); +extern byte *key_cache_read(KEY_CACHE *keycache, + File file, my_off_t filepos, int level, + byte *buff, uint length, + uint block_length,int return_buffer); +extern int key_cache_insert(KEY_CACHE *keycache, + File file, my_off_t filepos, int level, + byte *buff, uint length); +extern int key_cache_write(KEY_CACHE *keycache, + File file, my_off_t filepos, int level, + byte *buff, uint length, + uint block_length,int force_write); +extern int flush_key_blocks(KEY_CACHE *keycache, + int file, enum flush_type type); +extern void end_key_cache(KEY_CACHE *keycache, my_bool cleanup); + +/* Functions to handle multiple key caches */ +extern my_bool multi_keycache_init(void); +extern void multi_keycache_free(void); +extern KEY_CACHE *multi_key_cache_search(byte *key, uint length); +extern my_bool multi_key_cache_set(const byte *key, uint length, + KEY_CACHE *key_cache); +extern void multi_key_cache_change(KEY_CACHE *old_data, + KEY_CACHE *new_data); +C_MODE_END +#endif /* _keycache_h */ diff --git a/include/m_ctype.h b/include/m_ctype.h index e2b2f7f1668..0228b359111 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -335,6 +335,14 @@ uint my_instr_mb(struct charset_info_st *, extern my_bool my_parse_charset_xml(const char *bug, uint len, int (*add)(CHARSET_INFO *cs)); +#undef _U +#undef _L +#undef _NMR +#undef _SPC +#undef _PNT +#undef _CTR +#undef _B +#undef _X #define _U 01 /* Upper case */ #define _L 02 /* Lower case */ diff --git a/include/my_base.h b/include/my_base.h index 4c3e53c4573..25521d7b13d 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -46,7 +46,6 @@ #define HA_OPEN_DELAY_KEY_WRITE 8 /* Don't update index */ #define HA_OPEN_ABORT_IF_CRASHED 16 #define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */ -#define HA_OPEN_TO_ASSIGN 64 /* Open for key cache assignment */ /* The following is parameter to ha_rkey() how to use key */ @@ -126,14 +125,14 @@ enum ha_extra_function { HA_EXTRA_RESET_STATE, /* Reset positions */ HA_EXTRA_IGNORE_DUP_KEY, /* Dup keys don't rollback everything*/ HA_EXTRA_NO_IGNORE_DUP_KEY, - HA_EXTRA_RETRIEVE_ALL_COLS, /* Instructs InnoDB to retrieve all - columns, not just those where - field->query_id is the same as the - current query id */ + /* + Instructs InnoDB to retrieve all columns, not just those where + field->query_id is the same as the current query id + */ + HA_EXTRA_RETRIEVE_ALL_COLS, HA_EXTRA_PREPARE_FOR_DELETE, HA_EXTRA_PREPARE_FOR_UPDATE, /* Remove read cache if problems */ - HA_EXTRA_PRELOAD_BUFFER_SIZE, /* Set buffer size for preloading */ - HA_EXTRA_SET_KEY_CACHE /* Set ref to assigned key cache */ + HA_EXTRA_PRELOAD_BUFFER_SIZE /* Set buffer size for preloading */ }; /* The following is parameter to ha_panic() */ diff --git a/include/my_global.h b/include/my_global.h index 43cacf8fa65..b5b78774e91 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -688,7 +688,8 @@ typedef long long my_ptrdiff_t; #endif #endif #if defined(__IBMC__) || defined(__IBMCPP__) -#define STDCALL _System _Export +/* This was _System _Export but caused a lot of warnings on _AIX43 */ +#define STDCALL #elif !defined( STDCALL) #define STDCALL #endif diff --git a/include/my_no_pthread.h b/include/my_no_pthread.h index 0a034f78192..2c9cde65e78 100644 --- a/include/my_no_pthread.h +++ b/include/my_no_pthread.h @@ -27,5 +27,9 @@ #define pthread_mutex_lock(A) #define pthread_mutex_unlock(A) #define pthread_mutex_destroy(A) - +#define my_rwlock_init(A,B) +#define rw_rdlock(A) +#define rw_wrlock(A) +#define rw_unlock(A) +#define rwlock_destroy(A) #endif diff --git a/include/my_pthread.h b/include/my_pthread.h index a4ea88b20f0..44e6edcddec 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -468,7 +468,7 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); typedef struct st_safe_mutex_t { pthread_mutex_t global,mutex; - char *file; + const char *file; uint line,count; pthread_t thread; #ifdef SAFE_MUTEX_DETECT_DESTROY @@ -487,7 +487,7 @@ typedef struct st_safe_mutex_info_t { struct st_safe_mutex_info_t *next; struct st_safe_mutex_info_t *prev; - char *init_file; + const char *init_file; uint32 init_line; } safe_mutex_info_t; #endif /* SAFE_MUTEX_DETECT_DESTROY */ diff --git a/include/my_sys.h b/include/my_sys.h index 6082b988822..604eaf34fb7 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (C) 2000-2003 MySQL 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 @@ -111,6 +111,7 @@ extern int NEAR my_errno; /* Last error in mysys */ #define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */ #define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */ #define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */ +#define DFLT_INIT_HITS 3 /* root_alloc flags */ #define MY_KEEP_PREALLOC 1 @@ -159,7 +160,7 @@ extern char *my_strdup_with_length(const byte *from, uint length, #endif #ifdef HAVE_ALLOCA -#if defined(_AIX) && !defined(__GNUC__) +#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43) #pragma alloca #endif /* _AIX */ #if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) @@ -225,9 +226,8 @@ extern void add_compiled_collation(CHARSET_INFO *cs); extern ulong my_cache_w_requests, my_cache_write, my_cache_r_requests, my_cache_read; extern ulong my_blocks_used, my_blocks_changed; -extern uint key_cache_block_size; extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; -extern my_bool key_cache_inited, my_init_done; +extern my_bool my_init_done; /* Point to current my_message() */ extern void (*my_sigtstp_cleanup)(void), @@ -505,44 +505,6 @@ my_off_t my_b_append_tell(IO_CACHE* info); typedef uint32 ha_checksum; -/* Pointer to a key cache data structure (see the key cache module) */ -typedef struct st_key_cache* KEY_CACHE_HANDLE; - -/* Key cache variable structure */ -/* - The structure contains the parameters of a key cache that can - be set and undated by regular set global statements. - It also contains read-only statistics parameters. - If the corresponding key cache data structure has been already - created the variable contains the key cache handle. - The variables are put into a named list called key_caches. - At present the variables are only added to this list. -*/ -typedef struct st_key_cache_var -{ - ulonglong buff_size; /* size the memory allocated for the cache */ - ulong block_size; /* size of the blocks in the key cache */ - ulong division_limit; /* min. percentage of warm blocks */ - ulong age_threshold; /* determines when hot block is downgraded */ - KEY_CACHE_HANDLE cache; /* handles for the current and registered */ - ulong blocks_used; /* number of currently used blocks */ - ulong blocks_changed; /* number of currently dirty blocks */ - ulong cache_w_requests; /* number of write requests (write hits) */ - ulong cache_write; /* number of writes from the cache to files */ - ulong cache_r_requests; /* number of read requests (read hits) */ - ulong cache_read; /* number of reads from files to the cache */ - int blocks; /* max number of blocks in the cache */ - struct st_key_cache_asmt *assign_list; /* list of assignments to the cache */ - int assignments; /* number of not completed assignments */ - void (*action)(void *); /* optional call back function */ - void *extra_info; /* ptr to extra info */ -} KEY_CACHE_VAR; - -#define DEFAULT_KEY_CACHE_NAME "default" -extern KEY_CACHE_HANDLE *dflt_keycache; -extern KEY_CACHE_VAR dflt_key_cache_var; -#define DFLT_INIT_HITS 3 - #include <my_alloc.h> /* Prototypes for mysys and my_func functions */ @@ -682,26 +644,7 @@ extern int flush_write_cache(RECORD_CACHE *info); extern long my_clock(void); extern sig_handler sigtstp_handler(int signal_number); extern void handle_recived_signals(void); -extern int init_key_cache(KEY_CACHE_HANDLE *pkeycache, - uint key_cache_block_size, - ulong use_mem, KEY_CACHE_VAR* env); -extern int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, - uint key_cache_block_size, ulong use_mem); -extern void change_key_cache_param(KEY_CACHE_HANDLE keycache); -extern byte *key_cache_read(KEY_CACHE_HANDLE keycache, - File file, my_off_t filepos, int level, - byte* buff, uint length, - uint block_length,int return_buffer); -extern int key_cache_insert(KEY_CACHE_HANDLE keycache, - File file, my_off_t filepos, int level, - byte *buff, uint length); -extern int key_cache_write(KEY_CACHE_HANDLE keycache, - File file, my_off_t filepos, int level, - byte* buff, uint length, - uint block_length,int force_write); -extern int flush_key_blocks(KEY_CACHE_HANDLE keycache, - int file, enum flush_type type); -extern void end_key_cache(KEY_CACHE_HANDLE *pkeycache,my_bool cleanup); + extern sig_handler my_set_alarm_variable(int signo); extern void my_string_ptr_sort(void *base,uint items,size_s size); extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements, diff --git a/include/myisam.h b/include/myisam.h index bf28168b7d7..613a9965832 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -28,6 +28,9 @@ extern "C" { #ifndef _m_ctype_h #include <m_ctype.h> #endif +#ifndef _keycache_h +#include "keycache.h" +#endif #include "my_handler.h" /* defines used by myisam-funktions */ @@ -324,7 +327,7 @@ typedef struct st_mi_check_param sort_buffer_length,sort_key_blocks; uint out_flag,warning_printed,error_printed,verbose; uint opt_sort_key,total_files,max_level; - uint testflag; + uint testflag, key_cache_block_size; uint8 language; my_bool using_global_keycache, opt_lock_memory, opt_follow_links; my_bool retry_repair, force_sort, calc_checksum; @@ -388,7 +391,6 @@ int change_to_newfile(const char * filename, const char * old_ext, int lock_file(MI_CHECK *param, File file, my_off_t start, int lock_type, const char *filetype, const char *filename); void lock_memory(MI_CHECK *param); -int flush_blocks(MI_CHECK *param, File file); void update_auto_increment_key(MI_CHECK *param, MI_INFO *info, my_bool repair); int update_state_info(MI_CHECK *param, MI_INFO *info,uint update); @@ -408,9 +410,10 @@ my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, ulonglong key_map, int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows); void mi_flush_bulk_insert(MI_INFO *info, uint inx); void mi_end_bulk_insert(MI_INFO *info); -int mi_assign_to_keycache(MI_INFO *info, ulonglong key_map, - KEY_CACHE_VAR *key_cache, - pthread_mutex_t *assign_lock); +int mi_assign_to_key_cache(MI_INFO *info, ulonglong key_map, + KEY_CACHE *key_cache); +void mi_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache); int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves); #ifdef __cplusplus diff --git a/include/mysql.h b/include/mysql.h index f44d515478c..23d89fd531f 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -411,6 +411,9 @@ int STDCALL mysql_dump_debug_info(MYSQL *mysql); int STDCALL mysql_refresh(MYSQL *mysql, unsigned int refresh_options); int STDCALL mysql_kill(MYSQL *mysql,unsigned long pid); +int STDCALL mysql_set_server_option(MYSQL *mysql, + enum enum_mysql_set_option + option); int STDCALL mysql_ping(MYSQL *mysql); const char * STDCALL mysql_stat(MYSQL *mysql); const char * STDCALL mysql_get_server_info(MYSQL *mysql); @@ -532,10 +535,10 @@ typedef struct st_mysql_stmt char *query; /* query buffer */ MEM_ROOT mem_root; /* root allocations */ my_ulonglong last_fetched_column; /* last fetched column */ - unsigned long param_count; /* parameters count */ - unsigned long field_count; /* fields count */ unsigned long stmt_id; /* Id for prepared statement */ unsigned int last_errno; /* error code */ + unsigned int param_count; /* parameters count */ + unsigned int field_count; /* fields count */ enum PREP_STMT_STATE state; /* statement state */ char last_error[MYSQL_ERRMSG_SIZE]; /* error message */ char sqlstate[SQLSTATE_LENGTH+1]; @@ -549,27 +552,27 @@ typedef struct st_mysql_stmt typedef struct st_mysql_methods { - my_bool (STDCALL *read_query_result)(MYSQL *mysql); - my_bool (STDCALL *advanced_command)(MYSQL *mysql, - enum enum_server_command command, - const char *header, - unsigned long header_length, - const char *arg, - unsigned long arg_length, - my_bool skip_check); - MYSQL_DATA *(STDCALL *read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, - unsigned int fields); - MYSQL_RES * (STDCALL *use_result)(MYSQL *mysql); - void (STDCALL *fetch_lengths)(unsigned long *to, - MYSQL_ROW column, unsigned int field_count); + my_bool (*read_query_result)(MYSQL *mysql); + my_bool (*advanced_command)(MYSQL *mysql, + enum enum_server_command command, + const char *header, + unsigned long header_length, + const char *arg, + unsigned long arg_length, + my_bool skip_check); + MYSQL_DATA *(*read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, + unsigned int fields); + MYSQL_RES * (*use_result)(MYSQL *mysql); + void (*fetch_lengths)(unsigned long *to, + MYSQL_ROW column, unsigned int field_count); #if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY) - MYSQL_FIELD * (STDCALL *list_fields)(MYSQL *mysql); - my_bool (STDCALL *read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); - int (STDCALL *stmt_execute)(MYSQL_STMT *stmt); - MYSQL_DATA *(STDCALL *read_binary_rows)(MYSQL_STMT *stmt); - int (STDCALL *unbuffered_fetch)(MYSQL *mysql, char **row); - void (STDCALL *free_embedded_thd)(MYSQL *mysql); - const char *(STDCALL *read_statistic)(MYSQL *mysql); + MYSQL_FIELD * (*list_fields)(MYSQL *mysql); + my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); + int (*stmt_execute)(MYSQL_STMT *stmt); + MYSQL_DATA *(*read_binary_rows)(MYSQL_STMT *stmt); + int (*unbuffered_fetch)(MYSQL *mysql, char **row); + void (*free_embedded_thd)(MYSQL *mysql); + const char *(*read_statistic)(MYSQL *mysql); #endif } MYSQL_METHODS; @@ -601,7 +604,7 @@ MYSQL_RES *STDCALL mysql_param_result(MYSQL_STMT *stmt); my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt); int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt); my_bool STDCALL mysql_more_results(MYSQL *mysql); -my_bool STDCALL mysql_next_result(MYSQL *mysql); +int STDCALL mysql_next_result(MYSQL *mysql); MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt, MYSQL_ROW_OFFSET offset); MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt); diff --git a/include/mysql_com.h b/include/mysql_com.h index f4b6114c8d4..3031b883e98 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -44,7 +44,7 @@ enum enum_server_command COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP, COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE, COM_PREPARE, COM_EXECUTE, COM_LONG_DATA, COM_CLOSE_STMT, - COM_RESET_STMT, + COM_RESET_STMT, COM_SET_OPTION, COM_END /* Must be last */ }; @@ -116,7 +116,7 @@ enum enum_server_command #define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */ #define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */ #define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */ -#define CLIENT_MULTI_QUERIES 65536 /* Enable/disable multiquery support */ +#define CLIENT_MULTI_STATEMENTS 65536 /* Enable/disable multi-stmt support */ #define CLIENT_MULTI_RESULTS 131072 /* Enable/disable multi-results */ #define CLIENT_REMEMBER_OPTIONS (1L << 31) @@ -192,6 +192,7 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, }; /* For backward compatibility */ +#define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS #define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL #define FIELD_TYPE_TINY MYSQL_TYPE_TINY #define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT @@ -230,6 +231,13 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, #define MYSQL_TYPE_UINT24 -4 #endif +/* options for mysql_set_option */ +enum enum_mysql_set_option +{ + MYSQL_OPTION_MULTI_STATEMENTS_ON, + MYSQL_OPTION_MULTI_STATEMENTS_OFF +}; + #define net_new_transaction(net) ((net)->pkt_nr=0) #ifdef __cplusplus diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 91b10ab578a..a6e23fbff3a 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -295,12 +295,9 @@ #define ER_BAD_SLAVE_UNTIL_COND 1276 #define ER_MISSING_SKIP_SLAVE 1277 #define ER_UNTIL_COND_IGNORED 1278 -#define ER_WRONG_NAME 1279 -#define ER_TABLE 1280 -#define ER_DATABASE 1281 -#define ER_COLUMN 1282 -#define ER_INDEX 1283 -#define ER_CATALOG 1284 -#define ER_WARN_QC_RESIZE 1285 -#define ER_BAD_FT_COLUMN 1286 -#define ER_ERROR_MESSAGES 287 +#define ER_WRONG_NAME_FOR_INDEX 1279 +#define ER_WRONG_NAME_FOR_CATALOG 1280 +#define ER_WARN_QC_RESIZE 1281 +#define ER_BAD_FT_COLUMN 1282 +#define ER_UNKNOWN_KEY_CACHE 1283 +#define ER_ERROR_MESSAGES 284 diff --git a/include/sql_common.h b/include/sql_common.h index 1f442339c4f..1c374030a55 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -34,7 +34,7 @@ void end_server(MYSQL *mysql); my_bool mysql_reconnect(MYSQL *mysql); void mysql_read_default_options(struct st_mysql_options *options, const char *filename,const char *group); -my_bool STDCALL +my_bool cli_advanced_command(MYSQL *mysql, enum enum_server_command command, const char *header, ulong header_length, const char *arg, ulong arg_length, my_bool skip_check); diff --git a/include/sql_state.h b/include/sql_state.h index d55fb137e27..a514b1e59fc 100644 --- a/include/sql_state.h +++ b/include/sql_state.h @@ -159,4 +159,5 @@ ER_WARN_TOO_MANY_RECORDS, "01000", "", ER_WARN_NULL_TO_NOTNULL, "01000", "", ER_WARN_DATA_OUT_OF_RANGE, "01000", "", ER_WARN_DATA_TRUNCATED, "01000", "", -ER_WRONG_NAME, "42000", "", +ER_WRONG_NAME_FOR_INDEX, "42000", "", +ER_WRONG_NAME_FOR_CATALOG, "42000", "", diff --git a/include/violite.h b/include/violite.h index 37c5abbbe67..e8f30288d34 100644 --- a/include/violite.h +++ b/include/violite.h @@ -177,7 +177,7 @@ struct st_vio void (*viodelete)(Vio*); int (*vioerrno)(Vio*); int (*read)(Vio*, gptr, int); - int (*write)(Vio*, gptr, int); + int (*write)(Vio*, const gptr, int); int (*vioblocking)(Vio*, my_bool, my_bool *); my_bool (*is_blocking)(Vio*); int (*viokeepalive)(Vio*, my_bool); diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c index a9ae59fbd50..7cf3cc409b3 100644 --- a/innobase/fil/fil0fil.c +++ b/innobase/fil/fil0fil.c @@ -1567,7 +1567,7 @@ fil_op_write_log( mlog_close(mtr, log_ptr); - mlog_catenate_string(mtr, name, ut_strlen(name) + 1); + mlog_catenate_string(mtr, (byte*) name, ut_strlen(name) + 1); if (type == MLOG_FILE_RENAME) { log_ptr = mlog_open(mtr, 30); @@ -1576,7 +1576,7 @@ fil_op_write_log( mlog_close(mtr, log_ptr); - mlog_catenate_string(mtr, new_name, ut_strlen(new_name) + 1); + mlog_catenate_string(mtr, (byte*) new_name, ut_strlen(new_name) + 1); } } #endif @@ -1630,7 +1630,7 @@ fil_op_log_parse_or_replay( return(NULL); } - name = ptr; + name = (char*) ptr; ptr += name_len; @@ -1649,7 +1649,7 @@ fil_op_log_parse_or_replay( return(NULL); } - new_name = ptr; + new_name = (char*) ptr; ptr += new_name_len; } diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 067aec36627..3f375b66c4f 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -1629,9 +1629,6 @@ NetWare. */ srv_file_per_table = srv_file_per_table_original_value; - fprintf(stderr, -"TODO: make sure MySQL sets field->query_id right in prepare/execute\n"); - return((int) DB_SUCCESS); } diff --git a/isam/_locking.c b/isam/_locking.c index 0ffb46a81f8..e19804549e5 100644 --- a/isam/_locking.c +++ b/isam/_locking.c @@ -50,7 +50,7 @@ int nisam_lock_database(N_INFO *info, int lock_type) else count= --share->w_locks; if (info->lock_type == F_WRLCK && !share->w_locks && - flush_key_blocks(*dflt_keycache,share->kfile,FLUSH_KEEP)) + flush_key_blocks(dflt_key_cache,share->kfile,FLUSH_KEEP)) error=my_errno; if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) if (end_io_cache(&info->rec_cache)) @@ -329,7 +329,7 @@ int _nisam_test_if_changed(register N_INFO *info) share->state.uniq != info->last_uniq) { /* Keyfile has changed */ if (share->state.process != share->this_process) - VOID(flush_key_blocks(*dflt_keycache,share->kfile,FLUSH_RELEASE)); + VOID(flush_key_blocks(dflt_key_cache,share->kfile,FLUSH_RELEASE)); share->last_process=share->state.process; info->last_loop= share->state.loop; info->last_uniq= share->state.uniq; diff --git a/isam/_page.c b/isam/_page.c index 60f1dfb0ce6..e31115e624f 100644 --- a/isam/_page.c +++ b/isam/_page.c @@ -27,7 +27,7 @@ uchar *_nisam_fetch_keypage(register N_INFO *info, N_KEYDEF *keyinfo, my_off_t page, uchar *buff, int return_buffer) { uchar *tmp; - tmp=(uchar*) key_cache_read(*dflt_keycache, + tmp=(uchar*) key_cache_read(dflt_key_cache, info->s->kfile,page,DFLT_INIT_HITS,(byte*) buff, (uint) keyinfo->base.block_length, (uint) keyinfo->base.block_length, @@ -84,7 +84,7 @@ int _nisam_write_keypage(register N_INFO *info, register N_KEYDEF *keyinfo, length=keyinfo->base.block_length; } #endif - return (key_cache_write(*dflt_keycache, + return (key_cache_write(dflt_key_cache, info->s->kfile,page,DFLT_INIT_HITS, (byte*) buff,length, (uint) keyinfo->base.block_length, @@ -102,7 +102,7 @@ int _nisam_dispose(register N_INFO *info, N_KEYDEF *keyinfo, my_off_t pos) old_link=info->s->state.key_del[keynr]; info->s->state.key_del[keynr]=(ulong) pos; - DBUG_RETURN(key_cache_write(*dflt_keycache, + DBUG_RETURN(key_cache_write(dflt_key_cache, info->s->kfile,pos,DFLT_INIT_HITS, (byte*) &old_link, sizeof(long), @@ -131,7 +131,7 @@ ulong _nisam_new(register N_INFO *info, N_KEYDEF *keyinfo) } else { - if (!key_cache_read(*dflt_keycache, + if (!key_cache_read(dflt_key_cache, info->s->kfile,pos,DFLT_INIT_HITS, (byte*) &info->s->state.key_del[keynr], (uint) sizeof(long), diff --git a/isam/close.c b/isam/close.c index 37b35e450ae..37425653a5d 100644 --- a/isam/close.c +++ b/isam/close.c @@ -57,7 +57,7 @@ int nisam_close(register N_INFO *info) if (flag) { if (share->kfile >= 0 && - flush_key_blocks(*dflt_keycache,share->kfile,FLUSH_RELEASE)) + flush_key_blocks(dflt_key_cache,share->kfile,FLUSH_RELEASE)) error=my_errno; if (share->kfile >= 0 && my_close(share->kfile,MYF(0))) error = my_errno; diff --git a/isam/extra.c b/isam/extra.c index 3bf1dd012ed..421404311c8 100644 --- a/isam/extra.c +++ b/isam/extra.c @@ -215,7 +215,7 @@ int nisam_extra(N_INFO *info, enum ha_extra_function function) info->s->last_version= 0L; /* Impossible version */ #ifdef __WIN__ /* Close the isam and data files as Win32 can't drop an open table */ - if (flush_key_blocks(info->s->kfile,FLUSH_RELEASE)) + if (flush_key_blocks(dflt_key_cache, info->s->kfile, FLUSH_RELEASE)) error=my_errno; if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) { diff --git a/isam/isamchk.c b/isam/isamchk.c index e59da07e85b..0c0df603da0 100644 --- a/isam/isamchk.c +++ b/isam/isamchk.c @@ -516,8 +516,8 @@ static int nisamchk(my_string filename) if (!rep_quick) { if (testflag & T_EXTEND) - VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE, - use_buffers,&dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE, + use_buffers,0,0)); VOID(init_io_cache(&read_cache,datafile,(uint) read_buffer_length, READ_CACHE,share->pack.header_length,1, MYF(MY_WME))); @@ -1460,8 +1460,7 @@ my_string name; printf("Data records: %lu\n",(ulong) share->state.records); } - VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,use_buffers, - &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,use_buffers,0,0)); if (init_io_cache(&read_cache,info->dfile,(uint) read_buffer_length, READ_CACHE,share->pack.header_length,1,MYF(MY_WME))) goto err; @@ -1889,12 +1888,12 @@ static void lock_memory(void) static int flush_blocks(file) File file; { - if (flush_key_blocks(dflt_keycache,file,FLUSH_RELEASE)) + if (flush_key_blocks(dflt_key_cache,file,FLUSH_RELEASE)) { print_error("%d when trying to write bufferts",my_errno); return(1); } - end_key_cache(dflt_keycache,1); + end_key_cache(dflt_key_cache,1); return 0; } /* flush_blocks */ @@ -1938,8 +1937,7 @@ int write_info; if (share->state.key_root[sort_key] == NI_POS_ERROR) DBUG_RETURN(0); /* Nothing to do */ - init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,use_buffers, - &dflt_key_cache_var); + init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,use_buffers, 0, 0); if (init_io_cache(&info->rec_cache,-1,(uint) write_buffer_length, WRITE_CACHE,share->pack.header_length,1, MYF(MY_WME | MY_WAIT_IF_FULL))) diff --git a/isam/isamdef.h b/isam/isamdef.h index 54656b6842e..7d89730fe32 100644 --- a/isam/isamdef.h +++ b/isam/isamdef.h @@ -24,6 +24,7 @@ #else #include <my_no_pthread.h> #endif +#include <keycache.h> #ifdef my_write #undef my_write /* We want test if disk full */ diff --git a/isam/isamlog.c b/isam/isamlog.c index d8ea9d4ed80..75a35ef9704 100644 --- a/isam/isamlog.c +++ b/isam/isamlog.c @@ -329,8 +329,8 @@ static int examine_log(my_string file_name, char **table_names) bzero((gptr) com_count,sizeof(com_count)); init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1, (tree_element_free) file_info_free, NULL); - VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, - &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, + 0,0)); files_open=0; access_time=0; while (access_time++ != number_of_commands && !my_b_read(&cache,(byte*) head,9)) @@ -622,7 +622,7 @@ static int examine_log(my_string file_name, char **table_names) goto end; } } - end_key_cache(dflt_keycache,1); + end_key_cache(dflt_key_cache,1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); @@ -642,7 +642,7 @@ static int examine_log(my_string file_name, char **table_names) llstr(isamlog_filepos,llbuff))); fflush(stderr); end: - end_key_cache(dflt_keycache,1); + end_key_cache(dflt_key_cache,1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); diff --git a/isam/panic.c b/isam/panic.c index de765f50e62..7af979a5104 100644 --- a/isam/panic.c +++ b/isam/panic.c @@ -48,7 +48,7 @@ int nisam_panic(enum ha_panic_function flag) if (info->s->base.options & HA_OPTION_READ_ONLY_DATA) break; #endif - if (flush_key_blocks(*dflt_keycache,info->s->kfile,FLUSH_RELEASE)) + if (flush_key_blocks(dflt_key_cache,info->s->kfile,FLUSH_RELEASE)) error=my_errno; if (info->opt_flag & WRITE_CACHE_USED) if (flush_io_cache(&info->rec_cache)) diff --git a/isam/test2.c b/isam/test2.c index 67b411d1bbf..14a40f39865 100644 --- a/isam/test2.c +++ b/isam/test2.c @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) goto err; printf("- Writing key:s\n"); if (key_cacheing) - init_key_cache(dflt_keycache,512,IO_SIZE*16,0); /* Use a small cache */ + init_key_cache(dflt_key_cache,512,IO_SIZE*16,0,0); /* Use a small cache */ if (locking) nisam_lock_database(file,F_WRLCK); if (write_cacheing) @@ -674,7 +674,7 @@ end: puts("Locking used"); if (use_blob) puts("blobs used"); - end_key_cache(&dflt_keycache,1); + end_key_cache(dflt_key_cache,1); if (blob_buffer) my_free(blob_buffer,MYF(0)); my_end(MY_CHECK_ERROR | MY_GIVE_INFO); diff --git a/isam/test3.c b/isam/test3.c index 1b867ba0348..9195fcbf1b6 100644 --- a/isam/test3.c +++ b/isam/test3.c @@ -20,6 +20,7 @@ #include "nisam.h" #include <sys/types.h> +#include <keycache.h> #ifdef HAVE_SYS_WAIT_H # include <sys/wait.h> #endif @@ -173,7 +174,7 @@ void start_test(int id) exit(1); } if (key_cacheing && rnd(2) == 0) - init_key_cache(dflt_keycache,512,65536L,0); + init_key_cache(dflt_key_cache,512,65536L,0,0); printf("Process %d, pid: %d\n",id,(int) getpid()); fflush(stdout); for (error=i=0 ; i < tests && !error; i++) diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index 582f9613ee0..3798eaa3544 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -43,18 +43,18 @@ my_bool send_file_to_server(MYSQL *mysql, const char *filename); void mysql_read_default_options(struct st_mysql_options *options, const char *filename,const char *group); -MYSQL * STDCALL +MYSQL * cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user, const char *passwd, const char *db, uint port, const char *unix_socket,ulong client_flag); -void STDCALL cli_mysql_close(MYSQL *mysql); +void cli_mysql_close(MYSQL *mysql); -MYSQL_FIELD * STDCALL cli_list_fields(MYSQL *mysql); -my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt); -MYSQL_DATA * STDCALL cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, +MYSQL_FIELD * cli_list_fields(MYSQL *mysql); +my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt); +MYSQL_DATA * cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, uint fields); -int STDCALL cli_stmt_execute(MYSQL_STMT *stmt); -MYSQL_DATA * STDCALL cli_read_binary_rows(MYSQL_STMT *stmt); -int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row); -const char * STDCALL cli_read_statistic(MYSQL *mysql); +int cli_stmt_execute(MYSQL_STMT *stmt); +MYSQL_DATA * cli_read_binary_rows(MYSQL_STMT *stmt); +int cli_unbuffered_fetch(MYSQL *mysql, char **row); +const char * cli_read_statistic(MYSQL *mysql); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 1cad02948e1..980cc2bef4c 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -973,16 +973,16 @@ mysql_list_tables(MYSQL *mysql, const char *wild) DBUG_RETURN (mysql_store_result(mysql)); } -MYSQL_FIELD * STDCALL cli_list_fields(MYSQL *mysql) +MYSQL_FIELD *cli_list_fields(MYSQL *mysql) { MYSQL_DATA *query; if (!(query= cli_read_rows(mysql,(MYSQL_FIELD*) 0, protocol_41(mysql) ? 8 : 6))) return NULL; - mysql->field_count= query->rows; + mysql->field_count= (uint) query->rows; return unpack_fields(query,&mysql->field_alloc, - query->rows, 1, mysql->server_capabilities); + mysql->field_count, 1, mysql->server_capabilities); } @@ -1088,10 +1088,20 @@ mysql_refresh(MYSQL *mysql,uint options) int STDCALL mysql_kill(MYSQL *mysql,ulong pid) { - char buff[12]; + char buff[4]; DBUG_ENTER("mysql_kill"); int4store(buff,pid); - DBUG_RETURN(simple_command(mysql,COM_PROCESS_KILL,buff,4,0)); + DBUG_RETURN(simple_command(mysql,COM_PROCESS_KILL,buff,sizeof(buff),0)); +} + + +int STDCALL +mysql_set_server_option(MYSQL *mysql, enum enum_mysql_set_option option) +{ + char buff[2]; + DBUG_ENTER("mysql_set_server_option"); + int2store(buff, (uint) option); + DBUG_RETURN(simple_command(mysql, COM_SET_OPTION, buff, sizeof(buff), 0)); } @@ -1102,7 +1112,7 @@ mysql_dump_debug_info(MYSQL *mysql) DBUG_RETURN(simple_command(mysql,COM_DEBUG,0,0,0)); } -const char * STDCALL cli_read_statistic(MYSQL *mysql) +const char *cli_read_statistic(MYSQL *mysql) { mysql->net.read_pos[mysql->packet_length]=0; /* End of stat string */ if (!mysql->net.read_pos[0]) @@ -1579,7 +1589,7 @@ static my_bool my_realloc_str(NET *net, ulong length) 1 error */ -my_bool STDCALL cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) +my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) { uchar *pos; uint field_count; @@ -2000,7 +2010,8 @@ static my_bool execute(MYSQL_STMT * stmt, char *packet, ulong length) DBUG_RETURN(0); } -int STDCALL cli_stmt_execute(MYSQL_STMT *stmt) + +int cli_stmt_execute(MYSQL_STMT *stmt) { DBUG_ENTER("cli_stmt_execute"); @@ -2975,12 +2986,13 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row) return 0; } -int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row) +int cli_unbuffered_fetch(MYSQL *mysql, char **row) { if (packet_error == net_safe_read(mysql)) return 1; - *row= (mysql->net.read_pos[0] == 254) ? NULL : (mysql->net.read_pos+1); + *row= ((mysql->net.read_pos[0] == 254) ? NULL : + (char*) (mysql->net.read_pos+1)); return 0; } @@ -3098,7 +3110,7 @@ no_data: Read all rows of data from server (binary format) */ -MYSQL_DATA * STDCALL cli_read_binary_rows(MYSQL_STMT *stmt) +MYSQL_DATA *cli_read_binary_rows(MYSQL_STMT *stmt) { ulong pkt_len; uchar *cp; @@ -3307,7 +3319,7 @@ my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt) my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt) { MYSQL *mysql; - DBUG_ENTER("mysql_stmt_close"); + DBUG_ENTER("mysql_stmt_free_result"); DBUG_ASSERT(stmt != 0); @@ -3488,10 +3500,18 @@ my_bool STDCALL mysql_more_results(MYSQL *mysql) Reads and returns the next query results */ -my_bool STDCALL mysql_next_result(MYSQL *mysql) +int STDCALL mysql_next_result(MYSQL *mysql) { DBUG_ENTER("mysql_next_result"); + if (mysql->status != MYSQL_STATUS_READY) + { + strmov(mysql->net.sqlstate, unknown_sqlstate); + strmov(mysql->net.last_error, + ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); + DBUG_RETURN(1); + } + mysql->net.last_error[0]= 0; mysql->net.last_errno= 0; strmov(mysql->net.sqlstate, not_error_sqlstate); @@ -3500,9 +3520,10 @@ my_bool STDCALL mysql_next_result(MYSQL *mysql) if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) DBUG_RETURN((*mysql->methods->read_query_result)(mysql)); - DBUG_RETURN(0); + DBUG_RETURN(-1); /* No more results */ } + MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql) { return (*mysql->methods->use_result)(mysql); diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def index 787aa645017..868275d1d5d 100644 --- a/libmysql/libmysql.def +++ b/libmysql/libmysql.def @@ -67,6 +67,7 @@ EXPORTS mysql_init mysql_insert_id mysql_kill + mysql_set_server_option mysql_list_dbs mysql_list_fields mysql_list_processes diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am index 265e31fafdb..60c29a99762 100644 --- a/libmysql_r/Makefile.am +++ b/libmysql_r/Makefile.am @@ -19,7 +19,7 @@ target = libmysqlclient_r.la target_defs = -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ -## LIBS = @LIBS@ +LIBS = @LIBS@ @openssl_libs@ INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include $(openssl_includes) diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index f3b593f7341..e44516c16d6 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -251,7 +251,8 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) } /* going up to the first-level tree to continue search there */ - _mi_dpointer(info, ftbw->word+ftbw->off+HA_FT_WLEN, ftbw->key_root); + _mi_dpointer(info, (uchar*) (ftbw->word+ftbw->off+HA_FT_WLEN), + ftbw->key_root); ftbw->key_root=info->s->state.key_root[ftb->keynr]; ftbw->keyinfo=info->s->keyinfo+ftb->keynr; ftbw->off=0; diff --git a/myisam/ft_dump.c b/myisam/ft_dump.c index 183068789fe..8c40878cf00 100644 --- a/myisam/ft_dump.c +++ b/myisam/ft_dump.c @@ -80,6 +80,8 @@ int main(int argc,char *argv[]) if (argc < 2) usage(); + init_key_cache(dflt_key_cache,MI_KEY_BLOCK_LENGTH,USE_BUFFER_INIT, 0, 0); + if (!(info=mi_open(argv[0],2,HA_OPEN_ABORT_IF_LOCKED))) goto err; @@ -170,9 +172,9 @@ int main(int argc,char *argv[]) if (dump) { if (subkeys>=0) - printf("%9qx %20.7f %s\n",info->lastpos,weight,buf); + printf("%9lx %20.7f %s\n", (long) info->lastpos,weight,buf); else - printf("%9qx => %17d %s\n",info->lastpos,-subkeys,buf); + printf("%9lx => %17d %s\n",(long) info->lastpos,-subkeys,buf); } if (verbose && (total%HOW_OFTEN_TO_WRITE)==0) printf("%10ld\r",total); @@ -187,12 +189,12 @@ int main(int argc,char *argv[]) if ((ulong) count >= total/2) break; } - printf("Total rows: %qu\nTotal words: %lu\n" + printf("Total rows: %lu\nTotal words: %lu\n" "Unique words: %lu\nLongest word: %lu chars (%s)\n" "Median length: %u\n" "Average global weight: %f\n" "Most common word: %lu times, weight: %f (%s)\n", - (ulonglong)info->state->records, total, uniq, maxlen, buf_maxlen, + (long) info->state->records, total, uniq, maxlen, buf_maxlen, inx, avg_gws/uniq, max_doc_cnt, min_gws, buf_min_gws); } if (lstats) diff --git a/myisam/ft_nlq_search.c b/myisam/ft_nlq_search.c index a38c52704f7..1e3d47577d2 100644 --- a/myisam/ft_nlq_search.c +++ b/myisam/ft_nlq_search.c @@ -73,6 +73,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) uchar *keybuff=aio->keybuff; MI_KEYDEF *keyinfo=info->s->keyinfo+aio->keynr; my_off_t key_root=info->s->state.key_root[aio->keynr]; + uint extra=HA_FT_WLEN+info->s->base.rec_reflength+1; #if HA_FT_WTYPE == HA_KEYTYPE_FLOAT float tmp_weight; #else @@ -94,7 +95,8 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) { if (keylen && - mi_compare_text(aio->charset,info->lastkey,keylen, keybuff,keylen,0)) + mi_compare_text(aio->charset,info->lastkey+1, + info->lastkey_length-extra, keybuff+1,keylen-1,0)) break; subkeys=ft_sintXkorr(info->lastkey+keylen); @@ -223,7 +225,8 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, byte *query, if (flags & FT_EXPAND && ft_query_expansion_limit) { QUEUE best; - init_queue(&best,ft_query_expansion_limit,0,0, &FT_DOC_cmp, 0); + init_queue(&best,ft_query_expansion_limit,0,0, (queue_compare) &FT_DOC_cmp, + 0); tree_walk(&aio.dtree, (tree_walk_action) &walk_and_push, &best, left_root_right); while (best.elements) diff --git a/myisam/ft_static.c b/myisam/ft_static.c index 2edb86679e9..cf4f3d6a02a 100644 --- a/myisam/ft_static.c +++ b/myisam/ft_static.c @@ -53,13 +53,17 @@ const struct _ft_vft _ft_vft_boolean = { ft_boolean_get_relevance, ft_boolean_reinit_search }; + FT_INFO *ft_init_search(uint flags, void *info, uint keynr, byte *query, uint query_len, byte *record) { + FT_INFO *res; if (flags & FT_BOOL) - ft_init_boolean_search((MI_INFO *)info, keynr, query, query_len); + res= ft_init_boolean_search((MI_INFO *)info, keynr, query, query_len); else - ft_init_nlq_search((MI_INFO *)info, keynr, query, query_len, flags, record); + res= ft_init_nlq_search((MI_INFO *)info, keynr, query, query_len, flags, + record); + return res; } const char *ft_stopword_file = 0; diff --git a/myisam/ft_update.c b/myisam/ft_update.c index a87f239b8f8..b94a174b292 100644 --- a/myisam/ft_update.c +++ b/myisam/ft_update.c @@ -304,7 +304,7 @@ uint _mi_ft_convert_to_ft2(MI_INFO *info, uint keynr, uchar *key) my_off_t root; DYNAMIC_ARRAY *da=info->ft1_to_ft2; MI_KEYDEF *keyinfo=&info->s->ft2_keyinfo; - uchar *key_ptr=dynamic_array_ptr(da, 0), *end; + uchar *key_ptr= (uchar*) dynamic_array_ptr(da, 0), *end; uint length, key_length; DBUG_ENTER("_mi_ft_convert_to_ft2"); @@ -329,13 +329,13 @@ uint _mi_ft_convert_to_ft2(MI_INFO *info, uint keynr, uchar *key) DBUG_RETURN(-1); /* inserting the rest of key values */ - end=dynamic_array_ptr(da, da->elements); + end= (uchar*) dynamic_array_ptr(da, da->elements); for (key_ptr+=length; key_ptr < end; key_ptr+=keyinfo->keylength) if(_mi_ck_real_write_btree(info, keyinfo, key_ptr, 0, &root, SEARCH_SAME)) DBUG_RETURN(-1); /* now, writing the word key entry */ - ft_intXstore(key+key_length, -da->elements); + ft_intXstore(key+key_length, - (int) da->elements); _mi_dpointer(info, key+key_length+HA_FT_WLEN, root); DBUG_RETURN(_mi_ck_real_write_btree(info, diff --git a/myisam/mi_check.c b/myisam/mi_check.c index a75ac75a2e9..fd4c897983f 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -77,6 +77,7 @@ void myisamchk_init(MI_CHECK *param) param->tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL; param->myf_rw=MYF(MY_NABP | MY_WME | MY_WAIT_IF_FULL); param->start_check_pos=0; + param->key_cache_block_size= KEY_CACHE_BLOCK_SIZE; } /* Check the status flags for the table */ @@ -241,7 +242,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) if (next_link > info->state->key_file_length || next_link & (info->s->blocksize-1)) DBUG_RETURN(1); - if (!(buff=key_cache_read(*info->s->keycache, + if (!(buff=key_cache_read(info->s->key_cache, info->s->kfile, next_link, DFLT_INIT_HITS, (byte*) info->buff, myisam_block_size, block_size, 1))) @@ -261,7 +262,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) } /* check_k_link */ - /* Kontrollerar storleken p} filerna */ + /* Check sizes of files */ int chk_size(MI_CHECK *param, register MI_INFO *info) { @@ -272,8 +273,9 @@ int chk_size(MI_CHECK *param, register MI_INFO *info) if (!(param->testflag & T_SILENT)) puts("- check file-size"); - flush_key_blocks(*info->s->keycache, - info->s->kfile, FLUSH_FORCE_WRITE); /* If called externally */ + /* The following is needed if called externally (not from myisamchk) */ + flush_key_blocks(info->s->key_cache, + info->s->kfile, FLUSH_FORCE_WRITE); size=my_seek(info->s->kfile,0L,MY_SEEK_END,MYF(0)); if ((skr=(my_off_t) info->state->key_file_length) != size) @@ -501,7 +503,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) param->record_checksum=old_record_checksum-init_checksum; /* Remove delete links */ else param->record_checksum=0; - DBUG_RETURN(0); + DBUG_RETURN(result); } /* chk_key */ @@ -1141,9 +1143,12 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + if (!param->using_global_keycache) - VOID(init_key_cache(dflt_keycache,dflt_key_cache_var.block_size, - param->use_buffers,&dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache, param->key_cache_block_size, + param->use_buffers, 0, 0)); if (init_io_cache(¶m->read_cache,info->dfile, (uint) param->read_buffer_length, @@ -1354,6 +1359,7 @@ err: VOID(my_close(new_file,MYF(0))); VOID(my_raid_delete(param->temp_filename,info->s->base.raid_chunks, MYF(MY_WME))); + info->rec_cache.file=-1; /* don't flush data to new_file, it's closed */ } mi_mark_crashed_on_repair(info); } @@ -1364,7 +1370,7 @@ err: VOID(end_io_cache(¶m->read_cache)); info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); VOID(end_io_cache(&info->rec_cache)); - got_error|=flush_blocks(param,share->kfile); + got_error|=flush_blocks(param, share->key_cache, share->kfile); if (!got_error && param->testflag & T_UNPACK) { share->state.header.options[0]&= (uchar) ~HA_OPTION_COMPRESS_RECORD; @@ -1500,15 +1506,15 @@ void lock_memory(MI_CHECK *param __attribute__((unused))) /* Flush all changed blocks to disk */ -int flush_blocks(MI_CHECK *param, File file) +int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file) { - if (flush_key_blocks(*dflt_keycache,file,FLUSH_RELEASE)) + if (flush_key_blocks(key_cache, file, FLUSH_RELEASE)) { mi_check_print_error(param,"%d when trying to write bufferts",my_errno); return(1); } if (!param->using_global_keycache) - end_key_cache(dflt_keycache,1); + end_key_cache(key_cache,1); return 0; } /* flush_blocks */ @@ -1563,7 +1569,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) } /* Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(*share->keycache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); share->state.version=(ulong) time((time_t*) 0); old_state= share->state; /* save state if not stored */ @@ -1810,6 +1816,9 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + bzero((char*)&sort_info,sizeof(sort_info)); bzero((char *)&sort_param, sizeof(sort_param)); if (!(sort_info.key_block= @@ -1873,7 +1882,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(*share->keycache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); /* Clear the pointers to the given rows */ for (i=0 ; i < share->base.keys ; i++) share->state.key_root[i]= HA_OFFSET_ERROR; @@ -1883,7 +1892,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, } else { - if (flush_key_blocks(*share->keycache,share->kfile, FLUSH_FORCE_WRITE)) + if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) goto err; key_map= ~key_map; /* Create the missing keys */ } @@ -2075,7 +2084,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, memcpy( &share->state.state, info->state, sizeof(*info->state)); err: - got_error|= flush_blocks(param,share->kfile); + got_error|= flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(&info->rec_cache)); if (!got_error) { @@ -2181,6 +2190,9 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + bzero((char*)&sort_info,sizeof(sort_info)); if (!(sort_info.key_block= alloc_key_blocks(param, @@ -2236,7 +2248,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(*share->keycache,share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache,share->kfile, FLUSH_IGNORE_CHANGED); /* Clear the pointers to the given rows */ for (i=0 ; i < share->base.keys ; i++) share->state.key_root[i]= HA_OFFSET_ERROR; @@ -2246,7 +2258,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, } else { - if (flush_key_blocks(*share->keycache,share->kfile, FLUSH_FORCE_WRITE)) + if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_FORCE_WRITE)) goto err; key_map= ~key_map; /* Create the missing keys */ } @@ -2482,7 +2494,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, memcpy(&share->state.state, info->state, sizeof(*info->state)); err: - got_error|= flush_blocks(param,share->kfile); + got_error|= flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(&info->rec_cache)); if (!got_error) { @@ -2846,8 +2858,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) if (!(to=mi_alloc_rec_buff(info,block_info.rec_len, &(sort_param->rec_buff)))) { - mi_check_print_error(param,"Not enough memory for blob at %s", - llstr(sort_param->start_recpos,llbuff)); + mi_check_print_error(param,"Not enough memory for blob at %s (need %lu)", + llstr(sort_param->start_recpos,llbuff), block_info.rec_len); DBUG_RETURN(1); } } @@ -3087,7 +3099,8 @@ int sort_write_record(MI_SORT_PARAM *sort_param) (info->state->records % WRITE_COUNT) == 0) { char llbuff[22]; - printf("%s\r", llstr(info->state->records,llbuff)); VOID(fflush(stdout)); + printf("%s\r", llstr(info->state->records,llbuff)); + VOID(fflush(stdout)); } } DBUG_RETURN(0); diff --git a/myisam/mi_checksum.c b/myisam/mi_checksum.c index cdbb634c5ff..95338434211 100644 --- a/myisam/mi_checksum.c +++ b/myisam/mi_checksum.c @@ -27,7 +27,6 @@ ha_checksum mi_checksum(MI_INFO *info, const byte *buf) for (i=info->s->base.fields ; i-- ; buf+=(rec++)->length) { const byte *pos; - const byte *end; ulong length; switch (rec->type) { case FIELD_BLOB: diff --git a/myisam/mi_close.c b/myisam/mi_close.c index 8e7fb497dfc..deb0ccee8f3 100644 --- a/myisam/mi_close.c +++ b/myisam/mi_close.c @@ -64,7 +64,7 @@ int mi_close(register MI_INFO *info) if (flag) { if (share->kfile >= 0 && - flush_key_blocks(*share->keycache,share->kfile, + flush_key_blocks(share->key_cache, share->kfile, share->temporary ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE)) error=my_errno; diff --git a/myisam/mi_delete_all.c b/myisam/mi_delete_all.c index 99873661feb..3033249886f 100644 --- a/myisam/mi_delete_all.c +++ b/myisam/mi_delete_all.c @@ -53,7 +53,7 @@ int mi_delete_all_rows(MI_INFO *info) If we are using delayed keys or if the user has done changes to the tables since it was locked then there may be key blocks in the key cache */ - flush_key_blocks(*share->keycache, share->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->key_cache, share->kfile, FLUSH_IGNORE_CHANGED); if (my_chsize(info->dfile, 0, 0, MYF(MY_WME)) || my_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)) ) goto err; diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index 8c7515550e7..fcc753b62e5 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -283,7 +283,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) #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->keycache, share->kfile, + if (flush_key_blocks(share->key_cache, share->kfile, (function == HA_EXTRA_FORCE_REOPEN ? FLUSH_RELEASE : FLUSH_IGNORE_CHANGED))) { @@ -329,7 +329,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) break; case HA_EXTRA_FLUSH: if (!share->temporary) - flush_key_blocks(*share->keycache,share->kfile,FLUSH_KEEP); + flush_key_blocks(share->key_cache, share->kfile, FLUSH_KEEP); #ifdef HAVE_PWRITE _mi_decrement_open_count(info); #endif @@ -362,9 +362,6 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) case HA_EXTRA_PRELOAD_BUFFER_SIZE: info->preload_buff_size= *((ulong *) extra_arg); break; - case HA_EXTRA_SET_KEY_CACHE: - share->reg_keycache= share->keycache= (KEY_CACHE_HANDLE *) extra_arg; - break; case HA_EXTRA_KEY_CACHE: case HA_EXTRA_NO_KEY_CACHE: default: diff --git a/myisam/mi_keycache.c b/myisam/mi_keycache.c index 4b7d7d6b23f..fc51f331d76 100644 --- a/myisam/mi_keycache.c +++ b/myisam/mi_keycache.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +/* Copyright (C) 2003 MySQL 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 @@ -20,88 +20,142 @@ #include "myisamdef.h" - /* Assign pages of the index file for a table to a key cache SYNOPSIS - mi_assign_to_keycache() + mi_assign_to_key_cache() info open table - map map of indexes to assign to the key cache + key_map map of indexes to assign to the key cache key_cache_ptr pointer to the key cache handle + assign_lock Mutex to lock during assignment - RETURN VALUE - 0 if a success. error code - otherwise. + PREREQUESTS + One must have a READ lock or a WRITE lock on the table when calling + the function to ensure that there is no other writers to it. - NOTES. + The caller must also ensure that one doesn't call this function from + two different threads with the same table. + + NOTES At present pages for all indexes must be assigned to the same key cache. In future only pages for indexes specified in the key_map parameter of the table will be assigned to the specified key cache. -*/ -typedef struct st_assign_extra_info -{ - pthread_mutex_t *lock; - struct st_my_thread_var *waiting_thread; -} ASSIGN_EXTRA_INFO; + RETURN VALUE + 0 If a success + # Error code +*/ -static void remove_key_cache_assign(void *arg) +int mi_assign_to_key_cache(MI_INFO *info, + ulonglong key_map __attribute__((unused)), + KEY_CACHE *key_cache) { - KEY_CACHE_VAR *key_cache= (KEY_CACHE_VAR *) arg; - ASSIGN_EXTRA_INFO *extra_info= (ASSIGN_EXTRA_INFO *) key_cache->extra_info; - struct st_my_thread_var *waiting_thread; - pthread_mutex_t *lock= extra_info->lock; - pthread_mutex_lock(lock); - if (!(--key_cache->assignments) && - (waiting_thread = extra_info->waiting_thread)) + int error= 0; + MYISAM_SHARE* share= info->s; + DBUG_ENTER("mi_assign_to_key_cache"); + DBUG_PRINT("enter",("old_key_cache_handle: %lx new_key_cache_handle: %lx", + share->key_cache, key_cache)); + + /* + Skip operation if we didn't change key cache. This can happen if we + call this for all open instances of the same table + */ + if (share->key_cache == key_cache) + DBUG_RETURN(0); + + /* + First flush all blocks for the table in the old key cache. + This is to ensure that the disk is consistent with the data pages + in memory (which may not be the case if the table uses delayed_key_write) + + Note that some other read thread may still fill in the key cache with + new blocks during this call and after, but this doesn't matter as + all threads will start using the new key cache for their next call to + myisam library and we know that there will not be any changed blocks + in the old key cache. + */ + + if (flush_key_blocks(share->key_cache, share->kfile, FLUSH_REMOVE)) { - my_free(extra_info, MYF(0)); - key_cache->extra_info= 0; - if (waiting_thread != my_thread_var) - pthread_cond_signal(&waiting_thread->suspend); + error= my_errno; + mi_mark_crashed(info); /* Mark that table must be checked */ } - pthread_mutex_unlock(lock); + + /* + Flush the new key cache for this file. This is needed to ensure + that there is no old blocks (with outdated data) left in the new key + cache from an earlier assign_to_keycache operation + + (This can never fail as there is never any not written data in the + new key cache) + */ + (void) flush_key_blocks(key_cache, share->kfile, FLUSH_REMOVE); + + /* + ensure that setting the key cache and changing the multi_key_cache + is done atomicly + */ + pthread_mutex_lock(&share->intern_lock); + /* + Tell all threads to use the new key cache + This should be seen at the lastes for the next call to an myisam function. + */ + share->key_cache= key_cache; + + /* store the key cache in the global hash structure for future opens */ + if (multi_key_cache_set(share->unique_file_name, share->unique_name_length, + share->key_cache)) + error= my_errno; + pthread_mutex_unlock(&share->intern_lock); + DBUG_RETURN(error); } -int mi_assign_to_keycache(MI_INFO *info, ulonglong key_map, - KEY_CACHE_VAR *key_cache, - pthread_mutex_t *assign_lock) -{ - ASSIGN_EXTRA_INFO *extra_info; - int error= 0; - MYISAM_SHARE* share= info->s; - DBUG_ENTER("mi_assign_to_keycache"); +/* + Change all MyISAM entries that uses one key cache to another key cache - share->reg_keycache= &key_cache->cache; - pthread_mutex_lock(assign_lock); - if (!(extra_info= (ASSIGN_EXTRA_INFO *) key_cache->extra_info)) - { - if (!(extra_info= (ASSIGN_EXTRA_INFO*) my_malloc(sizeof(ASSIGN_EXTRA_INFO), - MYF(MY_WME | MY_ZEROFILL)))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - key_cache->extra_info= extra_info; - key_cache->action= remove_key_cache_assign; - extra_info->lock= assign_lock; - } - key_cache->assignments++; - pthread_mutex_unlock(assign_lock); - - if (!(info->lock_type == F_WRLCK && share->w_locks)) - { - if (flush_key_blocks(*share->keycache, share->kfile, FLUSH_REMOVE)) - { - error=my_errno; - mi_mark_crashed(info); /* Mark that table must be checked */ - } - share->keycache= &key_cache->cache; - } - else + SYNOPSIS + mi_change_key_cache() + old_key_cache Old key cache + new_key_cache New key cache + + NOTES + This is used when we delete one key cache. + + To handle the case where some other threads tries to open an MyISAM + table associated with the to-be-deleted key cache while this operation + is running, we have to call 'multi_key_cache_change()' from this + function while we have a lock on the MyISAM table list structure. + + This is safe as long as it's only MyISAM that is using this specific + key cache. +*/ + + +void mi_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache) +{ + LIST *pos; + DBUG_ENTER("mi_change_key_cache"); + + /* + Lock list to ensure that no one can close the table while we manipulate it + */ + pthread_mutex_lock(&THR_LOCK_myisam); + for (pos=myisam_open_list ; pos ; pos=pos->next) { - extra_info->waiting_thread= my_thread_var; + MI_INFO *info= (MI_INFO*) pos->data; + MYISAM_SHARE *share= info->s; + if (share->key_cache == old_key_cache) + mi_assign_to_key_cache(info, (ulonglong) ~0, new_key_cache); } - - DBUG_RETURN(error); + /* + We have to do the following call while we have the lock on the + MyISAM list structure to ensure that another thread is not trying to + open a new table that will be associted with the old key cache + */ + multi_key_cache_change(old_key_cache, new_key_cache); + pthread_mutex_unlock(&THR_LOCK_myisam); } - diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c index 6f996ab5abd..67ccca52d08 100644 --- a/myisam/mi_locking.c +++ b/myisam/mi_locking.c @@ -34,7 +34,6 @@ int mi_lock_database(MI_INFO *info, int lock_type) uint count; MYISAM_SHARE *share=info->s; uint flag; - uint switch_fl= 0; DBUG_ENTER("mi_lock_database"); DBUG_PRINT("info",("lock_type: %d", lock_type)); @@ -61,21 +60,13 @@ int mi_lock_database(MI_INFO *info, int lock_type) else count= --share->w_locks; --share->tot_locks; - /* - During a key cache reassignment the current and registered - key caches for the table are different. - */ if (info->lock_type == F_WRLCK && !share->w_locks && - ((switch_fl= share->keycache != share->reg_keycache) || - !share->delay_key_write) && - flush_key_blocks(*share->keycache, share->kfile, - switch_fl ? FLUSH_REMOVE : FLUSH_KEEP)) + !share->delay_key_write && flush_key_blocks(share->key_cache, + share->kfile,FLUSH_KEEP)) { error=my_errno; mi_mark_crashed(info); /* Mark that table must be checked */ } - if (switch_fl) - share->keycache= share->reg_keycache; if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) { if (end_io_cache(&info->rec_cache)) @@ -398,7 +389,7 @@ int _mi_test_if_changed(register MI_INFO *info) { /* Keyfile has changed */ DBUG_PRINT("info",("index file changed")); if (share->state.process != share->this_process) - VOID(flush_key_blocks(*share->keycache,share->kfile,FLUSH_RELEASE)); + VOID(flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE)); share->last_process=share->state.process; info->last_unique= share->state.unique; info->last_loop= share->state.update_count; diff --git a/myisam/mi_open.c b/myisam/mi_open.c index 0b4e8681bdd..d5492ae5e35 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -104,6 +104,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) share_buff.state.rec_per_key_part=rec_per_key_part; share_buff.state.key_root=key_root; share_buff.state.key_del=key_del; + share_buff.key_cache= multi_key_cache_search(name_buff, strlen(name_buff)); if ((kfile=my_open(name_buff,(open_mode=O_RDWR) | O_SHARE,MYF(0))) < 0) { @@ -293,6 +294,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) (char*) key_del, (sizeof(my_off_t) * share->state.header.max_block_size)); strmov(share->unique_file_name, name_buff); + share->unique_name_length= strlen(name_buff); strmov(share->index_file_name, index_name); strmov(share->data_file_name, data_name); diff --git a/myisam/mi_page.c b/myisam/mi_page.c index 72aaac5d381..8c6981afa00 100644 --- a/myisam/mi_page.c +++ b/myisam/mi_page.c @@ -32,7 +32,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_ENTER("_mi_fetch_keypage"); DBUG_PRINT("enter",("page: %ld",page)); - tmp=(uchar*) key_cache_read(*info->s->keycache, + tmp=(uchar*) key_cache_read(info->s->key_cache, info->s->kfile, page, level, (byte*) buff, (uint) keyinfo->block_length, (uint) keyinfo->block_length, @@ -52,6 +52,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, { DBUG_PRINT("error",("page %lu had wrong page length: %u", (ulong) page, page_size)); + DBUG_DUMP("page", tmp, keyinfo->block_length); info->last_keypage = HA_OFFSET_ERROR; my_errno = HA_ERR_CRASHED; tmp = 0; @@ -94,7 +95,7 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, length=keyinfo->block_length; } #endif - DBUG_RETURN((key_cache_write(*info->s->keycache, + DBUG_RETURN((key_cache_write(info->s->key_cache, info->s->kfile,page, level, (byte*) buff,length, (uint) keyinfo->block_length, (int) ((info->lock_type != F_UNLCK) || @@ -116,7 +117,7 @@ int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos, info->s->state.key_del[keyinfo->block_size]=pos; mi_sizestore(buff,old_link); info->s->state.changed|= STATE_NOT_SORTED_PAGES; - DBUG_RETURN(key_cache_write(*info->s->keycache, + DBUG_RETURN(key_cache_write(info->s->key_cache, info->s->kfile, pos , level, buff, sizeof(buff), (uint) keyinfo->block_length, @@ -145,7 +146,7 @@ my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo, int level) } else { - if (!key_cache_read(*info->s->keycache, + if (!key_cache_read(info->s->key_cache, info->s->kfile, pos, level, buff, (uint) sizeof(buff), diff --git a/myisam/mi_panic.c b/myisam/mi_panic.c index f1d1d839fcd..78698d88c54 100644 --- a/myisam/mi_panic.c +++ b/myisam/mi_panic.c @@ -48,7 +48,7 @@ int mi_panic(enum ha_panic_function flag) if (info->s->options & HA_OPTION_READ_ONLY_DATA) break; #endif - if (flush_key_blocks(*info->s->keycache,info->s->kfile,FLUSH_RELEASE)) + if (flush_key_blocks(info->s->key_cache, info->s->kfile, FLUSH_RELEASE)) error=my_errno; if (info->opt_flag & WRITE_CACHE_USED) if (flush_io_cache(&info->rec_cache)) diff --git a/myisam/mi_preload.c b/myisam/mi_preload.c index dc4fff5700a..80489cbcd13 100644 --- a/myisam/mi_preload.c +++ b/myisam/mi_preload.c @@ -69,7 +69,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME)))) DBUG_RETURN(my_errno= HA_ERR_OUT_OF_MEM); - if (flush_key_blocks(*share->keycache,share->kfile, FLUSH_RELEASE)) + if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE)) goto err; do @@ -87,7 +87,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) { if (mi_test_if_nod(buff)) { - if (key_cache_insert(*share->keycache, + if (key_cache_insert(share->key_cache, share->kfile, pos, DFLT_INIT_HITS, (byte*) buff, block_length)) goto err; @@ -99,7 +99,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) } else { - if (key_cache_insert(*share->keycache, + if (key_cache_insert(share->key_cache, share->kfile, pos, DFLT_INIT_HITS, (byte*) buff, length)) goto err; diff --git a/myisam/mi_test1.c b/myisam/mi_test1.c index ec68e23c0c2..64ffbe2db1d 100644 --- a/myisam/mi_test1.c +++ b/myisam/mi_test1.c @@ -50,7 +50,7 @@ int main(int argc,char *argv[]) MY_INIT(argv[0]); my_init(); if (key_cacheing) - init_key_cache(dflt_keycache,512,IO_SIZE*16,0); + init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,IO_SIZE*16,0,0); get_options(argc,argv); exit(run_test("test1")); diff --git a/myisam/mi_test2.c b/myisam/mi_test2.c index 5a40db3171d..d3c3cc2c492 100644 --- a/myisam/mi_test2.c +++ b/myisam/mi_test2.c @@ -49,7 +49,7 @@ static int verbose=0,testflag=0, static int pack_seg=HA_SPACE_PACK,pack_type=HA_PACK_KEY,remove_count=-1, create_flag=0; static ulong key_cache_size=IO_SIZE*16; -static uint key_cache_block_size=IO_SIZE; +static uint key_cache_block_size= KEY_CACHE_BLOCK_SIZE; static uint keys=MYISAM_KEYS,recant=1000; static uint use_blob=0; @@ -215,7 +215,7 @@ int main(int argc, char *argv[]) if (!silent) printf("- Writing key:s\n"); if (key_cacheing) - init_key_cache(dflt_keycache,key_cache_block_size,key_cache_size,0); /* Use a small cache */ + init_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size,0,0); if (locking) mi_lock_database(file,F_WRLCK); if (write_cacheing) @@ -274,9 +274,9 @@ int main(int argc, char *argv[]) puts("got error from mi_extra(HA_EXTRA_NO_CACHE)"); goto end; } - if (key_cacheing) - resize_key_cache(dflt_keycache,key_cache_block_size,key_cache_size*2); } + if (key_cacheing) + resize_key_cache(dflt_key_cache,key_cache_block_size,key_cache_size*2,0,0); if (!silent) printf("- Delete\n"); @@ -829,7 +829,7 @@ reads: %10lu\n", my_cache_r_requests, my_cache_read); #endif } - end_key_cache(dflt_keycache,1); + end_key_cache(dflt_key_cache,1); if (blob_buffer) my_free(blob_buffer,MYF(0)); my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO); diff --git a/myisam/mi_test3.c b/myisam/mi_test3.c index 866c6299fac..dca04a9a64b 100644 --- a/myisam/mi_test3.c +++ b/myisam/mi_test3.c @@ -177,7 +177,7 @@ void start_test(int id) exit(1); } if (key_cacheing && rnd(2) == 0) - init_key_cache(dflt_keycache,512,65536L,0); + init_key_cache(dflt_key_cache, KEY_CACHE_BLOCK_SIZE, 65536L, 0, 0); printf("Process %d, pid: %d\n",id,getpid()); fflush(stdout); for (error=i=0 ; i < tests && !error; i++) diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 59cc26b198b..f034d6ae406 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -321,7 +321,7 @@ static struct my_option my_long_options[] = { "ft_max_word_len", OPT_FT_MAX_WORD_LEN, "", (gptr*) &ft_max_word_len, (gptr*) &ft_max_word_len, 0, GET_ULONG, REQUIRED_ARG, HA_FT_MAXLEN, 10, HA_FT_MAXLEN, 0, 1, 0}, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -715,6 +715,7 @@ static void get_options(register int *argc,register char ***argv) exit(1); check_param.tmpdir=&myisamchk_tmpdir; + check_param.key_cache_block_size= opt_key_cache_block_size; if (set_charset_name) if (!(set_charset=get_charset_by_name(set_charset_name, MYF(MY_WME)))) @@ -1031,8 +1032,8 @@ static int myisamchk(MI_CHECK *param, my_string filename) !(param->testflag & (T_FAST | T_FORCE_CREATE))) { if (param->testflag & (T_EXTEND | T_MEDIUM)) - VOID(init_key_cache(dflt_keycache,opt_key_cache_block_size, - param->use_buffers,&dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,opt_key_cache_block_size, + param->use_buffers, 0, 0)); VOID(init_io_cache(¶m->read_cache,datafile, (uint) param->read_buffer_length, READ_CACHE, @@ -1046,7 +1047,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) HA_OPTION_COMPRESS_RECORD)) || (param->testflag & (T_EXTEND | T_MEDIUM))) error|=chk_data_link(param, info, param->testflag & T_EXTEND); - error|=flush_blocks(param,share->kfile); + error|=flush_blocks(param, share->key_cache, share->kfile); VOID(end_io_cache(¶m->read_cache)); } if (!error) @@ -1455,8 +1456,8 @@ static int mi_sort_records(MI_CHECK *param, if (share->state.key_root[sort_key] == HA_OFFSET_ERROR) DBUG_RETURN(0); /* Nothing to do */ - init_key_cache(dflt_keycache,opt_key_cache_block_size,param->use_buffers, - &dflt_key_cache_var); + init_key_cache(dflt_key_cache, opt_key_cache_block_size, param->use_buffers, + 0, 0); if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length, WRITE_CACHE,share->pack.header_length,1, MYF(MY_WME | MY_WAIT_IF_FULL))) @@ -1570,7 +1571,8 @@ err: my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR)); sort_info.buff=0; share->state.sortkey=sort_key; - DBUG_RETURN(flush_blocks(param, share->kfile) | got_error); + DBUG_RETURN(flush_blocks(param, share->key_cache, share->kfile) | + got_error); } /* sort_records */ diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index c23959d995c..c92d5a76815 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -166,8 +166,7 @@ typedef struct st_mi_isam_share { /* Shared between opens */ char *data_file_name, /* Resolved path names from symlinks */ *index_file_name; byte *file_map; /* mem-map of file if possible */ - KEY_CACHE_HANDLE *keycache; /* ref to the current key cache */ - KEY_CACHE_HANDLE *reg_keycache; /* ref to the registered key cache */ + KEY_CACHE *key_cache; /* ref to the current key cache */ MI_DECODE_TREE *decode_trees; uint16 *decode_tables; int (*read_record)(struct st_myisam_info*, my_off_t, byte*); @@ -188,6 +187,7 @@ typedef struct st_mi_isam_share { /* Shared between opens */ ulong max_pack_length; ulong state_diff_length; uint rec_reflength; /* rec_reflength in use now */ + uint unique_name_length; File kfile; /* Shared keyfile */ File data_file; /* Shared data file */ int mode; /* mode of file on open */ @@ -713,6 +713,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param); #ifdef THREAD pthread_handler_decl(thr_find_all_keys,arg); #endif +int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file); int sort_write_record(MI_SORT_PARAM *sort_param); int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong); diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c index 9b987364521..c9b00be7d9e 100644 --- a/myisam/myisamlog.c +++ b/myisam/myisamlog.c @@ -71,7 +71,7 @@ static void printf_log(const char *str,...); static bool cmp_filename(struct file_info *file_info,my_string name); static uint verbose=0,update=0,test_info=0,max_files=0,re_open_count=0, - recover=0,prefix_remove=0,opt_processes=0,opt_myisam_with_debug=0; + recover=0,prefix_remove=0,opt_processes=0; static my_string log_filename=0,filepath=0,write_filename=0,record_pos_file=0; static ulong com_count[10][3],number_of_commands=(ulong) ~0L, isamlog_process; @@ -201,9 +201,6 @@ static void get_options(register int *argc, register char ***argv) update=1; recover++; break; - case 'D': - opt_myisam_with_debug=1; - break; case 'P': opt_processes=1; break; @@ -333,8 +330,8 @@ static int examine_log(my_string file_name, char **table_names) bzero((gptr) com_count,sizeof(com_count)); init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1, (tree_element_free) file_info_free, NULL); - VOID(init_key_cache(dflt_keycache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, - &dflt_key_cache_var)); + VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, + 0, 0)); files_open=0; access_time=0; while (access_time++ != number_of_commands && @@ -648,7 +645,7 @@ static int examine_log(my_string file_name, char **table_names) goto end; } } - end_key_cache(dflt_keycache,1); + end_key_cache(dflt_key_cache,1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); @@ -668,7 +665,7 @@ static int examine_log(my_string file_name, char **table_names) llstr(isamlog_filepos,llbuff))); fflush(stderr); end: - end_key_cache(dflt_keycache,1); + end_key_cache(dflt_key_cache, 1); delete_tree(&tree); VOID(end_io_cache(&cache)); VOID(my_close(file,MYF(0))); diff --git a/myisam/sort.c b/myisam/sort.c index a41713f750f..651b2331cd1 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -84,7 +84,7 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, IO_CACHE *to_file, char* key, uint sort_length, uint count); -inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs); +inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file, byte *bufs); /* Creates a index of sorted keys @@ -622,21 +622,25 @@ static int NEAR_F write_keys(MI_SORT_PARAM *info, register uchar **sort_keys, DBUG_RETURN(0); } /* write_keys */ -inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs) + +inline int my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, byte *bufs) { int err; - uint16 len = _mi_keylength(info->keyinfo,bufs); + uint16 len = _mi_keylength(info->keyinfo, (uchar*) bufs); - if ((err= my_b_write(to_file,(byte*)&len,sizeof(len)))) + /* The following is safe as this is a local file */ + if ((err= my_b_write(to_file, (byte*)&len, sizeof(len)))) return (err); - if ((err= my_b_write(to_file,(byte*)bufs,(uint) len))) + if ((err= my_b_write(to_file,bufs, (uint) len))) return (err); return (0); } -static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_keys, - uint count, BUFFPEK *buffpek, IO_CACHE *tempfile) +static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, + register uchar **sort_keys, + uint count, BUFFPEK *buffpek, + IO_CACHE *tempfile) { uchar **end; int err; @@ -653,7 +657,7 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_k buffpek->count=count; for (end=sort_keys+count ; sort_keys != end ; sort_keys++) { - if ((err= my_var_write(info,tempfile,*sort_keys))) + if ((err= my_var_write(info,tempfile, (byte*) *sort_keys))) DBUG_RETURN(err); } DBUG_RETURN(0); @@ -816,7 +820,7 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, for (idx=1;idx<=count;idx++) { int err; - if ((err= my_var_write(info,to_file,bufs))) + if ((err= my_var_write(info,to_file, (byte*) bufs))) return (err); bufs=bufs+sort_length; } diff --git a/myisam/sp_test.c b/myisam/sp_test.c index c4847217efd..16a97771887 100644 --- a/myisam/sp_test.c +++ b/myisam/sp_test.c @@ -271,7 +271,8 @@ int run_test(const char *filename) create_key(key, nrecords*upd); print_key(key," INTERSECT\n"); - hrows=mi_records_in_range(file,0,key,0,HA_READ_MBR_INTERSECT,record+1,0,0); + hrows=mi_records_in_range(file,0,key,0,HA_READ_MBR_INTERSECT,record+1,0, + HA_READ_KEY_EXACT); printf(" %ld rows\n", (long) hrows); @@ -351,7 +352,7 @@ static void print_record(char * record, my_off_t offs,const char * tail) printf(" len=%d ",len); memcpy_fixed(&ptr,pos,sizeof(char*)); if(ptr) - rtree_PrintWKB(ptr,SPDIMS); + rtree_PrintWKB((uchar*) ptr,SPDIMS); else printf("<NULL> "); printf(" offs=%ld ",(long int)offs); @@ -406,7 +407,7 @@ static void create_linestring(char *record,uint rownr) pos++; memset(blob_key,0,sizeof(blob_key)); - tmp=rtree_CreateLineStringWKB(x,SPDIMS,npoints,blob_key); + tmp=rtree_CreateLineStringWKB(x,SPDIMS,npoints, (uchar*) blob_key); int4store(pos,tmp); pos+=4; diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 46d6819b819..c343f313d47 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -1,7 +1,7 @@ #! /bin/sh # mysql-test-run - originally written by Matt Wagner <matt@mysql.com> # modified by Sasha Pachev <sasha@mysql.com> -# Sligtly updated by Monty +# Slightly updated by Monty # Cleaned up again by Matt # Fixed by Sergei # :-) @@ -575,7 +575,7 @@ show_failed_diff () $DIFF -c $result_file $reject_file echo "-------------------------------------------------------" echo "Please follow the instructions outlined at" - echo "http://www.mysql.com/doc/R/e/Reporting_mysqltest_bugs.html" + echo "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html" echo "to find the reason to this problem and how to report this." fi } @@ -1311,7 +1311,7 @@ run_testcase () show_failed_diff $tname $ECHO if [ x$FORCE != x1 ] ; then - $ECHO "Aborting. To continue, re-run with '--force'." + $ECHO "Aborting: $tname failed. To continue, re-run with '--force'." $ECHO if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ] then diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 9d3a0461f9f..b82255bf652 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -319,6 +319,29 @@ alter table t1 change a a char(10) character set koi8r; select a,hex(a) from t1; a hex(a) ÔÅÓÔ D4C5D3D4 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) character set koi8r default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 DEFAULT CHARACTER SET latin1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) character set koi8r default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 CHARACTER SET latin1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 DEFAULT CHARACTER SET cp1251; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) character set latin1 default NULL +) TYPE=MyISAM DEFAULT CHARSET=cp1251 drop table t1; CREATE TABLE t1 ( Host varchar(16) binary NOT NULL default '', diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index 93214ae8479..4c6e1645451 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -18,9 +18,11 @@ select -(0-3),round(-(0-3)), round(9999999999999999999); -(0-3) round(-(0-3)) round(9999999999999999999) 3 3 10000000000000000000 create table t1 (a bigint unsigned not null, primary key(a)); -insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE); +insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612); select * from t1; a +18446744073709551612 +18446744073709551613 18446744073709551614 18446744073709551615 select * from t1 where a=18446744073709551615; @@ -29,6 +31,8 @@ a delete from t1 where a=18446744073709551615; select * from t1; a +18446744073709551612 +18446744073709551613 18446744073709551614 drop table t1; create table t1 ( a int not null default 1, big bigint ); @@ -70,3 +74,13 @@ select * from t1 limit 9999999999; id a 9999999999 1 drop table t1; +CREATE TABLE t1 ( quantity decimal(60,0)); +insert into t1 values (10000000000000000000); +insert into t1 values (10000000000000000000.0); +insert into t1 values ('10000000000000000000'); +select * from t1; +quantity +-8446744073709551616 +10000000000000000000 +10000000000000000000 +drop table t1; diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result index 4aab3defa2b..e9d432de077 100644 --- a/mysql-test/r/case.result +++ b/mysql-test/r/case.result @@ -90,20 +90,22 @@ CASE WHEN 1 THEN 1 ELSE 'a' END AS c4, CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5, CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6, CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7, -CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8 +CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8, +CASE WHEN 1 THEN 1.0 END AS c9 ; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` char(1) character set latin1 collate latin1_danish_ci default NULL, - `c2` char(1) character set latin1 collate latin1_danish_ci default NULL, - `c3` char(1) default NULL, - `c4` char(1) default NULL, - `c5` char(3) default NULL, - `c6` char(3) default NULL, - `c7` double(3,1) default NULL, - `c8` double(3,1) default NULL -) TYPE=MyISAM CHARSET=latin1 + `c1` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '', + `c2` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '', + `c3` char(1) NOT NULL default '', + `c4` char(1) NOT NULL default '', + `c5` char(3) NOT NULL default '', + `c6` char(3) NOT NULL default '', + `c7` double(3,1) NOT NULL default '0.0', + `c8` double(3,1) NOT NULL default '0.0', + `c9` double(3,1) default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; SELECT CASE WHEN 1 @@ -150,5 +152,5 @@ t1 CREATE TABLE `t1` ( `COALESCE(1,'1')` char(1) NOT NULL default '', `COALESCE(1.1,'1')` char(3) NOT NULL default '', `COALESCE('a' COLLATE latin1_bin,'b')` char(1) character set latin1 collate latin1_bin NOT NULL default '' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 974a79580ae..43afd02169c 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -45,7 +45,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `t` char(4) character set cp1251 NOT NULL default '' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select cast(_latin1'ab' AS char) as c1, @@ -72,7 +72,7 @@ t1 CREATE TABLE `t1` ( `c3` char(2) binary NOT NULL default '', `c4` char(2) binary NOT NULL default '', `c5` char(2) binary NOT NULL default '' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select cast(_koi8r'ÆÇ' AS nchar) as c1, @@ -99,7 +99,7 @@ t1 CREATE TABLE `t1` ( `c3` char(2) character set utf8 NOT NULL default '', `c4` char(2) character set utf8 NOT NULL default '', `c5` char(2) character set utf8 NOT NULL default '' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select cast("2001-1-1" as date) = "2001-01-01"; cast("2001-1-1" as date) = "2001-01-01" diff --git a/mysql-test/r/count_distinct3.result b/mysql-test/r/count_distinct3.result index 633bb2fa252..086e1360b0c 100644 --- a/mysql-test/r/count_distinct3.result +++ b/mysql-test/r/count_distinct3.result @@ -5,3 +5,4 @@ COUNT(*) 4181000 SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp; DROP TABLE t1; +set @@read_buffer_size=default; diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index d61614180b3..28f06f0bf47 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -179,7 +179,7 @@ t1 CREATE TABLE `t1` ( KEY `b_29` (`b`), KEY `b_30` (`b`), KEY `b_31` (`b`) -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 select if(1,'1','0'), month("2002-08-02"); drop table t1; @@ -197,7 +197,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0' -) TYPE=HEAP CHARSET=latin1 +) TYPE=HEAP DEFAULT CHARSET=latin1 drop table t1; SET SESSION table_type="gemini"; SELECT @@table_type; @@ -210,7 +210,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 SET SESSION table_type=default; drop table t1; create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2)); @@ -275,7 +275,7 @@ Table Create Table t3 CREATE TABLE `t3` ( `id` int(11) NOT NULL default '0', `name` char(20) default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 select * from t3; id name create table if not exists t3 like t1; @@ -289,7 +289,7 @@ show create table t3; Table Create Table t3 CREATE TEMPORARY TABLE `t3` ( `id` int(11) NOT NULL default '0' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 select * from t3; id drop table t3; @@ -298,7 +298,7 @@ Table Create Table t3 CREATE TABLE `t3` ( `id` int(11) NOT NULL default '0', `name` char(20) default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 select * from t3; id name drop table t2, t3; @@ -313,14 +313,14 @@ Table Create Table t3 CREATE TEMPORARY TABLE `t3` ( `id` int(11) NOT NULL default '0', `name` char(20) default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 create table t2 like t3; show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `id` int(11) NOT NULL default '0', `name` char(20) default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 select * from t2; id name create table t3 like t1; @@ -346,7 +346,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0' -) TYPE=HEAP CHARSET=latin1 +) TYPE=HEAP DEFAULT CHARSET=latin1 drop table t1; SET SESSION table_type="gemini"; SELECT @@table_type; @@ -359,7 +359,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 SET SESSION table_type=default; drop table t1; create table t1(a int,b int,c int unsigned,d date,e char,f datetime,g time,h blob); diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result index 6a9da97042b..2186b155f99 100644 --- a/mysql-test/r/ctype_collate.result +++ b/mysql-test/r/ctype_collate.result @@ -491,7 +491,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `latin1_f` char(32) NOT NULL default '' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 SHOW FIELDS FROM t1; Field Type Null Key Default Extra latin1_f char(32) @@ -501,7 +501,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `latin1_f` char(32) character set latin1 collate latin1_bin default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 SHOW FIELDS FROM t1; Field Type Null Key Default Extra latin1_f char(32) YES NULL @@ -509,8 +509,8 @@ ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `latin1_f` char(32) collate latin1_bin default NULL -) TYPE=MyISAM CHARSET=latin1 COLLATE=latin1_bin + `latin1_f` char(32) character set latin1 collate latin1_bin default NULL +) TYPE=MyISAM DEFAULT CHARSET=latin1 SHOW FIELDS FROM t1; Field Type Null Key Default Extra latin1_f char(32) YES NULL diff --git a/mysql-test/r/ctype_latin1_de.result b/mysql-test/r/ctype_latin1_de.result index 07ea97258d9..f1049b81d26 100644 --- a/mysql-test/r/ctype_latin1_de.result +++ b/mysql-test/r/ctype_latin1_de.result @@ -225,7 +225,7 @@ t1 CREATE TABLE `t1` ( `word` varchar(255) collate latin1_german2_ci NOT NULL default '', `word2` varchar(255) collate latin1_german2_ci NOT NULL default '', KEY `word` (`word`) -) TYPE=MyISAM CHARSET=latin1 COLLATE=latin1_german2_ci +) TYPE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae'); update t1 set word2=word; select word, word=binary 0xdf as t from t1 having t > 0; @@ -284,7 +284,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `s1` char(5) collate latin1_german2_ci default NULL -) TYPE=MyISAM CHARSET=latin1 COLLATE=latin1_german2_ci +) TYPE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci INSERT INTO t1 VALUES ('Ü'); INSERT INTO t1 VALUES ('ue'); SELECT DISTINCT s1 FROM t1; diff --git a/mysql-test/r/ctype_many.result b/mysql-test/r/ctype_many.result index c465655473d..764503f9e22 100644 --- a/mysql-test/r/ctype_many.result +++ b/mysql-test/r/ctype_many.result @@ -9,14 +9,14 @@ Table Create Table t1 CREATE TABLE `t1` ( `comment` char(32) character set latin1 NOT NULL default '', `koi8_ru_f` char(32) character set koi8r NOT NULL default '' -) TYPE=MyISAM CHARSET=latin5 +) TYPE=MyISAM DEFAULT CHARSET=latin5 ALTER TABLE t1 CHANGE comment comment CHAR(32) CHARACTER SET latin2 NOT NULL; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `comment` char(32) character set latin2 NOT NULL default '', `koi8_ru_f` char(32) character set koi8r NOT NULL default '' -) TYPE=MyISAM CHARSET=latin5 +) TYPE=MyISAM DEFAULT CHARSET=latin5 ALTER TABLE t1 ADD latin5_f CHAR(32) NOT NULL; SHOW CREATE TABLE t1; Table Create Table @@ -24,8 +24,8 @@ t1 CREATE TABLE `t1` ( `comment` char(32) character set latin2 NOT NULL default '', `koi8_ru_f` char(32) character set koi8r NOT NULL default '', `latin5_f` char(32) NOT NULL default '' -) TYPE=MyISAM CHARSET=latin5 -ALTER TABLE t1 CHARSET=latin2; +) TYPE=MyISAM DEFAULT CHARSET=latin5 +ALTER TABLE t1 DEFAULT CHARSET=latin2; ALTER TABLE t1 ADD latin2_f CHAR(32) NOT NULL; SHOW CREATE TABLE t1; Table Create Table @@ -34,14 +34,14 @@ t1 CREATE TABLE `t1` ( `koi8_ru_f` char(32) character set koi8r NOT NULL default '', `latin5_f` char(32) character set latin5 NOT NULL default '', `latin2_f` char(32) NOT NULL default '' -) TYPE=MyISAM CHARSET=latin2 +) TYPE=MyISAM DEFAULT CHARSET=latin2 ALTER TABLE t1 DROP latin2_f, DROP latin5_f; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `comment` char(32) NOT NULL default '', `koi8_ru_f` char(32) character set koi8r NOT NULL default '' -) TYPE=MyISAM CHARSET=latin2 +) TYPE=MyISAM DEFAULT CHARSET=latin2 INSERT INTO t1 (koi8_ru_f,comment) VALUES ('a','LAT SMALL A'); INSERT INTO t1 (koi8_ru_f,comment) VALUES ('b','LAT SMALL B'); INSERT INTO t1 (koi8_ru_f,comment) VALUES ('c','LAT SMALL C'); diff --git a/mysql-test/r/ctype_mb.result b/mysql-test/r/ctype_mb.result index ce4a4f98b42..88cd1b4f7fe 100644 --- a/mysql-test/r/ctype_mb.result +++ b/mysql-test/r/ctype_mb.result @@ -5,7 +5,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `c1` char(4) character set utf8 NOT NULL default '', `c2` char(4) character set utf8 NOT NULL default '' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 DELETE FROM t1; ALTER TABLE t1 ADD c3 CHAR(4) CHARACTER SET utf8; SHOW CREATE TABLE t1; @@ -14,7 +14,7 @@ t1 CREATE TABLE `t1` ( `c1` char(4) character set utf8 NOT NULL default '', `c2` char(4) character set utf8 NOT NULL default '', `c3` char(4) character set utf8 default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 INSERT INTO t1 VALUES ('aaaabbbbccccdddd','aaaabbbbccccdddd','aaaabbbbccccdddd'); Warnings: Warning 1264 Data truncated for column 'c1' at row 1 @@ -30,7 +30,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` char(4) character set utf8 default NULL, KEY `key_a` (`a`(3)) -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 SHOW KEYS FROM t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment t1 1 key_a 1 a A NULL 9 NULL YES BTREE @@ -40,7 +40,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` char(4) default NULL, KEY `key_a` (`a`(3)) -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 SHOW KEYS FROM t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment t1 1 key_a 1 a A NULL 3 NULL YES BTREE @@ -50,7 +50,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` char(4) character set utf8 default NULL, KEY `key_a` (`a`(3)) -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 SHOW KEYS FROM t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment t1 1 key_a 1 a A NULL 9 NULL YES BTREE diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index 1fe07692290..5afd2c041c8 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -6,7 +6,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `a` char(10) character set cp1251 default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 SELECT a FROM t1; a ÐÒÏÂÁ @@ -25,7 +25,7 @@ SHOW CREATE TABLE ÔÁÂÌÉÃÁ; Table Create Table ÔÁÂÌÉÃÁ CREATE TABLE `ÔÁÂÌÉÃÁ` ( `ÐÏÌÅ` char(32) character set koi8r NOT NULL default '' COMMENT 'ËÏÍÍÅÎÔÁÒÉÊ ÐÏÌÑ' -) TYPE=MyISAM CHARSET=latin1 COMMENT='ËÏÍÍÅÎÔÁÒÉÊ ÔÁÂÌÉÃÙ' +) TYPE=MyISAM DEFAULT CHARSET=latin1 COMMENT='ËÏÍÍÅÎÔÁÒÉÊ ÔÁÂÌÉÃÙ' SHOW FIELDS FROM ÔÁÂÌÉÃÁ; Field Type Null Key Default Extra ÐÏÌÅ char(32) @@ -37,7 +37,7 @@ SHOW CREATE TABLE òàáëèöà; Table Create Table òàáëèöà CREATE TABLE `òàáëèöà` ( `ïîëå` char(32) character set koi8r NOT NULL default '' COMMENT 'êîììåíòàðèé ïîëÿ' -) TYPE=MyISAM CHARSET=latin1 COMMENT='êîììåíòàðèé òàáëèöû' +) TYPE=MyISAM DEFAULT CHARSET=latin1 COMMENT='êîììåíòàðèé òàáëèöû' SHOW FIELDS FROM òàáëèöà; Field Type Null Key Default Extra ïîëå char(32) @@ -49,7 +49,7 @@ SHOW CREATE TABLE таблица; Table Create Table таблица CREATE TABLE `таблица` ( `поле` char(32) character set koi8r NOT NULL default '' COMMENT 'комментарий полÑ' -) TYPE=MyISAM CHARSET=latin1 COMMENT='комментарий таблицы' +) TYPE=MyISAM DEFAULT CHARSET=latin1 COMMENT='комментарий таблицы' SHOW FIELDS FROM таблица; Field Type Null Key Default Extra поле char(32) diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index db626c8acb1..977797f0278 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -45,7 +45,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `l` char(10) character set ucs2 NOT NULL default '', `r` char(10) character set ucs2 NOT NULL default '' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; SET NAMES koi8r; SET character_set_connection=ucs2; diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 346d086f34c..5eb21c40a3e 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -120,7 +120,7 @@ date format str_to_date 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 -15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 15 MAY 2001 %d %b %Y 2001-05-15 00:00:00 Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 @@ -144,7 +144,7 @@ date format con 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 -15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 15 MAY 2001 %d %b %Y 2001-05-15 00:00:00 Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 @@ -168,7 +168,7 @@ date format datetime 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 -15 SEPTEMB 2001 %d %M %Y 2001-01-15 00:00:00 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 15 MAY 2001 %d %b %Y 2001-05-15 00:00:00 Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00 @@ -192,7 +192,7 @@ date format date2 10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 15 September 2001 %d %M %Y 2001-09-15 -15 SEPTEMB 2001 %d %M %Y 2001-01-15 +15 SEPTEMB 2001 %d %M %Y 2001-09-15 15 MAY 2001 %d %b %Y 2001-05-15 Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index cd45cf03853..62724c19576 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -1,4 +1,4 @@ -drop table if exists t1; +drop table if exists t1,t11,t12,t2; CREATE TABLE t1 (a tinyint(3), b tinyint(5)); INSERT INTO t1 VALUES (1,1); INSERT LOW_PRIORITY INTO t1 VALUES (1,2); @@ -58,3 +58,65 @@ select count(*) from t1; count(*) 0 drop table t1; +create table t11 (a int NOT NULL, b int, primary key (a)); +create table t12 (a int NOT NULL, b int, primary key (a)); +create table t2 (a int NOT NULL, b int, primary key (a)); +insert into t11 values (0, 10),(1, 11),(2, 12); +insert into t12 values (33, 10),(0, 11),(2, 12); +insert into t2 values (1, 21),(2, 12),(3, 23); +select * from t11; +a b +0 10 +1 11 +2 12 +select * from t12; +a b +33 10 +0 11 +2 12 +select * from t2; +a b +1 21 +2 12 +3 23 +delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a); +ERROR 21000: Subquery returns more than 1 row +select * from t11; +a b +0 10 +1 11 +2 12 +select * from t12; +a b +33 10 +0 11 +2 12 +delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a); +Warnings: +Error 1241 Subquery returns more than 1 row +Error 1241 Subquery returns more than 1 row +select * from t11; +a b +0 10 +1 11 +select * from t12; +a b +33 10 +0 11 +insert into t11 values (2, 12); +delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a); +ERROR 21000: Subquery returns more than 1 row +select * from t11; +a b +0 10 +1 11 +2 12 +delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a); +Warnings: +Error 1241 Subquery returns more than 1 row +Error 1241 Subquery returns more than 1 row +select * from t11; +a b +0 10 +1 11 +drop table t11, t12, t2; diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index c59b68e4c4d..bb268cd1094 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -164,7 +164,7 @@ create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL); insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9); insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105); -SELECT d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; pla_id mat_id 100 1 101 1 @@ -172,7 +172,7 @@ pla_id mat_id 103 2 104 2 105 3 -SELECT d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; pla_id test 100 1 101 1 @@ -180,13 +180,13 @@ pla_id test 103 2 104 2 105 3 -explain SELECT d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY m2 ALL NULL NULL NULL NULL 9 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 Using where 2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort 2 DERIVED m2 index NULL PRIMARY 3 NULL 9 Using index -explain SELECT d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY m2 ALL NULL NULL NULL NULL 9 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 Using where diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 56f95ff0c90..5cb4263f649 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -201,7 +201,7 @@ t2 CREATE TABLE `t2` ( `inhalt` text, KEY `tig` (`ticket`), FULLTEXT KEY `tix` (`inhalt`) -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 select * from t2 where MATCH inhalt AGAINST (NULL); ticket inhalt select * from t2 where MATCH inhalt AGAINST ('foobar'); @@ -306,18 +306,27 @@ INSERT t1 VALUES ('Mit freundlichem Grüß'), ('aus Osnabrück'); SET NAMES koi8r; INSERT t1 VALUES ("üÔÏ ÍÙ - ÏÐÉÌËÉ"),("ïÔÌÅÚØ, ÇÎÉÄÁ!"), ("îÅ ×ÌÅÚÁÊ, ÕÂØÅÔ!"),("É ÂÕÄÅÔ ÐÒÁ×!"); -SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('ïðéìëé'); -t charset(t) -üÔÏ ÍÙ - ÏÐÉÌËÉ utf8 -SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('ðÒá*' IN BOOLEAN MODE); -t charset(t) -É ÂÕÄÅÔ ÐÒÁ×! utf8 +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('ïðéìëé'); +t collation(t) +üÔÏ ÍÙ - ÏÐÉÌËÉ utf8_general_ci +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('ðÒá*' IN BOOLEAN MODE); +t collation(t) +É ÂÕÄÅÔ ÐÒÁ×! utf8_general_ci SELECT * FROM t1 WHERE MATCH t AGAINST ('ÜÔÏ' IN BOOLEAN MODE); t -SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); -t charset(t) +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); +t collation(t) SET NAMES latin1; -SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); -t charset(t) -aus Osnabrück utf8 +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); +t collation(t) +aus Osnabrück utf8_general_ci +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck'); +t collation(t) +alter table t1 modify t varchar(200) collate latin1_german2_ci not null; +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); +t collation(t) +aus Osnabrück latin1_german2_ci +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck'); +t collation(t) +aus Osnabrück latin1_german2_ci DROP TABLE t1; diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index e43f9a9119e..64b6d7e65f9 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -539,7 +539,7 @@ t1 CREATE TABLE `t1` ( `substring(_latin2'ab',1)` char(2) character set latin2 NOT NULL default '', `insert(_latin2'abcd',2,3,_latin2'ef')` char(6) character set latin2 NOT NULL default '', `replace(_latin2'abcd',_latin2'b',_latin2'B')` char(4) character set latin2 NOT NULL default '' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select SUBSTR('abcdefg',3,2); SUBSTR('abcdefg',3,2) diff --git a/mysql-test/r/func_system.result b/mysql-test/r/func_system.result index 9d370b43099..d045d4865dc 100644 --- a/mysql-test/r/func_system.result +++ b/mysql-test/r/func_system.result @@ -49,7 +49,7 @@ t1 CREATE TABLE `t1` ( `database()` char(34) character set utf8 NOT NULL default '', `user()` char(77) character set utf8 NOT NULL default '', `version` char(40) default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select TRUE,FALSE,NULL; TRUE FALSE NULL diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 9d38083f48a..feaebc9b514 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -468,6 +468,23 @@ select date_add(time,INTERVAL 1 SECOND) from t1; date_add(time,INTERVAL 1 SECOND) 2006-07-08 00:00:01 drop table t1; +select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2, +last_day('2003-03-32') as f3, last_day('2003-04-01') as f4, +last_day('2001-01-01 01:01:01') as f5, last_day(NULL), +last_day('2001-02-12'); +f1 f2 f3 f4 f5 last_day(NULL) last_day('2001-02-12') +2000-02-29 2002-12-31 NULL 2003-04-30 2001-01-31 NULL 2001-02-28 +create table t1 select last_day('2000-02-05') as a; +describe t1; +Field Type Null Key Default Extra +a date 0000-00-00 +select * from t1; +a +2000-02-29 +drop table t1; +select last_day('2000-02-05'); +last_day('2000-02-05') +2000-02-29 select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0; strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0 1 diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result index 173a065adc2..ca54ec59938 100644 --- a/mysql-test/r/gis-rtree.result +++ b/mysql-test/r/gis-rtree.result @@ -11,7 +11,7 @@ t1 CREATE TABLE `t1` ( `g` geometry NOT NULL default '', PRIMARY KEY (`fid`), SPATIAL KEY `g` (`g`(32)) -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 INSERT INTO t1 (g) VALUES (GeomFromText('LineString(150 150, 150 150)')); INSERT INTO t1 (g) VALUES (GeomFromText('LineString(149 149, 151 151)')); INSERT INTO t1 (g) VALUES (GeomFromText('LineString(148 148, 152 152)')); @@ -294,7 +294,7 @@ t2 CREATE TABLE `t2` ( `g` geometry NOT NULL default '', PRIMARY KEY (`fid`), SPATIAL KEY `g` (`g`(32)) -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 SELECT count(*) FROM t2; count(*) 100 diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index af39dbf51f1..0ebf3d50ab8 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1,4 +1,4 @@ -drop table if exists t1,t2,t3; +drop table if exists t1,t2,t3,t4; drop database if exists mysqltest; create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) type=innodb; insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt'); @@ -819,7 +819,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` char(20) default NULL, KEY `a` (`a`(5)) -) TYPE=InnoDB CHARSET=latin1 +) TYPE=InnoDB DEFAULT CHARSET=latin1 drop table t1; create temporary table t1 (a int not null auto_increment, primary key(a)) type=innodb; insert into t1 values (NULL),(NULL),(NULL); diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result index 79fe0599bc4..4bc4cad40a4 100644 --- a/mysql-test/r/key_cache.result +++ b/mysql-test/r/key_cache.result @@ -1,3 +1,4 @@ +drop table if exists t1, t2, t3; SET @save_key_buffer=@@key_buffer_size; SELECT @@key_buffer_size, @@small.key_buffer_size; @@key_buffer_size @@small.key_buffer_size @@ -74,15 +75,15 @@ select @@keycache1.key_buffer_size; 0 select @@keycache1.key_cache_block_size; @@keycache1.key_cache_block_size -0 +2048 select @@key_buffer_size; @@key_buffer_size 2097152 select @@key_cache_block_size; @@key_cache_block_size 1024 -drop table if exists t1, t2; -create table t1 (p int primary key, a char(10)); +set global keycache1.key_buffer_size=1024*1024; +create table t1 (p int primary key, a char(10)) delay_key_write=1; create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a)); insert into t1 values (1, 'qqqq'), (11, 'yyyy'); insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'), @@ -99,7 +100,7 @@ p i a 4 3 zzzz update t1 set p=2 where p=1; update t2 set i=2 where i=1; -cache index t1 keys in keycache1; +cache index t1 keys (`primary`) in keycache1; Table Op Msg_type Msg_text test.t1 assign_to_keycache status OK explain select p from t1; @@ -125,15 +126,15 @@ id select_type table type possible_keys key key_len ref rows Extra select count(*) from t1, t2 where t1.p = t2.i; count(*) 3 -cache index t2 keys in keycache1; +cache index t2 in keycache1; Table Op Msg_type Msg_text test.t2 assign_to_keycache status OK update t2 set p=p+1000, i=2 where a='qqqq'; -cache index t2 keys in keycache2; +cache index t2 in keycache2; Table Op Msg_type Msg_text test.t2 assign_to_keycache status OK insert into t2 values (2000, 3, 'yyyy'); -cache index t2 keys in keycache1; +cache index t2 in keycache1; Table Op Msg_type Msg_text test.t2 assign_to_keycache status OK update t2 set p=3000 where a='zzzz'; @@ -174,6 +175,12 @@ qqqq yyyy yyyy zzzz +cache index t1 in unknown_key_cache; +ERROR HY000: Unknown key cache 'unknown_key_cache' +cache index t1 keys (unknown_key) in keycache1; +Table Op Msg_type Msg_text +test.t1 assign_to_keycache error Key column 'unknown_key' doesn't exist in table +test.t1 assign_to_keycache status Operation failed select @@keycache2.key_buffer_size; @@keycache2.key_buffer_size 4194304 @@ -186,7 +193,11 @@ select @@keycache2.key_buffer_size; 0 select @@keycache2.key_cache_block_size; @@keycache2.key_cache_block_size -0 +1024 +set global keycache2.key_buffer_size=1024*1024; +select @@keycache2.key_buffer_size; +@@keycache2.key_buffer_size +1048576 update t2 set p=4000 where a='zzzz'; update t1 set p=p+1; set global keycache1.key_buffer_size=0; @@ -232,3 +243,17 @@ select p from t1; p 3 12 +create table t3 (like t1); +cache index t3 in small; +Table Op Msg_type Msg_text +test.t3 assign_to_keycache status OK +insert into t3 select * from t1; +cache index t3 in keycache2; +Table Op Msg_type Msg_text +test.t3 assign_to_keycache status OK +cache index t1,t2 in default; +Table Op Msg_type Msg_text +test.t1 assign_to_keycache status OK +test.t2 assign_to_keycache status OK +drop table t1,t2,t3; +set global keycache1.key_buffer_size=0; diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 9a99d1c64fb..01635313590 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -175,7 +175,7 @@ t3 CREATE TABLE `t3` ( `a` int(11) NOT NULL default '0', `b` char(20) default NULL, KEY `a` (`a`) -) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(`t1`,`t2`) +) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`) create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2); select * from t4; ERROR HY000: Can't open file: 't4.MRG' (errno: 143) @@ -190,7 +190,7 @@ t5 CREATE TABLE `t5` ( `a` int(11) NOT NULL default '0', `b` char(20) default NULL, KEY `a` (`a`) -) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(`t1`,`mysqltest`.`t6`) +) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`mysqltest`.`t6`) alter table t5 type=myisam; drop table t5, mysqltest.t6; drop database mysqltest; @@ -263,14 +263,14 @@ t3 CREATE TABLE `t3` ( `incr` int(11) NOT NULL default '0', `othr` int(11) NOT NULL default '0', PRIMARY KEY (`incr`) -) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(`t1`,`t2`) +) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`) alter table t3 drop primary key; show create table t3; Table Create Table t3 CREATE TABLE `t3` ( `incr` int(11) NOT NULL default '0', `othr` int(11) NOT NULL default '0' -) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(`t1`,`t2`) +) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`) drop table t3,t2,t1; create table t1 (a int not null, key(a)) type=merge; select * from t1; @@ -299,28 +299,28 @@ t3 CREATE TABLE `t3` ( `a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', KEY `a` (`a`,`b`) -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 show create table t4; Table Create Table t4 CREATE TABLE `t4` ( `a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', KEY `a` (`a`,`b`) -) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(`t1`,`t2`) +) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`) show create table t5; Table Create Table t5 CREATE TABLE `t5` ( `a` int(11) NOT NULL default '0', `b` int(11) NOT NULL auto_increment, PRIMARY KEY (`a`,`b`) -) TYPE=MRG_MyISAM CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`,`t2`) +) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`,`t2`) show create table t6; Table Create Table t6 CREATE TABLE `t6` ( `a` int(11) NOT NULL default '0', `b` int(11) NOT NULL auto_increment, PRIMARY KEY (`a`,`b`) -) TYPE=MRG_MyISAM CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`) +) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`) insert into t1 values (1,NULL),(1,NULL),(1,NULL),(1,NULL); insert into t2 values (2,NULL),(2,NULL),(2,NULL),(2,NULL); select * from t3 order by b,a limit 3; @@ -385,7 +385,7 @@ t4 CREATE TABLE `t4` ( `a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', KEY `a` (`a`,`b`) -) TYPE=MRG_MyISAM CHARSET=latin1 UNION=(`t1`,`t2`,`t3`) +) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`,`t3`) select * from t4 order by a,b; a b 1 1 @@ -411,7 +411,7 @@ t4 CREATE TABLE `t4` ( `a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', KEY `a` (`a`,`b`) -) TYPE=MRG_MyISAM CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`,`t2`,`t3`) +) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`,`t2`,`t3`) insert into t4 values (4,1),(4,2); select * from t1 order by a,b; a b diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index a7579b538b5..b0d597f238a 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -341,3 +341,25 @@ select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and a b a b 2 2 NULL NULL drop table t1,t2; +create table t1 ( a int not null, b int not null) ; +alter table t1 add index i1(a); +delete from t1 where a > 2000000; +create table t2 like t1; +insert into t2 select * from t1; +select 't2 rows before small delete', count(*) from t1; +t2 rows before small delete count(*) +t2 rows before small delete 2000000 +delete t1,t2 from t1,t2 where t1.b=t2.a and t1.a < 2; +select 't2 rows after small delete', count(*) from t2; +t2 rows after small delete count(*) +t2 rows after small delete 1999999 +select 't1 rows after small delete', count(*) from t1; +t1 rows after small delete count(*) +t1 rows after small delete 1999999 +delete t1,t2 from t1,t2 where t1.b=t2.a and t1.a < 100*1000; +select 't2 rows after big delete', count(*) from t2; +t2 rows after big delete count(*) +t2 rows after big delete 1900001 +select 't1 rows after big delete', count(*) from t1; +t1 rows after big delete count(*) +t1 rows after big delete 1900001 diff --git a/mysql-test/r/preload.result b/mysql-test/r/preload.result index 4d9293c7929..bd7b828d5b9 100644 --- a/mysql-test/r/preload.result +++ b/mysql-test/r/preload.result @@ -69,7 +69,7 @@ flush status; select @@preload_buffer_size; @@preload_buffer_size 32768 -load index into cache t1 keys; +load index into cache t1; Table Op Msg_type Msg_text test.t1 preload_keys status OK show status like "key_read%"; @@ -93,7 +93,7 @@ set session preload_buffer_size=256*1024; select @@preload_buffer_size; @@preload_buffer_size 262144 -load index into cache t1 keys ignore leaves; +load index into cache t1 ignore leaves; Table Op Msg_type Msg_text test.t1 preload_keys status OK show status like "key_read%"; @@ -117,7 +117,7 @@ set session preload_buffer_size=1*1024; select @@preload_buffer_size; @@preload_buffer_size 1024 -load index into cache t1 keys, t2 keys (primary,b) ignore leaves; +load index into cache t1, t2 keys (primary,b) ignore leaves; Table Op Msg_type Msg_text test.t1 preload_keys status OK test.t2 preload_keys status OK @@ -141,7 +141,7 @@ show status like "key_read%"; Variable_name Value Key_read_requests 0 Key_reads 0 -load index into cache t3 keys, t2 keys (primary,b) ; +load index into cache t3, t2 keys (primary,b) ; Table Op Msg_type Msg_text test.t3 preload_keys error Table 'test.t3' doesn't exist test.t2 preload_keys status OK diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index e91153cae15..e668b9031cc 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -586,7 +586,7 @@ select * from t1; a set GLOBAL query_cache_size=1024; Warnings: -Warning 1285 Query cache failed to set size 1024, new query cache size is 0 +Warning 1281 Query cache failed to set size 1024, new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -594,7 +594,7 @@ select * from t1; a set GLOBAL query_cache_size=10240; Warnings: -Warning 1285 Query cache failed to set size 10240, new query cache size is 0 +Warning 1281 Query cache failed to set size 10240, new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -602,7 +602,7 @@ select * from t1; a set GLOBAL query_cache_size=20480; Warnings: -Warning 1285 Query cache failed to set size 20480, new query cache size is 0 +Warning 1281 Query cache failed to set size 20480, new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -610,7 +610,7 @@ select * from t1; a set GLOBAL query_cache_size=40960; Warnings: -Warning 1285 Query cache failed to set size 40960, new query cache size is 0 +Warning 1281 Query cache failed to set size 40960, new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 diff --git a/mysql-test/r/rpl000015.result b/mysql-test/r/rpl000015.result index 98ad998f2ed..8cbbe3ab0e8 100644 --- a/mysql-test/r/rpl000015.result +++ b/mysql-test/r/rpl000015.result @@ -1,22 +1,22 @@ reset master; show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 79 reset slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master change master to master_host='127.0.0.1'; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 test MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=MASTER_PORT; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 7 master-bin.000001 79 slave-relay-bin.000001 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No # drop table if exists t1; create table t1 (n int); diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result new file mode 100644 index 00000000000..883cb65171c --- /dev/null +++ b/mysql-test/r/rpl_change_master.result @@ -0,0 +1,32 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +select get_lock("a",5); +get_lock("a",5) +1 +create table t1(n int); +insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(2); +stop slave; +select * from t1; +n +1 +show slave status; +Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +# 127.0.0.1 root 9306 1 master-bin.000001 273 slave-relay-bin.000002 258 master-bin.000001 No No 0 0 214 317 None 0 No # +change master to master_user='root'; +show slave status; +Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +# 127.0.0.1 root 9306 1 master-bin.000001 214 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 214 4 None 0 No # +select release_lock("a"); +release_lock("a") +1 +start slave; +select * from t1; +n +1 +2 +drop table t1; diff --git a/mysql-test/r/rpl_empty_master_crash.result b/mysql-test/r/rpl_empty_master_crash.result index 41c5ebe47e1..3e234d4ef59 100644 --- a/mysql-test/r/rpl_empty_master_crash.result +++ b/mysql-test/r/rpl_empty_master_crash.result @@ -5,7 +5,7 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master load table t1 from master; ERROR 08S01: Error connecting to master: Master is not configured load table t1 from master; diff --git a/mysql-test/r/rpl_error_ignored_table.result b/mysql-test/r/rpl_error_ignored_table.result index 2baa69d4aad..8d5bbf91561 100644 --- a/mysql-test/r/rpl_error_ignored_table.result +++ b/mysql-test/r/rpl_error_ignored_table.result @@ -8,7 +8,7 @@ create table t1 (a int primary key); insert into t1 values (1),(1); ERROR 23000: Duplicate entry '1' for key 1 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 213 slave-relay-bin.000002 257 master-bin.000001 Yes Yes test.t1 0 0 213 257 None 0 No # show tables like 't1'; Tables_in_test (t1) diff --git a/mysql-test/r/rpl_flush_log_loop.result b/mysql-test/r/rpl_flush_log_loop.result index e0f85210616..6992b635672 100644 --- a/mysql-test/r/rpl_flush_log_loop.result +++ b/mysql-test/r/rpl_flush_log_loop.result @@ -13,5 +13,5 @@ master_password='',master_port=SLAVE_PORT; start slave; flush logs; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 79 relay-log.000002 4 slave-bin.000001 Yes Yes 0 0 79 4 None 0 No # diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index 092b14cacfb..65fc9d1b415 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -21,7 +21,7 @@ day id category name 2003-03-22 2161 c asdf 2003-03-22 2416 a bbbbb show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB slave-bin.000001 964 drop table t1; drop table t2; @@ -32,7 +32,7 @@ load data infile '../../std_data/rpl_loaddata.dat' into table t1; set global sql_slave_skip_counter=1; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1311 slave-relay-bin.000002 1355 master-bin.000001 Yes Yes 0 0 1311 1355 None 0 No # set sql_log_bin=0; delete from t1; @@ -42,8 +42,8 @@ stop slave; change master to master_user='test'; change master to master_user='root'; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1442 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 1442 4 None 0 No # +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1419 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 1419 4 None 0 No # set global sql_slave_skip_counter=1; start slave; set sql_log_bin=0; @@ -53,7 +53,7 @@ load data infile '../../std_data/rpl_loaddata.dat' into table t1; stop slave; reset slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # reset master; create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60), @@ -63,6 +63,6 @@ terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; ERROR 23000: Duplicate entry '2003-03-22' for key 1 show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 491 drop table t2; diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index 6860067a2d4..2f8a54369c9 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -95,7 +95,7 @@ slave-bin.000002 4 Query 1 4 use `test`; create table t1 (n int) slave-bin.000002 62 Query 1 62 use `test`; insert into t1 values (1) slave-bin.000002 122 Query 1 122 use `test`; drop table t1 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000002 276 slave-relay-bin.000003 214 master-bin.000002 Yes Yes 0 0 276 214 None 0 No # show binlog events in 'slave-bin.000005' from 4; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result index 098fb056cc6..10c78272de6 100644 --- a/mysql-test/r/rpl_log_pos.result +++ b/mysql-test/r/rpl_log_pos.result @@ -5,10 +5,10 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 79 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No # stop slave; change master to master_log_pos=73; @@ -16,20 +16,20 @@ start slave; stop slave; change master to master_log_pos=73; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 73 4 None 0 No # start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 48 master-bin.000001 No Yes 0 0 73 48 None 0 No # stop slave; change master to master_log_pos=173; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 173 slave-relay-bin.000001 4 master-bin.000001 No Yes 0 0 173 4 None 0 No # show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000001 79 create table if not exists t1 (n int); drop table if exists t1; diff --git a/mysql-test/r/rpl_max_relay_size.result b/mysql-test/r/rpl_max_relay_size.result index 2d08ca6e3a3..5c3360b0f66 100644 --- a/mysql-test/r/rpl_max_relay_size.result +++ b/mysql-test/r/rpl_max_relay_size.result @@ -15,7 +15,7 @@ select @@global.max_relay_log_size; 4096 start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50477 slave-relay-bin.000014 1221 master-bin.000001 Yes Yes 0 0 50477 1221 None 0 No # stop slave; reset slave; @@ -25,7 +25,7 @@ select @@global.max_relay_log_size; 20480 start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50477 slave-relay-bin.000004 9457 master-bin.000001 Yes Yes 0 0 50477 9457 None 0 No # stop slave; reset slave; @@ -35,27 +35,27 @@ select @@global.max_relay_log_size; 0 start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50477 slave-relay-bin.000008 1283 master-bin.000001 Yes Yes 0 0 50477 1283 None 0 No # stop slave; reset slave; flush logs; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # reset slave; start slave; flush logs; create table t1 (a int); show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50535 slave-relay-bin.000009 62 master-bin.000001 Yes Yes 0 0 50535 62 None 0 No # flush logs; drop table t1; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50583 slave-relay-bin.000010 52 master-bin.000001 Yes Yes 0 0 50583 52 None 0 No # flush logs; show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000002 4 diff --git a/mysql-test/r/rpl_openssl.result b/mysql-test/r/rpl_openssl.result index 32760f2c870..ad7251fd631 100644 --- a/mysql-test/r/rpl_openssl.result +++ b/mysql-test/r/rpl_openssl.result @@ -19,12 +19,12 @@ select * from t1; t 1 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 replssl MASTER_MYPORT 1 master-bin.000001 289 slave-relay-bin.000001 108 master-bin.000001 Yes Yes 0 0 289 108 None 0 Yes MYSQL_TEST_DIR/std_data/cacert.pem MYSQL_TEST_DIR/std_data/client-cert.pem MYSQL_TEST_DIR/std_data/client-key.pem # stop slave; change master to master_user='root',master_password='', master_ssl=0; start slave; drop table t1; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 337 slave-relay-bin.000001 96 master-bin.000001 Yes Yes 0 0 337 96 None 0 No MYSQL_TEST_DIR/std_data/cacert.pem MYSQL_TEST_DIR/std_data/client-cert.pem MYSQL_TEST_DIR/std_data/client-key.pem # diff --git a/mysql-test/r/rpl_redirect.result b/mysql-test/r/rpl_redirect.result index 24a0b1af541..9dd51eaba4d 100644 --- a/mysql-test/r/rpl_redirect.result +++ b/mysql-test/r/rpl_redirect.result @@ -5,7 +5,7 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; SHOW SLAVE STATUS; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master SHOW SLAVE HOSTS; Server_id Host Port Rpl_recovery_rank Master_id 2 127.0.0.1 SLAVE_PORT 2 1 diff --git a/mysql-test/r/rpl_replicate_do.result b/mysql-test/r/rpl_replicate_do.result index 271ee9cefa1..43de4a67ce9 100644 --- a/mysql-test/r/rpl_replicate_do.result +++ b/mysql-test/r/rpl_replicate_do.result @@ -27,5 +27,5 @@ select * from t11; ERROR 42S02: Table 'test.t11' doesn't exist drop table if exists t1,t2,t11; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1281 slave-relay-bin.000002 1325 master-bin.000001 Yes Yes test.t1 0 0 1281 1325 None 0 No # diff --git a/mysql-test/r/rpl_reset_slave.result b/mysql-test/r/rpl_reset_slave.result index e1fbf12786d..42d41533cb0 100644 --- a/mysql-test/r/rpl_reset_slave.result +++ b/mysql-test/r/rpl_reset_slave.result @@ -5,20 +5,20 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No # stop slave; change master to master_user='test'; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 test MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 79 4 None 0 No # reset slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No # start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No # stop slave; reset slave; diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index 4e31164f2ec..87ebf870f38 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -15,7 +15,7 @@ insert into temp_table values ("testing temporary tables"); create table t1 (s text); insert into t1 values('Could not break slave'),('Tried hard'); show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 60 master-bin.000001 417 slave-relay-bin.000001 461 master-bin.000001 Yes Yes 0 0 417 461 None 0 No # select * from t1; s @@ -56,7 +56,7 @@ Log_name master-bin.000003 insert into t2 values (65); show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 60 master-bin.000003 290 slave-relay-bin.000001 1088 master-bin.000003 Yes Yes 0 0 290 1088 None 0 No # select * from t2; m @@ -74,13 +74,13 @@ Log_name master-bin.000003 master-bin.000004 show master status; -File Position Binlog_do_db Binlog_ignore_db +File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000004 2886 select * from t4; a testing temporary tables part 2 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 60 master-bin.000004 2886 slave-relay-bin.000001 7891 master-bin.000004 Yes Yes 0 0 2886 7891 None 0 No # lock tables t3 read; select count(*) from t3 where n >= 4; diff --git a/mysql-test/r/rpl_trunc_binlog.result b/mysql-test/r/rpl_trunc_binlog.result index caca15ab4ef..39b754dec47 100644 --- a/mysql-test/r/rpl_trunc_binlog.result +++ b/mysql-test/r/rpl_trunc_binlog.result @@ -9,5 +9,5 @@ flush logs; reset slave; start slave; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_PORT 1 master-bin.000002 4 slave-relay-bin.000002 123 master-bin.000001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 326 None 0 No # diff --git a/mysql-test/r/rpl_until.result b/mysql-test/r/rpl_until.result index 3ee902cfc09..854a8605abb 100644 --- a/mysql-test/r/rpl_until.result +++ b/mysql-test/r/rpl_until.result @@ -30,7 +30,7 @@ n 3 4 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 332 master-bin.000001 Yes No 0 0 244 649 Master master-bin.000001 244 No # start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291; select * from t1; @@ -40,7 +40,7 @@ n 3 4 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 332 master-bin.000001 Yes No 0 0 244 649 Master master-no-such-bin.000001 291 No # start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=537; select * from t2; @@ -48,13 +48,13 @@ n 1 2 show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 537 master-bin.000001 Yes No 0 0 449 649 Relay slave-relay-bin.000002 537 No # start slave; stop slave; start slave until master_log_file='master-bin.000001', master_log_pos=561; show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 649 master-bin.000001 Yes No 0 0 561 693 Master master-bin.000001 561 No # start slave until master_log_file='master-bin', master_log_pos=561; ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 2a5955e6d87..2f29dcfdb47 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -77,13 +77,13 @@ show create table t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( `a` int(11) NOT NULL default '0' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 alter table t1 rename t2; show create table t2; Table Create Table t2 CREATE TEMPORARY TABLE `t2` ( `a` int(11) NOT NULL default '0' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t2; create table t1 ( test_set set( 'val1', 'val2', 'val3' ) not null default '', @@ -96,7 +96,7 @@ t1 CREATE TABLE `t1` ( `test_set` set('val1','val2','val3') NOT NULL default '', `name` char(20) default 'O''Brien' COMMENT 'O''Brien as default', `c` int(11) NOT NULL default '0' COMMENT 'int column' -) TYPE=MyISAM CHARSET=latin1 COMMENT='it''s a table' +) TYPE=MyISAM DEFAULT CHARSET=latin1 COMMENT='it''s a table' show full columns from t1; Field Type Collation Null Key Default Extra Privileges Comment test_set set('val1','val2','val3') latin1_swedish_ci select,insert,update,references @@ -109,7 +109,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', UNIQUE KEY `aa` (`a`) -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int not null, primary key (a)); show create table t1; @@ -117,7 +117,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', PRIMARY KEY (`a`) -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; flush tables; show open tables; @@ -135,7 +135,7 @@ t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', `b` char(10) default NULL, KEY `b` (`b`) -) TYPE=MyISAM CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test' +) TYPE=MyISAM DEFAULT CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test' alter table t1 MAX_ROWS=200 ROW_FORMAT=dynamic PACK_KEYS=0; show create table t1; Table Create Table @@ -143,7 +143,7 @@ t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', `b` varchar(10) default NULL, KEY `b` (`b`) -) TYPE=MyISAM CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=200 AVG_ROW_LENGTH=10 PACK_KEYS=0 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='test' +) TYPE=MyISAM DEFAULT CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=200 AVG_ROW_LENGTH=10 PACK_KEYS=0 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='test' ALTER TABLE t1 AVG_ROW_LENGTH=0 CHECKSUM=0 COMMENT="" MIN_ROWS=0 MAX_ROWS=0 PACK_KEYS=DEFAULT DELAY_KEY_WRITE=0 ROW_FORMAT=default; show create table t1; Table Create Table @@ -151,7 +151,7 @@ t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL default '0', `b` varchar(10) default NULL, KEY `b` (`b`) -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a decimal(9,2), b decimal (9,0), e double(9,2), f double(5,0), h float(3,2), i float(3,0)); show columns from t1; @@ -221,7 +221,7 @@ t1 CREATE TABLE `t1` ( `type_long_blob` longblob, PRIMARY KEY (`type_tiny`), KEY `type_short` (`type_short`) -) TYPE=MyISAM CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test' +) TYPE=MyISAM DEFAULT CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test' insert into t1 (type_timestamp) values ("2003-02-07 10:00:01"); select * from t1; type_bool type_tiny type_short type_mediumint type_bigint type_decimal type_numeric empty_char type_char type_varchar type_timestamp type_date type_time type_datetime type_year type_enum type_set type_tinyblob type_blob type_medium_blob type_long_blob diff --git a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result index 06451b8ac34..dddfe2432ee 100644 --- a/mysql-test/r/sql_mode.result +++ b/mysql-test/r/sql_mode.result @@ -18,7 +18,7 @@ t1 CREATE TABLE `t1` ( `email` varchar(60) character set latin2 NOT NULL default '', PRIMARY KEY (`a`), UNIQUE KEY `email` TYPE BTREE (`email`) -) TYPE=HEAP CHARSET=latin1 ROW_FORMAT=DYNAMIC +) TYPE=HEAP DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC set @@sql_mode="ansi_quotes"; show variables like 'sql_mode'; Variable_name Value @@ -31,7 +31,7 @@ t1 CREATE TABLE "t1" ( "email" varchar(60) character set latin2 NOT NULL default '', PRIMARY KEY ("a"), UNIQUE KEY "email" TYPE BTREE ("email") -) TYPE=HEAP CHARSET=latin1 ROW_FORMAT=DYNAMIC +) TYPE=HEAP DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC set @@sql_mode="no_table_options"; show variables like 'sql_mode'; Variable_name Value @@ -57,7 +57,7 @@ t1 CREATE TABLE `t1` ( `email` varchar(60) character set latin2 NOT NULL default '', PRIMARY KEY (`a`), UNIQUE KEY `email` (`email`) -) TYPE=HEAP CHARSET=latin1 ROW_FORMAT=DYNAMIC +) TYPE=HEAP DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC set @@sql_mode="no_field_options,mysql323,mysql40"; show variables like 'sql_mode'; Variable_name Value diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 31b5ff84365..95638cbee41 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1071,7 +1071,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` bigint(1) NOT NULL default '0', `(SELECT 1)` bigint(1) NOT NULL default '0' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT a)) a; SHOW CREATE TABLE t1; @@ -1079,7 +1079,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` bigint(1) NOT NULL default '0', `(SELECT a)` bigint(1) NOT NULL default '0' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT a+0)) a; SHOW CREATE TABLE t1; @@ -1087,7 +1087,7 @@ Table Create Table t1 CREATE TABLE `t1` ( `a` bigint(1) NOT NULL default '0', `(SELECT a+0)` bigint(17) NOT NULL default '0' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; CREATE TABLE t1 SELECT (SELECT 1 as a UNION SELECT 1+1 limit 1,1) as a; select * from t1; @@ -1097,7 +1097,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `a` bigint(17) NOT NULL default '0' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); insert into t1 values (1), (2), (3); diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index c31d1019d89..a56fe3e1462 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -40,7 +40,7 @@ t9 CREATE TABLE `t9` ( `b` char(16) NOT NULL default '', `c` int(11) NOT NULL default '0', PRIMARY KEY (`a`) -) TYPE=MyISAM CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' +) TYPE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' alter table t9 rename t8, add column d int not null; alter table t8 rename t7; rename table t7 to t9; @@ -62,5 +62,5 @@ t9 CREATE TABLE `t9` ( `c` int(11) NOT NULL default '0', `d` int(11) NOT NULL default '0', PRIMARY KEY (`a`) -) TYPE=MyISAM CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' +) TYPE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' drop database mysqltest; diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index 82aefa78bb2..d1147e55119 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -23,7 +23,7 @@ Table Create Table t3 CREATE TABLE `t3` ( `a` mediumtext, `b` mediumblob -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1,t2,t3 #; CREATE TABLE t1 (a char(257) default "hello"); diff --git a/mysql-test/r/type_enum.result b/mysql-test/r/type_enum.result index c0f0be246c9..f30feb4c0e6 100644 --- a/mysql-test/r/type_enum.result +++ b/mysql-test/r/type_enum.result @@ -1627,12 +1627,12 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` enum('','a','b') NOT NULL default '' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a enum (' ','a','b ') not null default 'b '); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` enum('','a','b') NOT NULL default 'b' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; diff --git a/mysql-test/r/type_nchar.result b/mysql-test/r/type_nchar.result index c495853cd4c..63193418f77 100644 --- a/mysql-test/r/type_nchar.result +++ b/mysql-test/r/type_nchar.result @@ -4,47 +4,47 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` char(10) character set utf8 default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (c national char(10)); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` char(10) character set utf8 default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (c national varchar(10)); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` varchar(10) character set utf8 default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (c nvarchar(10)); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` varchar(10) character set utf8 default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (c nchar varchar(10)); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` varchar(10) character set utf8 default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (c national character varying(10)); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` varchar(10) character set utf8 default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (c nchar varying(10)); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` varchar(10) character set utf8 default NULL -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; diff --git a/mysql-test/r/type_set.result b/mysql-test/r/type_set.result index 086f55a47a5..e98ec2c3fc4 100644 --- a/mysql-test/r/type_set.result +++ b/mysql-test/r/type_set.result @@ -4,14 +4,14 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` set('','a','b') NOT NULL default '' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a set (' ','a','b ') not null default 'b '); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` set('','a','b') NOT NULL default 'b' -) TYPE=MyISAM CHARSET=latin1 +) TYPE=MyISAM DEFAULT CHARSET=latin1 drop table t1; CREATE TABLE t1 ( user varchar(64) NOT NULL default '', path varchar(255) NOT NULL default '', privilege set('select','RESERVED30','RESERVED29','RESERVED28','RESERVED27','RESERVED26', 'RESERVED25','RESERVED24','data.delete','RESERVED22','RESERVED21', 'RESERVED20','data.insert.none','data.insert.approve', 'data.insert.delete','data.insert.move','data.insert.propose', 'data.insert.reject','RESERVED13','RESERVED12','RESERVED11','RESERVED10', 'RESERVED09','data.update','RESERVED07','RESERVED06','RESERVED05', 'RESERVED04','metadata.delete','metadata.put','RESERVED01','RESERVED00') NOT NULL default '', KEY user (user) ) TYPE=MyISAM CHARSET=utf8; DROP TABLE t1; diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 5729d3b32ee..00eddd596cf 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -486,7 +486,7 @@ a b 2 2 3 3 4 4 -explain (select * from t1 where a=1 and b=10) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a); +explain (select * from t1 where a=1 and b=10) union (select straight_join t1.a,t2.a from t1,t2 where t1.a=t2.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2 UNION t1 index PRIMARY PRIMARY 4 NULL 4 Using index diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 612c1f53bcf..fc3dc4eddcd 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -101,3 +101,22 @@ drop table t1; select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b; @a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b @a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b 10 2 1 10 2 1 10 2 1 10 2 1 +create table t1 (i int not null); +insert t1 values (1),(2),(2),(3),(3),(3); +select @a:=0; +@a:=0 +0 +select @a, @a:=@a+count(*), count(*), @a from t1 group by i; +@a @a:=@a+count(*) count(*) @a +0 1 1 0 +0 2 2 0 +0 3 3 0 +select @a:=0; +@a:=0 +0 +select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i; +@a+0 @a:=@a+0+count(*) count(*) @a+0 +0 1 1 0 +1 3 2 0 +3 6 3 0 +drop table t1; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 06a5db13ea3..11fe997e789 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -170,6 +170,17 @@ select a,hex(a) from t1; alter table t1 change a a char(10) character set koi8r; select a,hex(a) from t1; +# +# Test ALTER TABLE .. CHARACTER SET .. +# +show create table t1; +alter table t1 DEFAULT CHARACTER SET latin1; +show create table t1; +alter table t1 CHARACTER SET latin1; +show create table t1; +alter table t1 DEFAULT CHARACTER SET cp1251; +show create table t1; + drop table t1; # diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index 9ac44c8ba0a..5c977983087 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -22,7 +22,7 @@ select -(0-3),round(-(0-3)), round(9999999999999999999); # create table t1 (a bigint unsigned not null, primary key(a)); -insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE); +insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612); select * from t1; select * from t1 where a=18446744073709551615; # select * from t1 where a='18446744073709551615'; @@ -54,3 +54,17 @@ insert into t1 values (null,1); select * from t1; select * from t1 limit 9999999999; drop table t1; + +# +# Item_uint::save_to_field() +# BUG#1845 +# This can't be fixed in MySQL 4.0 without loosing precisions for bigints +# + +CREATE TABLE t1 ( quantity decimal(60,0)); +insert into t1 values (10000000000000000000); +insert into t1 values (10000000000000000000.0); +insert into t1 values ('10000000000000000000'); +select * from t1; +drop table t1; + diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test index 9a1b6b6bbfe..9377c6c4aef 100644 --- a/mysql-test/t/case.test +++ b/mysql-test/t/case.test @@ -57,7 +57,8 @@ CREATE TABLE t1 SELECT CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5, CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6, CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7, - CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8 + CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8, + CASE WHEN 1 THEN 1.0 END AS c9 ; SHOW CREATE TABLE t1; DROP TABLE t1; diff --git a/mysql-test/t/count_distinct3.test b/mysql-test/t/count_distinct3.test index e6cc98d47df..9d2bb0d139a 100644 --- a/mysql-test/t/count_distinct3.test +++ b/mysql-test/t/count_distinct3.test @@ -21,6 +21,7 @@ while ($1) INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev); dec $1; } +set @@read_buffer_size=2*1024*1024; CREATE TABLE t2 SELECT * FROM t1; INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; @@ -53,3 +54,5 @@ SELECT COUNT(*) FROM t1; SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp; --enable_result_log DROP TABLE t1; + +set @@read_buffer_size=default; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index cec7dd17e6d..0c1280751bc 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -40,9 +40,9 @@ create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null -- error 1044,1 create table not_existing_database.test (a int); ---error 1279 +--error 1103 create table `a/a` (a int); ---error 1279 +--error 1103 create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int); --error 1059 create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int); @@ -66,11 +66,11 @@ create table test_$1.test2$ (a int); drop table test_$1.test2$; drop database test_$1; ---error 1279 +--error 1103 create table `` (a int); ---error 1279 +--error 1103 drop table if exists ``; ---error 1279 +--error 1166 create table t1 (`` int); --error 1279 create table t1 (i int, index `` (i)); @@ -262,7 +262,7 @@ create table non_existing_database.t1 like t1; create table t3 like non_existing_table; --error 1050 create temporary table t3 like t1; ---error 1279 +--error 1103 create table t3 like `a/a`; drop table t1, t2, t3; drop table t3; diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test index a1549f952e5..7b44439aa50 100644 --- a/mysql-test/t/ctype_many.test +++ b/mysql-test/t/ctype_many.test @@ -16,7 +16,7 @@ ALTER TABLE t1 CHANGE comment comment CHAR(32) CHARACTER SET latin2 NOT NULL; SHOW CREATE TABLE t1; ALTER TABLE t1 ADD latin5_f CHAR(32) NOT NULL; SHOW CREATE TABLE t1; -ALTER TABLE t1 CHARSET=latin2; +ALTER TABLE t1 DEFAULT CHARSET=latin2; ALTER TABLE t1 ADD latin2_f CHAR(32) NOT NULL; SHOW CREATE TABLE t1; ALTER TABLE t1 DROP latin2_f, DROP latin5_f; diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index f1f751d728b..c529994f31b 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -3,7 +3,7 @@ # --disable_warnings -drop table if exists t1; +drop table if exists t1,t11,t12,t2; --enable_warnings CREATE TABLE t1 (a tinyint(3), b tinyint(5)); INSERT INTO t1 VALUES (1,1); @@ -71,3 +71,30 @@ delete from t1 where 3 > 2; select count(*) from t1; drop table t1; + +# +# IGNORE option +# +create table t11 (a int NOT NULL, b int, primary key (a)); +create table t12 (a int NOT NULL, b int, primary key (a)); +create table t2 (a int NOT NULL, b int, primary key (a)); +insert into t11 values (0, 10),(1, 11),(2, 12); +insert into t12 values (33, 10),(0, 11),(2, 12); +insert into t2 values (1, 21),(2, 12),(3, 23); +select * from t11; +select * from t12; +select * from t2; +-- error 1241 +delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a); +select * from t11; +select * from t12; +delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a); +select * from t11; +select * from t12; +insert into t11 values (2, 12); +-- error 1241 +delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a); +select * from t11; +delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a); +select * from t11; +drop table t11, t12, t2; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index ca881f73a4f..caf673d95c1 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -83,11 +83,11 @@ create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED N insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9); insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105); -SELECT d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; -SELECT d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; -explain SELECT d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; -explain SELECT d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; +explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; drop table t1,t2; # diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 3437e0a1440..a0292740c8d 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -133,9 +133,9 @@ select * from t2 having MATCH inhalt AGAINST ('foobar'); # check of fulltext errors # ---error 1286 +--error 1282 CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i)); ---error 1286 +--error 1282 CREATE TABLE t3 (t int(11),i text, j varchar(200) CHARACTER SET latin2, fulltext tix (i,j)); @@ -245,11 +245,16 @@ INSERT t1 VALUES ('Mit freundlichem Grüß'), ('aus Osnabrück'); SET NAMES koi8r; INSERT t1 VALUES ("üÔÏ ÍÙ - ÏÐÉÌËÉ"),("ïÔÌÅÚØ, ÇÎÉÄÁ!"), ("îÅ ×ÌÅÚÁÊ, ÕÂØÅÔ!"),("É ÂÕÄÅÔ ÐÒÁ×!"); -SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('ïðéìëé'); -SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('ðÒá*' IN BOOLEAN MODE); +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('ïðéìëé'); +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('ðÒá*' IN BOOLEAN MODE); SELECT * FROM t1 WHERE MATCH t AGAINST ('ÜÔÏ' IN BOOLEAN MODE); -SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); SET NAMES latin1; -SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck'); +#alter table t1 modify t text character set latin1 collate latin1_german2_ci not null; +alter table t1 modify t varchar(200) collate latin1_german2_ci not null; +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck'); DROP TABLE t1; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 96bdb547469..f1a24a4c3cb 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -224,6 +224,19 @@ select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1; select date_add(time,INTERVAL 1 SECOND) from t1; drop table t1; +# test for last_day +select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2, + last_day('2003-03-32') as f3, last_day('2003-04-01') as f4, + last_day('2001-01-01 01:01:01') as f5, last_day(NULL), + last_day('2001-02-12'); + +create table t1 select last_day('2000-02-05') as a; +describe t1; +select * from t1; +drop table t1; +select last_day('2000-02-05'); + + # Test SAPDB UTC_% functions. This part is TZ dependant (It is supposed that # TZ variable set to GMT-3 select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index f298b1abf53..3349ea21c45 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -5,7 +5,7 @@ # --disable_warnings -drop table if exists t1,t2,t3; +drop table if exists t1,t2,t3,t4; drop database if exists mysqltest; --enable_warnings diff --git a/mysql-test/t/isam.test b/mysql-test/t/isam.test index a31ba864b2f..e35ed0dfd4a 100644 --- a/mysql-test/t/isam.test +++ b/mysql-test/t/isam.test @@ -12,12 +12,14 @@ create table t1 (a tinyint not null auto_increment, b blob not null, primary key let $1=100; disable_query_log; +--disable_warnings while ($1) { eval insert into t1 (b) values(repeat(char(65+$1),65540-$1)); dec $1; } enable_query_log; +--enable_warnings delete from t1 where (a & 1); select sum(length(b)) from t1; drop table t1; diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index e8977ae9b62..8cef925cc24 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -112,7 +112,7 @@ drop table t1, t2; create table t1 (a int primary key); insert into t1 values(1),(2); select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a); ---replace_result "31 tables" "XX tables" "62 tables" "XX tables" +--replace_result "31 tables" "XX tables" "61 tables" "XX tables" --error 1116 select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a); drop table t1; diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test index 371d610eb5f..a3b8bca847d 100644 --- a/mysql-test/t/key_cache.test +++ b/mysql-test/t/key_cache.test @@ -1,6 +1,9 @@ # # Test of multiple key caches # +--disable_warnings +drop table if exists t1, t2, t3; +--enable_warnings SET @save_key_buffer=@@key_buffer_size; @@ -58,12 +61,9 @@ select @@keycache1.key_cache_block_size; select @@key_buffer_size; select @@key_cache_block_size; +set global keycache1.key_buffer_size=1024*1024; ---disable_warnings -drop table if exists t1, t2; ---enable_warnings - -create table t1 (p int primary key, a char(10)); +create table t1 (p int primary key, a char(10)) delay_key_write=1; create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a)); insert into t1 values (1, 'qqqq'), (11, 'yyyy'); @@ -75,7 +75,7 @@ select * from t2; update t1 set p=2 where p=1; update t2 set i=2 where i=1; -cache index t1 keys in keycache1; +cache index t1 keys (`primary`) in keycache1; explain select p from t1; select p from t1; @@ -84,11 +84,11 @@ select i from t2; explain select count(*) from t1, t2 where t1.p = t2.i; select count(*) from t1, t2 where t1.p = t2.i; -cache index t2 keys in keycache1; +cache index t2 in keycache1; update t2 set p=p+1000, i=2 where a='qqqq'; -cache index t2 keys in keycache2; +cache index t2 in keycache2; insert into t2 values (2000, 3, 'yyyy'); -cache index t2 keys in keycache1; +cache index t2 in keycache1; update t2 set p=3000 where a='zzzz'; select * from t2; explain select p from t2; @@ -98,12 +98,18 @@ select i from t2; explain select a from t2; select a from t2; +# Test some error conditions +--error 1283 +cache index t1 in unknown_key_cache; +cache index t1 keys (unknown_key) in keycache1; + select @@keycache2.key_buffer_size; select @@keycache2.key_cache_block_size; set global keycache2.key_buffer_size=0; select @@keycache2.key_buffer_size; select @@keycache2.key_cache_block_size; - +set global keycache2.key_buffer_size=1024*1024; +select @@keycache2.key_buffer_size; update t2 set p=4000 where a='zzzz'; update t1 set p=p+1; @@ -119,4 +125,14 @@ select a from t2; select * from t1; select p from t1; +# Use the 'small' key cache +create table t3 (like t1); +cache index t3 in small; +insert into t3 select * from t1; +cache index t3 in keycache2; +cache index t1,t2 in default; +drop table t1,t2,t3; +# Cleanup +# We don't reset keycache2 as we want to ensure that mysqld will reset it +set global keycache1.key_buffer_size=0; diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test index 314587feda6..26f7cbf22a0 100644 --- a/mysql-test/t/mix_innodb_myisam_binlog.test +++ b/mysql-test/t/mix_innodb_myisam_binlog.test @@ -3,7 +3,7 @@ # It would be nice to make this a replication test, but in 4.0 the # slave is always with --skip-innodb in the testsuite. I (Guilhem) however # did some tests manually on a slave; tables are replicated fine and -# Exec_master_log_pos advances as expected. +# Exec_Master_Log_Pos advances as expected. -- source include/have_innodb.inc diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 6b59778bbce..b3c742e0b30 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -275,3 +275,38 @@ insert into t2 values (1,1), (3,1); update t1 left join t2 on t1.a=t2.a set t1.b=2, t2.b=2 where t1.b=1 and t2.b=1 or t2.a is NULL; select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and t2.b=1 or t2.a is NULL; drop table t1,t2; + +# +# Test for bug #1820. +# + +create table t1 ( a int not null, b int not null) ; +--disable_query_log +insert into t1 values (1,1),(2,2),(3,3),(4,4); +let $1=19; +set @d=4; +while ($1) +{ + eval insert into t1 select a+@d,b+@d from t1; + eval set @d=@d*2; + dec $1; +} + +--enable_query_log +alter table t1 add index i1(a); +delete from t1 where a > 2000000; +create table t2 like t1; +insert into t2 select * from t1; + +select 't2 rows before small delete', count(*) from t1; +delete t1,t2 from t1,t2 where t1.b=t2.a and t1.a < 2; +select 't2 rows after small delete', count(*) from t2; +select 't1 rows after small delete', count(*) from t1; + +## Try deleting many rows + +delete t1,t2 from t1,t2 where t1.b=t2.a and t1.a < 100*1000; +select 't2 rows after big delete', count(*) from t2; +select 't1 rows after big delete', count(*) from t1; + +#drop table t1,t2; diff --git a/mysql-test/t/overflow.test b/mysql-test/t/overflow.test index 7a9616fd24e..17e443d51f8 100644 --- a/mysql-test/t/overflow.test +++ b/mysql-test/t/overflow.test @@ -1,4 +1,4 @@ connect (con1,localhost,boo,,); connection con1; --- error 1064,1102,1279 +-- error 1064,1102,1280 drop database AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA; diff --git a/mysql-test/t/preload.test b/mysql-test/t/preload.test index 7357b42c599..7eff5cee08f 100644 --- a/mysql-test/t/preload.test +++ b/mysql-test/t/preload.test @@ -63,7 +63,7 @@ show status like "key_read%"; flush tables; flush status; select @@preload_buffer_size; -load index into cache t1 keys; +load index into cache t1; show status like "key_read%"; select count(*) from t1 where b = 'test1'; show status like "key_read%"; @@ -72,7 +72,7 @@ flush tables; flush status; show status like "key_read%"; set session preload_buffer_size=256*1024; select @@preload_buffer_size; -load index into cache t1 keys ignore leaves; +load index into cache t1 ignore leaves; show status like "key_read%"; select count(*) from t1 where b = 'test1'; show status like "key_read%"; @@ -81,7 +81,7 @@ flush tables; flush status; show status like "key_read%"; set session preload_buffer_size=1*1024; select @@preload_buffer_size; -load index into cache t1 keys, t2 keys (primary,b) ignore leaves; +load index into cache t1, t2 keys (primary,b) ignore leaves; show status like "key_read%"; select count(*) from t1 where b = 'test1'; select count(*) from t2 where b = 'test1'; @@ -89,7 +89,7 @@ show status like "key_read%"; flush tables; flush status; show status like "key_read%"; -load index into cache t3 keys, t2 keys (primary,b) ; +load index into cache t3, t2 keys (primary,b) ; show status like "key_read%"; flush tables; flush status; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 65ba2ee6671..75cbb756998 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -223,7 +223,7 @@ INSERT INTO t1 VALUES (21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), (33,5),(33,5),(33,5),(33,5),(34,5),(35,5); -# we expect that optimizer will choose key on A +# we expect that optimizer will choose index on A EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; SELECT * FROM t1 WHERE a IN(1,2) AND b=5; diff --git a/mysql-test/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test new file mode 100644 index 00000000000..33fc2d75dd3 --- /dev/null +++ b/mysql-test/t/rpl_change_master.test @@ -0,0 +1,28 @@ +source include/master-slave.inc; + +connection slave; +select get_lock("a",5); +connection master; +create table t1(n int); +insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(2); +save_master_pos; +connection slave; +sleep 3; # can't sync_with_master as we should be blocked +stop slave; +select * from t1; +--replace_column 1 # 33 # +show slave status; +change master to master_user='root'; +--replace_column 1 # 33 # +show slave status; +# Will restart from after the values(2), which is bug +select release_lock("a"); +start slave; +sync_with_master; +select * from t1; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; diff --git a/mysql-test/t/rpl_max_relay_size.test b/mysql-test/t/rpl_max_relay_size.test index 99f0a9fdde6..a28aed52ec8 100644 --- a/mysql-test/t/rpl_max_relay_size.test +++ b/mysql-test/t/rpl_max_relay_size.test @@ -76,7 +76,7 @@ sync_with_master; --replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT --replace_column 1 # 33 # show slave status; -# one more rotation, to be sure Relay_log_space is correctly updated +# one more rotation, to be sure Relay_Log_Space is correctly updated flush logs; connection master; drop table t1; diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 78213c6a750..7560d56af1c 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -101,7 +101,8 @@ show master logs; # we just tests if synonyms are accepted purge binary logs to 'master-bin.000002'; show binary logs; ---sleep 1; +# sleeping 10 seconds or more would make the slave believe connection is down +--real_sleep 1; purge master logs before now(); show binary logs; insert into t2 values (65); diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index f356e7931c8..75ca521d24e 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1008,4 +1008,4 @@ CREATE TABLE t2(COLA FLOAT NOT NULL,COLB FLOAT NOT NULL,COLC CHAR(1) NOT NULL,PR INSERT INTO t1 VALUES (1,1,'1A3240'), (1,2,'4W2365'); INSERT INTO t2 VALUES (100, 200, 'C'); SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1); -DROP TABLE t1, t2;s +DROP TABLE t1, t2; diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index 4be0cd0c6a2..f618c342936 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -65,7 +65,7 @@ drop table t1; # disable_query_log; ---error 1279,1279 +--error 1103,1103 create table t1 (a int not null auto_increment, b char(16) not null, primary key (a)) type=myisam data directory="tmp"; # Check that we cannot link over a table from another database. @@ -75,7 +75,7 @@ create database mysqltest; --error 1,1 create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) type=myisam index directory="/this-dir-does-not-exist"; ---error 1279,1279 +--error 1103,1103 create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) type=myisam index directory="not-hard-path"; --error 1,1 diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 1f3f4085734..3cfdc14b0b8 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -280,7 +280,7 @@ explain extended (select * from t1 where a=1) union (select * from t2 where a=1) (select * from t1 where a=5 and a=6) union (select * from t2 where a=1); (select t1.a,t1.b from t1,t2 where t1.a=5) union (select * from t2 where a=1); (select * from t1 where a=1) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a); -explain (select * from t1 where a=1 and b=10) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a); +explain (select * from t1 where a=1 and b=10) union (select straight_join t1.a,t2.a from t1,t2 where t1.a=t2.a); explain (select * from t1 where a=1) union (select * from t1 where b=1); drop table t1,t2; create table t1 ( id int not null auto_increment, primary key (id) ,user_name text ); diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index 8fe48641fed..39742d20c7c 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -60,3 +60,14 @@ drop table t1; # just for fun :) select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b; + +# +# bug#1739 +# Item_func_set_user_var sets update_query_id, Item_func_get_user_var checks it +# +create table t1 (i int not null); +insert t1 values (1),(2),(2),(3),(3),(3); +select @a:=0; select @a, @a:=@a+count(*), count(*), @a from t1 group by i; +select @a:=0; select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i; +drop table t1; + diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 37c79e28395..bd508b8de12 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -29,7 +29,7 @@ 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_dup.c my_seek.c my_read.c \ my_pread.c my_write.c \ - mf_keycache.c my_crc32.c \ + mf_keycache.c mf_keycaches.c my_crc32.c \ mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \ mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \ my_malloc.c my_realloc.c my_once.c mulalloc.c \ diff --git a/mysys/default.c b/mysys/default.c index b1d9e40a1c2..3a751eb4e29 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -251,6 +251,7 @@ int load_defaults(const char *conf_file, const char **groups, err: fprintf(stderr,"Fatal error in defaults handling. Program aborted\n"); exit(1); + return 0; /* Keep compiler happy */ } diff --git a/mysys/hash.c b/mysys/hash.c index b0ddbd90794..665e3d11e8d 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -29,6 +29,11 @@ #define HIGHFIND 4 #define HIGHUSED 8 +typedef struct st_hash_info { + uint next; /* index to next key */ + byte *data; /* data for current entry */ +} HASH_LINK; + static uint hash_mask(uint hashnr,uint buffmax,uint maxlength); static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink); static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length); @@ -53,7 +58,7 @@ _hash_init(HASH *hash,CHARSET_INFO *charset, if (my_init_dynamic_array_ci(&hash->array,sizeof(HASH_LINK),size,0)) { hash->free=0; /* Allow call to hash_free */ - DBUG_RETURN(TRUE); + DBUG_RETURN(1); } hash->key_offset=key_offset; hash->key_length=key_length; diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 2f5a704234d..b1ef03fdcd2 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -15,14 +15,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* - These functions are to handle keyblock cacheing - for NISAM, MISAM and PISAM databases. + These functions handle keyblock cacheing for ISAM and MyISAM tables. + One cache can handle many files. It must contain buffers of the same blocksize. init_key_cache() should be used to init cache handler. */ #include "mysys_priv.h" +#include <keycache.h> #include "my_static.h" #include <m_string.h> #include <errno.h> @@ -85,28 +86,22 @@ typedef pthread_cond_t KEYCACHE_CONDVAR; -/* info about requests in a waiting queue */ -typedef struct st_keycache_wqueue -{ - struct st_my_thread_var *last_thread; /* circular list of waiting threads */ -} KEYCACHE_WQUEUE; - /* descriptor of the page in the key cache block buffer */ -typedef struct st_keycache_page +struct st_keycache_page { int file; /* file to which the page belongs to */ my_off_t filepos; /* position of the page in the file */ -} KEYCACHE_PAGE; +}; /* element in the chain of a hash table bucket */ -typedef struct st_hash_link +struct st_hash_link { struct st_hash_link *next, **prev; /* to connect links in the same bucket */ struct st_block_link *block; /* reference to the block for the page: */ File file; /* from such a file */ my_off_t diskpos; /* with such an offset */ uint requests; /* number of requests for the page */ -} HASH_LINK; /* offset is always alighed for key_cache_block_size */ +}; /* simple states of a block */ #define BLOCK_ERROR 1 /* an error occured when performing disk i/o */ @@ -122,7 +117,7 @@ typedef struct st_hash_link #define PAGE_WAIT_TO_BE_READ 2 /* key cache block */ -typedef struct st_block_link +struct st_block_link { struct st_block_link *next_used, **prev_used; /* to connect links in the LRU chain (ring) */ @@ -138,53 +133,15 @@ typedef struct st_block_link uint hits_left; /* number of hits left until promotion */ ulonglong last_hit_time; /* timestamp of the last hit */ KEYCACHE_CONDVAR *condvar; /* condition variable for 'no readers' event */ -} BLOCK_LINK; - -KEY_CACHE_VAR dflt_key_cache_var= -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -KEY_CACHE_HANDLE *dflt_keycache= &dflt_key_cache_var.cache; -#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */ +KEY_CACHE dflt_key_cache_var; +KEY_CACHE *dflt_key_cache= &dflt_key_cache_var; + #define FLUSH_CACHE 2000 /* sort this many blocks at once */ -typedef struct st_key_cache -{ - KEY_CACHE_VAR *env; /* pointer to key cache variables (if any) */ - my_bool key_cache_inited; - uint key_cache_shift; - ulong key_cache_mem_size; /* specified size of the cache memory */ - uint key_cache_block_size; /* size of the page buffer of a cache block */ - ulong min_warm_blocks; /* min number of warm blocks; */ - ulong age_threshold; /* age threshold for hot blocks */ - ulonglong keycache_time; /* total number of block link operations */ - uint hash_entries; /* max number of entries in the hash table */ - int hash_links; /* max number of hash links */ - int hash_links_used; /* number of hash links currently used */ - int disk_blocks; /* max number of blocks in the cache */ - ulong blocks_used; /* number of currently used blocks */ - ulong blocks_changed; /* number of currently dirty blocks */ - ulong warm_blocks; /* number of blocks in warm sub-chain */ -#if defined(KEYCACHE_DEBUG) - long blocks_available; /* number of blocks available in the LRU chain */ -#endif - HASH_LINK **hash_root; /* arr. of entries into hash table buckets */ - HASH_LINK *hash_link_root; /* memory for hash table links */ - HASH_LINK *free_hash_list; /* list of free hash links */ - BLOCK_LINK *block_root; /* memory for block links */ - byte HUGE_PTR *block_mem; /* memory for block buffers */ - BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */ - BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */ - pthread_mutex_t cache_lock; /* to lock access to the cache structure */ - KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */ - KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */ - BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/ - BLOCK_LINK *file_blocks[CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/ -} KEY_CACHE; - -static int flush_all_key_blocks(KEY_CACHE_HANDLE keycache); -static void test_key_cache(KEY_CACHE *keycache, +static int flush_all_key_blocks(KEY_CACHE *keycache); +static void test_key_cache(KEY_CACHE *keycache, const char *where, my_bool lock); #define KEYCACHE_HASH(f, pos) \ @@ -202,10 +159,10 @@ static void test_key_cache(KEY_CACHE *keycache, static FILE *keycache_debug_log=NULL; static void keycache_debug_print _VARARGS((const char *fmt,...)); #define KEYCACHE_DEBUG_OPEN \ - keycache_debug_log=fopen(KEYCACHE_DEBUG_LOG, "w") + if (!keycache_debug_log) keycache_debug_log=fopen(KEYCACHE_DEBUG_LOG, "w") #define KEYCACHE_DEBUG_CLOSE \ - if (keycache_debug_log) fclose(keycache_debug_log) + if (keycache_debug_log) { fclose(keycache_debug_log); keycache_debug_log=0; } #else #define KEYCACHE_DEBUG_OPEN #define KEYCACHE_DEBUG_CLOSE @@ -283,40 +240,34 @@ static uint next_power(uint value) SYNOPSIS init_ky_cache() - pkeycache in/out pointer to the key cache handle - key_cache_block_size size of blocks to keep cached data - use_mem total memory to use for the key cache - env ref to other parameters of the key cache, if any + keycache pointer to the key cache handle to initialize + key_cache_block_size size of blocks to keep cached data + use_mem total memory to use for the key cache + division_limit division limit (may be zero) + age_threshold age threshold (may be zero) RETURN VALUE number of blocks in the key cache, if successful, 0 - otherwise. NOTES. - If pkeycache points to an undefined handle (NULL), a new KEY_CACHE - data structure is created and a pointer to it is returned as a new - key cache handle, otherwise *pkeycache is considered as a reused - handle for a key cache with new blocks. + if keycache->key_cache_inited != 0 we assume that the key cache + is already initialized. This is for now used by myisamchk, but shouldn't + be something that a program should rely on! + It's assumed that no two threads call this function simultaneously referring to the same key cache handle. - + */ -int init_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, - ulong use_mem, KEY_CACHE_VAR *env) +int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, + ulong use_mem, uint division_limit, + uint age_threshold) { uint blocks, hash_links, length; int error; - KEY_CACHE *keycache; - DBUG_ENTER("init_key_cache"); - - if (!(keycache= (KEY_CACHE *) *pkeycache) && - !(keycache= (KEY_CACHE *) my_malloc(sizeof(KEY_CACHE), - MYF(MY_ZEROFILL)))) - DBUG_RETURN(0); - - keycache->env= env; + DBUG_ASSERT(key_cache_block_size >= 512); KEYCACHE_DEBUG_OPEN; if (keycache->key_cache_inited && keycache->disk_blocks > 0) @@ -324,38 +275,25 @@ int init_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, DBUG_PRINT("warning",("key cache already in use")); DBUG_RETURN(0); } - if (env && ! keycache->key_cache_inited) - { - env->cache_w_requests= env->cache_r_requests= 0; - env->cache_read= env->cache_write=0; - } + keycache->global_cache_w_requests= keycache->global_cache_r_requests= 0; + keycache->global_cache_read= keycache->global_cache_write= 0; + keycache->disk_blocks= -1; if (! keycache->key_cache_inited) { - keycache->key_cache_inited= TRUE; - keycache->disk_blocks= -1; + keycache->key_cache_inited= 1; + keycache->in_init= 0; pthread_mutex_init(&keycache->cache_lock, MY_MUTEX_INIT_FAST); - keycache->key_cache_shift= my_bit_log2(key_cache_block_size); - keycache->key_cache_mem_size= use_mem; - keycache->key_cache_block_size= key_cache_block_size; - DBUG_PRINT("info", ("key_cache_block_size: %u", - key_cache_block_size)); } - - /* - These are safety deallocations: actually we always call the - function after having called end_key_cache that deallocates - these memory itself. - */ - if (keycache->block_mem) - my_free_lock((gptr) keycache->block_mem, MYF(0)); - keycache->block_mem= NULL; - if (keycache->block_root) - my_free((gptr) keycache->block_root, MYF(0)); - keycache->block_root= NULL; + + keycache->key_cache_mem_size= use_mem; + keycache->key_cache_block_size= key_cache_block_size; + keycache->key_cache_shift= my_bit_log2(key_cache_block_size); + DBUG_PRINT("info", ("key_cache_block_size: %u", + key_cache_block_size)); blocks= (uint) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) + - sizeof(HASH_LINK*) * 5/4 + key_cache_block_size)); + sizeof(HASH_LINK*) * 5/4 + key_cache_block_size)); /* It doesn't make sense to have too few blocks (less than 8) */ if (blocks >= 8 && keycache->disk_blocks < 0) { @@ -371,18 +309,18 @@ int init_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, #endif while ((length= (ALIGN_SIZE(blocks * sizeof(BLOCK_LINK)) + ALIGN_SIZE(hash_links * sizeof(HASH_LINK)) + - ALIGN_SIZE(sizeof(HASH_LINK*) * + ALIGN_SIZE(sizeof(HASH_LINK*) * keycache->hash_entries))) + ((ulong) blocks << keycache->key_cache_shift) > use_mem) blocks--; /* Allocate memory for cache page buffers */ - if ((keycache->block_mem= - my_malloc_lock((ulong) blocks * keycache->key_cache_block_size, - MYF(0)))) + if ((keycache->block_mem= + my_malloc_lock((ulong) blocks * keycache->key_cache_block_size, + MYF(0)))) { /* - Allocate memory for blocks, hash_links and hash entries; - For each block 2 hash links are allocated + Allocate memory for blocks, hash_links and hash entries; + For each block 2 hash links are allocated */ if ((keycache->block_root= (BLOCK_LINK*) my_malloc((uint) length, MYF(0)))) @@ -402,57 +340,53 @@ int init_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, ALIGN_SIZE(blocks*sizeof(BLOCK_LINK))); keycache->hash_link_root= (HASH_LINK*) ((char*) keycache->hash_root + ALIGN_SIZE((sizeof(HASH_LINK*) * - keycache->hash_entries))); + keycache->hash_entries))); bzero((byte*) keycache->block_root, - keycache->disk_blocks * sizeof(BLOCK_LINK)); + keycache->disk_blocks * sizeof(BLOCK_LINK)); bzero((byte*) keycache->hash_root, keycache->hash_entries * sizeof(HASH_LINK*)); bzero((byte*) keycache->hash_link_root, - keycache->hash_links * sizeof(HASH_LINK)); + keycache->hash_links * sizeof(HASH_LINK)); keycache->hash_links_used= 0; keycache->free_hash_list= NULL; keycache->blocks_used= keycache->blocks_changed= 0; - if (env) - env->blocks_used= env->blocks_changed= 0; -#if defined(KEYCACHE_DEBUG) - keycache->blocks_available=0; -#endif + + keycache->global_blocks_used= keycache->global_blocks_changed= 0; + keycache->blocks_available=0; /* For debugging */ + /* The LRU chain is empty after initialization */ keycache->used_last= NULL; keycache->used_ins= NULL; keycache->keycache_time= 0; keycache->warm_blocks= 0; - keycache->min_warm_blocks= env && env->division_limit ? - blocks * env->division_limit / 100 + 1 : - blocks; - keycache->age_threshold= env && env->age_threshold ? - blocks * env->age_threshold / 100 : - blocks; + keycache->min_warm_blocks= (division_limit ? + blocks * division_limit / 100 + 1 : + blocks); + keycache->age_threshold= (age_threshold ? + blocks * age_threshold / 100 : + blocks); keycache->waiting_for_hash_link.last_thread= NULL; keycache->waiting_for_block.last_thread= NULL; DBUG_PRINT("exit", - ("disk_blocks: %d block_root: %lx hash_entries: %d hash_root: %lx \ + ("disk_blocks: %d block_root: %lx hash_entries: %d hash_root: %lx \ hash_links: %d hash_link_root %lx", - keycache->disk_blocks, keycache->block_root, - keycache->hash_entries, keycache->hash_root, - keycache->hash_links, keycache->hash_link_root)); + keycache->disk_blocks, keycache->block_root, + keycache->hash_entries, keycache->hash_root, + keycache->hash_links, keycache->hash_link_root)); + bzero((gptr) keycache->changed_blocks, + sizeof(keycache->changed_blocks[0]) * CHANGED_BLOCKS_HASH); + bzero((gptr) keycache->file_blocks, + sizeof(keycache->file_blocks[0]) * CHANGED_BLOCKS_HASH); } - bzero((gptr) keycache->changed_blocks, - sizeof(keycache->changed_blocks[0]) * CHANGED_BLOCKS_HASH); - bzero((gptr) keycache->file_blocks, - sizeof(keycache->file_blocks[0]) * CHANGED_BLOCKS_HASH); - - if (env) - env->blocks= keycache->disk_blocks > 0 ? keycache->disk_blocks : 0; - *pkeycache= keycache; + + keycache->blocks= keycache->disk_blocks > 0 ? keycache->disk_blocks : 0; DBUG_RETURN((int) blocks); err: error= my_errno; keycache->disk_blocks= 0; - if (env) - env->blocks= 0; + keycache->blocks= 0; if (keycache->block_mem) { my_free_lock((gptr) keycache->block_mem, MYF(0)); @@ -473,9 +407,11 @@ err: SYNOPSIS resize_key_cache() - pkeycache in/out pointer to the key cache handle - key_cache_block_size size of blocks to keep cached data - use_mem total memory to use for the new key cache + keycache in/out key cache handle + key_cache_block_size size of blocks to keep cached data + use_mem total memory to use for the new key cache + division_limit new division limit (if not zero) + age_threshold new age threshold (if not zero) RETURN VALUE number of blocks in the key cache, if successful, @@ -483,44 +419,50 @@ err: NOTES. The function first compares the memory size and the block size parameters - with the corresponding parameters of the key cache referred by - *pkeycache. If they differ the function free the the memory allocated - for the old key cache blocks by calling the end_key_cache function - and then rebuilds the key cache with new blocks by calling init_key_cache. + with the key cache values. + + If they differ the function free the the memory allocated for the + old key cache blocks by calling the end_key_cache function and + then rebuilds the key cache with new blocks by calling + init_key_cache. */ -int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, - ulong use_mem) +int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, + ulong use_mem, uint division_limit, + uint age_threshold) { int blocks; - KEY_CACHE *keycache= *pkeycache; + DBUG_ENTER("resize_key_cache"); - if (key_cache_block_size == keycache->key_cache_block_size && - use_mem == keycache->key_cache_mem_size) - return keycache->disk_blocks; + if (!keycache->key_cache_inited || + (key_cache_block_size == keycache->key_cache_block_size && + use_mem == keycache->key_cache_mem_size)) + DBUG_RETURN(keycache->disk_blocks); keycache_pthread_mutex_lock(&keycache->cache_lock); if (flush_all_key_blocks(keycache)) { /* TODO: if this happens, we should write a warning in the log file ! */ keycache_pthread_mutex_unlock(&keycache->cache_lock); - return 0; + DBUG_RETURN(0); } + end_key_cache(keycache, 0); /* Don't free mutex */ + /* the following will work even if use_mem is 0 */ + blocks= init_key_cache(keycache, key_cache_block_size, use_mem, + division_limit, age_threshold); keycache_pthread_mutex_unlock(&keycache->cache_lock); - end_key_cache(pkeycache, 0); - /* the following will work even if memory is 0 */ - blocks=init_key_cache(pkeycache, key_cache_block_size, use_mem, - keycache->env); return blocks; } /* - Change the key cache parameters + Change the key cache parameters SYNOPSIS change_key_cache_param() - keycache the key cache handle + keycache key cache handle + division_limit new division limit (if not zero) + age_threshold new age threshold (if not zero) RETURN VALUE none @@ -528,23 +470,20 @@ int resize_key_cache(KEY_CACHE_HANDLE *pkeycache, uint key_cache_block_size, NOTES. Presently the function resets the key cache parameters concerning midpoint insertion strategy - division_limit and - age_threshold. It corresponding values are passed through - the keycache->env structure. + age_threshold. */ -void change_key_cache_param(KEY_CACHE_HANDLE keycache) +void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, + uint age_threshold) { - KEY_CACHE_VAR *env= keycache->env; DBUG_ENTER("change_key_cache_param"); - if (!env) - return; - if (env->division_limit) - keycache->min_warm_blocks= keycache->disk_blocks * - env->division_limit / 100 + 1; - if (env->age_threshold) - keycache->age_threshold= keycache->disk_blocks * - env->age_threshold / 100; + if (division_limit) + keycache->min_warm_blocks= (keycache->disk_blocks * + division_limit / 100 + 1); + if (age_threshold) + keycache->age_threshold= (keycache->disk_blocks * + age_threshold / 100); DBUG_VOID_RETURN; } @@ -554,23 +493,21 @@ void change_key_cache_param(KEY_CACHE_HANDLE keycache) SYNOPSIS end_key_cache() - pkeycache in/out pointer to the key cache handle - cleanup <-> the key cache data structure is freed as well + keycache key cache handle + cleanup Complete free (Free also mutex for key cache) RETURN VALUE none - - NOTES. - If the cleanup parameter is TRUE the data structure with all associated - elements are freed completely and NULL is assigned to *pkeycache. - Otherwise only memory used by the key cache blocks is freed. */ -void end_key_cache(KEY_CACHE_HANDLE *pkeycache, my_bool cleanup) +void end_key_cache(KEY_CACHE *keycache, my_bool cleanup) { - KEY_CACHE *keycache= *pkeycache; - KEY_CACHE_VAR *env= keycache->env; DBUG_ENTER("end_key_cache"); + DBUG_PRINT("enter", ("key_cache: %lx", keycache)); + + if (!keycache->key_cache_inited) + DBUG_VOID_RETURN; + if (keycache->disk_blocks > 0) { if (keycache->block_mem) @@ -581,21 +518,22 @@ void end_key_cache(KEY_CACHE_HANDLE *pkeycache, my_bool cleanup) keycache->block_root= NULL; } keycache->disk_blocks= -1; + /* Reset blocks_changed to be safe if flush_all_key_blocks is called */ + keycache->blocks_changed= 0; } - KEYCACHE_DEBUG_CLOSE; - keycache->key_cache_inited= 0; - if (env) - DBUG_PRINT("status", - ("used: %d changed: %d w_requests: %ld \ - writes: %ld r_requests: %ld reads: %ld", - env->blocks_used, env->blocks_changed, - env->cache_w_requests, env->cache_write, - env->cache_r_requests, env->cache_read)); + + DBUG_PRINT("status", + ("used: %d changed: %d w_requests: %ld \ +writes: %ld r_requests: %ld reads: %ld", + keycache->global_blocks_used, keycache->global_blocks_changed, + keycache->global_cache_w_requests, keycache->global_cache_write, + keycache->global_cache_r_requests, keycache->global_cache_read)); + if (cleanup) { pthread_mutex_destroy(&keycache->cache_lock); - my_free((gptr) *pkeycache, MYF(0)); - *pkeycache= NULL; + keycache->key_cache_inited= 0; + KEYCACHE_DEBUG_CLOSE; } DBUG_VOID_RETURN; } /* end_key_cache */ @@ -606,8 +544,8 @@ void end_key_cache(KEY_CACHE_HANDLE *pkeycache, my_bool cleanup) SYNOPSIS link_into_queue() - wqueue pointer to the queue structure - thread pointer to the thread to be added to the queue + wqueue pointer to the queue structure + thread pointer to the thread to be added to the queue RETURN VALUE none @@ -643,8 +581,8 @@ static inline void link_into_queue(KEYCACHE_WQUEUE *wqueue, SYNOPSIS unlink_from_queue() - wqueue pointer to the queue structure - thread pointer to the thread to be removed from the queue + wqueue pointer to the queue structure + thread pointer to the thread to be removed from the queue RETURN VALUE none @@ -677,8 +615,8 @@ static inline void unlink_from_queue(KEYCACHE_WQUEUE *wqueue, SYNOPSIS add_to_queue() - wqueue pointer to the queue structure - thread pointer to the thread to be added to the queue + wqueue pointer to the queue structure + thread pointer to the thread to be added to the queue RETURN VALUE none @@ -709,8 +647,8 @@ static inline void add_to_queue(KEYCACHE_WQUEUE *wqueue, SYNOPSIS realease_queue() - wqueue pointer to the queue structure - thread pointer to the thread to be added to the queue + wqueue pointer to the queue structure + thread pointer to the thread to be added to the queue RETURN VALUE none @@ -718,7 +656,7 @@ static inline void add_to_queue(KEYCACHE_WQUEUE *wqueue, NOTES. See notes for add_to_queue When removed from the queue each thread is signaled via condition - variable thread->suspend. + variable thread->suspend. */ static void release_queue(KEYCACHE_WQUEUE *wqueue) @@ -779,8 +717,7 @@ static void link_to_file_list(KEY_CACHE *keycache, { block->status&= ~BLOCK_CHANGED; keycache->blocks_changed--; - if (keycache->env) - keycache->env->blocks_changed--; + keycache->global_blocks_changed--; } } @@ -798,8 +735,7 @@ static inline void link_to_changed_list(KEY_CACHE *keycache, &keycache->changed_blocks[FILE_HASH(block->hash_link->file)]); block->status|=BLOCK_CHANGED; keycache->blocks_changed++; - if (keycache->env) - keycache->env->blocks_changed++; + keycache->global_blocks_changed++; } @@ -809,7 +745,7 @@ static inline void link_to_changed_list(KEY_CACHE *keycache, SYNOPSIS link_block() - keycache pointer to a key cache data structure + keycache pointer to a key cache data structure block pointer to the block to link to the LRU chain hot <-> to link the block into the hot subchain at_end <-> to link the block at the end of the subchain @@ -818,11 +754,11 @@ static inline void link_to_changed_list(KEY_CACHE *keycache, none NOTES. - The LRU chain is represented by a curcular list of block structures. - The list is double-linked of the type (**prev,*next) type. - The LRU chain is divided into two parts - hot and warm. + The LRU chain is represented by a curcular list of block structures. + The list is double-linked of the type (**prev,*next) type. + The LRU chain is divided into two parts - hot and warm. There are two pointers to access the last blocks of these two - parts. The beginning of the warm part follows right after the + parts. The beginning of the warm part follows right after the end of the hot part. Only blocks of the warm part can be used for replacement. The first block from the beginning of this subchain is always @@ -836,12 +772,12 @@ static inline void link_to_changed_list(KEY_CACHE *keycache, | +------+ W A R M +------+ | +----| beg |---->...----| end |----+ +------+ +------+ins - first for eviction + first for eviction */ static void link_block(KEY_CACHE *keycache, BLOCK_LINK *block, my_bool hot, my_bool at_end) -{ +{ BLOCK_LINK *ins; BLOCK_LINK **pins; @@ -881,7 +817,7 @@ static void link_block(KEY_CACHE *keycache, BLOCK_LINK *block, my_bool hot, return; } pins= hot ? &keycache->used_ins : &keycache->used_last; - ins= *pins; + ins= *pins; if (ins) { ins->next_used->prev_used= &block->next_used; @@ -915,7 +851,7 @@ static void link_block(KEY_CACHE *keycache, BLOCK_LINK *block, my_bool hot, SYNOPSIS unlink_block() - keycache pointer to a key cache data structure + keycache pointer to a key cache data structure block pointer to the block to unlink from the LRU chain RETURN VALUE @@ -938,7 +874,7 @@ static void unlink_block(KEY_CACHE *keycache, BLOCK_LINK *block) keycache->used_last= STRUCT_PTR(BLOCK_LINK, next_used, block->prev_used); if (keycache->used_ins == block) keycache->used_ins=STRUCT_PTR(BLOCK_LINK, next_used, block->prev_used); - } + } block->next_used= NULL; KEYCACHE_THREAD_TRACE("unlink_block"); @@ -972,27 +908,27 @@ static void reg_requests(KEY_CACHE *keycache, BLOCK_LINK *block, int count) SYNOPSIS unreg_block() - keycache pointer to a key cache data structure + keycache pointer to a key cache data structure block pointer to the block to link to the LRU chain at_end <-> to link the block at the end of the LRU chain RETURN VALUE none - NOTES. + NOTES. Every linking to the LRU chain decrements by one a special block counter (if it's positive). If the at_end parameter is TRUE the block is added either at the end of warm sub-chain or at the end of hot sub-chain. - It is added to the hot subchain if its counter is zero and number of - blocks in warm sub-chain is not less than some low limit (determined by + It is added to the hot subchain if its counter is zero and number of + blocks in warm sub-chain is not less than some low limit (determined by the division_limit parameter). Otherwise the block is added to the warm sub-chain. If the at_end parameter is FALSE the block is always added - at beginning of the warm sub-chain. + at beginning of the warm sub-chain. Thus a warm block can be promoted to the hot sub-chain when its counter becomes zero for the first time. At the same time the block at the very beginning of the hot subchain might be moved to the beginning of the warm subchain if it stays untouched - for a too long time (this time is determined by parameter age_threshold). + for a too long time (this time is determined by parameter age_threshold). */ static inline void unreg_request(KEY_CACHE *keycache, @@ -1123,7 +1059,7 @@ static void unlink_hash(KEY_CACHE *keycache, HASH_LINK *hash_link) Get the hash link for a page */ -static HASH_LINK *get_hash_link(KEY_CACHE *keycache, +static HASH_LINK *get_hash_link(KEY_CACHE *keycache, int file, my_off_t filepos) { reg1 HASH_LINK *hash_link, **start; @@ -1206,16 +1142,16 @@ restart: Get a block for the file page requested by a keycache read/write operation; If the page is not in the cache return a free block, if there is none return the lru block after saving its buffer if the page is dirty. - + SYNOPSIS find_key_block() - keycache pointer to a key cache data structure + keycache pointer to a key cache data structure file handler for the file to read page from filepos position of the page in the file init_hits_left how initialize the block counter for the page wrmode <-> get for writing - page_st out {PAGE_READ,PAGE_TO_BE_READ,PAGE_WAIT_TO_BE_READ} + page_st out {PAGE_READ,PAGE_TO_BE_READ,PAGE_WAIT_TO_BE_READ} RETURN VALUE Pointer to the found block if successful, 0 - otherwise @@ -1227,15 +1163,15 @@ restart: If not, the function first chooses a block for this page. If there is no not used blocks in the key cache yet, the function takes the block at the very beginning of the warm sub-chain. It saves the page in that - block if it's dirty before returning the pointer to it. + block if it's dirty before returning the pointer to it. The function returns in the page_st parameter the following values: PAGE_READ - if page already in the block, PAGE_TO_BE_READ - if it is to be read yet by the current thread - WAIT_TO_BE_READ - if it is to be read by another thread + WAIT_TO_BE_READ - if it is to be read by another thread If an error occurs THE BLOCK_ERROR bit is set in the block status. It might happen that there are no blocks in LRU chain (in warm part) - all blocks are unlinked for some read/write operations. Then the function - waits until first of this operations links any block back. + waits until first of this operations links any block back. */ static BLOCK_LINK *find_key_block(KEY_CACHE *keycache, @@ -1321,8 +1257,7 @@ restart: block->offset= keycache->key_cache_block_size; block->requests= 1; keycache->blocks_used++; - if (keycache->env) - keycache->env->blocks_used++; + keycache->global_blocks_used++; keycache->warm_blocks++; block->hits_left= init_hits_left; block->last_hit_time= 0; @@ -1388,12 +1323,13 @@ restart: The call is thread safe because only the current thread might change the block->hash_link value */ - error=my_pwrite(block->hash_link->file, block->buffer, - block->length, block->hash_link->diskpos, - MYF(MY_NABP | MY_WAIT_IF_FULL)); + error= my_pwrite(block->hash_link->file, + block->buffer+block->offset, + block->length - block->offset, + block->hash_link->diskpos+ block->offset, + MYF(MY_NABP | MY_WAIT_IF_FULL)); keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_write++; + keycache->global_cache_write++; } block->status|= BLOCK_REASSIGNED; @@ -1432,8 +1368,7 @@ restart: PAGE_READ : PAGE_WAIT_TO_BE_READ; } } - if (keycache->env) - keycache->env->cache_read++; + keycache->global_cache_read++; } else { @@ -1465,12 +1400,12 @@ restart: SYNOPSIS read_block() - keycache pointer to a key cache data structure + keycache pointer to a key cache data structure block block to which buffer the data is to be read - read_length size of data to be read - min_length at least so much data must be read - primary <-> the current thread will read the data - + read_length size of data to be read + min_length at least so much data must be read + primary <-> the current thread will read the data + RETURN VALUE None @@ -1551,15 +1486,15 @@ static void read_block(KEY_CACHE *keycache, SYNOPSIS key_cache_read() - keycache pointer to a key cache data structure + keycache pointer to a key cache data structure file handler for the file for the block of data to be read filepos position of the block of data in the file level determines the weight of the data - buff buffer to where the data must be placed + buff buffer to where the data must be placed length length of the buffer - block_length length of the block in the key cache buffer - return_buffer return pointer to the key cache buffer with the data - + block_length length of the block in the key cache buffer + return_buffer return pointer to the key cache buffer with the data + RETURN VALUE Returns address from where the data is placed if sucessful, 0 - otherwise. @@ -1573,13 +1508,15 @@ static void read_block(KEY_CACHE *keycache, have to be a multiple of key_cache_block_size; */ -byte *key_cache_read(KEY_CACHE_HANDLE keycache, +byte *key_cache_read(KEY_CACHE *keycache, File file, my_off_t filepos, int level, byte *buff, uint length, uint block_length __attribute__((unused)), int return_buffer __attribute__((unused))) { int error=0; + uint offset= 0; + byte *start= buff; DBUG_ENTER("key_cache_read"); DBUG_PRINT("enter", ("file %u, filepos %lu, length %u", (uint) file, (ulong) filepos, length)); @@ -1588,32 +1525,35 @@ byte *key_cache_read(KEY_CACHE_HANDLE keycache, { /* Key cache is used */ reg1 BLOCK_LINK *block; - uint offset= (uint) (filepos & (keycache->key_cache_block_size-1)); - byte *start= buff; uint read_length; uint status; int page_st; -#ifndef THREAD - if (block_length > keycache->key_cache_block_size || offset) - return_buffer=0; -#endif - /* Read data in key_cache_block_size increments */ - filepos-= offset; do { + keycache_pthread_mutex_lock(&keycache->cache_lock); + if (keycache->disk_blocks <= 0) /* Resize failed */ + { + keycache_pthread_mutex_unlock(&keycache->cache_lock); + goto no_key_cache; + } read_length= length > keycache->key_cache_block_size ? keycache->key_cache_block_size : length; KEYCACHE_DBUG_ASSERT(read_length > 0); - keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_r_requests++; + offset= (uint) (filepos & (keycache->key_cache_block_size-1)); + filepos-= offset; +#ifndef THREAD + if (block_length > keycache->key_cache_block_size || offset) + return_buffer=0; +#endif + + keycache->global_cache_r_requests++; block=find_key_block(keycache, file, filepos, level, 0, &page_st); if (block->status != BLOCK_ERROR && page_st != PAGE_READ) { /* The requested page is to be read into the block buffer */ - read_block(keycache, block, + read_block(keycache, block, keycache->key_cache_block_size, read_length+offset, (my_bool)(page_st == PAGE_TO_BE_READ)); } @@ -1664,29 +1604,25 @@ byte *key_cache_read(KEY_CACHE_HANDLE keycache, DBUG_RETURN((byte *) 0); #ifndef THREAD + /* This is only true if we where able to read everything in one block */ if (return_buffer) - return (block->buffer); + return (block->buffer); #endif - buff+= read_length; filepos+= read_length; - offset= 0; } while ((length-= read_length)); DBUG_RETURN(start); } - /* Key cache is not used */ - if (keycache->env) - { - statistic_increment(keycache->env->cache_r_requests, - &keycache->cache_lock); - statistic_increment(keycache->env->cache_read, - &keycache->cache_lock); - } - if (my_pread(file, (byte*) buff, length, filepos, MYF(MY_NABP))) +no_key_cache: /* Key cache is not used */ + + /* We can't use mutex here as the key cache may not be initialized */ + keycache->global_cache_r_requests++; + keycache->global_cache_read++; + if (my_pread(file, (byte*) buff, length, filepos+offset, MYF(MY_NABP))) error= 1; - DBUG_RETURN(error? (byte*) 0 : buff); + DBUG_RETURN(error ? (byte*) 0 : start); } @@ -1694,20 +1630,23 @@ byte *key_cache_read(KEY_CACHE_HANDLE keycache, Insert a block of file data from a buffer into key cache SYNOPSIS - key_cache_insert() - keycache pointer to a key cache data structure - file handler for the file to insert data from - filepos position of the block of data in the file to insert - level determines the weight of the data - buff buffer to read data from - length length of the data in the buffer - + keycache pointer to a key cache data structure + file handler for the file to insert data from + filepos position of the block of data in the file to insert + level determines the weight of the data + buff buffer to read data from + length length of the data in the buffer + + NOTES + This is used by MyISAM to move all blocks from a index file to the key + cache + RETURN VALUE 0 if a success, 1 - otherwise. */ -int key_cache_insert(KEY_CACHE_HANDLE keycache, +int key_cache_insert(KEY_CACHE *keycache, File file, my_off_t filepos, int level, byte *buff, uint length) { @@ -1719,20 +1658,27 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache, { /* Key cache is used */ reg1 BLOCK_LINK *block; - uint offset= (uint) (filepos & (keycache->key_cache_block_size-1)); uint read_length; int page_st; + int error; - /* Read data into key cache from buff in key_cache_block_size increments */ - filepos-= offset; do { + uint offset; + keycache_pthread_mutex_lock(&keycache->cache_lock); + if (keycache->disk_blocks <= 0) /* Resize failed */ + { + keycache_pthread_mutex_unlock(&keycache->cache_lock); + DBUG_RETURN(0); + } read_length= length > keycache->key_cache_block_size ? keycache->key_cache_block_size : length; KEYCACHE_DBUG_ASSERT(read_length > 0); - keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_r_requests++; + offset= (uint) (filepos & (keycache->key_cache_block_size-1)); + /* Read data into key cache from buff in key_cache_block_size incr. */ + filepos-= offset; + + keycache->global_cache_r_requests++; block= find_key_block(keycache, file, filepos, level, 0, &page_st); if (block->status != BLOCK_ERROR && page_st != PAGE_READ) { @@ -1761,14 +1707,14 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache, */ unreg_request(keycache, block, 1); + error= (block->status & BLOCK_ERROR); keycache_pthread_mutex_unlock(&keycache->cache_lock); - if (block->status & BLOCK_ERROR) + if (error) DBUG_RETURN(1); buff+= read_length; filepos+= read_length; - offset=0; } while ((length-= read_length)); } @@ -1777,20 +1723,20 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache, /* - Write a buffer into a cached file. - + Write a buffer into a cached file. + SYNOPSIS key_cache_write() - keycache pointer to a key cache data structure + keycache pointer to a key cache data structure file handler for the file to write data to filepos position in the file to write data to level determines the weight of the data - buff buffer with the data + buff buffer with the data length length of the buffer dont_write if is 0 then all dirty pages involved in writing - should have been flushed from key cache - + should have been flushed from key cache + RETURN VALUE 0 if a success, 1 - otherwise. @@ -1798,12 +1744,12 @@ int key_cache_insert(KEY_CACHE_HANDLE keycache, The function copies the data of size length from buff into buffers for key cache blocks that are assigned to contain the portion of the file starting with position filepos. - It ensures that this data is flushed to the file if dont_write is FALSE. + It ensures that this data is flushed to the file if dont_write is FALSE. Filepos must be a multiple of 'block_length', but it doesn't have to be a multiple of key_cache_block_size; */ -int key_cache_write(KEY_CACHE_HANDLE keycache, +int key_cache_write(KEY_CACHE *keycache, File file, my_off_t filepos, int level, byte *buff, uint length, uint block_length __attribute__((unused)), @@ -1811,17 +1757,16 @@ int key_cache_write(KEY_CACHE_HANDLE keycache, { reg1 BLOCK_LINK *block; int error=0; - DBUG_ENTER("key_cache_write"); - DBUG_PRINT("enter", ("file %u, filepos %lu, length %u block_length %u", - (uint) file, (ulong) filepos, length, block_length)); + DBUG_PRINT("enter", + ("file %u filepos %lu length %u block_length %u key_block_length: %u", + (uint) file, (ulong) filepos, length, block_length, + keycache ? keycache->key_cache_block_size : 0)); if (!dont_write) { /* Force writing from buff into disk */ - if (keycache->env) - statistic_increment(keycache->env->cache_write, - &keycache->cache_lock); + keycache->global_cache_write++; if (my_pwrite(file, buff, length, filepos, MYF(MY_NABP | MY_WAIT_IF_FULL))) DBUG_RETURN(1); } @@ -1835,19 +1780,25 @@ int key_cache_write(KEY_CACHE_HANDLE keycache, { /* Key cache is used */ uint read_length; - uint offset= (uint) (filepos & (keycache->key_cache_block_size-1)); int page_st; - /* Write data in key_cache_block_size increments */ - filepos-= offset; do { + uint offset; + keycache_pthread_mutex_lock(&keycache->cache_lock); + if (keycache->disk_blocks <= 0) /* Resize failed */ + { + keycache_pthread_mutex_unlock(&keycache->cache_lock); + goto no_key_cache; + } read_length= length > keycache->key_cache_block_size ? - keycache->key_cache_block_size : length; + keycache->key_cache_block_size : length; KEYCACHE_DBUG_ASSERT(read_length > 0); - keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_w_requests++; + offset= (uint) (filepos & (keycache->key_cache_block_size-1)); + /* Write data in key_cache_block_size increments */ + filepos-= offset; + + keycache->global_cache_w_requests++; block= find_key_block(keycache, file, filepos, level, 1, &page_st); if (block->status != BLOCK_ERROR && page_st != PAGE_READ && (offset || read_length < keycache->key_cache_block_size)) @@ -1872,7 +1823,7 @@ int key_cache_write(KEY_CACHE_HANDLE keycache, if (! (block->status & BLOCK_ERROR)) { if (!(read_length & 511)) - bmove512(block->buffer+offset, buff, read_length); + bmove512(block->buffer+offset, buff, read_length); else memcpy(block->buffer+offset, buff, (size_t) read_length); } @@ -1897,25 +1848,21 @@ int key_cache_write(KEY_CACHE_HANDLE keycache, offset= 0; } while ((length-= read_length)); + goto end; } - else + +no_key_cache: + /* Key cache is not used */ + if (dont_write) { - /* Key cache is not used */ - if (dont_write) - { - if (keycache->env) - { - statistic_increment(keycache->env->cache_w_requests, - &keycache->cache_lock); - statistic_increment(keycache->env->cache_write, - &keycache->cache_lock); - } - if (my_pwrite(file, (byte*) buff, length, filepos, - MYF(MY_NABP | MY_WAIT_IF_FULL))) - error=1; - } + keycache->global_cache_w_requests++; + keycache->global_cache_write++; + if (my_pwrite(file, (byte*) buff, length, filepos, + MYF(MY_NABP | MY_WAIT_IF_FULL))) + error=1; } +end: #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) DBUG_EXECUTE("exec", test_key_cache(keycache, "end of key_cache_write", 1);); @@ -1991,12 +1938,13 @@ static int flush_cached_blocks(KEY_CACHE *keycache, KEYCACHE_DBUG_PRINT("flush_cached_blocks", ("block %u to be flushed", BLOCK_NUMBER(block))); keycache_pthread_mutex_unlock(&keycache->cache_lock); - error= my_pwrite(file, block->buffer+block->offset, block->length, - block->hash_link->diskpos, + error= my_pwrite(file, + block->buffer+block->offset, + block->length - block->offset, + block->hash_link->diskpos+ block->offset, MYF(MY_NABP | MY_WAIT_IF_FULL)); keycache_pthread_mutex_lock(&keycache->cache_lock); - if (keycache->env) - keycache->env->cache_write++; + keycache->global_cache_write++; if (error) { block->status|= BLOCK_ERROR; @@ -2007,8 +1955,7 @@ static int flush_cached_blocks(KEY_CACHE *keycache, if (! (type == FLUSH_KEEP || type == FLUSH_FORCE_WRITE)) { keycache->blocks_changed--; - if (keycache->env) - keycache->env->blocks_changed--; + keycache->global_blocks_changed--; free_block(keycache, block); } else @@ -2024,27 +1971,29 @@ static int flush_cached_blocks(KEY_CACHE *keycache, /* - Flush all blocks for a file to disk - - SYNOPSIS + flush all key blocks for a file to disk, but don't do any mutex locks - flush_key_blocks() - keycache pointer to a key cache data structure + flush_key_blocks_int() + keycache pointer to a key cache data structure file handler for the file to flush to flush_type type of the flush - - RETURN VALUE - 0 if a success, 1 - otherwise. - */ -int flush_key_blocks(KEY_CACHE_HANDLE keycache, - File file, enum flush_type type) + NOTES + This function doesn't do any mutex locks because it needs to be called both + from flush_key_blocks and flush_all_key_blocks (the later one does the + mutex lock in the resize_key_cache() function). + + RETURN + 0 ok + 1 error +*/ + +static int flush_key_blocks_int(KEY_CACHE *keycache, + File file, enum flush_type type) { - KEY_CACHE_VAR *env; BLOCK_LINK *cache_buff[FLUSH_CACHE],**cache; int last_errno= 0; - - DBUG_ENTER("flush_key_blocks"); + DBUG_ENTER("flush_key_blocks_int"); DBUG_PRINT("enter",("file: %d blocks_used: %d blocks_changed: %d", file, keycache->blocks_used, keycache->blocks_changed)); @@ -2053,8 +2002,6 @@ int flush_key_blocks(KEY_CACHE_HANDLE keycache, test_key_cache(keycache, "start of flush_key_blocks", 0);); #endif - keycache_pthread_mutex_lock(&keycache->cache_lock); - cache= cache_buff; if (keycache->disk_blocks > 0 && (!my_disable_flush_key_blocks || type != FLUSH_KEEP)) @@ -2132,7 +2079,7 @@ restart: This happens only if there is not enough memory for the big block */ - if ((error= flush_cached_blocks(keycache, file, cache, + if ((error= flush_cached_blocks(keycache, file, cache, end,type))) last_errno=error; /* @@ -2148,8 +2095,7 @@ restart: { /* It's a temporary file */ keycache->blocks_changed--; - if (keycache->env) - keycache->env->blocks_changed--; + keycache->global_blocks_changed--; free_block(keycache, block); } } @@ -2214,13 +2160,6 @@ restart: } } - keycache_pthread_mutex_unlock(&keycache->cache_lock); - - if (type == FLUSH_REMOVE && (env= keycache->env) && (env->action)) - { - (*env->action)((void *) env); - } - #ifndef DBUG_OFF DBUG_EXECUTE("check_keycache", test_key_cache(keycache, "end of flush_key_blocks", 0);); @@ -2234,6 +2173,37 @@ restart: /* + Flush all blocks for a file to disk + + SYNOPSIS + + flush_key_blocks() + keycache pointer to a key cache data structure + file handler for the file to flush to + flush_type type of the flush + + RETURN + 0 ok + 1 error +*/ + +int flush_key_blocks(KEY_CACHE *key_cache, + File file, enum flush_type type) +{ + int res; + DBUG_ENTER("flush_key_blocks"); + DBUG_PRINT("enter", ("key_cache: %lx", key_cache)); + + if (key_cache->disk_blocks <= 0) + DBUG_RETURN(0); + keycache_pthread_mutex_lock(&key_cache->cache_lock); + res= flush_key_blocks_int(key_cache, file, type); + keycache_pthread_mutex_unlock(&key_cache->cache_lock); + DBUG_RETURN(res); +} + + +/* Flush all blocks in the key cache to disk */ @@ -2253,7 +2223,8 @@ static int flush_all_key_blocks(KEY_CACHE *keycache) cnt++; KEYCACHE_DBUG_ASSERT(cnt <= keycache->blocks_used); #endif - if (flush_key_blocks(keycache, block->hash_link->file, FLUSH_RELEASE)) + if (flush_key_blocks_int(keycache, block->hash_link->file, + FLUSH_RELEASE)) return 1; break; } diff --git a/mysys/mf_keycaches.c b/mysys/mf_keycaches.c new file mode 100644 index 00000000000..806f83dc7d8 --- /dev/null +++ b/mysys/mf_keycaches.c @@ -0,0 +1,360 @@ +/* Copyright (C) 2003 MySQL 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 */ + +/* + Handling of multiple key caches + + The idea is to have a thread safe hash on the table name, + with a default key cache value that is returned if the table name is not in + the cache. +*/ + +#include "mysys_priv.h" +#include <keycache.h> +#include <hash.h> +#include <m_string.h> + +/***************************************************************************** + General functions to handle SAFE_HASH objects. + + A SAFE_HASH object is used to store the hash, the mutex and default value + needed by the rest of the key cache code. + This is a separate struct to make it easy to later reuse the code for other + purposes + + All entries are linked in a list to allow us to traverse all elements + and delete selected ones. (HASH doesn't allow any easy ways to do this). +*****************************************************************************/ + +/* + Struct to store a key and pointer to object +*/ + +typedef struct st_safe_hash_entry +{ + byte *key; + uint length; + byte *data; + struct st_safe_hash_entry *next, **prev; +} SAFE_HASH_ENTRY; + + +typedef struct st_safe_hash_with_default +{ +#ifdef THREAD + rw_lock_t mutex; +#endif + HASH hash; + byte *default_value; + SAFE_HASH_ENTRY *root; +} SAFE_HASH; + + +/* + Free a SAFE_HASH_ENTRY + + This function is called by the hash object on delete +*/ + +static void safe_hash_entry_free(SAFE_HASH_ENTRY *entry) +{ + DBUG_ENTER("free_assign_entry"); + my_free((gptr) entry, MYF(0)); + DBUG_VOID_RETURN; +} + + +/* Get key and length for a SAFE_HASH_ENTRY */ + +static byte *safe_hash_entry_get(SAFE_HASH_ENTRY *entry, uint *length, + my_bool not_used __attribute__((unused))) +{ + *length=entry->length; + return (byte*) entry->key; +} + + +/* + Init a SAFE_HASH object + + SYNOPSIS + safe_hash_init() + hash safe_hash handler + elements Expected max number of elements + default_value default value + + NOTES + In case of error we set hash->default_value to 0 to allow one to call + safe_hash_free on an object that couldn't be initialized. + + RETURN + 0 ok + 1 error +*/ + +static my_bool safe_hash_init(SAFE_HASH *hash, uint elements, + byte *default_value) +{ + DBUG_ENTER("safe_hash"); + if (hash_init(&hash->hash, &my_charset_bin, elements, + 0, 0, (hash_get_key) safe_hash_entry_get, + (void (*)(void*)) safe_hash_entry_free, 0)) + { + hash->default_value= 0; + DBUG_RETURN(1); + } + my_rwlock_init(&hash->mutex, 0); + hash->default_value= default_value; + hash->root= 0; + DBUG_RETURN(0); +} + + +/* + Free a SAFE_HASH object + + NOTES + This is safe to call on any object that has been sent to safe_hash_init() +*/ + +static void safe_hash_free(SAFE_HASH *hash) +{ + /* + Test if safe_hash_init succeeded. This will also guard us against multiple + free calls. + */ + if (hash->default_value) + { + hash_free(&hash->hash); + rwlock_destroy(&hash->mutex); + hash->default_value=0; + } +} + +/* + Return the value stored for a key or default value if no key +*/ + +static byte *safe_hash_search(SAFE_HASH *hash, const byte *key, uint length) +{ + byte *result; + DBUG_ENTER("safe_hash_search"); + rw_rdlock(&hash->mutex); + result= hash_search(&hash->hash, key, length); + rw_unlock(&hash->mutex); + if (!result) + result= hash->default_value; + else + result= ((SAFE_HASH_ENTRY*) result)->data; + DBUG_PRINT("exit",("data: %lx", result)); + DBUG_RETURN(result); +} + + +/* + Associate a key with some data + + SYONOPSIS + safe_hash_set() + hash Hash handle + key key (path to table etc..) + length Length of key + data data to to associate with the data + + NOTES + This can be used both to insert a new entry and change an existing + entry. + If one associates a key with the default key cache, the key is deleted + + RETURN + 0 ok + 1 error (Can only be EOM). In this case my_message() is called. +*/ + +static my_bool safe_hash_set(SAFE_HASH *hash, const byte *key, uint length, + byte *data) +{ + SAFE_HASH_ENTRY *entry; + my_bool error= 0; + DBUG_ENTER("safe_hash_set"); + DBUG_PRINT("enter",("key: %.*s data: %lx", length, key, data)); + + rw_wrlock(&hash->mutex); + entry= (SAFE_HASH_ENTRY*) hash_search(&hash->hash, key, length); + + if (data == hash->default_value) + { + /* + The key is to be associated with the default entry. In this case + we can just delete the entry (if it existed) from the hash as a + search will return the default entry + */ + if (!entry) /* nothing to do */ + goto end; + /* unlink entry from list */ + if ((*entry->prev= entry->next)) + entry->next->prev= entry->prev; + hash_delete(&hash->hash, (byte*) entry); + goto end; + } + if (entry) + { + /* Entry existed; Just change the pointer to point at the new data */ + entry->data= data; + } + else + { + if (!(entry= (SAFE_HASH_ENTRY *) my_malloc(sizeof(*entry) + length, + MYF(MY_WME)))) + { + error= 1; + goto end; + } + entry->key= (byte*) (entry +1); + memcpy((char*) entry->key, (char*) key, length); + entry->length= length; + entry->data= data; + /* Link entry to list */ + if ((entry->next= hash->root)) + entry->next->prev= &entry->next; + entry->prev= &hash->root; + hash->root= entry; + if (my_hash_insert(&hash->hash, (byte*) entry)) + { + /* This can only happen if hash got out of memory */ + my_delete((char*) entry, MYF(0)); + error= 1; + goto end; + } + } + +end: + rw_unlock(&hash->mutex); + DBUG_RETURN(error); +} + + +/* + Change all entres with one data value to another data value + + SYONOPSIS + safe_hash_change() + hash Hash handle + old_data Old data + new_data Change all 'old_data' to this + + NOTES + We use the linked list to traverse all elements in the hash as + this allows us to delete elements in the case where 'new_data' is the + default value. +*/ + +static void safe_hash_change(SAFE_HASH *hash, byte *old_data, byte *new_data) +{ + SAFE_HASH_ENTRY *entry, *next; + DBUG_ENTER("safe_hash_set"); + + rw_wrlock(&hash->mutex); + + for (entry= hash->root ; entry ; entry= next) + { + next= entry->next; + if (entry->data == old_data) + { + if (new_data == hash->default_value) + hash_delete(&hash->hash, (byte*) entry); + else + entry->data= new_data; + } + } + + rw_unlock(&hash->mutex); + DBUG_VOID_RETURN; +} + + +/***************************************************************************** + Functions to handle the key cache objects +*****************************************************************************/ + +/* Variable to store all key cache objects */ +static SAFE_HASH key_cache_hash; + + +my_bool multi_keycache_init(void) +{ + return safe_hash_init(&key_cache_hash, 16, (byte*) dflt_key_cache); +} + + +void multi_keycache_free(void) +{ + safe_hash_free(&key_cache_hash); +} + +/* + Get a key cache to be used for a specific table. + + SYNOPSIS + multi_key_cache_get() + key key to find (usually table path) + uint length Length of key. + + NOTES + This function is coded in such a way that we will return the + default key cache even if one never called multi_keycache_init. + This will ensure that it works with old MyISAM clients. + + RETURN + key cache to use +*/ + +KEY_CACHE *multi_key_cache_search(byte *key, uint length) +{ + if (!key_cache_hash.hash.records) + return dflt_key_cache; + return (KEY_CACHE*) safe_hash_search(&key_cache_hash, key, length); +} + + +/* + Assosiate a key cache with a key + + + SYONOPSIS + multi_key_cache_set() + key key (path to table etc..) + length Length of key + key_cache cache to assococite with the table + + NOTES + This can be used both to insert a new entry and change an existing + entry +*/ + + +my_bool multi_key_cache_set(const byte *key, uint length, + KEY_CACHE *key_cache) +{ + return safe_hash_set(&key_cache_hash, key, length, (byte*) key_cache); +} + + +void multi_key_cache_change(KEY_CACHE *old_data, + KEY_CACHE *new_data) +{ + safe_hash_change(&key_cache_hash, (byte*) old_data, (byte*) new_data); +} diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index aea21fb3d3c..da16457c299 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -38,6 +38,7 @@ #include <assert.h> #include <m_string.h> + inline void bitmap_lock(MY_BITMAP *map) { #ifdef THREAD @@ -46,6 +47,7 @@ inline void bitmap_lock(MY_BITMAP *map) #endif } + inline void bitmap_unlock(MY_BITMAP *map) { #ifdef THREAD @@ -54,14 +56,19 @@ inline void bitmap_unlock(MY_BITMAP *map) #endif } -my_bool bitmap_init(MY_BITMAP *map, uchar *buf, uint bitmap_size, my_bool thread_safe) + +my_bool bitmap_init(MY_BITMAP *map, uchar *buf, uint bitmap_size, + my_bool thread_safe) { + DBUG_ENTER("bitmap_init"); + DBUG_ASSERT((bitmap_size & 7) == 0); bitmap_size/=8; if (!(map->bitmap=buf) && - !(map->bitmap=(uchar*)my_malloc(bitmap_size + - (thread_safe ? sizeof(pthread_mutex_t) : 0), - MYF(MY_WME | MY_ZEROFILL)))) + !(map->bitmap= (uchar*) my_malloc(bitmap_size + + (thread_safe ? + sizeof(pthread_mutex_t) : 0), + MYF(MY_WME | MY_ZEROFILL)))) return 1; map->bitmap_size=bitmap_size; #ifdef THREAD @@ -73,22 +80,26 @@ my_bool bitmap_init(MY_BITMAP *map, uchar *buf, uint bitmap_size, my_bool thread else map->mutex=0; #endif - return 0; + DBUG_RETURN(0); } + void bitmap_free(MY_BITMAP *map) { -#ifdef THREAD - if (map->mutex) - pthread_mutex_destroy(map->mutex); -#endif + DBUG_ENTER("bitmap_free"); if (map->bitmap) { +#ifdef THREAD + if (map->mutex) + pthread_mutex_destroy(map->mutex); +#endif my_free((char*) map->bitmap, MYF(0)); map->bitmap=0; } + DBUG_VOID_RETURN; } + void bitmap_set_bit(MY_BITMAP *map, uint bitmap_bit) { DBUG_ASSERT(map->bitmap && bitmap_bit < map->bitmap_size*8); @@ -97,6 +108,7 @@ void bitmap_set_bit(MY_BITMAP *map, uint bitmap_bit) bitmap_unlock(map); } + uint bitmap_set_next(MY_BITMAP *map) { uchar *bitmap=map->bitmap; @@ -127,6 +139,7 @@ uint bitmap_set_next(MY_BITMAP *map) return bit_found; } + void bitmap_clear_bit(MY_BITMAP *map, uint bitmap_bit) { DBUG_ASSERT(map->bitmap && bitmap_bit < map->bitmap_size*8); @@ -135,12 +148,13 @@ void bitmap_clear_bit(MY_BITMAP *map, uint bitmap_bit) bitmap_unlock(map); } + void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size) { uint prefix_bytes, prefix_bits; DBUG_ASSERT(map->bitmap && - (prefix_size <= map->bitmap_size*8 || prefix_size == ~0)); + (prefix_size <= map->bitmap_size*8 || prefix_size == (uint) ~0)); bitmap_lock(map); set_if_smaller(prefix_size, map->bitmap_size*8); if ((prefix_bytes= prefix_size / 8)) @@ -152,16 +166,19 @@ void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size) bitmap_unlock(map); } + void bitmap_clear_all(MY_BITMAP *map) { bitmap_set_prefix(map, 0); } + void bitmap_set_all(MY_BITMAP *map) { bitmap_set_prefix(map, ~0); } + my_bool bitmap_is_prefix(const MY_BITMAP *map, uint prefix_size) { uint prefix_bits= prefix_size & 7, res= 0; @@ -188,6 +205,7 @@ ret: return res; } + my_bool bitmap_is_clear_all(const MY_BITMAP *map) { return bitmap_is_prefix(map, 0); @@ -198,15 +216,17 @@ my_bool bitmap_is_set_all(const MY_BITMAP *map) return bitmap_is_prefix(map, map->bitmap_size*8); } + my_bool bitmap_is_set(const MY_BITMAP *map, uint bitmap_bit) { DBUG_ASSERT(map->bitmap && bitmap_bit < map->bitmap_size*8); return map->bitmap[bitmap_bit / 8] & (1 << (bitmap_bit & 7)); } + my_bool bitmap_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2) { - uint length, res=0; + uint res=0; uchar *m1=map1->bitmap, *m2=map2->bitmap, *end; DBUG_ASSERT(map1->bitmap && map2->bitmap && @@ -217,8 +237,10 @@ my_bool bitmap_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2) end= m1+map1->bitmap_size; while (m1 < end) + { if ((*m1++) & ~(*m2++)) goto ret; + } res=1; ret: @@ -227,6 +249,7 @@ ret: return res; } + my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2) { uint res; @@ -243,6 +266,7 @@ my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2) return res; } + void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2) { uchar *to=map->bitmap, *from=map2->bitmap, *end; @@ -268,6 +292,7 @@ void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2) bitmap_unlock(map); } + void bitmap_subtract(MY_BITMAP *map, const MY_BITMAP *map2) { uchar *to=map->bitmap, *from=map2->bitmap, *end; @@ -286,6 +311,7 @@ void bitmap_subtract(MY_BITMAP *map, const MY_BITMAP *map2) bitmap_unlock(map); } + void bitmap_union(MY_BITMAP *map, const MY_BITMAP *map2) { uchar *to=map->bitmap, *from=map2->bitmap, *end; diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index edd35749633..830c62b349b 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -83,7 +83,7 @@ int handle_options(int *argc, char ***argv, char *)) { uint opt_found, argvpos= 0, length, i; - my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used, + my_bool end_of_options= 0, must_be_var, set_maximum_value, option_is_loose; char **pos, **pos_end, *optend, *prev_found, *opt_str, key_name[FN_REFLEN]; @@ -104,7 +104,6 @@ int handle_options(int *argc, char ***argv, char *argument= 0; must_be_var= 0; set_maximum_value= 0; - special_used= 0; option_is_loose= 0; cur_arg++; /* skip '-' */ @@ -202,7 +201,6 @@ int handle_options(int *argc, char ***argv, /* We were called with a special prefix, we can reuse opt_found */ - special_used= 1; opt_str+= (special_opt_prefix_lengths[i] + 1); if (i == OPT_LOOSE) option_is_loose= 1; @@ -682,60 +680,77 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp) return num; } -/* - function: init_variables +/* + Init one value to it's default values + + SYNOPSIS + init_one_value() + option Option to initialize + value Pointer to variable +*/ + +static void init_one_value(const struct my_option *option, gptr *variable, + longlong value) +{ + switch ((option->var_type & GET_TYPE_MASK)) { + case GET_BOOL: + *((my_bool*) variable)= (my_bool) value; + break; + case GET_INT: + *((int*) variable)= (int) value; + break; + case GET_UINT: + *((uint*) variable)= (uint) value; + break; + case GET_LONG: + *((long*) variable)= (long) value; + break; + case GET_ULONG: + *((ulong*) variable)= (ulong) value; + break; + case GET_LL: + *((longlong*) variable)= (longlong) value; + break; + case GET_ULL: + *((ulonglong*) variable)= (ulonglong) value; + break; + default: /* dummy default to avoid compiler warnings */ + break; + } +} + + +/* initialize all variables to their default values + + SYNOPSIS + init_variables() + options Array of options + + NOTES + We will initialize the value that is pointed to by options->value. + If the value is of type GET_ASK_ADDR, we will also ask for the address + for a value and initialize. */ static void init_variables(const struct my_option *options) { for (; options->name; options++) { - gptr *value= (options->var_type & GET_ASK_ADDR ? - (*getopt_get_addr)("", 0, options) : options->value); - if (value) - { - switch ((options->var_type & GET_TYPE_MASK)) { - case GET_BOOL: - if (options->u_max_value) - *((my_bool*) options->u_max_value)= (my_bool) options->max_value; - *((my_bool*) value)= (my_bool) options->def_value; - break; - case GET_INT: - if (options->u_max_value) - *((int*) options->u_max_value)= (int) options->max_value; - *((int*) value)= (int) options->def_value; - break; - case GET_UINT: - if (options->u_max_value) - *((uint*) options->u_max_value)= (uint) options->max_value; - *((uint*) value)= (uint) options->def_value; - break; - case GET_LONG: - if (options->u_max_value) - *((long*) options->u_max_value)= (long) options->max_value; - *((long*) value)= (long) options->def_value; - break; - case GET_ULONG: - if (options->u_max_value) - *((ulong*) options->u_max_value)= (ulong) options->max_value; - *((ulong*) value)= (ulong) options->def_value; - break; - case GET_LL: - if (options->u_max_value) - *((longlong*) options->u_max_value)= (longlong) options->max_value; - *((longlong*) value)= (longlong) options->def_value; - break; - case GET_ULL: - if (options->u_max_value) - *((ulonglong*) options->u_max_value)= (ulonglong) options->max_value; - *((ulonglong*) value)= (ulonglong) options->def_value; - break; - default: /* dummy default to avoid compiler warnings */ - break; - } - } + gptr *variable; + /* + We must set u_max_value first as for some variables + options->u_max_value == options->value and in this case we want to + set the value to default value. + */ + if (options->u_max_value) + init_one_value(options, options->u_max_value, options->max_value); + if (options->value) + init_one_value(options, options->value, options->def_value); + if (options->var_type & GET_ASK_ADDR && + (variable= (*getopt_get_addr)("", 0, options))) + init_one_value(options, variable, options->def_value); } } diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 9ee7371b639..1d4219e7bfb 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -28,7 +28,7 @@ pthread_key(struct st_my_thread_var*, THR_KEY_mysys); #else pthread_key(struct st_my_thread_var, THR_KEY_mysys); #endif /* USE_TLS */ -pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache, +pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open, THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_myisam,THR_LOCK_heap, THR_LOCK_net, THR_LOCK_charset; #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) @@ -63,7 +63,6 @@ my_bool my_thread_global_init(void) pthread_mutex_init(&THR_LOCK_malloc,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_open,MY_MUTEX_INIT_FAST); - pthread_mutex_init(&THR_LOCK_keycache,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_lock,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_isam,MY_MUTEX_INIT_SLOW); pthread_mutex_init(&THR_LOCK_myisam,MY_MUTEX_INIT_SLOW); @@ -96,7 +95,6 @@ void my_thread_global_end(void) #endif pthread_mutex_destroy(&THR_LOCK_malloc); pthread_mutex_destroy(&THR_LOCK_open); - pthread_mutex_destroy(&THR_LOCK_keycache); pthread_mutex_destroy(&THR_LOCK_lock); pthread_mutex_destroy(&THR_LOCK_isam); pthread_mutex_destroy(&THR_LOCK_myisam); diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index bf40ffc5b4d..54aa4d421f6 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -770,7 +770,9 @@ bool thr_got_alarm(thr_alarm_t *alrm_ptr) void thr_end_alarm(thr_alarm_t *alrm_ptr) { thr_alarm_t alrm= *alrm_ptr; + /* alrm may be zero if thr_alarm aborted with an error */ if (alrm && alrm->crono) + { KillTimer(NULL, alrm->crono); alrm->crono = 0; diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index 3abac2dc737..474334efcc0 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -54,12 +54,15 @@ void safe_mutex_global_init(void) int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr __attribute__((unused)), - const char *file __attribute__((unused)), - uint line __attribute__((unused))) + const char *file, + uint line) { bzero((char*) mp,sizeof(*mp)); pthread_mutex_init(&mp->global,MY_MUTEX_INIT_ERRCHK); pthread_mutex_init(&mp->mutex,attr); + /* Mark that mutex is initialized */ + mp->file= file; + mp->line= line; #ifdef SAFE_MUTEX_DETECT_DESTROY /* @@ -70,7 +73,7 @@ int safe_mutex_init(safe_mutex_t *mp, { struct st_safe_mutex_info_t *info =mp->info; - info->init_file= (char *) file; + info->init_file= file; info->init_line= line; info->prev= NULL; info->next= NULL; @@ -92,6 +95,13 @@ int safe_mutex_init(safe_mutex_t *mp, int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line) { int error; + if (!mp->file) + { + fprintf(stderr,"safe_mutex: Trying to lock unitialized mutex at %s, line %d", file, line); + fflush(stderr); + abort(); + } + pthread_mutex_lock(&mp->global); if (mp->count > 0 && pthread_equal(pthread_self(),mp->thread)) { @@ -117,7 +127,7 @@ line %d more than 1 time\n", file,line); abort(); } mp->thread=pthread_self(); - mp->file= (char*) file; + mp->file= file; mp->line=line; pthread_mutex_unlock(&mp->global); return error; @@ -204,7 +214,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file, abort(); } mp->thread=pthread_self(); - mp->file= (char*) file; + mp->file= file; mp->line=line; pthread_mutex_unlock(&mp->global); return error; @@ -242,7 +252,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp, abort(); } mp->thread=pthread_self(); - mp->file= (char*) file; + mp->file= file; mp->line=line; pthread_mutex_unlock(&mp->global); return error; @@ -268,6 +278,7 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line) if (pthread_mutex_destroy(&mp->mutex)) error=1; #endif + mp->file= 0; /* Mark destroyed */ #ifdef SAFE_MUTEX_DETECT_DESTROY if (mp->info) diff --git a/mysys/typelib.c b/mysys/typelib.c index e32fad8742f..e4eda5bd675 100644 --- a/mysys/typelib.c +++ b/mysys/typelib.c @@ -20,15 +20,28 @@ #include <m_string.h> #include <m_ctype.h> -/*************************************************************************** -** Search after a fieldtype. Endspace in x is not compared. -** If part, uniq field is found and full_name == 0 then x is expanded -** to full field. -** full_name has the following bit values: -** If & 1 accept only whole names -** If & 2 don't expand if half field -** If & 4 allow #number# as type -****************************************************************************/ + +/* + Search after a string in a list of strings. Endspace in x is not compared. + + SYNOPSIS + find_type() + x String to find + lib TYPELIB (struct of pointer to values + count) + full_name bitmap of what to do + If & 1 accept only whole names + If & 2 don't expand if half field + If & 4 allow #number# as type + + NOTES + If part, uniq field is found and full_name == 0 then x is expanded + to full field. + + RETURN + -1 Too many matching values + 0 No matching value + >0 Offset+1 in typelib for matched string +*/ int find_type(my_string x, TYPELIB *typelib, uint full_name) { diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 48592d2ff00..037adc64d39 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -120,6 +120,7 @@ SUFFIXES = .sh -e 's!@''LDFLAGS''@!@SAVE_LDFLAGS@!'\ -e 's!@''CLIENT_LIBS''@!@CLIENT_LIBS@!' \ -e 's!@''LIBS''@!@LIBS@!' \ + -e 's!@''WRAPLIBS''@!@WRAPLIBS@!' \ -e 's!@''innodb_system_libs''@!@innodb_system_libs@!' \ -e 's!@''openssl_libs''@!@openssl_libs@!' \ -e 's!@''VERSION''@!@VERSION@!' \ diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index 2f1b7b2939a..e164f8c15dd 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -287,7 +287,7 @@ for i in COPYING COPYING.LIB ChangeLog README \ INSTALL-WIN-SOURCE \ Docs/manual_toc.html Docs/manual.html \ Docs/manual.txt Docs/mysqld_error.txt \ - Docs/INSTALL-BINARY + Docs/INSTALL-BINARY Docs/internals.texi do print_debug "Copying file '$i'" diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 6b543bf4a07..051f3fa9c14 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -92,7 +92,7 @@ libs_r="$ldflags -L$pkglibdir -lmysqlclient_r @LIBS@ @openssl_libs@" libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` cflags="-I$pkgincludedir @CFLAGS@" include="-I$pkgincludedir" -embedded_libs="$ldflags -L$pkglibdir -lmysqld @LIBS@ @innodb_system_libs@" +embedded_libs="$ldflags -L$pkglibdir -lmysqld @LIBS@ @WRAPLIBS@ @innodb_system_libs@" embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` # Remove some options that a client doesn't have to care about diff --git a/sql-common/client.c b/sql-common/client.c index 85308539222..cb0d8230eb8 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -634,7 +634,7 @@ void free_rows(MYSQL_DATA *cur) } } -my_bool STDCALL +my_bool cli_advanced_command(MYSQL *mysql, enum enum_server_command command, const char *header, ulong header_length, const char *arg, ulong arg_length, my_bool skip_check) @@ -754,7 +754,15 @@ mysql_free_result(MYSQL_RES *result) if ((pkt_len=net_safe_read(result->handle)) == packet_error) break; if (pkt_len <= 8 && result->handle->net.read_pos[0] == 254) + { + if (protocol_41(result->handle)) + { + char *pos= (char*) result->handle->net.read_pos; + result->handle->warning_count=uint2korr(pos); pos+=2; + result->handle->server_status=uint2korr(pos); pos+=2; + } break; /* End of data */ + } } result->handle->status=MYSQL_STATUS_READY; } @@ -987,7 +995,7 @@ void mysql_read_default_options(struct st_mysql_options *options, options->client_flag|= CLIENT_MULTI_RESULTS; break; case 31: - options->client_flag|= CLIENT_MULTI_QUERIES | CLIENT_MULTI_RESULTS; + options->client_flag|= CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS; break; default: DBUG_PRINT("warning",("unknown option: %s",option[0])); @@ -1006,7 +1014,8 @@ void mysql_read_default_options(struct st_mysql_options *options, else the lengths are calculated from the offset between pointers. **************************************************************************/ -static void STDCALL cli_fetch_lengths(ulong *to, MYSQL_ROW column, unsigned int field_count) +static void cli_fetch_lengths(ulong *to, MYSQL_ROW column, + unsigned int field_count) { ulong *prev_length; byte *start=0; @@ -1137,8 +1146,8 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, /* Read all rows (fields or data) from server */ -MYSQL_DATA * STDCALL cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, - unsigned int fields) +MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, + unsigned int fields) { uint field; ulong pkt_len; @@ -1231,6 +1240,7 @@ MYSQL_DATA * STDCALL cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, if (pkt_len > 1) /* MySQL 4.1 protocol */ { mysql->warning_count= uint2korr(cp+1); + mysql->server_status= uint2korr(cp+3); DBUG_PRINT("info",("warning_count: %ld", mysql->warning_count)); } DBUG_PRINT("exit",("Got %d rows",result->rows)); @@ -1256,7 +1266,10 @@ read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) if (pkt_len <= 8 && net->read_pos[0] == 254) { if (pkt_len > 1) /* MySQL 4.1 protocol */ + { mysql->warning_count= uint2korr(net->read_pos+1); + mysql->server_status= uint2korr(net->read_pos+3); + } return 1; /* End of data */ } prev_pos= 0; /* allowed to write at packet[-1] */ @@ -1390,8 +1403,8 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused))) before calling mysql_real_connect ! */ -static my_bool STDCALL cli_mysql_read_query_result(MYSQL *mysql); -static MYSQL_RES * STDCALL cli_mysql_use_result(MYSQL *mysql); +static my_bool cli_mysql_read_query_result(MYSQL *mysql); +static MYSQL_RES *cli_mysql_use_result(MYSQL *mysql); static MYSQL_METHODS client_methods= { @@ -1818,7 +1831,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, client_flag|=mysql->options.client_flag; client_flag|=CLIENT_CAPABILITIES; - if (client_flag & CLIENT_MULTI_QUERIES) + if (client_flag & CLIENT_MULTI_STATEMENTS) client_flag|= CLIENT_MULTI_RESULTS; #ifdef HAVE_OPENSSL @@ -2215,7 +2228,7 @@ void STDCALL mysql_close(MYSQL *mysql) DBUG_VOID_RETURN; } -static my_bool STDCALL cli_mysql_read_query_result(MYSQL *mysql) +static my_bool cli_mysql_read_query_result(MYSQL *mysql) { uchar *pos; ulong field_count; @@ -2390,7 +2403,7 @@ MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql) have to wait for the client (and will not wait more than 30 sec/packet). **************************************************************************/ -static MYSQL_RES * STDCALL cli_mysql_use_result(MYSQL *mysql) +static MYSQL_RES * cli_mysql_use_result(MYSQL *mysql) { MYSQL_RES *result; DBUG_ENTER("cli_mysql_use_result"); diff --git a/sql/Makefile.am b/sql/Makefile.am index 0167124a892..e2ab55da6a2 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -46,7 +46,7 @@ mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ item_strfunc.h item_timefunc.h item_uniq.h \ item_create.h item_subselect.h item_row.h \ - mysql_priv.h item_geofunc.h \ + mysql_priv.h item_geofunc.h sql_bitmap.h \ procedure.h sql_class.h sql_lex.h sql_list.h \ sql_manager.h sql_map.h sql_string.h unireg.h \ field.h handler.h \ diff --git a/sql/derror.cc b/sql/derror.cc index ad7432f7675..53d0dc5b7e5 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -75,6 +75,7 @@ Please install the latest version of this file.",name); goto err1; } + /* TODO: Convert the character set to server system character set */ if (!(cset= get_charset(head[30],MYF(MY_WME)))) { sql_print_error("Character set #%d is not supported for messagefile '%s'", diff --git a/sql/field.cc b/sql/field.cc index 04e9c45327b..70b8ce6c080 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -334,7 +334,7 @@ void Field::store_time(TIME *ltime,timestamp_type type) bool Field::optimize_range(uint idx) { - return test(table->file->index_flags(idx) & HA_READ_NEXT); + return !test(table->file->index_flags(idx) & HA_WRONG_ASCII_ORDER); } /**************************************************************************** @@ -2850,7 +2850,7 @@ String *Field_timestamp::val_str(String *val_buffer, struct tm tm_tmp; val_buffer->alloc(field_length+1); - char *to=(char*) val_buffer->ptr(),*end=to+field_length; + char *to= (char*) val_buffer->ptr(); val_buffer->length(field_length); #ifdef WORDS_BIGENDIAN @@ -3987,7 +3987,6 @@ longlong Field_string::val_int(void) String *Field_string::val_str(String *val_buffer __attribute__((unused)), String *val_ptr) { - char *end=ptr+field_length; uint length= field_charset->cset->lengthsp(field_charset, ptr, field_length); val_ptr->set((const char*) ptr, length, field_charset); return val_ptr; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 7f8c99f7c15..f79c5b55927 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -546,7 +546,6 @@ innobase_query_caching_of_table_permitted( { ibool is_autocommit; trx_t* trx; - char* ptr; char norm_name[1000]; ut_a(full_name_len < 999); @@ -606,7 +605,7 @@ innobase_query_caching_of_table_permitted( #ifdef __WIN__ /* Put to lower case */ - ptr = norm_name; + char* ptr = norm_name; while (*ptr != '\0') { *ptr = tolower(*ptr); @@ -1391,7 +1390,6 @@ ha_innobase::open( uint test_if_locked) /* in: not used */ { dict_table_t* ib_table; - int error = 0; char norm_name[1000]; DBUG_ENTER("ha_innobase::open"); diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 52a5398bdd8..a10eeb3c934 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -229,12 +229,6 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) if (!(file=mi_open(name, mode, test_if_locked))) return (my_errno ? my_errno : -1); - /* Synchronize key cache assignment of the handler */ - KEY_CACHE_VAR *key_cache= table->key_cache ? table->key_cache : - &dflt_key_cache_var; - VOID(mi_extra(file, HA_EXTRA_SET_KEY_CACHE, - (void*) &key_cache->cache)); - if (test_if_locked & (HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_TMP_TABLE)) VOID(mi_extra(file, HA_EXTRA_NO_WAIT_LOCK, 0)); info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); @@ -698,93 +692,45 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) /* - Assign table indexes to a key cache. + Assign table indexes to a specific key cache. */ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) { - uint len; - KEY_CACHE_VAR *old_key_cache; - KEY_CACHE_VAR *new_key_cache; - const char *errmsg=0; + KEY_CACHE *new_key_cache= check_opt->key_cache; + const char *errmsg= 0; int error= HA_ADMIN_OK; ulonglong map= ~(ulonglong) 0; TABLE_LIST *table_list= table->pos_in_table_list; - const char *new_key_cache_name= table_list->option ? - (const char *) table_list->option : - DEFAULT_KEY_CACHE_NAME; - KEY_CACHE_ASMT *key_cache_asmt= table->key_cache_asmt; - bool triggered= key_cache_asmt->triggered; - DBUG_ENTER("ha_myisam::assign_to_keycache"); - VOID(pthread_mutex_lock(&LOCK_assign)); - - old_key_cache= key_cache_asmt->key_cache; - /* Check validity of the index references */ - if (!triggered && table_list->use_index) + if (table_list->use_index) { + /* We only come here when the user did specify an index map */ key_map kmap; - get_key_map_from_key_list(&kmap, table, table_list->use_index); - if (kmap.is_set_all()) + if (get_key_map_from_key_list(&kmap, table, table_list->use_index)) { errmsg= thd->net.last_error; error= HA_ADMIN_FAILED; goto err; } - if (!kmap.is_clear_all()) - map= kmap.to_ulonglong(); - } - - len= strlen(new_key_cache_name); - new_key_cache= get_or_create_key_cache(new_key_cache_name, len); - if (old_key_cache == new_key_cache) - { - /* Nothing to do: table is assigned to the same key cache */ - goto ok; + map= kmap.to_ulonglong(); } - if (!new_key_cache || - (!new_key_cache->cache && ha_key_cache(new_key_cache))) - { - if (key_cache_asmt->triggered) - error= HA_ERR_OUT_OF_MEM; - else - { - char buf[ERRMSGSIZE]; - my_snprintf(buf, ERRMSGSIZE, - "Failed to create key cache %s", new_key_cache_name); - errmsg= buf; - error= HA_ADMIN_FAILED; - } - goto err; - } - - reassign_key_cache(key_cache_asmt, new_key_cache); - - VOID(pthread_mutex_unlock(&LOCK_assign)); - error= mi_assign_to_keycache(file, map, new_key_cache, &LOCK_assign); - VOID(pthread_mutex_lock(&LOCK_assign)); - - if (error && !key_cache_asmt->triggered) + if ((error= mi_assign_to_key_cache(file, map, new_key_cache))) { - switch (error) { - default: - char buf[ERRMSGSIZE+20]; - my_snprintf(buf, ERRMSGSIZE, - "Failed to flush to index file (errno: %d)", my_errno); - errmsg= buf; - } + char buf[80]; + my_snprintf(buf, sizeof(buf), + "Failed to flush to index file (errno: %d)", error); + errmsg= buf; error= HA_ADMIN_CORRUPT; - goto err; } - goto ok; - err: - if (!triggered) + if (error != HA_ADMIN_OK) { + /* Send error to user */ MI_CHECK param; myisamchk_init(¶m); param.thd= thd; @@ -793,32 +739,7 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) param.table_name= table->table_name; param.testflag= 0; mi_check_print_error(¶m, errmsg); - } - - ok: - if (--key_cache_asmt->requests) - { - /* There is a queue of assignments for the table */ - - /* Remove the first member from the queue */ - struct st_my_thread_var *last= key_cache_asmt->queue; - struct st_my_thread_var *thread= last->next; - if (thread->next == thread) - key_cache_asmt->queue= 0; - else - { - last->next= thread->next; - last->next->prev= &last->next; - thread->next= 0; - } - /* Signal the first waiting thread to proceed */ - VOID(pthread_cond_signal(&thread->suspend)); } - - key_cache_asmt->triggered= 0; - - VOID(pthread_mutex_unlock(&LOCK_assign)); - DBUG_RETURN(error); } diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 05da214c1d4..3cd5d96d5f3 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -35,9 +35,11 @@ const char **ha_myisammrg::bas_ext() const { static const char *ext[]= { ".MRG", NullS }; return ext; } + int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) { char name_buff[FN_REFLEN]; + DBUG_PRINT("info", ("ha_myisammrg::open")); if (!(file=myrg_open(fn_format(name_buff,name,"","",2 | 4), mode, test_if_locked))) @@ -45,12 +47,6 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) DBUG_PRINT("info", ("ha_myisammrg::open exit %d", my_errno)); return (my_errno ? my_errno : -1); } - /* Synchronize key cache assignment for the file */ - KEY_CACHE_VAR *key_cache= table->key_cache ? table->key_cache : - &dflt_key_cache_var; - VOID(myrg_extra(file, HA_EXTRA_SET_KEY_CACHE, - (void*) &key_cache->cache)); - DBUG_PRINT("info", ("ha_myisammrg::open myrg_extrafunc...")) myrg_extrafunc(file, query_cache_invalidate_by_MyISAM_filename_ref); if (!(test_if_locked == HA_OPEN_WAIT_IF_LOCKED || @@ -315,11 +311,11 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd, static void split_file_name(const char *file_name, LEX_STRING *db, LEX_STRING *name) { - uint name_length, dir_length, prefix_length; + uint dir_length, prefix_length; char buff[FN_REFLEN]; db->length= 0; - name_length= (uint) (strmake(buff, file_name, sizeof(buff)-1) - buff); + strmake(buff, file_name, sizeof(buff)-1); dir_length= dirname_length(buff); if (dir_length > 1) { diff --git a/sql/handler.cc b/sql/handler.cc index 28f399818c4..5267ddc8986 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1105,76 +1105,104 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, DBUG_RETURN(error != 0); } - /* Use key cacheing on all databases */ +static int NEAR_F delete_file(const char *name,const char *ext,int extflag) +{ + char buff[FN_REFLEN]; + VOID(fn_format(buff,name,"",ext,extflag | 4)); + return(my_delete_with_symlink(buff,MYF(MY_WME))); +} -int ha_key_cache(KEY_CACHE_VAR *key_cache) +void st_ha_check_opt::init() { - if (!key_cache->cache) - { - /* - The following mutex is not really needed as long as keybuff_size is - treated as a long value, but we use the mutex here to guard for future - changes. - */ - pthread_mutex_lock(&LOCK_global_system_variables); - if (!key_cache->block_size) - key_cache->block_size= dflt_key_cache_block_size; - if (!key_cache->buff_size) - key_cache->buff_size= dflt_key_buff_size; - long tmp_buff_size= (long) key_cache->buff_size; - long tmp_block_size= (long) key_cache->block_size; - pthread_mutex_unlock(&LOCK_global_system_variables); - return !init_key_cache(&key_cache->cache, - tmp_block_size, - tmp_buff_size, - key_cache); - } - return 0; + flags= sql_flags= 0; + sort_buffer_size = current_thd->variables.myisam_sort_buff_size; } -int ha_resize_key_cache(KEY_CACHE_VAR *key_cache) + +/***************************************************************************** + Key cache handling. + + This code is only relevant for ISAM/MyISAM tables + + key_cache->cache may be 0 only in the case where a key cache is not + initialized or when we where not able to init the key cache in a previous + call to ha_init_key_cache() (probably out of memory) +*****************************************************************************/ + +/* Init a key cache if it has not been initied before */ + + +int ha_init_key_cache(const char *name, KEY_CACHE *key_cache) { - if (key_cache->cache) + DBUG_ENTER("ha_init_key_cache"); + + if (!key_cache->key_cache_inited) { pthread_mutex_lock(&LOCK_global_system_variables); - long tmp_buff_size= (long) key_cache->buff_size; - long tmp_block_size= (long) key_cache->block_size; + long tmp_buff_size= (long) key_cache->param_buff_size; + long tmp_block_size= (long) key_cache->param_block_size; + uint division_limit= key_cache->param_division_limit; + uint age_threshold= key_cache->param_age_threshold; pthread_mutex_unlock(&LOCK_global_system_variables); - return !resize_key_cache(&key_cache->cache, tmp_block_size, - tmp_buff_size); + DBUG_RETURN(!init_key_cache(key_cache, + tmp_block_size, + tmp_buff_size, + division_limit, age_threshold)); } - return 0; + DBUG_RETURN(0); } -int ha_change_key_cache_param(KEY_CACHE_VAR *key_cache) + +/* Resize key cache */ + +int ha_resize_key_cache(KEY_CACHE *key_cache) { - if (key_cache->cache) + DBUG_ENTER("ha_resize_key_cache"); + + if (key_cache->key_cache_inited) { - change_key_cache_param(key_cache->cache); + pthread_mutex_lock(&LOCK_global_system_variables); + long tmp_buff_size= (long) key_cache->param_buff_size; + long tmp_block_size= (long) key_cache->param_block_size; + uint division_limit= key_cache->param_division_limit; + uint age_threshold= key_cache->param_age_threshold; + pthread_mutex_unlock(&LOCK_global_system_variables); + DBUG_RETURN(!resize_key_cache(key_cache, tmp_block_size, + tmp_buff_size, + division_limit, age_threshold)); } - return 0; + DBUG_RETURN(0); } -int ha_end_key_cache(KEY_CACHE_VAR *key_cache) + +/* Change parameters for key cache (like size) */ + +int ha_change_key_cache_param(KEY_CACHE *key_cache) { - if (key_cache->cache) + if (key_cache->key_cache_inited) { - end_key_cache(&key_cache->cache, 1); - return key_cache->cache ? 1 : 0; + pthread_mutex_lock(&LOCK_global_system_variables); + uint division_limit= key_cache->param_division_limit; + uint age_threshold= key_cache->param_age_threshold; + pthread_mutex_unlock(&LOCK_global_system_variables); + change_key_cache_param(key_cache, division_limit, age_threshold); } return 0; } +/* Free memory allocated by a key cache */ -static int NEAR_F delete_file(const char *name,const char *ext,int extflag) +int ha_end_key_cache(KEY_CACHE *key_cache) { - char buff[FN_REFLEN]; - VOID(fn_format(buff,name,"",ext,extflag | 4)); - return(my_delete_with_symlink(buff,MYF(MY_WME))); + end_key_cache(key_cache, 1); // Can never fail + return 0; } -void st_ha_check_opt::init() +/* Move all tables from one key cache to another one */ + +int ha_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache) { - flags= sql_flags= 0; - sort_buffer_size = current_thd->variables.myisam_sort_buff_size; + mi_change_key_cache(old_key_cache, new_key_cache); + return 0; } diff --git a/sql/handler.h b/sql/handler.h index c24bf777f01..9089db60d77 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -22,6 +22,7 @@ #endif #include <ft_global.h> +#include <keycache.h> #ifndef NO_HASH #define NO_HASH /* Not yet implemented */ @@ -145,6 +146,7 @@ enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED, #define HA_CREATE_USED_AVG_ROW_LENGTH 64 #define HA_CREATE_USED_PACK_KEYS 128 #define HA_CREATE_USED_CHARSET 256 +#define HA_CREATE_USED_DEFAULT_CHARSET 512 typedef struct st_thd_trans { void *bdb_tid; @@ -157,7 +159,7 @@ enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED, typedef struct st_ha_create_information { - CHARSET_INFO *table_charset; + CHARSET_INFO *table_charset, *default_table_charset; char *comment,*password; char *data_file_name, *index_file_name; ulonglong max_rows,min_rows; @@ -186,9 +188,11 @@ typedef struct st_ha_check_opt ulong sort_buffer_size; uint flags; /* isam layer flags (e.g. for myisamchk) */ uint sql_flags; /* sql layer flags - for something myisamchk cannot do */ + KEY_CACHE *key_cache; /* new key cache when changing key cache */ void init(); } HA_CHECK_OPT; + class handler :public Sql_alloc { protected: @@ -390,10 +394,10 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, bool update_create_info); int ha_delete_table(enum db_type db_type, const char *path); void ha_drop_database(char* path); -int ha_key_cache(KEY_CACHE_VAR *key_cache); -int ha_resize_key_cache(KEY_CACHE_VAR *key_cache); -int ha_change_key_cache_param(KEY_CACHE_VAR *key_cache); -int ha_end_key_cache(KEY_CACHE_VAR *key_cache); +int ha_init_key_cache(const char *name, KEY_CACHE *key_cache); +int ha_resize_key_cache(KEY_CACHE *key_cache); +int ha_change_key_cache_param(KEY_CACHE *key_cache); +int ha_end_key_cache(KEY_CACHE *key_cache); int ha_start_stmt(THD *thd); int ha_report_binlog_offset_and_commit(THD *thd, char *log_file_name, my_off_t end_offset); @@ -407,3 +411,5 @@ int ha_autocommit_or_rollback(THD *thd, int error); void ha_set_spin_retries(uint retries); bool ha_flush_logs(void); int ha_recovery_logging(THD *thd, bool on); +int ha_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache); diff --git a/sql/item.cc b/sql/item.cc index d76ab529db5..9684fd3e518 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1190,6 +1190,15 @@ int Item_string::save_in_field(Field *field, bool no_conversions) -1 : 0; } +int Item_uint::save_in_field(Field *field, bool no_conversions) +{ + /* + TODO: To be fixed when wen have a + field->store(longlong, unsigned_flag) method + */ + return Item_int::save_in_field(field, no_conversions); +} + int Item_int::save_in_field(Field *field, bool no_conversions) { @@ -1347,7 +1356,7 @@ bool Item::send(Protocol *protocol, String *buffer) case MYSQL_TYPE_FLOAT: { float nr; - nr= val(); + nr= (float) val(); if (!null_value) result= protocol->store(nr, decimals, buffer); break; diff --git a/sql/item.h b/sql/item.h index f473ca33676..907b9ea5ad4 100644 --- a/sql/item.h +++ b/sql/item.h @@ -125,9 +125,10 @@ public: optimisation changes in prepared statements */ Item(THD *thd, Item &item); - virtual ~Item() { name=0; } /*lint -e1509 */ + virtual ~Item() { name=0; cleanup(); } /*lint -e1509 */ void set_name(const char *str,uint length, CHARSET_INFO *cs); void init_make_field(Send_field *tmp_field,enum enum_field_types type); + virtual void cleanup() {} virtual void make_field(Send_field *field); virtual bool fix_fields(THD *, struct st_table_list *, Item **); virtual int save_in_field(Field *field, bool no_conversions); @@ -403,6 +404,7 @@ public: double val() { return ulonglong2double((ulonglong)value); } String *val_str(String*); Item *new_item() { return new Item_uint(name,max_length); } + int save_in_field(Field *field, bool no_conversions); bool fix_fields(THD *thd, struct st_table_list *list, Item **item) { bool res= Item::fix_fields(thd, list, item); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 8731e8fbe21..db80428290a 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -397,13 +397,12 @@ int Arg_comparator::compare_row() int Arg_comparator::compare_e_row() { - int res= 0; (*a)->bring_value(); (*b)->bring_value(); uint n= (*a)->cols(); for (uint i= 0; i<n; i++) { - if ((res= !comparators[i].compare())) + if (!comparators[i].compare()) return 0; } return 1; @@ -1096,8 +1095,10 @@ void Item_func_case::fix_length_and_dec() return; - // Aggregate first expression and all THEN expression types - // and collations when string comparison + /* + Aggregate first expression and all THEN expression types + and collations when string comparison + */ if (first_expr_num != -1) { agg[0]= args[first_expr_num]; @@ -1110,7 +1111,7 @@ void Item_func_case::fix_length_and_dec() return; } - if (!else_expr_num != -1 || args[else_expr_num]->maybe_null) + if (else_expr_num == -1 || args[else_expr_num]->maybe_null) maybe_null=1; max_length=0; @@ -1127,6 +1128,7 @@ void Item_func_case::fix_length_and_dec() } } + /* TODO: Fix this so that it prints the whole CASE expression */ void Item_func_case::print(String *str) @@ -1375,6 +1377,7 @@ cmp_item* cmp_item::get_comparator(Item *item) return 0; // to satisfy compiler :) } + cmp_item* cmp_item_sort_string::make_same() { return new cmp_item_sort_string_in_static(cmp_charset); @@ -1395,27 +1398,46 @@ cmp_item* cmp_item_row::make_same() return new cmp_item_row(); } + +cmp_item_row::~cmp_item_row() +{ + DBUG_ENTER("~cmp_item_row"); + DBUG_PRINT("enter",("this: %lx", this)); + if (comparators) + { + for (uint i= 0; i < n; i++) + { + if (comparators[i]) + delete comparators[i]; + } + } + DBUG_VOID_RETURN; +} + + void cmp_item_row::store_value(Item *item) { - THD *thd= current_thd; + DBUG_ENTER("cmp_item_row::store_value"); n= item->cols(); - if ((comparators= (cmp_item **) thd->calloc(sizeof(cmp_item *)*n))) + if (!comparators) + comparators= (cmp_item **) current_thd->calloc(sizeof(cmp_item *)*n); + if (comparators) { item->bring_value(); item->null_value= 0; for (uint i=0; i < n; i++) - if ((comparators[i]= cmp_item::get_comparator(item->el(i)))) - { - comparators[i]->store_value(item->el(i)); - item->null_value|= item->el(i)->null_value; - } - else - return; + { + if (!comparators[i]) + if (!(comparators[i]= cmp_item::get_comparator(item->el(i)))) + break; // new failed + comparators[i]->store_value(item->el(i)); + item->null_value|= item->el(i)->null_value; + } } - else - return; + DBUG_VOID_RETURN; } + void cmp_item_row::store_value_by_template(cmp_item *t, Item *item) { cmp_item_row *tmpl= (cmp_item_row*) t; @@ -1430,19 +1452,17 @@ void cmp_item_row::store_value_by_template(cmp_item *t, Item *item) item->bring_value(); item->null_value= 0; for (uint i=0; i < n; i++) - if ((comparators[i]= tmpl->comparators[i]->make_same())) - { - comparators[i]->store_value_by_template(tmpl->comparators[i], - item->el(i)); - item->null_value|= item->el(i)->null_value; - } - else - return; + { + if (!(comparators[i]= tmpl->comparators[i]->make_same())) + break; // new failed + comparators[i]->store_value_by_template(tmpl->comparators[i], + item->el(i)); + item->null_value|= item->el(i)->null_value; + } } - else - return; } + int cmp_item_row::cmp(Item *arg) { arg->null_value= 0; @@ -1454,25 +1474,31 @@ int cmp_item_row::cmp(Item *arg) bool was_null= 0; arg->bring_value(); for (uint i=0; i < n; i++) + { if (comparators[i]->cmp(arg->el(i))) { if (!arg->el(i)->null_value) return 1; was_null= 1; } + } return (arg->null_value= was_null); } + int cmp_item_row::compare(cmp_item *c) { - int res; cmp_item_row *cmp= (cmp_item_row *) c; for (uint i=0; i < n; i++) + { + int res; if ((res= comparators[i]->compare(cmp->comparators[i]))) return res; + } return 0; } + bool Item_func_in::nulls_in_row() { Item **arg,**arg_end; @@ -1484,6 +1510,7 @@ bool Item_func_in::nulls_in_row() return 0; } + static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) { return cs->coll->strnncollsp(cs, @@ -1491,6 +1518,7 @@ static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) (unsigned char *) y->ptr(),y->length()); } + void Item_func_in::fix_length_and_dec() { Item **arg, **arg_end; @@ -1512,7 +1540,6 @@ void Item_func_in::fix_length_and_dec() { switch (cmp_type) { case STRING_RESULT: - uint i; array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in, cmp_collation.collation); break; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 081374345d8..51c53e6c136 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -638,17 +638,7 @@ class cmp_item_row :public cmp_item uint n; public: cmp_item_row(): comparators(0), n(0) {} - ~cmp_item_row() - { - if (comparators) - { - for (uint i= 0; i < n; i++) - { - if (comparators[i]) - delete comparators[i]; - } - } - } + ~cmp_item_row(); void store_value(Item *item); int cmp(Item *arg); int compare(cmp_item *arg); @@ -694,7 +684,7 @@ public: cmp_item_string *cmp= (cmp_item_string *)c; return sortcmp(value_res, cmp->value_res, cmp_charset); } - cmp_item * make_same() + cmp_item *make_same() { return new cmp_item_sort_string_in_static(cmp_charset); } @@ -715,7 +705,17 @@ class Item_func_in :public Item_int_func } longlong val_int(); void fix_length_and_dec(); - ~Item_func_in() { delete array; delete in_item; } + ~Item_func_in() + { + cleanup(); /* This is not called by Item::~Item() */ + } + void cleanup() + { + delete array; + delete in_item; + array= 0; + in_item= 0; + } optimize_type select_optimize() const { return array ? OPTIMIZE_KEY : OPTIMIZE_NONE; } void print(String *str); diff --git a/sql/item_create.cc b/sql/item_create.cc index 5c44d8b00ff..1c0588b06a8 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -159,7 +159,7 @@ Item *create_func_from_days(Item* a) Item *create_func_get_lock(Item* a, Item *b) { - current_thd->lex.uncacheable(); + current_thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT); return new Item_func_get_lock(a, b); } @@ -324,7 +324,7 @@ Item *create_func_radians(Item *a) Item *create_func_release_lock(Item* a) { - current_thd->lex.uncacheable(); + current_thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT); return new Item_func_release_lock(a); } @@ -445,7 +445,7 @@ Item *create_func_year(Item* a) Item *create_load_file(Item* a) { - current_thd->lex.uncacheable(); + current_thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT); return new Item_load_file(a); } @@ -472,13 +472,13 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len, Item *create_func_is_free_lock(Item* a) { - current_thd->lex.uncacheable(); + current_thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT); return new Item_func_is_free_lock(a); } Item *create_func_is_used_lock(Item* a) { - current_thd->lex.uncacheable(); + current_thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT); return new Item_func_is_used_lock(a); } @@ -707,3 +707,8 @@ Item *create_func_str_to_date(Item* a,Item* b) { return new Item_func_str_to_date(a, b); } + +Item *create_func_last_day(Item *a) +{ + return new Item_func_last_day(a); +} diff --git a/sql/item_create.h b/sql/item_create.h index 5d6cbe1d58f..083868d87a6 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -150,3 +150,4 @@ Item *create_func_subtime(Item* a,Item* b); Item *create_func_timediff(Item* a,Item* b); Item *create_func_maketime(Item* a,Item* b,Item* c); Item *create_func_str_to_date(Item* a,Item* b); +Item *create_func_last_day(Item *a); diff --git a/sql/item_func.cc b/sql/item_func.cc index 3112c73b188..2a07341d97a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2321,9 +2321,7 @@ String *user_var_entry::val_str(my_bool *null_value, String *str, bool Item_func_set_user_var::check() { - bool res; DBUG_ENTER("Item_func_set_user_var::check"); - LINT_INIT(res); switch (cached_result_type) { case REAL_RESULT: @@ -2648,6 +2646,8 @@ err: void Item_func_match::init_search(bool no_order) { DBUG_ENTER("Item_func_match::init_search"); + + /* Check if init_search() has been called before */ if (ft_handler) DBUG_VOID_RETURN; @@ -2685,7 +2685,8 @@ void Item_func_match::init_search(bool no_order) ft_tmp= &search_value; } - if (join_key && !no_order) flags|=FT_SORTED; + if (join_key && !no_order) + flags|=FT_SORTED; ft_handler=table->file->ft_init_ext(flags, key, (byte*) ft_tmp->ptr(), ft_tmp->length()); @@ -2743,7 +2744,7 @@ bool Item_func_match::fix_index() { Item_field *item; uint ft_to_key[MAX_KEY], ft_cnt[MAX_KEY], fts=0, keynr; - uint max_cnt=0, mkeys=0; + uint max_cnt=0, mkeys=0, i; if (key == NO_SUCH_KEY) return 0; @@ -2762,7 +2763,7 @@ bool Item_func_match::fix_index() if (!fts) goto err; - for (uint i=1; i < arg_count; i++) + for (i=1; i < arg_count; i++) { item=(Item_field*)args[i]; for (keynr=0 ; keynr < fts ; keynr++) @@ -2947,7 +2948,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name, } if (!(item=var->item(thd, var_type, component_name))) return 0; // Impossible - thd->lex.uncacheable(); + thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT); buff[0]='@'; buff[1]='@'; pos=buff+2; @@ -2987,7 +2988,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, const char *var_name, DBUG_ASSERT(var != 0); if (!(item=var->item(thd, var_type, &null_lex_string))) return 0; // Impossible - thd->lex.uncacheable(); + thd->lex.uncacheable(UNCACHEABLE_SIDEEFFECT); item->set_name(item_name, 0, system_charset_info); // Will use original name return item; } @@ -3010,7 +3011,6 @@ longlong Item_func_is_free_lock::val_int() String *res=args[0]->val_str(&value); THD *thd=current_thd; ULL *ull; - int error=0; null_value=0; if (!res || !res->length()) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index dfaf3001a19..f40d38dd4a8 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -324,7 +324,6 @@ null: void Item_func_concat::fix_length_and_dec() { - bool first_coll= 1; max_length=0; if (agg_arg_collations(collation, args, arg_count)) @@ -2018,7 +2017,7 @@ void Item_func_lpad::fix_length_and_dec() String *Item_func_lpad::val_str(String *str) { - uint32 res_byte_length,res_char_length,pad_byte_length,pad_char_length; + uint32 res_char_length,pad_char_length; ulong count= (long) args[1]->val_int(), byte_count; String a1,a3; String *res= args[0]->val_str(&a1); @@ -2028,7 +2027,6 @@ String *Item_func_lpad::val_str(String *str) goto err; null_value=0; - res_byte_length= res->length(); res_char_length= res->numchars(); if (count <= res_char_length) @@ -2037,7 +2035,6 @@ String *Item_func_lpad::val_str(String *str) return res; } - pad_byte_length= pad->length(); pad_char_length= pad->numchars(); byte_count= count * collation.collation->mbmaxlen; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 9fd6dab83f6..a60a35aac6b 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -111,10 +111,12 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) } fix_length_and_dec(); } - if (engine->uncacheable()) + uint8 uncacheable= engine->uncacheable(); + if (uncacheable) { const_item_cache= 0; - used_tables_cache|= RAND_TABLE_BIT; + if (uncacheable & UNCACHEABLE_RAND) + used_tables_cache|= RAND_TABLE_BIT; } fixed= 1; thd->where= save_where; @@ -155,7 +157,7 @@ void Item_subselect::fix_length_and_dec() table_map Item_subselect::used_tables() const { - return (table_map) (engine->dependent() ? used_tables_cache : 0L); + return (table_map) (engine->uncacheable() ? used_tables_cache : 0L); } @@ -558,7 +560,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, } if ((abort_on_null || (upper_not && upper_not->top_level())) && - !select_lex->master_unit()->dependent && !func->eqne_op()) + !select_lex->master_unit()->uncacheable && !func->eqne_op()) { if (substitution) { @@ -644,10 +646,10 @@ Item_in_subselect::single_value_transformer(JOIN *join, (char *)"<no matter>", (char *)in_left_expr_name); - unit->dependent= unit->uncacheable= 1; + unit->uncacheable|= UNCACHEABLE_DEPENDENT; } - select_lex->dependent= select_lex->uncacheable= 1; + select_lex->uncacheable|= UNCACHEABLE_DEPENDENT; Item *item; item= (Item*) select_lex->item_list.head(); @@ -768,12 +770,12 @@ Item_in_subselect::row_value_transformer(JOIN *join) DBUG_RETURN(RES_ERROR); } thd->lex.current_select= current; - unit->dependent= unit->uncacheable= 1; + unit->uncacheable|= UNCACHEABLE_DEPENDENT; } uint n= left_expr->cols(); - select_lex->dependent= select_lex->uncacheable= 1; + select_lex->uncacheable|= UNCACHEABLE_DEPENDENT; select_lex->setup_ref_array(thd, select_lex->order_list.elements + select_lex->group_list.elements); @@ -1047,7 +1049,7 @@ int subselect_single_select_engine::exec() DBUG_RETURN(1); } } - if ((select_lex->dependent || select_lex->uncacheable) && executed) + if (select_lex->uncacheable && executed) { if (join->reinit()) { @@ -1199,24 +1201,13 @@ uint subselect_union_engine::cols() } -bool subselect_single_select_engine::dependent() -{ - return select_lex->dependent; -} - -bool subselect_union_engine::dependent() -{ - return unit->dependent; -} - - -bool subselect_single_select_engine::uncacheable() +uint8 subselect_single_select_engine::uncacheable() { return select_lex->uncacheable; } -bool subselect_union_engine::uncacheable() +uint8 subselect_union_engine::uncacheable() { return unit->uncacheable; } diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 712b3de42ad..3637e025d3c 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -269,8 +269,7 @@ public: virtual void fix_length_and_dec(Item_cache** row)= 0; virtual int exec()= 0; virtual uint cols()= 0; /* return number of columnss in select */ - virtual bool dependent()= 0; /* depended from outer select */ - virtual bool uncacheable()= 0; /* query is uncacheable */ + virtual uint8 uncacheable()= 0; /* query is uncacheable */ enum Item_result type() { return res_type; } virtual void exclude()= 0; bool may_be_null() { return maybe_null; }; @@ -295,8 +294,7 @@ public: void fix_length_and_dec(Item_cache** row); int exec(); uint cols(); - bool dependent(); - bool uncacheable(); + uint8 uncacheable(); void exclude(); table_map upper_select_const_tables(); void print (String *str); @@ -314,8 +312,7 @@ public: void fix_length_and_dec(Item_cache** row); int exec(); uint cols(); - bool dependent(); - bool uncacheable(); + uint8 uncacheable(); void exclude(); table_map upper_select_const_tables(); void print (String *str); @@ -342,8 +339,7 @@ public: void fix_length_and_dec(Item_cache** row); int exec(); uint cols() { return 1; } - bool dependent() { return 1; } - bool uncacheable() { return 1; } + uint8 uncacheable() { return UNCACHEABLE_DEPENDENT; } void exclude(); table_map upper_select_const_tables() { return 0; } void print (String *str); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 74dd95bf0ab..a3d67e9f7fa 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1642,10 +1642,8 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct, original= 0; quick_group= 0; mark_as_sum_func(); - item_thd= current_thd; - SELECT_LEX *select_lex= item_thd->lex.current_select; order= 0; - group_concat_max_len= item_thd->variables.group_concat_max_len; + group_concat_max_len= current_thd->variables.group_concat_max_len; arg_show_fields= arg_count_field= is_select->elements; @@ -1791,6 +1789,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) thd->allow_sum_func= 0; maybe_null= 0; + item_thd= thd; for (i= 0 ; i < arg_count ; i++) { if (args[i]->fix_fields(thd, tables, args + i) || args[i]->check_cols(1)) @@ -1969,6 +1968,7 @@ String* Item_func_group_concat::val_str(String* str) return &result; } + void Item_func_group_concat::print(String *str) { str->append("group_concat(", 13); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index cf71f2b3bef..496ea0ed5c8 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -137,14 +137,12 @@ static bool make_datetime(date_time_format_types format, TIME *ltime, static bool extract_date_time(DATE_TIME_FORMAT *format, const char *val, uint length, TIME *l_time) { - int weekday= 0, yearday= 0, daypart= 0, len; + int weekday= 0, yearday= 0, daypart= 0; int week_number= -1; CHARSET_INFO *cs= &my_charset_bin; int error= 0; bool usa_time= 0; bool sunday_first= 0; - uint part_len= 0; - const char *val_ptr= val; const char *val_end= val + length; const char *ptr= format->format.str; const char *end= ptr+ format->format.length; @@ -237,7 +235,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, /* Second part */ case 'f': tmp= (char*) val_end; - l_time->second_part= my_strtoll10(val, &tmp, &error); + l_time->second_part= (int) my_strtoll10(val, &tmp, &error); val= tmp; break; @@ -1221,7 +1219,7 @@ String *Item_func_sec_to_time::val_str(String *str) sec= (uint) ((ulonglong) seconds % 3600); ltime.day= 0; - ltime.hour= seconds/3600; + ltime.hour= (uint) (seconds/3600); ltime.minute= sec/60; ltime.second= sec % 60; @@ -1385,7 +1383,6 @@ String *Item_func_from_unixtime::val_str(String *str) { struct tm tm_tmp,*start; time_t tmp=(time_t) args[0]->val_int(); - CHARSET_INFO *cs= &my_charset_bin; TIME ltime; if ((null_value=args[0]->null_value)) @@ -1759,6 +1756,7 @@ bool Item_extract::eq(const Item *item, bool binary_cmp) const return 1; } + void Item_typecast::print(String *str) { str->append("cast(", 5); @@ -1768,6 +1766,7 @@ void Item_typecast::print(String *str) str->append(')'); } + void Item_char_typecast::print(String *str) { str->append("cast(", 5); @@ -1851,9 +1850,8 @@ String *Item_datetime_typecast::val_str(String *str) if (!get_arg0_date(<ime,1) && !make_datetime(ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME, <ime, str)) - return str; + return str; -null_date: null_value=1; return 0; } @@ -1912,8 +1910,8 @@ String *Item_date_typecast::val_str(String *str) String *Item_func_makedate::val_str(String *str) { TIME l_time; - long daynr= args[1]->val_int(); - long yearnr= args[0]->val_int(); + long daynr= (long) args[1]->val_int(); + long yearnr= (long) args[0]->val_int(); long days; if (args[0]->null_value || args[1]->null_value || @@ -1921,7 +1919,7 @@ String *Item_func_makedate::val_str(String *str) goto err; days= calc_daynr(yearnr,1,1) + daynr - 1; - // Day number from year 0 to 9999-12-31 + /* Day number from year 0 to 9999-12-31 */ if (days >= 0 && days < MAX_DAY_NUMBER) { null_value=0; @@ -2125,7 +2123,8 @@ String *Item_func_timediff::val_str(String *str) microseconds= l_time1.second_part - l_sign*l_time2.second_part; seconds= ((longlong) days*86400L + l_time1.hour*3600L + l_time1.minute*60L + l_time1.second + microseconds/1000000L - - (longlong)l_sign*(l_time2.hour*3600L+l_time2.minute*60L+l_time2.second)); + (longlong)l_sign*(l_time2.hour*3600L+l_time2.minute*60L+ + l_time2.second)); l_time3.neg= 0; if (seconds < 0) @@ -2146,7 +2145,7 @@ String *Item_func_timediff::val_str(String *str) if ((l_time2.neg == l_time1.neg) && l_time1.neg) l_time3.neg= l_time3.neg ? 0 : 1; - calc_time_from_sec(&l_time3, seconds, microseconds); + calc_time_from_sec(&l_time3, (long) seconds, microseconds); if (!make_datetime(l_time1.second_part || l_time2.second_part ? TIME_MICROSECOND : TIME_ONLY, @@ -2168,9 +2167,9 @@ String *Item_func_maketime::val_str(String *str) { TIME ltime; - long hour= args[0]->val_int(); - long minute= args[1]->val_int(); - long second= args[2]->val_int(); + long hour= (long) args[0]->val_int(); + long minute= (long) args[1]->val_int(); + long second= (long) args[2]->val_int(); if ((null_value=(args[0]->null_value || args[1]->null_value || @@ -2186,9 +2185,9 @@ String *Item_func_maketime::val_str(String *str) ltime.neg= 1; hour= -hour; } - ltime.hour= (ulong)hour; - ltime.minute= (ulong)minute; - ltime.second= (ulong)second; + ltime.hour= (ulong) hour; + ltime.minute= (ulong) minute; + ltime.second= (ulong) second; make_time((DATE_TIME_FORMAT *) 0, <ime, str); return str; } @@ -2310,3 +2309,19 @@ String *Item_func_str_to_date::val_str(String *str) return str; return 0; } + + +String *Item_func_last_day::val_str(String *str) +{ + TIME ltime; + if (!get_arg0_date(<ime,0)) + { + uint month_idx= ltime.month-1; + ltime.day= days_in_month[month_idx]; + if ( month_idx == 1 && calc_days_in_year(ltime.year) == 366) + ltime.day+= 1; + if (!make_datetime(DATE_ONLY, <ime, str)) + return str; + } + return 0; +} diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index ef7fa1abfa0..a81b9f28d92 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -809,3 +809,21 @@ public: max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; } }; + +class Item_func_last_day :public Item_str_func +{ +public: + Item_func_last_day(Item *a) :Item_str_func(a) {} + String *val_str(String *str); + const char *func_name() const { return "last_day"; } + enum_field_types field_type() const { return MYSQL_TYPE_DATE; } + void fix_length_and_dec() + { + decimals=0; + max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; + } + Field *tmp_table_field(TABLE *t_arg) + { + return (new Field_date(maybe_null, name, t_arg, &my_charset_bin)); + } +}; diff --git a/sql/lex.h b/sql/lex.h index 7f3328fa7cb..fd13af348d1 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -551,7 +551,8 @@ static SYMBOL sql_functions[] = { { "IS_FREE_LOCK", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_is_free_lock)}, { "IS_USED_LOCK", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_is_used_lock)}, { "LAST_INSERT_ID", SYM(LAST_INSERT_ID),0,0}, - { "ISSIMPLE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_issimple)}, + { "ISSIMPLE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_issimple)}, + { "LAST_DAY", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_last_day)}, { "LCASE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_lcase)}, { "LEAST", SYM(LEAST_SYM),0,0}, { "LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_length)}, diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 12c772e7253..b9032381c45 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -24,7 +24,7 @@ #include <signal.h> #include <thr_lock.h> #include <my_base.h> /* Needed by field.h */ -#include <sql_bitmap.h> +#include "sql_bitmap.h" #ifdef __EMX__ #undef write /* remove pthread.h macro definition for EMX */ @@ -248,6 +248,11 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; #define MY_CHARSET_BIN_MB_MAXLEN 1 +// uncachable cause +#define UNCACHEABLE_DEPENDENT 1 +#define UNCACHEABLE_RAND 2 +#define UNCACHEABLE_SIDEEFFECT 4 + #ifdef EXTRA_DEBUG /* Sync points allow us to force the server to reach a certain line of code @@ -427,10 +432,6 @@ bool check_stack_overrun(THD *thd,char *dummy); void table_cache_init(void); void table_cache_free(void); uint cached_tables(void); -void assign_cache_init(void); -void assign_cache_free(void); -void reassign_key_cache(KEY_CACHE_ASMT *key_cache_asmt, - KEY_CACHE_VAR *new_key_cache); void kill_mysql(void); void close_connection(THD *thd, uint errcode, bool lock); bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, @@ -460,10 +461,11 @@ int mysql_analyze_table(THD* thd, TABLE_LIST* table_list, HA_CHECK_OPT* check_opt); int mysql_optimize_table(THD* thd, TABLE_LIST* table_list, HA_CHECK_OPT* check_opt); -int mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list); +int mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list, + LEX_STRING *key_cache_name); int mysql_preload_keys(THD* thd, TABLE_LIST* table_list); -int reassign_keycache_tables(THD* thd, KEY_CACHE_VAR* src_cache, - char *dest_name, bool remove_fl); +int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache, + KEY_CACHE *dst_cache); bool check_simple_select(); @@ -662,7 +664,7 @@ enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND, extern const Item **not_found_item; Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter, find_item_error_report_type report_error); -void get_key_map_from_key_list(key_map *map, TABLE *table, +bool get_key_map_from_key_list(key_map *map, TABLE *table, List<String> *index_list); bool insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name, const char *table_name, @@ -849,7 +851,7 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_error_log, LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, LOCK_slave_list, LOCK_active_mi, LOCK_manager, - LOCK_global_system_variables, LOCK_user_conn, LOCK_assign; + LOCK_global_system_variables, LOCK_user_conn; extern rw_lock_t LOCK_grant; extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager; extern pthread_attr_t connection_attrib; @@ -866,6 +868,7 @@ extern SHOW_COMP_OPTION have_berkeley_db; extern struct system_variables global_system_variables; extern struct system_variables max_system_variables; extern struct rand_struct sql_rand; +extern KEY_CACHE *sql_key_cache; extern const char *opt_date_time_formats[]; extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[]; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7c432a05786..a0b5d910986 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -355,6 +355,7 @@ struct system_variables max_system_variables; MY_TMPDIR mysql_tmpdir_list; MY_BITMAP temp_pool; +KEY_CACHE *sql_key_cache; CHARSET_INFO *system_charset_info, *files_charset_info ; CHARSET_INFO *national_charset_info, *table_alias_charset; @@ -373,7 +374,6 @@ pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count, LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received, LOCK_global_system_variables, - LOCK_assign, LOCK_user_conn, LOCK_slave_list, LOCK_active_mi; rw_lock_t LOCK_grant; pthread_cond_t COND_refresh,COND_thread_count, COND_slave_stopped, @@ -900,7 +900,6 @@ void clean_up(bool print_message) #endif query_cache_destroy(); table_cache_free(); - assign_cache_free(); hostname_cache_free(); item_user_lock_free(); lex_free(); /* Free some memory */ @@ -910,9 +909,8 @@ void clean_up(bool print_message) udf_free(); #endif (void) ha_panic(HA_PANIC_CLOSE); /* close all tables and logs */ - process_key_caches(&ha_end_key_cache); - ha_end_key_cache(&dflt_key_cache_var); - delete_elements(&key_caches, free_key_cache); + delete_elements(&key_caches, (void (*)(const char*, gptr)) free_key_cache); + multi_keycache_free(); end_thr_alarm(1); /* Free allocated memory */ #ifdef USE_RAID end_raid(); @@ -997,7 +995,6 @@ static void clean_up_mutexes() #endif (void) pthread_mutex_destroy(&LOCK_active_mi); (void) pthread_mutex_destroy(&LOCK_global_system_variables); - (void) pthread_mutex_destroy(&LOCK_assign); (void) pthread_cond_destroy(&COND_thread_count); (void) pthread_cond_destroy(&COND_refresh); (void) pthread_cond_destroy(&COND_thread_cache); @@ -1568,14 +1565,14 @@ We will try our best to scrape up some info that will hopefully help diagnose\n\ the problem, but since we have already crashed, something is definitely wrong\n\ and this may fail.\n\n"); fprintf(stderr, "key_buffer_size=%lu\n", - (ulong) dflt_key_cache_var.buff_size); + (ulong) sql_key_cache->key_cache_mem_size); fprintf(stderr, "read_buffer_size=%ld\n", global_system_variables.read_buff_size); fprintf(stderr, "max_used_connections=%ld\n", max_used_connections); fprintf(stderr, "max_connections=%ld\n", max_connections); fprintf(stderr, "threads_connected=%d\n", thread_count); fprintf(stderr, "It is possible that mysqld could use up to \n\ key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %ld K\n\ -bytes of memory\n", ((ulong) dflt_key_cache_var.buff_size + +bytes of memory\n", ((ulong) sql_key_cache->key_cache_mem_size + (global_system_variables.read_buff_size + global_system_variables.sortbuff_size) * max_connections)/ 1024); @@ -2040,7 +2037,6 @@ bool init_global_datetime_format(timestamp_type format_type, { /* Get command line option */ const char *str= opt_date_time_formats[format_type]; - DATE_TIME_FORMAT *format; if (!str) // No specified format { @@ -2071,6 +2067,8 @@ static int init_common_variables(const char *conf_file_name, int argc, max_system_variables.pseudo_thread_id= (ulong)~0; start_time=time((time_t*) 0); + if (init_thread_environment()) + return 1; mysql_init_variables(); #ifdef OS2 @@ -2114,8 +2112,6 @@ static int init_common_variables(const char *conf_file_name, int argc, load_defaults(conf_file_name, groups, &argc, &argv); defaults_argv=argv; get_options(argc,argv); - if (init_thread_environment()) - return 1; if (opt_log || opt_update_log || opt_slow_log || opt_bin_log) strcat(server_version,"-log"); DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname, @@ -2204,7 +2200,6 @@ static int init_thread_environment() (void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST); - (void) pthread_mutex_init(&LOCK_assign, MY_MUTEX_INIT_FAST); (void) my_rwlock_init(&LOCK_grant, NULL); (void) pthread_cond_init(&COND_thread_count,NULL); (void) pthread_cond_init(&COND_refresh,NULL); @@ -2256,7 +2251,6 @@ static int init_server_components() { DBUG_ENTER("init_server_components"); table_cache_init(); - assign_cache_init(); hostname_cache_init(); query_cache_result_size_limit(query_cache_limit); query_cache_set_min_res_unit(query_cache_min_res_unit); @@ -2328,9 +2322,10 @@ Now disabling --log-slave-updates."); if (opt_myisam_log) (void) mi_log(1); - ha_key_cache(&dflt_key_cache_var); - process_key_caches(&ha_key_cache); - + /* call ha_init_key_cache() on all key caches to init them */ + process_key_caches(&ha_init_key_cache); + /* We must set dflt_key_cache in case we are using ISAM tables */ + dflt_key_cache= sql_key_cache; #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) if (locked_in_memory && !geteuid()) @@ -2796,7 +2791,7 @@ int main(int argc, char **argv) but we started a bad tradition by calling it MySQL from the start and we are now stuck with it. */ - if (my_strcasecmp(argv[1],"mysql")) + if (my_strcasecmp(system_charset_info, argv[1],"mysql")) load_default_groups[3]= argv[1]; start_mode= 1; Service.Init(argv[1], mysql_service); @@ -2817,7 +2812,7 @@ int main(int argc, char **argv) opt_argc= 2; // Skip service-name opt_argv=argv; start_mode= 1; - if (my_strcasecmp(argv[2],"mysql")) + if (my_strcasecmp(system_charset_info, argv[2],"mysql")) load_default_groups[3]= argv[2]; Service.Init(argv[2], mysql_service); return 0; @@ -4320,26 +4315,29 @@ replicating a LOAD DATA INFILE command.", IO_SIZE, 0}, {"key_buffer_size", OPT_KEY_BUFFER_SIZE, "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", - (gptr*) &dflt_key_cache_var.buff_size, - (gptr*) &dflt_key_cache_var.buff_size, 0, - (enum get_opt_var_type) (GET_ULL | GET_ASK_ADDR), + (gptr*) &dflt_key_cache_var.param_buff_size, + (gptr*) 0, + 0, (enum get_opt_var_type) (GET_ULL | GET_ASK_ADDR), REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD, IO_SIZE, 0}, {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, "The default size of key cache blocks", - (gptr*) &dflt_key_cache_var.block_size, - (gptr*) &dflt_key_cache_var.block_size, 0, GET_ULONG, - REQUIRED_ARG, KEY_CACHE_BLOCK_SIZE , 512, 1024*16, MALLOC_OVERHEAD, 512, 0}, + (gptr*) &dflt_key_cache_var.param_block_size, + (gptr*) 0, + 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, + KEY_CACHE_BLOCK_SIZE , 512, 1024*16, MALLOC_OVERHEAD, 512, 0}, {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT, "The minimum percentage of warm blocks in key cache", - (gptr*) &dflt_key_cache_var.division_limit, - (gptr*) &dflt_key_cache_var.division_limit, 0, GET_ULONG, - REQUIRED_ARG, 100, 1, 100, 0, 1, 0}, + (gptr*) &dflt_key_cache_var.param_division_limit, + (gptr*) 0, + 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100, + 1, 100, 0, 1, 0}, {"key_cache_division_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD, "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache", - (gptr*) &dflt_key_cache_var.age_threshold, - (gptr*) &dflt_key_cache_var.age_threshold, 0, GET_ULONG, - REQUIRED_ARG, 300, 100, ~0L, 0, 100, 0}, + (gptr*) &dflt_key_cache_var.param_age_threshold, + (gptr*) 0, + 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, + 300, 100, ~0L, 0, 100, 0}, {"long_query_time", OPT_LONG_QUERY_TIME, "Log all queries that have taken more than long_query_time seconds to execute to file.", (gptr*) &global_system_variables.long_query_time, @@ -4758,19 +4756,19 @@ struct show_var_st status_vars[]= { {"Handler_rollback", (char*) &ha_rollback_count, SHOW_LONG}, {"Handler_update", (char*) &ha_update_count, SHOW_LONG}, {"Handler_write", (char*) &ha_write_count, SHOW_LONG}, - {"Key_blocks_used", (char*) &dflt_key_cache_var.blocks_used, - SHOW_LONG_CONST}, - {"Key_read_requests", (char*) &dflt_key_cache_var.cache_r_requests, - SHOW_LONG}, - {"Key_reads", (char*) &dflt_key_cache_var.cache_read, - SHOW_LONG}, - {"Key_write_requests", (char*) &dflt_key_cache_var.cache_w_requests, - SHOW_LONG}, - {"Key_writes", (char*) &dflt_key_cache_var.cache_write, - SHOW_LONG}, + {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, + SHOW_KEY_CACHE_LONG}, + {"Key_blocks_used", (char*) &dflt_key_cache_var.global_blocks_used, + SHOW_KEY_CACHE_LONG}, + {"Key_read_requests", (char*) &dflt_key_cache_var.global_cache_r_requests, + SHOW_KEY_CACHE_LONG}, + {"Key_reads", (char*) &dflt_key_cache_var.global_cache_read, + SHOW_KEY_CACHE_LONG}, + {"Key_write_requests", (char*) &dflt_key_cache_var.global_cache_w_requests, + SHOW_KEY_CACHE_LONG}, + {"Key_writes", (char*) &dflt_key_cache_var.global_cache_write, + SHOW_KEY_CACHE_LONG}, {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG}, - {"Not_flushed_key_blocks", (char*) &dflt_key_cache_var.blocks_changed, - SHOW_LONG_CONST}, {"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_CONST}, {"Open_tables", (char*) 0, SHOW_OPENTABLES}, {"Open_files", (char*) &my_file_opened, SHOW_LONG_CONST}, @@ -4984,8 +4982,9 @@ static void mysql_init_variables(void) threads.empty(); thread_cache.empty(); key_caches.empty(); - if (!get_or_create_key_cache(DEFAULT_KEY_CACHE_NAME, - strlen(DEFAULT_KEY_CACHE_NAME))) + multi_keycache_init(); + if (!(sql_key_cache= get_or_create_key_cache(default_key_cache_base.str, + default_key_cache_base.length))) exit(1); /* Initialize structures that is used when processing options */ @@ -5075,9 +5074,9 @@ static void mysql_init_variables(void) have_crypt=SHOW_OPTION_NO; #endif #ifdef HAVE_COMPRESS - SHOW_COMP_OPTION have_compress= SHOW_OPTION_YES; + have_compress= SHOW_OPTION_YES; #else - SHOW_COMP_OPTION have_compress= SHOW_OPTION_NO; + have_compress= SHOW_OPTION_NO; #endif #ifdef HAVE_LIBWRAP libwrapName= NullS; @@ -5608,18 +5607,18 @@ mysql_getopt_value(const char *keyname, uint key_length, case OPT_KEY_CACHE_DIVISION_LIMIT: case OPT_KEY_CACHE_AGE_THRESHOLD: { - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; if (!(key_cache= get_or_create_key_cache(keyname, key_length))) exit(1); switch (option->id) { case OPT_KEY_BUFFER_SIZE: - return (gptr*) &key_cache->buff_size; + return (gptr*) &key_cache->param_buff_size; case OPT_KEY_CACHE_BLOCK_SIZE: - return (gptr*) &key_cache->block_size; + return (gptr*) &key_cache->param_block_size; case OPT_KEY_CACHE_DIVISION_LIMIT: - return (gptr*) &key_cache->division_limit; + return (gptr*) &key_cache->param_division_limit; case OPT_KEY_CACHE_AGE_THRESHOLD: - return (gptr*) &key_cache->age_threshold; + return (gptr*) &key_cache->param_age_threshold; } } } @@ -5699,13 +5698,6 @@ static void get_options(int argc,char **argv) init_global_datetime_format(TIMESTAMP_DATETIME, &global_system_variables.datetime_format)) exit(1); - - /* Set up default values for a key cache */ - KEY_CACHE_VAR *key_cache= &dflt_key_cache_var; - dflt_key_cache_block_size= key_cache->block_size; - dflt_key_buff_size= key_cache->buff_size; - dflt_key_cache_division_limit= key_cache->division_limit; - dflt_key_cache_age_threshold= key_cache->age_threshold; } diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 932aceebdbb..4fdcd093132 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -83,7 +83,6 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) table_map removed_tables= 0, outer_tables= 0, used_tables= 0; table_map where_tables= 0; Item *item; - COND *org_conds= conds; int error; if (conds) diff --git a/sql/protocol.cc b/sql/protocol.cc index 8ba3cdec8e0..e1347ff3c6f 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -120,6 +120,10 @@ void send_error(THD *thd, uint sql_errno, const char *err) #endif /* EMBEDDED_LIBRARY*/ thd->is_fatal_error=0; // Error message is given thd->net.report_error= 0; + + /* Abort multi-result sets */ + thd->lex.found_colon= 0; + thd->server_status= ~SERVER_MORE_RESULTS_EXISTS; DBUG_VOID_RETURN; } @@ -298,6 +302,8 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) pos=net_store_data((char*) pos, message, strlen(message)); VOID(my_net_write(net,buff,(uint) (pos-buff))); VOID(net_flush(net)); + /* We can't anymore send an error to the client */ + thd->net.report_error= 0; DBUG_VOID_RETURN; } @@ -338,7 +344,14 @@ send_eof(THD *thd, bool no_flush) uint tmp= min(thd->total_warn_count, 65535); buff[0]=254; int2store(buff+1, tmp); - int2store(buff+3, 0); // No flags yet + /* + The following test should never be true, but it's better to do it + because if 'is_fatal_error' is set the server is not going to execute + other queries (see the if test in dispatch_command / COM_QUERY) + */ + if (thd->is_fatal_error) + thd->server_status= ~SERVER_MORE_RESULTS_EXISTS; + int2store(buff+3, thd->server_status); VOID(my_net_write(net,(char*) buff,5)); VOID(net_flush(net)); } diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index 19e3bb06d74..563a2d41019 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -30,7 +30,7 @@ bool Protocol_cursor::send_fields(List<Item> *list, uint flag) { List_iterator_fast<Item> it(*list); Item *item; - MYSQL_FIELD *field, *client_field; + MYSQL_FIELD *client_field; DBUG_ENTER("send_fields"); if (prepare_for_send(list)) @@ -71,9 +71,9 @@ bool Protocol_cursor::send_fields(List<Item> *list, uint flag) String tmp(buff, sizeof(buff), default_charset_info), *res; if (!(res=item->val_str(&tmp))) - client_field->def= strdup_root(alloc, ""); + client_field->def= (char*) ""; else - client_field->def= strdup_root(alloc, tmp.ptr()); + client_field->def= strmake_root(alloc, res->ptr(), res->length()); } else client_field->def=0; diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index aba887be070..0d2da91e015 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -254,7 +254,7 @@ static int find_target_pos(LEX_MASTER_INFO *mi, IO_CACHE *log, char *errmsg) it is reworked. Event's log_pos used to be preserved through log-slave-updates to make code in repl_failsafe.cc work (this function, SHOW NEW MASTER); but on the other side it caused unexpected - values in Exec_master_log_pos in A->B->C replication setup, + values in Exec_Master_Log_Pos in A->B->C replication setup, synchronization problems in master_pos_wait(), ... So we (Dmitri & Guilhem) removed it. @@ -623,7 +623,6 @@ err: int show_slave_hosts(THD* thd) { List<Item> field_list; - NET* net = &thd->net; Protocol *protocol= thd->protocol; DBUG_ENTER("show_slave_hosts"); diff --git a/sql/set_var.cc b/sql/set_var.cc index 76fb2e0a4b3..9b7be4afacc 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -60,11 +60,6 @@ #include "ha_innodb.h" #endif -ulonglong dflt_key_buff_size; -uint dflt_key_cache_block_size; -uint dflt_key_cache_division_limit; -uint dflt_key_cache_age_threshold; - static HASH system_variable_hash; const char *bool_type_names[]= { "OFF", "ON", NullS }; TYPELIB bool_typelib= @@ -97,7 +92,7 @@ static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type); static void fix_max_binlog_size(THD *thd, enum_var_type type); static void fix_max_relay_log_size(THD *thd, enum_var_type type); static void fix_max_connections(THD *thd, enum_var_type type); -static KEY_CACHE_VAR *create_key_cache(const char *name, uint length); +static KEY_CACHE *create_key_cache(const char *name, uint length); void fix_sql_mode_var(THD *thd, enum_var_type type); static byte *get_error_count(THD *thd); static byte *get_warning_count(THD *thd); @@ -148,11 +143,15 @@ sys_var_thd_ulong sys_interactive_timeout("interactive_timeout", sys_var_thd_ulong sys_join_buffer_size("join_buffer_size", &SV::join_buff_size); sys_var_key_buffer_size sys_key_buffer_size("key_buffer_size"); -sys_var_key_cache_block_size sys_key_cache_block_size("key_cache_block_size"); -sys_var_key_cache_division_limit - sys_key_cache_division_limit("key_cache_division_limit"); -sys_var_key_cache_age_threshold - sys_key_cache_age_threshold("key_cache_age_threshold"); +sys_var_key_cache_long sys_key_cache_block_size("key_cache_block_size", + offsetof(KEY_CACHE, + param_block_size)); +sys_var_key_cache_long sys_key_cache_division_limit("key_cache_division_limit", + offsetof(KEY_CACHE, + param_division_limit)); +sys_var_key_cache_long sys_key_cache_age_threshold("key_cache_age_threshold", + offsetof(KEY_CACHE, + param_age_threshold)); sys_var_bool_ptr sys_local_infile("local_infile", &opt_local_infile); sys_var_thd_bool sys_log_warnings("log_warnings", &SV::log_warnings); @@ -1266,7 +1265,13 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) } switch (type()) { case SHOW_LONG: - return new Item_uint((int32) *(ulong*) value_ptr(thd, var_type, base)); + { + ulong value; + pthread_mutex_lock(&LOCK_global_system_variables); + value= *(ulong*) value_ptr(thd, var_type, base); + pthread_mutex_unlock(&LOCK_global_system_variables); + return new Item_uint((int32) value); + } case SHOW_LONGLONG: { longlong value; @@ -1771,142 +1776,158 @@ void sys_var_collation_server::set_default(THD *thd, enum_var_type type) } -static LEX_STRING default_key_cache_base= {(char *) DEFAULT_KEY_CACHE_NAME, 7}; +LEX_STRING default_key_cache_base= {(char *) "default", 7 }; -static KEY_CACHE_VAR zero_key_cache= - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static KEY_CACHE zero_key_cache; -static KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name) +KEY_CACHE *get_key_cache(LEX_STRING *cache_name) { - if (!cache_name || !cache_name->str || !cache_name->length || - cache_name->str == default_key_cache_base.str || - (cache_name->length == default_key_cache_base.length && - !memcmp(cache_name->str, default_key_cache_base.str, - default_key_cache_base.length))) + safe_mutex_assert_owner(&LOCK_global_system_variables); + if (!cache_name || ! cache_name->length) cache_name= &default_key_cache_base; - return ((KEY_CACHE_VAR*) find_named(&key_caches, - cache_name->str, cache_name->length, - 0)); + return ((KEY_CACHE*) find_named(&key_caches, + cache_name->str, cache_name->length, 0)); } + byte *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - KEY_CACHE_VAR *key_cache= get_key_cache(base); + KEY_CACHE *key_cache= get_key_cache(base); if (!key_cache) key_cache= &zero_key_cache; return (byte*) key_cache + offset ; } + bool sys_var_key_buffer_size::update(THD *thd, set_var *var) { ulonglong tmp= var->save_result.ulonglong_value; - LEX_STRING *base_name= &var->base; + KEY_CACHE *key_cache; + bool error= 0; + + /* If no basename, assume it's for the key cache named 'default' */ if (!base_name->length) base_name= &default_key_cache_base; - KEY_CACHE_VAR *key_cache= get_key_cache(base_name); + + pthread_mutex_lock(&LOCK_global_system_variables); + key_cache= get_key_cache(base_name); if (!key_cache) { + /* Key cache didn't exists */ if (!tmp) // Tried to delete cache - return 0; // Ok, nothing to do - if (!(key_cache= create_key_cache(base_name->str, - base_name->length))) - return 1; + goto end; // Ok, nothing to do + if (!(key_cache= create_key_cache(base_name->str, base_name->length))) + { + error= 1; + goto end; + } } + + /* + Abort if some other thread is changing the key cache + TODO: This should be changed so that we wait until the previous + assignment is done and then do the new assign + */ + if (key_cache->in_init) + goto end; + if (!tmp) // Zero size means delete { - if (!key_cache->cache) - return 0; - /* Delete not default key caches */ - if (key_cache != &dflt_key_cache_var) + if (key_cache == sql_key_cache) + goto end; // Ignore default key cache + + if (key_cache->key_cache_inited) // If initied { /* - Move tables using this key cache to the default key cache - and remove this key cache if no tables are assigned to it + Move tables using this key cache to the default key cache + and clear the old key cache. */ NAMED_LIST *list; - key_cache= (KEY_CACHE_VAR *) find_named(&key_caches, base_name->str, + key_cache= (KEY_CACHE *) find_named(&key_caches, base_name->str, base_name->length, &list); - delete list; - int rc= reassign_keycache_tables(thd, key_cache, - default_key_cache_base.str, 1); - my_free((char*) key_cache, MYF(0)); - return rc; - + key_cache->in_init= 1; + pthread_mutex_unlock(&LOCK_global_system_variables); + error= reassign_keycache_tables(thd, key_cache, sql_key_cache); + pthread_mutex_lock(&LOCK_global_system_variables); + key_cache->in_init= 0; } - return 0; + /* + We don't delete the key cache as some running threads my still be + in the key cache code with a pointer to the deleted (empty) key cache + */ + goto end; } - key_cache->buff_size= (ulonglong) getopt_ull_limit_value(tmp, option_limits); + key_cache->param_buff_size= + (ulonglong) getopt_ull_limit_value(tmp, option_limits); + + /* If key cache didn't existed initialize it, else resize it */ + key_cache->in_init= 1; + pthread_mutex_unlock(&LOCK_global_system_variables); - if (!key_cache->cache) - return (bool)(ha_key_cache(key_cache)); + if (!key_cache->key_cache_inited) + error= (bool) (ha_init_key_cache("", key_cache)); else - return (bool)(ha_resize_key_cache(key_cache)); -} + error= (bool)(ha_resize_key_cache(key_cache)); -bool sys_var_key_cache_block_size::update(THD *thd, set_var *var) -{ - ulong tmp= var->value->val_int(); - LEX_STRING *base_name= &var->base; - if (!base_name->length) - base_name= &default_key_cache_base; - KEY_CACHE_VAR *key_cache= get_key_cache(base_name); - - if (!key_cache && !(key_cache= create_key_cache(base_name->str, - base_name->length))) - return 1; - - key_cache->block_size= (ulong) getopt_ull_limit_value(tmp, option_limits); + pthread_mutex_lock(&LOCK_global_system_variables); + key_cache->in_init= 0; - if (key_cache->cache) - /* Do not build a new key cache here */ - return (bool) (ha_resize_key_cache(key_cache)); - return 0; +end: + pthread_mutex_unlock(&LOCK_global_system_variables); + return error; } -bool sys_var_key_cache_division_limit::update(THD *thd, set_var *var) + +bool sys_var_key_cache_long::update(THD *thd, set_var *var) { - ulong tmp= var->value->val_int(); + ulong tmp= (ulong) var->value->val_int(); LEX_STRING *base_name= &var->base; + bool error= 0; + if (!base_name->length) base_name= &default_key_cache_base; - KEY_CACHE_VAR *key_cache= get_key_cache(base_name); + + pthread_mutex_lock(&LOCK_global_system_variables); + KEY_CACHE *key_cache= get_key_cache(base_name); if (!key_cache && !(key_cache= create_key_cache(base_name->str, base_name->length))) - return 1; + { + error= 1; + goto end; + } - key_cache->division_limit= + /* + Abort if some other thread is changing the key cache + TODO: This should be changed so that we wait until the previous + assignment is done and then do the new assign + */ + if (key_cache->in_init) + goto end; + + *((ulong*) (((char*) key_cache) + offset))= (ulong) getopt_ull_limit_value(tmp, option_limits); - if (key_cache->cache) - /* Do not build a new key cache here */ - return (bool) (ha_change_key_cache_param(key_cache)); - return 0; -} + /* + Don't create a new key cache if it didn't exist + (key_caches are created only when the user sets block_size) + */ + key_cache->in_init= 1; -bool sys_var_key_cache_age_threshold::update(THD *thd, set_var *var) -{ - ulong tmp= var->value->val_int(); - LEX_STRING *base_name= &var->base; - if (!base_name->length) - base_name= &default_key_cache_base; - KEY_CACHE_VAR *key_cache= get_key_cache(base_name); - - if (!key_cache && !(key_cache= create_key_cache(base_name->str, - base_name->length))) - return 1; - - key_cache->division_limit= - (ulong) getopt_ull_limit_value(tmp, option_limits); + pthread_mutex_unlock(&LOCK_global_system_variables); - if (key_cache->cache) - /* Do not build a new key cache here */ - return (bool) (ha_change_key_cache_param(key_cache)); - return 0; + error= (bool) (ha_resize_key_cache(key_cache)); + + pthread_mutex_lock(&LOCK_global_system_variables); + key_cache->in_init= 0; + +end: + pthread_mutex_unlock(&LOCK_global_system_variables); + return error; } @@ -2392,7 +2413,6 @@ byte *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type, ulong val; char buff[256]; String tmp(buff, sizeof(buff), &my_charset_latin1); - my_bool found= 0; tmp.length(0); val= ((type == OPT_GLOBAL) ? global_system_variables.*offset : @@ -2506,13 +2526,14 @@ gptr find_named(I_List<NAMED_LIST> *list, const char *name, uint length, } -void delete_elements(I_List<NAMED_LIST> *list, void (*free_element)(gptr)) +void delete_elements(I_List<NAMED_LIST> *list, + void (*free_element)(const char *name, gptr)) { NAMED_LIST *element; DBUG_ENTER("delete_elements"); while ((element= list->get())) { - (*free_element)(element->data); + (*free_element)(element->name, element->data); delete element; } DBUG_VOID_RETURN; @@ -2521,63 +2542,68 @@ void delete_elements(I_List<NAMED_LIST> *list, void (*free_element)(gptr)) /* Key cache functions */ -static KEY_CACHE_VAR *create_key_cache(const char *name, uint length) +static KEY_CACHE *create_key_cache(const char *name, uint length) { - KEY_CACHE_VAR *key_cache; - DBUG_PRINT("info",("Creating key cache: %.*s length: %d", length, name, - length)); - if (length != default_key_cache_base.length || - memcmp(name, default_key_cache_base.str, length)) - { - if ((key_cache= (KEY_CACHE_VAR*) my_malloc(sizeof(KEY_CACHE_VAR), - MYF(MY_ZEROFILL | MY_WME)))) - { - if (!new NAMED_LIST(&key_caches, name, length, (gptr) key_cache)) - { - my_free((char*) key_cache, MYF(0)); - key_cache= 0; - } - } - } - else + KEY_CACHE *key_cache; + DBUG_ENTER("create_key_cache"); + DBUG_PRINT("enter",("name: %.*s", length, name)); + + if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE), + MYF(MY_ZEROFILL | MY_WME)))) { - key_cache= &dflt_key_cache_var; if (!new NAMED_LIST(&key_caches, name, length, (gptr) key_cache)) + { + my_free((char*) key_cache, MYF(0)); key_cache= 0; + } + else + { + /* + Set default values for a key cache + The values in dflt_key_cache_var is set by my_getopt() at startup + + We don't set 'buff_size' as this is used to enable the key cache + */ + key_cache->param_block_size= dflt_key_cache_var.param_block_size; + key_cache->param_division_limit= dflt_key_cache_var.param_division_limit; + key_cache->param_age_threshold= dflt_key_cache_var.param_age_threshold; + } } - - return key_cache; + DBUG_RETURN(key_cache); } -KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length) +KEY_CACHE *get_or_create_key_cache(const char *name, uint length) { LEX_STRING key_cache_name; + KEY_CACHE *key_cache; + key_cache_name.str= (char *) name; key_cache_name.length= length; - KEY_CACHE_VAR *key_cache= get_key_cache(&key_cache_name); - if (!key_cache) + pthread_mutex_lock(&LOCK_global_system_variables); + if (!(key_cache= get_key_cache(&key_cache_name))) key_cache= create_key_cache(name, length); + pthread_mutex_unlock(&LOCK_global_system_variables); return key_cache; } -void free_key_cache(gptr key_cache) +void free_key_cache(const char *name, KEY_CACHE *key_cache) { - if (key_cache != (gptr) &dflt_key_cache_var) - my_free(key_cache, MYF(0)); + ha_end_key_cache(key_cache); + my_free((char*) key_cache, MYF(0)); } -bool process_key_caches(int (* func) (KEY_CACHE_VAR *)) -{ +bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)) +{ I_List_iterator<NAMED_LIST> it(key_caches); NAMED_LIST *element; + while ((element= it++)) { - KEY_CACHE_VAR *key_cache= (KEY_CACHE_VAR *) element->data; - if (key_cache != &dflt_key_cache_var) - func(key_cache); + KEY_CACHE *key_cache= (KEY_CACHE *) element->data; + func(element->name, key_cache); } return 0; } diff --git a/sql/set_var.h b/sql/set_var.h index c799eec750a..58ae53190e0 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -30,11 +30,6 @@ class set_var; typedef struct system_variables SV; extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib; -extern ulonglong dflt_key_buff_size; -extern uint dflt_key_cache_block_size; -extern uint dflt_key_cache_division_limit; -extern uint dflt_key_cache_age_threshold; - enum enum_var_type { OPT_DEFAULT, OPT_SESSION, OPT_GLOBAL @@ -546,73 +541,40 @@ public: byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; + class sys_var_key_cache_param :public sys_var { protected: - uint offset; + size_t offset; public: - sys_var_key_cache_param(const char *name_arg) - :sys_var(name_arg) - { - offset= 0; - } + sys_var_key_cache_param(const char *name_arg, size_t offset_arg) + :sys_var(name_arg), offset(offset_arg) + {} byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + bool check_default(enum_var_type type) { return 1; } + bool is_struct() { return 1; } }; + class sys_var_key_buffer_size :public sys_var_key_cache_param { public: sys_var_key_buffer_size(const char *name_arg) - :sys_var_key_cache_param(name_arg) - { - offset= offsetof(KEY_CACHE_VAR, buff_size); - } + :sys_var_key_cache_param(name_arg, offsetof(KEY_CACHE, param_buff_size)) + {} bool update(THD *thd, set_var *var); SHOW_TYPE type() { return SHOW_LONGLONG; } - bool check_default(enum_var_type type) { return 1; } - bool is_struct() { return 1; } -}; - -class sys_var_key_cache_block_size :public sys_var_key_cache_param -{ -public: - sys_var_key_cache_block_size(const char *name_arg) - :sys_var_key_cache_param(name_arg) - { - offset= offsetof(KEY_CACHE_VAR, block_size); - } - bool update(THD *thd, set_var *var); - SHOW_TYPE type() { return SHOW_LONG; } - bool check_default(enum_var_type type) { return 1; } - bool is_struct() { return 1; } }; -class sys_var_key_cache_division_limit :public sys_var_key_cache_param -{ -public: - sys_var_key_cache_division_limit(const char *name_arg) - :sys_var_key_cache_param(name_arg) - { - offset= offsetof(KEY_CACHE_VAR, division_limit); - } - bool update(THD *thd, set_var *var); - SHOW_TYPE type() { return SHOW_LONG; } - bool check_default(enum_var_type type) { return 1; } - bool is_struct() { return 1; } -}; -class sys_var_key_cache_age_threshold :public sys_var_key_cache_param +class sys_var_key_cache_long :public sys_var_key_cache_param { public: - sys_var_key_cache_age_threshold(const char *name_arg) - :sys_var_key_cache_param(name_arg) - { - offset= offsetof(KEY_CACHE_VAR, age_threshold); - } + sys_var_key_cache_long(const char *name_arg, size_t offset_arg) + :sys_var_key_cache_param(name_arg, offset_arg) + {} bool update(THD *thd, set_var *var); SHOW_TYPE type() { return SHOW_LONG; } - bool check_default(enum_var_type type) { return 1; } - bool is_struct() { return 1; } }; @@ -781,7 +743,7 @@ public: uint name_length_arg, gptr data_arg) :name_length(name_length_arg), data(data_arg) { - name= my_memdup((byte*) name_arg, name_length, MYF(MY_WME)); + name= my_strdup_with_length((byte*) name_arg, name_length, MYF(MY_WME)); links->push_back(this); } inline bool cmp(const char *name_cmp, uint length) @@ -792,11 +754,16 @@ public: { my_free((char*) name, MYF(0)); } + friend bool process_key_caches(int (* func) (const char *name, + KEY_CACHE *)); + friend void delete_elements(I_List<NAMED_LIST> *list, + void (*free_element)(const char*, gptr)); }; /* updated in sql_acl.cc */ extern sys_var_thd_bool sys_old_passwords; +extern LEX_STRING default_key_cache_base; /* For sql_yacc */ struct sys_var_with_base @@ -819,9 +786,11 @@ extern sys_var_str sys_charset_system; CHARSET_INFO *get_old_charset_by_name(const char *old_name); gptr find_named(I_List<NAMED_LIST> *list, const char *name, uint length, NAMED_LIST **found); -void delete_elements(I_List<NAMED_LIST> *list, void (*free_element)(gptr)); /* key_cache functions */ -KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length); -void free_key_cache(gptr key_cache); -bool process_key_caches(int (* func) (KEY_CACHE_VAR *)); +KEY_CACHE *get_key_cache(LEX_STRING *cache_name); +KEY_CACHE *get_or_create_key_cache(const char *name, uint length); +void free_key_cache(const char *name, KEY_CACHE *key_cache); +bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)); +void delete_elements(I_List<NAMED_LIST> *list, + void (*free_element)(const char*, gptr)); diff --git a/sql/share/charsets/cp850.xml b/sql/share/charsets/cp850.xml index ae2aebf13fa..d750bac37e2 100644 --- a/sql/share/charsets/cp850.xml +++ b/sql/share/charsets/cp850.xml @@ -15,13 +15,13 @@ 01 01 01 01 01 01 01 01 01 01 01 10 10 10 10 10 10 82 82 82 82 82 82 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 10 10 10 10 30 - 02 02 02 02 02 02 02 02 02 02 02 02 02 02 01 01 - 01 02 01 02 02 02 02 02 02 01 01 10 10 10 10 10 + 01 02 02 02 02 02 02 02 02 02 02 02 02 02 01 01 + 01 02 01 02 02 02 02 02 02 01 01 02 10 01 10 10 02 02 02 02 02 01 10 10 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 + 10 10 10 10 10 01 01 01 10 10 10 10 10 10 10 10 + 10 10 10 10 10 10 02 01 10 10 10 10 10 10 10 10 + 02 01 01 01 01 02 01 01 01 10 10 10 10 10 01 10 + 01 02 01 01 02 01 10 02 01 01 01 01 02 01 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 20 </map> </ctype> @@ -82,13 +82,13 @@ 0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 006a 006b 006c 006d 006e 006f 0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 007a 007b 007c 007d 007e 007f 00c7 00fc 00e9 00e2 00e4 00e0 00e5 00e7 00ea 00eb 00e8 00ef 00ee 00ec 00c4 00c5 -00c9 00e6 00c6 00f4 00f6 00f2 00fb 00f9 00ff 00d6 00dc 00a2 00a3 00a5 20a7 0192 -00e1 00ed 00f3 00fa 00f1 00d1 00aa 00ba 00bf 2310 00ac 00bd 00bc 00a1 00ab 00bb -2591 2592 2593 2502 2524 2561 2562 2556 2555 2563 2551 2557 255d 255c 255b 2510 -2514 2534 252c 251c 2500 253c 255e 255f 255a 2554 2569 2566 2560 2550 256c 2567 -2568 2564 2565 2559 2558 2552 2553 256b 256a 2518 250c 2588 2584 258c 2590 2580 -03b1 00df 0393 03c0 03a3 03c3 00b5 03c4 03a6 0398 03a9 03b4 221e 03c6 03b5 2229 -2261 00b1 2265 2264 2320 2321 00f7 2248 00b0 2219 00b7 221a 207f 00b2 25a0 00a0 +00c9 00e6 00c6 00f4 00f6 00f2 00fb 00f9 00ff 00d6 00dc 00f8 00a3 00d8 00d7 0192 +00e1 00ed 00f3 00fa 00f1 00d1 00aa 00ba 00bf 00ae 00ac 00bd 00bc 00a1 00ab 00bb +2591 2592 2593 2502 2524 00c1 00c2 00c0 00a9 2563 2551 2557 255d 00a2 00a5 2510 +2514 2534 252c 251c 2500 253c 00e3 00c3 255a 2554 2569 2566 2560 2550 256c 00a4 +00f0 00d0 00ca 00cb 00c8 0131 00cd 00ce 00cf 2518 250c 2588 2584 00a6 00cc 2580 +00d3 00df 00d4 00d2 00f5 00d5 00b5 00fe 00de 00da 00db 00d9 00fd 00dd 00af 00b4 +00ad 00b1 2017 00be 00b6 00a7 00f7 00b8 00b0 00a8 00b7 00b9 00b3 00b2 25a0 00a0 </map> </unicode> @@ -99,18 +99,18 @@ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F - 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F - 60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 55 56 57 58 59 5A 7B 7C 7D 7E 7F - 43 59 45 41 5C 41 5B 43 45 45 45 49 49 49 5C 5B - 45 5C 5C 4F 5D 4F 55 55 59 5D 59 24 24 24 24 24 - 41 49 4F 55 4E 4E A6 A7 3F A9 AA AB AC 21 22 22 - B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF - C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF - D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF - E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF - F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF + 40 41 51 53 55 59 63 65 67 69 74 76 78 7A 7C 80 + 8E 90 92 94 97 99 A3 A5 A7 A9 AE B1 B2 B3 B4 B5 + B6 41 51 53 55 59 63 65 67 69 74 76 78 7A 7C 80 + 8E 90 92 94 97 99 A3 A5 A7 A9 AE B7 B8 B9 BA BB + 54 A1 5D 47 4B 43 4D 54 5F 61 5B 71 6F 6B 4B 4D + 5D 4F 4F 86 8A 82 9F 9B AD 8A A1 8C E3 8C BD BE + 45 6D 84 9D 7E 7E EA FA FF EE EC FD FC CE EB FB + DC DD DE C3 C9 45 47 43 E9 D5 CF D1 D3 E2 E5 C5 + C6 CB CA C8 C2 CC 49 49 D2 D0 D7 D6 D4 CD D8 E4 + 57 57 5F 61 5B 73 6D 6F 71 C7 C4 DB DA E6 6B D9 + 84 96 86 82 88 88 F5 B0 B0 9D 9F 9B AB AB EF F4 + ED F1 C1 FE F6 E7 BF BC F0 E8 F7 F9 F3 F2 DF E0 </map> </collation> diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index c01df3b53cd..c40765ebf94 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -291,11 +291,8 @@ character-set=latin2 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index e67c430c4f7..98540e1bd0a 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -285,11 +285,8 @@ character-set=latin1 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 5f77163eeda..44c9399b821 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -293,11 +293,8 @@ character-set=latin1 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index baecefb8494..e4f7c27610b 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -282,11 +282,8 @@ character-set=latin1 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL. Otherwise you will get problems if you get an unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 09e63ddd804..dec488567ff 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -287,11 +287,8 @@ character-set=latin7 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 0956db6681e..c41c927d539 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -282,11 +282,8 @@ character-set=latin1 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 2cc98971915..0425a709950 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -294,11 +294,8 @@ character-set=latin1 "Falscher Parameter oder falsche Kombination von Parametern für START SLAVE UNTIL", "Es wird empfohlen, mit --skip-slave-start zu starten, wenn mit START SLAVE UNTIL eine Schritt-für-Schritt-Replikation ausgeführt wird. Ansonsten gibt es Probleme, wenn der Slave-Server unerwartet neu startet", "SQL-Thread soll nicht gestartet werden. Daher werden UNTIL-Optionen ignoriert", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 84e48d2f284..3cf5bbf592d 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -282,11 +282,8 @@ character-set=greek "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index da71f4b7da6..f1b719ba716 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -284,11 +284,8 @@ character-set=latin2 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 4ed4d477ab8..ed39950e9f1 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -282,11 +282,8 @@ character-set=latin1 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index d28cc026159..9760cd3f9e8 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -284,11 +284,8 @@ character-set=ujis "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index b0c4bf9463e..10eed3bb2de 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -282,11 +282,8 @@ character-set=euckr "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 1e9028de1d7..7149eea8b10 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -284,11 +284,8 @@ character-set=latin1 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 942c18cc045..dc96d39f8dc 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -284,11 +284,8 @@ character-set=latin1 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 17e6df6c443..b2b2e52ad75 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -286,11 +286,8 @@ character-set=latin2 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index fdf428c9b6d..c4a150d79bf 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -283,11 +283,8 @@ character-set=latin1 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 8f4fdb3a702..dce141da20a 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -286,11 +286,8 @@ character-set=latin2 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 2ef6a2c553b..27c1b49f4f0 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -284,11 +284,8 @@ character-set=koi8r "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "ëÅÛ ÚÁÐÒÏÓÏ× ÎÅ ÍÏÖÅÔ ÕÓÔÁÎÏ×ÉÔØ ÒÁÚÍÅÒ %lu, ÎÏ×ÙÊ ÒÁÚÍÅÒ ËÅÛÁ ÚÐÒÏÓÏ× - %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index cddc1059f44..5311fa016dc 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -277,11 +277,8 @@ character-set=cp1250 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 466e7d478b6..9355e8fc0c4 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -290,11 +290,8 @@ character-set=latin2 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index de8a245c7f9..3cdcc3967d7 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -284,11 +284,8 @@ character-set=latin1 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Query cache failed to set size %lu, new query cache size is %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index d8695db30a4..17dcdb89ae6 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -282,11 +282,8 @@ character-set=latin1 "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Felaktigt %s namn '%-.100s'", -"tabell", -"databas", -"kolumn", -"index", -"katalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "Storleken av "Query cache" kunde inte sättas till %lu, ny storlek är %lu", "Kolumn '%-.64s' kan inte vara del av ett FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 3a37ee02731..99a09afde6c 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -287,11 +287,8 @@ character-set=koi8u "Wrong parameter or combination of parameters for START SLAVE UNTIL", "It is recommended to run with --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL, otherwise you are not safe in case of unexpected slave's mysqld restart", "SQL thread is not to be started so UNTIL options are ignored", -"Incorrect %s name '%-.100s'", -"table", -"database", -"column", -"index", -"catalog", +"Incorrect index name '%-.100s'", +"Incorrect catalog name '%-.100s'", "ëÅÛ ÚÁÐÉÔ¦× ÎÅÓÐÒÏÍÏÖÅÎ ×ÓÔÁÎÏ×ÉÔÉ ÒÏÚÍ¦Ò %lu, ÎÏ×ÉÊ ÒÏÚÍ¦Ò ËÅÛÁ ÚÁÐÉÔ¦× - %lu", "Column '%-.64s' cannot be part of FULLTEXT index", +"Unknown key cache '%-.100s'", diff --git a/sql/slave.cc b/sql/slave.cc index 561b32b668c..329324efa3d 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1965,7 +1965,7 @@ int show_master_info(THD* thd, MASTER_INFO* mi) sizeof(mi->user))); field_list.push_back(new Item_return_int("Master_Port", 7, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Connect_retry", 10, + field_list.push_back(new Item_return_int("Connect_Retry", 10, MYSQL_TYPE_LONG)); field_list.push_back(new Item_empty_string("Master_Log_File", FN_REFLEN)); @@ -1979,24 +1979,24 @@ int show_master_info(THD* thd, MASTER_INFO* mi) FN_REFLEN)); field_list.push_back(new Item_empty_string("Slave_IO_Running", 3)); field_list.push_back(new Item_empty_string("Slave_SQL_Running", 3)); - field_list.push_back(new Item_empty_string("Replicate_do_db", 20)); - field_list.push_back(new Item_empty_string("Replicate_ignore_db", 20)); - field_list.push_back(new Item_empty_string("Replicate_do_table", 20)); - field_list.push_back(new Item_empty_string("Replicate_ignore_table", 23)); - field_list.push_back(new Item_empty_string("Replicate_wild_do_table", 24)); - field_list.push_back(new Item_empty_string("Replicate_wild_ignore_table", + field_list.push_back(new Item_empty_string("Replicate_Do_DB", 20)); + field_list.push_back(new Item_empty_string("Replicate_Ignore_DB", 20)); + field_list.push_back(new Item_empty_string("Replicate_Do_Table", 20)); + field_list.push_back(new Item_empty_string("Replicate_Ignore_Table", 23)); + field_list.push_back(new Item_empty_string("Replicate_Wild_Do_Table", 24)); + field_list.push_back(new Item_empty_string("Replicate_Wild_Ignore_Table", 28)); - field_list.push_back(new Item_return_int("Last_errno", 4, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_empty_string("Last_error", 20)); - field_list.push_back(new Item_return_int("Skip_counter", 10, + field_list.push_back(new Item_return_int("Last_Errno", 4, MYSQL_TYPE_LONG)); + field_list.push_back(new Item_empty_string("Last_Error", 20)); + field_list.push_back(new Item_return_int("Skip_Counter", 10, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Exec_master_log_pos", 10, + field_list.push_back(new Item_return_int("Exec_Master_Log_Pos", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_return_int("Relay_log_space", 10, + field_list.push_back(new Item_return_int("Relay_Log_Space", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_empty_string("Until_condition", 6)); + field_list.push_back(new Item_empty_string("Until_Condition", 6)); field_list.push_back(new Item_empty_string("Until_Log_File", FN_REFLEN)); - field_list.push_back(new Item_return_int("Until_Log_pos", 10, + field_list.push_back(new Item_return_int("Until_Log_Pos", 10, MYSQL_TYPE_LONGLONG)); field_list.push_back(new Item_empty_string("Master_SSL_Allowed", 7)); field_list.push_back(new Item_empty_string("Master_SSL_CA_File", @@ -2009,7 +2009,7 @@ int show_master_info(THD* thd, MASTER_INFO* mi) sizeof(mi->ssl_cipher))); field_list.push_back(new Item_empty_string("Master_SSL_Key", sizeof(mi->ssl_key))); - field_list.push_back(new Item_return_int("Seconds_behind_master", 10, + field_list.push_back(new Item_return_int("Seconds_Behind_Master", 10, MYSQL_TYPE_LONGLONG)); if (protocol->send_fields(&field_list, 1)) @@ -2362,7 +2362,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) thd->options = ((opt_log_slave_updates) ? OPTION_BIN_LOG:0) | OPTION_AUTO_IS_NULL; /* - It's nonsense to constraint the slave threads with max_join_size; if a + It's nonsense to constrain the slave threads with max_join_size; if a query succeeded on master, we HAVE to execute it. */ thd->variables.max_join_size= HA_POS_ERROR; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b54e6a95bc5..bcfa9c6dec5 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -632,8 +632,8 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, if (acl_user) { /* OK. User found and password checked continue validation */ - Vio *vio=thd->net.vio; #ifdef HAVE_OPENSSL + Vio *vio=thd->net.vio; SSL *ssl= (SSL*) vio->ssl_arg; #endif @@ -3457,7 +3457,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) { uint counter; int result; - ACL_USER *acl_user; ACL_DB *acl_db; + ACL_DB *acl_db; TABLE_LIST tables[4]; DBUG_ENTER("mysql_revoke_all"); @@ -3471,7 +3471,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) List_iterator <LEX_USER> user_list(list); while ((lex_user=user_list++)) { - if (!(acl_user= check_acl_user(lex_user, &counter))) + if (!check_acl_user(lex_user, &counter)) { sql_print_error("REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' not exists", lex_user->user.str, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3976ebd81f4..7a657841845 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -142,7 +142,8 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild) OPEN_TABLE_LIST *table; TABLE *entry=(TABLE*) hash_element(&open_cache,idx); - if ((!entry->real_name)) + DBUG_ASSERT(entry->real_name); + if ((!entry->real_name)) // To be removed continue; // Shouldn't happen if (wild) { @@ -772,8 +773,6 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, reg1 TABLE *table; char key[MAX_DBKEY_LENGTH]; uint key_length; - KEY_CACHE_ASMT *key_cache_asmt; - KEY_CACHE_VAR *key_cache; DBUG_ENTER("open_table"); /* find a unused table in the open table cache */ @@ -816,76 +815,6 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, DBUG_RETURN(0); } - VOID(pthread_mutex_lock(&LOCK_assign)); - key_cache_asmt= (KEY_CACHE_ASMT*) hash_search(&assign_cache, - (byte*) key, key_length) ; - if (thd->open_options & HA_OPEN_TO_ASSIGN) - { - /* When executing a CACHE INDEX command*/ - if (key_cache_asmt) - { - if (key_cache_asmt->requests++) - { - /* Another thread are assigning this table to some key cache*/ - - /* Put the assignment request into the queue of such requests */ - struct st_my_thread_var *last; - struct st_my_thread_var *thread= thd->mysys_var; - if (! (last= key_cache_asmt->queue)) - thread->next= thread; - else - { - thread->next= last->next; - last->next= thread; - } - key_cache_asmt->queue= thread; - - /* Wait until the request can be processed */ - do - { - VOID(pthread_cond_wait(&thread->suspend, &LOCK_assign)); - } - while (thread->next); - } - } - else - { - /* - The table has not been explicitly assigned to any key cache yet; - by default it's assigned to the default key cache; - */ - - if (!(key_cache_asmt= - (KEY_CACHE_ASMT *) my_malloc(sizeof(*key_cache_asmt), - MYF(MY_WME | MY_ZEROFILL))) || - !(key_cache_asmt->db_name= my_strdup(db, MYF(MY_WME))) || - !(key_cache_asmt->table_name= my_strdup(table_name, MYF(MY_WME))) || - !(key_cache_asmt->table_key= my_memdup((const byte *) key, - key_length, MYF(MY_WME)))) - { - VOID(pthread_mutex_unlock(&LOCK_assign)); - - if (key_cache_asmt) - { - if (key_cache_asmt->db_name) - my_free((gptr) key_cache_asmt->db_name, MYF(0)); - if (key_cache_asmt->table_name) - my_free((gptr) key_cache_asmt->table_name, MYF(0)); - my_free((gptr) key_cache_asmt, MYF(0)); - } - DBUG_RETURN(NULL); - } - key_cache_asmt->key_length= key_length; - key_cache_asmt->key_cache= &dflt_key_cache_var; - VOID(my_hash_insert(&assign_cache, (byte *) key_cache_asmt)); - key_cache_asmt->requests++; - } - key_cache_asmt->to_reassign= 0; - } - - key_cache= key_cache_asmt ? key_cache_asmt->key_cache : &dflt_key_cache_var; - VOID(pthread_mutex_unlock(&LOCK_assign)); - VOID(pthread_mutex_lock(&LOCK_open)); if (!thd->open_tables) @@ -929,8 +858,6 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, table->prev->next=table->next; /* Remove from unused list */ table->next->prev=table->prev; - table->key_cache= key_cache; - table->key_cache_asmt= key_cache_asmt; } else { @@ -944,8 +871,6 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(NULL); } - table->key_cache= key_cache; - table->key_cache_asmt= key_cache_asmt; if (open_unireg_entry(thd, table,db,table_name,alias) || !(table->table_cache_key=memdup_root(&table->mem_root,(char*) key, key_length))) @@ -963,8 +888,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, } table->in_use=thd; - check_unused(); - + check_unused(); // Debugging call VOID(pthread_mutex_unlock(&LOCK_open)); if (refresh) @@ -1071,8 +995,8 @@ bool reopen_table(TABLE *table,bool locked) tmp.grant= table->grant; /* Replace table in open list */ - tmp.next=table->next; - tmp.prev=table->prev; + tmp.next= table->next; + tmp.prev= table->prev; if (table->file) VOID(closefrm(table)); // close file, free everything @@ -1740,54 +1664,6 @@ bool rm_temporary_table(enum db_type base, char *path) DBUG_RETURN(error); } -static void free_assign_entry(KEY_CACHE_ASMT *key_cache_asmt) -{ - DBUG_ENTER("free_assign_entry"); - my_free((gptr) key_cache_asmt->table_key, MYF(0)); - my_free((gptr) key_cache_asmt, MYF(0)); - DBUG_VOID_RETURN; -} - -static byte *assign_cache_key(const byte *record,uint *length, - my_bool not_used __attribute__((unused))) -{ - KEY_CACHE_ASMT *entry=(KEY_CACHE_ASMT *) record; - *length=entry->key_length; - return (byte*) entry->table_key; -} - -void assign_cache_init(void) -{ - VOID(hash_init(&assign_cache, &my_charset_bin, - table_cache_size+16, 0, 0, assign_cache_key, - (hash_free_key) free_assign_entry,0)); -} - -void assign_cache_free(void) -{ - DBUG_ENTER("assign_cache_free"); - hash_free(&assign_cache); - DBUG_VOID_RETURN; -} - -void reassign_key_cache(KEY_CACHE_ASMT *key_cache_asmt, - KEY_CACHE_VAR *new_key_cache) -{ - if (key_cache_asmt->prev) - { - /* Unlink key_cache_asmt from the assignment list for the old key cache */ - if ((*key_cache_asmt->prev= key_cache_asmt->next)) - key_cache_asmt->next->prev= key_cache_asmt->prev; - } - /* Link key_cache_asmt into the assignment list for the new key cache */ - key_cache_asmt->prev= &new_key_cache->assign_list; - if ((key_cache_asmt->next= new_key_cache->assign_list)) - key_cache_asmt->next->prev= &key_cache_asmt->next; - new_key_cache->assign_list= key_cache_asmt; - - key_cache_asmt->key_cache= new_key_cache; -} - /***************************************************************************** ** find field in list or tables. if field is unqualifed and unique, @@ -2215,7 +2091,21 @@ bool setup_tables(TABLE_LIST *tables) } -void get_key_map_from_key_list(key_map *map, TABLE *table, +/* + Create a key_map from a list of index names + + SYNOPSIS + get_key_map_from_key_list() + map key_map to fill in + table Table + index_list List of index names + + RETURN + 0 ok; In this case *map will includes the choosed index + 1 error +*/ + +bool get_key_map_from_key_list(key_map *map, TABLE *table, List<String> *index_list) { List_iterator_fast<String> it(*index_list); @@ -2231,13 +2121,14 @@ void get_key_map_from_key_list(key_map *map, TABLE *table, my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), name->c_ptr(), table->real_name); map->set_all(); - return; + return 1; } map->set_bit(pos-1); } - return; + return 0; } + /**************************************************************************** This just drops in all fields instead of current '*' field Returns pointer to last inserted field if ok @@ -2488,7 +2379,7 @@ int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys) DBUG_ENTER("mysql_create_index"); bzero((char*) &create_info,sizeof(create_info)); create_info.db_type=DB_TYPE_DEFAULT; - create_info.table_charset= thd->variables.collation_database; + create_info.default_table_charset= thd->variables.collation_database; DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name, &create_info, table_list, fields, keys, drop, alter, 0, (ORDER*)0, FALSE, @@ -2505,7 +2396,7 @@ int mysql_drop_index(THD *thd, TABLE_LIST *table_list, List<Alter_drop> &drop) DBUG_ENTER("mysql_drop_index"); bzero((char*) &create_info,sizeof(create_info)); create_info.db_type=DB_TYPE_DEFAULT; - create_info.table_charset= thd->variables.collation_database; + create_info.default_table_charset= thd->variables.collation_database; DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name, &create_info, table_list, fields, keys, drop, alter, 0, (ORDER*)0, FALSE, diff --git a/sql/sql_class.h b/sql/sql_class.h index 7a8dc067256..b19caf057e6 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -509,7 +509,7 @@ public: PREP_STMT *last_prepared_stmt; #ifndef DBUG_OFF uint dbug_sentry; // watch out for memory corruption -#endif +#endif struct st_my_thread_var *mysys_var; enum enum_server_command command; uint32 server_id; @@ -531,9 +531,9 @@ public: THD_TRANS stmt; // Trans for current statement uint bdb_lock_count; - /* + /* Tables changed in transaction (that must be invalidated in query cache). - List contain only transactional tables, that not invalidated in query + List contain only transactional tables, that not invalidated in query cache (instead of full list of changed in transaction tables). */ CHANGED_TABLE_LIST* changed_tables; @@ -551,7 +551,7 @@ public: #endif #ifdef SIGNAL_WITH_VIO_CLOSE Vio* active_vio; -#endif +#endif /* next_insert_id is set on SET INSERT_ID= #. This is used as the next generated auto_increment value in handler.cc @@ -573,9 +573,9 @@ public: sent_row_count, examined_row_count; table_map used_tables; USER_CONN *user_connect; - CHARSET_INFO *db_charset; + CHARSET_INFO *db_charset; List<TABLE> temporary_tables_should_be_free; // list of temporary tables - List <MYSQL_ERROR> warn_list; + List <MYSQL_ERROR> warn_list; uint warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_END]; uint total_warn_count; ulong query_id, warn_id, version, options, thread_id, col_access; @@ -609,6 +609,7 @@ public: bool prepare_command; bool tmp_table_used; bool charset_is_system_charset, charset_is_collation_connection; + bool slow_command; /* If we do a purge of binary logs, log index info of the threads diff --git a/sql/sql_db.cc b/sql/sql_db.cc index b7d6c642398..5481b1b266f 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -60,10 +60,12 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0) { ulong length; - CHARSET_INFO *cs= (create && create->table_charset) ? - create->table_charset : + CHARSET_INFO *cs= (create && create->default_table_charset) ? + create->default_table_charset : thd->variables.collation_database; - length= my_sprintf(buf,(buf, "default-character-set=%s\ndefault-collation=%s\n", cs->csname,cs->name)); + length= my_sprintf(buf,(buf, + "default-character-set=%s\ndefault-collation=%s\n", + cs->csname,cs->name)); /* Error is written by my_write */ if (!my_write(file,(byte*) buf, length, MYF(MY_NABP+MY_WME))) @@ -99,7 +101,7 @@ static bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) uint nbytes; bzero((char*) create,sizeof(*create)); - create->table_charset= global_system_variables.collation_database; + create->default_table_charset= global_system_variables.collation_database; if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) >= 0) { IO_CACHE cache; @@ -116,16 +118,17 @@ static bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) { if (!strncmp(buf,"default-character-set", (pos-buf))) { - if (!(create->table_charset=get_charset_by_csname(pos+1, - MY_CS_PRIMARY, - MYF(0)))) + if (!(create->default_table_charset= get_charset_by_csname(pos+1, + MY_CS_PRIMARY, + MYF(0)))) { sql_print_error(ER(ER_UNKNOWN_CHARACTER_SET),pos+1); } } else if (!strncmp(buf,"default-collation", (pos-buf))) { - if (!(create->table_charset=get_charset_by_name(pos+1, MYF(0)))) + if (!(create->default_table_charset= get_charset_by_name(pos+1, + MYF(0)))) { sql_print_error(ER(ER_UNKNOWN_COLLATION),pos+1); } @@ -262,7 +265,6 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) char path[FN_REFLEN+16]; long result=1; int error = 0; - uint create_options = create_info ? create_info->options : 0; DBUG_ENTER("mysql_alter_db"); VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); @@ -286,8 +288,8 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) */ if (thd->db && !strcmp(thd->db,db)) { - thd->db_charset= (create_info && create_info->table_charset) ? - create_info->table_charset : + thd->db_charset= (create_info && create_info->default_table_charset) ? + create_info->default_table_charset : global_system_variables.collation_database; thd->variables.collation_database= thd->db_charset; } @@ -609,7 +611,7 @@ bool mysql_change_db(THD *thd, const char *name) } if ((db_length > NAME_LEN) || check_db_name(dbname)) { - net_printf(thd, ER_WRONG_NAME, ER(ER_DATABASE), dbname); + net_printf(thd, ER_WRONG_DB_NAME, dbname); x_free(dbname); DBUG_RETURN(1); } @@ -653,8 +655,8 @@ bool mysql_change_db(THD *thd, const char *name) #endif strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE); load_db_opt(thd, path, &create); - thd->db_charset= create.table_charset ? - create.table_charset : + thd->db_charset= create.default_table_charset ? + create.default_table_charset : global_system_variables.collation_database; thd->variables.collation_database= thd->db_charset; DBUG_RETURN(0); @@ -675,7 +677,7 @@ int mysqld_show_create_db(THD *thd, char *dbname, if (check_db_name(dbname)) { - net_printf(thd,ER_WRONG_NAME, ER(ER_DATABASE), dbname); + net_printf(thd,ER_WRONG_DB_NAME, dbname); DBUG_RETURN(1); } @@ -731,12 +733,13 @@ int mysqld_show_create_db(THD *thd, char *dbname, to= strxmov(to,"/*!32312 IF NOT EXISTS*/ ", NullS); to=strxmov(to,"`",dbname,"`", NullS); - if (create.table_charset) + if (create.default_table_charset) { - int cl= (create.table_charset->state & MY_CS_PRIMARY) ? 0 : 1; + int cl= (create.default_table_charset->state & MY_CS_PRIMARY) ? 0 : 1; to= strxmov(to," /*!40100" - " DEFAULT CHARACTER SET ",create.table_charset->csname, - cl ? " COLLATE " : "", cl ? create.table_charset->name : "", + " DEFAULT CHARACTER SET ",create.default_table_charset->csname, + cl ? " COLLATE " : "", + cl ? create.default_table_charset->name : "", " */",NullS); } protocol->store(path, (uint) (to-path), system_charset_info); diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 2985f7e04a0..4bab7be255c 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -66,6 +66,9 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order, DBUG_RETURN(1); } + if (thd->lex.duplicates == DUP_IGNORE) + thd->lex.select_lex.no_error= 1; + /* Test if the user wants to delete all rows */ if (!using_limit && const_cond && (!conds || conds->val_int()) && !(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE))) @@ -560,8 +563,8 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) HA_CREATE_INFO create_info; table->file->info(HA_STATUS_AUTO | HA_STATUS_NO_LOCK); bzero((char*) &create_info,sizeof(create_info)); - create_info.auto_increment_value= table->file->auto_increment_value; - create_info.table_charset=table->table_charset; + create_info.auto_increment_value= table->file->auto_increment_value; + create_info.default_table_charset= table->table_charset; db_type table_type=table->db_type; strmov(path,table->path); @@ -605,7 +608,6 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) } bzero((char*) &create_info,sizeof(create_info)); - create_info.table_charset=table_list->table->table_charset; *fn_ext(path)=0; // Remove the .frm extension error= ha_create_table(path,&create_info,1) ? -1 : 0; diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index bce1022d5c0..405cfdb5bdc 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -242,8 +242,8 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, { if (err != HA_ERR_KEY_NOT_FOUND && err != HA_ERR_END_OF_FILE) { - sql_print_error("mysql_ha_read: Got error %d when reading table", - err); + sql_print_error("mysql_ha_read: Got error %d when reading table '%s'", + err, tables->real_name); table->file->print_error(err,MYF(0)); goto err; } @@ -253,7 +253,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, continue; if (num_rows >= offset_limit) { - String *packet = &thd->packet; Item *item; protocol->prepare_for_resend(); it.rewind(); @@ -298,7 +297,20 @@ static TABLE **find_table_ptr_by_name(THD *thd, const char *db, !my_strcasecmp(system_charset_info, (is_alias ? table->table_name : table->real_name), table_name)) + { + if (table->version != refresh_version) + { + VOID(pthread_mutex_lock(&LOCK_open)); + if (close_thread_table(thd, ptr)) + { + /* Tell threads waiting for refresh that something has happened */ + VOID(pthread_cond_broadcast(&COND_refresh)); + } + VOID(pthread_mutex_unlock(&LOCK_open)); + continue; + } break; + } ptr= &(table->next); } return ptr; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 9077d4c6a2d..4484cdbe248 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1488,6 +1488,8 @@ void select_insert::send_error(uint errcode,const char *err) bool select_insert::send_eof() { int error,error2; + DBUG_ENTER("select_insert::send_eof"); + if (!(error=table->file->extra(HA_EXTRA_NO_CACHE))) error=table->file->activate_all_index(thd); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); @@ -1521,20 +1523,18 @@ bool select_insert::send_eof() table->file->print_error(error,MYF(0)); //TODO error should be sent at the query processing end ::send_error(thd); - return 1; + DBUG_RETURN(1); } + + char buff[160]; + if (info.handle_duplicates == DUP_IGNORE) + sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, + (ulong) (info.records - info.copied), (ulong) thd->cuted_fields); else - { - char buff[160]; - if (info.handle_duplicates == DUP_IGNORE) - sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, - (ulong) (info.records - info.copied), (ulong) thd->cuted_fields); - else - sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, - (ulong) info.deleted, (ulong) thd->cuted_fields); - ::send_ok(thd,info.copied+info.deleted,last_insert_id,buff); - return 0; - } + sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, + (ulong) info.deleted, (ulong) thd->cuted_fields); + ::send_ok(thd,info.copied+info.deleted,last_insert_id,buff); + DBUG_RETURN(0); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 5fa6c088a16..9b74073b64e 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -432,7 +432,7 @@ int yylex(void *arg, void *yythd) reg1 uchar c; int tokval, result_state; uint length; - enum my_lex_states state,prev_state; + enum my_lex_states state; LEX *lex= &(((THD *)yythd)->lex); YYSTYPE *yylval=(YYSTYPE*) arg; CHARSET_INFO *cs= ((THD *) yythd)->charset(); @@ -441,7 +441,7 @@ int yylex(void *arg, void *yythd) lex->yylval=yylval; // The global state lex->tok_start=lex->tok_end=lex->ptr; - prev_state=state=lex->next_state; + state=lex->next_state; lex->next_state=MY_LEX_OPERATOR_OR_IDENT; LINT_INIT(c); for (;;) @@ -870,7 +870,7 @@ int yylex(void *arg, void *yythd) case MY_LEX_COLON: // optional line terminator if (yyPeek()) { - if (((THD *)yythd)->client_capabilities & CLIENT_MULTI_QUERIES) + if (((THD *)yythd)->client_capabilities & CLIENT_MULTI_STATEMENTS) { lex->found_colon=(char*)lex->ptr; ((THD *)yythd)->server_status |= SERVER_MORE_RESULTS_EXISTS; @@ -965,7 +965,8 @@ void st_select_lex_node::init_query() { options= 0; linkage= UNSPECIFIED_TYPE; - no_error= no_table_names_allowed= uncacheable= dependent= 0; + no_error= no_table_names_allowed= 0; + uncacheable= 0; } void st_select_lex_node::init_select() @@ -1174,7 +1175,7 @@ void st_select_lex_unit::exclude_level() */ void st_select_lex_unit::exclude_tree() { - SELECT_LEX_UNIT *units= 0, **units_last= &units; + SELECT_LEX_UNIT *units= 0; for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select()) { // unlink current level from global SELECTs list @@ -1215,12 +1216,12 @@ void st_select_lex::mark_as_dependent(SELECT_LEX *last) for (SELECT_LEX *s= this; s && s != last; s= s->outer_select()) - if ( !s->dependent ) + if (!(s->uncacheable & UNCACHEABLE_DEPENDENT)) { // Select is dependent of outer select - s->dependent= s->uncacheable= 1; + s->uncacheable|= UNCACHEABLE_DEPENDENT; SELECT_LEX_UNIT *munit= s->master_unit(); - munit->dependent= munit->uncacheable= 1; + munit->uncacheable|= UNCACHEABLE_DEPENDENT; //Tables will be reopened many times for (TABLE_LIST *tbl= s->get_table_list(); tbl; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index be931c56247..d2345165eb9 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -84,6 +84,7 @@ enum enum_sql_command { #define DESCRIBE_NORMAL 1 #define DESCRIBE_EXTENDED 2 + typedef List<Item> List_item; typedef struct st_lex_master_info @@ -226,9 +227,14 @@ public: }; ulong options; + /* + result of this query can't be cached, bit field, can be : + UNCACHEABLE_DEPENDENT + UNCACHEABLE_RAND + UNCACHEABLE_SIDEEFFECT + */ + uint8 uncacheable; enum sub_select_type linkage; - bool dependent; /* dependent from outer select subselect */ - bool uncacheable; /* result of this query can't be cached */ bool no_table_names_allowed; /* used for global order by */ bool no_error; /* suppress error message (convert it to warnings) */ @@ -513,7 +519,7 @@ typedef struct st_lex sql_exchange *exchange; select_result *result; Item *default_value; - LEX_STRING *comment; + LEX_STRING *comment, name_and_length; LEX_USER *grant_user; gptr yacc_yyss,yacc_yyvs; THD *thd; @@ -565,7 +571,7 @@ typedef struct st_lex bool derived_tables; bool safe_to_cache_query; st_lex() {} - inline void uncacheable() + inline void uncacheable(uint8 cause) { safe_to_cache_query= 0; @@ -580,7 +586,8 @@ typedef struct st_lex un != &unit; sl= sl->outer_select(), un= sl->master_unit()) { - sl->uncacheable = un->uncacheable= 1; + sl->uncacheable|= cause; + un->uncacheable|= cause; } } } LEX; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b3c17167a3a..9f4b10682ba 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -44,7 +44,6 @@ #define MIN_HANDSHAKE_SIZE 6 #endif /* HAVE_OPENSSL */ -extern "C" pthread_mutex_t THR_LOCK_keycache; #ifdef SOLARIS extern "C" int gethostname(char *name, int namelen); #endif @@ -129,7 +128,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, USER_RESOURCES *mqh) { int return_val=0; - uint temp_len, user_len, host_len; + uint temp_len, user_len; char temp_user[USERNAME_LENGTH+HOSTNAME_LENGTH+2]; struct user_conn *uc; @@ -137,7 +136,6 @@ static int get_or_create_user_conn(THD *thd, const char *user, DBUG_ASSERT(host != 0); user_len=strlen(user); - host_len=strlen(host); temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1; (void) pthread_mutex_lock(&LOCK_user_conn); if (!(uc = (struct user_conn *) hash_search(&hash_user_connections, @@ -1069,6 +1067,14 @@ void free_items(Item *item) delete item; } + /* This works because items are allocated with sql_alloc() */ + +void cleanup_items(Item *item) +{ + for (; item ; item=item->next) + item->cleanup(); +} + int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd) { TABLE* table; @@ -1085,7 +1091,7 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd) if (!db || check_db_name(db)) { - net_printf(thd,ER_WRONG_NAME, ER(ER_DATABASE), db ? db : "NULL"); + net_printf(thd,ER_WRONG_DB_NAME, db ? db : "NULL"); goto err; } if (lower_case_table_names) @@ -1185,10 +1191,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd, Commands which will always take a long time should be marked with this so that they will not get logged to the slow query log */ - bool slow_command=FALSE; DBUG_ENTER("dispatch_command"); thd->command=command; + thd->slow_command=FALSE; thd->set_time(); VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->query_id=query_id; @@ -1224,7 +1230,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, uint tbl_len= *(uchar*) (packet + db_len + 1); statistic_increment(com_other, &LOCK_status); - slow_command= TRUE; + thd->slow_command= TRUE; db= thd->alloc(db_len + tbl_len + 2); tbl_name= strmake(db, packet + 1, db_len)+1; strmake(tbl_name, packet + db_len + 2, tbl_len); @@ -1345,14 +1351,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd, while (!thd->killed && !thd->is_fatal_error && thd->lex.found_colon) { char *packet= thd->lex.found_colon; - /* + /* Multiple queries exits, execute them individually */ if (thd->lock || thd->open_tables || thd->derived_tables) - close_thread_tables(thd); + close_thread_tables(thd); ulong length= thd->query_length-(ulong)(thd->lex.found_colon-thd->query); - + /* Remove garbage at start of query */ while (my_isspace(thd->charset(), *packet) && length > 0) { @@ -1429,7 +1435,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, // null test to handle EOM if (!db || !strip_sp(db) || check_db_name(db)) { - net_printf(thd,ER_WRONG_NAME, ER(ER_DATABASE), db ? db : "NULL"); + net_printf(thd,ER_WRONG_DB_NAME, db ? db : "NULL"); break; } if (check_access(thd,CREATE_ACL,db,0,1,0)) @@ -1445,7 +1451,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, // null test to handle EOM if (!db || !strip_sp(db) || check_db_name(db)) { - net_printf(thd,ER_WRONG_NAME, ER(ER_DATABASE), db ? db : "NULL"); + net_printf(thd,ER_WRONG_DB_NAME, db ? db : "NULL"); break; } if (check_access(thd,DROP_ACL,db,0,1,0)) @@ -1463,7 +1469,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, case COM_BINLOG_DUMP: { statistic_increment(com_other,&LOCK_status); - slow_command = TRUE; + thd->slow_command = TRUE; if (check_global_access(thd, REPL_SLAVE_ACL)) break; mysql_log.write(thd,command, 0); @@ -1576,6 +1582,23 @@ bool dispatch_command(enum enum_server_command command, THD *thd, kill_one_thread(thd,id); break; } + case COM_SET_OPTION: + { + statistic_increment(com_stat[SQLCOM_SET_OPTION], &LOCK_status); + enum_mysql_set_option command= (enum_mysql_set_option) uint2korr(packet); + switch (command) { + case MYSQL_OPTION_MULTI_STATEMENTS_ON: + thd->client_capabilities|= CLIENT_MULTI_STATEMENTS; + break; + case MYSQL_OPTION_MULTI_STATEMENTS_OFF: + thd->client_capabilities&= ~CLIENT_MULTI_STATEMENTS; + break; + default: + send_error(thd, ER_UNKNOWN_COM_ERROR); + break; + } + break; + } case COM_DEBUG: statistic_increment(com_other,&LOCK_status); if (check_global_access(thd, SUPER_ACL)) @@ -1606,7 +1629,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd->end_time(); // Set start time /* If not reading from backup and if the query took too long */ - if (!slow_command && !thd->user_time) // do not log 'slow_command' queries + if (!thd->slow_command && !thd->user_time) // do not log 'slow_command' queries { thd->proc_info="logging slow query"; @@ -1947,6 +1970,7 @@ mysql_execute_command(THD *thd) check_table_access(thd,SELECT_ACL, tables,0) || check_global_access(thd, FILE_ACL)) goto error; /* purecov: inspected */ + thd->slow_command=TRUE; res = mysql_backup_table(thd, tables); break; @@ -1957,6 +1981,7 @@ mysql_execute_command(THD *thd) check_table_access(thd, INSERT_ACL, tables,0) || check_global_access(thd, FILE_ACL)) goto error; /* purecov: inspected */ + thd->slow_command=TRUE; res = mysql_restore_table(thd, tables); break; } @@ -1966,7 +1991,7 @@ mysql_execute_command(THD *thd) check_access(thd, INDEX_ACL, tables->db, &tables->grant.privilege, 0, 0)) goto error; - res = mysql_assign_to_keycache(thd, tables); + res= mysql_assign_to_keycache(thd, tables, &lex->name_and_length); break; } case SQLCOM_PRELOAD_KEYS: @@ -1974,7 +1999,7 @@ mysql_execute_command(THD *thd) if (check_db_used(thd, tables) || check_access(thd, INDEX_ACL, tables->db, &tables->grant.privilege, 0, 0)) - goto error; + goto error; res = mysql_preload_keys(thd, tables); break; } @@ -2046,7 +2071,7 @@ mysql_execute_command(THD *thd) #endif if (strlen(tables->real_name) > NAME_LEN) { - net_printf(thd,ER_WRONG_NAME, ER(ER_TABLE), tables->real_name); + net_printf(thd,ER_WRONG_TABLE_NAME, tables->real_name); break; } LOCK_ACTIVE_MI; @@ -2091,7 +2116,7 @@ mysql_execute_command(THD *thd) #endif if (strlen(tables->real_name) > NAME_LEN) { - net_printf(thd, ER_WRONG_NAME, ER(ER_TABLE), tables->alias); + net_printf(thd, ER_WRONG_TABLE_NAME, tables->alias); res=0; break; } @@ -2108,6 +2133,19 @@ mysql_execute_command(THD *thd) break; } #endif + /* + If we are using SET CHARSET without DEFAULT, add an implicite + DEFAULT to not confuse old users. (This may change). + */ + if ((lex->create_info.used_fields & + (HA_CREATE_USED_DEFAULT_CHARSET | HA_CREATE_USED_CHARSET)) == + HA_CREATE_USED_CHARSET) + { + lex->create_info.used_fields&= ~HA_CREATE_USED_CHARSET; + lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; + lex->create_info.default_table_charset= lex->create_info.table_charset; + lex->create_info.table_charset= 0; + } if (select_lex->item_list.elements) // With select { select_result *result; @@ -2173,6 +2211,7 @@ mysql_execute_command(THD *thd) if (grant_option && check_grant(thd,INDEX_ACL,tables)) goto error; #endif + thd->slow_command=TRUE; if (end_active_trans(thd)) res= -1; else @@ -2223,7 +2262,7 @@ mysql_execute_command(THD *thd) ulong priv=0; if (lex->name && (!lex->name[0] || strlen(lex->name) > NAME_LEN)) { - net_printf(thd, ER_WRONG_NAME, ER(ER_TABLE), lex->name); + net_printf(thd, ER_WRONG_TABLE_NAME, lex->name); res=0; break; } @@ -2263,6 +2302,7 @@ mysql_execute_command(THD *thd) res= -1; else { + thd->slow_command=TRUE; res= mysql_alter_table(thd, select_lex->db, lex->name, &lex->create_info, tables, lex->create_list, @@ -2352,6 +2392,7 @@ mysql_execute_command(THD *thd) if (check_db_used(thd,tables) || check_table_access(thd,SELECT_ACL | INSERT_ACL, tables,0)) goto error; /* purecov: inspected */ + thd->slow_command=TRUE; res = mysql_repair_table(thd, tables, &lex->check_opt); /* ! we write after unlocking the table */ if (!res && !lex->no_write_to_binlog) @@ -2368,8 +2409,9 @@ mysql_execute_command(THD *thd) case SQLCOM_CHECK: { if (check_db_used(thd,tables) || - check_table_access(thd, SELECT_ACL | EXTRA_ACL , tables,0)) + check_table_access(thd, SELECT_ACL | EXTRA_ACL , tables,0)) goto error; /* purecov: inspected */ + thd->slow_command=TRUE; res = mysql_check_table(thd, tables, &lex->check_opt); break; } @@ -2378,6 +2420,7 @@ mysql_execute_command(THD *thd) if (check_db_used(thd,tables) || check_table_access(thd,SELECT_ACL | INSERT_ACL, tables,0)) goto error; /* purecov: inspected */ + thd->slow_command=TRUE; res = mysql_analyze_table(thd, tables, &lex->check_opt); /* ! we write after unlocking the table */ if (!res && !lex->no_write_to_binlog) @@ -2398,6 +2441,7 @@ mysql_execute_command(THD *thd) if (check_db_used(thd,tables) || check_table_access(thd,SELECT_ACL | INSERT_ACL, tables,0)) goto error; /* purecov: inspected */ + thd->slow_command=TRUE; if (specialflag & (SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC)) { /* Use ALTER TABLE */ @@ -2409,7 +2453,7 @@ mysql_execute_command(THD *thd) bzero((char*) &create_info,sizeof(create_info)); create_info.db_type=DB_TYPE_DEFAULT; create_info.row_type=ROW_TYPE_DEFAULT; - create_info.table_charset=default_charset_info; + create_info.default_table_charset=default_charset_info; res= mysql_alter_table(thd, NullS, NullS, &create_info, tables, lex->create_list, lex->key_list, lex->drop_list, lex->alter_list, @@ -2797,7 +2841,7 @@ mysql_execute_command(THD *thd) remove_escape(db); // Fix escaped '_' if (check_db_name(db)) { - net_printf(thd,ER_WRONG_NAME, ER(ER_DATABASE), db); + net_printf(thd,ER_WRONG_DB_NAME, db); goto error; } #ifndef NO_EMBEDDED_ACCESS_CHECKS @@ -2962,7 +3006,7 @@ mysql_execute_command(THD *thd) { if (!strip_sp(lex->name) || check_db_name(lex->name)) { - net_printf(thd,ER_WRONG_NAME, ER(ER_DATABASE), lex->name); + net_printf(thd,ER_WRONG_DB_NAME, lex->name); break; } /* @@ -2990,7 +3034,7 @@ mysql_execute_command(THD *thd) { if (!strip_sp(lex->name) || check_db_name(lex->name)) { - net_printf(thd, ER_WRONG_NAME, ER(ER_DATABASE), lex->name); + net_printf(thd, ER_WRONG_DB_NAME, lex->name); break; } /* @@ -3023,7 +3067,7 @@ mysql_execute_command(THD *thd) { if (!strip_sp(lex->name) || check_db_name(lex->name)) { - net_printf(thd, ER_WRONG_NAME, ER(ER_DATABASE), lex->name); + net_printf(thd, ER_WRONG_DB_NAME, lex->name); break; } if (check_access(thd,ALTER_ACL,lex->name,0,1,0)) @@ -3040,7 +3084,7 @@ mysql_execute_command(THD *thd) { if (!strip_sp(lex->name) || check_db_name(lex->name)) { - net_printf(thd,ER_WRONG_NAME, ER(ER_DATABASE), lex->name); + net_printf(thd,ER_WRONG_DB_NAME, lex->name); break; } if (check_access(thd,DROP_ACL,lex->name,0,1,0)) @@ -4290,7 +4334,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, if (check_table_name(table->table.str,table->table.length) || table->db.str && check_db_name(table->db.str)) { - net_printf(thd, ER_WRONG_NAME, ER(ER_TABLE), table->table.str); + net_printf(thd, ER_WRONG_TABLE_NAME, table->table.str); DBUG_RETURN(0); } @@ -4620,15 +4664,24 @@ void kill_one_thread(THD *thd, ulong id) static void refresh_status(void) { - pthread_mutex_lock(&THR_LOCK_keycache); pthread_mutex_lock(&LOCK_status); for (struct show_var_st *ptr=status_vars; ptr->name; ptr++) { if (ptr->type == SHOW_LONG) - *(ulong*) ptr->value=0; + *(ulong*) ptr->value= 0; + else if (ptr->type == SHOW_KEY_CACHE_LONG) + { + /* + Reset value in 'default' key cache. + This needs to be recoded when we have thread specific key values + */ + char *value= (((char*) sql_key_cache) + + (uint) ((char*) (ptr->value) - + (char*) &dflt_key_cache_var)); + *(ulong*) value= 0; + } } pthread_mutex_unlock(&LOCK_status); - pthread_mutex_unlock(&THR_LOCK_keycache); } @@ -4644,7 +4697,7 @@ static bool append_file_to_dir(THD *thd, char **filename_ptr, char *table_name) if (strlen(*filename_ptr)+strlen(table_name) >= FN_REFLEN-1 || !test_if_hard_path(*filename_ptr)) { - my_error(ER_WRONG_NAME, MYF(0), ER(ER_TABLE), *filename_ptr); + my_error(ER_WRONG_TABLE_NAME, MYF(0), *filename_ptr); return 1; } /* Fix is using unix filename format on dos */ diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 2fa08e2d649..354214a4da5 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1056,10 +1056,9 @@ void mysql_stmt_reset(THD *thd, char *packet) void mysql_stmt_free(THD *thd, char *packet) { ulong stmt_id= uint4korr(packet); - PREP_STMT *stmt; DBUG_ENTER("mysql_stmt_free"); - if (!(stmt=find_prepared_statement(thd, stmt_id, "close"))) + if (!find_prepared_statement(thd, stmt_id, "close")) { send_error(thd); // Not seen by the client DBUG_VOID_RETURN; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index ecad84ba0cb..c30409fd0cb 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -961,8 +961,8 @@ void kill_zombie_dump_threads(uint32 slave_server_id) int change_master(THD* thd, MASTER_INFO* mi) { int thread_mask; - const char* errmsg=0; - bool need_relay_log_purge=1; + const char* errmsg= 0; + bool need_relay_log_purge= 1; DBUG_ENTER("change_master"); lock_slave_threads(mi); @@ -1055,6 +1055,37 @@ int change_master(THD* thd, MASTER_INFO* mi) mi->rli.group_relay_log_pos= mi->rli.event_relay_log_pos= lex_mi->relay_log_pos; } + /* + If user did specify neither host nor port nor any log name nor any log + pos, i.e. he specified only user/password/master_connect_retry, he probably + wants replication to resume from where it had left, i.e. from the + coordinates of the **SQL** thread (imagine the case where the I/O is ahead + of the SQL; restarting from the coordinates of the I/O would lose some + events which is probably unwanted when you are just doing minor changes + like changing master_connect_retry). + A side-effect is that if only the I/O thread was started, this thread may + restart from ''/4 after the CHANGE MASTER. That's a minor problem (it is a + much more unlikely situation than the one we are fixing here). + Note: coordinates of the SQL thread must be read here, before the + 'if (need_relay_log_purge)' block which resets them. + */ + if (!lex_mi->host && !lex_mi->port && + !lex_mi->log_file_name && !lex_mi->pos && + need_relay_log_purge) + { + /* + Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is + not initialized), so we use a max(). + What happens to mi->rli.master_log_pos during the initialization stages + of replication is not 100% clear, so we guard against problems using + max(). + */ + mi->master_log_pos = max(BIN_LOG_HEADER_SIZE, + mi->rli.group_master_log_pos); + strmake(mi->master_log_name, mi->rli.group_master_log_name, + sizeof(mi->master_log_name)-1); + } + flush_master_info(mi); if (need_relay_log_purge) { @@ -1087,10 +1118,21 @@ int change_master(THD* thd, MASTER_INFO* mi) } mi->rli.group_master_log_pos = mi->master_log_pos; DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); - /* If changing RELAY_LOG_FILE or RELAY_LOG_POS, this will be nonsense: */ + + /* + Coordinates in rli were spoilt by the 'if (need_relay_log_purge)' block, + so restore them to good values. If we left them to ''/0, that would work; + but that would fail in the case of 2 successive CHANGE MASTER (without a + START SLAVE in between): because first one would set the coords in mi to + the good values of those in rli, the set those in rli to ''/0, then + second CHANGE MASTER would set the coords in mi to those of rli, i.e. to + ''/0: we have lost all copies of the original good coordinates. + That's why we always save good coords in rli. + */ mi->rli.group_master_log_pos= mi->master_log_pos; strmake(mi->rli.group_master_log_name,mi->master_log_name, sizeof(mi->rli.group_master_log_name)-1); + if (!mi->rli.group_master_log_name[0]) // uninitialized case mi->rli.group_master_log_pos=0; @@ -1251,8 +1293,8 @@ int show_binlog_info(THD* thd) field_list.push_back(new Item_empty_string("File", FN_REFLEN)); field_list.push_back(new Item_return_int("Position",20, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_empty_string("Binlog_do_db",255)); - field_list.push_back(new Item_empty_string("Binlog_ignore_db",255)); + field_list.push_back(new Item_empty_string("Binlog_Do_DB",255)); + field_list.push_back(new Item_empty_string("Binlog_Ignore_DB",255)); if (protocol->send_fields(&field_list, 1)) DBUG_RETURN(-1); @@ -1291,9 +1333,7 @@ int show_binlogs(THD* thd) { IO_CACHE *index_file; char fname[FN_REFLEN]; - NET* net = &thd->net; List<Item> field_list; - String *packet = &thd->packet; uint length; Protocol *protocol= thd->protocol; DBUG_ENTER("show_binlogs"); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c7f9de2ef6d..44b403c0bb1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5590,6 +5590,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) int error; bool found=0; COND *on_expr=join_tab->on_expr, *select_cond=join_tab->select_cond; + my_bool *report_error= &(join->thd->net.report_error); if (!(error=(*join_tab->read_first_record)(join_tab))) { @@ -5628,9 +5629,9 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) else info->file->unlock_row(); } - } while (!(error=info->read_record(info))); + } while (!(error=info->read_record(info)) && !(*report_error)); } - if (error > 0) // Fatal error + if (error > 0 || (*report_error)) // Fatal error return -1; if (!found && on_expr) @@ -7227,7 +7228,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having) entry->file->info(HA_STATUS_VARIABLE); if (entry->db_type == DB_TYPE_HEAP || (!entry->blob_fields && - ((ALIGN_SIZE(reclength) +sizeof(HASH_LINK)) * entry->file->records < + ((ALIGN_SIZE(reclength) + HASH_OVERHEAD) * entry->file->records < thd->variables.sortbuff_size))) error=remove_dup_with_hash_index(join->thd, entry, field_count, first_field, @@ -7737,8 +7738,6 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, Item *itemptr=*order->item; if (itemptr->type() == Item::INT_ITEM) { /* Order by position */ - Item *item=0; - uint count= (uint) ((Item_int*)itemptr)->value; if (!count || count > fields.elements) { @@ -9040,10 +9039,12 @@ int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) ((sl == first)? ((sl->linkage == DERIVED_TABLE_TYPE) ? "DERIVED": - ((sl->dependent)?"DEPENDENT SUBQUERY": + ((sl->uncacheable & UNCACHEABLE_DEPENDENT)? + "DEPENDENT SUBQUERY": (sl->uncacheable?"UNCACHEABLE SUBQUERY": "SUBQUERY"))): - ((sl->dependent)?"DEPENDENT UNION": + ((sl->uncacheable & UNCACHEABLE_DEPENDENT)? + "DEPENDENT UNION": sl->uncacheable?"UNCACHEABLE UNION": "UNION"))), result); diff --git a/sql/sql_select.h b/sql/sql_select.h index 24854713a0e..5f0370a5a32 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -166,11 +166,23 @@ class JOIN :public Sql_alloc JOIN *tmp_join; // copy of this JOIN to be used with temporary tables ROLLUP rollup; // Used with rollup - bool select_distinct, //Is select distinct? - no_order, simple_order, simple_group, - skip_sort_order, need_tmp, - hidden_group_fields, - buffer_result; + bool select_distinct; // Set if SELECT DISTINCT + + /* + simple_xxxxx is set if ORDER/GROUP BY doesn't include any references + to other tables than the first non-constant table in the JOIN. + It's also set if ORDER/GROUP BY is empty. + */ + bool simple_order, simple_group; + /* + Is set only in case if we have a GROUP BY clause + and no ORDER BY after constant elimination of 'order'. + */ + bool no_order; + /* Is set if we have a GROUP BY and we have ORDER BY on a constant. */ + bool skip_sort_order; + + bool need_tmp, hidden_group_fields, buffer_result; DYNAMIC_ARRAY keyuse; Item::cond_result cond_value; List<Item> all_fields; // to store all fields that used in query diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 95a6ebb36fb..e24102a5094 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -702,7 +702,6 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, restore_record(table,default_values); // Get empty record Field **ptr,*field; - String *packet= &thd->packet; for (ptr=table->field; (field= *ptr) ; ptr++) { if (!wild || !wild[0] || @@ -892,7 +891,6 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) if (protocol->send_fields(&field_list,1)) DBUG_RETURN(1); - String *packet= &thd->packet; KEY *key_info=table->key_info; table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); for (uint i=0 ; i < table->keys ; i++,key_info++) @@ -1253,7 +1251,7 @@ store_create_info(THD *thd, TABLE *table, String *packet) !(thd->variables.sql_mode & MODE_MYSQL323) && !(thd->variables.sql_mode & MODE_MYSQL40)) { - packet->append(" CHARSET=", 9); + packet->append(" DEFAULT CHARSET=", 17); packet->append(table->table_charset->csname); if (!(table->table_charset->state & MY_CS_PRIMARY)) { @@ -1589,6 +1587,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, if (protocol->send_fields(&field_list,1)) DBUG_RETURN(1); /* purecov: inspected */ null_lex_str.str= 0; // For sys_var->value_ptr() + null_lex_str.length= 0; pthread_mutex_lock(mutex); for (; variables->name; variables++) @@ -1848,6 +1847,10 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, break; #endif /* HAVE_OPENSSL */ + case SHOW_KEY_CACHE_LONG: + value= (value-(char*) &dflt_key_cache_var)+ (char*) sql_key_cache; + end= int10_to_str(*(long*) value, buff, 10); + break; case SHOW_UNDEF: // Show never happen case SHOW_SYS: break; // Return empty string diff --git a/sql/sql_table.cc b/sql/sql_table.cc index d2d1926ea06..8504a408605 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -422,6 +422,12 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, for (field_no=0; (sql_field=it++) ; field_no++) { if (!sql_field->charset) + sql_field->charset= create_info->default_table_charset; + /* + table_charset is set in ALTER TABLE if we want change character set + for all varchar/char columns + */ + if (create_info->table_charset) sql_field->charset= create_info->table_charset; sql_field->create_length_to_internal_length(); @@ -437,7 +443,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, if (check_column_name(sql_field->field_name)) { - my_error(ER_WRONG_NAME, MYF(0), ER(ER_COLUMN), sql_field->field_name); + my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name); DBUG_RETURN(-1); } @@ -461,7 +467,9 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, { /* Field redefined */ sql_field->sql_type= dup_field->sql_type; - sql_field->charset= dup_field->charset ? dup_field->charset : create_info->table_charset; + sql_field->charset= (dup_field->charset ? + dup_field->charset : + create_info->default_table_charset); sql_field->length= dup_field->length; sql_field->pack_length= dup_field->pack_length; sql_field->create_length_to_internal_length(); @@ -484,8 +492,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, it.rewind(); while ((sql_field=it++)) { - if (!sql_field->charset) - sql_field->charset = create_info->table_charset; + DBUG_ASSERT(sql_field->charset); + switch (sql_field->sql_type) { case FIELD_TYPE_BLOB: case FIELD_TYPE_MEDIUM_BLOB: @@ -888,7 +896,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, } if (!key_info->name || check_column_name(key_info->name)) { - my_error(ER_WRONG_NAME, MYF(0), ER(ER_INDEX), key_info->name); + my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key_info->name); DBUG_RETURN(-1); } if (!(key_info->flags & HA_NULL_PART_KEY)) @@ -1625,13 +1633,26 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) -1 error */ -int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables) +int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, + LEX_STRING *key_cache_name) { + HA_CHECK_OPT check_opt; + KEY_CACHE *key_cache; DBUG_ENTER("mysql_assign_to_keycache"); - DBUG_RETURN(mysql_admin_table(thd, tables, 0, - "assign_to_keycache", TL_READ, 0, - HA_OPEN_TO_ASSIGN, 0, - &handler::assign_to_keycache)); + + check_opt.init(); + pthread_mutex_lock(&LOCK_global_system_variables); + if (!(key_cache= get_key_cache(key_cache_name))) + { + pthread_mutex_unlock(&LOCK_global_system_variables); + my_error(ER_UNKNOWN_KEY_CACHE, MYF(0), key_cache_name->str); + DBUG_RETURN(-1); + } + pthread_mutex_unlock(&LOCK_global_system_variables); + check_opt.key_cache= key_cache; + DBUG_RETURN(mysql_admin_table(thd, tables, &check_opt, + "assign_to_keycache", TL_READ_NO_INSERT, 0, + 0, 0, &handler::assign_to_keycache)); } @@ -1642,78 +1663,34 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables) reassign_keycache_tables() thd Thread object src_cache Reference to the key cache to clean up - dest_name Name of the cache to assign tables to - remove_fl Flag to destroy key cache when all tables are reassigned + dest_cache New key cache - RETURN VALUES + NOTES + This is called when one sets a key cache size to zero, in which + case we have to move the tables associated to this key cache to + the "default" one. + + One has to ensure that one never calls this function while + some other thread is changing the key cache. This is assured by + the caller setting src_cache->in_init before calling this function. + + We don't delete the old key cache as there may still be pointers pointing + to it for a while after this function returns. + + RETURN VALUES 0 ok - -1 error */ -int reassign_keycache_tables(THD* thd, KEY_CACHE_VAR* src_cache, - char *dest_name, bool remove_fl) +int reassign_keycache_tables(THD *thd, KEY_CACHE *src_cache, + KEY_CACHE *dst_cache) { - int rc= 0; - TABLE_LIST table; - KEY_CACHE_ASMT *key_cache_asmt; - DBUG_ENTER("reassign_keycache_tables"); - VOID(pthread_mutex_lock(&LOCK_assign)); - for (key_cache_asmt= src_cache->assign_list ; - key_cache_asmt; - key_cache_asmt= key_cache_asmt->next) - key_cache_asmt->to_reassign = 1; - key_cache_asmt= src_cache->assign_list; - while (key_cache_asmt) - { - if (key_cache_asmt->to_reassign) - { - bool refresh; - VOID(pthread_mutex_unlock(&LOCK_assign)); - bzero((byte *) &table, sizeof(table)); - table.option= dest_name; - table.db= key_cache_asmt->db_name; - table.alias= table.real_name= key_cache_asmt->table_name; - thd->open_options|= HA_OPEN_TO_ASSIGN; - while (!(table.table=open_table(thd,table.db, - table.real_name,table.alias, - &refresh)) && refresh) ; - thd->open_options&= ~HA_OPEN_TO_ASSIGN; - if (!table.table) - DBUG_RETURN(-1); - table.table->pos_in_table_list= &table; - key_cache_asmt->triggered= 1; - rc= table.table->file->assign_to_keycache(thd, 0); - close_thread_tables(thd); - if (rc) - DBUG_RETURN(rc); - VOID(pthread_mutex_lock(&LOCK_assign)); - key_cache_asmt= src_cache->assign_list; - continue; - } - else - key_cache_asmt= key_cache_asmt->next; - } - - while (src_cache->assignments) - { - struct st_my_thread_var *waiting_thread= my_thread_var; - pthread_cond_wait(&waiting_thread->suspend, &LOCK_assign); - } - if (src_cache->extra_info) - { - my_free((char *) src_cache->extra_info, MYF(0)); - src_cache->extra_info= 0; - } - - if (remove_fl && !src_cache->assign_list && src_cache != &dflt_key_cache_var) - { - end_key_cache(&src_cache->cache, 1); - src_cache->buff_size= 0; - src_cache->block_size= 0; - } - VOID(pthread_mutex_unlock(&LOCK_assign)); + DBUG_ASSERT(src_cache != dst_cache); + DBUG_ASSERT(src_cache->in_init); + src_cache->param_buff_size= 0; // Free key cache + ha_resize_key_cache(src_cache); + ha_change_key_cache(src_cache, dst_cache); DBUG_RETURN(0); } @@ -1766,7 +1743,6 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table, char *src_db= thd->db; char *src_table= table_ident->table.str; int err; - DBUG_ENTER("mysql_create_like_table"); /* @@ -1777,7 +1753,7 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table, check_table_name(src_table,table_ident->table.length)) || table_ident->db.str && check_db_name((src_db= table_ident->db.str))) { - my_error(ER_WRONG_NAME, MYF(0), ER(ER_TABLE), src_table); + my_error(ER_WRONG_TABLE_NAME, MYF(0), src_table); DBUG_RETURN(-1); } @@ -1978,7 +1954,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ulonglong next_insert_id; uint save_time_stamp,db_create_options, used_fields; enum db_type old_db_type,new_db_type; - thr_lock_type lock_type; DBUG_ENTER("mysql_alter_table"); thd->proc_info="init"; @@ -2126,8 +2101,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, create_info->max_rows=table->max_rows; if (!(used_fields & HA_CREATE_USED_AVG_ROW_LENGTH)) create_info->avg_row_length=table->avg_row_length; - if (!(used_fields & HA_CREATE_USED_CHARSET)) - create_info->table_charset=table->table_charset; + if (!(used_fields & HA_CREATE_USED_DEFAULT_CHARSET)) + create_info->default_table_charset= table->table_charset; restore_record(table,default_values); // Empty record for DEFAULT List_iterator<Alter_drop> drop_it(drop_list); @@ -2821,7 +2796,6 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) for (table= tables; table; table= table->next) { char table_name[NAME_LEN*2+2]; - bool fatal_error= 0; TABLE *t; strxmov(table_name, table->db ,".", table->real_name, NullS); diff --git a/sql/sql_test.cc b/sql/sql_test.cc index c14d30f8d34..6763181ce4a 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -28,9 +28,6 @@ #include <sys/malloc.h> #endif -/* Intern key cache variables */ -extern "C" pthread_mutex_t THR_LOCK_keycache; - static const char *lock_descriptions[] = { "No lock", @@ -229,7 +226,9 @@ static int dl_compare(TABLE_LOCK_INFO *a,TABLE_LOCK_INFO *b) return 1; } -static void push_locks_into_array(DYNAMIC_ARRAY *ar, THR_LOCK_DATA *data, bool wait, const char *text) + +static void push_locks_into_array(DYNAMIC_ARRAY *ar, THR_LOCK_DATA *data, + bool wait, const char *text) { if (data) { @@ -238,31 +237,34 @@ static void push_locks_into_array(DYNAMIC_ARRAY *ar, THR_LOCK_DATA *data, bool w { TABLE_LOCK_INFO table_lock_info; table_lock_info.thread_id=table->in_use->thread_id; - memcpy(table_lock_info.table_name, table->table_cache_key, table->key_length); + memcpy(table_lock_info.table_name, table->table_cache_key, + table->key_length); table_lock_info.table_name[strlen(table_lock_info.table_name)]='.'; table_lock_info.waiting=wait; table_lock_info.lock_text=text; - table_lock_info.type=table->reginfo.lock_type; // obtainable also from THR_LOCK_DATA + // lock_type is also obtainable from THR_LOCK_DATA + table_lock_info.type=table->reginfo.lock_type; VOID(push_dynamic(ar,(gptr) &table_lock_info)); } } } -/* - Regarding MERGE tables: -For now, the best option is to use the common TABLE *pointer for all -cases; The drawback is that for MERGE tables we will see many locks -for the merge tables even if some of them are for individual tables. -The way to solve this is to add to 'THR_LOCK' structure a pointer to -the filename and use this when printing the data. -(We can for now ignore this and just print the same name for all merge -table parts; Please add the above as a comment to the display_lock -function so that we can easily add this if we ever need this. +/* + Regarding MERGE tables: + + For now, the best option is to use the common TABLE *pointer for all + cases; The drawback is that for MERGE tables we will see many locks + for the merge tables even if some of them are for individual tables. + The way to solve this is to add to 'THR_LOCK' structure a pointer to + the filename and use this when printing the data. + (We can for now ignore this and just print the same name for all merge + table parts; Please add the above as a comment to the display_lock + function so that we can easily add this if we ever need this. */ -static void display_table_locks (void) +static void display_table_locks(void) { LIST *list; DYNAMIC_ARRAY saved_table_locks; @@ -301,6 +303,36 @@ end: } +static int print_key_cache_status(const char *name, KEY_CACHE *key_cache) +{ + if (!key_cache->key_cache_inited) + { + printf("%s: Not in use\n", name); + } + else + { + printf("%s\n\ +Buffer_size: %10lu\n\ +Block_size: %10lu\n\ +Division_limit: %10lu\n\ +Age_limit: %10lu\n\ +blocks used: %10lu\n\ +not flushed: %10lu\n\ +w_requests: %10lu\n\ +writes: %10lu\n\ +r_requests: %10lu\n\ +reads: %10lu\n\n", + name, + (ulong) key_cache->param_buff_size, key_cache->param_block_size, + key_cache->param_division_limit, key_cache->param_age_threshold, + key_cache->global_blocks_used,key_cache->global_blocks_changed, + key_cache->global_cache_w_requests,key_cache->global_cache_write, + key_cache->global_cache_r_requests,key_cache->global_cache_read); + } + return 0; +} + + void mysql_print_status(THD *thd) { char current_dir[FN_REFLEN]; @@ -320,19 +352,8 @@ void mysql_print_status(THD *thd) /* Print key cache status */ if (thd) thd->proc_info="key cache"; - pthread_mutex_lock(&THR_LOCK_keycache); - printf("key_cache status:\n\ -blocks used:%10lu\n\ -not flushed:%10lu\n\ -w_requests: %10lu\n\ -writes: %10lu\n\ -r_requests: %10lu\n\ -reads: %10lu\n", - dflt_key_cache_var.blocks_used,dflt_key_cache_var.blocks_changed, - dflt_key_cache_var.cache_w_requests,dflt_key_cache_var.cache_write, - dflt_key_cache_var.cache_r_requests,dflt_key_cache_var.cache_read); - pthread_mutex_unlock(&THR_LOCK_keycache); - + puts("\nKey caches:"); + process_key_caches(print_key_cache_status); if (thd) thd->proc_info="status"; pthread_mutex_lock(&LOCK_status); diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 93541d66d65..5292299f928 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -249,11 +249,11 @@ int st_select_lex_unit::exec() ulonglong add_rows=0; DBUG_ENTER("st_select_lex_unit::exec"); - if (executed && !(dependent || uncacheable)) + if (executed && !uncacheable) DBUG_RETURN(0); executed= 1; - if ((dependent || uncacheable) || !item || !item->assigned()) + if (uncacheable || !item || !item->assigned()) { if (optimized && item && item->assigned()) { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index bb37c58004f..0dbe14fd2ab 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -588,7 +588,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); IDENT IDENT_QUOTED TEXT_STRING REAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM LEX_HOSTNAME ULONGLONG_NUM field_ident select_alias ident ident_or_text UNDERSCORE_CHARSET IDENT_sys TEXT_STRING_sys TEXT_STRING_literal - NCHAR_STRING opt_component + NCHAR_STRING opt_component key_cache_name %type <lex_str_ptr> opt_table_alias @@ -925,7 +925,7 @@ create: bzero((char*) &lex->create_info,sizeof(lex->create_info)); lex->create_info.options=$2 | $4; lex->create_info.db_type= (enum db_type) lex->thd->variables.table_type; - lex->create_info.table_charset= thd->variables.collation_database; + lex->create_info.default_table_charset= thd->variables.collation_database; lex->name=0; } create2 @@ -950,7 +950,7 @@ create: lex->col_list.empty(); } | CREATE DATABASE opt_if_not_exists ident - { Lex->create_info.table_charset=NULL; } + { Lex->create_info.default_table_charset=NULL; } opt_create_database_options { LEX *lex=Lex; @@ -1037,10 +1037,10 @@ create_database_options: | create_database_options create_database_option {}; create_database_option: - COLLATE_SYM collation_name_or_default - { Lex->create_info.table_charset=$2; } + opt_default COLLATE_SYM collation_name_or_default + { Lex->create_info.default_table_charset=$3; } | opt_default charset charset_name_or_default - { Lex->create_info.table_charset=$3; } + { Lex->create_info.default_table_charset=$3; } ; opt_table_options: @@ -1100,11 +1100,21 @@ create_table_option: table_list->next=0; lex->create_info.used_fields|= HA_CREATE_USED_UNION; } - | opt_default charset opt_equal charset_name_or_default + | DEFAULT charset opt_equal charset_name_or_default { - Lex->create_info.table_charset= $4; + Lex->create_info.default_table_charset= $4; + Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; + } + | charset opt_equal charset_name_or_default + { + Lex->create_info.table_charset= $3; Lex->create_info.used_fields|= HA_CREATE_USED_CHARSET; } + | DEFAULT COLLATE_SYM opt_equal collation_name_or_default + { + Lex->create_info.table_charset= $4; + Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; + } | COLLATE_SYM opt_equal collation_name_or_default { Lex->create_info.table_charset= $3; @@ -1578,6 +1588,11 @@ key_or_index: KEY_SYM {} | INDEX {}; +opt_keys_or_index: + /* empty */ {} + | keys_or_index + ; + keys_or_index: KEYS {} | INDEX {} @@ -1644,7 +1659,7 @@ alter: lex->select_lex.db=lex->name=0; bzero((char*) &lex->create_info,sizeof(lex->create_info)); lex->create_info.db_type= DB_TYPE_DEFAULT; - lex->create_info.table_charset= thd->variables.collation_database; + lex->create_info.default_table_charset= thd->variables.collation_database; lex->create_info.row_type= ROW_TYPE_NOT_USED; lex->alter_keys_onoff=LEAVE_AS_IS; lex->tablespace_op=NO_TABLESPACE_OP; @@ -1990,13 +2005,12 @@ table_to_table: }; keycache: - CACHE_SYM INDEX + CACHE_SYM INDEX keycache_list IN_SYM key_cache_name { LEX *lex=Lex; - lex->sql_command=SQLCOM_ASSIGN_TO_KEYCACHE; + lex->sql_command= SQLCOM_ASSIGN_TO_KEYCACHE; + lex->name_and_length= $5; } - keycache_list - {} ; keycache_list: @@ -2004,30 +2018,23 @@ keycache_list: | keycache_list ',' assign_to_keycache; assign_to_keycache: - table_ident cache_keys_spec IN_SYM ident + table_ident cache_keys_spec { LEX *lex=Lex; SELECT_LEX *sel= &lex->select_lex; if (!sel->add_table_to_list(lex->thd, $1, NULL, 0, TL_READ, sel->get_use_index(), - (List<String> *)0, - &($4))) - YYABORT; - } - | - table_ident cache_keys_spec IN_SYM DEFAULT - { - LEX *lex=Lex; - SELECT_LEX *sel= &lex->select_lex; - if (!sel->add_table_to_list(lex->thd, $1, NULL, 0, - TL_READ, - sel->get_use_index(), - (List<String> *)0)) + (List<String> *)0)) YYABORT; } ; +key_cache_name: + ident { $$= $1; } + | DEFAULT { $$ = default_key_cache_base; } + ; + preload: LOAD INDEX INTO CACHE_SYM { @@ -2056,19 +2063,22 @@ preload_keys: ; cache_keys_spec: - keys_or_index { Select->interval_list.empty(); } + { Select->interval_list.empty(); } cache_key_list_or_empty { LEX *lex=Lex; SELECT_LEX *sel= &lex->select_lex; sel->use_index= sel->interval_list; - sel->use_index_ptr= &sel->use_index; } ; cache_key_list_or_empty: - /* empty */ - | '(' key_usage_list2 ')' {} + /* empty */ { Lex->select_lex.use_index_ptr= 0; } + | opt_keys_or_index '(' key_usage_list2 ')' + { + SELECT_LEX *sel= &Lex->select_lex; + sel->use_index_ptr= &sel->use_index; + } ; opt_ignore_leaves: @@ -2197,7 +2207,7 @@ select_option: YYABORT; Select->options|= OPTION_FOUND_ROWS; } - | SQL_NO_CACHE_SYM { Lex->uncacheable(); } + | SQL_NO_CACHE_SYM { Lex->safe_to_cache_query=0; } | SQL_CACHE_SYM { Lex->select_lex.options|= OPTION_TO_QUERY_CACHE; @@ -2466,12 +2476,12 @@ simple_expr: | '@' ident_or_text SET_VAR expr { $$= new Item_func_set_user_var($2,$4); - Lex->uncacheable(); + Lex->uncacheable(UNCACHEABLE_RAND); } | '@' ident_or_text { $$= new Item_func_get_user_var($2); - Lex->uncacheable(); + Lex->uncacheable(UNCACHEABLE_RAND); } | '@' '@' opt_var_ident_type ident_or_text opt_component { @@ -2587,7 +2597,7 @@ simple_expr: | ENCRYPT '(' expr ')' { $$= new Item_func_encrypt($3); - Lex->uncacheable(); + Lex->uncacheable(UNCACHEABLE_RAND); } | ENCRYPT '(' expr ',' expr ')' { $$= new Item_func_encrypt($3,$5); } | DECODE_SYM '(' expr ',' TEXT_STRING_literal ')' @@ -2755,9 +2765,9 @@ simple_expr: | POSITION_SYM '(' no_in_expr IN_SYM expr ')' { $$ = new Item_func_locate($5,$3); } | RAND '(' expr ')' - { $$= new Item_func_rand($3); Lex->uncacheable();} + { $$= new Item_func_rand($3); Lex->uncacheable(UNCACHEABLE_RAND);} | RAND '(' ')' - { $$= new Item_func_rand(); Lex->uncacheable();} + { $$= new Item_func_rand(); Lex->uncacheable(UNCACHEABLE_RAND);} | REPLACE '(' expr ',' expr ',' expr ')' { $$= new Item_func_replace($3,$5,$7); } | RIGHT '(' expr ',' expr ')' @@ -2884,7 +2894,7 @@ simple_expr: | BENCHMARK_SYM '(' ULONG_NUM ',' expr ')' { $$=new Item_func_benchmark($3,$5); - Lex->uncacheable(); + Lex->uncacheable(UNCACHEABLE_SIDEEFFECT); } | EXTRACT_SYM '(' interval FROM expr ')' { $$=new Item_extract( $3, $5); }; @@ -3464,7 +3474,7 @@ procedure_clause: lex->proc_list.next= (byte**) &lex->proc_list.first; if (add_proc_to_list(lex->thd, new Item_field(NULL,NULL,$2.str))) YYABORT; - Lex->uncacheable(); + Lex->uncacheable(UNCACHEABLE_SIDEEFFECT); } '(' procedure_list ')'; @@ -3518,7 +3528,7 @@ into: LEX *lex=Lex; if (!lex->describe) { - lex->uncacheable(); + lex->uncacheable(UNCACHEABLE_SIDEEFFECT); if (!(lex->exchange= new sql_exchange($3.str,0))) YYABORT; if (!(lex->result= new select_export(lex->exchange))) @@ -3531,7 +3541,7 @@ into: LEX *lex=Lex; if (!lex->describe) { - lex->uncacheable(); + lex->uncacheable(UNCACHEABLE_SIDEEFFECT); if (!(lex->exchange= new sql_exchange($3.str,1))) YYABORT; if (!(lex->result= new select_dump(lex->exchange))) @@ -3540,7 +3550,7 @@ into: } | INTO select_var_list_init { - Lex->uncacheable(); + Lex->uncacheable(UNCACHEABLE_SIDEEFFECT); } ; @@ -3895,7 +3905,8 @@ opt_delete_options: opt_delete_option: QUICK { Select->options|= OPTION_QUICK; } - | LOW_PRIORITY { Lex->lock_option= TL_WRITE_LOW_PRIORITY; }; + | LOW_PRIORITY { Lex->lock_option= TL_WRITE_LOW_PRIORITY; } + | IGNORE_SYM { Lex->duplicates= DUP_IGNORE; }; truncate: TRUNCATE_SYM opt_table_sym table_name diff --git a/sql/strfunc.cc b/sql/strfunc.cc index 1db2124bcee..d00e57df5a1 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -112,7 +112,7 @@ uint find_type(TYPELIB *lib, const char *find, uint length, bool part_match) found_pos= pos; } } - return(found_count == 1 && part_match ? found_count : 0); + return(found_count == 1 && part_match ? found_pos : 0); } diff --git a/sql/structs.h b/sql/structs.h index 352823cceb2..37208e63400 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -173,7 +173,7 @@ enum SHOW_TYPE SHOW_SSL_CTX_SESS_TIMEOUTS, SHOW_SSL_CTX_SESS_CACHE_FULL, SHOW_SSL_GET_CIPHER_LIST, #endif /* HAVE_OPENSSL */ - SHOW_RPL_STATUS, SHOW_SLAVE_RUNNING + SHOW_RPL_STATUS, SHOW_SLAVE_RUNNING, SHOW_KEY_CACHE_LONG }; enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED}; diff --git a/sql/table.cc b/sql/table.cc index 14853011510..e87cafd5275 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1134,7 +1134,8 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo, int2store(fileinfo+30,create_info->table_options); fileinfo[32]=0; // No filename anymore int4store(fileinfo+34,create_info->avg_row_length); - fileinfo[38]= create_info->table_charset?create_info->table_charset->number:0; + fileinfo[38]= (create_info->default_table_charset ? + create_info->default_table_charset->number : 0); fileinfo[40]= (uchar) create_info->row_type; fileinfo[41]= (uchar) create_info->raid_type; fileinfo[42]= (uchar) create_info->raid_chunks; @@ -1165,7 +1166,8 @@ void update_create_info_from_table(HA_CREATE_INFO *create_info, TABLE *table) create_info->raid_type=table->raid_type; create_info->raid_chunks=table->raid_chunks; create_info->raid_chunksize=table->raid_chunksize; - create_info->table_charset=table->table_charset; + create_info->default_table_charset=table->table_charset; + create_info->table_charset= 0; DBUG_VOID_RETURN; } diff --git a/sql/table.h b/sql/table.h index b9c6a72bb09..4dcd24b2aff 100644 --- a/sql/table.h +++ b/sql/table.h @@ -56,30 +56,6 @@ typedef struct st_filesort_info } FILESORT_INFO; -/* Table key cache assignment descriptor */ -/* - In future the similar structure is to be used for - an assignment of an index to a key cache: the index name will be added. - The name of the database catalog will be added as well. - The descriptors for the current assignments are put in the - assignment cache: assign_cache. If a table is not found in the cache - it is considered assigned to the default key cache. -*/ -typedef struct st_key_cache_asmt -{ - char *db_name; /* db the table belongs to */ - char *table_name; /* the name of the table */ - char *table_key; /* key for the assignment cache */ - uint key_length; /* the length of this key */ - struct st_key_cache_var *key_cache; /* reference to the key cache */ - struct st_key_cache_asmt **prev; /* links in the chain all assignments */ - struct st_key_cache_asmt *next; /* to this cache */ - struct st_my_thread_var *queue; /* queue of requests for assignment */ - uint requests; /* number of current requests */ - bool to_reassign; /* marked when reassigning all cache */ - bool triggered; /* marked when assignment is triggered*/ -} KEY_CACHE_ASMT; - /* Table cache entry struct */ class Field_timestamp; @@ -87,13 +63,11 @@ class Field_blob; struct st_table { handler *file; - KEY_CACHE_VAR *key_cache; /* Ref to the key cache the table assigned to*/ - KEY_CACHE_ASMT *key_cache_asmt;/* Only when opened for key cache assignment */ - Field **field; /* Pointer to fields */ + Field **field; /* Pointer to fields */ Field_blob **blob_field; /* Pointer to blob fields */ HASH name_hash; /* hash of field names */ byte *record[2]; /* Pointer to records */ - byte *default_values; /* Record with default values for INSERT */ + byte *default_values; /* Default values for INSERT */ byte *insert_values; /* used by INSERT ... UPDATE */ uint fields; /* field count */ uint reclength; /* Recordlength */ diff --git a/sql/time.cc b/sql/time.cc index e696918dee3..fe22b80d59d 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -357,7 +357,6 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags) const char *end=str+length; const uchar *format_position; bool found_delimitier= 0, found_space= 0; - DATE_TIME_FORMAT *format; DBUG_ENTER("str_to_TIME"); DBUG_PRINT("ENTER",("str: %.*s",length,str)); diff --git a/sql/uniques.cc b/sql/uniques.cc index 4514de834a8..f289fd11f5b 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -132,7 +132,8 @@ bool Unique::get(TABLE *table) bzero((char*) &sort_param,sizeof(sort_param)); sort_param.max_rows= elements; sort_param.sort_form=table; - sort_param.sort_length=sort_param.ref_length=tree.size_of_element; + sort_param.rec_length= sort_param.sort_length=sort_param.ref_length= + tree.size_of_element; sort_param.keys= max_in_memory_size / sort_param.sort_length; sort_param.not_killable=1; diff --git a/sql/unireg.h b/sql/unireg.h index 8d62959317d..2da25edd72a 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -68,7 +68,8 @@ #define MAX_DATETIME_FULL_WIDTH 29 /* YYYY-MM-DD HH:MM:SS.###### AM */ #define MAX_DATETIME_WIDTH 19 /* YYYY-MM-DD HH:MM:SS */ -#define MAX_TABLES (sizeof(table_map)*8-2) /* Max tables in join */ +#define MAX_TABLES (sizeof(table_map)*8-3) /* Max tables in join */ +#define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3)) #define OUTER_REF_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-2)) #define RAND_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-1)) #define MAX_FIELDS 4096 /* Limit in the .frm file */ @@ -145,10 +146,10 @@ #define MTYP_NOEMPTY_BIT 128 /* - * Minimum length pattern before Turbo Boyer-Moore is used - * for SELECT "text" LIKE "%pattern%", excluding the two - * wildcards in class Item_func_like. - */ + Minimum length pattern before Turbo Boyer-Moore is used + for SELECT "text" LIKE "%pattern%", excluding the two + wildcards in class Item_func_like. +*/ #define MIN_TURBOBM_PATTERN_LEN 3 /* @@ -160,7 +161,9 @@ #define BIN_LOG_HEADER_SIZE 4 #define FLOATING_POINT_BUFFER 331 - /* Include prototypes for unireg */ +#define DEFAULT_KEY_CACHE_NAME "default" + +/* Include prototypes for unireg */ #include "mysqld_error.h" #include "structs.h" /* All structs we need */ diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index fd5e58ad8a7..a2edc33b3d2 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -472,13 +472,13 @@ static uchar *thai2sortable(const uchar *tstr, uint len, uint *out_length) const uchar *p= tstr; uchar *outBuf; uchar *pRight1, *pRight2, *pRight3; - uchar *pLeft1, *pLeft2, *pLeft3; + uchar *pLeft2, *pLeft3; uint bufSize; uint RightSize; bufSize= (uint) (len + 1) * BUFFER_MULTIPLY; RightSize= sizeof(uchar) * (len + 1); - if (!(outBuf= pLeft1= pRight1= + if (!(outBuf= pRight1= (uchar *)malloc(sizeof(uchar) * bufSize + RightSize*2))) { /* @@ -608,8 +608,8 @@ int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)), int my_strcoll_tis620(const uchar * s1, const uchar * s2) { - return my_strnncoll_tis620((CHARSET_INFO *) 0, s1, strlen(s1), s2, - strlen(s1)); + return my_strnncoll_tis620((CHARSET_INFO *) 0, s1, strlen((char*) s1), + s2, strlen((char*) s1)); } diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index cf324fb4468..6319fbb4d9f 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -15,10 +15,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <my_global.h> +#include <my_sys.h> #include <m_string.h> +#undef ULONGLONG_MAX #define ULONGLONG_MAX (~(ulonglong) 0) -#define MAX_NEGATIVE_NUMBER ((ulonglong) 0x8000000000000000LL) +#define MAX_NEGATIVE_NUMBER ((ulonglong) LL(0x8000000000000000)) #define INIT_CNT 9 #define LFACTOR LL(1000000000) #define LFACTOR1 LL(10000000000) @@ -80,7 +82,7 @@ longlong my_strtoll10(const char *nptr, char **endptr, int *error) unsigned long i, j, k; ulonglong li; int negative; - long cutoff, cutoff2, cutoff3; + ulong cutoff, cutoff2, cutoff3; s= nptr; /* If fixed length string */ diff --git a/tests/client_test.c b/tests/client_test.c index fd9eb380228..517cac39d1b 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -72,60 +72,55 @@ static double total_time; static void print_error(const char *msg); static void print_st_error(MYSQL_STMT *stmt, const char *msg); -static void check_errcode(const unsigned int err); static void client_disconnect(); #define myerror(msg) print_error(msg) #define mysterror(stmt, msg) print_st_error(stmt, msg) -#define myerrno(n) check_errcode(n) - -#define myassert(exp) assert(exp) -#define myassert_r(exp) assert(!(exp)) #define myquery(r) \ { \ if (r) \ myerror(NULL); \ - myassert(r == 0); \ + assert(r == 0); \ } #define myquery_r(r) \ { \ if (r) \ myerror(NULL); \ -myassert_r(r == 0); \ +assert(r != 0); \ } #define mystmt(stmt,r) \ { \ if (r) \ mysterror(stmt,NULL); \ -myassert(r == 0);\ +assert(r == 0);\ } #define mystmt_r(stmt,r) \ { \ if (r) \ mysterror(stmt,NULL); \ -myassert_r(r == 0);\ +assert(r != 0);\ } #define mystmt_init(stmt) \ { \ if ( stmt == 0) \ myerror(NULL); \ -myassert(stmt != 0); \ +assert(stmt != 0); \ } #define mystmt_init_r(stmt) \ { \ if (stmt == 0) \ myerror(NULL);\ -myassert(stmt == 0);\ +assert(stmt == 0);\ } -#define mytest(x) if (!x) {myerror(NULL);myassert(TRUE);} -#define mytest_r(x) if (x) {myerror(NULL);myassert(TRUE);} +#define mytest(x) if (!x) {myerror(NULL);assert(TRUE);} +#define mytest_r(x) if (x) {myerror(NULL);assert(TRUE);} /******************************************************** * print the error message * @@ -143,16 +138,6 @@ static void print_error(const char *msg) else if (msg) fprintf(stderr, " [MySQL] %s\n", msg); } -static void check_errcode(const unsigned int err) -{ - if (mysql->server_version) - fprintf(stdout,"\n [MySQL-%s]",mysql->server_version); - else - fprintf(stdout,"\n [MySQL]"); - fprintf(stdout,"[%d] %s\n",mysql_errno(mysql),mysql_error(mysql)); - myassert(mysql_errno(mysql) == err); -} - static void print_st_error(MYSQL_STMT *stmt, const char *msg) { if (stmt && mysql_stmt_errno(stmt)) @@ -523,7 +508,7 @@ static void verify_col_data(const char *table, const char *col, } fprintf(stdout,"\n obtained: `%s` (expected: `%s`)", row[field], exp_data); - myassert(strcmp(row[field],exp_data) == 0); + assert(strcmp(row[field],exp_data) == 0); mysql_free_result(result); } @@ -556,15 +541,15 @@ static void verify_prepare_field(MYSQL_RES *result, fprintf(stdout,"\n charsetnr:`%d`", field->charsetnr); fprintf(stdout,"\n default :`%s`\t(expected: `%s`)", field->def ? field->def : "(null)", def ? def: "(null)"); fprintf(stdout,"\n"); - myassert(strcmp(field->name,name) == 0); - myassert(strcmp(field->org_name,org_name) == 0); - myassert(field->type == type); - myassert(strcmp(field->table,table) == 0); - myassert(strcmp(field->org_table,org_table) == 0); - myassert(strcmp(field->db,db) == 0); - myassert(field->length == length); + assert(strcmp(field->name,name) == 0); + assert(strcmp(field->org_name,org_name) == 0); + assert(field->type == type); + assert(strcmp(field->table,table) == 0); + assert(strcmp(field->org_table,org_table) == 0); + assert(strcmp(field->db,db) == 0); + assert(field->length == length); if (def) - myassert(strcmp(field->def,def) == 0); + assert(strcmp(field->def,def) == 0); } /* @@ -575,7 +560,7 @@ static void verify_param_count(MYSQL_STMT *stmt, long exp_count) long param_count= mysql_param_count(stmt); fprintf(stdout,"\n total parameters in stmt: `%ld` (expected: `%ld`)", param_count, exp_count); - myassert(param_count == exp_count); + assert(param_count == exp_count); } /* @@ -586,7 +571,7 @@ static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count) ulonglong affected_rows= mysql_stmt_affected_rows(stmt); fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); - myassert(affected_rows == exp_count); + assert(affected_rows == exp_count); } /* @@ -597,7 +582,7 @@ static void verify_affected_rows(ulonglong exp_count) ulonglong affected_rows= mysql_affected_rows(mysql); fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); - myassert(affected_rows == exp_count); + assert(affected_rows == exp_count); } /* @@ -608,7 +593,7 @@ static void verify_field_count(MYSQL_RES *result, uint exp_count) uint field_count= mysql_num_fields(result); fprintf(stdout,"\n total fields in the result set: `%d` (expected: `%d`)", field_count, exp_count); - myassert(field_count == exp_count); + assert(field_count == exp_count); } /* @@ -630,7 +615,7 @@ static void execute_prepare_query(const char *query, ulonglong exp_count) fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); - myassert(affected_rows == exp_count); + assert(affected_rows == exp_count); mysql_stmt_close(stmt); } @@ -1174,7 +1159,7 @@ static void test_prepare() myquery(rc); /* test the results now, only one row should exists */ - myassert(tiny_data == (char) my_stmt_result("SELECT * FROM my_prepare",50)); + assert(tiny_data == (char) my_stmt_result("SELECT * FROM my_prepare",50)); stmt = mysql_prepare(mysql,"SELECT * FROM my_prepare",50); mystmt_init(stmt); @@ -1212,27 +1197,27 @@ static void test_prepare() fprintf(stdout, "\n\t str : %s (%lu)", str_data, length[1]); - myassert(tiny_data == o_tiny_data); - myassert(is_null[0] == 0); - myassert(length[0] == 1); + assert(tiny_data == o_tiny_data); + assert(is_null[0] == 0); + assert(length[0] == 1); - myassert(int_data == o_int_data); - myassert(length[2] == 4); + assert(int_data == o_int_data); + assert(length[2] == 4); - myassert(small_data == o_small_data); - myassert(length[3] == 2); + assert(small_data == o_small_data); + assert(length[3] == 2); - myassert(big_data == o_big_data); - myassert(length[4] == 8); + assert(big_data == o_big_data); + assert(length[4] == 8); - myassert(real_data == o_real_data); - myassert(length[5] == 4); + assert(real_data == o_real_data); + assert(length[5] == 4); - myassert(double_data == o_double_data); - myassert(length[6] == 8); + assert(double_data == o_double_data); + assert(length[6] == 8); - myassert(strcmp(data,str_data) == 0); - myassert(length[1] == len); + assert(strcmp(data,str_data) == 0); + assert(length[1] == len); o_int_data += 25; o_small_data += 10; @@ -1242,7 +1227,7 @@ static void test_prepare() } rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -1333,7 +1318,7 @@ static void test_double_compare() result = mysql_store_result(mysql); mytest(result); - myassert((int)tiny_data == my_process_result_set(result)); + assert((int)tiny_data == my_process_result_set(result)); mysql_free_result(result); } @@ -1408,7 +1393,7 @@ static void test_null() myquery(rc); nData*= 2; - myassert(nData == my_stmt_result("SELECT * FROM test_null", 30)); + assert(nData == my_stmt_result("SELECT * FROM test_null", 30)); /* Fetch results */ bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -1431,12 +1416,12 @@ static void test_null() is_null[0]= is_null[1]= 0; while (mysql_fetch(stmt) != MYSQL_NO_DATA) { - myassert(is_null[0]); - myassert(is_null[1]); + assert(is_null[0]); + assert(is_null[1]); rc++; is_null[0]= is_null[1]= 0; } - myassert(rc == (int)nData); + assert(rc == (int)nData); mysql_stmt_close(stmt); } @@ -1490,7 +1475,7 @@ static void test_fetch_null() strmov((char *)query , "SELECT * FROM test_fetch_null"); - myassert(3 == my_stmt_result(query,50)); + assert(3 == my_stmt_result(query,50)); stmt = mysql_prepare(mysql, query, 50); mystmt_init(stmt); @@ -1509,14 +1494,14 @@ static void test_fetch_null() { fprintf(stdout, "\n data[%d] : %s", i, is_null[i] ? "NULL" : "NOT NULL"); - myassert(is_null[i]); + assert(is_null[i]); } fprintf(stdout, "\n data[%d]: %d", i, nData); - myassert(nData == 1000 || nData == 88 || nData == 389789); - myassert(is_null[i] == 0); - myassert(length[i] == 4); + assert(nData == 1000 || nData == 88 || nData == 389789); + assert(is_null[i] == 0); + assert(length[i] == 4); } - myassert(rc == 3); + assert(rc == 3); mysql_stmt_close(stmt); } @@ -1651,7 +1636,7 @@ static void test_select_prepare() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); rc = mysql_query(mysql,"DROP TABLE test_select"); @@ -1681,7 +1666,7 @@ static void test_select_prepare() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -1757,7 +1742,7 @@ static void test_select() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); mysql_stmt_close(stmt); } @@ -1808,7 +1793,7 @@ session_id char(9) NOT NULL, \ rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); strmov(szData,(char *)"venu"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1824,7 +1809,7 @@ session_id char(9) NOT NULL, \ rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 0); + assert(my_process_stmt_result(stmt) == 0); strmov(szData,(char *)"abc"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1840,7 +1825,7 @@ session_id char(9) NOT NULL, \ rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); mysql_stmt_close(stmt); } @@ -1886,7 +1871,7 @@ static void test_bug1180() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 0); + assert(my_process_stmt_result(stmt) == 0); strmov(szData,(char *)"1111"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1902,7 +1887,7 @@ static void test_bug1180() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); strmov(szData,(char *)"abc"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1918,7 +1903,7 @@ static void test_bug1180() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 0); + assert(my_process_stmt_result(stmt) == 0); mysql_stmt_close(stmt); } @@ -1998,7 +1983,7 @@ static void test_bug1644() result= mysql_store_result(mysql); mytest(result); - myassert(3 == my_process_result_set(result)); + assert(3 == my_process_result_set(result)); mysql_data_seek(result, 0); @@ -2006,19 +1991,19 @@ static void test_bug1644() mytest(row); for (i = 0 ; i < 4 ; i++) { - myassert(strcmp(row[i], "22") == 0); + assert(strcmp(row[i], "22") == 0); } row= mysql_fetch_row(result); mytest(row); for (i = 0 ; i < 4 ; i++) { - myassert(row[i] == 0); + assert(row[i] == 0); } row= mysql_fetch_row(result); mytest(row); for (i = 0 ; i < 4 ; i++) { - myassert(strcmp(row[i], "88") == 0); + assert(strcmp(row[i], "88") == 0); } row= mysql_fetch_row(result); mytest_r(row); @@ -2084,7 +2069,7 @@ static void test_select_show() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -2170,7 +2155,7 @@ static void test_simple_update() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2256,7 +2241,7 @@ static void test_long_data() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); verify_col_data("test_long_data","col1","999"); @@ -2346,7 +2331,7 @@ static void test_long_data_str() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); my_sprintf(data,(data,"%d", i*5)); @@ -2435,7 +2420,7 @@ static void test_long_data_str1() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); my_sprintf(data,(data,"%ld",(long)i*length)); @@ -2526,7 +2511,7 @@ static void test_long_data_bin() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2614,7 +2599,7 @@ static void test_simple_delete() result = mysql_store_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); mysql_free_result(result); } @@ -2720,7 +2705,7 @@ static void test_update() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2770,7 +2755,7 @@ static void test_prepare_noparam() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2840,17 +2825,17 @@ static void test_bind_result() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d,%s(%lu)",nData, szData, length1); - myassert(nData == 10); - myassert(strcmp(szData,"venu")==0); - myassert(length1 == 4); + assert(nData == 10); + assert(strcmp(szData,"venu")==0); + assert(length1 == 4); rc = mysql_fetch(stmt); mystmt(stmt,rc); fprintf(stdout,"\n row 2: %d,%s(%lu)",nData, szData, length1); - myassert(nData == 20); - myassert(strcmp(szData,"MySQL")==0); - myassert(length1 == 5); + assert(nData == 20); + assert(strcmp(szData,"MySQL")==0); + assert(length1 == 5); length=99; rc = mysql_fetch(stmt); @@ -2858,12 +2843,12 @@ static void test_bind_result() if (is_null[0]) fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); - myassert(is_null[0]); - myassert(strcmp(szData,"monty")==0); - myassert(length1 == 5); + assert(is_null[0]); + assert(strcmp(szData,"monty")==0); + assert(length1 == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -2972,19 +2957,19 @@ static void test_bind_result_ext() fprintf(stdout, "\n data (bin) : %s(%lu)", bData, bLength); - myassert(t_data == 19); - myassert(s_data == 2999); - myassert(i_data == 3999); - myassert(b_data == 4999999); - /*myassert(f_data == 2345.60);*/ - /*myassert(d_data == 5678.89563);*/ - myassert(strcmp(szData,"venu")==0); - myassert(strncmp(bData,"mysql",5)==0); - myassert(szLength == 4); - myassert(bLength == 5); + assert(t_data == 19); + assert(s_data == 2999); + assert(i_data == 3999); + assert(b_data == 4999999); + /*assert(f_data == 2345.60);*/ + /*assert(d_data == 5678.89563);*/ + assert(strcmp(szData,"venu")==0); + assert(strncmp(bData,"mysql",5)==0); + assert(szLength == 4); + assert(bLength == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3096,23 +3081,23 @@ static void test_bind_result_ext1() fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]); fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]); - myassert(strcmp(t_data,"120")==0); - myassert(i_data == 3999); - myassert(f_data == 2); - myassert(strcmp(d_data,"58.89")==0); - myassert(b_data == 54); - - myassert(length[0] == 3); - myassert(length[1] == 4); - myassert(length[2] == 2); - myassert(length[3] == 1); - myassert(length[4] == 4); - myassert(length[5] == 5); - myassert(length[6] == 4); - myassert(length[7] == 8); + assert(strcmp(t_data,"120")==0); + assert(i_data == 3999); + assert(f_data == 2); + assert(strcmp(d_data,"58.89")==0); + assert(b_data == 54); + + assert(length[0] == 3); + assert(length[1] == 4); + assert(length[2] == 2); + assert(length[3] == 1); + assert(length[4] == 4); + assert(length[5] == 5); + assert(length[6] == 4); + assert(length[7] == 8); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3165,7 +3150,7 @@ static void bind_fetch(int row_count) mysql_stmt_close(stmt); - myassert(row_count == (int) + assert(row_count == (int) my_stmt_result("SELECT * FROM test_bind_fetch",50)); stmt = mysql_prepare(mysql,"SELECT * FROM test_bind_fetch",50); @@ -3220,33 +3205,33 @@ static void bind_fetch(int row_count) rc= 10+row_count; for (i=0; i < 4; i++) { - myassert(data[i] == rc+i); - myassert(length[i] == bit); + assert(data[i] == rc+i); + assert(length[i] == bit); bit<<= 1; rc+= 12; } /* FLOAT */ rc+= i; - myassert((int)f_data == rc); - myassert(length[4] == 4); + assert((int)f_data == rc); + assert(length[4] == 4); /* DOUBLE */ rc+= 13; - myassert((int)d_data == rc); - myassert(length[5] == 8); + assert((int)d_data == rc); + assert(length[5] == 8); /* CHAR */ rc+= 13; { char buff[20]; long len= my_sprintf(buff, (buff, "%d", rc)); - myassert(strcmp(s_data,buff)==0); - myassert(length[6] == (ulong) len); + assert(strcmp(s_data,buff)==0); + assert(length[6] == (ulong) len); } } rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3336,7 +3321,7 @@ static void test_fetch_date() bind[6].buffer_length= sizeof(ts_6); bind[6].length= &ts6_length; - myassert(1 == my_stmt_result("SELECT * FROM test_bind_result",50)); + assert(1 == my_stmt_result("SELECT * FROM test_bind_result",50)); stmt = mysql_prepare(mysql, "SELECT * FROM test_bind_result", 50); mystmt_init(stmt); @@ -3359,29 +3344,29 @@ static void test_fetch_date() fprintf(stdout, "\n ts(4) : %s(%lu)", ts_4, ts4_length); fprintf(stdout, "\n ts(6) : %s(%lu)", ts_6, ts6_length); - myassert(strcmp(date,"2002-01-02")==0); - myassert(d_length == 10); + assert(strcmp(date,"2002-01-02")==0); + assert(d_length == 10); - myassert(strcmp(time,"12:49:00")==0); - myassert(t_length == 8); + assert(strcmp(time,"12:49:00")==0); + assert(t_length == 8); - myassert(strcmp(ts,"2002-01-02 17:46:59")==0); - myassert(ts_length == 19); + assert(strcmp(ts,"2002-01-02 17:46:59")==0); + assert(ts_length == 19); - myassert(year == 2010); - myassert(y_length == 4); + assert(year == 2010); + assert(y_length == 4); - myassert(strcmp(dt,"2010-07-10 00:00:00")==0); - myassert(dt_length == 19); + assert(strcmp(dt,"2010-07-10 00:00:00")==0); + assert(dt_length == 19); - myassert(ts_4[0] == '\0'); - myassert(ts4_length == 0); + assert(ts_4[0] == '\0'); + assert(ts4_length == 0); - myassert(strcmp(ts_6,"1999-12-29 00:00:00")==0); - myassert(ts6_length == 19); + assert(strcmp(ts_6,"1999-12-29 00:00:00")==0); + assert(ts6_length == 19); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3726,7 +3711,7 @@ static void test_prepare_ext() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(nData == (int)my_process_stmt_result(stmt)); + assert(nData == (int)my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -3769,7 +3754,7 @@ static void test_field_names() result = mysql_use_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); mysql_free_result(result); /* with table name included with TRUE column name */ @@ -3779,7 +3764,7 @@ static void test_field_names() result = mysql_use_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); mysql_free_result(result); } @@ -3805,7 +3790,7 @@ static void test_warnings() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -3908,7 +3893,7 @@ static void test_insert() result = mysql_store_result(mysql); mytest(result); - myassert((int)tiny_data == my_process_result_set(result)); + assert((int)tiny_data == my_process_result_set(result)); mysql_free_result(result); } @@ -4074,18 +4059,18 @@ static void test_stmt_close() rc= mysql_stmt_close(stmt1); fprintf(stdout,"\n mysql_close_stmt(1) returned: %d", rc); - myassert(rc == 0); + assert(rc == 0); mysql_close(lmysql); /* it should free all open stmts(stmt3, 2 and 1) */ #if NOT_VALID rc= mysql_stmt_close(stmt3); fprintf(stdout,"\n mysql_close_stmt(3) returned: %d", rc); - myassert( rc == 1); + assert( rc == 1); rc= mysql_stmt_close(stmt2); fprintf(stdout,"\n mysql_close_stmt(2) returned: %d", rc); - myassert( rc == 1); + assert( rc == 1); #endif count= 100; @@ -4105,7 +4090,7 @@ static void test_stmt_close() rc= mysql_stmt_close(stmt_x); fprintf(stdout,"\n mysql_close_stmt(x) returned: %d", rc); - myassert( rc == 0); + assert( rc == 0); rc = mysql_query(mysql,"SELECT id FROM test_stmt_close"); myquery(rc); @@ -4113,7 +4098,7 @@ static void test_stmt_close() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -4161,9 +4146,9 @@ static void test_set_variable() fprintf(stdout, "\n max_error_count(default): %d", get_count); def_count= get_count; - myassert(strcmp(var,"max_error_count") == 0); + assert(strcmp(var,"max_error_count") == 0); rc = mysql_fetch(stmt1); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); stmt = mysql_prepare(mysql, "set max_error_count=?", 50); mystmt_init(stmt); @@ -4189,10 +4174,10 @@ static void test_set_variable() mystmt(stmt1, rc); fprintf(stdout, "\n max_error_count : %d", get_count); - myassert(get_count == set_count); + assert(get_count == set_count); rc = mysql_fetch(stmt1); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); /* restore back to default */ set_count= def_count; @@ -4206,10 +4191,10 @@ static void test_set_variable() mystmt(stmt1, rc); fprintf(stdout, "\n max_error_count(default): %d", get_count); - myassert(get_count == set_count); + assert(get_count == set_count); rc = mysql_fetch(stmt1); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); mysql_stmt_close(stmt1); @@ -4265,12 +4250,12 @@ static void test_insert_meta() field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1"); - myassert(strcmp(field->name,"col1")==0); + assert(strcmp(field->name,"col1")==0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3"); - myassert(strcmp(field->name,"col3")==0); + assert(strcmp(field->name,"col3")==0); field= mysql_fetch_field(result); mytest_r(field); @@ -4329,15 +4314,15 @@ static void test_update_meta() mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); - myassert(strcmp(field->name,"col1")==0); - myassert(strcmp(field->table,"test_prep_update")==0); + assert(strcmp(field->name,"col1")==0); + assert(strcmp(field->table,"test_prep_update")==0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); - myassert(strcmp(field->name,"col3")==0); - myassert(strcmp(field->table,"test_prep_update")==0); + assert(strcmp(field->name,"col3")==0); + assert(strcmp(field->table,"test_prep_update")==0); field= mysql_fetch_field(result); mytest_r(field); @@ -4394,15 +4379,15 @@ static void test_select_meta() mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); - myassert(strcmp(field->name,"col1")==0); - myassert(strcmp(field->table,"test_prep_select")==0); + assert(strcmp(field->name,"col1")==0); + assert(strcmp(field->table,"test_prep_select")==0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); - myassert(strcmp(field->name,"col2")==0); - myassert(strcmp(field->table,"test_prep_select")==0); + assert(strcmp(field->name,"col2")==0); + assert(strcmp(field->table,"test_prep_select")==0); field= mysql_fetch_field(result); mytest_r(field); @@ -4448,7 +4433,7 @@ static void test_func_fields() mytest(field); fprintf(stdout,"\n table name: `%s` (expected: `%s`)", field->table, "test_dateformat"); - myassert(strcmp(field->table, "test_dateformat")==0); + assert(strcmp(field->table, "test_dateformat")==0); field = mysql_fetch_field(result); mytest_r(field); /* no more fields */ @@ -4465,7 +4450,7 @@ static void test_func_fields() field = mysql_fetch_field(result); mytest(field); fprintf(stdout,"\n table name: `%s` (expected: `%s`)", field->table, ""); - myassert(field->table[0] == '\0'); + assert(field->table[0] == '\0'); field = mysql_fetch_field(result); mytest_r(field); /* no more fields */ @@ -4483,8 +4468,8 @@ static void test_func_fields() mytest(field); fprintf(stdout,"\n field name: `%s` (expected: `%s`)", field->name, "YEAR"); fprintf(stdout,"\n field org name: `%s` (expected: `%s`)",field->org_name,""); - myassert(strcmp(field->name, "YEAR")==0); - myassert(field->org_name[0] == '\0'); + assert(strcmp(field->name, "YEAR")==0); + assert(field->org_name[0] == '\0'); field = mysql_fetch_field(result); mytest_r(field); /* no more fields */ @@ -4552,11 +4537,11 @@ static void test_multi_stmt() fprintf(stdout, "\n int_data: %d(%lu)", id, length[0]); fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); - myassert(id == 10); - myassert(strcmp(name,"mysql")==0); + assert(id == 10); + assert(strcmp(name,"mysql")==0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); /* alter the table schema now */ stmt1 = mysql_prepare(mysql,"DELETE FROM test_multi_table WHERE id = ? AND name=?",100); @@ -4580,11 +4565,11 @@ static void test_multi_stmt() fprintf(stdout, "\n int_data: %d(%lu)", id, length[0]); fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); - myassert(id == 10); - myassert(strcmp(name,"updated")==0); + assert(id == 10); + assert(strcmp(name,"updated")==0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_execute(stmt1); mystmt(stmt1, rc); @@ -4597,9 +4582,9 @@ static void test_multi_stmt() mystmt(stmt, rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); - myassert(0 == my_stmt_result("SELECT * FROM test_multi_table",50)); + assert(0 == my_stmt_result("SELECT * FROM test_multi_table",50)); mysql_stmt_close(stmt); mysql_stmt_close(stmt2); @@ -4750,7 +4735,7 @@ static void test_manual_sample() fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } - myassert(2 == my_stmt_result("SELECT * FROM test_table",50)); + assert(2 == my_stmt_result("SELECT * FROM test_table",50)); /* DROP THE TABLE */ if (mysql_query(mysql,"DROP TABLE test_table")) @@ -4811,87 +4796,135 @@ static void test_prepare_alter() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(4 == my_stmt_result("SELECT * FROM test_prep_alter",50)); + assert(4 == my_stmt_result("SELECT * FROM test_prep_alter",50)); mysql_stmt_close(stmt); } /******************************************************** -* to test the support of multi-query executions * +* to test the support of multi-statement executions * *********************************************************/ -static void test_multi_query() + +static void test_multi_statements() { - MYSQL *l_mysql, *org_mysql; + MYSQL *mysql_local; MYSQL_RES *result; int rc; - const char *query= "DROP TABLE IF EXISTS test_multi_tab;\ - CREATE TABLE test_multi_tab(id int,name char(20));\ - INSERT INTO test_multi_tab(xxxx) VALUES(10);\ - UPDATE test_multi_tab SET id=10 WHERE unkown_col=10;\ - CREATE TABLE test_multi_tab(id int,name char(20));\ - INSERT INTO test_multi_tab(id) VALUES(10),(20);\ - INSERT INTO test_multi_tab VALUES(20,'insert;comma');\ - SELECT * FROM test_multi_tab;\ - UPDATE test_multi_tab SET unknown_col=100 WHERE id=100;\ - UPDATE test_multi_tab SET name='new;name' WHERE id=20;\ - DELETE FROM test_multi_tab WHERE name='new;name';\ - SELECT * FROM test_multi_tab;\ - DELETE FROM test_multi_tab WHERE id=10;\ - SELECT * FROM test_multi_tab;\ - DROP TABLE test_multi_tab;\ - DROP TABLE test_multi_tab;\ - DROP TABLE IF EXISTS test_multi_tab"; - uint count, rows[16]={0,1054,1054,1050,2,1,3,1054,2,2,1,1,0,0,1051,0}, exp_value; - - myheader("test_multi_query"); + const char *query="\ +DROP TABLE IF EXISTS test_multi_tab;\ +CREATE TABLE test_multi_tab(id int,name char(20));\ +INSERT INTO test_multi_tab(id) VALUES(10),(20);\ +INSERT INTO test_multi_tab VALUES(20,'insert;comma');\ +SELECT * FROM test_multi_tab;\ +UPDATE test_multi_tab SET name='new;name' WHERE id=20;\ +DELETE FROM test_multi_tab WHERE name='new;name';\ +SELECT * FROM test_multi_tab;\ +DELETE FROM test_multi_tab WHERE id=10;\ +SELECT * FROM test_multi_tab;\ +DROP TABLE test_multi_tab;\ +select 1;\ +DROP TABLE IF EXISTS test_multi_tab"; + uint count, exp_value; + uint rows[]= {0, 0, 2, 1, 3, 2, 2, 1, 1, 0, 0, 1, 0}; + + myheader("test_multi_statements"); + /* + First test that we get an error for multi statements + (Becasue default connection is not opened with CLIENT_MULTI_STATEMENTS) + */ rc = mysql_query(mysql, query); /* syntax error */ myquery_r(rc); - myassert(0 == mysql_next_result(mysql)); - myassert(0 == mysql_more_results(mysql)); + assert(-1 == mysql_next_result(mysql)); + assert(0 == mysql_more_results(mysql)); - if (!(l_mysql = mysql_init(NULL))) + if (!(mysql_local = mysql_init(NULL))) { fprintf(stdout,"\n mysql_init() failed"); exit(1); } - if (!(mysql_real_connect(l_mysql,opt_host,opt_user, + + /* Create connection that supprot multi statements */ + if (!(mysql_real_connect(mysql_local,opt_host,opt_user, opt_password, current_db, opt_port, - opt_unix_socket, CLIENT_MULTI_QUERIES))) /* enable multi queries */ + opt_unix_socket, CLIENT_MULTI_STATEMENTS))) { - fprintf(stdout,"\n connection failed(%s)", mysql_error(l_mysql)); + fprintf(stdout,"\n connection failed(%s)", mysql_error(mysql_local)); exit(1); - } - org_mysql= mysql; - mysql= l_mysql; + } - rc = mysql_query(mysql, query); + rc = mysql_query(mysql_local, query); myquery(rc); - count= exp_value= 0; - while (mysql_more_results(mysql) && count < array_elements(rows)) + for (count=0 ; count < array_elements(rows) ; count++) { fprintf(stdout,"\n Query %d: ", count); - if ((rc= mysql_next_result(mysql))) + if ((result= mysql_store_result(mysql_local))) + my_process_result_set(result); + else + fprintf(stdout,"OK, %lld row(s) affected, %d warning(s)\n", + mysql_affected_rows(mysql_local), + mysql_warning_count(mysql_local)); + + exp_value= (uint) mysql_affected_rows(mysql_local); + if (rows[count] != exp_value) { - exp_value= mysql_errno(mysql); - fprintf(stdout, "ERROR %d: %s", exp_value, mysql_error(mysql)); + fprintf(stdout, "row %d had affected rows: %d, should be %d\n", + count, exp_value, rows[count]); + exit(1); + } + if (count != array_elements(rows) -1) + { + if (!(rc= mysql_more_results(mysql_local))) + { + fprintf(stdout, + "mysql_more_result returned wrong value: %d for row %d\n", + rc, count); + exit(1); + } + if ((rc= mysql_next_result(mysql_local))) + { + exp_value= mysql_errno(mysql_local); + + exit(1); + } } else { - if ((result= mysql_store_result(mysql))) - my_process_result_set(result); - else - fprintf(stdout,"OK, %lld row(s) affected, %d warning(s)", - mysql_affected_rows(mysql), - mysql_warning_count(mysql)); - exp_value= (uint) mysql_affected_rows(mysql); + assert(mysql_more_results(mysql_local) == 0); + assert(mysql_next_result(mysql_local) == -1); } - myassert(rows[count++] == exp_value); } - mysql= org_mysql; + + /* check that errors abort multi statements */ + + rc= mysql_query(mysql_local, "select 1+1+a;select 1+1"); + myquery_r(rc); + assert(mysql_more_results(mysql_local) == 0); + assert(mysql_next_result(mysql_local) == -1); + + rc= mysql_query(mysql_local, "select 1+1;select 1+1+a;select 1"); + myquery(rc); + result= mysql_store_result(mysql_local); + mytest(result); + mysql_free_result(result); + assert(mysql_more_results(mysql_local) == 1); + assert(mysql_next_result(mysql_local) > 0); + + /* + Ensure that we can now do a simple query (this checks that the server is + not trying to send us the results for the last 'select 1' + */ + rc= mysql_query(mysql_local, "select 1+1+1"); + myquery(rc); + result= mysql_store_result(mysql_local); + mytest(result); + my_process_result_set(result); + mysql_free_result(result); + + mysql_close(mysql_local); } @@ -4961,17 +4994,17 @@ static void test_store_result() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %ld,%s(%lu)", nData, szData, length1); - myassert(nData == 10); - myassert(strcmp(szData,"venu")==0); - myassert(length1 == 4); + assert(nData == 10); + assert(strcmp(szData,"venu")==0); + assert(length1 == 4); rc = mysql_fetch(stmt); mystmt(stmt,rc); fprintf(stdout,"\n row 2: %ld,%s(%lu)",nData, szData, length1); - myassert(nData == 20); - myassert(strcmp(szData,"mysql")==0); - myassert(length1 == 5); + assert(nData == 20); + assert(strcmp(szData,"mysql")==0); + assert(length1 == 5); length=99; rc = mysql_fetch(stmt); @@ -4979,12 +5012,12 @@ static void test_store_result() if (is_null[0]) fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); - myassert(is_null[0]); - myassert(strcmp(szData,"monty")==0); - myassert(length1 == 5); + assert(is_null[0]); + assert(strcmp(szData,"monty")==0); + assert(length1 == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -4996,17 +5029,17 @@ static void test_store_result() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %ld,%s(%lu)",nData, szData, length1); - myassert(nData == 10); - myassert(strcmp(szData,"venu")==0); - myassert(length1 == 4); + assert(nData == 10); + assert(strcmp(szData,"venu")==0); + assert(length1 == 4); rc = mysql_fetch(stmt); mystmt(stmt,rc); fprintf(stdout,"\n row 2: %ld,%s(%lu)",nData, szData, length1); - myassert(nData == 20); - myassert(strcmp(szData,"mysql")==0); - myassert(length1 == 5); + assert(nData == 20); + assert(strcmp(szData,"mysql")==0); + assert(length1 == 5); length=99; rc = mysql_fetch(stmt); @@ -5014,12 +5047,12 @@ static void test_store_result() if (is_null[0]) fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); - myassert(is_null[0]); - myassert(strcmp(szData,"monty")==0); - myassert(length1 == 5); + assert(is_null[0]); + assert(strcmp(szData,"monty")==0); + assert(length1 == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -5069,7 +5102,7 @@ static void test_store_result1() while (mysql_fetch(stmt) != MYSQL_NO_DATA) rc++; fprintf(stdout, "\n total rows: %d", rc); - myassert(rc == 3); + assert(rc == 3); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -5081,7 +5114,7 @@ static void test_store_result1() while (mysql_fetch(stmt) != MYSQL_NO_DATA) rc++; fprintf(stdout, "\n total rows: %d", rc); - myassert(rc == 3); + assert(rc == 3); mysql_stmt_close(stmt); } @@ -5148,10 +5181,10 @@ static void test_store_result2() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",nData); - myassert(nData == 10); + assert(nData == 10); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); nData = 20; rc = mysql_execute(stmt); @@ -5165,10 +5198,10 @@ static void test_store_result2() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",nData); - myassert(nData == 20); + assert(nData == 20); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -5242,11 +5275,11 @@ static void test_subselect() mysql_stmt_close(stmt); - myassert(3 == my_stmt_result("SELECT * FROM test_sub2",50)); + assert(3 == my_stmt_result("SELECT * FROM test_sub2",50)); strmov((char *)query , "SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=?)"); - myassert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=8)",100)); - myassert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=7)",100)); + assert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=8)",100)); + assert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=7)",100)); stmt = mysql_prepare(mysql, query, 150); mystmt_init(stmt); @@ -5265,10 +5298,10 @@ static void test_subselect() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",id); - myassert(id == 1); + assert(id == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); id= 8; rc = mysql_execute(stmt); @@ -5278,10 +5311,10 @@ static void test_subselect() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",id); - myassert(id == 0); + assert(id == 0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); #endif @@ -5356,7 +5389,7 @@ static void test_bind_date_conv(uint row_count) mysql_stmt_close(stmt); - myassert(row_count == my_stmt_result("SELECT * FROM test_date",50)); + assert(row_count == my_stmt_result("SELECT * FROM test_date",50)); stmt = mysql_prepare(mysql,"SELECT * FROM test_date",50); myquery(rc); @@ -5384,23 +5417,23 @@ static void test_bind_date_conv(uint row_count) tm[i].hour, tm[i].minute, tm[i].second, tm[i].second_part); - myassert(tm[i].year == 0 || tm[i].year == year+count); - myassert(tm[i].month == 0 || tm[i].month == month+count); - myassert(tm[i].day == 0 || tm[i].day == day+count); + assert(tm[i].year == 0 || tm[i].year == year+count); + assert(tm[i].month == 0 || tm[i].month == month+count); + assert(tm[i].day == 0 || tm[i].day == day+count); - myassert(tm[i].hour == 0 || tm[i].hour == hour+count); + assert(tm[i].hour == 0 || tm[i].hour == hour+count); /* minute causes problems from date<->time, don't assert, instead validate separatly in another routine */ - /*myassert(tm[i].minute == 0 || tm[i].minute == minute+count); - myassert(tm[i].second == 0 || tm[i].second == sec+count);*/ + /*assert(tm[i].minute == 0 || tm[i].minute == minute+count); + assert(tm[i].second == 0 || tm[i].second == sec+count);*/ - myassert(tm[i].second_part == 0 || tm[i].second_part == second_part+count); + assert(tm[i].second_part == 0 || tm[i].second_part == second_part+count); } } rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -5673,9 +5706,9 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(buffer[0] == 'M'); - myassert(buffer[1] == 'X'); - myassert(length == 5); + assert(buffer[0] == 'M'); + assert(buffer[1] == 'X'); + assert(length == 5); bind[0].buffer_length=8; rc = mysql_bind_result(stmt, bind);/* re-bind */ @@ -5684,8 +5717,8 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(strncmp(buffer,"Database",8) == 0); - myassert(length == 8); + assert(strncmp(buffer,"Database",8) == 0); + assert(length == 8); bind[0].buffer_length=12; rc = mysql_bind_result(stmt, bind);/* re-bind */ @@ -5694,8 +5727,8 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(strcmp(buffer,"Open-Source") == 0); - myassert(length == 11); + assert(strcmp(buffer,"Open-Source") == 0); + assert(length == 11); bind[0].buffer_length=6; rc = mysql_bind_result(stmt, bind);/* re-bind */ @@ -5704,8 +5737,8 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(strncmp(buffer,"Popula",6) == 0); - myassert(length == 7); + assert(strncmp(buffer,"Popula",6) == 0); + assert(length == 7); mysql_stmt_close(stmt); } @@ -5736,7 +5769,7 @@ static void test_open_direct() result = mysql_store_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -5749,7 +5782,7 @@ static void test_open_direct() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -5762,7 +5795,7 @@ static void test_open_direct() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_stmt_close(stmt); /* run a direct query in the middle of a fetch */ @@ -5828,7 +5861,7 @@ static void test_fetch_nobuffs() rc++; fprintf(stdout, "\n total rows : %d", rc); - myassert(rc == 1); + assert(rc == 1); bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= (char *)str[0]; @@ -5856,7 +5889,7 @@ static void test_fetch_nobuffs() fprintf(stdout, "\n CURRENT_TIME() : %s", str[3]); } fprintf(stdout, "\n total rows : %d", rc); - myassert(rc == 1); + assert(rc == 1); mysql_stmt_close(stmt); } @@ -5927,20 +5960,20 @@ static void test_ushort_bug() fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - myassert(short_value == 35999); - myassert(s_length == 2); + assert(short_value == 35999); + assert(s_length == 2); - myassert(long_value == 35999); - myassert(l_length == 4); + assert(long_value == 35999); + assert(l_length == 4); - myassert(longlong_value == 35999); - myassert(ll_length == 8); + assert(longlong_value == 35999); + assert(ll_length == 8); - myassert(tiny_value == 200); - myassert(t_length == 1); + assert(tiny_value == 200); + assert(t_length == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6011,20 +6044,20 @@ static void test_sshort_bug() fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - myassert(short_value == -5999); - myassert(s_length == 2); + assert(short_value == -5999); + assert(s_length == 2); - myassert(long_value == -5999); - myassert(l_length == 4); + assert(long_value == -5999); + assert(l_length == 4); - myassert(longlong_value == 35999); - myassert(ll_length == 8); + assert(longlong_value == 35999); + assert(ll_length == 8); - myassert(tiny_value == 200); - myassert(t_length == 1); + assert(tiny_value == 200); + assert(t_length == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6095,20 +6128,20 @@ static void test_stiny_bug() fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - myassert(short_value == -128); - myassert(s_length == 2); + assert(short_value == -128); + assert(s_length == 2); - myassert(long_value == -127); - myassert(l_length == 4); + assert(long_value == -127); + assert(l_length == 4); - myassert(longlong_value == 255); - myassert(ll_length == 8); + assert(longlong_value == 255); + assert(ll_length == 8); - myassert(tiny_value == 0); - myassert(t_length == 1); + assert(tiny_value == 0); + assert(t_length == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6133,7 +6166,7 @@ static void test_field_misc() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); verify_prepare_field(result,0, "@@autocommit","", /* field and its org name */ @@ -6152,7 +6185,7 @@ static void test_field_misc() result = mysql_get_metadata(stmt); mytest(result); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@autocommit","", /* field and its org name */ @@ -6183,7 +6216,7 @@ static void test_field_misc() fprintf(stdout,"\n default table type: %s(%ld)", table_type, type_length); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -6196,7 +6229,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@table_type","", /* field and its org name */ @@ -6216,7 +6249,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@max_error_count","", /* field and its org name */ @@ -6236,7 +6269,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@max_allowed_packet","", /* field and its org name */ @@ -6256,7 +6289,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@sql_warnings","", /* field and its org name */ @@ -6303,7 +6336,7 @@ static void test_set_option() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_free_result(result); @@ -6314,7 +6347,7 @@ static void test_set_option() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(2 == my_process_stmt_result(stmt)); + assert(2 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); @@ -6329,7 +6362,7 @@ static void test_set_option() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(4 == my_process_stmt_result(stmt)); + assert(4 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -6400,7 +6433,7 @@ static void test_prepare_grant() execute_prepare_query("INSERT INTO test_grant(a) VALUES(NULL)",1); execute_prepare_query("INSERT INTO test_grant VALUES(NULL)",1); execute_prepare_query("UPDATE test_grant SET a=9 WHERE a=1",1); - myassert(4 == my_stmt_result("SELECT a FROM test_grant",50)); + assert(4 == my_stmt_result("SELECT a FROM test_grant",50)); rc = mysql_query(mysql,"DELETE FROM test_grant"); myquery_r(rc); @@ -6411,18 +6444,18 @@ static void test_prepare_grant() rc = mysql_execute(stmt); myquery_r(rc); - myassert(4 == my_stmt_result("SELECT * FROM test_grant",50)); + assert(4 == my_stmt_result("SELECT * FROM test_grant",50)); mysql_close(lmysql); mysql= org_mysql; rc = mysql_query(mysql,"delete from mysql.user where User='test_grant'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); rc = mysql_query(mysql,"delete from mysql.tables_priv where User='test_grant'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); } } @@ -6476,7 +6509,7 @@ static void test_frm_bug() fprintf(stdout,"\n data directory: %s", data_dir); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); strxmov(test_frm,data_dir,"/",current_db,"/","test_frm_bug.frm",NullS); @@ -6496,7 +6529,7 @@ static void test_frm_bug() result = mysql_store_result(mysql); mytest(result);/* It can't be NULL */ - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_data_seek(result,0); @@ -6504,7 +6537,7 @@ static void test_frm_bug() mytest(row); fprintf(stdout,"\n Comment: %s", row[16]); - myassert(row[16] != 0); + assert(row[16] != 0); mysql_free_result(result); mysql_stmt_close(stmt); @@ -6562,10 +6595,10 @@ static void test_decimal_bug() mystmt(stmt,rc); fprintf(stdout, "\n data: %g", data); - myassert(data == 8.0); + assert(data == 8.0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); data= 5.61; rc = mysql_execute(stmt); @@ -6579,17 +6612,17 @@ static void test_decimal_bug() mystmt(stmt,rc); fprintf(stdout, "\n data: %g", data); - myassert(data == 5.61); + assert(data == 5.61); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); is_null= 1; rc = mysql_execute(stmt); mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); data= 10.22; is_null= 0; rc = mysql_execute(stmt); @@ -6603,10 +6636,10 @@ static void test_decimal_bug() mystmt(stmt,rc); fprintf(stdout, "\n data: %g", data); - myassert(data == 10.22); + assert(data == 10.22); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6639,14 +6672,14 @@ static void test_explain_bug() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert( 2 == my_process_stmt_result(stmt)); + assert( 2 == my_process_stmt_result(stmt)); result = mysql_get_metadata(stmt); mytest(result); fprintf(stdout, "\n total fields in the result: %d", mysql_num_fields(result)); - myassert(6 == mysql_num_fields(result)); + assert(6 == mysql_num_fields(result)); verify_prepare_field(result,0,"Field","",MYSQL_TYPE_VAR_STRING, "","","",NAME_LEN,0); @@ -6675,14 +6708,14 @@ static void test_explain_bug() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert( 1 == my_process_stmt_result(stmt)); + assert( 1 == my_process_stmt_result(stmt)); result = mysql_get_metadata(stmt); mytest(result); fprintf(stdout, "\n total fields in the result: %d", mysql_num_fields(result)); - myassert(10 == mysql_num_fields(result)); + assert(10 == mysql_num_fields(result)); verify_prepare_field(result,0,"id","",MYSQL_TYPE_LONGLONG, "","","",3,0); @@ -6718,10 +6751,25 @@ static void test_explain_bug() mysql_stmt_close(stmt); } +#ifdef NOT_YET_WORKING + /* To test math functions bug #148 (reported by salle@mysql.com). */ + +#define myerrno(n) check_errcode(n) + +static void check_errcode(const unsigned int err) +{ + if (mysql->server_version) + fprintf(stdout,"\n [MySQL-%s]",mysql->server_version); + else + fprintf(stdout,"\n [MySQL]"); + fprintf(stdout,"[%d] %s\n",mysql_errno(mysql),mysql_error(mysql)); + assert(mysql_errno(mysql) == err); +} + static void test_drop_temp() { int rc; @@ -6814,18 +6862,19 @@ static void test_drop_temp() rc = mysql_query(mysql,"drop database test_drop_temp_db"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); rc = mysql_query(mysql,"delete from mysql.user where User='test_temp'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); rc = mysql_query(mysql,"delete from mysql.tables_priv where User='test_temp'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); } } +#endif /* To test warnings for cuted rows @@ -6851,14 +6900,14 @@ static void test_cuted_rows() count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); - myassert(count == 0); + assert(count == 0); rc = mysql_query(mysql, "INSERT INTO t2 SELECT * FROM t1"); myquery(rc); count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); - myassert(count == 2); + assert(count == 2); rc = mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); @@ -6866,7 +6915,7 @@ static void test_cuted_rows() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_free_result(result); rc = mysql_query(mysql, "INSERT INTO t1 VALUES('junk'),(876789)"); @@ -6874,7 +6923,7 @@ static void test_cuted_rows() count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); - myassert(count == 2); + assert(count == 2); rc = mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); @@ -6882,7 +6931,7 @@ static void test_cuted_rows() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_free_result(result); } @@ -6985,44 +7034,44 @@ static void test_logs() fprintf(stdout, "\n id : %d", id); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(id == 9876); - myassert(length == 19); /* Due to VARCHAR(20) */ - myassert(strcmp(data,"MySQL - Open Source")==0); + assert(id == 9876); + assert(length == 19); /* Due to VARCHAR(20) */ + assert(strcmp(data,"MySQL - Open Source")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 1); - myassert(strcmp(data,"'")==0); + assert(length == 1); + assert(strcmp(data,"'")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 1); - myassert(strcmp(data,"\"")==0); + assert(length == 1); + assert(strcmp(data,"\"")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 7); - myassert(strcmp(data,"my\'sql\'")==0); + assert(length == 7); + assert(strcmp(data,"my\'sql\'")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 7); - /*myassert(strcmp(data,"my\"sql\"")==0); */ + assert(length == 7); + /*assert(strcmp(data,"my\"sql\"")==0); */ rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -7089,10 +7138,10 @@ static void test_nstmts() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n total rows: %d", i); - myassert( i == total_stmts); + assert( i == total_stmts); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -7189,7 +7238,7 @@ static void test_fetch_seek() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -7249,17 +7298,17 @@ static void test_fetch_offset() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s (%ld)", data, length); - myassert(strncmp(data,"abcd",4) == 0 && length == 10); + assert(strncmp(data,"abcd",4) == 0 && length == 10); rc = mysql_fetch_column(stmt,bind,0,5); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s (%ld)", data, length); - myassert(strncmp(data,"fg",2) == 0 && length == 10); + assert(strncmp(data,"fg",2) == 0 && length == 10); rc = mysql_fetch_column(stmt,bind,0,9); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %s (%ld)", data, length); - myassert(strncmp(data,"j",1) == 0 && length == 10); + assert(strncmp(data,"j",1) == 0 && length == 10); rc = mysql_fetch(stmt); mystmt(stmt,rc); @@ -7269,10 +7318,10 @@ static void test_fetch_offset() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); - myassert(is_null == 1); + assert(is_null == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_fetch_column(stmt,bind,1,0); mystmt_r(stmt,rc); @@ -7342,13 +7391,13 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strncmp(c2,"venu",4)==0 && l2 == 4); + assert(strncmp(c2,"venu",4)==0 && l2 == 4); c2[0]= '\0'; l2= 0; rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strcmp(c2,"venu")==0 && l2 == 4); + assert(strcmp(c2,"venu")==0 && l2 == 4); c1= 0; bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7360,7 +7409,7 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); - myassert(c1 == 1 && l1 == 4); + assert(c1 == 1 && l1 == 4); rc = mysql_fetch_column(stmt,bind,10,0); mystmt_r(stmt,rc); @@ -7380,13 +7429,13 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strncmp(c2,"mysq",4)==0 && l2 == 5); + assert(strncmp(c2,"mysq",4)==0 && l2 == 5); c2[0]= '\0'; l2= 0; rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %si(%ld)", c2, l2); - myassert(strcmp(c2,"mysql")==0 && l2 == 5); + assert(strcmp(c2,"mysql")==0 && l2 == 5); c1= 0; bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7398,10 +7447,10 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); - myassert(c1 == 2 && l1 == 4); + assert(c1 == 2 && l1 == 4); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_fetch_column(stmt,bind,1,0); mystmt_r(stmt,rc); @@ -7427,7 +7476,7 @@ static void test_list_fields() result = mysql_list_fields(mysql, "test_list_fields",NULL); mytest(result); - myassert( 0 == my_process_result_set(result)); + assert( 0 == my_process_result_set(result)); verify_prepare_field(result,0,"c1","c1",MYSQL_TYPE_LONG, "test_list_fields","test_list_fields",current_db,11,"0"); @@ -7486,7 +7535,7 @@ static void test_mem_overun() rc = mysql_query(mysql,"select * from t_mem_overun"); myquery(rc); - myassert(1 == my_process_result(mysql)); + assert(1 == my_process_result(mysql)); stmt = mysql_prepare(mysql, "select * from t_mem_overun",30); mystmt_init(stmt); @@ -7498,7 +7547,7 @@ static void test_mem_overun() mytest(field_res); fprintf(stdout,"\n total fields : %d", mysql_num_fields(field_res)); - myassert( 1000 == mysql_num_fields(field_res)); + assert( 1000 == mysql_num_fields(field_res)); rc = mysql_stmt_store_result(stmt); mystmt(stmt,rc); @@ -7507,7 +7556,7 @@ static void test_mem_overun() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -7562,7 +7611,7 @@ static void test_free_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %s(%ld)", c2, l2); - myassert(strncmp(c2,"1",1)==0 && l2 == 1); + assert(strncmp(c2,"1",1)==0 && l2 == 1); rc = mysql_fetch(stmt); mystmt(stmt,rc); @@ -7577,7 +7626,7 @@ static void test_free_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); - myassert(c1 == 2 && l2 == 4); + assert(c1 == 2 && l2 == 4); rc = mysql_query(mysql,"drop table test_free_result"); myquery_r(rc); /* error should be, COMMANDS OUT OF SYNC */ @@ -7644,7 +7693,7 @@ static void test_free_store_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strncmp(c2,"1",1)==0 && l2 == 1); + assert(strncmp(c2,"1",1)==0 && l2 == 1); rc = mysql_fetch(stmt); mystmt(stmt,rc); @@ -7659,7 +7708,7 @@ static void test_free_store_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); - myassert(c1 == 2 && l2 == 4); + assert(c1 == 2 && l2 == 4); rc = mysql_stmt_free_result(stmt); mystmt(stmt,rc); @@ -7770,7 +7819,7 @@ static void test_sqlmode() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); fprintf(stdout,"\n returned 1 row\n"); mysql_stmt_close(stmt); @@ -7793,7 +7842,7 @@ static void test_sqlmode() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); fprintf(stdout,"\n returned 1 row"); mysql_stmt_close(stmt); @@ -7872,7 +7921,7 @@ static void test_ts() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert( 2== my_process_stmt_result(stmt)); + assert( 2== my_process_stmt_result(stmt)); field_count= mysql_num_fields(prep_res); mysql_free_result(prep_res); @@ -7899,7 +7948,7 @@ static void test_ts() row_count++; fprintf(stdout, "\n returned '%d' rows", row_count); - myassert(row_count == 2); + assert(row_count == 2); mysql_stmt_close(stmt); } } @@ -8108,7 +8157,7 @@ int main(int argc, char **argv) test_stmt_close(); /* mysql_stmt_close() test -- hangs */ test_prepare_field_result(); /* prepare meta info */ test_multi_stmt(); /* multi stmt test */ - test_multi_query(); /* test multi query execution */ + test_multi_statements(); /* test multi statement execution */ test_store_result(); /* test the store_result */ test_store_result1(); /* test store result without buffers */ test_store_result2(); /* test store result for misc case */ |