diff options
473 files changed, 6987 insertions, 2759 deletions
diff --git a/VC++Files/libmysqld/libmysqld.vcproj b/VC++Files/libmysqld/libmysqld.vcproj index 32a2e098564..0ee0cf8aa2d 100644 --- a/VC++Files/libmysqld/libmysqld.vcproj +++ b/VC++Files/libmysqld/libmysqld.vcproj @@ -2051,6 +2051,42 @@ </FileConfiguration> </File> <File + RelativePath="..\sql-common\my_user.c"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;SAFEMALLOC;HAVE_BERKELEY_DB;USE_SYMDIR;SIGNAL_WITH_VIO_CLOSE;HAVE_DLOPEN;EMBEDDED_LIBRARY;HAVE_INNOBASE_DB;USE_TLS;__WIN__;$(NoInherit)" + BasicRuntimeChecks="3"/> + </FileConfiguration> + <FileConfiguration + Name="pro|Win32"> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;USE_SYMDIR;SIGNAL_WITH_VIO_CLOSE;EMBEDDED_LIBRARY;USE_TLS;__WIN__;MYSQL_SERVER;LICENSE=Commercial;_MBCS;HAVE_DLOPEN;HAVE_INNOBASE_DB;DBUG_OFF;NDEBUG;_WINDOWS;_CONSOLE;$(NoInherit)"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;SIGNAL_WITH_VIO_CLOSE;HAVE_DLOPEN;EMBEDDED_LIBRARY;HAVE_INNOBASE_DB;DBUG_OFF;USE_TLS;__WIN__;$(NoInherit)"/> + </FileConfiguration> + <FileConfiguration + Name="classic|Win32"> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;_WINDOWS;USE_SYMDIR;SIGNAL_WITH_VIO_CLOSE;HAVE_DLOPEN;EMBEDDED_LIBRARY;USE_TLS;__WIN__;LICENSE=Commercial;DBUG_OFF;_MBCS;NDEBUG;$(NoInherit)"/> + </FileConfiguration> + </File> + <File RelativePath="..\sql\net_serv.cpp"> <FileConfiguration Name="Debug|Win32"> diff --git a/VC++Files/mysql.sln b/VC++Files/mysql.sln index afe09897ace..da6d1bbcc9f 100644 --- a/VC++Files/mysql.sln +++ b/VC++Files/mysql.sln @@ -124,6 +124,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysqld", "sql\mysqld.vcproj {13A3EB35-EF87-42DC-AFD6-CDF5EFB228AD} = {13A3EB35-EF87-42DC-AFD6-CDF5EFB228AD} {BA86AE72-0CF5-423D-BBA2-E12B0D72EBFB} = {BA86AE72-0CF5-423D-BBA2-E12B0D72EBFB} {DB28DE80-837F-4497-9AA9-CC0A20584C98} = {DB28DE80-837F-4497-9AA9-CC0A20584C98} + {BFCDA391-91A5-45F5-A14F-1011F8424113} = {BFCDA391-91A5-45F5-A14F-1011F8424113} {433BCD9B-15C5-4B11-B8BE-825EA98EACE6} = {433BCD9B-15C5-4B11-B8BE-825EA98EACE6} {8762A9B8-72A9-462E-A9A2-F3265081F8AF} = {8762A9B8-72A9-462E-A9A2-F3265081F8AF} {F74653C4-8003-4A79-8F53-FC69E0AD7A9B} = {F74653C4-8003-4A79-8F53-FC69E0AD7A9B} @@ -302,6 +303,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "storage\example\ ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fulltext", "plugin\fulltext\fulltext.vcproj", "{BFCDA391-91A5-45F5-A14F-1011F8424113}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject Global GlobalSection(SolutionConfiguration) = preSolution classic = classic @@ -1778,6 +1783,42 @@ Global {6B6812DB-636E-465D-B53D-5012F237E539}.TLS.Build.0 = TLS|Win32 {6B6812DB-636E-465D-B53D-5012F237E539}.TLS_DEBUG.ActiveCfg = TLS_DEBUG|Win32 {6B6812DB-636E-465D-B53D-5012F237E539}.TLS_DEBUG.Build.0 = TLS_DEBUG|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.classic.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.classic.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.classic nt.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.classic nt.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Debug.ActiveCfg = Debug|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Debug.Build.0 = Debug|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Embedded_Classic.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Embedded_Classic.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Embedded_Debug.ActiveCfg = Debug|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Embedded_Debug.Build.0 = Debug|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Embedded_Pro.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Embedded_Pro.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Embedded_ProGPL.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Embedded_ProGPL.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Embedded_Release.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Embedded_Release.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Max.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Max.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Max nt.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Max nt.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.nt.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.nt.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.pro.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.pro.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.pro gpl.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.pro gpl.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.pro gpl nt.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.pro gpl nt.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.pro nt.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.pro nt.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Release.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.Release.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.TLS.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.TLS.Build.0 = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.TLS_DEBUG.ActiveCfg = Release|Win32 + {BFCDA391-91A5-45F5-A14F-1011F8424113}.TLS_DEBUG.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection diff --git a/VC++Files/plugin/fulltext/fulltext.def b/VC++Files/plugin/fulltext/fulltext.def new file mode 100644 index 00000000000..2df551f6486 --- /dev/null +++ b/VC++Files/plugin/fulltext/fulltext.def @@ -0,0 +1,5 @@ +LIBRARY fulltext +EXPORTS + _mysql_plugin_interface_version_ + _mysql_plugin_declarations_ +
\ No newline at end of file diff --git a/VC++Files/plugin/fulltext/fulltext.vcproj b/VC++Files/plugin/fulltext/fulltext.vcproj new file mode 100644 index 00000000000..6a9fe986fea --- /dev/null +++ b/VC++Files/plugin/fulltext/fulltext.vcproj @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="windows-1251"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="fulltext" + ProjectGUID="{BFCDA391-91A5-45F5-A14F-1011F8424113}" + Keyword="Win32Proj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="2" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../include" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FULLTEXT_EXPORTS" + MinimalRebuild="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + WarningLevel="3" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="4"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + OutputFile="../../client_debug/fulltext.dll" + LinkIncremental="2" + ModuleDefinitionFile="fulltext.def" + GenerateDebugInformation="TRUE" + ProgramDatabaseFile="$(OutDir)/fulltext.pdb" + SubSystem="2" + ImportLibrary="$(OutDir)/fulltext.lib" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="2" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../../include" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FULLTEXT_EXPORTS" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + OutputFile="../../client_release/fulltext.dll" + LinkIncremental="1" + ModuleDefinitionFile="fulltext.def" + GenerateDebugInformation="TRUE" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + ImportLibrary="$(OutDir)/fulltext.lib" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath=".\fulltext.def"> + </File> + <File + RelativePath=".\plugin_example.c"> + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/client/Makefile.am b/client/Makefile.am index 849bd37eb57..14ebadbfacb 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -49,6 +49,8 @@ mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c \ $(top_srcdir)/mysys/base64.c mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS) mysqlslap_LDADD = $(LDADD) $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) +mysqlimport_LDADD = $(LDADD) $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ + $(top_builddir)/mysys/libmysys.a mysqltestmanager_pwgen_SOURCES = mysqlmanager-pwgen.c mysqltestmanagerc_SOURCES= mysqlmanagerc.c $(yassl_dummy_link_fix) mysqlcheck_SOURCES= mysqlcheck.c $(yassl_dummy_link_fix) @@ -57,7 +59,8 @@ mysqlslap_SOURCES= mysqlslap.c $(top_srcdir)/mysys/my_lock.c \ $(top_srcdir)/mysys/my_alarm.c \ $(yassl_dummy_link_fix) mysqldump_SOURCES= mysqldump.c my_user.c $(yassl_dummy_link_fix) -mysqlimport_SOURCES= mysqlimport.c $(yassl_dummy_link_fix) +mysqlimport_SOURCES= mysqlimport.c \ + $(yassl_dummy_link_fix) sql_src=log_event.h mysql_priv.h log_event.cc my_decimal.h my_decimal.cc strings_src=decimal.c diff --git a/client/client_priv.h b/client/client_priv.h index 44f3ce227af..2763dabb027 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -54,6 +54,7 @@ enum options_client OPT_MYSQL_LOCK_DIRECTORY, OPT_MYSQL_SLAP_SLAVE, OPT_USE_THREADS, + OPT_IMPORT_USE_THREADS, OPT_MYSQL_NUMBER_OF_QUERY, OPT_MYSQL_PRESERVE_SCHEMA, OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE, diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 8694093f06b..fbe15b94111 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -29,6 +29,12 @@ #include "client_priv.h" #include "mysql_version.h" +#include <my_pthread.h> + + +/* Global Thread counter */ +int counter= 0; +pthread_mutex_t counter_mutex; static void db_error_with_table(MYSQL *mysql, char *table); static void db_error(MYSQL *mysql); @@ -39,6 +45,7 @@ static char *add_load_option(char *ptr,const char *object, static my_bool verbose=0,lock_tables=0,ignore_errors=0,opt_delete=0, replace=0,silent=0,ignore=0,opt_compress=0, opt_low_priority= 0, tty_password= 0; +static my_bool opt_use_threads= 0; static uint opt_local_file=0; static MYSQL mysql_connection; static char *opt_password=0, *current_user=0, @@ -108,8 +115,9 @@ static struct my_option my_long_options[] = REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"local", 'L', "Read all files through the client.", (gptr*) &opt_local_file, (gptr*) &opt_local_file, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"lock-tables", 'l', "Lock all tables for write.", (gptr*) &lock_tables, - (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"lock-tables", 'l', "Lock all tables for write (this disables threads).", + (gptr*) &lock_tables, (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, + 0, 0, 0, 0, 0, 0}, {"low-priority", OPT_LOW_PRIORITY, "Use LOW_PRIORITY when updating the table.", (gptr*) &opt_low_priority, (gptr*) &opt_low_priority, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -138,6 +146,11 @@ static struct my_option my_long_options[] = (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include <sslopt-longopts.h> + {"use-threads", OPT_USE_THREADS, + "Parrelize the loading of files. Requires an arguement for the number \ + threads to use for loading of data.", + (gptr*) &opt_use_threads, (gptr*) &opt_use_threads, 0, + GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DONT_ALLOW_USER_CHANGE {"user", 'u', "User for login if not current user.", (gptr*) ¤t_user, (gptr*) ¤t_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -287,7 +300,7 @@ static int write_to_table(char *filename, MYSQL *sock) { if (verbose) fprintf(stdout, "Deleting the old data from table %s\n", tablename); - sprintf(sql_statement, "DELETE FROM %s", tablename); + snprintf(sql_statement, FN_REFLEN*16+256, "DELETE FROM %s", tablename); if (mysql_query(sock, sql_statement)) { db_error_with_table(sock, tablename); @@ -497,12 +510,41 @@ static char *field_escape(char *to,const char *from,uint length) } +pthread_handler_t worker_thread(void *arg) +{ + char *raw_table_name= (char *)arg; + MYSQL *sock= 0; + if (!(sock= db_connect(current_host,current_db,current_user,opt_password))) + { + goto error; + } + + if (mysql_query(sock, "set @@character_set_database=binary;")) + { + db_error(sock); /* We shall countinue here, if --force was given */ + goto error; + } + + /* + We should do something about the error + */ + write_to_table(raw_table_name, sock); + +error: + if (sock) + db_disconnect(current_host, sock); + + pthread_mutex_lock(&counter_mutex); + counter--; + pthread_mutex_unlock(&counter_mutex); + return 0; +} + int main(int argc, char **argv) { int exitcode=0, error=0; char **argv_to_free; - MYSQL *sock=0; MY_INIT(argv[0]); load_defaults("my",load_default_groups,&argc,&argv); @@ -513,25 +555,79 @@ int main(int argc, char **argv) free_defaults(argv_to_free); return(1); } - if (!(sock= db_connect(current_host,current_db,current_user,opt_password))) - { - free_defaults(argv_to_free); - return(1); /* purecov: deadcode */ - } - if (mysql_query(sock, "set @@character_set_database=binary;")) + if (opt_use_threads && !lock_tables) { - db_error(sock); /* We shall countinue here, if --force was given */ - return(1); + pthread_t mainthread; /* Thread descriptor */ + pthread_attr_t attr; /* Thread attributes */ + VOID(pthread_mutex_init(&counter_mutex, NULL)); + + for (; *argv != NULL; argv++) /* Loop through tables */ + { + /* + If we hit thread count limit we loop until some threads exit. + We sleep for a second, so that we don't chew up a lot of + CPU in the loop. + */ +sanity_label: + if (counter == opt_use_threads) + { + sleep(1); + goto sanity_label; + } + pthread_mutex_lock(&counter_mutex); + counter++; + pthread_mutex_unlock(&counter_mutex); + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, + PTHREAD_CREATE_DETACHED); + + /* now create the thread */ + if (pthread_create(&mainthread, &attr, worker_thread, + (void *)*argv) != 0) + { + pthread_mutex_lock(&counter_mutex); + counter--; + pthread_mutex_unlock(&counter_mutex); + fprintf(stderr,"%s: Could not create thread\n", + my_progname); + } + } + + /* + We loop until we know that all children have cleaned up. + */ +loop_label: + if (counter) + { + sleep(1); + goto loop_label; + } + VOID(pthread_mutex_destroy(&counter_mutex)); } + else + { + MYSQL *sock= 0; + if (!(sock= db_connect(current_host,current_db,current_user,opt_password))) + { + free_defaults(argv_to_free); + return(1); /* purecov: deadcode */ + } - if (lock_tables) - lock_table(sock, argc, argv); - for (; *argv != NULL; argv++) - if ((error=write_to_table(*argv, sock))) - if (exitcode == 0) - exitcode = error; - db_disconnect(current_host, sock); + if (mysql_query(sock, "set @@character_set_database=binary;")) + { + db_error(sock); /* We shall countinue here, if --force was given */ + return(1); + } + + if (lock_tables) + lock_table(sock, argc, argv); + for (; *argv != NULL; argv++) + if ((error=write_to_table(*argv, sock))) + if (exitcode == 0) + exitcode = error; + db_disconnect(current_host, sock); + } my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR)); #ifdef HAVE_SMEM my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR)); diff --git a/client/mysqltest.c b/client/mysqltest.c index 98097b1896e..ce1a64ec653 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -3605,6 +3605,59 @@ static void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val) /* + Append the result for one field to the dynamic string ds +*/ + +static void append_field(DYNAMIC_STRING *ds, uint col_idx, MYSQL_FIELD* field, + const char* val, ulonglong len, bool is_null) +{ + + char buf[256]; + if (col_idx < max_replace_column && replace_column[col_idx]) + { + val= replace_column[col_idx]; + len= strlen(val); + } + else if (is_null) + { + val= "NULL"; + len= 4; + } +#ifdef __WIN__ + else if ((field->type == MYSQL_TYPE_DOUBLE || + field->type == MYSQL_TYPE_FLOAT ) && + field->decimals >= 31) + { + /* Convert 1.2e+018 to 1.2e+18 and 1.2e-018 to 1.2e-18 */ + char *start= strchr(val, 'e'); + if (start && strlen(start) >= 5 && + (start[1] == '-' || start[1] == '+') && start[2] == '0') + { + start+=2; /* Now points at first '0' */ + /* Move all chars after the first '0' one step left */ + memmove(start, start + 1, strlen(start)); + len--; + } + } +#endif + + if (!display_result_vertically) + { + if (col_idx) + dynstr_append_mem(ds, "\t", 1); + replace_dynstr_append_mem(ds, val, (int)len); + } + else + { + dynstr_append(ds, field->name); + dynstr_append_mem(ds, "\t", 1); + replace_dynstr_append_mem(ds, val, (int)len); + dynstr_append_mem(ds, "\n", 1); + } +} + + +/* Append all results to the dynamic string separated with '\t' Values may be converted with 'replace_column' */ @@ -3613,41 +3666,16 @@ static void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res) { MYSQL_ROW row; uint num_fields= mysql_num_fields(res); - MYSQL_FIELD *fields= !display_result_vertically ? 0 : mysql_fetch_fields(res); + MYSQL_FIELD *fields= mysql_fetch_fields(res); ulong *lengths; + while ((row = mysql_fetch_row(res))) { uint i; lengths = mysql_fetch_lengths(res); for (i = 0; i < num_fields; i++) - { - const char *val= row[i]; - ulonglong len= lengths[i]; - - if (i < max_replace_column && replace_column[i]) - { - val= replace_column[i]; - len= strlen(val); - } - if (!val) - { - val= "NULL"; - len= 4; - } - if (!display_result_vertically) - { - if (i) - dynstr_append_mem(ds, "\t", 1); - replace_dynstr_append_mem(ds, val, (int)len); - } - else - { - dynstr_append(ds, fields[i].name); - dynstr_append_mem(ds, "\t", 1); - replace_dynstr_append_mem(ds, val, (int)len); - dynstr_append_mem(ds, "\n", 1); - } - } + append_field(ds, i, &fields[i], + (const char*)row[i], lengths[i], !row[i]); if (!display_result_vertically) dynstr_append_mem(ds, "\n", 1); } @@ -3661,13 +3689,12 @@ static void append_result(DYNAMIC_STRING *ds, MYSQL_RES *res) */ static void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt, - MYSQL_FIELD *field, uint num_fields) + MYSQL_FIELD *fields, uint num_fields) { MYSQL_BIND *bind; my_bool *is_null; ulong *length; - ulonglong num_rows; - uint col_idx, row_idx; + uint i; /* Allocate array with bind structs, lengths and NULL flags */ bind= (MYSQL_BIND*) my_malloc(num_fields * sizeof(MYSQL_BIND), @@ -3677,71 +3704,29 @@ static void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt, is_null= (my_bool*) my_malloc(num_fields * sizeof(my_bool), MYF(MY_WME | MY_FAE)); - for (col_idx= 0; col_idx < num_fields; col_idx++) + /* Allocate data for the result of each field */ + for (i= 0; i < num_fields; i++) { - /* Allocate data for output */ - uint max_length= field[col_idx].max_length + 1; - char *str_data= (char *) my_malloc(max_length, MYF(MY_WME | MY_FAE)); - - bind[col_idx].buffer_type= MYSQL_TYPE_STRING; - bind[col_idx].buffer= (char *)str_data; - bind[col_idx].buffer_length= max_length; - bind[col_idx].is_null= &is_null[col_idx]; - bind[col_idx].length= &length[col_idx]; + uint max_length= fields[i].max_length + 1; + bind[i].buffer_type= MYSQL_TYPE_STRING; + bind[i].buffer= (char *)my_malloc(max_length, MYF(MY_WME | MY_FAE)); + bind[i].buffer_length= max_length; + bind[i].is_null= &is_null[i]; + bind[i].length= &length[i]; DBUG_PRINT("bind", ("col[%d]: buffer_type: %d, buffer_length: %d", - col_idx, - bind[col_idx].buffer_type, - bind[col_idx].buffer_length)); + i, bind[i].buffer_type, bind[i].buffer_length)); } - /* Fill in the data into the structures created above */ if (mysql_stmt_bind_result(stmt, bind)) die("mysql_stmt_bind_result failed: %d: %s", mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); - /* Read result from each row */ - num_rows= mysql_stmt_num_rows(stmt); - for (row_idx= 0; row_idx < num_rows; row_idx++) + while (mysql_stmt_fetch(stmt) == 0) { - if (mysql_stmt_fetch(stmt)) - die("mysql_stmt_fetch failed: %d %s", - mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); - - /* Read result from each column */ - for (col_idx= 0; col_idx < num_fields; col_idx++) - { - const char *val; - ulonglong len; - if (col_idx < max_replace_column && replace_column[col_idx]) - { - val= replace_column[col_idx]; - len= strlen(val); - } - else if (*bind[col_idx].is_null) - { - val= "NULL"; - len= 4; - } - else - { - val= (const char *) bind[col_idx].buffer; - len= *bind[col_idx].length; - } - if (!display_result_vertically) - { - if (col_idx) /* No tab before first col */ - dynstr_append_mem(ds, "\t", 1); - replace_dynstr_append_mem(ds, val, (int)len); - } - else - { - dynstr_append(ds, field[col_idx].name); - dynstr_append_mem(ds, "\t", 1); - replace_dynstr_append_mem(ds, val, (int)len); - dynstr_append_mem(ds, "\n", 1); - } - } + for (i= 0; i < num_fields; i++) + append_field(ds, i, &fields[i], (const char *) bind[i].buffer, + *bind[i].length, *bind[i].is_null); if (!display_result_vertically) dynstr_append_mem(ds, "\n", 1); } @@ -3752,10 +3737,10 @@ static void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt, free_replace_column(); - for (col_idx= 0; col_idx < num_fields; col_idx++) + for (i= 0; i < num_fields; i++) { /* Free data for output */ - my_free((gptr)bind[col_idx].buffer, MYF(MY_WME | MY_FAE)); + my_free((gptr)bind[i].buffer, MYF(MY_WME | MY_FAE)); } /* Free array with bind structs, lengths and NULL flags */ my_free((gptr)bind , MYF(MY_WME | MY_FAE)); diff --git a/configure.in b/configure.in index bdaa1f5166e..ae2e63d3087 100644 --- a/configure.in +++ b/configure.in @@ -343,7 +343,7 @@ MYSQL_PROG_AR # libmysqlclient versioning when linked with GNU ld. if $LD --version 2>/dev/null|grep -q GNU; then - LD_VERSION_SCRIPT="-Wl,--version-script=\$(top_srcdir)/libmysql/libmysql.ver" + LD_VERSION_SCRIPT="-Wl,--version-script=\$(top_builddir)/libmysql/libmysql.ver" AC_CONFIG_FILES(libmysql/libmysql.ver) fi AC_SUBST(LD_VERSION_SCRIPT) diff --git a/extra/perror.c b/extra/perror.c index e82ff08ad5d..3b7560837b9 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -239,10 +239,24 @@ int main(int argc,char *argv[]) if ((ndb_error_string(code, ndb_string, sizeof(ndb_string)) < 0) && (ndbd_exit_string(code, ndb_string, sizeof(ndb_string)) < 0)) { - msg= 0; + msg= 0; } else msg= ndb_string; + if (msg) + { + if (verbose) + printf("NDB error code %3d: %s\n",code,msg); + else + puts(msg); + } + else + { + fprintf(stderr,"Illegal ndb error code: %d\n",code); + error= 1; + } + found= 1; + msg= 0; } else #endif diff --git a/include/heap.h b/include/heap.h index 1f9b6f7130f..855cff117e2 100644 --- a/include/heap.h +++ b/include/heap.h @@ -136,6 +136,7 @@ typedef struct st_heap_share HP_KEYDEF *keydef; ulong min_records,max_records; /* Params to open */ ulong data_length,index_length,max_table_size; + uint key_stat_version; /* version to indicate insert/delete */ uint records; /* records */ uint blength; /* records rounded up to 2^n */ uint deleted; /* Deleted records in database */ diff --git a/include/my_base.h b/include/my_base.h index 168625f4a87..564cd833185 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -367,8 +367,11 @@ enum ha_base_keytype { given value */ #define HA_ERR_RBR_LOGGING_FAILED 161 /* Row-based binlogging of row failed */ #define HA_ERR_DROP_INDEX_FK 162 /* Index needed in foreign key constr. */ +#define HA_ERR_FOREIGN_DUPLICATE_KEY 163 /* Upholding foreign key constraints + would lead to a duplicate key + error in some other table. */ -#define HA_ERR_LAST 162 /* Copy last error no */ +#define HA_ERR_LAST 163 /* Copy last error no */ /* Add error numbers before HA_ERR_LAST and change it accordingly. */ #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index a77d1408383..d59ba999ee2 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -5036,6 +5036,12 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt) { DBUG_ENTER("mysql_stmt_reset"); DBUG_ASSERT(stmt != 0); + if (!stmt->mysql) + { + /* mysql can be reset in mysql_close called from mysql_reconnect */ + set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); + DBUG_RETURN(1); + } /* Reset the client and server sides of the prepared statement */ DBUG_RETURN(reset_stmt_handle(stmt, RESET_SERVER_SIDE | RESET_LONG_DATA)); } diff --git a/mysql-test/extra/binlog_tests/blackhole.test b/mysql-test/extra/binlog_tests/blackhole.test index 1b5a9beb887..7e03dc9ed57 100644 --- a/mysql-test/extra/binlog_tests/blackhole.test +++ b/mysql-test/extra/binlog_tests/blackhole.test @@ -108,7 +108,7 @@ insert into t1 values(1); insert ignore into t1 values(1); replace into t1 values(100); create table t2 (a varchar(200)) engine=blackhole; -load data infile '../../std_data/words.dat' into table t2; +load data infile '../std_data_ln/words.dat' into table t2; alter table t1 add b int; alter table t1 drop b; create table t3 like t1; diff --git a/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test b/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test index f7f46388033..940310e4499 100644 --- a/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test +++ b/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test @@ -14,7 +14,7 @@ show binlog events from 102; # absolutely need variables names to be quoted and strings to be # escaped). --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 drop table t2; # End of 4.1 tests diff --git a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test index a9612b831f1..0de20ed8be8 100644 --- a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test +++ b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test @@ -197,7 +197,7 @@ connection con3; delete from t1; delete from t2; --disable_warnings -alter table t2 type=MyISAM; +alter table t2 engine=MyISAM; --enable_warnings insert into t1 values (1); begin; diff --git a/mysql-test/extra/rpl_tests/rpl000006.test b/mysql-test/extra/rpl_tests/rpl000006.test deleted file mode 100644 index 272e5744d9c..00000000000 --- a/mysql-test/extra/rpl_tests/rpl000006.test +++ /dev/null @@ -1,47 +0,0 @@ -# -# Test forced timestamp -# --- source include/master-slave.inc - -# Don't log table creating to the slave as we want to test LOAD TABLE -set SQL_LOG_BIN=0,timestamp=200006; -create table t1(t timestamp not null,a char(1)); -insert into t1 ( a) values ('F'); -select unix_timestamp(t) from t1; -connection slave; -load table t1 from master; -select unix_timestamp(t) from t1; - -# Delete the created table on master and slave -connection master; -set SQL_LOG_BIN=1,timestamp=default; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; -connection master; - -# -# Test copying table with checksum -# - -# Don't log table creating to the slave as we want to test LOAD TABLE -set SQL_LOG_BIN=0; - -eval CREATE TABLE t1 ( - a int not null -) ENGINE=$engine_type MAX_ROWS=4000 CHECKSUM=1; -INSERT INTO t1 VALUES (1); -save_master_pos; -connection slave; -sync_with_master; -load table t1 from master; -check table t1; -drop table t1; -connection master; -drop table t1; -save_master_pos; -connection slave; -sync_with_master; - -# End of 4.1 tests diff --git a/mysql-test/extra/rpl_tests/rpl_EE_err.test b/mysql-test/extra/rpl_tests/rpl_EE_err.test index 9c4621c7df4..3dce12b3f4e 100644 --- a/mysql-test/extra/rpl_tests/rpl_EE_err.test +++ b/mysql-test/extra/rpl_tests/rpl_EE_err.test @@ -20,7 +20,7 @@ eval create table t1 (a int) engine=$engine_type; flush tables; -system rm ./var/master-data/test/t1.MYI ; +system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ; drop table if exists t1; save_master_pos; connection slave; diff --git a/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test b/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test index c046487729e..c5db667e29b 100644 --- a/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test +++ b/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test @@ -46,5 +46,8 @@ sleep 1; --error 1192 stop slave; +connection master; +drop table t3, t4, t5; + # End of 4.1 tests diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id.test b/mysql-test/extra/rpl_tests/rpl_insert_id.test index adf8631bea2..a832076fbe2 100644 --- a/mysql-test/extra/rpl_tests/rpl_insert_id.test +++ b/mysql-test/extra/rpl_tests/rpl_insert_id.test @@ -1,5 +1,14 @@ +########################################################### +# 2006-02-01: By JBM: Added 1022, ORDER BY +########################################################### # See if queries that use both auto_increment and LAST_INSERT_ID() # are replicated well +############################################################ +# REQUIREMENT +# Auto increment should work for a table with an auto_increment +# column and index but without primary key. +############################################################## + # We also check how the foreign_key_check variable is replicated @@ -15,8 +24,8 @@ insert into t2 values (null,last_insert_id()); save_master_pos; connection slave; sync_with_master; -select * from t1; -select * from t2; +select * from t1 ORDER BY a; +select * from t2 ORDER BY b; connection master; #check if multi-line inserts, #which set last_insert_id to the first id inserted, @@ -49,13 +58,13 @@ create table t2(b int auto_increment, c int, key(b)); insert into t1 values (10); insert into t1 values (null),(null),(null); insert into t2 values (5,0); -insert into t2 (c) select * from t1; -select * from t2; +insert into t2 (c) select * from t1 ORDER BY a; +select * from t2 ORDER BY b; save_master_pos; connection slave; sync_with_master; -select * from t1; -select * from t2; +select * from t1 ORDER BY a; +select * from t2 ORDER BY b; connection master; drop table t1; drop table t2; @@ -71,7 +80,8 @@ connection master; SET TIMESTAMP=1000000000; CREATE TABLE t1 ( a INT UNIQUE ); SET FOREIGN_KEY_CHECKS=0; ---error 1062 +# Duplicate Key Errors +--error 1022, 1062 INSERT INTO t1 VALUES (1),(1); sync_slave_with_master; diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test new file mode 100644 index 00000000000..a36c402b630 --- /dev/null +++ b/mysql-test/extra/rpl_tests/rpl_insert_id_pk.test @@ -0,0 +1,87 @@ +########################################################### +# 2006-02-08: By JBM: +########################################################### +# See if queries that use both auto_increment and LAST_INSERT_ID() +# are replicated well +############################################################ +# REQUIREMENT +# Auto increment should work for a table with auto_increment column +# and primary key. +############################################################## + +# We also check how the foreign_key_check variable is replicated + +-- source include/master-slave.inc +#should work for both SBR and RBR + +connection master; +create table t1(a int auto_increment, primary key(a)); +create table t2(b int auto_increment, c int, primary key(b)); +insert into t1 values (1),(2),(3); +insert into t1 values (null); +insert into t2 values (null,last_insert_id()); +save_master_pos; +connection slave; +sync_with_master; +select * from t1 ORDER BY a; +select * from t2 ORDER BY b; +connection master; +#check if multi-line inserts, +#which set last_insert_id to the first id inserted, +#are replicated the same way +drop table t1; +drop table t2; +--disable_warnings +eval create table t1(a int auto_increment, key(a)) engine=$engine_type; +eval create table t2(b int auto_increment, c int, key(b), foreign key(b) references t1(a)) engine=$engine_type; +--enable_warnings +SET FOREIGN_KEY_CHECKS=0; +insert into t1 values (10); +insert into t1 values (null),(null),(null); +insert into t2 values (5,0); +insert into t2 values (null,last_insert_id()); +SET FOREIGN_KEY_CHECKS=1; +save_master_pos; +connection slave; +sync_with_master; +select * from t1; +select * from t2; +connection master; + +# check if INSERT SELECT in auto_increment is well replicated (bug #490) + +drop table t2; +drop table t1; +create table t1(a int auto_increment, primary key(a)); +create table t2(b int auto_increment, c int, primary key(b)); +insert into t1 values (10); +insert into t1 values (null),(null),(null); +insert into t2 values (5,0); +insert into t2 (c) select * from t1 ORDER BY a; +select * from t2 ORDER BY b; +save_master_pos; +connection slave; +sync_with_master; +select * from t1 ORDER BY a; +select * from t2 ORDER BY b; +connection master; +drop table t1; +drop table t2; +save_master_pos; +connection slave; +sync_with_master; + +# +# Bug#8412: Error codes reported in binary log for CHARACTER SET, +# FOREIGN_KEY_CHECKS +# +connection master; +SET TIMESTAMP=1000000000; +CREATE TABLE t1 ( a INT UNIQUE ); +SET FOREIGN_KEY_CHECKS=0; +# Duplicate Key Errors codes +--error 1022, 1062 +INSERT INTO t1 VALUES (1),(1); +sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/extra/rpl_tests/rpl_loaddata.test b/mysql-test/extra/rpl_tests/rpl_loaddata.test index 0da3a8b8011..5d7c69bd959 100644 --- a/mysql-test/extra/rpl_tests/rpl_loaddata.test +++ b/mysql-test/extra/rpl_tests/rpl_loaddata.test @@ -21,10 +21,10 @@ reset master; connection master; create table t1(a int not null auto_increment, b int, primary key(a) ); -load data infile '../../std_data/rpl_loaddata.dat' into table t1; +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60)); -load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; +load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60)); insert into t3 select * from t2; @@ -59,7 +59,7 @@ sync_with_master; insert into t1 values(1,10); connection master; -load data infile '../../std_data/rpl_loaddata.dat' into table t1; +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; save_master_pos; connection slave; @@ -83,7 +83,7 @@ connection master; set sql_log_bin=0; delete from t1; set sql_log_bin=1; -load data infile '../../std_data/rpl_loaddata.dat' into table t1; +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; save_master_pos; connection slave; # The SQL slave thread should be stopped now. @@ -108,7 +108,7 @@ connection master; set sql_log_bin=0; delete from t1; set sql_log_bin=1; -load data infile '../../std_data/rpl_loaddata.dat' into table t1; +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; save_master_pos; connection slave; # The SQL slave thread should be stopped now. @@ -128,7 +128,7 @@ reset master; eval create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60), unique(day)) engine=$engine_type; # no transactions --error 1062 -load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields +load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; select * from t2; @@ -144,7 +144,7 @@ alter table t2 drop key day; connection master; delete from t2; --error 1062 -load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields +load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; connection slave; diff --git a/mysql-test/extra/rpl_tests/rpl_log.test b/mysql-test/extra/rpl_tests/rpl_log.test index 252c1fcca41..7f1c50aaf0e 100644 --- a/mysql-test/extra/rpl_tests/rpl_log.test +++ b/mysql-test/extra/rpl_tests/rpl_log.test @@ -30,21 +30,25 @@ let $VERSION=`select version()`; connection master; reset master; -create table t1(n int not null auto_increment primary key); +eval create table t1(n int not null auto_increment primary key)ENGINE=$engine_type; insert into t1 values (NULL); drop table t1; -create table t1 (word char(20) not null); -load data infile '../../std_data/words.dat' into table t1 ignore 1 lines; +eval create table t1 (word char(20) not null)ENGINE=$engine_type; +load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines; select count(*) from t1; drop table t1; --replace_result $VERSION VERSION --replace_column 2 # 5 # +--replace_regex /\/\* xid=.* \*\//\/* XID *\// show binlog events; --replace_column 2 # 5 # +--replace_regex /\/\* xid=.* \*\//\/* XID *\// show binlog events from 102 limit 1; --replace_column 2 # 5 # +--replace_regex /\/\* xid=.* \*\//\/* XID *\// show binlog events from 102 limit 2; --replace_column 2 # 5 # +--replace_regex /\/\* xid=.* \*\//\/* XID *\// show binlog events from 102 limit 2,1; flush logs; @@ -64,7 +68,7 @@ flush logs; # To make it predictable, we do a useless update now, but which has the # interest of making the slave catch both rotate events. -create table t5 (a int); +eval create table t5 (a int)ENGINE=$engine_type; drop table t5; # Sync slave and force it to start on another binary log @@ -82,14 +86,16 @@ connection master; # Create some entries for second log -create table t1 (n int); +eval create table t1 (n int)ENGINE=$engine_type; insert into t1 values (1); drop table t1; --replace_result $VERSION VERSION --replace_column 2 # 5 # +--replace_regex /\/\* xid=.* \*\//\/* XID *\// show binlog events; --replace_result $VERSION VERSION --replace_column 2 # 5 # +--replace_regex /\/\* xid=.* \*\//\/* XID *\// show binlog events in 'master-bin.000002'; show binary logs; save_master_pos; @@ -99,9 +105,11 @@ sync_with_master; show binary logs; --replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION --replace_column 2 # 5 # +--replace_regex /\/\* xid=.* \*\//\/* XID *\// show binlog events in 'slave-bin.000001' from 4; --replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION --replace_column 2 # 5 # +--replace_regex /\/\* xid=.* \*\//\/* XID *\// show binlog events in 'slave-bin.000002' from 4; --replace_result $MASTER_MYPORT MASTER_PORT --replace_column 1 # 8 # 9 # 16 # 23 # 33 # diff --git a/mysql-test/extra/rpl_tests/rpl_row_001.test b/mysql-test/extra/rpl_tests/rpl_row_001.test index 2efefb3cd63..44638bdac96 100644 --- a/mysql-test/extra/rpl_tests/rpl_row_001.test +++ b/mysql-test/extra/rpl_tests/rpl_row_001.test @@ -5,7 +5,7 @@ CREATE TABLE t1 (word CHAR(20) NOT NULL); LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR eval LOAD DATA LOCAL INFILE '$MYSQL_TEST_DIR/std_data/words.dat' INTO TABLE t1; -SELECT * FROM t1 LIMIT 10; +SELECT * FROM t1 ORDER BY word LIMIT 10; # # Test slave with wrong password @@ -30,7 +30,7 @@ sleep 2; CREATE TABLE t3(n INT); INSERT INTO t3 VALUES(1),(2); sync_slave_with_master; -SELECT * FROM t3; +SELECT * FROM t3 ORDER BY n; SELECT SUM(LENGTH(word)) FROM t1; connection master; DROP TABLE t1,t3; diff --git a/mysql-test/extra/rpl_tests/rpl_row_UUID.test b/mysql-test/extra/rpl_tests/rpl_row_UUID.test index 6bad362057a..2f203eb8963 100644 --- a/mysql-test/extra/rpl_tests/rpl_row_UUID.test +++ b/mysql-test/extra/rpl_tests/rpl_row_UUID.test @@ -63,7 +63,9 @@ connection master; # Let's cleanup DROP PROCEDURE test.p1; +DROP FUNCTION test.fn1; DROP TABLE test.t1; +DROP TABLE test.t2; # Let's compare. Note: If they match test will pass, if they do not match # the test will show that the diff statement failed and not reject file diff --git a/mysql-test/extra/rpl_tests/rpl_row_blob.test b/mysql-test/extra/rpl_tests/rpl_row_blob.test index 5f1e4bea6f3..a1beafc32e1 100644 --- a/mysql-test/extra/rpl_tests/rpl_row_blob.test +++ b/mysql-test/extra/rpl_tests/rpl_row_blob.test @@ -20,12 +20,11 @@ DROP TABLE IF EXISTS test.t2; --echo ***** Table Create Section **** --echo --disable_warnings ---replace_result $engine_type engine_type -CREATE TABLE test.t1 (c1 int not null auto_increment, +--replace_result $engine_type # +eval CREATE TABLE test.t1 (c1 int not null auto_increment, data LONGBLOB, PRIMARY KEY(c1))ENGINE=$engine_type; --enable_warnings --echo - --echo **** Data Insert Section test.t1 ***** --echo INSERT INTO test.t1 VALUES (NULL, NULL); @@ -77,8 +76,8 @@ connection master; --echo **** Create Table test.t2 **** --echo --disable_warnings ---replace_result $engine_type engine_type -CREATE TABLE test.t2 ( +--replace_result $engine_type # +eval CREATE TABLE test.t2 ( c1 INT NOT NULL PRIMARY KEY, c2 TEXT, c3 INT, diff --git a/mysql-test/extra/rpl_tests/rpl_stm_000001.test b/mysql-test/extra/rpl_tests/rpl_stm_000001.test index fb2749a0764..443ed27053a 100644 --- a/mysql-test/extra/rpl_tests/rpl_stm_000001.test +++ b/mysql-test/extra/rpl_tests/rpl_stm_000001.test @@ -2,7 +2,7 @@ -- source include/master-slave.inc create table t1 (word char(20) not null); -load data infile '../../std_data/words.dat' into table t1; +load data infile '../std_data_ln/words.dat' into table t1; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1; select * from t1 limit 10; @@ -124,6 +124,7 @@ select n from t1; select select_priv,user from mysql.user where user = _binary'blafasel2'; connection master1; drop table t1; +delete from mysql.user where user="blafasel2"; save_master_pos; connection slave; sync_with_master; diff --git a/mysql-test/extra/rpl_tests/rpl_stm_charset.test b/mysql-test/extra/rpl_tests/rpl_stm_charset.test index e05bbb49c4a..e5209a9b9ac 100644 --- a/mysql-test/extra/rpl_tests/rpl_stm_charset.test +++ b/mysql-test/extra/rpl_tests/rpl_stm_charset.test @@ -156,7 +156,7 @@ select hex(c1), hex(c2) from t1; connection master; # Let's have a look at generated SETs. --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 drop table t1; sync_slave_with_master; diff --git a/mysql-test/t/rpl000005.test b/mysql-test/extra/rpl_tests/rpl_sv_relay_space.test index 0a2b7f9458a..57b74c80b58 100644 --- a/mysql-test/t/rpl000005.test +++ b/mysql-test/extra/rpl_tests/rpl_sv_relay_space.test @@ -3,6 +3,10 @@ # Change Date: 2006-01-17 # Change: Added order by in select #################### +# Change Date: 2006-02-02 +# Change: renamed to make bettre sense, +# and wrapped per Engine test +############################ source include/master-slave.inc; # @@ -10,7 +14,7 @@ source include/master-slave.inc; # SHOW VARIABLES LIKE 'relay_log_space_limit'; -CREATE TABLE t1 (name varchar(64), age smallint(3)); +eval CREATE TABLE t1 (name varchar(64), age smallint(3))ENGINE=$engine_type; INSERT INTO t1 SET name='Andy', age=31; INSERT t1 SET name='Jacob', age=2; INSERT into t1 SET name='Caleb', age=1; diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test new file mode 100644 index 00000000000..30cb7391f30 --- /dev/null +++ b/mysql-test/include/check-testcase.test @@ -0,0 +1,51 @@ +# +# This test is executed twice for each test case if mysql-test-run is passed +# the flag --check-testcase. +# Before every testcase it's run with mysqltest in record mode and will +# thus produce an output file +# that can be compared to output from after the tescase. +# In that way it's possible to check that a testcase does not have +# any unwanted side affects. +# + +# +# Dump all global variables +# +show global variables; + +# +# Dump all databases +# +show databases; + +# +# Dump the "test" database, all it's tables and their data +# +--exec $MYSQL_DUMP --skip-comments test + +# +# Dump the "mysql" database and it's tables +# Select data separately to add "order by" +# +--exec $MYSQL_DUMP --skip-comments --no-data mysql +use mysql; +select * from columns_priv; +select * from db order by host, db, user; +select * from func; +select * from help_category; +select * from help_keyword; +select * from help_relation; +select * from help_relation; +select * from host; +select * from proc; +select * from procs_priv; +select * from tables_priv; +select * from time_zone; +select * from time_zone_leap_second; +select * from time_zone_name; +select * from time_zone_transition; +select * from time_zone_transition_type; +select * from user; + + + diff --git a/mysql-test/include/have_outfile.inc b/mysql-test/include/have_outfile.inc index 31e95f4810a..10f093ec3ef 100644 --- a/mysql-test/include/have_outfile.inc +++ b/mysql-test/include/have_outfile.inc @@ -1,5 +1,5 @@ -- require r/have_outfile.require disable_query_log; select load_file(concat(@tmpdir,"/outfile.test")); ---exec rm $MYSQL_TEST_DIR/var/tmp/outfile.test +--exec rm $MYSQLTEST_VARDIR/tmp/outfile.test enable_query_log; diff --git a/mysql-test/include/sourced.inc b/mysql-test/include/sourced.inc new file mode 100644 index 00000000000..be1a270641a --- /dev/null +++ b/mysql-test/include/sourced.inc @@ -0,0 +1 @@ +echo here is the sourced script; diff --git a/mysql-test/include/sourced1.inc b/mysql-test/include/sourced1.inc new file mode 100644 index 00000000000..920561e5de2 --- /dev/null +++ b/mysql-test/include/sourced1.inc @@ -0,0 +1 @@ +--source include/sourced.inc diff --git a/mysql-test/include/test_outfile.inc b/mysql-test/include/test_outfile.inc index 0bede4938c6..b67e67a4dd4 100644 --- a/mysql-test/include/test_outfile.inc +++ b/mysql-test/include/test_outfile.inc @@ -1 +1 @@ -eval select "Outfile OK" into outfile "$MYSQL_TEST_DIR/var/tmp/outfile.test"; +eval select "Outfile OK" into outfile "$MYSQLTEST_VARDIR/tmp/outfile.test"; diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index a98a929b947..d6068c9691a 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -111,7 +111,7 @@ sub collect_test_cases ($) { # Disable some tests listed in disabled.def # ---------------------------------------------------------------------- my %disabled; - if ( open(DISABLED, "$testdir/disabled.def" ) ) + if ( ! $::opt_ignore_disabled_def and open(DISABLED, "$testdir/disabled.def" ) ) { while ( <DISABLED> ) { @@ -277,8 +277,8 @@ sub collect_one_test_case($$$$$$$) { my $disabled_file= "$testdir/$tname.disabled"; my $im_opt_file= "$testdir/$tname-im.opt"; - $tinfo->{'master_opt'}= $::glob_win32 ? ["--default-time-zone=+3:00"] : []; - $tinfo->{'slave_opt'}= $::glob_win32 ? ["--default-time-zone=+3:00"] : []; + $tinfo->{'master_opt'}= []; + $tinfo->{'slave_opt'}= []; $tinfo->{'slave_mi'}= []; if ( -f $master_opt_file ) @@ -301,7 +301,6 @@ sub collect_one_test_case($$$$$$$) { if ( defined $value ) { $tinfo->{'timezone'}= $value; - $tinfo->{'skip'}= 1 if $::glob_win32; # FIXME server unsets TZ last MASTER_OPT; } diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 4d88c9b3322..86a4312e0c8 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -781,7 +781,15 @@ sub mtr_record_dead_children () { } sub start_reap_all { - $SIG{CHLD}= 'IGNORE'; # FIXME is this enough? + # This causes terminating processes to not become zombies, avoiding + # the need for (or possibility of) explicit waitpid(). + $SIG{CHLD}= 'IGNORE'; + + # On some platforms (Linux, QNX, OSX, ...) there is potential race + # here. If a process terminated before setting $SIG{CHLD} (but after + # any attempt to waitpid() it), it will still be a zombie. So we + # have to handle any such process here. + while(waitpid(-1, &WNOHANG) > 0) { }; } sub stop_reap_all { diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index 515988ee5c7..88ddbf63d0f 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -185,39 +185,57 @@ sub mtr_report_stats ($) { } # ---------------------------------------------------------------------- + # If a debug run, there might be interesting information inside + # the "var/log/*.err" files. We save this info in "var/log/warnings" # ---------------------------------------------------------------------- if ( ! $::glob_use_running_server ) { + # Save and report if there was any fatal warnings/errors in err logs - # Report if there was any fatal warnings/errors in the log files - # - unlink("$::opt_vardir/log/warnings"); - unlink("$::opt_vardir/log/warnings.tmp"); - # Remove some non fatal warnings from the log files - -# FIXME what is going on ????? ;-) -# sed -e 's!Warning: Table:.* on delete!!g' -e 's!Warning: Setting lower_case_table_names=2!!g' -e 's!Warning: One can only use the --user.*root!!g' \ -# var/log/*.err \ -# | sed -e 's!Warning: Table:.* on rename!!g' \ -# > var/log/warnings.tmp; -# -# found_error=0; -# # Find errors -# for i in "^Warning:" "^Error:" "^==.* at 0x" -# do -# if ( $GREP "$i" var/log/warnings.tmp >> var/log/warnings ) -# { -# found_error=1 -# } -# done -# unlink("$::opt_vardir/log/warnings.tmp"); -# if ( $found_error= "1" ) -# { -# print "WARNING: Got errors/warnings while running tests. Please examine\n" -# print "$::opt_vardir/log/warnings for details.\n" -# } -# } + my $warnlog= "$::opt_vardir/log/warnings"; + + unless ( open(WARN, ">$warnlog") ) + { + mtr_warning("can't write to the file \"$warnlog\": $!"); + } + else + { + my $found_problems= 0; # Some warnings are errors... + + # We report different types of problems in order + foreach my $pattern ( "^Warning:", "^Error:", "^==.* at 0x" ) + { + foreach my $errlog ( sort glob("$::opt_vardir/log/*.err") ) + { + unless ( open(ERR, $errlog) ) + { + mtr_warning("can't read $errlog"); + next; + } + while ( <ERR> ) + { + # Skip some non fatal warnings from the log files + if ( /Warning:\s+Table:.* on (delete|rename)/ or + /Warning:\s+Setting lower_case_table_names=2/ or + /Warning:\s+One can only use the --user.*root/ ) + { + next; # Skip these lines + } + if ( /$pattern/ ) + { + $found_problems= 1; + print WARN $_; + } + } + } + if ( $found_problems ) + { + mtr_warning("Got errors/warnings while running tests, please examine", + "\"$warnlog\" for details."); + } + } + } } print "\n"; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 1861b9e35e5..6f9400d4fff 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -76,6 +76,7 @@ $Devel::Trace::TRACE= 0; # Don't trace boring init stuff #require 5.6.1; use File::Path; use File::Basename; +use File::Copy; use Cwd; use Getopt::Long; use Sys::Hostname; @@ -156,8 +157,8 @@ our $path_client_bindir; our $path_language; our $path_timefile; our $path_manager_log; # Used by mysqldadmin -our $path_mysqltest_log; our $path_slave_load_tmpdir; # What is this?! +our $path_mysqltest_log; our $path_my_basedir; our $opt_vardir; # A path but set directly on cmd line our $opt_tmpdir; # A path but set directly on cmd line @@ -246,6 +247,7 @@ our $opt_manager_port; # Does nothing now, we never use manager our $opt_old_master; our $opt_record; +our $opt_check_testcases; our $opt_result_ext; @@ -514,15 +516,26 @@ sub command_line_setup () { my $im_mysqld1_port= 9312; my $im_mysqld2_port= 9314; + # + # To make it easier for different devs to work on the same host, + # an environment variable can be used to control all ports. A small + # number is to be used, 0 - 16 or similar. + # + # Note the MASTER_MYPORT has to be set the same in all 4.x and 5.x + # versions of this script, else a 4.0 test run might conflict with a + # 5.1 test run, even if different MTR_BUILD_THREAD is used. This means + # all port numbers might not be used in this version of the script. + # if ( $ENV{'MTR_BUILD_THREAD'} ) { - $opt_master_myport= $ENV{'MTR_BUILD_THREAD'} * 40 + 8120; - $opt_slave_myport= $opt_master_myport + 16; - $opt_ndbcluster_port= $opt_master_myport + 24; - $opt_ndbcluster_port_slave= $opt_master_myport + 32; - $im_port= $opt_master_myport + 10; - $im_mysqld1_port= $opt_master_myport + 12; - $im_mysqld2_port= $opt_master_myport + 14; + # Up to two masters, up to three slaves + $opt_master_myport= $ENV{'MTR_BUILD_THREAD'} * 10 + 10000; # and 1 + $opt_slave_myport= $opt_master_myport + 2; # and 3 4 + $opt_ndbcluster_port= $opt_master_myport + 5; + $opt_ndbcluster_port_slave= $opt_master_myport + 6; + $im_port= $opt_master_myport + 7; + $im_mysqld1_port= $opt_master_myport + 8; + $im_mysqld2_port= $opt_master_myport + 9; } # Read the command line @@ -571,6 +584,7 @@ sub command_line_setup () { # Test case authoring 'record' => \$opt_record, + 'check-testcases' => \$opt_check_testcases, # ??? 'mysqld=s' => \@opt_extra_mysqld_opt, @@ -681,6 +695,7 @@ sub command_line_setup () { # -------------------------------------------------------------------------- $opt_tmpdir= "$opt_vardir/tmp" unless $opt_tmpdir; + $opt_tmpdir =~ s,/+$,,; # Remove ending slash if any # FIXME maybe not needed? $path_manager_log= "$opt_vardir/log/manager.log" unless $path_manager_log; @@ -1118,12 +1133,15 @@ sub environment_setup () { $ENV{'USE_RUNNING_SERVER'}= $glob_use_running_server; $ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir; $ENV{'MYSQL_TEST_WINDIR'}= $glob_mysql_test_dir; - $ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_mysock'}; + $ENV{'MYSQLTEST_VARDIR'}= $opt_vardir; $ENV{'MASTER_WINMYSOCK'}= $master->[0]->{'path_mysock'}; + $ENV{'MASTER_MYSOCK'}= $master->[0]->{'path_mysock'}; $ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_mysock'}; $ENV{'MASTER_MYPORT'}= $master->[0]->{'path_myport'}; $ENV{'MASTER_MYPORT1'}= $master->[1]->{'path_myport'}; $ENV{'SLAVE_MYPORT'}= $slave->[0]->{'path_myport'}; + $ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'path_myport'}; + $ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'path_myport'}; # $ENV{'MYSQL_TCP_PORT'}= '@MYSQL_TCP_PORT@'; # FIXME $ENV{'MYSQL_TCP_PORT'}= 3306; @@ -1131,6 +1149,7 @@ sub environment_setup () { $ENV{'NDBCLUSTER_PORT_SLAVE'}=$opt_ndbcluster_port_slave; $ENV{'IM_PATH_PID'}= $instance_manager->{path_pid}; + $ENV{'IM_PORT'}= $instance_manager->{port}; $ENV{'IM_MYSQLD1_SOCK'}= $instance_manager->{instances}->[0]->{path_sock}; $ENV{'IM_MYSQLD1_PORT'}= $instance_manager->{instances}->[0]->{port}; @@ -1149,15 +1168,20 @@ sub environment_setup () { } } + $ENV{MTR_BUILD_THREAD}= 0 unless $ENV{MTR_BUILD_THREAD}; # Set if not set + # We are nice and report a bit about our settings - print "Using MTR_BUILD_THREAD = ",$ENV{MTR_BUILD_THREAD} || 0,"\n"; - print "Using MASTER_MYPORT = $ENV{MASTER_MYPORT}\n"; - print "Using MASTER_MYPORT1 = $ENV{MASTER_MYPORT1}\n"; - print "Using SLAVE_MYPORT = $ENV{SLAVE_MYPORT}\n"; - print "Using NDBCLUSTER_PORT = $ENV{NDBCLUSTER_PORT}\n"; + print "Using MTR_BUILD_THREAD = $ENV{MTR_BUILD_THREAD}\n"; + print "Using MASTER_MYPORT = $ENV{MASTER_MYPORT}\n"; + print "Using MASTER_MYPORT1 = $ENV{MASTER_MYPORT1}\n"; + print "Using SLAVE_MYPORT = $ENV{SLAVE_MYPORT}\n"; + print "Using SLAVE_MYPORT1 = $ENV{SLAVE_MYPORT1}\n"; + print "Using SLAVE_MYPORT2 = $ENV{SLAVE_MYPORT2}\n"; + print "Using NDBCLUSTER_PORT = $ENV{NDBCLUSTER_PORT}\n"; print "Using NDBCLUSTER_PORT_SLAVE = $ENV{NDBCLUSTER_PORT_SLAVE}\n"; - print "Using IM_MYSQLD1_PORT = $ENV{'IM_MYSQLD1_PORT'}\n"; - print "Using IM_MYSQLD2_PORT = $ENV{'IM_MYSQLD2_PORT'}\n"; + print "Using IM_PORT = $ENV{IM_PORT}\n"; + print "Using IM_MYSQLD1_PORT = $ENV{IM_MYSQLD1_PORT}\n"; + print "Using IM_MYSQLD2_PORT = $ENV{IM_MYSQLD2_PORT}\n"; } @@ -1208,6 +1232,7 @@ sub kill_running_server () { mkpath("$opt_vardir/log"); # Needed for mysqladmin log mtr_kill_leftovers(); + $using_ndbcluster_master= $opt_with_ndbcluster; ndbcluster_stop(); $master->[0]->{'ndbcluster'}= 1; ndbcluster_stop_slave(); @@ -1221,10 +1246,40 @@ sub kill_and_cleanup () { mtr_report("Removing Stale Files"); - rmtree("$opt_vardir/log"); - rmtree("$opt_vardir/ndbcluster-$opt_ndbcluster_port"); - rmtree("$opt_vardir/run"); - rmtree("$opt_vardir/tmp"); + if ( $opt_vardir eq "$glob_mysql_test_dir/var" ) + { + # + # Running with "var" in mysql-test dir + # + if ( -l "$glob_mysql_test_dir/var" ) + { + # Some users creates a soft link in mysql-test/var to another area + # - allow it + mtr_report("WARNING: Using the 'mysql-test/var' symlink"); + rmtree("$opt_vardir/log"); + rmtree("$opt_vardir/ndbcluster-$opt_ndbcluster_port"); + rmtree("$opt_vardir/run"); + rmtree("$opt_vardir/tmp"); + } + else + { + # Remove the entire "var" dir + rmtree("$opt_vardir/"); + } + } + else + { + # + # Running with "var" in some other place + # + + # Remove the var/ dir in mysql-test dir if any + # this could be an old symlink that shouldn't be there + rmtree("$glob_mysql_test_dir/var"); + + # Remove the "var" dir + rmtree("$opt_vardir/"); + } mkpath("$opt_vardir/log"); mkpath("$opt_vardir/run"); @@ -1240,7 +1295,7 @@ sub kill_and_cleanup () { $slave->[0]->{'path_myddir'}, $slave->[1]->{'path_myddir'}, $slave->[2]->{'path_myddir'}); - + foreach my $instance (@{$instance_manager->{'instances'}}) { push(@data_dir_lst, $instance->{'path_datadir'}); @@ -1253,18 +1308,27 @@ sub kill_and_cleanup () { mkpath("$data_dir/test"); } - # To make some old test cases work, we create a soft - # link from the old "var" location to the new one - - if ( ! $glob_win32 and $opt_vardir ne "$glob_mysql_test_dir/var" ) + # Make a link std_data_ln in var/ that points to std_data + if ( ! $glob_win32 ) { - # FIXME why bother with the above, why not always remove all of var?! - rmtree("$glob_mysql_test_dir/var"); # Clean old var, FIXME or rename it?! - symlink($opt_vardir, "$glob_mysql_test_dir/var"); + symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln"); + } + else + { + # on windows, copy all files from std_data into var/std_data_ln + mkpath("$opt_vardir/std_data_ln"); + opendir(DIR, "$glob_mysql_test_dir/std_data") + or mtr_error("Can't find the std_data directory: $!"); + for(readdir(DIR)) { + next if -d "$glob_mysql_test_dir/std_data/$_"; + copy("$glob_mysql_test_dir/std_data/$_", "$opt_vardir/std_data_ln/$_"); + } + closedir(DIR); } } + sub check_ssl_support () { if ($opt_skip_ssl) @@ -1408,6 +1472,7 @@ sub ndbcluster_start ($) { } if ( $using_ndbcluster_master ) { + # Master already started return 0; } # FIXME, we want to _append_ output to file $file_ndb_testrun_log instead of /dev/null @@ -1840,7 +1905,7 @@ EOF ; print OUT "nonguarded\n" if $instance->{'nonguarded'}; - print OUT "old-log-format\n" if $instance->{'old_log_format'}; + print OUT "log-output=FILE\n" if $instance->{'old_log_format'}; print OUT "\n"; } @@ -1917,7 +1982,8 @@ sub run_testcase ($) { { if ( $tinfo->{'master_restart'} or $master->[0]->{'running_master_is_special'} or - ( $tinfo->{'ndb_test'} != $using_ndbcluster_master ) ) + # Stop if cluster is started but test cases does not need cluster + ( $tinfo->{'ndb_test'} != $using_ndbcluster_master ) ) { stop_masters(); $master->[0]->{'running_master_is_special'}= 0; # Forget why we stopped @@ -1972,12 +2038,16 @@ sub run_testcase ($) { { if ( $master->[0]->{'ndbcluster'} ) { + # Cluster is not started + + # Call ndbcluster_start to check if test case needs cluster + # Start it if not already started $master->[0]->{'ndbcluster'}= ndbcluster_start($tinfo->{'ndb_test'}); - if ( $master->[0]->{'ndbcluster'} ) - { - report_failure_and_restart($tinfo); - return; - } + if ( $master->[0]->{'ndbcluster'} ) + { + report_failure_and_restart($tinfo); + return; + } } if ( ! $master->[0]->{'pid'} ) { @@ -1994,6 +2064,7 @@ sub run_testcase ($) { } if ( $using_ndbcluster_master and ! $master->[1]->{'pid'} ) { + # Test needs cluster, start an extra mysqld connected to cluster mtr_tofile($master->[1]->{'path_myerr'},"CURRENT_TEST: $tname\n"); $master->[1]->{'pid'}= mysqld_start('master',1,$tinfo->{'master_opt'},[], @@ -2316,15 +2387,15 @@ sub mysqld_arguments ($$$$$$) { mtr_add_arg($args, "%s--skip-innodb", $prefix); } - if ( $opt_skip_ndbcluster ) + if ( $opt_skip_ndbcluster || !$using_ndbcluster) { mtr_add_arg($args, "%s--skip-ndbcluster", $prefix); } - if ( $using_ndbcluster ) + else { mtr_add_arg($args, "%s--ndbcluster", $prefix); mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix, - $opt_ndbconnectstring); + $opt_ndbconnectstring); mtr_add_arg($args, "%s--ndb-extra-logging", $prefix); } } @@ -2359,8 +2430,12 @@ sub mysqld_arguments ($$$$$$) { mtr_add_arg($args, "%s--skip-innodb", $prefix); mtr_add_arg($args, "%s--skip-ndbcluster", $prefix); mtr_add_arg($args, "%s--skip-slave-start", $prefix); + + # Directory where slaves find the dumps generated by "load data" + # on the server. The path need to have constant length otherwise + # test results will vary, thus a relative path is used. mtr_add_arg($args, "%s--slave-load-tmpdir=%s", $prefix, - $path_slave_load_tmpdir); + "../tmp"); mtr_add_arg($args, "%s--socket=%s", $prefix, $slave->[$idx]->{'path_mysock'}); mtr_add_arg($args, "%s--set-variable=slave_net_timeout=10", $prefix); @@ -2506,6 +2581,7 @@ sub mysqld_start ($$$$$) { my $slave_master_info= shift; my $using_ndbcluster= shift; + my $args; # Arg vector my $exe; my $pid; @@ -2730,6 +2806,54 @@ sub im_stop($) { $instance_manager->{'pid'} = undef; } +# +# Run include/check-testcase.test +# Before a testcase, run in record mode, save result file to var +# After testcase, run and compare with the recorded file, they should be equal! +# +sub run_check_testcase ($) { + + my $mode= shift; + + my $args; + mtr_init_args(\$args); + + mtr_add_arg($args, "--no-defaults"); + mtr_add_arg($args, "--silent"); + mtr_add_arg($args, "-v"); + mtr_add_arg($args, "--skip-safemalloc"); + mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir); + + mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_mysock'}); + mtr_add_arg($args, "--port=%d", $master->[0]->{'path_myport'}); + mtr_add_arg($args, "--database=test"); + mtr_add_arg($args, "--user=%s", $opt_user); + mtr_add_arg($args, "--password="); + + mtr_add_arg($args, "-R"); + mtr_add_arg($args, "$opt_vardir/tmp/check-testcase.result"); + + if ( $mode eq "before" ) + { + mtr_add_arg($args, "--record"); + } + + my $res = mtr_run_test($exe_mysqltest,$args, + "include/check-testcase.test", "", "", ""); + + if ( $res == 1 and $mode = "after") + { + mtr_run("diff",["-u", + "$opt_vardir/tmp/check-testcase.result", + "$opt_vardir/tmp/check-testcase.reject"], + "", "", "", ""); + } + elsif ( $res ) + { + mtr_error("Could not execute 'check-testcase' $mode testcase"); + } +} + sub run_mysqltest ($) { my $tinfo= shift; @@ -2983,7 +3107,18 @@ sub run_mysqltest ($) { mtr_add_arg($args, "--record"); } - return mtr_run_test($exe,$args,$tinfo->{'path'},"",$path_timefile,""); + if ( $opt_check_testcases ) + { + run_check_testcase("before"); + } + + my $res = mtr_run_test($exe,$args,$tinfo->{'path'},"",$path_timefile,""); + + if ( $opt_check_testcases ) + { + run_check_testcase("after"); + } + return $res; } @@ -3040,7 +3175,7 @@ Options to control what engine/variation to run sp-protocol Create a stored procedure to execute all queries compress Use the compressed protocol between client and server ssl Use ssl protocol between client and server - skip-ssl Dont start sterver with support for ssl connections + skip-ssl Dont start server with support for ssl connections bench Run the benchmark suite FIXME small-bench FIXME @@ -3067,6 +3202,7 @@ Options that specify ports Options for test case authoring record TESTNAME (Re)genereate the result file for TESTNAME + check-testcases Check testcases for sideeffects Options that pass on options diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 409a5a345f8..df3b8090ab0 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -185,7 +185,8 @@ BASEDIR=`pwd` cd $CWD MYSQL_TEST_DIR=$BASEDIR/mysql-test MYSQL_TEST_WINDIR=$MYSQL_TEST_DIR -export MYSQL_TEST_DIR MYSQL_TEST_WINDIR +MYSQLTEST_VARDIR=$MYSQL_TEST_DIR/var +export MYSQL_TEST_DIR MYSQL_TEST_WINDIR MYSQLTEST_VARDIR STD_DATA=$MYSQL_TEST_DIR/std_data hostname=`hostname` # Installed in the mysql privilege table @@ -201,7 +202,14 @@ SYST=0 REALT=0 FAST_START="" MYSQL_TMP_DIR=$MYSQL_TEST_DIR/var/tmp -SLAVE_LOAD_TMPDIR=../../var/tmp #needs to be same length to test logging + +# Use a relative path for where the slave will find the dumps +# generated by "LOAD DATA" on the master. The path is relative +# since it must have fixed length to test logging +# i.e otherwise the output from "SHOW MASTER STATUS" will vary +# with the strlen() of MYSQL_TEST_DIR +SLAVE_LOAD_TMPDIR=../tmp + RES_SPACE=" " MYSQLD_SRC_DIRS="strings mysys include extra regex myisam \ myisammrg heap sql" @@ -239,11 +247,16 @@ MYSQL_MANAGER_USER=root # an environment variable can be used to control all ports. A small # number is to be used, 0 - 16 or similar. # +# Note the MASTER_MYPORT has to be set the same in all 4.x and 5.x +# versions of this script, else a 4.0 test run might conflict with a +# 5.1 test run, even if different MTR_BUILD_THREAD is used. This means +# all port numbers might not be used in this version of the script. +# if [ -n "$MTR_BUILD_THREAD" ] ; then - MASTER_MYPORT=`expr $MTR_BUILD_THREAD '*' 5 + 10000` + MASTER_MYPORT=`expr $MTR_BUILD_THREAD '*' 10 + 10000` MYSQL_MANAGER_PORT=`expr $MASTER_MYPORT + 2` SLAVE_MYPORT=`expr $MASTER_MYPORT + 3` - NDBCLUSTER_PORT=`expr $MASTER_MYPORT + 4` + NDBCLUSTER_PORT=`expr $MASTER_MYPORT + 6` echo "Using MTR_BUILD_THREAD = $MTR_BUILD_THREAD" echo "Using MASTER_MYPORT = $MASTER_MYPORT" @@ -650,6 +663,9 @@ fi [ -d $MYSQL_TEST_DIR/var/tmp ] || mkdir $MYSQL_TEST_DIR/var/tmp [ -d $MYSQL_TEST_DIR/var/run ] || mkdir $MYSQL_TEST_DIR/var/run [ -d $MYSQL_TEST_DIR/var/log ] || mkdir $MYSQL_TEST_DIR/var/log +if ! test -L $MYSQL_TEST_DIR/var/std_data_ln ; then + ln -s $MYSQL_TEST_DIR/std_data/ $MYSQL_TEST_DIR/var/std_data_ln +fi if test ${COLUMNS:-0} -lt 80 ; then COLUMNS=80 ; fi E=`$EXPR $COLUMNS - 8` @@ -1371,7 +1387,7 @@ start_master() fi if [ x$MASTER_MYSQLDBINLOG = x1 ] then - EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --log-bin=$MYSQL_TEST_DIR/var/log/master-bin$1" + MASTER_MYSQLD_BINLOG_OPT="--log-bin=$MYSQL_TEST_DIR/var/log/master-bin$1" fi if [ -z "$DO_BENCH" -a -z "$DO_STRESS" ] then @@ -1398,6 +1414,7 @@ start_master() --loose-binlog-show-xid=0 \ $MASTER_40_ARGS \ $SMALL_SERVER \ + $MASTER_MYSQLD_BINLOG_OPT \ $EXTRA_MASTER_MYSQLD_OPT $EXTRA_MASTER_OPT \ $NOT_FIRST_MASTER_EXTRA_OPTS $CURR_MASTER_MYSQLD_TRACE" else @@ -1421,6 +1438,7 @@ start_master() --loose-binlog-show-xid=0 \ $MASTER_40_ARGS \ $SMALL_SERVER \ + $MASTER_MYSQLD_BINLOG_OPT \ $EXTRA_MASTER_MYSQLD_OPT $EXTRA_MASTER_OPT \ $NOT_FIRST_MASTER_EXTRA_OPTS" fi @@ -1563,7 +1581,7 @@ start_slave() if [ x$SLAVE_MYSQLDBINLOG = x1 ] then - EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --log-bin=$MYSQL_TEST_DIR/var/log/$slave_ident-bin --log-slave-updates" + SLAVE_MYSQLD_BINLOG_OPT="--log-bin=$MYSQL_TEST_DIR/var/log/$slave_ident-bin --log-slave-updates" fi $RM -f $slave_datadir/log.* @@ -1592,6 +1610,7 @@ start_slave() --log-bin-trust-function-creators \ --loose-binlog-show-xid=0 \ $SMALL_SERVER \ + $SLAVE_MYSQLD_BINLOG_OPT \ $EXTRA_SLAVE_MYSQLD_OPT $EXTRA_SLAVE_OPT \ $USE_NDBCLUSTER_SLAVE_OPT" CUR_MYERR=$slave_err diff --git a/mysql-test/r/analyze.result b/mysql-test/r/analyze.result index 17686d597a4..65c6955a959 100644 --- a/mysql-test/r/analyze.result +++ b/mysql-test/r/analyze.result @@ -46,3 +46,4 @@ Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_ execute stmt1; Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype deallocate prepare stmt1; +drop table t1; diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index 201383b06be..26d95a4dc8d 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -12537,4 +12537,59 @@ SELECT c FROM t5 WHERE a IN (32, 23, 5); c NULL posterity +drop table t1; +create table t1 (v varchar(32)); +insert into t1 values ('def'),('abc'),('hij'),('3r4f'); +select * from t1; +v +def +abc +hij +3r4f +alter table t1 change v v2 varchar(32); +select * from t1; +v2 +def +abc +hij +3r4f +alter table t1 change v2 v varchar(64); +select * from t1; +v +def +abc +hij +3r4f +update t1 set v = 'lmn' where v = 'hij'; +select * from t1; +v +def +abc +lmn +3r4f +alter table t1 add i int auto_increment not null primary key first; +select * from t1; +i v +1 def +2 abc +3 lmn +4 3r4f +update t1 set i=5 where i=3; +select * from t1; +i v +1 def +2 abc +5 lmn +4 3r4f +alter table t1 change i i bigint; +select * from t1; +i v +1 def +2 abc +5 lmn +4 3r4f +alter table t1 add unique key (i, v); +select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn'); +i v +4 3r4f drop table t1, t2, t4, t5; diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index 89f30c9d1f4..2fe4db859b5 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -145,12 +145,12 @@ id select_type table type possible_keys key key_len ref rows Extra Warnings: Note 1003 select sql_no_cache last_insert_id() AS `last_insert_id()` insert into t1 set i = 254; -ERROR 23000: Duplicate entry '254' for key 1 +ERROR 23000: Duplicate entry '254' for key 'PRIMARY' select last_insert_id(); last_insert_id() 255 insert into t1 set i = null; -ERROR 23000: Duplicate entry '255' for key 1 +ERROR 23000: Duplicate entry '255' for key 'PRIMARY' select last_insert_id(); last_insert_id() 0 @@ -178,7 +178,7 @@ select last_insert_id(); last_insert_id() 2 insert into t1 values (NULL, 10); -ERROR 23000: Duplicate entry '10' for key 2 +ERROR 23000: Duplicate entry '10' for key 'b' select last_insert_id(); last_insert_id() 0 @@ -379,7 +379,7 @@ key (rowid), unique(val)); replace into t1 (val) values ('1'),('2'); replace into t1 (val) values ('1'),('2'); insert into t1 (val) values ('1'),('2'); -ERROR 23000: Duplicate entry '1' for key 2 +ERROR 23000: Duplicate entry '1' for key 'val' select * from t1; rowid val 3 1 diff --git a/mysql-test/r/backup.result b/mysql-test/r/backup.result index 96df7c2da06..8c5d76565da 100644 --- a/mysql-test/r/backup.result +++ b/mysql-test/r/backup.result @@ -6,7 +6,7 @@ Table Op Msg_type Msg_text test.t4 backup error Failed copying .frm file (errno: X) test.t4 backup status Operation failed Warnings: -Error 1 Can't create/write to file 'MYSQL_TEST_DIR/var/bogus/t4.frm' (Errcode: X) +Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/bogus/t4.frm' (Errcode: X) backup table t4 to '../tmp'; Table Op Msg_type Msg_text test.t4 backup status OK @@ -15,7 +15,7 @@ Table Op Msg_type Msg_text test.t4 backup error Failed copying .frm file (errno: X) test.t4 backup status Operation failed Warnings: -Error 1 Can't create/write to file 'MYSQL_TEST_DIR/var/tmp/t4.frm' (Errcode: X) +Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/tmp/t4.frm' (Errcode: X) drop table t4; restore table t4 from '../tmp'; Table Op Msg_type Msg_text @@ -33,7 +33,7 @@ restore table t1 from '../bogus'; Table Op Msg_type Msg_text t1 restore error Failed copying .frm file Warnings: -Error 29 File 'MYSQL_TEST_DIR/var/bogus/t1.frm' not found (Errcode: X) +Error 29 File 'MYSQLTEST_VARDIR/bogus/t1.frm' not found (Errcode: X) restore table t1 from '../tmp'; Table Op Msg_type Msg_text test.t1 restore status OK diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index c40fd696704..ba6ed396f93 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -48,7 +48,7 @@ id parent_id level 15 102 2 update t1 set id=id+1000; update t1 set id=1024 where id=1009; -ERROR 23000: Duplicate entry '1024' for key 1 +ERROR 23000: Duplicate entry '1024' for key 'PRIMARY' select * from t1; id parent_id level 1001 100 0 @@ -270,7 +270,7 @@ n after commit commit; insert into t1 values (5); insert into t1 values (4); -ERROR 23000: Duplicate entry '4' for key 1 +ERROR 23000: Duplicate entry '4' for key 'PRIMARY' commit; select n, "after commit" from t1; n after commit @@ -279,7 +279,7 @@ n after commit set autocommit=1; insert into t1 values (6); insert into t1 values (4); -ERROR 23000: Duplicate entry '4' for key 1 +ERROR 23000: Duplicate entry '4' for key 'PRIMARY' select n from t1; n 4 @@ -343,7 +343,7 @@ drop table t1; CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=bdb; insert into t1 values ('pippo', 12); insert into t1 values ('pippo', 12); -ERROR 23000: Duplicate entry 'pippo' for key 1 +ERROR 23000: Duplicate entry 'pippo' for key 'PRIMARY' delete from t1; delete from t1 where id = 'pippo'; select * from t1; @@ -498,9 +498,9 @@ UNIQUE ggid (ggid) insert into t1 (ggid,passwd) values ('test1','xxx'); insert into t1 (ggid,passwd) values ('test2','yyy'); insert into t1 (ggid,passwd) values ('test2','this will fail'); -ERROR 23000: Duplicate entry 'test2' for key 2 +ERROR 23000: Duplicate entry 'test2' for key 'ggid' insert into t1 (ggid,id) values ('this will fail',1); -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t1 where ggid='test1'; id ggid email passwd 1 test1 xxx @@ -513,7 +513,7 @@ id ggid email passwd replace into t1 (ggid,id) values ('this will work',1); replace into t1 (ggid,passwd) values ('test2','this will work'); update t1 set id=100,ggid='test2' where id=1; -ERROR 23000: Duplicate entry 'test2' for key 2 +ERROR 23000: Duplicate entry 'test2' for key 'ggid' select * from t1; id ggid email passwd 1 this will work @@ -1047,7 +1047,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); LOCK TABLES t1 WRITE; insert into t1 values (99,1,2,'D'),(1,1,2,'D'); -ERROR 23000: Duplicate entry '1-1' for key 1 +ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY' select id from t1; id 0 @@ -1065,7 +1065,7 @@ insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJ LOCK TABLES t1 WRITE; begin; insert into t1 values (99,1,2,'D'),(1,1,2,'D'); -ERROR 23000: Duplicate entry '1-1' for key 1 +ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY' select id from t1; id 0 @@ -1487,7 +1487,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref v v 13 const # Using where alter table t1 add unique(v); -ERROR 23000: Duplicate entry '{ ' for key 1 +ERROR 23000: Duplicate entry '{ ' for key 'v_2' alter table t1 add key(v); select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a'; qq @@ -1847,16 +1847,16 @@ drop table t1; create table t1 (a char(10), unique (a)); insert into t1 values ('a '); insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a' for key 1 +ERROR 23000: Duplicate entry 'a' for key 'a' alter table t1 modify a varchar(10); insert into t1 values ('a '),('a '),('a '),('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' update t1 set a='a ' where a like 'a%'; select concat(a,'.') from t1; concat(a,'.') diff --git a/mysql-test/r/binlog_row_blackhole.result b/mysql-test/r/binlog_row_blackhole.result index 5c79f27bdf5..941d208a10b 100644 --- a/mysql-test/r/binlog_row_blackhole.result +++ b/mysql-test/r/binlog_row_blackhole.result @@ -92,7 +92,7 @@ insert into t1 values(1); insert ignore into t1 values(1); replace into t1 values(100); create table t2 (a varchar(200)) engine=blackhole; -load data infile '../../std_data/words.dat' into table t2; +load data infile '../std_data_ln/words.dat' into table t2; alter table t1 add b int; alter table t1 drop b; create table t3 like t1; diff --git a/mysql-test/r/binlog_stm_binlog.result b/mysql-test/r/binlog_stm_binlog.result index 80de6b6eaa9..ac4ca23782d 100644 --- a/mysql-test/r/binlog_stm_binlog.result +++ b/mysql-test/r/binlog_stm_binlog.result @@ -1,3 +1,15 @@ +create table t1 (a int, b int) engine=innodb; +begin; +insert into t1 values (1,2); +commit; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 4 Format_desc 1 102 Server ver: 5.1.7-beta-debug-log, Binlog ver: 4 +master-bin.000001 102 Query 1 209 use `test`; create table t1 (a int, b int) engine=innodb +master-bin.000001 209 Query 1 277 use `test`; BEGIN +master-bin.000001 277 Query 1 90 use `test`; insert into t1 values (1,2) +master-bin.000001 367 Xid 1 394 COMMIT /* XID */ +drop table t1; drop table if exists t1, t2; reset master; create table t1 (a int) engine=bdb; diff --git a/mysql-test/r/binlog_stm_blackhole.result b/mysql-test/r/binlog_stm_blackhole.result index 994a40832c7..90eabc6fa66 100644 --- a/mysql-test/r/binlog_stm_blackhole.result +++ b/mysql-test/r/binlog_stm_blackhole.result @@ -92,7 +92,7 @@ insert into t1 values(1); insert ignore into t1 values(1); replace into t1 values(100); create table t2 (a varchar(200)) engine=blackhole; -load data infile '../../std_data/words.dat' into table t2; +load data infile '../std_data_ln/words.dat' into table t2; alter table t1 add b int; alter table t1 drop b; create table t3 like t1; @@ -122,7 +122,7 @@ master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; create table t2 (a varchar(200)) engine=blackhole master-bin.000001 # Begin_load_query 1 # ;file_id=1;block_len=581 master-bin.000001 # Query 1 # use `test`; COMMIT -master-bin.000001 # Execute_load_query 1 # use `test`; load data infile '../../std_data/words.dat' into table t2 ;file_id=1 +master-bin.000001 # Execute_load_query 1 # use `test`; load data infile '../std_data_ln/words.dat' into table t2 ;file_id=1 master-bin.000001 # Query 1 # use `test`; COMMIT master-bin.000001 # Query 1 # use `test`; alter table t1 add b int master-bin.000001 # Query 1 # use `test`; alter table t1 drop b diff --git a/mysql-test/r/binlog_stm_insert_select.result b/mysql-test/r/binlog_stm_insert_select.result index 42bba580f47..35e328a769c 100644 --- a/mysql-test/r/binlog_stm_insert_select.result +++ b/mysql-test/r/binlog_stm_insert_select.result @@ -4,7 +4,7 @@ create table t2(a int); insert into t2 values(1),(2); reset master; insert into t1 select * from t2; -ERROR 23000: Duplicate entry '2' for key 1 +ERROR 23000: Duplicate entry '2' for key 'a' show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 @@ -18,7 +18,7 @@ create table t1(a int); insert into t1 values(1),(1); reset master; create table t2(unique(a)) select a from t1; -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'a' show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 diff --git a/mysql-test/r/binlog_stm_mix_innodb_myisam.result b/mysql-test/r/binlog_stm_mix_innodb_myisam.result index 5d75bf79990..59280961e41 100644 --- a/mysql-test/r/binlog_stm_mix_innodb_myisam.result +++ b/mysql-test/r/binlog_stm_mix_innodb_myisam.result @@ -185,7 +185,7 @@ master-bin.000001 258 Query 1 # use `test`; insert into t1 values(18) master-bin.000001 346 Xid 1 # COMMIT /* xid= */ delete from t1; delete from t2; -alter table t2 type=MyISAM; +alter table t2 engine=MyISAM; insert into t1 values (1); begin; select * from t1 for update; @@ -239,20 +239,20 @@ master-bin.000001 373 Query 1 # use `test`; delete from t1 master-bin.000001 450 Xid 1 # COMMIT /* xid= */ master-bin.000001 477 Query 1 # use `test`; delete from t2 master-bin.000001 554 Xid 1 # COMMIT /* xid= */ -master-bin.000001 581 Query 1 # use `test`; alter table t2 type=MyISAM -master-bin.000001 670 Query 1 # use `test`; insert into t1 values (1) -master-bin.000001 758 Xid 1 # COMMIT /* xid= */ -master-bin.000001 785 Query 1 # use `test`; insert into t2 values (20) -master-bin.000001 874 Query 1 # use `test`; drop table t1,t2 -master-bin.000001 953 Query 1 # use `test`; create temporary table ti (a int) engine=innodb -master-bin.000001 1063 Query 1 # use `test`; insert into ti values(1) -master-bin.000001 1150 Xid 1 # COMMIT /* xid= */ -master-bin.000001 1177 Query 1 # use `test`; create temporary table t1 (a int) engine=myisam -master-bin.000001 1287 Query 1 # use `test`; insert t1 values (1) -master-bin.000001 1370 Query 1 # use `test`; create table t0 (n int) -master-bin.000001 1456 Query 1 # use `test`; insert t0 select * from t1 -master-bin.000001 1545 Query 1 # use `test`; insert into t0 select GET_LOCK("lock1",null) -master-bin.000001 1652 Query 1 # use `test`; create table t2 (n int) engine=innodb -master-bin.000001 1752 Query 1 # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti` +master-bin.000001 581 Query 1 # use `test`; alter table t2 engine=MyISAM +master-bin.000001 672 Query 1 # use `test`; insert into t1 values (1) +master-bin.000001 760 Xid 1 # COMMIT /* xid= */ +master-bin.000001 787 Query 1 # use `test`; insert into t2 values (20) +master-bin.000001 876 Query 1 # use `test`; drop table t1,t2 +master-bin.000001 955 Query 1 # use `test`; create temporary table ti (a int) engine=innodb +master-bin.000001 1065 Query 1 # use `test`; insert into ti values(1) +master-bin.000001 1152 Xid 1 # COMMIT /* xid= */ +master-bin.000001 1179 Query 1 # use `test`; create temporary table t1 (a int) engine=myisam +master-bin.000001 1289 Query 1 # use `test`; insert t1 values (1) +master-bin.000001 1372 Query 1 # use `test`; create table t0 (n int) +master-bin.000001 1458 Query 1 # use `test`; insert t0 select * from t1 +master-bin.000001 1547 Query 1 # use `test`; insert into t0 select GET_LOCK("lock1",null) +master-bin.000001 1654 Query 1 # use `test`; create table t2 (n int) engine=innodb +master-bin.000001 1754 Query 1 # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti` do release_lock("lock1"); drop table t0,t2; diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 0e79dba8298..fc0d6c73cf4 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -162,7 +162,7 @@ Note 1051 Unknown table 't2' CREATE TABLE t1 (a int not null); INSERT INTO t1 values (1),(2),(1); CREATE TABLE t2 (primary key(a)) SELECT * FROM t1; -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' SELECT * from t2; ERROR 42S02: Table 'test.t2' doesn't exist DROP TABLE t1; @@ -280,7 +280,7 @@ create table if not exists t1 select 3 as 'a',4 as 'b'; Warnings: Note 1050 Table 't1' already exists create table if not exists t1 select 3 as 'a',3 as 'b'; -ERROR 23000: Duplicate entry '3' for key 1 +ERROR 23000: Duplicate entry '3' for key 'PRIMARY' select * from t1; a b 1 1 diff --git a/mysql-test/r/create_select_tmp.result b/mysql-test/r/create_select_tmp.result index b99bf3e3591..f499e539baf 100644 --- a/mysql-test/r/create_select_tmp.result +++ b/mysql-test/r/create_select_tmp.result @@ -2,18 +2,19 @@ drop table if exists t1, t2; CREATE TABLE t1 ( a int ); INSERT INTO t1 VALUES (1),(2),(1); CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t2; ERROR 42S02: Table 'test.t2' doesn't exist CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t2; ERROR 42S02: Table 'test.t2' doesn't exist CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t2; ERROR 42S02: Table 'test.t2' doesn't exist CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t2; ERROR 42S02: Table 'test.t2' doesn't exist +drop table t1; diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index 6f58fdfe54a..9e63b82c29d 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -5017,3 +5017,58 @@ insert t1 values (1),(2),(3),(4),(5); truncate table t1; affected rows: 0 drop table t1; +create table t1 (v varchar(32)); +insert into t1 values ('def'),('abc'),('hij'),('3r4f'); +select * from t1; +v +def +abc +hij +3r4f +alter table t1 change v v2 varchar(32); +select * from t1; +v2 +def +abc +hij +3r4f +alter table t1 change v2 v varchar(64); +select * from t1; +v +def +abc +hij +3r4f +update t1 set v = 'lmn' where v = 'hij'; +select * from t1; +v +def +abc +lmn +3r4f +alter table t1 add i int auto_increment not null primary key first; +select * from t1; +i v +1 def +2 abc +3 lmn +4 3r4f +update t1 set i=5 where i=3; +select * from t1; +i v +1 def +2 abc +5 lmn +4 3r4f +alter table t1 change i i bigint; +select * from t1; +i v +1 def +2 abc +5 lmn +4 3r4f +alter table t1 add unique key (i, v); +select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn'); +i v +4 3r4f +drop table t1; diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index 1b92da2a7a3..996f6fa8645 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -247,3 +247,4 @@ lpad(c1,3,'ö') lpad('ö',3,c1) select rpad(c1,3,'ö'), rpad('ö',3,c1) from t1; rpad(c1,3,'ö') rpad('ö',3,c1) ßöö ößß +drop table t1; diff --git a/mysql-test/r/ctype_ujis.result b/mysql-test/r/ctype_ujis.result index 2e14fe34430..fa47959579f 100644 --- a/mysql-test/r/ctype_ujis.result +++ b/mysql-test/r/ctype_ujis.result @@ -132,7 +132,7 @@ a INTEGER NOT NULL, b VARCHAR(50) NOT NULL DEFAULT '', PRIMARY KEY (a), KEY b (b(10)) -) TYPE=InnoDB CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci'; +) ENGINE=InnoDB CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci'; INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd'); INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh'); INSERT INTO t1 (a, b) VALUES (2, 'iiijjjkkkl'); @@ -152,7 +152,7 @@ a INTEGER NOT NULL, b VARCHAR(50) NOT NULL DEFAULT '', PRIMARY KEY (a), KEY b (b(10)) -) TYPE=MyISAM CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci'; +) ENGINE=MyISAM CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci'; INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd'); INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh'); INSERT INTO t1 (a, b) VALUES (2, 'iiijjjkkkl'); diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index b2a22036cb5..5fdab07e1d2 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -296,9 +296,9 @@ create table t1 (c varchar(30) character set utf8, unique(c(10))); insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); insert into t1 values ('aaaaaaaaaa'); insert into t1 values ('aaaaaaaaaaa'); -ERROR 23000: Duplicate entry 'aaaaaaaaaaa' for key 1 +ERROR 23000: Duplicate entry 'aaaaaaaaaaa' for key 'c' insert into t1 values ('aaaaaaaaaaaa'); -ERROR 23000: Duplicate entry 'aaaaaaaaaaaa' for key 1 +ERROR 23000: Duplicate entry 'aaaaaaaaaaaa' for key 'c' insert into t1 values (repeat('b',20)); select c c1 from t1 where c='1'; c1 @@ -329,9 +329,9 @@ create table t1 (c varchar(30) character set utf8, unique(c(10))) engine=innodb; insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); insert into t1 values ('aaaaaaaaaa'); insert into t1 values ('aaaaaaaaaaa'); -ERROR 23000: Duplicate entry 'aaaaaaaaaaa' for key 1 +ERROR 23000: Duplicate entry 'aaaaaaaaaaa' for key 'c' insert into t1 values ('aaaaaaaaaaaa'); -ERROR 23000: Duplicate entry 'aaaaaaaaaaaa' for key 1 +ERROR 23000: Duplicate entry 'aaaaaaaaaaaa' for key 'c' insert into t1 values (repeat('b',20)); select c c1 from t1 where c='1'; c1 @@ -363,46 +363,46 @@ insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); insert into t1 values ('a'); insert into t1 values ('aa'); insert into t1 values ('aaa'); -ERROR 23000: Duplicate entry 'aaa' for key 1 +ERROR 23000: Duplicate entry 'aaa' for key 'c' insert into t1 values ('b'); insert into t1 values ('bb'); insert into t1 values ('bbb'); -ERROR 23000: Duplicate entry 'bbb' for key 1 +ERROR 23000: Duplicate entry 'bbb' for key 'c' insert into t1 values ('а'); insert into t1 values ('аа'); insert into t1 values ('ааа'); -ERROR 23000: Duplicate entry 'ааа' for key 1 +ERROR 23000: Duplicate entry 'ааа' for key 'c' insert into t1 values ('б'); insert into t1 values ('бб'); insert into t1 values ('ббб'); -ERROR 23000: Duplicate entry 'ббб' for key 1 +ERROR 23000: Duplicate entry 'ббб' for key 'c' insert into t1 values ('ꪪ'); insert into t1 values ('ꪪꪪ'); insert into t1 values ('ꪪꪪꪪ'); -ERROR 23000: Duplicate entry 'ꪪꪪ' for key 1 +ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c' drop table t1; create table t1 (c char(3) character set utf8, unique (c(2))) engine=innodb; insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); insert into t1 values ('a'); insert into t1 values ('aa'); insert into t1 values ('aaa'); -ERROR 23000: Duplicate entry 'aaa' for key 1 +ERROR 23000: Duplicate entry 'aaa' for key 'c' insert into t1 values ('b'); insert into t1 values ('bb'); insert into t1 values ('bbb'); -ERROR 23000: Duplicate entry 'bbb' for key 1 +ERROR 23000: Duplicate entry 'bbb' for key 'c' insert into t1 values ('а'); insert into t1 values ('аа'); insert into t1 values ('ааа'); -ERROR 23000: Duplicate entry 'ааа' for key 1 +ERROR 23000: Duplicate entry 'ааа' for key 'c' insert into t1 values ('б'); insert into t1 values ('бб'); insert into t1 values ('ббб'); -ERROR 23000: Duplicate entry 'ббб' for key 1 +ERROR 23000: Duplicate entry 'ббб' for key 'c' insert into t1 values ('ꪪ'); insert into t1 values ('ꪪꪪ'); insert into t1 values ('ꪪꪪꪪ'); -ERROR 23000: Duplicate entry 'ꪪꪪ' for key 1 +ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c' drop table t1; create table t1 ( c char(10) character set utf8, @@ -416,14 +416,14 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MEMORY DEFAULT CHARSET=latin1 insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); insert into t1 values ('aa'); -ERROR 23000: Duplicate entry 'aa' for key 1 +ERROR 23000: Duplicate entry 'aa' for key 'a' insert into t1 values ('aaa'); -ERROR 23000: Duplicate entry 'aaa' for key 1 +ERROR 23000: Duplicate entry 'aaa' for key 'a' insert into t1 values ('б'); insert into t1 values ('бб'); -ERROR 23000: Duplicate entry 'бÐ' for key 1 +ERROR 23000: Duplicate entry 'бÐ' for key 'a' insert into t1 values ('ббб'); -ERROR 23000: Duplicate entry 'бÐ' for key 1 +ERROR 23000: Duplicate entry 'бÐ' for key 'a' select c as c_all from t1 order by c; c_all a @@ -452,14 +452,14 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MEMORY DEFAULT CHARSET=latin1 insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); insert into t1 values ('aa'); -ERROR 23000: Duplicate entry 'aa' for key 1 +ERROR 23000: Duplicate entry 'aa' for key 'a' insert into t1 values ('aaa'); -ERROR 23000: Duplicate entry 'aaa' for key 1 +ERROR 23000: Duplicate entry 'aaa' for key 'a' insert into t1 values ('б'); insert into t1 values ('бб'); -ERROR 23000: Duplicate entry 'бÐ' for key 1 +ERROR 23000: Duplicate entry 'бÐ' for key 'a' insert into t1 values ('ббб'); -ERROR 23000: Duplicate entry 'бÐ' for key 1 +ERROR 23000: Duplicate entry 'бÐ' for key 'a' select c as c_all from t1 order by c; c_all a @@ -482,14 +482,14 @@ unique key a (c(1)) ) engine=bdb; insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); insert into t1 values ('aa'); -ERROR 23000: Duplicate entry 'aa' for key 1 +ERROR 23000: Duplicate entry 'aa' for key 'a' insert into t1 values ('aaa'); -ERROR 23000: Duplicate entry 'aaa' for key 1 +ERROR 23000: Duplicate entry 'aaa' for key 'a' insert into t1 values ('б'); insert into t1 values ('бб'); -ERROR 23000: Duplicate entry 'бÐ' for key 1 +ERROR 23000: Duplicate entry 'бÐ' for key 'a' insert into t1 values ('ббб'); -ERROR 23000: Duplicate entry 'бÐ' for key 1 +ERROR 23000: Duplicate entry 'бÐ' for key 'a' select c as c_all from t1 order by c; c_all a @@ -510,9 +510,9 @@ create table t1 (c varchar(30) character set utf8 collate utf8_bin, unique(c(10) insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); insert into t1 values ('aaaaaaaaaa'); insert into t1 values ('aaaaaaaaaaa'); -ERROR 23000: Duplicate entry 'aaaaaaaaaaa' for key 1 +ERROR 23000: Duplicate entry 'aaaaaaaaaaa' for key 'c' insert into t1 values ('aaaaaaaaaaaa'); -ERROR 23000: Duplicate entry 'aaaaaaaaaaaa' for key 1 +ERROR 23000: Duplicate entry 'aaaaaaaaaaaa' for key 'c' insert into t1 values (repeat('b',20)); select c c1 from t1 where c='1'; c1 @@ -544,23 +544,23 @@ insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); insert into t1 values ('a'); insert into t1 values ('aa'); insert into t1 values ('aaa'); -ERROR 23000: Duplicate entry 'aaa' for key 1 +ERROR 23000: Duplicate entry 'aaa' for key 'c' insert into t1 values ('b'); insert into t1 values ('bb'); insert into t1 values ('bbb'); -ERROR 23000: Duplicate entry 'bbb' for key 1 +ERROR 23000: Duplicate entry 'bbb' for key 'c' insert into t1 values ('а'); insert into t1 values ('аа'); insert into t1 values ('ааа'); -ERROR 23000: Duplicate entry 'ааа' for key 1 +ERROR 23000: Duplicate entry 'ааа' for key 'c' insert into t1 values ('б'); insert into t1 values ('бб'); insert into t1 values ('ббб'); -ERROR 23000: Duplicate entry 'ббб' for key 1 +ERROR 23000: Duplicate entry 'ббб' for key 'c' insert into t1 values ('ꪪ'); insert into t1 values ('ꪪꪪ'); insert into t1 values ('ꪪꪪꪪ'); -ERROR 23000: Duplicate entry 'ꪪꪪ' for key 1 +ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c' drop table t1; create table t1 ( c char(10) character set utf8 collate utf8_bin, @@ -574,14 +574,14 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MEMORY DEFAULT CHARSET=latin1 insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); insert into t1 values ('aa'); -ERROR 23000: Duplicate entry 'aa' for key 1 +ERROR 23000: Duplicate entry 'aa' for key 'a' insert into t1 values ('aaa'); -ERROR 23000: Duplicate entry 'aaa' for key 1 +ERROR 23000: Duplicate entry 'aaa' for key 'a' insert into t1 values ('б'); insert into t1 values ('бб'); -ERROR 23000: Duplicate entry 'бÐ' for key 1 +ERROR 23000: Duplicate entry 'бÐ' for key 'a' insert into t1 values ('ббб'); -ERROR 23000: Duplicate entry 'бÐ' for key 1 +ERROR 23000: Duplicate entry 'бÐ' for key 'a' select c as c_all from t1 order by c; c_all a @@ -610,14 +610,14 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MEMORY DEFAULT CHARSET=latin1 insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); insert into t1 values ('aa'); -ERROR 23000: Duplicate entry 'aa' for key 1 +ERROR 23000: Duplicate entry 'aa' for key 'a' insert into t1 values ('aaa'); -ERROR 23000: Duplicate entry 'aaa' for key 1 +ERROR 23000: Duplicate entry 'aaa' for key 'a' insert into t1 values ('б'); insert into t1 values ('бб'); -ERROR 23000: Duplicate entry 'бÐ' for key 1 +ERROR 23000: Duplicate entry 'бÐ' for key 'a' insert into t1 values ('ббб'); -ERROR 23000: Duplicate entry 'бÐ' for key 1 +ERROR 23000: Duplicate entry 'бÐ' for key 'a' select c as c_all from t1 order by c; c_all a @@ -640,14 +640,14 @@ unique key a (c(1)) ) engine=bdb; insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); insert into t1 values ('aa'); -ERROR 23000: Duplicate entry 'aa' for key 1 +ERROR 23000: Duplicate entry 'aa' for key 'a' insert into t1 values ('aaa'); -ERROR 23000: Duplicate entry 'aaa' for key 1 +ERROR 23000: Duplicate entry 'aaa' for key 'a' insert into t1 values ('б'); insert into t1 values ('бб'); -ERROR 23000: Duplicate entry 'бÐ' for key 1 +ERROR 23000: Duplicate entry 'бÐ' for key 'a' insert into t1 values ('ббб'); -ERROR 23000: Duplicate entry 'бÐ' for key 1 +ERROR 23000: Duplicate entry 'бÐ' for key 'a' select c as c_all from t1 order by c; c_all a diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 434a5df1e17..214c9466c8c 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -506,3 +506,12 @@ d1 d2 02 February 01 January drop table t1; +select str_to_date( 1, NULL ); +str_to_date( 1, NULL ) +NULL +select str_to_date( NULL, 1 ); +str_to_date( NULL, 1 ) +NULL +select str_to_date( 1, IF(1=1,NULL,NULL) ); +str_to_date( 1, IF(1=1,NULL,NULL) ) +NULL diff --git a/mysql-test/r/events.result b/mysql-test/r/events.result index 41f944ab089..b5b1b76f1a8 100644 --- a/mysql-test/r/events.result +++ b/mysql-test/r/events.result @@ -15,20 +15,11 @@ create event event2 on schedule every 2 second starts now() ends date_add(now(), drop event event2; create event e_43 on schedule every 1 second do set @a = 5; set global event_scheduler = 1; -select sleep(2); -sleep(2) -0 alter event e_43 do alter event e_43 do set @a = 4; -select sleep(3); -sleep(3) -0 select db, name, body, status, interval_field, interval_value from mysql.event; db name body status interval_field interval_value events_test e_43 set @a = 4 ENABLED SECOND 1 drop event e_43; -select sleep(1); -sleep(1) -0 set global event_scheduler = 0; create table t_event3 (a int, b float); drop event if exists event3; @@ -64,7 +55,7 @@ SHOW GRANTS; Grants for ev_test@localhost GRANT USAGE ON *.* TO 'ev_test'@'localhost' GRANT ALL PRIVILEGES ON `events_test`.* TO 'ev_test'@'localhost' -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `events_test2`.* TO 'ev_test'@'localhost' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, TRIGGER ON `events_test2`.* TO 'ev_test'@'localhost' "Here comes an error:"; SHOW EVENTS; ERROR 42000: Access denied for user 'ev_test'@'localhost' to database 'events_test2' @@ -121,6 +112,7 @@ drop event two_event; drop event three_event; drop user ev_test@localhost; drop event one_event; +"Sleep a bit so the server closes the second connection" create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5; select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event; db name body definer convert_tz(execute_at, 'UTC', 'SYSTEM') on_completion @@ -137,4 +129,68 @@ set event_scheduler=0; ERROR HY000: Variable 'event_scheduler' is a GLOBAL variable and should be set with SET GLOBAL set global event_scheduler=2; ERROR 42000: Variable 'event_scheduler' can't be set to the value of '2' +"DISABLE the scheduler. Testing that it does not work when the variable is 0" +set global event_scheduler=0; +select definer, name, db from mysql.event; +definer name db +select get_lock("test_lock1", 20); +get_lock("test_lock1", 20) +1 +create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20); +"Should return 1 row" +select definer, name, db from mysql.event; +definer name db +root@localhost закачка events_test +"Should be only 1 process" +show processlist; +Id User Host db Command Time State Info +# root localhost events_test Query # NULL show processlist +select release_lock("test_lock1"); +release_lock("test_lock1") +1 +drop event закачка; +"Should have 0 events" +select count(*) from mysql.event; +count(*) +0 +"ENABLE the scheduler and get a lock" +set global event_scheduler=1; +select get_lock("test_lock2", 20); +get_lock("test_lock2", 20) +1 +"Create an event which tries to acquire a mutex. The event locks on the mutex" +create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20); +"Let some time pass to the event starts" +"Should have only 3 processes: the scheduler, our conn and the locked event" +show processlist; +Id User Host db Command Time State Info +# root localhost events_test Query # NULL show processlist +# event_scheduler NULL Connect # Sleeping NULL +# root events_test Connect # User lock select get_lock("test_lock2", 20) +"Release the mutex, the event worker should finish." +select release_lock("test_lock2"); +release_lock("test_lock2") +1 +drop event закачка; +set global event_scheduler=1; +select get_lock("test_lock2_1", 20); +get_lock("test_lock2_1", 20) +1 +create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20); +"Should see 2 processes, one locked on get_lock(" +"Shutting down the scheduler, it should wait for the running event" +set global event_scheduler=0; +"Should have only 3 processes: the scheduler, our conn and the locked event" +show processlist; +Id User Host db Command Time State Info +# root localhost events_test Query # NULL show processlist +"Release the lock so the child process should finish. Hence the scheduler also" +select release_lock("test_lock2_1"); +release_lock("test_lock2_1") +1 +"Should have only our process now:" +show processlist; +Id User Host db Command Time State Info +# root localhost events_test Query # NULL show processlist +drop event закачка21; drop database events_test; diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result index f9b13beb6e5..c1e7533bcee 100644 --- a/mysql-test/r/federated.result +++ b/mysql-test/r/federated.result @@ -1517,6 +1517,48 @@ bitty drop table federated.t1; drop table federated.t1; DROP TABLE IF EXISTS federated.t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE federated.t1 ( +`id` int(20) NOT NULL auto_increment, +PRIMARY KEY (`id`)); +DROP TABLE IF EXISTS federated.t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE federated.t1 ( +`id` int(20) NOT NULL auto_increment, +PRIMARY KEY (`id`) +) +ENGINE="FEDERATED" DEFAULT CHARSET=latin1 +CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1'; +INSERT INTO federated.t1 VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +1 +INSERT INTO federated.t1 VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +2 +INSERT INTO federated.t1 VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +3 +INSERT INTO federated.t1 VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +4 +INSERT INTO federated.t1 VALUES (); +SELECT LAST_INSERT_ID(); +LAST_INSERT_ID() +5 +SELECT * FROM federated.t1; +id +1 +2 +3 +4 +5 +DROP TABLE IF EXISTS federated.t1; DROP DATABASE IF EXISTS federated; DROP TABLE IF EXISTS federated.t1; DROP DATABASE IF EXISTS federated; diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 4ee95cffb00..b5084fff165 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -449,3 +449,14 @@ t1 CREATE TABLE `t1` ( FULLTEXT KEY `a` (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; +CREATE TABLE t1 (a TEXT, FULLTEXT KEY(a)); +INSERT INTO t1 VALUES('test'),('test1'),('test'); +PREPARE stmt from "SELECT a, MATCH(a) AGAINST('test1 test') FROM t1 WHERE MATCH(a) AGAINST('test1 test')"; +EXECUTE stmt; +a MATCH(a) AGAINST('test1 test') +test1 0.68526661396027 +EXECUTE stmt; +a MATCH(a) AGAINST('test1 test') +test1 0.68526661396027 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index fba274b9bb1..1507f959ae6 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -203,3 +203,18 @@ NULL Warnings: Error 1365 Division by 0 set sql_mode=''; +select round(111,-10); +round(111,-10) +0 +select round(-5000111000111000155,-1); +round(-5000111000111000155,-1) +-5000111000111000160 +select round(15000111000111000155,-1); +round(15000111000111000155,-1) +15000111000111000160 +select truncate(-5000111000111000155,-1); +truncate(-5000111000111000155,-1) +-5000111000111000150 +select truncate(15000111000111000155,-1); +truncate(15000111000111000155,-1) +15000111000111000150 diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index 246aaa3a93e..e38953b6446 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -238,6 +238,7 @@ ERROR HY000: Operation DROP USER failed for 'mysqltest_2b'@'%' create user 'mysqltest_2' identified by 'Mysqltest-2'; drop user 'mysqltest_2' identified by 'Mysqltest-2'; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'Mysqltest-2'' at line 1 +drop user 'mysqltest_2'; create user '%@b'@'b'; show grants for '%@b'@'b'; Grants for %@b@b @@ -279,6 +280,7 @@ Warning 1364 Field 'x509_subject' doesn't have a default value create user mysqltest_A@'%'; rename user mysqltest_B@'%' to mysqltest_C@'%'; drop user mysqltest_C@'%'; +drop user mysqltest_A@'%'; drop user mysqltest_3@localhost; set @@sql_mode=''; create database mysqltest_1; diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index 91579a7ea42..b1703c51f4e 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -2043,3 +2043,30 @@ c1 c2 30 8 30 9 drop table t1; +CREATE TABLE t1 (a varchar(5), b int(11), PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES ('AA',1), ('AA',2), ('AA',3), ('BB',1), ('AA',4); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +SELECT a FROM t1 WHERE a='AA' GROUP BY a; +a +AA +SELECT a FROM t1 WHERE a='BB' GROUP BY a; +a +BB +EXPLAIN SELECT a FROM t1 WHERE a='AA' GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 3 Using where; Using index +EXPLAIN SELECT a FROM t1 WHERE a='BB' GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 1 Using where; Using index +SELECT DISTINCT a FROM t1 WHERE a='BB'; +a +BB +SELECT DISTINCT a FROM t1 WHERE a LIKE 'B%'; +a +BB +SELECT a FROM t1 WHERE a LIKE 'B%' GROUP BY a; +a +BB +DROP TABLE t1; diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index 379c2f83c78..e54f6d7f2a4 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -141,6 +141,23 @@ SUM(a) 6 4 DROP TABLE t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1), (2), (1), (3), (2), (1); +SELECT a FROM t1 GROUP BY a HAVING a > 1; +a +2 +3 +SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1; +a +SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1; +x a +EXPLAIN SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING +DROP table t1; create table t1 (col1 int, col2 varchar(5), col_t1 int); create table t2 (col1 int, col2 varchar(5), col_t2 int); create table t3 (col1 int, col2 varchar(5), col_t3 int); diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result index 7f40dfa3a36..8fb09922eb8 100644 --- a/mysql-test/r/heap.result +++ b/mysql-test/r/heap.result @@ -169,7 +169,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL btn NULL NULL NULL 11 Using where explain select * from t1 where btn="a" and new_col="a"; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref btn btn 11 const,const 1 Using where +1 SIMPLE t1 ref btn btn 11 const,const 2 Using where drop table t1; CREATE TABLE t1 ( a int default NULL, @@ -182,7 +182,7 @@ SELECT * FROM t1 WHERE a=NULL; a b explain SELECT * FROM t1 WHERE a IS NULL; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref a a 5 const 1 Using where +1 SIMPLE t1 ref a a 5 const 2 Using where SELECT * FROM t1 WHERE a<=>NULL; a b NULL 99 @@ -195,7 +195,7 @@ SELECT * FROM t1 WHERE b<=>NULL; a b 99 NULL INSERT INTO t1 VALUES (1,3); -ERROR 23000: Duplicate entry '3' for key 1 +ERROR 23000: Duplicate entry '3' for key 'b' DROP TABLE t1; CREATE TABLE t1 ( a int default NULL, @@ -384,7 +384,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref v v 13 const 10 Using where alter table t1 add unique(v); -ERROR 23000: Duplicate entry '{ ' for key 1 +ERROR 23000: Duplicate entry '{ ' for key 'v_2' select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*')); qq *a*a*a* @@ -536,16 +536,16 @@ drop table t1; create table t1 (a char(10), unique (a)); insert into t1 values ('a'); insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a' for key 1 +ERROR 23000: Duplicate entry 'a' for key 'a' alter table t1 modify a varchar(10); insert into t1 values ('a '),('a '),('a '),('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' update t1 set a='a ' where a like 'a '; update t1 set a='a ' where a like 'a '; drop table t1; @@ -607,7 +607,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref v v 13 const # Using where alter table t1 add unique(v); -ERROR 23000: Duplicate entry '{ ' for key 1 +ERROR 23000: Duplicate entry '{ ' for key 'v_2' select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*')); qq *a*a*a* @@ -627,16 +627,16 @@ drop table t1; create table t1 (a char(10), unique using btree (a)) engine=heap; insert into t1 values ('a'); insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a' for key 1 +ERROR 23000: Duplicate entry 'a' for key 'a' alter table t1 modify a varchar(10); insert into t1 values ('a '),('a '),('a '),('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' update t1 set a='a ' where a like 'a '; update t1 set a='a ' where a like 'a '; drop table t1; @@ -699,7 +699,17 @@ ERROR 42000: Incorrect table definition; there can be only one auto column and i create table t1 (c char(255), primary key(c(90))); insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); -ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 1 +ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 'PRIMARY' +drop table t1; +CREATE TABLE t1 (a int, key(a)) engine=heap; +insert into t1 values (0); +delete from t1; +select * from t1; +a +insert into t1 values (0), (1); +select * from t1 where a = 0; +a +0 drop table t1; create table t1 (c char(10)) engine=memory; create table t2 (c varchar(10)) engine=memory; diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index 374d2c63632..a100266978b 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -224,7 +224,7 @@ SELECT * FROM t1 WHERE b<=>NULL; a b 99 NULL INSERT INTO t1 VALUES (1,3); -ERROR 23000: Duplicate entry '3' for key 1 +ERROR 23000: Duplicate entry '3' for key 'b' DROP TABLE t1; CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) engine=heap; INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1); diff --git a/mysql-test/r/heap_hash.result b/mysql-test/r/heap_hash.result index d8d89b786b5..d4dea8b3a2e 100644 --- a/mysql-test/r/heap_hash.result +++ b/mysql-test/r/heap_hash.result @@ -169,7 +169,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL btn NULL NULL NULL 11 Using where explain select * from t1 where btn="a" and new_col="a"; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref btn btn 11 const,const 1 Using where +1 SIMPLE t1 ref btn btn 11 const,const 2 Using where drop table t1; CREATE TABLE t1 ( a int default NULL, @@ -182,7 +182,7 @@ SELECT * FROM t1 WHERE a=NULL; a b explain SELECT * FROM t1 WHERE a IS NULL; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref a a 5 const 1 Using where +1 SIMPLE t1 ref a a 5 const 2 Using where SELECT * FROM t1 WHERE a<=>NULL; a b NULL 99 @@ -195,7 +195,7 @@ SELECT * FROM t1 WHERE b<=>NULL; a b 99 NULL INSERT INTO t1 VALUES (1,3); -ERROR 23000: Duplicate entry '3' for key 1 +ERROR 23000: Duplicate entry '3' for key 'b' DROP TABLE t1; CREATE TABLE t1 (a int not null, primary key using HASH (a)) engine=heap; INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); @@ -220,16 +220,16 @@ insert into t1 values ('aaag', 'prefill-hash=3',0); insert into t1 values ('aaah', 'prefill-hash=6',0); explain select * from t1 where a='aaaa'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref a a 8 const 1 Using where +1 SIMPLE t1 ref a a 8 const 2 Using where explain select * from t1 where a='aaab'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref a a 8 const 1 Using where +1 SIMPLE t1 ref a a 8 const 2 Using where explain select * from t1 where a='aaac'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref a a 8 const 1 Using where +1 SIMPLE t1 ref a a 8 const 2 Using where explain select * from t1 where a='aaad'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref a a 8 const 1 Using where +1 SIMPLE t1 ref a a 8 const 2 Using where insert into t1 select * from t1; flush tables; explain select * from t1 where a='aaaa'; @@ -291,25 +291,25 @@ insert into t1 (name) values ('Matt'), ('Lilu'), ('Corbin'), ('Carly'), insert into t2 select * from t1; explain select * from t1 where name='matt'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref heap_idx,btree_idx heap_idx 22 const 1 Using where +1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 22 const 1 Using where explain select * from t2 where name='matt'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 22 const 1 Using where explain select * from t1 where name='Lilu'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref heap_idx,btree_idx heap_idx 22 const 1 Using where +1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 22 const 1 Using where explain select * from t2 where name='Lilu'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 22 const 1 Using where explain select * from t1 where name='Phil'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref heap_idx,btree_idx heap_idx 22 const 1 Using where +1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 22 const 1 Using where explain select * from t2 where name='Phil'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 22 const 1 Using where explain select * from t1 where name='Lilu'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref heap_idx,btree_idx heap_idx 22 const 1 Using where +1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 22 const 1 Using where explain select * from t2 where name='Lilu'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 22 const 1 Using where @@ -364,5 +364,5 @@ a 3 explain select a from t1 where a in (1,3); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 5 NULL 2 Using where +1 SIMPLE t1 range a a 5 NULL 4 Using where drop table t1; diff --git a/mysql-test/r/im_life_cycle.result b/mysql-test/r/im_life_cycle.result index f8eaf0ccb46..70aef9c40d5 100644 --- a/mysql-test/r/im_life_cycle.result +++ b/mysql-test/r/im_life_cycle.result @@ -3,22 +3,22 @@ instance_name status mysqld1 online mysqld2 offline SHOW INSTANCE STATUS mysqld1; -instance_name status version -mysqld1 online VERSION +instance_name status version_number version +mysqld1 online VERSION_NUMBER VERSION SHOW INSTANCE STATUS mysqld2; -instance_name status version -mysqld2 offline VERSION +instance_name status version_number version +mysqld2 offline VERSION_NUMBER VERSION START INSTANCE mysqld2; SHOW INSTANCES; instance_name status mysqld1 online mysqld2 online SHOW INSTANCE STATUS mysqld1; -instance_name status version -mysqld1 online VERSION +instance_name status version_number version +mysqld1 online VERSION_NUMBER VERSION SHOW INSTANCE STATUS mysqld2; -instance_name status version -mysqld2 online VERSION +instance_name status version_number version +mysqld2 online VERSION_NUMBER VERSION SHOW VARIABLES LIKE 'port'; Variable_name Value port IM_MYSQLD1_PORT @@ -28,11 +28,11 @@ instance_name status mysqld1 online mysqld2 offline SHOW INSTANCE STATUS mysqld1; -instance_name status version -mysqld1 online VERSION +instance_name status version_number version +mysqld1 online VERSION_NUMBER VERSION SHOW INSTANCE STATUS mysqld2; -instance_name status version -mysqld2 offline VERSION +instance_name status version_number version +mysqld2 offline VERSION_NUMBER VERSION START INSTANCE mysqld3; ERROR HY000: Bad instance name. Check that the instance with such a name exists START INSTANCE mysqld1; @@ -62,3 +62,5 @@ SHOW INSTANCES; instance_name status mysqld1 online mysqld2 offline +SHOW INSTANCE STATUS; +ERROR 42000: You have an error in your command syntax. Check the manual that corresponds to your MySQL Instance Manager version for the right syntax to use diff --git a/mysql-test/r/im_utils.result b/mysql-test/r/im_utils.result index e204affc8ec..504b2efe4af 100644 --- a/mysql-test/r/im_utils.result +++ b/mysql-test/r/im_utils.result @@ -21,7 +21,7 @@ skip-stack-trace VALUE skip-innodb VALUE skip-bdb VALUE skip-ndbcluster VALUE -old-log-format VALUE +log-output VALUE SHOW INSTANCE OPTIONS mysqld2; option_name value instance_name VALUE @@ -42,7 +42,7 @@ skip-stack-trace VALUE skip-innodb VALUE skip-bdb VALUE skip-ndbcluster VALUE -old-log-format VALUE +log-output VALUE START INSTANCE mysqld2; STOP INSTANCE mysqld2; SHOW mysqld1 LOG FILES; diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index fe3c409744d..daca6a94b0d 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -57,8 +57,8 @@ TABLES TABLE_CONSTRAINTS TABLE_PRIVILEGES TRIGGERS -VIEWS USER_PRIVILEGES +VIEWS binlog_index columns_priv db diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result index 7b106cb0e55..65277f46675 100644 --- a/mysql-test/r/information_schema_db.result +++ b/mysql-test/r/information_schema_db.result @@ -20,8 +20,8 @@ TABLES TABLE_CONSTRAINTS TABLE_PRIVILEGES TRIGGERS -VIEWS USER_PRIVILEGES +VIEWS show tables from INFORMATION_SCHEMA like 'T%'; Tables_in_information_schema (T%) TABLES diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 577e6a7192a..90dc859f854 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -234,7 +234,7 @@ n after commit commit; insert into t1 values (5); insert into t1 values (4); -ERROR 23000: Duplicate entry '4' for key 1 +ERROR 23000: Duplicate entry '4' for key 'PRIMARY' commit; select n, "after commit" from t1; n after commit @@ -243,7 +243,7 @@ n after commit set autocommit=1; insert into t1 values (6); insert into t1 values (4); -ERROR 23000: Duplicate entry '4' for key 1 +ERROR 23000: Duplicate entry '4' for key 'PRIMARY' select n from t1; n 4 @@ -318,7 +318,7 @@ drop table t1; CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb; insert into t1 values ('pippo', 12); insert into t1 values ('pippo', 12); -ERROR 23000: Duplicate entry 'pippo' for key 1 +ERROR 23000: Duplicate entry 'pippo' for key 'PRIMARY' delete from t1; delete from t1 where id = 'pippo'; select * from t1; @@ -482,9 +482,9 @@ UNIQUE ggid (ggid) insert into t1 (ggid,passwd) values ('test1','xxx'); insert into t1 (ggid,passwd) values ('test2','yyy'); insert into t1 (ggid,passwd) values ('test2','this will fail'); -ERROR 23000: Duplicate entry 'test2' for key 2 +ERROR 23000: Duplicate entry 'test2' for key 'ggid' insert into t1 (ggid,id) values ('this will fail',1); -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t1 where ggid='test1'; id ggid email passwd 1 test1 xxx @@ -497,7 +497,7 @@ id ggid email passwd replace into t1 (ggid,id) values ('this will work',1); replace into t1 (ggid,passwd) values ('test2','this will work'); update t1 set id=100,ggid='test2' where id=1; -ERROR 23000: Duplicate entry 'test2' for key 2 +ERROR 23000: Duplicate entry 'test2' for key 'ggid' select * from t1; id ggid email passwd 1 this will work @@ -816,7 +816,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); LOCK TABLES t1 WRITE; insert into t1 values (99,1,2,'D'),(1,1,2,'D'); -ERROR 23000: Duplicate entry '1-1' for key 1 +ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY' select id from t1; id 0 @@ -834,7 +834,7 @@ insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJ LOCK TABLES t1 WRITE; begin; insert into t1 values (99,1,2,'D'),(1,1,2,'D'); -ERROR 23000: Duplicate entry '1-1' for key 1 +ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY' select id from t1; id 0 @@ -1964,7 +1964,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref v v 13 const # Using where; Using index alter table t1 add unique(v); -ERROR 23000: Duplicate entry '{ ' for key 1 +ERROR 23000: Duplicate entry '{ ' for key 'v_2' alter table t1 add key(v); select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a'; qq @@ -2324,16 +2324,16 @@ drop table t1; create table t1 (a char(10), unique (a)); insert into t1 values ('a '); insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a' for key 1 +ERROR 23000: Duplicate entry 'a' for key 'a' alter table t1 modify a varchar(10); insert into t1 values ('a '),('a '),('a '),('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' update t1 set a='a ' where a like 'a%'; select concat(a,'.') from t1; concat(a,'.') @@ -2456,7 +2456,7 @@ key (rowid), unique(val)) engine=innodb; replace into t1 (val) values ('1'),('2'); replace into t1 (val) values ('1'),('2'); insert into t1 (val) values ('1'),('2'); -ERROR 23000: Duplicate entry '1' for key 2 +ERROR 23000: Duplicate entry '1' for key 'val' select * from t1; rowid val 3 1 @@ -2466,7 +2466,7 @@ create table t1 (a int not null auto_increment primary key, val int) engine=Inno insert into t1 (val) values (1); update t1 set a=2 where a=1; insert into t1 (val) values (1); -ERROR 23000: Duplicate entry '2' for key 1 +ERROR 23000: Duplicate entry '2' for key 'PRIMARY' select * from t1; a val 2 1 @@ -2758,3 +2758,21 @@ e varchar(255) character set utf8, key (a,b,c,d,e)) engine=innodb; ERROR 42000: Specified key was too long; max key length is 3072 bytes End of 5.0 tests +CREATE TABLE t1 ( +field1 varchar(8) NOT NULL DEFAULT '', +field2 varchar(8) NOT NULL DEFAULT '', +PRIMARY KEY (field1, field2) +) ENGINE=InnoDB; +CREATE TABLE t2 ( +field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, +FOREIGN KEY (field1) REFERENCES t1 (field1) +ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('old', 'somevalu'); +INSERT INTO t1 VALUES ('other', 'anyvalue'); +INSERT INTO t2 VALUES ('old'); +INSERT INTO t2 VALUES ('other'); +UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; +ERROR 23000: Upholding foreign key constraints for table 't1', entry 'other-somevalu', key 1 would lead to a duplicate entry +DROP TABLE t2; +DROP TABLE t1; diff --git a/mysql-test/r/innodb_cache.result b/mysql-test/r/innodb_cache.result index 5e8611655a2..5c494814df9 100644 --- a/mysql-test/r/innodb_cache.result +++ b/mysql-test/r/innodb_cache.result @@ -121,7 +121,7 @@ id a begin; insert into t3 VALUES ( NULL, 1, 1, 2 ); insert into t3 VALUES ( NULL, 1, 1, 2 ); -ERROR 23000: Duplicate entry '1-1' for key 2 +ERROR 23000: Duplicate entry '1-1' for key 't1_id' commit; select t1.* from t1, t2, t3 where t3.state & 1 = 0 and t3.t1_id = t1.id and t3.t2_id = t2.id and t1.id = 1 order by t1.a asc; id a diff --git a/mysql-test/r/innodb_concurrent.result b/mysql-test/r/innodb_concurrent.result index 8e9d2e2ffe6..56adb812cb7 100644 --- a/mysql-test/r/innodb_concurrent.result +++ b/mysql-test/r/innodb_concurrent.result @@ -1,7 +1,7 @@ drop table if exists t1; Warnings: Note 1051 Unknown table 't1' -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) ENGINE=innodb; Warnings: Warning 1287 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); @@ -106,7 +106,7 @@ eta tipo c 2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk drop table t1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) ENGINE=innodb; Warnings: Warning 1287 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); @@ -239,7 +239,7 @@ a b 1 1 commit; drop table t1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) ENGINE=innodb; Warnings: Warning 1287 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); @@ -323,7 +323,7 @@ eta tipo c 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk drop table t1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) ENGINE=innodb; Warnings: Warning 1287 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); @@ -407,7 +407,7 @@ eta tipo c 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk drop table t1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) ENGINE=innodb; Warnings: Warning 1287 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); @@ -478,7 +478,7 @@ eta tipo c 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk drop table t1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) ENGINE=innodb; Warnings: Warning 1287 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); @@ -549,7 +549,7 @@ eta tipo c 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk drop table t1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) ENGINE=innodb; Warnings: Warning 1287 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); diff --git a/mysql-test/r/innodb_unsafe_binlog.result b/mysql-test/r/innodb_unsafe_binlog.result deleted file mode 100644 index 4a4f0e0fae5..00000000000 --- a/mysql-test/r/innodb_unsafe_binlog.result +++ /dev/null @@ -1,48 +0,0 @@ -drop table if exists t1,t2; -create table t1 (id int not null, f_id int not null, f int not null, -primary key(f_id, id)) engine=innodb; -create table t2 (id int not null,s_id int not null,s varchar(200), -primary key(id)) engine=innodb; -INSERT INTO t1 VALUES (8, 1, 3); -INSERT INTO t1 VALUES (1, 2, 1); -INSERT INTO t2 VALUES (1, 0, ''); -INSERT INTO t2 VALUES (8, 1, ''); -commit; -DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id) -WHERE mm.id IS NULL; -select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id) -where mm.id is null lock in share mode; -id f_id f -drop table t1,t2; -create table t1 (id int not null, f_id int not null, f int not null, -primary key(id),key(f_id)) engine=innodb; -create table t2 (id int not null,s_id int not null,s varchar(200), -primary key(id),key(s_id)) engine=innodb; -INSERT INTO t1 VALUES (8, 1, 3); -INSERT INTO t1 VALUES (1, 2, 1); -INSERT INTO t2 VALUES (1, 0, ''); -INSERT INTO t2 VALUES (8, 1, ''); -commit; -delete ml.* from t1 as ml left join t2 as mm on (mm.s_id=ml.f_id) where mm.s is null; -select ml.* from t1 as ml left join t2 as mm on (mm.s_id=ml.f_id) where mm.s is null lock in share mode; -id f_id f -drop table t1,t2; -create table t1(a int not null, b int, primary key(a)) engine=innodb; -insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2); -commit; -set autocommit = 0; -select * from t1 lock in share mode; -a b -1 1 -2 2 -3 1 -4 2 -5 1 -6 2 -update t1 set b = 5 where b = 1; -set autocommit = 0; -select * from t1 where a = 2 and b = 2 for update; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -commit; -commit; -drop table t1; diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index fa8c3f8a2b8..772179d758a 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -4,7 +4,7 @@ insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7, create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY); insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1; insert into t2 (payoutID) SELECT payoutID+10 FROM t1; -ERROR 23000: Duplicate entry '16' for key 1 +ERROR 23000: Duplicate entry '16' for key 'PRIMARY' insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1; select * from t2; payoutID @@ -561,7 +561,7 @@ create table t2 (a int not null, b char(10)); insert into t1 values (1,"t1:1"),(3,"t1:3"); insert into t2 values (2,"t2:2"), (3,"t2:3"); insert into t1 select * from t2; -ERROR 23000: Duplicate entry '3' for key 1 +ERROR 23000: Duplicate entry '3' for key 'PRIMARY' select * from t1; a b 1 t1:1 diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result index dbe5d600a95..aeaa2b66ec7 100644 --- a/mysql-test/r/insert_update.result +++ b/mysql-test/r/insert_update.result @@ -26,7 +26,7 @@ a b c 3 4 1020 5 6 130 INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4; -ERROR 23000: Duplicate entry '4' for key 2 +ERROR 23000: Duplicate entry '4' for key 'b' SELECT * FROM t1; a b c 1 2 10010 @@ -132,7 +132,7 @@ a b c 3 4 1020 5 6 130 INSERT t1 SELECT 1,9,70 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100000, b=4; -ERROR 23000: Duplicate entry '4' for key 2 +ERROR 23000: Duplicate entry '4' for key 'b' SELECT * FROM t1; a b c 1 2 10010 diff --git a/mysql-test/r/join_nested.result b/mysql-test/r/join_nested.result index faad969fcd1..dfcfa35d31d 100644 --- a/mysql-test/r/join_nested.result +++ b/mysql-test/r/join_nested.result @@ -1481,3 +1481,26 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref a a 5 test.t1.a 1 1 SIMPLE t3 ref a a 5 test.t2.a 1 drop table t1, t2, t3; +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t2 (pid int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t3 (cid int NOT NULL PRIMARY KEY, +id int NOT NULL, +pid int NOT NULL); +INSERT INTO t1 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t2 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t3 VALUES (1, 1, 1), (3, 3, 3); +SELECT * FROM t1 p LEFT JOIN (t3 JOIN t1) +ON (t1.id=t3.id AND t1.type='B' AND p.id=t3.id) +LEFT JOIN t2 ON (t3.pid=t2.pid) +WHERE p.id=1; +id type cid id pid id type pid type +1 A NULL NULL NULL NULL NULL NULL NULL +CREATE VIEW v1 AS +SELECT t3.* FROM t3 JOIN t1 ON t1.id=t3.id AND t1.type='B'; +SELECT * FROM t1 p LEFT JOIN v1 ON p.id=v1.id +LEFT JOIN t2 ON v1.pid=t2.pid +WHERE p.id=1; +id type cid id pid pid type +1 A NULL NULL NULL NULL NULL +DROP VIEW v1; +DROP TABLE t1,t2,t3; diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 92b352aa608..9d6c6140dd5 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -169,7 +169,7 @@ usr_id uniq_id increment usr2_id c_amount max 3 4 84676 NULL NULL NULL INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); -ERROR 23000: Duplicate entry '2-3' for key 1 +ERROR 23000: Duplicate entry '2-3' for key 'PRIMARY' INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 ORDER BY t2.c_amount; usr_id uniq_id increment usr2_id c_amount max @@ -992,6 +992,7 @@ SELECT * FROM v1 WHERE EMPNUM < 10; EMPNUM NAME GRP 0 KERI 10 9 BARRY NULL +DROP VIEW v1; DROP TABLE t1,t2; CREATE TABLE t1 (c11 int); CREATE TABLE t2 (c21 int); diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result index 75676507760..5d62f8d61d6 100644 --- a/mysql-test/r/key.result +++ b/mysql-test/r/key.result @@ -127,7 +127,7 @@ primary key (SEQNO, MOTYPEID, MOINSTANCEID, ATTRID, VALUE ) INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); INSERT INTO t1 VALUES (1, 1, 1, 1, 'b'); INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); -ERROR 23000: Duplicate entry '1-1-1-1-a' for key 1 +ERROR 23000: Duplicate entry '1-1-1-1-a' for key 'PRIMARY' drop table t1; CREATE TABLE t1 ( a tinytext NOT NULL, @@ -251,13 +251,13 @@ insert t1 values ('cccc', 'tttt'), (0xD0B1212223D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1212223D0B1D0B1D0B1D0B1), (0xD0B1222123D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1222123D0B1D0B1D0B1D0B1); insert t1 (c) values ('cc22'); -ERROR 23000: Duplicate entry 'cc22' for key 1 +ERROR 23000: Duplicate entry 'cc22' for key 'c' insert t1 (t) values ('ttt22'); -ERROR 23000: Duplicate entry 'ttt22' for key 2 +ERROR 23000: Duplicate entry 'ttt22' for key 't' insert t1 (c) values (0xD0B1212322D0B1D0B1D0B1D0B1D0B1); -ERROR 23000: Duplicate entry 'б!#"Ð' for key 1 +ERROR 23000: Duplicate entry 'б!#"Ð' for key 'c' insert t1 (t) values (0xD0B1D0B1212322D0B1D0B1D0B1D0B1); -ERROR 23000: Duplicate entry 'бб!#"б' for key 2 +ERROR 23000: Duplicate entry 'бб!#"б' for key 't' select c from t1 where c='cccc'; c cccc @@ -462,5 +462,5 @@ insert into t1 values(1, 'a', 'a', NULL); insert into t1 values(1, 'b', 'b', NULL); alter table t1 drop index i3, drop index i2, drop index i1; alter table t1 add index i3 (c3), add index i2 (c2), add unique index i1 (c1); -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'i1' drop table t1; diff --git a/mysql-test/r/kill.result b/mysql-test/r/kill.result index 2413834be4f..e9d41c104dd 100644 --- a/mysql-test/r/kill.result +++ b/mysql-test/r/kill.result @@ -1,4 +1,4 @@ -drop table if exists t1; +drop table if exists t1, t2, t3; create table t1 (kill_id int); insert into t1 values(connection_id()); select ((@id := kill_id) - kill_id) from t1; @@ -15,6 +15,18 @@ select 4; 4 4 drop table t1; +create table t1 (id int primary key); +create table t2 (id int unsigned not null); +insert into t2 select id from t1; +create table t3 (kill_id int); +insert into t3 values(connection_id()); + select id from t1 where id in (select distinct id from t2); +select ((@id := kill_id) - kill_id) from t3; +((@id := kill_id) - kill_id) +0 +kill @id; +Got one of the listed errors +drop table t1, t2, t3; select get_lock("a", 10); get_lock("a", 10) 1 diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index 0246ca5f71d..0b314defece 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -1,6 +1,6 @@ drop table if exists t1, t2; create table t1 (a date, b date, c date not null, d date); -load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ','; +load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ','; Warnings: Warning 1265 Data truncated for column 'a' at row 1 Warning 1265 Data truncated for column 'c' at row 1 @@ -8,7 +8,7 @@ Warning 1265 Data truncated for column 'd' at row 1 Warning 1265 Data truncated for column 'a' at row 2 Warning 1265 Data truncated for column 'b' at row 2 Warning 1265 Data truncated for column 'd' at row 2 -load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; +load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; SELECT * from t1; a b c d 0000-00-00 NULL 0000-00-00 0000-00-00 @@ -16,7 +16,7 @@ a b c d 2003-03-03 2003-03-03 2003-03-03 NULL 2003-03-03 2003-03-03 2003-03-03 NULL truncate table t1; -load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); +load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); Warnings: Warning 1265 Data truncated for column 'c' at row 1 Warning 1265 Data truncated for column 'd' at row 1 @@ -29,7 +29,7 @@ NULL 0000-00-00 0000-00-00 0000-00-00 NULL 2003-03-03 2003-03-03 NULL drop table t1; create table t1 (a text, b text); -load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; +load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; Warnings: Warning 1261 Row 3 doesn't contain data for all columns select concat('|',a,'|'), concat('|',b,'|') from t1; @@ -41,7 +41,7 @@ Field 3,'Field 4| |Field 6| | 'Field 7'| drop table t1; create table t1 (a int, b char(10)); -load data infile '../../std_data/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; +load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; Warnings: Warning 1264 Out of range value for column 'a' at row 3 Warning 1262 Row 3 was truncated; it contained more data than there were input columns @@ -55,7 +55,7 @@ a b 3 row 3 0 1234567890 truncate table t1; -load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; +load data infile '../std_data_ln/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; Warnings: Warning 1264 Out of range value for column 'a' at row 4 Warning 1261 Row 4 doesn't contain data for all columns @@ -78,7 +78,7 @@ id SET @@SQL_MODE=@OLD_SQL_MODE; drop table t1; create table t1 (a varchar(20), b varchar(20)); -load data infile '../../std_data/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b); +load data infile '../std_data_ln/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b); select * from t1; a b field1 field2 @@ -86,25 +86,25 @@ a"b cd"ef a"b c"d"e drop table t1; create table t1 (a int default 100, b int, c varchar(60)); -load data infile '../../std_data/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b); +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b); select * from t1; a b c NULL 20 b=10 NULL 25 b=15 truncate table t1; -load data infile '../../std_data/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a); +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a); select * from t1; a b c NULL NULL oops NULL NULL oops truncate table t1; set @c:=123; -load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b); +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b); select * from t1; a b c 100 10 123 100 15 123 -load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, @b); +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, @b); select * from t1; a b c 100 10 123 @@ -115,25 +115,25 @@ select @a, @b; @a @b NULL 15 truncate table t1; -load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow"; +load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow"; select * from t1; a b c 1 2 Wow 3 4 Wow 5 6 Wow truncate table t1; -load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c=concat(a,"+",b,"+",@c,"+",b,"+",if(c is null,"NIL",c)); +load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c=concat(a,"+",b,"+",@c,"+",b,"+",if(c is null,"NIL",c)); select * from t1; a b c 1 2 1+2+123+2+NIL 3 4 3+4+123+4+NIL 5 6 5+6+123+6+NIL -load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b); +load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b); ERROR HY000: Can't load value from file with fixed size rows to variable create table t2 (num int primary key, str varchar(10)); insert into t2 values (10,'Ten'), (15,'Fifteen'); truncate table t1; -load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@dummy,@n) set a= @n, c= (select str from t2 where num=@n); +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@dummy,@n) set a= @n, c= (select str from t2 where num=@n); select * from t1; a b c 10 NULL Ten diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result index caaf0367bb7..f75cf503938 100644 --- a/mysql-test/r/log_tables.result +++ b/mysql-test/r/log_tables.result @@ -52,3 +52,15 @@ select "Mark that we woke up from TRUNCATE in the test" as "test passed"; test passed Mark that we woke up from TRUNCATE in the test +use test; +truncate table mysql.general_log; +set names utf8; +create table bug16905 (s char(15) character set utf8 default 'пуÑто'); +insert into bug16905 values ('новое'); +select * from mysql.general_log; +event_time user_host thread_id server_id command_type argument +TIMESTAMP root[root] @ localhost [] 2 1 Query set names utf8 +TIMESTAMP root[root] @ localhost [] 2 1 Query create table bug16905 (s char(15) character set utf8 default 'пуÑто') +TIMESTAMP root[root] @ localhost [] 2 1 Query insert into bug16905 values ('новое') +TIMESTAMP root[root] @ localhost [] 2 1 Query select * from mysql.general_log +drop table bug16905; diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 437b001070a..85082d606a7 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -548,9 +548,9 @@ select * from t4 where a+0 > 90; a b 99 1 insert t5 values (1,1); -ERROR 23000: Duplicate entry '1-1' for key 1 +ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY' insert t6 values (2,1); -ERROR 23000: Duplicate entry '2-1' for key 1 +ERROR 23000: Duplicate entry '2-1' for key 'PRIMARY' insert t5 values (1,1) on duplicate key update b=b+10; insert t6 values (2,1) on duplicate key update b=b+20; select * from t5 where a < 3; diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index e000cfd9c11..06e1872a1c0 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -469,9 +469,9 @@ b. c. update t1 set b='b ' where a=2; update t1 set b='b ' where a > 1; -ERROR 23000: Duplicate entry 'b ' for key 2 +ERROR 23000: Duplicate entry 'b ' for key 'b' insert into t1 (b) values ('b'); -ERROR 23000: Duplicate entry 'b' for key 2 +ERROR 23000: Duplicate entry 'b' for key 'b' select * from t1; a b 1 a @@ -567,7 +567,7 @@ Warnings: Note 1031 Table storage engine for 't1' doesn't have this option 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 a 1 a NULL 1000 NULL NULL YES HASH +t1 1 a 1 a NULL 500 NULL NULL YES HASH drop table t1,t2; create table t1 ( a tinytext, b char(1), index idx (a(1),b) ); insert into t1 values (null,''), (null,''); @@ -867,7 +867,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref v v 13 const # Using where; Using index alter table t1 add unique(v); -ERROR 23000: Duplicate entry '{ ' for key 1 +ERROR 23000: Duplicate entry '{ ' for key 'v_2' alter table t1 add key(v); select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a'; qq @@ -1227,16 +1227,16 @@ drop table t1; create table t1 (a char(10), unique (a)); insert into t1 values ('a '); insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a' for key 1 +ERROR 23000: Duplicate entry 'a' for key 'a' alter table t1 modify a varchar(10); insert into t1 values ('a '),('a '),('a '),('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'a' update t1 set a='a ' where a like 'a%'; select concat(a,'.') from t1; concat(a,'.') diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index cab3d924dd2..fda69b15fd1 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -4,11 +4,11 @@ create table t1 (word varchar(20)); create table t2 (id int auto_increment not null primary key); insert into t1 values ("abirvalg"); insert into t2 values (); -load data infile '../../std_data/words.dat' into table t1; -load data infile '../../std_data/words.dat' into table t1; -load data infile '../../std_data/words.dat' into table t1; -load data infile '../../std_data/words.dat' into table t1; -load data infile '../../std_data/words.dat' into table t1; +load data infile '../std_data_ln/words.dat' into table t1; +load data infile '../std_data_ln/words.dat' into table t1; +load data infile '../std_data_ln/words.dat' into table t1; +load data infile '../std_data_ln/words.dat' into table t1; +load data infile '../std_data_ln/words.dat' into table t1; insert into t1 values ("Alas"); flush logs; @@ -32,13 +32,13 @@ SET INSERT_ID=1; SET TIMESTAMP=1000000000; insert into t2 values (); SET TIMESTAMP=1000000000; -load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD_MB-1-0' INTO table t1; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-1-0' INTO table t1; SET TIMESTAMP=1000000000; -load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD_MB-2-0' INTO table t1; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-2-0' INTO table t1; SET TIMESTAMP=1000000000; -load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD_MB-3-0' INTO table t1; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-3-0' INTO table t1; SET TIMESTAMP=1000000000; -load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD_MB-4-0' INTO table t1; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-4-0' INTO table t1; # End of log file ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; @@ -98,13 +98,13 @@ SET INSERT_ID=1; SET TIMESTAMP=1000000000; insert into t2 values (); SET TIMESTAMP=1000000000; -load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD_MB-1-2' INTO table t1; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-1-2' INTO table t1; SET TIMESTAMP=1000000000; -load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD_MB-2-2' INTO table t1; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-2-2' INTO table t1; SET TIMESTAMP=1000000000; -load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD_MB-3-2' INTO table t1; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-3-2' INTO table t1; SET TIMESTAMP=1000000000; -load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD_MB-4-2' INTO table t1; +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-4-2' INTO table t1; # End of log file ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 79b22964f8a..7328a7da2eb 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -2650,3 +2650,35 @@ DELIMITER ; DROP TRIGGER tr1; DROP TABLE t1; +create table t1 (a text , b text); +create table t2 (a text , b text); +insert t1 values ("Duck, Duck", "goose"); +insert t1 values ("Duck, Duck", "pidgeon"); +insert t2 values ("We the people", "in order to perform"); +insert t2 values ("a more perfect", "union"); +select * from t1; +a b +Duck, Duck goose +Duck, Duck pidgeon +select * from t2; +a b +We the people in order to perform +a more perfect union +test.t1: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0 +test.t2: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0 +test.t1: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0 +test.t2: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0 +select * from t1; +a b +Duck, Duck goose +Duck, Duck pidgeon +Duck, Duck goose +Duck, Duck pidgeon +select * from t2; +a b +We the people in order to perform +a more perfect union +We the people in order to perform +a more perfect union +drop table t1; +drop table t2; diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index f2d57fccad2..2ef005f4ceb 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -223,8 +223,8 @@ mysqltest: At line 1: Missing variable name in let mysqltest: At line 1: Missing assignment operator in let mysqltest: At line 1: Missing file name in source mysqltest: At line 1: Could not open file ./non_existingFile -mysqltest: In included file "./var/tmp/recursive.sql": At line 1: Source directives are nesting too deep -mysqltest: In included file "./var/tmp/error.sql": At line 1: query 'garbage ' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep +mysqltest: In included file "MYSQLTEST_VARDIR/tmp/error.sql": At line 1: query 'garbage ' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 2 = outer loop variable after while here is the sourced script @@ -358,9 +358,9 @@ mysqltest: At line 1: Could not open connection 'con2': 1049 Unknown database 'i mysqltest: At line 1: Illegal argument for port: 'illegal_port' mysqltest: At line 1: Illegal option to connect: SMTP OK -mysqltest: In included file "./var/tmp/con.sql": At line 7: Connection limit exhausted - increase MAX_CONS in mysqltest.c -mysqltest: In included file "./var/tmp/con.sql": At line 3: connection 'test_con1' not found in connection pool -mysqltest: In included file "./var/tmp/con.sql": At line 2: Connection test_con1 already exists +mysqltest: In included file "MYSQLTEST_VARDIR/tmp/con.sql": At line 7: Connection limit exhausted - increase MAX_CONS in mysqltest.c +mysqltest: In included file "MYSQLTEST_VARDIR/tmp/con.sql": At line 3: connection 'test_con1' not found in connection pool +mysqltest: In included file "MYSQLTEST_VARDIR/tmp/con.sql": At line 2: Connection test_con1 already exists connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET); Output from mysqltest-x.inc Output from mysqltest-x.inc @@ -439,3 +439,11 @@ mysqltest: At line 1: Error parsing replace_regex "a " mysqltest: At line 1: Error parsing replace_regex "a b" mysqltest: At line 1: Error parsing replace_regex "/a b c" mysqltest: At line 1: Error parsing replace_regex "/a /b c " +create table t1 (a int, b int); +insert into t1 values (1,3); +insert into t1 values (2,4); +select * from t1; +a D +1 1 +1 4 +drop table t1; diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index 1e863c9012f..9477caf97ab 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -562,7 +562,7 @@ c125 int, c126 int, c127 int, c128 int, -primary key(c1)) engine=ndb; +primary key using hash(c1)) engine=ndb partition by key(c1); drop table t1; create table t1 ( a1234567890123456789012345678901234567890 int primary key, @@ -678,6 +678,61 @@ CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb; select * from t1; b drop table t1; +create table t1 (a int) engine=ndb; +create table t2 (a int) engine=ndb; +insert into t1 values (1); +insert into t2 values (1); +delete t1.* from t1, t2 where t1.a = t2.a; +select * from t1; +a +select * from t2; +a +1 +drop table t1; +drop table t2; +CREATE TABLE t1 ( +i INT, +j INT, +x INT, +y INT, +z INT +) engine=ndb; +CREATE TABLE t2 ( +i INT, +k INT, +x INT, +y INT, +z INT +) engine=ndb; +CREATE TABLE t3 ( +j INT, +k INT, +x INT, +y INT, +z INT +) engine=ndb; +INSERT INTO t1 VALUES ( 1, 2,13,14,15); +INSERT INTO t2 VALUES ( 1, 3,23,24,25); +INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36); +UPDATE t1 AS a +INNER JOIN t2 AS b +ON a.i = b.i +INNER JOIN t3 AS c +ON a.j = c.j AND b.k = c.k +SET a.x = b.x, +a.y = b.y, +a.z = ( +SELECT sum(z) +FROM t3 +WHERE y = 34 +) +WHERE b.x = 23; +select * from t1; +i j x y z +1 2 23 24 71 +drop table t1; +drop table t2; +drop table t3; create table atablewithareallylongandirritatingname (a int); insert into atablewithareallylongandirritatingname values (2); select * from atablewithareallylongandirritatingname; diff --git a/mysql-test/r/ndb_binlog_ddl_multi.result b/mysql-test/r/ndb_binlog_ddl_multi.result index 46789069324..e9a3f80281d 100644 --- a/mysql-test/r/ndb_binlog_ddl_multi.result +++ b/mysql-test/r/ndb_binlog_ddl_multi.result @@ -8,12 +8,12 @@ create database mysqltest; use mysqltest; create table t1 (a int primary key) engine=ndb; create table t2 (a int primary key) engine=ndb; -show binlog events from 102; +show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin1.000001 # Query # # create database mysqltest master-bin1.000001 # Query # # use `mysqltest`; create table t1 (a int primary key) engine=ndb master-bin1.000001 # Query # # use `test`; create table t2 (a int primary key) engine=ndb -show binlog events from 102; +show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # create database mysqltest master-bin.000001 # Query # # use `mysqltest`; create table t1 (a int primary key) engine=ndb @@ -21,7 +21,7 @@ master-bin.000001 # Query # # use `test`; create table t2 (a int primary key) en reset master; reset master; alter table t2 add column (b int); -show binlog events from 102; +show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster_replication.apply_status @@ -32,7 +32,7 @@ reset master; reset master; ALTER DATABASE mysqltest CHARACTER SET latin1; drop table mysqltest.t1; -show binlog events from 102; +show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # ALTER DATABASE mysqltest CHARACTER SET latin1 master-bin.000001 # Query # # BEGIN @@ -46,7 +46,7 @@ use test; insert into t2 values (1,2); drop database mysqltest; create table t1 (a int primary key) engine=ndb; -show binlog events from 102; +show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster_replication.apply_status @@ -88,7 +88,7 @@ ENGINE = NDB; DROP LOGFILE GROUP lg1 ENGINE =NDB; drop table t1; -show binlog events from 102; +show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin1.000001 # Query # # CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undofile.dat' diff --git a/mysql-test/r/ndb_binlog_ignore_db.result b/mysql-test/r/ndb_binlog_ignore_db.result new file mode 100644 index 00000000000..8dc2c1ff1f8 --- /dev/null +++ b/mysql-test/r/ndb_binlog_ignore_db.result @@ -0,0 +1,10 @@ +drop table if exists t1; +drop database if exists mysqltest; +create database mysqltest; +use mysqltest; +create table t1 (a int primary key, b int) engine=ndb; +insert into t1 values (1, 1); +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; drop table if exists t1 +drop database mysqltest; diff --git a/mysql-test/r/ndb_blob.result b/mysql-test/r/ndb_blob.result index f28cb865962..9c76d46f4f0 100644 --- a/mysql-test/r/ndb_blob.result +++ b/mysql-test/r/ndb_blob.result @@ -428,6 +428,13 @@ delete from t1; select * from t1; a b commit; +replace t1 set a=2, b='y'; +select * from t1; +a b +2 y +delete from t1; +select * from t1; +a b drop table t1; set autocommit=0; create table t1 ( diff --git a/mysql-test/r/ndb_charset.result b/mysql-test/r/ndb_charset.result index b1f8190f0ca..b3a2112d50b 100644 --- a/mysql-test/r/ndb_charset.result +++ b/mysql-test/r/ndb_charset.result @@ -27,9 +27,9 @@ a char(3) character set latin1 collate latin1_swedish_ci primary key ) engine=ndb; insert into t1 values('aAa'); insert into t1 values('aaa'); -ERROR 23000: Duplicate entry 'aaa' for key 1 +ERROR 23000: Duplicate entry 'aaa' for key 'PRIMARY' insert into t1 values('AAA'); -ERROR 23000: Duplicate entry 'AAA' for key 1 +ERROR 23000: Duplicate entry 'AAA' for key 'PRIMARY' select * from t1 order by a; a aAa @@ -51,9 +51,9 @@ a varchar(20) character set latin1 collate latin1_swedish_ci primary key ) engine=ndb; insert into t1 values ('A'),('b '),('C '),('d '),('E'),('f'); insert into t1 values('b'); -ERROR 23000: Duplicate entry 'b' for key 1 +ERROR 23000: Duplicate entry 'b' for key 'PRIMARY' insert into t1 values('a '); -ERROR 23000: Duplicate entry 'a ' for key 1 +ERROR 23000: Duplicate entry 'a ' for key 'PRIMARY' select a,length(a) from t1 order by a; a length(a) A 1 @@ -112,9 +112,9 @@ unique key(a) ) engine=ndb; insert into t1 values(1, 'aAa'); insert into t1 values(2, 'aaa'); -ERROR 23000: Duplicate entry '2' for key 1 +ERROR 23000: Duplicate entry '2' for key 'PRIMARY' insert into t1 values(3, 'AAA'); -ERROR 23000: Duplicate entry '3' for key 1 +ERROR 23000: Duplicate entry '3' for key 'PRIMARY' select * from t1 order by p; p a 1 aAa @@ -138,9 +138,9 @@ unique key(a) ) engine=ndb; insert into t1 values (1,'A'),(2,'b '),(3,'C '),(4,'d '),(5,'E'),(6,'f'); insert into t1 values(99,'b'); -ERROR 23000: Duplicate entry '99' for key 1 +ERROR 23000: Duplicate entry '99' for key 'PRIMARY' insert into t1 values(99,'a '); -ERROR 23000: Duplicate entry '99' for key 1 +ERROR 23000: Duplicate entry '99' for key 'PRIMARY' select a,length(a) from t1 order by a; a length(a) A 1 diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index 1401ae26ddb..1085d15ec30 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -22,7 +22,7 @@ select * from t1 where b = 4 order by a; a b c 3 4 6 insert into t1 values(8, 2, 3); -ERROR 23000: Duplicate entry '8' for key 1 +ERROR 23000: Duplicate entry '8' for key 'PRIMARY' select * from t1 order by a; a b c 1 2 3 @@ -89,7 +89,7 @@ a b c 1 1 1 4 4 NULL insert into t1 values(5,1,1); -ERROR 23000: Duplicate entry '5' for key 1 +ERROR 23000: Duplicate entry '5' for key 'PRIMARY' drop table t1; CREATE TABLE t2 ( a int unsigned NOT NULL PRIMARY KEY, @@ -112,7 +112,7 @@ select * from t2 where b = 4 order by a; a b c 3 4 6 insert into t2 values(8, 2, 3); -ERROR 23000: Duplicate entry '8' for key 1 +ERROR 23000: Duplicate entry '8' for key 'PRIMARY' select * from t2 order by a; a b c 1 2 3 @@ -177,7 +177,7 @@ pk a 3 NULL 4 4 insert into t1 values (5,0); -ERROR 23000: Duplicate entry '5' for key 1 +ERROR 23000: Duplicate entry '5' for key 'PRIMARY' select * from t1 order by pk; pk a -1 NULL @@ -210,7 +210,7 @@ pk a b c 0 NULL 18 NULL 1 3 19 abc insert into t2 values(2,3,19,'abc'); -ERROR 23000: Duplicate entry '2' for key 1 +ERROR 23000: Duplicate entry '2' for key 'PRIMARY' select * from t2 order by pk; pk a b c -1 1 17 NULL @@ -626,3 +626,12 @@ select * from t1 where code = '12' and month = 4 and year = 2004 ; id month year code 1 4 2004 12 drop table t1; +create table t1 (a int primary key, b varchar(1000) not null, unique key (b)) +engine=ndb charset=utf8; +insert into t1 values (1, repeat(_utf8 0xe288ab6474, 200)); +insert into t1 values (2, repeat(_utf8 0xe288ab6474, 200)); +ERROR 23000: Duplicate entry '2' for key 'PRIMARY' +select a, sha1(b) from t1; +a sha1(b) +1 08f5d02c8b8bc244f275bdfc22c42c5cab0d9d7d +drop table t1; diff --git a/mysql-test/r/ndb_insert.result b/mysql-test/r/ndb_insert.result index 50739ca15da..11d322a06de 100644 --- a/mysql-test/r/ndb_insert.result +++ b/mysql-test/r/ndb_insert.result @@ -417,7 +417,7 @@ SELECT COUNT(*) FROM t1; COUNT(*) 2000 INSERT INTO t1 VALUES (1,1,1); -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' INSERT INTO t1 VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), (6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); diff --git a/mysql-test/r/ndb_replace.result b/mysql-test/r/ndb_replace.result index 63fd8b55c8e..6aa1a387661 100644 --- a/mysql-test/r/ndb_replace.result +++ b/mysql-test/r/ndb_replace.result @@ -11,7 +11,7 @@ insert into t1 (gesuchnr, benutzer_id) value (3,2); replace into t1 (gesuchnr,benutzer_id) values (1,1); replace into t1 (gesuchnr,benutzer_id) values (1,1); insert into t1 (gesuchnr,benutzer_id) values (1,1); -ERROR 23000: Duplicate entry '1-1' for key 1 +ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY' replace into t1 (gesuchnr,benutzer_id) values (1,1); select * from t1 order by gesuchnr; gesuchnr benutzer_id diff --git a/mysql-test/r/ndb_update.result b/mysql-test/r/ndb_update.result index c2247564e65..ea6eb1644f2 100644 --- a/mysql-test/r/ndb_update.result +++ b/mysql-test/r/ndb_update.result @@ -18,7 +18,7 @@ pk1 b c 2 2 2 4 1 1 UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4; -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t1 order by pk1; pk1 b c 0 0 0 diff --git a/mysql-test/r/ndb_view.result b/mysql-test/r/ndb_view.result new file mode 100644 index 00000000000..b7d1b6860c8 --- /dev/null +++ b/mysql-test/r/ndb_view.result @@ -0,0 +1,24 @@ +DROP TABLE IF EXISTS t1,t2,t3; +DROP VIEW IF EXISTS v1,v2,v3; +create table t1 (a int, b int, c int, d int) engine=ndb; +insert into t1 values (1,2,3,4),(5,6,7,8); +create view v1 as select t1.c as a, t1.a as b, t1.d as c, t1.a+t1.b+t1.c as d from t1; +select * from v1 order by a,b,c; +a b c d +3 1 4 6 +7 5 8 18 +update v1 set a=a+100 where b=1; +select * from v1 order by a,b,c; +a b c d +7 5 8 18 +103 1 4 106 +drop view v1; +create view v1 as select t1.c as a from t1; +insert into v1 values (200); +select * from t1 order by a,b,c,d; +a b c d +NULL NULL 200 NULL +1 2 103 4 +5 6 7 8 +drop view v1; +drop table t1; diff --git a/mysql-test/r/outfile.result b/mysql-test/r/outfile.result Binary files differindex 5eb24a78ef0..ee8c3249c9d 100644 --- a/mysql-test/r/outfile.result +++ b/mysql-test/r/outfile.result diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result index cf858cc1d32..859050fd4a3 100644 --- a/mysql-test/r/ps_1general.result +++ b/mysql-test/r/ps_1general.result @@ -785,4 +785,4 @@ prepare stmt1 from @string ; execute stmt1 ; prepare stmt1 from ' select * from t5 ' ; execute stmt1 ; -drop table t5, t9; +drop table t1, t5, t9; diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index 0fef8922f43..b5560a4757c 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -1426,7 +1426,7 @@ select a,b from t1 where b = @arg00; a b 6 six execute stmt1 using @arg00; -ERROR 23000: Duplicate entry '6' for key 1 +ERROR 23000: Duplicate entry '6' for key 'PRIMARY' set @arg00=NULL ; prepare stmt1 from 'insert into t1 values(0, ? )'; execute stmt1 using @arg00; @@ -1539,7 +1539,7 @@ a b set @arg00=81 ; set @arg01=1 ; execute stmt1 using @arg00, @arg01; -ERROR 23000: Duplicate entry '82' for key 1 +ERROR 23000: Duplicate entry '82' for key 'PRIMARY' drop table if exists t2 ; create table t2 (id int auto_increment primary key) ENGINE= 'MYISAM' ; diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 5f979a124e1..594e673ba4d 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -1409,7 +1409,7 @@ select a,b from t1 where b = @arg00; a b 6 six execute stmt1 using @arg00; -ERROR 23000: Duplicate entry '6' for key 1 +ERROR 23000: Duplicate entry '6' for key 'PRIMARY' set @arg00=NULL ; prepare stmt1 from 'insert into t1 values(0, ? )'; execute stmt1 using @arg00; @@ -1522,7 +1522,7 @@ a b set @arg00=81 ; set @arg01=1 ; execute stmt1 using @arg00, @arg01; -ERROR 23000: Duplicate entry '82' for key 1 +ERROR 23000: Duplicate entry '82' for key 'PRIMARY' drop table if exists t2 ; create table t2 (id int auto_increment primary key) ENGINE= 'InnoDB' ; diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index 021db900e86..fb94ed7ca34 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -1410,7 +1410,7 @@ select a,b from t1 where b = @arg00; a b 6 six execute stmt1 using @arg00; -ERROR 23000: Duplicate entry '6' for key 1 +ERROR 23000: Duplicate entry '6' for key 'PRIMARY' set @arg00=NULL ; prepare stmt1 from 'insert into t1 values(0, ? )'; execute stmt1 using @arg00; @@ -1523,7 +1523,7 @@ a b set @arg00=81 ; set @arg01=1 ; execute stmt1 using @arg00, @arg01; -ERROR 23000: Duplicate entry '82' for key 1 +ERROR 23000: Duplicate entry '82' for key 'PRIMARY' drop table if exists t2 ; create table t2 (id int auto_increment primary key) ENGINE= 'HEAP' ; diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index f1444df4888..3a630b58b8a 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -1452,7 +1452,7 @@ select a,b from t1 where b = @arg00; a b 6 six execute stmt1 using @arg00; -ERROR 23000: Duplicate entry '6' for key 1 +ERROR 23000: Duplicate entry '6' for key 'PRIMARY' set @arg00=NULL ; prepare stmt1 from 'insert into t1 values(0, ? )'; execute stmt1 using @arg00; @@ -1565,7 +1565,7 @@ a b set @arg00=81 ; set @arg01=1 ; execute stmt1 using @arg00, @arg01; -ERROR 23000: Duplicate entry '82' for key 1 +ERROR 23000: Duplicate entry '82' for key 'PRIMARY' drop table if exists t2 ; create table t2 (id int auto_increment primary key) ENGINE= 'MYISAM' ; @@ -4466,7 +4466,7 @@ select a,b from t1 where b = @arg00; a b 6 six execute stmt1 using @arg00; -ERROR 23000: Duplicate entry '6' for key 1 +ERROR 23000: Duplicate entry '6' for key 'PRIMARY' set @arg00=NULL ; prepare stmt1 from 'insert into t1 values(0, ? )'; execute stmt1 using @arg00; @@ -4579,7 +4579,7 @@ a b set @arg00=81 ; set @arg01=1 ; execute stmt1 using @arg00, @arg01; -ERROR 23000: Duplicate entry '82' for key 1 +ERROR 23000: Duplicate entry '82' for key 'PRIMARY' drop table if exists t2 ; create table t2 (id int auto_increment primary key) ENGINE= 'MYISAM' ; diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result index f83a5b090f4..581369a3faa 100644 --- a/mysql-test/r/ps_6bdb.result +++ b/mysql-test/r/ps_6bdb.result @@ -1409,7 +1409,7 @@ select a,b from t1 where b = @arg00; a b 6 six execute stmt1 using @arg00; -ERROR 23000: Duplicate entry '6' for key 1 +ERROR 23000: Duplicate entry '6' for key 'PRIMARY' set @arg00=NULL ; prepare stmt1 from 'insert into t1 values(0, ? )'; execute stmt1 using @arg00; @@ -1522,7 +1522,7 @@ a b set @arg00=81 ; set @arg01=1 ; execute stmt1 using @arg00, @arg01; -ERROR 23000: Duplicate entry '82' for key 1 +ERROR 23000: Duplicate entry '82' for key 'PRIMARY' drop table if exists t2 ; create table t2 (id int auto_increment primary key) ENGINE= 'BDB' ; diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 8d76f8fc701..942eca42c93 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -1076,6 +1076,7 @@ a f1() 1 2 2 2 drop procedure p1// +drop function f1// drop table t1// flush query cache; reset query cache; diff --git a/mysql-test/r/read_only.result b/mysql-test/r/read_only.result index 55a14bcaec8..1a1991a6255 100644 --- a/mysql-test/r/read_only.result +++ b/mysql-test/r/read_only.result @@ -41,3 +41,4 @@ insert into t1 values(1); ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement drop table t1,t2; drop user test@localhost; +set global read_only=0; diff --git a/mysql-test/r/renamedb.result b/mysql-test/r/renamedb.result new file mode 100644 index 00000000000..26ae42e72aa --- /dev/null +++ b/mysql-test/r/renamedb.result @@ -0,0 +1,29 @@ +drop database if exists testdb1; +create database testdb1 default character set latin2; +use testdb1; +create table t1 (a int); +insert into t1 values (1),(2),(3); +show create database testdb1; +Database Create Database +testdb1 CREATE DATABASE `testdb1` /*!40100 DEFAULT CHARACTER SET latin2 */ +show tables; +Tables_in_testdb1 +t1 +rename database testdb1 to testdb2; +show create database testdb1; +ERROR 42000: Unknown database 'testdb1' +show create database testdb2; +Database Create Database +testdb2 CREATE DATABASE `testdb2` /*!40100 DEFAULT CHARACTER SET latin2 */ +select database(); +database() +testdb2 +show tables; +Tables_in_testdb2 +t1 +select a from t1 order by a; +a +1 +2 +3 +drop database testdb2; diff --git a/mysql-test/r/replace.result b/mysql-test/r/replace.result index a7d59fcfa62..ca32b3d45bf 100644 --- a/mysql-test/r/replace.result +++ b/mysql-test/r/replace.result @@ -13,9 +13,9 @@ drop table t1; create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value"); insert into t1 values (126,"first"),(63, "middle"),(0,"last"); insert into t1 values (0,"error"); -ERROR 23000: Duplicate entry '127' for key 1 +ERROR 23000: Duplicate entry '127' for key 'PRIMARY' replace into t1 values (0,"error"); -ERROR 23000: Duplicate entry '127' for key 1 +ERROR 23000: Duplicate entry '127' for key 'PRIMARY' replace into t1 values (126,"first updated"); replace into t1 values (63,default); select * from t1; diff --git a/mysql-test/r/rpl000004.a.result b/mysql-test/r/rpl000004.a.result deleted file mode 100644 index 694d7429a14..00000000000 --- a/mysql-test/r/rpl000004.a.result +++ /dev/null @@ -1,2 +0,0 @@ -Table Op Msg_type Msg_text -test.t1 check status OK diff --git a/mysql-test/r/rpl000004.b.result b/mysql-test/r/rpl000004.b.result deleted file mode 100644 index 7e05933909e..00000000000 --- a/mysql-test/r/rpl000004.b.result +++ /dev/null @@ -1,2 +0,0 @@ -count(*) -10 diff --git a/mysql-test/r/rpl000004.result b/mysql-test/r/rpl000004.result deleted file mode 100644 index 9abb4db7974..00000000000 --- a/mysql-test/r/rpl000004.result +++ /dev/null @@ -1,28 +0,0 @@ -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; -set SQL_LOG_BIN=0; -create table t1 (word char(20) not null, index(word)); -load data infile '../../std_data/words.dat' into table t1; -create table t2 (word char(20) not null); -load data infile '../../std_data/words.dat' into table t2; -create table t3 (word char(20) not null primary key); -load table t1 from master; -load table t2 from master; -load table t3 from master; -check table t1; -Table Op Msg_type Msg_text -test.t1 check status OK -select count(*) from t2; -count(*) -70 -select count(*) from t3; -count(*) -0 -set SQL_LOG_BIN=1; -drop table if exists t1,t2,t3; -create table t1(n int); -drop table t1; diff --git a/mysql-test/r/rpl000006.result b/mysql-test/r/rpl000006.result deleted file mode 100644 index e4c2006c2f0..00000000000 --- a/mysql-test/r/rpl000006.result +++ /dev/null @@ -1,29 +0,0 @@ -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; -set SQL_LOG_BIN=0,timestamp=200006; -create table t1(t timestamp not null,a char(1)); -insert into t1 ( a) values ('F'); -select unix_timestamp(t) from t1; -unix_timestamp(t) -200006 -load table t1 from master; -select unix_timestamp(t) from t1; -unix_timestamp(t) -200006 -set SQL_LOG_BIN=1,timestamp=default; -drop table t1; -set SQL_LOG_BIN=0; -CREATE TABLE t1 ( -a int not null -) ENGINE=MyISAM MAX_ROWS=4000 CHECKSUM=1; -INSERT INTO t1 VALUES (1); -load table t1 from master; -check table t1; -Table Op Msg_type Msg_text -test.t1 check status OK -drop table t1; -drop table t1; diff --git a/mysql-test/r/rpl000017.result b/mysql-test/r/rpl000017.result index 245848a07e4..1c611357e64 100644 --- a/mysql-test/r/rpl000017.result +++ b/mysql-test/r/rpl000017.result @@ -15,3 +15,4 @@ select * from t1; n 24 drop table t1; +delete from mysql.user where user="replicate"; diff --git a/mysql-test/r/rpl_LD_INFILE.result b/mysql-test/r/rpl_LD_INFILE.result index a2e4ef7b83b..b092dd9e088 100644 --- a/mysql-test/r/rpl_LD_INFILE.result +++ b/mysql-test/r/rpl_LD_INFILE.result @@ -4,118 +4,114 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; -DROP PROCEDURE IF EXISTS test.p1; DROP TABLE IF EXISTS test.t1; CREATE TABLE test.t1 (a VARCHAR(255), PRIMARY KEY(a)); LOAD DATA INFILE '../../std_data/words2.dat' INTO TABLE test.t1; DELETE FROM test.t1 WHERE a = 'abashed'; DELETE FROM test.t1; LOAD DATA INFILE '../../std_data/words2.dat' INTO TABLE test.t1; -SELECT * FROM test.t1; +SELECT * FROM test.t1 ORDER BY a DESC; a -abase -abased -abasement -abasements -abases -abash -abashed -abashes -abashing -abasing -abate -abated -abatement -abatements -abater -abates -abating -Abba -abbe -abbey -abbeys -abbot -abbots -Abbott -abbreviate -abbreviated -abbreviates -abbreviating -abbreviation -abbreviations -Abby -abdomen -abdomens -abdominal -abduct -abducted -abduction -abductions -abductor -abductors -abducts -Abe -abed -Abel -Abelian -Abelson -Aberdeen -Abernathy -aberrant aberration -SELECT * FROM test.t1; -a -abase -abased -abasement -abasements -abases -abash -abashed -abashes -abashing -abasing -abate -abated -abatement -abatements -abater -abates -abating -Abba -abbe -abbey -abbeys -abbot -abbots -Abbott -abbreviate -abbreviated -abbreviates -abbreviating -abbreviation -abbreviations -Abby -abdomen -abdomens -abdominal -abduct -abducted -abduction -abductions -abductor -abductors -abducts -Abe -abed -Abel -Abelian -Abelson -Aberdeen -Abernathy aberrant +Abernathy +Aberdeen +Abelson +Abelian +Abel +abed +Abe +abducts +abductors +abductor +abductions +abduction +abducted +abduct +abdominal +abdomens +abdomen +Abby +abbreviations +abbreviation +abbreviating +abbreviates +abbreviated +abbreviate +Abbott +abbots +abbot +abbeys +abbey +abbe +Abba +abating +abates +abater +abatements +abatement +abated +abate +abasing +abashing +abashes +abashed +abash +abases +abasements +abasement +abased +abase +SELECT * FROM test.t1 ORDER BY a DESC; +a aberration -DROP PROCEDURE IF EXISTS test.p1; -Warnings: -Note 1305 PROCEDURE p1 does not exist +aberrant +Abernathy +Aberdeen +Abelson +Abelian +Abel +abed +Abe +abducts +abductors +abductor +abductions +abduction +abducted +abduct +abdominal +abdomens +abdomen +Abby +abbreviations +abbreviation +abbreviating +abbreviates +abbreviated +abbreviate +Abbott +abbots +abbot +abbeys +abbey +abbe +Abba +abating +abates +abater +abatements +abatement +abated +abate +abasing +abashing +abashes +abashed +abash +abases +abasements +abasement +abased +abase DROP TABLE test.t1; diff --git a/mysql-test/r/rpl_auto_increment.result b/mysql-test/r/rpl_auto_increment.result index 9eca51ad2d9..9984ccf51f3 100644 --- a/mysql-test/r/rpl_auto_increment.result +++ b/mysql-test/r/rpl_auto_increment.result @@ -126,7 +126,7 @@ a 504 set @@insert_id=600; insert into t1 values(600),(NULL),(NULL); -ERROR 23000: Duplicate entry '600' for key 1 +ERROR 23000: Duplicate entry '600' for key 'PRIMARY' set @@insert_id=600; insert ignore into t1 values(600),(NULL),(NULL),(610),(NULL); select * from t1; diff --git a/mysql-test/r/rpl_create_database.result b/mysql-test/r/rpl_create_database.result index 74708c8ec9a..cb3c7944962 100644 --- a/mysql-test/r/rpl_create_database.result +++ b/mysql-test/r/rpl_create_database.result @@ -61,16 +61,14 @@ mysql mysqltest_prometheus mysqltest_sisyfos test -SHOW CREATE TABLE mysqltest_prometheus.t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -SHOW CREATE TABLE mysqltest_sisyfos.t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 +USE mysqltest_prometheus; +SHOW TABLES; +Tables_in_mysqltest_prometheus +t1 +USE mysqltest_sisyfos; +SHOW TABLES; +Tables_in_mysqltest_sisyfos +t2 DROP DATABASE IF EXISTS mysqltest_prometheus; DROP DATABASE IF EXISTS mysqltest_sisyfos; DROP DATABASE IF EXISTS mysqltest_bob; diff --git a/mysql-test/r/rpl_drop_temp.result b/mysql-test/r/rpl_drop_temp.result index 04fe094ea26..40d578dd13e 100644 --- a/mysql-test/r/rpl_drop_temp.result +++ b/mysql-test/r/rpl_drop_temp.result @@ -5,8 +5,8 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; create database if not exists mysqltest; -create temporary table mysqltest.t1 (n int); -create temporary table mysqltest.t2 (n int); +create temporary table mysqltest.t1 (n int)ENGINE=MyISAM; +create temporary table mysqltest.t2 (n int)ENGINE=MyISAM; show status like 'Slave_open_temp_tables'; Variable_name Value Slave_open_temp_tables 0 diff --git a/mysql-test/r/rpl_err_ignoredtable.result b/mysql-test/r/rpl_err_ignoredtable.result index 84072be7d44..27db9c0372c 100644 --- a/mysql-test/r/rpl_err_ignoredtable.result +++ b/mysql-test/r/rpl_err_ignoredtable.result @@ -7,14 +7,14 @@ start slave; create table t1 (a int primary key); create table t4 (a int primary key); insert into t1 values (1),(1); -ERROR 23000: Duplicate entry '1' for key 1 +Got one of the listed errors insert into t4 values (1),(2); show tables like 't1'; Tables_in_test (t1) show tables like 't4'; Tables_in_test (t4) t4 -SELECT * FROM test.t4; +SELECT * FROM test.t4 ORDER BY a; a 1 2 @@ -33,7 +33,7 @@ select (@id := id) - id from t3; kill @id; drop table t2,t3; insert into t4 values (3),(4); -SELECT * FROM test.t4; +SELECT * FROM test.t4 ORDER BY a; a 1 2 diff --git a/mysql-test/r/rpl_heap.result b/mysql-test/r/rpl_heap.result index 1facbcb7676..d0ef7e541b2 100644 --- a/mysql-test/r/rpl_heap.result +++ b/mysql-test/r/rpl_heap.result @@ -1,10 +1,10 @@ reset master; drop table if exists t1; -create table t1 type=HEAP select 10 as a; +create table t1 ENGINE=HEAP select 10 as a; insert into t1 values(11); show binlog events from 79; Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.001 79 Query 1 79 use `test`; create table t1 type=HEAP select 10 as a +master-bin.001 79 Query 1 79 use `test`; create table t1 ENGINE=HEAP select 10 as a master-bin.001 154 Query 1 154 use `test`; insert into t1 values(11) reset slave; start slave; @@ -12,7 +12,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` bigint(2) NOT NULL default '0' -) TYPE=HEAP +) ENGINE=HEAP select * from t1; a 10 diff --git a/mysql-test/r/rpl_ignore_revoke.result b/mysql-test/r/rpl_ignore_revoke.result index 094b571f4f4..42625119f28 100644 --- a/mysql-test/r/rpl_ignore_revoke.result +++ b/mysql-test/r/rpl_ignore_revoke.result @@ -26,3 +26,4 @@ select select_priv from mysql.user where user='user_foo' /* slave:must get Y */; select_priv Y revoke select on *.* FROM 'user_foo'; +delete from mysql.user where user="user_foo"; diff --git a/mysql-test/r/rpl_ignore_table.result b/mysql-test/r/rpl_ignore_table.result new file mode 100644 index 00000000000..356a9dcb2f8 --- /dev/null +++ b/mysql-test/r/rpl_ignore_table.result @@ -0,0 +1,16 @@ +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; +**** Test case for BUG#16487 **** +**** Master **** +CREATE TABLE test.t4 (a int); +CREATE TABLE test.t1 (a int); +UPDATE test.t4 NATURAL JOIN test.t1 SET t1.a=5; +**** Slave **** +SELECT * FROM t4; +a +DROP TABLE t1; +DROP TABLE t4; diff --git a/mysql-test/r/rpl000008.result b/mysql-test/r/rpl_ignore_table_update.result index a88a3c690ed..a88a3c690ed 100644 --- a/mysql-test/r/rpl000008.result +++ b/mysql-test/r/rpl_ignore_table_update.result diff --git a/mysql-test/r/rpl_innodb.result b/mysql-test/r/rpl_innodb.result index ebf1d79c4d0..765de8af458 100644 --- a/mysql-test/r/rpl_innodb.result +++ b/mysql-test/r/rpl_innodb.result @@ -12,7 +12,7 @@ PRIMARY KEY (id), UNIQUE KEY unique_rec (name,number) ) ENGINE=InnoDB; LOAD DATA -INFILE '../../std_data/loaddata_pair.dat' +INFILE '../std_data_ln/loaddata_pair.dat' REPLACE INTO TABLE t4 (name,number); SELECT * FROM t4; @@ -24,7 +24,7 @@ id name number 1 XXX 12345 2 XXY 12345 LOAD DATA -INFILE '../../std_data/loaddata_pair.dat' +INFILE '../std_data_ln/loaddata_pair.dat' REPLACE INTO TABLE t4 (name,number); SELECT * FROM t4; diff --git a/mysql-test/r/rpl_insert_id.result b/mysql-test/r/rpl_insert_id.result index 8482f631553..4504ad8e5a7 100644 --- a/mysql-test/r/rpl_insert_id.result +++ b/mysql-test/r/rpl_insert_id.result @@ -9,13 +9,13 @@ create table t2(b int auto_increment, c int, key(b)); insert into t1 values (1),(2),(3); insert into t1 values (null); insert into t2 values (null,last_insert_id()); -select * from t1; +select * from t1 ORDER BY a; a 1 2 3 4 -select * from t2; +select * from t2 ORDER BY b; b c 1 4 drop table t1; @@ -45,21 +45,21 @@ create table t2(b int auto_increment, c int, key(b)); insert into t1 values (10); insert into t1 values (null),(null),(null); insert into t2 values (5,0); -insert into t2 (c) select * from t1; -select * from t2; +insert into t2 (c) select * from t1 ORDER BY a; +select * from t2 ORDER BY b; b c 5 0 6 10 7 11 8 12 9 13 -select * from t1; +select * from t1 ORDER BY a; a 10 11 12 13 -select * from t2; +select * from t2 ORDER BY b; b c 5 0 6 10 @@ -72,4 +72,4 @@ SET TIMESTAMP=1000000000; CREATE TABLE t1 ( a INT UNIQUE ); SET FOREIGN_KEY_CHECKS=0; INSERT INTO t1 VALUES (1),(1); -ERROR 23000: Duplicate entry '1' for key 1 +Got one of the listed errors diff --git a/mysql-test/r/rpl_insert_id_pk.result b/mysql-test/r/rpl_insert_id_pk.result new file mode 100644 index 00000000000..0a452d2dd73 --- /dev/null +++ b/mysql-test/r/rpl_insert_id_pk.result @@ -0,0 +1,75 @@ +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; +create table t1(a int auto_increment, primary key(a)); +create table t2(b int auto_increment, c int, primary key(b)); +insert into t1 values (1),(2),(3); +insert into t1 values (null); +insert into t2 values (null,last_insert_id()); +select * from t1 ORDER BY a; +a +1 +2 +3 +4 +select * from t2 ORDER BY b; +b c +1 4 +drop table t1; +drop table t2; +create table t1(a int auto_increment, key(a)) engine=innodb; +create table t2(b int auto_increment, c int, key(b), foreign key(b) references t1(a)) engine=innodb; +SET FOREIGN_KEY_CHECKS=0; +insert into t1 values (10); +insert into t1 values (null),(null),(null); +insert into t2 values (5,0); +insert into t2 values (null,last_insert_id()); +SET FOREIGN_KEY_CHECKS=1; +select * from t1; +a +10 +11 +12 +13 +select * from t2; +b c +5 0 +6 11 +drop table t2; +drop table t1; +create table t1(a int auto_increment, primary key(a)); +create table t2(b int auto_increment, c int, primary key(b)); +insert into t1 values (10); +insert into t1 values (null),(null),(null); +insert into t2 values (5,0); +insert into t2 (c) select * from t1 ORDER BY a; +select * from t2 ORDER BY b; +b c +5 0 +6 10 +7 11 +8 12 +9 13 +select * from t1 ORDER BY a; +a +10 +11 +12 +13 +select * from t2 ORDER BY b; +b c +5 0 +6 10 +7 11 +8 12 +9 13 +drop table t1; +drop table t2; +SET TIMESTAMP=1000000000; +CREATE TABLE t1 ( a INT UNIQUE ); +SET FOREIGN_KEY_CHECKS=0; +INSERT INTO t1 VALUES (1),(1); +Got one of the listed errors diff --git a/mysql-test/r/rpl000009.result b/mysql-test/r/rpl_load_from_master.result index 9a3a2e7af3f..edf1f0ee7c9 100644 --- a/mysql-test/r/rpl000009.result +++ b/mysql-test/r/rpl_load_from_master.result @@ -13,11 +13,11 @@ drop database if exists mysqltest3; create database mysqltest2; create database mysqltest; create database mysqltest2; -create table mysqltest2.foo (n int); +create table mysqltest2.foo (n int)ENGINE=MyISAM; insert into mysqltest2.foo values(4); -create table mysqltest2.foo (n int); +create table mysqltest2.foo (n int)ENGINE=MyISAM; insert into mysqltest2.foo values(5); -create table mysqltest.bar (m int); +create table mysqltest.bar (m int)ENGINE=MyISAM; insert into mysqltest.bar values(15); select mysqltest2.foo.n,mysqltest.bar.m from mysqltest2.foo,mysqltest.bar; n m @@ -38,12 +38,12 @@ mysql mysqltest mysqltest2 test -create table mysqltest2.t1(n int, s char(20)); -create table mysqltest2.t2(n int, s text); +create table mysqltest2.t1(n int, s char(20))ENGINE=MyISAM; +create table mysqltest2.t2(n int, s text)ENGINE=MyISAM; insert into mysqltest2.t1 values (1, 'one'), (2, 'two'), (3, 'three'); insert into mysqltest2.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen'); -create table mysqltest.t1(n int, s char(20)); -create table mysqltest.t2(n int, s text); +create table mysqltest.t1(n int, s char(20))ENGINE=MyISAM; +create table mysqltest.t2(n int, s text)ENGINE=MyISAM; insert into mysqltest.t1 values (1, 'one test'), (2, 'two test'), (3, 'three test'); insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'), (13, 'thirteen test'); @@ -55,17 +55,17 @@ cluster_replication mysql test create database mysqltest2; -create table mysqltest2.t1(n int, s char(20)); +create table mysqltest2.t1(n int, s char(20))ENGINE=MyISAM; insert into mysqltest2.t1 values (1, 'original foo.t1'); -create table mysqltest2.t3(n int, s char(20)); +create table mysqltest2.t3(n int, s char(20))ENGINE=MyISAM; insert into mysqltest2.t3 values (1, 'original foo.t3'); create database mysqltest3; -create table mysqltest3.t1(n int, s char(20)); +create table mysqltest3.t1(n int, s char(20))ENGINE=MyISAM; insert into mysqltest3.t1 values (1, 'original foo2.t1'); create database mysqltest; -create table mysqltest.t1(n int, s char(20)); +create table mysqltest.t1(n int, s char(20))ENGINE=MyISAM; insert into mysqltest.t1 values (1, 'original bar.t1'); -create table mysqltest.t3(n int, s char(20)); +create table mysqltest.t3(n int, s char(20))ENGINE=MyISAM; insert into mysqltest.t3 values (1, 'original bar.t3'); load data from master; show databases; diff --git a/mysql-test/r/rpl_load_table_from_master.result b/mysql-test/r/rpl_load_table_from_master.result new file mode 100644 index 00000000000..9d9a1d7d6cb --- /dev/null +++ b/mysql-test/r/rpl_load_table_from_master.result @@ -0,0 +1,51 @@ +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; +"******************** Test Requirment 1 *************" +SET SQL_LOG_BIN=0,timestamp=200006; +CREATE TABLE t1(t TIMESTAMP NOT NULL,a CHAR(1))ENGINE=MyISAM; +INSERT INTO t1 ( a) VALUE ('F'); +select unix_timestamp(t) from t1; +unix_timestamp(t) +200006 +load table t1 from master; +select unix_timestamp(t) from t1; +unix_timestamp(t) +200006 +set SQL_LOG_BIN=1,timestamp=default; +drop table t1; +set SQL_LOG_BIN=0; +"******************** Test Requirment 2 *************" +CREATE TABLE t1 (a INT NOT NULL) ENGINE=MyISAM MAX_ROWS=4000 CHECKSUM=1; +INSERT INTO t1 VALUES (1); +load table t1 from master; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +drop table t1; +set SQL_LOG_BIN=0; +create table t1 (word char(20) not null, index(word))ENGINE=MyISAM; +load data infile '../../std_data/words.dat' into table t1; +create table t2 (word char(20) not null)ENGINE=MyISAM; +load data infile '../../std_data/words.dat' into table t2; +create table t3 (word char(20) not null primary key)ENGINE=MyISAM; +load table t1 from master; +load table t2 from master; +load table t3 from master; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select count(*) from t2; +count(*) +70 +select count(*) from t3; +count(*) +0 +set SQL_LOG_BIN=1; +drop table if exists t1,t2,t3; +create table t1(n int); +drop table t1; diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index 0b2e108843b..47e056429ce 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -6,9 +6,9 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; reset master; create table t1(a int not null auto_increment, b int, primary key(a) ); -load data infile '../../std_data/rpl_loaddata.dat' into table t1; +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60)); -load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; +load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines; create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60)); insert into t3 select * from t2; select * from t1; @@ -22,13 +22,13 @@ day id category name 2003-03-22 2416 a bbbbb show master status; File Position Binlog_Do_DB Binlog_Ignore_DB -slave-bin.000001 1290 +slave-bin.000001 1276 drop table t1; drop table t2; drop table t3; create table t1(a int, b int, unique(b)); insert into t1 values(1,10); -load data infile '../../std_data/rpl_loaddata.dat' into table t1; +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; set global sql_slave_skip_counter=1; start slave; show slave status; @@ -37,7 +37,7 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File set sql_log_bin=0; delete from t1; set sql_log_bin=1; -load data infile '../../std_data/rpl_loaddata.dat' into table t1; +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; stop slave; change master to master_user='test'; change master to master_user='root'; @@ -49,7 +49,7 @@ start slave; set sql_log_bin=0; delete from t1; set sql_log_bin=1; -load data infile '../../std_data/rpl_loaddata.dat' into table t1; +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1; stop slave; reset slave; show slave status; @@ -58,10 +58,10 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File reset master; create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60), unique(day)) engine=MyISAM; -load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields +load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields 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 +ERROR 23000: Duplicate entry '2003-03-22' for key 'day' select * from t2; day id category name 2003-02-22 2461 b a a a @ % ' " a @@ -73,9 +73,9 @@ day id category name 2003-03-22 2161 c asdf alter table t2 drop key day; delete from t2; -load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields +load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields 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 +ERROR 23000: Duplicate entry '2003-03-22' for key 'day' drop table t2; drop table t2; diff --git a/mysql-test/r/rpl_loaddata2.result b/mysql-test/r/rpl_loaddata2.result index 00b64dc2c51..5e3923616ed 100644 --- a/mysql-test/r/rpl_loaddata2.result +++ b/mysql-test/r/rpl_loaddata2.result @@ -150,3 +150,4 @@ Aberdeen Abernathy aberrant aberration +drop table t1; diff --git a/mysql-test/r/rpl_loaddata_s.result b/mysql-test/r/rpl_loaddata_s.result index 8d50d9cc0d9..f0c79c81c15 100644 --- a/mysql-test/r/rpl_loaddata_s.result +++ b/mysql-test/r/rpl_loaddata_s.result @@ -6,9 +6,10 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; reset master; create table test.t1(a int, b int, unique(b)); -load data infile '../../std_data/rpl_loaddata.dat' into table test.t1; +load data infile '../std_data_ln/rpl_loaddata.dat' into table test.t1; select count(*) from test.t1; count(*) 2 show binlog events from 102; Log_name Pos Event_type Server_id End_log_pos Info +drop table test.t1; diff --git a/mysql-test/r/rpl_loaddatalocal.result b/mysql-test/r/rpl_loaddatalocal.result index c29825c3c98..20e56a62133 100644 --- a/mysql-test/r/rpl_loaddatalocal.result +++ b/mysql-test/r/rpl_loaddatalocal.result @@ -5,19 +5,19 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; create table t1(a int); -select * into outfile '../../var/master-data/rpl_loaddatalocal.select_outfile' from t1; +select * into outfile 'MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' from t1; truncate table t1; -load data local infile './var/master-data/rpl_loaddatalocal.select_outfile' into table t1; +load data local infile 'MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1; select a,count(*) from t1 group by a; a count(*) 1 10000 drop table t1; create table t1(a int); insert into t1 values (1), (2), (2), (3); -select * into outfile '../../var/master-data/rpl_loaddatalocal.select_outfile' from t1; +select * into outfile 'MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' from t1; drop table t1; create table t1(a int primary key); -load data local infile './var/master-data/rpl_loaddatalocal.select_outfile' into table t1; +load data local infile 'MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1; select * from t1; a 1 diff --git a/mysql-test/r/rpl_misc_functions.result b/mysql-test/r/rpl_misc_functions.result index a687063706d..c11663b8ac8 100644 --- a/mysql-test/r/rpl_misc_functions.result +++ b/mysql-test/r/rpl_misc_functions.result @@ -15,7 +15,9 @@ insert into t1 values(3, 0, 0, 0, password('does_this_work?')); insert into t1 values(4, connection_id(), rand()*1000, rand()*1000, password('does_this_still_work?')); select * into outfile 'rpl_misc_functions.outfile' from t1; create table t2 like t1; -load data local infile './var/master-data/test/rpl_misc_functions.outfile' into table t2; +load data local infile 'MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile' into table t2; select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p); id i r1 r2 p id i r1 r2 p stop slave; +drop table t1; +drop table t1; diff --git a/mysql-test/r/rpl000002.result b/mysql-test/r/rpl_mixed_ddl_dml.result index e5e661795fe..e5e661795fe 100644 --- a/mysql-test/r/rpl000002.result +++ b/mysql-test/r/rpl_mixed_ddl_dml.result diff --git a/mysql-test/r/rpl_ndb_auto_inc.result b/mysql-test/r/rpl_ndb_auto_inc.result new file mode 100644 index 00000000000..9eca51ad2d9 --- /dev/null +++ b/mysql-test/r/rpl_ndb_auto_inc.result @@ -0,0 +1,185 @@ +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; +create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3; +insert into t1 values (NULL,1),(NULL,2),(NULL,3); +select * from t1; +a b +12 1 +22 2 +32 3 +select * from t1; +a b +12 1 +22 2 +32 3 +drop table t1; +create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam; +insert into t1 values (1,1),(NULL,2),(3,3),(NULL,4); +delete from t1 where b=4; +insert into t1 values (NULL,5),(NULL,6); +select * from t1; +a b +1 1 +2 2 +3 3 +22 5 +32 6 +select * from t1; +a b +1 1 +2 2 +3 3 +22 5 +32 6 +drop table t1; +set @@session.auto_increment_increment=100, @@session.auto_increment_offset=10; +show variables like "%auto_inc%"; +Variable_name Value +auto_increment_increment 100 +auto_increment_offset 10 +create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; +insert into t1 values (NULL),(5),(NULL); +insert into t1 values (250),(NULL); +select * from t1; +a +5 +10 +110 +250 +310 +insert into t1 values (1000); +set @@insert_id=400; +insert into t1 values(NULL),(NULL); +select * from t1; +a +5 +10 +110 +250 +310 +400 +410 +1000 +select * from t1; +a +5 +10 +110 +250 +310 +400 +410 +1000 +drop table t1; +create table t1 (a int not null auto_increment, primary key (a)) engine=innodb; +insert into t1 values (NULL),(5),(NULL); +insert into t1 values (250),(NULL); +select * from t1; +a +5 +10 +110 +250 +310 +insert into t1 values (1000); +set @@insert_id=400; +insert into t1 values(NULL),(NULL); +select * from t1; +a +5 +10 +110 +250 +310 +400 +410 +1000 +select * from t1; +a +5 +10 +110 +250 +310 +400 +410 +1000 +drop table t1; +set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1; +create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; +insert into t1 values (NULL),(5),(NULL),(NULL); +insert into t1 values (500),(NULL),(502),(NULL),(NULL); +select * from t1; +a +1 +5 +6 +7 +500 +501 +502 +503 +504 +set @@insert_id=600; +insert into t1 values(600),(NULL),(NULL); +ERROR 23000: Duplicate entry '600' for key 1 +set @@insert_id=600; +insert ignore into t1 values(600),(NULL),(NULL),(610),(NULL); +select * from t1; +a +1 +5 +6 +7 +500 +501 +502 +503 +504 +600 +610 +611 +select * from t1; +a +1 +5 +6 +7 +500 +501 +502 +503 +504 +600 +610 +611 +drop table t1; +set @@session.auto_increment_increment=10, @@session.auto_increment_offset=1; +create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; +insert into t1 values(2),(12),(22),(32),(42); +insert into t1 values (NULL),(NULL); +insert into t1 values (3),(NULL),(NULL); +select * from t1; +a +1 +3 +11 +21 +31 +select * from t1; +a +1 +2 +3 +11 +12 +21 +22 +31 +32 +42 +drop table t1; diff --git a/mysql-test/r/rpl_ndb_func003.result b/mysql-test/r/rpl_ndb_func003.result new file mode 100644 index 00000000000..ad72a3fb244 --- /dev/null +++ b/mysql-test/r/rpl_ndb_func003.result @@ -0,0 +1,29 @@ +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; +DROP FUNCTION IF EXISTS test.f1; +DROP TABLE IF EXISTS test.t1; +CREATE TABLE test.t1 (a INT NOT NULL AUTO_INCREMENT, c CHAR(16),PRIMARY KEY(a))ENGINE=NDB; +create function test.f1() RETURNS CHAR(16) +BEGIN +DECLARE tmp CHAR(16); +DECLARE var_name FLOAT; +SET var_name = RAND(); +IF var_name > .6 +THEN SET tmp = 'Texas'; +ELSE SET tmp = 'MySQL'; +END IF; +RETURN tmp; +END| +INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1()); +INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1()); +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO test.t1 VALUES (null,test.f1()); +ROLLBACK; +SET AUTOCOMMIT=1; +DROP FUNCTION test.f1; +DROP TABLE test.t1; diff --git a/mysql-test/r/rpl_ndb_log.result b/mysql-test/r/rpl_ndb_log.result new file mode 100644 index 00000000000..0bc3811ce05 --- /dev/null +++ b/mysql-test/r/rpl_ndb_log.result @@ -0,0 +1,145 @@ +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; +stop slave; +reset master; +reset slave; +reset master; +create table t1(n int not null auto_increment primary key)ENGINE=NDB; +insert into t1 values (NULL); +drop table t1; +create table t1 (word char(20) not null)ENGINE=NDB; +load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines; +select count(*) from t1; +count(*) +69 +drop table t1; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=NDB +master-bin.000001 # Query 1 # BEGIN +master-bin.000001 # Table_map 1 # cluster_replication.apply_status +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Query 1 # use `test`; drop table t1 +master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=NDB +master-bin.000001 # Query 1 # BEGIN +master-bin.000001 # Table_map 1 # cluster_replication.apply_status +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Query 1 # use `test`; drop table t1 +show binlog events from 102 limit 1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=NDB +show binlog events from 102 limit 2; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=NDB +master-bin.000001 # Query 1 # BEGIN +show binlog events from 102 limit 2,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Table_map 1 # cluster_replication.apply_status +flush logs; +create table t5 (a int)ENGINE=NDB; +drop table t5; +start slave; +flush logs; +stop slave; +create table t1 (n int)ENGINE=NDB; +insert into t1 values (1); +drop table t1; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=NDB +master-bin.000001 # Query 1 # BEGIN +master-bin.000001 # Table_map 1 # cluster_replication.apply_status +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Query 1 # use `test`; drop table t1 +master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=NDB +master-bin.000001 # Query 1 # BEGIN +master-bin.000001 # Table_map 1 # cluster_replication.apply_status +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Query 1 # use `test`; drop table t1 +master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 +show binlog events in 'master-bin.000002'; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 +master-bin.000002 # Query 1 # use `test`; create table t5 (a int)ENGINE=NDB +master-bin.000002 # Query 1 # BEGIN +master-bin.000002 # Table_map 1 # cluster_replication.apply_status +master-bin.000002 # Write_rows 1 # +master-bin.000002 # Query 1 # COMMIT +master-bin.000002 # Query 1 # use `test`; drop table t5 +master-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=NDB +master-bin.000002 # Query 1 # BEGIN +master-bin.000002 # Table_map 1 # cluster_replication.apply_status +master-bin.000002 # Write_rows 1 # +master-bin.000002 # Table_map 1 # test.t1 +master-bin.000002 # Write_rows 1 # +master-bin.000002 # Query 1 # COMMIT +master-bin.000002 # Query 1 # use `test`; drop table t1 +show binary logs; +Log_name File_size +master-bin.000001 1798 +master-bin.000002 991 +start slave; +show binary logs; +Log_name File_size +slave-bin.000001 2205 +slave-bin.000002 583 +show binlog events in 'slave-bin.000001' from 4; +Log_name Pos Event_type Server_id End_log_pos Info +slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 +slave-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=NDB +slave-bin.000001 # Query 2 # BEGIN +slave-bin.000001 # Table_map 2 # cluster_replication.apply_status +slave-bin.000001 # Write_rows 2 # +slave-bin.000001 # Table_map 2 # test.t1 +slave-bin.000001 # Write_rows 2 # +slave-bin.000001 # Query 2 # COMMIT +slave-bin.000001 # Query 1 # use `test`; drop table t1 +slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=NDB +slave-bin.000001 # Query 2 # BEGIN +slave-bin.000001 # Table_map 2 # cluster_replication.apply_status +slave-bin.000001 # Write_rows 2 # +slave-bin.000001 # Table_map 2 # test.t1 +slave-bin.000001 # Write_rows 2 # +slave-bin.000001 # Query 2 # COMMIT +slave-bin.000001 # Query 1 # use `test`; drop table t1 +slave-bin.000001 # Query 1 # use `test`; create table t5 (a int)ENGINE=NDB +slave-bin.000001 # Query 2 # BEGIN +slave-bin.000001 # Table_map 2 # cluster_replication.apply_status +slave-bin.000001 # Write_rows 2 # +slave-bin.000001 # Query 2 # COMMIT +slave-bin.000001 # Query 1 # use `test`; drop table t5 +slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4 +show binlog events in 'slave-bin.000002' from 4; +Log_name Pos Event_type Server_id End_log_pos Info +slave-bin.000002 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 +slave-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=NDB +slave-bin.000002 # Query 2 # BEGIN +slave-bin.000002 # Table_map 2 # cluster_replication.apply_status +slave-bin.000002 # Write_rows 2 # +slave-bin.000002 # Table_map 2 # test.t1 +slave-bin.000002 # Write_rows 2 # +slave-bin.000002 # Query 2 # COMMIT +slave-bin.000002 # Query 1 # 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 +# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 991 # # master-bin.000002 Yes Yes # 0 0 991 # 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_ndb_relay_space.result b/mysql-test/r/rpl_ndb_relay_space.result new file mode 100644 index 00000000000..1e25b7fe8c1 --- /dev/null +++ b/mysql-test/r/rpl_ndb_relay_space.result @@ -0,0 +1,25 @@ +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; +SHOW VARIABLES LIKE 'relay_log_space_limit'; +Variable_name Value +relay_log_space_limit 0 +CREATE TABLE t1 (name varchar(64), age smallint(3))ENGINE=NDB; +INSERT INTO t1 SET name='Andy', age=31; +INSERT t1 SET name='Jacob', age=2; +INSERT into t1 SET name='Caleb', age=1; +ALTER TABLE t1 ADD id int(8) ZEROFILL AUTO_INCREMENT PRIMARY KEY; +SELECT * FROM t1 ORDER BY id; +name age id +Andy 31 00000001 +Caleb 1 00000002 +Jacob 2 00000003 +SELECT * FROM t1 ORDER BY id; +name age id +Andy 31 00000001 +Caleb 1 00000002 +Jacob 2 00000003 +drop table t1; diff --git a/mysql-test/r/rpl_ndb_sync.result b/mysql-test/r/rpl_ndb_sync.result index 44d0efa7e5a..e17c9b99e12 100644 --- a/mysql-test/r/rpl_ndb_sync.result +++ b/mysql-test/r/rpl_ndb_sync.result @@ -25,8 +25,7 @@ hex(c2) hex(c3) c1 0 1 BCDEF 1 0 CD 0 0 DEFGHIJKL -CREATE TABLE IF NOT EXISTS cluster_replication.backup_info (id INT, backup_id INT); -DELETE FROM cluster_replication.backup_info; +CREATE TEMPORARY TABLE cluster_replication.backup_info (id INT, backup_id INT) ENGINE=HEAP; LOAD DATA INFILE '../../var/tmp.dat' INTO TABLE cluster_replication.backup_info FIELDS TERMINATED BY ','; SELECT @the_backup_id:=backup_id FROM cluster_replication.backup_info; @the_backup_id:=backup_id diff --git a/mysql-test/r/rpl_redirect.result b/mysql-test/r/rpl_redirect.result index 9dd51eaba4d..dd16626cbe3 100644 --- a/mysql-test/r/rpl_redirect.result +++ b/mysql-test/r/rpl_redirect.result @@ -12,26 +12,26 @@ Server_id Host Port Rpl_recovery_rank Master_id create table t1 ( n int); insert into t1 values (1),(2),(3),(4); insert into t1 values(5); -select * from t1; +SELECT * FROM t1 ORDER BY n; n 1 2 3 4 5 -select * from t1; +SELECT * FROM t1 ORDER BY n; n 1 2 3 4 -select * from t1; +SELECT * FROM t1 ORDER BY n; n 1 2 3 4 -select * from t1; +SELECT * FROM t1 ORDER BY n; n 1 2 @@ -39,4 +39,3 @@ n 4 5 drop table t1; -drop table t1; diff --git a/mysql-test/r/rpl000005.result b/mysql-test/r/rpl_relay_space_innodb.result index 2518c12aace..80d8c48c241 100644 --- a/mysql-test/r/rpl000005.result +++ b/mysql-test/r/rpl_relay_space_innodb.result @@ -7,7 +7,7 @@ start slave; SHOW VARIABLES LIKE 'relay_log_space_limit'; Variable_name Value relay_log_space_limit 0 -CREATE TABLE t1 (name varchar(64), age smallint(3)); +CREATE TABLE t1 (name varchar(64), age smallint(3))ENGINE=InnoDB; INSERT INTO t1 SET name='Andy', age=31; INSERT t1 SET name='Jacob', age=2; INSERT into t1 SET name='Caleb', age=1; diff --git a/mysql-test/r/rpl_relay_space_myisam.result b/mysql-test/r/rpl_relay_space_myisam.result new file mode 100644 index 00000000000..02bff7ae881 --- /dev/null +++ b/mysql-test/r/rpl_relay_space_myisam.result @@ -0,0 +1,25 @@ +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; +SHOW VARIABLES LIKE 'relay_log_space_limit'; +Variable_name Value +relay_log_space_limit 0 +CREATE TABLE t1 (name varchar(64), age smallint(3))ENGINE=MyISAM; +INSERT INTO t1 SET name='Andy', age=31; +INSERT t1 SET name='Jacob', age=2; +INSERT into t1 SET name='Caleb', age=1; +ALTER TABLE t1 ADD id int(8) ZEROFILL AUTO_INCREMENT PRIMARY KEY; +SELECT * FROM t1 ORDER BY id; +name age id +Andy 31 00000001 +Jacob 2 00000002 +Caleb 1 00000003 +SELECT * FROM t1 ORDER BY id; +name age id +Andy 31 00000001 +Jacob 2 00000002 +Caleb 1 00000003 +drop table t1; diff --git a/mysql-test/r/rpl_replicate_do.result b/mysql-test/r/rpl_replicate_do.result index 438671fb103..43e7c6779bf 100644 --- a/mysql-test/r/rpl_replicate_do.result +++ b/mysql-test/r/rpl_replicate_do.result @@ -9,14 +9,14 @@ drop table if exists t11; create table t2 (n int); insert into t2 values(4); create table t2 (s char(20)); -load data infile '../../std_data/words.dat' into table t2; +load data infile '../std_data_ln/words.dat' into table t2; insert into t2 values('five'); create table t1 (m int); insert into t1 values(15),(16),(17); update t1 set m=20 where m=16; delete from t1 where m=17; create table t11 select * from t1; -select * from t1; +select * from t1 ORDER BY m; m 15 20 @@ -40,3 +40,4 @@ set one_shot time_zone='met'; select * from t1; ts 2005-08-12 00:00:00 +drop table t1; diff --git a/mysql-test/r/rpl_rewrt_db.result b/mysql-test/r/rpl_rewrt_db.result index 6c72e982e3e..0c33ffc918f 100644 --- a/mysql-test/r/rpl_rewrt_db.result +++ b/mysql-test/r/rpl_rewrt_db.result @@ -24,7 +24,7 @@ drop database if exists rewrite; create database rewrite; use test; create table t1 (a date, b date, c date not null, d date); -load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ','; +load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ','; Warnings: Warning 1265 Data truncated for column 'a' at row 1 Warning 1265 Data truncated for column 'c' at row 1 @@ -32,7 +32,7 @@ Warning 1265 Data truncated for column 'd' at row 1 Warning 1265 Data truncated for column 'a' at row 2 Warning 1265 Data truncated for column 'b' at row 2 Warning 1265 Data truncated for column 'd' at row 2 -load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; +load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; select * from rewrite.t1; a b c d 0000-00-00 NULL 0000-00-00 0000-00-00 @@ -40,7 +40,7 @@ a b c d 2003-03-03 2003-03-03 2003-03-03 NULL 2003-03-03 2003-03-03 2003-03-03 NULL truncate table t1; -load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); +load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); Warnings: Warning 1265 Data truncated for column 'c' at row 1 Warning 1265 Data truncated for column 'd' at row 1 @@ -53,7 +53,7 @@ NULL 0000-00-00 0000-00-00 0000-00-00 NULL 2003-03-03 2003-03-03 NULL drop table t1; create table t1 (a text, b text); -load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; +load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; Warnings: Warning 1261 Row 3 doesn't contain data for all columns select concat('|',a,'|'), concat('|',b,'|') from rewrite.t1; @@ -65,7 +65,7 @@ Field 3,'Field 4| |Field 6| | 'Field 7'| drop table t1; create table t1 (a int, b char(10)); -load data infile '../../std_data/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; +load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; Warnings: Warning 1264 Out of range value for column 'a' at row 3 Warning 1262 Row 3 was truncated; it contained more data than there were input columns @@ -79,7 +79,7 @@ a b 3 row 3 0 1234567890 truncate table t1; -load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; +load data infile '../std_data_ln/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; Warnings: Warning 1264 Out of range value for column 'a' at row 4 Warning 1261 Row 4 doesn't contain data for all columns diff --git a/mysql-test/r/rpl_row_001.result b/mysql-test/r/rpl_row_001.result index 990ebbc5d7a..b07a99644fc 100644 --- a/mysql-test/r/rpl_row_001.result +++ b/mysql-test/r/rpl_row_001.result @@ -7,25 +7,25 @@ start slave; CREATE TABLE t1 (word CHAR(20) NOT NULL); LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/std_data/words.dat' INTO TABLE t1; -SELECT * FROM t1 LIMIT 10; +SELECT * FROM t1 ORDER BY word LIMIT 10; word Aarhus +Aarhus +Aarhus +Aarhus +Aaron Aaron +Aaron +Aaron +Ababa Ababa -aback -abaft -abandon -abandoned -abandoning -abandonment -abandons STOP SLAVE; SET PASSWORD FOR root@"localhost" = PASSWORD('foo'); START SLAVE; SET PASSWORD FOR root@"localhost" = PASSWORD(''); CREATE TABLE t3(n INT); INSERT INTO t3 VALUES(1),(2); -SELECT * FROM t3; +SELECT * FROM t3 ORDER BY n; n 1 2 diff --git a/mysql-test/r/rpl_row_UUID.result b/mysql-test/r/rpl_row_UUID.result index 06c81e28ef6..36aa3c625bb 100644 --- a/mysql-test/r/rpl_row_UUID.result +++ b/mysql-test/r/rpl_row_UUID.result @@ -35,4 +35,6 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP PROCEDURE test.p1; +DROP FUNCTION test.fn1; DROP TABLE test.t1; +DROP TABLE test.t2; diff --git a/mysql-test/r/rpl_row_basic_7ndb.result b/mysql-test/r/rpl_row_basic_7ndb.result index 634d5b2b5d5..ccf94a02ed8 100644 --- a/mysql-test/r/rpl_row_basic_7ndb.result +++ b/mysql-test/r/rpl_row_basic_7ndb.result @@ -392,11 +392,11 @@ DROP TABLE t7; CREATE TABLE t7 (a INT PRIMARY KEY, b INT UNIQUE, c INT UNIQUE) ENGINE = 'NDB' ; INSERT INTO t7 VALUES (99,99,99); INSERT INTO t7 VALUES (99,22,33); -ERROR 23000: Duplicate entry '99' for key 1 +ERROR 23000: Duplicate entry '99' for key 'PRIMARY' INSERT INTO t7 VALUES (11,99,33); -ERROR 23000: Duplicate entry '11' for key 1 +ERROR 23000: Duplicate entry '11' for key 'PRIMARY' INSERT INTO t7 VALUES (11,22,99); -ERROR 23000: Duplicate entry '11' for key 1 +ERROR 23000: Duplicate entry '11' for key 'PRIMARY' SELECT * FROM t7 ORDER BY a; a b c 99 99 99 diff --git a/mysql-test/r/rpl_row_blob_innodb.result b/mysql-test/r/rpl_row_blob_innodb.result index 92671f10ab9..b9dc831350b 100644 --- a/mysql-test/r/rpl_row_blob_innodb.result +++ b/mysql-test/r/rpl_row_blob_innodb.result @@ -9,7 +9,7 @@ DROP TABLE IF EXISTS test.t2; ***** Table Create Section **** CREATE TABLE test.t1 (c1 int not null auto_increment, -data LONGBLOB, PRIMARY KEY(c1))ENGINE=$engine_type; +data LONGBLOB, PRIMARY KEY(c1))ENGINE=#; **** Data Insert Section test.t1 ***** @@ -76,7 +76,7 @@ c1 INT NOT NULL PRIMARY KEY, c2 TEXT, c3 INT, c4 LONGBLOB, -KEY(c3))ENGINE=$engine_type; +KEY(c3))ENGINE=#; *** Setup Values For test.t2 *** set @x0 = '01234567012345670123456701234567'; diff --git a/mysql-test/r/rpl_row_blob_myisam.result b/mysql-test/r/rpl_row_blob_myisam.result index 92671f10ab9..b9dc831350b 100644 --- a/mysql-test/r/rpl_row_blob_myisam.result +++ b/mysql-test/r/rpl_row_blob_myisam.result @@ -9,7 +9,7 @@ DROP TABLE IF EXISTS test.t2; ***** Table Create Section **** CREATE TABLE test.t1 (c1 int not null auto_increment, -data LONGBLOB, PRIMARY KEY(c1))ENGINE=$engine_type; +data LONGBLOB, PRIMARY KEY(c1))ENGINE=#; **** Data Insert Section test.t1 ***** @@ -76,7 +76,7 @@ c1 INT NOT NULL PRIMARY KEY, c2 TEXT, c3 INT, c4 LONGBLOB, -KEY(c3))ENGINE=$engine_type; +KEY(c3))ENGINE=#; *** Setup Values For test.t2 *** set @x0 = '01234567012345670123456701234567'; diff --git a/mysql-test/r/rpl_row_flsh_tbls.result b/mysql-test/r/rpl_row_flsh_tbls.result index 503fcc7a368..e2352b8605b 100644 --- a/mysql-test/r/rpl_row_flsh_tbls.result +++ b/mysql-test/r/rpl_row_flsh_tbls.result @@ -30,3 +30,4 @@ flush tables with read lock; start slave; stop slave; ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction +drop table t3, t4, t5; diff --git a/mysql-test/r/rpl_row_log.result b/mysql-test/r/rpl_row_log.result index 8784d9d16e2..a5317975302 100644 --- a/mysql-test/r/rpl_row_log.result +++ b/mysql-test/r/rpl_row_log.result @@ -8,11 +8,11 @@ stop slave; reset master; reset slave; reset master; -create table t1(n int not null auto_increment primary key); +create table t1(n int not null auto_increment primary key)ENGINE=MyISAM; insert into t1 values (NULL); drop table t1; -create table t1 (word char(20) not null); -load data infile '../../std_data/words.dat' into table t1 ignore 1 lines; +create table t1 (word char(20) not null)ENGINE=MyISAM; +load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines; select count(*) from t1; count(*) 69 @@ -20,41 +20,41 @@ drop table t1; show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 -master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM master-bin.000001 # Table_map 1 # test.t1 master-bin.000001 # Write_rows 1 # master-bin.000001 # Query 1 # use `test`; drop table t1 -master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null) +master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM master-bin.000001 # Table_map 1 # test.t1 master-bin.000001 # Write_rows 1 # master-bin.000001 # Query 1 # use `test`; drop table t1 show binlog events from 102 limit 1; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM show binlog events from 102 limit 2; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM master-bin.000001 # Table_map 1 # test.t1 show binlog events from 102 limit 2,1; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Write_rows 1 # flush logs; -create table t5 (a int); +create table t5 (a int)ENGINE=MyISAM; drop table t5; start slave; flush logs; stop slave; -create table t1 (n int); +create table t1 (n int)ENGINE=MyISAM; insert into t1 values (1); drop table t1; show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 -master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM master-bin.000001 # Table_map 1 # test.t1 master-bin.000001 # Write_rows 1 # master-bin.000001 # Query 1 # use `test`; drop table t1 -master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null) +master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM master-bin.000001 # Table_map 1 # test.t1 master-bin.000001 # Write_rows 1 # master-bin.000001 # Query 1 # use `test`; drop table t1 @@ -62,44 +62,44 @@ master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 show binlog events in 'master-bin.000002'; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000002 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 -master-bin.000002 # Query 1 # use `test`; create table t5 (a int) +master-bin.000002 # Query 1 # use `test`; create table t5 (a int)ENGINE=MyISAM master-bin.000002 # Query 1 # use `test`; drop table t5 -master-bin.000002 # Query 1 # use `test`; create table t1 (n int) +master-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=MyISAM master-bin.000002 # Table_map 1 # test.t1 master-bin.000002 # Write_rows 1 # master-bin.000002 # Query 1 # use `test`; drop table t1 show binary logs; Log_name File_size -master-bin.000001 1306 -master-bin.000002 499 +master-bin.000001 1332 +master-bin.000002 525 start slave; show binary logs; Log_name File_size -slave-bin.000001 1467 -slave-bin.000002 337 +slave-bin.000001 1506 +slave-bin.000002 350 show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 -slave-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key) +slave-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM slave-bin.000001 # Table_map 1 # test.t1 slave-bin.000001 # Write_rows 1 # slave-bin.000001 # Query 1 # use `test`; drop table t1 -slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null) +slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM slave-bin.000001 # Table_map 1 # test.t1 slave-bin.000001 # Write_rows 1 # slave-bin.000001 # Query 1 # use `test`; drop table t1 -slave-bin.000001 # Query 1 # use `test`; create table t5 (a int) +slave-bin.000001 # Query 1 # use `test`; create table t5 (a int)ENGINE=MyISAM slave-bin.000001 # Query 1 # use `test`; drop table t5 slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4 show binlog events in 'slave-bin.000002' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000002 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 -slave-bin.000002 # Query 1 # use `test`; create table t1 (n int) +slave-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=MyISAM slave-bin.000002 # Table_map 1 # test.t1 slave-bin.000002 # Write_rows 1 # slave-bin.000002 # Query 1 # 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 -# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 499 # # master-bin.000002 Yes Yes # 0 0 499 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 525 # # master-bin.000002 Yes Yes # 0 0 525 # 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_row_log_innodb.result b/mysql-test/r/rpl_row_log_innodb.result new file mode 100644 index 00000000000..52b5219cf43 --- /dev/null +++ b/mysql-test/r/rpl_row_log_innodb.result @@ -0,0 +1,113 @@ +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; +stop slave; +reset master; +reset slave; +reset master; +create table t1(n int not null auto_increment primary key)ENGINE=InnoDB; +insert into t1 values (NULL); +drop table t1; +create table t1 (word char(20) not null)ENGINE=InnoDB; +load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines; +select count(*) from t1; +count(*) +69 +drop table t1; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB +master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Xid 1 # COMMIT /* XID */ +master-bin.000001 # Query 1 # use `test`; drop table t1 +master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=InnoDB +master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Xid 1 # COMMIT /* XID */ +master-bin.000001 # Query 1 # use `test`; drop table t1 +show binlog events from 102 limit 1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB +show binlog events from 102 limit 2; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB +master-bin.000001 # Table_map 1 # test.t1 +show binlog events from 102 limit 2,1; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Write_rows 1 # +flush logs; +create table t5 (a int)ENGINE=InnoDB; +drop table t5; +start slave; +flush logs; +stop slave; +create table t1 (n int)ENGINE=InnoDB; +insert into t1 values (1); +drop table t1; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB +master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Xid 1 # COMMIT /* XID */ +master-bin.000001 # Query 1 # use `test`; drop table t1 +master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=InnoDB +master-bin.000001 # Table_map 1 # test.t1 +master-bin.000001 # Write_rows 1 # +master-bin.000001 # Xid 1 # COMMIT /* XID */ +master-bin.000001 # Query 1 # use `test`; drop table t1 +master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 +show binlog events in 'master-bin.000002'; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 +master-bin.000002 # Query 1 # use `test`; create table t5 (a int)ENGINE=InnoDB +master-bin.000002 # Query 1 # use `test`; drop table t5 +master-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=InnoDB +master-bin.000002 # Table_map 1 # test.t1 +master-bin.000002 # Write_rows 1 # +master-bin.000002 # Xid 1 # COMMIT /* XID */ +master-bin.000002 # Query 1 # use `test`; drop table t1 +show binary logs; +Log_name File_size +master-bin.000001 1386 +master-bin.000002 552 +start slave; +show binary logs; +Log_name File_size +slave-bin.000001 1560 +slave-bin.000002 377 +show binlog events in 'slave-bin.000001' from 4; +Log_name Pos Event_type Server_id End_log_pos Info +slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 +slave-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB +slave-bin.000001 # Table_map 1 # test.t1 +slave-bin.000001 # Write_rows 1 # +slave-bin.000001 # Xid 1 # COMMIT /* XID */ +slave-bin.000001 # Query 1 # use `test`; drop table t1 +slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=InnoDB +slave-bin.000001 # Table_map 1 # test.t1 +slave-bin.000001 # Write_rows 1 # +slave-bin.000001 # Xid 1 # COMMIT /* XID */ +slave-bin.000001 # Query 1 # use `test`; drop table t1 +slave-bin.000001 # Query 1 # use `test`; create table t5 (a int)ENGINE=InnoDB +slave-bin.000001 # Query 1 # use `test`; drop table t5 +slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4 +show binlog events in 'slave-bin.000002' from 4; +Log_name Pos Event_type Server_id End_log_pos Info +slave-bin.000002 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 +slave-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=InnoDB +slave-bin.000002 # Table_map 1 # test.t1 +slave-bin.000002 # Write_rows 1 # +slave-bin.000002 # Xid 1 # COMMIT /* XID */ +slave-bin.000002 # Query 1 # 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 +# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 552 # # master-bin.000002 Yes Yes # 0 0 552 # 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_row_sp001.result b/mysql-test/r/rpl_row_sp001.result index 0276fb721b9..8c26c061376 100644 --- a/mysql-test/r/rpl_row_sp001.result +++ b/mysql-test/r/rpl_row_sp001.result @@ -28,52 +28,52 @@ UPDATE test.t2 set t ='NONE'; END CASE; end// INSERT INTO test.t2 VALUES(NULL,'NEW'),(NULL,'NEW'),(NULL,'NEW'),(NULL,'NEW'); -select * from test.t2; +SELECT * FROM t2 ORDER BY a; a t 1 NEW 2 NEW 3 NEW 4 NEW -select * from test.t2; +SELECT * FROM t2 ORDER BY a; a t 1 NEW 2 NEW 3 NEW 4 NEW call test.p2(1); -select * from test.t2; +SELECT * FROM t2 ORDER BY a; a t 1 Tex 2 Tex 3 Tex 4 Tex -select * from test.t2; +SELECT * FROM t2 ORDER BY a; a t 1 Tex 2 Tex 3 Tex 4 Tex call test.p2(2); -select * from test.t2; +SELECT * FROM t2 ORDER BY a; a t 1 SQL 2 SQL 3 SQL 4 SQL -select * from test.t2; +SELECT * FROM t2 ORDER BY a; a t 1 SQL 2 SQL 3 SQL 4 SQL call test.p2(3); -select * from test.t2; +SELECT * FROM t2 ORDER BY a; a t 1 NONE 2 NONE 3 NONE 4 NONE -select * from test.t2; +SELECT * FROM t2 ORDER BY a; a t 1 NONE 2 NONE diff --git a/mysql-test/r/rpl_row_sp005.result b/mysql-test/r/rpl_row_sp005.result index 24d68f3af3d..01e1970e0df 100644 --- a/mysql-test/r/rpl_row_sp005.result +++ b/mysql-test/r/rpl_row_sp005.result @@ -17,8 +17,8 @@ BEGIN DECLARE done INT DEFAULT 0; DECLARE spa CHAR(16); DECLARE spb,spc INT; -DECLARE cur1 CURSOR FOR SELECT id,data FROM test.t1; -DECLARE cur2 CURSOR FOR SELECT id2 FROM test.t2; +DECLARE cur1 CURSOR FOR SELECT id,data FROM test.t1 ORDER BY id; +DECLARE cur2 CURSOR FOR SELECT id2 FROM test.t2 ORDER BY id2; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; OPEN cur1; OPEN cur2; @@ -46,13 +46,13 @@ END| < ---- Master selects-- > ------------------------- CALL test.p2(); -SELECT * FROM test.t1; +SELECT * FROM test.t1 ORDER BY id; id data 8 MySQL -20 ROCKS -11 Texas 10 kyle -SELECT * FROM test.t2; +11 Texas +20 ROCKS +SELECT * FROM test.t2 ORDER BY id2; id2 1 2 @@ -61,13 +61,13 @@ id2 < ---- Slave selects-- > ------------------------ -SELECT * FROM test.t1; +SELECT * FROM test.t1 ORDER BY id; id data 8 MySQL -20 ROCKS -11 Texas 10 kyle -SELECT * FROM test.t2; +11 Texas +20 ROCKS +SELECT * FROM test.t2 ORDER BY id2; id2 1 2 @@ -77,21 +77,21 @@ id2 < ---- Master selects-- > ------------------------- CALL test.p1(); -SELECT * FROM test.t3; +SELECT * FROM test.t3 ORDER BY id3; id3 c 1 MySQL -2 ROCKS +2 kyle 3 Texas -4 kyle +4 ROCKS < ---- Slave selects-- > ------------------------ -SELECT * FROM test.t3; +SELECT * FROM test.t3 ORDER BY id3; id3 c 1 MySQL -2 ROCKS +2 kyle 3 Texas -4 kyle +4 ROCKS ALTER PROCEDURE test.p1 MODIFIES SQL DATA; DROP PROCEDURE IF EXISTS test.p1; DROP PROCEDURE IF EXISTS test.p2; diff --git a/mysql-test/r/rpl_row_sp009.result b/mysql-test/r/rpl_row_sp009.result index 8073e506ade..35ce0d7b420 100644 --- a/mysql-test/r/rpl_row_sp009.result +++ b/mysql-test/r/rpl_row_sp009.result @@ -49,28 +49,28 @@ END; END IF; END| CALL test.p1('a'); -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; a 1 3 -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; a 1 3 truncate test.t2; call test.p1('b'); -select * from test.t2; +select * from test.t2 ORDER BY a; a 2 4 -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; a 2 4 truncate test.t2; -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; a -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; a DROP PROCEDURE test.p1; DROP TABLE test.t1; diff --git a/mysql-test/r/rpl_row_trig001.result b/mysql-test/r/rpl_row_trig001.result index dcbb05e4ab4..6665dc6d555 100644 --- a/mysql-test/r/rpl_row_trig001.result +++ b/mysql-test/r/rpl_row_trig001.result @@ -22,6 +22,7 @@ END// <End test section 2 (Tiggers & SP)> ----------------------------------- DROP PROCEDURE test.p2; +DROP PROCEDURE test.p3; DROP TRIGGER test.t2_ai; DROP TRIGGER test.t3_bi_t2; DROP TABLE test.t1; diff --git a/mysql-test/r/rpl_row_trig002.result b/mysql-test/r/rpl_row_trig002.result index 62dc2f17562..794104db750 100644 --- a/mysql-test/r/rpl_row_trig002.result +++ b/mysql-test/r/rpl_row_trig002.result @@ -13,14 +13,14 @@ CREATE TABLE test.t3 (value CHAR(30),domain_id INT, mailaccount_id INT, program CREATE TABLE test.t1 (id INT,domain CHAR(30),PRIMARY KEY(id)); CREATE TRIGGER test.t2_ai AFTER INSERT ON test.t2 FOR EACH ROW UPDATE test.t3 ms, test.t1 d SET ms.value='No' WHERE ms.domain_id = (SELECT max(id) FROM test.t1 WHERE domain='example.com') AND ms.mailaccount_id IS NULL AND ms.program='spamfilter' AND ms.keey='scan_incoming'| INSERT INTO test.t1 VALUES (1, 'example.com'),(2, 'mysql.com'),(3, 'earthmotherwear.com'), (4, 'yahoo.com'),(5, 'example.com'); -select * from test.t1; +SELECT * FROM test.t1 ORDER BY id; id domain 1 example.com 2 mysql.com 3 earthmotherwear.com 4 yahoo.com 5 example.com -select * from test.t1; +SELECT * FROM test.t1 ORDER BY id; id domain 1 example.com 2 mysql.com @@ -45,13 +45,19 @@ value domain_id mailaccount_id program keey No 5 NULL spamfilter scan_incoming Yes 1 NULL spamfilter scan_incoming DELETE FROM test.t1 WHERE id = 1; -select * from test.t1; +SELECT * FROM test.t1 ORDER BY id; id domain 2 mysql.com 3 earthmotherwear.com 4 yahoo.com 5 example.com -select * from test.t1; +SELECT * FROM test.t1 ORDER BY id; +id domain +2 mysql.com +3 earthmotherwear.com +4 yahoo.com +5 example.com +SELECT * FROM test.t1 ORDER BY id; id domain 2 mysql.com 3 earthmotherwear.com diff --git a/mysql-test/r/rpl_row_view01.result b/mysql-test/r/rpl_row_view01.result index 039d14d6272..0006ec99f5e 100644 --- a/mysql-test/r/rpl_row_view01.result +++ b/mysql-test/r/rpl_row_view01.result @@ -21,15 +21,15 @@ CREATE TABLE mysqltest1.t5 (qty INT, price INT, total INT, PRIMARY KEY(qty)); INSERT INTO mysqltest1.t1 VALUES (1,'Thank'),(2,'it'),(3,'Friday'); INSERT INTO mysqltest1.t2 VALUES (1,'GOD'),(2,'is'),(3,'TGIF'); INSERT INTO mysqltest1.t4 VALUES(1, 3, 50),(2, 18, 3),(4, 4, 4); -CREATE VIEW mysqltest1.v2 AS SELECT qty, price, qty*price AS value FROM mysqltest1.t4; -CREATE VIEW mysqltest1.v1 AS SELECT t1.a, t1.c, t2.c as c2 FROM mysqltest1.t1 as t1, mysqltest1.t2 AS t2 WHERE mysqltest1.t1.a = mysqltest1.t2.a; +CREATE VIEW mysqltest1.v2 AS SELECT qty, price, qty*price AS value FROM mysqltest1.t4 ORDER BY qty; +CREATE VIEW mysqltest1.v1 AS SELECT t1.a, t1.c, t2.c as c2 FROM mysqltest1.t1 as t1, mysqltest1.t2 AS t2 WHERE mysqltest1.t1.a = mysqltest1.t2.a ORDER BY a; CREATE VIEW mysqltest1.v3 AS SELECT * FROM mysqltest1.t1; CREATE VIEW mysqltest1.v4 AS SELECT * FROM mysqltest1.v3 WHERE a > 1 WITH LOCAL CHECK OPTION; SELECT * FROM mysqltest1.v2; qty price value 3 50 150 -18 3 54 4 4 16 +18 3 54 SELECT * FROM mysqltest1.v1; a c c2 1 Thank GOD @@ -38,8 +38,8 @@ a c c2 SELECT * FROM mysqltest1.v2; qty price value 3 50 150 -18 3 54 4 4 16 +18 3 54 SELECT * FROM mysqltest1.v1; a c c2 1 Thank GOD @@ -47,45 +47,45 @@ a c c2 3 Friday TGIF INSERT INTO mysqltest1.t5 SELECT * FROM mysqltest1.v2; INSERT INTO mysqltest1.t3 SELECT * FROM mysqltest1.v1; -SELECT * FROM mysqltest1.t5; +SELECT * FROM mysqltest1.t5 ORDER BY qty; qty price total 3 50 150 -18 3 54 4 4 16 -SELECT * FROM mysqltest1.t3; +18 3 54 +SELECT * FROM mysqltest1.t3 ORDER BY a; a c c2 1 Thank GOD 2 it is 3 Friday TGIF -SELECT * FROM mysqltest1.t5; +SELECT * FROM mysqltest1.t5 ORDER BY qty; qty price total 3 50 150 -18 3 54 4 4 16 -SELECT * FROM mysqltest1.t3; +18 3 54 +SELECT * FROM mysqltest1.t3 ORDER BY a; a c c2 1 Thank GOD 2 it is 3 Friday TGIF INSERT INTO mysqltest1.v4 VALUES (4,'TEST'); -SELECT * FROM mysqltest1.t1; +SELECT * FROM mysqltest1.t1 ORDER BY a; a c 1 Thank 2 it 3 Friday 4 TEST -SELECT * FROM mysqltest1.v4; +SELECT * FROM mysqltest1.v4 ORDER BY a; a c 2 it 3 Friday 4 TEST -SELECT * FROM mysqltest1.t1; +SELECT * FROM mysqltest1.t1 ORDER BY a; a c 1 Thank 2 it 3 Friday 4 TEST -SELECT * FROM mysqltest1.v4; +SELECT * FROM mysqltest1.v4 ORDER BY a; a c 2 it 3 Friday diff --git a/mysql-test/r/rpl_skip_error.result b/mysql-test/r/rpl_skip_error.result index e52426c381c..248ce5b52c3 100644 --- a/mysql-test/r/rpl_skip_error.result +++ b/mysql-test/r/rpl_skip_error.result @@ -8,8 +8,9 @@ create table t1 (n int not null primary key); insert into t1 values (1); insert into t1 values (1); insert into t1 values (2),(3); -select * from t1; +select * from t1 ORDER BY n; n 1 2 3 +drop table t1; diff --git a/mysql-test/r/rpl_slave_status.result b/mysql-test/r/rpl_slave_status.result index 2146132aeb0..641a65f5ed7 100644 --- a/mysql-test/r/rpl_slave_status.result +++ b/mysql-test/r/rpl_slave_status.result @@ -52,3 +52,5 @@ Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master NULL +drop table t1; +drop table t1; diff --git a/mysql-test/r/rpl_sporadic_master.result b/mysql-test/r/rpl_sporadic_master.result index 789c3bf2b2b..14fb673a081 100644 --- a/mysql-test/r/rpl_sporadic_master.result +++ b/mysql-test/r/rpl_sporadic_master.result @@ -15,7 +15,7 @@ insert into t1 values (NULL),(NULL); flush logs; truncate table t1; insert into t1 values (10),(NULL),(NULL),(NULL),(NULL),(NULL); -select * from t1; +select * from t1 ORDER BY n; n 10 11 diff --git a/mysql-test/r/rpl_stm_000001.result b/mysql-test/r/rpl_stm_000001.result index de9f6f16b2a..ef4226e07b5 100644 --- a/mysql-test/r/rpl_stm_000001.result +++ b/mysql-test/r/rpl_stm_000001.result @@ -5,7 +5,7 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; create table t1 (word char(20) not null); -load data infile '../../std_data/words.dat' into table t1; +load data infile '../std_data_ln/words.dat' into table t1; load data local infile 'MYSQL_TEST_DIR/std_data/words.dat' into table t1; select * from t1 limit 10; word @@ -79,3 +79,4 @@ select select_priv,user from mysql.user where user = _binary'blafasel2'; select_priv user Y blafasel2 drop table t1; +delete from mysql.user where user="blafasel2"; diff --git a/mysql-test/r/rpl_stm_EE_err2.result b/mysql-test/r/rpl_stm_EE_err2.result index fa1ce0ae0e6..13aa45d8ced 100644 --- a/mysql-test/r/rpl_stm_EE_err2.result +++ b/mysql-test/r/rpl_stm_EE_err2.result @@ -9,5 +9,5 @@ set sql_log_bin=0; insert into t1 values(2); set sql_log_bin=1; insert into t1 values(1),(2); -ERROR 23000: Duplicate entry '2' for key 1 +ERROR 23000: Duplicate entry '2' for key 'a' drop table t1; diff --git a/mysql-test/r/rpl_stm_flsh_tbls.result b/mysql-test/r/rpl_stm_flsh_tbls.result index 8a813c57451..a6123d75cb3 100644 --- a/mysql-test/r/rpl_stm_flsh_tbls.result +++ b/mysql-test/r/rpl_stm_flsh_tbls.result @@ -30,3 +30,4 @@ flush tables with read lock; start slave; stop slave; ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction +drop table t3, t4, t5; diff --git a/mysql-test/r/rpl_stm_log.result b/mysql-test/r/rpl_stm_log.result index a7ef117854d..d9713660dbb 100644 --- a/mysql-test/r/rpl_stm_log.result +++ b/mysql-test/r/rpl_stm_log.result @@ -8,11 +8,11 @@ stop slave; reset master; reset slave; reset master; -create table t1(n int not null auto_increment primary key); +create table t1(n int not null auto_increment primary key)ENGINE=MyISAM; insert into t1 values (NULL); drop table t1; -create table t1 (word char(20) not null); -load data infile '../../std_data/words.dat' into table t1 ignore 1 lines; +create table t1 (word char(20) not null)ENGINE=MyISAM; +load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines; select count(*) from t1; count(*) 69 @@ -20,84 +20,84 @@ drop table t1; show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 -master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM master-bin.000001 # Intvar 1 # INSERT_ID=1 master-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL) master-bin.000001 # Query 1 # use `test`; drop table t1 -master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null) +master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM master-bin.000001 # Begin_load_query 1 # ;file_id=1;block_len=581 -master-bin.000001 # Execute_load_query 1 # use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1 +master-bin.000001 # Execute_load_query 1 # use `test`; load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines ;file_id=1 master-bin.000001 # Query 1 # use `test`; drop table t1 show binlog events from 102 limit 1; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM show binlog events from 102 limit 2; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM master-bin.000001 # Intvar 1 # INSERT_ID=1 show binlog events from 102 limit 2,1; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL) flush logs; -create table t5 (a int); +create table t5 (a int)ENGINE=MyISAM; drop table t5; start slave; flush logs; stop slave; -create table t1 (n int); +create table t1 (n int)ENGINE=MyISAM; insert into t1 values (1); drop table t1; show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 -master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key) +master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM master-bin.000001 # Intvar 1 # INSERT_ID=1 master-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL) master-bin.000001 # Query 1 # use `test`; drop table t1 -master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null) +master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM master-bin.000001 # Begin_load_query 1 # ;file_id=1;block_len=581 -master-bin.000001 # Execute_load_query 1 # use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1 +master-bin.000001 # Execute_load_query 1 # use `test`; load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines ;file_id=1 master-bin.000001 # Query 1 # use `test`; drop table t1 master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 show binlog events in 'master-bin.000002'; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000002 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 -master-bin.000002 # Query 1 # use `test`; create table t5 (a int) +master-bin.000002 # Query 1 # use `test`; create table t5 (a int)ENGINE=MyISAM master-bin.000002 # Query 1 # use `test`; drop table t5 -master-bin.000002 # Query 1 # use `test`; create table t1 (n int) +master-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=MyISAM master-bin.000002 # Query 1 # use `test`; insert into t1 values (1) master-bin.000002 # Query 1 # use `test`; drop table t1 show binary logs; Log_name File_size -master-bin.000001 1393 -master-bin.000002 514 +master-bin.000001 1419 +master-bin.000002 540 start slave; show binary logs; Log_name File_size -slave-bin.000001 1563 -slave-bin.000002 352 +slave-bin.000001 1595 +slave-bin.000002 365 show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 -slave-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key) +slave-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM slave-bin.000001 # Intvar 1 # INSERT_ID=1 slave-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL) slave-bin.000001 # Query 1 # use `test`; drop table t1 -slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null) +slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM slave-bin.000001 # Begin_load_query 1 # ;file_id=1;block_len=581 -slave-bin.000001 # Execute_load_query 1 # use `test`; load data INFILE '../../var/tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1 +slave-bin.000001 # Execute_load_query 1 # use `test`; load data INFILE '../tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1 slave-bin.000001 # Query 1 # use `test`; drop table t1 -slave-bin.000001 # Query 1 # use `test`; create table t5 (a int) +slave-bin.000001 # Query 1 # use `test`; create table t5 (a int)ENGINE=MyISAM slave-bin.000001 # Query 1 # use `test`; drop table t5 slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4 show binlog events in 'slave-bin.000002' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000002 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 -slave-bin.000002 # Query 1 # use `test`; create table t1 (n int) +slave-bin.000002 # Query 1 # use `test`; create table t1 (n int)ENGINE=MyISAM slave-bin.000002 # Query 1 # use `test`; insert into t1 values (1) slave-bin.000002 # Query 1 # 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 -# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 514 # # master-bin.000002 Yes Yes # 0 0 514 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 540 # # master-bin.000002 Yes Yes # 0 0 540 # 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_000012.result b/mysql-test/r/rpl_temp_table.result index e4ca31d8908..e4ca31d8908 100644 --- a/mysql-test/r/rpl_000012.result +++ b/mysql-test/r/rpl_temp_table.result diff --git a/mysql-test/r/rpl_temporary.result b/mysql-test/r/rpl_temporary.result index a7dbfd44944..5e3030f2c7a 100644 --- a/mysql-test/r/rpl_temporary.result +++ b/mysql-test/r/rpl_temporary.result @@ -32,7 +32,7 @@ insert into t3 select * from t1 where f>=4; drop temporary table t3; insert into t2 select count(*) from t3; drop temporary table t3; -select * from t2; +select * from t2 ORDER BY f; f 5 7 @@ -68,7 +68,7 @@ insert into t2 select count(*) from t3; SET TIMESTAMP=1040324224; SET @@session.pseudo_thread_id=2; drop temporary table t3; -select * from t2; +select * from t2 ORDER BY f; f 5 7 diff --git a/mysql-test/r/rpl_timezone.result b/mysql-test/r/rpl_timezone.result index 78e76d168f0..4ad6afa8c94 100644 --- a/mysql-test/r/rpl_timezone.result +++ b/mysql-test/r/rpl_timezone.result @@ -41,7 +41,7 @@ t n 2004-06-11 09:39:02 6 delete from t1; set time_zone='UTC'; -load data infile '../../std_data/rpl_timezone2.dat' into table t1; +load data infile '../std_data_ln/rpl_timezone2.dat' into table t1; Warnings: Warning 1265 Data truncated for column 't' at row 1 Warning 1261 Row 1 doesn't contain data for all columns diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 960c389eee2..38dba8019a5 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -32,7 +32,7 @@ t1 0 PRIMARY 1 a A 5 NULL NULL BTREE t1 1 b 1 b A 1 NULL NULL BTREE t1 1 b 2 c A 5 NULL NULL BTREE insert into t1 values (5,5,5); -ERROR 23000: Duplicate entry '5' for key 1 +ERROR 23000: Duplicate entry '5' for key 'PRIMARY' optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK diff --git a/mysql-test/r/sp-code.result b/mysql-test/r/sp-code.result index 943471c2261..4156b351281 100644 --- a/mysql-test/r/sp-code.result +++ b/mysql-test/r/sp-code.result @@ -1,3 +1,5 @@ +drop procedure if exists empty; +drop procedure if exists code_sample; create procedure empty() begin end; @@ -60,3 +62,140 @@ Pos Instruction 20 cpop 1 21 stmt 0 "select t.name, t.idx from t2 t order ..." drop procedure code_sample; +drop procedure if exists sudoku_solve; +create procedure sudoku_solve(p_naive boolean, p_all boolean) +deterministic +modifies sql data +begin +drop temporary table if exists sudoku_work, sudoku_schedule; +create temporary table sudoku_work +( +row smallint not null, +col smallint not null, +dig smallint not null, +cnt smallint, +key using btree (cnt), +key using btree (row), +key using btree (col), +unique key using hash (row,col) +); +create temporary table sudoku_schedule +( +idx int not null auto_increment primary key, +row smallint not null, +col smallint not null +); +call sudoku_init(); +if p_naive then +update sudoku_work set cnt = 0 where dig = 0; +else +call sudoku_count(); +end if; +insert into sudoku_schedule (row,col) +select row,col from sudoku_work where cnt is not null order by cnt desc; +begin +declare v_scounter bigint default 0; +declare v_i smallint default 1; +declare v_dig smallint; +declare v_schedmax smallint; +select count(*) into v_schedmax from sudoku_schedule; +more: +loop +begin +declare v_tcounter bigint default 0; +sched: +while v_i <= v_schedmax do +begin +declare v_row, v_col smallint; +select row,col into v_row,v_col from sudoku_schedule where v_i = idx; +select dig into v_dig from sudoku_work +where v_row = row and v_col = col; +case v_dig +when 0 then +set v_dig = 1; +update sudoku_work set dig = 1 +where v_row = row and v_col = col; +when 9 then +if v_i > 0 then +update sudoku_work set dig = 0 +where v_row = row and v_col = col; +set v_i = v_i - 1; +iterate sched; +else +select v_scounter as 'Solutions'; +leave more; +end if; +else +set v_dig = v_dig + 1; +update sudoku_work set dig = v_dig +where v_row = row and v_col = col; +end case; +set v_tcounter = v_tcounter + 1; +if not sudoku_digit_ok(v_row, v_col, v_dig) then +iterate sched; +end if; +set v_i = v_i + 1; +end; +end while sched; +select dig from sudoku_work; +select v_tcounter as 'Tests'; +set v_scounter = v_scounter + 1; +if p_all and v_i > 0 then +set v_i = v_i - 1; +else +leave more; +end if; +end; +end loop more; +end; +drop temporary table sudoku_work, sudoku_schedule; +end// +show procedure code sudoku_solve; +Pos Instruction +0 stmt 9 "drop temporary table if exists sudoku..." +1 stmt 1 "create temporary table sudoku_work ( ..." +2 stmt 1 "create temporary table sudoku_schedul..." +3 stmt 94 "call sudoku_init(" +4 jump_if_not 7(8) p_naive@0 +5 stmt 4 "update sudoku_work set cnt = 0 where ..." +6 jump 8 +7 stmt 94 "call sudoku_count(" +8 stmt 6 "insert into sudoku_schedule (row,col)..." +9 set v_scounter@2 0 +10 set v_i@3 1 +11 set v_dig@4 NULL +12 set v_schedmax@5 NULL +13 stmt 0 "select count(*) into v_schedmax from ..." +14 set v_tcounter@6 0 +15 jump_if_not 39(39) (v_i@3 <= v_schedmax@5) +16 set v_row@7 NULL +17 set v_col@8 NULL +18 stmt 0 "select row,col into v_row,v_col from ..." +19 stmt 0 "select dig into v_dig from sudoku_wor..." +20 set_case_expr (34) 0 v_dig@4 +21 jump_if_not 25(34) (case_expr@0 = 0) +22 set v_dig@4 1 +23 stmt 4 "update sudoku_work set dig = 1 where ..." +24 jump 34 +25 jump_if_not 32(34) (case_expr@0 = 9) +26 jump_if_not 30(34) (v_i@3 > 0) +27 stmt 4 "update sudoku_work set dig = 0 where ..." +28 set v_i@3 (v_i@3 - 1) +29 jump 15 +30 stmt 0 "select v_scounter as 'Solutions'" +31 jump 45 +32 set v_dig@4 (v_dig@4 + 1) +33 stmt 4 "update sudoku_work set dig = v_dig wh..." +34 set v_tcounter@6 (v_tcounter@6 + 1) +35 jump_if_not 37(37) not(`test`.`sudoku_digit_ok`(v_row@7,v_col@8,v_dig@4)) +36 jump 15 +37 set v_i@3 (v_i@3 + 1) +38 jump 15 +39 stmt 0 "select dig from sudoku_work" +40 stmt 0 "select v_tcounter as 'Tests'" +41 set v_scounter@2 (v_scounter@2 + 1) +42 jump_if_not 45(14) (p_all@1 and (v_i@3 > 0)) +43 set v_i@3 (v_i@3 - 1) +44 jump 14 +45 stmt 9 "drop temporary table sudoku_work, sud..." +drop procedure sudoku_solve; diff --git a/mysql-test/r/sp-destruct.result b/mysql-test/r/sp-destruct.result index 1b720be9403..4df8086c84e 100644 --- a/mysql-test/r/sp-destruct.result +++ b/mysql-test/r/sp-destruct.result @@ -72,6 +72,12 @@ drop trigger t1_ai; create trigger t1_ai after insert on t1 for each row call bug14233_3(); insert into t1 values (0); ERROR HY000: Failed to load routine test.bug14233_3. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6) -delete from mysql.proc where name like 'bug14233%'; drop trigger t1_ai; drop table t1; +drop function bug14233_1; +drop function bug14233_2; +drop procedure bug14233_3; +show procedure status; +Db Name Type Definer Modified Created Security_type Comment +show function status; +Db Name Type Definer Modified Created Security_type Comment diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index d26f0029001..fc29f915b82 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -425,7 +425,7 @@ set y = x; end| set @x = 0| call bug3279(@x)| -ERROR 23000: Duplicate entry '6' for key 1 +ERROR 23000: Duplicate entry '6' for key 'PRIMARY' select @x| @x 0 @@ -1134,3 +1134,32 @@ show procedure status; Db Name Type Definer Modified Created Security_type Comment test bug15658 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER drop procedure ` bug15658`; +drop function if exists bug14270; +drop table if exists t1; +create table t1 (s1 int primary key); +create function bug14270() returns int +begin +load index into cache t1; +return 1; +end| +ERROR 0A000: Not allowed to return a result set from a function +create function bug14270() returns int +begin +cache index t1 key (`primary`) in keycache1; +return 1; +end| +ERROR 0A000: Not allowed to return a result set from a function +drop table t1; +drop procedure if exists bug15091; +create procedure bug15091() +begin +declare selectstr varchar(6000) default ' '; +declare conditionstr varchar(5000) default ''; +set selectstr = concat(selectstr, +' and ', +c.operatorid, +'in (',conditionstr, ')'); +end| +call bug15091(); +ERROR 42S02: Unknown table 'c' in field list +drop procedure bug15091; diff --git a/mysql-test/r/sp-prelocking.result b/mysql-test/r/sp-prelocking.result index 0ba31155790..c2614892016 100644 --- a/mysql-test/r/sp-prelocking.result +++ b/mysql-test/r/sp-prelocking.result @@ -208,9 +208,9 @@ select f3() // f3() 1 call sp1() // -drop table t1,t2,t3; +drop view v1; +drop table t1,t2,t3,t4; drop function f1; drop function f2; drop function f3; drop procedure sp1; -drop view v1; diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result index fbc6d64f9c9..ff729e87f97 100644 --- a/mysql-test/r/sp-security.result +++ b/mysql-test/r/sp-security.result @@ -134,7 +134,11 @@ drop database db2; select type,db,name from mysql.proc; type db name delete from mysql.user where user='user1' or user='user2'; +delete from mysql.user where user='' and host='%'; delete from mysql.procs_priv where user='user1' or user='user2'; +delete from mysql.procs_priv where user='' and host='%'; +delete from mysql.db where user='user2'; +flush privileges; grant usage on *.* to usera@localhost; grant usage on *.* to userb@localhost; grant usage on *.* to userc@localhost; @@ -195,6 +199,9 @@ use test; drop database sptest; delete from mysql.user where user='usera' or user='userb' or user='userc'; delete from mysql.procs_priv where user='usera' or user='userb' or user='userc'; +delete from mysql.tables_priv where user='usera'; +flush privileges; +drop table t1; drop function if exists bug_9503; create database mysqltest// use mysqltest// @@ -284,3 +291,26 @@ drop user user1_bug14834@localhost; drop user user2_bug14834@localhost; drop user user3_bug14834@localhost; drop database db_bug14834; +create database db_bug14533; +use db_bug14533; +create table t1 (id int); +create user user_bug14533@localhost identified by ''; +create procedure bug14533_1() +sql security definer +desc db_bug14533.t1; +create procedure bug14533_2() +sql security definer +select * from db_bug14533.t1; +grant execute on procedure db_bug14533.bug14533_1 to user_bug14533@localhost; +grant execute on procedure db_bug14533.bug14533_2 to user_bug14533@localhost; +call db_bug14533.bug14533_1(); +Field Type Null Key Default Extra +id int(11) YES NULL +call db_bug14533.bug14533_2(); +id +desc db_bug14533.t1; +ERROR 42000: SELECT command denied to user 'user_bug14533'@'localhost' for table 't1' +select * from db_bug14533.t1; +ERROR 42000: SELECT command denied to user 'user_bug14533'@'localhost' for table 't1' +drop user user_bug14533@localhost; +drop database db_bug14533; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index ea4420c8e70..5961c71223a 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -3410,7 +3410,7 @@ begin select bug12379(); end| select bug12379()| -ERROR 23000: Duplicate entry 'X' for key 1 +ERROR 23000: Duplicate entry 'X' for key 'PRIMARY' select 1| 1 1 @@ -3427,7 +3427,7 @@ select 3| 3 3 call bug12379_3()| -ERROR 23000: Duplicate entry 'X' for key 1 +ERROR 23000: Duplicate entry 'X' for key 'PRIMARY' select 4| 4 4 @@ -3482,7 +3482,7 @@ s1 0 1 call bug6127()| -ERROR 23000: Duplicate entry '0' for key 1 +ERROR 23000: Duplicate entry '0' for key 's1' select * from t3| s1 0 @@ -4011,8 +4011,6 @@ NULL 1 call bug14643_2()| Handler boo -2 -2 Handler boo drop procedure bug14643_1| @@ -4360,6 +4358,11 @@ Handler error End done +call bug14498_4()| +Handler +error +End +done call bug14498_5()| Handler error @@ -4425,4 +4428,23 @@ drop procedure if exists bug15231_1| drop procedure if exists bug15231_2| drop procedure if exists bug15231_3| drop procedure if exists bug15231_4| +drop procedure if exists bug15011| +create table t3 (c1 int primary key)| +insert into t3 values (1)| +create procedure bug15011() +deterministic +begin +declare continue handler for 1062 +select 'Outer' as 'Handler'; +begin +declare continue handler for 1062 +select 'Inner' as 'Handler'; +insert into t3 values (1); +end; +end| +call bug15011()| +Handler +Inner +drop procedure bug15011| +drop table t3| drop table t1,t2; diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index e9289cf01c7..144b32feb28 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -82,7 +82,7 @@ end if; return i; end| insert into t1 values (bug10015_5(4)), (bug10015_5(5))| -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t1| id 1 diff --git a/mysql-test/r/subselect_innodb.result b/mysql-test/r/subselect_innodb.result index 4dec7882d58..6c6d563e284 100644 --- a/mysql-test/r/subselect_innodb.result +++ b/mysql-test/r/subselect_innodb.result @@ -243,4 +243,5 @@ x NULL x NULL +drop procedure p1; drop tables t1,t2,t3; diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index b36020bc2a3..f4dcb2baa02 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, `c` int(11) NOT NULL, PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/run/' alter table t9 rename t8, add column d int not null; alter table t8 rename t7; rename table t7 to t9; @@ -53,7 +53,7 @@ t9 CREATE TABLE `t9` ( `c` int(11) NOT NULL, `d` int(11) NOT NULL, PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/run/' Got one of the listed errors Got one of the listed errors Got one of the listed errors @@ -71,7 +71,7 @@ t9 CREATE TABLE `t9` ( `c` int(11) NOT NULL, `d` int(11) NOT NULL, PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/run/' drop database mysqltest; create table t1 (a int not null) engine=myisam; show create table t1; diff --git a/mysql-test/r/temp_table.result b/mysql-test/r/temp_table.result index ca5e6e1a32f..c5570e7b4f7 100644 --- a/mysql-test/r/temp_table.result +++ b/mysql-test/r/temp_table.result @@ -77,7 +77,7 @@ drop table t1,t2; create temporary table t1 (a int not null); insert into t1 values (1),(1); alter table t1 add primary key (a); -ERROR 23000: Duplicate entry '1' for key 1 +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' drop table t1; CREATE TABLE t1 ( d datetime default NULL diff --git a/mysql-test/r/trigger-compat.result b/mysql-test/r/trigger-compat.result index 71682376ab5..068bf6c6968 100644 --- a/mysql-test/r/trigger-compat.result +++ b/mysql-test/r/trigger-compat.result @@ -35,3 +35,13 @@ SELECT * FROM INFORMATION_SCHEMA.TRIGGERS ORDER BY trigger_name; TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER NULL mysqltest_db1 wl2818_trg1 INSERT NULL mysqltest_db1 t1 0 NULL INSERT INTO t2 VALUES(CURRENT_USER()) ROW BEFORE NULL NULL OLD NEW NULL NULL mysqltest_db1 wl2818_trg2 INSERT NULL mysqltest_db1 t1 0 NULL INSERT INTO t2 VALUES(CURRENT_USER()) ROW AFTER NULL NULL OLD NEW NULL mysqltest_dfn@localhost +DROP TRIGGER wl2818_trg1; +Warnings: +Warning 1454 No definer attribute for trigger 'mysqltest_db1'.'wl2818_trg1'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger. +DROP TRIGGER wl2818_trg2; +use mysqltest_db1; +DROP TABLE t1; +DROP TABLE t2; +DROP USER mysqltest_dfn@localhost; +DROP USER mysqltest_inv@localhost; +DROP DATABASE mysqltest_db1; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 9cfecde7610..62c0d01327d 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -404,13 +404,13 @@ create table t1 (i int, j int, k int); create trigger trg1 before insert on t1 for each row set new.k = new.i; create trigger trg2 after insert on t1 for each row set @b:= "Fired"; set @b:=""; -load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, i); +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, i); select *, @b from t1; i j k @b 10 NULL 10 Fired 15 NULL 15 Fired set @b:=""; -load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, j); +load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, j); select *, @b from t1; i j k @b 10 NULL 10 Fired @@ -447,7 +447,7 @@ ERROR 42S22: Unknown column 'at' in 'OLD' select * from t1; i k 1 1 -load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); ERROR 42S22: Unknown column 'at' in 'NEW' select * from t1; i k @@ -528,7 +528,7 @@ select * from t1; i k 1 1 2 2 -load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); ERROR 42S22: Unknown column 'bt' in 'NEW' select * from t1; i k @@ -785,3 +785,8 @@ create trigger test.t1_bi before insert on t1 for each row set @a:=0; ERROR 3D000: No database selected drop trigger t1_bi; ERROR 3D000: No database selected +create table t1 (i int); +create trigger t1_bi before insert on t1 for each row return 0; +ERROR 42000: RETURN is only allowed in a FUNCTION +insert into t1 values (1); +drop table t1; diff --git a/mysql-test/r/type_binary.result b/mysql-test/r/type_binary.result index 597defb7a9b..34cbc9efabf 100644 --- a/mysql-test/r/type_binary.result +++ b/mysql-test/r/type_binary.result @@ -47,7 +47,7 @@ create table t1 (s1 binary(2) primary key); insert into t1 values (0x01); insert into t1 values (0x0120); insert into t1 values (0x0100); -ERROR 23000: Duplicate entry '' for key 1 +ERROR 23000: Duplicate entry '' for key 'PRIMARY' select hex(s1) from t1 order by s1; hex(s1) 0100 diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index 942e165649e..2b69fc79835 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -71,7 +71,7 @@ hex(a) 1 1 alter table t1 add unique (a); -ERROR 23000: Duplicate entry '' for key 1 +ERROR 23000: Duplicate entry '' for key 'a' drop table t1; create table t1 (a bit(2)); insert into t1 values (b'00'), (b'01'), (b'10'), (b'100'); @@ -563,3 +563,4 @@ b1+0 sum(b1) sum(b2) 0 0 0 1 4 4 2 2 2 +drop table t1, t2; diff --git a/mysql-test/r/type_bit_innodb.result b/mysql-test/r/type_bit_innodb.result index 20eadd94342..3481159396c 100644 --- a/mysql-test/r/type_bit_innodb.result +++ b/mysql-test/r/type_bit_innodb.result @@ -71,7 +71,7 @@ hex(a) 1 1 alter table t1 add unique (a); -ERROR 23000: Duplicate entry '' for key 1 +ERROR 23000: Duplicate entry '' for key 'a' drop table t1; create table t1 (a bit(2)) engine=innodb; insert into t1 values (b'00'), (b'01'), (b'10'), (b'100'); diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index b366b1ed755..cbd716ad110 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -530,9 +530,9 @@ l longblob NULL YES NULL # drop table t1; create table t1 (id integer primary key auto_increment, txt text not null, unique index txt_index (txt (20))); insert into t1 (txt) values ('Chevy'), ('Chevy '); -ERROR 23000: Duplicate entry 'Chevy ' for key 2 +ERROR 23000: Duplicate entry 'Chevy ' for key 'txt_index' insert into t1 (txt) values ('Chevy'), ('CHEVY'); -ERROR 23000: Duplicate entry 'Chevy' for key 2 +ERROR 23000: Duplicate entry 'Chevy' for key 'txt_index' alter table t1 drop index txt_index, add index txt_index (txt(20)); insert into t1 (txt) values ('Chevy '); select * from t1 where txt='Chevy'; diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index 1e5373ba766..5327acc207f 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -31,14 +31,14 @@ select * from t1; f1 f2 10 10 100000 100000 -1.23457e+9 1234567890 +1.23457e+09 1234567890 1e+10 10000000000 1e+15 1e+15 1e+20 1e+20 3.40282e+38 1e+50 3.40282e+38 1e+150 -10 -10 -1e-5 1e-5 +1e-05 1e-05 1e-10 1e-10 1e-15 1e-15 1e-20 1e-20 diff --git a/mysql-test/r/type_varchar.result b/mysql-test/r/type_varchar.result index e74850bba33..1de87ad529e 100644 --- a/mysql-test/r/type_varchar.result +++ b/mysql-test/r/type_varchar.result @@ -62,7 +62,7 @@ binary v='a ' 1 insert into t1 values('a'); alter table t1 add primary key (v); -ERROR 23000: Duplicate entry 'a' for key 1 +ERROR 23000: Duplicate entry 'a' for key 'PRIMARY' drop table t1; create table t1 (v varbinary(20)); insert into t1 values('a'); diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index abeade5df0c..4b7dbb3dbe9 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -358,3 +358,22 @@ update t2,t1 set f1=3,f2=3 where f1=f2 and f1=1; affected rows: 3 info: Rows matched: 3 Changed: 3 Warnings: 0 drop table t1,t2; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler1 char(200), filler2 char(200), key(a)); +insert into t2 select A.a + 10*B.a, 'filler','filler' from t1 A, t1 B; +flush status; +update t2 set a=3 where a=2; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_next 1 +Handler_read_prev 0 +Handler_read_rnd 1 +Handler_read_rnd_next 0 +drop table t1, t2; +create table t1(f1 int, `*f2` int); +insert into t1 values (1,1); +update t1 set `*f2`=1; +drop table t1; diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 8ee6dfe53cf..5a8926e0638 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -71,6 +71,7 @@ c_id c_name c_country 1 Bozo USA 4 Mr. Floppy GB drop table t1; +set GLOBAL max_join_size=10; set max_join_size=100; show variables like 'max_join_size'; Variable_name Value diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index fea725922ab..5396db82965 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1293,7 +1293,7 @@ drop view v2, v1; drop table t1; create table t1 (a int, b char(10)); create view v1 as select * from t1 where a != 0 with check option; -load data infile '../../std_data/loaddata3.dat' into table v1 fields terminated by '' enclosed by '' ignore 1 lines; +load data infile '../std_data_ln/loaddata3.dat' into table v1 fields terminated by '' enclosed by '' ignore 1 lines; ERROR HY000: CHECK OPTION failed 'test.v1' select * from t1; a b @@ -1304,7 +1304,7 @@ a b 1 row 1 2 row 2 delete from t1; -load data infile '../../std_data/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines; +load data infile '../std_data_ln/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines; Warnings: Warning 1264 Out of range value for column 'a' at row 3 Error 1369 CHECK OPTION failed 'test.v1' @@ -1324,14 +1324,14 @@ drop view v1; drop table t1; create table t1 (a text, b text); create view v1 as select * from t1 where a <> 'Field A' with check option; -load data infile '../../std_data/loaddata2.dat' into table v1 fields terminated by ',' enclosed by ''''; +load data infile '../std_data_ln/loaddata2.dat' into table v1 fields terminated by ',' enclosed by ''''; ERROR HY000: CHECK OPTION failed 'test.v1' select concat('|',a,'|'), concat('|',b,'|') from t1; concat('|',a,'|') concat('|',b,'|') select concat('|',a,'|'), concat('|',b,'|') from v1; concat('|',a,'|') concat('|',b,'|') delete from t1; -load data infile '../../std_data/loaddata2.dat' ignore into table v1 fields terminated by ',' enclosed by ''''; +load data infile '../std_data_ln/loaddata2.dat' ignore into table v1 fields terminated by ',' enclosed by ''''; Warnings: Error 1369 CHECK OPTION failed 'test.v1' Warning 1261 Row 2 doesn't contain data for all columns @@ -2495,3 +2495,37 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away DROP VIEW v1; DROP TABLE t1; +CREATE TABLE t1 (x varchar(10)); +INSERT INTO t1 VALUES (null), ('foo'), ('bar'), (null); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT IF(x IS NULL, 'blank', 'not blank') FROM v1 GROUP BY x; +IF(x IS NULL, 'blank', 'not blank') +blank +not blank +not blank +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM t1 GROUP BY x; +x +blank +not blank +not blank +Warnings: +Warning 1052 Column 'x' in group statement is ambiguous +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1; +x +blank +not blank +not blank +blank +SELECT IF(x IS NULL, 'blank', 'not blank') AS y FROM v1 GROUP BY y; +y +blank +not blank +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1 GROUP BY x; +x +blank +not blank +not blank +Warnings: +Warning 1052 Column 'x' in group statement is ambiguous +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index f7156bbb701..8da8805b14b 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -9,6 +9,7 @@ revoke create view on test.* from test@localhost; show grants for test@localhost; Grants for test@localhost GRANT USAGE ON *.* TO 'test'@'localhost' +drop user test@localhost; create database mysqltest; create table mysqltest.t1 (a int, b int); create table mysqltest.t2 (a int, b int); diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index 0d3fed4cd4d..9f9d3b53063 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -70,7 +70,7 @@ select @@warning_count; 1 drop table t1; create table t1(a tinyint, b int not null, c date, d char(5)); -load data infile '../../std_data/warnings_loaddata.dat' into table t1 fields terminated by ','; +load data infile '../std_data_ln/warnings_loaddata.dat' into table t1 fields terminated by ','; Warnings: Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'b' at row 2 Warning 1265 Data truncated for column 'd' at row 3 @@ -166,13 +166,6 @@ show variables like 'max_error_count'; Variable_name Value max_error_count 10 drop table t1; -create table t1 (id int) type=heap; -Warnings: -Warning 1287 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead -alter table t1 type=myisam; -Warnings: -Warning 1287 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead -drop table t1; set table_type=MYISAM; Warnings: Warning 1287 'table_type' is deprecated; use 'storage_engine' instead diff --git a/mysql-test/t/analyze.test b/mysql-test/t/analyze.test index 656ff752c9b..a8fd0a4283e 100644 --- a/mysql-test/t/analyze.test +++ b/mysql-test/t/analyze.test @@ -61,5 +61,6 @@ prepare stmt1 from "SELECT * FROM t1 PROCEDURE ANALYSE()"; execute stmt1; execute stmt1; deallocate prepare stmt1; +drop table t1; # End of 4.1 tests diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 185210b8c54..68e3192e8a4 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1456,6 +1456,34 @@ SELECT c FROM t5; SELECT c FROM t5 WHERE a =3; SELECT c FROM t5 WHERE a IN (32, 23, 5); +# Adding this in case someone tries to add fast alter table and doesn't tes +# it. +# Some additional tests for new, faster alter table. Note that most of the +# whole alter table code is being tested all around the test suite already. +# + +drop table t1; +create table t1 (v varchar(32)); +insert into t1 values ('def'),('abc'),('hij'),('3r4f'); +select * from t1; +# Fast alter, no copy performed +alter table t1 change v v2 varchar(32); +select * from t1; +# Fast alter, no copy performed +alter table t1 change v2 v varchar(64); +select * from t1; +update t1 set v = 'lmn' where v = 'hij'; +select * from t1; +# Regular alter table +alter table t1 add i int auto_increment not null primary key first; +select * from t1; +update t1 set i=5 where i=3; +select * from t1; +alter table t1 change i i bigint; +select * from t1; +alter table t1 add unique key (i, v); +select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn'); + # # Cleanup, test is over # diff --git a/mysql-test/t/backup-master.sh b/mysql-test/t/backup-master.sh index 99da5857afe..c099064f6b7 100755 --- a/mysql-test/t/backup-master.sh +++ b/mysql-test/t/backup-master.sh @@ -1,5 +1,5 @@ #!/bin/sh if [ "$MYSQL_TEST_DIR" ] then - rm -f $MYSQL_TEST_DIR/var/tmp/*.frm $MYSQL_TEST_DIR/var/tmp/*.MY? + rm -f $MYSQLTEST_VARDIR/tmp/*.frm $MYSQLTEST_VARDIR/tmp/*.MY? fi diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test index 64de3a426b2..917c3f98ebb 100644 --- a/mysql-test/t/backup.test +++ b/mysql-test/t/backup.test @@ -13,10 +13,10 @@ set SQL_LOG_BIN=0; drop table if exists t1, t2, t3, t4; --enable_warnings create table t4(n int); ---replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQL_TEST_DIR MYSQL_TEST_DIR +--replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR backup table t4 to '../bogus'; backup table t4 to '../tmp'; ---replace_result ": 7" ": X" ": 17" ": X" $MYSQL_TEST_DIR MYSQL_TEST_DIR +--replace_result ": 7" ": X" ": 17" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR backup table t4 to '../tmp'; drop table t4; restore table t4 from '../tmp'; @@ -26,7 +26,7 @@ create table t1(n int); insert into t1 values (23),(45),(67); backup table t1 to '../tmp'; drop table t1; ---replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQL_TEST_DIR MYSQL_TEST_DIR +--replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR restore table t1 from '../bogus'; restore table t1 from '../tmp'; select n from t1; @@ -55,6 +55,6 @@ unlock tables; connection con1; reap; drop table t5; ---system rm $MYSQL_TEST_DIR/var/tmp/t?.* +--system rm $MYSQLTEST_VARDIR/tmp/t?.* # End of 4.1 tests diff --git a/mysql-test/t/binlog_stm_binlog.test b/mysql-test/t/binlog_stm_binlog.test index 6d3dce9a323..d608741da0b 100644 --- a/mysql-test/t/binlog_stm_binlog.test +++ b/mysql-test/t/binlog_stm_binlog.test @@ -1,6 +1,18 @@ +# REQUIREMENT +# replace_regex should replace output of SHOW BINLOG EVENTS + +create table t1 (a int, b int) engine=innodb; +begin; +insert into t1 values (1,2); +commit; +--replace_regex /\/\* xid=.* \*\//\/* XID *\// +show binlog events; +drop table t1; + # This is a wrapper for binlog.test so that the same test case can be used # For both statement and row based bin logs 9/19/2005 [jbm] -- source include/not_embedded.inc -- source include/have_binlog_format_statement.inc -- source extra/binlog_tests/binlog.test + diff --git a/mysql-test/t/create_select_tmp.test b/mysql-test/t/create_select_tmp.test index dad83942806..144bccc5871 100644 --- a/mysql-test/t/create_select_tmp.test +++ b/mysql-test/t/create_select_tmp.test @@ -30,5 +30,6 @@ select * from t2; CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; --error 1146 select * from t2; +drop table t1; # End of 4.1 tests diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index 6f0f42f109c..916a2132deb 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1418,3 +1418,29 @@ truncate table t1; -- truncate --disable_info drop table t1; +# +# Some additional tests for new, faster alter table. Note that most of the +# whole alter table code is being tested all around the test suite already. +# + +create table t1 (v varchar(32)); +insert into t1 values ('def'),('abc'),('hij'),('3r4f'); +select * from t1; +# Fast alter, no copy performed +alter table t1 change v v2 varchar(32); +select * from t1; +# Fast alter, no copy performed +alter table t1 change v2 v varchar(64); +select * from t1; +update t1 set v = 'lmn' where v = 'hij'; +select * from t1; +# Regular alter table +alter table t1 add i int auto_increment not null primary key first; +select * from t1; +update t1 set i=5 where i=3; +select * from t1; +alter table t1 change i i bigint; +select * from t1; +alter table t1 add unique key (i, v); +select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn'); +drop table t1; diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index 5648cea7fd3..2d6b55600b1 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -186,5 +186,5 @@ select rpad(c1,3,'ö'), rpad('ö',3,c1) from t1; # TODO #select case c1 when 'ß' then 'ß' when 'ö' then 'ö' else 'c' end from t1; #select export_set(5,c1,'ö'), export_set(5,'ö',c1) from t1; - +drop table t1; # End of 4.1 tests diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test index 77d250b5c45..e8bf840facc 100644 --- a/mysql-test/t/ctype_ujis.test +++ b/mysql-test/t/ctype_ujis.test @@ -94,7 +94,7 @@ CREATE TABLE t1 b VARCHAR(50) NOT NULL DEFAULT '', PRIMARY KEY (a), KEY b (b(10)) -) TYPE=InnoDB CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci'; +) ENGINE=InnoDB CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci'; --enable_warnings INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd'); INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh'); @@ -110,7 +110,7 @@ CREATE TABLE t1 b VARCHAR(50) NOT NULL DEFAULT '', PRIMARY KEY (a), KEY b (b(10)) -) TYPE=MyISAM CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci'; +) ENGINE=MyISAM CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci'; --enable_warnings INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd'); INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh'); diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index 88106ae6956..2e1af51efa7 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -272,4 +272,11 @@ insert into t1 (f1) values ("2005-01-01"); insert into t1 (f1) values ("2005-02-01"); select date_format(f1, "%m") as d1, date_format(f1, "%M") as d2 from t1 order by date_format(f1, "%M"); drop table t1; + +# +# Bug #15828 +# +select str_to_date( 1, NULL ); +select str_to_date( NULL, 1 ); +select str_to_date( 1, IF(1=1,NULL,NULL) ); # End of 4.1 tests diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index fd49bc21ae7..7555df95b04 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -10,26 +10,25 @@ # ############################################################################## -sp-goto : GOTO is currently is disabled - will be fixed in the future -rpl_bit_npk : Bug #13418 -events : Test case instability - infinite locking. To be fixed. -func_group : Bug #15448 -func_math : Bug #15448 -group_min_max : Bug #15448 -innodb_concurrent : Results are not deterministic, Elliot will fix (BUG#3300) -innodb_unsafe_binlog : re-enable with InnoDB 5.1 snapshot containing bug#15650 -subselect : Bug#15706 -ps_7ndb : dbug assert in RBR mode when executing test suite -rpl_ddl : Bug#15963 SBR does not show "Definer" correctly -partition_03ndb : Bug#16385 -ndb_binlog_basic : Results are not deterministic, Tomas will fix -rpl_ndb_basic : Bug#16228 -rpl_sp : Bug #16456 -#ndb_dd_disk2memory : Bug #16466 -ndb_autodiscover : Needs to be fixed w.r.t binlog -ndb_autodiscover2 : Needs to be fixed w.r.t binlog +events : Test case instability - infinite locking. To be fixed. +func_group : Bug#15448 +func_math : Bug#15448 +group_min_max : Bug#15448 #ndb_alter_table_row : sometimes wrong error 1015!=1046 -ndb_gis : garbled msgs from corrupt THD* -ndb_binlog_ddl_multi : Bug #17038 - -# vim: set filetype=conf: +ndb_autodiscover : Needs to be fixed w.r.t binlog +ndb_autodiscover2 : Needs to be fixed w.r.t binlog +ndb_binlog_basic : Results are not deterministic, Tomas will fix +ndb_binlog_ddl_multi : Bug#17038 [PATCH PENDING] +ndb_gis : garbled msgs from corrupt THD* +ndb_load : Bug#17233 +partition_03ndb : Bug#16385 +ps_7ndb : dbug assert in RBR mode when executing test suite +rpl_bit_npk : Bug#13418 +rpl_ddl : Bug#15963 SBR does not show "Definer" correctly +rpl_ndb_auto_inc : Bug#17086 +rpl_ndb_basic : Bug#16228 [IN REVIEW] +rpl_ndb_relay_space : Bug#16993 +rpl_sp : Bug#16456 +rpl_until : Unstable test case, bug#15886 +sp-goto : GOTO is currently is disabled - will be fixed in the future +subselect : Bug#15706 (ps mode) [PATCH PENDING] diff --git a/mysql-test/t/events.test b/mysql-test/t/events.test index be24d490393..aa759d5ca6f 100644 --- a/mysql-test/t/events.test +++ b/mysql-test/t/events.test @@ -17,12 +17,12 @@ drop event event2; create event e_43 on schedule every 1 second do set @a = 5; set global event_scheduler = 1; -select sleep(2); +--sleep 2 alter event e_43 do alter event e_43 do set @a = 4; -select sleep(3); +--sleep 2 select db, name, body, status, interval_field, interval_value from mysql.event; drop event e_43; -select sleep(1); +--sleep 1 set global event_scheduler = 0; create table t_event3 (a int, b float); @@ -107,8 +107,8 @@ drop event one_event; ##INFORMATION_SCHEMA.EVENTS test end # - - +--echo "Sleep a bit so the server closes the second connection" +--sleep 2 create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5; select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event; @@ -129,23 +129,38 @@ set event_scheduler=0; --error 1231 set global event_scheduler=2; -#set global event_scheduler=0; -#select count(*) from mysql.event; -#select get_lock("test_lock1", 20); -#create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20); -#select count(*) from mysql.event; -##show processlist; -#select release_lock("test_lock1"); -#drop event закачка; -#select count(*) from mysql.event; +--echo "DISABLE the scheduler. Testing that it does not work when the variable is 0" +set global event_scheduler=0; +select definer, name, db from mysql.event; +select get_lock("test_lock1", 20); +create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20); +--echo "Should return 1 row" +select definer, name, db from mysql.event; + +--echo "Should be only 1 process" +--replace_column 1 # 6 # +show processlist; +select release_lock("test_lock1"); +drop event закачка; +--echo "Should have 0 events" +select count(*) from mysql.event; + # -#set global event_scheduler=1; -#select get_lock("test_lock2", 20); -#create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20); -#select sleep(2); -#show processlist; -#select release_lock("test_lock2"); -#drop event закачка; +# +# +--echo "ENABLE the scheduler and get a lock" +set global event_scheduler=1; +select get_lock("test_lock2", 20); +--echo "Create an event which tries to acquire a mutex. The event locks on the mutex" +create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20); +--echo "Let some time pass to the event starts" +--sleep 2 +--echo "Should have only 3 processes: the scheduler, our conn and the locked event" +--replace_column 1 # 6 # +show processlist; +--echo "Release the mutex, the event worker should finish." +select release_lock("test_lock2"); +drop event закачка; ## ## 1. get a lock @@ -155,26 +170,34 @@ set global event_scheduler=2; ## 5. kill the scheduler, it will wait for the child to stop ## 6. both processes should be there on show processlist ## 7. release the lock and sleep, both scheduler and child should end -#set global event_scheduler=1; -#select get_lock("test_lock2_1", 20); -#create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20); -#select sleep(2); -##show processlist; -#set global event_scheduler=0; -#select sleep(2); -##show processlist; -#select release_lock("test_lock2_1"); -#select sleep(2); -##show processlist; -#drop event закачка21; - -#set global event_scheduler=1; -#select get_lock("test_lock3", 20); -#create event закачка on schedule every 10 hour do select get_lock("test_lock3", 20); -#select sleep(2); +set global event_scheduler=1; +select get_lock("test_lock2_1", 20); +create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20); +--sleep 1 +--echo "Should see 2 processes, one locked on get_lock(" +#--replace_column 1 # 6 # #show processlist; -#drop event закачка; -#select release_lock("test_lock3"); +--echo "Shutting down the scheduler, it should wait for the running event" +set global event_scheduler=0; +--sleep 1 +--echo "Should have only 3 processes: the scheduler, our conn and the locked event" +--replace_column 1 # 6 # +show processlist; +--echo "Release the lock so the child process should finish. Hence the scheduler also" +select release_lock("test_lock2_1"); +--sleep 1 +--echo "Should have only our process now:" +--replace_column 1 # 6 # +show processlist; +drop event закачка21; + +##set global event_scheduler=1; +##select get_lock("test_lock3", 20); +##create event закачка on schedule every 10 hour do select get_lock("test_lock3", 20); +##select sleep(2); +##show processlist; +##drop event закачка; +##select release_lock("test_lock3"); # # test with very often occuring event @@ -182,14 +205,15 @@ set global event_scheduler=2; ##select get_lock("test_lock4", 20); ##create event закачка4 on schedule every 1 second do select get_lock("test_lock4", 20); ##select sleep(3); +##--replace_column 1 # 6 # ##show processlist; ##drop event закачка4; ##select release_lock("test_lock4"); -#set global event_scheduler=0; -#select sleep(2); +##set global event_scheduler=0; +##select sleep(2); +##--replace_column 1 # 6 # ##show processlist; -##the following locks for some reason and is a bug, commented for now ##select count(*) from mysql.event; drop database events_test; diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test index a31fcf59074..a6587aa6a13 100644 --- a/mysql-test/t/federated.test +++ b/mysql-test/t/federated.test @@ -1226,4 +1226,35 @@ drop table federated.t1; connection slave; drop table federated.t1; +# +# BUG# 14768 test auto_increment last_insert_id() +# +connection slave; +DROP TABLE IF EXISTS federated.t1; +CREATE TABLE federated.t1 ( + `id` int(20) NOT NULL auto_increment, + PRIMARY KEY (`id`)); + +connection master; +DROP TABLE IF EXISTS federated.t1; +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval CREATE TABLE federated.t1 ( + `id` int(20) NOT NULL auto_increment, + PRIMARY KEY (`id`) + ) + ENGINE="FEDERATED" DEFAULT CHARSET=latin1 + CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; + +INSERT INTO federated.t1 VALUES (); +SELECT LAST_INSERT_ID(); +INSERT INTO federated.t1 VALUES (); +SELECT LAST_INSERT_ID(); +INSERT INTO federated.t1 VALUES (); +SELECT LAST_INSERT_ID(); +INSERT INTO federated.t1 VALUES (); +SELECT LAST_INSERT_ID(); +INSERT INTO federated.t1 VALUES (); +SELECT LAST_INSERT_ID(); +SELECT * FROM federated.t1; + source include/federated_cleanup.inc; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 7974b74081a..590a7dc495b 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -371,4 +371,16 @@ CREATE TABLE t1 (a VARCHAR(10000), FULLTEXT(a)); SHOW CREATE TABLE t1; DROP TABLE t1; +# +# BUG#14496: Crash or strange results with prepared statement, +# MATCH and FULLTEXT +# +CREATE TABLE t1 (a TEXT, FULLTEXT KEY(a)); +INSERT INTO t1 VALUES('test'),('test1'),('test'); +PREPARE stmt from "SELECT a, MATCH(a) AGAINST('test1 test') FROM t1 WHERE MATCH(a) AGAINST('test1 test')"; +EXECUTE stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + # End of 4.1 tests diff --git a/mysql-test/t/fulltext_var.test b/mysql-test/t/fulltext_var.test index 6b0b8aa463b..a048dab7f40 100644 --- a/mysql-test/t/fulltext_var.test +++ b/mysql-test/t/fulltext_var.test @@ -5,6 +5,9 @@ drop table if exists t1; --enable_warnings +# Save ft_boolean_syntax variable +let $saved_ft_boolean_syntax=`select @@global.ft_boolean_syntax`; + show variables like "ft\_%"; create table t1 (b text not null); @@ -25,4 +28,9 @@ set global ft_boolean_syntax='@ -><()~*:""@|'; set global ft_boolean_syntax='+ -><()~*:""@!|'; drop table t1; +# Restore ft_boolean_syntax variable +--disable_query_log +eval set global ft_boolean_syntax='$saved_ft_boolean_syntax'; +--enable_query_log + # End of 4.1 tests diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 9cf0ee452cd..8dc4eb215c7 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -141,3 +141,17 @@ select log(2,-1); select log(-2,1); set sql_mode=''; +# +# Bug #8461 truncate() and round() return false results 2nd argument negative. +# +# round(a,-b) log_10(b) > a +select round(111,-10); +# round on bigint +select round(-5000111000111000155,-1); +# round on unsigned bigint +select round(15000111000111000155,-1); +# truncate on bigint +select truncate(-5000111000111000155,-1); +# truncate on unsigned bigint +select truncate(15000111000111000155,-1); + diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index c19bb1482d6..430a3a5dd4a 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -286,6 +286,7 @@ drop user 'mysqltest_1b', 'mysqltest_2b', 'mysqltest_3b'; create user 'mysqltest_2' identified by 'Mysqltest-2'; --error 1064 drop user 'mysqltest_2' identified by 'Mysqltest-2'; +drop user 'mysqltest_2'; # # Strange user names create user '%@b'@'b'; @@ -325,6 +326,7 @@ insert into mysql.user set host='%', user='mysqltest_B'; create user mysqltest_A@'%'; rename user mysqltest_B@'%' to mysqltest_C@'%'; drop user mysqltest_C@'%'; +drop user mysqltest_A@'%'; disconnect user4; connection default; drop user mysqltest_3@localhost; diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index e15ef92116c..8dc55532bbf 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -715,3 +715,24 @@ select distinct c1, c2 from t1 order by c2; select c1,min(c2) as c2 from t1 group by c1 order by c2; select c1,c2 from t1 group by c1,c2 order by c2; drop table t1; + +# +# Bug #16203: Analysis for possible min/max optimization erroneously +# returns impossible range +# + +CREATE TABLE t1 (a varchar(5), b int(11), PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES ('AA',1), ('AA',2), ('AA',3), ('BB',1), ('AA',4); +OPTIMIZE TABLE t1; + +SELECT a FROM t1 WHERE a='AA' GROUP BY a; +SELECT a FROM t1 WHERE a='BB' GROUP BY a; + +EXPLAIN SELECT a FROM t1 WHERE a='AA' GROUP BY a; +EXPLAIN SELECT a FROM t1 WHERE a='BB' GROUP BY a; + +SELECT DISTINCT a FROM t1 WHERE a='BB'; +SELECT DISTINCT a FROM t1 WHERE a LIKE 'B%'; +SELECT a FROM t1 WHERE a LIKE 'B%' GROUP BY a; + +DROP TABLE t1; diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index 1cc894697f9..78628bef198 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -135,6 +135,22 @@ SELECT SUM(a) FROM t1 GROUP BY a HAVING SUM(a); DROP TABLE t1; +# +# Bug #14927: HAVING clause containing constant false conjunct +# + +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1), (2), (1), (3), (2), (1); + +SELECT a FROM t1 GROUP BY a HAVING a > 1; +SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1; +SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1; + +EXPLAIN SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1; +EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1; + +DROP table t1; + # End of 4.1 tests # diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index fcaa4c41ece..82294db336d 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -436,6 +436,17 @@ insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); drop table t1; +# +# Bug 12796: Record doesn't show when selecting through index +# +CREATE TABLE t1 (a int, key(a)) engine=heap; +insert into t1 values (0); +delete from t1; +select * from t1; +insert into t1 values (0), (1); +select * from t1 where a = 0; +drop table t1; + # End of 4.1 tests # diff --git a/mysql-test/t/im_daemon_life_cycle-im.opt b/mysql-test/t/im_daemon_life_cycle-im.opt index 6bfd9a24107..21c01191e4c 100644 --- a/mysql-test/t/im_daemon_life_cycle-im.opt +++ b/mysql-test/t/im_daemon_life_cycle-im.opt @@ -1,2 +1,2 @@ --run-as-service ---log=$MYSQL_TEST_DIR/var/log/im.log +--log=$MYSQLTEST_VARDIR/log/im.log diff --git a/mysql-test/t/im_life_cycle.imtest b/mysql-test/t/im_life_cycle.imtest index c2b1c9a56ec..2ea0c151d5a 100644 --- a/mysql-test/t/im_life_cycle.imtest +++ b/mysql-test/t/im_life_cycle.imtest @@ -18,9 +18,9 @@ ########################################################################### SHOW INSTANCES; ---replace_column 3 VERSION +--replace_column 3 VERSION_NUMBER 4 VERSION SHOW INSTANCE STATUS mysqld1; ---replace_column 3 VERSION +--replace_column 3 VERSION_NUMBER 4 VERSION SHOW INSTANCE STATUS mysqld2; ########################################################################### @@ -38,9 +38,9 @@ START INSTANCE mysqld2; --sleep 3 SHOW INSTANCES; ---replace_column 3 VERSION +--replace_column 3 VERSION_NUMBER 4 VERSION SHOW INSTANCE STATUS mysqld1; ---replace_column 3 VERSION +--replace_column 3 VERSION_NUMBER 4 VERSION SHOW INSTANCE STATUS mysqld2; --connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK) @@ -66,9 +66,9 @@ STOP INSTANCE mysqld2; --sleep 3 SHOW INSTANCES; ---replace_column 3 VERSION +--replace_column 3 VERSION_NUMBER 4 VERSION SHOW INSTANCE STATUS mysqld1; ---replace_column 3 VERSION +--replace_column 3 VERSION_NUMBER 4 VERSION SHOW INSTANCE STATUS mysqld2; ########################################################################### @@ -140,3 +140,12 @@ SHOW INSTANCES; --exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed SHOW INSTANCES; + +########################################################################### +# +# 1.1.8. Check that Instance Manager returns an error on +# incomplete SHOW INSTANCE STATUS command. +# +########################################################################### +--error 1149 +SHOW INSTANCE STATUS; diff --git a/mysql-test/t/im_options_set.imtest b/mysql-test/t/im_options_set.imtest index 785c6d05fef..a9b64861f99 100644 --- a/mysql-test/t/im_options_set.imtest +++ b/mysql-test/t/im_options_set.imtest @@ -48,7 +48,7 @@ # - check the configuration file; ---exec grep server_id $MYSQL_TEST_DIR/var/im.cnf ; +--exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; # - check the running instances. @@ -79,7 +79,7 @@ SET mysqld1.server_id = 11; # - check that the configuration file has been updated (i.e. contains # server_id=SERVER_ID for the instance); ---exec grep server_id $MYSQL_TEST_DIR/var/im.cnf ; +--exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; # - (for mysqld1) check that the running instance has not been affected: # connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id'' @@ -104,7 +104,7 @@ SET mysqld2.server_id = 12; # - check that the configuration file has been updated (i.e. contains # server_id=SERVER_ID for the instance); ---exec grep server_id $MYSQL_TEST_DIR/var/im.cnf ; +--exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; # - check that internal cache of Instance Manager has not been affected # (i.e. SHOW INSTANCE OPTIONS <instance> does not contain updated value). @@ -122,7 +122,7 @@ FLUSH INSTANCES; # - check that the configuration file has not been updated; ---exec grep server_id $MYSQL_TEST_DIR/var/im.cnf ; +--exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; # - (for mysqld1) check that the running instance has not been affected: # connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id'' diff --git a/mysql-test/t/im_options_unset.imtest b/mysql-test/t/im_options_unset.imtest index 74ec42ac3f9..40629805d45 100644 --- a/mysql-test/t/im_options_unset.imtest +++ b/mysql-test/t/im_options_unset.imtest @@ -55,7 +55,7 @@ # - check the configuration file; ---exec grep server_id $MYSQL_TEST_DIR/var/im.cnf ; +--exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; # - check the running instances. @@ -86,7 +86,7 @@ UNSET mysqld1.server_id; # - check that the configuration file has been updated (i.e. does not # contain 'server_id=' line for the instance); ---exec grep server_id $MYSQL_TEST_DIR/var/im.cnf ; +--exec grep server_id $MYSQLTEST_VARDIR/im.cnf ; # - check that the running instance has not been affected: connect to the # instance and check that 'SHOW VARIABLES LIKE 'server_id'' returns non-zero @@ -111,7 +111,7 @@ UNSET mysqld2.server_id; # - check that the configuration file has been updated (i.e. does not # contain 'server_id=' line for the instance); ---exec grep server_id $MYSQL_TEST_DIR/var/im.cnf || true; +--exec grep server_id $MYSQLTEST_VARDIR/im.cnf || true; # - check that internal cache of Instance Manager is not affected (i.e. SHOW # INSTANCE OPTIONS <instance> contains non-zero value for server_id); @@ -130,7 +130,7 @@ FLUSH INSTANCES; # - check that the configuration file has not been updated (i.e. does not # contain 'server_id=' for the instance); ---exec grep server_id $MYSQL_TEST_DIR/var/im.cnf || true; +--exec grep server_id $MYSQLTEST_VARDIR/im.cnf || true; # - (for mysqld1) check that the running instance has not been affected: # connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id'' diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 36374683e24..ce5c4f71c8c 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -800,9 +800,9 @@ DROP FUNCTION func2; # create database mysqltest; create table mysqltest.t1(a int); ---exec chmod -r $MYSQL_TEST_DIR/var/master-data/mysqltest +--exec chmod -r $MYSQLTEST_VARDIR/master-data/mysqltest select table_schema from information_schema.tables where table_schema='mysqltest'; ---exec chmod +r $MYSQL_TEST_DIR/var/master-data/mysqltest +--exec chmod +r $MYSQLTEST_VARDIR/master-data/mysqltest drop database mysqltest; # diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 10cb1dcf08b..ceffc3ada5b 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -1715,3 +1715,32 @@ create table t1 (a varchar(255) character set utf8, key (a,b,c,d,e)) engine=innodb; --echo End of 5.0 tests + +# +# Test that cascading updates leading to duplicate keys give the correct +# error message (bug #9680) +# + +CREATE TABLE t1 ( + field1 varchar(8) NOT NULL DEFAULT '', + field2 varchar(8) NOT NULL DEFAULT '', + PRIMARY KEY (field1, field2) +) ENGINE=InnoDB; + +CREATE TABLE t2 ( + field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, + FOREIGN KEY (field1) REFERENCES t1 (field1) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; + +INSERT INTO t1 VALUES ('old', 'somevalu'); +INSERT INTO t1 VALUES ('other', 'anyvalue'); + +INSERT INTO t2 VALUES ('old'); +INSERT INTO t2 VALUES ('other'); + +--error ER_FOREIGN_DUPLICATE_KEY +UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; + +DROP TABLE t2; +DROP TABLE t1; diff --git a/mysql-test/t/innodb_cache.test b/mysql-test/t/innodb_cache.test index a811d660bd7..8ed2853e4f7 100644 --- a/mysql-test/t/innodb_cache.test +++ b/mysql-test/t/innodb_cache.test @@ -63,6 +63,7 @@ drop table t1; # # one statement roll back inside transation # +let $save_query_cache_size=`select @@global.query_cache_size`; set GLOBAL query_cache_size=1355776; CREATE TABLE t1 ( id int(10) NOT NULL auto_increment, a varchar(25) default NULL, PRIMARY KEY (id), UNIQUE KEY a (a)) ENGINE=innodb; CREATE TABLE t2 ( id int(10) NOT NULL auto_increment, b varchar(25) default NULL, PRIMARY KEY (id), UNIQUE KEY b (b)) ENGINE=innodb; @@ -79,5 +80,8 @@ insert into t3 VALUES ( NULL, 1, 1, 2 ); commit; select t1.* from t1, t2, t3 where t3.state & 1 = 0 and t3.t1_id = t1.id and t3.t2_id = t2.id and t1.id = 1 order by t1.a asc; drop table t3,t2,t1; +--disable_query_log +eval set GLOBAL query_cache_size=$save_query_cache_size; +--enable_query_log # End of 4.1 tests diff --git a/mysql-test/t/innodb_concurrent.test b/mysql-test/t/innodb_concurrent.test index 1595fcd2467..957276a44c7 100644 --- a/mysql-test/t/innodb_concurrent.test +++ b/mysql-test/t/innodb_concurrent.test @@ -11,7 +11,7 @@ connection default; drop table if exists t1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb; connect (thread1, localhost, mysqltest,,); connection thread1; insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); @@ -57,7 +57,7 @@ drop table t1; # #connect (thread1, localhost, mysqltest,,); connection thread1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb; insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc"); @@ -132,7 +132,7 @@ drop table t1; # #connect (thread1, localhost, mysqltest,,); connection thread1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb; insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc"); @@ -175,7 +175,7 @@ drop table t1; # #connect (thread1, localhost, mysqltest,,); connection thread1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb; insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc"); @@ -218,7 +218,7 @@ drop table t1; # #connect (thread1, localhost, mysqltest,,); connection thread1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb; insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc"); @@ -261,7 +261,7 @@ drop table t1; # #connect (thread1, localhost, mysqltest,,); connection thread1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb; insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc"); @@ -305,7 +305,7 @@ drop table t1; # #connect (thread1, localhost, mysqltest,,); connection thread1; -create table t1(eta int(11) not null, tipo int(11), c varchar(255)) type=innodb; +create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb; insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc"); diff --git a/mysql-test/t/innodb_unsafe_binlog-master.opt b/mysql-test/t/innodb_unsafe_binlog-master.opt deleted file mode 100644 index 503c8457b2c..00000000000 --- a/mysql-test/t/innodb_unsafe_binlog-master.opt +++ /dev/null @@ -1 +0,0 @@ ---innodb_locks_unsafe_for_binlog=true diff --git a/mysql-test/t/innodb_unsafe_binlog.test b/mysql-test/t/innodb_unsafe_binlog.test deleted file mode 100644 index fa240eb7608..00000000000 --- a/mysql-test/t/innodb_unsafe_binlog.test +++ /dev/null @@ -1,67 +0,0 @@ --- source include/have_innodb.inc -# -# Note that these tests uses a innodb_locks_unsafe_for_binlog option. -# -# Test cases for a bug #15650 DELETE with LEFT JOIN crashes server -# - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings -create table t1 (id int not null, f_id int not null, f int not null, -primary key(f_id, id)) engine=innodb; -create table t2 (id int not null,s_id int not null,s varchar(200), -primary key(id)) engine=innodb; -INSERT INTO t1 VALUES (8, 1, 3); -INSERT INTO t1 VALUES (1, 2, 1); -INSERT INTO t2 VALUES (1, 0, ''); -INSERT INTO t2 VALUES (8, 1, ''); -commit; -DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id) -WHERE mm.id IS NULL; -select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id) -where mm.id is null lock in share mode; -drop table t1,t2; - -create table t1 (id int not null, f_id int not null, f int not null, -primary key(id),key(f_id)) engine=innodb; -create table t2 (id int not null,s_id int not null,s varchar(200), -primary key(id),key(s_id)) engine=innodb; -INSERT INTO t1 VALUES (8, 1, 3); -INSERT INTO t1 VALUES (1, 2, 1); -INSERT INTO t2 VALUES (1, 0, ''); -INSERT INTO t2 VALUES (8, 1, ''); -commit; -delete ml.* from t1 as ml left join t2 as mm on (mm.s_id=ml.f_id) where mm.s is null; -select ml.* from t1 as ml left join t2 as mm on (mm.s_id=ml.f_id) where mm.s is null lock in share mode; -drop table t1,t2; - -# -# Test case for unlock row bug where unlock releases all locks granted for -# a row. Only the latest lock should be released. -# - -connect (a,localhost,root,,); -connect (b,localhost,root,,); -connection a; -create table t1(a int not null, b int, primary key(a)) engine=innodb; -insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2); -commit; -set autocommit = 0; -select * from t1 lock in share mode; -update t1 set b = 5 where b = 1; -connection b; -set autocommit = 0; -# -# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update -# ---error 1205 -select * from t1 where a = 2 and b = 2 for update; -connection a; -commit; -connection b; -commit; -drop table t1; -disconnect a; -disconnect b; - diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index 51d936f5b4f..ddde6cfa5d3 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -99,27 +99,22 @@ create table t1(number int auto_increment primary key, original_value varchar(50 set @value= "aa"; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); ---replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= "1aa"; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); ---replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= "aa1"; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); ---replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= "1e+1111111111a"; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); ---replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= "-1e+1111111111a"; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); ---replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() --error 1367 @@ -130,22 +125,18 @@ set @value= -1e+1111111111; set @value= 1e+111; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); ---replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= -1e+111; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); ---replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= 1; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); ---replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() set @value= -1; insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value); ---replace_result e-0 e- e+0 e+ --query_vertical select * from t1 where number =last_insert_id() drop table t1; diff --git a/mysql-test/t/join_nested.test b/mysql-test/t/join_nested.test index 145edded486..8adcf05be93 100644 --- a/mysql-test/t/join_nested.test +++ b/mysql-test/t/join_nested.test @@ -914,3 +914,31 @@ explain select * from t1 left join on (t1.a = t2.a); drop table t1, t2, t3; +# +# Bug #16260: single row table in the inner nest of an outer join +# + +CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t2 (pid int NOT NULL PRIMARY KEY, type varchar(10)); +CREATE TABLE t3 (cid int NOT NULL PRIMARY KEY, + id int NOT NULL, + pid int NOT NULL); + +INSERT INTO t1 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t2 VALUES (1, 'A'), (3, 'C'); +INSERT INTO t3 VALUES (1, 1, 1), (3, 3, 3); + +SELECT * FROM t1 p LEFT JOIN (t3 JOIN t1) + ON (t1.id=t3.id AND t1.type='B' AND p.id=t3.id) + LEFT JOIN t2 ON (t3.pid=t2.pid) + WHERE p.id=1; + +CREATE VIEW v1 AS + SELECT t3.* FROM t3 JOIN t1 ON t1.id=t3.id AND t1.type='B'; + +SELECT * FROM t1 p LEFT JOIN v1 ON p.id=v1.id + LEFT JOIN t2 ON v1.pid=t2.pid + WHERE p.id=1; + +DROP VIEW v1; +DROP TABLE t1,t2,t3; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 367b98f2485..03ad56ed2b6 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -700,6 +700,7 @@ SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS EMPNUM, NAME, GRP SELECT * FROM v1; SELECT * FROM v1 WHERE EMPNUM < 10; +DROP VIEW v1; DROP TABLE t1,t2; # diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index c50c35825fc..8302c767985 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -12,7 +12,7 @@ connect (con2, localhost, root,,); #remember id of con1 connection con1; --disable_warnings -drop table if exists t1; +drop table if exists t1, t2, t3; --enable_warnings --disable_reconnect @@ -47,6 +47,50 @@ connection con2; select 4; drop table t1; +connection default; +# +# BUG#14851: killing long running subquery processed via a temporary table. +# +create table t1 (id int primary key); +create table t2 (id int unsigned not null); + +connect (conn1, localhost, root,,); +connection conn1; + +-- disable_result_log +-- disable_query_log +let $1 = 4096; +while ($1) +{ + eval insert into t1 values ($1); + dec $1; +} +-- enable_query_log +-- enable_result_log + +insert into t2 select id from t1; + +create table t3 (kill_id int); +insert into t3 values(connection_id()); + +-- disable_result_log +send select id from t1 where id in (select distinct id from t2); +-- enable_result_log + +connect (conn2, localhost, root,,); +connection conn2; +select ((@id := kill_id) - kill_id) from t3; +-- sleep 1 +kill @id; + +connection conn1; +-- error 1053,2013 +reap; + +connection default; + +drop table t1, t2, t3; + # End of 4.1 tests # diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 014d09da746..34d2e7dbd54 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -7,25 +7,25 @@ drop table if exists t1, t2; --enable_warnings create table t1 (a date, b date, c date not null, d date); -load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ','; -load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; +load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ','; +load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; SELECT * from t1; truncate table t1; -load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); +load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); SELECT * from t1; drop table t1; create table t1 (a text, b text); -load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; +load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; select concat('|',a,'|'), concat('|',b,'|') from t1; drop table t1; create table t1 (a int, b char(10)); -load data infile '../../std_data/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; +load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; select * from t1; truncate table t1; -load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; +load data infile '../std_data_ln/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; # The empty line last comes from the end line field in the file select * from t1; @@ -38,23 +38,23 @@ SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=NO_AUTO_VALUE_ON_ZERO; create table t1(id integer not null auto_increment primary key); insert into t1 values(0); disable_query_log; -eval SELECT * INTO OUTFILE '$MYSQL_TEST_DIR/var/tmp/t1' from t1; +eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' from t1; delete from t1; -eval load data infile '$MYSQL_TEST_DIR/var/tmp/t1' into table t1; +eval load data infile '$MYSQLTEST_VARDIR/tmp/t1' into table t1; enable_query_log; select * from t1; ---exec rm $MYSQL_TEST_DIR/var/tmp/t1 +--exec rm $MYSQLTEST_VARDIR/tmp/t1 disable_query_log; -eval SELECT * INTO OUTFILE '$MYSQL_TEST_DIR/var/tmp/t1' +eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n' FROM t1; delete from t1; -eval load data infile '$MYSQL_TEST_DIR/var/tmp/t1' into table t1 +eval load data infile '$MYSQLTEST_VARDIR/tmp/t1' into table t1 FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n'; enable_query_log; select * from t1; ---exec rm $MYSQL_TEST_DIR/var/tmp/t1 +--exec rm $MYSQLTEST_VARDIR/tmp/t1 SET @@SQL_MODE=@OLD_SQL_MODE; drop table t1; @@ -63,7 +63,7 @@ drop table t1; # ENCLOSED # create table t1 (a varchar(20), b varchar(20)); -load data infile '../../std_data/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b); +load data infile '../std_data_ln/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b); select * from t1; drop table t1; @@ -74,40 +74,40 @@ drop table t1; # create table t1 (a int default 100, b int, c varchar(60)); # we can do something like this -load data infile '../../std_data/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b); +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b); select * from t1; truncate table t1; # we can use filled fields in expressions # we also assigning NULL value to field with non-NULL default here -load data infile '../../std_data/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a); +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a); select * from t1; truncate table t1; # we even can use variables in set clause, and missed columns will be set # with default values set @c:=123; -load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b); +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b); select * from t1; # let us test side-effect of such load -load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, @b); +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, @b); select * from t1; select @a, @b; truncate table t1; # now going to test fixed field-row file format -load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow"; +load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow"; select * from t1; truncate table t1; # this also should work -load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c=concat(a,"+",b,"+",@c,"+",b,"+",if(c is null,"NIL",c)); +load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c=concat(a,"+",b,"+",@c,"+",b,"+",if(c is null,"NIL",c)); select * from t1; # and this should bark --error 1409 -load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b); +load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b); # Now let us test LOAD DATA with subselect create table t2 (num int primary key, str varchar(10)); insert into t2 values (10,'Ten'), (15,'Fifteen'); truncate table t1; -load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@dummy,@n) set a= @n, c= (select str from t2 where num=@n); +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@dummy,@n) set a= @n, c= (select str from t2 where num=@n); select * from t1; # cleanup diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test index 794beaa2a4d..7b7c30f002f 100644 --- a/mysql-test/t/log_tables.test +++ b/mysql-test/t/log_tables.test @@ -144,7 +144,24 @@ reap; select "Mark that we woke up from TRUNCATE in the test" as "test passed"; -disconnect con2; +connection con1; + +use test; + +# +# Bug #16905 Log tables: unicode statements are logged incorrectly +# + +truncate table mysql.general_log; +set names utf8; +create table bug16905 (s char(15) character set utf8 default 'пуÑто'); +insert into bug16905 values ('новое'); +--replace_column 1 TIMESTAMP +select * from mysql.general_log; +drop table bug16905; + +# kill all connections disconnect con1; +disconnect con2; --enable_ps_protocol diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index fb90c16bb86..4f07df4e4f2 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -711,14 +711,14 @@ eval set storage_engine=$default; # Test how DROP TABLE works if the index or data file doesn't exists create table t1 (a int) engine=myisam; -system rm ./var/master-data/test/t1.MYI ; +system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ; drop table if exists t1; create table t1 (a int) engine=myisam; -system rm ./var/master-data/test/t1.MYI ; +system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ; --error 1051,6 drop table t1; create table t1 (a int) engine=myisam; -system rm ./var/master-data/test/t1.MYD ; +system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYD ; --error 1105,6,29 drop table t1; --error 1051 diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 30af9fd8126..dbe80c84ede 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -24,11 +24,11 @@ insert into t2 values (); # test for load data and load data distributed among the several # files (we need to fill up first binlog) -load data infile '../../std_data/words.dat' into table t1; -load data infile '../../std_data/words.dat' into table t1; -load data infile '../../std_data/words.dat' into table t1; -load data infile '../../std_data/words.dat' into table t1; -load data infile '../../std_data/words.dat' into table t1; +load data infile '../std_data_ln/words.dat' into table t1; +load data infile '../std_data_ln/words.dat' into table t1; +load data infile '../std_data_ln/words.dat' into table t1; +load data infile '../std_data_ln/words.dat' into table t1; +load data infile '../std_data_ln/words.dat' into table t1; # simple query to show more in second binlog insert into t1 values ("Alas"); flush logs; @@ -43,29 +43,29 @@ select "--- Local --" as ""; # be time dependend. Better than nothing. # ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ $MYSQL_TEST_DIR/var/log/master-bin.000001 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000001 # this should not fail but shouldn't produce any working statements --disable_query_log select "--- Broken LOAD DATA --" as ""; --enable_query_log ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ $MYSQL_TEST_DIR/var/log/master-bin.000002 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000002 # this should show almost nothing --disable_query_log select "--- --database --" as ""; --enable_query_log ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --database=nottest $MYSQL_TEST_DIR/var/log/master-bin.000001 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=nottest $MYSQLTEST_VARDIR/log/master-bin.000001 # this test for position option --disable_query_log select "--- --position --" as ""; --enable_query_log ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --position=235 $MYSQL_TEST_DIR/var/log/master-bin.000002 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=235 $MYSQLTEST_VARDIR/log/master-bin.000002 # These are tests for remote binlog. # They should return the same as previous test. @@ -75,29 +75,29 @@ select "--- Remote --" as ""; --enable_query_log # This is broken now ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 # This is broken too --disable_query_log select "--- Broken LOAD DATA --" as ""; --enable_query_log ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 # And this too ! (altough it is documented) --disable_query_log select "--- --database --" as ""; --enable_query_log ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.000001 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.000001 # Strangely but this works --disable_query_log select "--- --position --" as ""; --enable_query_log ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=235 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=235 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 # Bug#7853 (mysqlbinlog does not accept input from stdin) --disable_query_log diff --git a/mysql-test/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test index 89af8e33a03..91da502da02 100644 --- a/mysql-test/t/mysqlbinlog2.test +++ b/mysql-test/t/mysqlbinlog2.test @@ -43,28 +43,28 @@ select "--- Local --" as ""; # be time dependent (the Start events). Better than nothing. # ---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 --disable_query_log select "--- offset --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --offset=2 $MYSQL_TEST_DIR/var/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --offset=2 $MYSQLTEST_VARDIR/log/master-bin.000001 --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=604 $MYSQL_TEST_DIR/var/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --start-position=604 $MYSQLTEST_VARDIR/log/master-bin.000001 --disable_query_log select "--- stop-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --stop-position=604 $MYSQL_TEST_DIR/var/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --stop-position=604 $MYSQLTEST_VARDIR/log/master-bin.000001 --disable_query_log select "--- start-datetime --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQL_TEST_DIR/var/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 --disable_query_log select "--- stop-datetime --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" $MYSQL_TEST_DIR/var/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 --disable_query_log select "--- Local with 2 binlogs on command line --" as ""; @@ -72,28 +72,28 @@ select "--- Local with 2 binlogs on command line --" as ""; # This is to verify that some options apply only to first, or last binlog ---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 --disable_query_log select "--- offset --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --offset=2 $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form --offset=2 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=604 $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form --start-position=604 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 --disable_query_log select "--- stop-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --stop-position=130 $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form --stop-position=130 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 --disable_query_log select "--- start-datetime --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 --disable_query_log select "--- stop-datetime --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 --disable_query_log select "--- Remote --" as ""; diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index e688e89ad05..dea8e32869e 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -125,14 +125,14 @@ drop table t1; create table t1(a int); insert into t1 values (1),(2),(3); ---exec $MYSQL_DUMP --skip-comments --tab=$MYSQL_TEST_DIR/var/tmp/ test ---exec cat $MYSQL_TEST_DIR/var/tmp/t1.sql ---exec cat $MYSQL_TEST_DIR/var/tmp/t1.txt ---exec rm $MYSQL_TEST_DIR/var/tmp/t1.sql ---exec rm $MYSQL_TEST_DIR/var/tmp/t1.txt ---exec $MYSQL_DUMP --tab=$MYSQL_TEST_DIR/var/tmp/ test ---exec rm $MYSQL_TEST_DIR/var/tmp/t1.sql ---exec rm $MYSQL_TEST_DIR/var/tmp/t1.txt +--exec $MYSQL_DUMP --skip-comments --tab=$MYSQLTEST_VARDIR/tmp/ test +--exec cat $MYSQLTEST_VARDIR/tmp/t1.sql +--exec cat $MYSQLTEST_VARDIR/tmp/t1.txt +--exec rm $MYSQLTEST_VARDIR/tmp/t1.sql +--exec rm $MYSQLTEST_VARDIR/tmp/t1.txt +--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ test +--exec rm $MYSQLTEST_VARDIR/tmp/t1.sql +--exec rm $MYSQLTEST_VARDIR/tmp/t1.txt drop table t1; # @@ -587,7 +587,7 @@ create view v1 as select * from t2; create view v2 as select * from t1; # dump tables and view from db2 ---exec $MYSQL_DUMP db2 > var/tmp/bug10713.sql +--exec $MYSQL_DUMP db2 > $MYSQLTEST_VARDIR/tmp/bug10713.sql # drop the db, tables and views drop table t1, t2; @@ -597,7 +597,7 @@ drop database db2; # create db1 and reload dump create database db1; use db1; ---exec $MYSQL db1 < var/tmp/bug10713.sql +--exec $MYSQL db1 < $MYSQLTEST_VARDIR/tmp/bug10713.sql # check that all tables and views could be created show tables; @@ -705,9 +705,9 @@ drop table t1, t2; create table t1 (a text character set utf8, b text character set latin1); insert t1 values (0x4F736E616272C3BC636B, 0x4BF66C6E); select * from t1; ---exec $MYSQL_DUMP --tab=$MYSQL_TEST_DIR/var/tmp/ test ---exec $MYSQL test < $MYSQL_TEST_DIR/var/tmp/t1.sql ---exec $MYSQL_IMPORT test $MYSQL_TEST_DIR/var/tmp/t1.txt +--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ test +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql +--exec $MYSQL_IMPORT test $MYSQLTEST_VARDIR/tmp/t1.txt select * from t1; drop table t1; @@ -827,9 +827,9 @@ update t1 set a = 4 where a=3; # Skip dumping triggers --exec $MYSQL_DUMP --skip-comments --databases --skip-triggers test # Dump and reload... ---exec $MYSQL_DUMP --skip-comments --databases test > var/tmp/mysqldump.sql +--exec $MYSQL_DUMP --skip-comments --databases test > $MYSQLTEST_VARDIR/tmp/mysqldump.sql drop table t1; ---exec $MYSQL test < var/tmp/mysqldump.sql +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqldump.sql # Check that tables have been reloaded show tables; --replace_column 6 # @@ -840,11 +840,11 @@ DROP TABLE t1, t2; # Bugs #9136, #12917: problems with --defaults-extra-file option # ---exec echo "[mysqltest1]" > $MYSQL_TEST_DIR/var/tmp/tmp.cnf ---exec echo "port=1234" >> $MYSQL_TEST_DIR/var/tmp/tmp.cnf ---exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQL_TEST_DIR/var/tmp/tmp.cnf mysqltest1 ---exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQL_TEST_DIR/var/tmp/tmp.cnf mysqltest1 mysqltest1 ---exec rm $MYSQL_TEST_DIR/var/tmp/tmp.cnf +--exec echo "[mysqltest1]" > $MYSQLTEST_VARDIR/tmp/tmp.cnf +--exec echo "port=1234" >> $MYSQLTEST_VARDIR/tmp/tmp.cnf +--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 +--exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 mysqltest1 +--exec rm $MYSQLTEST_VARDIR/tmp/tmp.cnf # # Test of fix to BUG 12597 @@ -869,13 +869,13 @@ INSERT INTO `test1` VALUES (1); SELECT * FROM `test2`; # dump ---exec $MYSQL_DUMP --skip-comments --databases test > var/tmp/mysqldump.sql +--exec $MYSQL_DUMP --skip-comments --databases test > $MYSQLTEST_VARDIR/tmp/mysqldump.sql #DROP TRIGGER testref; #DROP TABLE test1; #DROP TABLE test2; # restore ---exec $MYSQL test < var/tmp/mysqldump.sql +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqldump.sql SHOW TRIGGERS; SELECT * FROM `test1`; SELECT * FROM `test2`; @@ -1048,3 +1048,27 @@ SET SQL_MODE = @old_sql_mode; DROP TRIGGER tr1; DROP TABLE t1; + +# +# Added for use-thread option +# +create table t1 (a text , b text); +create table t2 (a text , b text); +insert t1 values ("Duck, Duck", "goose"); +insert t1 values ("Duck, Duck", "pidgeon"); +insert t2 values ("We the people", "in order to perform"); +insert t2 values ("a more perfect", "union"); +select * from t1; +select * from t2; +--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ test +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t2.sql +# The first load tests the pausing code +--exec $MYSQL_IMPORT --use-threads=1 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt +# Now we test with multiple threads! +--exec $MYSQL_IMPORT --use-threads=5 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt +select * from t1; +select * from t2; + +drop table t1; +drop table t2; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index a59788ae229..271d6fb783e 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -360,20 +360,20 @@ select 3 from t1 ; # Missing delimiter # The comment will be "sucked into" the sleep command since # delimiter is missing until after "show status" ---system echo "sleep 4" > var/tmp/mysqltest.sql ---system echo "# A comment" >> var/tmp/mysqltest.sql ---system echo "show status;" >> var/tmp/mysqltest.sql +--system echo "sleep 4" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql +--system echo "# A comment" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql +--system echo "show status;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql --error 1 ---exec $MYSQL_TEST < var/tmp/mysqltest.sql 2>&1 +--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 # # Missing delimiter until eof # The comment will be "sucked into" the sleep command since # delimiter is missing ---system echo "sleep 7" > var/tmp/mysqltest.sql ---system echo "# Another comment" >> var/tmp/mysqltest.sql +--system echo "sleep 7" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql +--system echo "# Another comment" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql --error 1 ---exec $MYSQL_TEST < var/tmp/mysqltest.sql 2>&1 +--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 # # Extra delimiter @@ -587,25 +587,26 @@ echo $var3_var3; --exec echo "source non_existingFile;" | $MYSQL_TEST 2>&1 # Too many source ---exec echo "source var/tmp/recursive.sql;" > var/tmp/recursive.sql +--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" > $MYSQLTEST_VARDIR/tmp/recursive.sql +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --error 1 ---exec echo "source var/tmp/recursive.sql;" | $MYSQL_TEST 2>&1 +--exec echo "source $MYSQLTEST_VARDIR/tmp/recursive.sql;" | $MYSQL_TEST 2>&1 # Source a file with error ---exec echo "garbage ;" > var/tmp/error.sql +--exec echo "garbage ;" > $MYSQLTEST_VARDIR/tmp/error.sql +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --error 1 ---exec echo "source var/tmp/error.sql;" | $MYSQL_TEST 2>&1 +--exec echo "source $MYSQLTEST_VARDIR/tmp/error.sql;" | $MYSQL_TEST 2>&1 # Test execution of source in a while loop ---exec echo "echo here is the sourced script;" > var/tmp/sourced.sql --disable_query_log let $outer= 2; # Number of outer loops while ($outer) { eval SELECT '$outer = outer loop variable after while' AS ""; - --source var/tmp/sourced.sql + --source include/sourced.inc eval SELECT '$outer = outer loop variable before dec' AS ""; dec $outer; @@ -626,7 +627,6 @@ while ($outer) # Test execution of source in a while loop ---exec echo "--source var/tmp/sourced.sql" > var/tmp/sourced1.sql --disable_abort_on_error # Sourcing of a file within while loop, sourced file will # source other file @@ -634,7 +634,7 @@ let $num= 9; while ($num) { SELECT 'In loop' AS ""; - --source var/tmp/sourced1.sql + --source include/sourced1.inc dec $num; } --enable_abort_on_error @@ -772,20 +772,20 @@ while ($i) --error 1 --exec echo "{;" | $MYSQL_TEST 2>&1 ---system echo "while (0)" > var/tmp/mysqltest.sql ---system echo "echo hej;" >> var/tmp/mysqltest.sql +--system echo "while (0)" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql +--system echo "echo hej;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql --error 1 ---exec $MYSQL_TEST < var/tmp/mysqltest.sql 2>&1 +--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 ---system echo "while (0)" > var/tmp/mysqltest.sql ---system echo "{echo hej;" >> var/tmp/mysqltest.sql +--system echo "while (0)" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql +--system echo "{echo hej;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql --error 1 ---exec $MYSQL_TEST < var/tmp/mysqltest.sql 2>&1 +--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 ---system echo "while (0){" > var/tmp/mysqltest.sql ---system echo "echo hej;" >> var/tmp/mysqltest.sql +--system echo "while (0){" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql +--system echo "echo hej;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql --error 1 ---exec $MYSQL_TEST < var/tmp/mysqltest.sql 2>&1 +--exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1 # ---------------------------------------------------------------------------- # Test error messages returned from comments starting with a command @@ -876,38 +876,41 @@ select "a" as col1, "c" as col2; --exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $MYSQL_TEST 2>&1 # Repeat connect/disconnect ---exec echo "let \$i=100;" > var/tmp/con.sql ---exec echo "while (\$i)" >> var/tmp/con.sql ---exec echo "{" >> var/tmp/con.sql ---exec echo " connect (test_con1,localhost,root,,); " >> var/tmp/con.sql ---exec echo " disconnect test_con1; " >> var/tmp/con.sql ---exec echo " dec \$i; " >> var/tmp/con.sql ---exec echo "}" >> var/tmp/con.sql ---exec echo "source var/tmp/con.sql; echo OK;" | $MYSQL_TEST 2>&1 +--exec echo "let \$i=100;" > $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo "while (\$i)" >> $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo "{" >> $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo " connect (test_con1,localhost,root,,); " >> $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo " disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo " dec \$i; " >> $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo "}" >> $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo "source $MYSQLTEST_VARDIR/tmp/con.sql; echo OK;" | $MYSQL_TEST 2>&1 # Repeat connect/disconnect, exceed max number of connections ---exec echo "let \$i=200;" > var/tmp/con.sql ---exec echo "while (\$i)" >> var/tmp/con.sql ---exec echo "{" >> var/tmp/con.sql ---exec echo " connect (test_con1,localhost,root,,); " >> var/tmp/con.sql ---exec echo " disconnect test_con1; " >> var/tmp/con.sql ---exec echo " dec \$i; " >> var/tmp/con.sql ---exec echo "}" >> var/tmp/con.sql +--exec echo "let \$i=200;" > $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo "while (\$i)" >> $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo "{" >> $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo " connect (test_con1,localhost,root,,); " >> $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo " disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo " dec \$i; " >> $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo "}" >> $MYSQLTEST_VARDIR/tmp/con.sql +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --error 1 ---exec echo "source var/tmp/con.sql;" | $MYSQL_TEST 2>&1 +--exec echo "source $MYSQLTEST_VARDIR/tmp/con.sql;" | $MYSQL_TEST 2>&1 # Select disconnected connection ---exec echo "connect (test_con1,localhost,root,,);" > var/tmp/con.sql ---exec echo "disconnect test_con1; " >> var/tmp/con.sql ---exec echo "connection test_con1;" >> var/tmp/con.sql +--exec echo "connect (test_con1,localhost,root,,);" > $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo "disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo "connection test_con1;" >> $MYSQLTEST_VARDIR/tmp/con.sql +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --error 1 ---exec echo "source var/tmp/con.sql;" | $MYSQL_TEST 2>&1 +--exec echo "source $MYSQLTEST_VARDIR/tmp/con.sql;" | $MYSQL_TEST 2>&1 # Connection name already used ---exec echo "connect (test_con1,localhost,root,,);" > var/tmp/con.sql ---exec echo "connect (test_con1,localhost,root,,);" >> var/tmp/con.sql +--exec echo "connect (test_con1,localhost,root,,);" > $MYSQLTEST_VARDIR/tmp/con.sql +--exec echo "connect (test_con1,localhost,root,,);" >> $MYSQLTEST_VARDIR/tmp/con.sql +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --error 1 ---exec echo "source var/tmp/con.sql;" | $MYSQL_TEST 2>&1 +--exec echo "source $MYSQLTEST_VARDIR/tmp/con.sql;" | $MYSQL_TEST 2>&1 # connect when "disable_abort_on_error" caused "connection not found" --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT @@ -999,26 +1002,26 @@ select "this will be executed"; # # Test zero length result file. Should not pass # ---exec touch $MYSQL_TEST_DIR/var/tmp/zero_length_file.result ---exec echo "echo ok;" > $MYSQL_TEST_DIR/var/tmp/query.sql +--exec touch $MYSQLTEST_VARDIR/tmp/zero_length_file.result +--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql --error 1 ---exec $MYSQL_TEST -x var/tmp/query.sql -R var/tmp/zero_length_file.result 2>&1 +--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result 2>&1 # # Test that a test file that does not generate any output fails. # ---exec echo "let \$i= 1;" > $MYSQL_TEST_DIR/var/tmp/query.sql +--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql --error 1 ---exec $MYSQL_TEST -x var/tmp/query.sql 2>&1 +--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql 2>&1 # # Test that mysqltest fails when there are no queries executed # but a result file exist # NOTE! This will never happen as long as it's not allowed to have # test files that does not produce any output -#--exec echo "something" > $MYSQL_TEST_DIR/var/tmp/result_file.result -#--exec echo "let \$i= 1;" > $MYSQL_TEST_DIR/var/tmp/query.sql +#--exec echo "something" > $MYSQLTEST_VARDIR/tmp/result_file.result +#--exec echo "let \$i= 1;" > $MYSQLTEST_VARDIR/tmp/query.sql #--error 1 -#--exec $MYSQL_TEST -x var/tmp/query.sql -R var/tmp/result_file.result 2>&1 +#--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/result_file.result 2>&1 # # Bug #11731 mysqltest in multi-statement queries ignores errors in @@ -1027,43 +1030,43 @@ select "this will be executed"; echo Failing multi statement query; # PS does not support multi statement ---exec echo "--disable_ps_protocol" > var/tmp/bug11731.sql ---exec echo "delimiter ||||;" >> var/tmp/bug11731.sql ---exec echo "create table t1 (a int primary key);" >> var/tmp/bug11731.sql ---exec echo "insert into t1 values (1);" >> var/tmp/bug11731.sql ---exec echo "select 'select-me';" >> var/tmp/bug11731.sql ---exec echo "insertz 'error query'||||" >> var/tmp/bug11731.sql ---exec echo "delimiter ;||||" >> var/tmp/bug11731.sql +--exec echo "--disable_ps_protocol" > $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "delimiter ||||;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "create table t1 (a int primary key);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "insert into t1 values (1);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "insertz 'error query'||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql --error 1 ---exec $MYSQL_TEST -x $MYSQL_TEST_DIR/var/tmp/bug11731.sql 2>&1 +--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1 drop table t1; --error 1 ---exec $MYSQL_TEST --record -x $MYSQL_TEST_DIR/var/tmp/bug11731.sql -R $MYSQL_TEST_DIR/var/tmp/bug11731.out 2>&1 +--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1 # The .out file should be non existent ---exec test ! -s $MYSQL_TEST_DIR/var/tmp/bug11731.out +--exec test ! -s $MYSQLTEST_VARDIR/tmp/bug11731.out drop table t1; echo Multi statement using expected error; # PS does not support multi statement ---exec echo "--disable_ps_protocol" > var/tmp/bug11731.sql ---exec echo "delimiter ||||;" >> var/tmp/bug11731.sql ---exec echo "--error 1064" >> var/tmp/bug11731.sql ---exec echo "create table t1 (a int primary key);" >> var/tmp/bug11731.sql ---exec echo "insert into t1 values (1);" >> var/tmp/bug11731.sql ---exec echo "select 'select-me';" >> var/tmp/bug11731.sql ---exec echo "insertz "error query"||||" >> var/tmp/bug11731.sql ---exec echo "delimiter ;||||" >> var/tmp/bug11731.sql +--exec echo "--disable_ps_protocol" > $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "delimiter ||||;" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "--error 1064" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "create table t1 (a int primary key);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "insert into t1 values (1);" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "select 'select-me';" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "insertz "error query"||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql +--exec echo "delimiter ;||||" >> $MYSQLTEST_VARDIR/tmp/bug11731.sql # These two should work since the error is expected ---exec $MYSQL_TEST -x $MYSQL_TEST_DIR/var/tmp/bug11731.sql 2>&1 +--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/bug11731.sql 2>&1 drop table t1; ---exec $MYSQL_TEST --record -x $MYSQL_TEST_DIR/var/tmp/bug11731.sql -R $MYSQL_TEST_DIR/var/tmp/bug11731.out 2>&1 +--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1 # The .out file should exist ---exec test -s $MYSQL_TEST_DIR/var/tmp/bug11731.out +--exec test -s $MYSQLTEST_VARDIR/tmp/bug11731.out drop table t1; @@ -1094,3 +1097,13 @@ select "strawberry","blueberry","potato"; --exec echo "--replace_regex /a b c" | $MYSQL_TEST 2>&1 --error 1 --exec echo "replace_regex /a /b c ;" | $MYSQL_TEST 2>&1 + +# REQUIREMENT +# replace_regex should replace substitutions from left to right in output + +create table t1 (a int, b int); +insert into t1 values (1,3); +insert into t1 values (2,4); +--replace_regex /A/C/ /B/D/i /3/2/ /2/1/ +select * from t1; +drop table t1; diff --git a/mysql-test/t/ndb_autodiscover.test b/mysql-test/t/ndb_autodiscover.test index 7192cc89a07..7424687cd8a 100644 --- a/mysql-test/t/ndb_autodiscover.test +++ b/mysql-test/t/ndb_autodiscover.test @@ -24,7 +24,7 @@ create table t1( insert into t1 values(1, "Autodiscover"); flush tables; -system rm var/master-data/test/t1.frm ; +system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ; select * from t1; show status like 'handler_discover%'; @@ -33,13 +33,13 @@ show status like 'handler_discover%'; # flush tables; -system rm var/master-data/test/t1.frm ; +system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ; insert into t1 values (2, "Auto 2"); show status like 'handler_discover%'; insert into t1 values (3, "Discover 3"); show status like 'handler_discover%'; flush tables; -system rm var/master-data/test/t1.frm ; +system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ; select * from t1 order by id; show status like 'handler_discover%'; @@ -48,7 +48,7 @@ show status like 'handler_discover%'; # flush tables; -system rm var/master-data/test/t1.frm ; +system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ; update t1 set name="Autodiscover" where id = 2; show status like 'handler_discover%'; select * from t1 order by id; @@ -59,7 +59,7 @@ show status like 'handler_discover%'; # flush tables; -system rm var/master-data/test/t1.frm ; +system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm ; delete from t1 where id = 3; select * from t1 order by id; show status like 'handler_discover%'; @@ -85,7 +85,7 @@ show status like 'handler_discover%'; flush tables; # Modify the frm file on disk -system echo "blaj" >> var/master-data/test/t2.frm ; +system echo "blaj" >> $MYSQLTEST_VARDIR/master-data/test/t2.frm ; select * from t2; show status like 'handler_discover%'; @@ -111,7 +111,7 @@ show status like 'handler_discover%'; flush tables; # Remove the frm file from disk -system rm var/master-data/test/t3.frm ; +system rm $MYSQLTEST_VARDIR/master-data/test/t3.frm ; --error 1050 create table t3( @@ -168,14 +168,14 @@ show status like 'handler_discover%'; # Remove the frm file from disk flush tables; -system rm var/master-data/test/t7.frm ; +system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm ; show tables from test; show status like 'handler_discover%'; # Remove the frm file from disk again flush tables; -system rm var/master-data/test/t7.frm ; +system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm ; --replace_column 6 # 7 # 8 # 9 # 12 # 13 # 15 # 18 # show table status; @@ -290,8 +290,8 @@ insert into t9 values (9); system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 >> $NDB_TOOLS_OUTPUT ; system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 >> $NDB_TOOLS_OUTPUT ; # Remove t6, t7 from disk -system rm var/master-data/test/t6.frm > /dev/null ; -system rm var/master-data/test/t7.frm > /dev/null ; +system rm $MYSQLTEST_VARDIR/master-data/test/t6.frm > /dev/null ; +system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm > /dev/null ; SHOW TABLES; @@ -332,8 +332,8 @@ insert into t9 values (9); system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 > /dev/null ; system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 > /dev/null ; # Remove t6, t7 from disk -system rm var/master-data/test/t6.frm > /dev/null ; -system rm var/master-data/test/t7.frm > /dev/null ; +system rm $MYSQLTEST_VARDIR/master-data/test/t6.frm > /dev/null ; +system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm > /dev/null ; SHOW TABLES LIKE 't6'; @@ -375,9 +375,9 @@ insert into t3 values (3, "ndb table 3"); insert into t4 values (4); # Remove t1, t2, t3 from disk -system rm var/master-data/test/t1.frm > /dev/null ; -system rm var/master-data/test/t2.frm > /dev/null ; -system rm var/master-data/test/t3.frm > /dev/null ; +system rm $MYSQLTEST_VARDIR/master-data/test/t1.frm > /dev/null ; +system rm $MYSQLTEST_VARDIR/master-data/test/t2.frm > /dev/null ; +system rm $MYSQLTEST_VARDIR/master-data/test/t3.frm > /dev/null ; flush tables; # Select from the table which only exists in NDB. @@ -530,7 +530,7 @@ CREATE TABLE t9 ( insert t9 values(1, 2), (2,3), (3, 4), (4, 5); #Don't drop the table, instead remove the frm file -system rm var/master-data/test/t9.frm ; +system rm $MYSQLTEST_VARDIR/master-data/test/t9.frm ; # Now leave test case, when ndb_autodiscover2 will run, this # MySQL Server will have been restarted because it has a diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index e99503843bd..df94545abea 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -404,7 +404,9 @@ drop table t1; # # test the limit of no of attributes in one table # - +# also tests bug#17179, more than 31 attributes in +# a partitioned table +# create table t1 ( c1 int, c2 int, @@ -534,7 +536,7 @@ c125 int, c126 int, c127 int, c128 int, -primary key(c1)) engine=ndb; +primary key using hash(c1)) engine=ndb partition by key(c1); drop table t1; # @@ -625,6 +627,72 @@ CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb; select * from t1; drop table t1; +# +# Bug #17249 delete statement with join where clause fails +# when table do not have pk +# + +create table t1 (a int) engine=ndb; +create table t2 (a int) engine=ndb; +insert into t1 values (1); +insert into t2 values (1); +delete t1.* from t1, t2 where t1.a = t2.a; +select * from t1; +select * from t2; +drop table t1; +drop table t2; + +# +# Bug #17257 update fails for inner joins if tables +# do not have Primary Key +# + +CREATE TABLE t1 ( + i INT, + j INT, + x INT, + y INT, + z INT +) engine=ndb; + +CREATE TABLE t2 ( + i INT, + k INT, + x INT, + y INT, + z INT +) engine=ndb; + +CREATE TABLE t3 ( + j INT, + k INT, + x INT, + y INT, + z INT +) engine=ndb; + +INSERT INTO t1 VALUES ( 1, 2,13,14,15); +INSERT INTO t2 VALUES ( 1, 3,23,24,25); +INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36); + +UPDATE t1 AS a +INNER JOIN t2 AS b + ON a.i = b.i +INNER JOIN t3 AS c + ON a.j = c.j AND b.k = c.k +SET a.x = b.x, + a.y = b.y, + a.z = ( + SELECT sum(z) + FROM t3 + WHERE y = 34 + ) +WHERE b.x = 23; +select * from t1; +drop table t1; +drop table t2; +drop table t3; + # End of 4.1 tests # diff --git a/mysql-test/t/ndb_binlog_ddl_multi.test b/mysql-test/t/ndb_binlog_ddl_multi.test index 17d304db0b1..3aa3b9469fd 100644 --- a/mysql-test/t/ndb_binlog_ddl_multi.test +++ b/mysql-test/t/ndb_binlog_ddl_multi.test @@ -33,10 +33,12 @@ create table t1 (a int primary key) engine=ndb; --connection server2 create table t2 (a int primary key) engine=ndb; +--replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start --connection server1 +--replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start @@ -51,6 +53,7 @@ reset master; alter table t2 add column (b int); --connections server1 +--replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start @@ -70,6 +73,7 @@ ALTER DATABASE mysqltest CHARACTER SET latin1; drop table mysqltest.t1; --connection server1 +--replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start @@ -87,6 +91,7 @@ drop database mysqltest; create table t1 (a int primary key) engine=ndb; --connection server2 +--replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start @@ -139,5 +144,6 @@ ENGINE =NDB; drop table t1; --connection server2 +--replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start diff --git a/mysql-test/t/ndb_binlog_ignore_db-master.opt b/mysql-test/t/ndb_binlog_ignore_db-master.opt new file mode 100644 index 00000000000..e3947c0eeed --- /dev/null +++ b/mysql-test/t/ndb_binlog_ignore_db-master.opt @@ -0,0 +1 @@ +--binlog-ignore-db=mysqltest diff --git a/mysql-test/t/ndb_binlog_ignore_db.test b/mysql-test/t/ndb_binlog_ignore_db.test new file mode 100644 index 00000000000..a46266f209a --- /dev/null +++ b/mysql-test/t/ndb_binlog_ignore_db.test @@ -0,0 +1,19 @@ +-- source include/have_ndb.inc +-- source include/have_binlog_format_row.inc + +--let $binlog_start=102 + +--disable_warnings +drop table if exists t1; +drop database if exists mysqltest; +--enable_warnings + +create database mysqltest; +use mysqltest; +create table t1 (a int primary key, b int) engine=ndb; +insert into t1 values (1, 1); +--replace_result $binlog_start <binlog_start> +--replace_column 2 # 4 # 5 # +--eval show binlog events from $binlog_start + +drop database mysqltest; diff --git a/mysql-test/t/ndb_blob.test b/mysql-test/t/ndb_blob.test index a12ebee2f0d..f80b7f71281 100644 --- a/mysql-test/t/ndb_blob.test +++ b/mysql-test/t/ndb_blob.test @@ -338,7 +338,7 @@ select * from t1 order by a; drop table t1; drop database test2; -# -- bug-5252 tinytext crashes plus no-commit result -- +# -- bug-5252 tinytext crashes + no-commit result + replace -- set autocommit=0; create table t1 ( @@ -352,6 +352,10 @@ select * from t1; delete from t1; select * from t1; commit; +replace t1 set a=2, b='y'; +select * from t1; +delete from t1; +select * from t1; drop table t1; # -- bug-5013 insert empty string to text -- diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index 2185276c2c6..8561b3794c4 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -309,4 +309,18 @@ select * from t1 where code = '12' and month = 4 and year = 2004 ; drop table t1; +# bug#15918 Unique Key Limit in NDB Engine + +create table t1 (a int primary key, b varchar(1000) not null, unique key (b)) +engine=ndb charset=utf8; + +insert into t1 values (1, repeat(_utf8 0xe288ab6474, 200)); +--error 1062 +insert into t1 values (2, repeat(_utf8 0xe288ab6474, 200)); +select a, sha1(b) from t1; + +# perl -e 'print pack("H2000","e288ab6474"x200)' | sha1sum + +drop table t1; + # End of 4.1 tests diff --git a/mysql-test/t/ndb_view.test b/mysql-test/t/ndb_view.test new file mode 100644 index 00000000000..3b8fc330b40 --- /dev/null +++ b/mysql-test/t/ndb_view.test @@ -0,0 +1,29 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3; +DROP VIEW IF EXISTS v1,v2,v3; +--enable_warnings + +# +# simple operations via view +# + +create table t1 (a int, b int, c int, d int) engine=ndb; +insert into t1 values (1,2,3,4),(5,6,7,8); + +create view v1 as select t1.c as a, t1.a as b, t1.d as c, t1.a+t1.b+t1.c as d from t1; +select * from v1 order by a,b,c; + +update v1 set a=a+100 where b=1; +select * from v1 order by a,b,c; + +drop view v1; + +create view v1 as select t1.c as a from t1; +insert into v1 values (200); +select * from t1 order by a,b,c,d; + +drop view v1; +drop table t1; diff --git a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test index 37e96d9d38d..d404a6fff9f 100644 --- a/mysql-test/t/outfile.test +++ b/mysql-test/t/outfile.test @@ -1,6 +1,7 @@ disable_query_log; -- source include/test_outfile.inc -eval set @tmpdir="$MYSQL_TEST_DIR/var/tmp"; +# Server are started in "var/master-data", so "../tmp" will be "var/tmp" +eval set @tmpdir="../tmp"; enable_query_log; -- source include/have_outfile.inc @@ -15,42 +16,43 @@ drop table if exists t1; create table t1 (`a` blob); insert into t1 values("hello world"),("Hello mars"),(NULL); disable_query_log; -eval select * into outfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.1" from t1; +eval select * into outfile "../tmp/outfile-test.1" from t1; enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.1")); disable_query_log; -eval select * into dumpfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.2" from t1 limit 1; +eval select * into dumpfile "../tmp/outfile-test.2" from t1 limit 1; enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.2")); disable_query_log; -eval select * into dumpfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.3" from t1 where a is null; +eval select * into dumpfile "../tmp/outfile-test.3" from t1 where a is null; enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.3")); # the following should give errors -#disabled as error message has variable path -#disable_query_log; -#--error 1086 -#eval select * into outfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.1" from t1; -#--error 1086 -#eval select * into dumpfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.2" from t1; -#--error 1086 -#eval select * into dumpfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.3" from t1; -#enable_query_log; +disable_query_log; +--error 1086 +eval select * into outfile "../tmp/outfile-test.1" from t1; + +--error 1086 +eval select * into dumpfile "../tmp/outfile-test.2" from t1; + +--error 1086 +eval select * into dumpfile "../tmp/outfile-test.3" from t1; +enable_query_log; --error 13,2 select load_file(concat(@tmpdir,"/outfile-test.not-exist")); ---exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.1 ---exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.2 ---exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.3 +--exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.1 +--exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.2 +--exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.3 drop table t1; # Bug#8191 disable_query_log; -eval select 1 into outfile "$MYSQL_TEST_DIR/var/tmp/outfile-test.4"; +eval select 1 into outfile "../tmp/outfile-test.4"; enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.4")); ---exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.4 +--exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.4 # # Bug #5382: 'explain select into outfile' crashes the server @@ -70,16 +72,16 @@ DROP TABLE t1; # Bug#13202 SELECT * INTO OUTFILE ... FROM information_schema.schemata now fails # disable_query_log; -eval SELECT * INTO OUTFILE "$MYSQL_TEST_DIR/var/tmp/outfile-test.4" +eval SELECT * INTO OUTFILE "../tmp/outfile-test.4" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM information_schema.schemata LIMIT 0, 5; # enable_query_log; ---exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.4 +--exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.4 use information_schema; # disable_query_log; -eval SELECT * INTO OUTFILE "$MYSQL_TEST_DIR/var/tmp/outfile-test.4" +eval SELECT * INTO OUTFILE "../tmp/outfile-test.4" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM schemata LIMIT 0, 5; enable_query_log; ---exec rm $MYSQL_TEST_DIR/var/tmp/outfile-test.4 +--exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.4 diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test index fa844f02ace..6b168711de8 100644 --- a/mysql-test/t/ps_1general.test +++ b/mysql-test/t/ps_1general.test @@ -834,7 +834,7 @@ execute stmt1 ; --disable_metadata --horizontal_results -drop table t5, t9; +drop table t1, t5, t9; ##### RULES OF THUMB TO PRESERVE THE SYSTEMATICS OF THE PS TEST CASES ##### # diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index a99d802e5a5..15559d75d6c 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -787,6 +787,7 @@ begin end// call p1()// drop procedure p1// +drop function f1// drop table t1// delimiter ;// diff --git a/mysql-test/t/raid.test b/mysql-test/t/raid.test deleted file mode 100644 index 3ca5adaaaea..00000000000 --- a/mysql-test/t/raid.test +++ /dev/null @@ -1,224 +0,0 @@ --- require r/have_raid.require -disable_query_log; -show variables like "have_raid"; -enable_query_log; - -# -# Test of raided tables -# - ---disable_warnings -DROP TABLE IF EXISTS t1,t2; -DROP DATABASE IF EXISTS test_$1; ---enable_warnings - -# -# Test dropping database with raid tables -# - -create database test_$1; -create table test_$1.r1 (i int) raid_type=1; -create table test_$1.r2 (i int) raid_type=1 raid_chunks=32; -drop database test_$1; - -# -# Bug #3182: Test using more than 257 raid chunks -# -create database test_$1; -create table test_$1.r2 (i int) raid_type=1 raid_chunks=257; -show create table test_$1.r2; -drop database test_$1; - -# -# Test that data is spread over different raid directories -# - -CREATE TABLE t1 ( -id int unsigned not null auto_increment primary key, -c char(255) not null -) RAID_TYPE=STRIPED RAID_CHUNKS=2 RAID_CHUNKSIZE=123; -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -select count(*) from t1; -ALTER TABLE t1 ADD COLUMN x INT UNSIGNED NOT NULL; -ALTER TABLE t1 ADD KEY c (c); -ALTER TABLE t1 DROP KEY c; -ALTER TABLE t1 DROP COLUMN x; -ALTER TABLE t1 RENAME t2; -select count(*) from t2; -DROP TABLE t2; - -/* variable rows */ -CREATE TABLE t1 ( -id int unsigned not null auto_increment primary key, -c varchar(255) not null -) RAID_TYPE=STRIPED RAID_CHUNKS=5 RAID_CHUNKSIZE=121; -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -INSERT INTO t1 VALUES -(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'), -(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'), -(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'), -(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'), -(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'), -(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'), -(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'), -(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'), -(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'), -(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'), -(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'), -(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'), -(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'), -(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'), -(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a'); -select count(*) from t1; -ALTER TABLE t1 ADD COLUMN x INT UNSIGNED NOT NULL; -ALTER TABLE t1 ADD KEY c (c); -ALTER TABLE t1 DROP KEY c; -ALTER TABLE t1 DROP COLUMN x; -ALTER TABLE t1 RENAME t2; -ALTER TABLE t2 CHANGE COLUMN c c VARCHAR(251) NOT NULL; -select count(*) from t2; -DROP TABLE t2; - -# End of 4.1 tests diff --git a/mysql-test/t/read_only.test b/mysql-test/t/read_only.test index 1e92e438122..175a5bba6fa 100644 --- a/mysql-test/t/read_only.test +++ b/mysql-test/t/read_only.test @@ -104,3 +104,5 @@ insert into t1 values(1); connection default; drop table t1,t2; drop user test@localhost; + +set global read_only=0; diff --git a/mysql-test/t/renamedb.test b/mysql-test/t/renamedb.test new file mode 100644 index 00000000000..5cfb2ce0c12 --- /dev/null +++ b/mysql-test/t/renamedb.test @@ -0,0 +1,18 @@ +--disable_warnings +drop database if exists testdb1; +--enable_warnings + +create database testdb1 default character set latin2; +use testdb1; +create table t1 (a int); +insert into t1 values (1),(2),(3); +show create database testdb1; +show tables; +rename database testdb1 to testdb2; +--error 1049 +show create database testdb1; +show create database testdb2; +select database(); +show tables; +select a from t1 order by a; +drop database testdb2; diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair.test index 5e39e0b6a50..16e1d76d460 100644 --- a/mysql-test/t/repair.test +++ b/mysql-test/t/repair.test @@ -29,7 +29,7 @@ repair table t1 use_frm; create table t1 engine=myisam SELECT 1,"table 1"; flush tables; -system echo 1 > $MYSQL_TEST_DIR/var/master-data/test/t1.MYI ; +system echo 1 > $MYSQLTEST_VARDIR/master-data/test/t1.MYI ; repair table t1; repair table t1 use_frm; drop table t1; diff --git a/mysql-test/t/rpl000004.test b/mysql-test/t/rpl000004.test deleted file mode 100644 index f2a02bd4dd6..00000000000 --- a/mysql-test/t/rpl000004.test +++ /dev/null @@ -1,25 +0,0 @@ -source include/master-slave.inc; - -set SQL_LOG_BIN=0; -create table t1 (word char(20) not null, index(word)); -load data infile '../../std_data/words.dat' into table t1; -create table t2 (word char(20) not null); -load data infile '../../std_data/words.dat' into table t2; -create table t3 (word char(20) not null primary key); -connection slave; -load table t1 from master; -load table t2 from master; -load table t3 from master; -check table t1; -select count(*) from t2; -select count(*) from t3; -connection master; -set SQL_LOG_BIN=1; -drop table if exists t1,t2,t3; -save_master_pos; -connection slave; -sync_with_master; -create table t1(n int); -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/rpl000006.test b/mysql-test/t/rpl000006.test deleted file mode 100644 index bca97391f8e..00000000000 --- a/mysql-test/t/rpl000006.test +++ /dev/null @@ -1,2 +0,0 @@ -let $engine_type=MyISAM; --- source extra/rpl_tests/rpl000006.test diff --git a/mysql-test/t/rpl000017-slave.sh b/mysql-test/t/rpl000017-slave.sh index 4dbbaec31ce..17188aba0db 100755 --- a/mysql-test/t/rpl000017-slave.sh +++ b/mysql-test/t/rpl000017-slave.sh @@ -1,6 +1,6 @@ -rm -f $MYSQL_TEST_DIR/var/log/*relay* -rm -f $MYSQL_TEST_DIR/var/slave-data/relay-log.info -cat > $MYSQL_TEST_DIR/var/slave-data/master.info <<EOF +rm -f $MYSQLTEST_VARDIR/log/*relay* +rm -f $MYSQLTEST_VARDIR/slave-data/relay-log.info +cat > $MYSQLTEST_VARDIR/slave-data/master.info <<EOF master-bin.000001 4 127.0.0.1 diff --git a/mysql-test/t/rpl000017.test b/mysql-test/t/rpl000017.test index 792801dd3d2..2ba321cd8c3 100644 --- a/mysql-test/t/rpl000017.test +++ b/mysql-test/t/rpl000017.test @@ -16,6 +16,7 @@ sync_slave_with_master; select * from t1; connection master; drop table t1; +delete from mysql.user where user="replicate"; sync_slave_with_master; # End of 4.1 tests diff --git a/mysql-test/t/rpl_000015-slave.sh b/mysql-test/t/rpl_000015-slave.sh index 62748605af1..7deeca3d2d6 100755 --- a/mysql-test/t/rpl_000015-slave.sh +++ b/mysql-test/t/rpl_000015-slave.sh @@ -1 +1 @@ -rm -f $MYSQL_TEST_DIR/var/slave-data/master.info +rm -f $MYSQLTEST_VARDIR/slave-data/master.info diff --git a/mysql-test/t/rpl_LD_INFILE.test b/mysql-test/t/rpl_LD_INFILE.test index 769462b5898..ae647ed6648 100644 --- a/mysql-test/t/rpl_LD_INFILE.test +++ b/mysql-test/t/rpl_LD_INFILE.test @@ -11,7 +11,6 @@ # Begin clean up test section --disable_warnings connection master; -DROP PROCEDURE IF EXISTS test.p1; DROP TABLE IF EXISTS test.t1; --enable_warnings @@ -23,19 +22,17 @@ DELETE FROM test.t1; LOAD DATA INFILE '../../std_data/words2.dat' INTO TABLE test.t1; -connection master; -SELECT * FROM test.t1; +SELECT * FROM test.t1 ORDER BY a DESC; save_master_pos; sync_slave_with_master; connection slave; -SELECT * FROM test.t1; +SELECT * FROM test.t1 ORDER BY a DESC; -connection master; -# Lets cleanup +# Cleanup #show binlog events; - -DROP PROCEDURE IF EXISTS test.p1; +connection master; DROP TABLE test.t1; +sync_slave_with_master; # End of 5.0 test case diff --git a/mysql-test/t/rpl_auto_increment-slave.opt b/mysql-test/t/rpl_auto_increment-slave.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/t/rpl_auto_increment-slave.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/t/rpl_create_database.test b/mysql-test/t/rpl_create_database.test index 7ec73132113..70cff8daca2 100644 --- a/mysql-test/t/rpl_create_database.test +++ b/mysql-test/t/rpl_create_database.test @@ -58,8 +58,10 @@ let $VERSION=`select version()`; SHOW DATABASES; sync_slave_with_master; SHOW DATABASES; -SHOW CREATE TABLE mysqltest_prometheus.t1; -SHOW CREATE TABLE mysqltest_sisyfos.t2; +USE mysqltest_prometheus; +SHOW TABLES; +USE mysqltest_sisyfos; +SHOW TABLES; connection master; DROP DATABASE IF EXISTS mysqltest_prometheus; diff --git a/mysql-test/t/rpl_drop_db.test b/mysql-test/t/rpl_drop_db.test index 548009b758e..df17ec88aaa 100644 --- a/mysql-test/t/rpl_drop_db.test +++ b/mysql-test/t/rpl_drop_db.test @@ -54,5 +54,5 @@ sync_slave_with_master; #cleanup connection slave; stop slave; -#system rm -rf var/master-data/mysqltest1; +#system rm -rf $MYSQLTEST_VARDIR/master-data/mysqltest1; diff --git a/mysql-test/t/rpl_drop_temp.test b/mysql-test/t/rpl_drop_temp.test index 55a4e741d7c..305c78d3f06 100644 --- a/mysql-test/t/rpl_drop_temp.test +++ b/mysql-test/t/rpl_drop_temp.test @@ -1,17 +1,27 @@ +############################################## +# Change Author: JBM +# Change Date: 2006-02-07 +# Change: Added ENGINE=MyISAM +# Purpose: According to TU in 16552 This is how +# to work around NDB's issue with temp tables +############################################## source include/master-slave.inc; --disable_warnings create database if not exists mysqltest; --enable_warnings -create temporary table mysqltest.t1 (n int); -create temporary table mysqltest.t2 (n int); +create temporary table mysqltest.t1 (n int)ENGINE=MyISAM; +create temporary table mysqltest.t2 (n int)ENGINE=MyISAM; sync_slave_with_master; connection master; disconnect master; connection slave; --real_sleep 3 # time for DROP to be written show status like 'Slave_open_temp_tables'; + +# Cleanup connection default; drop database mysqltest; +sync_slave_with_master; # End of 4.1 tests diff --git a/mysql-test/t/rpl_err_ignoredtable.test b/mysql-test/t/rpl_err_ignoredtable.test index 81aa76225be..42ca8cf2e8b 100644 --- a/mysql-test/t/rpl_err_ignoredtable.test +++ b/mysql-test/t/rpl_err_ignoredtable.test @@ -1,15 +1,17 @@ # Test for # Bug #797: If a query is ignored on slave (replicate-ignore-table) the slave # still checks that it has the same error as on the master. +########################################################################## +# 2006-02-07 JBM Added error code 1022 for NDB Engine + ORDER BY +########################################################################## -# Requires statement logging -- source include/master-slave.inc connection master; create table t1 (a int primary key); create table t4 (a int primary key); # generate an error that goes to the binlog ---error 1062 +--error 1022, 1062 insert into t1 values (1),(1); insert into t4 values (1),(2); save_master_pos; @@ -19,7 +21,7 @@ sync_with_master; # check that the table has been ignored, because otherwise the test is nonsense show tables like 't1'; show tables like 't4'; -SELECT * FROM test.t4; +SELECT * FROM test.t4 ORDER BY a; connection master; drop table t1; save_master_pos; @@ -53,7 +55,7 @@ connection master1; save_master_pos; connection slave; sync_with_master; -SELECT * FROM test.t4; +SELECT * FROM test.t4 ORDER BY a; connection master1; DROP TABLE test.t4; diff --git a/mysql-test/t/rpl_flushlog_loop-master.opt b/mysql-test/t/rpl_flushlog_loop-master.opt index 4f6e0f3d00c..a4d1d403dc9 100644 --- a/mysql-test/t/rpl_flushlog_loop-master.opt +++ b/mysql-test/t/rpl_flushlog_loop-master.opt @@ -1 +1 @@ --O max_binlog_size=1M --relay-log=$MYSQL_TEST_DIR/var/master-data/relay-log +-O max_binlog_size=1M --relay-log=$MYSQLTEST_VARDIR/master-data/relay-log diff --git a/mysql-test/t/rpl_flushlog_loop-master.sh b/mysql-test/t/rpl_flushlog_loop-master.sh index 9e56af99f5c..a321dd690cd 100755 --- a/mysql-test/t/rpl_flushlog_loop-master.sh +++ b/mysql-test/t/rpl_flushlog_loop-master.sh @@ -1,5 +1,5 @@ -rm -f $MYSQL_TEST_DIR/var/slave-data/*-bin.* -rm -f $MYSQL_TEST_DIR/var/slave-data/master.info -rm -f $MYSQL_TEST_DIR/var/slave-data/*.index +rm -f $MYSQLTEST_VARDIR/slave-data/*-bin.* +rm -f $MYSQLTEST_VARDIR/slave-data/master.info +rm -f $MYSQLTEST_VARDIR/slave-data/*.index diff --git a/mysql-test/t/rpl_flushlog_loop-slave.opt b/mysql-test/t/rpl_flushlog_loop-slave.opt index d1373f139b1..95839c831c9 100644 --- a/mysql-test/t/rpl_flushlog_loop-slave.opt +++ b/mysql-test/t/rpl_flushlog_loop-slave.opt @@ -1 +1 @@ --O max_binlog_size=1M --relay-log=$MYSQL_TEST_DIR/var/slave-data/relay-log +-O max_binlog_size=1M --relay-log=$MYSQLTEST_VARDIR/slave-data/relay-log diff --git a/mysql-test/t/rpl_flushlog_loop-slave.sh b/mysql-test/t/rpl_flushlog_loop-slave.sh index b8814e059a9..e46ea6d400b 100755 --- a/mysql-test/t/rpl_flushlog_loop-slave.sh +++ b/mysql-test/t/rpl_flushlog_loop-slave.sh @@ -1,4 +1,4 @@ -rm -f $MYSQL_TEST_DIR/var/master-data/master.info -rm -f $MYSQL_TEST_DIR/var/master-data/*-bin.* -rm -f $MYSQL_TEST_DIR/var/master-data/*.index +rm -f $MYSQLTEST_VARDIR/master-data/master.info +rm -f $MYSQLTEST_VARDIR/master-data/*-bin.* +rm -f $MYSQLTEST_VARDIR/master-data/*.index diff --git a/mysql-test/t/rpl_foreign_key_innodb-slave.opt b/mysql-test/t/rpl_foreign_key_innodb-slave.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/t/rpl_foreign_key_innodb-slave.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/t/rpl_heap.test b/mysql-test/t/rpl_heap.test index 03c9070678b..2436b851a03 100644 --- a/mysql-test/t/rpl_heap.test +++ b/mysql-test/t/rpl_heap.test @@ -18,7 +18,7 @@ reset master; drop table if exists t1; # we use CREATE SELECT to verify that DELETE does not get into binlog # before CREATE SELECT -create table t1 type=HEAP select 10 as a; +create table t1 engine=HEAP select 10 as a; insert into t1 values(11); save_master_pos; --replace_column 2 # 5 # diff --git a/mysql-test/t/rpl_ignore_revoke.test b/mysql-test/t/rpl_ignore_revoke.test index e5b5bafb3c5..cdeb40df069 100644 --- a/mysql-test/t/rpl_ignore_revoke.test +++ b/mysql-test/t/rpl_ignore_revoke.test @@ -41,3 +41,7 @@ connection slave; --disable_abort_on_error revoke select on *.* FROM 'user_foo'; --enable_abort_on_error + +connection master; +delete from mysql.user where user="user_foo"; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_ignore_table-slave.opt b/mysql-test/t/rpl_ignore_table-slave.opt new file mode 100644 index 00000000000..cb49119bfcb --- /dev/null +++ b/mysql-test/t/rpl_ignore_table-slave.opt @@ -0,0 +1 @@ +--replicate-ignore-table=test.t1 --replicate-ignore-table=test.t2 --replicate-ignore-table=test.t3 diff --git a/mysql-test/t/rpl_ignore_table.test b/mysql-test/t/rpl_ignore_table.test new file mode 100644 index 00000000000..84b0a4cde38 --- /dev/null +++ b/mysql-test/t/rpl_ignore_table.test @@ -0,0 +1,30 @@ +source include/master-slave.inc; + +# +# BUG#16487 +# +# Requirement: +# Multi-updates on ignored tables should not fail even if the slave does +# not have the ignored tables. +# +# Note table t1, t2, and t3 are ignored in the option file to this test. +# + +--echo **** Test case for BUG#16487 **** +--echo **** Master **** +connection master; +CREATE TABLE test.t4 (a int); +CREATE TABLE test.t1 (a int); + +# Expect: The row must *not* by updated on slave, since t1 is ignored +UPDATE test.t4 NATURAL JOIN test.t1 SET t1.a=5; + +--echo **** Slave **** +sync_slave_with_master; +SELECT * FROM t4; + +# Cleanup +connection master; +DROP TABLE t1; +DROP TABLE t4; +sync_slave_with_master; diff --git a/mysql-test/t/rpl000008-slave.opt b/mysql-test/t/rpl_ignore_table_update-slave.opt index 177f89e0910..177f89e0910 100644 --- a/mysql-test/t/rpl000008-slave.opt +++ b/mysql-test/t/rpl_ignore_table_update-slave.opt diff --git a/mysql-test/t/rpl000008.test b/mysql-test/t/rpl_ignore_table_update.test index fe030f90411..fe030f90411 100644 --- a/mysql-test/t/rpl000008.test +++ b/mysql-test/t/rpl_ignore_table_update.test diff --git a/mysql-test/t/rpl_innodb.test b/mysql-test/t/rpl_innodb.test index 551657fd7e3..b88276e2107 100644 --- a/mysql-test/t/rpl_innodb.test +++ b/mysql-test/t/rpl_innodb.test @@ -18,7 +18,7 @@ CREATE TABLE t4 ( --disable_warnings LOAD DATA - INFILE '../../std_data/loaddata_pair.dat' + INFILE '../std_data_ln/loaddata_pair.dat' REPLACE INTO TABLE t4 (name,number); --enable_warnings @@ -30,7 +30,7 @@ SELECT * FROM t4; connection master; --disable_warnings LOAD DATA - INFILE '../../std_data/loaddata_pair.dat' + INFILE '../std_data_ln/loaddata_pair.dat' REPLACE INTO TABLE t4 (name,number); --enable_warnings diff --git a/mysql-test/t/rpl_insert_id_pk-slave.opt b/mysql-test/t/rpl_insert_id_pk-slave.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/t/rpl_insert_id_pk-slave.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/t/rpl_insert_id_pk.test b/mysql-test/t/rpl_insert_id_pk.test new file mode 100644 index 00000000000..148afdac87b --- /dev/null +++ b/mysql-test/t/rpl_insert_id_pk.test @@ -0,0 +1,6 @@ +################################# +# Wrapper for rpl_insert_id.test# +################################# +-- source include/have_innodb.inc +let $engine_type=innodb; +-- source extra/rpl_tests/rpl_insert_id_pk.test diff --git a/mysql-test/t/rpl000009-slave.opt b/mysql-test/t/rpl_load_from_master-slave.opt index c015c02ba78..c015c02ba78 100644 --- a/mysql-test/t/rpl000009-slave.opt +++ b/mysql-test/t/rpl_load_from_master-slave.opt diff --git a/mysql-test/t/rpl000009.test b/mysql-test/t/rpl_load_from_master.test index 81e9860c186..9bab7d5696e 100644 --- a/mysql-test/t/rpl000009.test +++ b/mysql-test/t/rpl_load_from_master.test @@ -1,5 +1,11 @@ # This one assumes we are ignoring updates on tables in database mysqltest2, # but doing the ones in database mysqltest +################################################################# +# Change Author: JBM +# Change Date: 2006-02-02 +# Change: Added ENGINE=MyISAM +# Reason: LOAD from master is only supported by MyISAM +################################################################# source include/master-slave.inc; --disable_warnings @@ -19,12 +25,12 @@ save_master_pos; connection slave; sync_with_master; create database mysqltest2; -create table mysqltest2.foo (n int); +create table mysqltest2.foo (n int)ENGINE=MyISAM; insert into mysqltest2.foo values(4); connection master; -create table mysqltest2.foo (n int); +create table mysqltest2.foo (n int)ENGINE=MyISAM; insert into mysqltest2.foo values(5); -create table mysqltest.bar (m int); +create table mysqltest.bar (m int)ENGINE=MyISAM; insert into mysqltest.bar values(15); save_master_pos; connection slave; @@ -49,13 +55,13 @@ set sql_log_bin = 0; create database mysqltest2; create database mysqltest; show databases; -create table mysqltest2.t1(n int, s char(20)); -create table mysqltest2.t2(n int, s text); +create table mysqltest2.t1(n int, s char(20))ENGINE=MyISAM; +create table mysqltest2.t2(n int, s text)ENGINE=MyISAM; insert into mysqltest2.t1 values (1, 'one'), (2, 'two'), (3, 'three'); insert into mysqltest2.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen'); -create table mysqltest.t1(n int, s char(20)); -create table mysqltest.t2(n int, s text); +create table mysqltest.t1(n int, s char(20))ENGINE=MyISAM; +create table mysqltest.t2(n int, s text)ENGINE=MyISAM; insert into mysqltest.t1 values (1, 'one test'), (2, 'two test'), (3, 'three test'); insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'), (13, 'thirteen test'); @@ -69,21 +75,21 @@ show databases; # Create mysqltest2 and mysqltest3 on slave; we expect that LOAD DATA FROM # MASTER will neither touch database mysqltest nor mysqltest3 create database mysqltest2; -create table mysqltest2.t1(n int, s char(20)); +create table mysqltest2.t1(n int, s char(20))ENGINE=MyISAM; insert into mysqltest2.t1 values (1, 'original foo.t1'); -create table mysqltest2.t3(n int, s char(20)); +create table mysqltest2.t3(n int, s char(20))ENGINE=MyISAM; insert into mysqltest2.t3 values (1, 'original foo.t3'); create database mysqltest3; -create table mysqltest3.t1(n int, s char(20)); +create table mysqltest3.t1(n int, s char(20))ENGINE=MyISAM; insert into mysqltest3.t1 values (1, 'original foo2.t1'); # Create mysqltest, and mysqltest.t1, to check that it gets replaced, # and mysqltest.t3 to check that it is not touched (there is no # mysqltest.t3 on master) create database mysqltest; -create table mysqltest.t1(n int, s char(20)); +create table mysqltest.t1(n int, s char(20))ENGINE=MyISAM; insert into mysqltest.t1 values (1, 'original bar.t1'); -create table mysqltest.t3(n int, s char(20)); +create table mysqltest.t3(n int, s char(20))ENGINE=MyISAM; insert into mysqltest.t3 values (1, 'original bar.t3'); load data from master; @@ -138,10 +144,10 @@ select * from mysqltest.t1; # DISABLED FOR NOW AS chmod IS NOT PORTABLE ON NON-UNIX # insert into mysqltest.t1 values(10, 'should be there'); # flush tables; -# system chmod 500 var/slave-data/mysqltest/; +# system chmod 500 $MYSQLTEST_VARDIR/slave-data/mysqltest/; # --error 6 # load data from master; # should fail (errno 13) -# system chmod 700 var/slave-data/mysqltest/; +# system chmod 700 $MYSQLTEST_VARDIR/slave-data/mysqltest/; # select * from mysqltest.t1; # should contain the row (10, ...) diff --git a/mysql-test/t/rpl_load_table_from_master.test b/mysql-test/t/rpl_load_table_from_master.test new file mode 100644 index 00000000000..aad113878d3 --- /dev/null +++ b/mysql-test/t/rpl_load_table_from_master.test @@ -0,0 +1,98 @@ +########################################################### +# Change Author: JBM +# Change Date: 2006-2-2 +# Change: Added ENGINE=$engine_type for first create table +# Reason: Only MyISAM supports load from master no need to +# run test case for other engines, in addition test will +# fail if other engines are set as default engine +########################################################### +# Change Author: JBM +# Change Date: 2006-2-3 +# Change: removed ENGINE=$engine_type for first create table +# and renamed test file to rpl_load_table_from_master.test. +# In addition added test requirements. +# Reason: Request from review. +############################################################ +# REQUIREMENT TEST 1: +# LOAD TABLE FROM MASTER must work with a forced timestamp. +############################################################ +# +# Test forced timestamp +# +-- source include/master-slave.inc + +-- echo "******************** Test Requirment 1 *************" + +# Don't log table creating to the slave as we want to test LOAD TABLE +SET SQL_LOG_BIN=0,timestamp=200006; +eval CREATE TABLE t1(t TIMESTAMP NOT NULL,a CHAR(1))ENGINE=MyISAM; +INSERT INTO t1 ( a) VALUE ('F'); +select unix_timestamp(t) from t1; +connection slave; +load table t1 from master; +select unix_timestamp(t) from t1; + +# Delete the created table on master and slave +connection master; +set SQL_LOG_BIN=1,timestamp=default; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; +connection master; + +# +# Test copying table with checksum +# + +# Don't log table creating to the slave as we want to test LOAD TABLE +set SQL_LOG_BIN=0; + +####################################################### +# REQUIREMENTi TEST 2: +#LOAD TABLE FROM MASTER must work with table checksum +####################################################### +-- echo "******************** Test Requirment 2 *************" + +eval CREATE TABLE t1 (a INT NOT NULL) ENGINE=MyISAM MAX_ROWS=4000 CHECKSUM=1; +INSERT INTO t1 VALUES (1); +save_master_pos; +connection slave; +sync_with_master; +load table t1 from master; +check table t1; +drop table t1; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; + +connection master; +set SQL_LOG_BIN=0; +create table t1 (word char(20) not null, index(word))ENGINE=MyISAM; +load data infile '../../std_data/words.dat' into table t1; +create table t2 (word char(20) not null)ENGINE=MyISAM; +load data infile '../../std_data/words.dat' into table t2; +create table t3 (word char(20) not null primary key)ENGINE=MyISAM; +connection slave; +load table t1 from master; +load table t2 from master; +load table t3 from master; +check table t1; +select count(*) from t2; +select count(*) from t3; +connection master; +set SQL_LOG_BIN=1; +drop table if exists t1,t2,t3; +save_master_pos; +connection slave; +sync_with_master; +create table t1(n int); +drop table t1; + + + + + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_loaddata2.test b/mysql-test/t/rpl_loaddata2.test index 8bbbbf62f61..439c2b48ca5 100644 --- a/mysql-test/t/rpl_loaddata2.test +++ b/mysql-test/t/rpl_loaddata2.test @@ -4,11 +4,11 @@ CREATE TABLE t1 (word CHAR(20) NOT NULL); LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1; SELECT * FROM t1 ORDER BY word; sync_slave_with_master; -SELECT * FROM t1 ORDER BY word; -########## -# Change Author: JBM -# Change Date: 2006-01-16 -# Change: Added Order by for NDB -########## +# Check +SELECT * FROM t1 ORDER BY word; +# Cleanup +connection master; +drop table t1; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_loaddata_m.test b/mysql-test/t/rpl_loaddata_m.test index 01ef89d4efc..42c3ad99f33 100644 --- a/mysql-test/t/rpl_loaddata_m.test +++ b/mysql-test/t/rpl_loaddata_m.test @@ -42,8 +42,11 @@ SHOW TABLES; SELECT COUNT(*) FROM mysqltest.t1; #show binlog events; + +# Cleanup connection master; DROP DATABASE mysqltest; DROP TABLE test.t1; +sync_slave_with_master; # End of test diff --git a/mysql-test/t/rpl_loaddata_s.test b/mysql-test/t/rpl_loaddata_s.test index c49fe461d7b..8e2bf012bc9 100644 --- a/mysql-test/t/rpl_loaddata_s.test +++ b/mysql-test/t/rpl_loaddata_s.test @@ -12,7 +12,7 @@ reset master; connection master; # 'test' is the current database create table test.t1(a int, b int, unique(b)); -load data infile '../../std_data/rpl_loaddata.dat' into table test.t1; +load data infile '../std_data_ln/rpl_loaddata.dat' into table test.t1; # Test logging on slave; @@ -22,3 +22,8 @@ sync_with_master; select count(*) from test.t1; # check that LOAD was replicated --replace_column 2 # 5 # show binlog events from 102; # should be nothing + +# Cleanup +connection master; +drop table test.t1; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_loaddatalocal.test b/mysql-test/t/rpl_loaddatalocal.test index 0b54de8462e..af4fd0106bd 100644 --- a/mysql-test/t/rpl_loaddatalocal.test +++ b/mysql-test/t/rpl_loaddatalocal.test @@ -14,17 +14,18 @@ disable_query_log; set SQL_LOG_BIN=0; while ($1) { -#eval means expand $ expressions - eval insert into t1 values(1); + insert into t1 values(1); dec $1; } set SQL_LOG_BIN=1; enable_query_log; -select * into outfile '../../var/master-data/rpl_loaddatalocal.select_outfile' from t1; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval select * into outfile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' from t1; #This will generate a 20KB file, now test LOAD DATA LOCAL truncate table t1; -load data local infile './var/master-data/rpl_loaddatalocal.select_outfile' into table t1; -system rm ./var/master-data/rpl_loaddatalocal.select_outfile ; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1; +system rm $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile ; save_master_pos; connection slave; sync_with_master; @@ -45,11 +46,13 @@ sync_with_master; connection master; create table t1(a int); insert into t1 values (1), (2), (2), (3); -select * into outfile '../../var/master-data/rpl_loaddatalocal.select_outfile' from t1; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval select * into outfile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' from t1; drop table t1; create table t1(a int primary key); -load data local infile './var/master-data/rpl_loaddatalocal.select_outfile' into table t1; -system rm ./var/master-data/rpl_loaddatalocal.select_outfile ; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1; +system rm $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile ; select * from t1; save_master_pos; connection slave; diff --git a/mysql-test/t/rpl_loadfile.test b/mysql-test/t/rpl_loadfile.test index 61a0cc46628..1e7f2c5fdfe 100644 --- a/mysql-test/t/rpl_loadfile.test +++ b/mysql-test/t/rpl_loadfile.test @@ -40,8 +40,10 @@ sync_slave_with_master; connection slave; SELECT * FROM test.t1 ORDER BY blob_column; -# Lets cleanup +# Cleanup connection master; DROP PROCEDURE IF EXISTS test.p1; DROP TABLE test.t1; +sync_slave_with_master; + # End of 5.0 test case diff --git a/mysql-test/t/rpl_misc_functions-slave.sh b/mysql-test/t/rpl_misc_functions-slave.sh index c293715e16f..8ce79797822 100755 --- a/mysql-test/t/rpl_misc_functions-slave.sh +++ b/mysql-test/t/rpl_misc_functions-slave.sh @@ -1 +1 @@ -rm -f $MYSQL_TEST_DIR/var/master-data/test/rpl_misc_functions.outfile +rm -f $MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile diff --git a/mysql-test/t/rpl_misc_functions.test b/mysql-test/t/rpl_misc_functions.test index f20d0aa83e4..6e0bda90503 100644 --- a/mysql-test/t/rpl_misc_functions.test +++ b/mysql-test/t/rpl_misc_functions.test @@ -24,9 +24,14 @@ select * into outfile 'rpl_misc_functions.outfile' from t1; sync_slave_with_master; create table t2 like t1; # read the values from the master table -load data local infile './var/master-data/test/rpl_misc_functions.outfile' into table t2; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval load data local infile '$MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile' into table t2; # compare them with the replica; the SELECT below should return no row select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p); stop slave; +drop table t1; + +connection master; +drop table t1; # End of 4.1 tests diff --git a/mysql-test/t/rpl000002.test b/mysql-test/t/rpl_mixed_ddl_dml.test index 5b9ed6898b8..5b9ed6898b8 100644 --- a/mysql-test/t/rpl000002.test +++ b/mysql-test/t/rpl_mixed_ddl_dml.test diff --git a/mysql-test/t/rpl_multi_update4.test b/mysql-test/t/rpl_multi_update4.test index 3d909b8e5cd..4991a385f6f 100644 --- a/mysql-test/t/rpl_multi_update4.test +++ b/mysql-test/t/rpl_multi_update4.test @@ -15,7 +15,7 @@ connection slave; drop database if exists d2; --enable_warnings -### Test +### Do on master connection master; create database d1; # accepted by slave @@ -30,15 +30,16 @@ insert into t2 select id + 3 from t1; update t1 join t2 using (id) set t1.id = 0; insert into d1.t0 values (0); # replication works +### Check on slave + sync_slave_with_master; use d1; -#connection slave; select * from t0 where id=0; # must find ### Clean-up connection master; drop database d1; drop database d2; - +sync_slave_with_master; # End of test diff --git a/mysql-test/t/rpl_ndb_auto_inc-master.opt b/mysql-test/t/rpl_ndb_auto_inc-master.opt new file mode 100644 index 00000000000..a8a6af19da9 --- /dev/null +++ b/mysql-test/t/rpl_ndb_auto_inc-master.opt @@ -0,0 +1 @@ +--auto-increment-increment=10 --auto-increment-offset=2 diff --git a/mysql-test/t/rpl_ndb_auto_inc.test b/mysql-test/t/rpl_ndb_auto_inc.test new file mode 100644 index 00000000000..c64fe1d2f8f --- /dev/null +++ b/mysql-test/t/rpl_ndb_auto_inc.test @@ -0,0 +1,7 @@ +##################################### +# Wrapper for rpl_auto_increment.test# +##################################### +-- source include/have_innodb.inc +let $engine_type=NDB; +let $engine_type2=myisam; +-- source extra/rpl_tests/rpl_auto_increment.test diff --git a/mysql-test/t/rpl_ndb_bank.test b/mysql-test/t/rpl_ndb_bank.test index 1b900236963..817f40f2fa3 100644 --- a/mysql-test/t/rpl_ndb_bank.test +++ b/mysql-test/t/rpl_ndb_bank.test @@ -10,14 +10,14 @@ # 5. check that the slave and master BANK databases are the same # -# kill any trailing processes ---system killall lt-bankTransactionMaker lt-bankTimer lt-bankMakeGL || true - --source include/have_ndb.inc --source include/have_ndb_extra.inc --source include/have_binlog_format_row.inc --source include/master-slave.inc +# kill any trailing processes +--system killall lt-bankTransactionMaker lt-bankTimer lt-bankMakeGL || true + --disable_warnings # initialize master --connection master diff --git a/mysql-test/t/rpl_ndb_basic.test b/mysql-test/t/rpl_ndb_basic.test index 95c1737f715..57028464179 100644 --- a/mysql-test/t/rpl_ndb_basic.test +++ b/mysql-test/t/rpl_ndb_basic.test @@ -144,3 +144,4 @@ select * from t1 order by nid; # cleanup --connection master DROP TABLE t1; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_ndb_func003.test b/mysql-test/t/rpl_ndb_func003.test new file mode 100644 index 00000000000..2d240385555 --- /dev/null +++ b/mysql-test/t/rpl_ndb_func003.test @@ -0,0 +1,11 @@ +################################### +# Wrapper for rpl_row_func003.test# +# This test was orginally designed# +# To test InnoDB using RBR, but # +# It can also be used to test NDB # +# So this wrapper is being used to# +# reduce test case code # +################################### +-- source include/have_ndb.inc +let $engine_type=NDB; +-- source extra/rpl_tests/rpl_row_func003.test diff --git a/mysql-test/t/rpl_ndb_log-master.opt b/mysql-test/t/rpl_ndb_log-master.opt new file mode 100644 index 00000000000..e0d075c3fbd --- /dev/null +++ b/mysql-test/t/rpl_ndb_log-master.opt @@ -0,0 +1 @@ +--skip-external-locking diff --git a/mysql-test/t/rpl_ndb_log.test b/mysql-test/t/rpl_ndb_log.test new file mode 100644 index 00000000000..e883d24b977 --- /dev/null +++ b/mysql-test/t/rpl_ndb_log.test @@ -0,0 +1,12 @@ +################################### +# Wrapper for rpl_row_log.test # +# Added wrapper so that MyISAM & # +# Innodb and NDB could all use the# +# Same test. NDB produced a diff # +# bin-log # +################################### +-- source include/have_binlog_format_row.inc +-- source include/have_ndb.inc +let $engine_type=NDB; +-- source extra/rpl_tests/rpl_log.test + diff --git a/mysql-test/t/rpl_ndb_relay_space.test b/mysql-test/t/rpl_ndb_relay_space.test new file mode 100644 index 00000000000..0484d807996 --- /dev/null +++ b/mysql-test/t/rpl_ndb_relay_space.test @@ -0,0 +1,21 @@ +################################### +# Wrapper rpl_sv_relay_space.test # +# This test has to be wrapped as # +# It tests ndb, innodb and MyISAM.# +# By Wrapping we are saving some # +# space and making the test more # +# Maintainable by only having one # +# test file and reusing the code # +# In Addition, INNODB has to have # +# Option files during this test # +# to force innodb on the slave # +# else the test will fail # +################################### +#Change Author: JBM # +#Change Date: 2006-02-03 # +#Change: Added Comments # +################################### +--source include/have_ndb.inc +let $engine_type=NDB; +-- source extra/rpl_tests/rpl_sv_relay_space.test + diff --git a/mysql-test/t/rpl_ndb_sync.test b/mysql-test/t/rpl_ndb_sync.test index 2e1e96d87de..143ff6d6651 100644 --- a/mysql-test/t/rpl_ndb_sync.test +++ b/mysql-test/t/rpl_ndb_sync.test @@ -27,8 +27,7 @@ SELECT hex(c2),hex(c3),c1 FROM t2 ORDER BY c1; # take a backup on master --exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "start backup" >> $NDB_TOOLS_OUTPUT --exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > var/tmp.dat -CREATE TABLE IF NOT EXISTS cluster_replication.backup_info (id INT, backup_id INT); -DELETE FROM cluster_replication.backup_info; +CREATE TEMPORARY TABLE cluster_replication.backup_info (id INT, backup_id INT) ENGINE=HEAP; LOAD DATA INFILE '../../var/tmp.dat' INTO TABLE cluster_replication.backup_info FIELDS TERMINATED BY ','; --replace_column 1 <the_backup_id> SELECT @the_backup_id:=backup_id FROM cluster_replication.backup_info; diff --git a/mysql-test/t/rpl_redirect.test b/mysql-test/t/rpl_redirect.test index c001d85d2f8..078d1048794 100644 --- a/mysql-test/t/rpl_redirect.test +++ b/mysql-test/t/rpl_redirect.test @@ -32,14 +32,16 @@ insert into t1 values(5); connection master; enable_rpl_parse; # The first of the queries will be sent to the slave, the second to the master. -select * from t1; -select * from t1; +SELECT * FROM t1 ORDER BY n; +SELECT * FROM t1 ORDER BY n; disable_rpl_parse; -select * from t1; +SELECT * FROM t1 ORDER BY n; connection slave; -select * from t1; -drop table t1; +SELECT * FROM t1 ORDER BY n; + +# Cleanup connection master; drop table t1; +sync_slave_with_master; # End of 4.1 tests diff --git a/mysql-test/t/rpl_relay_space_innodb-master.opt b/mysql-test/t/rpl_relay_space_innodb-master.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/t/rpl_relay_space_innodb-master.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/t/rpl_relay_space_innodb-slave.opt b/mysql-test/t/rpl_relay_space_innodb-slave.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/t/rpl_relay_space_innodb-slave.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/t/rpl_relay_space_innodb.test b/mysql-test/t/rpl_relay_space_innodb.test new file mode 100644 index 00000000000..90276d87523 --- /dev/null +++ b/mysql-test/t/rpl_relay_space_innodb.test @@ -0,0 +1,21 @@ +################################### +# Wrapper rpl_sv_relay_space.test # +# This test has to be wrapped as # +# It tests ndb, innodb and MyISAM.# +# By Wrapping we are saving some # +# space and making the test more # +# Maintainable by only having one # +# test file and reusing the code # +# In Addition, INNODB has to have # +# Option files during this test # +# to force innodb on the slave # +# else the test will fail # +################################### +#Change Author: JBM # +#Change Date: 2006-02-03 # +#Change: Added Comments # +################################### +-- source include/have_innodb.inc +let $engine_type=InnoDB; +-- source extra/rpl_tests/rpl_sv_relay_space.test + diff --git a/mysql-test/t/rpl_relay_space_myisam.test b/mysql-test/t/rpl_relay_space_myisam.test new file mode 100644 index 00000000000..cb129f7c87a --- /dev/null +++ b/mysql-test/t/rpl_relay_space_myisam.test @@ -0,0 +1,20 @@ +################################### +# Wrapper rpl_sv_relay_space.test # +# This test has to be wrapped as # +# It tests ndb, innodb and MyISAM.# +# By Wrapping we are saving some # +# space and making the test more # +# Maintainable by only having one # +# test file and reusing the code # +# In Addition, INNODB has to have # +# Option files during this test # +# to force innodb on the slave # +# else the test will fail # +################################### +#Change Author: JBM # +#Change Date: 2006-02-03 # +#Change: Added Comments # +################################### +let $engine_type=MyISAM; +-- source extra/rpl_tests/rpl_sv_relay_space.test + diff --git a/mysql-test/t/rpl_replicate_do.test b/mysql-test/t/rpl_replicate_do.test index 5a2cb50d53a..e7141c3f905 100644 --- a/mysql-test/t/rpl_replicate_do.test +++ b/mysql-test/t/rpl_replicate_do.test @@ -11,7 +11,7 @@ create table t2 (n int); insert into t2 values(4); connection master; create table t2 (s char(20)); -load data infile '../../std_data/words.dat' into table t2; +load data infile '../std_data_ln/words.dat' into table t2; insert into t2 values('five'); create table t1 (m int); insert into t1 values(15),(16),(17); @@ -21,7 +21,7 @@ create table t11 select * from t1; save_master_pos; connection slave; sync_with_master; -select * from t1; +select * from t1 ORDER BY m; select * from t2; --error 1146 select * from t11; @@ -53,4 +53,8 @@ connection slave; set one_shot time_zone='met'; select * from t1; +connection master; +drop table t1; +sync_slave_with_master; + # End of 4.1 tests diff --git a/mysql-test/t/rpl_rewrt_db.test b/mysql-test/t/rpl_rewrt_db.test index c66ced46717..8acc05f6ff5 100644 --- a/mysql-test/t/rpl_rewrt_db.test +++ b/mysql-test/t/rpl_rewrt_db.test @@ -34,8 +34,8 @@ create database rewrite; connection master; use test; create table t1 (a date, b date, c date not null, d date); -load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ','; -load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; +load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ','; +load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; sync_slave_with_master; connection slave; @@ -43,7 +43,7 @@ select * from rewrite.t1; connection master; truncate table t1; -load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); +load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); sync_slave_with_master; connection slave; @@ -52,7 +52,7 @@ select * from rewrite.t1; connection master; drop table t1; create table t1 (a text, b text); -load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; +load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; sync_slave_with_master; connection slave; @@ -61,7 +61,7 @@ select concat('|',a,'|'), concat('|',b,'|') from rewrite.t1; connection master; drop table t1; create table t1 (a int, b char(10)); -load data infile '../../std_data/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; +load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; sync_slave_with_master; connection slave; @@ -69,7 +69,7 @@ select * from rewrite.t1; connection master; truncate table t1; -load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; +load data infile '../std_data_ln/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; sync_slave_with_master; connection slave; diff --git a/mysql-test/t/rpl_rotate_logs-slave.sh b/mysql-test/t/rpl_rotate_logs-slave.sh index 9259f593e54..81490a54b4b 100755 --- a/mysql-test/t/rpl_rotate_logs-slave.sh +++ b/mysql-test/t/rpl_rotate_logs-slave.sh @@ -1,2 +1,2 @@ -rm -f $MYSQL_TEST_DIR/var/slave-data/master.info -rm -f $MYSQL_TEST_DIR/var/slave-data/*relay* +rm -f $MYSQLTEST_VARDIR/slave-data/master.info +rm -f $MYSQLTEST_VARDIR/slave-data/*relay* diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 1f5f4ebbed2..7f76aaf3355 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -17,8 +17,8 @@ connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); drop table if exists t1, t2, t3, t4; --enable_warnings connect (slave,localhost,root,,test,$SLAVE_MYPORT,slave.sock); -system cat /dev/null > var/slave-data/master.info; -system chmod 000 var/slave-data/master.info; +system cat /dev/null > $MYSQLTEST_VARDIR/slave-data/master.info; +system chmod 000 $MYSQLTEST_VARDIR/slave-data/master.info; connection slave; --disable_warnings drop table if exists t1, t2, t3, t4; @@ -29,7 +29,7 @@ drop table if exists t1, t2, t3, t4; --replace_result $MYSQL_TEST_DIR TESTDIR --error 1105,1105,29 start slave; -system chmod 600 var/slave-data/master.info; +system chmod 600 $MYSQLTEST_VARDIR/slave-data/master.info; # It will fail again because the file is empty so the slave cannot get valuable # info about how to connect to the master from it (failure in # init_strvar_from_file() in init_master_info()). diff --git a/mysql-test/t/rpl_row_blob_innodb-slave.opt b/mysql-test/t/rpl_row_blob_innodb-slave.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/t/rpl_row_blob_innodb-slave.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/t/rpl_row_blob_innodb.test b/mysql-test/t/rpl_row_blob_innodb.test index b6832010e22..0e43af8c388 100644 --- a/mysql-test/t/rpl_row_blob_innodb.test +++ b/mysql-test/t/rpl_row_blob_innodb.test @@ -2,6 +2,6 @@ # Wrapper for rpl_row_blob.test# ################################# -- source include/have_innodb.inc -let $engine_type=INNODB; +let $engine_type=InnoDB; -- source extra/rpl_tests/rpl_row_blob.test diff --git a/mysql-test/t/rpl_row_func001.test b/mysql-test/t/rpl_row_func001.test index 6c538017911..53fb55118e6 100644 --- a/mysql-test/t/rpl_row_func001.test +++ b/mysql-test/t/rpl_row_func001.test @@ -48,9 +48,10 @@ connection master; #Used for debugging #show binlog events; -# Lets cleanup +# Cleanup DROP FUNCTION test.f1; DROP TABLE test.t1; +sync_slave_with_master; # End of 5.0 test case diff --git a/mysql-test/t/rpl_row_func002.test b/mysql-test/t/rpl_row_func002.test index 3812eac201c..966124ce035 100644 --- a/mysql-test/t/rpl_row_func002.test +++ b/mysql-test/t/rpl_row_func002.test @@ -87,10 +87,10 @@ connection master; --exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/func002_master.sql --exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/func002_slave.sql -# First lets cleanupi +# Cleanup DROP FUNCTION test.f1; DROP TABLE test.t1; - +sync_slave_with_master; # the test will show that the diff statement failed and no reject file # will be created. You will need to go to the mysql-test dir and diff @@ -99,6 +99,5 @@ DROP TABLE test.t1; exec diff ./var/tmp/func002_master.sql ./var/tmp/func002_slave.sql; - # End of 5.0 test case diff --git a/mysql-test/t/rpl_row_func003-slave.opt b/mysql-test/t/rpl_row_func003-slave.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/t/rpl_row_func003-slave.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/t/rpl_row_log.test b/mysql-test/t/rpl_row_log.test index 29abf5bb93e..5a9b21165e5 100644 --- a/mysql-test/t/rpl_row_log.test +++ b/mysql-test/t/rpl_row_log.test @@ -1,4 +1,11 @@ -# Requires row base logging +################################### +# Wrapper for rpl_row_log.test # +# Added wrapper so that MyISAM & # +# Innodb and NDB could all use the# +# Same test. NDB produced a diff # +# bin-log # +################################### -- source include/have_binlog_format_row.inc +let $engine_type=MyISAM; -- source extra/rpl_tests/rpl_log.test diff --git a/mysql-test/t/rpl_row_log_innodb-master.opt b/mysql-test/t/rpl_row_log_innodb-master.opt new file mode 100644 index 00000000000..e0d075c3fbd --- /dev/null +++ b/mysql-test/t/rpl_row_log_innodb-master.opt @@ -0,0 +1 @@ +--skip-external-locking diff --git a/mysql-test/t/rpl_row_log_innodb-slave.opt b/mysql-test/t/rpl_row_log_innodb-slave.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/t/rpl_row_log_innodb-slave.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/t/rpl_row_log_innodb.test b/mysql-test/t/rpl_row_log_innodb.test new file mode 100644 index 00000000000..f4a9cf06291 --- /dev/null +++ b/mysql-test/t/rpl_row_log_innodb.test @@ -0,0 +1,12 @@ +################################### +# Wrapper for rpl_row_log.test # +# Added wrapper so that MyISAM & # +# Innodb and NDB could all use the# +# Same test. NDB produced a diff # +# bin-log # +################################### +-- source include/have_binlog_format_row.inc +-- source include/have_innodb.inc +let $engine_type=InnoDB; +-- source extra/rpl_tests/rpl_log.test + diff --git a/mysql-test/t/rpl_row_sp001.test b/mysql-test/t/rpl_row_sp001.test index f6ac18dc78b..88384b242b0 100644 --- a/mysql-test/t/rpl_row_sp001.test +++ b/mysql-test/t/rpl_row_sp001.test @@ -85,34 +85,34 @@ delimiter ;// INSERT INTO test.t2 VALUES(NULL,'NEW'),(NULL,'NEW'),(NULL,'NEW'),(NULL,'NEW'); -select * from test.t2; +SELECT * FROM t2 ORDER BY a; save_master_pos; connection slave; sync_with_master; -select * from test.t2; +SELECT * FROM t2 ORDER BY a; connection master; call test.p2(1); -select * from test.t2; +SELECT * FROM t2 ORDER BY a; sync_slave_with_master; -select * from test.t2; +SELECT * FROM t2 ORDER BY a; connection master; call test.p2(2); -select * from test.t2; +SELECT * FROM t2 ORDER BY a; save_master_pos; connection slave; sync_with_master; -select * from test.t2; +SELECT * FROM t2 ORDER BY a; connection master; call test.p2(3); -select * from test.t2; +SELECT * FROM t2 ORDER BY a; save_master_pos; connection slave; sync_with_master; -select * from test.t2; +SELECT * FROM t2 ORDER BY a; ##Used for debugging #show binlog events; @@ -124,10 +124,12 @@ select * from test.t2; # First lets cleanup +connection master; DROP PROCEDURE test.p1; DROP PROCEDURE test.p2; DROP TABLE test.t1; DROP TABLE test.t2; +sync_slave_with_master; # Lets compare. Note: If they match test will pass, if they do not match # the test will show that the diff statement failed and not reject file diff --git a/mysql-test/t/rpl_row_sp005.test b/mysql-test/t/rpl_row_sp005.test index c2cdd820eeb..054fa02f514 100644 --- a/mysql-test/t/rpl_row_sp005.test +++ b/mysql-test/t/rpl_row_sp005.test @@ -6,7 +6,8 @@ # Test: Tests SPs with cursors, flow logic, and alter sp. In addition the # # tests SPs with insert and update operations. # ############################################################################# - +# 2006-02-08 By JBM added ORDER BY for use with NDB engine +############################################################################# # Includes -- source include/have_binlog_format_row.inc @@ -35,8 +36,8 @@ BEGIN DECLARE done INT DEFAULT 0; DECLARE spa CHAR(16); DECLARE spb,spc INT; - DECLARE cur1 CURSOR FOR SELECT id,data FROM test.t1; - DECLARE cur2 CURSOR FOR SELECT id2 FROM test.t2; + DECLARE cur1 CURSOR FOR SELECT id,data FROM test.t1 ORDER BY id; + DECLARE cur2 CURSOR FOR SELECT id2 FROM test.t2 ORDER BY id2; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; OPEN cur1; @@ -68,38 +69,42 @@ delimiter ;| let $message=< ---- Master selects-- >; --source include/show_msg.inc CALL test.p2(); -SELECT * FROM test.t1; -SELECT * FROM test.t2; +SELECT * FROM test.t1 ORDER BY id; +SELECT * FROM test.t2 ORDER BY id2; let $message=< ---- Slave selects-- >; --source include/show_msg.inc save_master_pos; connection slave; sync_with_master; -SELECT * FROM test.t1; -SELECT * FROM test.t2; +SELECT * FROM test.t1 ORDER BY id; +SELECT * FROM test.t2 ORDER BY id2; let $message=< ---- Master selects-- >; --source include/show_msg.inc connection master; CALL test.p1(); sleep 6; -SELECT * FROM test.t3; +SELECT * FROM test.t3 ORDER BY id3; let $message=< ---- Slave selects-- >; --source include/show_msg.inc connection slave; -SELECT * FROM test.t3; +SELECT * FROM test.t3 ORDER BY id3; connection master; ALTER PROCEDURE test.p1 MODIFIES SQL DATA; #show binlog events; +# Cleanup + +connection master; DROP PROCEDURE IF EXISTS test.p1; DROP PROCEDURE IF EXISTS test.p2; DROP TABLE IF EXISTS test.t1; DROP TABLE IF EXISTS test.t2; DROP TABLE IF EXISTS test.t3; +sync_slave_with_master; # End of 5.0 test case diff --git a/mysql-test/t/rpl_row_sp008.test b/mysql-test/t/rpl_row_sp008.test index c30339b8c7c..611062543e0 100644 --- a/mysql-test/t/rpl_row_sp008.test +++ b/mysql-test/t/rpl_row_sp008.test @@ -51,8 +51,11 @@ let $VERSION=`select version()`; --replace_result $VERSION VERSION show binlog events; +# Cleanup +connection master; DROP PROCEDURE IF EXISTS test.p1; DROP TABLE IF EXISTS test.t1; +sync_slave_with_master; # End of 5.0 test case diff --git a/mysql-test/t/rpl_row_sp009.test b/mysql-test/t/rpl_row_sp009.test index b06267df783..92d47c6f50f 100644 --- a/mysql-test/t/rpl_row_sp009.test +++ b/mysql-test/t/rpl_row_sp009.test @@ -5,6 +5,8 @@ ############################################################################# #TEST: Taken and modfied from http://bugs.mysql.com/bug.php?id=12168 # ############################################################################# +# 2006-02-08 By JBM : Added order by for ndb engine use +############################################################################# # Includes -- source include/have_binlog_format_row.inc @@ -68,38 +70,36 @@ END| delimiter ;| CALL test.p1('a'); -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; save_master_pos; connection slave; sync_with_master; -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; connection master; truncate test.t2; # this next call fails, but should not call test.p1('b'); -select * from test.t2; +select * from test.t2 ORDER BY a; save_master_pos; connection slave; sync_with_master; -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; connection master; truncate test.t2; -SELECT * FROM test.t2; +SELECT * FROM test.t2 ORDER BY a; save_master_pos; connection slave; sync_with_master; -SELECT * FROM test.t2; - +SELECT * FROM test.t2 ORDER BY a; +# Cleanup connection master; #show binlog events; -# lets cleanup - DROP PROCEDURE test.p1; DROP TABLE test.t1; DROP TABLE test.t2; - +sync_slave_with_master; # End of 5.0 test case diff --git a/mysql-test/t/rpl_row_sp010.test b/mysql-test/t/rpl_row_sp010.test index 8d11ca10087..10940e1e030 100644 --- a/mysql-test/t/rpl_row_sp010.test +++ b/mysql-test/t/rpl_row_sp010.test @@ -66,16 +66,15 @@ connection slave; sync_with_master; SELECT * FROM test.t2; +# Cleanup connection master; #show binlog events; -# lets cleanup - DROP PROCEDURE IF EXISTS test.p1; DROP PROCEDURE IF EXISTS test.p2; DROP PROCEDURE IF EXISTS test.p3; DROP PROCEDURE IF EXISTS test.p4; DROP TABLE IF EXISTS test.t1; DROP TABLE IF EXISTS test.t2; - +sync_slave_with_master; # End of 5.0 test case diff --git a/mysql-test/t/rpl_row_sp011.test b/mysql-test/t/rpl_row_sp011.test index 8d843510b6b..73d2f628dbd 100644 --- a/mysql-test/t/rpl_row_sp011.test +++ b/mysql-test/t/rpl_row_sp011.test @@ -78,15 +78,13 @@ CALL test.p1(); #SELECT * FROM test.t2; sync_slave_with_master; #SELECT * FROM test.t2; -connection master; - -#show binlog events; -# lets cleanup --exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/sp011_master.sql --exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/sp011_slave.sql - +# Cleanup +connection master; +#show binlog events; DROP PROCEDURE IF EXISTS test.p1; DROP PROCEDURE IF EXISTS test.p2; DROP PROCEDURE IF EXISTS test.p3; @@ -96,9 +94,7 @@ DROP PROCEDURE IF EXISTS test.p6; DROP PROCEDURE IF EXISTS test.p7; DROP TABLE IF EXISTS test.t1; DROP TABLE IF EXISTS test.t2; - - -# First lets cleanup +sync_slave_with_master; # Lets compare. Note: If they match test will pass, if they do not match # the test will show that the diff statement failed and not reject file diff --git a/mysql-test/t/rpl_row_sp012.test b/mysql-test/t/rpl_row_sp012.test index 2b9c07895f0..5b6fc139577 100644 --- a/mysql-test/t/rpl_row_sp012.test +++ b/mysql-test/t/rpl_row_sp012.test @@ -61,14 +61,14 @@ SELECT USER(); CALL test.p3(); CALL test.p2(); +# Cleanup connection master; - -# lets cleanup DROP PROCEDURE IF EXISTS test.p1; DROP PROCEDURE IF EXISTS test.p3; DROP PROCEDURE IF EXISTS test.p2; DROP TABLE IF EXISTS test.t1; DROP TABLE IF EXISTS test.t2; +sync_slave_with_master; # End of 5.0 test case diff --git a/mysql-test/t/rpl_row_trig001.test b/mysql-test/t/rpl_row_trig001.test index e2f10ecf1fa..b7866069a51 100644 --- a/mysql-test/t/rpl_row_trig001.test +++ b/mysql-test/t/rpl_row_trig001.test @@ -78,14 +78,16 @@ let $message=<End test section 2 (Tiggers & SP)>; --exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/trig001_master.sql --exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/trig001_slave.sql -# First lets cleanup - +# Cleanup +connection master; DROP PROCEDURE test.p2; +DROP PROCEDURE test.p3; DROP TRIGGER test.t2_ai; DROP TRIGGER test.t3_bi_t2; DROP TABLE test.t1; DROP TABLE test.t2; DROP TABLE test.t3; +sync_slave_with_master; # Lets compare. Note: If they match test will pass, if they do not match # the test will show that the diff statement failed and not reject file diff --git a/mysql-test/t/rpl_row_trig002.test b/mysql-test/t/rpl_row_trig002.test index 2cd84009b2b..7ca8a68f060 100644 --- a/mysql-test/t/rpl_row_trig002.test +++ b/mysql-test/t/rpl_row_trig002.test @@ -37,12 +37,12 @@ delimiter ;| INSERT INTO test.t1 VALUES (1, 'example.com'),(2, 'mysql.com'),(3, 'earthmotherwear.com'), (4, 'yahoo.com'),(5, 'example.com'); -select * from test.t1; +SELECT * FROM test.t1 ORDER BY id; #show binlog events; save_master_pos; connection slave; sync_with_master; -select * from test.t1; +SELECT * FROM test.t1 ORDER BY id; connection master; INSERT INTO test.t3 VALUES ('Yes', 5, NULL, 'spamfilter','scan_incoming'); @@ -60,20 +60,21 @@ connection master; DELETE FROM test.t1 WHERE id = 1; -select * from test.t1; +SELECT * FROM test.t1 ORDER BY id; +connection master; +SELECT * FROM test.t1 ORDER BY id; save_master_pos; connection slave; sync_with_master; -select * from test.t1; -connection master; +SELECT * FROM test.t1 ORDER BY id; +# Cleanup +connection master; #show binlog events; - -# cleanup - DROP TRIGGER test.t2_ai; DROP TABLE test.t1; DROP TABLE test.t2; DROP TABLE test.t3; +sync_slave_with_master; # End of 5.0 test case diff --git a/mysql-test/t/rpl_row_view01.test b/mysql-test/t/rpl_row_view01.test index 85137e03dbf..895a922fef8 100644 --- a/mysql-test/t/rpl_row_view01.test +++ b/mysql-test/t/rpl_row_view01.test @@ -5,7 +5,8 @@ ############################################################################# #TEST: row based replication of views # ############################################################################# - +# 2006-02-08 By JBM added order by and sleep for use with ndb engine +############################################################################# # Includes -- source include/have_binlog_format_row.inc -- source include/master-slave.inc @@ -34,14 +35,19 @@ INSERT INTO mysqltest1.t2 VALUES (1,'GOD'),(2,'is'),(3,'TGIF'); INSERT INTO mysqltest1.t4 VALUES(1, 3, 50),(2, 18, 3),(4, 4, 4); -CREATE VIEW mysqltest1.v2 AS SELECT qty, price, qty*price AS value FROM mysqltest1.t4; -CREATE VIEW mysqltest1.v1 AS SELECT t1.a, t1.c, t2.c as c2 FROM mysqltest1.t1 as t1, mysqltest1.t2 AS t2 WHERE mysqltest1.t1.a = mysqltest1.t2.a; +CREATE VIEW mysqltest1.v2 AS SELECT qty, price, qty*price AS value FROM mysqltest1.t4 ORDER BY qty; +CREATE VIEW mysqltest1.v1 AS SELECT t1.a, t1.c, t2.c as c2 FROM mysqltest1.t1 as t1, mysqltest1.t2 AS t2 WHERE mysqltest1.t1.a = mysqltest1.t2.a ORDER BY a; CREATE VIEW mysqltest1.v3 AS SELECT * FROM mysqltest1.t1; CREATE VIEW mysqltest1.v4 AS SELECT * FROM mysqltest1.v3 WHERE a > 1 WITH LOCAL CHECK OPTION; SELECT * FROM mysqltest1.v2; SELECT * FROM mysqltest1.v1; +# Had to add a sleep for use with NDB +# engine. Injector thread would have not +# populated biblog and data would not be on +# the slave. +sleep 10; sync_slave_with_master; SELECT * FROM mysqltest1.v2; SELECT * FROM mysqltest1.v1; @@ -50,20 +56,20 @@ connection master; INSERT INTO mysqltest1.t5 SELECT * FROM mysqltest1.v2; INSERT INTO mysqltest1.t3 SELECT * FROM mysqltest1.v1; -SELECT * FROM mysqltest1.t5; -SELECT * FROM mysqltest1.t3; +SELECT * FROM mysqltest1.t5 ORDER BY qty; +SELECT * FROM mysqltest1.t3 ORDER BY a; sync_slave_with_master; -SELECT * FROM mysqltest1.t5; -SELECT * FROM mysqltest1.t3; +SELECT * FROM mysqltest1.t5 ORDER BY qty; +SELECT * FROM mysqltest1.t3 ORDER BY a; connection master; INSERT INTO mysqltest1.v4 VALUES (4,'TEST'); -SELECT * FROM mysqltest1.t1; -SELECT * FROM mysqltest1.v4; +SELECT * FROM mysqltest1.t1 ORDER BY a; +SELECT * FROM mysqltest1.v4 ORDER BY a; sync_slave_with_master; -SELECT * FROM mysqltest1.t1; -SELECT * FROM mysqltest1.v4; +SELECT * FROM mysqltest1.t1 ORDER BY a; +SELECT * FROM mysqltest1.v4 ORDER BY a; connection master; diff --git a/mysql-test/t/rpl_skip_error.test b/mysql-test/t/rpl_skip_error.test index e0e569a65b7..ff81e2f010e 100644 --- a/mysql-test/t/rpl_skip_error.test +++ b/mysql-test/t/rpl_skip_error.test @@ -1,3 +1,7 @@ +########################################## +# 2006-02-07 By JBM: Added order by +######################################### +# Note that errors are ignored by opt file. source include/master-slave.inc; create table t1 (n int not null primary key); @@ -6,11 +10,20 @@ connection slave; sync_with_master; insert into t1 values (1); connection master; +# Here we expect (ignored) error, since 1 is already in slave table insert into t1 values (1); + +# These should work fine insert into t1 values (2),(3); + save_master_pos; connection slave; sync_with_master; -select * from t1; +select * from t1 ORDER BY n; + +# Cleanup +connection master; +drop table t1; +sync_slave_with_master; # End of 4.1 tests diff --git a/mysql-test/t/rpl_slave_status.test b/mysql-test/t/rpl_slave_status.test index 67d3816f443..a4a276b63d6 100644 --- a/mysql-test/t/rpl_slave_status.test +++ b/mysql-test/t/rpl_slave_status.test @@ -1,11 +1,21 @@ -# Test case for BUG #10780 --source include/master-slave.inc + +############################################################################ +# Test case for BUG#10780 +# +# REQUIREMENT +# A slave without replication privileges should have Slave_IO_Running = No + +# 1. Create new replication user connection master; grant replication slave on *.* to rpl@127.0.0.1 identified by 'rpl'; + connection slave; stop slave; change master to master_user='rpl',master_password='rpl'; start slave; + +# 2. Do replication as new user connection master; --disable_warnings drop table if exists t1; @@ -16,12 +26,19 @@ save_master_pos; connection slave; sync_with_master; select * from t1; + +# 3. Delete new replication user connection master; delete from mysql.user where user='rpl'; flush privileges; connection slave; + +# 4. Restart slave without privileges +# (slave.err will contain access denied error for this START SLAVE command) stop slave; start slave; + +# 5. Make sure Slave_IO_Running = No --replace_result $MASTER_MYPORT MASTER_MYPORT # Column 1 is replaced, since the output can be either # "Connecting to master" or "Waiting for master update" @@ -29,4 +46,12 @@ start slave; --vertical_results show slave status; +# Cleanup (Note that slave IO thread is not running) +connection slave; +drop table t1; +connection master; +drop table t1; + +# end of test case for BUG#10780 + # end of 4.1 tests diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index 708a3e0acaa..73f14bd49b3 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -429,17 +429,10 @@ CALL p1('test'); SELECT * FROM t1; sync_slave_with_master; -connection slave; - SELECT * FROM t1; -# Cleanup. - +# Cleanup connection master; - DROP PROCEDURE p1; - -# cleanup -connection master; drop table t1; -reset master; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_sp004.test b/mysql-test/t/rpl_sp004.test index 6f6bd79ae82..9156e6f4047 100644 --- a/mysql-test/t/rpl_sp004.test +++ b/mysql-test/t/rpl_sp004.test @@ -75,21 +75,21 @@ sync_with_master; SELECT * FROM test.t1; SELECT * FROM test.t2; #SELECT * FROM test.t3; -connection master; -#show binlog events; - - -# If the test fails, you will need to diff the dumps to see why. --exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/sp004_master.sql --exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > ./var/tmp/sp004_slave.sql +# Cleanup +connection master; +#show binlog events; DROP PROCEDURE IF EXISTS test.p1; DROP PROCEDURE IF EXISTS test.p2; DROP TABLE IF EXISTS test.t1; DROP TABLE IF EXISTS test.t2; DROP TABLE IF EXISTS test.t3; -#sync_slave_with_master; +sync_slave_with_master; + +# If the test fails, you will need to diff the dumps to see why. -- exec diff ./var/tmp/sp004_master.sql ./var/tmp/sp004_slave.sql diff --git a/mysql-test/t/rpl_sporadic_master.test b/mysql-test/t/rpl_sporadic_master.test index 26b633a1c4f..824f7abc9f5 100644 --- a/mysql-test/t/rpl_sporadic_master.test +++ b/mysql-test/t/rpl_sporadic_master.test @@ -1,3 +1,6 @@ +############################################################# +# 2006-02-07 By JBM added order by +############################################################# # test to see if replication can continue when master sporadically fails on # COM_BINLOG_DUMP and additionally limits the number of events per dump @@ -18,7 +21,7 @@ flush logs; truncate table t1; insert into t1 values (10),(NULL),(NULL),(NULL),(NULL),(NULL); sync_slave_with_master; -select * from t1; +select * from t1 ORDER BY n; connection master; drop table t1,t2; sync_slave_with_master; diff --git a/mysql-test/t/rpl_stm_log.test b/mysql-test/t/rpl_stm_log.test index f5b0a7eead8..d11e1fd8ac1 100644 --- a/mysql-test/t/rpl_stm_log.test +++ b/mysql-test/t/rpl_stm_log.test @@ -1,5 +1,6 @@ # Requires statement logging -- source include/have_binlog_format_statement.inc +let $engine_type=MyISAM; -- source extra/rpl_tests/rpl_log.test diff --git a/mysql-test/t/rpl_000012.test b/mysql-test/t/rpl_temp_table.test index 17f1d38dbae..c29fa8e676d 100644 --- a/mysql-test/t/rpl_000012.test +++ b/mysql-test/t/rpl_temp_table.test @@ -1,7 +1,7 @@ # drop table t1 t2 t3 are included int master-slave.inc -# Like rpl000013, meaningful only in statement-based: +# meaningful only in statement-based: + -- source include/have_binlog_format_statement.inc -# Should work on both stm and row -- source include/master-slave.inc diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index 0eb5d4074d8..9c6056f9217 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -1,3 +1,4 @@ + -- source include/master-slave.inc # Clean up old slave's binlogs. @@ -79,7 +80,7 @@ connection con2; insert into t2 select count(*) from t3; drop temporary table t3; -select * from t2; +select * from t2 ORDER BY f; # Commented out 8/30/2005 to make compatable with both sbr and rbr #--replace_result $VERSION VERSION @@ -121,7 +122,7 @@ SET TIMESTAMP=1040324224; SET @@session.pseudo_thread_id=2; drop temporary table t3; -select * from t2; +select * from t2 ORDER BY f; drop table t1,t2; # Create last a temporary table that is not dropped at end to ensure that we diff --git a/mysql-test/t/rpl_timezone.test b/mysql-test/t/rpl_timezone.test index b3fabdb016f..5a6c1cd06f8 100644 --- a/mysql-test/t/rpl_timezone.test +++ b/mysql-test/t/rpl_timezone.test @@ -56,15 +56,15 @@ connection master; # Change Author: JBM # Change Date: 2005-12-22 # Change: Comment out the exec of the binlog so test works for both SBR and RBR -#--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -#--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 +#--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +#--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 # Let us check with LOAD DATA INFILE # (we do it after mysqlbinlog because the temp files names are not constant) connection master; delete from t1; set time_zone='UTC'; -load data infile '../../std_data/rpl_timezone2.dat' into table t1; +load data infile '../std_data_ln/rpl_timezone2.dat' into table t1; SELECT * FROM t1 ORDER BY n; sync_slave_with_master; set time_zone='UTC'; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 7ffafe1374a..9cfe85d3bd4 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -387,7 +387,7 @@ DROP TABLE t1; flush tables; # Create a junk frm file on disk -system echo "this is a junk file for test" >> var/master-data/test/t1.frm ; +system echo "this is a junk file for test" >> $MYSQLTEST_VARDIR/master-data/test/t1.frm ; --replace_column 6 # 7 # 8 # 9 # SHOW TABLE STATUS like 't1'; --error 1033 diff --git a/mysql-test/t/sp-code.test b/mysql-test/t/sp-code.test index 6644bc3ab43..0a26ea644f6 100644 --- a/mysql-test/t/sp-code.test +++ b/mysql-test/t/sp-code.test @@ -4,6 +4,11 @@ -- source include/is_debug_build.inc +--disable_warnings +drop procedure if exists empty; +drop procedure if exists code_sample; +--enable_warnings + create procedure empty() begin end; @@ -47,3 +52,141 @@ end// delimiter ;// show procedure code code_sample; drop procedure code_sample; + + +# +# BUG#15737: Stored procedure optimizer bug with LEAVE +# +# This is a much more extensive test case than is strictly needed, +# but it was kept as is for two reasons: +# - The bug occurs under some quite special circumstances, so it +# wasn't trivial to create a smaller test, +# - There's some value in having another more complex code sample +# in this test file. This might catch future code generation bugs +# that doesn't show in behaviour in any obvious way. + +--disable_warnings +drop procedure if exists sudoku_solve; +--enable_warnings + +delimiter //; +create procedure sudoku_solve(p_naive boolean, p_all boolean) + deterministic + modifies sql data +begin + drop temporary table if exists sudoku_work, sudoku_schedule; + + create temporary table sudoku_work + ( + row smallint not null, + col smallint not null, + dig smallint not null, + cnt smallint, + key using btree (cnt), + key using btree (row), + key using btree (col), + unique key using hash (row,col) + ); + + create temporary table sudoku_schedule + ( + idx int not null auto_increment primary key, + row smallint not null, + col smallint not null + ); + + call sudoku_init(); + + if p_naive then + update sudoku_work set cnt = 0 where dig = 0; + else + call sudoku_count(); + end if; + insert into sudoku_schedule (row,col) + select row,col from sudoku_work where cnt is not null order by cnt desc; + + begin + declare v_scounter bigint default 0; + declare v_i smallint default 1; + declare v_dig smallint; + declare v_schedmax smallint; + + select count(*) into v_schedmax from sudoku_schedule; + + more: + loop + begin + declare v_tcounter bigint default 0; + + sched: + while v_i <= v_schedmax do + begin + declare v_row, v_col smallint; + + select row,col into v_row,v_col from sudoku_schedule where v_i = idx; + + select dig into v_dig from sudoku_work + where v_row = row and v_col = col; + + case v_dig + when 0 then + set v_dig = 1; + update sudoku_work set dig = 1 + where v_row = row and v_col = col; + when 9 then + if v_i > 0 then + update sudoku_work set dig = 0 + where v_row = row and v_col = col; + set v_i = v_i - 1; + iterate sched; + else + select v_scounter as 'Solutions'; + leave more; + end if; + else + set v_dig = v_dig + 1; + update sudoku_work set dig = v_dig + where v_row = row and v_col = col; + end case; + + set v_tcounter = v_tcounter + 1; + if not sudoku_digit_ok(v_row, v_col, v_dig) then + iterate sched; + end if; + set v_i = v_i + 1; + end; + end while sched; + + select dig from sudoku_work; + select v_tcounter as 'Tests'; + set v_scounter = v_scounter + 1; + + if p_all and v_i > 0 then + set v_i = v_i - 1; + else + leave more; + end if; + end; + end loop more; + end; + + drop temporary table sudoku_work, sudoku_schedule; +end// +delimiter ;// + +# The interestings parts are where the code for the two "leave" are: +# ... +#| 26 | jump_if_not 30 (v_i@3 > 0) | +# ... +#| 30 | stmt 0 "select v_scounter as 'Solutions'" | +#| 31 | jump 45 | +# ... +#| 42 | jump_if_not 45 (p_all@1 and (v_i@3 > 0)) | +#| 43 | set v_i@3 (v_i@3 - 1) | +#| 44 | jump 14 | +#| 45 | stmt 9 "drop temporary table sudoku_work, sud..." | +#+-----+-----------------------------------------------------------------------+ +# The bug appeared at position 42 (with the wrong destination). +show procedure code sudoku_solve; + +drop procedure sudoku_solve; diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test index bb61f3383bc..5fc81c338c6 100644 --- a/mysql-test/t/sp-destruct.test +++ b/mysql-test/t/sp-destruct.test @@ -16,9 +16,9 @@ --source include/not_windows.inc # Backup proc table ---system rm -rf var/master-data/mysql/backup ---system mkdir var/master-data/mysql/backup ---system cp var/master-data/mysql/proc.* var/master-data/mysql/backup/ +--system rm -rf $MYSQLTEST_VARDIR/master-data/mysql/backup +--system mkdir $MYSQLTEST_VARDIR/master-data/mysql/backup +--system cp $MYSQLTEST_VARDIR/master-data/mysql/proc.* $MYSQLTEST_VARDIR/master-data/mysql/backup/ use test; @@ -53,7 +53,7 @@ insert into t1 values (0); flush table mysql.proc; # Thrashing the .frm file ---system echo 'saljdlfa' > var/master-data/mysql/proc.frm +--system echo 'saljdlfa' > $MYSQLTEST_VARDIR/master-data/mysql/proc.frm --error ER_NOT_FORM_FILE call bug14233(); --error ER_NOT_FORM_FILE @@ -65,7 +65,7 @@ insert into t1 values (0); flush table mysql.proc; # Drop the mysql.proc table ---system rm var/master-data/mysql/proc.* +--system rm $MYSQLTEST_VARDIR/master-data/mysql/proc.* --error ER_NO_SUCH_TABLE call bug14233(); --error ER_NO_SUCH_TABLE @@ -74,8 +74,8 @@ create view v1 as select bug14233_f(); insert into t1 values (0); # Restore mysql.proc ---system mv var/master-data/mysql/backup/* var/master-data/mysql/ ---system rmdir var/master-data/mysql/backup +--system mv $MYSQLTEST_VARDIR/master-data/mysql/backup/* $MYSQLTEST_VARDIR/master-data/mysql/ +--system rmdir $MYSQLTEST_VARDIR/master-data/mysql/backup flush table mysql.proc; flush privileges; @@ -127,6 +127,15 @@ create trigger t1_ai after insert on t1 for each row call bug14233_3(); insert into t1 values (0); # Clean-up -delete from mysql.proc where name like 'bug14233%'; drop trigger t1_ai; drop table t1; + +# +# BUG#16303: erroneus stored procedures and functions should be droppable +# +drop function bug14233_1; +drop function bug14233_2; +drop procedure bug14233_3; +# Assert: These should show nothing. +show procedure status; +show function status; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index d7044bee632..63185ea9a88 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -1622,6 +1622,66 @@ drop procedure ` bug15658`; # +# BUG#14270: Stored procedures: crash if load index +# +--disable_warnings +drop function if exists bug14270; +drop table if exists t1; +--enable_warnings + +create table t1 (s1 int primary key); + +delimiter |; +--error ER_SP_NO_RETSET +create function bug14270() returns int +begin + load index into cache t1; + return 1; +end| + +--error ER_SP_NO_RETSET +create function bug14270() returns int +begin + cache index t1 key (`primary`) in keycache1; + return 1; +end| +delimiter ;| + +drop table t1; + + +# +# BUG#15091: Sp Returns Unknown error in order clause....and +# there is no order by clause +# +--disable_warnings +drop procedure if exists bug15091; +--enable_warnings + +delimiter |; +create procedure bug15091() +begin + declare selectstr varchar(6000) default ' '; + declare conditionstr varchar(5000) default ''; + + set selectstr = concat(selectstr, + ' and ', + c.operatorid, + 'in (',conditionstr, ')'); +end| +delimiter ;| + +# The error message used to be: +# ERROR 1109 (42S02): Unknown table 'c' in order clause +# but is now rephrased to something less misleading: +# ERROR 1109 (42S02): Unknown table 'c' in field list +--error ER_UNKNOWN_TABLE +call bug15091(); + +drop procedure bug15091; + + +# # BUG#NNNN: New bug synopsis # #--disable_warnings diff --git a/mysql-test/t/sp-prelocking.test b/mysql-test/t/sp-prelocking.test index bae144f51ac..edb8ae5b92d 100644 --- a/mysql-test/t/sp-prelocking.test +++ b/mysql-test/t/sp-prelocking.test @@ -234,9 +234,9 @@ select f3() // call sp1() // delimiter ;// -drop table t1,t2,t3; +drop view v1; +drop table t1,t2,t3,t4; drop function f1; drop function f2; drop function f3; drop procedure sp1; -drop view v1; diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test index 0b24881a056..90160780618 100644 --- a/mysql-test/t/sp-security.test +++ b/mysql-test/t/sp-security.test @@ -196,7 +196,6 @@ use db2; call q(); select * from t2; - # # BUG#6030: Stored procedure has no appropriate DROP privilege # (or ALTER for that matter) @@ -233,9 +232,13 @@ drop database db2; select type,db,name from mysql.proc; # Get rid of the users delete from mysql.user where user='user1' or user='user2'; +delete from mysql.user where user='' and host='%'; # And any routine privileges delete from mysql.procs_priv where user='user1' or user='user2'; - +# Delete the grants to user ''@'%' that was created above +delete from mysql.procs_priv where user='' and host='%'; +delete from mysql.db where user='user2'; +flush privileges; # # Test the new security acls # @@ -304,6 +307,9 @@ use test; drop database sptest; delete from mysql.user where user='usera' or user='userb' or user='userc'; delete from mysql.procs_priv where user='usera' or user='userb' or user='userc'; +delete from mysql.tables_priv where user='usera'; +flush privileges; +drop table t1; # # BUG#9503: reseting correct parameters of thread after error in SP function @@ -481,4 +487,42 @@ drop user user2_bug14834@localhost; drop user user3_bug14834@localhost; drop database db_bug14834; + +# +# BUG#14533: 'desc tbl' in stored procedure causes error 1142 +# +create database db_bug14533; +use db_bug14533; +create table t1 (id int); +create user user_bug14533@localhost identified by ''; + +create procedure bug14533_1() + sql security definer + desc db_bug14533.t1; + +create procedure bug14533_2() + sql security definer + select * from db_bug14533.t1; + +grant execute on procedure db_bug14533.bug14533_1 to user_bug14533@localhost; +grant execute on procedure db_bug14533.bug14533_2 to user_bug14533@localhost; + +connect (user_bug14533,localhost,user_bug14533,,test); + +# These should work +call db_bug14533.bug14533_1(); +call db_bug14533.bug14533_2(); + +# For reference, these should not work +--error ER_TABLEACCESS_DENIED_ERROR +desc db_bug14533.t1; +--error ER_TABLEACCESS_DENIED_ERROR +select * from db_bug14533.t1; + +# Cleanup +connection default; +disconnect user_bug14533; +drop user user_bug14533@localhost; +drop database db_bug14533; + # End of 5.0 bugs. diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 02772313d01..45de4010535 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -5125,10 +5125,7 @@ end| call bug14498_1()| call bug14498_2()| call bug14498_3()| -# We couldn't call this before, due to a known bug (BUG#14643) -# QQ We still can't since the new set_case_expr instruction breaks -# the semantics of case; it won't crash, but will get the wrong result. -#call bug14498_4()| +call bug14498_4()| call bug14498_5()| drop procedure bug14498_1| @@ -5199,6 +5196,37 @@ drop procedure if exists bug15231_4| # +# BUG#15011: error handler in nested block not activated +# +--disable_warnings +drop procedure if exists bug15011| +--enable_warnings + +create table t3 (c1 int primary key)| + +insert into t3 values (1)| + +create procedure bug15011() + deterministic +begin + declare continue handler for 1062 + select 'Outer' as 'Handler'; + + begin + declare continue handler for 1062 + select 'Inner' as 'Handler'; + + insert into t3 values (1); + end; +end| + +call bug15011()| + +drop procedure bug15011| +drop table t3| + + +# # BUG#NNNN: New bug synopsis # #--disable_warnings diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test index 4bfc4d17588..573fe0c1810 100644 --- a/mysql-test/t/subselect_innodb.test +++ b/mysql-test/t/subselect_innodb.test @@ -236,4 +236,5 @@ delimiter ;// call p1(); call p1(); call p1(); +drop procedure p1; drop tables t1,t2,t3; diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index 6a6dd305006..19a720a4fb8 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -43,7 +43,7 @@ drop table t2; # disable_query_log; -eval create table t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="$MYSQL_TEST_DIR/var/tmp" index directory="$MYSQL_TEST_DIR/var/run"; +eval create table t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="$MYSQLTEST_VARDIR/tmp" index directory="$MYSQLTEST_VARDIR/run"; enable_query_log; insert into t9 select * from t1; @@ -52,7 +52,7 @@ optimize table t9; repair table t9; alter table t9 add column c int not null; ---replace_result $MYSQL_TEST_DIR TEST_DIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show create table t9; # Test renames @@ -67,7 +67,7 @@ drop table t1; # Note that we are using the above table t9 here! # ---replace_result $MYSQL_TEST_DIR TEST_DIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR SHOW CREATE TABLE t9; disable_query_log; @@ -86,11 +86,11 @@ create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, p # Should fail becasue the file t9.MYI already exist in 'run' --error 1,1,1105 -eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam index directory="$MYSQL_TEST_DIR/var/run"; +eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam index directory="$MYSQLTEST_VARDIR/run"; # Should fail becasue the file t9.MYD already exist in 'tmp' --error 1,1 -eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="$MYSQL_TEST_DIR/var/tmp"; +eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="$MYSQLTEST_VARDIR/tmp"; enable_query_log; # Check moving table t9 from default database to mysqltest; @@ -98,7 +98,7 @@ enable_query_log; alter table t9 rename mysqltest.t9; select count(*) from mysqltest.t9; ---replace_result $MYSQL_TEST_DIR TEST_DIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show create table mysqltest.t9; drop database mysqltest; @@ -108,18 +108,18 @@ drop database mysqltest; create table t1 (a int not null) engine=myisam; disable_query_log; -eval alter table t1 data directory="$MYSQL_TEST_DIR/var/tmp"; +eval alter table t1 data directory="$MYSQLTEST_VARDIR/tmp"; enable_query_log; ---replace_result $MYSQL_TEST_DIR TEST_DIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show create table t1; alter table t1 add b int; disable_query_log; -eval alter table t1 data directory="$MYSQL_TEST_DIR/var/log"; +eval alter table t1 data directory="$MYSQLTEST_VARDIR/log"; enable_query_log; ---replace_result $MYSQL_TEST_DIR TEST_DIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show create table t1; disable_query_log; -eval alter table t1 index directory="$MYSQL_TEST_DIR/var/log"; +eval alter table t1 index directory="$MYSQLTEST_VARDIR/log"; enable_query_log; show create table t1; drop table t1; @@ -129,12 +129,12 @@ drop table t1; # have been chosen. (Bug #8707) # disable_query_log; -eval create table t1 (i int) data directory = "$MYSQL_TEST_DIR/var/master-data/test/"; +eval create table t1 (i int) data directory = "$MYSQLTEST_VARDIR/master-data/test/"; enable_query_log; show create table t1; drop table t1; disable_query_log; -eval create table t1 (i int) index directory = "$MYSQL_TEST_DIR/var/master-data/test/"; +eval create table t1 (i int) index directory = "$MYSQLTEST_VARDIR/master-data/test/"; enable_query_log; show create table t1; drop table t1; diff --git a/mysql-test/t/system_mysql_db_fix.test b/mysql-test/t/system_mysql_db_fix.test index 11ed48011d7..18e1efb3120 100644 --- a/mysql-test/t/system_mysql_db_fix.test +++ b/mysql-test/t/system_mysql_db_fix.test @@ -38,7 +38,7 @@ CREATE TABLE db ( PRIMARY KEY Host (Host,Db,User), KEY User (User) ) -type=MyISAM; +engine=MyISAM; --enable-warnings INSERT INTO db VALUES ('%','test', '','Y','Y','Y','Y','Y','Y'); @@ -56,7 +56,7 @@ CREATE TABLE host ( Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db) ) -type=MyISAM; +engine=MyISAM; --enable-warnings --disable_warnings @@ -75,7 +75,7 @@ CREATE TABLE user ( Process_priv enum('N','Y') DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,User) ) -type=MyISAM; +engine=MyISAM; --enable-warnings INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y'); diff --git a/mysql-test/t/temp_table-master.opt b/mysql-test/t/temp_table-master.opt index 026d3d4640c..5ac2ca8495b 100644 --- a/mysql-test/t/temp_table-master.opt +++ b/mysql-test/t/temp_table-master.opt @@ -1 +1 @@ ---tmpdir=$MYSQL_TEST_DIR/var//tmp +--tmpdir=$MYSQLTEST_VARDIR//tmp diff --git a/mysql-test/t/trigger-compat.test b/mysql-test/t/trigger-compat.test index 5b2483cc3ea..9f7fd8bc505 100644 --- a/mysql-test/t/trigger-compat.test +++ b/mysql-test/t/trigger-compat.test @@ -60,8 +60,8 @@ CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1 --echo --echo ---> patching t1.TRG... ---exec grep -v 'definers=' $MYSQL_TEST_DIR/var/master-data/mysqltest_db1/t1.TRG > $MYSQL_TEST_DIR/var/tmp/t1.TRG ---exec mv $MYSQL_TEST_DIR/var/tmp/t1.TRG $MYSQL_TEST_DIR/var/master-data/mysqltest_db1/t1.TRG +--exec grep -v 'definers=' $MYSQLTEST_VARDIR/master-data/mysqltest_db1/t1.TRG > $MYSQLTEST_VARDIR/tmp/t1.TRG +--exec mv $MYSQLTEST_VARDIR/tmp/t1.TRG $MYSQLTEST_VARDIR/master-data/mysqltest_db1/t1.TRG # # Create a new trigger. @@ -80,3 +80,16 @@ SELECT trigger_name, definer FROM INFORMATION_SCHEMA.TRIGGERS ORDER BY trigger_n --echo SELECT * FROM INFORMATION_SCHEMA.TRIGGERS ORDER BY trigger_name; + +# Clean up +DROP TRIGGER wl2818_trg1; +DROP TRIGGER wl2818_trg2; +disconnect wl2818_definer_con; +connection default; +use mysqltest_db1; +DROP TABLE t1; +DROP TABLE t2; +DROP USER mysqltest_dfn@localhost; +DROP USER mysqltest_inv@localhost; +DROP DATABASE mysqltest_db1; + diff --git a/mysql-test/t/trigger-grant.test b/mysql-test/t/trigger-grant.test index dc863bd8e32..c0a12c3ecb5 100644 --- a/mysql-test/t/trigger-grant.test +++ b/mysql-test/t/trigger-grant.test @@ -362,9 +362,9 @@ CREATE TRIGGER trg5 BEFORE DELETE ON t1 FOR EACH ROW SET @a = 5; ---exec egrep -v '^definers=' $MYSQL_TEST_DIR/var/master-data/mysqltest_db1/t1.TRG > $MYSQL_TEST_DIR/var/tmp/t1.TRG ---exec echo "definers='' '@' '@abc@def@@' '@hostname' '@abcdef@@@hostname'" >> $MYSQL_TEST_DIR/var/tmp/t1.TRG ---exec mv $MYSQL_TEST_DIR/var/tmp/t1.TRG $MYSQL_TEST_DIR/var/master-data/mysqltest_db1/t1.TRG +--exec egrep -v '^definers=' $MYSQLTEST_VARDIR/master-data/mysqltest_db1/t1.TRG > $MYSQLTEST_VARDIR/tmp/t1.TRG +--exec echo "definers='' '@' '@abc@def@@' '@hostname' '@abcdef@@@hostname'" >> $MYSQLTEST_VARDIR/tmp/t1.TRG +--exec mv $MYSQLTEST_VARDIR/tmp/t1.TRG $MYSQLTEST_VARDIR/master-data/mysqltest_db1/t1.TRG --echo diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index f2d9bb6c856..c3cc8e3f8e8 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -465,11 +465,11 @@ create trigger trg1 before insert on t1 for each row set new.k = new.i; create trigger trg2 after insert on t1 for each row set @b:= "Fired"; set @b:=""; # Test triggers with file with separators -load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, i); +load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, i); select *, @b from t1; set @b:=""; # Test triggers with fixed size row file -load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, j); +load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, j); select *, @b from t1; # This also will drop triggers drop table t1; @@ -503,7 +503,7 @@ delete from t1 where i = 2; select * from t1; # Should fail and insert only 1 row --error 1054 -load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); select * from t1; --error 1054 insert into t1 select 3, 3; @@ -563,7 +563,7 @@ select * from t1; delete from t1; select * from t1; --error 1054 -load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); select * from t1; --error 1054 insert into t1 select 3, 3; @@ -958,3 +958,12 @@ create trigger test.t1_bi before insert on t1 for each row set @a:=0; --error ER_NO_DB_ERROR drop trigger t1_bi; connection default; + +# Test for bug #16829 "Firing trigger with RETURN crashes the server" +# RETURN is not supposed to be used anywhere except functions, so error +# should be returned when one attempts to create trigger with RETURN. +create table t1 (i int); +--error ER_SP_BADRETURN +create trigger t1_bi before insert on t1 for each row return 0; +insert into t1 values (1); +drop table t1; diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 0c45dea21bb..1f05a9574d6 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -226,3 +226,4 @@ select a1, a2, b1+0, b2+0 from t1 join t2 on b1 = b2; select sum(a1), b1+0, b2+0 from t1 join t2 on b1 = b2 group by b1 order by 1; select 1 from t1 join t2 on b1 = b2 group by b1 order by 1; select b1+0,sum(b1), sum(b2) from t1 join t2 on b1 = b2 group by b1 order by 1; +drop table t1, t2; diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 79f29624e89..d223c315735 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -6,9 +6,7 @@ drop table if exists t1,t2; --enable_warnings ---replace_result e-0 e- e+0 e+ SELECT 10,10.0,10.,.1e+2,100.0e-1; ---replace_result e-00 e-0 SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000; SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1; SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01; @@ -21,7 +19,6 @@ create table t1 (f1 float(24),f2 float(52)); show full columns from t1; insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150); insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150); ---replace_result e-0 e- e+0 e+ select * from t1; drop table t1; diff --git a/mysql-test/t/type_varchar.test b/mysql-test/t/type_varchar.test index 2d2314f0a29..e5614afe4f6 100644 --- a/mysql-test/t/type_varchar.test +++ b/mysql-test/t/type_varchar.test @@ -3,7 +3,7 @@ drop table if exists t1, t2; --enable_warnings create table t1 (v varchar(30), c char(3), e enum('abc','def','ghi'), t text); -system cp std_data/vchar.frm var/master-data/test/; +system cp $MYSQL_TEST_DIR/std_data/vchar.frm $MYSQLTEST_VARDIR/master-data/test/; truncate table vchar; show create table t1; show create table vchar; diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index d0496b48c7a..5a49de248b1 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -287,4 +287,23 @@ update t1 set f1=1 where f1=3; update t2,t1 set f1=3,f2=3 where f1=f2 and f1=1; --disable_info drop table t1,t2; + + +# BUG#15935 +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler1 char(200), filler2 char(200), key(a)); +insert into t2 select A.a + 10*B.a, 'filler','filler' from t1 A, t1 B; +flush status; +update t2 set a=3 where a=2; +show status like 'handler_read%'; +drop table t1, t2; + +# +# Bug #16510 Updating field named like '*name' caused server crash +# +create table t1(f1 int, `*f2` int); +insert into t1 values (1,1); +update t1 set `*f2`=1; +drop table t1; # End of 4.1 tests diff --git a/mysql-test/t/user_var-binlog.test b/mysql-test/t/user_var-binlog.test index a3128064c91..a7726c990f1 100644 --- a/mysql-test/t/user_var-binlog.test +++ b/mysql-test/t/user_var-binlog.test @@ -19,7 +19,7 @@ show binlog events from 102; # absolutely need variables names to be quoted and strings to be # escaped). --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 drop table t1; # End of 4.1 tests diff --git a/mysql-test/t/variables-master.opt b/mysql-test/t/variables-master.opt index a0577107f74..abd826bc7fa 100644 --- a/mysql-test/t/variables-master.opt +++ b/mysql-test/t/variables-master.opt @@ -1 +1 @@ ---max_join_size=10 +--max_join_size=100 diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 76761f9177d..eb3273a9e9b 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -20,7 +20,6 @@ select @test, @`test`, @TEST, @`TEST`, @"teSt"; set @select=2,@t5=1.23456; select @`select`,@not_used; set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL; ---replace_result e-0 e- e+0 e+ select @test_int,@test_double,@test_string,@test_string2,@select; set @test_int="hello",@test_double="hello",@test_string="hello",@test_string2="hello"; select @test_int,@test_double,@test_string,@test_string2; @@ -48,7 +47,7 @@ drop table t1; # # Test system variables # - +set GLOBAL max_join_size=10; set max_join_size=100; show variables like 'max_join_size'; --replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 33741b9bf46..5d1b5a80a9b 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1221,11 +1221,11 @@ drop table t1; create table t1 (a int, b char(10)); create view v1 as select * from t1 where a != 0 with check option; -- error 1369 -load data infile '../../std_data/loaddata3.dat' into table v1 fields terminated by '' enclosed by '' ignore 1 lines; +load data infile '../std_data_ln/loaddata3.dat' into table v1 fields terminated by '' enclosed by '' ignore 1 lines; select * from t1; select * from v1; delete from t1; -load data infile '../../std_data/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines; +load data infile '../std_data_ln/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines; select * from t1; select * from v1; drop view v1; @@ -1234,11 +1234,11 @@ drop table t1; create table t1 (a text, b text); create view v1 as select * from t1 where a <> 'Field A' with check option; -- error 1369 -load data infile '../../std_data/loaddata2.dat' into table v1 fields terminated by ',' enclosed by ''''; +load data infile '../std_data_ln/loaddata2.dat' into table v1 fields terminated by ',' enclosed by ''''; select concat('|',a,'|'), concat('|',b,'|') from t1; select concat('|',a,'|'), concat('|',b,'|') from v1; delete from t1; -load data infile '../../std_data/loaddata2.dat' ignore into table v1 fields terminated by ',' enclosed by ''''; +load data infile '../std_data_ln/loaddata2.dat' ignore into table v1 fields terminated by ',' enclosed by ''''; select concat('|',a,'|'), concat('|',b,'|') from t1; select concat('|',a,'|'), concat('|',b,'|') from v1; drop view v1; @@ -2358,3 +2358,20 @@ EXPLAIN SELECT MIN(a) FROM v1; DROP VIEW v1; DROP TABLE t1; + +# +# Bug#16382: grouping name is resolved against a view column name +# which coincides with a select column name + +CREATE TABLE t1 (x varchar(10)); +INSERT INTO t1 VALUES (null), ('foo'), ('bar'), (null); +CREATE VIEW v1 AS SELECT * FROM t1; + +SELECT IF(x IS NULL, 'blank', 'not blank') FROM v1 GROUP BY x; +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM t1 GROUP BY x; +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1; +SELECT IF(x IS NULL, 'blank', 'not blank') AS y FROM v1 GROUP BY y; +SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1 GROUP BY x; + +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test index 26a4a7e1ec5..1327436d6c3 100644 --- a/mysql-test/t/view_grant.test +++ b/mysql-test/t/view_grant.test @@ -12,6 +12,8 @@ grant create view on test.* to test@localhost; show grants for test@localhost; revoke create view on test.* from test@localhost; show grants for test@localhost; +# The grant above creates a new user test@localhost, delete it +drop user test@localhost; # grant create view test # diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test index f65ce962ef2..a1a38298345 100644 --- a/mysql-test/t/warnings.test +++ b/mysql-test/t/warnings.test @@ -50,7 +50,7 @@ drop table t1; # create table t1(a tinyint, b int not null, c date, d char(5)); -load data infile '../../std_data/warnings_loaddata.dat' into table t1 fields terminated by ','; +load data infile '../std_data_ln/warnings_loaddata.dat' into table t1 fields terminated by ','; # PS doesn't work good with @@warning_count --disable_ps_protocol select @@warning_count; @@ -118,14 +118,6 @@ drop table t1; #drop table t1; # -# Test for deprecated TYPE= syntax -# - -create table t1 (id int) type=heap; -alter table t1 type=myisam; -drop table t1; - -# # Test for deprecated table_type variable # set table_type=MYISAM; diff --git a/mysys/my_init.c b/mysys/my_init.c index f28f47e090e..c2bfdde0ddd 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -152,6 +152,7 @@ void my_end(int infoflag) DBUG_PRINT("error",("%s",errbuff[0])); } } + free_charsets(); my_once_free(); if ((infoflag & MY_GIVE_INFO) || print_info) diff --git a/scripts/fill_func_tables.sh b/scripts/fill_func_tables.sh index 203c730dd9a..83501886d88 100644 --- a/scripts/fill_func_tables.sh +++ b/scripts/fill_func_tables.sh @@ -140,7 +140,7 @@ print " max_args tinyint,"; print " date_created datetime not null,"; print " last_modified timestamp not null,"; print " primary key (func_id)"; -print ") type=myisam;\n\n"; +print ") ENGINE=MYISAM;\n\n"; print "DROP TABLE IF EXISTS function_category_name;\n"; print "CREATE TABLE function_category_name ("; @@ -150,14 +150,14 @@ print " url char(128) not null,"; print " date_created datetime not null,"; print " last_modified timestamp not null,"; print " primary key (cat_id)"; -print ") type=myisam;\n\n"; +print ") ENGINE=MYISAM;\n\n"; print "DROP TABLE IF EXISTS function_category;\n"; print "CREATE TABLE function_category ("; print " cat_id smallint unsigned not null references function_category_name,"; print " func_id int unsigned not null references function,"; print " primary key (cat_id, func_id)"; -print ") type=myisam;\n\n"; +print ") ENGINE=MYISAM;\n\n"; print "DELETE FROM function_category_name;\n"; print "DELETE FROM function_category;\n"; diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 2f59c3e1d4c..03c2c6d3154 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -131,7 +131,7 @@ BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \ extra/resolve_stack_dump$BS extra/mysql_waitpid$BS \ storage/myisam/myisamchk$BS storage/myisam/myisampack$BS \ storage/myisam/myisamlog$BS storage/myisam/myisam_ftdump$BS \ - sql/mysqld$BS sql/mysql_tzinfo_to_sql$BS \ + sql/mysqld$BS sql/mysqld-debug$BS sql/mysql_tzinfo_to_sql$BS \ server-tools/instance-manager/mysqlmanager$BS \ client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \ client/mysqlslap$BS \ @@ -173,8 +173,9 @@ if [ x$STRIP = x1 ] ; then strip $BASE/bin/* fi -# Copy not binary files -copyfileto $BASE/bin sql/mysqld.sym.gz +# Obsolete, starting from 5.1.6-beta +# # Copy not binary files +# copyfileto $BASE/bin sql/mysqld.sym.gz if [ $BASE_SYSTEM = "netware" ] ; then $CP netware/*.pl $BASE/scripts @@ -304,11 +305,12 @@ else rm -f $BASE/README.NW fi -# Make safe_mysqld a symlink to mysqld_safe for backwards portability -# To be removed in MySQL 4.1 -if [ $BASE_SYSTEM != "netware" ] ; then - (cd $BASE/bin ; ln -s mysqld_safe safe_mysqld ) -fi +# Dropped with 5.1.6-beta +# # Make safe_mysqld a symlink to mysqld_safe for backwards portability +# # To be removed in MySQL 4.1 +# if [ $BASE_SYSTEM != "netware" ] ; then +# (cd $BASE/bin ; ln -s mysqld_safe safe_mysqld ) +# fi # Clean up if we did this from a bk tree if [ -d $BASE/sql-bench/SCCS ] ; then @@ -345,7 +347,7 @@ BASE=$BASE2 if [ x"@GXX@" = x"yes" ] ; then gcclib=`@CC@ --print-libgcc-file` if [ $? -ne 0 ] ; then - print "Warning: Couldn't find libgcc.a!" + echo "Warning: Couldn't find libgcc.a!" else $CP $gcclib $BASE/lib/libmygcc.a fi diff --git a/scripts/mysql_convert_table_format.sh b/scripts/mysql_convert_table_format.sh index c1955e632fb..4b68d6c5039 100644 --- a/scripts/mysql_convert_table_format.sh +++ b/scripts/mysql_convert_table_format.sh @@ -69,7 +69,7 @@ foreach $table (@ARGV) } } print "converting $table\n" if ($opt_verbose); - if (!$dbh->do("ALTER TABLE $table type=$opt_type")) + if (!$dbh->do("ALTER TABLE $table ENGINE=$opt_type")) { print STDERR "Can't convert $table: Error $DBI::errstr\n"; exit(1) if (!$opt_force); @@ -114,7 +114,7 @@ Conversion of a MySQL tables to other table types. --socket='/path/to/socket' Socket to connect with. ---type='table-type' +--ENGINE='table-type' Converts tables to the given table type (Default: $opt_type) MySQL 3.23 supports at least the BDB, ISAM and MYISAM types. diff --git a/server-tools/instance-manager/Makefile.am b/server-tools/instance-manager/Makefile.am index 7449735f0bf..043a0336b93 100644 --- a/server-tools/instance-manager/Makefile.am +++ b/server-tools/instance-manager/Makefile.am @@ -30,11 +30,9 @@ liboptions_a_CXXFLAGS= $(CXXFLAGS) \ -DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager.pid" \ -DDEFAULT_LOG_FILE_NAME="$(localstatedir)/mysqlmanager.log" \ -DDEFAULT_SOCKET_FILE_NAME="/tmp/mysqlmanager.sock" \ - -DDEFAULT_PASSWORD_FILE_NAME="$(sysconfdir)/mysqlmanager.passwd" \ + -DDEFAULT_PASSWORD_FILE_NAME="/etc/mysqlmanager.passwd" \ -DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld$(EXEEXT)" \ - -DDEFAULT_MONITORING_INTERVAL="20" \ - -DDEFAULT_PORT="2273" \ - -DDEFAULT_CONFIG_FILE="/etc/my.cnf" \ + -DDEFAULT_CONFIG_FILE="/etc/my.cnf" \ -DPROTOCOL_VERSION=@PROTOCOL_VERSION@ liboptions_a_SOURCES= options.h options.cc priv.h priv.cc @@ -79,7 +77,8 @@ mysqlmanager_SOURCES= command.cc command.h mysqlmanager.cc \ mysql_manager_error.h \ portability.h -mysqlmanager_LDADD= liboptions.a \ +mysqlmanager_LDADD= @CLIENT_EXTRA_LDFLAGS@ \ + liboptions.a \ libnet.a \ $(top_builddir)/vio/libvio.a \ $(top_builddir)/mysys/libmysys.a \ diff --git a/server-tools/instance-manager/commands.cc b/server-tools/instance-manager/commands.cc index b4dd1b469f1..7b999f61503 100644 --- a/server-tools/instance-manager/commands.cc +++ b/server-tools/instance-manager/commands.cc @@ -25,6 +25,7 @@ #include "options.h" #include <m_string.h> +#include <m_ctype.h> #include <mysql.h> #include <my_dir.h> @@ -62,6 +63,31 @@ static inline int put_to_buff(Buffer *buff, const char *str, uint *position) } +static int parse_version_number(const char *version_str, char *version, + uint version_size) +{ + const char *start= version_str; + const char *end; + + // skip garbage + while (!my_isdigit(default_charset_info, *start)) + start++; + + end= start; + // skip digits and dots + while (my_isdigit(default_charset_info, *end) || *end == '.') + end++; + + if ((uint)(end - start) >= version_size) + return -1; + + strncpy(version, start, end-start); + version[end-start]= '\0'; + + return 0; +} + + /* implementation for Show_instances: */ @@ -174,9 +200,10 @@ int Show_instance_status::execute(struct st_net *net, { enum { MAX_VERSION_LENGTH= 40 }; Buffer send_buff; /* buffer for packets */ - LIST name, status, version; + LIST name, status, version, version_number; LIST *field_list; - NAME_WITH_LENGTH name_field, status_field, version_field; + NAME_WITH_LENGTH name_field, status_field, version_field, + version_number_field; uint position=0; if (!instance_name) @@ -192,7 +219,11 @@ int Show_instance_status::execute(struct st_net *net, version_field.name= (char*) "version"; version_field.length= MAX_VERSION_LENGTH; version.data= &version_field; + version_number_field.name= (char*) "version_number"; + version_number_field.length= MAX_VERSION_LENGTH; + version_number.data= &version_number_field; field_list= list_add(NULL, &version); + field_list= list_add(field_list, &version_number); field_list= list_add(field_list, &status); field_list= list_add(field_list, &name); @@ -210,10 +241,21 @@ int Show_instance_status::execute(struct st_net *net, store_to_protocol_packet(&send_buff, (char*) "offline", &position); if (instance->options.mysqld_version) + { + char parsed_version[MAX_VERSION_LENGTH]; + + parse_version_number(instance->options.mysqld_version, parsed_version, + sizeof(parsed_version)); + store_to_protocol_packet(&send_buff, parsed_version, &position); + store_to_protocol_packet(&send_buff, instance->options.mysqld_version, &position); + } else + { store_to_protocol_packet(&send_buff, (char*) "unknown", &position); + store_to_protocol_packet(&send_buff, (char*) "unknown", &position); + } if (send_buff.is_error() || @@ -483,7 +525,7 @@ int Show_instance_log::execute(struct st_net *net, ulong connection_id) read_buff.reserve(0, buff_size); /* read in one chunk */ - read_len= my_seek(fd, file_stat.st_size - size, MY_SEEK_SET, MYF(0)); + read_len= (int)my_seek(fd, file_stat.st_size - size, MY_SEEK_SET, MYF(0)); if ((read_len= my_read(fd, (byte*) read_buff.buffer, buff_size, MYF(0))) < 0) diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc index 3d04403f830..39381b457ab 100644 --- a/server-tools/instance-manager/instance.cc +++ b/server-tools/instance-manager/instance.cc @@ -418,6 +418,10 @@ bool Instance::is_running() if (options.mysqld_socket) socket= strchr(options.mysqld_socket, '=') + 1; + /* no port was specified => instance falled back to default value */ + if (!options.mysqld_port && !options.mysqld_socket) + port= SERVER_DEFAULT_PORT; + pthread_mutex_lock(&LOCK_instance); mysql_init(&mysql); diff --git a/server-tools/instance-manager/instance_map.cc b/server-tools/instance-manager/instance_map.cc index 611eda457f2..7dfe0ae688b 100644 --- a/server-tools/instance-manager/instance_map.cc +++ b/server-tools/instance-manager/instance_map.cc @@ -229,11 +229,33 @@ int Instance_map::load() uint args_used= 0; const char *argv_options[3]; char **argv= (char **) &argv_options; - + char defaults_file_arg[FN_REFLEN]; /* the name of the program may be orbitrary here in fact */ argv_options[0]= "mysqlmanager"; - argv_options[1]= '\0'; + + /* + If the option file was forced by the user when starting + the IM with --defaults-file=xxxx, make sure it is also + passed as --defaults-file, not only as Options::config_file. + This is important for option files given with relative path: + e.g. --defaults-file=my.cnf. + Otherwise my_search_option_files will treat "my.cnf" as a group + name and start looking for files named "my.cnf.cnf" in all + default dirs. Which is not what we want. + */ + if (Options::is_forced_default_file) + { + snprintf(defaults_file_arg, FN_REFLEN, "--defaults-file=%s", + Options::config_file); + + argv_options[1]= defaults_file_arg; + argv_options[2]= '\0'; + + argc= 2; + } + else + argv_options[1]= '\0'; /* If the routine failed, we'll simply fallback to defaults in diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc index 83f13b34aa2..d2946270b9e 100644 --- a/server-tools/instance-manager/instance_options.cc +++ b/server-tools/instance-manager/instance_options.cc @@ -138,9 +138,14 @@ int Instance_options::fill_instance_version() if (*result != '\0') { + char *start; /* chop the newline from the end of the version string */ result[strlen(result) - NEWLINE_LEN]= '\0'; - mysqld_version= strdup_root(&alloc, result); + /* trim leading whitespaces */ + start= result; + while (my_isspace(default_charset_info, *start)) + ++start; + mysqld_version= strdup_root(&alloc, start); } err: return rc; @@ -167,8 +172,6 @@ err: int Instance_options::fill_log_options() { Buffer buff; - uint position= 0; - char **tmp_argv= argv; enum { MAX_LOG_OPTION_LENGTH= 256 }; char datadir[MAX_LOG_OPTION_LENGTH]; char hostname[MAX_LOG_OPTION_LENGTH]; diff --git a/server-tools/instance-manager/mysqlmanager.cc b/server-tools/instance-manager/mysqlmanager.cc index 3d2907f4776..d0b2cf2666c 100644 --- a/server-tools/instance-manager/mysqlmanager.cc +++ b/server-tools/instance-manager/mysqlmanager.cc @@ -82,12 +82,13 @@ int main(int argc, char *argv[]) int return_value= 1; init_environment(argv[0]); Options options; - struct passwd *user_info; if (options.load(argc, argv)) goto err; #ifndef __WIN__ + struct passwd *user_info; + if ((user_info= check_user(options.user))) { if (set_user(options.user, user_info)) diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc index b16fcabae01..8119e8fc0ea 100644 --- a/server-tools/instance-manager/options.cc +++ b/server-tools/instance-manager/options.cc @@ -55,6 +55,8 @@ uint Options::monitoring_interval= DEFAULT_MONITORING_INTERVAL; uint Options::port_number= DEFAULT_PORT; /* just to declare */ char **Options::saved_argv= NULL; +/* Remember if the config file was forced */ +bool Options::is_forced_default_file= 0; /* List of options, accepted by the instance manager. @@ -118,7 +120,7 @@ static struct my_option my_long_options[] = " Server binary.", (gptr *) &Options::default_mysqld_path, (gptr *) &Options::default_mysqld_path, - 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, { "monitoring-interval", OPT_MONITORING_INTERVAL, "Interval to monitor" " instances in seconds.", @@ -254,6 +256,7 @@ int Options::load(int argc, char **argv) if (is_prefix(argv[1], "--defaults-file=")) { Options::config_file= strchr(argv[1], '=') + 1; + Options::is_forced_default_file= 1; } if (is_prefix(argv[1], "--defaults-extra-file=") || is_prefix(argv[1], "--no-defaults")) diff --git a/server-tools/instance-manager/options.h b/server-tools/instance-manager/options.h index 6d719c69629..abb094eac93 100644 --- a/server-tools/instance-manager/options.h +++ b/server-tools/instance-manager/options.h @@ -36,6 +36,7 @@ struct Options static char run_as_service; /* handle_options doesn't support bool */ static const char *user; #endif + static bool is_forced_default_file; static const char *log_file_name; static const char *pid_file_name; static const char *socket_file_name; diff --git a/server-tools/instance-manager/parse.cc b/server-tools/instance-manager/parse.cc index a79a6ad6742..9d9064240d4 100644 --- a/server-tools/instance-manager/parse.cc +++ b/server-tools/instance-manager/parse.cc @@ -166,7 +166,8 @@ Command *parse_command(Instance_map *map, const char *text) skip= true; case TOK_SET: - get_text_id(&text, &instance_name_len, &instance_name); + if (get_text_id(&text, &instance_name_len, &instance_name)) + goto syntax_error; text+= instance_name_len; /* the next token should be a dot */ @@ -221,7 +222,8 @@ Command *parse_command(Instance_map *map, const char *text) switch (Token tok2= shift_token(&text, &word_len)) { case TOK_OPTIONS: case TOK_STATUS: - get_text_id(&text, &instance_name_len, &instance_name); + if (get_text_id(&text, &instance_name_len, &instance_name)) + goto syntax_error; text+= instance_name_len; /* check that this is the end of the command */ get_word(&text, &word_len); @@ -273,7 +275,8 @@ Command *parse_command(Instance_map *map, const char *text) goto syntax_error; } /* get the size of the log we want to retrieve */ - get_text_id(&text, &word_len, &log_size); + if (get_text_id(&text, &word_len, &log_size)) + goto syntax_error; text+= word_len; /* this parameter is required */ if (!word_len) @@ -291,7 +294,6 @@ Command *parse_command(Instance_map *map, const char *text) instance_name_len, log_type, log_size, text); - //get_text_id(&text, &log_size_len, &log_size); break; case '\0': command= new Show_instance_log(map, instance_name, diff --git a/server-tools/instance-manager/portability.h b/server-tools/instance-manager/portability.h index 2bdeff71a72..1a3be5705e3 100644 --- a/server-tools/instance-manager/portability.h +++ b/server-tools/instance-manager/portability.h @@ -8,13 +8,12 @@ #ifdef __WIN__ #define vsnprintf _vsnprintf +#define snprintf _snprintf #define SIGKILL 9 #define SHUT_RDWR 0x2 /*TODO: fix this */ -#define DEFAULT_MONITORING_INTERVAL 20 -#define DEFAULT_PORT 2273 #define PROTOCOL_VERSION 10 typedef int pid_t; diff --git a/server-tools/instance-manager/priv.cc b/server-tools/instance-manager/priv.cc index e39c12f4ebb..d2d6a3f636c 100644 --- a/server-tools/instance-manager/priv.cc +++ b/server-tools/instance-manager/priv.cc @@ -15,6 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <my_global.h> +#include <mysql_com.h> #include "priv.h" #include "portability.h" @@ -52,7 +53,7 @@ unsigned long net_buffer_length= 16384; unsigned long max_allowed_packet= 16384; -unsigned long net_read_timeout= 30; // same as in mysqld +unsigned long net_read_timeout= NET_WAIT_TIMEOUT; // same as in mysqld unsigned long net_write_timeout= 60; // same as in mysqld diff --git a/server-tools/instance-manager/priv.h b/server-tools/instance-manager/priv.h index 4739bca68eb..af6d2837933 100644 --- a/server-tools/instance-manager/priv.h +++ b/server-tools/instance-manager/priv.h @@ -24,6 +24,11 @@ #endif #include "my_pthread.h" +/* IM-wide platform-independent defines */ +#define SERVER_DEFAULT_PORT 3306 +#define DEFAULT_MONITORING_INTERVAL 20 +#define DEFAULT_PORT 2273 + /* the pid of the manager process (of the signal thread on the LinuxThreads) */ extern pid_t manager_pid; diff --git a/sql/event.cc b/sql/event.cc index abca622835a..a7c6d48b988 100644 --- a/sql/event.cc +++ b/sql/event.cc @@ -704,11 +704,17 @@ done: } +/* + 0 - OK can drop from outside + 1 - Scheduled from dropping, don't drop from outside +*/ + static int evex_remove_from_cache(LEX_STRING *db, LEX_STRING *name, bool use_lock, bool is_drop) { uint i; + int ret= 0; DBUG_ENTER("evex_remove_from_cache"); /* @@ -738,7 +744,8 @@ evex_remove_from_cache(LEX_STRING *db, LEX_STRING *name, bool use_lock, DBUG_PRINT("evex_remove_from_cache", ("running.defer mem free. is_drop=%d", is_drop)); et->flags|= EVENT_EXEC_NO_MORE; - et->dropped= is_drop; + if ((et->dropped= is_drop)) + ret= 1; } DBUG_PRINT("evex_remove_from_cache", ("delete from queue")); evex_queue_delete_element(&EVEX_EQ_NAME, i); @@ -751,7 +758,7 @@ done: if (use_lock) VOID(pthread_mutex_unlock(&LOCK_event_arrays)); - DBUG_RETURN(0); + DBUG_RETURN(ret); } @@ -866,21 +873,25 @@ done: Drops an event SYNOPSIS - evex_drop_event() + db_drop_event() thd THD et event's name drop_if_exists if set and the event not existing => warning onto the stack + rows_affected affected number of rows is returned heres */ -int -evex_drop_event(THD *thd, event_timed *et, bool drop_if_exists, - uint *rows_affected) +int db_drop_event(THD *thd, event_timed *et, bool drop_if_exists, + uint *rows_affected) { TABLE *table; - int ret= EVEX_OPEN_TABLE_FAILED; - DBUG_ENTER("evex_drop_event"); + Open_tables_state backup; + uint ret; + + DBUG_ENTER("db_drop_event"); + ret= EVEX_OPEN_TABLE_FAILED; + thd->reset_n_backup_open_tables_state(&backup); if (evex_open_event_table(thd, TL_WRITE, &table)) { my_error(ER_EVENT_OPEN_TABLE_FAILED, MYF(0)); @@ -908,10 +919,6 @@ evex_drop_event(THD *thd, event_timed *et, bool drop_if_exists, goto done; } - VOID(pthread_mutex_lock(&LOCK_evex_running)); - if (evex_is_running) - ret= evex_remove_from_cache(&et->dbname, &et->name, true, true); - VOID(pthread_mutex_unlock(&LOCK_evex_running)); done: /* @@ -919,6 +926,44 @@ done: we have to close our thread tables. */ close_thread_tables(thd); + thd->restore_backup_open_tables_state(&backup); + DBUG_RETURN(ret); +} + + +/* + Drops an event + + SYNOPSIS + evex_drop_event() + thd THD + et event's name + drop_if_exists if set and the event not existing => warning onto the stack + rows_affected affected number of rows is returned heres + +*/ + +int +evex_drop_event(THD *thd, event_timed *et, bool drop_if_exists, + uint *rows_affected) +{ + TABLE *table; + int ret= 0; + + DBUG_ENTER("evex_drop_event"); + + + VOID(pthread_mutex_lock(&LOCK_evex_running)); + if (evex_is_running) + ret= evex_remove_from_cache(&et->dbname, &et->name, true, true); + VOID(pthread_mutex_unlock(&LOCK_evex_running)); + + if (ret == 1) + ret= 0; + else if (ret == 0) + ret= db_drop_event(thd, et, drop_if_exists, rows_affected); + else + my_error(ER_UNKNOWN_ERROR, MYF(0)); DBUG_RETURN(ret); } diff --git a/sql/event_executor.cc b/sql/event_executor.cc index 7960f1e1758..d06e3e57a1e 100644 --- a/sql/event_executor.cc +++ b/sql/event_executor.cc @@ -31,6 +31,7 @@ extern ulong thread_created; extern const char *my_localhost; +extern pthread_attr_t connection_attrib; pthread_mutex_t LOCK_event_arrays, LOCK_workers_count, @@ -41,7 +42,7 @@ bool evex_is_running= false; ulonglong evex_main_thread_id= 0; ulong opt_event_executor; -volatile my_bool event_executor_running_global_var; +my_bool event_executor_running_global_var; static my_bool evex_mutexes_initted= false; static uint workers_count; @@ -102,7 +103,7 @@ init_events() { #ifndef DBUG_FAULTY_THR //TODO Andrey: Change the error code returned! - if (pthread_create(&th, NULL, event_executor_main, (void*)NULL)) + if (pthread_create(&th, &connection_attrib, event_executor_main,(void*)NULL)) DBUG_RETURN(ER_SLAVE_THREAD); #else event_executor_main(NULL); @@ -351,7 +352,7 @@ event_executor_main(void *arg) ++iter_num; DBUG_PRINT("info", (" Spawning a thread %d", iter_num)); #ifndef DBUG_FAULTY_THR - if (pthread_create(&th, NULL, event_executor_worker, (void*)et)) + if (pthread_create(&th,&connection_attrib,event_executor_worker,(void*)et)) { sql_print_error("Problem while trying to create a thread"); UNLOCK_MUTEX_AND_BAIL_OUT(LOCK_event_arrays, err); diff --git a/sql/event_priv.h b/sql/event_priv.h index 7d1cdbcd264..b0ba205d806 100644 --- a/sql/event_priv.h +++ b/sql/event_priv.h @@ -40,6 +40,9 @@ evex_db_find_event_aux(THD *thd, const LEX_STRING dbname, int event_timed_compare_q(void *vptr, byte* a, byte *b); +int db_drop_event(THD *thd, event_timed *et, bool drop_if_exists, + uint *rows_affected); + #define EXEC_QUEUE_QUEUE_NAME executing_queue #define EXEC_QUEUE_DARR_NAME evex_executing_queue diff --git a/sql/event_timed.cc b/sql/event_timed.cc index 28d21089b74..e585f6252ca 100644 --- a/sql/event_timed.cc +++ b/sql/event_timed.cc @@ -877,20 +877,10 @@ int event_timed::drop(THD *thd) { TABLE *table; - int ret= 0; + uint tmp= 0; DBUG_ENTER("event_timed::drop"); - if (evex_open_event_table(thd, TL_WRITE, &table)) - DBUG_RETURN(-1); - - if (evex_db_find_event_aux(thd, dbname, name, definer, table)) - DBUG_RETURN(-2); - - if ((ret= table->file->ha_delete_row(table->record[0]))) - DBUG_RETURN(ret); - - close_thread_tables(thd); - DBUG_RETURN(0); + DBUG_RETURN(db_drop_event(thd, this, false, &tmp)); } diff --git a/sql/field.cc b/sql/field.cc index 3d983bb4d12..72e28cbda9c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5243,7 +5243,7 @@ int Field_date::store(double nr) else tmp= (longlong) rint(nr); - return Field_date::store(tmp); + return Field_date::store(tmp, TRUE); } @@ -5265,6 +5265,9 @@ int Field_date::store(longlong nr, bool unsigned_val) error= 2; } + if (nr >= 19000000000000.0 && nr <= 99991231235959.0) + nr=floor(nr/1000000.0); // Timestamp to date + if (error) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, error == 2 ? ER_WARN_DATA_OUT_OF_RANGE : diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc index 2a2ac475c0b..b6ae7a4b75f 100644 --- a/sql/ha_archive.cc +++ b/sql/ha_archive.cc @@ -177,7 +177,9 @@ handlerton archive_hton = { NULL, /* Partition flags */ NULL, /* Alter table flags */ NULL, /* Alter interface */ - HTON_NO_FLAGS + HTON_NO_FLAGS, + NULL, /* binlog_func */ + NULL /* binlog_log_query */ }; static handler *archive_create_handler(TABLE_SHARE *table) @@ -403,12 +405,14 @@ int ha_archive::write_meta_file(File meta_file, ha_rows rows, See ha_example.cc for a longer description. */ -ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table) +ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, + TABLE *table, int *rc) { ARCHIVE_SHARE *share; char meta_file_name[FN_REFLEN]; uint length; char *tmp_name; + DBUG_ENTER("ha_archive::get_share"); pthread_mutex_lock(&archive_mutex); length=(uint) strlen(table_name); @@ -423,7 +427,8 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table) NullS)) { pthread_mutex_unlock(&archive_mutex); - return NULL; + *rc= HA_ERR_OUT_OF_MEM; + DBUG_RETURN(NULL); } share->use_count= 0; @@ -466,9 +471,14 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table) thr_lock_init(&share->lock); } share->use_count++; + DBUG_PRINT("info", ("archive table %.*s has %d open handles now", + share->table_name_length, share->table_name, + share->use_count)); + if (share->crashed) + *rc= HA_ERR_CRASHED_ON_USAGE; pthread_mutex_unlock(&archive_mutex); - return share; + DBUG_RETURN(share); } @@ -479,14 +489,23 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, TABLE *table) int ha_archive::free_share(ARCHIVE_SHARE *share) { int rc= 0; + DBUG_ENTER("ha_archive::free_share"); + DBUG_PRINT("info", ("archive table %.*s has %d open handles on entrance", + share->table_name_length, share->table_name, + share->use_count)); + pthread_mutex_lock(&archive_mutex); if (!--share->use_count) { hash_delete(&archive_open_tables, (byte*) share); thr_lock_delete(&share->lock); VOID(pthread_mutex_destroy(&share->mutex)); - (void)write_meta_file(share->meta_file, share->rows_recorded, - share->auto_increment_value, FALSE); + if (share->crashed) + (void)write_meta_file(share->meta_file, share->rows_recorded, + share->auto_increment_value, TRUE); + else + (void)write_meta_file(share->meta_file, share->rows_recorded, + share->auto_increment_value, FALSE); if (azclose(&(share->archive_write))) rc= 1; if (my_close(share->meta_file, MYF(0))) @@ -495,7 +514,7 @@ int ha_archive::free_share(ARCHIVE_SHARE *share) } pthread_mutex_unlock(&archive_mutex); - return rc; + DBUG_RETURN(rc); } @@ -520,12 +539,25 @@ const char **ha_archive::bas_ext() const Init out lock. We open the file we will read from. */ -int ha_archive::open(const char *name, int mode, uint test_if_locked) +int ha_archive::open(const char *name, int mode, uint open_options) { + int rc= 0; DBUG_ENTER("ha_archive::open"); - if (!(share= get_share(name, table))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); // Not handled well by calling code! + DBUG_PRINT("info", ("archive table was opened for crash %s", + (open_options & HA_OPEN_FOR_REPAIR) ? "yes" : "no")); + share= get_share(name, table, &rc); + + if (rc == HA_ERR_CRASHED_ON_USAGE && !(open_options & HA_OPEN_FOR_REPAIR)) + { + free_share(share); + DBUG_RETURN(rc); + } + else if (rc == HA_ERR_OUT_OF_MEM) + { + DBUG_RETURN(rc); + } + thr_lock_data_init(&share->lock,&lock,NULL); if (!(azopen(&archive, share->data_file_name, O_RDONLY|O_BINARY))) @@ -535,7 +567,14 @@ int ha_archive::open(const char *name, int mode, uint test_if_locked) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); } - DBUG_RETURN(0); + DBUG_PRINT("info", ("archive table was crashed %s", + rc == HA_ERR_CRASHED_ON_USAGE ? "yes" : "no")); + if (rc == HA_ERR_CRASHED_ON_USAGE && open_options & HA_OPEN_FOR_REPAIR) + { + DBUG_RETURN(0); + } + else + DBUG_RETURN(rc); } @@ -921,6 +960,7 @@ int ha_archive::rnd_init(bool scan) if (scan) { scan_rows= share->rows_recorded; + DBUG_PRINT("info", ("archive will retrieve %llu rows", scan_rows)); records= 0; /* @@ -932,6 +972,7 @@ int ha_archive::rnd_init(bool scan) pthread_mutex_lock(&share->mutex); if (share->dirty == TRUE) { + DBUG_PRINT("info", ("archive flushing out rows for scan")); azflush(&(share->archive_write), Z_SYNC_FLUSH); share->dirty= FALSE; } @@ -1171,6 +1212,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) share->rows_recorded++; } } + DBUG_PRINT("info", ("recovered %llu archive rows", share->rows_recorded)); my_free((char*)buf, MYF(0)); if (rc && rc != HA_ERR_END_OF_FILE) @@ -1196,9 +1238,29 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) } azclose(&writer); + share->dirty= FALSE; + azclose(&(share->archive_write)); + if (!(azopen(&(share->archive_write), share->data_file_name, + O_WRONLY|O_APPEND|O_BINARY))) + { + DBUG_PRINT("info", ("Could not open archive write file")); + rc= HA_ERR_CRASHED_ON_USAGE; + goto error; + } my_rename(writer_filename,share->data_file_name,MYF(0)); + /* + Now we need to reopen our read descriptor since it has changed. + */ + azclose(&archive); + if (!(azopen(&archive, share->data_file_name, O_RDONLY|O_BINARY))) + { + rc= HA_ERR_CRASHED_ON_USAGE; + goto error; + } + + DBUG_RETURN(0); error: @@ -1340,7 +1402,8 @@ int ha_archive::delete_all_rows() */ bool ha_archive::is_crashed() const { - return share->crashed; + DBUG_ENTER("ha_archive::is_crashed"); + DBUG_RETURN(share->crashed); } /* @@ -1402,12 +1465,5 @@ bool ha_archive::check_and_repair(THD *thd) check_opt.init(); - if (check(thd, &check_opt) == HA_ADMIN_CORRUPT) - { - DBUG_RETURN(repair(thd, &check_opt)); - } - else - { - DBUG_RETURN(HA_ADMIN_OK); - } + DBUG_RETURN(repair(thd, &check_opt)); } diff --git a/sql/ha_archive.h b/sql/ha_archive.h index 528f94b129f..7766ae0d2e9 100644 --- a/sql/ha_archive.h +++ b/sql/ha_archive.h @@ -101,7 +101,7 @@ public: int read_meta_file(File meta_file, ha_rows *rows, ulonglong *auto_increment); int write_meta_file(File meta_file, ha_rows rows, ulonglong auto_increment, bool dirty); - ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table); + ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table, int *rc); int free_share(ARCHIVE_SHARE *share); bool auto_repair() const { return 1; } // For the moment we just do this int read_data_header(azio_stream *file_to_read); diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index a4282e5013c..f7e0c1242fe 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -1409,6 +1409,12 @@ static int free_share(FEDERATED_SHARE *share) hash_delete(&federated_open_tables, (byte*) share); my_free((gptr) share->scheme, MYF(MY_ALLOW_ZERO_PTR)); share->scheme= 0; + if (share->socket) + { + my_free((gptr) share->socket, MYF(MY_ALLOW_ZERO_PTR)); + share->socket= 0; + } + thr_lock_delete(&share->lock); VOID(pthread_mutex_destroy(&share->mutex)); my_free((gptr) share, MYF(0)); @@ -1688,10 +1694,34 @@ int ha_federated::write_row(byte *buf) { DBUG_RETURN(stash_remote_error()); } + /* + If the table we've just written a record to contains an auto_increment field, + then store the last_insert_id() value from the foreign server + */ + if (table->next_number_field) + update_auto_increment(); DBUG_RETURN(0); } +/* + ha_federated::update_auto_increment + + This method ensures that last_insert_id() works properly. What it simply does + is calls last_insert_id() on the foreign database immediately after insert + (if the table has an auto_increment field) and sets the insert id via + thd->insert_id(ID) (as well as storing thd->prev_insert_id) +*/ +void ha_federated::update_auto_increment(void) +{ + THD *thd= current_thd; + DBUG_ENTER("ha_federated::update_auto_increment"); + + thd->insert_id(mysql->last_used_con->insert_id); + DBUG_PRINT("info",("last_insert_id %d", auto_increment_value)); + + DBUG_VOID_RETURN; +} int ha_federated::optimize(THD* thd, HA_CHECK_OPT* check_opt) { diff --git a/sql/ha_federated.h b/sql/ha_federated.h index c596f066098..953f4208bc5 100644 --- a/sql/ha_federated.h +++ b/sql/ha_federated.h @@ -286,6 +286,7 @@ public: void position(const byte *record); //required void info(uint); //required + void update_auto_increment(void); int repair(THD* thd, HA_CHECK_OPT* check_opt); int optimize(THD* thd, HA_CHECK_OPT* check_opt); diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index c520a4e88d4..d4790cf7d01 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -73,7 +73,7 @@ static handler *heap_create_handler(TABLE_SHARE *table) ha_heap::ha_heap(TABLE_SHARE *table_arg) :handler(&heap_hton, table_arg), file(0), records_changed(0), - key_stats_ok(0) + key_stat_version(0) {} @@ -124,7 +124,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked) ha_heap::info(), which is always called before key statistics are used. */ - key_stats_ok= FALSE; + key_stat_version= file->s->key_stat_version-1; } return (file ? 0 : 1); } @@ -171,14 +171,21 @@ void ha_heap::update_key_stats() continue; if (key->algorithm != HA_KEY_ALG_BTREE) { - ha_rows hash_buckets= file->s->keydef[i].hash_buckets; - key->rec_per_key[key->key_parts-1]= - hash_buckets ? file->s->records/hash_buckets : 0; + if (key->flags & HA_NOSAME) + key->rec_per_key[key->key_parts-1]= 1; + else + { + ha_rows hash_buckets= file->s->keydef[i].hash_buckets; + uint no_records= hash_buckets ? file->s->records/hash_buckets : 2; + if (no_records < 2) + no_records= 2; + key->rec_per_key[key->key_parts-1]= no_records; + } } } records_changed= 0; /* At the end of update_key_stats() we can proudly claim they are OK. */ - key_stats_ok= TRUE; + key_stat_version= file->s->key_stat_version; } @@ -193,7 +200,13 @@ int ha_heap::write_row(byte * buf) res= heap_write(file,buf); if (!res && (++records_changed*HEAP_STATS_UPDATE_THRESHOLD > file->s->records)) - key_stats_ok= FALSE; + { + /* + We can perform this safely since only one writer at the time is + allowed on the table. + */ + file->s->key_stat_version++; + } return res; } @@ -206,7 +219,13 @@ int ha_heap::update_row(const byte * old_data, byte * new_data) res= heap_update(file,old_data,new_data); if (!res && ++records_changed*HEAP_STATS_UPDATE_THRESHOLD > file->s->records) - key_stats_ok= FALSE; + { + /* + We can perform this safely since only one writer at the time is + allowed on the table. + */ + file->s->key_stat_version++; + } return res; } @@ -217,7 +236,13 @@ int ha_heap::delete_row(const byte * buf) res= heap_delete(file,buf); if (!res && table->s->tmp_table == NO_TMP_TABLE && ++records_changed*HEAP_STATS_UPDATE_THRESHOLD > file->s->records) - key_stats_ok= FALSE; + { + /* + We can perform this safely since only one writer at the time is + allowed on the table. + */ + file->s->key_stat_version++; + } return res; } @@ -344,7 +369,7 @@ void ha_heap::info(uint flag) have to update the key statistics. Hoping that a table lock is now in place. */ - if (! key_stats_ok) + if (key_stat_version != file->s->key_stat_version) update_key_stats(); } @@ -357,7 +382,13 @@ int ha_heap::delete_all_rows() { heap_clear(file); if (table->s->tmp_table == NO_TMP_TABLE) - key_stats_ok= FALSE; + { + /* + We can perform this safely since only one writer at the time is + allowed on the table. + */ + file->s->key_stat_version++; + } return 0; } @@ -524,8 +555,11 @@ ha_rows ha_heap::records_in_range(uint inx, key_range *min_key, max_key->flag != HA_READ_AFTER_KEY) return HA_POS_ERROR; // Can only use exact keys + if (records <= 1) + return records; + /* Assert that info() did run. We need current statistics here. */ - DBUG_ASSERT(key_stats_ok); + DBUG_ASSERT(key_stat_version); return key->rec_per_key[key->key_parts-1]; } diff --git a/sql/ha_heap.h b/sql/ha_heap.h index 909b36f975b..9b9b7f90d90 100644 --- a/sql/ha_heap.h +++ b/sql/ha_heap.h @@ -29,7 +29,7 @@ class ha_heap: public handler key_map btree_keys; /* number of records changed since last statistics update */ uint records_changed; - bool key_stats_ok; + uint key_stat_version; public: ha_heap(TABLE_SHARE *table); ~ha_heap() {} diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index eaf52a9ca09..0002ab0123f 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -465,6 +465,10 @@ convert_error_code_to_mysql( return(HA_ERR_FOUND_DUPP_KEY); + } else if (error == (int) DB_FOREIGN_DUPLICATE_KEY) { + + return(HA_ERR_FOREIGN_DUPLICATE_KEY); + } else if (error == (int) DB_RECORD_NOT_FOUND) { return(HA_ERR_NO_ACTIVE_RECORD); @@ -5757,7 +5761,7 @@ ha_innobase::analyze( } /************************************************************************** -This is mapped to "ALTER TABLE tablename TYPE=InnoDB", which rebuilds +This is mapped to "ALTER TABLE tablename ENGINE=InnoDB", which rebuilds the table in MySQL. */ int diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 5f0adba6e8c..4b84d3efa7f 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -1381,10 +1381,6 @@ void ha_myisam::info(uint flag) if (share->tmp_table == NO_TMP_TABLE) pthread_mutex_unlock(&share->mutex); - raid_type= info.raid_type; - raid_chunks= info.raid_chunks; - raid_chunksize= info.raid_chunksize; - /* Set data_file_name and index_file_name to point at the symlink value if table is symlinked (Ie; Real name is not same as generated name) @@ -1461,12 +1457,6 @@ void ha_myisam::update_create_info(HA_CREATE_INFO *create_info) { create_info->auto_increment_value=auto_increment_value; } - if (!(create_info->used_fields & HA_CREATE_USED_RAID)) - { - create_info->raid_type= raid_type; - create_info->raid_chunks= raid_chunks; - create_info->raid_chunksize= raid_chunksize; - } create_info->data_file_name=data_file_name; create_info->index_file_name=index_file_name; } @@ -1658,11 +1648,6 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, (ulonglong) 0); create_info.data_file_length= ((ulonglong) share->max_rows * share->avg_row_length); - create_info.raid_type=info->raid_type; - create_info.raid_chunks= (info->raid_chunks ? info->raid_chunks : - RAID_DEFAULT_CHUNKS); - create_info.raid_chunksize= (info->raid_chunksize ? info->raid_chunksize : - RAID_DEFAULT_CHUNKSIZE); create_info.data_file_name= info->data_file_name; create_info.index_file_name= info->index_file_name; @@ -1787,9 +1772,6 @@ bool ha_myisam::check_if_incompatible_data(HA_CREATE_INFO *info, uint options= table->s->db_options_in_use; if (info->auto_increment_value != auto_increment_value || - info->raid_type != raid_type || - info->raid_chunks != raid_chunks || - info->raid_chunksize != raid_chunksize || info->data_file_name != data_file_name || info->index_file_name != index_file_name || table_changes == IS_EQUAL_NO) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 361401e22d6..1b1b16f4ae4 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -69,7 +69,7 @@ handlerton ndbcluster_hton = { MYSQL_HANDLERTON_INTERFACE_VERSION, "ndbcluster", SHOW_OPTION_YES, - "Clustered, fault-tolerant, memory-based tables", + "Clustered, fault-tolerant tables", DB_TYPE_NDBCLUSTER, ndbcluster_init, ~(uint)0, /* slot */ @@ -97,8 +97,6 @@ static uint ndbcluster_alter_table_flags(uint flags) } -#define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8 - #define NDB_FAILED_AUTO_INCREMENT ~(Uint64)0 #define NDB_AUTO_INCREMENT_RETRIES 10 @@ -952,7 +950,7 @@ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field, } // Used for hidden key only - m_value[fieldnr].rec= ndb_op->getValue(fieldnr, NULL); + m_value[fieldnr].rec= ndb_op->getValue(fieldnr, m_ref); DBUG_RETURN(m_value[fieldnr].rec == NULL); } @@ -2551,13 +2549,10 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) DBUG_PRINT("info", ("Using hidden key")); // Require that the PK for this record has previously been - // read into m_value - uint no_fields= table_share->fields; - const NdbRecAttr* rec= m_value[no_fields].rec; - DBUG_ASSERT(rec); - DBUG_DUMP("key", (char*)rec->aRef(), NDB_HIDDEN_PRIMARY_KEY_LENGTH); + // read into m_ref + DBUG_DUMP("key", m_ref, NDB_HIDDEN_PRIMARY_KEY_LENGTH); - if (set_hidden_key(op, no_fields, rec->aRef())) + if (set_hidden_key(op, table->s->fields, m_ref)) ERR_RETURN(op->getNdbError()); } else @@ -2664,11 +2659,8 @@ int ha_ndbcluster::delete_row(const byte *record) { // This table has no primary key, use "hidden" primary key DBUG_PRINT("info", ("Using hidden key")); - uint no_fields= table_share->fields; - const NdbRecAttr* rec= m_value[no_fields].rec; - DBUG_ASSERT(rec != NULL); - if (set_hidden_key(op, no_fields, rec->aRef())) + if (set_hidden_key(op, table->s->fields, m_ref)) ERR_RETURN(op->getNdbError()); } else @@ -3242,17 +3234,15 @@ void ha_ndbcluster::position(const byte *record) { // No primary key, get hidden key DBUG_PRINT("info", ("Getting hidden key")); - int hidden_no= table_share->fields; - const NdbRecAttr* rec= m_value[hidden_no].rec; - memcpy(ref, (const void*)rec->aRef(), ref_length); #ifndef DBUG_OFF + int hidden_no= table->s->fields; const NDBTAB *tab= (const NDBTAB *) m_table; const NDBCOL *hidden_col= tab->getColumn(hidden_no); DBUG_ASSERT(hidden_col->getPrimaryKey() && hidden_col->getAutoIncrement() && - rec != NULL && ref_length == NDB_HIDDEN_PRIMARY_KEY_LENGTH); #endif + memcpy(ref, m_ref, ref_length); } DBUG_DUMP("ref", (char*)ref, ref_length); @@ -5823,7 +5813,11 @@ static bool ndbcluster_init() opt_ndbcluster_connectstring)); goto ndbcluster_init_error; } - + { + char buf[128]; + my_snprintf(buf, sizeof(buf), "mysqld --server-id=%d", server_id); + g_ndb_cluster_connection->set_name(buf); + } g_ndb_cluster_connection->set_optimized_node_selection (opt_ndb_optimized_node_selection); @@ -6199,6 +6193,10 @@ uint ha_ndbcluster::max_supported_key_length() const { return NDB_MAX_KEY_SIZE; } +uint ha_ndbcluster::max_supported_key_part_length() const +{ + return NDB_MAX_KEY_SIZE; +} bool ha_ndbcluster::low_byte_first() const { #ifdef WORDS_BIGENDIAN @@ -8917,9 +8915,9 @@ ha_ndbcluster::generate_scan_filter(Ndb_cond_stack *ndb_cond_stack, /* get table space info for SHOW CREATE TABLE */ -char* ha_ndbcluster::get_tablespace_name() +char* ha_ndbcluster::get_tablespace_name(THD *thd) { - Ndb *ndb= get_ndb(); + Ndb *ndb= check_ndb_in_thd(thd); NDBDICT *ndbdict= ndb->getDictionary(); NdbError ndberr; Uint32 id; @@ -8943,11 +8941,11 @@ char* ha_ndbcluster::get_tablespace_name() } err: if (ndberr.status == NdbError::TemporaryError) - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, ER_GET_TEMPORARY_ERRMSG, ER(ER_GET_TEMPORARY_ERRMSG), ndberr.code, ndberr.message, "NDB"); else - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, ER_GET_ERRMSG, ER(ER_GET_ERRMSG), ndberr.code, ndberr.message, "NDB"); return 0; @@ -9592,6 +9590,7 @@ bool ha_ndbcluster::get_no_parts(const char *name, uint *no_parts) break; } ndb= get_ndb(); + ndb->setDatabaseName(m_dbname); dict= ndb->getDictionary(); if (!(tab= dict->getTable(m_tabname))) ERR_BREAK(dict->getNdbError(), err); diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index f12b6198a68..1eb8ac1ea70 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -31,6 +31,8 @@ #include <NdbApi.hpp> #include <ndbapi_limits.h> +#define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8 + class Ndb; // Forward declaration class NdbOperation; // Forward declaration class NdbTransaction; // Forward declaration @@ -604,6 +606,7 @@ class ha_ndbcluster: public handler uint max_supported_keys() const; uint max_supported_key_parts() const; uint max_supported_key_length() const; + uint max_supported_key_part_length() const; int rename_table(const char *from, const char *to); int delete_table(const char *name); @@ -721,7 +724,7 @@ private: uint set_up_partition_info(partition_info *part_info, TABLE *table, void *tab); - char* get_tablespace_name(); + char* get_tablespace_name(THD *thd); int set_range_data(void *tab, partition_info* part_info); int set_list_data(void *tab, partition_info* part_info); int complemented_pk_read(const byte *old_data, byte *new_data, @@ -817,6 +820,7 @@ private: NDB_INDEX_DATA m_index[MAX_KEY]; // NdbRecAttr has no reference to blob NdbValue m_value[NDB_MAX_ATTRIBUTES_IN_TABLE]; + byte m_ref[NDB_HIDDEN_PRIMARY_KEY_LENGTH]; partition_info *m_part_info; byte *m_rec0; Field **m_part_field_array; diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 0fa9daa66b4..b349e3320de 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -20,6 +20,7 @@ #ifdef HAVE_NDB_BINLOG #include "rpl_injector.h" +#include "rpl_filter.h" #include "slave.h" #include "ha_ndbcluster_binlog.h" @@ -2019,6 +2020,12 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab, DBUG_RETURN(0); } + if (!binlog_filter->db_ok(share->db)) + { + share->flags|= NSF_NO_BINLOG; + DBUG_RETURN(0); + } + if (share->op) { assert(share->op->getCustomData() == (void *) share); diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 2bc4a106536..0bd300df2e2 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4284,9 +4284,6 @@ void ha_partition::info(uint flag) sortkey: Never used at any place so ignored ref_length: We set this to the value calculated and stored in local object - raid_type: Set by first handler (MyISAM) - raid_chunks: Set by first handler (MyISAM) - raid_chunksize: Set by first handler (MyISAM) create_time: Creation time of table Set by first handler @@ -4297,9 +4294,6 @@ void ha_partition::info(uint flag) file= m_file[0]; file->info(HA_STATUS_CONST); create_time= file->create_time; - raid_type= file->raid_type; - raid_chunks= file->raid_chunks; - raid_chunksize= file->raid_chunksize; ref_length= m_ref_length; } if (flag & HA_STATUS_ERRKEY) diff --git a/sql/handler.cc b/sql/handler.cc index 24e9f6aa1e2..dc7ec37a23d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -358,6 +358,7 @@ static int ha_init_errors(void) SETMSG(HA_ERR_TABLE_EXIST, ER(ER_TABLE_EXISTS_ERROR)); SETMSG(HA_ERR_NO_CONNECTION, "Could not connect to storage engine"); SETMSG(HA_ERR_TABLE_DEF_CHANGED, ER(ER_TABLE_DEF_CHANGED)); + SETMSG(HA_ERR_FOREIGN_DUPLICATE_KEY, "FK constraint would lead to duplicate key"); /* Register the error messages for use with my_error(). */ return my_error_register(errmsgs, HA_ERR_FIRST, HA_ERR_LAST); @@ -1857,17 +1858,35 @@ void handler::print_error(int error, myf errflag) str.length(max_length-4); str.append(STRING_WITH_LEN("...")); } -#ifdef XXX_TO_BE_DONE_BY_A_FOLLOWUP_OF_WL1563 - my_printf_error(ER_DUP_ENTRY, "Duplicate entry '%s' for key '%s'", - MYF(0), str.c_ptr(), table->key_info[key_nr].name); -#else - my_error(ER_DUP_ENTRY, MYF(0), str.c_ptr(), key_nr+1); -#endif + my_error(ER_DUP_ENTRY, MYF(0), str.c_ptr(), table->key_info[key_nr].name); DBUG_VOID_RETURN; } textno=ER_DUP_KEY; break; } + case HA_ERR_FOREIGN_DUPLICATE_KEY: + { + uint key_nr= get_dup_key(error); + if ((int) key_nr >= 0) + { + /* Write the key in the error message */ + char key[MAX_KEY_LENGTH]; + String str(key,sizeof(key),system_charset_info); + /* Table is opened and defined at this point */ + key_unpack(&str,table,(uint) key_nr); + uint max_length= MYSQL_ERRMSG_SIZE-(uint) strlen(ER(ER_FOREIGN_DUPLICATE_KEY)); + if (str.length() >= max_length) + { + str.length(max_length-4); + str.append(STRING_WITH_LEN("...")); + } + my_error(ER_FOREIGN_DUPLICATE_KEY, MYF(0), table_share->table_name.str, + str.c_ptr(), key_nr+1); + DBUG_VOID_RETURN; + } + textno= ER_DUP_KEY; + break; + } case HA_ERR_NULL_IN_SPATIAL: textno= ER_UNKNOWN_ERROR; break; @@ -2003,8 +2022,9 @@ uint handler::get_dup_key(int error) { DBUG_ENTER("handler::get_dup_key"); table->file->errkey = (uint) -1; - if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOUND_DUPP_UNIQUE || - error == HA_ERR_NULL_IN_SPATIAL || error == HA_ERR_DROP_INDEX_FK) + if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOREIGN_DUPLICATE_KEY || + error == HA_ERR_FOUND_DUPP_UNIQUE || error == HA_ERR_NULL_IN_SPATIAL || + error == HA_ERR_DROP_INDEX_FK) info(HA_STATUS_ERRKEY | HA_STATUS_NO_LOCK); DBUG_RETURN(table->file->errkey); } diff --git a/sql/handler.h b/sql/handler.h index de4623b39b9..55af6cf4da6 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -266,7 +266,7 @@ enum enum_binlog_command { /* Bits in used_fields */ #define HA_CREATE_USED_AUTO (1L << 0) -#define HA_CREATE_USED_RAID (1L << 1) +#define HA_CREATE_USED_RAID (1L << 1) //RAID is no longer availble #define HA_CREATE_USED_UNION (1L << 2) #define HA_CREATE_USED_INSERT_METHOD (1L << 3) #define HA_CREATE_USED_MIN_ROWS (1L << 4) @@ -1068,14 +1068,12 @@ typedef struct st_ha_create_information ulonglong auto_increment_value; ulong table_options; ulong avg_row_length; - ulong raid_chunksize; ulong used_fields; SQL_LIST merge_list; handlerton *db_type; enum row_type row_type; uint null_bits; /* NULL bits at start of record */ uint options; /* OR of HA_CREATE_ options */ - uint raid_type,raid_chunks; uint merge_insert_method; uint extra_size; /* length of extra data segment */ bool table_existed; /* 1 in create if table existed */ @@ -1204,7 +1202,6 @@ public: ulonglong auto_increment_value; ha_rows records; /* Records in table */ ha_rows deleted; /* Deleted records */ - ulong raid_chunksize; ulong mean_rec_length; /* physical reclength */ time_t create_time; /* When table was created */ time_t check_time; @@ -1228,7 +1225,6 @@ public: /* Length of ref (1-8 or the clustered key length) */ uint ref_length; uint block_size; /* index block size */ - uint raid_type,raid_chunks; FT_INFO *ft_handler; enum {NONE=0, INDEX, RND} inited; bool auto_increment_column_changed; @@ -1245,7 +1241,7 @@ public: create_time(0), check_time(0), update_time(0), key_used_on_scan(MAX_KEY), active_index(MAX_KEY), ref_length(sizeof(my_off_t)), block_size(0), - raid_type(0), ft_handler(0), inited(NONE), implicit_emptied(0), + ft_handler(0), inited(NONE), implicit_emptied(0), pushed_cond(NULL) {} virtual ~handler(void) @@ -1716,7 +1712,7 @@ public: { return FALSE; } virtual char* get_foreign_key_create_info() { return(NULL);} /* gets foreign key create string from InnoDB */ - virtual char* get_tablespace_name() + virtual char* get_tablespace_name(THD *thd) { return(NULL);} /* gets tablespace name from handler */ /* used in ALTER TABLE; 1 if changing storage engine is allowed */ virtual bool can_switch_engines() { return 1; } @@ -2030,7 +2026,7 @@ int ha_binlog_end(THD *thd); #define ha_reset_logs(a) 0 #define ha_binlog_index_purge_file(a,b) 0 #define ha_reset_slave(a) -#define ha_binlog_log_query(a,b,c,d,e,f); +#define ha_binlog_log_query(a,b,c,d,e,f,g); #define ha_binlog_wait(a) #define ha_binlog_end(a) 0 #endif diff --git a/sql/item_func.cc b/sql/item_func.cc index 60b0dafefc5..22200732861 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1865,28 +1865,30 @@ longlong Item_func_round::int_op() return value; // integer have not digits after point abs_dec= -dec; - double tmp; - /* - tmp2 is here to avoid return the value with 80 bit precision - This will fix that the test round(0.1,1) = round(0.1,1) is true - */ - volatile double tmp2; - - tmp= (abs_dec < array_elements(log_10) ? - log_10[abs_dec] : pow(10.0, (double) abs_dec)); - + longlong tmp; + + if(abs_dec >= array_elements(log_10_int)) + return 0; + + tmp= log_10_int[abs_dec]; + if (truncate) { if (unsigned_flag) - tmp2= floor(ulonglong2double(value)/tmp)*tmp; - else if (value >= 0) - tmp2= floor(((double)value)/tmp)*tmp; + value= (ulonglong(value)/tmp)*tmp; else - tmp2= ceil(((double)value)/tmp)*tmp; + value= (value/tmp)*tmp; } else - tmp2= rint(((double)value)/tmp)*tmp; - return (longlong)tmp2; + { + if (unsigned_flag) + value= ((ulonglong(value)+(tmp>>1))/tmp)*tmp; + else if ( value >= 0) + value= ((value+(tmp>>1))/tmp)*tmp; + else + value= ((value-(tmp>>1))/tmp)*tmp; + } + return value; } diff --git a/sql/item_func.h b/sql/item_func.h index d81eb5f6ebf..d8fa45fb9c0 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1283,10 +1283,8 @@ public: DBUG_ENTER("Item_func_match"); Item_real_func::cleanup(); if (!master && ft_handler) - { ft_handler->please->close_search(ft_handler); - ft_handler=0; - } + ft_handler= 0; concat= 0; DBUG_VOID_RETURN; } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 112ce053648..2effe3a615c 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2967,9 +2967,9 @@ void Item_func_str_to_date::fix_length_and_dec() cached_field_type= MYSQL_TYPE_STRING; max_length= MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; cached_timestamp_type= MYSQL_TIMESTAMP_NONE; - if ((const_item= args[1]->const_item())) + format= args[1]->val_str(&format_str); + if (!args[1]->null_value && (const_item= args[1]->const_item())) { - format= args[1]->val_str(&format_str); cached_format_type= get_date_time_result_type(format->ptr(), format->length()); switch (cached_format_type) { diff --git a/sql/lex.h b/sql/lex.h index 3dfaa0cf6cb..b52be29457f 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -410,10 +410,6 @@ static SYMBOL symbols[] = { { "QUARTER", SYM(QUARTER_SYM)}, { "QUERY", SYM(QUERY_SYM)}, { "QUICK", SYM(QUICK)}, - { "RAID0", SYM(RAID_0_SYM)}, - { "RAID_CHUNKS", SYM(RAID_CHUNKS)}, - { "RAID_CHUNKSIZE", SYM(RAID_CHUNKSIZE)}, - { "RAID_TYPE", SYM(RAID_TYPE)}, { "RANGE", SYM(RANGE_SYM)}, { "READ", SYM(READ_SYM)}, { "READ_ONLY", SYM(READ_ONLY_SYM)}, @@ -512,7 +508,6 @@ static SYMBOL symbols[] = { { "STORAGE", SYM(STORAGE_SYM)}, { "STRAIGHT_JOIN", SYM(STRAIGHT_JOIN)}, { "STRING", SYM(STRING_SYM)}, - { "STRIPED", SYM(RAID_STRIPED_SYM)}, { "SUBJECT", SYM(SUBJECT_SYM)}, { "SUBPARTITION", SYM(SUBPARTITION_SYM)}, { "SUBPARTITIONS", SYM(SUBPARTITIONS_SYM)}, diff --git a/sql/log.cc b/sql/log.cc index bb93c741dd9..a7e6a3da7f6 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -311,7 +311,8 @@ bool Log_to_csv_event_handler:: log_general(time_t event_time, const char *user_host, uint user_host_len, int thread_id, const char *command_type, uint command_type_len, - const char *sql_text, uint sql_text_len) + const char *sql_text, uint sql_text_len, + CHARSET_INFO *client_cs) { TABLE *table= general_log.table; @@ -326,11 +327,11 @@ bool Log_to_csv_event_handler:: /* set default value (which is CURRENT_TIMESTAMP) */ table->field[0]->set_null(); - table->field[1]->store(user_host, user_host_len, &my_charset_latin1); + table->field[1]->store(user_host, user_host_len, client_cs); table->field[2]->store((longlong) thread_id); table->field[3]->store((longlong) server_id); - table->field[4]->store(command_type, command_type_len, &my_charset_latin1); - table->field[5]->store(sql_text, sql_text_len, &my_charset_latin1); + table->field[4]->store(command_type, command_type_len, client_cs); + table->field[5]->store(sql_text, sql_text_len, client_cs); table->file->ha_write_row(table->record[0]); reenable_binlog(current_thd); @@ -376,6 +377,7 @@ bool Log_to_csv_event_handler:: { /* table variables */ TABLE *table= slow_log.table; + CHARSET_INFO *client_cs= thd->variables.character_set_client; DBUG_ENTER("log_slow_to_csv"); @@ -396,7 +398,7 @@ bool Log_to_csv_event_handler:: table->field[0]->set_null(); /* store the value */ - table->field[1]->store(user_host, user_host_len, &my_charset_latin1); + table->field[1]->store(user_host, user_host_len, client_cs); if (query_start_arg) { @@ -419,7 +421,7 @@ bool Log_to_csv_event_handler:: if (thd->db) /* fill database field */ - table->field[6]->store(thd->db, thd->db_length, &my_charset_latin1); + table->field[6]->store(thd->db, thd->db_length, client_cs); else table->field[6]->set_null(); @@ -437,8 +439,7 @@ bool Log_to_csv_event_handler:: table->field[9]->store((longlong) server_id); /* sql_text */ - table->field[10]->store(sql_text,sql_text_len, - &my_charset_latin1); + table->field[10]->store(sql_text,sql_text_len, client_cs); /* write the row */ table->file->ha_write_row(table->record[0]); @@ -494,7 +495,8 @@ bool Log_to_file_event_handler:: log_general(time_t event_time, const char *user_host, uint user_host_len, int thread_id, const char *command_type, uint command_type_len, - const char *sql_text, uint sql_text_len) + const char *sql_text, uint sql_text_len, + CHARSET_INFO *client_cs) { return mysql_log.write(event_time, user_host, user_host_len, thread_id, command_type, command_type_len, @@ -608,7 +610,7 @@ void LOGGER::init_base() file_log_handler= new Log_to_file_event_handler; /* by default we use traditional error log */ - init_error_log(LEGACY); + init_error_log(LOG_FILE); file_log_handler->init_pthread_objects(); (void) pthread_mutex_init(&LOCK_logger, MY_MUTEX_INIT_SLOW); @@ -810,47 +812,54 @@ bool LOGGER::general_log_print(THD *thd, enum enum_server_command command, user_host_len, id, command_name[(uint) command].str, command_name[(uint) command].length, - message_buff, message_buff_len) || error; + message_buff, message_buff_len, + thd->variables.character_set_client) || error; unlock(); } return error; } -void LOGGER::init_error_log(enum enum_printer error_log_printer) +void LOGGER::init_error_log(uint error_log_printer) { - switch (error_log_printer) { - case NONE: + if (error_log_printer & LOG_NONE) + { error_log_handler_list[0]= 0; - break; - case LEGACY: + return; + } + + switch (error_log_printer) { + case LOG_FILE: error_log_handler_list[0]= file_log_handler; error_log_handler_list[1]= 0; break; /* these two are disabled for now */ - case CSV: + case LOG_TABLE: DBUG_ASSERT(0); break; - case LEGACY_AND_CSV: + case LOG_TABLE|LOG_FILE: DBUG_ASSERT(0); break; } } -void LOGGER::init_slow_log(enum enum_printer slow_log_printer) +void LOGGER::init_slow_log(uint slow_log_printer) { - switch (slow_log_printer) { - case NONE: + if (slow_log_printer & LOG_NONE) + { slow_log_handler_list[0]= 0; - break; - case LEGACY: + return; + } + + switch (slow_log_printer) { + case LOG_FILE: slow_log_handler_list[0]= file_log_handler; slow_log_handler_list[1]= 0; break; - case CSV: + case LOG_TABLE: slow_log_handler_list[0]= table_log_handler; slow_log_handler_list[1]= 0; break; - case LEGACY_AND_CSV: + case LOG_TABLE|LOG_FILE: slow_log_handler_list[0]= file_log_handler; slow_log_handler_list[1]= table_log_handler; slow_log_handler_list[2]= 0; @@ -858,21 +867,24 @@ void LOGGER::init_slow_log(enum enum_printer slow_log_printer) } } -void LOGGER::init_general_log(enum enum_printer general_log_printer) +void LOGGER::init_general_log(uint general_log_printer) { - switch (general_log_printer) { - case NONE: + if (general_log_printer & LOG_NONE) + { general_log_handler_list[0]= 0; - break; - case LEGACY: + return; + } + + switch (general_log_printer) { + case LOG_FILE: general_log_handler_list[0]= file_log_handler; general_log_handler_list[1]= 0; break; - case CSV: + case LOG_TABLE: general_log_handler_list[0]= table_log_handler; general_log_handler_list[1]= 0; break; - case LEGACY_AND_CSV: + case LOG_TABLE|LOG_FILE: general_log_handler_list[0]= file_log_handler; general_log_handler_list[1]= table_log_handler; general_log_handler_list[2]= 0; @@ -903,20 +915,20 @@ bool Log_to_csv_event_handler::init() return (open_log_table(QUERY_LOG_GENERAL) || open_log_table(QUERY_LOG_SLOW)); } -int LOGGER::set_handlers(enum enum_printer error_log_printer, - enum enum_printer slow_log_printer, - enum enum_printer general_log_printer) +int LOGGER::set_handlers(uint error_log_printer, + uint slow_log_printer, + uint general_log_printer) { /* error log table is not supported yet */ - DBUG_ASSERT(error_log_printer < CSV); + DBUG_ASSERT(error_log_printer < LOG_TABLE); lock(); - if ((slow_log_printer >= CSV || general_log_printer >= CSV) && + if ((slow_log_printer & LOG_TABLE || general_log_printer & LOG_TABLE) && !is_log_tables_initialized) { - slow_log_printer= LEGACY; - general_log_printer= LEGACY; + slow_log_printer= (slow_log_printer & ~LOG_TABLE) | LOG_FILE; + general_log_printer= (general_log_printer & ~LOG_TABLE) | LOG_FILE; sql_print_error("Failed to initialize log tables. " "Falling back to the old-fashioned logs"); diff --git a/sql/log.h b/sql/log.h index 9868fe23292..98a86072fca 100644 --- a/sql/log.h +++ b/sql/log.h @@ -138,14 +138,10 @@ typedef struct st_log_info */ #define MAX_LOG_HANDLERS_NUM 3 -enum enum_printer -{ - NONE, - LEGACY, - CSV, - LEGACY_AND_CSV -}; - +/* log event handler flags */ +#define LOG_NONE 1 +#define LOG_FILE 2 +#define LOG_TABLE 4 class Log_event; class Rows_log_event; @@ -368,7 +364,8 @@ public: virtual bool log_general(time_t event_time, const char *user_host, uint user_host_len, int thread_id, const char *command_type, uint command_type_len, - const char *sql_text, uint sql_text_len)= 0; + const char *sql_text, uint sql_text_len, + CHARSET_INFO *client_cs)= 0; virtual ~Log_event_handler() {} }; @@ -403,7 +400,8 @@ public: virtual bool log_general(time_t event_time, const char *user_host, uint user_host_len, int thread_id, const char *command_type, uint command_type_len, - const char *sql_text, uint sql_text_len); + const char *sql_text, uint sql_text_len, + CHARSET_INFO *client_cs); bool flush(THD *thd, TABLE_LIST *close_slow_Log, TABLE_LIST* close_general_log); void close_log_table(uint log_type, bool lock_in_use); @@ -431,7 +429,8 @@ public: virtual bool log_general(time_t event_time, const char *user_host, uint user_host_len, int thread_id, const char *command_type, uint command_type_len, - const char *sql_text, uint sql_text_len); + const char *sql_text, uint sql_text_len, + CHARSET_INFO *client_cs); void flush(); void init_pthread_objects(); }; @@ -500,12 +499,12 @@ public: bool reopen_log_table(uint log_type); /* we use this function to setup all enabled log event handlers */ - int set_handlers(enum enum_printer error_log_printer, - enum enum_printer slow_log_printer, - enum enum_printer general_log_printer); - void init_error_log(enum enum_printer error_log_printer); - void init_slow_log(enum enum_printer slow_log_printer); - void init_general_log(enum enum_printer general_log_printer); + int set_handlers(uint error_log_printer, + uint slow_log_printer, + uint general_log_printer); + void init_error_log(uint error_log_printer); + void init_slow_log(uint slow_log_printer); + void init_general_log(uint general_log_printer); }; #endif /* LOG_H */ diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 29faefcabda..fc777c47818 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -611,6 +611,7 @@ void write_bin_log(THD *thd, bool clear_error, bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent); bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create); bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent); +bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db); void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags); void mysql_client_binlog_statement(THD *thd); bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, @@ -623,7 +624,7 @@ int mysql_rm_table_part2_with_lock(THD *thd, TABLE_LIST *tables, bool quick_rm_table(handlerton *base,const char *db, const char *table_name); void close_cached_table(THD *thd, TABLE *table); -bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list); +bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent); bool mysql_change_db(THD *thd,const char *name,bool no_access_check); void mysql_parse(THD *thd,char *inBuf,uint length); bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length); @@ -1228,10 +1229,12 @@ uint check_word(TYPELIB *lib, const char *val, const char *end, bool is_keyword(const char *name, uint len); #define MY_DB_OPT_FILE "db.opt" +bool my_database_names_init(void); +void my_database_names_free(void); bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create); -bool my_dbopt_init(void); void my_dbopt_cleanup(void); -void my_dbopt_free(void); +extern int creating_database; // How many database locks are made +extern int creating_table; // How many mysql_create_table() are running /* External variables @@ -1305,7 +1308,6 @@ extern my_bool locked_in_memory; extern bool opt_using_transactions, mysqld_embedded; extern bool using_update_log, opt_large_files, server_id_supplied; extern bool opt_log, opt_update_log, opt_bin_log, opt_slow_log, opt_error_log; -extern bool opt_old_log_format; extern bool opt_disable_networking, opt_skip_show_db; extern my_bool opt_character_set_client_handshake; extern bool volatile abort_loop, shutdown_in_progress, grant_option; @@ -1334,7 +1336,7 @@ extern FILE *bootstrap_file; extern int bootstrap_error; extern FILE *stderror_file; extern pthread_key(MEM_ROOT**,THR_MALLOC); -extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, +extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_lock_db, LOCK_thread_count,LOCK_mapped_file,LOCK_user_locks, LOCK_status, LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, @@ -1365,7 +1367,7 @@ extern const char *opt_date_time_formats[]; extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[]; extern String null_string; -extern HASH open_cache; +extern HASH open_cache, lock_db_cache; extern TABLE *unused_tables; extern const char* any_db; extern struct my_option my_long_options[]; @@ -1432,7 +1434,6 @@ extern handlerton myisam_hton; extern handlerton myisammrg_hton; extern handlerton heap_hton; -extern SHOW_COMP_OPTION have_isam; extern SHOW_COMP_OPTION have_row_based_replication; extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink; extern SHOW_COMP_OPTION have_query_cache; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index be476c11533..2b04d45064d 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -304,8 +304,16 @@ arg_cmp_func Arg_comparator::comparator_matrix[5][2] = {&Arg_comparator::compare_row, &Arg_comparator::compare_e_row}, {&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal}}; +const char *log_output_names[] = +{ "NONE", "FILE", "TABLE", NullS}; +TYPELIB log_output_typelib= {array_elements(log_output_names)-1,"", + log_output_names, NULL}; + /* static variables */ +/* the default log output is log tables */ +static const char *log_output_str= "TABLE"; +static ulong log_output_options= LOG_TABLE; static bool lower_case_table_names_used= 0; static bool volatile select_thread_in_use, signal_thread_in_use; static bool volatile ready_to_exit; @@ -339,9 +347,6 @@ static my_bool opt_sync_bdb_logs; bool opt_log, opt_update_log, opt_bin_log, opt_slow_log; bool opt_error_log= IF_WIN(1,0); -#ifdef WITH_CSV_STORAGE_ENGINE -bool opt_old_log_format, opt_both_log_formats; -#endif bool opt_disable_networking=0, opt_skip_show_db=0; my_bool opt_character_set_client_handshake= 1; bool server_id_supplied = 0; @@ -576,7 +581,7 @@ CHARSET_INFO *national_charset_info, *table_alias_charset; CHARSET_INFO *character_set_filesystem; SHOW_COMP_OPTION have_row_based_replication; -SHOW_COMP_OPTION have_raid, have_openssl, have_symlink, have_query_cache; +SHOW_COMP_OPTION have_openssl, have_symlink, have_query_cache; SHOW_COMP_OPTION have_geometry, have_rtree_keys; SHOW_COMP_OPTION have_crypt, have_compress; @@ -1165,7 +1170,7 @@ void clean_up(bool print_message) bitmap_free(&slave_error_mask); #endif my_tz_free(); - my_dbopt_free(); + my_database_names_free(); #ifndef NO_EMBEDDED_ACCESS_CHECKS acl_free(1); grant_free(); @@ -1193,9 +1198,6 @@ void clean_up(bool print_message) multi_keycache_free(); free_status_vars(); end_thr_alarm(1); /* Free allocated memory */ -#ifdef USE_RAID - end_raid(); -#endif my_free_open_file_info(); my_free((char*) global_system_variables.date_format, MYF(MY_ALLOW_ZERO_PTR)); @@ -1281,6 +1283,7 @@ static void wait_for_signal_thread_to_end() static void clean_up_mutexes() { (void) pthread_mutex_destroy(&LOCK_mysql_create_db); + (void) pthread_mutex_destroy(&LOCK_lock_db); (void) pthread_mutex_destroy(&LOCK_Acl); (void) rwlock_destroy(&LOCK_grant); (void) pthread_mutex_destroy(&LOCK_open); @@ -2405,8 +2408,8 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) sql_print_information("Got signal %d to shutdown mysqld",sig); #endif /* switch to the old log message processing */ - logger.set_handlers(LEGACY, opt_slow_log ? LEGACY:NONE, - opt_log ? LEGACY:NONE); + logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE, + opt_log ? LOG_FILE:LOG_NONE); DBUG_PRINT("info",("Got signal: %d abort_loop: %d",sig,abort_loop)); if (!abort_loop) { @@ -2435,8 +2438,8 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) (TABLE_LIST*) 0, ¬_used); // Flush logs } /* reenable logs after the options were reloaded */ - logger.set_handlers(LEGACY, opt_slow_log ? CSV:NONE, - opt_log ? CSV:NONE); + logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_TABLE:LOG_NONE, + opt_log ? LOG_TABLE:LOG_NONE); break; #ifdef USE_ONE_SIGNAL_HAND case THR_SERVER_ALARM: @@ -2836,7 +2839,7 @@ static int init_common_variables(const char *conf_file_name, int argc, if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1)) return 1; - if (my_dbopt_init()) + if (my_database_names_init()) return 1; /* @@ -2890,6 +2893,7 @@ You should consider changing lower_case_table_names to 1 or 2", static int init_thread_environment() { (void) pthread_mutex_init(&LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW); + (void) pthread_mutex_init(&LOCK_lock_db,MY_MUTEX_INIT_SLOW); (void) pthread_mutex_init(&LOCK_Acl,MY_MUTEX_INIT_SLOW); (void) pthread_mutex_init(&LOCK_open, NULL); (void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST); @@ -3094,25 +3098,38 @@ static int init_server_components() #ifdef WITH_CSV_STORAGE_ENGINE if (opt_bootstrap) - opt_old_log_format= TRUE; + log_output_options= LOG_FILE; else logger.init_log_tables(); - if (opt_old_log_format || (have_csv_db != SHOW_OPTION_YES)) - logger.set_handlers(LEGACY, opt_slow_log ? LEGACY:NONE, - opt_log ? LEGACY:NONE); + if (log_output_options & LOG_NONE) + { + /* + Issue a warining if there were specified additional options to the + log-output along with NONE. Probably this wasn't what user wanted. + */ + if ((log_output_options & LOG_NONE) && (log_output_options & ~LOG_NONE)) + sql_print_warning("There were other values specified to " + "log-output besides NONE. Disabling slow " + "and general logs anyway."); + logger.set_handlers(LOG_FILE, LOG_NONE, LOG_NONE); + } else - if (opt_both_log_formats) - logger.set_handlers(LEGACY, - opt_slow_log ? LEGACY_AND_CSV:NONE, - opt_log ? LEGACY_AND_CSV:NONE); - else - /* the default is CSV log tables */ - logger.set_handlers(LEGACY, opt_slow_log ? CSV:NONE, - opt_log ? CSV:NONE); + { + /* fall back to the log files if tables are not present */ + if (have_csv_db == SHOW_OPTION_NO) + { + sql_print_error("CSV engine is not present, falling back to the " + "log files"); + log_output_options= log_output_options & ~LOG_TABLE | LOG_FILE; + } + + logger.set_handlers(LOG_FILE, opt_slow_log ? log_output_options:LOG_NONE, + opt_log ? log_output_options:LOG_NONE); + } #else - logger.set_handlers(LEGACY, opt_slow_log ? LEGACY:NONE, - opt_log ? LEGACY:NONE); + logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE, + opt_log ? LOG_FILE:LOG_NONE); #endif if (opt_update_log) @@ -4692,7 +4709,7 @@ enum options_mysqld OPT_REPLICATE_IGNORE_TABLE, OPT_REPLICATE_WILD_DO_TABLE, OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID, OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER, - OPT_ABORT_SLAVE_EVENT_COUNT, OPT_OLD_LOG_FORMAT, OPT_BOTH_LOG_FORMATS, + OPT_ABORT_SLAVE_EVENT_COUNT, OPT_INNODB_DATA_HOME_DIR, OPT_INNODB_DATA_FILE_PATH, OPT_INNODB_LOG_GROUP_HOME_DIR, @@ -4835,6 +4852,7 @@ enum options_mysqld OPT_LOG_SLOW_ADMIN_STATEMENTS, OPT_TABLE_LOCK_WAIT_TIMEOUT, OPT_PLUGIN_DIR, + OPT_LOG_OUTPUT, OPT_PORT_OPEN_TIMEOUT }; @@ -5216,8 +5234,8 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite, */ {"log-bin-trust-function-creators", OPT_LOG_BIN_TRUST_FUNCTION_CREATORS, "If equal to 0 (the default), then when --log-bin is used, creation of " - "a function is allowed only to users having the SUPER privilege and only " - "if this function may not break binary logging." + "a function (a trigger) is allowed only to users having the SUPER privilege " + "and only if this function (trigger) may not break binary logging." #ifdef HAVE_ROW_BASED_REPLICATION " If using --binlog-format=row, the security issues do not exist and the " "binary logging cannot break so this option is automatically set to 1." @@ -5233,6 +5251,13 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite, {"log-long-format", '0', "Log some extra information to update log. Please note that this option is deprecated; see --log-short-format option.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, +#ifdef WITH_CSV_STORAGE_ENGINE + {"log-output", OPT_LOG_OUTPUT, + "Syntax: log-output[=value[,value...]], where \"value\" could be TABLE, " + "FILE or NONE.", + (gptr*) &log_output_str, (gptr*) &log_output_str, 0, + GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, +#endif {"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES, "Log queries that are executed without benefit of any index to the slow log if it is open.", (gptr*) &opt_log_queries_not_using_indexes, (gptr*) &opt_log_queries_not_using_indexes, @@ -5254,16 +5279,6 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite, "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.", (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef WITH_CSV_STORAGE_ENGINE - {"old-log-format", OPT_OLD_LOG_FORMAT, - "Enable old log file format. (No SELECT * FROM logs)", - (gptr*) &opt_old_log_format, 0, 0, GET_BOOL, OPT_ARG, - 0, 0, 0, 0, 0, 0}, - {"both-log-formats", OPT_BOTH_LOG_FORMATS, - "Enable old log file format along with log tables", - (gptr*) &opt_both_log_formats, 0, 0, GET_BOOL, OPT_ARG, - 0, 0, 0, 0, 0, 0}, -#endif {"log-tc", OPT_LOG_TC, "Path to transaction coordinator log (used for transactions that affect " "more than one storage engine, when binary log is disabled)", @@ -6957,10 +6972,6 @@ static void mysql_init_variables(void) opt_skip_slave_start= opt_reckless_slave = 0; mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0; opt_log= opt_update_log= opt_slow_log= 0; -#ifdef WITH_CSV_STORAGE_ENGINE - opt_old_log_format= 0; - opt_both_log_formats= 0; -#endif opt_bin_log= 0; opt_disable_networking= opt_skip_show_db=0; opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname= 0; @@ -7094,11 +7105,6 @@ static void mysql_init_variables(void) #else have_ndbcluster=SHOW_OPTION_NO; #endif -#ifdef USE_RAID - have_raid=SHOW_OPTION_YES; -#else - have_raid=SHOW_OPTION_NO; -#endif #ifdef HAVE_OPENSSL have_openssl=SHOW_OPTION_YES; #else @@ -7374,12 +7380,25 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_slow_log= 1; break; #ifdef WITH_CSV_STORAGE_ENGINE - case (int) OPT_OLD_LOG_FORMAT: - opt_old_log_format= 1; - break; - case (int) OPT_BOTH_LOG_FORMATS: - opt_both_log_formats= 1; + case OPT_LOG_OUTPUT: + { + if (!argument || !argument[0]) + { + log_output_options= LOG_TABLE; + log_output_str= log_output_typelib.type_names[1]; + } + else + { + log_output_str= argument; + if ((log_output_options= + find_bit_type(argument, &log_output_typelib)) == ~(ulong) 0) + { + fprintf(stderr, "Unknown option to log-output: %s\n", argument); + exit(1); + } + } break; + } #endif case (int) OPT_SKIP_NEW: opt_specialflag|= SPECIAL_NO_NEW_FUNC; @@ -8133,7 +8152,6 @@ static void create_pid_file() /***************************************************************************** Instantiate have_xyx for missing storage engines *****************************************************************************/ -#undef have_isam #undef have_berkeley_db #undef have_innodb #undef have_ndbcluster @@ -8146,7 +8164,6 @@ static void create_pid_file() SHOW_COMP_OPTION have_berkeley_db= SHOW_OPTION_NO; SHOW_COMP_OPTION have_innodb= SHOW_OPTION_NO; -SHOW_COMP_OPTION have_isam= SHOW_OPTION_NO; SHOW_COMP_OPTION have_ndbcluster= SHOW_OPTION_NO; SHOW_COMP_OPTION have_example_db= SHOW_OPTION_NO; SHOW_COMP_OPTION have_archive_db= SHOW_OPTION_NO; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 887690aecc1..c0f1abe597c 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -9068,6 +9068,7 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, quick_prefix_selectivity= (double) quick_prefix_records / (double) table_records; num_groups= (uint) rint(num_groups * quick_prefix_selectivity); + set_if_bigger(num_groups, 1); } if (used_key_parts > group_key_parts) diff --git a/sql/set_var.cc b/sql/set_var.cc index a6c2fca7fc5..f082e893205 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -109,7 +109,7 @@ extern ulong ndb_report_thresh_binlog_mem_usage; -extern volatile my_bool event_executor_running_global_var; +extern my_bool event_executor_running_global_var; static HASH system_variable_hash; const char *bool_type_names[]= { "OFF", "ON", NullS }; @@ -629,14 +629,12 @@ sys_var_have_variable sys_have_federated_db("have_federated_engine", &have_federated_db); sys_var_have_variable sys_have_geometry("have_geometry", &have_geometry); sys_var_have_variable sys_have_innodb("have_innodb", &have_innodb); -sys_var_have_variable sys_have_isam("have_isam", &have_isam); sys_var_have_variable sys_have_ndbcluster("have_ndbcluster", &have_ndbcluster); sys_var_have_variable sys_have_openssl("have_openssl", &have_openssl); sys_var_have_variable sys_have_partition_db("have_partitioning", &have_partition_db); sys_var_have_variable sys_have_query_cache("have_query_cache", &have_query_cache); -sys_var_have_variable sys_have_raid("have_raid", &have_raid); sys_var_have_variable sys_have_rtree_keys("have_rtree_keys", &have_rtree_keys); sys_var_have_variable sys_have_symlink("have_symlink", &have_symlink); sys_var_have_variable sys_have_row_based_replication("have_row_based_replication",&have_row_based_replication); @@ -750,12 +748,10 @@ SHOW_VAR init_vars[]= { {sys_have_federated_db.name,(char*) &have_federated_db, SHOW_HAVE}, {sys_have_geometry.name, (char*) &have_geometry, SHOW_HAVE}, {sys_have_innodb.name, (char*) &have_innodb, SHOW_HAVE}, - {sys_have_isam.name, (char*) &have_isam, SHOW_HAVE}, {sys_have_ndbcluster.name, (char*) &have_ndbcluster, SHOW_HAVE}, {sys_have_openssl.name, (char*) &have_openssl, SHOW_HAVE}, {sys_have_partition_db.name,(char*) &have_partition_db, SHOW_HAVE}, {sys_have_query_cache.name, (char*) &have_query_cache, SHOW_HAVE}, - {sys_have_raid.name, (char*) &have_raid, SHOW_HAVE}, {sys_have_row_based_replication.name, (char*) &have_row_based_replication, SHOW_HAVE}, {sys_have_rtree_keys.name, (char*) &have_rtree_keys, SHOW_HAVE}, {sys_have_symlink.name, (char*) &have_symlink, SHOW_HAVE}, diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index be3c14d0039..690fd071652 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -1479,30 +1479,30 @@ ER_DUP_KEYNAME 42000 S1009 swe "Nyckelnamn '%-.64s' finns flera gånger" ukr "äÕÂÌÀÀÞÅ ¦Í'Ñ ËÌÀÞÁ '%-.64s'" ER_DUP_ENTRY 23000 S1009 - cze "Zvojen-Bý klíè '%-.64s' (èíslo klíèe %d)" - dan "Ens værdier '%-.64s' for indeks %d" - nla "Dubbele ingang '%-.64s' voor zoeksleutel %d" - eng "Duplicate entry '%-.64s' for key %d" - jps "'%-.64s' ‚Í key %d ‚É‚¨‚¢‚Äd•¡‚µ‚Ä‚¢‚Ü‚·", - est "Kattuv väärtus '%-.64s' võtmele %d" - fre "Duplicata du champ '%-.64s' pour la clef %d" - ger "Doppelter Eintrag '%-.64s' für Schlüssel %d" - greek "ÄéðëÞ åããñáöÞ '%-.64s' ãéá ôï êëåéäß %d" - hun "Duplikalt bejegyzes '%-.64s' a %d kulcs szerint." - ita "Valore duplicato '%-.64s' per la chiave %d" - jpn "'%-.64s' ¤Ï key %d ¤Ë¤ª¤¤¤Æ½ÅÊ£¤·¤Æ¤¤¤Þ¤¹" - kor "Áߺ¹µÈ ÀÔ·Â °ª '%-.64s': key %d" - nor "Like verdier '%-.64s' for nøkkel %d" - norwegian-ny "Like verdiar '%-.64s' for nykkel %d" - pol "Powtórzone wyst?pienie '%-.64s' dla klucza %d" - por "Entrada '%-.64s' duplicada para a chave %d" - rum "Cimpul '%-.64s' e duplicat pentru cheia %d" - rus "äÕÂÌÉÒÕÀÝÁÑÓÑ ÚÁÐÉÓØ '%-.64s' ÐÏ ËÌÀÞÕ %d" - serbian "Dupliran unos '%-.64s' za kljuè '%d'" - slo "Opakovaný kµúè '%-.64s' (èíslo kµúèa %d)" - spa "Entrada duplicada '%-.64s' para la clave %d" - swe "Dubbel nyckel '%-.64s' för nyckel %d" - ukr "äÕÂÌÀÀÞÉÊ ÚÁÐÉÓ '%-.64s' ÄÌÑ ËÌÀÞÁ %d" + cze "Zvojen-Bý klíè '%-.64s' (èíslo klíèe '%-.64s')" + dan "Ens værdier '%-.64s' for indeks '%-.64s'" + nla "Dubbele ingang '%-.64s' voor zoeksleutel '%-.64s'" + eng "Duplicate entry '%-.64s' for key '%-.64s'" + jps "'%-.64s' ‚Í key '%-.64s' ‚É‚¨‚¢‚Äd•¡‚µ‚Ä‚¢‚Ü‚·", + est "Kattuv väärtus '%-.64s' võtmele '%-.64s'" + fre "Duplicata du champ '%-.64s' pour la clef '%-.64s'" + ger "Doppelter Eintrag '%-.64s' für Schlüssel '%-.64s'" + greek "ÄéðëÞ åããñáöÞ '%-.64s' ãéá ôï êëåéäß '%-.64s'" + hun "Duplikalt bejegyzes '%-.64s' a '%-.64s' kulcs szerint." + ita "Valore duplicato '%-.64s' per la chiave '%-.64s'" + jpn "'%-.64s' ¤Ï key '%-.64s' ¤Ë¤ª¤¤¤Æ½ÅÊ£¤·¤Æ¤¤¤Þ¤¹" + kor "Áߺ¹µÈ ÀÔ·Â °ª '%-.64s': key '%-.64s'" + nor "Like verdier '%-.64s' for nøkkel '%-.64s'" + norwegian-ny "Like verdiar '%-.64s' for nykkel '%-.64s'" + pol "Powtórzone wyst?pienie '%-.64s' dla klucza '%-.64s'" + por "Entrada '%-.64s' duplicada para a chave '%-.64s'" + rum "Cimpul '%-.64s' e duplicat pentru cheia '%-.64s'" + rus "äÕÂÌÉÒÕÀÝÁÑÓÑ ÚÁÐÉÓØ '%-.64s' ÐÏ ËÌÀÞÕ '%-.64s'" + serbian "Dupliran unos '%-.64s' za kljuè '%-.64s'" + slo "Opakovaný kµúè '%-.64s' (èíslo kµúèa '%-.64s')" + spa "Entrada duplicada '%-.64s' para la clave '%-.64s'" + swe "Dubbel nyckel '%-.64s' för nyckel '%-.64s'" + ukr "äÕÂÌÀÀÞÉÊ ÚÁÐÉÓ '%-.64s' ÄÌÑ ËÌÀÞÁ '%-.64s'" ER_WRONG_FIELD_SPEC 42000 S1009 cze "Chybn-Bá specifikace sloupce '%-.64s'" dan "Forkert kolonnespecifikaton for felt '%-.64s'" @@ -5800,3 +5800,5 @@ ER_CANT_READ_LOCK_LOG_TABLE eng "You can't use usual read lock with log tables. Try READ LOCAL instead." ER_SP_WRONG_NAME 42000 eng "Incorrect routine name '%-.64s'" +ER_FOREIGN_DUPLICATE_KEY 23000 S1009 + eng "Upholding foreign key constraints for table '%.64s', entry '%-.64s', key %d would lead to a duplicate entry" diff --git a/sql/sp.cc b/sql/sp.cc index bf639b13a41..4838f839b4e 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1003,22 +1003,26 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp, } +/* + This is used by sql_acl.cc:mysql_routine_grant() and is used to find + the routines in 'routines'. +*/ int -sp_exists_routine(THD *thd, TABLE_LIST *tables, bool any, bool no_error) +sp_exist_routines(THD *thd, TABLE_LIST *routines, bool any, bool no_error) { - TABLE_LIST *table; + TABLE_LIST *routine; bool result= 0; DBUG_ENTER("sp_exists_routine"); - for (table= tables; table; table= table->next_global) + for (routine= routines; routine; routine= routine->next_global) { sp_name *name; LEX_STRING lex_db; LEX_STRING lex_name; - lex_db.length= strlen(table->db); - lex_name.length= strlen(table->table_name); - lex_db.str= thd->strmake(table->db, lex_db.length); - lex_name.str= thd->strmake(table->table_name, lex_name.length); + lex_db.length= strlen(routine->db); + lex_name.length= strlen(routine->table_name); + lex_db.str= thd->strmake(routine->db, lex_db.length); + lex_name.str= thd->strmake(routine->table_name, lex_name.length); name= new sp_name(lex_db, lex_name); name->init_qname(thd); if (sp_find_routine(thd, TYPE_ENUM_PROCEDURE, name, @@ -1035,7 +1039,7 @@ sp_exists_routine(THD *thd, TABLE_LIST *tables, bool any, bool no_error) if (!no_error) { my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION or PROCEDURE", - table->table_name); + routine->table_name); DBUG_RETURN(-1); } DBUG_RETURN(0); @@ -1045,6 +1049,39 @@ sp_exists_routine(THD *thd, TABLE_LIST *tables, bool any, bool no_error) } +/* + Check if a routine exists in the mysql.proc table, without actually + parsing the definition. (Used for dropping) + + SYNOPSIS + sp_routine_exists_in_table() + thd - thread context + name - name of procedure + + RETURN VALUE + 0 - Success + non-0 - Error; SP_OPEN_TABLE_FAILED or SP_KEY_NOT_FOUND +*/ + +int +sp_routine_exists_in_table(THD *thd, int type, sp_name *name) +{ + TABLE *table; + int ret; + Open_tables_state open_tables_state_backup; + + if (!(table= open_proc_table_for_read(thd, &open_tables_state_backup))) + ret= SP_OPEN_TABLE_FAILED; + else + { + if ((ret= db_find_routine_aux(thd, type, name, table)) != SP_OK) + ret= SP_KEY_NOT_FOUND; + close_proc_table(thd, &open_tables_state_backup); + } + return ret; +} + + int sp_create_procedure(THD *thd, sp_head *sp) { @@ -40,7 +40,10 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp, bool cache_only); int -sp_exists_routine(THD *thd, TABLE_LIST *procs, bool any, bool no_error); +sp_exist_routines(THD *thd, TABLE_LIST *procs, bool any, bool no_error); + +int +sp_routine_exists_in_table(THD *thd, int type, sp_name *name); int sp_create_procedure(THD *thd, sp_head *sp); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index e4e87eb5620..cf1097a28c6 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1776,7 +1776,7 @@ sp_head::fill_field_definition(THD *thd, LEX *lex, void -sp_head::new_cont_backpatch(sp_instr_jump_if_not *i) +sp_head::new_cont_backpatch(sp_instr_opt_meta *i) { m_cont_level+= 1; if (i) @@ -1788,7 +1788,7 @@ sp_head::new_cont_backpatch(sp_instr_jump_if_not *i) } void -sp_head::add_cont_backpatch(sp_instr_jump_if_not *i) +sp_head::add_cont_backpatch(sp_instr_opt_meta *i) { i->m_cont_dest= m_cont_level; (void)m_cont_backpatch.push_front(i); @@ -1799,7 +1799,7 @@ sp_head::do_cont_backpatch() { uint dest= instructions(); uint lev= m_cont_level--; - sp_instr_jump_if_not *i; + sp_instr_opt_meta *i; while ((i= m_cont_backpatch.head()) && i->m_cont_dest == lev) { @@ -2026,6 +2026,15 @@ sp_head::show_create_function(THD *thd) 1) Mark used instructions 1.1) While doing this, shortcut jumps to jump instructions 2) Compact the code, removing unused instructions + + This is the main mark and move loop; it relies on the following methods + in sp_instr and its subclasses: + + opt_mark() Mark instruction as reachable (will recurse for jumps) + opt_shortcut_jump() Shortcut jumps to the final destination; + used by opt_mark(). + opt_move() Update moved instruction + set_destination() Set the new destination (jump instructions only) */ void sp_head::optimize() @@ -2054,10 +2063,10 @@ void sp_head::optimize() set_dynamic(&m_instr, (gptr)&i, dst); while ((ibp= li++)) - { - sp_instr_jump *ji= static_cast<sp_instr_jump *>(ibp); - ji->set_destination(src, dst); - } + { + sp_instr_opt_meta *im= static_cast<sp_instr_opt_meta *>(ibp); + im->set_destination(src, dst); + } } i->opt_move(dst, &bp); src+= 1; @@ -2079,6 +2088,10 @@ sp_head::opt_mark(uint ip) #ifndef DBUG_OFF +/* + Return the routine instructions as a result set. + Returns 0 if ok, !=0 on error. +*/ int sp_head::show_routine_code(THD *thd) { @@ -2106,6 +2119,22 @@ sp_head::show_routine_code(THD *thd) for (ip= 0; (i = get_instr(ip)) ; ip++) { + /* + Consistency check. If these are different something went wrong + during optimization. + */ + if (ip != i->m_ip) + { + const char *format= "Instruction at position %u has m_ip=%u"; + char tmp[sizeof(format) + 2*SP_INSTR_UINT_MAXLEN + 1]; + + sprintf(tmp, format, ip, i->m_ip); + /* + Since this is for debugging purposes only, we don't bother to + introduce a special error code for it. + */ + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, tmp); + } protocol->prepare_for_resend(); protocol->store((longlong)ip); @@ -2530,14 +2559,14 @@ sp_instr_jump_if_not::exec_core(THD *thd, uint *nextp) void sp_instr_jump_if_not::print(String *str) { - /* jump_if_not dest ... */ + /* jump_if_not dest(cont) ... */ if (str->reserve(2*SP_INSTR_UINT_MAXLEN+14+32)) // Add some for the expr. too return; str->qs_append(STRING_WITH_LEN("jump_if_not ")); str->qs_append(m_dest); - str->append('('); + str->qs_append('('); str->qs_append(m_cont_dest); - str->append(") "); + str->qs_append(STRING_WITH_LEN(") ")); m_expr->print(str); } @@ -2718,12 +2747,6 @@ sp_instr_hpop::print(String *str) str->qs_append(m_count); } -void -sp_instr_hpop::backpatch(uint dest, sp_pcontext *dst_ctx) -{ - m_count= m_ctx->diff_handlers(dst_ctx); -} - /* sp_instr_hreturn class functions @@ -2845,12 +2868,6 @@ sp_instr_cpop::print(String *str) str->qs_append(m_count); } -void -sp_instr_cpop::backpatch(uint dest, sp_pcontext *dst_ctx) -{ - m_count= m_ctx->diff_cursors(dst_ctx); -} - /* sp_instr_copen class functions @@ -3095,30 +3112,53 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp) spcont->clear_handler(); thd->spcont= spcont; } + *nextp= m_cont_dest; /* For continue handler */ } + else + *nextp= m_ip+1; - *nextp = m_ip+1; - - return res; /* no error */ + return res; } void sp_instr_set_case_expr::print(String *str) { - const char CASE_EXPR_TAG[]= "set_case_expr "; - const int CASE_EXPR_TAG_LEN= sizeof(CASE_EXPR_TAG) - 1; - const int INT_STRING_MAX_LEN= 10; - - /* We must call reserve(), because qs_append() doesn't care about memory. */ - str->reserve(CASE_EXPR_TAG_LEN + INT_STRING_MAX_LEN + 2); - - str->qs_append(CASE_EXPR_TAG, CASE_EXPR_TAG_LEN); + /* set_case_expr (cont) id ... */ + str->reserve(2*SP_INSTR_UINT_MAXLEN+18+32); // Add some extra for expr too + str->qs_append(STRING_WITH_LEN("set_case_expr (")); + str->qs_append(m_cont_dest); + str->qs_append(STRING_WITH_LEN(") ")); str->qs_append(m_case_expr_id); str->qs_append(' '); m_case_expr->print(str); } +uint +sp_instr_set_case_expr::opt_mark(sp_head *sp) +{ + sp_instr *i; + + marked= 1; + if ((i= sp->get_instr(m_cont_dest))) + { + m_cont_dest= i->opt_shortcut_jump(sp, this); + m_cont_optdest= sp->get_instr(m_cont_dest); + } + sp->opt_mark(m_cont_dest); + return m_ip+1; +} + +void +sp_instr_set_case_expr::opt_move(uint dst, List<sp_instr> *bp) +{ + if (m_cont_dest > m_ip) + bp->push_back(this); // Forward + else if (m_cont_optdest) + m_cont_dest= m_cont_optdest->m_ip; // Backward + m_ip= dst; +} + /* ------------------------------------------------------------------ */ diff --git a/sql/sp_head.h b/sql/sp_head.h index c4b6cb36090..a637c466041 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -41,6 +41,7 @@ sp_get_flags_for_command(LEX *lex); struct sp_label; class sp_instr; +class sp_instr_opt_meta; class sp_instr_jump_if_not; struct sp_cond_type; struct sp_pvar; @@ -270,11 +271,11 @@ public: // Start a new cont. backpatch level. If 'i' is NULL, the level is just incr. void - new_cont_backpatch(sp_instr_jump_if_not *i); + new_cont_backpatch(sp_instr_opt_meta *i); // Add an instruction to the current level void - add_cont_backpatch(sp_instr_jump_if_not *i); + add_cont_backpatch(sp_instr_opt_meta *i); // Backpatch (and pop) the current level to the current position. void @@ -371,15 +372,15 @@ private: } bp_t; List<bp_t> m_backpatch; // Instructions needing backpatching /* - We need a special list for backpatching of conditional jump's continue + We need a special list for backpatching of instructions with a continue destination (in the case of a continue handler catching an error in the test), since it would otherwise interfere with the normal backpatch - mechanism - jump_if_not instructions have two different destination + mechanism - e.g. jump_if_not instructions have two different destinations which are to be patched differently. Since these occur in a more restricted way (always the same "level" in the code), we don't need the label. */ - List<sp_instr_jump_if_not> m_cont_backpatch; + List<sp_instr_opt_meta> m_cont_backpatch; uint m_cont_level; // The current cont. backpatch level /* @@ -460,17 +461,34 @@ public: virtual void backpatch(uint dest, sp_pcontext *dst_ctx) {} + /* + Mark this instruction as reachable during optimization and return the + index to the next instruction. Jump instruction will mark their + destination too recursively. + */ virtual uint opt_mark(sp_head *sp) { marked= 1; return m_ip+1; } + /* + Short-cut jumps to jumps during optimization. This is used by the + jump instructions' opt_mark() methods. 'start' is the starting point, + used to prevent the mark sweep from looping for ever. Return the + end destination. + */ virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start) { return m_ip; } + /* + Inform the instruction that it has been moved during optimization. + Most instructions will simply update its index, but jump instructions + must also take care of their destination pointers. Forward jumps get + pushed to the backpatch list 'ibp'. + */ virtual void opt_move(uint dst, List<sp_instr> *ibp) { m_ip= dst; @@ -659,21 +677,55 @@ private: }; // class sp_instr_trigger_field : public sp_instr -class sp_instr_jump : public sp_instr +/* + An abstract class for all instructions with destinations that + needs to be updated by the optimizer. + Even if not all subclasses will use both the normal destination and + the continuation destination, we put them both here for simplicity. + */ +class sp_instr_opt_meta : public sp_instr +{ +public: + + uint m_dest; // Where we will go + uint m_cont_dest; // Where continue handlers will go + + sp_instr_opt_meta(uint ip, sp_pcontext *ctx) + : sp_instr(ip, ctx), + m_dest(0), m_cont_dest(0), m_optdest(0), m_cont_optdest(0) + {} + + sp_instr_opt_meta(uint ip, sp_pcontext *ctx, uint dest) + : sp_instr(ip, ctx), + m_dest(dest), m_cont_dest(0), m_optdest(0), m_cont_optdest(0) + {} + + virtual ~sp_instr_opt_meta() + {} + + virtual void set_destination(uint old_dest, uint new_dest) + = 0; + +protected: + + sp_instr *m_optdest; // Used during optimization + sp_instr *m_cont_optdest; // Used during optimization + +}; // class sp_instr_opt_meta : public sp_instr + +class sp_instr_jump : public sp_instr_opt_meta { sp_instr_jump(const sp_instr_jump &); /* Prevent use of these */ void operator=(sp_instr_jump &); public: - uint m_dest; // Where we will go - sp_instr_jump(uint ip, sp_pcontext *ctx) - : sp_instr(ip, ctx), m_dest(0), m_optdest(0) + : sp_instr_opt_meta(ip, ctx) {} sp_instr_jump(uint ip, sp_pcontext *ctx, uint dest) - : sp_instr(ip, ctx), m_dest(dest), m_optdest(0) + : sp_instr_opt_meta(ip, ctx, dest) {} virtual ~sp_instr_jump() @@ -695,17 +747,16 @@ public: m_dest= dest; } + /* + Update the destination; used by the optimizer. + */ virtual void set_destination(uint old_dest, uint new_dest) { if (m_dest == old_dest) m_dest= new_dest; } -protected: - - sp_instr *m_optdest; // Used during optimization - -}; // class sp_instr_jump : public sp_instr +}; // class sp_instr_jump : public sp_instr_opt_meta class sp_instr_jump_if_not : public sp_instr_jump @@ -715,16 +766,14 @@ class sp_instr_jump_if_not : public sp_instr_jump public: - uint m_cont_dest; // Where continue handlers will go - sp_instr_jump_if_not(uint ip, sp_pcontext *ctx, Item *i, LEX *lex) - : sp_instr_jump(ip, ctx), m_cont_dest(0), m_expr(i), - m_lex_keeper(lex, TRUE), m_cont_optdest(0) + : sp_instr_jump(ip, ctx), m_expr(i), + m_lex_keeper(lex, TRUE) {} sp_instr_jump_if_not(uint ip, sp_pcontext *ctx, Item *i, uint dest, LEX *lex) - : sp_instr_jump(ip, ctx, dest), m_cont_dest(0), m_expr(i), - m_lex_keeper(lex, TRUE), m_cont_optdest(0) + : sp_instr_jump(ip, ctx, dest), m_expr(i), + m_lex_keeper(lex, TRUE) {} virtual ~sp_instr_jump_if_not() @@ -738,6 +787,7 @@ public: virtual uint opt_mark(sp_head *sp); + /* Override sp_instr_jump's shortcut; we stop here */ virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start) { return m_ip; @@ -756,7 +806,6 @@ private: Item *m_expr; // The condition sp_lex_keeper m_lex_keeper; - sp_instr *m_cont_optdest; // Used during optimization }; // class sp_instr_jump_if_not : public sp_instr_jump @@ -821,6 +870,7 @@ public: virtual uint opt_mark(sp_head *sp); + /* Override sp_instr_jump's shortcut; we stop here. */ virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start) { return m_ip; @@ -858,15 +908,6 @@ public: virtual void print(String *str); - virtual void backpatch(uint dest, sp_pcontext *dst_ctx); - - virtual uint opt_mark(sp_head *sp) - { - if (m_count) - marked= 1; - return m_ip+1; - } - private: uint m_count; @@ -898,7 +939,7 @@ private: uint m_frame; -}; // class sp_instr_hreturn : public sp_instr +}; // class sp_instr_hreturn : public sp_instr_jump /* This is DECLARE CURSOR */ @@ -952,15 +993,6 @@ public: virtual void print(String *str); - virtual void backpatch(uint dest, sp_pcontext *dst_ctx); - - virtual uint opt_mark(sp_head *sp) - { - if (m_count) - marked= 1; - return m_ip+1; - } - private: uint m_count; @@ -1084,14 +1116,18 @@ private: }; // class sp_instr_error : public sp_instr -class sp_instr_set_case_expr :public sp_instr +class sp_instr_set_case_expr : public sp_instr_opt_meta { public: sp_instr_set_case_expr(uint ip, sp_pcontext *ctx, uint case_expr_id, Item *case_expr, LEX *lex) - :sp_instr(ip, ctx), m_case_expr_id(case_expr_id), m_case_expr(case_expr), - m_lex_keeper(lex, TRUE) + : sp_instr_opt_meta(ip, ctx), + m_case_expr_id(case_expr_id), m_case_expr(case_expr), + m_lex_keeper(lex, TRUE) + {} + + virtual ~sp_instr_set_case_expr() {} virtual int execute(THD *thd, uint *nextp); @@ -1100,13 +1136,23 @@ public: virtual void print(String *str); + virtual uint opt_mark(sp_head *sp); + + virtual void opt_move(uint dst, List<sp_instr> *ibp); + + virtual void set_destination(uint old_dest, uint new_dest) + { + if (m_cont_dest == old_dest) + m_cont_dest= new_dest; + } + private: uint m_case_expr_id; Item *m_case_expr; sp_lex_keeper m_lex_keeper; -}; // class sp_instr_set_case_expr : public sp_instr +}; // class sp_instr_set_case_expr : public sp_instr_opt_meta #ifndef NO_EMBEDDED_ACCESS_CHECKS diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 215de01e657..af4e41c29be 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -164,6 +164,33 @@ sp_rcontext::set_return_value(THD *thd, Item *return_value_item) #define IS_NOT_FOUND_CONDITION(S) ((S)[0] == '0' && (S)[1] == '2') #define IS_EXCEPTION_CONDITION(S) ((S)[0] != '0' || (S)[1] > '2') +/* + Find a handler for the given errno. + This is called from all error message functions (e.g. push_warning, + net_send_error, et al) when a sp_rcontext is in effect. If a handler + is found, no error is sent, and the the SP execution loop will instead + invoke the found handler. + This might be called several times before we get back to the execution + loop, so m_hfound can be >= 0 if a handler has already been found. + (In which case we don't search again - the first found handler will + be used.) + Handlers are pushed on the stack m_handler, with the latest/innermost + one on the top; we then search for matching handlers from the top and + down. + We search through all the handlers, looking for the most specific one + (sql_errno more specific than sqlstate more specific than the rest). + Note that mysql error code handlers is a MySQL extension, not part of + the standard. + + SYNOPSIS + sql_errno The error code + level Warning level + + RETURN + 1 if a handler was found, m_hfound is set to its index (>= 0) + 0 if not found, m_hfound is -1 +*/ + bool sp_rcontext::find_handler(uint sql_errno, MYSQL_ERROR::enum_warning_level level) @@ -174,11 +201,13 @@ sp_rcontext::find_handler(uint sql_errno, const char *sqlstate= mysql_errno_to_sqlstate(sql_errno); int i= m_hcount, found= -1; + /* Search handlers from the latest (innermost) to the oldest (outermost) */ while (i--) { sp_cond_type_t *cond= m_handler[i].cond; int j= m_ihsp; + /* Check active handlers, to avoid invoking one recursively */ while (j--) if (m_in_handler[j] == m_handler[i].handler) break; @@ -188,7 +217,8 @@ sp_rcontext::find_handler(uint sql_errno, switch (cond->type) { case sp_cond_type_t::number: - if (sql_errno == cond->mysqlerr) + if (sql_errno == cond->mysqlerr && + (found < 0 || m_handler[found].cond->type > sp_cond_type_t::number)) found= i; // Always the most specific break; case sp_cond_type_t::state: diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index cfcdd6d9e61..49f05a29ef3 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3045,7 +3045,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, if (!revoke_grant) { - if (sp_exists_routine(thd, table_list, is_proc, no_error)<0) + if (sp_exist_routines(thd, table_list, is_proc, no_error)<0) DBUG_RETURN(TRUE); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 44b3a22ec52..2d6576bff8b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3858,13 +3858,37 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list, register_tree_change, actual_table); } + if (fld) + { #ifndef NO_EMBEDDED_ACCESS_CHECKS - /* Check if there are sufficient access rights to the found field. */ - if (fld && check_privileges && - check_column_grant_in_table_ref(thd, *actual_table, name, length)) - fld= WRONG_GRANT; + /* Check if there are sufficient access rights to the found field. */ + if (check_privileges && + check_column_grant_in_table_ref(thd, *actual_table, name, length)) + fld= WRONG_GRANT; + else #endif - + if (thd->set_query_id) + { + /* + * get rw_set correct for this field so that the handler + * knows that this field is involved in the query and gets + * retrieved/updated + */ + Field *field_to_set= NULL; + if (fld == view_ref_found) + { + Item *it= (*ref)->real_item(); + if (it->type() == Item::FIELD_ITEM) + field_to_set= ((Item_field*)it)->field; + } + else + field_to_set= fld; + if (field_to_set) + field_to_set->table->file-> + ha_set_bit_in_rw_set(field_to_set->fieldnr, + (bool)(thd->set_query_id-1)); + } + } DBUG_RETURN(fld); } @@ -3888,8 +3912,18 @@ Field *find_field_in_table_sef(TABLE *table, const char *name) { Field **field_ptr; if (table->s->name_hash.records) + { field_ptr= (Field**)hash_search(&table->s->name_hash,(byte*) name, strlen(name)); + if (field_ptr) + { + /* + field_ptr points to field in TABLE_SHARE. Convert it to the matching + field in table + */ + field_ptr= (table->field + (field_ptr - table->s->field)); + } + } else { if (!(field_ptr= table->field)) @@ -5044,6 +5078,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, DBUG_ENTER("setup_fields"); thd->set_query_id=set_query_id; + DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id)); if (allow_sum_func) thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level; thd->where= THD::DEFAULT_WHERE; @@ -5070,6 +5105,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, { thd->lex->allow_sum_func= save_allow_sum_func; thd->set_query_id= save_set_query_id; + DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id)); DBUG_RETURN(TRUE); /* purecov: inspected */ } if (ref) @@ -5081,6 +5117,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, } thd->lex->allow_sum_func= save_allow_sum_func; thd->set_query_id= save_set_query_id; + DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id)); DBUG_RETURN(test(thd->net.report_error)); } @@ -5527,6 +5564,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, arena= 0; // For easier test thd->set_query_id=1; + DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id)); select_lex->cond_count= 0; for (table= tables; table; table= table->next_local) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 5833842f660..e68bcb9e281 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1862,11 +1862,14 @@ bool select_dumpvar::send_eof() void TMP_TABLE_PARAM::init() { + DBUG_ENTER("TMP_TABLE_PARAM::init"); + DBUG_PRINT("enter", ("this: 0x%lx", (ulong)this)); field_count= sum_func_count= func_count= hidden_field_count= 0; group_parts= group_length= group_null_parts= 0; quick_group= 1; table_charset= 0; precomputed_group_by= 0; + DBUG_VOID_RETURN; } diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 3dcf49b4517..a7a7327bb87 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -38,6 +38,107 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, static long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path); static my_bool rm_dir_w_symlink(const char *org_path, my_bool send_error); + + +/* Database lock hash */ +HASH lock_db_cache; +pthread_mutex_t LOCK_lock_db; +int creating_database= 0; // how many database locks are made + + +/* Structure for database lock */ +typedef struct my_dblock_st +{ + char *name; /* Database name */ + uint name_length; /* Database length name */ +} my_dblock_t; + + +/* + lock_db key. +*/ + +static byte* lock_db_get_key(my_dblock_t *ptr, uint *length, + my_bool not_used __attribute__((unused))) +{ + *length= ptr->name_length; + return (byte*) ptr->name; +} + + +/* + Free lock_db hash element. +*/ + +static void lock_db_free_element(void *ptr) +{ + my_free((gptr) ptr, MYF(0)); +} + + +/* + Put a database lock entry into the hash. + + DESCRIPTION + Insert a database lock entry into hash. + LOCK_db_lock must be previously locked. + + RETURN VALUES + 0 on success. + 1 on error. +*/ + +static my_bool lock_db_insert(const char *dbname, uint length) +{ + my_dblock_t *opt; + my_bool error= 0; + DBUG_ENTER("lock_db_insert"); + + safe_mutex_assert_owner(&LOCK_lock_db); + + if (!(opt= (my_dblock_t*) hash_search(&lock_db_cache, + (byte*) dbname, length))) + { + /* Db is not in the hash, insert it */ + char *tmp_name; + if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), + &opt, (uint) sizeof(*opt), &tmp_name, length+1, + NullS)) + { + error= 1; + goto end; + } + + opt->name= tmp_name; + strmov(opt->name, dbname); + opt->name_length= length; + + if ((error= my_hash_insert(&lock_db_cache, (byte*) opt))) + { + my_free((gptr) opt, MYF(0)); + goto end; + } + } + +end: + DBUG_RETURN(error); +} + + +/* + Delete a database lock entry from hash. +*/ + +void lock_db_delete(const char *name, uint length) +{ + my_dblock_t *opt; + safe_mutex_assert_owner(&LOCK_lock_db); + opt= (my_dblock_t *)hash_search(&lock_db_cache, (const byte*) name, length); + DBUG_ASSERT(opt != NULL); + hash_delete(&lock_db_cache, (byte*) opt); +} + + /* Database options hash */ static HASH dboptions; static my_bool dboptions_init= 0; @@ -90,10 +191,10 @@ static void free_dbopt(void *dbopt) /* - Initialize database option hash + Initialize database option hash and locked database hash. SYNOPSIS - my_dbopt_init() + my_database_names() NOTES Must be called before any other database function is called. @@ -103,7 +204,7 @@ static void free_dbopt(void *dbopt) 1 Fatal error */ -bool my_dbopt_init(void) +bool my_database_names_init(void) { bool error= 0; (void) my_rwlock_init(&LOCK_dboptions, NULL); @@ -113,27 +214,38 @@ bool my_dbopt_init(void) error= hash_init(&dboptions, lower_case_table_names ? &my_charset_bin : system_charset_info, 32, 0, 0, (hash_get_key) dboptions_get_key, - free_dbopt,0); + free_dbopt,0) || + hash_init(&lock_db_cache, lower_case_table_names ? + &my_charset_bin : system_charset_info, + 32, 0, 0, (hash_get_key) lock_db_get_key, + lock_db_free_element,0); + } return error; } + /* - Free database option hash. + Free database option hash and locked databases hash. */ -void my_dbopt_free(void) +void my_database_names_free(void) { if (dboptions_init) { dboptions_init= 0; hash_free(&dboptions); (void) rwlock_destroy(&LOCK_dboptions); + hash_free(&lock_db_cache); } } +/* + Cleanup cached options +*/ + void my_dbopt_cleanup(void) { rw_wrlock(&LOCK_dboptions); @@ -395,6 +507,12 @@ err1: silent Used by replication when internally creating a database. In this case the entry should not be logged. + SIDE-EFFECTS + 1. Report back to client that command succeeded (send_ok) + 2. Report errors to client + 3. Log event to binary log + (The 'silent' flags turns off 1 and 3.) + RETURN VALUES FALSE ok TRUE Error @@ -435,17 +553,17 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, if (my_stat(path,&stat_info,MYF(0))) { - if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS)) + if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS)) { my_error(ER_DB_CREATE_EXISTS, MYF(0), db); error= -1; goto exit; } push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, - ER_DB_CREATE_EXISTS, ER(ER_DB_CREATE_EXISTS), db); - error= 0; + ER_DB_CREATE_EXISTS, ER(ER_DB_CREATE_EXISTS), db); if (!silent) send_ok(thd); + error= 0; goto exit; } else @@ -1213,3 +1331,312 @@ end: } DBUG_RETURN(0); } + + +static int +lock_databases(THD *thd, const char *db1, uint length1, + const char *db2, uint length2) +{ + pthread_mutex_lock(&LOCK_lock_db); + while (!thd->killed && + (hash_search(&lock_db_cache,(byte*) db1, length1) || + hash_search(&lock_db_cache,(byte*) db2, length2))) + { + wait_for_condition(thd, &LOCK_lock_db, &COND_refresh); + pthread_mutex_lock(&LOCK_lock_db); + } + + if (thd->killed) + { + pthread_mutex_unlock(&LOCK_lock_db); + return 1; + } + + lock_db_insert(db1, length1); + lock_db_insert(db2, length2); + creating_database++; + + /* + Wait if a concurent thread is creating a table at the same time. + The assumption here is that it will not take too long until + there is a point in time when a table is not created. + */ + + while (!thd->killed && creating_table) + { + wait_for_condition(thd, &LOCK_lock_db, &COND_refresh); + pthread_mutex_lock(&LOCK_lock_db); + } + + if (thd->killed) + { + lock_db_delete(db1, length1); + lock_db_delete(db2, length2); + creating_database--; + pthread_mutex_unlock(&LOCK_lock_db); + pthread_cond_signal(&COND_refresh); + return(1); + } + + /* + We can unlock now as the hash will protect against anyone creating a table + in the databases we are using + */ + pthread_mutex_unlock(&LOCK_lock_db); + return 0; +} + + +/* + Rename database. + + SYNOPSIS + mysql_rename_db() + thd Thread handler + olddb Old database name + newdb New database name + + DESCRIPTION + This function is invoked whenever a RENAME DATABASE query is executed: + + RENAME DATABASE 'olddb' TO 'newdb'. + + NOTES + + If we have managed to rename (move) tables to the new database + but something failed on a later step, then we store the + RENAME DATABASE event in the log. mysql_rename_db() is atomic in + the sense that it will rename all or none of the tables. + + TODO: + - Better trigger, stored procedure, event, grant handling, + see the comments below. + NOTE: It's probably a good idea to call wait_if_global_read_lock() + once in mysql_rename_db(), instead of locking inside all + the required functions for renaming triggerts, SP, events, grants, etc. + + RETURN VALUES + 0 ok + 1 error +*/ + + +bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db) +{ + int error= 0, change_to_newdb= 0; + char path[FN_REFLEN+16]; + uint length; + HA_CREATE_INFO create_info; + MY_DIR *dirp; + TABLE_LIST *table_list; + SELECT_LEX *sl= thd->lex->current_select; + DBUG_ENTER("mysql_rename_db"); + + if (lock_databases(thd, old_db->str, old_db->length, + new_db->str, new_db->length)) + return 1; + + /* + Let's remember if we should do "USE newdb" afterwards. + thd->db will be cleared in mysql_rename_db() + */ + if (thd->db && !strcmp(thd->db, old_db->str)) + change_to_newdb= 1; + + build_table_filename(path, sizeof(path)-1, old_db->str, "", MY_DB_OPT_FILE); + if ((load_db_opt(thd, path, &create_info))) + create_info.default_table_charset= thd->variables.collation_server; + + length= build_table_filename(path, sizeof(path)-1, old_db->str, "", ""); + if (length && path[length-1] == FN_LIBCHAR) + path[length-1]=0; // remove ending '\' + if ((error= my_access(path,F_OK))) + { + my_error(ER_BAD_DB_ERROR, MYF(0), old_db->str); + goto exit; + } + + /* Step1: Create the new database */ + if ((error= mysql_create_db(thd, new_db->str, &create_info, 1))) + goto exit; + + /* Step2: Move tables to the new database */ + if ((dirp = my_dir(path,MYF(MY_DONT_SORT)))) + { + uint nfiles= (uint) dirp->number_off_files; + for (uint idx=0 ; idx < nfiles && !thd->killed ; idx++) + { + FILEINFO *file= dirp->dir_entry + idx; + char *extension, tname[FN_REFLEN]; + LEX_STRING table_str; + DBUG_PRINT("info",("Examining: %s", file->name)); + + /* skiping non-FRM files */ + if (my_strcasecmp(files_charset_info, + (extension= fn_rext(file->name)), reg_ext)) + continue; + + /* A frm file found, add the table info rename list */ + *extension= '\0'; + + table_str.length= filename_to_tablename(file->name, + tname, sizeof(tname)-1); + table_str.str= sql_memdup(tname, table_str.length + 1); + Table_ident *old_ident= new Table_ident(thd, *old_db, table_str, 0); + Table_ident *new_ident= new Table_ident(thd, *new_db, table_str, 0); + if (!old_ident || !new_ident || + !sl->add_table_to_list(thd, old_ident, NULL, + TL_OPTION_UPDATING, TL_IGNORE) || + !sl->add_table_to_list(thd, new_ident, NULL, + TL_OPTION_UPDATING, TL_IGNORE)) + { + error= 1; + my_dirend(dirp); + goto exit; + } + } + my_dirend(dirp); + } + + if ((table_list= thd->lex->query_tables) && + (error= mysql_rename_tables(thd, table_list, 1))) + { + /* + Failed to move all tables from the old database to the new one. + In the best case mysql_rename_tables() moved all tables back to the old + database. In the worst case mysql_rename_tables() moved some tables + to the new database, then failed, then started to move the tables back, and + then failed again. In this situation we have some tables in the + old database and some tables in the new database. + Let's delete the option file, and then the new database directory. + If some tables were left in the new directory, rmdir() will fail. + It garantees we never loose any tables. + */ + build_table_filename(path, sizeof(path)-1, new_db->str,"",MY_DB_OPT_FILE); + my_delete(path, MYF(MY_WME)); + length= build_table_filename(path, sizeof(path)-1, new_db->str, "", ""); + if (length && path[length-1] == FN_LIBCHAR) + path[length-1]=0; // remove ending '\' + rmdir(path); + goto exit; + } + + + /* + Step3: move all remaining files to the new db's directory. + Skip db opt file: it's been created by mysql_create_db() in + the new directory, and will be dropped by mysql_rm_db() in the old one. + Trigger TRN and TRG files are be moved as regular files at the moment, + without any special treatment. + + Triggers without explicit database qualifiers in table names work fine: + use d1; + create trigger trg1 before insert on t2 for each row set @a:=1 + rename database d1 to d2; + + TODO: Triggers, having the renamed database explicitely written + in the table qualifiers. + 1. when the same database is renamed: + create trigger d1.trg1 before insert on d1.t1 for each row set @a:=1; + rename database d1 to d2; + Problem: After database renaming, the trigger's body + still points to the old database d1. + 2. when another database is renamed: + create trigger d3.trg1 before insert on d3.t1 for each row + insert into d1.t1 values (...); + rename database d1 to d2; + Problem: After renaming d1 to d2, the trigger's body + in the database d3 still points to database d1. + */ + + if ((dirp = my_dir(path,MYF(MY_DONT_SORT)))) + { + uint nfiles= (uint) dirp->number_off_files; + for (uint idx=0 ; idx < nfiles ; idx++) + { + FILEINFO *file= dirp->dir_entry + idx; + char oldname[FN_REFLEN], newname[FN_REFLEN]; + DBUG_PRINT("info",("Examining: %s", file->name)); + + /* skiping . and .. and MY_DB_OPT_FILE */ + if ((file->name[0] == '.' && + (!file->name[1] || (file->name[1] == '.' && !file->name[2]))) || + !my_strcasecmp(files_charset_info, file->name, MY_DB_OPT_FILE)) + continue; + + /* pass empty file name, and file->name as extension to avoid encoding */ + build_table_filename(oldname, sizeof(oldname)-1, + old_db->str, "", file->name); + build_table_filename(newname, sizeof(newname)-1, + new_db->str, "", file->name); + my_rename(oldname, newname, MYF(MY_WME)); + } + my_dirend(dirp); + } + + /* + Step4: TODO: moving stored procedures in the 'proc' system table + We need a new function: sp_move_db_routines(thd, olddb, newdb) + Which will basically have the same effect with: + UPDATE proc SET db='newdb' WHERE db='olddb' + Note, for 5.0 to 5.1 upgrade purposes we don't really need it. + + The biggest problem here is that we can't have a lock on LOCK_open() while + calling open_table() for 'proc'. + + Two solutions: + - Start by opening the 'event' and 'proc' (and other) tables for write + even before creating the 'to' database. (This will have the nice + effect of blocking another 'rename database' while the lock is active). + - Use the solution "Disable create of new tables during lock table" + + For an example of how to read through all rows, see: + sql_help.cc::search_topics() + */ + + /* + Step5: TODO: moving events in the 'event' system table + We need a new function evex_move_db_events(thd, olddb, newdb) + Which will have the same effect with: + UPDATE event SET db='newdb' WHERE db='olddb' + Note, for 5.0 to 5.1 upgrade purposes we don't really need it. + */ + + /* + Step6: TODO: moving grants in the 'db', 'tables_priv', 'columns_priv'. + Update each grant table, doing the same with: + UPDATE system_table SET db='newdb' WHERE db='olddb' + */ + + /* + Step7: drop the old database. + remove_db_from_cache(olddb) and query_cache_invalidate(olddb) + are done inside mysql_rm_db(), no needs to execute them again. + mysql_rm_db() also "unuses" if we drop the current database. + */ + error= mysql_rm_db(thd, old_db->str, 0, 1); + + /* Step8: logging */ + if (mysql_bin_log.is_open()) + { + Query_log_event qinfo(thd, thd->query, thd->query_length, 0, TRUE); + thd->clear_error(); + mysql_bin_log.write(&qinfo); + } + + /* Step9: Let's do "use newdb" if we renamed the current database */ + if (change_to_newdb) + error|= mysql_change_db(thd, new_db->str, 0); + +exit: + pthread_mutex_lock(&LOCK_lock_db); + /* Remove the databases from db lock cache */ + lock_db_delete(old_db->str, old_db->length); + lock_db_delete(new_db->str, new_db->length); + creating_database--; + /* Signal waiting CREATE TABLE's to continue */ + pthread_cond_signal(&COND_refresh); + pthread_mutex_unlock(&LOCK_lock_db); + + DBUG_RETURN(error); +} diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index a9050ddf277..20c71ae738b 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1128,7 +1128,7 @@ void st_select_lex::init_query() embedding= leaf_tables= 0; item_list.empty(); join= 0; - having= where= prep_where= 0; + having= prep_having= where= prep_where= 0; olap= UNSPECIFIED_OLAP_TYPE; having_fix_field= 0; context.select_lex= this; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 07a42f7af2c..bf4bf272f4d 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -67,6 +67,7 @@ enum enum_sql_command { SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES, SQLCOM_GRANT, SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_ALTER_DB, + SQLCOM_RENAME_DB, SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT, SQLCOM_CREATE_FUNCTION, SQLCOM_DROP_FUNCTION, SQLCOM_REVOKE,SQLCOM_OPTIMIZE, SQLCOM_CHECK, @@ -493,6 +494,7 @@ public: char *db; Item *where, *having; /* WHERE & HAVING clauses */ Item *prep_where; /* saved WHERE clause for prepared statement processing */ + Item *prep_having;/* saved HAVING clause for prepared statement processing */ /* point on lex in which it was created, used in view subquery detection */ st_lex *parent_lex; enum olap_type olap; @@ -817,6 +819,7 @@ typedef struct st_lex required a local context, the parser pops the top-most context. */ List<Name_resolution_context> context_stack; + List<LEX_STRING> db_list; SQL_LIST proc_list, auxilliary_table_list, save_list; create_field *last_field; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 279a02fa1d1..afb0aaed0d7 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3073,7 +3073,7 @@ end_with_restore_list: } } query_cache_invalidate3(thd, first_table, 0); - if (end_active_trans(thd) || mysql_rename_tables(thd, first_table)) + if (end_active_trans(thd) || mysql_rename_tables(thd, first_table, 0)) goto error; break; } @@ -3663,6 +3663,48 @@ end_with_restore_list: res= mysql_rm_db(thd, lex->name, lex->drop_if_exists, 0); break; } + case SQLCOM_RENAME_DB: + { + LEX_STRING *olddb, *newdb; + List_iterator <LEX_STRING> db_list(lex->db_list); + olddb= db_list++; + newdb= db_list++; + if (end_active_trans(thd)) + { + res= 1; + break; + } +#ifdef HAVE_REPLICATION + if (thd->slave_thread && + (!rpl_filter->db_ok(olddb->str) || + !rpl_filter->db_ok(newdb->str) || + !rpl_filter->db_ok_with_wild_table(olddb->str) || + !rpl_filter->db_ok_with_wild_table(newdb->str))) + { + res= 1; + my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0)); + break; + } +#endif + if (check_access(thd,ALTER_ACL,olddb->str,0,1,0,is_schema_db(olddb->str)) || + check_access(thd,DROP_ACL,olddb->str,0,1,0,is_schema_db(olddb->str)) || + check_access(thd,CREATE_ACL,newdb->str,0,1,0,is_schema_db(newdb->str))) + { + res= 1; + break; + } + if (thd->locked_tables || thd->active_transaction()) + { + res= 1; + my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, + ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0)); + goto error; + } + res= mysql_rename_db(thd, olddb, newdb); + if (!res) + send_ok(thd); + break; + } case SQLCOM_ALTER_DB: { char *db= lex->name ? lex->name : thd->db; @@ -3743,6 +3785,8 @@ end_with_restore_list: res= evex_drop_event(thd, lex->et, lex->drop_if_exists, &rows_affected); default:; } + DBUG_PRINT("info", ("CREATE/ALTER/DROP returned error code=%d af_rows=%d", + res, rows_affected)); if (!res) send_ok(thd, rows_affected); @@ -4490,21 +4534,17 @@ end_with_restore_list: case SQLCOM_DROP_PROCEDURE: case SQLCOM_DROP_FUNCTION: { - sp_head *sp; int result; - char *db, *name; + int type= (lex->sql_command == SQLCOM_DROP_PROCEDURE ? + TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION); - if (lex->sql_command == SQLCOM_DROP_PROCEDURE) - sp= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname, - &thd->sp_proc_cache, FALSE); - else - sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, lex->spname, - &thd->sp_func_cache, FALSE); + result= sp_routine_exists_in_table(thd, type, lex->spname); mysql_reset_errors(thd, 0); - if (sp) + if (result == SP_OK) { - db= thd->strdup(sp->m_db.str); - name= thd->strdup(sp->m_name.str); + char *db= lex->spname->m_db.str; + char *name= lex->spname->m_name.str; + if (check_routine_access(thd, ALTER_PROC_ACL, db, name, lex->sql_command == SQLCOM_DROP_PROCEDURE, 0)) goto error; @@ -4644,7 +4684,7 @@ end_with_restore_list: else sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, lex->spname, &thd->sp_func_cache, FALSE); - if (!sp || !sp->show_routine_code(thd)) + if (!sp || sp->show_routine_code(thd)) { /* We don't distinguish between errors for now */ my_error(ER_SP_DOES_NOT_EXIST, MYF(0), diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index aec0d2108ed..290d512198f 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -250,14 +250,14 @@ char *are_partitions_in_table(partition_info *new_part_info, FALSE Success */ -bool partition_default_handling(TABLE *table, partition_info *part_info) +bool partition_default_handling(TABLE *table, partition_info *part_info, + const char *normalized_path) { DBUG_ENTER("partition_default_handling"); if (part_info->use_default_no_partitions) { - if (table->file->get_no_parts(table->s->normalized_path.str, - &part_info->no_parts)) + if (table->file->get_no_parts(normalized_path, &part_info->no_parts)) { DBUG_RETURN(TRUE); } @@ -266,8 +266,7 @@ bool partition_default_handling(TABLE *table, partition_info *part_info) part_info->use_default_no_subpartitions) { uint no_parts; - if (table->file->get_no_parts(table->s->normalized_path.str, - &no_parts)) + if (table->file->get_no_parts(normalized_path, &no_parts)) { DBUG_RETURN(TRUE); } @@ -1985,6 +1984,7 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table, DBUG_RETURN(FALSE); } thd->set_query_id= 0; + DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id)); /* Set-up the TABLE_LIST object to be a list with a single table Set the object to zero to create NULL pointers and set alias @@ -2005,7 +2005,8 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table, if (!is_create_table_ind) { - if (partition_default_handling(table, part_info)) + if (partition_default_handling(table, part_info, + table->s->normalized_path.str)) { DBUG_RETURN(TRUE); } @@ -2120,6 +2121,7 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table, result= FALSE; end: thd->set_query_id= save_set_query_id; + DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id)); DBUG_RETURN(result); } @@ -2397,7 +2399,9 @@ char *generate_partition_syntax(partition_info *part_info, DBUG_ENTER("generate_partition_syntax"); write_part_state= (part_info->part_state && !part_info->part_state_len); - if (unlikely(((fptr= create_temp_file(path,mysql_tmpdir,"psy", 0,0))) < 0)) + if (unlikely(((fptr= create_temp_file(path,mysql_tmpdir,"psy", + O_RDWR | O_BINARY | O_TRUNC | + O_TEMPORARY, MYF(MY_WME)))) < 0)) DBUG_RETURN(NULL); #ifndef __WIN__ unlink(path); @@ -3901,9 +3905,15 @@ bool mysql_unpack_partition(THD *thd, const uchar *part_buf, old_lex->name contains the t2 and the table we are opening has name t1. */ - if (partition_default_handling(table, part_info)) + Table_ident *table_ident= (Table_ident *)old_lex->name; + char *src_db= table_ident->db.str ? table_ident->db.str : thd->db; + char *src_table= table_ident->table.str; + char buf[FN_REFLEN]; + build_table_filename(buf, sizeof(buf), src_db, src_table, ""); + if (partition_default_handling(table, part_info, buf)) { - DBUG_RETURN(TRUE); + result= TRUE; + goto end; } } else diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 9fee7abb619..8c5579d978b 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -354,7 +354,7 @@ struct st_plugin_int *plugin_lock(LEX_STRING *name, int type) rw_wrlock(&THR_LOCK_plugin); if ((rc= plugin_find_internal(name, type))) { - if (rc->state == PLUGIN_IS_READY) + if (rc->state == PLUGIN_IS_READY || rc->state == PLUGIN_IS_UNINITIALIZED) rc->ref_count++; else rc= 0; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index cb080ba68e0..1b9cca9d84f 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -411,7 +411,7 @@ static void set_param_decimal(Item_param *param, uchar **pos, ulong len) { ulong length= get_param_length(pos, len); param->set_decimal((char*)*pos, length); - *pos+= len; + *pos+= length; } #ifndef EMBEDDED_LIBRARY @@ -2075,14 +2075,19 @@ void reinit_stmt_before_use(THD *thd, LEX *lex) sl->exclude_from_table_unique_test= FALSE; /* - Copy WHERE clause pointers to avoid damaging they by optimisation + Copy WHERE, HAVING clause pointers to avoid damaging them by optimisation */ - if (sl->prep_where) - { - sl->where= sl->prep_where->copy_andor_structure(thd); - sl->where->cleanup(); - } - DBUG_ASSERT(sl->join == 0); + if (sl->prep_where) + { + sl->where= sl->prep_where->copy_andor_structure(thd); + sl->where->cleanup(); + } + if (sl->prep_having) + { + sl->having= sl->prep_having->copy_andor_structure(thd); + sl->having->cleanup(); + } + DBUG_ASSERT(sl->join == 0); ORDER *order; /* Fix GROUP list */ for (order= (ORDER *)sl->group_list.first; order; order= order->next) diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 150c1dba1c9..5f20442cc84 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -31,7 +31,7 @@ static TABLE_LIST *reverse_table_list(TABLE_LIST *table_list); second entry is the new name. */ -bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list) +bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent) { bool error= 1; TABLE_LIST *ren_table= 0; @@ -79,7 +79,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list) } /* Lets hope this doesn't fail as the result will be messy */ - if (!error) + if (!silent && !error) { if (mysql_bin_log.is_open()) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 47aa53d25e2..cafcd94632a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -612,6 +612,7 @@ JOIN::optimize() build_bitmap_for_nested_joins(join_list, 0); sel->prep_where= conds ? conds->copy_andor_structure(thd) : 0; + sel->prep_having= having ? having->copy_andor_structure(thd) : 0; if (arena) thd->restore_active_arena(arena, &backup); @@ -625,13 +626,26 @@ JOIN::optimize() DBUG_RETURN(1); } - if (cond_value == Item::COND_FALSE || - (!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS))) - { /* Impossible cond */ - DBUG_PRINT("info", ("Impossible WHERE")); - zero_result_cause= "Impossible WHERE"; - error= 0; - DBUG_RETURN(0); + { + Item::cond_result having_value; + having= optimize_cond(this, having, join_list, &having_value); + if (thd->net.report_error) + { + error= 1; + DBUG_PRINT("error",("Error from optimize_cond")); + DBUG_RETURN(1); + } + + if (cond_value == Item::COND_FALSE || having_value == Item::COND_FALSE || + (!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS))) + { /* Impossible cond */ + DBUG_PRINT("info", (having_value == Item::COND_FALSE ? + "Impossible HAVING" : "Impossible WHERE")); + zero_result_cause= having_value == Item::COND_FALSE ? + "Impossible HAVING" : "Impossible WHERE"; + error= 0; + DBUG_RETURN(0); + } } #ifdef WITH_PARTITION_STORAGE_ENGINE @@ -2214,7 +2228,8 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds, if (eq_part.is_prefix(table->key_info[key].key_parts) && ((table->key_info[key].flags & (HA_NOSAME | HA_END_SPACE_KEY)) == HA_NOSAME) && - !table->fulltext_searched) + !table->fulltext_searched && + !table->pos_in_table_list->embedding) { if (const_ref == eq_part) { // Found everything for ref. @@ -6063,6 +6078,20 @@ void JOIN::cleanup(bool full) problems in free_elements() as some of the elements are then deleted. */ tmp_table_param.copy_funcs.empty(); + /* + If we have tmp_join and 'this' JOIN is not tmp_join and + tmp_table_param.copy_field's of them are equal then we have to remove + pointer to tmp_table_param.copy_field from tmp_join, because it qill + be removed in tmp_table_param.cleanup(). + */ + if (tmp_join && + tmp_join != this && + tmp_join->tmp_table_param.copy_field == + tmp_table_param.copy_field) + { + tmp_join->tmp_table_param.copy_field= + tmp_join->tmp_table_param.save_copy_field= 0; + } tmp_table_param.cleanup(); } DBUG_VOID_RETURN; @@ -12457,7 +12486,8 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, overshadows the column reference from the SELECT list. */ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_NON_UNIQ_ERROR, - ER(ER_NON_UNIQ_ERROR), from_field->field_name, + ER(ER_NON_UNIQ_ERROR), + ((Item_ident*) order_item)->field_name, current_thd->where); } } diff --git a/sql/sql_select.h b/sql/sql_select.h index 523182d96cd..4f93a4aa996 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -286,7 +286,14 @@ class JOIN :public Sql_alloc { init(thd_arg, fields_arg, select_options_arg, result_arg); } - + + JOIN(JOIN &join) + :fields_list(join.fields_list) + { + init(join.thd, join.fields_list, join.select_options, + join.result); + } + void init(THD *thd_arg, List<Item> &fields_arg, ulonglong select_options_arg, select_result *result_arg) { @@ -333,7 +340,7 @@ class JOIN :public Sql_alloc all_fields= fields_arg; fields_list= fields_arg; bzero((char*) &keyuse,sizeof(keyuse)); - tmp_table_param.copy_field=0; + tmp_table_param.init(); tmp_table_param.end_write_records= HA_POS_ERROR; rollup.state= ROLLUP::STATE_NONE; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index d30ce8d6b59..387e5e4fcfb 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1138,7 +1138,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, to the CREATE TABLE statement */ - if ((for_str= file->get_tablespace_name())) + if ((for_str= file->get_tablespace_name(thd))) { packet->append(" TABLESPACE "); packet->append(for_str, strlen(for_str)); @@ -1234,15 +1234,6 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, packet->append(STRING_WITH_LEN(" CONNECTION=")); append_unescaped(packet, share->connect_string.str, share->connect_string.length); } - if (file->raid_type) - { - uint length; - length= my_snprintf(buff,sizeof(buff), - " RAID_TYPE=%s RAID_CHUNKS=%d RAID_CHUNKSIZE=%ld", - my_raid_type(file->raid_type), file->raid_chunks, - file->raid_chunksize/RAID_BLOCK_SIZE); - packet->append(buff, length); - } append_directory(thd, packet, "DATA", create_info.data_file_name); append_directory(thd, packet, "INDEX", create_info.index_file_name); } @@ -2591,15 +2582,6 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables, ptr=strxmov(ptr, " row_format=", ha_row_type[(uint) share->row_type], NullS); - if (file->raid_type) - { - char buff[100]; - my_snprintf(buff,sizeof(buff), - " raid_type=%s raid_chunks=%d raid_chunksize=%ld", - my_raid_type(file->raid_type), file->raid_chunks, - file->raid_chunksize/RAID_BLOCK_SIZE); - ptr=strmov(ptr,buff); - } table->field[19]->store(option_buff+1, (ptr == option_buff ? 0 : (uint) (ptr-option_buff)-1), cs); @@ -4005,7 +3987,7 @@ int fill_schema_events(THD *thd, TABLE_LIST *tables, COND *cond) store(thd->lex->select_lex.db, strlen(thd->lex->select_lex.db), scs); key_len+= event_table->key_info->key_part[1].store_length; } - if (!(key_buf= alloc_root(thd->mem_root, key_len))) + if (!(key_buf= (byte *)alloc_root(thd->mem_root, key_len))) { ret= 1; goto err; @@ -5073,12 +5055,12 @@ ST_SCHEMA_TABLE schema_tables[]= fill_schema_table_privileges, 0, 0, -1, -1, 0}, {"TRIGGERS", triggers_fields_info, create_schema_table, get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0}, + {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table, + fill_schema_user_privileges, 0, 0, -1, -1, 0}, {"VARIABLES", variables_fields_info, create_schema_table, fill_variables, make_old_format, 0, -1, -1, 1}, {"VIEWS", view_fields_info, create_schema_table, get_all_tables, 0, get_schema_views_record, 1, 2, 0}, - {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table, - fill_schema_user_privileges, 0, 0, -1, -1, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0} }; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e1a83a4ecf8..92ade0ff43b 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -28,6 +28,8 @@ #include <io.h> #endif +int creating_table= 0; // How many mysql_create_table are running + const char *primary_key_name="PRIMARY"; static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end); @@ -1973,7 +1975,7 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field) Create a table SYNOPSIS - mysql_create_table() + mysql_create_table_internal() thd Thread object db Database table_name Table name @@ -1996,11 +1998,12 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field) TRUE error */ -bool mysql_create_table(THD *thd,const char *db, const char *table_name, - HA_CREATE_INFO *create_info, - List<create_field> &fields, - List<Key> &keys,bool internal_tmp_table, - uint select_field_count) +bool mysql_create_table_internal(THD *thd, + const char *db, const char *table_name, + HA_CREATE_INFO *create_info, + List<create_field> &fields, + List<Key> &keys,bool internal_tmp_table, + uint select_field_count) { char path[FN_REFLEN]; uint path_length; @@ -2009,7 +2012,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, KEY *key_info_buffer; handler *file; bool error= TRUE; - DBUG_ENTER("mysql_create_table"); + DBUG_ENTER("mysql_create_table_internal"); /* Check for duplicate fields and check type of table to create */ if (!fields.elements) @@ -2289,6 +2292,49 @@ warn: goto unlock_and_end; } + +/* + Database locking aware wrapper for mysql_create_table_internal(), +*/ + +bool mysql_create_table(THD *thd, const char *db, const char *table_name, + HA_CREATE_INFO *create_info, + List<create_field> &fields, + List<Key> &keys,bool internal_tmp_table, + uint select_field_count) +{ + bool result; + DBUG_ENTER("mysql_create_table"); + + /* Wait for any database locks */ + pthread_mutex_lock(&LOCK_lock_db); + while (!thd->killed && + hash_search(&lock_db_cache,(byte*) db, strlen(db))) + { + wait_for_condition(thd, &LOCK_lock_db, &COND_refresh); + pthread_mutex_lock(&LOCK_lock_db); + } + + if (thd->killed) + { + pthread_mutex_unlock(&LOCK_lock_db); + DBUG_RETURN(TRUE); + } + creating_table++; + pthread_mutex_unlock(&LOCK_lock_db); + + result= mysql_create_table_internal(thd, db, table_name, create_info, + fields, keys, internal_tmp_table, + select_field_count); + + pthread_mutex_lock(&LOCK_lock_db); + if (!--creating_table && creating_database) + pthread_cond_signal(&COND_refresh); + pthread_mutex_unlock(&LOCK_lock_db); + DBUG_RETURN(result); +} + + /* ** Give the key name after the first field with an optional '_#' after **/ diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index f653033b9cb..0198dba780d 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -195,10 +195,8 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) /* There is no DETERMINISTIC clause for triggers, so can't check it. But a trigger can in theory be used to do nasty things (if it supported - DROP for example) so we do the check for privileges. For now there is - already a stronger test right above; but when this stronger test will - be removed, the test below will hold. Because triggers have the same - nature as functions regarding binlogging: their body is implicitely + DROP for example) so we do the check for privileges. Triggers have the + same nature as functions regarding binlogging: their body is implicitely binlogged, so they share the same danger, so trust_function_creators applies to them too. */ @@ -1183,7 +1181,7 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event, my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), priv_desc, thd->security_ctx->priv_user, thd->security_ctx->host_or_ip, - table->s->table_name); + table->s->table_name.str); sp_restore_security_context(thd, save_ctx); return TRUE; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index d6bf01f5a25..b1abf2c0777 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -331,7 +331,6 @@ int mysql_update(THD *thd, SORT_FIELD *sortorder; ha_rows examined_rows; - used_index= MAX_KEY; // For call to init_read_record() table->sort.io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE), MYF(MY_FAE | MY_ZEROFILL)); if (!(sortorder=make_unireg_sortorder(order, &length)) || @@ -362,7 +361,21 @@ int mysql_update(THD *thd, if (open_cached_file(&tempfile, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, MYF(MY_WME))) goto err; - + + /* If quick select is used, initialize it before retrieving rows. */ + if (select && select->quick && select->quick->reset()) + goto err; + + /* + When we get here, we have one of the following options: + A. used_index == MAX_KEY + This means we should use full table scan, and start it with + init_read_record call + B. used_index != MAX_KEY + B.1 quick select is used, start the scan with init_read_record + B.2 quick select is not used, this is full index scan (with LIMIT) + Full index scan must be started with init_read_record_idx + */ /* If quick select is used, initialize it before retrieving rows. */ if (select && select->quick && select->quick->reset()) goto err; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 78497a2cf8b..c4cb9770e14 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1338,6 +1338,7 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view) */ bool save_set_query_id= thd->set_query_id; thd->set_query_id= 0; + DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id)); for (Field_translator *fld= trans; fld < end_of_trans; fld++) { if (!fld->item->fixed && fld->item->fix_fields(thd, &fld->item)) @@ -1347,6 +1348,7 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view) } } thd->set_query_id= save_set_query_id; + DBUG_PRINT("info", ("thd->set_query_id: %d", thd->set_query_id)); } /* Loop over all keys to see if a unique-not-null key is used */ for (;key_info != key_info_end ; key_info++) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index cded92618ec..e7e258ca3bd 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -516,11 +516,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token QUARTER_SYM %token QUERY_SYM %token QUICK -%token RAID_0_SYM -%token RAID_CHUNKS -%token RAID_CHUNKSIZE -%token RAID_STRIPED_SYM -%token RAID_TYPE %token RAND %token RANGE_SYM %token READS_SYM @@ -753,7 +748,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); union_opt select_derived_init option_type2 %type <ulong_num> - ulong_num raid_types merge_insert_types + ulong_num merge_insert_types %type <ulonglong_number> ulonglong_num size_number @@ -868,7 +863,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); clear_privileges flush_options flush_option equal optional_braces opt_key_definition key_usage_list2 opt_mi_check_type opt_to mi_check_types normal_join - table_to_table_list table_to_table opt_table_list opt_as + db_to_db table_to_table_list table_to_table opt_table_list opt_as handler_rkey_function handler_read_or_scan single_multi table_wild_list table_wild_one opt_wild union_clause union_list @@ -2361,7 +2356,7 @@ sp_proc_stmt_return: LEX *lex= Lex; sp_head *sp= lex->sphead; - if (sp->m_type == TYPE_ENUM_PROCEDURE) + if (sp->m_type != TYPE_ENUM_FUNCTION) { my_message(ER_SP_BADRETURN, ER(ER_SP_BADRETURN), MYF(0)); YYABORT; @@ -2400,17 +2395,18 @@ sp_proc_stmt_case: sp_head *sp= lex->sphead; sp_pcontext *parsing_ctx= lex->spcont; int case_expr_id= parsing_ctx->register_case_expr(); + sp_instr_set_case_expr *i; if (parsing_ctx->push_case_expr_id(case_expr_id)) YYABORT; - - sp->add_instr( - new sp_instr_set_case_expr(sp->instructions(), - parsing_ctx, - case_expr_id, - $3, - lex)); - + + i= new sp_instr_set_case_expr(sp->instructions(), + parsing_ctx, + case_expr_id, + $3, + lex); + sp->add_cont_backpatch(i); + sp->add_instr(i); sp->m_flags|= sp_head::IN_SIMPLE_CASE; sp->restore_lex(YYTHD); } @@ -2450,17 +2446,16 @@ sp_proc_stmt_leave: } else { - uint ip= sp->instructions(); sp_instr_jump *i; - sp_instr_hpop *ih; - sp_instr_cpop *ic; + uint ip= sp->instructions(); + uint n; - ih= new sp_instr_hpop(ip++, ctx, 0); - sp->push_backpatch(ih, lab); - sp->add_instr(ih); - ic= new sp_instr_cpop(ip++, ctx, 0); - sp->push_backpatch(ic, lab); - sp->add_instr(ic); + n= ctx->diff_handlers(lab->ctx); + if (n) + sp->add_instr(new sp_instr_hpop(ip++, ctx, n)); + n= ctx->diff_cursors(lab->ctx); + if (n) + sp->add_instr(new sp_instr_cpop(ip++, ctx, n)); i= new sp_instr_jump(ip, ctx); sp->push_backpatch(i, lab); /* Jumping forward */ sp->add_instr(i); @@ -3996,7 +3991,6 @@ create_table_options: create_table_option: ENGINE_SYM opt_equal storage_engines { Lex->create_info.db_type= $3; Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE; } - | TYPE_SYM opt_equal storage_engines { Lex->create_info.db_type= $3; WARN_DEPRECATED("TYPE=storage_engine","ENGINE=storage_engine"); Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE; } | MAX_ROWS opt_equal ulonglong_num { Lex->create_info.max_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;} | MIN_ROWS opt_equal ulonglong_num { Lex->create_info.min_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;} | AVG_ROW_LENGTH opt_equal ulong_num { Lex->create_info.avg_row_length=$3; Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;} @@ -4027,21 +4021,6 @@ create_table_option: | CHECKSUM_SYM opt_equal ulong_num { Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM; Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM; } | DELAY_KEY_WRITE_SYM opt_equal ulong_num { Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE; Lex->create_info.used_fields|= HA_CREATE_USED_DELAY_KEY_WRITE; } | ROW_FORMAT_SYM opt_equal row_types { Lex->create_info.row_type= $3; Lex->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT; } - | RAID_TYPE opt_equal raid_types - { - my_error(ER_WARN_DEPRECATED_SYNTAX, MYF(0), "RAID_TYPE", "PARTITION"); - YYABORT; - } - | RAID_CHUNKS opt_equal ulong_num - { - my_error(ER_WARN_DEPRECATED_SYNTAX, MYF(0), "RAID_CHUNKS", "PARTITION"); - YYABORT; - } - | RAID_CHUNKSIZE opt_equal ulong_num - { - my_error(ER_WARN_DEPRECATED_SYNTAX, MYF(0), "RAID_CHUNKSIZE", "PARTITION"); - YYABORT; - } | UNION_SYM opt_equal '(' table_list ')' { /* Move the union list to the merge_list */ @@ -4121,11 +4100,6 @@ row_types: | REDUNDANT_SYM { $$= ROW_TYPE_REDUNDANT; } | COMPACT_SYM { $$= ROW_TYPE_COMPACT; }; -raid_types: - RAID_STRIPED_SYM { $$= RAID_TYPE_0; } - | RAID_0_SYM { $$= RAID_TYPE_0; } - | ulong_num { $$=$1;}; - merge_insert_types: NO_SYM { $$= MERGE_INSERT_DISABLED; } | FIRST_SYM { $$= MERGE_INSERT_TO_FIRST; } @@ -5511,6 +5485,13 @@ rename: } table_to_table_list {} + | RENAME DATABASE + { + Lex->db_list.empty(); + Lex->sql_command= SQLCOM_RENAME_DB; + } + db_to_db + {} | RENAME USER clear_privileges rename_list { Lex->sql_command = SQLCOM_RENAME_USER; @@ -5546,6 +5527,17 @@ table_to_table: YYABORT; }; +db_to_db: + ident TO_SYM ident + { + LEX *lex=Lex; + if (Lex->db_list.push_back((LEX_STRING*) + sql_memdup(&$1, sizeof(LEX_STRING))) || + Lex->db_list.push_back((LEX_STRING*) + sql_memdup(&$3, sizeof(LEX_STRING)))) + YYABORT; + }; + keycache: CACHE_SYM INDEX_SYM keycache_list IN_SYM key_cache_name { @@ -9496,11 +9488,6 @@ keyword_sp: | QUARTER_SYM {} | QUERY_SYM {} | QUICK {} - | RAID_0_SYM {} - | RAID_CHUNKS {} - | RAID_CHUNKSIZE {} - | RAID_STRIPED_SYM {} - | RAID_TYPE {} | REBUILD_SYM {} | RECOVER_SYM {} | REDO_BUFFER_SIZE_SYM {} diff --git a/sql/table.cc b/sql/table.cc index b7920d0d530..7e12d42ac57 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -438,9 +438,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, { share->avg_row_length= uint4korr(head+34); share-> row_type= (row_type) head[40]; - share->raid_type= head[41]; - share->raid_chunks= head[42]; - share->raid_chunksize= uint4korr(head+43); share->table_charset= get_charset((uint) head[38],MYF(0)); share->null_field_first= 1; } @@ -2021,12 +2018,6 @@ File create_frm(THD *thd, const char *name, const char *db, if (create_info->min_rows > UINT_MAX32) create_info->min_rows= UINT_MAX32; - /* - Ensure that raid_chunks can't be larger than 255, as this would cause - problems with drop database - */ - set_if_smaller(create_info->raid_chunks, 255); - if ((file= my_create(name, CREATE_MODE, create_flags, MYF(0))) >= 0) { uint key_length, tmp_key_length; @@ -2059,9 +2050,13 @@ File create_frm(THD *thd, const char *name, const char *db, 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; - int4store(fileinfo+43,create_info->raid_chunksize); + /* Next few bytes were for RAID support */ + fileinfo[41]= 0; + fileinfo[42]= 0; + fileinfo[43]= 0; + fileinfo[44]= 0; + fileinfo[45]= 0; + fileinfo[46]= 0; int4store(fileinfo+47, key_length); tmp= MYSQL_VERSION_ID; // Store to avoid warning from int4store int4store(fileinfo+51, tmp); @@ -2098,9 +2093,6 @@ void update_create_info_from_table(HA_CREATE_INFO *create_info, TABLE *table) create_info->table_options= share->db_create_options; create_info->avg_row_length= share->avg_row_length; create_info->row_type= share->row_type; - create_info->raid_type= share->raid_type; - create_info->raid_chunks= share->raid_chunks; - create_info->raid_chunksize= share->raid_chunksize; create_info->default_table_charset= share->table_charset; create_info->table_charset= 0; diff --git a/sql/table.h b/sql/table.h index a799d4389fb..3a017983ff9 100644 --- a/sql/table.h +++ b/sql/table.h @@ -354,9 +354,9 @@ enum enum_schema_tables SCH_TABLE_NAMES, SCH_TABLE_PRIVILEGES, SCH_TRIGGERS, + SCH_USER_PRIVILEGES, SCH_VARIABLES, - SCH_VIEWS, - SCH_USER_PRIVILEGES + SCH_VIEWS }; diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 17c842f43e0..bc228d5c767 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -92,7 +92,9 @@ handlerton tina_hton= { NULL, /* Alter table flags */ NULL, /* Alter Tablespace */ NULL, /* Fill FILES Table */ - HTON_CAN_RECREATE + HTON_CAN_RECREATE, + NULL, /* binlog_func */ + NULL /* binlog_log_query */ }; /***************************************************************************** @@ -1018,6 +1020,12 @@ int ha_tina::create(const char *name, TABLE *table_arg, DBUG_RETURN(0); } +bool ha_tina::check_if_incompatible_data(HA_CREATE_INFO *info, + uint table_changes) +{ + return COMPATIBLE_DATA_YES; +} + mysql_declare_plugin { MYSQL_STORAGE_ENGINE_PLUGIN, diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h index a11d4281389..572d05cb779 100644 --- a/storage/csv/ha_tina.h +++ b/storage/csv/ha_tina.h @@ -122,6 +122,8 @@ public: int extra(enum ha_extra_function operation); int delete_all_rows(void); int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); + bool check_if_incompatible_data(HA_CREATE_INFO *info, + uint table_changes); THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type); diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c index a90078cc9fb..329f4b7fa2d 100644 --- a/storage/heap/hp_create.c +++ b/storage/heap/hp_create.c @@ -135,6 +135,7 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, DBUG_RETURN(1); } share->keydef= (HP_KEYDEF*) (share + 1); + share->key_stat_version= 1; keyseg= (HA_KEYSEG*) (share->keydef + keys); init_block(&share->block, reclength + 1, min_records, max_records); /* Fix keys */ diff --git a/storage/innobase/include/db0err.h b/storage/innobase/include/db0err.h index de5ac44e73f..7f75e7e10a6 100644 --- a/storage/innobase/include/db0err.h +++ b/storage/innobase/include/db0err.h @@ -57,6 +57,10 @@ Created 5/24/1996 Heikki Tuuri buffer pool (for big transactions, InnoDB stores the lock structs in the buffer pool) */ +#define DB_FOREIGN_DUPLICATE_KEY 46 /* foreign key constraints + activated by the operation would + lead to a duplicate key in some + table */ /* The following are partial failure codes */ #define DB_FAIL 1000 diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 15650f22ed8..dd4862b3808 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -126,14 +126,8 @@ by one. */ #ifdef __WIN__ #define UNIV_INLINE __inline #else -/* config.h contains the right def for 'inline' for the current compiler */ -#if (__GNUC__ == 2) -#define UNIV_INLINE extern inline -#else -/* extern inline doesn't work with gcc 3.0.2 */ #define UNIV_INLINE static inline #endif -#endif #else /* If we want to compile a noninlined version we use the following macro diff --git a/storage/innobase/row/row0ins.c b/storage/innobase/row/row0ins.c index 5e833372299..128b46f9aa4 100644 --- a/storage/innobase/row/row0ins.c +++ b/storage/innobase/row/row0ins.c @@ -1376,6 +1376,21 @@ run_again: thr, foreign, &pcur, entry, &mtr); if (err != DB_SUCCESS) { + /* Since reporting a plain + "duplicate key" error + message to the user in + cases where a long CASCADE + operation would lead to a + duplicate key in some + other table is very + confusing, map duplicate + key errors resulting from + FK constraints to a + separate error code. */ + + if (err == DB_DUPLICATE_KEY) { + err = DB_FOREIGN_DUPLICATE_KEY; + } break; } diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 86d9ecf9c54..a16ffc5aa41 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -473,8 +473,9 @@ handle_new_error: ut_a(err != DB_SUCCESS); trx->error_state = DB_SUCCESS; - - if (err == DB_DUPLICATE_KEY) { + + if ((err == DB_DUPLICATE_KEY) + || (err == DB_FOREIGN_DUPLICATE_KEY)) { if (savept) { /* Roll back the latest, possibly incomplete insertion or update */ diff --git a/storage/ndb/include/mgmapi/mgmapi.h b/storage/ndb/include/mgmapi/mgmapi.h index 9d74be5d603..75cdf60f91c 100644 --- a/storage/ndb/include/mgmapi/mgmapi.h +++ b/storage/ndb/include/mgmapi/mgmapi.h @@ -468,6 +468,14 @@ extern "C" { */ void ndb_mgm_destroy_handle(NdbMgmHandle * handle); + /** + * Set a name of the handle. Name is reported in cluster log. + * + * @param handle Management handle + * @param name Name + */ + void ndb_mgm_set_name(NdbMgmHandle handle, const char *name); + /** @} *********************************************************************/ /** * @name Functions: Connect/Disconnect Management Server diff --git a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h index 59d048370ae..d0f72c28209 100644 --- a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h +++ b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h @@ -84,6 +84,11 @@ #define CFG_DB_BACKUP_DATADIR 158 #define CFG_DB_MAX_OPEN_FILES 159 +#define CFG_DB_DISK_PAGE_BUFFER_MEMORY 160 /* used from 5.1 */ +#define CFG_DB_STRING_MEMORY 161 /* used from 5.1 */ +#define CFG_DB_INITIAL_OPEN_FILES 162 /* used from 5.1 */ + +#define CFG_DB_DATA_MEM_2 199 /* used in special build in 5.1 */ #define CFG_DB_DISK_PAGE_BUFFER_MEMORY 160 #define CFG_DB_STRING_MEMORY 161 diff --git a/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp b/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp index 2ecfb7ab9ad..01c700d14b2 100644 --- a/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp +++ b/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp @@ -55,6 +55,14 @@ public: ~Ndb_cluster_connection(); /** + * Set a name on the connection, which will be reported in cluster log + * + * @param name + * + */ + void set_name(const char *name); + + /** * Connect to a cluster management server * * @param no_retries specifies the number of retries to attempt diff --git a/storage/ndb/src/kernel/blocks/Makefile.am b/storage/ndb/src/kernel/blocks/Makefile.am index d6e9f3f3352..05648653532 100644 --- a/storage/ndb/src/kernel/blocks/Makefile.am +++ b/storage/ndb/src/kernel/blocks/Makefile.am @@ -38,7 +38,7 @@ libblocks_a_SOURCES = tsman.cpp lgman.cpp pgman.cpp diskpage.cpp restore.cpp\ dbtux/DbtuxSearch.cpp dbtux/DbtuxCmp.cpp dbtux/DbtuxStat.cpp \ dbtux/DbtuxDebug.cpp -ndbtools_PROGRAMS = ndb_print_file +EXTRA_PROGRAMS = ndb_print_file ndb_print_file_SOURCES = print_file.cpp diskpage.cpp dbtup/tuppage.cpp ndb_print_file_LDFLAGS = @ndb_bin_am_ldflags@ \ $(top_builddir)/storage/ndb/src/libndbclient.la \ diff --git a/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp b/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp index 2794990d608..5b1f85f1dd6 100644 --- a/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp +++ b/storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp @@ -1061,7 +1061,7 @@ private: Uint32 cexcPrevforward; Uint32 clocalkey[32]; union { - Uint32 ckeys[2048]; + Uint32 ckeys[2048 * MAX_XFRM_MULTIPLY]; Uint64 ckeys_align; }; diff --git a/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp b/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp index 166917b00d2..31d877917e7 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp +++ b/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp @@ -775,7 +775,7 @@ private: //------------------------------------ // Methods for LCP functionality //------------------------------------ - void checkKeepGci(Uint32 replicaStartIndex); + void checkKeepGci(TabRecordPtr, Uint32, Fragmentstore*, Uint32); void checkLcpStart(Signal *, Uint32 lineNo); void checkStartMoreLcp(Signal *, Uint32 nodeId); bool reportLcpCompletion(const class LcpFragRep *); @@ -1300,7 +1300,7 @@ private: } Uint32 lcpStart; - Uint32 lcpStartGcp; + Uint32 lcpStopGcp; Uint32 keepGci; /* USED TO CALCULATE THE GCI TO KEEP AFTER A LCP */ Uint32 oldestRestorableGci; @@ -1369,7 +1369,8 @@ private: Uint32 cstarttype; Uint32 csystemnodes; Uint32 currentgcp; - + Uint32 c_newest_restorable_gci; + enum GcpMasterTakeOverState { GMTOS_IDLE = 0, GMTOS_INITIAL = 1, diff --git a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index b0fcfc342da..2c854da9609 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -685,6 +685,7 @@ void Dbdih::execCOPY_GCIREQ(Signal* signal) jam(); coldgcp = SYSFILE->newestRestorableGCI; crestartGci = SYSFILE->newestRestorableGCI; + c_newest_restorable_gci = SYSFILE->newestRestorableGCI; Sysfile::setRestartOngoing(SYSFILE->systemRestartBits); currentgcp = coldgcp + 1; cnewgcp = coldgcp + 1; @@ -703,6 +704,7 @@ void Dbdih::execCOPY_GCIREQ(Signal* signal) ok = true; jam(); cgcpParticipantState = GCP_PARTICIPANT_COPY_GCI_RECEIVED; + c_newest_restorable_gci = SYSFILE->newestRestorableGCI; setNodeInfo(signal); break; }//if @@ -8039,6 +8041,8 @@ void Dbdih::execCOPY_GCICONF(Signal* signal) signal->theData[1] = coldgcp; sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB); + c_newest_restorable_gci = coldgcp; + CRASH_INSERTION(7004); emptyWaitGCPMasterQueue(signal); cgcpStatus = GCP_READY; @@ -9522,7 +9526,7 @@ void Dbdih::checkTcCounterLab(Signal* signal) }//if c_lcpState.ctimer += 32; if ((c_nodeStartMaster.blockLcp == true) || - ((c_lcpState.lcpStartGcp + 1) > currentgcp)) { + (c_lcpState.lcpStopGcp >= c_newest_restorable_gci)) { jam(); /* --------------------------------------------------------------------- */ // No reason to start juggling the states and checking for start of LCP if @@ -9605,7 +9609,6 @@ void Dbdih::execTCGETOPSIZECONF(Signal* signal) /* ----------------------------------------------------------------------- */ c_lcpState.ctimer = 0; c_lcpState.keepGci = coldgcp; - c_lcpState.lcpStartGcp = currentgcp; /* ----------------------------------------------------------------------- */ /* UPDATE THE NEW LATEST LOCAL CHECKPOINT ID. */ /* ----------------------------------------------------------------------- */ @@ -9677,7 +9680,7 @@ void Dbdih::calculateKeepGciLab(Signal* signal, Uint32 tableId, Uint32 fragId) cnoOfActiveTables++; FragmentstorePtr fragPtr; getFragstore(tabPtr.p, fragId, fragPtr); - checkKeepGci(fragPtr.p->storedReplicas); + checkKeepGci(tabPtr, fragId, fragPtr.p, fragPtr.p->storedReplicas); fragId++; if (fragId >= tabPtr.p->totalfragments) { jam(); @@ -10537,6 +10540,7 @@ void Dbdih::allNodesLcpCompletedLab(Signal* signal) signal->theData[0] = NDB_LE_LocalCheckpointCompleted; //Event type signal->theData[1] = SYSFILE->latestLCP_ID; sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB); + c_lcpState.lcpStopGcp = c_newest_restorable_gci; /** * Start checking for next LCP @@ -10971,7 +10975,8 @@ void Dbdih::checkEscalation() /* DESCRIPTION: CHECK FOR MINIMUM GCI RESTORABLE WITH NEW LOCAL */ /* CHECKPOINT. */ /*************************************************************************/ -void Dbdih::checkKeepGci(Uint32 replicaStartIndex) +void Dbdih::checkKeepGci(TabRecordPtr tabPtr, Uint32 fragId, Fragmentstore*, + Uint32 replicaStartIndex) { ReplicaRecordPtr ckgReplicaPtr; ckgReplicaPtr.i = replicaStartIndex; @@ -10993,7 +10998,6 @@ void Dbdih::checkKeepGci(Uint32 replicaStartIndex) if (oldestRestorableGci > c_lcpState.oldestRestorableGci) { jam(); c_lcpState.oldestRestorableGci = oldestRestorableGci; - ndbrequire(((int)c_lcpState.oldestRestorableGci) >= 0); }//if ckgReplicaPtr.i = ckgReplicaPtr.p->nextReplica; }//while @@ -11287,7 +11291,7 @@ void Dbdih::findMinGci(ReplicaRecordPtr fmgReplicaPtr, do { ndbrequire(lcpNo < MAX_LCP_STORED); if (fmgReplicaPtr.p->lcpStatus[lcpNo] == ZVALID && - fmgReplicaPtr.p->maxGciStarted[lcpNo] <= coldgcp) + fmgReplicaPtr.p->maxGciStarted[lcpNo] < c_newest_restorable_gci) { jam(); keepGci = fmgReplicaPtr.p->maxGciCompleted[lcpNo]; @@ -11409,7 +11413,7 @@ void Dbdih::initCommonData() c_lcpState.clcpDelay = 0; c_lcpState.lcpStart = ZIDLE; - c_lcpState.lcpStartGcp = 0; + c_lcpState.lcpStopGcp = 0; c_lcpState.setLcpStatus(LCP_STATUS_IDLE, __LINE__); c_lcpState.currentFragment.tableId = 0; c_lcpState.currentFragment.fragmentId = 0; @@ -11446,6 +11450,7 @@ void Dbdih::initCommonData() csystemnodes = 0; c_updateToLock = RNIL; currentgcp = 0; + c_newest_restorable_gci = 0; cverifyQueueCounter = 0; cwaitLcpSr = false; c_nextLogPart = 0; @@ -11522,6 +11527,7 @@ void Dbdih::initRestartInfo() currentgcp = 2; cnewgcp = 2; crestartGci = 1; + c_newest_restorable_gci = 1; SYSFILE->keepGCI = 1; SYSFILE->oldestRestorableGCI = 1; @@ -13494,9 +13500,9 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) if (signal->theData[0] == 7001) { infoEvent("c_lcpState.keepGci = %d", c_lcpState.keepGci); - infoEvent("c_lcpState.lcpStatus = %d, clcpStartGcp = %d", + infoEvent("c_lcpState.lcpStatus = %d, clcpStopGcp = %d", c_lcpState.lcpStatus, - c_lcpState.lcpStartGcp); + c_lcpState.lcpStopGcp); infoEvent("cgcpStartCounter = %d, cimmediateLcpStart = %d", cgcpStartCounter, c_lcpState.immediateLcpStart); }//if @@ -13677,8 +13683,8 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) infoEvent("lcpStatus = %d (update place = %d) ", c_lcpState.lcpStatus, c_lcpState.lcpStatusUpdatedPlace); infoEvent - ("lcpStart = %d lcpStartGcp = %d keepGci = %d oldestRestorable = %d", - c_lcpState.lcpStart, c_lcpState.lcpStartGcp, + ("lcpStart = %d lcpStopGcp = %d keepGci = %d oldestRestorable = %d", + c_lcpState.lcpStart, c_lcpState.lcpStopGcp, c_lcpState.keepGci, c_lcpState.oldestRestorableGci); infoEvent diff --git a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index eaf935da2c5..a6e731a64d1 100644 --- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -14738,7 +14738,9 @@ void Dblqh::execSr(Signal* signal) signal->theData[4] = logFilePtr.p->currentFilepage; signal->theData[5] = logFilePtr.p->currentMbyte; signal->theData[6] = logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX]; - sendSignal(cownref, GSN_DEBUG_SIG, signal, 7, JBA); + signal->theData[7] = ~0; + signal->theData[8] = __LINE__; + sendSignal(cownref, GSN_DEBUG_SIG, signal, 9, JBA); return; }//if }//if @@ -14804,7 +14806,8 @@ void Dblqh::execSr(Signal* signal) signal->theData[5] = logFilePtr.p->currentFilepage; signal->theData[6] = logPagePtr.p->logPageWord[ZCURR_PAGE_INDEX]; signal->theData[7] = logWord; - sendSignal(cownref, GSN_DEBUG_SIG, signal, 8, JBA); + signal->theData[8] = __LINE__; + sendSignal(cownref, GSN_DEBUG_SIG, signal, 9, JBA); return; break; }//switch @@ -14833,8 +14836,9 @@ void Dblqh::execDEBUG_SIG(Signal* signal) char buf[100]; BaseString::snprintf(buf, 100, - "Error while reading REDO log.\n" + "Error while reading REDO log. from %d\n" "D=%d, F=%d Mb=%d FP=%d W1=%d W2=%d", + signal->theData[8], signal->theData[2], signal->theData[3], signal->theData[4], signal->theData[5], signal->theData[6], signal->theData[7]); @@ -15417,6 +15421,10 @@ void Dblqh::readSrFourthZeroLab(Signal* signal) // to read a page from file. lfoPtr.p->lfoState = LogFileOperationRecord::WRITE_SR_INVALIDATE_PAGES; + /** + * Make sure we dont release zero page + */ + seizeLogpage(signal); invalidateLogAfterLastGCI(signal); return; }//Dblqh::readSrFourthZeroLab() diff --git a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index f7888a8059d..5990a0fa468 100644 --- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -3027,7 +3027,7 @@ void Dbtc::tckeyreq050Lab(Signal* signal) /* NODE IF POSSIBLE TO AVOID UNNECESSARY COMMUNICATION */ /* WITH SIMPLE READS. */ /*-------------------------------------------------------------*/ - arrGuard(tnoOfBackup, 4); + arrGuard(tnoOfBackup, MAX_REPLICAS); UintR Tindex; UintR TownNode = cownNodeid; for (Tindex = 1; Tindex <= tnoOfBackup; Tindex++) { @@ -6306,7 +6306,7 @@ void Dbtc::timeOutFoundLab(Signal* signal, Uint32 TapiConPtr) jam(); tcConnectptr.i = apiConnectptr.p->currentTcConnect; ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord); - arrGuard(apiConnectptr.p->currentReplicaNo, 4); + arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS); hostptr.i = tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo]; ptrCheckGuard(hostptr, chostFilesize, hostRecord); if (hostptr.p->hostStatus == HS_ALIVE) { @@ -6332,7 +6332,7 @@ void Dbtc::timeOutFoundLab(Signal* signal, Uint32 TapiConPtr) jam(); tcConnectptr.i = apiConnectptr.p->currentTcConnect; ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord); - arrGuard(apiConnectptr.p->currentReplicaNo, 4); + arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS); hostptr.i = tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo]; ptrCheckGuard(hostptr, chostFilesize, hostRecord); if (hostptr.p->hostStatus == HS_ALIVE) { @@ -6358,7 +6358,7 @@ void Dbtc::timeOutFoundLab(Signal* signal, Uint32 TapiConPtr) jam(); tcConnectptr.i = apiConnectptr.p->currentTcConnect; ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord); - arrGuard(apiConnectptr.p->currentReplicaNo, 4); + arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS); hostptr.i = tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo]; ptrCheckGuard(hostptr, chostFilesize, hostRecord); if (hostptr.p->hostStatus == HS_ALIVE) { @@ -6495,7 +6495,7 @@ void Dbtc::sendAbortedAfterTimeout(Signal* signal, int Tcheck) // in time to the ABORT signal we will declare it as dead. /*------------------------------------------------------------------*/ UintR Ti = 0; - arrGuard(tcConnectptr.p->noOfNodes, 4); + arrGuard(tcConnectptr.p->noOfNodes, MAX_REPLICAS+1); for (Ti = 0; Ti < tcConnectptr.p->noOfNodes; Ti++) { jam(); if (tcConnectptr.p->tcNodedata[Ti] != 0) { @@ -7552,7 +7552,7 @@ void Dbtc::execABORTCONF(Signal* signal) warningReport(signal, 18); return; }//if - arrGuard(apiConnectptr.p->currentReplicaNo, 4); + arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS); if (tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo] != tnodeid) { warningReport(signal, 19); @@ -7568,7 +7568,7 @@ void Dbtc::toAbortHandlingLab(Signal* signal) do { if (tcurrentReplicaNo != (Uint8)Z8NIL) { jam(); - arrGuard(tcurrentReplicaNo, 4); + arrGuard(tcurrentReplicaNo, MAX_REPLICAS); const LqhTransConf::OperationStatus stat = (LqhTransConf::OperationStatus) tcConnectptr.p->failData[tcurrentReplicaNo]; @@ -7702,7 +7702,7 @@ void Dbtc::execCOMMITCONF(Signal* signal) warningReport(signal, 10); return; }//if - arrGuard(apiConnectptr.p->currentReplicaNo, 4); + arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS); if (tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo] != tnodeid) { warningReport(signal, 11); @@ -7722,7 +7722,7 @@ void Dbtc::toCommitHandlingLab(Signal* signal) do { if (tcurrentReplicaNo != (Uint8)Z8NIL) { jam(); - arrGuard(tcurrentReplicaNo, 4); + arrGuard(tcurrentReplicaNo, MAX_REPLICAS); switch (tcConnectptr.p->failData[tcurrentReplicaNo]) { case LqhTransConf::InvalidStatus: jam(); @@ -7847,7 +7847,7 @@ void Dbtc::execCOMPLETECONF(Signal* signal) warningReport(signal, 14); return; }//if - arrGuard(apiConnectptr.p->currentReplicaNo, 4); + arrGuard(apiConnectptr.p->currentReplicaNo, MAX_REPLICAS); if (tcConnectptr.p->tcNodedata[apiConnectptr.p->currentReplicaNo] != tnodeid) { warningReport(signal, 15); @@ -7867,7 +7867,7 @@ void Dbtc::toCompleteHandlingLab(Signal* signal) do { if (tcurrentReplicaNo != (Uint8)Z8NIL) { jam(); - arrGuard(tcurrentReplicaNo, 4); + arrGuard(tcurrentReplicaNo, MAX_REPLICAS); switch (tcConnectptr.p->failData[tcurrentReplicaNo]) { case LqhTransConf::InvalidStatus: jam(); @@ -8156,6 +8156,7 @@ void Dbtc::setupFailData(Signal* signal) case OS_PREPARED: case OS_COMMITTING: jam(); + arrGuard(tcConnectptr.p->lastReplicaNo, MAX_REPLICAS); for (tindex = 0; tindex <= tcConnectptr.p->lastReplicaNo; tindex++) { jam(); /*------------------------------------------------------------------- @@ -8163,13 +8164,13 @@ void Dbtc::setupFailData(Signal* signal) * IN THIS CASE ALL LQH'S ARE PREPARED AND WAITING FOR * COMMIT/ABORT DECISION. *------------------------------------------------------------------*/ - arrGuard(tindex, 4); tcConnectptr.p->failData[tindex] = LqhTransConf::Prepared; }//for break; case OS_COMMITTED: case OS_COMPLETING: jam(); + arrGuard(tcConnectptr.p->lastReplicaNo, MAX_REPLICAS); for (tindex = 0; tindex <= tcConnectptr.p->lastReplicaNo; tindex++) { jam(); /*------------------------------------------------------------------- @@ -8177,19 +8178,18 @@ void Dbtc::setupFailData(Signal* signal) * IN THIS CASE ALL LQH'S ARE COMMITTED AND WAITING FOR * COMPLETE MESSAGE. *------------------------------------------------------------------*/ - arrGuard(tindex, 4); tcConnectptr.p->failData[tindex] = LqhTransConf::Committed; }//for break; case OS_COMPLETED: jam(); + arrGuard(tcConnectptr.p->lastReplicaNo, MAX_REPLICAS); for (tindex = 0; tindex <= tcConnectptr.p->lastReplicaNo; tindex++) { jam(); /*------------------------------------------------------------------- * KEYDATA IS USED TO KEEP AN INDICATION OF STATE IN LQH. * IN THIS CASE ALL LQH'S ARE COMPLETED. *-------------------------------------------------------------------*/ - arrGuard(tindex, 4); tcConnectptr.p->failData[tindex] = LqhTransConf::InvalidStatus; }//for break; diff --git a/storage/ndb/src/kernel/blocks/dbtup/Makefile.am b/storage/ndb/src/kernel/blocks/dbtup/Makefile.am index 7a53f43817a..d963cdecaf9 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/Makefile.am +++ b/storage/ndb/src/kernel/blocks/dbtup/Makefile.am @@ -5,7 +5,7 @@ include $(top_srcdir)/storage/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% -ndbtest_PROGRAMS = test_varpage +EXTRA_PROGRAMS = test_varpage test_varpage_SOURCES = test_varpage.cpp tuppage.cpp test_varpage_LDFLAGS = @ndb_bin_am_ldflags@ \ $(top_builddir)/storage/ndb/src/libndbclient.la \ diff --git a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp index 6947a4902a1..e0324c2c8ea 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp @@ -370,7 +370,6 @@ void AsyncFile::openReq(Request* request) const int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; -retry: if(flags & FsOpenReq::OM_CREATE_IF_NONE){ if((theFd = ::open(theFileName.c_str(), new_flags, mode)) != -1) { close(theFd); @@ -432,6 +431,7 @@ retry: m_fs.EXECUTE_DIRECT(block, GSN_FSWRITEREQ, signal, FsReadWriteReq::FixedLength + 1); + retry: Uint32 size = request->par.open.page_size; char* buf = (char*)m_page_ptr.p; while(size > 0){ @@ -449,9 +449,21 @@ retry: } if(size != 0) { + int err = errno; +#ifdef O_DIRECT + if ((new_flags & O_DIRECT) && off == 0) + { + ndbout_c("error on first write(%d), disable O_DIRECT", err); + new_flags &= ~O_DIRECT; + close(theFd); + theFd = ::open(theFileName.c_str(), new_flags, mode); + if (theFd != -1) + goto retry; + } +#endif close(theFd); unlink(theFileName.c_str()); - request->error = errno; + request->error = err; return; } off += request->par.open.page_size; diff --git a/storage/ndb/src/kernel/main.cpp b/storage/ndb/src/kernel/main.cpp index 4bc9fbf76e5..7c1763485ce 100644 --- a/storage/ndb/src/kernel/main.cpp +++ b/storage/ndb/src/kernel/main.cpp @@ -63,8 +63,10 @@ extern "C" void handler_sigusr1(int signum); // child signalling failed restart void systemInfo(const Configuration & conf, const LogLevel & ll); -static FILE *child_info_file_r= 0; -static FILE *child_info_file_w= 0; +// These are used already before fork if fetch_configuration() fails +// (e.g. Unable to alloc node id). Set them to something reasonable. +static FILE *child_info_file_r= stdin; +static FILE *child_info_file_w= stdout; static void writeChildInfo(const char *token, int val) { @@ -270,8 +272,8 @@ int main(int argc, char** argv) #ifndef NDB_WIN32 signal(SIGUSR1, handler_sigusr1); - pid_t child; - while (1) + pid_t child = -1; + while (! theConfig->getForegroundMode()) // the cond is const { // setup reporting between child and parent int filedes[2]; @@ -393,8 +395,10 @@ int main(int argc, char** argv) if (child >= 0) g_eventLogger.info("Angel pid: %d ndb pid: %d", getppid(), getpid()); - else + else if (child > 0) g_eventLogger.info("Ndb pid: %d", getpid()); + else + g_eventLogger.info("Ndb started in foreground"); #else g_eventLogger.info("Ndb started"); #endif @@ -569,10 +573,7 @@ catchsigs(bool ignore){ #ifdef SIGPOLL SIGPOLL, #endif - SIGSEGV, -#ifdef SIGTRAP - SIGTRAP -#endif + SIGSEGV }; static const int signals_ignore[] = { @@ -586,6 +587,11 @@ catchsigs(bool ignore){ handler_register(signals_error[i], handler_error, ignore); for(i = 0; i < sizeof(signals_ignore)/sizeof(signals_ignore[0]); i++) handler_register(signals_ignore[i], SIG_IGN, ignore); +#ifdef SIGTRAP + Configuration* theConfig = globalEmulatorData.theConfiguration; + if (! theConfig->getForegroundMode()) + handler_register(SIGTRAP, handler_error, ignore); +#endif #endif } diff --git a/storage/ndb/src/kernel/vm/Configuration.cpp b/storage/ndb/src/kernel/vm/Configuration.cpp index 771fa6f5fe4..5f3b601023f 100644 --- a/storage/ndb/src/kernel/vm/Configuration.cpp +++ b/storage/ndb/src/kernel/vm/Configuration.cpp @@ -48,11 +48,13 @@ extern EventLogger g_eventLogger; enum ndbd_options { OPT_INITIAL = NDB_STD_OPTIONS_LAST, - OPT_NODAEMON + OPT_NODAEMON, + OPT_FOREGROUND }; NDB_STD_OPTS_VARS; -static int _daemon, _no_daemon, _initial, _no_start; +// XXX should be my_bool ??? +static int _daemon, _no_daemon, _foreground, _initial, _no_start; /** * Arguments to NDB process */ @@ -75,6 +77,11 @@ static struct my_option my_long_options[] = "Do not start ndbd as daemon, provided for testing purposes", (gptr*) &_no_daemon, (gptr*) &_no_daemon, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "foreground", OPT_FOREGROUND, + "Run real ndbd in foreground, provided for debugging purposes" + " (implies --nodaemon)", + (gptr*) &_foreground, (gptr*) &_foreground, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; static void short_usage_sub(void) @@ -103,13 +110,14 @@ Configuration::init(int argc, char** argv) ndb_std_get_one_option))) exit(ho_error); - if (_no_daemon) { + if (_no_daemon || _foreground) { _daemon= 0; } DBUG_PRINT("info", ("no_start=%d", _no_start)); DBUG_PRINT("info", ("initial=%d", _initial)); DBUG_PRINT("info", ("daemon=%d", _daemon)); + DBUG_PRINT("info", ("foreground=%d", _foreground)); DBUG_PRINT("info", ("connect_str=%s", opt_connect_str)); ndbSetOwnVersion(); @@ -131,6 +139,8 @@ Configuration::init(int argc, char** argv) // Check daemon flag if (_daemon) _daemonMode = true; + if (_foreground) + _foregroundMode = true; // Save programname if(argc > 0 && argv[0] != 0) @@ -151,6 +161,7 @@ Configuration::Configuration() _backupPath = 0; _initialStart = false; _daemonMode = false; + _foregroundMode = false; m_config_retriever= 0; m_clusterConfig= 0; m_clusterConfigIter= 0; diff --git a/storage/ndb/src/kernel/vm/Configuration.hpp b/storage/ndb/src/kernel/vm/Configuration.hpp index 243ecbee4e7..6315209ddbb 100644 --- a/storage/ndb/src/kernel/vm/Configuration.hpp +++ b/storage/ndb/src/kernel/vm/Configuration.hpp @@ -64,6 +64,7 @@ public: bool getInitialStart() const; void setInitialStart(bool val); bool getDaemonMode() const; + bool getForegroundMode() const; const ndb_mgm_configuration_iterator * getOwnConfigIterator() const; @@ -105,7 +106,8 @@ private: char * _connectString; Uint32 m_mgmd_port; BaseString m_mgmd_host; - bool _daemonMode; + bool _daemonMode; // if not, angel in foreground + bool _foregroundMode; // no angel, raw ndbd in foreground void calcSizeAlt(class ConfigValues * ); }; @@ -140,4 +142,10 @@ Configuration::getDaemonMode() const { return _daemonMode; } +inline +bool +Configuration::getForegroundMode() const { + return _foregroundMode; +} + #endif diff --git a/storage/ndb/src/mgmapi/mgmapi.cpp b/storage/ndb/src/mgmapi/mgmapi.cpp index eb93ec88b6f..27e25369439 100644 --- a/storage/ndb/src/mgmapi/mgmapi.cpp +++ b/storage/ndb/src/mgmapi/mgmapi.cpp @@ -102,6 +102,7 @@ struct ndb_mgm_handle { FILE* logfile; #endif FILE *errstream; + char *m_name; }; #define SET_ERROR(h, e, s) setError(h, e, __LINE__, s) @@ -156,6 +157,7 @@ ndb_mgm_create_handle() h->write_timeout = 100; h->cfg_i = -1; h->errstream = stdout; + h->m_name = 0; strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE); @@ -171,6 +173,14 @@ ndb_mgm_create_handle() } extern "C" +void +ndb_mgm_set_name(NdbMgmHandle handle, const char *name) +{ + my_free(handle->m_name, MYF(MY_ALLOW_ZERO_PTR)); + handle->m_name= my_strdup(name, MYF(MY_WME)); +} + +extern "C" int ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv) { @@ -216,6 +226,7 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle) } #endif (*handle)->cfg.~LocalConfig(); + my_free((*handle)->m_name, MYF(MY_ALLOW_ZERO_PTR)); my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR)); * handle = 0; DBUG_VOID_RETURN; @@ -1875,6 +1886,8 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype) args.put("password", "mysqld"); args.put("public key", "a public key"); args.put("endian", (endian_check.c[sizeof(long)-1])?"big":"little"); + if (handle->m_name) + args.put("name", handle->m_name); const ParserRow<ParserDummy> reply[]= { MGM_CMD("get nodeid reply", NULL, ""), diff --git a/storage/ndb/src/mgmsrv/Services.cpp b/storage/ndb/src/mgmsrv/Services.cpp index 80f0aa2eda8..3564c5c40ba 100644 --- a/storage/ndb/src/mgmsrv/Services.cpp +++ b/storage/ndb/src/mgmsrv/Services.cpp @@ -35,6 +35,7 @@ #include <base64.h> extern bool g_StopServer; +extern EventLogger g_eventLogger; static const unsigned int MAX_READ_TIMEOUT = 1000 ; static const unsigned int MAX_WRITE_TIMEOUT = 100 ; @@ -135,6 +136,7 @@ ParserRow<MgmApiSession> commands[] = { MGM_ARG("password", String, Mandatory, "Password"), MGM_ARG("public key", String, Mandatory, "Public key"), MGM_ARG("endian", String, Optional, "Endianness"), + MGM_ARG("name", String, Optional, "Name of connection"), MGM_CMD("get version", &MgmApiSession::getVersion, ""), @@ -411,6 +413,7 @@ MgmApiSession::get_nodeid(Parser_t::Context &, const char * password; const char * public_key; const char * endian= NULL; + const char * name= NULL; union { long l; char c[sizeof(long)]; } endian_check; args.get("version", &version); @@ -421,6 +424,7 @@ MgmApiSession::get_nodeid(Parser_t::Context &, args.get("password", &password); args.get("public key", &public_key); args.get("endian", &endian); + args.get("name", &name); endian_check.l = 1; if(endian @@ -489,6 +493,9 @@ MgmApiSession::get_nodeid(Parser_t::Context &, m_output->println(""); m_allocated_resources->reserve_node(tmp); + if (name) + g_eventLogger.info("Node %d: %s", tmp, name); + return; } diff --git a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp index 405141cd143..d8d4391efb6 100644 --- a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -262,7 +262,8 @@ Ndb_cluster_connection::wait_until_ready(int timeout, Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char * connect_string) : Ndb_cluster_connection(*this), - m_optimized_node_selection(1) + m_optimized_node_selection(1), + m_name(0) { DBUG_ENTER("Ndb_cluster_connection"); DBUG_PRINT("enter",("Ndb_cluster_connection this=0x%x", this)); @@ -287,7 +288,11 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char * delete m_config_retriever; m_config_retriever= 0; } - + if (m_name) + { + NdbMgmHandle h= m_config_retriever->get_mgmHandle(); + ndb_mgm_set_name(h, m_name); + } m_transporter_facade= TransporterFacade::theFacadeInstance= new TransporterFacade(); @@ -326,10 +331,26 @@ Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl() ndb_print_state_mutex= NULL; } #endif + if (m_name) + free(m_name); + DBUG_VOID_RETURN; } void +Ndb_cluster_connection_impl::set_name(const char *name) +{ + if (m_name) + free(m_name); + m_name= strdup(name); + if (m_config_retriever && m_name) + { + NdbMgmHandle h= m_config_retriever->get_mgmHandle(); + ndb_mgm_set_name(h, m_name); + } +} + +void Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config) @@ -480,6 +501,11 @@ Ndb_cluster_connection_impl::do_test() delete [] nodes; } +void Ndb_cluster_connection::set_name(const char *name) +{ + m_impl.set_name(name); +} + int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds, int verbose) { diff --git a/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp b/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp index 561babd62c1..db6e1f9e6ed 100644 --- a/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp +++ b/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp @@ -62,6 +62,7 @@ private: Vector<Node> m_all_nodes; void init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config); void connect_thread(); + void set_name(const char *name); TransporterFacade *m_transporter_facade; ConfigRetriever *m_config_retriever; @@ -69,6 +70,7 @@ private: int (*m_connect_callback)(void); int m_optimized_node_selection; + char *m_name; }; #endif diff --git a/storage/ndb/test/ndbapi/testBlobs.cpp b/storage/ndb/test/ndbapi/testBlobs.cpp index a88d7d21820..fff5ac247df 100644 --- a/storage/ndb/test/ndbapi/testBlobs.cpp +++ b/storage/ndb/test/ndbapi/testBlobs.cpp @@ -839,9 +839,6 @@ insertPk(int style) CHK(g_con->execute(NoCommit) == 0); CHK(writeBlobData(tup) == 0); } - // just another trap - if (urandom(10) == 0) - CHK(g_con->execute(NoCommit) == 0); if (++n == g_opt.m_batch) { CHK(g_con->execute(Commit) == 0); g_ndb->closeTransaction(g_con); @@ -963,21 +960,31 @@ static int deletePk() { DBG("--- deletePk ---"); + unsigned n = 0; + CHK((g_con = g_ndb->startTransaction()) != 0); for (unsigned k = 0; k < g_opt.m_rows; k++) { Tup& tup = g_tups[k]; DBG("deletePk pk1=" << hex << tup.m_pk1); - CHK((g_con = g_ndb->startTransaction()) != 0); CHK((g_opr = g_con->getNdbOperation(g_opt.m_tname)) != 0); CHK(g_opr->deleteTuple() == 0); CHK(g_opr->equal("PK1", tup.m_pk1) == 0); if (g_opt.m_pk2len != 0) CHK(g_opr->equal("PK2", tup.m_pk2) == 0); - CHK(g_con->execute(Commit) == 0); - g_ndb->closeTransaction(g_con); + if (++n == g_opt.m_batch) { + CHK(g_con->execute(Commit) == 0); + g_ndb->closeTransaction(g_con); + CHK((g_con = g_ndb->startTransaction()) != 0); + n = 0; + } g_opr = 0; - g_con = 0; tup.m_exists = false; } + if (n != 0) { + CHK(g_con->execute(Commit) == 0); + n = 0; + } + g_ndb->closeTransaction(g_con); + g_con = 0; return 0; } @@ -1080,19 +1087,27 @@ static int deleteIdx() { DBG("--- deleteIdx ---"); + unsigned n = 0; + CHK((g_con = g_ndb->startTransaction()) != 0); for (unsigned k = 0; k < g_opt.m_rows; k++) { Tup& tup = g_tups[k]; DBG("deleteIdx pk1=" << hex << tup.m_pk1); - CHK((g_con = g_ndb->startTransaction()) != 0); CHK((g_opx = g_con->getNdbIndexOperation(g_opt.m_x1name, g_opt.m_tname)) != 0); CHK(g_opx->deleteTuple() == 0); CHK(g_opx->equal("PK2", tup.m_pk2) == 0); - CHK(g_con->execute(Commit) == 0); - g_ndb->closeTransaction(g_con); + if (++n == g_opt.m_batch) { + CHK(g_con->execute(Commit) == 0); + g_ndb->closeTransaction(g_con); + CHK((g_con = g_ndb->startTransaction()) != 0); + n = 0; + } g_opx = 0; - g_con = 0; tup.m_exists = false; } + if (n != 0) { + CHK(g_con->execute(Commit) == 0); + n = 0; + } return 0; } @@ -1220,20 +1235,49 @@ deleteScan(bool idx) CHK(g_ops->getValue("PK2", tup.m_pk2) != 0); CHK(g_con->execute(NoCommit) == 0); unsigned rows = 0; + unsigned n = 0; while (1) { int ret; tup.m_pk1 = (Uint32)-1; memset(tup.m_pk2, 'x', g_opt.m_pk2len); - CHK((ret = g_ops->nextResult()) == 0 || ret == 1); + CHK((ret = g_ops->nextResult(true)) == 0 || ret == 1); if (ret == 1) break; - DBG("deleteScan" << (idx ? "Idx" : "") << " pk1=" << hex << tup.m_pk1); - CHK(g_ops->deleteCurrentTuple() == 0); - CHK(g_con->execute(NoCommit) == 0); - Uint32 k = tup.m_pk1 - g_opt.m_pk1off; - CHK(k < g_opt.m_rows && g_tups[k].m_exists); - g_tups[k].m_exists = false; - rows++; + while (1) { + DBG("deleteScan" << (idx ? "Idx" : "") << " pk1=" << hex << tup.m_pk1); + Uint32 k = tup.m_pk1 - g_opt.m_pk1off; + CHK(k < g_opt.m_rows && g_tups[k].m_exists); + g_tups[k].m_exists = false; + CHK(g_ops->deleteCurrentTuple() == 0); + rows++; + tup.m_pk1 = (Uint32)-1; + memset(tup.m_pk2, 'x', g_opt.m_pk2len); + CHK((ret = g_ops->nextResult(false)) == 0 || ret == 1 || ret == 2); + if (++n == g_opt.m_batch || ret == 2) { + DBG("execute batch: n=" << n << " ret=" << ret); + switch (0) { + case 0: // works normally + CHK(g_con->execute(NoCommit) == 0); + CHK(true || g_con->restart() == 0); + break; + case 1: // nonsense - g_con is invalid for 2nd batch + CHK(g_con->execute(Commit) == 0); + CHK(true || g_con->restart() == 0); + break; + case 2: // DBTC sendSignalErrorRefuseLab + CHK(g_con->execute(NoCommit) == 0); + CHK(g_con->restart() == 0); + break; + case 3: // 266 time-out + CHK(g_con->execute(Commit) == 0); + CHK(g_con->restart() == 0); + break; + } + n = 0; + } + if (ret == 2) + break; + } } CHK(g_con->execute(Commit) == 0); g_ndb->closeTransaction(g_con); @@ -1256,7 +1300,7 @@ static int testmain() { g_ndb = new Ndb(g_ncc, "TEST_DB"); - CHK(g_ndb->init() == 0); + CHK(g_ndb->init(20) == 0); CHK(g_ndb->waitUntilReady() == 0); g_dic = g_ndb->getDictionary(); g_tups = new Tup [g_opt.m_rows]; @@ -1483,13 +1527,16 @@ testperf() // insert char (one trans) { DBG("--- insert char ---"); + char b[20]; t1.on(); CHK((g_con = g_ndb->startTransaction()) != 0); for (Uint32 k = 0; k < g_opt.m_rowsperf; k++) { CHK((g_opr = g_con->getNdbOperation(tab.getName())) != 0); CHK(g_opr->insertTuple() == 0); CHK(g_opr->equal(cA, (char*)&k) == 0); - CHK(g_opr->setValue(cB, "b") == 0); + memset(b, 0x20, sizeof(b)); + b[0] = 'b'; + CHK(g_opr->setValue(cB, b) == 0); CHK(g_con->execute(NoCommit) == 0); } t1.off(g_opt.m_rowsperf); @@ -1526,12 +1573,15 @@ testperf() { DBG("--- insert for read test ---"); unsigned n = 0; + char b[20]; CHK((g_con = g_ndb->startTransaction()) != 0); for (Uint32 k = 0; k < g_opt.m_rowsperf; k++) { CHK((g_opr = g_con->getNdbOperation(tab.getName())) != 0); CHK(g_opr->insertTuple() == 0); CHK(g_opr->equal(cA, (char*)&k) == 0); - CHK(g_opr->setValue(cB, "b") == 0); + memset(b, 0x20, sizeof(b)); + b[0] = 'b'; + CHK(g_opr->setValue(cB, b) == 0); CHK((g_bh1 = g_opr->getBlobHandle(cC)) != 0); CHK((g_bh1->setValue("c", 1) == 0)); if (++n == g_opt.m_batch) { @@ -1565,7 +1615,7 @@ testperf() a = (Uint32)-1; b[0] = 0; CHK(g_con->execute(NoCommit) == 0); - CHK(a == k && strcmp(b, "b") == 0); + CHK(a == k && b[0] == 'b'); } CHK(g_con->execute(Commit) == 0); t1.off(g_opt.m_rowsperf); @@ -1591,7 +1641,7 @@ testperf() CHK(g_con->execute(NoCommit) == 0); Uint32 m = 20; CHK(g_bh1->readData(c, m) == 0); - CHK(a == k && m == 1 && strcmp(c, "c") == 0); + CHK(a == k && m == 1 && c[0] == 'c'); } CHK(g_con->execute(Commit) == 0); t2.off(g_opt.m_rowsperf); @@ -1623,7 +1673,7 @@ testperf() CHK((ret = g_ops->nextResult(true)) == 0 || ret == 1); if (ret == 1) break; - CHK(a < g_opt.m_rowsperf && strcmp(b, "b") == 0); + CHK(a < g_opt.m_rowsperf && b[0] == 'b'); n++; } CHK(n == g_opt.m_rowsperf); @@ -1654,7 +1704,7 @@ testperf() break; Uint32 m = 20; CHK(g_bh1->readData(c, m) == 0); - CHK(a < g_opt.m_rowsperf && m == 1 && strcmp(c, "c") == 0); + CHK(a < g_opt.m_rowsperf && m == 1 && c[0] == 'c'); n++; } CHK(n == g_opt.m_rowsperf); diff --git a/storage/ndb/tools/delete_all.cpp b/storage/ndb/tools/delete_all.cpp index 6b7453d4d55..feedded06ad 100644 --- a/storage/ndb/tools/delete_all.cpp +++ b/storage/ndb/tools/delete_all.cpp @@ -22,7 +22,8 @@ #include <NdbSleep.h> #include <NDBT.hpp> -static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240); +static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, + bool commit_across_open_cursor, int parallelism=240); NDB_STD_OPTS_VARS; @@ -83,8 +84,18 @@ int main(int argc, char** argv){ ndbout << " Table " << argv[i] << " does not exist!" << endl; return NDBT_ProgramExit(NDBT_WRONGARGS); } + // Check if we have any blobs + bool commit_across_open_cursor = true; + for (int j = 0; j < pTab->getNoOfColumns(); j++) { + NdbDictionary::Column::Type t = pTab->getColumn(j)->getType(); + if (t == NdbDictionary::Column::Blob || + t == NdbDictionary::Column::Text) { + commit_across_open_cursor = false; + break; + } + } ndbout << "Deleting all from " << argv[i] << "..."; - if(clear_table(&MyNdb, pTab) == NDBT_FAILED){ + if(clear_table(&MyNdb, pTab, commit_across_open_cursor) == NDBT_FAILED){ res = NDBT_FAILED; ndbout << "FAILED" << endl; } @@ -93,7 +104,8 @@ int main(int argc, char** argv){ } -int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism) +int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, + bool commit_across_open_cursor, int parallelism) { // Scan all records exclusive and delete // them one by one @@ -155,8 +167,12 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism) } while((check = pOp->nextResult(false)) == 0); if(check != -1){ - check = pTrans->execute(NdbTransaction::Commit); - pTrans->restart(); + if (commit_across_open_cursor) { + check = pTrans->execute(NdbTransaction::Commit); + pTrans->restart(); // new tx id + } else { + check = pTrans->execute(NdbTransaction::NoCommit); + } } err = pTrans->getNdbError(); @@ -182,6 +198,11 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism) } goto failed; } + if (! commit_across_open_cursor && + pTrans->execute(NdbTransaction::Commit) != 0) { + err = pTrans->getNdbError(); + goto failed; + } pNdb->closeTransaction(pTrans); return NDBT_OK; } diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp index 200925bf8bb..e4d8f98363a 100644 --- a/storage/ndb/tools/restore/consumer_restore.cpp +++ b/storage/ndb/tools/restore/consumer_restore.cpp @@ -30,6 +30,8 @@ static Uint32 get_part_id(const NdbDictionary::Table *table, Uint32 hash_value); extern const char * g_connect_string; +extern BaseString g_options; + bool BackupRestore::init() { @@ -39,6 +41,7 @@ BackupRestore::init() return true; m_cluster_connection = new Ndb_cluster_connection(g_connect_string); + m_cluster_connection->set_name(g_options.c_str()); if(m_cluster_connection->connect(12, 5, 1) != 0) { return false; diff --git a/storage/ndb/tools/restore/restore_main.cpp b/storage/ndb/tools/restore/restore_main.cpp index 11687860bf5..86e6ef98d0a 100644 --- a/storage/ndb/tools/restore/restore_main.cpp +++ b/storage/ndb/tools/restore/restore_main.cpp @@ -58,7 +58,8 @@ static int _print_log = 0; static int _restore_data = 0; static int _restore_meta = 0; static int _no_restore_disk = 0; - +BaseString g_options("ndb_restore"); + static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_restore"), @@ -450,6 +451,18 @@ main(int argc, char** argv) exitHandler(NDBT_FAILED); } + g_options.appfmt(" -b %d", ga_backupId); + g_options.appfmt(" -n %d", ga_nodeId); + if (_restore_meta) + g_options.appfmt(" -m"); + if (_restore_data) + g_options.appfmt(" -r"); + if (ga_restore_epoch) + g_options.appfmt(" -e"); + if (_no_restore_disk) + g_options.appfmt(" -d"); + g_options.appfmt(" -p %d", ga_nParallelism); + g_connect_string = opt_connect_str; /** diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 3242b18dd42..3e53bb74b60 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -114,8 +114,6 @@ Group: Applications/Databases This package contains the ndbcluster storage engine. It is necessary to have this package installed on all computers that should store ndbcluster table data. -Note that this storage engine can only be used in conjunction -with the MySQL Max server. %{see_base} @@ -181,29 +179,6 @@ Group: Applications/Databases This package contains the shared libraries (*.so*) which certain languages and applications need to dynamically load and use MySQL. -%package Max -Summary: MySQL - server with extended functionality -Group: Applications/Databases -Provides: mysql-Max -Obsoletes: mysql-Max -Requires: MySQL-server >= @MYSQL_BASE_VERSION@ - -%description Max -Optional MySQL server binary that supports additional features like: - - - Berkeley DB Storage Engine - - Ndbcluster Storage Engine interface - - Archive Storage Engine - - CSV Storage Engine - - Example Storage Engine - - Federated Storage Engine - - User Defined Functions (UDFs). - -To activate this binary, just install this package in addition to -the standard MySQL package. - -Please note that this is a dynamically linked binary! - %package embedded Requires: %{name}-devel Summary: MySQL - embedded library @@ -224,7 +199,11 @@ client/server version. %{see_base} %prep -%setup -n mysql-%{mysql_version} +# We unpack the source twice, once for debug and once for release build. +%setup -T -a 0 -c -n mysql-%{mysql_version} +mv mysql-%{mysql_version} mysql-debug-%{mysql_version} +%setup -D -T -a 0 -n mysql-%{mysql_version} +mv mysql-%{mysql_version} mysql-release-%{mysql_version} %build @@ -234,12 +213,13 @@ BuildMySQL() { sh -c "PATH=\"${MYSQL_BUILD_PATH:-$PATH}\" \ CC=\"${CC:-$MYSQL_BUILD_CC}\" \ CXX=\"${CXX:-$MYSQL_BUILD_CXX}\" \ - CFLAGS=\"${MYSQL_BUILD_CFLAGS:-$RPM_OPT_FLAGS}\" \ - CXXFLAGS=\"${MYSQL_BUILD_CXXFLAGS:-$RPM_OPT_FLAGS \ - -felide-constructors -fno-exceptions -fno-rtti \ - }\" \ + CFLAGS=\"$CFLAGS\" \ + CXXFLAGS=\"$CXXFLAGS\" \ ./configure \ $* \ + --with-mysqld-ldflags='-static' \ + --with-client-ldflags='-static' \ + --with-zlib-dir=bundled \ --enable-assembler \ --enable-local-infile \ --with-mysqld-user=%{mysqld_user} \ @@ -280,7 +260,6 @@ fi # Use the build root for temporary storage of the shared libraries. RBR=$RPM_BUILD_ROOT -MBD=$RPM_BUILD_DIR/mysql-%{mysql_version} # Clean up the BuildRoot first [ "$RBR" != "/" ] && [ -d $RBR ] && rm -rf $RBR; @@ -292,8 +271,7 @@ mkdir -p $RBR%{_libdir}/mysql PATH=${MYSQL_BUILD_PATH:-/bin:/usr/bin} export PATH -# Build the Max binary (includes BDB and UDFs and therefore -# cannot be linked statically against the patched glibc) +# Build the Debug binary. # Use gcc for C and C++ code (to avoid a dependency on libstdc++ and # including exceptions into the code @@ -303,7 +281,12 @@ then export CXX="gcc" fi +# Strip -Oxxx, add -g and --with-debug. +(cd mysql-debug-%{mysql_version} && +CFLAGS=`echo "${MYSQL_BUILD_CFLAGS:-$RPM_OPT_FLAGS} -g" | sed -e 's/-O[0-9]*//g'` \ +CXXFLAGS=`echo "${MYSQL_BUILD_CXXFLAGS:-$RPM_OPT_FLAGS -felide-constructors -fno-exceptions -fno-rtti} -g" | sed -e 's/-O[0-9]*//g'` \ BuildMySQL "--enable-shared \ + --with-debug \ --with-berkeley-db \ --with-innodb \ --with-ndbcluster \ @@ -313,86 +296,43 @@ BuildMySQL "--enable-shared \ --with-blackhole-storage-engine \ --with-federated-storage-engine \ --with-big-tables \ - --with-comment=\"MySQL Community Edition - Experimental (GPL)\" \ - --with-server-suffix='-max'" + --with-comment=\"MySQL Community Edition - Debug (GPL)\"") # We might want to save the config log file -if test -n "$MYSQL_MAXCONFLOG_DEST" -then - cp -fp config.log "$MYSQL_MAXCONFLOG_DEST" -fi - -make test-force || true - -# Save mysqld-max -# check if mysqld was installed in .libs/ -if test -f sql/.libs/mysqld -then - cp sql/.libs/mysqld sql/mysqld-max -else - cp sql/mysqld sql/mysqld-max -fi -nm --numeric-sort sql/mysqld-max > sql/mysqld-max.sym -# Save the perror binary so it supports the NDB error codes (BUG#13740) -mv extra/perror extra/perror.ndb - -# Install the ndb binaries -(cd ndb; make install DESTDIR=$RBR) - -# Include libgcc.a in the devel subpackage (BUG 4921) -if expr "$CC" : ".*gcc.*" > /dev/null ; +if test -n "$MYSQL_DEBUGCONFLOG_DEST" then - libgcc=`$CC --print-libgcc-file` - if [ -f $libgcc ] - then - %define have_libgcc 1 - install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a - fi + cp -fp mysql-debug-%{mysql_version}/config.log "$MYSQL_DEBUGCONFLOG_DEST" fi -# Save libraries -(cd libmysql/.libs; tar cf $RBR/shared-libs.tar *.so*) -(cd libmysql_r/.libs; tar rf $RBR/shared-libs.tar *.so*) -(cd ndb/src/.libs; tar rf $RBR/shared-libs.tar *.so*) +(cd mysql-debug-%{mysql_version} && make -i test-force) || true -# Now clean up -make clean - -# -# Only link statically on our i386 build host (which has a specially -# patched static glibc installed) - ia64 and x86_64 run glibc-2.3 (unpatched) -# so don't link statically there -# -BuildMySQL "--disable-shared \ -%if %{STATIC_BUILD} - --with-mysqld-ldflags='-all-static' \ - --with-client-ldflags='-all-static' \ - $USE_OTHER_LIBC_DIR \ -%endif - --with-zlib-dir=bundled \ - --with-comment=\"MySQL Community Edition - Standard (GPL)\" \ - --with-server-suffix='%{server_suffix}' \ - --with-archive-storage-engine \ +# Build release binary. +(cd mysql-release-%{mysql_version} && +CFLAGS="${MYSQL_BUILD_CFLAGS:-$RPM_OPT_FLAGS} -g" \ +CXXFLAGS="${MYSQL_BUILD_CXXFLAGS:-$RPM_OPT_FLAGS -felide-constructors -fno-exceptions -fno-rtti} -g" \ +BuildMySQL "--enable-shared \ + --with-berkeley-db \ --with-innodb \ - --with-big-tables" -if test -f sql/.libs/mysqld -then - nm --numeric-sort sql/.libs/mysqld > sql/mysqld.sym -else - nm --numeric-sort sql/mysqld > sql/mysqld.sym -fi + --with-ndbcluster \ + --with-archive-storage-engine \ + --with-csv-storage-engine \ + --with-example-storage-engine \ + --with-blackhole-storage-engine \ + --with-federated-storage-engine \ + --with-big-tables \ + --with-comment=\"MySQL Community Edition (GPL)\"") # We might want to save the config log file if test -n "$MYSQL_CONFLOG_DEST" then - cp -fp config.log "$MYSQL_CONFLOG_DEST" + cp -fp mysql-release-%{mysql_version}/config.log "$MYSQL_CONFLOG_DEST" fi -make test-force || true +(cd mysql-release-%{mysql_version} && make -i test-force) || true %install RBR=$RPM_BUILD_ROOT -MBD=$RPM_BUILD_DIR/mysql-%{mysql_version} +MBD=$RPM_BUILD_DIR/mysql-%{mysql_version}/mysql-release-%{mysql_version} # Ensure that needed directories exists install -d $RBR%{_sysconfdir}/{logrotate.d,init.d} @@ -404,21 +344,22 @@ install -d $RBR%{_mandir} install -d $RBR%{_sbindir} -# Install all binaries stripped -make install-strip DESTDIR=$RBR benchdir_root=%{_datadir} - -# Install shared libraries (Disable for architectures that don't support it) -(cd $RBR%{_libdir}; tar xf $RBR/shared-libs.tar; rm -f $RBR/shared-libs.tar) +# Install all binaries +(cd $MBD && make install DESTDIR=$RBR benchdir_root=%{_datadir}) +# Old packages put shared libs in %{_libdir}/ (not %{_libdir}/mysql), so do +# the same here. +mv $RBR/%{_libdir}/mysql/*.so* $RBR/%{_libdir}/ -# install saved mysqld-max -install -s -m 755 $MBD/sql/mysqld-max $RBR%{_sbindir}/mysqld-max +# install mysqld-debug +if test -f $RPM_BUILD_DIR/mysql-%{mysql_version}/mysql-debug-%{mysql_version}/sql/.libs/mysqld +then + install -m 755 $RPM_BUILD_DIR/mysql-%{mysql_version}/mysql-debug-%{mysql_version}/sql/.libs/mysqld $RBR%{_sbindir}/mysqld-debug +else + install -m 755 $RPM_BUILD_DIR/mysql-%{mysql_version}/mysql-debug-%{mysql_version}/sql/mysqld $RBR%{_sbindir}/mysqld-debug +fi # install saved perror binary with NDB support (BUG#13740) -install -s -m 755 $MBD/extra/perror.ndb $RBR%{_bindir}/perror - -# install symbol files ( for stack trace resolution) -install -m 644 $MBD/sql/mysqld-max.sym $RBR%{_libdir}/mysql/mysqld-max.sym -install -m 644 $MBD/sql/mysqld.sym $RBR%{_libdir}/mysql/mysqld.sym +install -m 755 $MBD/extra/perror $RBR%{_bindir}/perror # Install logrotate and autostart install -m 644 $MBD/support-files/mysql-log-rotate $RBR%{_sysconfdir}/logrotate.d/mysql @@ -510,11 +451,6 @@ mysql_clusterdir=/var/lib/mysql-cluster if test ! -d $mysql_clusterdir; then mkdir -m 755 $mysql_clusterdir; fi -%post Max -# Restart mysqld, to use the new binary. -echo "Restarting mysqld." -%{_sysconfdir}/init.d/mysql restart > /dev/null 2>&1 - %preun server if test $1 = 0 then @@ -546,9 +482,9 @@ fi %files server %defattr(-,root,root,0755) -%doc COPYING README -%doc support-files/my-*.cnf -%doc support-files/ndb-*.ini +%doc mysql-release-%{mysql_version}/COPYING mysql-release-%{mysql_version}/README +%doc mysql-release-%{mysql_version}/support-files/my-*.cnf +%doc mysql-release-%{mysql_version}/support-files/ndb-*.ini %doc %attr(644, root, root) %{_infodir}/mysql.info* @@ -597,9 +533,9 @@ fi %attr(755, root, root) %{_bindir}/safe_mysqld %attr(755, root, root) %{_sbindir}/mysqld +%attr(755, root, root) %{_sbindir}/mysqld-debug %attr(755, root, root) %{_sbindir}/mysqlmanager %attr(755, root, root) %{_sbindir}/rcmysql -%attr(644, root, root) %{_libdir}/mysql/mysqld.sym %attr(644, root, root) %config(noreplace,missingok) %{_sysconfdir}/logrotate.d/mysql %attr(755, root, root) %{_sysconfdir}/init.d/mysql @@ -631,6 +567,7 @@ fi %doc %attr(644, root, man) %{_mandir}/man1/mysqldump.1* %doc %attr(644, root, man) %{_mandir}/man1/mysqlimport.1* %doc %attr(644, root, man) %{_mandir}/man1/mysqlshow.1* +%doc %attr(644, root, man) %{_mandir}/man1/mysqlslap.1* %post shared /sbin/ldconfig @@ -666,7 +603,7 @@ fi %files devel %defattr(-, root, root, 0755) -%doc EXCEPTIONS-CLIENT +%doc mysql-release-%{mysql_version}/EXCEPTIONS-CLIENT %doc %attr(644, root, man) %{_mandir}/man1/mysql_config.1* %attr(755, root, root) %{_bindir}/comp_err %attr(755, root, root) %{_bindir}/mysql_config @@ -675,9 +612,6 @@ fi %{_includedir}/mysql/* %{_libdir}/mysql/libdbug.a %{_libdir}/mysql/libheap.a -%if %{have_libgcc} -%{_libdir}/mysql/libmygcc.a -%endif %{_libdir}/mysql/libmyisam.a %{_libdir}/mysql/libmyisammrg.a %{_libdir}/mysql/libmysqlclient.a @@ -706,11 +640,6 @@ fi %attr(755, root, root) %{_bindir}/mysqltestmanager-pwgen %attr(755, root, root) %{_bindir}/mysqltestmanagerc -%files Max -%defattr(-, root, root, 0755) -%attr(755, root, root) %{_sbindir}/mysqld-max -%attr(644, root, root) %{_libdir}/mysql/mysqld-max.sym - %files embedded %defattr(-, root, root, 0755) # %attr(644, root, root) %{_libdir}/mysql/libmysqld.a @@ -719,7 +648,25 @@ fi # itself - note that they must be ordered by date (important when # merging BK trees) %changelog -* Fri Dec 12 2005 Rodrigo Novo <rodrigo@mysql.com> +* Mon Feb 13 2006 Joerg Bruehe <joerg@mysql.com> + +- Use "-i" on "make test-force"; + this is essential for later evaluation of this log file. + +* Thu Feb 09 2006 Kent Boortz <kent@mysql.com> + +- Pass '-static' to libtool, link static with our own libraries, dynamic + with system libraries. Link with the bundled zlib. + +* Wed Feb 08 2006 Kristian Nielsen <knielsen@mysql.com> + +- Modified RPM spec to match new 5.1 debug+max combined community packaging. + +* Sun Dec 18 2005 Kent Boortz <kent@mysql.com> + +- Added "client/mysqlslap" + +* Mon Dec 12 2005 Rodrigo Novo <rodrigo@mysql.com> - Added zlib to the list of (static) libraries installed - Added check against libtool wierdness (WRT: sql/mysqld || sql/.libs/mysqld) diff --git a/tests/fork_big.pl b/tests/fork_big.pl index c72eb59946b..5c4f11b00e2 100755 --- a/tests/fork_big.pl +++ b/tests/fork_big.pl @@ -65,7 +65,7 @@ if (!$opt_skip_create) } # Create the table we use to signal that we should end the test $dbh->do("drop table if exists $abort_table"); - $dbh->do("create table $abort_table (id int(6) not null) type=heap") || + $dbh->do("create table $abort_table (id int(6) not null) ENGINE=heap") || die $DBI::errstr; } diff --git a/tests/fork_big2.pl b/tests/fork_big2.pl index 567cfafa176..8a0c5e317a0 100644 --- a/tests/fork_big2.pl +++ b/tests/fork_big2.pl @@ -89,7 +89,7 @@ if (!$opt_skip_create) } # Create the table we use to signal that we should end the test $dbh->do("drop table if exists $abort_table"); - $dbh->do("create table $abort_table (id int(6) not null) type=heap") || + $dbh->do("create table $abort_table (id int(6) not null) ENGINE=heap") || die $DBI::errstr; } diff --git a/tests/mail_to_db.pl b/tests/mail_to_db.pl index 5ceda392313..e50415d96f3 100755 --- a/tests/mail_to_db.pl +++ b/tests/mail_to_db.pl @@ -253,7 +253,7 @@ CREATE TABLE my_mail KEY (message_id), KEY (in_reply_to), PRIMARY KEY (mail_from, date, hash)) - TYPE=MyISAM COMMENT='' + ENGINE=MyISAM COMMENT='' EOF $sth = $dbh->prepare($query) or die $DBI::errstr; $sth->execute() or die "Couldn't create table: $DBI::errstr\n"; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index e118289101e..e737cad0ef1 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -1201,7 +1201,7 @@ static void test_tran_bdb() /* create the table 'mytran_demo' of type BDB' or 'InnoDB' */ rc= mysql_query(mysql, "CREATE TABLE my_demo_transaction( " - "col1 int , col2 varchar(30)) TYPE= BDB"); + "col1 int , col2 varchar(30)) ENGINE= BDB"); myquery(rc); /* insert a row and commit the transaction */ @@ -1274,7 +1274,7 @@ static void test_tran_innodb() /* create the table 'mytran_demo' of type BDB' or 'InnoDB' */ rc= mysql_query(mysql, "CREATE TABLE my_demo_transaction(col1 int, " - "col2 varchar(30)) TYPE= InnoDB"); + "col2 varchar(30)) ENGINE= InnoDB"); myquery(rc); /* insert a row and commit the transaction */ @@ -9798,7 +9798,7 @@ static void test_derived() myquery(rc); rc= mysql_query(mysql, "create table t1 (id int(8), primary key (id)) \ -TYPE=InnoDB DEFAULT CHARSET=utf8"); +ENGINE=InnoDB DEFAULT CHARSET=utf8"); myquery(rc); rc= mysql_query(mysql, "insert into t1 values (1)"); @@ -9846,16 +9846,16 @@ static void test_xjoin() rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2, t3, t4"); myquery(rc); - rc= mysql_query(mysql, "create table t3 (id int(8), param1_id int(8), param2_id int(8)) TYPE=InnoDB DEFAULT CHARSET=utf8"); + rc= mysql_query(mysql, "create table t3 (id int(8), param1_id int(8), param2_id int(8)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); myquery(rc); - rc= mysql_query(mysql, "create table t1 ( id int(8), name_id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8"); + rc= mysql_query(mysql, "create table t1 ( id int(8), name_id int(8), value varchar(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); myquery(rc); - rc= mysql_query(mysql, "create table t2 (id int(8), name_id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8;"); + rc= mysql_query(mysql, "create table t2 (id int(8), name_id int(8), value varchar(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); myquery(rc); - rc= mysql_query(mysql, "create table t4(id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8"); + rc= mysql_query(mysql, "create table t4(id int(8), value varchar(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); myquery(rc); rc= mysql_query(mysql, "insert into t3 values (1, 1, 1), (2, 2, null)"); @@ -14387,7 +14387,7 @@ static void test_bug14210() itself is not InnoDB related. In case the table is MyISAM this test is harmless. */ - mysql_query(mysql, "create table t1 (a varchar(255)) type=InnoDB"); + mysql_query(mysql, "create table t1 (a varchar(255)) engine=InnoDB"); rc= mysql_query(mysql, "insert into t1 (a) values (repeat('a', 256))"); myquery(rc); rc= mysql_query(mysql, "set @@session.max_heap_table_size=16384"); @@ -14697,6 +14697,38 @@ static void test_opt_reconnect() mysql_close(lmysql); } + +static void test_bug12744() +{ + MYSQL_STMT *prep_stmt = NULL; + int rc; + myheader("test_bug12744"); + + prep_stmt= mysql_stmt_init(mysql); + rc= mysql_stmt_prepare(prep_stmt, "SELECT 1", 8); + DIE_UNLESS(rc==0); + + mysql_close(mysql); + + if (rc= mysql_stmt_execute(prep_stmt)) + { + if (rc= mysql_stmt_reset(prep_stmt)) + printf("OK!\n"); + else + { + printf("Error!"); + DIE_UNLESS(1==0); + } + } + else + { + fprintf(stderr, "expected error but no error occured\n"); + DIE_UNLESS(1==0); + } + rc= mysql_stmt_close(prep_stmt); + client_connect(0); +} + /* Bug #16144: mysql_stmt_attr_get type error */ static void test_bug16144() @@ -14711,6 +14743,7 @@ static void test_bug16144() mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (const void*) &flag); mysql_stmt_attr_get(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void*) &flag); DIE_UNLESS(flag == flag_orig); + mysql_stmt_close(stmt); } @@ -15038,6 +15071,7 @@ static struct my_tests_st my_tests[]= { { "test_bug14845", test_bug14845 }, { "test_opt_reconnect", test_opt_reconnect }, { "test_bug15510", test_bug15510}, + { "test_bug12744", test_bug12744 }, { "test_bug16144", test_bug16144 }, { "test_bug15613", test_bug15613 }, { 0, 0 } diff --git a/win/cmakefiles/base b/win/cmakefiles/base index 20f9307e79c..4430ac0ec46 100644 --- a/win/cmakefiles/base +++ b/win/cmakefiles/base @@ -2,12 +2,34 @@ PROJECT(MySql) EXEC_PROGRAM(cscript.exe win ARGS config-version.js OUT_VARIABLE out) -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4996 -D_DEBUG") -SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /wd4996 -D_DEBUG") +# in some places we use DBUG_OFF +SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D DBUG_OFF") +SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D DBUG_OFF") + +IF(CMAKE_GENERATOR MATCHES "Visual Studio 8") + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4996") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /wd4996") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /wd4996") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /wd4996") +ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8") + +IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8") + # replace /MDd with /MTd + STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG_INIT ${CMAKE_C_FLAGS_DEBUG_INIT}) + STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) + STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) + + # remove support for Exception handling + STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT}) + STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT}) +ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8") -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /wd4996 -DDBUG_OFF -DNDEBUG") -SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /wd4996 -DDBUG_OFF -DNDEBUG") ADD_DEFINITIONS("-D_WINDOWS -D__WIN__") -SUBDIRS(vio dbug strings regex mysys zlib storage/innobase storage/heap storage/myisam storage/myisammrg - extra extra/yassl extra/yassl/taocrypt client sql) +SUBDIRS(vio dbug strings regex mysys extra zlib storage/innobase storage/heap storage/myisam storage/myisammrg + extra/yassl extra/yassl/taocrypt client sql server-tools/instance-manager) diff --git a/win/cmakefiles/client b/win/cmakefiles/client index a3bc2576ebc..7c0c6f2400b 100644 --- a/win/cmakefiles/client +++ b/win/cmakefiles/client @@ -2,7 +2,11 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") ADD_DEFINITIONS(-DUSE_TLS -DMYSQL_CLIENT) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/extra/yassl/include ${CMAKE_SOURCE_DIR}/libmysql) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/zlib + ${CMAKE_SOURCE_DIR}/extra/yassl/include + ${CMAKE_SOURCE_DIR}/libmysql) + ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c @@ -37,9 +41,9 @@ ADD_LIBRARY(mysqlclient ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c - ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c - ${CMAKE_SOURCE_DIR}/include/mysql_version.h) + ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c) +ADD_DEPENDENCIES(mysqlclient GenError) ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc) LINK_DIRECTORIES(${MYSQL_BINARY_DIR}/mysys ${MYSQL_BINARY_DIR}/zlib) TARGET_LINK_LIBRARIES(mysql mysqlclient mysys yassl zlib dbug yassl taocrypt wsock32) diff --git a/win/cmakefiles/dbug b/win/cmakefiles/dbug index 5c927d4e13f..fe20fdd3db6 100644 --- a/win/cmakefiles/dbug +++ b/win/cmakefiles/dbug @@ -1,5 +1,5 @@ -SET(CMAKE_CXX_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX -D__WIN32__") -SET(CMAKE_C_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -D__WIN32__") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) ADD_LIBRARY(dbug dbug.c factorial.c sanity.c) diff --git a/win/cmakefiles/deploy.bat b/win/cmakefiles/deploy.bat index 52a921a7188..cb55b8cdb12 100644 --- a/win/cmakefiles/deploy.bat +++ b/win/cmakefiles/deploy.bat @@ -16,4 +16,4 @@ copy heap ..\..\storage\heap\cmakelists.txt copy innobase ..\..\storage\innobase\cmakelists.txt copy myisam ..\..\storage\myisam\cmakelists.txt copy myisammrg ..\..\storage\myisammrg\cmakelists.txt - +copy im ..\..\server-tools\instance-manager\cmakelists.txt diff --git a/win/cmakefiles/extra b/win/cmakefiles/extra index d73d961e7b6..40327eac0ad 100644 --- a/win/cmakefiles/extra +++ b/win/cmakefiles/extra @@ -1,9 +1,21 @@ -SET(CMAKE_CXX_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") -SET(CMAKE_C_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) ADD_EXECUTABLE(comp_err comp_err.c) TARGET_LINK_LIBRARIES(comp_err dbug mysys strings wsock32) +GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION) + +ADD_CUSTOM_TARGET(GenError + ${COMP_ERR_EXE} --charset=${PROJECT_SOURCE_DIR}/sql/share/charsets + --out-dir=${PROJECT_SOURCE_DIR}/sql/share/ + --header_file=${PROJECT_SOURCE_DIR}/include/mysqld_error.h + --name_file=${PROJECT_SOURCE_DIR}/include/mysqld_ername.h + --state_file=${PROJECT_SOURCE_DIR}/include/sql_state.h + --in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt + DEPENDS comp_err ${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt) + + diff --git a/win/cmakefiles/im b/win/cmakefiles/im new file mode 100644 index 00000000000..32f243b43d9 --- /dev/null +++ b/win/cmakefiles/im @@ -0,0 +1,16 @@ +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +ADD_DEFINITIONS(-DMYSQL_SERVER -DMYSQL_INSTANCE_MANAGER) +INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/sql) + +ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instance.cc instance_map.cc + instance_options.cc listener.cc log.cc manager.cc messages.cc mysql_connection.cc + mysqlmanager.cc options.cc parse.cc parse_output.cc priv.cc protocol.cc + thread_registry.cc user_map.cc imservice.cpp windowsservice.cpp + ../../sql/net_serv.cc ../../sql-common/pack.c ../../sql/password.c + ../../sql/sql_state.c ../../sql-common/client.c ../../libmysql/get_password.c + ../../libmysql/errmsg.c) + +ADD_DEPENDENCIES(mysqlmanager GenError) +TARGET_LINK_LIBRARIES(mysqlmanager dbug mysys strings taocrypt vio yassl zlib wsock32) diff --git a/win/cmakefiles/myisam b/win/cmakefiles/myisam index f8935ed6400..80fe4e81138 100644 --- a/win/cmakefiles/myisam +++ b/win/cmakefiles/myisam @@ -1,5 +1,5 @@ -SET(CMAKE_CXX_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") -SET(CMAKE_C_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) ADD_LIBRARY(myisam ft_boolean_search.c ft_nlq_search.c ft_parser.c ft_static.c ft_stem.c diff --git a/win/cmakefiles/myisammrg b/win/cmakefiles/myisammrg index 6d7fb22e174..83168f6c60c 100644 --- a/win/cmakefiles/myisammrg +++ b/win/cmakefiles/myisammrg @@ -1,5 +1,5 @@ -SET(CMAKE_CXX_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") -SET(CMAKE_C_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) ADD_LIBRARY(myisammrg myrg_close.c myrg_create.c myrg_delete.c myrg_extra.c myrg_info.c diff --git a/win/cmakefiles/regex b/win/cmakefiles/regex index 9702a787440..77b3d05f55e 100644 --- a/win/cmakefiles/regex +++ b/win/cmakefiles/regex @@ -1,7 +1,5 @@ -SET(CMAKE_C_FLAGS_DEBUG "-D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX") -SET(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX") -SET(CMAKE_C_FLAGS_RELEASE "-DDBUG_OFF -DNDEBUG") -SET(CMAKE_CXX_FLAGS_RELEASE "-DDBUG_OFF -DNDEBUG") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX") ADD_DEFINITIONS(-D_WINDOWS -D__WIN__) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) diff --git a/win/cmakefiles/sql b/win/cmakefiles/sql index f583b6f8dee..ee53436a1a6 100644 --- a/win/cmakefiles/sql +++ b/win/cmakefiles/sql @@ -1,18 +1,23 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR") -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/extra/yassl/include ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/regex ${CMAKE_SOURCE_DIR}/zlib) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/extra/yassl/include + ${CMAKE_SOURCE_DIR}/sql + ${CMAKE_SOURCE_DIR}/regex + ${CMAKE_SOURCE_DIR}/zlib) SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/sql/message.rc ${CMAKE_SOURCE_DIR}/sql/message.h ${CMAKE_SOURCE_DIR}/sql/sql_yacc.h ${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc - ${CMAKE_SOURCE_DIR}/include/mysqld_error.h - ${CMAKE_SOURCE_DIR}/include/mysqld_ername.h - ${CMAKE_SOURCE_DIR}/include/sql_state.h ${CMAKE_SOURCE_DIR}/include/mysql_version.h ${CMAKE_SOURCE_DIR}/sql/handlerton.cc - ${CMAKE_SOURCE_DIR}/sql/lex_hash.h PROPERTIES GENERATED 1) + ${CMAKE_SOURCE_DIR}/sql/lex_hash.h + ${PROJECT_SOURCE_DIR}/include/mysqld_error.h + ${PROJECT_SOURCE_DIR}/include/mysqld_ername.h + ${PROJECT_SOURCE_DIR}/include/sql_state.h PROPERTIES GENERATED 1) + ADD_DEFINITIONS(-DWITH_INNOBASE_STORAGE_ENGINE -DHAVE_ARCHIVE_DB -DHAVE_BLACKHOLE_DB -DHAVE_EXAMPLE_DB) ADD_DEFINITIONS(-DHAVE_ROW_BASED_REPLICATION -DHAVE_FEDERATED_DB -DMYSQL_SERVER -D_CONSOLE -DHAVE_DLOPEN -DWITH_PARTITION_STORAGE_ENGINE -D_CRT_SECURE_NO_DEPRECATE) @@ -36,27 +41,28 @@ ADD_EXECUTABLE(mysqld ../sql-common/client.c derror.cc des_key_file.cc discover. sql_update.cc sql_view.cc sql_yacc.h sql_yacc.cc strfunc.cc table.cc thr_malloc.cc time.cc tztime.cc uniques.cc unireg.cc item_xmlfunc.cc rpl_tblmap.cc sql_binlog.cc event_executor.cc event_timed.cc sql_tablespace.cc event.cc ../sql-common/my_user.c - ${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc - ${CMAKE_SOURCE_DIR}/sql/sql_yacc.h - ${CMAKE_SOURCE_DIR}/include/mysqld_error.h - ${CMAKE_SOURCE_DIR}/include/mysqld_ername.h - ${CMAKE_SOURCE_DIR}/include/sql_state.h - ${CMAKE_SOURCE_DIR}/include/mysql_version.h - ${CMAKE_SOURCE_DIR}/sql/handlerton.cc - ${CMAKE_SOURCE_DIR}/sql/lex_hash.h) + ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc + ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h + ${PROJECT_SOURCE_DIR}/include/mysqld_error.h + ${PROJECT_SOURCE_DIR}/include/mysqld_ername.h + ${PROJECT_SOURCE_DIR}/include/sql_state.h + ${PROJECT_SOURCE_DIR}/include/mysql_version.h + ${PROJECT_SOURCE_DIR}/sql/handlerton.cc + ${PROJECT_SOURCE_DIR}/sql/lex_hash.h) TARGET_LINK_LIBRARIES(mysqld heap myisam myisammrg innobase mysys yassl zlib dbug yassl taocrypt strings vio regex wsock32) +ADD_DEPENDENCIES(mysqld GenError) # Sql Parser custom command ADD_CUSTOM_COMMAND( - SOURCE ${CMAKE_SOURCE_DIR}/sql/sql_yacc.yy - OUTPUT ${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc + SOURCE ${PROJECT_SOURCE_DIR}/sql/sql_yacc.yy + OUTPUT ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc COMMAND bison.exe ARGS --defines=sql_yacc.h --output=sql_yacc.cc sql_yacc.yy - DEPENDS ${CMAKE_SOURCE_DIR}/sql/sql_yacc.yy) + DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.yy) ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_SOURCE_DIR}/sql/sql_yacc.h + OUTPUT ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h COMMAND echo - DEPENDS ${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc + DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc ) # Windows message file @@ -67,44 +73,44 @@ ADD_CUSTOM_COMMAND( DEPENDS ../VC++Files/sql/message.mc) # MySql_version.h. -ADD_CUSTOM_COMMAND( - SOURCE ${CMAKE_SOURCE_DIR}/include/mysql_version.h.in - OUTPUT ${CMAKE_SOURCE_DIR}/include/mysql_version.h - COMMAND ${CMAKE_SOURCE_DIR}/win/config-version.js - DEPENDS ${CMAKE_SOURCE_DIR}/include/mysql_version.h.in) +#ADD_CUSTOM_COMMAND( +# SOURCE ${PROJECT_SOURCE_DIR}/include/mysql_version.h.in +# OUTPUT ${PROJECT_SOURCE_DIR}/include/mysql_version.h +# COMMAND ${PROJECT_SOURCE_DIR}/win/config-version.js +# DEPENDS ${PROJECT_SOURCE_DIR}/include/mysql_version.h.in) # Handlerton file ADD_CUSTOM_COMMAND( - SOURCE ${CMAKE_SOURCE_DIR}/sql/handlerton.cc.in - OUTPUT ${CMAKE_SOURCE_DIR}/sql/handlerton.cc - COMMAND ${CMAKE_SOURCE_DIR}/win/config-handlerton.js ARGS ${CMAKE_SOURCE_DIR}/win/configure.data - DEPENDS ${CMAKE_SOURCE_DIR}/sql/handlerton.cc.in) + SOURCE ${PROJECT_SOURCE_DIR}/sql/handlerton.cc.in + OUTPUT ${PROJECT_SOURCE_DIR}/sql/handlerton.cc + COMMAND ${PROJECT_SOURCE_DIR}/win/config-handlerton.js ARGS ${PROJECT_SOURCE_DIR}/win/configure.data + DEPENDS ${PROJECT_SOURCE_DIR}/sql/handlerton.cc.in) # Error file -GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION) -ADD_CUSTOM_COMMAND( - SOURCE ${CMAKE_SOURCE_DIR}/sql/share/errmsg.txt - OUTPUT ${CMAKE_SOURCE_DIR}/include/mysqld_error.h - COMMAND ${COMP_ERR_EXE} - ARGS --charset=${CMAKE_SOURCE_DIR}/sql/share/charsets - --out-dir=${CMAKE_SOURCE_DIR}/sql/share/ - --header_file=${CMAKE_SOURCE_DIR}/include/mysqld_error.h - --name_file=${CMAKE_SOURCE_DIR}/include/mysqld_ername.h - --state_file=${CMAKE_SOURCE_DIR}/include/sql_state.h - --in_file=${CMAKE_SOURCE_DIR}/sql/share/errmsg.txt - DEPENDS ${COMP_ERR_EXE} share/errmsg.txt) +#GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION) +#ADD_CUSTOM_COMMAND( + #SOURCE ${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt + #OUTPUT ${PROJECT_SOURCE_DIR}/include/mysqld_error.h + #COMMAND ${COMP_ERR_EXE} + #ARGS --charset=${PROJECT_SOURCE_DIR}/sql/share/charsets + # --out-dir=${PROJECT_SOURCE_DIR}/sql/share/ +## --header_file=${PROJECT_SOURCE_DIR}/include/mysqld_error.h +# --name_file=${PROJECT_SOURCE_DIR}/include/mysqld_ername.h +# --state_file=${PROJECT_SOURCE_DIR}/include/sql_state.h + # --in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt + # DEPENDS ${COMP_ERR_EXE} share/errmsg.txt) -ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_SOURCE_DIR}/include/mysqld_ername.h - COMMAND echo - DEPENDS ${CMAKE_SOURCE_DIR}/include/mysqld_error.h -) +#ADD_CUSTOM_COMMAND( +# OUTPUT ${PROJECT_SOURCE_DIR}/include/mysqld_ername.h +# COMMAND echo +# DEPENDS ${PROJECT_SOURCE_DIR}/include/mysqld_error.h +#) -ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_SOURCE_DIR}/include/sql_state.h - COMMAND echo - DEPENDS ${CMAKE_SOURCE_DIR}/include/mysqld_ername.h -) +#ADD_CUSTOM_COMMAND( +# OUTPUT ${PROJECT_SOURCE_DIR}/include/sql_state.h +# COMMAND echo +# DEPENDS ${PROJECT_SOURCE_DIR}/include/mysqld_ername.h +#) # Gen_lex_hash @@ -112,7 +118,9 @@ ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc) TARGET_LINK_LIBRARIES(gen_lex_hash dbug mysqlclient wsock32) GET_TARGET_PROPERTY(GEN_LEX_HASH_EXE gen_lex_hash LOCATION) ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_SOURCE_DIR}/sql/lex_hash.h + OUTPUT ${PROJECT_SOURCE_DIR}/sql/lex_hash.h COMMAND ${GEN_LEX_HASH_EXE} ARGS > lex_hash.h DEPENDS ${GEN_LEX_HASH_EXE} ) + +ADD_DEPENDENCIES(mysqld gen_lex_hash) diff --git a/win/cmakefiles/taocrypt b/win/cmakefiles/taocrypt index 96449e412d0..6f4d0395ff6 100644 --- a/win/cmakefiles/taocrypt +++ b/win/cmakefiles/taocrypt @@ -1,4 +1,8 @@ INCLUDE_DIRECTORIES(../mySTL include) + +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /GX-") +SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GX-") + ADD_LIBRARY(taocrypt src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp src/asn.cpp src/coding.cpp src/des.cpp src/dh.cpp src/dsa.cpp src/file.cpp src/hash.cpp src/integer.cpp src/md2.cpp src/md5.cpp src/misc.cpp src/random.cpp src/ripemd.cpp src/rsa.cpp src/sha.cpp diff --git a/win/cmakefiles/vio b/win/cmakefiles/vio index c11042b08e4..91b51e3793d 100644 --- a/win/cmakefiles/vio +++ b/win/cmakefiles/vio @@ -1,8 +1,5 @@ -SET(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR") -SET(CMAKE_C_FLAGS_DEBUG "-D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR") - -SET(CMAKE_CXX_FLAGS_RELEASE "-DDBUG_OFF -DNDEBUG") -SET(CMAKE_C_FLAGS_RELEASE "-DDBUG_OFF -DNDEBUG") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR") ADD_DEFINITIONS(-D_WINDOWS -D__WIN__) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/extra/yassl/include) diff --git a/win/cmakefiles/zlib b/win/cmakefiles/zlib index d2de8908fed..2a3abacd3c2 100644 --- a/win/cmakefiles/zlib +++ b/win/cmakefiles/zlib @@ -1,8 +1,5 @@ -SET(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG __WIN32__") -SET(CMAKE_C_FLAGS_DEBUG "-D_DEBUG __WIN32__") - -SET(CMAKE_CXX_FLAGS_RELEASE "-DDBUG_OFF -DNDEBUG") -SET(CMAKE_C_FLAGS_RELEASE "-DDBUG_OFF -DNDEBUG") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -D __WIN32__") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -D __WIN32__") ADD_DEFINITIONS(-DUSE_TLS -DMYSQL_CLIENT -D_WINDOWS -D__WIN__) ADD_LIBRARY(zlib adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.c infback.c inffast.c inffast.h |