diff options
509 files changed, 12832 insertions, 4219 deletions
diff --git a/BUILD/check-cpu b/BUILD/check-cpu index 33bf857b845..9fa48adfb5f 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -47,8 +47,13 @@ check_cpu () { model_name=`sysctl -n hw.model` ;; Darwin) - cpu_family=`uname -p` - model_name=`machine` + cpu_family=`sysctl -n machdep.cpu.vendor` + model_name=`sysctl -n machdep.cpu.brand_string` + if [ -z "$cpu_family" -o -z "$model_name" ] + then + cpu_family=`uname -p` + model_name=`machine` + fi ;; *) cpu_family=`uname -m`; diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c173c9cb49..e4dc16040a7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,10 @@ SET(WITH_MYISAMMRG_STORAGE_ENGINE TRUE) ADD_DEFINITIONS(-DWITH_MYISAMMRG_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisammrg_plugin") +IF(WITH_COMMUNITY_FEATURES) + ADD_DEFINITIONS(-DENABLED_PROFILING -DCOMMUNITY_SERVER) +ENDIF(WITH_COMMUNITY_FEATURES) + IF(WITH_ARCHIVE_STORAGE_ENGINE) ADD_DEFINITIONS(-DWITH_ARCHIVE_STORAGE_ENGINE) SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_archive_plugin") @@ -1,11 +1,19 @@ This is a release of MySQL, a dual-license SQL database server. -MySQL is brought to you by the MySQL team at MySQL AB. +MySQL is brought to you by the MySQL team at Sun Microsystems, Inc. License information can be found in these files: - For GPL (free) distributions, see the COPYING file and the EXCEPTIONS-CLIENT file. - For commercial distributions, see the LICENSE.mysql file. +GPLv2 Disclaimer +For the avoidance of doubt, except that if any license choice +other than GPL or LGPL is available it will apply instead, Sun +elects to use only the General Public License version 2 (GPLv2) +at this time for any software where a choice of GPL license versions +is made available with the language indicating that GPLv2 or any +later version may be used, or where a choice of which version of +the GPL is applied is otherwise unspecified. For further information about MySQL or additional documentation, see: - The latest information about MySQL: http://www.mysql.com diff --git a/client/Makefile.am b/client/Makefile.am index ab5bc8d601a..ecdd010575f 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -80,14 +80,14 @@ mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ mysqlshow_SOURCES= mysqlshow.c mysqlslap_SOURCES= mysqlslap.c -mysqlslap_CFLAGS= -DTHREAD -UUNDEF_THREADS_HACK +mysqlslap_CFLAGS= -DTHREAD -UMYSQL_CLIENT_NO_THREADS mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ @CLIENT_EXTRA_LDFLAGS@ \ $(LIBMYSQLCLIENT_LA) \ $(top_builddir)/mysys/libmysys.a mysqltest_SOURCES= mysqltest.cc -mysqltest_CXXFLAGS= -DTHREAD -UUNDEF_THREADS_HACK +mysqltest_CXXFLAGS= -DTHREAD -UMYSQL_CLIENT_NO_THREADS mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ @CLIENT_EXTRA_LDFLAGS@ \ $(LIBMYSQLCLIENT_LA) \ @@ -99,7 +99,7 @@ mysql_upgrade_SOURCES= mysql_upgrade.c \ $(top_srcdir)/mysys/my_getpagesize.c # Fix for mit-threads -DEFS = -DUNDEF_THREADS_HACK \ +DEFS = -DMYSQL_CLIENT_NO_THREADS \ -DDEFAULT_MYSQL_HOME="\"$(prefix)\"" \ -DDATADIR="\"$(localstatedir)\"" diff --git a/client/mysql.cc b/client/mysql.cc index 8de3cfee041..5afbc2e960b 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -115,7 +115,7 @@ extern "C" { #define PROMPT_CHAR '\\' #define DEFAULT_DELIMITER ";" -#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L) +#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L * 1024L) typedef struct st_status { @@ -143,7 +143,8 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0, tty_password= 0, opt_nobeep=0, opt_reconnect=1, default_charset_used= 0, opt_secure_auth= 0, default_pager_set= 0, opt_sigint_ignore= 0, - show_warnings= 0, executing_query= 0, interrupted_query= 0; + show_warnings= 0, executing_query= 0, interrupted_query= 0, + ignore_spaces= 0; static my_bool debug_info_flag, debug_check_flag; static my_bool column_types_flag; static my_bool preserve_comments= 0; @@ -1378,8 +1379,9 @@ static struct my_option my_long_options[] = {"no-named-commands", 'g', "Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"ignore-spaces", 'i', "Ignore space after function names.", 0, 0, 0, - GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"ignore-spaces", 'i', "Ignore space after function names.", + (uchar**) &ignore_spaces, (uchar**) &ignore_spaces, 0, GET_BOOL, NO_ARG, 0, 0, + 0, 0, 0, 0}, {"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE.", (uchar**) &opt_local_infile, (uchar**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -1800,6 +1802,10 @@ static int get_options(int argc, char **argv) my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; if (debug_check_flag) my_end_arg= MY_CHECK_ERROR; + + if (ignore_spaces) + connect_flag|= CLIENT_IGNORE_SPACE; + return(0); } @@ -1973,7 +1979,7 @@ static COMMANDS *find_command(char *name,char cmd_char) */ if (strstr(name, "\\g") || (strstr(name, delimiter) && !(strlen(name) >= 9 && - !my_strnncoll(charset_info, + !my_strnncoll(&my_charset_latin1, (uchar*) name, 9, (const uchar*) "delimiter", 9)))) @@ -1994,11 +2000,11 @@ static COMMANDS *find_command(char *name,char cmd_char) { if (commands[i].func && ((name && - !my_strnncoll(charset_info,(uchar*)name,len, + !my_strnncoll(&my_charset_latin1, (uchar*)name, len, (uchar*)commands[i].name,len) && !commands[i].name[len] && (!end || (end && commands[i].takes_params))) || - !name && commands[i].cmd_char == cmd_char)) + (!name && commands[i].cmd_char == cmd_char))) { DBUG_PRINT("exit",("found command: %s", commands[i].name)); DBUG_RETURN(&commands[i]); @@ -2157,7 +2163,7 @@ static bool add_line(String &buffer,char *line,char *in_string, buffer.length(0); } else if (!*ml_comment && (!*in_string && (inchar == '#' || - inchar == '-' && pos[1] == '-' && + (inchar == '-' && pos[1] == '-' && /* The third byte is either whitespace or is the end of the line -- which would occur only @@ -2165,7 +2171,7 @@ static bool add_line(String &buffer,char *line,char *in_string, itself whitespace and should also match. */ (my_isspace(charset_info,pos[2]) || - !pos[2])))) + !pos[2]))))) { // Flush previously accepted characters if (out != line) @@ -2726,7 +2732,7 @@ static int com_server_help(String *buffer __attribute__((unused)), { MYSQL_ROW cur; const char *server_cmd= buffer->ptr(); - char cmd_buf[100]; + char cmd_buf[100 + 1]; MYSQL_RES *result; int error; @@ -4258,41 +4264,36 @@ com_status(String *buffer __attribute__((unused)), MYSQL_RES *result; LINT_INIT(result); + if (mysql_real_query_for_lazy( + C_STRING_WITH_LEN("select DATABASE(), USER() limit 1"))) + return 0; + tee_puts("--------------", stdout); usage(1); /* Print version */ - if (connected) + tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql)); + /* + Don't remove "limit 1", + it is protection againts SQL_SELECT_LIMIT=0 + */ + if (mysql_store_result_for_lazy(&result)) { - tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql)); - /* - Don't remove "limit 1", - it is protection againts SQL_SELECT_LIMIT=0 - */ - if (!mysql_query(&mysql,"select DATABASE(), USER() limit 1") && - (result=mysql_use_result(&mysql))) + MYSQL_ROW cur=mysql_fetch_row(result); + if (cur) { - MYSQL_ROW cur=mysql_fetch_row(result); - if (cur) - { - tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : ""); - tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]); - } - mysql_free_result(result); - } -#ifdef HAVE_OPENSSL - if ((status_str= mysql_get_ssl_cipher(&mysql))) - tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n", - status_str); - else -#endif /* HAVE_OPENSSL */ - tee_puts("SSL:\t\t\tNot in use", stdout); + tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : ""); + tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]); + } + mysql_free_result(result); } + +#ifdef HAVE_OPENSSL + if ((status_str= mysql_get_ssl_cipher(&mysql))) + tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n", + status_str); else - { - vidattr(A_BOLD); - tee_fprintf(stdout, "\nNo connection\n"); - vidattr(A_NORMAL); - return 0; - } +#endif /* HAVE_OPENSSL */ + tee_puts("SSL:\t\t\tNot in use", stdout); + if (skip_updates) { vidattr(A_BOLD); @@ -4311,8 +4312,14 @@ com_status(String *buffer __attribute__((unused)), tee_fprintf(stdout, "Insert id:\t\t%s\n", llstr(id, buff)); /* "limit 1" is protection against SQL_SELECT_LIMIT=0 */ - if (!mysql_query(&mysql,"select @@character_set_client, @@character_set_connection, @@character_set_server, @@character_set_database limit 1") && - (result=mysql_use_result(&mysql))) + if (mysql_real_query_for_lazy(C_STRING_WITH_LEN( + "select @@character_set_client, @@character_set_connection, " + "@@character_set_server, @@character_set_database limit 1"))) + { + if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) + return 0; + } + if (mysql_store_result_for_lazy(&result)) { MYSQL_ROW cur=mysql_fetch_row(result); if (cur) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index cbc60d8acad..641d4a38d16 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -39,6 +39,7 @@ static uint my_end_arg= 0; static char *opt_user= (char*)"root"; static DYNAMIC_STRING ds_args; +static DYNAMIC_STRING conn_args; static char *opt_password= 0; static my_bool tty_password= 0; @@ -135,6 +136,7 @@ static void free_used_memory(void) free_defaults(defaults_argv); dynstr_free(&ds_args); + dynstr_free(&conn_args); } @@ -204,7 +206,7 @@ static void add_one_option(DYNAMIC_STRING* ds, } } dynstr_append_os_quoted(ds, "--", opt->name, eq, arg, NullS); - dynstr_append(&ds_args, " "); + dynstr_append(ds, " "); } @@ -232,7 +234,7 @@ get_one_option(int optid, const struct my_option *opt, case 'p': if (argument == disabled_my_option) - argument= (char*) ""; // Don't require password + argument= (char*) ""; /* Don't require password */ tty_password= 1; add_option= FALSE; if (argument) @@ -256,6 +258,15 @@ get_one_option(int optid, const struct my_option *opt, case 'f': /* --force */ add_option= FALSE; break; + + case 'h': /* --host */ + case 'W': /* --pipe */ + case 'P': /* --port */ + case 'S': /* --socket */ + case OPT_MYSQL_PROTOCOL: /* --protocol */ + case OPT_SHARED_MEMORY_BASE_NAME: /* --shared-memory-base-name */ + add_one_option(&conn_args, opt, argument); + break; } if (add_option) @@ -604,13 +615,27 @@ static void create_mysql_upgrade_info_file(void) /* + Print connection-related arguments. +*/ + +static void print_conn_args(const char *tool_name) +{ + if (conn_args.str[0]) + verbose("Running '%s' with connection arguments: %s", tool_name, + conn_args.str); + else + verbose("Running '%s with default connection arguments", tool_name); +} + + +/* Check and upgrade(if neccessary) all tables in the server using "mysqlcheck --check-upgrade .." */ static int run_mysqlcheck_upgrade(void) { - verbose("Running 'mysqlcheck'..."); + print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", @@ -624,7 +649,7 @@ static int run_mysqlcheck_upgrade(void) static int run_mysqlcheck_fixnames(void) { - verbose("Running 'mysqlcheck'..."); + print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", @@ -753,7 +778,8 @@ int main(int argc, char **argv) strncpy(self_name, argv[0], FN_REFLEN); } - if (init_dynamic_string(&ds_args, "", 512, 256)) + if (init_dynamic_string(&ds_args, "", 512, 256) || + init_dynamic_string(&conn_args, "", 512, 256)) die("Out of memory"); load_defaults("my", load_default_groups, &argc, &argv); diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index aeaf49b5a15..82af7ca65f6 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -679,6 +679,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, { char ll_buff[21]; Log_event_type ev_type= ev->get_type_code(); + my_bool destroy_evt= TRUE; DBUG_ENTER("process_event"); print_event_info->short_form= short_form; Exit_status retval= OK_CONTINUE; @@ -687,8 +688,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, Format events are not concerned by --offset and such, we always need to read them to be able to process the wanted events. */ - if ((rec_count >= offset) && - ((my_time_t)(ev->when) >= start_datetime) || + if (((rec_count >= offset) && + ((my_time_t)(ev->when) >= start_datetime)) || (ev_type == FORMAT_DESCRIPTION_EVENT)) { if (ev_type != FORMAT_DESCRIPTION_EVENT) @@ -869,12 +870,63 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, break; } case TABLE_MAP_EVENT: + { + Table_map_log_event *map= ((Table_map_log_event *)ev); + if (shall_skip_database(map->get_db_name())) + { + print_event_info->m_table_map_ignored.set_table(map->get_table_id(), map); + destroy_evt= FALSE; + goto end; + } + } case WRITE_ROWS_EVENT: case DELETE_ROWS_EVENT: case UPDATE_ROWS_EVENT: case PRE_GA_WRITE_ROWS_EVENT: case PRE_GA_DELETE_ROWS_EVENT: case PRE_GA_UPDATE_ROWS_EVENT: + { + if (ev_type != TABLE_MAP_EVENT) + { + Rows_log_event *e= (Rows_log_event*) ev; + Table_map_log_event *ignored_map= + print_event_info->m_table_map_ignored.get_table(e->get_table_id()); + bool skip_event= (ignored_map != NULL); + + /* + end of statement check: + i) destroy/free ignored maps + ii) if skip event, flush cache now + */ + if (e->get_flags(Rows_log_event::STMT_END_F)) + { + /* + Now is safe to clear ignored map (clear_tables will also + delete original table map events stored in the map). + */ + if (print_event_info->m_table_map_ignored.count() > 0) + print_event_info->m_table_map_ignored.clear_tables(); + + /* + One needs to take into account an event that gets + filtered but was last event in the statement. If this is + the case, previous rows events that were written into + IO_CACHEs still need to be copied from cache to + result_file (as it would happen in ev->print(...) if + event was not skipped). + */ + if (skip_event) + { + if ((copy_event_cache_to_file_and_reinit(&print_event_info->head_cache, result_file) || + copy_event_cache_to_file_and_reinit(&print_event_info->body_cache, result_file))) + goto err; + } + } + + /* skip the event check */ + if (skip_event) + goto end; + } /* These events must be printed in base64 format, if printed. base64 format requires a FD event to be safe, so if no FD @@ -898,6 +950,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, goto err; } /* FALL THROUGH */ + } default: ev->print(result_file, print_event_info); } @@ -917,7 +970,8 @@ end: { if (remote_opt) ev->temp_buf= 0; - delete ev; + if (destroy_evt) /* destroy it later if not set (ignored table map) */ + delete ev; } DBUG_RETURN(retval); } @@ -1532,8 +1586,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, If reading from a remote host, ensure the temp_buf for the Log_event class is pointing to the incoming stream. */ - if (remote_opt) - ev->register_temp_buf((char*) net->read_pos + 1); + ev->register_temp_buf((char *) net->read_pos + 1); Log_event_type type= ev->get_type_code(); if (glob_description_event->binlog_version >= 3 || diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 1bdb28f5a11..c59049d8b72 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -287,7 +287,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case 'p': if (argument == disabled_my_option) - argument= (char*) ""; // Don't require password + argument= (char*) ""; /* Don't require password */ if (argument) { char *start = argument; diff --git a/client/mysqldump.c b/client/mysqldump.c index efcb1820be4..6d45d901b33 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -703,7 +703,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), #endif case 'p': if (argument == disabled_my_option) - argument= (char*) ""; // Don't require password + argument= (char*) ""; /* Don't require password */ if (argument) { char *start=argument; @@ -1397,18 +1397,19 @@ static char *cover_definer_clause_in_sp(const char *def_str, SYNOPSIS open_sql_file_for_table name name of the table or view + flags flags (as per "man 2 open") RETURN VALUES 0 Failed to open file > 0 Handle of the open file */ -static FILE* open_sql_file_for_table(const char* table) +static FILE* open_sql_file_for_table(const char* table, int flags) { FILE* res; char filename[FN_REFLEN], tmp_path[FN_REFLEN]; convert_dirname(tmp_path,path,NullS); res= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4), - O_WRONLY, MYF(MY_WME)); + flags, MYF(MY_WME)); return res; } @@ -2290,7 +2291,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, if (path) { - if (!(sql_file= open_sql_file_for_table(table))) + if (!(sql_file= open_sql_file_for_table(table, O_WRONLY))) DBUG_RETURN(0); write_header(sql_file, db); @@ -2501,7 +2502,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, { if (path) { - if (!(sql_file= open_sql_file_for_table(table))) + if (!(sql_file= open_sql_file_for_table(table, O_WRONLY))) DBUG_RETURN(0); write_header(sql_file, db); } @@ -2725,12 +2726,10 @@ continue_xml: DBUG_RETURN((uint) num_fields); } /* get_table_structure */ -static void dump_trigger_old(MYSQL_RES *show_triggers_rs, +static void dump_trigger_old(FILE *sql_file, MYSQL_RES *show_triggers_rs, MYSQL_ROW *show_trigger_row, const char *table_name) { - FILE *sql_file= md_result_file; - char quoted_table_name_buf[NAME_LEN * 2 + 3]; char *quoted_table_name= quote_name(table_name, quoted_table_name_buf, 1); @@ -2796,11 +2795,10 @@ static void dump_trigger_old(MYSQL_RES *show_triggers_rs, DBUG_VOID_RETURN; } -static int dump_trigger(MYSQL_RES *show_create_trigger_rs, +static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs, const char *db_name, const char *db_cl_name) { - FILE *sql_file= md_result_file; MYSQL_ROW row; int db_cl_altered= FALSE; @@ -2864,22 +2862,28 @@ static int dump_triggers_for_table(char *table_name, char *db_name) uint old_opt_compatible_mode= opt_compatible_mode; MYSQL_RES *show_triggers_rs; MYSQL_ROW row; + FILE *sql_file= md_result_file; char db_cl_name[MY_CS_NAME_SIZE]; + int ret= TRUE; DBUG_ENTER("dump_triggers_for_table"); DBUG_PRINT("enter", ("db: %s, table_name: %s", db_name, table_name)); + if (path && !(sql_file= open_sql_file_for_table(table_name, + O_WRONLY | O_APPEND))) + DBUG_RETURN(1); + /* Do not use ANSI_QUOTES on triggers in dump */ opt_compatible_mode&= ~MASK_ANSI_QUOTES; /* Get database collation. */ if (switch_character_set_results(mysql, "binary")) - DBUG_RETURN(TRUE); + goto done; if (fetch_db_collation(db_name, db_cl_name, sizeof (db_cl_name))) - DBUG_RETURN(TRUE); + goto done; /* Get list of triggers. */ @@ -2888,7 +2892,7 @@ static int dump_triggers_for_table(char *table_name, char *db_name) quote_for_like(table_name, name_buff)); if (mysql_query_with_error_report(mysql, &show_triggers_rs, query_buff)) - DBUG_RETURN(TRUE); + goto done; /* Dump triggers. */ @@ -2909,17 +2913,15 @@ static int dump_triggers_for_table(char *table_name, char *db_name) provide all the necessary information to restore trigger properly. */ - dump_trigger_old(show_triggers_rs, &row, table_name); + dump_trigger_old(sql_file, show_triggers_rs, &row, table_name); } else { MYSQL_RES *show_create_trigger_rs= mysql_store_result(mysql); if (!show_create_trigger_rs || - dump_trigger(show_create_trigger_rs, db_name, db_cl_name)) - { - DBUG_RETURN(TRUE); - } + dump_trigger(sql_file, show_create_trigger_rs, db_name, db_cl_name)) + goto done; mysql_free_result(show_create_trigger_rs); } @@ -2929,7 +2931,7 @@ static int dump_triggers_for_table(char *table_name, char *db_name) mysql_free_result(show_triggers_rs); if (switch_character_set_results(mysql, default_charset)) - DBUG_RETURN(TRUE); + goto done; /* make sure to set back opt_compatible mode to @@ -2937,7 +2939,13 @@ static int dump_triggers_for_table(char *table_name, char *db_name) */ opt_compatible_mode=old_opt_compatible_mode; - DBUG_RETURN(FALSE); + ret= FALSE; + +done: + if (path) + my_fclose(sql_file, MYF(0)); + + DBUG_RETURN(ret); } static void add_load_option(DYNAMIC_STRING *str, const char *option, @@ -4790,7 +4798,7 @@ static my_bool get_view_structure(char *table, char* db) /* If requested, open separate .sql file for this view */ if (path) { - if (!(sql_file= open_sql_file_for_table(table))) + if (!(sql_file= open_sql_file_for_table(table, O_WRONLY))) DBUG_RETURN(1); write_header(sql_file, db); diff --git a/client/mysqlimport.c b/client/mysqlimport.c index ec418244f3d..57aee7379f2 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -222,7 +222,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), #endif case 'p': if (argument == disabled_my_option) - argument= (char*) ""; // Don't require password + argument= (char*) ""; /* Don't require password */ if (argument) { char *start=argument; diff --git a/client/mysqlshow.c b/client/mysqlshow.c index e401d6cad8f..15f791ca8fb 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -282,7 +282,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case 'p': if (argument == disabled_my_option) - argument= (char*) ""; // Don't require password + argument= (char*) ""; /* Don't require password */ if (argument) { char *start=argument; diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 4cf8c7204ed..316fb6a9da3 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -713,7 +713,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case 'p': if (argument == disabled_my_option) - argument= (char*) ""; // Don't require password + argument= (char*) ""; /* Don't require password */ if (argument) { char *start= argument; diff --git a/client/mysqltest.cc b/client/mysqltest.cc index f29fd36aa27..265d3b0a8e7 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -280,6 +280,7 @@ enum enum_commands { Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR, Q_LIST_FILES, Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE, Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER, + Q_MOVE_FILE, Q_UNKNOWN, /* Unknown command. */ Q_COMMENT, /* Comments, ignored. */ @@ -376,6 +377,7 @@ const char *command_names[]= "list_files_append_file", "send_shutdown", "shutdown_server", + "move_file", 0 }; @@ -966,6 +968,7 @@ void check_command_args(struct st_command *command, for (i= 0; i < num_args; i++) { const struct command_arg *arg= &args[i]; + char delimiter; switch (arg->type) { /* A string */ @@ -974,8 +977,15 @@ void check_command_args(struct st_command *command, while (*ptr && *ptr == ' ') ptr++; start= ptr; - /* Find end of arg, terminated by "delimiter_arg" */ - while (*ptr && *ptr != delimiter_arg) + delimiter = delimiter_arg; + /* If start of arg is ' ` or " search to matching quote end instead */ + if (*ptr && strchr ("'`\"", *ptr)) + { + delimiter= *ptr; + start= ++ptr; + } + /* Find end of arg, terminated by "delimiter" */ + while (*ptr && *ptr != delimiter) ptr++; if (ptr > start) { @@ -987,6 +997,11 @@ void check_command_args(struct st_command *command, /* Empty string */ init_dynamic_string(arg->ds, "", 0, 0); } + /* Find real end of arg, terminated by "delimiter_arg" */ + /* This will do nothing if arg was not closed by quotes */ + while (*ptr && *ptr != delimiter_arg) + ptr++; + command->last_argument= (char*)ptr; /* Step past the delimiter */ @@ -1445,34 +1460,38 @@ static int run_tool(const char *tool_path, DYNAMIC_STRING *ds_res, ...) Test if diff is present. This is needed on Windows systems as the OS returns 1 whether diff is successful or if it is not present. - Takes name of diff program as argument - + We run diff -v and look for output in stdout. We don't redirect stderr to stdout to make for a simplified check Windows will output '"diff"' is not recognized... to stderr if it is not present. */ -int diff_check (const char *diff_name) +#ifdef __WIN__ + +static int diff_check(const char *diff_name) { - char buf[512]= {0}; - FILE *res_file; - char cmd[128]; - my_snprintf (cmd, sizeof(cmd), "%s -v", diff_name); - int have_diff = 0; + FILE *res_file; + char buf[128]; + int have_diff= 0; - if (!(res_file= popen(cmd, "r"))) - die("popen(\"%s\", \"r\") failed", cmd); + my_snprintf(buf, sizeof(buf), "%s -v", diff_name); - /* if diff is not present, nothing will be in stdout to increment have_diff */ - if (fgets(buf, sizeof(buf), res_file)) - { - have_diff += 1; - } - pclose(res_file); - return have_diff; + if (!(res_file= popen(buf, "r"))) + die("popen(\"%s\", \"r\") failed", buf); + + /* if diff is not present, nothing will be in stdout to increment have_diff */ + if (fgets(buf, sizeof(buf), res_file)) + have_diff= 1; + + pclose(res_file); + + return have_diff; } +#endif + + /* Show the diff of two files using the systems builtin diff command. If no such diff command exist, just dump the content @@ -1794,7 +1813,7 @@ void check_result() log_file.file_name(), reject_file, errno); show_diff(NULL, result_file_name, reject_file); - die(mess); + die("%s", mess); break; } default: /* impossible */ @@ -2891,6 +2910,42 @@ void do_copy_file(struct st_command *command) /* SYNOPSIS + do_move_file + command command handle + + DESCRIPTION + move_file <from_file> <to_file> + Move <from_file> to <to_file> +*/ + +void do_move_file(struct st_command *command) +{ + int error; + static DYNAMIC_STRING ds_from_file; + static DYNAMIC_STRING ds_to_file; + const struct command_arg move_file_args[] = { + { "from_file", ARG_STRING, TRUE, &ds_from_file, "Filename to move from" }, + { "to_file", ARG_STRING, TRUE, &ds_to_file, "Filename to move to" } + }; + DBUG_ENTER("do_move_file"); + + check_command_args(command, command->first_argument, + move_file_args, + sizeof(move_file_args)/sizeof(struct command_arg), + ' '); + + DBUG_PRINT("info", ("Move %s to %s", ds_from_file.str, ds_to_file.str)); + error= (my_rename(ds_from_file.str, ds_to_file.str, + MYF(0)) != 0); + handle_command_error(command, error); + dynstr_free(&ds_from_file); + dynstr_free(&ds_to_file); + DBUG_VOID_RETURN; +} + + +/* + SYNOPSIS do_chmod_file command command handle @@ -4546,7 +4601,7 @@ void select_connection(struct st_command *command) }; check_command_args(command, command->first_argument, connection_args, sizeof(connection_args)/sizeof(struct command_arg), - ','); + ' '); DBUG_PRINT("info", ("changing connection: %s", ds_connection.str)); select_connection_name(ds_connection.str); @@ -7680,6 +7735,7 @@ int main(int argc, char **argv) case Q_CHANGE_USER: do_change_user(command); break; case Q_CAT_FILE: do_cat_file(command); break; case Q_COPY_FILE: do_copy_file(command); break; + case Q_MOVE_FILE: do_move_file(command); break; case Q_CHMOD_FILE: do_chmod_file(command); break; case Q_PERL: do_perl(command); break; case Q_DELIMITER: diff --git a/cmd-line-utils/readline/Makefile.am b/cmd-line-utils/readline/Makefile.am index 5fcbcde0516..e5f5717858d 100644 --- a/cmd-line-utils/readline/Makefile.am +++ b/cmd-line-utils/readline/Makefile.am @@ -31,7 +31,7 @@ noinst_HEADERS = readline.h chardefs.h keymaps.h \ EXTRA_DIST= emacs_keymap.c vi_keymap.c -DEFS = -DUNDEF_THREADS_HACK -DHAVE_CONFIG_H -DNO_KILL_INTR +DEFS = -DMYSQL_CLIENT_NO_THREADS -DHAVE_CONFIG_H -DNO_KILL_INTR # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/cmd-line-utils/readline/bind.c b/cmd-line-utils/readline/bind.c index baed1dfad49..490691943a8 100644 --- a/cmd-line-utils/readline/bind.c +++ b/cmd-line-utils/readline/bind.c @@ -79,7 +79,7 @@ static int _rl_read_init_file PARAMS((const char *, int)); static int glean_key_from_name PARAMS((char *)); static int find_boolean_var PARAMS((const char *)); -static char *_rl_get_string_variable_value PARAMS((const char *)); +static const char *_rl_get_string_variable_value PARAMS((const char *)); static int substring_member_of_array PARAMS((char *, const char **)); static int currently_reading_init_file; @@ -442,7 +442,7 @@ rl_translate_keyseq (seq, array, len) { register int i, c, l, temp; - for (i = l = 0; c = seq[i]; i++) + for (i = l = 0; (c = seq[i]); i++) { if (c == '\\') { @@ -701,7 +701,7 @@ rl_function_of_keyseq (keyseq, map, type) { unsigned char ic = keyseq[i]; - if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii) + if (META_CHAR_FOR_UCHAR (ic) && _rl_convert_meta_chars_to_ascii) { if (map[ESC].type == ISKMAP) { @@ -776,7 +776,8 @@ _rl_read_file (filename, sizep) file_size = (size_t)finfo.st_size; /* check for overflow on very large files */ - if (file_size != finfo.st_size || file_size + 1 < file_size) +if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) || + file_size + 1 < file_size) { if (file >= 0) close (file); @@ -807,7 +808,7 @@ _rl_read_file (filename, sizep) /* Re-read the current keybindings file. */ int rl_re_read_init_file (count, ignore) - int count, ignore; + int count __attribute__((unused)), ignore __attribute__((unused)); { int r; r = rl_read_init_file ((const char *)NULL); @@ -1031,7 +1032,7 @@ parser_if (args) /* Invert the current parser state if there is anything on the stack. */ static int parser_else (args) - char *args; + char *args __attribute__((unused)); { register int i; @@ -1062,7 +1063,7 @@ parser_else (args) _rl_parsing_conditionalized_out from the stack. */ static int parser_endif (args) - char *args; + char *args __attribute__((unused)); { if (if_stack_depth) _rl_parsing_conditionalized_out = if_stack[--if_stack_depth]; @@ -1185,7 +1186,7 @@ rl_parse_and_bind (string) { int passc = 0; - for (i = 1; c = string[i]; i++) + for (i = 1; (c = string[i]); i++) { if (passc) { @@ -1276,7 +1277,7 @@ rl_parse_and_bind (string) int delimiter, passc; delimiter = string[i++]; - for (passc = 0; c = string[i]; i++) + for (passc = 0; (c = string[i]); i++) { if (passc) { @@ -1436,7 +1437,7 @@ static struct { #if defined (VISIBLE_STATS) { "visible-stats", &rl_visible_stats, 0 }, #endif /* VISIBLE_STATS */ - { (char *)NULL, (int *)NULL } + { (char *)NULL, (int *)NULL, 0 } }; static int @@ -1505,7 +1506,7 @@ static struct { { "editing-mode", V_STRING, sv_editmode }, { "isearch-terminators", V_STRING, sv_isrchterm }, { "keymap", V_STRING, sv_keymap }, - { (char *)NULL, 0 } + { (char *)NULL, 0, (_rl_sv_func_t*)NULL } }; static int @@ -1532,7 +1533,7 @@ bool_to_int (value) (value[0] == '1' && value[1] == '\0')); } -char * +const char * rl_variable_value (name) const char *name; { @@ -1799,7 +1800,7 @@ rl_set_keymap_from_edit_mode () #endif /* VI_MODE */ } -char * +const char * rl_get_keymap_name_from_edit_mode () { if (rl_editing_mode == emacs_mode) @@ -2048,7 +2049,7 @@ rl_function_dumper (print_readably) fprintf (rl_outstream, "\n"); - for (i = 0; name = names[i]; i++) + for (i = 0; (name = names[i]); i++) { rl_command_func_t *function; char **invokers; @@ -2108,7 +2109,7 @@ rl_function_dumper (print_readably) the output in such a way that it can be read back in. */ int rl_dump_functions (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { if (rl_dispatching) fprintf (rl_outstream, "\r\n"); @@ -2188,7 +2189,7 @@ rl_macro_dumper (print_readably) int rl_dump_macros (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { if (rl_dispatching) fprintf (rl_outstream, "\r\n"); @@ -2197,12 +2198,13 @@ rl_dump_macros (count, key) return (0); } -static char * +static const char * _rl_get_string_variable_value (name) const char *name; { static char numbuf[32]; - char *ret; + const char *ret; + char *tmp; if (_rl_stricmp (name, "bell-style") == 0) { @@ -2230,11 +2232,11 @@ _rl_get_string_variable_value (name) { if (_rl_isearch_terminators == 0) return 0; - ret = _rl_untranslate_macro_value (_rl_isearch_terminators); - if (ret) + tmp = _rl_untranslate_macro_value (_rl_isearch_terminators); + if (tmp) { - strncpy (numbuf, ret, sizeof (numbuf) - 1); - free (ret); + strncpy (numbuf, tmp, sizeof (numbuf) - 1); + free (tmp); numbuf[sizeof(numbuf) - 1] = '\0'; } else @@ -2257,7 +2259,7 @@ rl_variable_dumper (print_readably) int print_readably; { int i; - char *v; + const char *v; for (i = 0; boolean_varlist[i].name; i++) { @@ -2286,7 +2288,7 @@ rl_variable_dumper (print_readably) the output in such a way that it can be read back in. */ int rl_dump_variables (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { if (rl_dispatching) fprintf (rl_outstream, "\r\n"); diff --git a/cmd-line-utils/readline/chardefs.h b/cmd-line-utils/readline/chardefs.h index def3a111bd3..0787d9943bb 100644 --- a/cmd-line-utils/readline/chardefs.h +++ b/cmd-line-utils/readline/chardefs.h @@ -59,7 +59,8 @@ #define largest_char 255 /* Largest character value. */ #define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0)) -#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char) +#define META_CHAR_FOR_UCHAR(c) ((c) > meta_character_threshold) +#define META_CHAR(c) (META_CHAR_FOR_UCHAR(c) && (c) <= largest_char) #define CTRL(c) ((c) & control_character_mask) #define META(c) ((c) | meta_character_bit) diff --git a/cmd-line-utils/readline/complete.c b/cmd-line-utils/readline/complete.c index 916aa5dd9b9..2745e4e4801 100644 --- a/cmd-line-utils/readline/complete.c +++ b/cmd-line-utils/readline/complete.c @@ -359,14 +359,14 @@ rl_complete (ignore, invoking_key) /* List the possible completions. See description of rl_complete (). */ int rl_possible_completions (ignore, invoking_key) - int ignore, invoking_key; + int ignore __attribute__((unused)), invoking_key __attribute__((unused)); { return (rl_complete_internal ('?')); } int rl_insert_completions (ignore, invoking_key) - int ignore, invoking_key; + int ignore __attribute__((unused)), invoking_key __attribute__((unused)); { return (rl_complete_internal ('*')); } @@ -696,7 +696,8 @@ print_filename (to_print, full_pathname) char *to_print, *full_pathname; { int printed_len, extension_char, slen, tlen; - char *s, c, *new_full_pathname, *dn; + char *s, c, *new_full_pathname; + const char *dn; extension_char = 0; printed_len = fnprint (to_print); @@ -783,7 +784,7 @@ print_filename (to_print, full_pathname) static char * rl_quote_filename (s, rtype, qcp) char *s; - int rtype; + int rtype __attribute__((unused)); char *qcp; { char *r; @@ -884,7 +885,7 @@ _rl_find_completion_word (fp, dp) /* We didn't find an unclosed quoted substring upon which to do completion, so use the word break characters to find the substring on which to complete. */ - while (rl_point = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_ANY)) + while ((rl_point = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_ANY))) { scan = rl_line_buffer[rl_point]; @@ -1803,7 +1804,7 @@ rl_completion_matches (text, entry_function) match_list = (char **)xmalloc ((match_list_size + 1) * sizeof (char *)); match_list[1] = (char *)NULL; - while (string = (*entry_function) (text, matches)) + while ((string = (*entry_function) (text, matches))) { if (matches + 1 == match_list_size) match_list = (char **)xrealloc @@ -2111,7 +2112,7 @@ rl_filename_completion_function (text, state) ring the bell, and reset the counter to zero. */ int rl_menu_complete (count, ignore) - int count, ignore; + int count, ignore __attribute__((unused)); { rl_compentry_func_t *our_func; int matching_filenames, found_quote; diff --git a/cmd-line-utils/readline/display.c b/cmd-line-utils/readline/display.c index 6f63faa9738..f9b88f0006c 100644 --- a/cmd-line-utils/readline/display.c +++ b/cmd-line-utils/readline/display.c @@ -127,7 +127,7 @@ int _rl_want_redisplay = 0; /* The stuff that gets printed out before the actual text of the line. This is usually pointing to rl_prompt. */ -char *rl_display_prompt = (char *)NULL; +const char *rl_display_prompt = (const char *)NULL; /* Pseudo-global variables declared here. */ @@ -229,7 +229,10 @@ expand_prompt (pmt, lp, lip, niflp, vlp) int *lp, *lip, *niflp, *vlp; { char *r, *ret, *p, *igstart; - int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars; + int l, rl, last, ignoring, ninvis, invfl, invflset, physchars; +#if defined (HANDLE_MULTIBYTE) + int ind, pind; +#endif /* Short-circuit if we can. */ if ((MB_CUR_MAX <= 1 || rl_byte_oriented) && strchr (pmt, RL_PROMPT_START_IGNORE) == 0) @@ -242,7 +245,7 @@ expand_prompt (pmt, lp, lip, niflp, vlp) if (niflp) *niflp = 0; if (vlp) - *vlp = lp ? *lp : strlen (r); + *vlp = lp ? *lp : (int)strlen (r); return r; } @@ -459,9 +462,10 @@ rl_redisplay () register int in, out, c, linenum, cursor_linenum; register char *line; int inv_botlin, lb_botlin, lb_linenum, o_cpos; - int newlines, lpos, temp, modmark, n0, num; - char *prompt_this_line; + int newlines, lpos, temp, modmark; + const char *prompt_this_line; #if defined (HANDLE_MULTIBYTE) + int num, n0; wchar_t wc; size_t wc_bytes; int wc_width; @@ -626,7 +630,6 @@ rl_redisplay () contents of the command line? */ while (lpos >= _rl_screenwidth) { - int z; /* fix from Darin Johnson <darin@acuson.com> for prompt string with invisible characters that is longer than the screen width. The prompt_invis_chars_first_line variable could be made into an array @@ -635,6 +638,7 @@ rl_redisplay () prompts that exceed two physical lines? Additional logic fix from Edward Catmur <ed@catmur.co.uk> */ #if defined (HANDLE_MULTIBYTE) + int z; if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { n0 = num; @@ -878,6 +882,7 @@ rl_redisplay () if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up) { int nleft, pos, changed_screen_line, tx; + char empty_str[1] = { 0 }; if (!rl_display_fixed || forced_display) { @@ -902,7 +907,7 @@ rl_redisplay () #define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l])) #define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l]) #define VIS_CHARS(line) (visible_line + vis_lbreaks[line]) -#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line) +#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? empty_str : VIS_CHARS(line) #define INV_LINE(line) (invisible_line + inv_lbreaks[line]) /* For each line in the buffer, do the updating display. */ @@ -969,7 +974,7 @@ rl_redisplay () _rl_move_vert (linenum); _rl_move_cursor_relative (0, tt); _rl_clear_to_eol - ((linenum == _rl_vis_botlin) ? strlen (tt) : _rl_screenwidth); + ((linenum == _rl_vis_botlin) ? (int)strlen (tt) : _rl_screenwidth); } } _rl_vis_botlin = inv_botlin; @@ -1888,7 +1893,7 @@ rl_character_len (c, pos) uc = (unsigned char)c; - if (META_CHAR (uc)) + if (META_CHAR_FOR_UCHAR (uc)) return ((_rl_output_meta_chars == 0) ? 4 : 1); if (uc == '\t') @@ -2261,7 +2266,7 @@ static void redraw_prompt (t) char *t; { - char *oldp; + const char *oldp; oldp = rl_display_prompt; rl_save_prompt (); diff --git a/cmd-line-utils/readline/histexpand.c b/cmd-line-utils/readline/histexpand.c index 45377fc3b5e..ab8d8ecc866 100644 --- a/cmd-line-utils/readline/histexpand.c +++ b/cmd-line-utils/readline/histexpand.c @@ -87,14 +87,14 @@ char history_comment_char = '\0'; /* The list of characters which inhibit the expansion of text if found immediately following history_expansion_char. */ -char *history_no_expand_chars = " \t\n\r="; +const char *history_no_expand_chars = " \t\n\r="; /* If set to a non-zero value, single quotes inhibit history expansion. The default is 0. */ int history_quotes_inhibit_expansion = 0; /* Used to split words by history_tokenize_internal. */ -char *history_word_delimiters = HISTORY_WORD_DELIMITERS; +const char *history_word_delimiters = HISTORY_WORD_DELIMITERS; /* If set, this points to a function that is called to verify that a particular history expansion should be performed. */ @@ -203,7 +203,7 @@ get_history_event (string, caller_index, delimiting_quote) } /* Only a closing `?' or a newline delimit a substring search string. */ - for (local_index = i; c = string[i]; i++) + for (local_index = i; (c = string[i]); i++) { #if defined (HANDLE_MULTIBYTE) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) diff --git a/cmd-line-utils/readline/histfile.c b/cmd-line-utils/readline/histfile.c index d98293d933c..118c5ebd328 100644 --- a/cmd-line-utils/readline/histfile.c +++ b/cmd-line-utils/readline/histfile.c @@ -186,7 +186,8 @@ read_history_range (filename, from, to) file_size = (size_t)finfo.st_size; /* check for overflow on very large files */ - if (file_size != finfo.st_size || file_size + 1 < file_size) +if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) || + file_size + 1 < file_size) { errno = overflow_errno; goto error_and_exit; @@ -339,7 +340,8 @@ history_truncate_file (fname, lines) file_size = (size_t)finfo.st_size; /* check for overflow on very large files */ - if (file_size != finfo.st_size || file_size + 1 < file_size) +if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) || + file_size + 1 < file_size) { close (file); #if defined (EFBIG) diff --git a/cmd-line-utils/readline/history.h b/cmd-line-utils/readline/history.h index 14ca2a996c7..5790ed1c71d 100644 --- a/cmd-line-utils/readline/history.h +++ b/cmd-line-utils/readline/history.h @@ -243,9 +243,9 @@ extern int history_length; extern int history_max_entries; extern char history_expansion_char; extern char history_subst_char; -extern char *history_word_delimiters; +extern const char *history_word_delimiters; extern char history_comment_char; -extern char *history_no_expand_chars; +extern const char *history_no_expand_chars; extern char *history_search_delimiter_chars; extern int history_quotes_inhibit_expansion; diff --git a/cmd-line-utils/readline/input.c b/cmd-line-utils/readline/input.c index 62c0443d890..84c0422059a 100644 --- a/cmd-line-utils/readline/input.c +++ b/cmd-line-utils/readline/input.c @@ -420,7 +420,7 @@ rl_read_key () else { /* If input is coming from a macro, then use that. */ - if (c = _rl_next_macro_key ()) + if ((c = _rl_next_macro_key ())) return (c); /* If the user has an event function, then call it periodically. */ diff --git a/cmd-line-utils/readline/isearch.c b/cmd-line-utils/readline/isearch.c index 8060adb97cd..305c847d8da 100644 --- a/cmd-line-utils/readline/isearch.c +++ b/cmd-line-utils/readline/isearch.c @@ -75,7 +75,7 @@ static int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, int)); static char *last_isearch_string; static int last_isearch_string_len; -static char *default_isearch_terminators = "\033\012"; +static const char *default_isearch_terminators = "\033\012"; _rl_search_cxt * _rl_scxt_alloc (type, flags) @@ -119,7 +119,7 @@ _rl_scxt_alloc (type, flags) void _rl_scxt_dispose (cxt, flags) _rl_search_cxt *cxt; - int flags; + int flags __attribute__((unused)); { FREE (cxt->search_string); FREE (cxt->allocated_line); @@ -154,7 +154,7 @@ rl_forward_search_history (sign, key) static void rl_display_search (search_string, reverse_p, where) char *search_string; - int reverse_p, where; + int reverse_p, where __attribute__((unused)); { char *message; int msglen, searchlen; @@ -614,7 +614,7 @@ _rl_isearch_cleanup (cxt, r) backwards. */ static int rl_search_history (direction, invoking_key) - int direction, invoking_key; + int direction, invoking_key __attribute__((unused)); { _rl_search_cxt *cxt; /* local for now, but saved globally */ int c, r; diff --git a/cmd-line-utils/readline/kill.c b/cmd-line-utils/readline/kill.c index 42c53948689..adae2e1cd07 100644 --- a/cmd-line-utils/readline/kill.c +++ b/cmd-line-utils/readline/kill.c @@ -79,7 +79,7 @@ static int rl_yank_nth_arg_internal PARAMS((int, int, int)); of kill material. */ int rl_set_retained_kills (num) - int num; + int num __attribute__((unused)); { return 0; } @@ -296,7 +296,7 @@ rl_backward_kill_line (direction, ignore) /* Kill the whole line, no matter where point is. */ int rl_kill_full_line (count, ignore) - int count, ignore; + int count __attribute__((unused)), ignore __attribute__((unused)); { rl_begin_undo_group (); rl_point = 0; @@ -314,7 +314,7 @@ rl_kill_full_line (count, ignore) using behaviour that they expect. */ int rl_unix_word_rubout (count, key) - int count, key; + int count, key __attribute__((unused)); { int orig_point; @@ -347,7 +347,7 @@ rl_unix_word_rubout (count, key) deletes backward to directory separator (`/') or whitespace. */ int rl_unix_filename_rubout (count, key) - int count, key; + int count, key __attribute__((unused)); { int orig_point, c; @@ -391,7 +391,7 @@ rl_unix_filename_rubout (count, key) doing. */ int rl_unix_line_discard (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { if (rl_point == 0) rl_ding (); @@ -428,7 +428,7 @@ region_kill_internal (delete) /* Copy the text in the region to the kill ring. */ int rl_copy_region_to_kill (count, ignore) - int count, ignore; + int count __attribute__((unused)), ignore __attribute__((unused)); { return (region_kill_internal (0)); } @@ -436,7 +436,7 @@ rl_copy_region_to_kill (count, ignore) /* Kill the text between the point and mark. */ int rl_kill_region (count, ignore) - int count, ignore; + int count __attribute__((unused)), ignore __attribute__((unused)); { int r, npoint; @@ -501,7 +501,7 @@ rl_copy_backward_word (count, key) /* Yank back the last killed text. This ignores arguments. */ int rl_yank (count, ignore) - int count, ignore; + int count __attribute__((unused)), ignore __attribute__((unused)); { if (rl_kill_ring == 0) { @@ -520,7 +520,7 @@ rl_yank (count, ignore) yank back some other text. */ int rl_yank_pop (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { int l, n; diff --git a/cmd-line-utils/readline/macro.c b/cmd-line-utils/readline/macro.c index 3473f705335..0ee7b3077c3 100644 --- a/cmd-line-utils/readline/macro.c +++ b/cmd-line-utils/readline/macro.c @@ -201,7 +201,7 @@ _rl_kill_kbd_macro () re-executing the existing macro. */ int rl_start_kbd_macro (ignore1, ignore2) - int ignore1, ignore2; + int ignore1 __attribute__((unused)), ignore2 __attribute__((unused)); { if (RL_ISSTATE (RL_STATE_MACRODEF)) { @@ -226,7 +226,7 @@ rl_start_kbd_macro (ignore1, ignore2) that many times, counting the definition as the first time. */ int rl_end_kbd_macro (count, ignore) - int count, ignore; + int count, ignore __attribute__((unused)); { if (RL_ISSTATE (RL_STATE_MACRODEF) == 0) { @@ -246,7 +246,7 @@ rl_end_kbd_macro (count, ignore) COUNT says how many times to execute it. */ int rl_call_last_kbd_macro (count, ignore) - int count, ignore; + int count, ignore __attribute__((unused)); { if (current_macro == 0) _rl_abort_internal (); diff --git a/cmd-line-utils/readline/mbutil.c b/cmd-line-utils/readline/mbutil.c index e21708fb748..b571afa18bb 100644 --- a/cmd-line-utils/readline/mbutil.c +++ b/cmd-line-utils/readline/mbutil.c @@ -346,8 +346,8 @@ _rl_char_value (buf, ind) #undef _rl_find_next_mbchar int _rl_find_next_mbchar (string, seed, count, flags) - char *string; - int seed, count, flags; + char *string __attribute__((unused)); + int seed, count, flags __attribute__((unused)); { #if defined (HANDLE_MULTIBYTE) return _rl_find_next_mbchar_internal (string, seed, count, flags); @@ -362,8 +362,8 @@ _rl_find_next_mbchar (string, seed, count, flags) #undef _rl_find_prev_mbchar int _rl_find_prev_mbchar (string, seed, flags) - char *string; - int seed, flags; + char *string __attribute__((unused)); + int seed, flags __attribute__((unused)); { #if defined (HANDLE_MULTIBYTE) return _rl_find_prev_mbchar_internal (string, seed, flags); diff --git a/cmd-line-utils/readline/misc.c b/cmd-line-utils/readline/misc.c index e0e6893c60e..f5f0370fb6a 100644 --- a/cmd-line-utils/readline/misc.c +++ b/cmd-line-utils/readline/misc.c @@ -228,7 +228,7 @@ _rl_reset_argument () /* Start a numeric argument with initial value KEY */ int rl_digit_argument (ignore, key) - int ignore, key; + int ignore __attribute__((unused)), key; { _rl_arg_init (); if (RL_ISSTATE (RL_STATE_CALLBACK)) @@ -249,7 +249,7 @@ rl_digit_argument (ignore, key) dispatch on it. If the key is the abort character then abort. */ int rl_universal_argument (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { _rl_arg_init (); rl_numeric_arg *= 4; @@ -413,7 +413,7 @@ _rl_history_set_point () void rl_replace_from_history (entry, flags) HIST_ENTRY *entry; - int flags; /* currently unused */ + int flags __attribute__((unused)); /* currently unused */ { /* Can't call with `1' because rl_undo_list might point to an undo list from a history entry, just like we're setting up here. */ @@ -440,7 +440,7 @@ rl_replace_from_history (entry, flags) /* Meta-< goes to the start of the history. */ int rl_beginning_of_history (count, key) - int count, key; + int count __attribute__((unused)), key; { return (rl_get_previous_history (1 + where_history (), key)); } @@ -448,7 +448,7 @@ rl_beginning_of_history (count, key) /* Meta-> goes to the end of the history. (The current line). */ int rl_end_of_history (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { rl_maybe_replace_line (); using_history (); @@ -553,7 +553,7 @@ rl_get_previous_history (count, key) /* How to toggle back and forth between editing modes. */ int rl_vi_editing_mode (count, key) - int count, key; + int count __attribute__((unused)), key; { #if defined (VI_MODE) _rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */ @@ -566,7 +566,7 @@ rl_vi_editing_mode (count, key) int rl_emacs_editing_mode (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { rl_editing_mode = emacs_mode; _rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */ @@ -577,7 +577,7 @@ rl_emacs_editing_mode (count, key) /* Function for the rest of the library to use to set insert/overwrite mode. */ void _rl_set_insert_mode (im, force) - int im, force; + int im, force __attribute__((unused)); { #ifdef CURSOR_MODE _rl_set_cursor (im, force); @@ -590,7 +590,7 @@ _rl_set_insert_mode (im, force) mode. A negative or zero explicit argument selects insert mode. */ int rl_overwrite_mode (count, key) - int count, key; + int count, key __attribute__((unused)); { if (rl_explicit_arg == 0) _rl_set_insert_mode (rl_insert_mode ^ 1, 0); diff --git a/cmd-line-utils/readline/nls.c b/cmd-line-utils/readline/nls.c index 6ec685ed9ea..ff40b14228c 100644 --- a/cmd-line-utils/readline/nls.c +++ b/cmd-line-utils/readline/nls.c @@ -101,7 +101,8 @@ _rl_init_eightbit () /* If we have setlocale(3), just check the current LC_CTYPE category value, and go into eight-bit mode if it's not C or POSIX. */ #if defined (HAVE_SETLOCALE) - char *lspec, *t; + const char *lspec; + char *t; /* Set the LC_CTYPE locale category from environment variables. */ lspec = _rl_get_locale_var ("LC_CTYPE"); @@ -127,7 +128,8 @@ _rl_init_eightbit () return (0); #else /* !HAVE_SETLOCALE */ - char *lspec, *t; + const char *lspec; + char *t; int i; /* We don't have setlocale. Finesse it. Check the environment for the diff --git a/cmd-line-utils/readline/readline.c b/cmd-line-utils/readline/readline.c index 8c3cad52d36..fb92becdbf9 100644 --- a/cmd-line-utils/readline/readline.c +++ b/cmd-line-utils/readline/readline.c @@ -90,7 +90,7 @@ static void bind_arrow_keys_internal PARAMS((Keymap)); static void bind_arrow_keys PARAMS((void)); static void readline_default_bindings PARAMS((void)); -static void reset_default_bindings PARAMS((void)); +static void reset_default_bindings PARAMS((void)) __attribute__((unused)); static int _rl_subseq_result PARAMS((int, Keymap, int, int)); static int _rl_subseq_getchar PARAMS((int)); diff --git a/cmd-line-utils/readline/readline.h b/cmd-line-utils/readline/readline.h index b71bf98d204..668a452c765 100644 --- a/cmd-line-utils/readline/readline.h +++ b/cmd-line-utils/readline/readline.h @@ -304,7 +304,7 @@ extern int rl_bind_keyseq_if_unbound PARAMS((const char *, rl_command_func_t *)) extern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap)); extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap)); -extern char *rl_variable_value PARAMS((const char *)); +extern const char *rl_variable_value PARAMS((const char *)); extern int rl_variable_bind PARAMS((const char *, const char *)); /* Backwards compatibility, use rl_bind_keyseq_in_map instead. */ @@ -343,7 +343,7 @@ extern void rl_set_keymap PARAMS((Keymap)); extern Keymap rl_get_keymap PARAMS((void)); /* Undocumented; used internally only. */ extern void rl_set_keymap_from_edit_mode PARAMS((void)); -extern char *rl_get_keymap_name_from_edit_mode PARAMS((void)); +extern const char *rl_get_keymap_name_from_edit_mode PARAMS((void)); /* Functions for manipulating the funmap, which maps command names to functions. */ extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *)); @@ -406,7 +406,7 @@ extern void rl_set_screen_size PARAMS((int, int)); extern void rl_get_screen_size PARAMS((int *, int *)); extern void rl_reset_screen_size PARAMS((void)); -extern char *rl_get_termcap PARAMS((const char *)); +extern const char *rl_get_termcap PARAMS((const char *)); /* Functions for character input. */ extern int rl_stuff_char PARAMS((int)); diff --git a/cmd-line-utils/readline/rlprivate.h b/cmd-line-utils/readline/rlprivate.h index 64aa7bdd3fa..1ab696766b0 100644 --- a/cmd-line-utils/readline/rlprivate.h +++ b/cmd-line-utils/readline/rlprivate.h @@ -77,7 +77,7 @@ typedef struct __rl_search_context int sline_len; int sline_index; - char *search_terminators; + const char *search_terminators; } _rl_search_cxt; /* Callback data for reading numeric arguments */ @@ -164,7 +164,7 @@ extern int rl_set_retained_kills PARAMS((int)); extern void _rl_set_screen_size PARAMS((int, int)); /* undo.c */ -extern int _rl_fix_last_undo_of_type PARAMS((int, int, int)); +extern int _rl_fix_last_undo_of_type PARAMS((enum undo_code, int, int)); /* util.c */ extern char *_rl_savestring PARAMS((const char *)); @@ -359,7 +359,7 @@ extern int _rl_vis_botlin; extern int _rl_last_c_pos; extern int _rl_suppress_redisplay; extern int _rl_want_redisplay; -extern char *rl_display_prompt; +extern const char *rl_display_prompt; /* isearch.c */ extern char *_rl_isearch_terminators; @@ -398,17 +398,17 @@ extern _rl_search_cxt *_rl_nscxt; /* terminal.c */ extern int _rl_enable_keypad; extern int _rl_enable_meta; -extern char *_rl_term_clreol; -extern char *_rl_term_clrpag; -extern char *_rl_term_im; -extern char *_rl_term_ic; -extern char *_rl_term_ei; -extern char *_rl_term_DC; -extern char *_rl_term_up; -extern char *_rl_term_dc; -extern char *_rl_term_cr; -extern char *_rl_term_IC; -extern char *_rl_term_forward_char; +extern const char *_rl_term_clreol; +extern const char *_rl_term_clrpag; +extern const char *_rl_term_im; +extern const char *_rl_term_ic; +extern const char *_rl_term_ei; +extern const char *_rl_term_DC; +extern const char *_rl_term_up; +extern const char *_rl_term_dc; +extern const char *_rl_term_cr; +extern const char *_rl_term_IC; +extern const char *_rl_term_forward_char; extern int _rl_screenheight; extern int _rl_screenwidth; extern int _rl_screenchars; diff --git a/cmd-line-utils/readline/rltty.c b/cmd-line-utils/readline/rltty.c index 8c896bd3b26..8849206fd6d 100644 --- a/cmd-line-utils/readline/rltty.c +++ b/cmd-line-utils/readline/rltty.c @@ -764,7 +764,7 @@ rl_deprep_terminal () int rl_restart_output (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { #if defined (__MINGW32__) return 0; @@ -802,7 +802,7 @@ rl_restart_output (count, key) int rl_stop_output (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { #if defined (__MINGW32__) return 0; diff --git a/cmd-line-utils/readline/search.c b/cmd-line-utils/readline/search.c index cfa5db1dc17..1da450a692a 100644 --- a/cmd-line-utils/readline/search.c +++ b/cmd-line-utils/readline/search.c @@ -211,7 +211,7 @@ _rl_nsearch_init (dir, pchar) rl_end = rl_point = 0; p = _rl_make_prompt_for_search (pchar ? pchar : ':'); - rl_message ("%s", p, 0); + rl_message ("%s", p); free (p); RL_SETSTATE(RL_STATE_NSEARCH); @@ -383,7 +383,7 @@ noninc_search (dir, pchar) code calls this, KEY will be `?'. */ int rl_noninc_forward_search (count, key) - int count, key; + int count __attribute__((unused)), key; { return noninc_search (1, (key == '?') ? '?' : 0); } @@ -392,7 +392,7 @@ rl_noninc_forward_search (count, key) calls this, KEY will be `/'. */ int rl_noninc_reverse_search (count, key) - int count, key; + int count __attribute__((unused)), key; { return noninc_search (-1, (key == '/') ? '/' : 0); } @@ -401,7 +401,7 @@ rl_noninc_reverse_search (count, key) for. If there is no saved search string, abort. */ int rl_noninc_forward_search_again (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { int r; @@ -418,7 +418,7 @@ rl_noninc_forward_search_again (count, key) for. If there is no saved search string, abort. */ int rl_noninc_reverse_search_again (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { int r; diff --git a/cmd-line-utils/readline/terminal.c b/cmd-line-utils/readline/terminal.c index a630bc02e05..3f92821f9dd 100644 --- a/cmd-line-utils/readline/terminal.c +++ b/cmd-line-utils/readline/terminal.c @@ -104,34 +104,36 @@ char PC, *BC, *UP; #endif /* __linux__ */ /* Some strings to control terminal actions. These are output by tputs (). */ -char *_rl_term_clreol; -char *_rl_term_clrpag; -char *_rl_term_cr; -char *_rl_term_backspace; -char *_rl_term_goto; -char *_rl_term_pc; +const char *_rl_term_clreol; +const char *_rl_term_clrpag; +const char *_rl_term_cr; +const char *_rl_term_backspace; +char _rl_term_backspace_default[2] = { '\b', 0 }; +const char *_rl_term_goto; +const char *_rl_term_pc; /* Non-zero if we determine that the terminal can do character insertion. */ int _rl_terminal_can_insert = 0; /* How to insert characters. */ -char *_rl_term_im; -char *_rl_term_ei; -char *_rl_term_ic; -char *_rl_term_ip; -char *_rl_term_IC; +const char *_rl_term_im; +const char *_rl_term_ei; +const char *_rl_term_ic; +const char *_rl_term_ip; +const char *_rl_term_IC; /* How to delete characters. */ -char *_rl_term_dc; -char *_rl_term_DC; +const char *_rl_term_dc; +const char *_rl_term_DC; -char *_rl_term_forward_char; +const char *_rl_term_forward_char; /* How to go up a line. */ -char *_rl_term_up; +const char *_rl_term_up; +char _rl_term_up_default[2] = { 0, 0 }; /* A visible bell; char if the terminal can be made to flash the screen. */ -static char *_rl_visible_bell; +static const char *_rl_visible_bell; /* Non-zero means the terminal can auto-wrap lines. */ int _rl_term_autowrap = -1; @@ -141,33 +143,33 @@ static int term_has_meta; /* The sequences to write to turn on and off the meta key, if this terminal has one. */ -static char *_rl_term_mm; -static char *_rl_term_mo; +static const char *_rl_term_mm; +static const char *_rl_term_mo; /* The key sequences output by the arrow keys, if this terminal has any. */ -static char *_rl_term_ku; -static char *_rl_term_kd; -static char *_rl_term_kr; -static char *_rl_term_kl; +static const char *_rl_term_ku; +static const char *_rl_term_kd; +static const char *_rl_term_kr; +static const char *_rl_term_kl; /* How to initialize and reset the arrow keys, if this terminal has any. */ -static char *_rl_term_ks; -static char *_rl_term_ke; +static const char *_rl_term_ks; +static const char *_rl_term_ke; /* The key sequences sent by the Home and End keys, if any. */ -static char *_rl_term_kh; -static char *_rl_term_kH; -static char *_rl_term_at7; /* @7 */ +static const char *_rl_term_kh; +static const char *_rl_term_kH; +static const char *_rl_term_at7; /* @7 */ /* Delete key */ -static char *_rl_term_kD; +static const char *_rl_term_kD; /* Insert key */ -static char *_rl_term_kI; +static const char *_rl_term_kI; /* Cursor control */ -static char *_rl_term_vs; /* very visible */ -static char *_rl_term_ve; /* normal */ +static const char *_rl_term_vs; /* very visible */ +static const char *_rl_term_ve; /* normal */ static void bind_termcap_arrow_keys PARAMS((Keymap)); @@ -362,7 +364,7 @@ rl_resize_terminal () struct _tc_string { const char *tc_var; - char **tc_value; + const char **tc_value; }; /* This should be kept sorted, just in case we decide to change the @@ -409,7 +411,7 @@ get_term_capabilities (bp) char **bp; { #if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */ - register int i; + register unsigned int i; for (i = 0; i < NUM_TC_STRINGS; i++) *(tc_strings[i].tc_value) = tgetstr ((char *)tc_strings[i].tc_var, bp); @@ -496,8 +498,9 @@ _rl_init_terminal_io (terminal_name) tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we change that later... */ PC = '\0'; - BC = _rl_term_backspace = "\b"; - UP = _rl_term_up; + _rl_term_backspace = _rl_term_backspace_default; + BC = (char*)_rl_term_backspace; + UP = (char*)_rl_term_up; return 0; } @@ -507,8 +510,8 @@ _rl_init_terminal_io (terminal_name) /* Set up the variables that the termcap library expects the application to provide. */ PC = _rl_term_pc ? *_rl_term_pc : 0; - BC = _rl_term_backspace; - UP = _rl_term_up; + BC = (char*)_rl_term_backspace; + UP = (char*)_rl_term_up; if (!_rl_term_cr) _rl_term_cr = "\r"; @@ -568,11 +571,11 @@ bind_termcap_arrow_keys (map) _rl_keymap = xkeymap; } -char * +const char * rl_get_termcap (cap) const char *cap; { - register int i; + register unsigned int i; if (tcap_initialized == 0) return ((char *)NULL); diff --git a/cmd-line-utils/readline/text.c b/cmd-line-utils/readline/text.c index b26afeda525..272848c798c 100644 --- a/cmd-line-utils/readline/text.c +++ b/cmd-line-utils/readline/text.c @@ -410,7 +410,7 @@ rl_backward (count, key) /* Move to the beginning of the line. */ int rl_beg_of_line (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { rl_point = 0; return 0; @@ -419,7 +419,7 @@ rl_beg_of_line (count, key) /* Move to the end of the line. */ int rl_end_of_line (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { rl_point = rl_end; return 0; @@ -527,7 +527,7 @@ rl_backward_word (count, key) /* Clear the current line. Numeric argument to C-l does this. */ int rl_refresh_line (ignore1, ignore2) - int ignore1, ignore2; + int ignore1 __attribute__((unused)), ignore2 __attribute__((unused)); { int curr_line; @@ -566,7 +566,7 @@ rl_clear_screen (count, key) int rl_arrow_keys (count, c) - int count, c; + int count, c __attribute__((unused)); { int ch; @@ -884,7 +884,7 @@ _rl_insert_next_callback (data) int rl_quoted_insert (count, key) - int count, key; + int count, key __attribute__((unused)); { /* Let's see...should the callback interface futz with signal handling? */ #if defined (HANDLE_SIGNALS) @@ -907,7 +907,7 @@ rl_quoted_insert (count, key) /* Insert a tab character. */ int rl_tab_insert (count, key) - int count, key; + int count, key __attribute__((unused)); { return (_rl_insert_char (count, '\t')); } @@ -917,7 +917,7 @@ rl_tab_insert (count, key) meaning in the future. */ int rl_newline (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { rl_done = 1; @@ -951,7 +951,7 @@ rl_newline (count, key) is special cased. */ int rl_do_lowercase_version (ignore1, ignore2) - int ignore1, ignore2; + int ignore1 __attribute__((unused)), ignore2 __attribute__((unused)); { return 0; } @@ -1118,7 +1118,7 @@ rl_rubout_or_delete (count, key) /* Delete all spaces and tabs around point. */ int rl_delete_horizontal_space (count, ignore) - int count, ignore; + int count __attribute__((unused)), ignore __attribute__((unused)); { int start = rl_point; @@ -1163,9 +1163,9 @@ rl_delete_or_show_completions (count, key) A K*rn shell style function. */ int rl_insert_comment (count, key) - int count, key; + int count __attribute__((unused)), key; { - char *rl_comment_text; + const char *rl_comment_text; int rl_comment_len; rl_beg_of_line (1, key); @@ -1202,7 +1202,7 @@ rl_insert_comment (count, key) /* Uppercase the word at point. */ int rl_upcase_word (count, key) - int count, key; + int count, key __attribute__((unused)); { return (rl_change_case (count, UpCase)); } @@ -1210,7 +1210,7 @@ rl_upcase_word (count, key) /* Lowercase the word at point. */ int rl_downcase_word (count, key) - int count, key; + int count, key __attribute__((unused)); { return (rl_change_case (count, DownCase)); } @@ -1218,7 +1218,7 @@ rl_downcase_word (count, key) /* Upcase the first letter, downcase the rest. */ int rl_capitalize_word (count, key) - int count, key; + int count, key __attribute__((unused)); { return (rl_change_case (count, CapCase)); } @@ -1381,7 +1381,7 @@ rl_transpose_words (count, key) then transpose the characters before point. */ int rl_transpose_chars (count, key) - int count, key; + int count, key __attribute__((unused)); { #if defined (HANDLE_MULTIBYTE) char *dummy; @@ -1557,7 +1557,7 @@ _rl_char_search_callback (data) int rl_char_search (count, key) - int count, key; + int count, key __attribute__((unused)); { #if defined (READLINE_CALLBACKS) if (RL_ISSTATE (RL_STATE_CALLBACK)) @@ -1575,7 +1575,7 @@ rl_char_search (count, key) int rl_backward_char_search (count, key) - int count, key; + int count, key __attribute__((unused)); { #if defined (READLINE_CALLBACKS) if (RL_ISSTATE (RL_STATE_CALLBACK)) @@ -1612,7 +1612,7 @@ _rl_set_mark_at_pos (position) /* A bindable command to set the mark. */ int rl_set_mark (count, key) - int count, key; + int count, key __attribute__((unused)); { return (_rl_set_mark_at_pos (rl_explicit_arg ? count : rl_point)); } @@ -1620,7 +1620,7 @@ rl_set_mark (count, key) /* Exchange the position of mark and point. */ int rl_exchange_point_and_mark (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { if (rl_mark > rl_end) rl_mark = -1; diff --git a/cmd-line-utils/readline/tilde.c b/cmd-line-utils/readline/tilde.c index d50f7a0ffa4..128cc26d9a7 100644 --- a/cmd-line-utils/readline/tilde.c +++ b/cmd-line-utils/readline/tilde.c @@ -196,7 +196,7 @@ tilde_expand (string) int result_size, result_index; result_index = result_size = 0; - if (result = strchr (string, '~')) + if ((result = strchr (string, '~'))) result = (char *)xmalloc (result_size = (strlen (string) + 16)); else result = (char *)xmalloc (result_size = (strlen (string) + 1)); diff --git a/cmd-line-utils/readline/undo.c b/cmd-line-utils/readline/undo.c index 5699193b14c..79846c26024 100644 --- a/cmd-line-utils/readline/undo.c +++ b/cmd-line-utils/readline/undo.c @@ -231,7 +231,8 @@ rl_do_undo () int _rl_fix_last_undo_of_type (type, start, end) - int type, start, end; + enum undo_code type; + int start, end; { UNDO_LIST *rl; @@ -289,7 +290,7 @@ rl_modifying (start, end) /* Revert the current line to its previous state. */ int rl_revert_line (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { if (!rl_undo_list) rl_ding (); @@ -309,7 +310,7 @@ rl_revert_line (count, key) /* Do some undoing of things that were done. */ int rl_undo_command (count, key) - int count, key; + int count, key __attribute__((unused)); { if (count < 0) return 0; /* Nothing to do. */ diff --git a/cmd-line-utils/readline/util.c b/cmd-line-utils/readline/util.c index 935c9c927c2..50cfea75cb9 100644 --- a/cmd-line-utils/readline/util.c +++ b/cmd-line-utils/readline/util.c @@ -115,14 +115,14 @@ _rl_abort_internal () int rl_abort (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { return (_rl_abort_internal ()); } int rl_tty_status (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { #if defined (TIOCSTAT) ioctl (1, TIOCSTAT, (char *)0); @@ -172,7 +172,7 @@ rl_extend_line_buffer (len) /* A function for simple tilde expansion. */ int rl_tilde_expand (ignore, key) - int ignore, key; + int ignore __attribute__((unused)), key __attribute__((unused)); { register int start, end; char *homedir, *temp; diff --git a/cmd-line-utils/readline/vi_mode.c b/cmd-line-utils/readline/vi_mode.c index 25213cb762f..620bb863c7b 100644 --- a/cmd-line-utils/readline/vi_mode.c +++ b/cmd-line-utils/readline/vi_mode.c @@ -131,7 +131,7 @@ static int _rl_vi_callback_char_search PARAMS((_rl_callback_generic_arg *)); void _rl_vi_initialize_line () { - register int i; + register size_t i; for (i = 0; i < sizeof (vi_mark_chars) / sizeof (int); i++) vi_mark_chars[i] = -1; @@ -190,7 +190,7 @@ _rl_vi_stuff_insert (count) puts you back into insert mode. */ int rl_vi_redo (count, c) - int count, c; + int count, c __attribute__((unused)); { int r; @@ -238,7 +238,7 @@ rl_vi_undo (count, key) /* Yank the nth arg from the previous line into this line at point. */ int rl_vi_yank_arg (count, key) - int count, key; + int count, key __attribute__((unused)); { /* Readline thinks that the first word on a line is the 0th, while vi thinks the first word on a line is the 1st. Compensate. */ @@ -321,7 +321,7 @@ rl_vi_search (count, key) /* Completion, from vi's point of view. */ int rl_vi_complete (ignore, key) - int ignore, key; + int ignore __attribute__((unused)), key; { if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point]))) { @@ -348,7 +348,7 @@ rl_vi_complete (ignore, key) /* Tilde expansion for vi mode. */ int rl_vi_tilde_expand (ignore, key) - int ignore, key; + int ignore __attribute__((unused)), key; { rl_tilde_expand (0, key); rl_vi_start_inserting (key, 1, rl_arg_sign); @@ -419,7 +419,7 @@ rl_vi_end_word (count, key) /* Move forward a word the way that 'W' does. */ int rl_vi_fWord (count, ignore) - int count, ignore; + int count, ignore __attribute__((unused)); { while (count-- && rl_point < (rl_end - 1)) { @@ -436,7 +436,7 @@ rl_vi_fWord (count, ignore) int rl_vi_bWord (count, ignore) - int count, ignore; + int count, ignore __attribute__((unused)); { while (count-- && rl_point > 0) { @@ -460,7 +460,7 @@ rl_vi_bWord (count, ignore) int rl_vi_eWord (count, ignore) - int count, ignore; + int count, ignore __attribute__((unused)); { while (count-- && rl_point < (rl_end - 1)) { @@ -491,7 +491,7 @@ rl_vi_eWord (count, ignore) int rl_vi_fword (count, ignore) - int count, ignore; + int count, ignore __attribute__((unused)); { while (count-- && rl_point < (rl_end - 1)) { @@ -517,7 +517,7 @@ rl_vi_fword (count, ignore) int rl_vi_bword (count, ignore) - int count, ignore; + int count, ignore __attribute__((unused)); { while (count-- && rl_point > 0) { @@ -556,7 +556,7 @@ rl_vi_bword (count, ignore) int rl_vi_eword (count, ignore) - int count, ignore; + int count, ignore __attribute__((unused)); { while (count-- && rl_point < rl_end - 1) { @@ -581,7 +581,7 @@ rl_vi_eword (count, ignore) int rl_vi_insert_beg (count, key) - int count, key; + int count __attribute__((unused)), key; { rl_beg_of_line (1, key); rl_vi_insertion_mode (1, key); @@ -610,7 +610,7 @@ _rl_vi_append_forward (key) int rl_vi_append_mode (count, key) - int count, key; + int count __attribute__((unused)), key; { _rl_vi_append_forward (key); rl_vi_start_inserting (key, 1, rl_arg_sign); @@ -619,7 +619,7 @@ rl_vi_append_mode (count, key) int rl_vi_append_eol (count, key) - int count, key; + int count __attribute__((unused)), key; { rl_end_of_line (1, key); rl_vi_append_mode (1, key); @@ -629,7 +629,7 @@ rl_vi_append_eol (count, key) /* What to do in the case of C-d. */ int rl_vi_eof_maybe (count, c) - int count, c; + int count __attribute__((unused)), c __attribute__((unused)); { return (rl_newline (1, '\n')); } @@ -640,7 +640,7 @@ rl_vi_eof_maybe (count, c) switching keymaps. */ int rl_vi_insertion_mode (count, key) - int count, key; + int count __attribute__((unused)), key; { _rl_keymap = vi_insertion_keymap; _rl_vi_last_key_before_insert = key; @@ -703,7 +703,7 @@ _rl_vi_done_inserting () int rl_vi_movement_mode (count, key) - int count, key; + int count __attribute__((unused)), key; { if (rl_point > 0) rl_backward_char (1, key); @@ -783,7 +783,7 @@ _rl_vi_change_mbchar_case (count) int rl_vi_change_case (count, ignore) - int count, ignore; + int count, ignore __attribute__((unused)); { int c, p; @@ -1031,7 +1031,7 @@ rl_digit_loop1 () int rl_vi_delete_to (count, key) - int count, key; + int count __attribute__((unused)), key; { int c; @@ -1057,7 +1057,7 @@ rl_vi_delete_to (count, key) int rl_vi_change_to (count, key) - int count, key; + int count __attribute__((unused)), key; { int c, start_pos; @@ -1110,7 +1110,7 @@ rl_vi_change_to (count, key) int rl_vi_yank_to (count, key) - int count, key; + int count __attribute__((unused)), key; { int c, save; @@ -1202,7 +1202,7 @@ rl_vi_delete (count, key) int rl_vi_back_to_indent (count, key) - int count, key; + int count __attribute__((unused)), key; { rl_beg_of_line (1, key); while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point])) @@ -1212,7 +1212,7 @@ rl_vi_back_to_indent (count, key) int rl_vi_first_print (count, key) - int count, key; + int count __attribute__((unused)), key; { return (rl_vi_back_to_indent (1, key)); } @@ -1319,7 +1319,7 @@ rl_vi_char_search (count, key) /* Match brackets */ int rl_vi_match (ignore, key) - int ignore, key; + int ignore __attribute__((unused)), key; { int count = 1, brack, pos, tmp, pre; @@ -1426,7 +1426,7 @@ rl_vi_bracktype (c) static int _rl_vi_change_char (count, c, mb) int count, c; - char *mb; + char *mb __attribute__((unused)); { int p; @@ -1458,8 +1458,8 @@ _rl_vi_change_char (count, c, mb) static int _rl_vi_callback_getchar (mb, mlen) - char *mb; - int mlen; + char *mb __attribute__((unused)); + int mlen __attribute__((unused)); { int c; @@ -1494,7 +1494,7 @@ _rl_vi_callback_change_char (data) int rl_vi_change_char (count, key) - int count, key; + int count, key __attribute__((unused)); { int c; char mb[MB_LEN_MAX]; @@ -1582,7 +1582,7 @@ rl_vi_overstrike_delete (count, key) int rl_vi_replace (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { int i; @@ -1663,7 +1663,7 @@ _rl_vi_set_mark () #if defined (READLINE_CALLBACKS) static int _rl_vi_callback_set_mark (data) - _rl_callback_generic_arg *data; + _rl_callback_generic_arg *data __attribute__((unused)); { _rl_callback_func = 0; _rl_want_redisplay = 1; @@ -1674,7 +1674,7 @@ _rl_vi_callback_set_mark (data) int rl_vi_set_mark (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { #if defined (READLINE_CALLBACKS) if (RL_ISSTATE (RL_STATE_CALLBACK)) @@ -1721,7 +1721,7 @@ _rl_vi_goto_mark () #if defined (READLINE_CALLBACKS) static int _rl_vi_callback_goto_mark (data) - _rl_callback_generic_arg *data; + _rl_callback_generic_arg *data __attribute__((unused)); { _rl_callback_func = 0; _rl_want_redisplay = 1; @@ -1732,7 +1732,7 @@ _rl_vi_callback_goto_mark (data) int rl_vi_goto_mark (count, key) - int count, key; + int count __attribute__((unused)), key __attribute__((unused)); { #if defined (READLINE_CALLBACKS) if (RL_ISSTATE (RL_STATE_CALLBACK)) diff --git a/configure.in b/configure.in index 83cc012111d..d68a4121642 100644 --- a/configure.in +++ b/configure.in @@ -10,7 +10,7 @@ AC_CANONICAL_SYSTEM # # When changing major version number please also check switch statement # in mysqlbinlog::check_master_version(). -AM_INIT_AUTOMAKE(mysql, 5.1.35) +AM_INIT_AUTOMAKE(mysql, 5.1.37) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 @@ -603,10 +603,11 @@ AC_SUBST(NOINST_LDFLAGS) # Check if we are using Linux and a glibc compiled with static nss # (this is true on the MySQL build machines to avoid NSS problems) # +AC_CHECK_TOOL([NM], [nm]) if test "$TARGET_LINUX" = "true" -a "$static_nss" = "" then - tmp=`nm /usr/lib*/libc.a | grep _nss_files_getaliasent_r` + tmp=`$NM ${other_libc_lib:-/usr/lib*}/libc.a | grep _nss_files_getaliasent_r1` if test -n "$tmp" then STATIC_NSS_FLAGS="-lc -lnss_files -lnss_dns -lresolv" @@ -1624,7 +1625,7 @@ esac # Build optimized or debug version ? # First check for gcc and g++ -if test "$ac_cv_prog_gcc" = "yes" +if test "$GCC" = "yes" then DEBUG_CFLAGS="-g" DEBUG_OPTIMIZE_CC="-O" @@ -1632,9 +1633,16 @@ then else DEBUG_CFLAGS="-g" DEBUG_OPTIMIZE_CC="" - OPTIMIZE_CFLAGS="-O" + case $SYSTEM_TYPE in + *solaris*) + OPTIMIZE_CFLAGS="-O1" + ;; + *) + OPTIMIZE_CFLAGS="-O" + ;; + esac fi -if test "$ac_cv_prog_cxx_g" = "yes" +if test "$GXX" = "yes" then DEBUG_CXXFLAGS="-g" DEBUG_OPTIMIZE_CXX="-O" @@ -1642,7 +1650,14 @@ then else DEBUG_CXXFLAGS="-g" DEBUG_OPTIMIZE_CXX="" - OPTIMIZE_CXXFLAGS="-O" + case $SYSTEM_TYPE in + *solaris*) + OPTIMIZE_CXXFLAGS="-O1" + ;; + *) + OPTIMIZE_CXXFLAGS="-O" + ;; + esac fi case $SYSTEM_TYPE in @@ -2076,6 +2091,25 @@ case "$mysql_cv_sys_os" in # unsupported priority values are passed to pthread_setschedprio. # Since the only supported value is 1, treat it as inexistent. ;; + SunOS) # Bug#42599 error: `pthread_setschedprio' was not declared in this scope + # In some installations, the pthread.h header used by GCC does not + # declare the pthread_setscheprio prototype, but the function is + # implemented. Since the function is used in C++ code, ensure that + # the function prototype is present. + AC_MSG_CHECKING([whether pthread_setschedprio is declared]) + AC_LANG_PUSH([C++]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([#include <pthread.h>], + [(void)(pthread_setschedprio);])], + [ac_cv_func_pthread_setschedprio=yes], + [ac_cv_func_pthread_setschedprio=no]) + AC_LANG_POP([C++]) + AC_MSG_RESULT([$ac_cv_func_pthread_setschedprio]) + if test "$ac_cv_func_pthread_setschedprio" = yes; then + AC_DEFINE(HAVE_PTHREAD_SETSCHEDPRIO, 1, + [Define to 1 if you have the `pthread_setschedprio' function.]) + fi + ;; *) AC_CHECK_FUNCS(pthread_setschedprio) ;; esac diff --git a/dbug/user.r b/dbug/user.r index 19de840d0ad..ef67ef7a7cf 100644 --- a/dbug/user.r +++ b/dbug/user.r @@ -32,6 +32,7 @@ .\" === Set line length .\".ll 6.5i .TL +.warn 0 D B U G .P 0 C Program Debugging Package diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index 262b5cb3b8b..b4d9005af15 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -790,15 +790,17 @@ void processReply(SSL& ssl) if (ssl.GetError()) return; if (DoProcessReply(ssl)) + { // didn't complete process if (!ssl.getSocket().IsNonBlocking()) { // keep trying now, blocking ok while (!ssl.GetError()) if (DoProcessReply(ssl) == 0) break; - } + } else // user will have try again later, non blocking ssl.SetError(YasslError(SSL_ERROR_WANT_READ)); + } } @@ -873,10 +875,12 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer) void sendChangeCipher(SSL& ssl, BufferOutput buffer) { if (ssl.getSecurity().get_parms().entity_ == server_end) + { if (ssl.getSecurity().get_resuming()) ssl.verifyState(clientKeyExchangeComplete); else ssl.verifyState(clientFinishedComplete); + } if (ssl.GetError()) return; ChangeCipherSpec ccs; diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp index 20dfe50f132..f079df8c7ce 100644 --- a/extra/yassl/src/yassl_imp.cpp +++ b/extra/yassl/src/yassl_imp.cpp @@ -1305,6 +1305,7 @@ void ServerHello::Process(input_buffer&, SSL& ssl) ssl.useSecurity().use_connection().sessionID_Set_ = false; if (ssl.getSecurity().get_resuming()) + { if (memcmp(session_id_, ssl.getSecurity().get_resume().GetID(), ID_LEN) == 0) { ssl.set_masterSecret(ssl.getSecurity().get_resume().GetSecret()); @@ -1319,6 +1320,7 @@ void ServerHello::Process(input_buffer&, SSL& ssl) ssl.useSecurity().set_resuming(false); ssl.useLog().Trace("server denied resumption"); } + } if (ssl.CompressionOn() && !compression_method_) ssl.UnSetCompression(); // server isn't supporting yaSSL zlib request diff --git a/extra/yassl/taocrypt/include/modes.hpp b/extra/yassl/taocrypt/include/modes.hpp index d1ebce7568b..4575fe1414b 100644 --- a/extra/yassl/taocrypt/include/modes.hpp +++ b/extra/yassl/taocrypt/include/modes.hpp @@ -96,10 +96,12 @@ inline void Mode_BASE::Process(byte* out, const byte* in, word32 sz) if (mode_ == ECB) ECB_Process(out, in, sz); else if (mode_ == CBC) + { if (dir_ == ENCRYPTION) CBC_Encrypt(out, in, sz); else CBC_Decrypt(out, in, sz); + } } diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp index 3b1c1c2136a..78200841bda 100644 --- a/extra/yassl/taocrypt/src/asn.cpp +++ b/extra/yassl/taocrypt/src/asn.cpp @@ -781,10 +781,12 @@ void CertDecoder::GetDate(DateType dt) source_.advance(length); if (!ValidateDate(date, b, dt) && verify_) + { if (dt == BEFORE) source_.SetError(BEFORE_DATE_E); else source_.SetError(AFTER_DATE_E); + } // save for later use if (dt == BEFORE) { @@ -1062,6 +1064,7 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz) } word32 rLen = GetLength(source); if (rLen != 20) + { if (rLen == 21) { // zero at front, eat source.next(); --rLen; @@ -1074,6 +1077,7 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz) source.SetError(DSA_SZ_E); return 0; } + } memcpy(decoded, source.get_buffer() + source.get_index(), rLen); source.advance(rLen); @@ -1084,6 +1088,7 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz) } word32 sLen = GetLength(source); if (sLen != 20) + { if (sLen == 21) { source.next(); // zero at front, eat --sLen; @@ -1096,6 +1101,7 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz) source.SetError(DSA_SZ_E); return 0; } + } memcpy(decoded + rLen, source.get_buffer() + source.get_index(), sLen); source.advance(sLen); diff --git a/include/hash.h b/include/hash.h index f4b82454b81..629b404e8a7 100644 --- a/include/hash.h +++ b/include/hash.h @@ -106,7 +106,7 @@ void my_hash_replace(HASH *hash, HASH_SEARCH_STATE *state, uchar *new_row); my_bool my_hash_check(HASH *hash); /* Only in debug library */ #define my_hash_clear(H) bzero((char*) (H), sizeof(*(H))) -#define my_hash_inited(H) ((H)->array.buffer != 0) +#define my_hash_inited(H) ((H)->blength != 0) #define my_hash_init_opt(A,B,C,D,E,F,G,H) \ (!my_hash_inited(A) && _my_hash_init(A,0,B,C,D,E,F,G, H CALLER_INFO)) diff --git a/include/my_global.h b/include/my_global.h index 9e8c9bdfc70..5b29c7ce000 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -276,7 +276,7 @@ #endif /* The client defines this to avoid all thread code */ -#if defined(UNDEF_THREADS_HACK) +#if defined(MYSQL_CLIENT_NO_THREADS) || defined(UNDEF_THREADS_HACK) #undef THREAD #undef HAVE_LINUXTHREADS #undef HAVE_NPTL diff --git a/include/my_sys.h b/include/my_sys.h index 01804cd089f..263b567684d 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -511,7 +511,7 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *); ((info)->write_pos + (Count) <=(info)->write_end ?\ (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\ ((info)->write_pos+=(Count)),0) : \ - (*(info)->write_function)((info),(Buffer),(Count))) + (*(info)->write_function)((info),(uchar *)(Buffer),(Count))) #define my_b_get(info) \ ((info)->read_pos != (info)->read_end ?\ diff --git a/include/myisam.h b/include/myisam.h index d7bfdf7191e..02251eeacb4 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -404,7 +404,8 @@ typedef struct st_mi_check_param my_off_t keydata,totaldata,key_blocks,start_check_pos; ha_rows total_records,total_deleted; ha_checksum record_checksum,glob_crc; - ulong use_buffers,read_buffer_length,write_buffer_length, + ulonglong use_buffers; + ulong read_buffer_length,write_buffer_length, sort_buffer_length,sort_key_blocks; uint out_flag,warning_printed,error_printed,verbose; uint opt_sort_key,total_files,max_level; diff --git a/include/myisammrg.h b/include/myisammrg.h index dafae157ee0..446ecb7d719 100644 --- a/include/myisammrg.h +++ b/include/myisammrg.h @@ -88,7 +88,8 @@ extern MYRG_INFO *myrg_parent_open(const char *parent_name, void *callback_param); extern int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, MI_INFO *(*callback)(void*), - void *callback_param); + void *callback_param, + my_bool *need_compat_check); extern int myrg_detach_children(MYRG_INFO *m_info); extern int myrg_panic(enum ha_panic_function function); extern int myrg_rfirst(MYRG_INFO *file,uchar *buf,int inx); diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am index 21f8f372d0f..f67abfd8ac6 100644 --- a/libmysql/Makefile.am +++ b/libmysql/Makefile.am @@ -21,7 +21,7 @@ # This file is public domain and comes with NO WARRANTY of any kind target = libmysqlclient.la -target_defs = -DUNDEF_THREADS_HACK -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ +target_defs = -DMYSQL_CLIENT_NO_THREADS -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ LIBS = @CLIENT_LIBS@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ $(openssl_includes) @ZLIB_INCLUDES@ @@ -104,7 +104,7 @@ do-lib-dist: echo "# A very minimal Makefile to compile" > $$dir/Makefile; \ echo "# the minimized libmysql library" >> $$dir/Makefile; \ echo "# This file is autogenerated from Makefile.am" >> $$dir/Makefile; \ - echo 'CFLAGS= -I. -DUNDEF_THREADS_HACK' >>$$dir/Makefile; \ + echo 'CFLAGS= -I. -DMYSQL_CLIENT_NO_THREADS' >>$$dir/Makefile; \ echo "obj=$$objs" >>$$dir/Makefile; \ echo 'all: libmysql.a' >>$$dir/Makefile; \ echo 'libmysql.a: $$(obj)' >>$$dir/Makefile; \ diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 5e3582d5e16..7a56584190d 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -25,6 +25,7 @@ test_SCRIPTS = mtr \ mysql-stress-test.pl nobase_test_DATA = \ + valgrind.supp \ lib/v1/mysql-test-run.pl \ lib/v1/mtr_cases.pl \ lib/v1/mtr_io.pl \ @@ -41,7 +42,6 @@ nobase_test_DATA = \ lib/v1/mtr_im.pl \ lib/v1/mtr_process.pl \ lib/v1/mtr_unique.pl \ -\ lib/mtr_cases.pm \ lib/mtr_gcov.pl \ lib/mtr_gprof.pl \ @@ -69,9 +69,8 @@ nobase_test_DATA = \ SUBDIRS = lib/My/SafeProcess EXTRA_DIST = README \ - valgrind.supp \ $(test_SCRIPTS) \ - $(nobase_test_DATA) + $(nobase_test_DATA) # List of directories containing test + result files and the # related test data files that should be copied @@ -93,7 +92,7 @@ TEST_DIRS = t r include std_data std_data/parts collections \ suite/jp suite/jp/t suite/jp/r suite/jp/std_data suite/jp/include \ suite/manual/t suite/manual/r \ suite/ndb_team suite/ndb_team/t suite/ndb_team/r \ - suite/rpl suite/rpl/data suite/rpl/include suite/rpl/r \ + suite/rpl suite/rpl/include suite/rpl/r \ suite/rpl/t \ suite/stress/include suite/stress/t suite/stress/r \ suite/ndb suite/ndb/t suite/ndb/r \ diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental index 103069f79cf..faa8ba110d3 100644 --- a/mysql-test/collections/default.experimental +++ b/mysql-test/collections/default.experimental @@ -1 +1,13 @@ funcs_1.charset_collation_1 # depends on compile-time decisions +binlog.binlog_tmp_table # Bug#45578: Test binlog_tmp_table fails ramdonly on PB2: Unknown table 't2' +main.ctype_gbk_binlog # Bug#46010: main.ctype_gbk_binlog fails sporadically : Table 't2' already exists +rpl.rpl_row_create_table # Bug#45576: rpl_row_create_table fails on PB2 +rpl.rpl_extraColmaster_myisam # Bug#46013: rpl_extraColmaster_myisam fails on pb2 +rpl.rpl_stm_reset_slave # Bug#46014: rpl_stm_reset_slave crashes the server sporadically in pb2 +rpl.rpl_extraCol_myisam # Bug#40796 +rpl.rpl_extraColmaster_innodb # Bug#40796 +rpl.rpl_extraCol_innodb # Bug#40796 +rpl_ndb.rpl_ndb_log # Bug#38998 +rpl.rpl_innodb_bug28430 # Bug#46029 +rpl.rpl_row_basic_3innodb # Bug#45243 +rpl.rpl_truncate_3innodb # Bug#46030 diff --git a/mysql-test/collections/default.push b/mysql-test/collections/default.push index 0879b6fde2c..0f7c8d9949e 100644 --- a/mysql-test/collections/default.push +++ b/mysql-test/collections/default.push @@ -1,5 +1,5 @@ -perl mysql-test-run.pl --timer --force --comment=n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental -perl mysql-test-run.pl --timer --force --comment=ps_row --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental -perl mysql-test-run.pl --timer --force --comment=embedded --embedded --experimental=collections/default.experimental -perl mysql-test-run.pl --timer --force --comment=rpl_binlog_row --suite=rpl,binlog --mysqld=--binlog-format=row --experimental=collections/default.experimental -perl mysql-test-run.pl --timer --force --comment=funcs_1 --suite=funcs_1 --experimental=collections/default.experimental +perl mysql-test-run.pl --timer --force --parallel=auto --comment=n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental +perl mysql-test-run.pl --timer --force --parallel=auto --comment=ps_row --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental +perl mysql-test-run.pl --timer --force --parallel=auto --comment=embedded --embedded --experimental=collections/default.experimental +perl mysql-test-run.pl --timer --force --parallel=auto --comment=rpl_binlog_row --suite=rpl,binlog --mysqld=--binlog-format=row --experimental=collections/default.experimental +perl mysql-test-run.pl --timer --force --parallel=auto --comment=funcs_1 --suite=funcs_1 --experimental=collections/default.experimental diff --git a/mysql-test/extra/rpl_tests/rpl_reset_slave.test b/mysql-test/extra/rpl_tests/rpl_reset_slave.test index 2cc041a35e1..1f88c792fce 100644 --- a/mysql-test/extra/rpl_tests/rpl_reset_slave.test +++ b/mysql-test/extra/rpl_tests/rpl_reset_slave.test @@ -41,3 +41,57 @@ reset slave; start slave; sync_with_master; show status like 'slave_open_temp_tables'; + +# +#Bug#34654 RESET SLAVE does not clear LAST_IO_Err* +# + +# clearing the status +stop slave; +reset slave; +let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1); +echo *** errno must be zero: $last_io_errno ***; + +# +# verifying start slave resets Last_IO_Error and Last_IO_Errno. +# + +change master to master_user='impossible_user_name'; +start slave; +source include/wait_for_slave_io_error.inc; +let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1); +--disable_query_log +eval SELECT $last_io_errno > 0 as ONE; +--enable_query_log + +source include/stop_slave.inc; +change master to master_user='root'; +source include/start_slave.inc; +let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1); +let $last_io_error= query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1); +--echo *** last errno must be zero: $last_io_errno *** +--echo *** last error must be blank: $last_io_error *** + +# +# verifying reset slave resets Last_{IO,SQL}_Err{or,no} +# + +source include/stop_slave.inc; +change master to master_user='impossible_user_name'; +start slave; +source include/wait_for_slave_io_error.inc; +let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1); +--disable_query_log +eval SELECT $last_io_errno > 0 as ONE; +--enable_query_log + +source include/stop_slave.inc; +reset slave; +let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1); +let $last_io_error= query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1); +let $last_sql_errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1); +let $last_sql_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1); +--echo *** io last errno must be zero: $last_io_errno *** +--echo *** io last error must be blank: $last_io_error *** +--echo *** sql last errno must be zero: $last_sql_errno *** +--echo *** sql last error must be blank: $last_sql_error *** diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc index a4e7d9ae601..d412eae8364 100644 --- a/mysql-test/include/commit.inc +++ b/mysql-test/include/commit.inc @@ -669,13 +669,9 @@ call p_verify_status_increment(1, 0, 1, 0); insert t1 set a=3; call p_verify_status_increment(2, 2, 2, 2); savepoint a; -call p_verify_status_increment(0, 0, 0, 0); +call p_verify_status_increment(1, 0, 1, 0); insert t1 set a=4; ---echo # Binlog does not register itself this time for other than the 1st ---echo # statement of the transaction with MIXED/STATEMENT binlog_format. ---echo # It needs registering with the ROW format. Therefore 1,0,2,2 are ---echo # the correct arguments to this test after bug#40221 fixed. -call p_verify_status_increment(1, 0, 2, 2); +call p_verify_status_increment(2, 2, 2, 2); release savepoint a; rollback; call p_verify_status_increment(0, 0, 0, 0); diff --git a/mysql-test/include/concurrent.inc b/mysql-test/include/concurrent.inc index 2180ec4cc9c..66f8a65a102 100644 --- a/mysql-test/include/concurrent.inc +++ b/mysql-test/include/concurrent.inc @@ -659,11 +659,16 @@ drop table t1; connection thread1; select * from t1; +--echo ** Cleanup +connection thread1; +disconnect thread1; +--source include/wait_until_disconnected.inc +--echo ** connection thread2 +connection thread2; +disconnect thread2; +--source include/wait_until_disconnected.inc --echo ** connection default connection default; drop table t1; drop user mysqltest@localhost; -disconnect thread1; -disconnect thread2; - diff --git a/mysql-test/include/grant_cache.inc b/mysql-test/include/grant_cache.inc index 501e115f0ee..47eef1cdb67 100644 --- a/mysql-test/include/grant_cache.inc +++ b/mysql-test/include/grant_cache.inc @@ -171,15 +171,30 @@ show status like "Qcache_not_cached"; # Cleanup ---echo ----- switch to connection default and close connections ----- -connection default; +--echo ----- close connections ----- +connection root; disconnect root; +--source include/wait_until_disconnected.inc +connection root2; disconnect root2; +--source include/wait_until_disconnected.inc +connection user1; disconnect user1; +--source include/wait_until_disconnected.inc +connection user2; disconnect user2; +--source include/wait_until_disconnected.inc +connection user3; disconnect user3; +--source include/wait_until_disconnected.inc +connection user4; disconnect user4; +--source include/wait_until_disconnected.inc +connection unkuser; disconnect unkuser; +--source include/wait_until_disconnected.inc +--echo ----- switch to connection default ----- +connection default; # # A temporary 4.1 workaround to make this test pass if diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc index 96f90aba8e0..6e7f53ba9b2 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/include/handler.inc @@ -719,6 +719,7 @@ connection con1; --reap drop table t1; disconnect con1; +--source include/wait_until_disconnected.inc connection default; # diff --git a/mysql-test/include/index_merge1.inc b/mysql-test/include/index_merge1.inc index 5837df67a75..d137b0957c0 100644 --- a/mysql-test/include/index_merge1.inc +++ b/mysql-test/include/index_merge1.inc @@ -527,4 +527,30 @@ where exists (select 1 from t2, t3 drop table t0, t1, t2, t3; +--echo # +--echo # BUG#44810: index merge and order by with low sort_buffer_size +--echo # crashes server! +--echo # +CREATE TABLE t1(a VARCHAR(128),b VARCHAR(128),KEY(A),KEY(B)); +INSERT INTO t1 VALUES (REPEAT('a',128),REPEAT('b',128)); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SET SESSION sort_buffer_size=1; +EXPLAIN +SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%' + ORDER BY a,b; +# we don't actually care about the result : we're checking if it crashes +--disable_result_log +SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%' + ORDER BY a,b; +--enable_result_log + +SET SESSION sort_buffer_size=DEFAULT; +DROP TABLE t1; + + --echo End of 5.0 tests diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index c9cbf2d2839..6dabe4864a9 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -1162,6 +1162,25 @@ ROLLBACK; --error 1305 ROLLBACK TO SAVEPOINT s4; +# +# Bug#39793 Foreign keys not constructed when column has a '#' in a comment or default value +# + +#This statement should be written on a single line for proper testing +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY COMMENT 'My ID#', f2 INTEGER DEFAULT NULL, f3 CHAR(10) DEFAULT 'My ID#', CONSTRAINT f2_ref FOREIGN KEY (f2) REFERENCES t1 (f1)) ENGINE=INNODB; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--echo # +--echo # Bug #36995: valgrind error in remove_const during subquery executions +--echo # + +create table t1 (a bit(1) not null,b int) engine=myisam; +create table t2 (c int) engine=innodb; +explain +select b from t1 where a not in (select b from t1,t2 group by a) group by a; +DROP TABLE t1,t2; + --echo End of 5.0 tests # Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY @@ -1479,41 +1498,56 @@ INSERT INTO t1 VALUES (4,1,3,'pk',NULL),(5,1,3,'c2',NULL), (2,1,4,'c_extra',NULL),(3,1,4,'c_extra',NULL); -EXPLAIN SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC; +EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC; -SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC; +SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC; DROP TABLE t1; -# -# Bug#21704: Renaming column does not update FK definition. -# +--echo # +--echo # Bug #44290: explain crashes for subquery with distinct in +--echo # SQL_SELECT::test_quick_select +--echo # (reproduced only with InnoDB tables) +--echo # -# -# --disable_warnings -# DROP TABLE IF EXISTS t1; -# DROP TABLE IF EXISTS t2; -# --enable_warnings -# -# CREATE TABLE t1(id INT PRIMARY KEY) -# ENGINE=innodb; -# -# CREATE TABLE t2( -# t1_id INT PRIMARY KEY, -# CONSTRAINT fk1 FOREIGN KEY (t1_id) REFERENCES t1(id)) -# ENGINE=innodb; -# -# --echo -# -# --disable_result_log -# --error ER_ERROR_ON_RENAME -# ALTER TABLE t1 CHANGE id id2 INT; -# --enable_result_log -# -# --echo -# -# DROP TABLE t2; -# DROP TABLE t1; -# +eval +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, KEY (c3), KEY (c2, c3)) + ENGINE=$engine_type; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); + +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) + FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) + FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; + +DROP TABLE t1; + +eval +CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3)) + ENGINE=$engine_type; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); + +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) + FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) + FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; + +DROP TABLE t1; + +eval +CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2), + KEY (c3), KEY (c2, c3)) + ENGINE=$engine_type; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); + +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) + FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) + FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; + +DROP TABLE t1; --echo End of 5.1 tests diff --git a/mysql-test/include/mtr_check.sql b/mysql-test/include/mtr_check.sql index 12cb2c870a2..9db631a2615 100644 --- a/mysql-test/include/mtr_check.sql +++ b/mysql-test/include/mtr_check.sql @@ -57,3 +57,13 @@ BEGIN mysql.user; END|| + +-- +-- Procedure used by test case used to force all +-- servers to restart after testcase and thus skipping +-- check test case after test +-- +CREATE DEFINER=root@localhost PROCEDURE force_restart() +BEGIN + SELECT 1 INTO OUTFILE 'force_restart'; +END|| diff --git a/mysql-test/include/mtr_warnings.sql b/mysql-test/include/mtr_warnings.sql index 73287900f3c..b99402c8031 100644 --- a/mysql-test/include/mtr_warnings.sql +++ b/mysql-test/include/mtr_warnings.sql @@ -139,9 +139,9 @@ INSERT INTO global_suppressions VALUES ("Cannot find or open table test\/bug29807 from"), /* innodb foreign key tests that fail in ALTER or RENAME produce this */ - ("InnoDB: Error: in ALTER TABLE `test`.`t[12]`"), + ("InnoDB: Error: in ALTER TABLE `test`.`t[123]`"), ("InnoDB: Error: in RENAME TABLE table `test`.`t1`"), - ("InnoDB: Error: table `test`.`t[12]` does not exist in the InnoDB internal"), + ("InnoDB: Error: table `test`.`t[123]` does not exist in the InnoDB internal"), /* Test case for Bug#14233 produces the following warnings: */ ("Stored routine 'test'.'bug14233_1': invalid value in column mysql.proc"), diff --git a/mysql-test/include/mysqldump.inc b/mysql-test/include/mysqldump.inc new file mode 100644 index 00000000000..6227138b012 --- /dev/null +++ b/mysql-test/include/mysqldump.inc @@ -0,0 +1,50 @@ +################################################################################ +# mysqldump.inc +# +# SUMMARY: include file to facilitate testing the quality of mysqldump output +# +# INPUTS: Two variables: +# $table_name - the name of the table that was dumped +# $mysqldumpfile - the name of the file that captured mysqldump output +# +# OUTPUTS: minor echo data: +# We 'echo' some stage information to the .result file: +# 'altering original table', 'restoring from dumpfile', 'comparing' +# +# OTHER FILES: We use include/diff_tables.inc to compare the original, renamed +# table with the 'restored' one. +# +# DESCRIPTION: This file works by being fed the name of the original table +# and a mysqldump output file. The original table is then renamed +# to <table_name>_orig, the mysqldump file is used to recreate the +# table, then diff_tables.inc is called to compare them. +# +# LIMITATIONS: Does *NOT* work with xml output! +# +# AUTHOR: pcrews 2009-05-21 +# Bug#40465 mysqldump.test does no checking of dump or restore +# +# LAST CHANGE: 2009-05-21 +# +################################################################################ + +--echo # Begin testing mysqldump output + restore +--echo # Create 'original table name - <table>_orig +# NOTE: We use SET then let as query_get_value has issues with the extra commas +# used in the CONCAT statement. +eval SET @orig_table_name = CONCAT('$table_name', '_orig'); +let $orig_table_name = query_get_value(SELECT @orig_table_name,@orig_table_name,1); +--echo # Rename original table +eval ALTER TABLE $table_name RENAME to $orig_table_name; +--echo # Recreate table from mysqldump output +--exec $MYSQL test < $mysqldumpfile +--echo # Compare original and recreated tables +--echo # Recreated table: $table_name +--echo # Original table: $orig_table_name +let $diff_table_1 = $table_name; +let $diff_table_2 = $orig_table_name; +--source include/diff_tables.inc +--echo # Cleanup +--remove_file $mysqldumpfile +eval DROP TABLE $table_name, $orig_table_name; + diff --git a/mysql-test/include/no_valgrind_without_big.inc b/mysql-test/include/no_valgrind_without_big.inc new file mode 100644 index 00000000000..743e974daec --- /dev/null +++ b/mysql-test/include/no_valgrind_without_big.inc @@ -0,0 +1,12 @@ +# include/no_valgrind_without_big.inc +# +# If we are running with Valgrind ($VALGRIND_TEST <> 0) than the resource +# consumption (storage space needed, runtime ...) will be extreme. +# Therefore we require that the option "--big-test" is also set. +# + +if (`SELECT $VALGRIND_TEST <> 0 AND '$BIG_TEST' = ''`) +{ + --skip Need "--big-test" when running with Valgrind +} + diff --git a/mysql-test/include/query_cache.inc b/mysql-test/include/query_cache.inc index 77ea0021a5d..7ce97b42158 100644 --- a/mysql-test/include/query_cache.inc +++ b/mysql-test/include/query_cache.inc @@ -177,6 +177,7 @@ show status like "Qcache_hits"; # Final cleanup eval set GLOBAL query_cache_size=$save_query_cache_size; +disconnect connection1; +--source include/wait_until_disconnected.inc connection default; drop table t2; -disconnect connection1; diff --git a/mysql-test/include/wait_for_slave_io_error.inc b/mysql-test/include/wait_for_slave_io_error.inc new file mode 100644 index 00000000000..094406e02b2 --- /dev/null +++ b/mysql-test/include/wait_for_slave_io_error.inc @@ -0,0 +1,23 @@ +# ==== Purpose ==== +# +# Waits until the IO thread of the current connection has got an +# error, or until a timeout is reached. +# +# ==== Usage ==== +# +# source include/wait_for_slave_io_error.inc; +# +# Parameters to this macro are $slave_timeout and +# $slave_keep_connection. See wait_for_slave_param.inc for +# descriptions. + +let $old_slave_param_comparison= $slave_param_comparison; + +let $slave_param= Last_IO_Errno; +let $slave_param_comparison= !=; +let $slave_param_value= 0; +let $slave_error_message= Failed while waiting for slave to produce an error in its sql thread; +source include/wait_for_slave_param.inc; +let $slave_error_message= ; + +let $slave_param_comparison= $old_slave_param_comparison; diff --git a/mysql-test/lib/My/CoreDump.pm b/mysql-test/lib/My/CoreDump.pm index f3e9f521384..3ac9e385070 100644 --- a/mysql-test/lib/My/CoreDump.pm +++ b/mysql-test/lib/My/CoreDump.pm @@ -22,6 +22,33 @@ use My::Platform; use File::Temp qw/ tempfile tempdir /; +my $hint_mysqld; # Last resort guess for executable path + +# If path in core file is 79 chars we assume it's been truncated +# Looks like we can still find the full path using 'strings' +# If that doesn't work, use the hint (mysqld path) as last resort. + +sub _verify_binpath { + my ($binary, $core_name)= @_; + my $binpath; + + if (length $binary != 79) { + $binpath= $binary; + print "Core generated by '$binpath'\n"; + } else { + # Last occurrence of path ending in /mysql*, cut from first / + if (`strings '$core_name' | grep "/mysql[^/. ]*\$" | tail -1` =~ /(\/.*)/) { + $binpath= $1; + print "Guessing that core was generated by '$binpath'\n"; + } else { + return unless $hint_mysqld; + $binpath= $hint_mysqld; + print "Wild guess that core was generated by '$binpath'\n"; + } + } + return $binpath; +} + sub _gdb { my ($core_name)= @_; @@ -33,7 +60,8 @@ sub _gdb { `gdb -c '$core_name' --batch 2>&1` =~ /Core was generated by `([^\s\'\`]+)/; my $binary= $1 or return; - print "Core generated by '$binary'\n"; + + $binary= _verify_binpath ($binary, $core_name) or return; # Create tempfile containing gdb commands my ($tmp, $tmp_name) = tempfile(); @@ -73,7 +101,8 @@ sub _dbx { `echo | dbx - '$core_name' 2>&1` =~ /Corefile specified executable: "([^"]+)"/; my $binary= $1 or return; - print "Core generated by '$binary'\n"; + + $binary= _verify_binpath ($binary, $core_name) or return; # Find all threads my @thr_ids = `echo threads | dbx '$binary' '$core_name' 2>&1` =~ /t@\d+/g; @@ -203,7 +232,7 @@ sub _cdb { my $cdb_cmd = "!sym prompts off; !analyze -v; .ecxr; !for_each_frame dv /t;!uniqstack -p;q"; my $cdb_output= - `cdb -z $core_name -i "$image_path" -y "$symbol_path" -t 0 -lines -c "$cdb_cmd" 2>&1`; + `cdb -c "$cdb_cmd" -z $core_name -i "$image_path" -y "$symbol_path" -t 0 -lines 2>&1`; return if $? >> 8; return unless $cdb_output; @@ -225,7 +254,8 @@ EOF sub show { - my ($class, $core_name)= @_; + my ($class, $core_name, $exe_mysqld)= @_; + $hint_mysqld= $exe_mysqld; # On Windows, rely on cdb to be there... if (IS_WINDOWS) diff --git a/mysql-test/lib/My/File/Path.pm b/mysql-test/lib/My/File/Path.pm index 99edeecdaf7..25a26568eee 100644 --- a/mysql-test/lib/My/File/Path.pm +++ b/mysql-test/lib/My/File/Path.pm @@ -164,6 +164,9 @@ sub copytree { copytree("$from_dir/$_", "$to_dir/$_"); next; } + + # Only copy plain files + next unless -f "$from_dir/$_"; copy("$from_dir/$_", "$to_dir/$_"); } closedir(DIR); diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index 5ef3286ad8e..7e102b628ca 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -536,7 +536,37 @@ sub wait_any { return $proc; } + +# +# Wait for all processes to exit +# +sub wait_all { + while(keys %running) + { + wait_any(); + } +} + + # +# Check if any process has exited, but don't wait. +# +# Returns a reference to the SafeProcess that +# exited or undefined +# +sub check_any { + for my $proc (values %running){ + if ( $proc->is_child($$) ) { + if (not $proc->wait_one(0)) { + _verbose ("Found exited $proc"); + return $proc; + } + } + } + return undef; +} + + # Overload string operator # and fallback to default functions if no # overloaded function is found diff --git a/mysql-test/lib/My/SafeProcess/Base.pm b/mysql-test/lib/My/SafeProcess/Base.pm index 3fc1b1be017..9a6871264b8 100644 --- a/mysql-test/lib/My/SafeProcess/Base.pm +++ b/mysql-test/lib/My/SafeProcess/Base.pm @@ -83,6 +83,13 @@ sub exit_status { }; } +# threads.pm may not exist everywhere, so use only on Windows. + +use if $^O eq "MSWin32", "threads"; +use if $^O eq "MSWin32", "threads::shared"; + +my $win32_spawn_lock :shared; + # # Create a new process @@ -104,6 +111,8 @@ sub create_process { if ($^O eq "MSWin32"){ + lock($win32_spawn_lock); + #printf STDERR "stdin %d, stdout %d, stderr %d\n", # fileno STDIN, fileno STDOUT, fileno STDERR; diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc index dc7b7da28c7..50c433b9b39 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process.cc @@ -89,7 +89,7 @@ static void die(const char* fmt, ...) } -static void kill_child (void) +static void kill_child(void) { int status= 0; @@ -119,7 +119,7 @@ static void kill_child (void) } -static void handle_abort (int sig) +extern "C" void handle_abort(int sig) { message("Got signal %d, child_pid: %d, sending ABRT", sig, child_pid); @@ -128,8 +128,8 @@ static void handle_abort (int sig) } } - -static void handle_signal (int sig) + +extern "C" void handle_signal(int sig) { message("Got signal %d, child_pid: %d", sig, child_pid); terminated= 1; @@ -152,7 +152,7 @@ int main(int argc, char* const argv[] ) pid_t own_pid= getpid(); pid_t parent_pid= getppid(); bool nocore = false; - + /* Install signal handlers */ signal(SIGTERM, handle_signal); signal(SIGINT, handle_signal); @@ -232,10 +232,11 @@ int main(int argc, char* const argv[] ) message("setrlimit failed, errno=%d", errno); } } - + // Signal that child is ready buf= 37; - write(pfd[1], &buf, 1); + if ((write(pfd[1], &buf, 1)) < 1) + die("Failed to signal that child is ready"); // Close write end close(pfd[1]); @@ -246,8 +247,10 @@ int main(int argc, char* const argv[] ) close(pfd[1]); // Close unused write end // Wait for child to signal it's ready - read(pfd[0], &buf, 1); - if(buf != 37) + if ((read(pfd[0], &buf, 1)) < 1) + die("Failed to read signal from child"); + + if (buf != 37) die("Didn't get 37 from pipe"); close(pfd[0]); // Close read end @@ -272,7 +275,7 @@ int main(int argc, char* const argv[] ) if (WIFEXITED(status)) { // Process has exited, collect return status - int ret_code= WEXITSTATUS(status); + ret_code= WEXITSTATUS(status); message("Child exit: %d", ret_code); // Exit with exit status of the child exit(ret_code); @@ -287,6 +290,6 @@ int main(int argc, char* const argv[] ) } kill_child(); - exit(1); + return 1; } diff --git a/mysql-test/lib/My/SafeProcess/safe_process_win.cc b/mysql-test/lib/My/SafeProcess/safe_process_win.cc index 4fb89f098ed..80c1b7a97f2 100755 --- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc @@ -259,22 +259,37 @@ int main(int argc, const char** argv ) the JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flag, making sure it will be terminated when the last handle to it is closed(which is owned by this process). + + If breakaway from job fails on some reason, fallback is to create a + new process group. Process groups also allow to kill process and its + descedants, subject to some restrictions (processes have to run within + the same console,and must not ignore CTRL_BREAK) */ - if (CreateProcess(NULL, (LPSTR)child_args, + DWORD create_flags[]= {CREATE_BREAKAWAY_FROM_JOB, CREATE_NEW_PROCESS_GROUP, 0}; + BOOL process_created= FALSE; + BOOL jobobject_assigned= FALSE; + + for (int i=0; i < sizeof(create_flags)/sizeof(create_flags[0]); i++) + { + process_created= CreateProcess(NULL, (LPSTR)child_args, NULL, NULL, TRUE, /* inherit handles */ - CREATE_SUSPENDED | CREATE_BREAKAWAY_FROM_JOB, + CREATE_SUSPENDED | create_flags[i], NULL, NULL, &si, - &process_info) == 0) - die("CreateProcess failed"); + &process_info); + if (process_created) + { + jobobject_assigned= AssignProcessToJobObject(job_handle, process_info.hProcess); + break; + } + } - if (AssignProcessToJobObject(job_handle, process_info.hProcess) == 0) + if (!process_created) { - TerminateProcess(process_info.hProcess, 200); - die("AssignProcessToJobObject failed"); + die("CreateProcess failed"); } ResumeThread(process_info.hThread); CloseHandle(process_info.hThread); @@ -312,6 +327,13 @@ int main(int argc, const char** argv ) message("TerminateJobObject failed"); CloseHandle(job_handle); message("Job terminated and closed"); + + if (!jobobject_assigned) + { + GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, process_info.dwProcessId); + TerminateProcess(process_info.hProcess, 202); + } + if (wait_res != WAIT_OBJECT_0 + CHILD) { /* The child has not yet returned, wait for it */ diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 23a85ef7ecc..2a7b07debd0 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -33,7 +33,7 @@ our $print_testcases; our $skip_rpl; our $do_test; our $skip_test; -our $opt_skip_combination; +our $skip_combinations; our $binlog_format; our $enable_disabled; our $default_storage_engine; @@ -119,11 +119,22 @@ sub collect_test_cases ($$) { if ( $test->{name} =~ /.*\.$tname/ ) { $found= 1; + last; } } if ( not $found ) { - mtr_error("Could not find '$tname' in '$suites' suite(s)"); + mtr_error("Could not find '$tname' in '$suites' suite(s)") unless $sname; + # If suite was part of name, find it there + my ($this_case) = collect_one_suite($sname, [ $tname ]); + if ($this_case) + { + push (@$cases, $this_case); + } + else + { + mtr_error("Could not find '$tname' in '$sname' suite"); + } } } } @@ -375,7 +386,7 @@ sub collect_one_suite($) # Read combinations for this suite and build testcases x combinations # if any combinations exists # ---------------------------------------------------------------------- - if ( ! $opt_skip_combination ) + if ( ! $skip_combinations ) { my @combinations; my $combination_file= "$suitedir/combinations"; @@ -887,7 +898,8 @@ sub collect_one_test_case { if ( $tinfo->{'innodb_test'} ) { # This is a test that need innodb - if ( $::mysqld_variables{'innodb'} ne "TRUE" ) + if ( $::mysqld_variables{'innodb'} eq "OFF" || + ! exists $::mysqld_variables{'innodb'} ) { # innodb is not supported, skip it $tinfo->{'skip'}= 1; diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index a99119a199d..a42627c93cd 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -21,7 +21,25 @@ use strict; use Socket; use Errno; - +use My::Platform; +use if IS_WINDOWS, "Net::Ping"; + +# Ancient perl might not have port_number method for Net::Ping. +# Check it and use fallback to connect() if it is not present. +BEGIN +{ + my $use_netping= 0; + if (IS_WINDOWS) + { + my $ping = Net::Ping->new(); + if ($ping->can("port_number")) + { + $use_netping= 1; + } + } + eval 'sub USE_NETPING { $use_netping }'; +} + sub sleep_until_file_created ($$$); sub mtr_ping_port ($); @@ -30,6 +48,24 @@ sub mtr_ping_port ($) { mtr_verbose("mtr_ping_port: $port"); + if (IS_WINDOWS && USE_NETPING) + { + # Under Windows, connect to a port that is not open is slow + # It takes ~1sec. Net::Ping with small timeout is much faster. + my $ping = Net::Ping->new(); + $ping->port_number($port); + if ($ping->ping("localhost",0.1)) + { + mtr_verbose("USED"); + return 1; + } + else + { + mtr_verbose("FREE"); + return 0; + } + } + my $remote= "localhost"; my $iaddr= inet_aton($remote); if ( ! $iaddr ) diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm index 9c6ab35ee5e..a246c5bbef6 100644 --- a/mysql-test/lib/mtr_report.pm +++ b/mysql-test/lib/mtr_report.pm @@ -30,6 +30,8 @@ our @EXPORT= qw(report_option mtr_print_line mtr_print_thick_line mtr_report_test); use mtr_match; +use My::Platform; +use POSIX qw[ _exit ]; require "mtr_io.pl"; my $tot_real_time= 0; @@ -69,6 +71,8 @@ sub _mtr_report_test_name ($) { print _name(), _timestamp(); printf "%-40s ", $tname; + my $worker = $tinfo->{worker}; + printf "w$worker " if $worker; return $tname; } @@ -217,8 +221,8 @@ sub mtr_report_test ($) { } -sub mtr_report_stats ($) { - my $tests= shift; +sub mtr_report_stats ($;$) { + my ($tests, $dont_error)= @_; # ---------------------------------------------------------------------- # Find out how we where doing @@ -257,6 +261,17 @@ sub mtr_report_stats ($) { $tot_restarts++; } + # Add counts for repeated runs, if any. + # Note that the last run has already been counted above. + my $num_repeat = $tinfo->{'repeat'} - 1; + if ( $num_repeat > 0 ) + { + $tot_tests += $num_repeat; + my $rep_failed = $tinfo->{'rep_failures'} || 0; + $tot_failed += $rep_failed; + $tot_passed += $num_repeat - $rep_failed; + } + # Look for warnings produced by mysqltest my $base_file= mtr_match_extension($tinfo->{'result_file'}, "result"); # Trim extension @@ -336,7 +351,7 @@ sub mtr_report_stats ($) { foreach my $tinfo (@$tests) { my $tname= $tinfo->{'name'}; - if ( $tinfo->{failures} and ! $seen{$tname}) + if ( ($tinfo->{failures} || $tinfo->{rep_failures}) and ! $seen{$tname}) { print " $tname"; $seen{$tname}= 1; @@ -359,7 +374,7 @@ sub mtr_report_stats ($) { if ( $tot_failed != 0 || $found_problems) { - mtr_error("there were failing test cases"); + mtr_error("there were failing test cases") unless $dont_error; } } @@ -459,7 +474,14 @@ sub mtr_warning (@) { sub mtr_error (@) { print STDERR _name(), _timestamp(), "mysql-test-run: *** ERROR: ", join(" ", @_), "\n"; - exit(1); + if (IS_WINDOWS) + { + POSIX::_exit(1); + } + else + { + exit(1); + } } diff --git a/mysql-test/lib/mtr_unique.pm b/mysql-test/lib/mtr_unique.pm index 294a5d7b4d6..6b60157422d 100644 --- a/mysql-test/lib/mtr_unique.pm +++ b/mysql-test/lib/mtr_unique.pm @@ -28,32 +28,36 @@ sub msg { # print "### unique($$) - ", join(" ", @_), "\n"; } -my $file; +my $dir; if(!IS_WINDOWS) { - $file= "/tmp/mysql-test-ports"; + $dir= "/tmp/mysql-unique-ids"; } else { - $file= $ENV{'TEMP'}."/mysql-test-ports"; + # Try to use machine-wide directory location for unique IDs, + # $ALLUSERSPROFILE . IF it is not available, fallback to $TEMP + # which is typically a per-user temporary directory + if (exists $ENV{'ALLUSERSPROFILE'} && -w $ENV{'ALLUSERSPROFILE'}) + { + $dir= $ENV{'ALLUSERSPROFILE'}."/mysql-unique-ids"; + } + else + { + $dir= $ENV{'TEMP'}."/mysql-unique-ids"; + } } - -my %mtr_unique_ids; +my $mtr_unique_fh = undef; -END { - my $allocated_id= $mtr_unique_ids{$$}; - if (defined $allocated_id) - { - mtr_release_unique_id($allocated_id); - } - delete $mtr_unique_ids{$$}; +END +{ + mtr_release_unique_id(); } # -# Get a unique, numerical ID, given a file name (where all -# requested IDs are stored), a minimum and a maximum value. +# Get a unique, numerical ID in a specified range. # # If no unique ID within the specified parameters can be # obtained, return undef. @@ -61,135 +65,63 @@ END { sub mtr_get_unique_id($$) { my ($min, $max)= @_;; - msg("get, '$file', $min-$max"); - - die "Can only get one unique id per process!" if $mtr_unique_ids{$$}; + msg("get $min-$max, $$"); - my $ret = undef; - my $changed = 0; - - if(eval("readlink '$file'") || eval("readlink '$file.sem'")) { - die 'lock file is a symbolic link'; - } + die "Can only get one unique id per process!" if defined $mtr_unique_fh; - chmod 0777, "$file.sem"; - open SEM, ">", "$file.sem" or die "can't write to $file.sem"; - flock SEM, LOCK_EX or die "can't lock $file.sem"; - if(! -e $file) { - open FILE, ">", $file or die "can't create $file"; - close FILE; - } - msg("HAVE THE LOCK"); + # Make sure our ID directory exists + if (! -d $dir) + { + # If there is a file with the reserved + # directory name, just delete the file. + if (-e $dir) + { + unlink($dir); + } - if(eval("readlink '$file'") || eval("readlink '$file.sem'")) { - die 'lock file is a symbolic link'; - } + mkdir $dir; + chmod 0777, $dir; - chmod 0777, $file; - open FILE, "+<", $file or die "can't open $file"; - #select undef,undef,undef,0.2; - seek FILE, 0, 0; - my %taken = (); - while(<FILE>) { - chomp; - my ($id, $pid) = split / /; - $taken{$id} = $pid; - msg("taken: $id, $pid"); - # Check if process with given pid is alive - if(!process_alive($pid)) { - print "Removing slot $id used by missing process $pid\n"; - msg("Removing slot $id used by missing process $pid"); - delete $taken{$id}; - $changed++; + if(! -d $dir) + { + die "can't make directory $dir"; } } - for(my $i=$min; $i<=$max; ++$i) { - if(! exists $taken{$i}) { - $ret = $i; - $taken{$i} = $$; - $changed++; - # Remember the id this process got - $mtr_unique_ids{$$}= $i; - msg(" got $i"); - last; + + + my $fh; + for(my $id = $min; $id <= $max; $id++) + { + open( $fh, ">$dir/$id"); + chmod 0666, "$dir/$id"; + # Try to lock the file exclusively. If lock succeeds, we're done. + if (flock($fh, LOCK_EX|LOCK_NB)) + { + # Store file handle - we would need it to release the ID (==unlock the file) + $mtr_unique_fh = $fh; + return $id; } - } - if($changed) { - seek FILE, 0, 0; - truncate FILE, 0 or die "can't truncate $file"; - for my $k (keys %taken) { - print FILE $k . ' ' . $taken{$k} . "\n"; + else + { + close $fh; } } - close FILE; - - msg("RELEASING THE LOCK"); - flock SEM, LOCK_UN or warn "can't unlock $file.sem"; - close SEM; - - return $ret; + return undef; } # # Release a unique ID. # -sub mtr_release_unique_id($) { - my ($myid)= @_; - - msg("release, $myid"); - - - if(eval("readlink '$file'") || eval("readlink '$file.sem'")) { - die 'lock file is a symbolic link'; - } - - open SEM, ">", "$file.sem" or die "can't write to $file.sem"; - flock SEM, LOCK_EX or die "can't lock $file.sem"; - - msg("HAVE THE LOCK"); - - if(eval("readlink '$file'") || eval("readlink '$file.sem'")) { - die 'lock file is a symbolic link'; - } - - if(! -e $file) { - open FILE, ">", $file or die "can't create $file"; - close FILE; - } - open FILE, "+<", $file or die "can't open $file"; - #select undef,undef,undef,0.2; - seek FILE, 0, 0; - my %taken = (); - while(<FILE>) { - chomp; - my ($id, $pid) = split / /; - msg(" taken, $id $pid"); - $taken{$id} = $pid; - } - - if ($taken{$myid} != $$) +sub mtr_release_unique_id() +{ + msg("release $$"); + if (defined $mtr_unique_fh) { - msg(" The unique id for this process does not match pid"); + close $mtr_unique_fh; + $mtr_unique_fh = undef; } - - - msg(" removing $myid"); - delete $taken{$myid}; - seek FILE, 0, 0; - truncate FILE, 0 or die "can't truncate $file"; - for my $k (keys %taken) { - print FILE $k . ' ' . $taken{$k} . "\n"; - } - close FILE; - - msg("RELEASE THE LOCK"); - - flock SEM, LOCK_UN or warn "can't unlock $file.sem"; - close SEM; - - delete $mtr_unique_ids{$$}; } diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3949148ec49..2a6a069d81c 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -209,6 +209,7 @@ sub check_timeout { return $opt_testcase_timeout * 6; }; my $opt_start; my $opt_start_dirty; +my $opt_wait_all; my $opt_repeat= 1; my $opt_retry= 3; my $opt_retry_failure= 2; @@ -312,7 +313,7 @@ sub main { ####################################################################### my $num_tests= @$tests; - if ( not defined $opt_parallel ) { + if ( $opt_parallel eq "auto" ) { # Try to find a suitable value for number of workers my $sys_info= My::SysInfo->new(); @@ -429,6 +430,7 @@ sub run_test_server ($$$) { my $completed= []; my %running; my $result; + my $exe_mysqld= find_mysqld($basedir) || ""; # Used as hint to CoreDump my $suite_timeout_proc= My::SafeProcess->timer(suite_timeout()); @@ -500,7 +502,7 @@ sub run_test_server ($$$) { mtr_report(" - found '$core_name'", "($num_saved_cores/$opt_max_save_core)"); - My::CoreDump->show($core_file); + My::CoreDump->show($core_file, $exe_mysqld); if ($num_saved_cores >= $opt_max_save_core) { mtr_report(" - deleting it, already saved", @@ -515,6 +517,7 @@ sub run_test_server ($$$) { } } $num_saved_datadir++; + $num_failed_test++ unless $result->{retries}; if ( !$opt_force ) { # Test has failed, force is off @@ -525,11 +528,12 @@ sub run_test_server ($$$) { elsif ($opt_max_test_fail > 0 and $num_failed_test >= $opt_max_test_fail) { $suite_timeout_proc->kill(); + push(@$completed, $result); + mtr_report_stats($completed, 1); mtr_report("Too many tests($num_failed_test) failed!", "Terminating..."); return undef; } - $num_failed_test++; } # Retry test run after test failure @@ -554,9 +558,11 @@ sub run_test_server ($$$) { # Repeat test $opt_repeat number of times my $repeat= $result->{repeat} || 1; - if ($repeat < $opt_repeat) + # Don't repeat if test was skipped + if ($repeat < $opt_repeat && $result->{'result'} ne 'MTR_RES_SKIPPED') { $result->{retries}= 0; + $result->{rep_failures}++ if $result->{failures}; $result->{failures}= 0; delete($result->{result}); $result->{repeat}= $repeat+1; @@ -655,6 +661,7 @@ sub run_test_server ($$$) { # ---------------------------------------------------- if ( ! $suite_timeout_proc->wait_one(0) ) { + mtr_report_stats($completed, 1); mtr_report("Test suite timeout! Terminating..."); return undef; } @@ -719,6 +726,8 @@ sub run_worker ($) { delete($test->{'comment'}); delete($test->{'logfile'}); + $test->{worker} = $thread_num if $opt_parallel > 1; + run_testcase($test); #$test->{result}= 'MTR_RES_PASSED'; # Send it back, now with results set @@ -786,7 +795,7 @@ sub command_line_setup { 'vs-config' => \$opt_vs_config, # Max number of parallel threads to use - 'parallel=i' => \$opt_parallel, + 'parallel=s' => \$opt_parallel, # Config file to use as template for all tests 'defaults-file=s' => \&collect_option, @@ -876,6 +885,7 @@ sub command_line_setup { 'sleep=i' => \$opt_sleep, 'start-dirty' => \$opt_start_dirty, 'start' => \$opt_start, + 'wait-all' => \$opt_wait_all, 'print-testcases' => \&collect_option, 'repeat=i' => \$opt_repeat, 'retry=i' => \$opt_retry, @@ -1125,9 +1135,9 @@ sub command_line_setup { # -------------------------------------------------------------------------- # Check parallel value # -------------------------------------------------------------------------- - if ($opt_parallel < 1) + if ($opt_parallel ne "auto" && $opt_parallel < 1) { - mtr_error("0 or negative parallel value makes no sense, use positive number"); + mtr_error("0 or negative parallel value makes no sense, use 'auto' or positive number"); } # -------------------------------------------------------------------------- @@ -1234,6 +1244,15 @@ sub command_line_setup { } # -------------------------------------------------------------------------- + # Check use of wait-all + # -------------------------------------------------------------------------- + + if ($opt_wait_all && ! ($opt_start_dirty || $opt_start)) + { + mtr_error("--wait-all can only be used with --start or --start-dirty"); + } + + # -------------------------------------------------------------------------- # Check timeout arguments # -------------------------------------------------------------------------- @@ -1323,29 +1342,31 @@ sub set_build_thread_ports($) { if ( lc($opt_build_thread) eq 'auto' ) { my $found_free = 0; - $build_thread = 250; # Start attempts from here + $build_thread = 300; # Start attempts from here while (! $found_free) { - $build_thread= mtr_get_unique_id($build_thread, 299); + $build_thread= mtr_get_unique_id($build_thread, 349); if ( !defined $build_thread ) { - mtr_error("Could not get a unique build thread id"); + mtr_error("Could not get a unique build thread id"); } $found_free= check_ports_free($build_thread); # If not free, release and try from next number - mtr_release_unique_id($build_thread++) unless $found_free; + if (! $found_free) { + mtr_release_unique_id(); + $build_thread++; + } } } else { $build_thread = $opt_build_thread + $thread - 1; + if (! check_ports_free($build_thread)) { + # Some port was not free(which one has already been printed) + mtr_error("Some port(s) was not free") + } } $ENV{MTR_BUILD_THREAD}= $build_thread; - if (! check_ports_free($build_thread)) { - # Some port was not free(which one has already been printed) - mtr_error("Some port(s) was not free") - } - # Calculate baseport $baseport= $build_thread * 10 + 10000; if ( $baseport < 5001 or $baseport + 9 >= 32767 ) @@ -3134,6 +3155,26 @@ sub find_analyze_request } +# The test can leave a file in var/tmp/ to signal +# that all servers should be restarted +sub restart_forced_by_test +{ + my $restart = 0; + foreach my $mysqld ( mysqlds() ) + { + my $datadir = $mysqld->value('datadir'); + my $force_restart_file = "$datadir/mtr/force_restart"; + if ( -f $force_restart_file ) + { + mtr_verbose("Restart of servers forced by test"); + $restart = 1; + last; + } + } + return $restart; +} + + # Return timezone value of tinfo or default value sub timezone { my ($tinfo)= @_; @@ -3175,7 +3216,7 @@ sub run_testcase ($) { { # Remove old datadirs - clean_datadir(); + clean_datadir() unless $opt_start_dirty; # Restore old ENV while (my ($option, $value)= each( %old_env )) { @@ -3242,19 +3283,29 @@ sub run_testcase ($) { # -------------------------------------------------------------------- # If --start or --start-dirty given, stop here to let user manually # run tests + # If --wait-all is also given, do the same, but don't die if one + # server exits # ---------------------------------------------------------------------- + if ( $opt_start or $opt_start_dirty ) { mtr_print("\nStarted", started(all_servers())); mtr_print("Waiting for server(s) to exit..."); - my $proc= My::SafeProcess->wait_any(); - if ( grep($proc eq $_, started(all_servers())) ) - { - mtr_print("Server $proc died"); + if ( $opt_wait_all ) { + My::SafeProcess->wait_all(); + mtr_print( "All servers exited" ); + exit(1); + } + else { + my $proc= My::SafeProcess->wait_any(); + if ( grep($proc eq $_, started(all_servers())) ) + { + mtr_print("Server $proc died"); + exit(1); + } + mtr_print("Unknown process $proc died"); exit(1); } - mtr_print("Unknown process $proc died"); - exit(1); } my $test_timeout_proc= My::SafeProcess->timer(testcase_timeout()); @@ -3272,10 +3323,38 @@ sub run_testcase ($) { } my $test= start_mysqltest($tinfo); + # Set only when we have to keep waiting after expectedly died server + my $keep_waiting_proc = 0; while (1) { - my $proc= My::SafeProcess->wait_any(); + my $proc; + if ($keep_waiting_proc) + { + # Any other process exited? + $proc = My::SafeProcess->check_any(); + if ($proc) + { + mtr_verbose ("Found exited process $proc"); + # If that was the timeout, cancel waiting + if ( $proc eq $test_timeout_proc ) + { + $keep_waiting_proc = 0; + } + } + else + { + $proc = $keep_waiting_proc; + } + } + else + { + $proc= My::SafeProcess->wait_any(); + } + + # Will be restored if we need to keep waiting + $keep_waiting_proc = 0; + unless ( defined $proc ) { mtr_error("wait_any failed"); @@ -3302,7 +3381,11 @@ sub run_testcase ($) { if ( $res == 0 ) { my $check_res; - if ( $opt_check_testcases and + if ( restart_forced_by_test() ) + { + stop_all_servers(); + } + elsif ( $opt_check_testcases and $check_res= check_testcase($tinfo, "after")) { if ($check_res == 1) { @@ -3367,8 +3450,12 @@ sub run_testcase ($) { # ---------------------------------------------------- # Check if it was an expected crash # ---------------------------------------------------- - if ( check_expected_crash_and_restart($proc) ) + my $check_crash = check_expected_crash_and_restart($proc); + if ($check_crash) { + # Keep waiting if it returned 2, if 1 don't wait or stop waiting. + $keep_waiting_proc = 0 if $check_crash == 1; + $keep_waiting_proc = $proc if $check_crash == 2; next; } @@ -3709,16 +3796,16 @@ sub check_expected_crash_and_restart { { mtr_verbose("Crash was expected, file '$expect_file' exists"); - while (1){ - + for (my $waits = 0; $waits < 50; $waits++) + { # If last line in expect file starts with "wait" # sleep a little and try again, thus allowing the # test script to control when the server should start - # up again + # up again. Keep trying for up to 5s at a time. my $last_line= mtr_lastlinesfromfile($expect_file, 1); if ($last_line =~ /^wait/ ) { - mtr_verbose("Test says wait before restart"); + mtr_verbose("Test says wait before restart") if $waits == 0; mtr_milli_sleep(100); next; } @@ -3728,11 +3815,11 @@ sub check_expected_crash_and_restart { # Start server with same settings as last time mysqld_start($mysqld, $mysqld->{'started_opts'}); - last; + return 1; } + # Loop ran through: we should keep waiting after a re-check + return 2; } - - return 1; } # Not an expected crash @@ -4431,14 +4518,17 @@ sub start_servers($) { my $mysqld_basedir= $mysqld->value('basedir'); if ( $basedir eq $mysqld_basedir ) { - # Copy datadir from installed system db - for my $path ( "$opt_vardir", "$opt_vardir/..") { - my $install_db= "$path/install.db"; - copytree($install_db, $datadir) - if -d $install_db; + if (! $opt_start_dirty) # If dirty, keep possibly grown system db + { + # Copy datadir from installed system db + for my $path ( "$opt_vardir", "$opt_vardir/..") { + my $install_db= "$path/install.db"; + copytree($install_db, $datadir) + if -d $install_db; + } + mtr_error("Failed to copy system db to '$datadir'") + unless -d $datadir; } - mtr_error("Failed to copy system db to '$datadir'") - unless -d $datadir; } else { @@ -4978,10 +5068,13 @@ Options to control what engine/variation to run vs-config Visual Studio configuration used to create executables (default: MTR_VS_CONFIG environment variable) - config|defaults-file=<config template> Use fixed config template for all + defaults-file=<config template> Use fixed config template for all tests defaults_extra_file=<config template> Extra config template to add to all generated configs + combination=<opt> Use at least twice to run tests with specified + options to mysqld + skip-combinations Ignore combination file (or options) Options to control directories to use tmpdir=DIR The directory where temporary files are stored @@ -5004,7 +5097,6 @@ Options to control what test suites or cases to run force Continue to run the suite after failure with-ndbcluster-only Run only tests that include "ndb" in the filename skip-ndb[cluster] Skip all tests that need cluster - skip-ndb[cluster]-slave Skip all tests that need a slave cluster do-test=PREFIX or REGEX Run test cases which name are prefixed with PREFIX or fulfills REGEX @@ -5019,6 +5111,9 @@ Options to control what test suites or cases to run The default is: "$DEFAULT_SUITES" skip-rpl Skip the replication test cases. big-test Also run tests marked as "big" + enable-disabled Run also tests marked as disabled + print_testcases Don't run the tests but print details about all the + selected tests, in the order they would be run. Options that specify ports @@ -5087,7 +5182,7 @@ Options for valgrind valgrind-options=ARGS Deprecated, use --valgrind-option valgrind-option=ARGS Option to give valgrind, replaces default option(s), can be specified more then once - valgrind-path=[EXE] Path to the valgrind executable + valgrind-path=<EXE> Path to the valgrind executable callgrind Instruct valgrind to use callgrind Misc options @@ -5095,14 +5190,19 @@ Misc options comment=STR Write STR to the output notimer Don't show test case execution time verbose More verbose output(use multiple times for even more) + verbose-restart Write when and why servers are restarted start Only initialize and start the servers, using the startup settings for the first specified test case Example: $0 --start alias & start-dirty Only start the servers (without initialization) for the first specified test case + wait-all If --start or --start-dirty option is used, wait for all + servers to exit before finishing the process fast Run as fast as possible, dont't wait for servers to shutdown etc. + parallel=N Run tests in N parallel threads (default=1) + Use parallel=auto for auto-setting of N repeat=N Run each test N number of times retry=N Retry tests that fail N times, limit number of failures to $opt_retry_failure @@ -5120,6 +5220,12 @@ Misc options sleep=SECONDS Passed to mysqltest, will be used as fixed sleep time gcov Collect coverage information after the test. The result is a gcov file per source and header file. + experimental=<file> Refer to list of tests considered experimental; + failures will be marked exp-fail instead of fail. + report-features First run a "test" that reports mysql features + timestamp Print timestamp before each test report line + timediff With --timestamp, also print time passed since + *previous* test started HERE exit(1); diff --git a/mysql-test/r/bug46080.result b/mysql-test/r/bug46080.result new file mode 100644 index 00000000000..18c7c22829a --- /dev/null +++ b/mysql-test/r/bug46080.result @@ -0,0 +1,14 @@ +# +# Bug #46080: group_concat(... order by) crashes server when +# sort_buffer_size cannot allocate +# +CREATE TABLE t1(a CHAR(255)); +INSERT INTO t1 VALUES ('a'); +SET @@SESSION.sort_buffer_size=5*16*1000000; +SET @@SESSION.max_heap_table_size=5*1000000; +# Must not crash. +SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a; +DROP TABLE t1; +SET @@SESSION.sort_buffer_size=default; +SET @@SESSION.max_heap_table_size=default; +End of 5.0 tests diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index c1af92c5f8d..dd61396e485 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -439,3 +439,16 @@ HOUR(NULL) MINUTE(NULL) SECOND(NULL) NULL NULL NULL DROP TABLE t1; End of 5.0 tests +# +# Bug #44766: valgrind error when using convert() in a subquery +# +CREATE TABLE t1(a tinyint); +INSERT INTO t1 VALUES (127); +SELECT 1 FROM +( +SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1 +) AS s LIMIT 1; +1 +1 +DROP TABLE t1; +End of 5.1 tests diff --git a/mysql-test/r/commit_1innodb.result b/mysql-test/r/commit_1innodb.result index de80dba47c1..cabd4c29c1d 100644 --- a/mysql-test/r/commit_1innodb.result +++ b/mysql-test/r/commit_1innodb.result @@ -766,15 +766,11 @@ call p_verify_status_increment(2, 2, 2, 2); SUCCESS savepoint a; -call p_verify_status_increment(0, 0, 0, 0); +call p_verify_status_increment(1, 0, 1, 0); SUCCESS insert t1 set a=4; -# Binlog does not register itself this time for other than the 1st -# statement of the transaction with MIXED/STATEMENT binlog_format. -# It needs registering with the ROW format. Therefore 1,0,2,2 are -# the correct arguments to this test after bug#40221 fixed. -call p_verify_status_increment(1, 0, 2, 2); +call p_verify_status_increment(2, 2, 2, 2); SUCCESS release savepoint a; diff --git a/mysql-test/r/concurrent_innodb_safelog.result b/mysql-test/r/concurrent_innodb_safelog.result index e6adaac1068..24a84afb9ce 100644 --- a/mysql-test/r/concurrent_innodb_safelog.result +++ b/mysql-test/r/concurrent_innodb_safelog.result @@ -785,6 +785,8 @@ eta tipo c 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk +** Cleanup +** connection thread2 ** connection default drop table t1; drop user mysqltest@localhost; diff --git a/mysql-test/r/concurrent_innodb_unsafelog.result b/mysql-test/r/concurrent_innodb_unsafelog.result index e9c53d4cfa0..35fc2d89cfe 100644 --- a/mysql-test/r/concurrent_innodb_unsafelog.result +++ b/mysql-test/r/concurrent_innodb_unsafelog.result @@ -781,6 +781,8 @@ eta tipo c 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 80 1 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk +** Cleanup +** connection thread2 ** connection default drop table t1; drop user mysqltest@localhost; diff --git a/mysql-test/r/consistent_snapshot.result b/mysql-test/r/consistent_snapshot.result index 694c996a58e..3a0227b1a1a 100644 --- a/mysql-test/r/consistent_snapshot.result +++ b/mysql-test/r/consistent_snapshot.result @@ -1,6 +1,9 @@ DROP TABLE IF EXISTS t1; # Establish connection con1 (user=root) # Establish connection con2 (user=root) +### Test 1: +### - While a consistent snapshot transaction is executed, +### no external inserts should be visible to the transaction. # Switch to connection con1 CREATE TABLE t1 (a INT) ENGINE=innodb; START TRANSACTION WITH CONSISTENT SNAPSHOT; @@ -10,6 +13,9 @@ INSERT INTO t1 VALUES(1); SELECT * FROM t1; a COMMIT; +### Test 2: +### - For any non-consistent snapshot transaction, external +### committed inserts should be visible to the transaction. DELETE FROM t1; START TRANSACTION; # Switch to connection con2 @@ -19,5 +25,18 @@ SELECT * FROM t1; a 1 COMMIT; +### Test 3: +### - Bug#44664: valgrind warning for COMMIT_AND_CHAIN and ROLLBACK_AND_CHAIN +### Chaining a transaction does not retain consistency level. +START TRANSACTION WITH CONSISTENT SNAPSHOT; +DELETE FROM t1; +COMMIT WORK AND CHAIN; +# Switch to connection con2 +INSERT INTO t1 VALUES(1); +# Switch to connection con1 +SELECT * FROM t1; +a +1 +COMMIT; # Switch to connection default + close connections con1 and con2 DROP TABLE t1; diff --git a/mysql-test/r/ctype_cp932_binlog_row.result b/mysql-test/r/ctype_cp932_binlog_row.result index 0370b7a1cf6..cbac6b14669 100644 --- a/mysql-test/r/ctype_cp932_binlog_row.result +++ b/mysql-test/r/ctype_cp932_binlog_row.result @@ -9,10 +9,10 @@ EXECUTE stmt1 USING @var1; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; CREATE TABLE t1(f1 blob) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT SELECT HEX(f1) FROM t1; HEX(f1) 8300 diff --git a/mysql-test/r/ctype_cp932_binlog_stm.result b/mysql-test/r/ctype_cp932_binlog_stm.result index 2f67eb16b2e..044885d1ea7 100644 --- a/mysql-test/r/ctype_cp932_binlog_stm.result +++ b/mysql-test/r/ctype_cp932_binlog_stm.result @@ -9,7 +9,7 @@ EXECUTE stmt1 USING @var1; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; CREATE TABLE t1(f1 blob) -master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES('ƒ\0') +master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES(0x8300) SELECT HEX(f1) FROM t1; HEX(f1) 8300 @@ -29,22 +29,22 @@ HEX(s1) HEX(s2) d 466F6F2773206120426172 ED40ED41ED42 47.93 DROP PROCEDURE bug18293| DROP TABLE t4| -SHOW BINLOG EVENTS FROM 369| +SHOW BINLOG EVENTS FROM 370| Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 369 Query 1 535 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, +master-bin.000001 370 Query 1 536 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, s2 CHAR(50) CHARACTER SET cp932, d DECIMAL(10,2)) -master-bin.000001 535 Query 1 784 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `bug18293`(IN ins1 CHAR(50), +master-bin.000001 536 Query 1 785 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `bug18293`(IN ins1 CHAR(50), IN ins2 CHAR(50) CHARACTER SET cp932, IN ind DECIMAL(10,2)) BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); END -master-bin.000001 784 Query 1 1048 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172 COLLATE 'latin1_swedish_ci'), NAME_CONST('ins2',_cp932 0xED40ED41ED42 COLLATE 'cp932_japanese_ci'), NAME_CONST('ind',47.93)) -master-bin.000001 1048 Query 1 1137 use `test`; DROP PROCEDURE bug18293 -master-bin.000001 1137 Query 1 1216 use `test`; DROP TABLE t4 +master-bin.000001 785 Query 1 1049 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172 COLLATE 'latin1_swedish_ci'), NAME_CONST('ins2',_cp932 0xED40ED41ED42 COLLATE 'cp932_japanese_ci'), NAME_CONST('ind',47.93)) +master-bin.000001 1049 Query 1 1138 use `test`; DROP PROCEDURE bug18293 +master-bin.000001 1138 Query 1 1217 use `test`; DROP TABLE t4 End of 5.0 tests -SHOW BINLOG EVENTS FROM 364; +SHOW BINLOG EVENTS FROM 365; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment. CREATE TABLE t1 (a varchar(16)) character set cp932; diff --git a/mysql-test/r/ctype_gbk_binlog.result b/mysql-test/r/ctype_gbk_binlog.result new file mode 100644 index 00000000000..a49e170ff19 --- /dev/null +++ b/mysql-test/r/ctype_gbk_binlog.result @@ -0,0 +1,26 @@ +SET NAMES gbk; +CREATE TABLE t1 ( +f1 BLOB +) ENGINE=MyISAM DEFAULT CHARSET=gbk; +CREATE PROCEDURE p1(IN val BLOB) +BEGIN +SET @tval = val; +SET @sql_cmd = CONCAT_WS(' ', 'insert into t1(f1) values(?)'); +PREPARE stmt FROM @sql_cmd; +EXECUTE stmt USING @tval; +DEALLOCATE PREPARE stmt; +END| +SET @`tcontent`:=_binary 0x50434B000900000000000000E9000000 COLLATE `binary`/*!*/; +CALL p1(@`tcontent`); +FLUSH LOGS; +DROP PROCEDURE p1; +RENAME TABLE t1 to t2; +SELECT hex(f1) FROM t2; +hex(f1) +50434B000900000000000000E9000000 +SELECT hex(f1) FROM t1; +hex(f1) +50434B000900000000000000E9000000 +DROP PROCEDURE p1; +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/r/ctype_ldml.result b/mysql-test/r/ctype_ldml.result index 5dc9ea35cc3..711921eb526 100644 --- a/mysql-test/r/ctype_ldml.result +++ b/mysql-test/r/ctype_ldml.result @@ -40,6 +40,14 @@ abcd abcd efgh efgh ijkl ijkl DROP TABLE t1; +# +# Bug#43827 Server closes connections and restarts +# +CREATE TABLE t1 (c1 VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_test_ci); +INSERT INTO t1 SELECT REPEAT('a',11); +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +DROP TABLE t1; show collation like 'ucs2_vn_ci'; Collation Charset Id Default Compiled Sortlen ucs2_vn_ci ucs2 242 8 diff --git a/mysql-test/r/ddl_i18n_koi8r.result b/mysql-test/r/ddl_i18n_koi8r.result index af3a0899181..fe24c17a1c5 100644 --- a/mysql-test/r/ddl_i18n_koi8r.result +++ b/mysql-test/r/ddl_i18n_koi8r.result @@ -2829,7 +2829,11 @@ t2 CREATE TABLE `t2` ( `col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs +---> connection: con2 + +---> connection: con3 + ---> connection: default -use test| -DROP DATABASE mysqltest1| -DROP DATABASE mysqltest2| +USE test; +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; diff --git a/mysql-test/r/ddl_i18n_utf8.result b/mysql-test/r/ddl_i18n_utf8.result index 10c2afcadc1..cf4272bf90c 100644 --- a/mysql-test/r/ddl_i18n_utf8.result +++ b/mysql-test/r/ddl_i18n_utf8.result @@ -2829,7 +2829,11 @@ t2 CREATE TABLE `t2` ( `col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs +---> connection: con2 + +---> connection: con3 + ---> connection: default -use test| -DROP DATABASE mysqltest1| -DROP DATABASE mysqltest2| +USE test; +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 306c51fb8cf..80f04ffd455 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -383,3 +383,21 @@ select t2.* from (select * from t1) as A inner join t2 on A.ID = t2.FID; ID DATA FID drop table t1, t2; drop user mysqltest_1; +# End of 4.1 tests +SELECT 0 FROM +(SELECT 0) t01, (SELECT 0) t02, (SELECT 0) t03, (SELECT 0) t04, (SELECT 0) t05, +(SELECT 0) t06, (SELECT 0) t07, (SELECT 0) t08, (SELECT 0) t09, (SELECT 0) t10, +(SELECT 0) t11, (SELECT 0) t12, (SELECT 0) t13, (SELECT 0) t14, (SELECT 0) t15, +(SELECT 0) t16, (SELECT 0) t17, (SELECT 0) t18, (SELECT 0) t19, (SELECT 0) t20, +(SELECT 0) t21, (SELECT 0) t22, (SELECT 0) t23, (SELECT 0) t24, (SELECT 0) t25, +(SELECT 0) t26, (SELECT 0) t27, (SELECT 0) t28, (SELECT 0) t29, (SELECT 0) t30, +(SELECT 0) t31, (SELECT 0) t32, (SELECT 0) t33, (SELECT 0) t34, (SELECT 0) t35, +(SELECT 0) t36, (SELECT 0) t37, (SELECT 0) t38, (SELECT 0) t39, (SELECT 0) t40, +(SELECT 0) t41, (SELECT 0) t42, (SELECT 0) t43, (SELECT 0) t44, (SELECT 0) t45, +(SELECT 0) t46, (SELECT 0) t47, (SELECT 0) t48, (SELECT 0) t49, (SELECT 0) t50, +(SELECT 0) t51, (SELECT 0) t52, (SELECT 0) t53, (SELECT 0) t54, (SELECT 0) t55, +(SELECT 0) t56, (SELECT 0) t57, (SELECT 0) t58, (SELECT 0) t59, (SELECT 0) t60, +(SELECT 0) t61; +0 +0 +# End of 5.0 tests diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index f71bbd175e3..e0324af8cfd 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -629,21 +629,21 @@ SELECT DISTINCT @v5:= fruit_id, @v6:= fruit_name INTO @v7, @v8 FROM t1 WHERE fruit_name = 'APPLE'; SELECT @v5, @v6, @v7, @v8; @v5 @v6 @v7 @v8 -3 PEAR 3 PEAR +2 APPLE 2 APPLE SELECT DISTINCT @v5 + fruit_id, CONCAT(@v6, fruit_name) INTO @v9, @v10 FROM t1 WHERE fruit_name = 'APPLE'; SELECT @v5, @v6, @v7, @v8, @v9, @v10; @v5 @v6 @v7 @v8 @v9 @v10 -3 PEAR 3 PEAR 5 PEARAPPLE +2 APPLE 2 APPLE 4 APPLEAPPLE SELECT DISTINCT @v11:= @v5 + fruit_id, @v12:= CONCAT(@v6, fruit_name) INTO @v13, @v14 FROM t1 WHERE fruit_name = 'APPLE'; SELECT @v11, @v12, @v13, @v14; @v11 @v12 @v13 @v14 -6 PEARPEAR 6 PEARPEAR +4 APPLEAPPLE 4 APPLEAPPLE SELECT DISTINCT @v13, @v14 INTO @v15, @v16 FROM t1 WHERE fruit_name = 'APPLE'; SELECT @v15, @v16; @v15 @v16 -6 PEARPEAR +4 APPLEAPPLE SELECT DISTINCT 2 + 2, 'Bob' INTO @v17, @v18 FROM t1 WHERE fruit_name = 'APPLE'; SELECT @v17, @v18; diff --git a/mysql-test/r/events_stress.result b/mysql-test/r/events_stress.result index 17eb32b36b7..9b9f3caaff6 100644 --- a/mysql-test/r/events_stress.result +++ b/mysql-test/r/events_stress.result @@ -63,3 +63,4 @@ DROP TABLE fill_it1; DROP TABLE fill_it2; DROP TABLE fill_it3; DROP DATABASE events_test; +SET GLOBAL event_scheduler=off; diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result index 8e14b7695ee..b4e61d0e4fc 100644 --- a/mysql-test/r/func_compress.result +++ b/mysql-test/r/func_compress.result @@ -117,4 +117,13 @@ Warnings: Error 1259 ZLIB: Input data corrupted Error 1259 ZLIB: Input data corrupted drop table t1; +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1), (1111), (11111); +SELECT UNCOMPRESS(c1), UNCOMPRESSED_LENGTH(c1) FROM t1; +UNCOMPRESS(c1) UNCOMPRESSED_LENGTH(c1) +NULL NULL +NULL NULL +NULL 825307441 +EXPLAIN EXTENDED SELECT * FROM (SELECT UNCOMPRESSED_LENGTH(c1) FROM t1) AS s; +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/r/func_concat.result b/mysql-test/r/func_concat.result index 7e7c163716e..75b4888fbb2 100644 --- a/mysql-test/r/func_concat.result +++ b/mysql-test/r/func_concat.result @@ -89,3 +89,34 @@ c1 c2 First DROP TABLE t1; # End of 5.0 tests +# +# Bug #44743: Join in combination with concat does not always work +# +CREATE TABLE t1 ( +a VARCHAR(100) NOT NULL DEFAULT '0', +b VARCHAR(2) NOT NULL DEFAULT '', +c VARCHAR(2) NOT NULL DEFAULT '', +d TEXT NOT NULL, +PRIMARY KEY (a, b, c), +KEY (a) +) DEFAULT CHARSET=utf8; +INSERT INTO t1 VALUES ('gui_A', 'a', 'b', 'str1'), +('gui_AB', 'a', 'b', 'str2'), ('gui_ABC', 'a', 'b', 'str3'); +CREATE TABLE t2 ( +a VARCHAR(100) NOT NULL DEFAULT '', +PRIMARY KEY (a) +) DEFAULT CHARSET=latin1; +INSERT INTO t2 VALUES ('A'), ('AB'), ('ABC'); +SELECT CONCAT('gui_', t2.a), t1.d FROM t2 +LEFT JOIN t1 ON t1.a = CONCAT('gui_', t2.a) AND t1.b = 'a' AND t1.c = 'b'; +CONCAT('gui_', t2.a) d +gui_A str1 +gui_AB str2 +gui_ABC str3 +EXPLAIN SELECT CONCAT('gui_', t2.a), t1.d FROM t2 +LEFT JOIN t1 ON t1.a = CONCAT('gui_', t2.a) AND t1.b = 'a' AND t1.c = 'b'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index NULL PRIMARY 102 NULL 3 Using index +1 SIMPLE t1 eq_ref PRIMARY,a PRIMARY 318 func,const,const 1 +DROP TABLE t1, t2; +# End of 5.1 tests diff --git a/mysql-test/r/func_crypt.result b/mysql-test/r/func_crypt.result index 25b921681c5..c2f369b3941 100644 --- a/mysql-test/r/func_crypt.result +++ b/mysql-test/r/func_crypt.result @@ -95,3 +95,14 @@ Note 1003 select password('idkfa ') AS `password('idkfa ')`,old_password('idkfa' select encrypt('1234','_.'); encrypt('1234','_.') # +# +# Bug #44767: invalid memory reads in password() and old_password() +# functions +# +CREATE TABLE t1(c1 MEDIUMBLOB); +INSERT INTO t1 VALUES (REPEAT('a', 1024)); +SELECT OLD_PASSWORD(c1), PASSWORD(c1) FROM t1; +OLD_PASSWORD(c1) PASSWORD(c1) +77023ffe214c04ff *82E58A2C08AAFE72C8EB523069CD8ADB33F78F58 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index 1e967b668c5..88a822a2fa6 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -587,4 +587,25 @@ SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; CASE c1 WHEN c1 + 1 THEN 1 END ABS(AVG(c0)) NULL 1.0000 DROP TABLE t1; +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SUM( DISTINCT a ) +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SUM( DISTINCT b ) +1 +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SUM( DISTINCT c ) +1 +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SUM( DISTINCT d ) +1.00 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SUM( DISTINCT e ) +1 +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN +((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +SUM( DISTINCT e ) +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index c3d2db2d553..fd7ef72409e 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -437,6 +437,13 @@ a ROUND(a) -1e+16 -10000000000000002 1e+16 10000000000000002 DROP TABLE t1; +CREATE TABLE t1(f1 LONGTEXT) engine=myisam; +INSERT INTO t1 VALUES ('a'); +SELECT 1 FROM (SELECT ROUND(f1) AS a FROM t1) AS s WHERE a LIKE 'a'; +1 +SELECT 1 FROM (SELECT ROUND(f1, f1) AS a FROM t1) AS s WHERE a LIKE 'a'; +1 +DROP TABLE t1; End of 5.0 tests SELECT 1e308 + 1e308; 1e308 + 1e308 @@ -456,4 +463,23 @@ NULL SELECT POW(10, 309); POW(10, 309) NULL +# +# Bug #44768: SIGFPE crash when selecting rand from a view +# containing null +# +CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a; +SELECT RAND(a) FROM v1; +RAND(a) +0.155220427694936 +DROP VIEW v1; +SELECT RAND(a) FROM (SELECT NULL AS a) b; +RAND(a) +0.155220427694936 +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (NULL); +SELECT RAND(i) FROM t1; +RAND(i) +0.155220427694936 +DROP TABLE t1; +# End of 5.1 tests diff --git a/mysql-test/r/func_set.result b/mysql-test/r/func_set.result index ecdc35ac4cd..14ebc8203ec 100644 --- a/mysql-test/r/func_set.result +++ b/mysql-test/r/func_set.result @@ -146,3 +146,16 @@ NULL 0 0 drop table t1; +CREATE TABLE t1( a SET('a', 'b', 'c') ); +CREATE TABLE t2( a SET('a', 'b', 'c') ); +INSERT INTO t1 VALUES ('d'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +INSERT INTO t2 VALUES (''); +SELECT CONVERT( a USING latin1 ) FROM t1; +CONVERT( a USING latin1 ) + +SELECT CONVERT( a USING latin1 ) FROM t2; +CONVERT( a USING latin1 ) + +DROP TABLE t1, t2; diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 25cbf2470ed..a0c3935fde0 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -2525,6 +2525,15 @@ SELECT DATE_FORMAT(c, GET_FORMAT(DATE, 'eur')) h, CONCAT(UPPER(aa),', ', aa) i F h i 31.12.2008 AAAAAA, aaaaaa DROP TABLE t1; +# +# BUG#44774: load_file function produces valgrind warnings +# +CREATE TABLE t1 (a TINYBLOB); +INSERT INTO t1 VALUES ('aaaaaaaa'); +SELECT LOAD_FILE(a) FROM t1; +LOAD_FILE(a) +NULL +DROP TABLE t1; End of 5.0 tests drop table if exists t1; create table t1(f1 tinyint default null)engine=myisam; diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 494b7a36532..a3708d06a1c 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -984,4 +984,52 @@ f4 geometry YES NULL f5 datetime YES NULL drop view v1; drop table t1; +SELECT MultiPoint(12345,''); +MultiPoint(12345,'') +NULL +SELECT MultiPoint(123451,''); +MultiPoint(123451,'') +NULL +SELECT MultiPoint(1234512,''); +MultiPoint(1234512,'') +NULL +SELECT MultiPoint(12345123,''); +MultiPoint(12345123,'') +NULL +SELECT MultiLineString(12345,''); +MultiLineString(12345,'') +NULL +SELECT MultiLineString(123451,''); +MultiLineString(123451,'') +NULL +SELECT MultiLineString(1234512,''); +MultiLineString(1234512,'') +NULL +SELECT MultiLineString(12345123,''); +MultiLineString(12345123,'') +NULL +SELECT LineString(12345,''); +LineString(12345,'') +NULL +SELECT LineString(123451,''); +LineString(123451,'') +NULL +SELECT LineString(1234512,''); +LineString(1234512,'') +NULL +SELECT LineString(12345123,''); +LineString(12345123,'') +NULL +SELECT Polygon(12345,''); +Polygon(12345,'') +NULL +SELECT Polygon(123451,''); +Polygon(123451,'') +NULL +SELECT Polygon(1234512,''); +Polygon(1234512,'') +NULL +SELECT Polygon(12345123,''); +Polygon(12345123,'') +NULL End of 5.1 tests diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index de80a83d538..a677d71b266 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1358,3 +1358,58 @@ DROP USER 'userbug33464'@'localhost'; USE test; DROP DATABASE dbbug33464; SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators; +CREATE USER user1; +CREATE USER user2; +GRANT CREATE ON db1.* TO 'user1'@'localhost'; +GRANT CREATE ROUTINE ON db1.* TO 'user1'@'localhost'; +GRANT CREATE ON db1.* TO 'user2'@'%'; +GRANT CREATE ROUTINE ON db1.* TO 'user2'@'%'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR 'user1'@'localhost'; +Grants for user1@localhost +GRANT USAGE ON *.* TO 'user1'@'localhost' +GRANT CREATE, CREATE ROUTINE ON `db1`.* TO 'user1'@'localhost' +** Connect as user1 and create a procedure. +** The creation will imply implicitly assigned +** EXECUTE and ALTER ROUTINE privileges to +** the current user user1@localhost. +SELECT @@GLOBAL.sql_mode; +@@GLOBAL.sql_mode + +SELECT @@SESSION.sql_mode; +@@SESSION.sql_mode + +CREATE DATABASE db1; +CREATE PROCEDURE db1.proc1(p1 INT) +BEGIN +SET @x = 0; +REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT; +END ;|| +** Connect as user2 and create a procedure. +** Implicitly assignment of privileges will +** fail because the user2@localhost is an +** unknown user. +CREATE PROCEDURE db1.proc2(p1 INT) +BEGIN +SET @x = 0; +REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT; +END ;|| +Warnings: +Warning 1404 Failed to grant EXECUTE and ALTER ROUTINE privileges +SHOW GRANTS FOR 'user1'@'localhost'; +Grants for user1@localhost +GRANT USAGE ON *.* TO 'user1'@'localhost' +GRANT CREATE, CREATE ROUTINE ON `db1`.* TO 'user1'@'localhost' +GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `db1`.`proc1` TO 'user1'@'localhost' +SHOW GRANTS FOR 'user2'; +Grants for user2@% +GRANT USAGE ON *.* TO 'user2'@'%' +GRANT CREATE, CREATE ROUTINE ON `db1`.* TO 'user2'@'%' +DROP PROCEDURE db1.proc1; +DROP PROCEDURE db1.proc2; +REVOKE ALL ON db1.* FROM 'user1'@'localhost'; +REVOKE ALL ON db1.* FROM 'user2'@'%'; +DROP USER 'user1'; +DROP USER 'user1'@'localhost'; +DROP USER 'user2'; +DROP DATABASE db1; diff --git a/mysql-test/r/grant_cache_no_prot.result b/mysql-test/r/grant_cache_no_prot.result index cb9acaf540d..32bb9cce90e 100644 --- a/mysql-test/r/grant_cache_no_prot.result +++ b/mysql-test/r/grant_cache_no_prot.result @@ -206,7 +206,8 @@ Qcache_hits 8 show status like "Qcache_not_cached"; Variable_name Value Qcache_not_cached 8 ------ switch to connection default and close connections ----- +----- close connections ----- +----- switch to connection default ----- set names binary; delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); diff --git a/mysql-test/r/grant_cache_ps_prot.result b/mysql-test/r/grant_cache_ps_prot.result index cf1450f3b75..281468ee2e1 100644 --- a/mysql-test/r/grant_cache_ps_prot.result +++ b/mysql-test/r/grant_cache_ps_prot.result @@ -206,7 +206,8 @@ Qcache_hits 8 show status like "Qcache_not_cached"; Variable_name Value Qcache_not_cached 5 ------ switch to connection default and close connections ----- +----- close connections ----- +----- switch to connection default ----- set names binary; delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3"); diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index b17884c4f7a..27448d3e949 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -2462,4 +2462,43 @@ c 1 2 DROP TABLE t1; +# +# Bug #45386: Wrong query result with MIN function in field list, +# WHERE and GROUP BY clause +# +CREATE TABLE t (a INT, b INT, INDEX (a,b)); +INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1); +INSERT INTO t SELECT * FROM t; +# test MIN +#should use range with index for group by +EXPLAIN +SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by +#should return 1 row +SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a; +a MIN(b) +2 1 +# test MAX +#should use range with index for group by +EXPLAIN +SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by +#should return 1 row +SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a; +a MAX(b) +2 0 +# test 3 ranges and use the middle one +INSERT INTO t SELECT a, 2 FROM t; +#should use range with index for group by +EXPLAIN +SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by +#should return 1 row +SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a; +a MAX(b) +2 1 +DROP TABLE t; End of 5.0 tests diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index 9db03855c01..7ad0f212d99 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -336,4 +336,11 @@ a b NULL NULL NULL 1 drop table t1; +# +# bug#39918 - memory (heap) engine crashing while executing self join with delete +# +CREATE TABLE t1(a INT, KEY USING BTREE (a)) ENGINE=MEMORY; +INSERT INTO t1 VALUES(1),(1); +DELETE a1 FROM t1 AS a1, t1 AS a2 WHERE a1.a=a2.a; +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result index 8a935d87457..c639b20de91 100644 --- a/mysql-test/r/index_merge_myisam.result +++ b/mysql-test/r/index_merge_myisam.result @@ -557,6 +557,30 @@ a 1 2 drop table t0, t1, t2, t3; +# +# BUG#44810: index merge and order by with low sort_buffer_size +# crashes server! +# +CREATE TABLE t1(a VARCHAR(128),b VARCHAR(128),KEY(A),KEY(B)); +INSERT INTO t1 VALUES (REPEAT('a',128),REPEAT('b',128)); +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT * FROM t1; +SET SESSION sort_buffer_size=1; +Warnings: +Warning 1292 Truncated incorrect sort_buffer_size value: '1' +EXPLAIN +SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%' +ORDER BY a,b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b a,b 131,131 NULL 64 Using sort_union(a,b); Using where; Using filesort +SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%' +ORDER BY a,b; +SET SESSION sort_buffer_size=DEFAULT; +DROP TABLE t1; End of 5.0 tests #---------------- ROR-index_merge tests ----------------------- SET SESSION STORAGE_ENGINE = MyISAM; diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result index 475839569c7..6305f8cd47a 100644 --- a/mysql-test/r/information_schema_db.result +++ b/mysql-test/r/information_schema_db.result @@ -61,7 +61,7 @@ begin select table_name from information_schema.key_column_usage order by table_name; end| -create table t1 +create table t1 (f1 int(10) unsigned not null, f2 varchar(100) not null, primary key (f1), unique key (f2)); @@ -203,15 +203,15 @@ View Create View character_set_client collation_connection v2 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_2`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`f1` AS `f1` from `testdb_1`.`v1` latin1 latin1_swedish_ci show create view testdb_1.v1; ERROR 42000: SHOW VIEW command denied to user 'testdb_2'@'localhost' for table 'v1' -select table_name from information_schema.columns a +select table_name from information_schema.columns a where a.table_name = 'v2'; table_name v2 -select view_definition from information_schema.views a +select view_definition from information_schema.views a where a.table_name = 'v2'; view_definition select `v1`.`f1` AS `f1` from `testdb_1`.`v1` -select view_definition from information_schema.views a +select view_definition from information_schema.views a where a.table_name = 'testdb_1.v1'; view_definition select * from v2; diff --git a/mysql-test/r/init_file.result b/mysql-test/r/init_file.result index 8e014815a9c..43ed908ad01 100644 --- a/mysql-test/r/init_file.result +++ b/mysql-test/r/init_file.result @@ -4,6 +4,7 @@ SELECT * INTO @Y FROM init_file.startup limit 1,1; SELECT YEAR(@X)-YEAR(@Y); YEAR(@X)-YEAR(@Y) 0 +DROP DATABASE init_file; ok end of 4.1 tests select * from t1; @@ -19,3 +20,5 @@ y 3 11 13 +drop table t1, t2; +call mtr.force_restart(); diff --git a/mysql-test/r/innodb_bug21704.result b/mysql-test/r/innodb_bug21704.result new file mode 100644 index 00000000000..b8e0b15d50d --- /dev/null +++ b/mysql-test/r/innodb_bug21704.result @@ -0,0 +1,55 @@ +# +# Bug#21704: Renaming column does not update FK definition. +# + +# Test that it's not possible to rename columns participating in a +# foreign key (either in the referencing or referenced table). + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT ENGINE=INNODB; +CREATE TABLE t2 (a INT PRIMARY KEY, b INT, +CONSTRAINT fk1 FOREIGN KEY (a) REFERENCES t1(a)) +ROW_FORMAT=COMPACT ENGINE=INNODB; +CREATE TABLE t3 (a INT PRIMARY KEY, b INT, KEY(b), C INT, +CONSTRAINT fk2 FOREIGN KEY (b) REFERENCES t3 (a)) +ROW_FORMAT=COMPACT ENGINE=INNODB; +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); +INSERT INTO t2 VALUES (1,1),(2,2),(3,3); +INSERT INTO t3 VALUES (1,1,1),(2,2,2),(3,3,3); + +# Test renaming the column in the referenced table. + +ALTER TABLE t1 CHANGE a c INT; +ERROR HY000: Error on rename of '#sql-temporary' to './test/t1' (errno: 150) +# Ensure that online column rename works. +ALTER TABLE t1 CHANGE b c INT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 + +# Test renaming the column in the referencing table + +ALTER TABLE t2 CHANGE a c INT; +ERROR HY000: Error on rename of '#sql-temporary' to './test/t2' (errno: 150) +# Ensure that online column rename works. +ALTER TABLE t2 CHANGE b c INT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 + +# Test with self-referential constraints + +ALTER TABLE t3 CHANGE a d INT; +ERROR HY000: Error on rename of '#sql-temporary' to './test/t3' (errno: 150) +ALTER TABLE t3 CHANGE b d INT; +ERROR HY000: Error on rename of '#sql-temporary' to './test/t3' (errno: 150) +# Ensure that online column rename works. +ALTER TABLE t3 CHANGE c d INT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 + +# Cleanup. + +DROP TABLE t3; +DROP TABLE t2; +DROP TABLE t1; diff --git a/mysql-test/r/innodb_bug40565.result b/mysql-test/r/innodb_bug40565.result new file mode 100644 index 00000000000..21e923d9336 --- /dev/null +++ b/mysql-test/r/innodb_bug40565.result @@ -0,0 +1,9 @@ +create table bug40565(value decimal(4,2)) engine=innodb; +insert into bug40565 values (1), (null); +update bug40565 set value=NULL; +affected rows: 1 +info: Rows matched: 2 Changed: 1 Warnings: 0 +update bug40565 set value=NULL; +affected rows: 0 +info: Rows matched: 2 Changed: 0 Warnings: 0 +drop table bug40565; diff --git a/mysql-test/r/innodb_bug42101-nonzero.result b/mysql-test/r/innodb_bug42101-nonzero.result new file mode 100644 index 00000000000..277dfffdd35 --- /dev/null +++ b/mysql-test/r/innodb_bug42101-nonzero.result @@ -0,0 +1,26 @@ +set global innodb_commit_concurrency=0; +ERROR HY000: Incorrect arguments to SET +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +1 +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +1 +set global innodb_commit_concurrency=42; +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +42 +set global innodb_commit_concurrency=DEFAULT; +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +1 +set global innodb_commit_concurrency=0; +ERROR HY000: Incorrect arguments to SET +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +1 +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +1 diff --git a/mysql-test/r/innodb_bug42101.result b/mysql-test/r/innodb_bug42101.result new file mode 100644 index 00000000000..805097ffe9d --- /dev/null +++ b/mysql-test/r/innodb_bug42101.result @@ -0,0 +1,22 @@ +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +0 +set global innodb_commit_concurrency=1; +ERROR HY000: Incorrect arguments to SET +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +0 +set global innodb_commit_concurrency=42; +ERROR HY000: Incorrect arguments to SET +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +0 +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +0 +set global innodb_commit_concurrency=DEFAULT; +select @@innodb_commit_concurrency; +@@innodb_commit_concurrency +0 diff --git a/mysql-test/r/innodb_bug45357.result b/mysql-test/r/innodb_bug45357.result new file mode 100644 index 00000000000..7adeff2062f --- /dev/null +++ b/mysql-test/r/innodb_bug45357.result @@ -0,0 +1,7 @@ +set session transaction isolation level read committed; +create table bug45357(a int, b int,key(b))engine=innodb; +insert into bug45357 values (25170,6122); +update bug45357 set a=1 where b=30131; +delete from bug45357 where b < 20996; +delete from bug45357 where b < 7001; +drop table bug45357; diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 3f830378afa..3ff5f04b6c6 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1408,6 +1408,30 @@ SAVEPOINT s4; ROLLBACK; ROLLBACK TO SAVEPOINT s4; ERROR 42000: SAVEPOINT s4 does not exist +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY COMMENT 'My ID#', f2 INTEGER DEFAULT NULL, f3 CHAR(10) DEFAULT 'My ID#', CONSTRAINT f2_ref FOREIGN KEY (f2) REFERENCES t1 (f1)) ENGINE=INNODB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL COMMENT 'My ID#', + `f2` int(11) DEFAULT NULL, + `f3` char(10) DEFAULT 'My ID#', + PRIMARY KEY (`f1`), + KEY `f2_ref` (`f2`), + CONSTRAINT `f2_ref` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +# +# Bug #36995: valgrind error in remove_const during subquery executions +# +create table t1 (a bit(1) not null,b int) engine=myisam; +create table t2 (c int) engine=innodb; +explain +select b from t1 where a not in (select b from t1,t2 group by a) group by a; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 +DROP TABLE t1,t2; End of 5.0 tests CREATE TABLE `t2` ( `k` int(11) NOT NULL auto_increment, @@ -1677,16 +1701,64 @@ INSERT INTO t1 VALUES (4,1,2,'c2',NULL),(5,1,2,'c1',NULL),(2,1,3,'c2',NULL),(3,1,3,'c2',NULL), (4,1,3,'pk',NULL),(5,1,3,'c2',NULL), (2,1,4,'c_extra',NULL),(3,1,4,'c_extra',NULL); -EXPLAIN SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC; +EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index vid PRIMARY 12 NULL 16 Using where -SELECT * FROM t1 WHERE tid = 1 AND vid = 3 ORDER BY idx DESC; +1 SIMPLE t1 index NULL PRIMARY 12 NULL 16 Using where +SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC; vid tid idx name type 3 1 4 c_extra NULL 3 1 3 c2 NULL 3 1 2 c1 NULL 3 1 1 pk NULL DROP TABLE t1; +# +# Bug #44290: explain crashes for subquery with distinct in +# SQL_SELECT::test_quick_select +# (reproduced only with InnoDB tables) +# +CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, KEY (c3), KEY (c2, c3)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +1 +1 +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> system NULL NULL NULL NULL 1 +2 DERIVED t1 index c3,c2 c2 10 NULL 5 +DROP TABLE t1; +CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +1 +1 +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> system NULL NULL NULL NULL 1 +2 DERIVED t1 index c3,c2 c2 18 NULL 5 +DROP TABLE t1; +CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2), +KEY (c3), KEY (c2, c3)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2); +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +1 +1 +EXPLAIN +SELECT 1 FROM (SELECT COUNT(DISTINCT c1) +FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> system NULL NULL NULL NULL 1 +2 DERIVED t1 index c3,c2 c2 14 NULL 5 +DROP TABLE t1; End of 5.1 tests drop table if exists t1, t2, t3; create table t1(a int); @@ -2021,4 +2093,119 @@ DROP TABLE t4; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; +CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE = INNODB; +CREATE TABLE t2 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; +CREATE TABLE t3 (a INT, b INT KEY, KEY (a)) ENGINE = INNODB; +CREATE TABLE t4 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +INSERT INTO t3 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105), (6, 106); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t1, t2 SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b; +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +UPDATE t3, t4 SET t3.a = t3.a + 100, t4.b = t3.a + 10 +WHERE t3.a BETWEEN 2 AND 4 AND t4.a = t3.b - 100; +SELECT * FROM t4; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2, t3, t4; +# +# Bug#44886: SIGSEGV in test_if_skip_sort_order() - +# uninitialized variable used as subscript +# +CREATE TABLE t1 (a INT, b INT, c INT, d INT, PRIMARY KEY (b), KEY (a,c)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1,0); +CREATE TABLE t2 (a INT, b INT, e INT, KEY (e)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,1,2); +CREATE TABLE t3 (a INT, b INT) ENGINE=MyISAM; +INSERT INTO t3 VALUES (1, 1); +SELECT * FROM t1, t2, t3 +WHERE t1.a = t3.a AND (t1.b = t3.b OR t1.d) AND t2.b = t1.b AND t2.e = 2 +GROUP BY t1.b; +a b c d a b e a b +1 1 1 0 1 1 2 1 1 +DROP TABLE t1, t2, t3; +# +# Bug #45828: Optimizer won't use partial primary key if another +# index can prevent filesort +# +CREATE TABLE `t1` ( +c1 int NOT NULL, +c2 int NOT NULL, +c3 int NOT NULL, +PRIMARY KEY (c1,c2), +KEY (c3) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (5,2,1246276747); +INSERT INTO t1 VALUES (2,1,1246281721); +INSERT INTO t1 VALUES (7,3,1246281756); +INSERT INTO t1 VALUES (4,2,1246282139); +INSERT INTO t1 VALUES (3,1,1246282230); +INSERT INTO t1 VALUES (1,0,1246282712); +INSERT INTO t1 VALUES (8,3,1246282765); +INSERT INTO t1 SELECT c1+10,c2+10,c3+10 FROM t1; +INSERT INTO t1 SELECT c1+100,c2+100,c3+100 from t1; +INSERT INTO t1 SELECT c1+1000,c2+1000,c3+1000 from t1; +INSERT INTO t1 SELECT c1+10000,c2+10000,c3+10000 from t1; +INSERT INTO t1 SELECT c1+100000,c2+100000,c3+100000 from t1; +INSERT INTO t1 SELECT c1+1000000,c2+1000000,c3+1000000 from t1; +SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; +c1 c2 c3 +EXPLAIN SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref PRIMARY,c3 PRIMARY 4 const 1 Using where; Using filesort +EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref PRIMARY PRIMARY 4 const 1 Using where; Using filesort +CREATE TABLE t2 ( +c1 int NOT NULL, +c2 int NOT NULL, +c3 int NOT NULL, +KEY (c1,c2), +KEY (c3) +) ENGINE=InnoDB; +explain SELECT * FROM t2 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref c1,c3 c1 4 const 1 Using where; Using filesort +DROP TABLE t1,t2; +# +# 36259: Optimizing with ORDER BY +# +CREATE TABLE t1 ( +a INT NOT NULL AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL, +d VARCHAR(5), +e INT NOT NULL, +PRIMARY KEY (a), KEY i2 (b,c,d) +) ENGINE=InnoDB; +INSERT INTO t1 (b,c,d,e) VALUES (1,1,'a',1), (2,2,'b',2); +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +EXPLAIN SELECT * FROM t1 WHERE b=1 AND c=1 ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref i2 i2 8 const,const 1 Using where; Using filesort +EXPLAIN SELECT * FROM t1 FORCE INDEX(i2) WHERE b=1 and c=1 ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref i2 i2 8 const,const 1 Using where; Using filesort +EXPLAIN SELECT * FROM t1 FORCE INDEX(PRIMARY) WHERE b=1 AND c=1 ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 128 Using where +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/r/log_tables_debug.result b/mysql-test/r/log_tables_debug.result new file mode 100644 index 00000000000..daedb8c103a --- /dev/null +++ b/mysql-test/r/log_tables_debug.result @@ -0,0 +1,24 @@ +SET @old_general_log= @@global.general_log; +SET @old_general_log_file= @@global.general_log_file; +SET @old_slow_query_log= @@global.slow_query_log; +SET @old_slow_query_log_file= @@global.slow_query_log_file; +# +# Bug#45387 Information about statement id for prepared +# statements missed from general log +# +SET @@global.general_log = ON; +SET @@global.general_log_file = 'bug45387_general.log'; +SET SESSION debug='+d,reset_log_last_time'; +FLUSH LOGS; +SET @@global.general_log = @old_general_log; +SET @@global.general_log_file = @old_general_log_file; +SET SESSION debug='-d'; +Bug#45387: ID match. +End of 5.1 tests +# +# Cleanup +# +SET global general_log = @old_general_log; +SET global general_log_file = @old_general_log_file; +SET global slow_query_log = @old_slow_query_log; +SET global slow_query_log_file = @old_slow_query_log_file; diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index f53b328d14e..bf9108459d7 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -2127,4 +2127,18 @@ SELECT * FROM m1; ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist DROP VIEW v1; DROP TABLE m1, t1; +# +# Bug #45796: invalid memory reads and writes when altering merge and +# base tables +# +CREATE TABLE t1(c1 INT) ENGINE=MyISAM; +CREATE TABLE m1(c1 INT) ENGINE=MERGE UNION=(t1); +ALTER TABLE m1 ADD INDEX idx_c1(c1); +SELECT * FROM m1; +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +ALTER TABLE t1 ADD INDEX idx_c1(c1); +SELECT * FROM m1; +c1 +DROP TABLE m1; +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/r/mysql-bug45236.result b/mysql-test/r/mysql-bug45236.result new file mode 100644 index 00000000000..cefcb1d314c --- /dev/null +++ b/mysql-test/r/mysql-bug45236.result @@ -0,0 +1,8 @@ +DROP TABLE IF EXISTS t1; +SET @old_max_allowed_packet= @@global.max_allowed_packet; +SET @@global.max_allowed_packet = 1024 * 1024 + 1024; +CREATE TABLE t1(data LONGBLOB); +INSERT INTO t1 SELECT CONCAT(REPEAT('1', 1024*1024 - 27), +"\'\r dummydb dummyhost"); +DROP TABLE t1; +SET @@global.max_allowed_packet = @old_max_allowed_packet; diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index c53a2243811..e704f81e187 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -192,6 +192,13 @@ delimiter 1 1 1 +COUNT (*) +1 +COUNT (*) +1 +COUNT (*) +1 +ERROR 2005 (HY000) at line 1: Unknown MySQL server host 'invalid_hostname' (errno) End of 5.0 tests WARNING: --server-arg option not supported in this configuration. Warning (Code 1286): Unknown table engine 'nonexistent' diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index b55a96b6f30..295a2f41d40 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -471,4 +471,7 @@ IS NOT NULL 1 *** Unsigned server_id 4294967295 is found: 1 *** SET @@global.server_id= 1; +RESET MASTER; +FLUSH LOGS; +End of 5.0 tests End of 5.1 tests diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 7e987df8166..2f8e0ce5ec1 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -4431,6 +4431,57 @@ DROP DATABASE mysqldump_test_db; # -- End of test case for Bug#32538. SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT; + +Bug #34861 - mysqldump with --tab gives weird output for triggers. + +CREATE TABLE t1 (f1 INT); +CREATE TRIGGER tr1 BEFORE UPDATE ON t1 FOR EACH ROW SET @f1 = 1; +CREATE PROCEDURE pr1 () SELECT "Meow"; +CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO SELECT "Meow"; + +SHOW TRIGGERS; +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +tr1 UPDATE t1 SET @f1 = 1 BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +SHOW EVENTS; +Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation +test ev1 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci +SELECT name,body FROM mysql.proc WHERE NAME = 'pr1'; +name body +pr1 SELECT "Meow" + +dump table; if anything goes to stdout, it ends up here: --------------- + +drop everything +DROP EVENT ev1; +DROP TRIGGER tr1; +DROP TABLE t1; +DROP PROCEDURE pr1; + +reload table; this should restore table and trigger +SHOW TRIGGERS; +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +tr1 UPDATE t1 SET @f1 = 1 BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +SHOW EVENTS; +Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation +SELECT name,body FROM mysql.proc WHERE NAME = 'pr1'; +name body + +reload db; this should restore routines and events +SHOW TRIGGERS; +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +tr1 UPDATE t1 SET @f1 = 1 BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +SHOW EVENTS; +Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation +test ev1 root@localhost SYSTEM ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci +SELECT name,body FROM mysql.proc WHERE NAME = 'pr1'; +name body +pr1 SELECT "Meow" + +cleanup +DROP EVENT IF EXISTS ev1; +DROP PROCEDURE IF EXISTS pr1; +DROP TRIGGER IF EXISTS tr1; +DROP TABLE IF EXISTS t1; # # End of 5.1 tests # diff --git a/mysql-test/r/mysqldump_restore.result b/mysql-test/r/mysqldump_restore.result new file mode 100644 index 00000000000..16698251913 --- /dev/null +++ b/mysql-test/r/mysqldump_restore.result @@ -0,0 +1,110 @@ +# Set concurrent_insert = 0 to prevent random errors +# will reset to original value at the end of the test +SET @old_concurrent_insert = @@global.concurrent_insert; +SET @@global.concurrent_insert = 0; +# Pre-test cleanup +DROP TABLE IF EXISTS t1; +# Begin tests +# +# Bug#2005 Long decimal comparison bug. +# +CREATE TABLE t1 (a DECIMAL(64, 20)); +INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), +("0987654321098765432109876543210987654321"); +# Begin testing mysqldump output + restore +# Create 'original table name - <table>_orig +SET @orig_table_name = CONCAT('test.t1', '_orig'); +# Rename original table +ALTER TABLE test.t1 RENAME to test.t1_orig; +# Recreate table from mysqldump output +# Compare original and recreated tables +# Recreated table: test.t1 +# Original table: test.t1_orig +Comparing tables test.t1 and test.t1_orig +# Cleanup +DROP TABLE test.t1, test.t1_orig; +# +# Bug#3361 mysqldump quotes DECIMAL values inconsistently +# +CREATE TABLE t1 (a DECIMAL(10,5), b FLOAT); +INSERT INTO t1 VALUES (1.2345, 2.3456); +INSERT INTO t1 VALUES ('1.2345', 2.3456); +INSERT INTO t1 VALUES ("1.2345", 2.3456); +SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI_QUOTES'; +INSERT INTO t1 VALUES (1.2345, 2.3456); +INSERT INTO t1 VALUES ('1.2345', 2.3456); +INSERT INTO t1 VALUES ("1.2345", 2.3456); +ERROR 42S22: Unknown column '1.2345' in 'field list' +SET SQL_MODE=@OLD_SQL_MODE; +# Begin testing mysqldump output + restore +# Create 'original table name - <table>_orig +SET @orig_table_name = CONCAT('test.t1', '_orig'); +# Rename original table +ALTER TABLE test.t1 RENAME to test.t1_orig; +# Recreate table from mysqldump output +# Compare original and recreated tables +# Recreated table: test.t1 +# Original table: test.t1_orig +Comparing tables test.t1 and test.t1_orig +# Cleanup +DROP TABLE test.t1, test.t1_orig; +# +# Bug#1994 mysqldump does not correctly dump UCS2 data +# Bug#4261 mysqldump 10.7 (mysql 4.1.2) --skip-extended-insert drops NULL from inserts +# +CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r; +INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL); +# Begin testing mysqldump output + restore +# Create 'original table name - <table>_orig +SET @orig_table_name = CONCAT('test.t1', '_orig'); +# Rename original table +ALTER TABLE test.t1 RENAME to test.t1_orig; +# Recreate table from mysqldump output +# Compare original and recreated tables +# Recreated table: test.t1 +# Original table: test.t1_orig +Comparing tables test.t1 and test.t1_orig +# Cleanup +DROP TABLE test.t1, test.t1_orig; +# +# WL#2319 Exclude Tables from dump +# +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (4),(5),(6); +# Begin testing mysqldump output + restore +# Create 'original table name - <table>_orig +SET @orig_table_name = CONCAT('test.t2', '_orig'); +# Rename original table +ALTER TABLE test.t2 RENAME to test.t2_orig; +# Recreate table from mysqldump output +# Compare original and recreated tables +# Recreated table: test.t2 +# Original table: test.t2_orig +Comparing tables test.t2 and test.t2_orig +# Cleanup +DROP TABLE test.t2, test.t2_orig; +DROP TABLE t1; +# +# Bug#8830 mysqldump --skip-extended-insert causes --hex-blob to dump wrong values +# +CREATE TABLE t1 (`b` blob); +INSERT INTO `t1` VALUES (0x602010000280100005E71A); +# Begin testing mysqldump output + restore +# Create 'original table name - <table>_orig +SET @orig_table_name = CONCAT('test.t1', '_orig'); +# Rename original table +ALTER TABLE test.t1 RENAME to test.t1_orig; +# Recreate table from mysqldump output +# Compare original and recreated tables +# Recreated table: test.t1 +# Original table: test.t1_orig +Comparing tables test.t1 and test.t1_orig +# Cleanup +DROP TABLE test.t1, test.t1_orig; +# End tests +# Cleanup +# Reset concurrent_insert to its original value +SET @@global.concurrent_insert = @old_concurrent_insert; +# remove mysqldumpfile diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index a9c20e34517..52a1734ea54 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -545,6 +545,8 @@ mysqltest: At line 1: Failed to open file 'non_existing_file' mysqltest: At line 1: Missing required argument 'filename' to command 'file_exists' mysqltest: At line 1: Missing required argument 'from_file' to command 'copy_file' mysqltest: At line 1: Missing required argument 'to_file' to command 'copy_file' +mysqltest: At line 1: Missing required argument 'from_file' to command 'move_file' +mysqltest: At line 1: Missing required argument 'to_file' to command 'move_file' mysqltest: At line 1: Missing required argument 'mode' to command 'chmod' mysqltest: At line 1: You must write a 4 digit octal number for mode mysqltest: At line 1: You must write a 4 digit octal number for mode @@ -697,6 +699,7 @@ statement="SHOW COLUMNS FROM t1" row_number=1, column_name="Type", Value=int(11) statement=SHOW COLUMNS FROM t1 row_number=1, column_name=Default, Value=NULL value= ->A B<- value= 1 +value= 2 mysqltest: At line 1: query_get_value - argument list started with '(' must be ended with ')' mysqltest: At line 1: Missing required argument 'query' to command 'query_get_value' mysqltest: At line 1: Missing required argument 'column name' to command 'query_get_value' diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result index c408c14b716..b0dd3acd662 100644 --- a/mysql-test/r/openssl_1.result +++ b/mysql-test/r/openssl_1.result @@ -202,4 +202,10 @@ Ssl_cipher RC4-SHA select 'is still running; no cipher request crashed the server' as result from dual; result is still running; no cipher request crashed the server +GRANT SELECT ON test.* TO bug42158@localhost REQUIRE X509; +FLUSH PRIVILEGES; +SHOW STATUS LIKE 'Ssl_cipher'; +Variable_name Value +Ssl_cipher DHE-RSA-AES256-SHA +DROP USER bug42158@localhost; End of 5.1 tests diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index f69ba522a9c..8e3fbde1ea8 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1924,5 +1924,72 @@ EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a>=200; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p2,p3 ALL NULL NULL NULL NULL 3 Using where DROP TABLE t1; +CREATE TABLE t1 ( a INT, b INT, c INT, KEY bc(b, c) ) +PARTITION BY KEY (a, b) PARTITIONS 3 +; +INSERT INTO t1 VALUES +(17, 1, -8), +(3, 1, -7), +(23, 1, -6), +(22, 1, -5), +(11, 1, -4), +(21, 1, -3), +(19, 1, -2), +(30, 1, -1), +(20, 1, 1), +(16, 1, 2), +(18, 1, 3), +(9, 1, 4), +(15, 1, 5), +(28, 1, 6), +(29, 1, 7), +(25, 1, 8), +(10, 1, 9), +(13, 1, 10), +(27, 1, 11), +(24, 1, 12), +(12, 1, 13), +(26, 1, 14), +(14, 1, 15) +; +SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c; +b c +1 -8 +1 -7 +1 -6 +1 -5 +1 -4 +1 -3 +1 -2 +1 -1 +1 1 +1 2 +1 3 +1 4 +1 5 +1 6 +1 7 +1 8 +1 9 +1 10 +1 11 +1 12 +1 13 +1 14 +1 15 +EXPLAIN +SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range bc bc 10 NULL 7 Using where; Using index for group-by +DROP TABLE t1; +# +# Bug #45807: crash accessing partitioned table and sql_mode +# contains ONLY_FULL_GROUP_BY +# +SET SESSION SQL_MODE='ONLY_FULL_GROUP_BY'; +CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM +PARTITION BY HASH(id) PARTITIONS 2; +DROP TABLE t1; +SET SESSION SQL_MODE=DEFAULT; End of 5.1 tests SET @@global.general_log= @old_general_log; diff --git a/mysql-test/r/query_cache_debug.result b/mysql-test/r/query_cache_debug.result index b03a71d3fec..eb59e62c8ba 100644 --- a/mysql-test/r/query_cache_debug.result +++ b/mysql-test/r/query_cache_debug.result @@ -71,3 +71,111 @@ DROP TABLE t1,t2; SET GLOBAL concurrent_insert= DEFAULT; SET GLOBAL query_cache_size= DEFAULT; SET GLOBAL query_cache_type= DEFAULT; +# +# Bug43758 Query cache can lock up threads in 'freeing items' state +# +FLUSH STATUS; +SET GLOBAL query_cache_type=DEMAND; +SET GLOBAL query_cache_size= 1024*768; +DROP TABLE IF EXISTS t1,t2,t3,t4,t5; +CREATE TABLE t1 (a VARCHAR(100)); +CREATE TABLE t2 (a VARCHAR(100)); +CREATE TABLE t3 (a VARCHAR(100)); +CREATE TABLE t4 (a VARCHAR(100)); +CREATE TABLE t5 (a VARCHAR(100)); +INSERT INTO t1 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t2 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t3 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t4 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t5 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +=================================== Connection thd1 +** +** Load Query Cache with a result set and one table. +** +SELECT SQL_CACHE * FROM t1; +a +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +************************************************************************* +** We want to accomplish the following state: +** - Query cache status: TABLE_FLUSH_IN_PROGRESS +** - THD1: invalidate_table_internal (iterating query blocks) +** - THD2: query_cache_insert (cond_wait) +** - THD3: query_cache_insert (cond_wait) +** - No thread should be holding the structure_guard_mutex. +** +** First step is to place a DELETE-statement on the debug hook just +** before the mutex lock in invalidate_table_internal. +** This will allow new result sets to be written into the QC. +** +SET SESSION debug='+d,wait_in_query_cache_invalidate1'; +SET SESSION debug='+d,wait_in_query_cache_invalidate2'; +DELETE FROM t1 WHERE a like '%a%';; +=================================== Connection default +** Assert that the expect process status is obtained. +** +=================================== Connection thd2 +** On THD2: Insert a result into the cache. This attempt will be blocked +** because of a debug hook placed just before the mutex lock after which +** the first part of the result set is written. +SET SESSION debug='+d,wait_in_query_cache_insert'; +SELECT SQL_CACHE * FROM t2 UNION SELECT * FROM t3; +=================================== Connection thd3 +** On THD3: Insert another result into the cache and block on the same +** debug hook. +SET SESSION debug='+d,wait_in_query_cache_insert'; +SELECT SQL_CACHE * FROM t4 UNION SELECT * FROM t5;; +=================================== Connection default +** Assert that the two SELECT-stmt threads to reach the hook. +** +** +** Signal the DELETE thread, THD1, to continue. It will enter the mutex +** lock and set query cache status to TABLE_FLUSH_IN_PROGRESS and then +** unlock the mutex before stopping on the next debug hook. +SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate1' LIMIT 1 INTO @flush_thread_id; +KILL QUERY @flush_thread_id; +** Assert that we reach the next debug hook. +** +** Signal the remaining debug hooks blocking THD2 and THD3. +** The threads will grab the guard mutex enter the wait condition and +** and finally release the mutex. The threads will continue to wait +** until a broadcast signal reaches them causing both threads to +** come alive and check the condition. +SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id ASC LIMIT 1 INTO @thread_id; +KILL QUERY @thread_id; +SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id DESC LIMIT 1 INTO @thread_id; +KILL QUERY @thread_id; +** +** Finally signal the DELETE statement on THD1 one last time. +** The stmt will complete the query cache invalidation and return +** cache status to NO_FLUSH_IN_PROGRESS. On the status change +** One signal will be sent to the thread group waiting for executing +** invalidations and a broadcast signal will be sent to the thread +** group holding result set writers. +SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate2' LIMIT 1 INTO @flush_thread_id; +KILL QUERY @flush_thread_id; +** +************************************************************************* +** No tables should be locked +=================================== Connection thd2 +a +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +DELETE FROM t1; +DELETE FROM t2; +DELETE FROM t3; +=================================== Connection thd3 +a +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +DELETE FROM t4; +DELETE FROM t5; +=================================== Connection thd1 +** Done. +SET GLOBAL query_cache_size= 0; +# Restore defaults +RESET QUERY CACHE; +FLUSH STATUS; +DROP TABLE t1,t2,t3,t4,t5; +SET GLOBAL query_cache_size= DEFAULT; +SET GLOBAL query_cache_type= DEFAULT; diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 09c7d1b329d..50b5c3c13fb 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4457,4 +4457,83 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select '0' AS `a`,'0' AS `b`,'0' AS `c` from `test`.`t1` where 1 DROP TABLE t1; +# +# Bug#45266: Uninitialized variable lead to an empty result. +# +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`date_key` date NOT NULL, +`date_nokey` date NOT NULL, +`datetime_key` datetime NOT NULL, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +`time_nokey` time NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `datetime_key` (`datetime_key`) +); +CREATE TABLE `AA` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`time_key` time NOT NULL, +KEY `time_key` (`time_key`), +PRIMARY KEY (`pk`) +); +CREATE TABLE `B` ( +`date_nokey` date NOT NULL, +`date_key` date NOT NULL, +`time_key` time NOT NULL, +`datetime_nokey` datetime NOT NULL, +`varchar_key` varchar(1) NOT NULL, +KEY `date_key` (`date_key`), +KEY `time_key` (`time_key`), +KEY `varchar_key` (`varchar_key`) +); +INSERT INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); +CREATE TABLE `BB` ( +`pk` int(11) NOT NULL AUTO_INCREMENT, +`int_nokey` int(11) NOT NULL, +`date_key` date NOT NULL, +`varchar_nokey` varchar(1) NOT NULL, +`date_nokey` date NOT NULL, +PRIMARY KEY (`pk`), +KEY `date_key` (`date_key`) +); +INSERT INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +SELECT table1 . `pk` AS field1 +FROM +(BB AS table1 INNER JOIN +(AA AS table2 STRAIGHT_JOIN A AS table3 +ON ( table3 . `date_key` = table2 . `pk` )) +ON ( table3 . `datetime_key` = table2 . `int_nokey` )) +WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) +GROUP BY field1 ; +field1 +SELECT table3 .`date_key` field1 +FROM +B table1 LEFT JOIN B table3 JOIN +(BB table6 JOIN A table7 ON table6 .`varchar_nokey`) +ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; +field1 +NULL +SELECT table4 . `time_nokey` AS field1 FROM +(AA AS table1 CROSS JOIN +(AA AS table2 STRAIGHT_JOIN +(B AS table3 STRAIGHT_JOIN A AS table4 +ON ( table4 . `date_key` = table3 . `time_key` )) +ON ( table4 . `pk` = table3 . `date_nokey` )) +ON ( table4 . `time_key` = table3 . `datetime_nokey` )) +WHERE ( table4 . `time_key` < table1 . `time_key` AND +table1 . `int_nokey` != 'f') +GROUP BY field1 ORDER BY field1 , field1; +field1 +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +field2 +00:05:48 +15:13:38 +drop table A,AA,B,BB; +#end of test for bug#45266 End of 5.1 tests diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 35d61ce757d..17ab2b79043 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1660,3 +1660,13 @@ declare continue handler for sqlstate '00000' set @x=0; end$$ ERROR 42000: Bad SQLSTATE: '00000' LOAD DATA INFILE '../../tmp/proc.txt' INTO TABLE mysql.proc; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1), (2,2); +SELECT MAX (a) FROM t1 WHERE b = 999999; +ERROR 42000: FUNCTION test.MAX does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT AVG (a) FROM t1 WHERE b = 999999; +AVG (a) +NULL +SELECT non_existent (a) FROM t1 WHERE b = 999999; +ERROR 42000: FUNCTION test.non_existent does not exist +DROP TABLE t1; diff --git a/mysql-test/r/sp-fib.result b/mysql-test/r/sp-fib.result new file mode 100644 index 00000000000..a26e104c1e8 --- /dev/null +++ b/mysql-test/r/sp-fib.result @@ -0,0 +1,33 @@ +drop table if exists t3; +create table t3 ( f bigint unsigned not null ); +drop procedure if exists fib; +create procedure fib(n int unsigned) +begin +if n > 1 then +begin +declare x, y bigint unsigned; +declare c cursor for select f from t3 order by f desc limit 2; +open c; +fetch c into y; +fetch c into x; +insert into t3 values (x+y); +call fib(n-1); +## Close the cursor AFTER the recursion to ensure that the stack +## frame is somewhat intact. +close c; +end; +end if; +end| +set @@max_sp_recursion_depth= 20| +insert into t3 values (0), (1)| +call fib(4)| +select * from t3 order by f asc| +f +0 +1 +1 +2 +3 +drop table t3| +drop procedure fib| +set @@max_sp_recursion_depth= 0| diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 9574841bc35..3ad556b8c30 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -1337,52 +1337,6 @@ drop procedure opp| drop procedure ip| show procedure status where name like '%p%' and db='test'| Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation -drop table if exists t3| -create table t3 ( f bigint unsigned not null )| -drop procedure if exists fib| -create procedure fib(n int unsigned) -begin -if n > 1 then -begin -declare x, y bigint unsigned; -declare c cursor for select f from t3 order by f desc limit 2; -open c; -fetch c into y; -fetch c into x; -close c; -insert into t3 values (x+y); -call fib(n-1); -end; -end if; -end| -set @@max_sp_recursion_depth= 20| -insert into t3 values (0), (1)| -call fib(3)| -select * from t3 order by f asc| -f -0 -1 -1 -2 -truncate table t3| -insert into t3 values (0), (1)| -call fib(10)| -select * from t3 order by f asc| -f -0 -1 -1 -2 -3 -5 -8 -13 -21 -34 -55 -drop table t3| -drop procedure fib| -set @@max_sp_recursion_depth= 0| drop procedure if exists bar| create procedure bar(x char(16), y int) comment "111111111111" sql security invoker diff --git a/mysql-test/r/sp_notembedded.result b/mysql-test/r/sp_notembedded.result index d15efc6d7d7..c6641e673ee 100644 --- a/mysql-test/r/sp_notembedded.result +++ b/mysql-test/r/sp_notembedded.result @@ -233,4 +233,19 @@ rl_acquirer old drop procedure p1; drop table t1; set session low_priority_updates=default; +INSERT INTO mysql.user (Host, User, Password, Select_priv, Insert_priv, Update_priv, +Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, +Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, +Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv, +Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, +Create_user_priv, ssl_type, ssl_cipher, x509_issuer, x509_subject, max_questions, +max_updates, max_connections, max_user_connections) +VALUES('%', 'mysqltest_1', password(''), 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', +'N', 'N', 'N', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'N', '', +'', '', '', '0', '0', '0', '0'); +FLUSH PRIVILEGES; +CREATE PROCEDURE p1(i INT) BEGIN END; +DROP PROCEDURE p1; +DELETE FROM mysql.user WHERE User='mysqltest_1'; +FLUSH PRIVILEGES; set @@global.concurrent_insert= @old_concurrent_insert; diff --git a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result index 401340f204c..0b0d5a38d0b 100644 --- a/mysql-test/r/sql_mode.result +++ b/mysql-test/r/sql_mode.result @@ -506,3 +506,24 @@ mysqltest_32753@localhost set session sql_mode=@OLD_SQL_MODE; flush privileges; drop user mysqltest_32753@localhost; +DROP TABLE IF EXISTS t1,t2; +CREATE USER 'user_PCTFL'@'localhost' identified by 'PWD'; +CREATE USER 'user_no_PCTFL'@'localhost' identified by 'PWD'; +CREATE TABLE t1 (f1 BIGINT); +CREATE TABLE t2 (f1 CHAR(3) NOT NULL, f2 CHAR(20)); +GRANT ALL ON t1 TO 'user_PCTFL'@'localhost','user_no_PCTFL'@'localhost'; +GRANT SELECT(f1) ON t2 TO 'user_PCTFL'@'localhost','user_no_PCTFL'@'localhost'; +SET @OLD_SQL_MODE = @@SESSION.SQL_MODE; +SET SESSION SQL_MODE = 'PAD_CHAR_TO_FULL_LENGTH'; +DROP USER 'user_PCTFL'@'localhost'; +SET SESSION SQL_MODE = @OLD_SQL_MODE; +DROP USER 'user_no_PCTFL'@'localhost'; +FLUSH PRIVILEGES; +SELECT * FROM mysql.db WHERE Host = 'localhost' AND User LIKE 'user_%PCTFL'; +Host Db User Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Grant_priv References_priv Index_priv Alter_priv Create_tmp_table_priv Lock_tables_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Execute_priv Event_priv Trigger_priv +SELECT * FROM mysql.tables_priv WHERE Host = 'localhost' AND User LIKE 'user_%PCTFL'; +Host Db User Table_name Grantor Timestamp Table_priv Column_priv +SELECT * FROM mysql.columns_priv WHERE Host = 'localhost' AND User LIKE 'user_%PCTFL'; +Host Db User Table_name Column_name Timestamp Column_priv +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/r/status.result b/mysql-test/r/status.result index ca815540c29..ce3acba9b8a 100644 --- a/mysql-test/r/status.result +++ b/mysql-test/r/status.result @@ -1,13 +1,15 @@ set @old_concurrent_insert= @@global.concurrent_insert; set @@global.concurrent_insert= 0; +SET @old_log_output = @@global.log_output; +SET GLOBAL LOG_OUTPUT = 'FILE'; flush status; show status like 'Table_lock%'; Variable_name Value -Table_locks_immediate 1 +Table_locks_immediate 0 Table_locks_waited 0 select * from information_schema.session_status where variable_name like 'Table_lock%'; VARIABLE_NAME VARIABLE_VALUE -TABLE_LOCKS_IMMEDIATE 2 +TABLE_LOCKS_IMMEDIATE 0 TABLE_LOCKS_WAITED 0 # Switched to connection: con1 set sql_log_bin=0; @@ -154,7 +156,7 @@ Variable_name Value Com_show_status 3 show status like 'hand%write%'; Variable_name Value -Handler_write 5 +Handler_write 0 show status like '%tmp%'; Variable_name Value Created_tmp_disk_tables 0 @@ -162,7 +164,7 @@ Created_tmp_files 0 Created_tmp_tables 0 show status like 'hand%write%'; Variable_name Value -Handler_write 7 +Handler_write 0 show status like '%tmp%'; Variable_name Value Created_tmp_disk_tables 0 @@ -237,3 +239,4 @@ SELECT 9; DROP PROCEDURE p1; DROP FUNCTION f1; set @@global.concurrent_insert= @old_concurrent_insert; +SET GLOBAL log_output = @old_log_output; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 23f15f618f2..4476735735c 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -2073,4 +2073,18 @@ select @a, @b; drop trigger trg1; drop trigger trg2; drop table t1, t2; +CREATE TABLE t1 ( a INT, b INT ); +CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY, b INT ); +INSERT INTO t1 (a) VALUES (1); +CREATE TRIGGER tr1 +BEFORE INSERT ON t2 +FOR EACH ROW +BEGIN +UPDATE a_nonextisting_table SET a = 1; +END// +CREATE TABLE IF NOT EXISTS t2 ( a INT, b INT ) SELECT a, b FROM t1; +ERROR 42S02: Table 'test.a_nonextisting_table' doesn't exist +SELECT * FROM t2; +a b +DROP TABLE t1, t2; End of 5.1 tests. diff --git a/mysql-test/r/trigger_notembedded.result b/mysql-test/r/trigger_notembedded.result index 1e13bff03b1..335e6910a3a 100644 --- a/mysql-test/r/trigger_notembedded.result +++ b/mysql-test/r/trigger_notembedded.result @@ -462,4 +462,18 @@ unlock tables; select * from t1; i drop table t1; +CREATE DATABASE db1; +CREATE TABLE db1.t1 (a char(30)) ENGINE=MEMORY; +CREATE TRIGGER db1.trg AFTER INSERT ON db1.t1 FOR EACH ROW +INSERT INTO db1.t1 VALUES('Some very sensitive data goes here'); +CREATE USER 'no_rights'@'localhost'; +REVOKE ALL ON *.* FROM 'no_rights'@'localhost'; +FLUSH PRIVILEGES; +SELECT trigger_name FROM INFORMATION_SCHEMA.TRIGGERS +WHERE trigger_schema = 'db1'; +trigger_name +SHOW CREATE TRIGGER db1.trg; +ERROR 42000: Access denied; you need the TRIGGER privilege for this operation +DROP USER 'no_rights'@'localhost'; +DROP DATABASE db1; End of 5.1 tests. diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index f2b08d1c6b7..748aadee4fb 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -1524,10 +1524,10 @@ Warnings: Warning 1264 Out of range value for column 'f1' at row 1 DESC t1; Field Type Null Key Default Extra -f1 decimal(59,30) NO 0.000000000000000000000000000000 +f1 decimal(65,30) NO 0.000000000000000000000000000000 SELECT f1 FROM t1; f1 -99999999999999999999999999999.999999999999999999999999999999 +99999999999999999999999999999999999.999999999999999999999999999999 DROP TABLE t1; select (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 * 1.01500000 * 1.01500000 * 0.99500000); @@ -1577,3 +1577,56 @@ Error 1264 Out of range value for column 'cast(-13.4 as decimal(2,1))' at row 1 select cast(98.6 as decimal(2,0)); cast(98.6 as decimal(2,0)) 99 +# +# Bug #45262: Bad effects with CREATE TABLE and DECIMAL +# +CREATE TABLE t1 SELECT .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +Warnings: +Note 1265 Data truncated for column 'my_col' at row 1 +DESCRIBE t1; +Field Type Null Key Default Extra +my_col decimal(30,30) NO 0.000000000000000000000000000000 +SELECT my_col FROM t1; +my_col +0.123456789123456789123456789123 +DROP TABLE t1; +CREATE TABLE t1 SELECT 1 + .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +Warnings: +Note 1265 Data truncated for column 'my_col' at row 1 +DESCRIBE t1; +Field Type Null Key Default Extra +my_col decimal(65,30) NO 0.000000000000000000000000000000 +SELECT my_col FROM t1; +my_col +1.123456789123456789123456789123 +DROP TABLE t1; +CREATE TABLE t1 SELECT 1 * .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +Warnings: +Note 1265 Data truncated for column 'my_col' at row 1 +DESCRIBE t1; +Field Type Null Key Default Extra +my_col decimal(65,30) NO 0.000000000000000000000000000000 +SELECT my_col FROM t1; +my_col +0.123456789123456789123456789123 +DROP TABLE t1; +CREATE TABLE t1 SELECT 1 / .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +Warnings: +Note 1265 Data truncated for column 'my_col' at row 1 +DESCRIBE t1; +Field Type Null Key Default Extra +my_col decimal(65,4) YES NULL +SELECT my_col FROM t1; +my_col +8.1000 +DROP TABLE t1; +CREATE TABLE t1 SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +Warnings: +Note 1265 Data truncated for column 'my_col' at row 1 +DESCRIBE t1; +Field Type Null Key Default Extra +my_col decimal(65,30) YES NULL +SELECT my_col FROM t1; +my_col +0.012345687012345687012345687012 +DROP TABLE t1; diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result index d80a3973555..e4b90196c2d 100644 --- a/mysql-test/r/type_time.result +++ b/mysql-test/r/type_time.result @@ -128,3 +128,13 @@ SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2; sum(f3) 3 drop table t1; +# +# Bug #44792: valgrind warning when casting from time to time +# +CREATE TABLE t1 (c TIME); +INSERT INTO t1 VALUES ('0:00:00'); +SELECT CAST(c AS TIME) FROM t1; +CAST(c AS TIME) +00:00:00 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 23a7724984c..44a3812725a 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1574,4 +1574,17 @@ SHOW FIELDS FROM t2; Field Type Null Key Default Extra d double(9,6) YES NULL DROP TABLE t1, t2; +CREATE TABLE t1(a INT); +EXPLAIN EXTENDED +SELECT a FROM t1 +UNION +SELECT a FROM t1 +ORDER BY a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 system NULL NULL NULL NULL 0 0.00 const row not found +2 UNION t1 system NULL NULL NULL NULL 0 0.00 const row not found +NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL Using filesort +Warnings: +Note 1003 select '0' AS `a` from `test`.`t1` union select '0' AS `a` from `test`.`t1` order by `a` +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 8961a935006..28da1dae931 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -399,6 +399,17 @@ select @lastid != id, @lastid, @lastid := id from t1; 0 3 3 1 3 4 drop table t1; +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (0, 0), (2, 1), (2, 3), (1, 1), (30, 20); +SELECT a, b INTO @a, @b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; +SELECT @a, @b; +@a @b +2 3 +SELECT a, b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; +a b +2 3 +DROP TABLE t1; +End of 5.0 tests CREATE TABLE t1 (i INT); CREATE TRIGGER t_after_insert AFTER INSERT ON t1 FOR EACH ROW SET @bug42188 = 10; INSERT INTO t1 VALUES (1); diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index f27d0b9fdd5..c1cd1840df8 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -1436,7 +1436,7 @@ Warnings: Warning 1292 Truncated incorrect auto_increment_offset value: '0' select @@storage_engine; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def @@storage_engine 253 6 6 N 1 31 8 +def @@storage_engine 253 6 6 Y 0 31 8 @@storage_engine MyISAM SET @old_server_id = @@GLOBAL.server_id; @@ -1467,4 +1467,24 @@ SELECT @@GLOBAL.server_id; @@GLOBAL.server_id 0 SET GLOBAL server_id = @old_server_id; +SELECT @@GLOBAL.INIT_FILE, @@GLOBAL.INIT_FILE IS NULL; +@@GLOBAL.INIT_FILE @@GLOBAL.INIT_FILE IS NULL +NULL 1 +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (); +SET @bug42778= @@sql_safe_updates; +SET @@sql_safe_updates= 0; +DELETE FROM t1 ORDER BY (@@GLOBAL.INIT_FILE) ASC LIMIT 10; +SET @@sql_safe_updates= @bug42778; +DROP TABLE t1; +# +# BUG#10206 - InnoDB: Transaction requiring Max_BinLog_Cache_size > 4GB always rollsback +# +SET @old_max_binlog_cache_size = @@GLOBAL.max_binlog_cache_size; +# Set the max_binlog_cache_size to size more than 4GB. +SET GLOBAL max_binlog_cache_size = 5 * 1024 * 1024 * 1024; +SELECT @@GLOBAL.max_binlog_cache_size; +@@GLOBAL.max_binlog_cache_size +5368709120 +SET GLOBAL max_binlog_cache_size = @old_max_binlog_cache_size; End of 5.1 tests diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 0905fc0109b..2dc448a29d8 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3700,6 +3700,136 @@ ERROR 42000: Key 'c2' doesn't exist in table 'v1' DROP VIEW v1; DROP TABLE t1; # ----------------------------------------------------------------- +# -- Bug#40825: Error 1356 while selecting from a view +# -- with a "HAVING" clause though query works +# ----------------------------------------------------------------- + +CREATE TABLE t1 (c INT); + +CREATE VIEW v1 (view_column) AS SELECT c AS alias FROM t1 HAVING alias; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`c` AS `view_column` from `t1` having `view_column` latin1 latin1_swedish_ci +SELECT * FROM v1; +view_column + +DROP VIEW v1; +DROP TABLE t1; + +# -- End of test case for Bug#40825 + +# +# Bug #45806 crash when replacing into a view with a join! +# +CREATE TABLE t1(a INT UNIQUE); +CREATE VIEW v1 AS SELECT t1.a FROM t1, t1 AS a; +INSERT INTO t1 VALUES (1), (2); +REPLACE INTO v1(a) SELECT 1 FROM t1,t1 AS c; +SELECT * FROM v1; +a +1 +2 +1 +2 +REPLACE INTO v1(a) SELECT 3 FROM t1,t1 AS c; +SELECT * FROM v1; +a +1 +2 +3 +1 +2 +3 +1 +2 +3 +DELETE FROM t1 WHERE a=3; +INSERT INTO v1(a) SELECT 1 FROM t1,t1 AS c +ON DUPLICATE KEY UPDATE `v1`.`a`= 1; +SELECT * FROM v1; +a +1 +2 +1 +2 +CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a; +REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c; +SELECT * FROM v2; +a +1 +2 +1 +2 +1 +2 +1 +2 +REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c; +SELECT * FROM v2; +a +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c +ON DUPLICATE KEY UPDATE `v2`.`a`= 1; +SELECT * FROM v2; +a +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +1 +2 +3 +DROP VIEW v1; +DROP VIEW v2; +DROP TABLE t1; +# -- End of test case for Bug#45806 +# ----------------------------------------------------------------- # -- End of 5.0 tests. # ----------------------------------------------------------------- DROP DATABASE IF EXISTS `d-1`; @@ -3817,6 +3947,14 @@ call p(); call p(); drop view a; drop procedure p; +# +# Bug #44860: ALTER TABLE on view crashes server +# +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +ALTER TABLE v1; +DROP VIEW v1; +DROP TABLE t1; # ----------------------------------------------------------------- # -- End of 5.1 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/r/xa.result b/mysql-test/r/xa.result index 592cf07522b..a597806d897 100644 --- a/mysql-test/r/xa.result +++ b/mysql-test/r/xa.result @@ -75,3 +75,17 @@ xa rollback 'a','c'; xa start 'a','c'; drop table t1; End of 5.0 tests +xa start 'a'; +xa end 'a'; +xa rollback 'a'; +xa start 'a'; +xa end 'a'; +xa rollback 'a'; +xa start 'a'; +xa end 'a'; +xa prepare 'a'; +xa commit 'a'; +xa start 'a'; +xa end 'a'; +xa prepare 'a'; +xa commit 'a'; diff --git a/mysql-test/suite/binlog/r/binlog_database.result b/mysql-test/suite/binlog/r/binlog_database.result index 8dbe0f21852..1cc9281f3fc 100644 --- a/mysql-test/suite/binlog/r/binlog_database.result +++ b/mysql-test/suite/binlog/r/binlog_database.result @@ -100,15 +100,15 @@ drop table tt1, t1; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1 (a int) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # drop database if exists mysqltest1 -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ FLUSH STATUS; show databases; diff --git a/mysql-test/suite/binlog/r/binlog_incident.result b/mysql-test/suite/binlog/r/binlog_incident.result new file mode 100644 index 00000000000..d8b0357b8c4 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_incident.result @@ -0,0 +1,12 @@ +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT * FROM t1; +a +1 +2 +3 +REPLACE INTO t1 VALUES (4); +DROP TABLE t1; +FLUSH LOGS; +Contain RELOAD DATABASE +1 diff --git a/mysql-test/suite/binlog/r/binlog_innodb.result b/mysql-test/suite/binlog/r/binlog_innodb.result index 919ac33ef35..1922897f631 100644 --- a/mysql-test/suite/binlog/r/binlog_innodb.result +++ b/mysql-test/suite/binlog/r/binlog_innodb.result @@ -66,49 +66,49 @@ COMMIT; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=INNODB -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6) master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 2*a WHERE a > 1 master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 3*a WHERE a > 3 master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 4*a WHERE a > 4 master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 3*a WHERE a > 3 master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 4*a WHERE a > 4 master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ diff --git a/mysql-test/suite/binlog/r/binlog_innodb_row.result b/mysql-test/suite/binlog/r/binlog_innodb_row.result index fab79c4bc2f..f7415610dc5 100644 --- a/mysql-test/suite/binlog/r/binlog_innodb_row.result +++ b/mysql-test/suite/binlog/r/binlog_innodb_row.result @@ -9,7 +9,7 @@ commit; *** Results of the test: the binlog must have only Write_rows events not any Update_rows *** show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ @@ -24,7 +24,7 @@ commit; *** Results of the test: the binlog must have only one Write_rows event not two *** show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ diff --git a/mysql-test/suite/binlog/r/binlog_multi_engine.result b/mysql-test/suite/binlog/r/binlog_multi_engine.result index caae5f55d13..9252229903b 100644 --- a/mysql-test/suite/binlog/r/binlog_multi_engine.result +++ b/mysql-test/suite/binlog/r/binlog_multi_engine.result @@ -17,16 +17,16 @@ TRUNCATE t1b; TRUNCATE t1n; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -mysqld-bin.000001 # Query # # use `test`; BEGIN +mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2) -mysqld-bin.000001 # Query # # use `test`; COMMIT +mysqld-bin.000001 # Query # # COMMIT mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2) mysqld-bin.000001 # Query # # use `test`; UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c -mysqld-bin.000001 # Query # # use `test`; BEGIN +mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2) mysqld-bin.000001 # Query # # use `test`; UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f mysqld-bin.000001 # Query # # use `test`; UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c -mysqld-bin.000001 # Query # # use `test`; COMMIT +mysqld-bin.000001 # Query # # COMMIT mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Table_map # # table_id: # (test.t1n) mysqld-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) @@ -48,9 +48,9 @@ TRUNCATE t1b; TRUNCATE t1n; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -mysqld-bin.000001 # Query # # use `test`; BEGIN +mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2) -mysqld-bin.000001 # Query # # use `test`; COMMIT +mysqld-bin.000001 # Query # # COMMIT mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2) mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Table_map # # table_id: # (test.t1n) @@ -73,14 +73,14 @@ UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c; ERROR HY000: Binary logging not possible. Message: Statement cannot be written atomically since more than one engine involved and at least one engine is self-logging show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -mysqld-bin.000001 # Query # # use `test`; BEGIN +mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Table_map # # table_id: # (test.t1m) mysqld-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -mysqld-bin.000001 # Query # # use `test`; COMMIT -mysqld-bin.000001 # Query # # use `test`; BEGIN +mysqld-bin.000001 # Query # # COMMIT +mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Table_map # # table_id: # (test.t1b) mysqld-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -mysqld-bin.000001 # Query # # use `test`; COMMIT +mysqld-bin.000001 # Query # # COMMIT mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Table_map # # table_id: # (test.t1n) mysqld-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result index 25cb7a4726f..4baa47db129 100644 --- a/mysql-test/suite/binlog/r/binlog_row_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result @@ -12,11 +12,11 @@ show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1 (a int) engine=innodb master-bin.000001 # Query # # use `test`; create table t2 (a int) engine=innodb -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ @@ -29,7 +29,7 @@ drop table t1; show binlog events in 'master-bin.000001' from 106; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (n int) engine=innodb -master-bin.000001 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -249,7 +249,7 @@ show binlog events from 0; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 106 Server version, Binlog ver: 4 master-bin.000001 106 Query 1 205 use `test`; create table t1(n int) engine=innodb -master-bin.000001 205 Query 1 273 use `test`; BEGIN +master-bin.000001 205 Query 1 273 BEGIN master-bin.000001 273 Table_map 1 314 table_id: # (test.t1) master-bin.000001 314 Write_rows 1 348 table_id: # flags: STMT_END_F master-bin.000001 348 Table_map 1 389 table_id: # (test.t1) @@ -266,7 +266,7 @@ show binlog events from 0; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 106 Server version, Binlog ver: 4 master-bin.000001 106 Query 1 206 use `test`; create table t1 (a int) engine=innodb -master-bin.000001 206 Query 1 274 use `test`; BEGIN +master-bin.000001 206 Query 1 274 BEGIN master-bin.000001 274 Table_map 1 315 table_id: # (test.t1) master-bin.000001 315 Write_rows 1 349 table_id: # flags: STMT_END_F master-bin.000001 349 Table_map 1 390 table_id: # (test.t1) @@ -1085,10 +1085,10 @@ show binlog events from 0; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 106 Server version, Binlog ver: 4 master-bin.000001 106 Query 1 227 use `test`; create table t1 (a bigint unsigned, b bigint(20) unsigned) -master-bin.000001 227 Query 1 295 use `test`; BEGIN +master-bin.000001 227 Query 1 295 BEGIN master-bin.000001 295 Table_map 1 337 table_id: # (test.t1) master-bin.000001 337 Write_rows 1 383 table_id: # flags: STMT_END_F -master-bin.000001 383 Query 1 452 use `test`; COMMIT +master-bin.000001 383 Query 1 452 COMMIT master-bin.000001 452 Query 1 528 use `test`; drop table t1 reset master; CREATE DATABASE bug39182 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; @@ -1192,32 +1192,32 @@ use test; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; drop table t1 master-bin.000001 # Query # # use `test`; create table t1 (a int) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; CREATE TABLE IF NOT EXISTS `t2` ( `a` int(11) DEFAULT NULL ) -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; CREATE TABLE IF NOT EXISTS `t3` ( `a` int(11) DEFAULT NULL ) -master-bin.000001 # Query # # use `mysql`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (mysql.user) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `mysql`; COMMIT -master-bin.000001 # Query # # use `mysql`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (mysql.user) master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `mysql`; COMMIT -master-bin.000001 # Query # # use `mysql`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (mysql.user) master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `mysql`; COMMIT +master-bin.000001 # Query # # COMMIT drop table t1,t2,t3,tt1; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; insert delayed into t1 values (207); @@ -1227,46 +1227,46 @@ FLUSH TABLES; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1 (id tinyint auto_increment primary key) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; drop table t1 master-bin.000001 # Query # # use `test`; create table t1 (a int) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; CREATE TABLE IF NOT EXISTS `t2` ( `a` int(11) DEFAULT NULL ) -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; CREATE TABLE IF NOT EXISTS `t3` ( `a` int(11) DEFAULT NULL ) -master-bin.000001 # Query # # use `mysql`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (mysql.user) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `mysql`; COMMIT -master-bin.000001 # Query # # use `mysql`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (mysql.user) master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `mysql`; COMMIT -master-bin.000001 # Query # # use `mysql`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (mysql.user) master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `mysql`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE `t1`,`t2`,`t3` /* generated by server */ master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; FLUSH TABLES insert delayed into t1 values (null),(null),(null),(null); insert delayed into t1 values (null),(null),(400),(null); diff --git a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result index 49aa64adfb5..8daed8d5c25 100644 --- a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result +++ b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result @@ -5,16 +5,15 @@ reset master; insert into t2 values (@v); show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT flush logs; /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; ROLLBACK/*!*/; -use test/*!*/; SET TIMESTAMP=10000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_row_insert_select.result b/mysql-test/suite/binlog/r/binlog_row_insert_select.result index d4370c4de12..c7386b092e4 100644 --- a/mysql-test/suite/binlog/r/binlog_row_insert_select.result +++ b/mysql-test/suite/binlog/r/binlog_row_insert_select.result @@ -8,10 +8,10 @@ insert into t1 select * from t2; ERROR 23000: Duplicate entry '2' for key 'a' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select * from t1; a 1 diff --git a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result index 4f3bc57e576..4d639c3da68 100644 --- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result @@ -8,7 +8,7 @@ insert into t2 select * from t1; commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t2) @@ -25,12 +25,12 @@ Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK delete from t1; delete from t2; reset master; @@ -45,7 +45,7 @@ Warning 1196 Some non-transactional changed tables couldn't be rolled back commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # use `test`; savepoint my_savepoint @@ -74,7 +74,7 @@ a 7 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # use `test`; savepoint my_savepoint @@ -100,12 +100,12 @@ get_lock("a",10) 1 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK delete from t1; delete from t2; reset master; @@ -113,14 +113,14 @@ insert into t1 values(9); insert into t2 select * from t1; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT delete from t1; delete from t2; reset master; @@ -129,7 +129,7 @@ begin; insert into t2 select * from t1; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ @@ -137,11 +137,11 @@ insert into t1 values(11); commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t1) @@ -157,7 +157,7 @@ insert into t2 select * from t1; commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t2) @@ -184,7 +184,7 @@ rollback to savepoint my_savepoint; commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ @@ -205,7 +205,7 @@ a 18 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t1) @@ -257,31 +257,31 @@ get_lock("lock1",60) 1 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; alter table t2 engine=MyISAM -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; drop table t1,t2 master-bin.000001 # Query # # use `test`; create table t0 (n int) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t0) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t0) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; create table t2 (n int) engine=innodb do release_lock("lock1"); drop table t0,t2; @@ -364,46 +364,46 @@ a b DROP TABLE t1,t2; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE if exists t2 -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t2 master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; TRUNCATE table t2 -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE t2 -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK master-bin.000001 # Query # # use `test`; TRUNCATE table t2 -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ reset master; create table t1 (a int) engine=innodb; @@ -447,12 +447,12 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.ti) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.ti) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from ti /* zero */; count(*) 0 @@ -499,11 +499,11 @@ insert into t2 values (bug27417(2)); ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* only (!) with fixes for #23333 will show there is the query */; select count(*) from t1 /* must be 3 */; count(*) @@ -518,11 +518,11 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT /* the query must be in regardless of #23333 */; select count(*) from t1 /* must be 5 */; count(*) @@ -544,11 +544,11 @@ insert into t2 values (bug27417(1)); ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; select count(*) from t1 /* must be 1 */; count(*) @@ -561,12 +561,12 @@ insert into t2 select bug27417(1) union select bug27417(2); ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; select count(*) from t1 /* must be 2 */; count(*) @@ -578,13 +578,13 @@ update t3 set b=b+bug27417(1); ERROR 23000: Duplicate entry '4' for key 'b' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t3) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Update_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; select count(*) from t1 /* must be 2 */; count(*) @@ -598,11 +598,11 @@ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */; ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t4) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; select count(*) from t1 /* must be 4 */; count(*) @@ -631,12 +631,12 @@ delete from t2; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (test.t3) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; select count(*) from t1 /* must be 1 */; count(*) @@ -654,13 +654,13 @@ delete t2.* from t2,t5 where t2.a=t5.a + 1; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Delete_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; select count(*) from t1 /* must be 1 */; count(*) @@ -679,13 +679,13 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t4) master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; drop trigger trg_del_t2; drop table t1,t2,t3,t4,t5; @@ -706,12 +706,12 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.ti) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Table_map # # table_id: # (test.ti) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from ti /* zero */; count(*) 0 @@ -795,10 +795,10 @@ insert into t2 values (bug27417(1)); ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=1 master-bin.000001 # Query # # use `test`; insert into t2 values (bug27417(1)) -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 1 */; count(*) 1 @@ -810,10 +810,10 @@ insert into t2 select bug27417(1) union select bug27417(2); ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=2 master-bin.000001 # Query # # use `test`; insert into t2 select bug27417(1) union select bug27417(2) -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 2 */; count(*) 2 @@ -867,10 +867,10 @@ delete from t2; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=9 master-bin.000001 # Query # # use `test`; delete from t2 -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 1 */; count(*) 1 @@ -887,9 +887,9 @@ delete t2.* from t2,t5 where t2.a=t5.a + 1; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; delete t2.* from t2,t5 where t2.a=t5.a + 1 -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 1 */; count(*) 1 @@ -907,14 +907,14 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=10 master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=# master-bin.000001 # Intvar # # INSERT_ID=10 master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci master-bin.000001 # Execute_load_query # # use `test`; load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2) ;file_id=# -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK drop trigger trg_del_t2; drop table t1,t2,t3,t4,t5; drop function bug27417; diff --git a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_db_filter.result b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_db_filter.result new file mode 100644 index 00000000000..354fd832fb3 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_db_filter.result @@ -0,0 +1,43 @@ +RESET MASTER; +CREATE TABLE t1 (id int); +CREATE TABLE t2 (id int); +CREATE TABLE t3 (txt TEXT); +CREATE TABLE t4 (a int) ENGINE= InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t1 VALUES (3); +LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3; +INSERT INTO t1 VALUES (4); +CREATE DATABASE b42941; +use b42941; +CREATE TABLE t1 (id int); +CREATE TABLE t2 (id int); +CREATE TABLE t3 (txt TEXT); +CREATE TABLE t4 (a int) ENGINE= InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t1 VALUES (3); +LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3; +INSERT INTO t1 VALUES (4); +INSERT INTO test.t1 VALUES (5); +FLUSH LOGS; +UPDATE test.t1 t11, b42941.t1 t12 SET t11.id=10, t12.id=100; +BEGIN; +INSERT INTO test.t4 VALUES (1); +INSERT INTO b42941.t4 VALUES (1); +UPDATE test.t4 tn4, b42941.t4 tt4 SET tn4.a= 10, tt4.a= 100; +COMMIT; +FLUSH LOGS; +SET @b42941_output.1= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.1'); +SET @b42941_output.2= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.2'); +SET @b42941_output.1= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.1'); +SET @b42941_output.2= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.2'); +SET @b42941_output.1= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.1'); +SET @b42941_output.2= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.2'); +DROP DATABASE b42941; +use test; +DROP TABLE t1, t2, t3, t4; diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result index efdeb30a2af..d151e31269f 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result +++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result @@ -6,7 +6,7 @@ show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 106 Server ver: #, Binlog ver: # master-bin.000001 106 Query 1 213 use `test`; create table t1 (a int, b int) engine=innodb -master-bin.000001 213 Query 1 281 use `test`; BEGIN +master-bin.000001 213 Query 1 281 BEGIN master-bin.000001 281 Query 1 371 use `test`; insert into t1 values (1,2) master-bin.000001 371 Xid 1 398 COMMIT /* XID */ drop table t1; @@ -24,10 +24,10 @@ show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1 (a int) engine=innodb master-bin.000001 # Query # # use `test`; create table t2 (a int) engine=innodb -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert t1 values (5) master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert t2 values (5) master-bin.000001 # Xid # # COMMIT /* XID */ drop table t1,t2; @@ -39,7 +39,7 @@ drop table t1; show binlog events in 'master-bin.000001' from 106; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (n int) engine=innodb -master-bin.000001 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test`; insert into t1 values(100 + 4) master-bin.000001 # Query 1 # use `test`; insert into t1 values(99 + 4) master-bin.000001 # Query 1 # use `test`; insert into t1 values(98 + 4) @@ -159,7 +159,7 @@ show binlog events from 0; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 106 Server version, Binlog ver: 4 master-bin.000001 106 Query 1 205 use `test`; create table t1(n int) engine=innodb -master-bin.000001 205 Query 1 273 use `test`; BEGIN +master-bin.000001 205 Query 1 273 BEGIN master-bin.000001 273 Query 1 361 use `test`; insert into t1 values (1) master-bin.000001 361 Query 1 449 use `test`; insert into t1 values (2) master-bin.000001 449 Query 1 537 use `test`; insert into t1 values (3) @@ -173,7 +173,7 @@ show binlog events from 0; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 106 Server version, Binlog ver: 4 master-bin.000001 106 Query 1 206 use `test`; create table t1 (a int) engine=innodb -master-bin.000001 206 Query 1 274 use `test`; BEGIN +master-bin.000001 206 Query 1 274 BEGIN master-bin.000001 274 Query 1 365 use `test`; insert into t1 values( 400 ) master-bin.000001 365 Query 1 456 use `test`; insert into t1 values( 399 ) master-bin.000001 456 Query 1 547 use `test`; insert into t1 values( 398 ) @@ -730,18 +730,18 @@ master-bin.000001 # Query # # use `mysql`; UPDATE user SET password=password('An master-bin.000001 # Query # # use `mysql`; DELETE FROM user WHERE host='localhost' AND user='@#@' master-bin.000001 # Query # # use `test`; drop table t1,t2,t3,tt1 master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; FLUSH TABLES insert delayed into t1 values (null),(null),(null),(null); insert delayed into t1 values (null),(null),(400),(null); diff --git a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result index 1cd77cfbed4..f3a01f66fc2 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result +++ b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result @@ -109,35 +109,35 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Format_desc # # Server ver: VERSION, Binlog ver: 4 master-bin.000001 # Query # # use `test`; drop table t1,t2 master-bin.000001 # Query # # use `test`; create table t1 (a int) engine=blackhole -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; delete from t1 where a=10 -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; update t1 set a=11 where a=15 -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(1) -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert ignore into t1 values(1) -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; replace into t1 values(100) -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; create table t2 (a varchar(200)) engine=blackhole -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=581 master-bin.000001 # Execute_load_query # # use `test`; load data infile '../../std_data/words.dat' into table t2 ;file_id=# -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; alter table t1 add b int master-bin.000001 # Query # # use `test`; alter table t1 drop b master-bin.000001 # Query # # use `test`; create table t3 like t1 -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 select * from t3 -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; replace into t1 select * from t3 -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT drop table t1,t2,t3; CREATE TABLE t1(a INT) ENGINE=BLACKHOLE; INSERT DELAYED INTO t1 VALUES(1); @@ -167,9 +167,9 @@ show binlog events; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Format_desc # # Server ver: VERSION, Binlog ver: 4 master-bin.000001 # Query # # use `test`; create table t1 (a int) engine=blackhole -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(1) -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT drop table if exists t1; reset master; create table t1 (a int auto_increment, primary key (a)) engine=blackhole; @@ -181,16 +181,16 @@ insert into t1 values (55), (NULL); show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (a int auto_increment, primary key (a)) engine=blackhole -master-bin.000001 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Intvar 1 # INSERT_ID=1 master-bin.000001 # Query 1 # use `test`; insert into t1 values (11), (NULL), (NULL), (NULL) -master-bin.000001 # Query 1 # use `test`; COMMIT -master-bin.000001 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Intvar 1 # INSERT_ID=3 master-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL), (33), (NULL) -master-bin.000001 # Query 1 # use `test`; COMMIT -master-bin.000001 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Intvar 1 # INSERT_ID=5 master-bin.000001 # Query 1 # use `test`; insert into t1 values (55), (NULL) -master-bin.000001 # Query 1 # use `test`; COMMIT +master-bin.000001 # Query 1 # COMMIT drop table t1; diff --git a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result index 38488c9331d..95773a247b9 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result @@ -8,7 +8,7 @@ insert into t2 select * from t1; commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(1) master-bin.000001 # Query # # use `test`; insert into t2 select * from t1 master-bin.000001 # Xid # # COMMIT /* XID */ @@ -23,10 +23,10 @@ Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(2) master-bin.000001 # Query # # use `test`; insert into t2 select * from t1 -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK delete from t1; delete from t2; reset master; @@ -41,7 +41,7 @@ Warning 1196 Some non-transactional changed tables couldn't be rolled back commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(3) master-bin.000001 # Query # # use `test`; savepoint my_savepoint master-bin.000001 # Query # # use `test`; insert into t1 values(4) @@ -67,7 +67,7 @@ a 7 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(5) master-bin.000001 # Query # # use `test`; savepoint my_savepoint master-bin.000001 # Query # # use `test`; insert into t1 values(6) @@ -89,10 +89,10 @@ get_lock("a",10) 1 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(8) master-bin.000001 # Query # # use `test`; insert into t2 select * from t1 -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK delete from t1; delete from t2; reset master; @@ -100,7 +100,7 @@ insert into t1 values(9); insert into t2 select * from t1; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(9) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; insert into t2 select * from t1 @@ -112,7 +112,7 @@ begin; insert into t2 select * from t1; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(10) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; insert into t2 select * from t1 @@ -120,11 +120,11 @@ insert into t1 values(11); commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(10) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; insert into t2 select * from t1 -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(11) master-bin.000001 # Xid # # COMMIT /* XID */ alter table t2 engine=INNODB; @@ -137,7 +137,7 @@ insert into t2 select * from t1; commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(12) master-bin.000001 # Query # # use `test`; insert into t2 select * from t1 master-bin.000001 # Xid # # COMMIT /* XID */ @@ -162,7 +162,7 @@ rollback to savepoint my_savepoint; commit; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(14) master-bin.000001 # Xid # # COMMIT /* XID */ delete from t1; @@ -182,7 +182,7 @@ a 18 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(16) master-bin.000001 # Query # # use `test`; insert into t1 values(18) master-bin.000001 # Xid # # COMMIT /* XID */ @@ -232,26 +232,26 @@ get_lock("lock1",60) 1 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(16) master-bin.000001 # Query # # use `test`; insert into t1 values(18) master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; delete from t1 master-bin.000001 # Xid # # COMMIT /* XID */ -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; delete from t2 master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; alter table t2 engine=MyISAM -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values (1) master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; insert into t2 values (20) master-bin.000001 # Query # # use `test`; drop table t1,t2 master-bin.000001 # Query # # use `test`; create temporary table ti (a int) engine=innodb -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into ti values(1) -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; create temporary table t1 (a int) engine=myisam master-bin.000001 # Query # # use `test`; insert t1 values (1) master-bin.000001 # Query # # use `test`; create table t0 (n int) @@ -356,9 +356,9 @@ master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (8,8) master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (9,9) master-bin.000001 # Query # # use `test`; TRUNCATE table t2 master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (10,10) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; INSERT INTO t2 values (100,100) -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE t1,t2 reset master; create table t1 (a int) engine=innodb; @@ -402,11 +402,11 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into ti values (1) master-bin.000001 # Query # # use `test`; insert into ti values (2) master-bin.000001 # Query # # use `test`; insert into tt select * from ti -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from ti /* zero */; count(*) 0 @@ -428,11 +428,11 @@ Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into ti values (1) master-bin.000001 # Query # # use `test`; insert into ti values (2) /* to make the dup error in the following */ master-bin.000001 # Query # # use `test`; insert into tt select * from ti /* one affected and error */ -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from ti /* zero */; count(*) 0 @@ -499,10 +499,10 @@ insert into t2 values (bug27417(1)); ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=1 master-bin.000001 # Query # # use `test`; insert into t2 values (bug27417(1)) -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; select count(*) from t1 /* must be 1 */; count(*) @@ -515,10 +515,10 @@ insert into t2 select bug27417(1) union select bug27417(2); ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=2 master-bin.000001 # Query # # use `test`; insert into t2 select bug27417(1) union select bug27417(2) -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; select count(*) from t1 /* must be 2 */; count(*) @@ -575,10 +575,10 @@ delete from t2; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=9 master-bin.000001 # Query # # use `test`; delete from t2 -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; select count(*) from t1 /* must be 1 */; count(*) @@ -596,9 +596,9 @@ delete t2.* from t2,t5 where t2.a=t5.a + 1; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; delete t2.* from t2,t5 where t2.a=t5.a + 1 -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; select count(*) from t1 /* must be 1 */; count(*) @@ -617,12 +617,12 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=10 master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=# master-bin.000001 # Intvar # # INSERT_ID=10 master-bin.000001 # Execute_load_query # # use `test`; load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2) ;file_id=# -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK /* the output must denote there is the query */; drop trigger trg_del_t2; drop table t1,t2,t3,t4,t5; @@ -644,11 +644,11 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into ti values (1) master-bin.000001 # Query # # use `test`; insert into ti values (2) master-bin.000001 # Query # # use `test`; insert into tt select * from ti -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from ti /* zero */; count(*) 0 @@ -670,11 +670,11 @@ Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; insert into ti values (1) master-bin.000001 # Query # # use `test`; insert into ti values (2) /* to make the dup error in the following */ master-bin.000001 # Query # # use `test`; insert into tt select * from ti /* one affected and error */ -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from ti /* zero */; count(*) 0 @@ -739,10 +739,10 @@ insert into t2 values (bug27417(1)); ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=1 master-bin.000001 # Query # # use `test`; insert into t2 values (bug27417(1)) -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 1 */; count(*) 1 @@ -754,10 +754,10 @@ insert into t2 select bug27417(1) union select bug27417(2); ERROR 23000: Duplicate entry '2' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=2 master-bin.000001 # Query # # use `test`; insert into t2 select bug27417(1) union select bug27417(2) -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 2 */; count(*) 2 @@ -811,10 +811,10 @@ delete from t2; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=9 master-bin.000001 # Query # # use `test`; delete from t2 -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 1 */; count(*) 1 @@ -831,9 +831,9 @@ delete t2.* from t2,t5 where t2.a=t5.a + 1; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; delete t2.* from t2,t5 where t2.a=t5.a + 1 -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK select count(*) from t1 /* must be 1 */; count(*) 1 @@ -851,14 +851,14 @@ count(*) 2 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Intvar # # INSERT_ID=10 master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci master-bin.000001 # Begin_load_query # # ;file_id=#;block_len=# master-bin.000001 # Intvar # # INSERT_ID=10 master-bin.000001 # User var # # @`b`=_latin1 0x3135 COLLATE latin1_swedish_ci master-bin.000001 # Execute_load_query # # use `test`; load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2) ;file_id=# -master-bin.000001 # Query # # use `test`; ROLLBACK +master-bin.000001 # Query # # ROLLBACK drop trigger trg_del_t2; drop table t1,t2,t3,t4,t5; drop function bug27417; diff --git a/mysql-test/suite/binlog/r/binlog_stm_ps.result b/mysql-test/suite/binlog/r/binlog_stm_ps.result index ea7cc6f16df..3af525e297c 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_ps.result +++ b/mysql-test/suite/binlog/r/binlog_stm_ps.result @@ -11,7 +11,7 @@ prepare s from "insert into t1 select 100 limit ?"; set @a=100; execute s using @a; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1 (a int) diff --git a/mysql-test/suite/binlog/r/binlog_stm_row.result b/mysql-test/suite/binlog/r/binlog_stm_row.result index d1cc55f03b3..f96073a2b92 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_row.result +++ b/mysql-test/suite/binlog/r/binlog_stm_row.result @@ -65,10 +65,10 @@ master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES(2) master-bin.000001 # Query # # use `test`; INSERT INTO t1 SELECT * FROM t2 WHERE GET_LOCK('Bug#34306', 120) master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES (3) master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES (4) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT DROP TABLE t1; DROP TABLE t2; SET GLOBAL BINLOG_FORMAT = @saved_global_binlog_format; diff --git a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result new file mode 100644 index 00000000000..439bff0cfe1 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result @@ -0,0 +1,30 @@ +### NOT filtered database => assertion: warnings ARE shown +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a int, b int, primary key (a)); +INSERT INTO t1 VALUES (1,2), (2,3); +UPDATE t1 SET b='4' WHERE a=1 LIMIT 1; +Warnings: +Note 1592 Statement may not be safe to log in statement format. +UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1; +Warnings: +Note 1592 Statement may not be safe to log in statement format. +DROP TABLE t1; +### NOT filtered database => assertion: binlog disabled and warnings ARE NOT shown +SET SQL_LOG_BIN= 0; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a int, b int, primary key (a)); +INSERT INTO t1 VALUES (1,2), (2,3); +UPDATE t1 SET b='4' WHERE a=1 LIMIT 1; +UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1; +DROP TABLE t1; +SET SQL_LOG_BIN= 1; +### FILTERED database => assertion: warnings ARE NOT shown +CREATE DATABASE b42851; +USE b42851; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a int, b int, primary key (a)); +INSERT INTO t1 VALUES (1,2), (2,3); +UPDATE t1 SET b='4' WHERE a=1 LIMIT 1; +UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1; +DROP TABLE t1; +DROP DATABASE b42851; diff --git a/mysql-test/suite/binlog/r/binlog_tbl_metadata.result b/mysql-test/suite/binlog/r/binlog_tbl_metadata.result new file mode 100644 index 00000000000..a2f185edc85 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_tbl_metadata.result @@ -0,0 +1,156 @@ +RESET MASTER; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( +`c1` int(11) NOT NULL AUTO_INCREMENT, +`c2` varchar(30) NOT NULL, +`c3` varchar(30) DEFAULT NULL, +`c4` varchar(30) DEFAULT NULL, +`c5` varchar(30) DEFAULT NULL, +`c6` varchar(30) DEFAULT NULL, +`c7` varchar(30) DEFAULT NULL, +`c8` varchar(30) DEFAULT NULL, +`c9` varchar(30) DEFAULT NULL, +`c10` varchar(30) DEFAULT NULL, +`c11` varchar(30) DEFAULT NULL, +`c12` varchar(30) DEFAULT NULL, +`c13` varchar(30) DEFAULT NULL, +`c14` varchar(30) DEFAULT NULL, +`c15` varchar(30) DEFAULT NULL, +`c16` varchar(30) DEFAULT NULL, +`c17` varchar(30) DEFAULT NULL, +`c18` varchar(30) DEFAULT NULL, +`c19` varchar(30) DEFAULT NULL, +`c20` varchar(30) DEFAULT NULL, +`c21` varchar(30) DEFAULT NULL, +`c22` varchar(30) DEFAULT NULL, +`c23` varchar(30) DEFAULT NULL, +`c24` varchar(30) DEFAULT NULL, +`c25` varchar(30) DEFAULT NULL, +`c26` varchar(30) DEFAULT NULL, +`c27` varchar(30) DEFAULT NULL, +`c28` varchar(30) DEFAULT NULL, +`c29` varchar(30) DEFAULT NULL, +`c30` varchar(30) DEFAULT NULL, +`c31` varchar(30) DEFAULT NULL, +`c32` varchar(30) DEFAULT NULL, +`c33` varchar(30) DEFAULT NULL, +`c34` varchar(30) DEFAULT NULL, +`c35` varchar(30) DEFAULT NULL, +`c36` varchar(30) DEFAULT NULL, +`c37` varchar(30) DEFAULT NULL, +`c38` varchar(30) DEFAULT NULL, +`c39` varchar(30) DEFAULT NULL, +`c40` varchar(30) DEFAULT NULL, +`c41` varchar(30) DEFAULT NULL, +`c42` varchar(30) DEFAULT NULL, +`c43` varchar(30) DEFAULT NULL, +`c44` varchar(30) DEFAULT NULL, +`c45` varchar(30) DEFAULT NULL, +`c46` varchar(30) DEFAULT NULL, +`c47` varchar(30) DEFAULT NULL, +`c48` varchar(30) DEFAULT NULL, +`c49` varchar(30) DEFAULT NULL, +`c50` varchar(30) DEFAULT NULL, +`c51` varchar(30) DEFAULT NULL, +`c52` varchar(30) DEFAULT NULL, +`c53` varchar(30) DEFAULT NULL, +`c54` varchar(30) DEFAULT NULL, +`c55` varchar(30) DEFAULT NULL, +`c56` varchar(30) DEFAULT NULL, +`c57` varchar(30) DEFAULT NULL, +`c58` varchar(30) DEFAULT NULL, +`c59` varchar(30) DEFAULT NULL, +`c60` varchar(30) DEFAULT NULL, +`c61` varchar(30) DEFAULT NULL, +`c62` varchar(30) DEFAULT NULL, +`c63` varchar(30) DEFAULT NULL, +`c64` varchar(30) DEFAULT NULL, +`c65` varchar(30) DEFAULT NULL, +`c66` varchar(30) DEFAULT NULL, +`c67` varchar(30) DEFAULT NULL, +`c68` varchar(30) DEFAULT NULL, +`c69` varchar(30) DEFAULT NULL, +`c70` varchar(30) DEFAULT NULL, +`c71` varchar(30) DEFAULT NULL, +`c72` varchar(30) DEFAULT NULL, +`c73` varchar(30) DEFAULT NULL, +`c74` varchar(30) DEFAULT NULL, +`c75` varchar(30) DEFAULT NULL, +`c76` varchar(30) DEFAULT NULL, +`c77` varchar(30) DEFAULT NULL, +`c78` varchar(30) DEFAULT NULL, +`c79` varchar(30) DEFAULT NULL, +`c80` varchar(30) DEFAULT NULL, +`c81` varchar(30) DEFAULT NULL, +`c82` varchar(30) DEFAULT NULL, +`c83` varchar(30) DEFAULT NULL, +`c84` varchar(30) DEFAULT NULL, +`c85` varchar(30) DEFAULT NULL, +`c86` varchar(30) DEFAULT NULL, +`c87` varchar(30) DEFAULT NULL, +`c88` varchar(30) DEFAULT NULL, +`c89` varchar(30) DEFAULT NULL, +`c90` varchar(30) DEFAULT NULL, +`c91` varchar(30) DEFAULT NULL, +`c92` varchar(30) DEFAULT NULL, +`c93` varchar(30) DEFAULT NULL, +`c94` varchar(30) DEFAULT NULL, +`c95` varchar(30) DEFAULT NULL, +`c96` varchar(30) DEFAULT NULL, +`c97` varchar(30) DEFAULT NULL, +`c98` varchar(30) DEFAULT NULL, +`c99` varchar(30) DEFAULT NULL, +`c100` varchar(30) DEFAULT NULL, +`c101` varchar(30) DEFAULT NULL, +`c102` varchar(30) DEFAULT NULL, +`c103` varchar(30) DEFAULT NULL, +`c104` varchar(30) DEFAULT NULL, +`c105` varchar(30) DEFAULT NULL, +`c106` varchar(30) DEFAULT NULL, +`c107` varchar(30) DEFAULT NULL, +`c108` varchar(30) DEFAULT NULL, +`c109` varchar(30) DEFAULT NULL, +`c110` varchar(30) DEFAULT NULL, +`c111` varchar(30) DEFAULT NULL, +`c112` varchar(30) DEFAULT NULL, +`c113` varchar(30) DEFAULT NULL, +`c114` varchar(30) DEFAULT NULL, +`c115` varchar(30) DEFAULT NULL, +`c116` varchar(30) DEFAULT NULL, +`c117` varchar(30) DEFAULT NULL, +`c118` varchar(30) DEFAULT NULL, +`c119` varchar(30) DEFAULT NULL, +`c120` varchar(30) DEFAULT NULL, +`c121` varchar(30) DEFAULT NULL, +`c122` varchar(30) DEFAULT NULL, +`c123` varchar(30) DEFAULT NULL, +`c124` varchar(30) DEFAULT NULL, +`c125` varchar(30) DEFAULT NULL, +`c126` varchar(30) DEFAULT NULL, +`c127` varchar(30) DEFAULT NULL, +`c128` varchar(30) DEFAULT NULL, +`c129` varchar(30) DEFAULT NULL, +`c130` varchar(30) DEFAULT NULL, +`c131` varchar(30) DEFAULT NULL, +`c132` varchar(30) DEFAULT NULL, +`c133` varchar(30) DEFAULT NULL, +`c134` varchar(30) DEFAULT NULL, +`c135` varchar(30) DEFAULT NULL, +`c136` varchar(30) DEFAULT NULL, +`c137` varchar(30) DEFAULT NULL, +`c138` varchar(30) DEFAULT NULL, +`c139` varchar(30) DEFAULT NULL, +`c140` varchar(30) DEFAULT NULL, +`c141` varchar(30) DEFAULT NULL, +`c142` varchar(30) DEFAULT NULL, +`c143` varchar(30) DEFAULT NULL, +`c144` varchar(30) DEFAULT NULL, +`c145` varchar(30) DEFAULT NULL, +`c146` varchar(30) DEFAULT NULL, +PRIMARY KEY (`c1`) +) ENGINE=InnoDB; +LOCK TABLES `t1` WRITE; +INSERT INTO `t1` VALUES ('1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'); +DROP TABLE `t1`; +FLUSH LOGS; +=== Using mysqlbinlog to detect failure. Before the patch mysqlbinlog would find a corrupted event, thence would fail. diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result index 675c327e9e7..4c2c32ad8f1 100644 --- a/mysql-test/suite/binlog/r/binlog_unsafe.result +++ b/mysql-test/suite/binlog/r/binlog_unsafe.result @@ -10,25 +10,25 @@ INSERT DELAYED INTO t1 VALUES (5); ---- Insert directly ---- INSERT INTO t1 VALUES (@@global.sync_binlog); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t1 VALUES (@@session.insert_id); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t1 VALUES (@@global.auto_increment_increment); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t2 SELECT UUID(); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t2 VALUES (@@session.sql_mode); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t2 VALUES (@@global.init_slave); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t2 VALUES (@@hostname); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. ---- Insert from stored procedure ---- CREATE PROCEDURE proc() BEGIN @@ -42,13 +42,13 @@ INSERT INTO t2 VALUES (@@hostname); END| CALL proc(); Warnings: -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. ---- Insert from stored function ---- CREATE FUNCTION func() RETURNS INT @@ -66,13 +66,13 @@ SELECT func(); func() 0 Warnings: -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. ---- Insert from trigger ---- CREATE TRIGGER trig BEFORE INSERT ON trigger_table @@ -88,14 +88,14 @@ INSERT INTO t2 VALUES (@@hostname); END| INSERT INTO trigger_table VALUES ('bye.'); Warnings: -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. ---- Insert from prepared statement ---- PREPARE p1 FROM 'INSERT INTO t1 VALUES (@@global.sync_binlog)'; PREPARE p2 FROM 'INSERT INTO t1 VALUES (@@session.insert_id)'; @@ -106,25 +106,25 @@ PREPARE p6 FROM 'INSERT INTO t2 VALUES (@@global.init_slave)'; PREPARE p7 FROM 'INSERT INTO t2 VALUES (@@hostname)'; EXECUTE p1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. EXECUTE p2; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. EXECUTE p3; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. EXECUTE p4; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. EXECUTE p5; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. EXECUTE p6; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. EXECUTE p7; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. ---- Insert from nested call of triggers / functions / procedures ---- CREATE PROCEDURE proc1() INSERT INTO trigger_table VALUES ('ha!')| @@ -154,13 +154,13 @@ EXECUTE prep6; func5() 0 Warnings: -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. ==== Variables that should *not* be unsafe ==== INSERT INTO t1 VALUES (@@session.pseudo_thread_id); INSERT INTO t1 VALUES (@@session.pseudo_thread_id); @@ -195,16 +195,16 @@ DROP TABLE t1, t2, t3, trigger_table, trigger_table2; CREATE TABLE t1(a INT, b INT, KEY(a), PRIMARY KEY(b)); INSERT INTO t1 SELECT * FROM t1 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. REPLACE INTO t1 SELECT * FROM t1 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. UPDATE t1 SET a=1 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. DELETE FROM t1 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. CREATE PROCEDURE p1() BEGIN INSERT INTO t1 SELECT * FROM t1 LIMIT 1; @@ -214,10 +214,10 @@ DELETE FROM t1 LIMIT 1; END| CALL p1(); Warnings: -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. DROP PROCEDURE p1; DROP TABLE t1; DROP TABLE IF EXISTS t1; @@ -225,16 +225,16 @@ CREATE TABLE t1 (a VARCHAR(100), b VARCHAR(100)); INSERT INTO t1 VALUES ('a','b'); UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. DROP TABLE t1; DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1(i INT PRIMARY KEY); CREATE TABLE t2(i INT PRIMARY KEY); CREATE TABLE t3(i INT, ch CHAR(50)); -"Should issue message Statement is not safe to log in statement format." +"Should issue message Statement may not be safe to log in statement format." INSERT INTO t1 SELECT * FROM t2 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. CREATE FUNCTION func6() RETURNS INT BEGIN @@ -243,10 +243,10 @@ INSERT INTO t1 VALUES (11); INSERT INTO t1 VALUES (12); RETURN 0; END| -"Should issue message Statement is not safe to log in statement format only once" +"Should issue message Statement may not be safe to log in statement format only once" INSERT INTO t3 VALUES(func6(), UUID()); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. "Check whether SET @@SQL_LOG_BIN = 0/1 doesn't work in substatements" CREATE FUNCTION fun_check_log_bin() RETURNS INT BEGIN @@ -259,7 +259,7 @@ SELECT fun_check_log_bin(); fun_check_log_bin() 100 Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. "SQL_LOG_BIN should be ON still" SHOW VARIABLES LIKE "SQL_LOG_BIN"; Variable_name Value @@ -315,16 +315,16 @@ CREATE TABLE t1(i INT PRIMARY KEY); CREATE TABLE t2(i INT PRIMARY KEY); INSERT INTO t1 SELECT * FROM t2 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. INSERT INTO t1 VALUES(@@global.sync_binlog); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. UPDATE t1 SET i = 999 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. DELETE FROM t1 LIMIT 1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. DROP TABLE t1, t2; SET @@SESSION.SQL_MODE = @save_sql_mode; "End of tests" diff --git a/mysql-test/suite/binlog/t/binlog_incident-master.opt b/mysql-test/suite/binlog/t/binlog_incident-master.opt new file mode 100644 index 00000000000..57ce0081ae5 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_incident-master.opt @@ -0,0 +1 @@ +--loose-debug=+d,incident_database_resync_on_replace
\ No newline at end of file diff --git a/mysql-test/suite/binlog/t/binlog_incident.test b/mysql-test/suite/binlog/t/binlog_incident.test new file mode 100644 index 00000000000..208c7f24df2 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_incident.test @@ -0,0 +1,27 @@ +# The purpose of this test is to provide a reference for how the +# incident log event is represented in the output from the mysqlbinlog +# program. + +source include/have_log_bin.inc; +source include/have_debug.inc; + +let $MYSQLD_DATADIR= `select @@datadir`; + +CREATE TABLE t1 (a INT); + +INSERT INTO t1 VALUES (1),(2),(3); +SELECT * FROM t1; + +# This will generate an incident log event and store it in the binary +# log before the replace statement. +REPLACE INTO t1 VALUES (4); + +DROP TABLE t1; +FLUSH LOGS; + +exec $MYSQL_BINLOG --start-position=106 $MYSQLD_DATADIR/master-bin.000001 >$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql; +--disable_query_log +eval SELECT cont LIKE '%RELOAD DATABASE; # Shall generate syntax error%' AS `Contain RELOAD DATABASE` FROM (SELECT load_file('$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql') AS cont) AS tbl; +--enable_query_log + +remove_file $MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
\ No newline at end of file diff --git a/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test new file mode 100644 index 00000000000..0422c204270 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test @@ -0,0 +1,143 @@ +# BUG#42941: --database parameter to mysqlbinlog fails with RBR +# +# WHAT +# ==== +# +# This test aims at checking whether a rows log event is printed or +# not when --database parameter is used to filter events from one +# given database. +# +# HOW +# === +# +# The test is implemented as follows: +# +# i) Some operations are done in two different databases: +# 'test' and 'b42941'; +# ii) mysqlbinlog is used to dump the contents of the binlog file +# filtering only events from 'b42941'. The result of the dump is +# stored in a temporary file. (This is done with and without +# --verbose/hexdump flag); +# iii) The contents of the dump are loaded into a session variable; +# iv) The variable contents are searched for 'test' and 'b42941'; +# v) Should 'test' be found, an ERROR is reported. Should 'b42941' be +# absent, an ERROR is reported. + +-- source include/have_log_bin.inc +-- source include/have_binlog_format_row.inc +-- source include/have_innodb.inc + +RESET MASTER; +-- let $MYSQLD_DATADIR= `select @@datadir` + +CREATE TABLE t1 (id int); +CREATE TABLE t2 (id int); +CREATE TABLE t3 (txt TEXT); +CREATE TABLE t4 (a int) ENGINE= InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t1 VALUES (3); +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +-- eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3 +INSERT INTO t1 VALUES (4); + +CREATE DATABASE b42941; +use b42941; +CREATE TABLE t1 (id int); +CREATE TABLE t2 (id int); +CREATE TABLE t3 (txt TEXT); +CREATE TABLE t4 (a int) ENGINE= InnoDB; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (2); +INSERT INTO t1 VALUES (3); +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +-- eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3 +INSERT INTO t1 VALUES (4); + +INSERT INTO test.t1 VALUES (5); + +FLUSH LOGS; + +UPDATE test.t1 t11, b42941.t1 t12 SET t11.id=10, t12.id=100; + +BEGIN; +INSERT INTO test.t4 VALUES (1); +INSERT INTO b42941.t4 VALUES (1); +UPDATE test.t4 tn4, b42941.t4 tt4 SET tn4.a= 10, tt4.a= 100; +COMMIT; + +FLUSH LOGS; + +-- let $log_file1= $MYSQLD_DATADIR/master-bin.000001 +-- let $log_file2= $MYSQLD_DATADIR/master-bin.000002 +-- let $outfile= $MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog +-- let $cmd= $MYSQL_BINLOG + +let $i= 3; +while($i) +{ + -- let $flags=--database=b42941 + + # construct CLI for mysqlbinlog + if(`SELECT $i=3`) + { + -- let $flags= $flags --verbose --hexdump + } + + if(`SELECT $i=2`) + { + -- let $flags= $flags --verbose + } + +# if(`SELECT $i=1`) +# { + # do nothing $flags is already set as it should be +# } + + # execute mysqlbinlog on the two available master binlog files + -- exec $cmd $flags $log_file1 > $outfile.1 + -- exec $cmd $flags $log_file2 > $outfile.2 + + # load outputs into a variable + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + -- eval SET @b42941_output.1= LOAD_FILE('$outfile.1') + + -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR + -- eval SET @b42941_output.2= LOAD_FILE('$outfile.2') + + # remove unecessary files + -- remove_file $outfile.1 + -- remove_file $outfile.2 + + # assertion: events for database test are filtered + if (`SELECT INSTR(@b42941_output.1, 'test')`) + { + -- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.1). + } + + if (`SELECT INSTR(@b42941_output.2, 'test')`) + { + -- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.2). + } + + # assertion: events for database b42941 are not filtered + if (!`SELECT INSTR(@b42941_output.1, 'b42941')`) + { + -- echo **** ERROR **** Database name 'b42941' NOT FOUND in mysqlbinlog output ($flags $outfile.1). + } + + if (!`SELECT INSTR(@b42941_output.2, 'b42941')`) + { + -- echo **** ERROR **** Database name 'b42941' NOT FOUND in mysqlbinlog output ($flags $outfile.2). + } + + dec $i; +} + +DROP DATABASE b42941; +use test; +DROP TABLE t1, t2, t3, t4; diff --git a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt new file mode 100644 index 00000000000..24c2027e399 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt @@ -0,0 +1 @@ +--binlog-ignore-db=b42851 diff --git a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test new file mode 100644 index 00000000000..0bf685ea921 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test @@ -0,0 +1,73 @@ +# BUG#42851: Spurious "Statement is not safe to log in statement +# format." warnings +# +# WHY +# === +# +# This test aims at checking that the fix that removes spurious +# entries in the error log when the statement is filtered out from +# binlog, is working. +# +# HOW +# === +# +# The test case is split into three assertions when issuing statements +# containing LIMIT and ORDER BY: +# +# i) issue statements in database that is not filtered => check +# that warnings ARE shown; +# +# ii) issue statements in database that is not filtered, but with +# binlog disabled => check that warnings ARE NOT shown; +# +# iii) issue statements in database that is filtered => check that +# warnings ARE NOT shown. + +-- source include/have_log_bin.inc +-- source include/have_binlog_format_statement.inc + +-- echo ### NOT filtered database => assertion: warnings ARE shown + +-- disable_warnings +DROP TABLE IF EXISTS t1; +-- enable_warnings + +CREATE TABLE t1 (a int, b int, primary key (a)); +INSERT INTO t1 VALUES (1,2), (2,3); +UPDATE t1 SET b='4' WHERE a=1 LIMIT 1; +UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1; +DROP TABLE t1; + +-- echo ### NOT filtered database => assertion: binlog disabled and warnings ARE NOT shown + +SET SQL_LOG_BIN= 0; + +-- disable_warnings +DROP TABLE IF EXISTS t1; +-- enable_warnings + +CREATE TABLE t1 (a int, b int, primary key (a)); +INSERT INTO t1 VALUES (1,2), (2,3); +UPDATE t1 SET b='4' WHERE a=1 LIMIT 1; +UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1; +DROP TABLE t1; + +SET SQL_LOG_BIN= 1; + +-- echo ### FILTERED database => assertion: warnings ARE NOT shown + +CREATE DATABASE b42851; +USE b42851; + +-- disable_warnings +DROP TABLE IF EXISTS t1; +-- enable_warnings + +CREATE TABLE t1 (a int, b int, primary key (a)); +INSERT INTO t1 VALUES (1,2), (2,3); +UPDATE t1 SET b='4' WHERE a=1 LIMIT 1; +UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1; +DROP TABLE t1; + +# clean up +DROP DATABASE b42851; diff --git a/mysql-test/suite/binlog/t/binlog_tbl_metadata.test b/mysql-test/suite/binlog/t/binlog_tbl_metadata.test new file mode 100644 index 00000000000..5e847ab5fbd --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_tbl_metadata.test @@ -0,0 +1,199 @@ +# +# BUG#42749: infinite loop writing to row based binlog - processlist shows +# "freeing items" +# +# WHY +# === +# +# This bug would make table map event to report data_written one byte less +# than what would actually be written in its body. This would cause one byte shorter +# event end_log_pos. The ultimate impact was that it would make fixing the +# position in MYSQL_BIN_LOG::write_cache bogus or end up in an infinite loop. +# +# HOW +# === +# +# Checking that the patch fixes the problem is done as follows: +# i) a table with several fields is created; +# ii) an insert is performed; +# iii) the logs are flushed; +# iv) mysqlbinlog is used to check if it succeeds. +# +# In step iv), before the bug was fixed, the test case would fail with +# mysqlbinlog reporting that it was unable to succeed in reading the event. +# + +-- source include/have_log_bin.inc +-- source include/have_innodb.inc +-- source include/have_binlog_format_row.inc +-- connection default + +RESET MASTER; + +-- disable_warnings +DROP TABLE IF EXISTS `t1`; +-- enable_warnings + +CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + `c2` varchar(30) NOT NULL, + `c3` varchar(30) DEFAULT NULL, + `c4` varchar(30) DEFAULT NULL, + `c5` varchar(30) DEFAULT NULL, + `c6` varchar(30) DEFAULT NULL, + `c7` varchar(30) DEFAULT NULL, + `c8` varchar(30) DEFAULT NULL, + `c9` varchar(30) DEFAULT NULL, + `c10` varchar(30) DEFAULT NULL, + `c11` varchar(30) DEFAULT NULL, + `c12` varchar(30) DEFAULT NULL, + `c13` varchar(30) DEFAULT NULL, + `c14` varchar(30) DEFAULT NULL, + `c15` varchar(30) DEFAULT NULL, + `c16` varchar(30) DEFAULT NULL, + `c17` varchar(30) DEFAULT NULL, + `c18` varchar(30) DEFAULT NULL, + `c19` varchar(30) DEFAULT NULL, + `c20` varchar(30) DEFAULT NULL, + `c21` varchar(30) DEFAULT NULL, + `c22` varchar(30) DEFAULT NULL, + `c23` varchar(30) DEFAULT NULL, + `c24` varchar(30) DEFAULT NULL, + `c25` varchar(30) DEFAULT NULL, + `c26` varchar(30) DEFAULT NULL, + `c27` varchar(30) DEFAULT NULL, + `c28` varchar(30) DEFAULT NULL, + `c29` varchar(30) DEFAULT NULL, + `c30` varchar(30) DEFAULT NULL, + `c31` varchar(30) DEFAULT NULL, + `c32` varchar(30) DEFAULT NULL, + `c33` varchar(30) DEFAULT NULL, + `c34` varchar(30) DEFAULT NULL, + `c35` varchar(30) DEFAULT NULL, + `c36` varchar(30) DEFAULT NULL, + `c37` varchar(30) DEFAULT NULL, + `c38` varchar(30) DEFAULT NULL, + `c39` varchar(30) DEFAULT NULL, + `c40` varchar(30) DEFAULT NULL, + `c41` varchar(30) DEFAULT NULL, + `c42` varchar(30) DEFAULT NULL, + `c43` varchar(30) DEFAULT NULL, + `c44` varchar(30) DEFAULT NULL, + `c45` varchar(30) DEFAULT NULL, + `c46` varchar(30) DEFAULT NULL, + `c47` varchar(30) DEFAULT NULL, + `c48` varchar(30) DEFAULT NULL, + `c49` varchar(30) DEFAULT NULL, + `c50` varchar(30) DEFAULT NULL, + `c51` varchar(30) DEFAULT NULL, + `c52` varchar(30) DEFAULT NULL, + `c53` varchar(30) DEFAULT NULL, + `c54` varchar(30) DEFAULT NULL, + `c55` varchar(30) DEFAULT NULL, + `c56` varchar(30) DEFAULT NULL, + `c57` varchar(30) DEFAULT NULL, + `c58` varchar(30) DEFAULT NULL, + `c59` varchar(30) DEFAULT NULL, + `c60` varchar(30) DEFAULT NULL, + `c61` varchar(30) DEFAULT NULL, + `c62` varchar(30) DEFAULT NULL, + `c63` varchar(30) DEFAULT NULL, + `c64` varchar(30) DEFAULT NULL, + `c65` varchar(30) DEFAULT NULL, + `c66` varchar(30) DEFAULT NULL, + `c67` varchar(30) DEFAULT NULL, + `c68` varchar(30) DEFAULT NULL, + `c69` varchar(30) DEFAULT NULL, + `c70` varchar(30) DEFAULT NULL, + `c71` varchar(30) DEFAULT NULL, + `c72` varchar(30) DEFAULT NULL, + `c73` varchar(30) DEFAULT NULL, + `c74` varchar(30) DEFAULT NULL, + `c75` varchar(30) DEFAULT NULL, + `c76` varchar(30) DEFAULT NULL, + `c77` varchar(30) DEFAULT NULL, + `c78` varchar(30) DEFAULT NULL, + `c79` varchar(30) DEFAULT NULL, + `c80` varchar(30) DEFAULT NULL, + `c81` varchar(30) DEFAULT NULL, + `c82` varchar(30) DEFAULT NULL, + `c83` varchar(30) DEFAULT NULL, + `c84` varchar(30) DEFAULT NULL, + `c85` varchar(30) DEFAULT NULL, + `c86` varchar(30) DEFAULT NULL, + `c87` varchar(30) DEFAULT NULL, + `c88` varchar(30) DEFAULT NULL, + `c89` varchar(30) DEFAULT NULL, + `c90` varchar(30) DEFAULT NULL, + `c91` varchar(30) DEFAULT NULL, + `c92` varchar(30) DEFAULT NULL, + `c93` varchar(30) DEFAULT NULL, + `c94` varchar(30) DEFAULT NULL, + `c95` varchar(30) DEFAULT NULL, + `c96` varchar(30) DEFAULT NULL, + `c97` varchar(30) DEFAULT NULL, + `c98` varchar(30) DEFAULT NULL, + `c99` varchar(30) DEFAULT NULL, + `c100` varchar(30) DEFAULT NULL, + `c101` varchar(30) DEFAULT NULL, + `c102` varchar(30) DEFAULT NULL, + `c103` varchar(30) DEFAULT NULL, + `c104` varchar(30) DEFAULT NULL, + `c105` varchar(30) DEFAULT NULL, + `c106` varchar(30) DEFAULT NULL, + `c107` varchar(30) DEFAULT NULL, + `c108` varchar(30) DEFAULT NULL, + `c109` varchar(30) DEFAULT NULL, + `c110` varchar(30) DEFAULT NULL, + `c111` varchar(30) DEFAULT NULL, + `c112` varchar(30) DEFAULT NULL, + `c113` varchar(30) DEFAULT NULL, + `c114` varchar(30) DEFAULT NULL, + `c115` varchar(30) DEFAULT NULL, + `c116` varchar(30) DEFAULT NULL, + `c117` varchar(30) DEFAULT NULL, + `c118` varchar(30) DEFAULT NULL, + `c119` varchar(30) DEFAULT NULL, + `c120` varchar(30) DEFAULT NULL, + `c121` varchar(30) DEFAULT NULL, + `c122` varchar(30) DEFAULT NULL, + `c123` varchar(30) DEFAULT NULL, + `c124` varchar(30) DEFAULT NULL, + `c125` varchar(30) DEFAULT NULL, + `c126` varchar(30) DEFAULT NULL, + `c127` varchar(30) DEFAULT NULL, + `c128` varchar(30) DEFAULT NULL, + `c129` varchar(30) DEFAULT NULL, + `c130` varchar(30) DEFAULT NULL, + `c131` varchar(30) DEFAULT NULL, + `c132` varchar(30) DEFAULT NULL, + `c133` varchar(30) DEFAULT NULL, + `c134` varchar(30) DEFAULT NULL, + `c135` varchar(30) DEFAULT NULL, + `c136` varchar(30) DEFAULT NULL, + `c137` varchar(30) DEFAULT NULL, + `c138` varchar(30) DEFAULT NULL, + `c139` varchar(30) DEFAULT NULL, + `c140` varchar(30) DEFAULT NULL, + `c141` varchar(30) DEFAULT NULL, + `c142` varchar(30) DEFAULT NULL, + `c143` varchar(30) DEFAULT NULL, + `c144` varchar(30) DEFAULT NULL, + `c145` varchar(30) DEFAULT NULL, + `c146` varchar(30) DEFAULT NULL, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB; + +LOCK TABLES `t1` WRITE; + +INSERT INTO `t1` VALUES ('1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'); + +DROP TABLE `t1`; + +FLUSH LOGS; + +-- echo === Using mysqlbinlog to detect failure. Before the patch mysqlbinlog would find a corrupted event, thence would fail. + +-- let $MYSQLD_DATADIR= `SELECT @@datadir`; +-- exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug42749.binlog +-- remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug42749.binlog diff --git a/mysql-test/suite/binlog/t/binlog_unsafe.test b/mysql-test/suite/binlog/t/binlog_unsafe.test index 1b0f0a6c30a..c4e1f31cbce 100644 --- a/mysql-test/suite/binlog/t/binlog_unsafe.test +++ b/mysql-test/suite/binlog/t/binlog_unsafe.test @@ -289,7 +289,7 @@ CREATE TABLE t1(i INT PRIMARY KEY); CREATE TABLE t2(i INT PRIMARY KEY); CREATE TABLE t3(i INT, ch CHAR(50)); ---echo "Should issue message Statement is not safe to log in statement format." +--echo "Should issue message Statement may not be safe to log in statement format." INSERT INTO t1 SELECT * FROM t2 LIMIT 1; DELIMITER |; @@ -302,7 +302,7 @@ BEGIN RETURN 0; END| DELIMITER ;| ---echo "Should issue message Statement is not safe to log in statement format only once" +--echo "Should issue message Statement may not be safe to log in statement format only once" INSERT INTO t3 VALUES(func6(), UUID()); --echo "Check whether SET @@SQL_LOG_BIN = 0/1 doesn't work in substatements" diff --git a/mysql-test/suite/funcs_1/datadict/is_key_column_usage.inc b/mysql-test/suite/funcs_1/datadict/is_key_column_usage.inc index c8e8a186673..098b8c6eca2 100644 --- a/mysql-test/suite/funcs_1/datadict/is_key_column_usage.inc +++ b/mysql-test/suite/funcs_1/datadict/is_key_column_usage.inc @@ -126,7 +126,6 @@ ORDER BY constraint_catalog, constraint_schema, constraint_name, eval $select; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict); eval $select; diff --git a/mysql-test/suite/funcs_1/datadict/is_routines.inc b/mysql-test/suite/funcs_1/datadict/is_routines.inc index 573967cbc1b..c2b547e600f 100644 --- a/mysql-test/suite/funcs_1/datadict/is_routines.inc +++ b/mysql-test/suite/funcs_1/datadict/is_routines.inc @@ -96,10 +96,11 @@ CREATE FUNCTION function_for_routines() RETURNS INT RETURN 0; SELECT specific_name,routine_catalog,routine_schema,routine_name,routine_type, routine_body,external_name,external_language,parameter_style,sql_path FROM information_schema.routines -WHERE routine_catalog IS NOT NULL OR external_name IS NOT NULL +WHERE routine_schema = 'test' AND + (routine_catalog IS NOT NULL OR external_name IS NOT NULL OR external_language IS NOT NULL OR sql_path IS NOT NULL OR routine_body <> 'SQL' OR parameter_style <> 'SQL' - OR specific_name <> routine_name; + OR specific_name <> routine_name); DROP PROCEDURE sp_for_routines; DROP FUNCTION function_for_routines; @@ -178,7 +179,6 @@ GRANT EXECUTE ON db_datadict_2.* TO 'testuser2'@'localhost'; FLUSH PRIVILEGES; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict); --replace_column 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss" diff --git a/mysql-test/suite/funcs_1/datadict/is_schemata.inc b/mysql-test/suite/funcs_1/datadict/is_schemata.inc index 96061d541b7..29e1f6af4ef 100644 --- a/mysql-test/suite/funcs_1/datadict/is_schemata.inc +++ b/mysql-test/suite/funcs_1/datadict/is_schemata.inc @@ -104,7 +104,6 @@ eval $my_select; eval $my_show; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict_1); # Shows db_datadict_1 diff --git a/mysql-test/suite/funcs_1/datadict/is_tables.inc b/mysql-test/suite/funcs_1/datadict/is_tables.inc index 4f608eb02ea..d1e4608a572 100644 --- a/mysql-test/suite/funcs_1/datadict/is_tables.inc +++ b/mysql-test/suite/funcs_1/datadict/is_tables.inc @@ -130,7 +130,6 @@ WHERE table_schema = 'db_datadict' ORDER BY table_name; let $my_show = SHOW TABLES FROM db_datadict; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict); # tb2 is not granted to anyone diff --git a/mysql-test/suite/funcs_1/datadict/is_triggers.inc b/mysql-test/suite/funcs_1/datadict/is_triggers.inc index 70d5540e163..3b83a75295b 100644 --- a/mysql-test/suite/funcs_1/datadict/is_triggers.inc +++ b/mysql-test/suite/funcs_1/datadict/is_triggers.inc @@ -122,7 +122,6 @@ let $my_select = SELECT * FROM information_schema.triggers WHERE trigger_name = 'trg1'; let $my_show = SHOW TRIGGERS FROM db_datadict; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict); --replace_result $engine_type <engine_type> diff --git a/mysql-test/suite/funcs_1/datadict/is_views.inc b/mysql-test/suite/funcs_1/datadict/is_views.inc index 542dab05a8e..32e66e4f684 100644 --- a/mysql-test/suite/funcs_1/datadict/is_views.inc +++ b/mysql-test/suite/funcs_1/datadict/is_views.inc @@ -108,7 +108,6 @@ WHERE table_schema = 'db_datadict' ORDER BY table_name; eval $select; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , test); eval $select; diff --git a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc index d8e1b398bfc..b5c40c63566 100644 --- a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc +++ b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc @@ -212,7 +212,7 @@ GRANT PROCESS ON *.* TO ''@'localhost'; --echo anonymous user with PROCESS privilege --echo SHOW/SELECT shows all processes/threads. --echo #################################################################################### -connect (anonymous1,localhost,'',,information_schema); +connect (anonymous1,localhost,"''",,information_schema); SHOW GRANTS; --replace_column 1 ID 3 HOST_NAME 6 TIME SHOW processlist; @@ -253,7 +253,7 @@ REVOKE PROCESS ON *.* FROM ''@'localhost'; --echo #################################################################################### --echo 7.1 New connection (anonymous2,localhost,'',,information_schema) -connect (anonymous2,localhost,'',,information_schema); +connect (anonymous2,localhost,"''",,information_schema); --echo The anonymous user has no more the PROCESS privilege --echo Again only the processes of the anonymous user are visible. --echo #################################################################################### diff --git a/mysql-test/suite/funcs_1/datadict/statistics.inc b/mysql-test/suite/funcs_1/datadict/statistics.inc index 6f24f422b5e..00fd7a1b06b 100644 --- a/mysql-test/suite/funcs_1/datadict/statistics.inc +++ b/mysql-test/suite/funcs_1/datadict/statistics.inc @@ -42,7 +42,6 @@ ORDER BY table_schema, table_name, index_name, seq_in_index, column_name; eval $my_select; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1,localhost,testuser1,,db_datadict); --replace_column 10 #CARD# diff --git a/mysql-test/suite/funcs_1/datadict/table_constraints.inc b/mysql-test/suite/funcs_1/datadict/table_constraints.inc index 513057c84a0..9e57976862b 100644 --- a/mysql-test/suite/funcs_1/datadict/table_constraints.inc +++ b/mysql-test/suite/funcs_1/datadict/table_constraints.inc @@ -33,7 +33,6 @@ ORDER BY table_schema,table_name,constraint_name; eval $my_select; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1,localhost,testuser1,,db_datadict); eval $my_select; diff --git a/mysql-test/suite/funcs_1/datadict/tables.inc b/mysql-test/suite/funcs_1/datadict/tables.inc index 8dae7ba0ebc..5aa072d184c 100644 --- a/mysql-test/suite/funcs_1/datadict/tables.inc +++ b/mysql-test/suite/funcs_1/datadict/tables.inc @@ -37,7 +37,6 @@ CREATE USER testuser1@localhost; GRANT SELECT ON test1.* TO testuser1@localhost; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1,localhost,testuser1,,test1); --source suite/funcs_1/datadict/tables2.inc diff --git a/mysql-test/suite/funcs_1/datadict/tables1.inc b/mysql-test/suite/funcs_1/datadict/tables1.inc index 2dff32d81a9..2e054a9dcfb 100644 --- a/mysql-test/suite/funcs_1/datadict/tables1.inc +++ b/mysql-test/suite/funcs_1/datadict/tables1.inc @@ -27,7 +27,6 @@ CREATE USER testuser1@localhost; GRANT SELECT ON test1.* TO testuser1@localhost; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1,localhost,testuser1,,test1); --source suite/funcs_1/datadict/tables2.inc diff --git a/mysql-test/suite/funcs_1/r/charset_collation.result b/mysql-test/suite/funcs_1/r/charset_collation.result new file mode 100644 index 00000000000..b3183ba48e1 --- /dev/null +++ b/mysql-test/suite/funcs_1/r/charset_collation.result @@ -0,0 +1,40 @@ +DROP USER dbdict_test@localhost; +CREATE USER dbdict_test@localhost; +# Establish connection con (user=dbdict_test) + +SELECT * +FROM information_schema.character_sets +WHERE character_set_name IN ('utf8','latin1','binary') +ORDER BY character_set_name; +CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN +binary binary Binary pseudo charset 1 +latin1 latin1_swedish_ci cp1252 West European 1 +utf8 utf8_general_ci UTF-8 Unicode 3 + +SELECT * +FROM information_schema.collations +WHERE character_set_name IN ('utf8','latin1','binary') +AND (collation_name LIKE CONCAT(character_set_name,'_general_ci') +OR +collation_name LIKE CONCAT(character_set_name,'_bin')) +ORDER BY collation_name; +COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN +latin1_bin latin1 47 Yes 1 +latin1_general_ci latin1 48 Yes 1 +utf8_bin utf8 83 Yes 1 +utf8_general_ci utf8 33 Yes Yes 1 + +SELECT * +FROM information_schema.collation_character_set_applicability +WHERE character_set_name IN ('utf8','latin1','binary') +AND (collation_name LIKE CONCAT(character_set_name,'_general_ci') +OR +collation_name LIKE CONCAT(character_set_name,'_bin')) +ORDER BY collation_name, character_set_name; +COLLATION_NAME CHARACTER_SET_NAME +latin1_bin latin1 +latin1_general_ci latin1 +utf8_bin utf8 +utf8_general_ci utf8 +# Switch to connection default + disconnect con +DROP USER dbdict_test@localhost; diff --git a/mysql-test/suite/funcs_1/r/charset_collation_1.result b/mysql-test/suite/funcs_1/r/charset_collation_1.result deleted file mode 100644 index 55ed4b4704c..00000000000 --- a/mysql-test/suite/funcs_1/r/charset_collation_1.result +++ /dev/null @@ -1,312 +0,0 @@ -DROP USER dbdict_test@localhost; -CREATE USER dbdict_test@localhost; -# Establish connection con (user=dbdict_test) - -SELECT * -FROM information_schema.character_sets -ORDER BY character_set_name; -CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN -armscii8 armscii8_general_ci ARMSCII-8 Armenian 1 -ascii ascii_general_ci US ASCII 1 -big5 big5_chinese_ci Big5 Traditional Chinese 2 -binary binary Binary pseudo charset 1 -cp1250 cp1250_general_ci Windows Central European 1 -cp1251 cp1251_general_ci Windows Cyrillic 1 -cp1256 cp1256_general_ci Windows Arabic 1 -cp1257 cp1257_general_ci Windows Baltic 1 -cp850 cp850_general_ci DOS West European 1 -cp852 cp852_general_ci DOS Central European 1 -cp866 cp866_general_ci DOS Russian 1 -cp932 cp932_japanese_ci SJIS for Windows Japanese 2 -dec8 dec8_swedish_ci DEC West European 1 -eucjpms eucjpms_japanese_ci UJIS for Windows Japanese 3 -euckr euckr_korean_ci EUC-KR Korean 2 -gb2312 gb2312_chinese_ci GB2312 Simplified Chinese 2 -gbk gbk_chinese_ci GBK Simplified Chinese 2 -geostd8 geostd8_general_ci GEOSTD8 Georgian 1 -greek greek_general_ci ISO 8859-7 Greek 1 -hebrew hebrew_general_ci ISO 8859-8 Hebrew 1 -hp8 hp8_english_ci HP West European 1 -keybcs2 keybcs2_general_ci DOS Kamenicky Czech-Slovak 1 -koi8r koi8r_general_ci KOI8-R Relcom Russian 1 -koi8u koi8u_general_ci KOI8-U Ukrainian 1 -latin1 latin1_swedish_ci cp1252 West European 1 -latin2 latin2_general_ci ISO 8859-2 Central European 1 -latin5 latin5_turkish_ci ISO 8859-9 Turkish 1 -latin7 latin7_general_ci ISO 8859-13 Baltic 1 -macce macce_general_ci Mac Central European 1 -macroman macroman_general_ci Mac West European 1 -sjis sjis_japanese_ci Shift-JIS Japanese 2 -swe7 swe7_swedish_ci 7bit Swedish 1 -tis620 tis620_thai_ci TIS620 Thai 1 -ucs2 ucs2_general_ci UCS-2 Unicode 2 -ujis ujis_japanese_ci EUC-JP Japanese 3 -utf8 utf8_general_ci UTF-8 Unicode 3 - -SELECT * -FROM information_schema.collations -ORDER BY collation_name; -COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN -armscii8_bin armscii8 64 0 -armscii8_general_ci armscii8 32 Yes 0 -ascii_bin ascii 65 0 -ascii_general_ci ascii 11 Yes 0 -big5_bin big5 84 Yes 1 -big5_chinese_ci big5 1 Yes Yes 1 -binary binary 63 Yes Yes 1 -cp1250_bin cp1250 66 Yes 1 -cp1250_croatian_ci cp1250 44 Yes 1 -cp1250_czech_cs cp1250 34 Yes 2 -cp1250_general_ci cp1250 26 Yes Yes 1 -cp1250_polish_ci cp1250 99 Yes 1 -cp1251_bin cp1251 50 0 -cp1251_bulgarian_ci cp1251 14 0 -cp1251_general_ci cp1251 51 Yes 0 -cp1251_general_cs cp1251 52 0 -cp1251_ukrainian_ci cp1251 23 0 -cp1256_bin cp1256 67 0 -cp1256_general_ci cp1256 57 Yes 0 -cp1257_bin cp1257 58 0 -cp1257_general_ci cp1257 59 Yes 0 -cp1257_lithuanian_ci cp1257 29 0 -cp850_bin cp850 80 0 -cp850_general_ci cp850 4 Yes 0 -cp852_bin cp852 81 0 -cp852_general_ci cp852 40 Yes 0 -cp866_bin cp866 68 0 -cp866_general_ci cp866 36 Yes 0 -cp932_bin cp932 96 Yes 1 -cp932_japanese_ci cp932 95 Yes Yes 1 -dec8_bin dec8 69 0 -dec8_swedish_ci dec8 3 Yes 0 -eucjpms_bin eucjpms 98 Yes 1 -eucjpms_japanese_ci eucjpms 97 Yes Yes 1 -euckr_bin euckr 85 Yes 1 -euckr_korean_ci euckr 19 Yes Yes 1 -gb2312_bin gb2312 86 Yes 1 -gb2312_chinese_ci gb2312 24 Yes Yes 1 -gbk_bin gbk 87 Yes 1 -gbk_chinese_ci gbk 28 Yes Yes 1 -geostd8_bin geostd8 93 0 -geostd8_general_ci geostd8 92 Yes 0 -greek_bin greek 70 0 -greek_general_ci greek 25 Yes 0 -hebrew_bin hebrew 71 0 -hebrew_general_ci hebrew 16 Yes 0 -hp8_bin hp8 72 0 -hp8_english_ci hp8 6 Yes 0 -keybcs2_bin keybcs2 73 0 -keybcs2_general_ci keybcs2 37 Yes 0 -koi8r_bin koi8r 74 0 -koi8r_general_ci koi8r 7 Yes 0 -koi8u_bin koi8u 75 0 -koi8u_general_ci koi8u 22 Yes 0 -latin1_bin latin1 47 Yes 1 -latin1_danish_ci latin1 15 Yes 1 -latin1_general_ci latin1 48 Yes 1 -latin1_general_cs latin1 49 Yes 1 -latin1_german1_ci latin1 5 Yes 1 -latin1_german2_ci latin1 31 Yes 2 -latin1_spanish_ci latin1 94 Yes 1 -latin1_swedish_ci latin1 8 Yes Yes 1 -latin2_bin latin2 77 Yes 1 -latin2_croatian_ci latin2 27 Yes 1 -latin2_czech_cs latin2 2 Yes 4 -latin2_general_ci latin2 9 Yes Yes 1 -latin2_hungarian_ci latin2 21 Yes 1 -latin5_bin latin5 78 0 -latin5_turkish_ci latin5 30 Yes 0 -latin7_bin latin7 79 0 -latin7_estonian_cs latin7 20 0 -latin7_general_ci latin7 41 Yes 0 -latin7_general_cs latin7 42 0 -macce_bin macce 43 0 -macce_general_ci macce 38 Yes 0 -macroman_bin macroman 53 0 -macroman_general_ci macroman 39 Yes 0 -sjis_bin sjis 88 Yes 1 -sjis_japanese_ci sjis 13 Yes Yes 1 -swe7_bin swe7 82 0 -swe7_swedish_ci swe7 10 Yes 0 -tis620_bin tis620 89 Yes 1 -tis620_thai_ci tis620 18 Yes Yes 4 -ucs2_bin ucs2 90 Yes 1 -ucs2_czech_ci ucs2 138 Yes 8 -ucs2_danish_ci ucs2 139 Yes 8 -ucs2_esperanto_ci ucs2 145 Yes 8 -ucs2_estonian_ci ucs2 134 Yes 8 -ucs2_general_ci ucs2 35 Yes Yes 1 -ucs2_hungarian_ci ucs2 146 Yes 8 -ucs2_icelandic_ci ucs2 129 Yes 8 -ucs2_latvian_ci ucs2 130 Yes 8 -ucs2_lithuanian_ci ucs2 140 Yes 8 -ucs2_persian_ci ucs2 144 Yes 8 -ucs2_polish_ci ucs2 133 Yes 8 -ucs2_romanian_ci ucs2 131 Yes 8 -ucs2_roman_ci ucs2 143 Yes 8 -ucs2_slovak_ci ucs2 141 Yes 8 -ucs2_slovenian_ci ucs2 132 Yes 8 -ucs2_spanish2_ci ucs2 142 Yes 8 -ucs2_spanish_ci ucs2 135 Yes 8 -ucs2_swedish_ci ucs2 136 Yes 8 -ucs2_turkish_ci ucs2 137 Yes 8 -ucs2_unicode_ci ucs2 128 Yes 8 -ujis_bin ujis 91 Yes 1 -ujis_japanese_ci ujis 12 Yes Yes 1 -utf8_bin utf8 83 Yes 1 -utf8_czech_ci utf8 202 Yes 8 -utf8_danish_ci utf8 203 Yes 8 -utf8_esperanto_ci utf8 209 Yes 8 -utf8_estonian_ci utf8 198 Yes 8 -utf8_general_ci utf8 33 Yes Yes 1 -utf8_hungarian_ci utf8 210 Yes 8 -utf8_icelandic_ci utf8 193 Yes 8 -utf8_latvian_ci utf8 194 Yes 8 -utf8_lithuanian_ci utf8 204 Yes 8 -utf8_persian_ci utf8 208 Yes 8 -utf8_polish_ci utf8 197 Yes 8 -utf8_romanian_ci utf8 195 Yes 8 -utf8_roman_ci utf8 207 Yes 8 -utf8_slovak_ci utf8 205 Yes 8 -utf8_slovenian_ci utf8 196 Yes 8 -utf8_spanish2_ci utf8 206 Yes 8 -utf8_spanish_ci utf8 199 Yes 8 -utf8_swedish_ci utf8 200 Yes 8 -utf8_turkish_ci utf8 201 Yes 8 -utf8_unicode_ci utf8 192 Yes 8 - - -SELECT * -FROM information_schema.collation_character_set_applicability -ORDER BY collation_name, character_set_name; -COLLATION_NAME CHARACTER_SET_NAME -armscii8_bin armscii8 -armscii8_general_ci armscii8 -ascii_bin ascii -ascii_general_ci ascii -big5_bin big5 -big5_chinese_ci big5 -binary binary -cp1250_bin cp1250 -cp1250_croatian_ci cp1250 -cp1250_czech_cs cp1250 -cp1250_general_ci cp1250 -cp1250_polish_ci cp1250 -cp1251_bin cp1251 -cp1251_bulgarian_ci cp1251 -cp1251_general_ci cp1251 -cp1251_general_cs cp1251 -cp1251_ukrainian_ci cp1251 -cp1256_bin cp1256 -cp1256_general_ci cp1256 -cp1257_bin cp1257 -cp1257_general_ci cp1257 -cp1257_lithuanian_ci cp1257 -cp850_bin cp850 -cp850_general_ci cp850 -cp852_bin cp852 -cp852_general_ci cp852 -cp866_bin cp866 -cp866_general_ci cp866 -cp932_bin cp932 -cp932_japanese_ci cp932 -dec8_bin dec8 -dec8_swedish_ci dec8 -eucjpms_bin eucjpms -eucjpms_japanese_ci eucjpms -euckr_bin euckr -euckr_korean_ci euckr -filename filename -gb2312_bin gb2312 -gb2312_chinese_ci gb2312 -gbk_bin gbk -gbk_chinese_ci gbk -geostd8_bin geostd8 -geostd8_general_ci geostd8 -greek_bin greek -greek_general_ci greek -hebrew_bin hebrew -hebrew_general_ci hebrew -hp8_bin hp8 -hp8_english_ci hp8 -keybcs2_bin keybcs2 -keybcs2_general_ci keybcs2 -koi8r_bin koi8r -koi8r_general_ci koi8r -koi8u_bin koi8u -koi8u_general_ci koi8u -latin1_bin latin1 -latin1_danish_ci latin1 -latin1_general_ci latin1 -latin1_general_cs latin1 -latin1_german1_ci latin1 -latin1_german2_ci latin1 -latin1_spanish_ci latin1 -latin1_swedish_ci latin1 -latin2_bin latin2 -latin2_croatian_ci latin2 -latin2_czech_cs latin2 -latin2_general_ci latin2 -latin2_hungarian_ci latin2 -latin5_bin latin5 -latin5_turkish_ci latin5 -latin7_bin latin7 -latin7_estonian_cs latin7 -latin7_general_ci latin7 -latin7_general_cs latin7 -macce_bin macce -macce_general_ci macce -macroman_bin macroman -macroman_general_ci macroman -sjis_bin sjis -sjis_japanese_ci sjis -swe7_bin swe7 -swe7_swedish_ci swe7 -tis620_bin tis620 -tis620_thai_ci tis620 -ucs2_bin ucs2 -ucs2_czech_ci ucs2 -ucs2_danish_ci ucs2 -ucs2_esperanto_ci ucs2 -ucs2_estonian_ci ucs2 -ucs2_general_ci ucs2 -ucs2_hungarian_ci ucs2 -ucs2_icelandic_ci ucs2 -ucs2_latvian_ci ucs2 -ucs2_lithuanian_ci ucs2 -ucs2_persian_ci ucs2 -ucs2_polish_ci ucs2 -ucs2_romanian_ci ucs2 -ucs2_roman_ci ucs2 -ucs2_slovak_ci ucs2 -ucs2_slovenian_ci ucs2 -ucs2_spanish2_ci ucs2 -ucs2_spanish_ci ucs2 -ucs2_swedish_ci ucs2 -ucs2_turkish_ci ucs2 -ucs2_unicode_ci ucs2 -ujis_bin ujis -ujis_japanese_ci ujis -utf8_bin utf8 -utf8_czech_ci utf8 -utf8_danish_ci utf8 -utf8_esperanto_ci utf8 -utf8_estonian_ci utf8 -utf8_general_ci utf8 -utf8_hungarian_ci utf8 -utf8_icelandic_ci utf8 -utf8_latvian_ci utf8 -utf8_lithuanian_ci utf8 -utf8_persian_ci utf8 -utf8_polish_ci utf8 -utf8_romanian_ci utf8 -utf8_roman_ci utf8 -utf8_slovak_ci utf8 -utf8_slovenian_ci utf8 -utf8_spanish2_ci utf8 -utf8_spanish_ci utf8 -utf8_swedish_ci utf8 -utf8_turkish_ci utf8 -utf8_unicode_ci utf8 -# Switch to connection default + disconnect con -DROP USER dbdict_test@localhost; diff --git a/mysql-test/suite/funcs_1/r/charset_collation_2.result b/mysql-test/suite/funcs_1/r/charset_collation_2.result deleted file mode 100644 index a9fb15a588c..00000000000 --- a/mysql-test/suite/funcs_1/r/charset_collation_2.result +++ /dev/null @@ -1,314 +0,0 @@ -DROP USER dbdict_test@localhost; -CREATE USER dbdict_test@localhost; -# Establish connection con (user=dbdict_test) - -SELECT * -FROM information_schema.character_sets -ORDER BY character_set_name; -CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN -armscii8 armscii8_general_ci ARMSCII-8 Armenian 1 -ascii ascii_general_ci US ASCII 1 -big5 big5_chinese_ci Big5 Traditional Chinese 2 -binary binary Binary pseudo charset 1 -cp1250 cp1250_general_ci Windows Central European 1 -cp1251 cp1251_general_ci Windows Cyrillic 1 -cp1256 cp1256_general_ci Windows Arabic 1 -cp1257 cp1257_general_ci Windows Baltic 1 -cp850 cp850_general_ci DOS West European 1 -cp852 cp852_general_ci DOS Central European 1 -cp866 cp866_general_ci DOS Russian 1 -cp932 cp932_japanese_ci SJIS for Windows Japanese 2 -dec8 dec8_swedish_ci DEC West European 1 -eucjpms eucjpms_japanese_ci UJIS for Windows Japanese 3 -euckr euckr_korean_ci EUC-KR Korean 2 -gb2312 gb2312_chinese_ci GB2312 Simplified Chinese 2 -gbk gbk_chinese_ci GBK Simplified Chinese 2 -geostd8 geostd8_general_ci GEOSTD8 Georgian 1 -greek greek_general_ci ISO 8859-7 Greek 1 -hebrew hebrew_general_ci ISO 8859-8 Hebrew 1 -hp8 hp8_english_ci HP West European 1 -keybcs2 keybcs2_general_ci DOS Kamenicky Czech-Slovak 1 -koi8r koi8r_general_ci KOI8-R Relcom Russian 1 -koi8u koi8u_general_ci KOI8-U Ukrainian 1 -latin1 latin1_swedish_ci cp1252 West European 1 -latin2 latin2_general_ci ISO 8859-2 Central European 1 -latin5 latin5_turkish_ci ISO 8859-9 Turkish 1 -latin7 latin7_general_ci ISO 8859-13 Baltic 1 -macce macce_general_ci Mac Central European 1 -macroman macroman_general_ci Mac West European 1 -sjis sjis_japanese_ci Shift-JIS Japanese 2 -swe7 swe7_swedish_ci 7bit Swedish 1 -tis620 tis620_thai_ci TIS620 Thai 1 -ucs2 ucs2_general_ci UCS-2 Unicode 2 -ujis ujis_japanese_ci EUC-JP Japanese 3 -utf8 utf8_general_ci UTF-8 Unicode 3 - -SELECT * -FROM information_schema.collations -ORDER BY collation_name; -COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN -armscii8_bin armscii8 64 0 -armscii8_general_ci armscii8 32 Yes 0 -ascii_bin ascii 65 0 -ascii_general_ci ascii 11 Yes 0 -big5_bin big5 84 Yes 1 -big5_chinese_ci big5 1 Yes Yes 1 -binary binary 63 Yes Yes 1 -cp1250_bin cp1250 66 Yes 1 -cp1250_croatian_ci cp1250 44 Yes 1 -cp1250_czech_cs cp1250 34 Yes 2 -cp1250_general_ci cp1250 26 Yes Yes 1 -cp1250_polish_ci cp1250 99 Yes 1 -cp1251_bin cp1251 50 0 -cp1251_bulgarian_ci cp1251 14 0 -cp1251_general_ci cp1251 51 Yes 0 -cp1251_general_cs cp1251 52 0 -cp1251_ukrainian_ci cp1251 23 0 -cp1256_bin cp1256 67 0 -cp1256_general_ci cp1256 57 Yes 0 -cp1257_bin cp1257 58 0 -cp1257_general_ci cp1257 59 Yes 0 -cp1257_lithuanian_ci cp1257 29 0 -cp850_bin cp850 80 0 -cp850_general_ci cp850 4 Yes 0 -cp852_bin cp852 81 0 -cp852_general_ci cp852 40 Yes 0 -cp866_bin cp866 68 0 -cp866_general_ci cp866 36 Yes 0 -cp932_bin cp932 96 Yes 1 -cp932_japanese_ci cp932 95 Yes Yes 1 -dec8_bin dec8 69 0 -dec8_swedish_ci dec8 3 Yes 0 -eucjpms_bin eucjpms 98 Yes 1 -eucjpms_japanese_ci eucjpms 97 Yes Yes 1 -euckr_bin euckr 85 Yes 1 -euckr_korean_ci euckr 19 Yes Yes 1 -gb2312_bin gb2312 86 Yes 1 -gb2312_chinese_ci gb2312 24 Yes Yes 1 -gbk_bin gbk 87 Yes 1 -gbk_chinese_ci gbk 28 Yes Yes 1 -geostd8_bin geostd8 93 0 -geostd8_general_ci geostd8 92 Yes 0 -greek_bin greek 70 0 -greek_general_ci greek 25 Yes 0 -hebrew_bin hebrew 71 0 -hebrew_general_ci hebrew 16 Yes 0 -hp8_bin hp8 72 0 -hp8_english_ci hp8 6 Yes 0 -keybcs2_bin keybcs2 73 0 -keybcs2_general_ci keybcs2 37 Yes 0 -koi8r_bin koi8r 74 0 -koi8r_general_ci koi8r 7 Yes 0 -koi8u_bin koi8u 75 0 -koi8u_general_ci koi8u 22 Yes 0 -latin1_bin latin1 47 Yes 1 -latin1_danish_ci latin1 15 Yes 1 -latin1_general_ci latin1 48 Yes 1 -latin1_general_cs latin1 49 Yes 1 -latin1_german1_ci latin1 5 Yes 1 -latin1_german2_ci latin1 31 Yes 2 -latin1_spanish_ci latin1 94 Yes 1 -latin1_swedish_ci latin1 8 Yes Yes 1 -latin2_bin latin2 77 Yes 1 -latin2_croatian_ci latin2 27 Yes 1 -latin2_czech_cs latin2 2 Yes 4 -latin2_general_ci latin2 9 Yes Yes 1 -latin2_hungarian_ci latin2 21 Yes 1 -latin5_bin latin5 78 0 -latin5_turkish_ci latin5 30 Yes 0 -latin7_bin latin7 79 0 -latin7_estonian_cs latin7 20 0 -latin7_general_ci latin7 41 Yes 0 -latin7_general_cs latin7 42 0 -macce_bin macce 43 0 -macce_general_ci macce 38 Yes 0 -macroman_bin macroman 53 0 -macroman_general_ci macroman 39 Yes 0 -sjis_bin sjis 88 Yes 1 -sjis_japanese_ci sjis 13 Yes Yes 1 -swe7_bin swe7 82 0 -swe7_swedish_ci swe7 10 Yes 0 -tis620_bin tis620 89 Yes 1 -tis620_thai_ci tis620 18 Yes Yes 4 -ucs2_bin ucs2 90 Yes 1 -ucs2_czech_ci ucs2 138 Yes 8 -ucs2_danish_ci ucs2 139 Yes 8 -ucs2_esperanto_ci ucs2 145 Yes 8 -ucs2_estonian_ci ucs2 134 Yes 8 -ucs2_general_ci ucs2 35 Yes Yes 1 -ucs2_hungarian_ci ucs2 146 Yes 8 -ucs2_icelandic_ci ucs2 129 Yes 8 -ucs2_latvian_ci ucs2 130 Yes 8 -ucs2_lithuanian_ci ucs2 140 Yes 8 -ucs2_persian_ci ucs2 144 Yes 8 -ucs2_polish_ci ucs2 133 Yes 8 -ucs2_romanian_ci ucs2 131 Yes 8 -ucs2_roman_ci ucs2 143 Yes 8 -ucs2_slovak_ci ucs2 141 Yes 8 -ucs2_slovenian_ci ucs2 132 Yes 8 -ucs2_spanish2_ci ucs2 142 Yes 8 -ucs2_spanish_ci ucs2 135 Yes 8 -ucs2_swedish_ci ucs2 136 Yes 8 -ucs2_turkish_ci ucs2 137 Yes 8 -ucs2_unicode_ci ucs2 128 Yes 8 -ujis_bin ujis 91 Yes 1 -ujis_japanese_ci ujis 12 Yes Yes 1 -utf8_bin utf8 83 Yes 1 -utf8_czech_ci utf8 202 Yes 8 -utf8_danish_ci utf8 203 Yes 8 -utf8_esperanto_ci utf8 209 Yes 8 -utf8_estonian_ci utf8 198 Yes 8 -utf8_general_ci utf8 33 Yes Yes 1 -utf8_general_cs utf8 254 Yes 1 -utf8_hungarian_ci utf8 210 Yes 8 -utf8_icelandic_ci utf8 193 Yes 8 -utf8_latvian_ci utf8 194 Yes 8 -utf8_lithuanian_ci utf8 204 Yes 8 -utf8_persian_ci utf8 208 Yes 8 -utf8_polish_ci utf8 197 Yes 8 -utf8_romanian_ci utf8 195 Yes 8 -utf8_roman_ci utf8 207 Yes 8 -utf8_slovak_ci utf8 205 Yes 8 -utf8_slovenian_ci utf8 196 Yes 8 -utf8_spanish2_ci utf8 206 Yes 8 -utf8_spanish_ci utf8 199 Yes 8 -utf8_swedish_ci utf8 200 Yes 8 -utf8_turkish_ci utf8 201 Yes 8 -utf8_unicode_ci utf8 192 Yes 8 - - -SELECT * -FROM information_schema.collation_character_set_applicability -ORDER BY collation_name, character_set_name; -COLLATION_NAME CHARACTER_SET_NAME -armscii8_bin armscii8 -armscii8_general_ci armscii8 -ascii_bin ascii -ascii_general_ci ascii -big5_bin big5 -big5_chinese_ci big5 -binary binary -cp1250_bin cp1250 -cp1250_croatian_ci cp1250 -cp1250_czech_cs cp1250 -cp1250_general_ci cp1250 -cp1250_polish_ci cp1250 -cp1251_bin cp1251 -cp1251_bulgarian_ci cp1251 -cp1251_general_ci cp1251 -cp1251_general_cs cp1251 -cp1251_ukrainian_ci cp1251 -cp1256_bin cp1256 -cp1256_general_ci cp1256 -cp1257_bin cp1257 -cp1257_general_ci cp1257 -cp1257_lithuanian_ci cp1257 -cp850_bin cp850 -cp850_general_ci cp850 -cp852_bin cp852 -cp852_general_ci cp852 -cp866_bin cp866 -cp866_general_ci cp866 -cp932_bin cp932 -cp932_japanese_ci cp932 -dec8_bin dec8 -dec8_swedish_ci dec8 -eucjpms_bin eucjpms -eucjpms_japanese_ci eucjpms -euckr_bin euckr -euckr_korean_ci euckr -filename filename -gb2312_bin gb2312 -gb2312_chinese_ci gb2312 -gbk_bin gbk -gbk_chinese_ci gbk -geostd8_bin geostd8 -geostd8_general_ci geostd8 -greek_bin greek -greek_general_ci greek -hebrew_bin hebrew -hebrew_general_ci hebrew -hp8_bin hp8 -hp8_english_ci hp8 -keybcs2_bin keybcs2 -keybcs2_general_ci keybcs2 -koi8r_bin koi8r -koi8r_general_ci koi8r -koi8u_bin koi8u -koi8u_general_ci koi8u -latin1_bin latin1 -latin1_danish_ci latin1 -latin1_general_ci latin1 -latin1_general_cs latin1 -latin1_german1_ci latin1 -latin1_german2_ci latin1 -latin1_spanish_ci latin1 -latin1_swedish_ci latin1 -latin2_bin latin2 -latin2_croatian_ci latin2 -latin2_czech_cs latin2 -latin2_general_ci latin2 -latin2_hungarian_ci latin2 -latin5_bin latin5 -latin5_turkish_ci latin5 -latin7_bin latin7 -latin7_estonian_cs latin7 -latin7_general_ci latin7 -latin7_general_cs latin7 -macce_bin macce -macce_general_ci macce -macroman_bin macroman -macroman_general_ci macroman -sjis_bin sjis -sjis_japanese_ci sjis -swe7_bin swe7 -swe7_swedish_ci swe7 -tis620_bin tis620 -tis620_thai_ci tis620 -ucs2_bin ucs2 -ucs2_czech_ci ucs2 -ucs2_danish_ci ucs2 -ucs2_esperanto_ci ucs2 -ucs2_estonian_ci ucs2 -ucs2_general_ci ucs2 -ucs2_hungarian_ci ucs2 -ucs2_icelandic_ci ucs2 -ucs2_latvian_ci ucs2 -ucs2_lithuanian_ci ucs2 -ucs2_persian_ci ucs2 -ucs2_polish_ci ucs2 -ucs2_romanian_ci ucs2 -ucs2_roman_ci ucs2 -ucs2_slovak_ci ucs2 -ucs2_slovenian_ci ucs2 -ucs2_spanish2_ci ucs2 -ucs2_spanish_ci ucs2 -ucs2_swedish_ci ucs2 -ucs2_turkish_ci ucs2 -ucs2_unicode_ci ucs2 -ujis_bin ujis -ujis_japanese_ci ujis -utf8_bin utf8 -utf8_czech_ci utf8 -utf8_danish_ci utf8 -utf8_esperanto_ci utf8 -utf8_estonian_ci utf8 -utf8_general_ci utf8 -utf8_general_cs utf8 -utf8_hungarian_ci utf8 -utf8_icelandic_ci utf8 -utf8_latvian_ci utf8 -utf8_lithuanian_ci utf8 -utf8_persian_ci utf8 -utf8_polish_ci utf8 -utf8_romanian_ci utf8 -utf8_roman_ci utf8 -utf8_slovak_ci utf8 -utf8_slovenian_ci utf8 -utf8_spanish2_ci utf8 -utf8_spanish_ci utf8 -utf8_swedish_ci utf8 -utf8_turkish_ci utf8 -utf8_unicode_ci utf8 -# Switch to connection default + disconnect con -DROP USER dbdict_test@localhost; diff --git a/mysql-test/suite/funcs_1/r/charset_collation_3.result b/mysql-test/suite/funcs_1/r/charset_collation_3.result deleted file mode 100644 index 55ed4b4704c..00000000000 --- a/mysql-test/suite/funcs_1/r/charset_collation_3.result +++ /dev/null @@ -1,312 +0,0 @@ -DROP USER dbdict_test@localhost; -CREATE USER dbdict_test@localhost; -# Establish connection con (user=dbdict_test) - -SELECT * -FROM information_schema.character_sets -ORDER BY character_set_name; -CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN -armscii8 armscii8_general_ci ARMSCII-8 Armenian 1 -ascii ascii_general_ci US ASCII 1 -big5 big5_chinese_ci Big5 Traditional Chinese 2 -binary binary Binary pseudo charset 1 -cp1250 cp1250_general_ci Windows Central European 1 -cp1251 cp1251_general_ci Windows Cyrillic 1 -cp1256 cp1256_general_ci Windows Arabic 1 -cp1257 cp1257_general_ci Windows Baltic 1 -cp850 cp850_general_ci DOS West European 1 -cp852 cp852_general_ci DOS Central European 1 -cp866 cp866_general_ci DOS Russian 1 -cp932 cp932_japanese_ci SJIS for Windows Japanese 2 -dec8 dec8_swedish_ci DEC West European 1 -eucjpms eucjpms_japanese_ci UJIS for Windows Japanese 3 -euckr euckr_korean_ci EUC-KR Korean 2 -gb2312 gb2312_chinese_ci GB2312 Simplified Chinese 2 -gbk gbk_chinese_ci GBK Simplified Chinese 2 -geostd8 geostd8_general_ci GEOSTD8 Georgian 1 -greek greek_general_ci ISO 8859-7 Greek 1 -hebrew hebrew_general_ci ISO 8859-8 Hebrew 1 -hp8 hp8_english_ci HP West European 1 -keybcs2 keybcs2_general_ci DOS Kamenicky Czech-Slovak 1 -koi8r koi8r_general_ci KOI8-R Relcom Russian 1 -koi8u koi8u_general_ci KOI8-U Ukrainian 1 -latin1 latin1_swedish_ci cp1252 West European 1 -latin2 latin2_general_ci ISO 8859-2 Central European 1 -latin5 latin5_turkish_ci ISO 8859-9 Turkish 1 -latin7 latin7_general_ci ISO 8859-13 Baltic 1 -macce macce_general_ci Mac Central European 1 -macroman macroman_general_ci Mac West European 1 -sjis sjis_japanese_ci Shift-JIS Japanese 2 -swe7 swe7_swedish_ci 7bit Swedish 1 -tis620 tis620_thai_ci TIS620 Thai 1 -ucs2 ucs2_general_ci UCS-2 Unicode 2 -ujis ujis_japanese_ci EUC-JP Japanese 3 -utf8 utf8_general_ci UTF-8 Unicode 3 - -SELECT * -FROM information_schema.collations -ORDER BY collation_name; -COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN -armscii8_bin armscii8 64 0 -armscii8_general_ci armscii8 32 Yes 0 -ascii_bin ascii 65 0 -ascii_general_ci ascii 11 Yes 0 -big5_bin big5 84 Yes 1 -big5_chinese_ci big5 1 Yes Yes 1 -binary binary 63 Yes Yes 1 -cp1250_bin cp1250 66 Yes 1 -cp1250_croatian_ci cp1250 44 Yes 1 -cp1250_czech_cs cp1250 34 Yes 2 -cp1250_general_ci cp1250 26 Yes Yes 1 -cp1250_polish_ci cp1250 99 Yes 1 -cp1251_bin cp1251 50 0 -cp1251_bulgarian_ci cp1251 14 0 -cp1251_general_ci cp1251 51 Yes 0 -cp1251_general_cs cp1251 52 0 -cp1251_ukrainian_ci cp1251 23 0 -cp1256_bin cp1256 67 0 -cp1256_general_ci cp1256 57 Yes 0 -cp1257_bin cp1257 58 0 -cp1257_general_ci cp1257 59 Yes 0 -cp1257_lithuanian_ci cp1257 29 0 -cp850_bin cp850 80 0 -cp850_general_ci cp850 4 Yes 0 -cp852_bin cp852 81 0 -cp852_general_ci cp852 40 Yes 0 -cp866_bin cp866 68 0 -cp866_general_ci cp866 36 Yes 0 -cp932_bin cp932 96 Yes 1 -cp932_japanese_ci cp932 95 Yes Yes 1 -dec8_bin dec8 69 0 -dec8_swedish_ci dec8 3 Yes 0 -eucjpms_bin eucjpms 98 Yes 1 -eucjpms_japanese_ci eucjpms 97 Yes Yes 1 -euckr_bin euckr 85 Yes 1 -euckr_korean_ci euckr 19 Yes Yes 1 -gb2312_bin gb2312 86 Yes 1 -gb2312_chinese_ci gb2312 24 Yes Yes 1 -gbk_bin gbk 87 Yes 1 -gbk_chinese_ci gbk 28 Yes Yes 1 -geostd8_bin geostd8 93 0 -geostd8_general_ci geostd8 92 Yes 0 -greek_bin greek 70 0 -greek_general_ci greek 25 Yes 0 -hebrew_bin hebrew 71 0 -hebrew_general_ci hebrew 16 Yes 0 -hp8_bin hp8 72 0 -hp8_english_ci hp8 6 Yes 0 -keybcs2_bin keybcs2 73 0 -keybcs2_general_ci keybcs2 37 Yes 0 -koi8r_bin koi8r 74 0 -koi8r_general_ci koi8r 7 Yes 0 -koi8u_bin koi8u 75 0 -koi8u_general_ci koi8u 22 Yes 0 -latin1_bin latin1 47 Yes 1 -latin1_danish_ci latin1 15 Yes 1 -latin1_general_ci latin1 48 Yes 1 -latin1_general_cs latin1 49 Yes 1 -latin1_german1_ci latin1 5 Yes 1 -latin1_german2_ci latin1 31 Yes 2 -latin1_spanish_ci latin1 94 Yes 1 -latin1_swedish_ci latin1 8 Yes Yes 1 -latin2_bin latin2 77 Yes 1 -latin2_croatian_ci latin2 27 Yes 1 -latin2_czech_cs latin2 2 Yes 4 -latin2_general_ci latin2 9 Yes Yes 1 -latin2_hungarian_ci latin2 21 Yes 1 -latin5_bin latin5 78 0 -latin5_turkish_ci latin5 30 Yes 0 -latin7_bin latin7 79 0 -latin7_estonian_cs latin7 20 0 -latin7_general_ci latin7 41 Yes 0 -latin7_general_cs latin7 42 0 -macce_bin macce 43 0 -macce_general_ci macce 38 Yes 0 -macroman_bin macroman 53 0 -macroman_general_ci macroman 39 Yes 0 -sjis_bin sjis 88 Yes 1 -sjis_japanese_ci sjis 13 Yes Yes 1 -swe7_bin swe7 82 0 -swe7_swedish_ci swe7 10 Yes 0 -tis620_bin tis620 89 Yes 1 -tis620_thai_ci tis620 18 Yes Yes 4 -ucs2_bin ucs2 90 Yes 1 -ucs2_czech_ci ucs2 138 Yes 8 -ucs2_danish_ci ucs2 139 Yes 8 -ucs2_esperanto_ci ucs2 145 Yes 8 -ucs2_estonian_ci ucs2 134 Yes 8 -ucs2_general_ci ucs2 35 Yes Yes 1 -ucs2_hungarian_ci ucs2 146 Yes 8 -ucs2_icelandic_ci ucs2 129 Yes 8 -ucs2_latvian_ci ucs2 130 Yes 8 -ucs2_lithuanian_ci ucs2 140 Yes 8 -ucs2_persian_ci ucs2 144 Yes 8 -ucs2_polish_ci ucs2 133 Yes 8 -ucs2_romanian_ci ucs2 131 Yes 8 -ucs2_roman_ci ucs2 143 Yes 8 -ucs2_slovak_ci ucs2 141 Yes 8 -ucs2_slovenian_ci ucs2 132 Yes 8 -ucs2_spanish2_ci ucs2 142 Yes 8 -ucs2_spanish_ci ucs2 135 Yes 8 -ucs2_swedish_ci ucs2 136 Yes 8 -ucs2_turkish_ci ucs2 137 Yes 8 -ucs2_unicode_ci ucs2 128 Yes 8 -ujis_bin ujis 91 Yes 1 -ujis_japanese_ci ujis 12 Yes Yes 1 -utf8_bin utf8 83 Yes 1 -utf8_czech_ci utf8 202 Yes 8 -utf8_danish_ci utf8 203 Yes 8 -utf8_esperanto_ci utf8 209 Yes 8 -utf8_estonian_ci utf8 198 Yes 8 -utf8_general_ci utf8 33 Yes Yes 1 -utf8_hungarian_ci utf8 210 Yes 8 -utf8_icelandic_ci utf8 193 Yes 8 -utf8_latvian_ci utf8 194 Yes 8 -utf8_lithuanian_ci utf8 204 Yes 8 -utf8_persian_ci utf8 208 Yes 8 -utf8_polish_ci utf8 197 Yes 8 -utf8_romanian_ci utf8 195 Yes 8 -utf8_roman_ci utf8 207 Yes 8 -utf8_slovak_ci utf8 205 Yes 8 -utf8_slovenian_ci utf8 196 Yes 8 -utf8_spanish2_ci utf8 206 Yes 8 -utf8_spanish_ci utf8 199 Yes 8 -utf8_swedish_ci utf8 200 Yes 8 -utf8_turkish_ci utf8 201 Yes 8 -utf8_unicode_ci utf8 192 Yes 8 - - -SELECT * -FROM information_schema.collation_character_set_applicability -ORDER BY collation_name, character_set_name; -COLLATION_NAME CHARACTER_SET_NAME -armscii8_bin armscii8 -armscii8_general_ci armscii8 -ascii_bin ascii -ascii_general_ci ascii -big5_bin big5 -big5_chinese_ci big5 -binary binary -cp1250_bin cp1250 -cp1250_croatian_ci cp1250 -cp1250_czech_cs cp1250 -cp1250_general_ci cp1250 -cp1250_polish_ci cp1250 -cp1251_bin cp1251 -cp1251_bulgarian_ci cp1251 -cp1251_general_ci cp1251 -cp1251_general_cs cp1251 -cp1251_ukrainian_ci cp1251 -cp1256_bin cp1256 -cp1256_general_ci cp1256 -cp1257_bin cp1257 -cp1257_general_ci cp1257 -cp1257_lithuanian_ci cp1257 -cp850_bin cp850 -cp850_general_ci cp850 -cp852_bin cp852 -cp852_general_ci cp852 -cp866_bin cp866 -cp866_general_ci cp866 -cp932_bin cp932 -cp932_japanese_ci cp932 -dec8_bin dec8 -dec8_swedish_ci dec8 -eucjpms_bin eucjpms -eucjpms_japanese_ci eucjpms -euckr_bin euckr -euckr_korean_ci euckr -filename filename -gb2312_bin gb2312 -gb2312_chinese_ci gb2312 -gbk_bin gbk -gbk_chinese_ci gbk -geostd8_bin geostd8 -geostd8_general_ci geostd8 -greek_bin greek -greek_general_ci greek -hebrew_bin hebrew -hebrew_general_ci hebrew -hp8_bin hp8 -hp8_english_ci hp8 -keybcs2_bin keybcs2 -keybcs2_general_ci keybcs2 -koi8r_bin koi8r -koi8r_general_ci koi8r -koi8u_bin koi8u -koi8u_general_ci koi8u -latin1_bin latin1 -latin1_danish_ci latin1 -latin1_general_ci latin1 -latin1_general_cs latin1 -latin1_german1_ci latin1 -latin1_german2_ci latin1 -latin1_spanish_ci latin1 -latin1_swedish_ci latin1 -latin2_bin latin2 -latin2_croatian_ci latin2 -latin2_czech_cs latin2 -latin2_general_ci latin2 -latin2_hungarian_ci latin2 -latin5_bin latin5 -latin5_turkish_ci latin5 -latin7_bin latin7 -latin7_estonian_cs latin7 -latin7_general_ci latin7 -latin7_general_cs latin7 -macce_bin macce -macce_general_ci macce -macroman_bin macroman -macroman_general_ci macroman -sjis_bin sjis -sjis_japanese_ci sjis -swe7_bin swe7 -swe7_swedish_ci swe7 -tis620_bin tis620 -tis620_thai_ci tis620 -ucs2_bin ucs2 -ucs2_czech_ci ucs2 -ucs2_danish_ci ucs2 -ucs2_esperanto_ci ucs2 -ucs2_estonian_ci ucs2 -ucs2_general_ci ucs2 -ucs2_hungarian_ci ucs2 -ucs2_icelandic_ci ucs2 -ucs2_latvian_ci ucs2 -ucs2_lithuanian_ci ucs2 -ucs2_persian_ci ucs2 -ucs2_polish_ci ucs2 -ucs2_romanian_ci ucs2 -ucs2_roman_ci ucs2 -ucs2_slovak_ci ucs2 -ucs2_slovenian_ci ucs2 -ucs2_spanish2_ci ucs2 -ucs2_spanish_ci ucs2 -ucs2_swedish_ci ucs2 -ucs2_turkish_ci ucs2 -ucs2_unicode_ci ucs2 -ujis_bin ujis -ujis_japanese_ci ujis -utf8_bin utf8 -utf8_czech_ci utf8 -utf8_danish_ci utf8 -utf8_esperanto_ci utf8 -utf8_estonian_ci utf8 -utf8_general_ci utf8 -utf8_hungarian_ci utf8 -utf8_icelandic_ci utf8 -utf8_latvian_ci utf8 -utf8_lithuanian_ci utf8 -utf8_persian_ci utf8 -utf8_polish_ci utf8 -utf8_romanian_ci utf8 -utf8_roman_ci utf8 -utf8_slovak_ci utf8 -utf8_slovenian_ci utf8 -utf8_spanish2_ci utf8 -utf8_spanish_ci utf8 -utf8_swedish_ci utf8 -utf8_turkish_ci utf8 -utf8_unicode_ci utf8 -# Switch to connection default + disconnect con -DROP USER dbdict_test@localhost; diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result index d5e1309e39f..59ad695c413 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result @@ -166,7 +166,7 @@ NULL information_schema PROCESSLIST HOST 3 NO varchar 64 192 NULL NULL utf8 utf NULL information_schema PROCESSLIST ID 1 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4) NULL information_schema PROCESSLIST INFO 8 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext NULL information_schema PROCESSLIST STATE 7 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) -NULL information_schema PROCESSLIST TIME 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(7) +NULL information_schema PROCESSLIST TIME 6 0 NO int NULL NULL 10 0 NULL NULL int(7) NULL information_schema PROCESSLIST USER 2 NO varchar 16 48 NULL NULL utf8 utf8_general_ci varchar(16) NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) @@ -340,6 +340,7 @@ ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML; COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME NULL bigint NULL NULL NULL datetime NULL NULL +NULL int NULL NULL --> CHAR(0) is allowed (see manual), and here both CHARACHTER_* values --> are 0, which is intended behavior, and the result of 0 / 0 IS NULL SELECT CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML, @@ -519,7 +520,7 @@ NULL information_schema PROCESSLIST ID bigint NULL NULL NULL NULL bigint(4) 3.0000 information_schema PROCESSLIST HOST varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema PROCESSLIST DB varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema PROCESSLIST COMMAND varchar 16 48 utf8 utf8_general_ci varchar(16) -NULL information_schema PROCESSLIST TIME bigint NULL NULL NULL NULL bigint(7) +NULL information_schema PROCESSLIST TIME int NULL NULL NULL NULL int(7) 3.0000 information_schema PROCESSLIST STATE varchar 64 192 utf8 utf8_general_ci varchar(64) 1.0000 information_schema PROCESSLIST INFO longtext 4294967295 4294967295 utf8 utf8_general_ci longtext 3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) diff --git a/mysql-test/suite/funcs_1/r/is_columns_myisam_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_myisam_embedded.result index d22c5cc06f7..2721dcf3c6e 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_myisam_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_myisam_embedded.result @@ -514,7 +514,7 @@ NULL test tb1 f6 6 NULL YES mediumtext 16777215 16777215 NULL NULL latin1 latin1 NULL test tb1 f7 7 NULL YES longtext 4294967295 4294967295 NULL NULL latin1 latin1_swedish_ci longtext NULL test tb1 f8 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL tinyblob NULL test tb1 f9 9 NULL YES blob 65535 65535 NULL NULL NULL NULL blob -NULL test tb2 f100 42 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill NULL test tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date NULL test tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time NULL test tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime @@ -547,32 +547,32 @@ NULL test tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) u NULL test tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill NULL test tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill NULL test tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double -NULL test tb2 f74 16 NULL YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned -NULL test tb2 f75 17 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill -NULL test tb2 f76 18 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned +NULL test tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill NULL test tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double -NULL test tb2 f78 20 7.7 YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned -NULL test tb2 f79 21 00000000000000000007.7 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill -NULL test tb2 f80 22 00000000000000000008.8 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned +NULL test tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill NULL test tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float -NULL test tb2 f82 24 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned -NULL test tb2 f83 25 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test tb2 f84 26 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned +NULL test tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill NULL test tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float NULL test tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float -NULL test tb2 f87 29 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned -NULL test tb2 f88 30 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned -NULL test tb2 f89 31 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test tb2 f90 32 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test tb2 f91 33 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test tb2 f92 34 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned +NULL test tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned +NULL test tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill NULL test tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float NULL test tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double -NULL test tb2 f95 37 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned -NULL test tb2 f96 38 8.8 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned -NULL test tb2 f97 39 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test tb2 f98 40 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill -NULL test tb2 f99 41 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned +NULL test tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned +NULL test tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill NULL test tb3 f118 1 a NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) NULL test tb3 f119 2 NO char 1 1 NULL NULL latin1 latin1_bin char(1) NULL test tb3 f120 3 NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) @@ -646,33 +646,33 @@ NULL test tb4 f187 12 000000000000000000000000000000009.000000000000000000000000 NULL test tb4 f188 13 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill NULL test tb4 f189 14 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill NULL test tb4 f190 15 88.8 NO double NULL NULL 22 NULL NULL NULL double -NULL test tb4 f191 16 88.8 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned -NULL test tb4 f192 17 00000000000000000088.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill -NULL test tb4 f193 18 00000000000000000088.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test tb4 f191 16 88.8 NO double NULL NULL 22 NULL NULL NULL double unsigned +NULL test tb4 f192 17 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test tb4 f193 18 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill NULL test tb4 f194 19 55.5 NO double NULL NULL 22 NULL NULL NULL double -NULL test tb4 f195 20 55.5 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned -NULL test tb4 f196 21 00000000000000000055.5 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill -NULL test tb4 f197 22 00000000000000000055.5 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test tb4 f195 20 55.5 NO double NULL NULL 22 NULL NULL NULL double unsigned +NULL test tb4 f196 21 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test tb4 f197 22 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill NULL test tb4 f198 23 NULL YES float NULL NULL 12 NULL NULL NULL float -NULL test tb4 f199 24 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned -NULL test tb4 f200 25 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test tb4 f201 26 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb4 f199 24 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned +NULL test tb4 f200 25 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb4 f201 26 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill NULL test tb4 f202 27 NULL YES float NULL NULL 12 NULL NULL NULL float NULL test tb4 f203 28 NULL YES float NULL NULL 12 NULL NULL NULL float -NULL test tb4 f204 29 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned -NULL test tb4 f205 30 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned -NULL test tb4 f206 31 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test tb4 f207 32 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test tb4 f208 33 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test tb4 f209 34 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb4 f204 29 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned +NULL test tb4 f205 30 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned +NULL test tb4 f206 31 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb4 f207 32 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb4 f208 33 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb4 f209 34 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill NULL test tb4 f210 35 NULL YES float NULL NULL 12 NULL NULL NULL float NULL test tb4 f211 36 NULL YES double NULL NULL 22 NULL NULL NULL double -NULL test tb4 f212 37 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned -NULL test tb4 f213 38 NULL YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned -NULL test tb4 f214 39 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test tb4 f215 40 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill -NULL test tb4 f216 41 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test tb4 f212 37 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned +NULL test tb4 f213 38 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned +NULL test tb4 f214 39 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb4 f215 40 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test tb4 f216 41 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test tb4 f217 42 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime @@ -698,7 +698,7 @@ NULL test tb4 f239 64 NULL YES varbinary 1000 1000 NULL NULL NULL NULL varbinary NULL test tb4 f240 65 NULL YES varchar 120 120 NULL NULL latin1 latin1_swedish_ci varchar(120) NULL test tb4 f241 66 NULL YES char 100 100 NULL NULL latin1 latin1_swedish_ci char(100) NULL test tb4 f242 67 NULL YES bit NULL NULL 30 NULL NULL NULL bit(30) -NULL test1 tb2 f100 42 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test1 tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill NULL test1 tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date NULL test1 tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time NULL test1 tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime @@ -731,32 +731,32 @@ NULL test1 tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) NULL test1 tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill NULL test1 tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill NULL test1 tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double -NULL test1 tb2 f74 16 NULL YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned -NULL test1 tb2 f75 17 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill -NULL test1 tb2 f76 18 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test1 tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned +NULL test1 tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test1 tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill NULL test1 tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double -NULL test1 tb2 f78 20 7.7 YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned -NULL test1 tb2 f79 21 00000000000000000007.7 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill -NULL test1 tb2 f80 22 00000000000000000008.8 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test1 tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned +NULL test1 tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test1 tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill NULL test1 tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float -NULL test1 tb2 f82 24 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned -NULL test1 tb2 f83 25 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test1 tb2 f84 26 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned +NULL test1 tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill NULL test1 tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float NULL test1 tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float -NULL test1 tb2 f87 29 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned -NULL test1 tb2 f88 30 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned -NULL test1 tb2 f89 31 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test1 tb2 f90 32 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test1 tb2 f91 33 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test1 tb2 f92 34 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned +NULL test1 tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned +NULL test1 tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill NULL test1 tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float NULL test1 tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double -NULL test1 tb2 f95 37 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned -NULL test1 tb2 f96 38 8.8 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned -NULL test1 tb2 f97 39 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill -NULL test1 tb2 f98 40 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill -NULL test1 tb2 f99 41 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned +NULL test1 tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned +NULL test1 tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill +NULL test1 tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill NULL test4 t6 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) NULL test4 t6 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) NULL test4 t6 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date @@ -817,11 +817,7 @@ NULL date NULL NULL NULL datetime NULL NULL NULL decimal NULL NULL NULL double NULL NULL -NULL double unsigned NULL NULL -NULL double unsigned zerofill NULL NULL NULL float NULL NULL -NULL float unsigned NULL NULL -NULL float unsigned zerofill NULL NULL NULL int NULL NULL NULL mediumint NULL NULL NULL smallint NULL NULL @@ -963,33 +959,33 @@ NULL test tb2 f70 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill NULL test tb2 f71 decimal NULL NULL NULL NULL decimal(10,0) unsigned zerofill NULL test tb2 f72 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill NULL test tb2 f73 double NULL NULL NULL NULL double -NULL test tb2 f74 double unsigned NULL NULL NULL NULL double unsigned -NULL test tb2 f75 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill -NULL test tb2 f76 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill +NULL test tb2 f74 double NULL NULL NULL NULL double unsigned +NULL test tb2 f75 double NULL NULL NULL NULL double unsigned zerofill +NULL test tb2 f76 double NULL NULL NULL NULL double unsigned zerofill NULL test tb2 f77 double NULL NULL NULL NULL double -NULL test tb2 f78 double unsigned NULL NULL NULL NULL double unsigned -NULL test tb2 f79 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill -NULL test tb2 f80 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill +NULL test tb2 f78 double NULL NULL NULL NULL double unsigned +NULL test tb2 f79 double NULL NULL NULL NULL double unsigned zerofill +NULL test tb2 f80 double NULL NULL NULL NULL double unsigned zerofill NULL test tb2 f81 float NULL NULL NULL NULL float -NULL test tb2 f82 float unsigned NULL NULL NULL NULL float unsigned -NULL test tb2 f83 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test tb2 f84 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill +NULL test tb2 f82 float NULL NULL NULL NULL float unsigned +NULL test tb2 f83 float NULL NULL NULL NULL float unsigned zerofill +NULL test tb2 f84 float NULL NULL NULL NULL float unsigned zerofill NULL test tb2 f85 float NULL NULL NULL NULL float NULL test tb2 f86 float NULL NULL NULL NULL float -NULL test tb2 f87 float unsigned NULL NULL NULL NULL float unsigned -NULL test tb2 f88 float unsigned NULL NULL NULL NULL float unsigned -NULL test tb2 f89 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test tb2 f90 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test tb2 f91 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test tb2 f92 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill +NULL test tb2 f87 float NULL NULL NULL NULL float unsigned +NULL test tb2 f88 float NULL NULL NULL NULL float unsigned +NULL test tb2 f89 float NULL NULL NULL NULL float unsigned zerofill +NULL test tb2 f90 float NULL NULL NULL NULL float unsigned zerofill +NULL test tb2 f91 float NULL NULL NULL NULL float unsigned zerofill +NULL test tb2 f92 float NULL NULL NULL NULL float unsigned zerofill NULL test tb2 f93 float NULL NULL NULL NULL float NULL test tb2 f94 double NULL NULL NULL NULL double -NULL test tb2 f95 float unsigned NULL NULL NULL NULL float unsigned -NULL test tb2 f96 double unsigned NULL NULL NULL NULL double unsigned -NULL test tb2 f97 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test tb2 f98 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill -NULL test tb2 f99 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test tb2 f100 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill +NULL test tb2 f95 float NULL NULL NULL NULL float unsigned +NULL test tb2 f96 double NULL NULL NULL NULL double unsigned +NULL test tb2 f97 float NULL NULL NULL NULL float unsigned zerofill +NULL test tb2 f98 double NULL NULL NULL NULL double unsigned zerofill +NULL test tb2 f99 float NULL NULL NULL NULL float unsigned zerofill +NULL test tb2 f100 double NULL NULL NULL NULL double unsigned zerofill NULL test tb2 f101 date NULL NULL NULL NULL date NULL test tb2 f102 time NULL NULL NULL NULL time NULL test tb2 f103 datetime NULL NULL NULL NULL datetime @@ -1080,33 +1076,33 @@ NULL test tb4 f187 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill NULL test tb4 f188 decimal NULL NULL NULL NULL decimal(10,0) unsigned zerofill NULL test tb4 f189 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill NULL test tb4 f190 double NULL NULL NULL NULL double -NULL test tb4 f191 double unsigned NULL NULL NULL NULL double unsigned -NULL test tb4 f192 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill -NULL test tb4 f193 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill +NULL test tb4 f191 double NULL NULL NULL NULL double unsigned +NULL test tb4 f192 double NULL NULL NULL NULL double unsigned zerofill +NULL test tb4 f193 double NULL NULL NULL NULL double unsigned zerofill NULL test tb4 f194 double NULL NULL NULL NULL double -NULL test tb4 f195 double unsigned NULL NULL NULL NULL double unsigned -NULL test tb4 f196 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill -NULL test tb4 f197 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill +NULL test tb4 f195 double NULL NULL NULL NULL double unsigned +NULL test tb4 f196 double NULL NULL NULL NULL double unsigned zerofill +NULL test tb4 f197 double NULL NULL NULL NULL double unsigned zerofill NULL test tb4 f198 float NULL NULL NULL NULL float -NULL test tb4 f199 float unsigned NULL NULL NULL NULL float unsigned -NULL test tb4 f200 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test tb4 f201 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill +NULL test tb4 f199 float NULL NULL NULL NULL float unsigned +NULL test tb4 f200 float NULL NULL NULL NULL float unsigned zerofill +NULL test tb4 f201 float NULL NULL NULL NULL float unsigned zerofill NULL test tb4 f202 float NULL NULL NULL NULL float NULL test tb4 f203 float NULL NULL NULL NULL float -NULL test tb4 f204 float unsigned NULL NULL NULL NULL float unsigned -NULL test tb4 f205 float unsigned NULL NULL NULL NULL float unsigned -NULL test tb4 f206 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test tb4 f207 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test tb4 f208 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test tb4 f209 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill +NULL test tb4 f204 float NULL NULL NULL NULL float unsigned +NULL test tb4 f205 float NULL NULL NULL NULL float unsigned +NULL test tb4 f206 float NULL NULL NULL NULL float unsigned zerofill +NULL test tb4 f207 float NULL NULL NULL NULL float unsigned zerofill +NULL test tb4 f208 float NULL NULL NULL NULL float unsigned zerofill +NULL test tb4 f209 float NULL NULL NULL NULL float unsigned zerofill NULL test tb4 f210 float NULL NULL NULL NULL float NULL test tb4 f211 double NULL NULL NULL NULL double -NULL test tb4 f212 float unsigned NULL NULL NULL NULL float unsigned -NULL test tb4 f213 double unsigned NULL NULL NULL NULL double unsigned -NULL test tb4 f214 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test tb4 f215 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill -NULL test tb4 f216 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test tb4 f217 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill +NULL test tb4 f212 float NULL NULL NULL NULL float unsigned +NULL test tb4 f213 double NULL NULL NULL NULL double unsigned +NULL test tb4 f214 float NULL NULL NULL NULL float unsigned zerofill +NULL test tb4 f215 double NULL NULL NULL NULL double unsigned zerofill +NULL test tb4 f216 float NULL NULL NULL NULL float unsigned zerofill +NULL test tb4 f217 double NULL NULL NULL NULL double unsigned zerofill NULL test tb4 f218 date NULL NULL NULL NULL date NULL test tb4 f219 time NULL NULL NULL NULL time NULL test tb4 f220 datetime NULL NULL NULL NULL datetime @@ -1147,33 +1143,33 @@ NULL test1 tb2 f70 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill NULL test1 tb2 f71 decimal NULL NULL NULL NULL decimal(10,0) unsigned zerofill NULL test1 tb2 f72 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill NULL test1 tb2 f73 double NULL NULL NULL NULL double -NULL test1 tb2 f74 double unsigned NULL NULL NULL NULL double unsigned -NULL test1 tb2 f75 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill -NULL test1 tb2 f76 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill +NULL test1 tb2 f74 double NULL NULL NULL NULL double unsigned +NULL test1 tb2 f75 double NULL NULL NULL NULL double unsigned zerofill +NULL test1 tb2 f76 double NULL NULL NULL NULL double unsigned zerofill NULL test1 tb2 f77 double NULL NULL NULL NULL double -NULL test1 tb2 f78 double unsigned NULL NULL NULL NULL double unsigned -NULL test1 tb2 f79 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill -NULL test1 tb2 f80 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill +NULL test1 tb2 f78 double NULL NULL NULL NULL double unsigned +NULL test1 tb2 f79 double NULL NULL NULL NULL double unsigned zerofill +NULL test1 tb2 f80 double NULL NULL NULL NULL double unsigned zerofill NULL test1 tb2 f81 float NULL NULL NULL NULL float -NULL test1 tb2 f82 float unsigned NULL NULL NULL NULL float unsigned -NULL test1 tb2 f83 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test1 tb2 f84 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f82 float NULL NULL NULL NULL float unsigned +NULL test1 tb2 f83 float NULL NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f84 float NULL NULL NULL NULL float unsigned zerofill NULL test1 tb2 f85 float NULL NULL NULL NULL float NULL test1 tb2 f86 float NULL NULL NULL NULL float -NULL test1 tb2 f87 float unsigned NULL NULL NULL NULL float unsigned -NULL test1 tb2 f88 float unsigned NULL NULL NULL NULL float unsigned -NULL test1 tb2 f89 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test1 tb2 f90 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test1 tb2 f91 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test1 tb2 f92 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f87 float NULL NULL NULL NULL float unsigned +NULL test1 tb2 f88 float NULL NULL NULL NULL float unsigned +NULL test1 tb2 f89 float NULL NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f90 float NULL NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f91 float NULL NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f92 float NULL NULL NULL NULL float unsigned zerofill NULL test1 tb2 f93 float NULL NULL NULL NULL float NULL test1 tb2 f94 double NULL NULL NULL NULL double -NULL test1 tb2 f95 float unsigned NULL NULL NULL NULL float unsigned -NULL test1 tb2 f96 double unsigned NULL NULL NULL NULL double unsigned -NULL test1 tb2 f97 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test1 tb2 f98 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill -NULL test1 tb2 f99 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill -NULL test1 tb2 f100 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill +NULL test1 tb2 f95 float NULL NULL NULL NULL float unsigned +NULL test1 tb2 f96 double NULL NULL NULL NULL double unsigned +NULL test1 tb2 f97 float NULL NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f98 double NULL NULL NULL NULL double unsigned zerofill +NULL test1 tb2 f99 float NULL NULL NULL NULL float unsigned zerofill +NULL test1 tb2 f100 double NULL NULL NULL NULL double unsigned zerofill NULL test1 tb2 f101 date NULL NULL NULL NULL date NULL test1 tb2 f102 time NULL NULL NULL NULL time NULL test1 tb2 f103 datetime NULL NULL NULL NULL datetime diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result index 1d37a87f868..9c9d3cd26de 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result @@ -48,7 +48,7 @@ NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL NULL NUL NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp NULL mysql event name 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI NULL mysql event on_completion 14 DROP NO enum 8 24 NULL NULL utf8 utf8_general_ci enum('DROP','PRESERVE') -NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL int(10) +NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned NULL mysql event sql_mode 15 NO set 478 1434 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime NULL mysql event status 13 ENABLED NO enum 18 54 NULL NULL utf8 utf8_general_ci enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') @@ -60,7 +60,7 @@ NULL mysql func type 4 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('fu NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP -NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(11) +NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(11) NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned PRI @@ -150,7 +150,7 @@ NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL NULL NULL time NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL NULL NULL time NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL int(11) NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL int(11) -NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(11) +NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext @@ -329,7 +329,7 @@ NULL mysql event ends datetime NULL NULL NULL NULL datetime 3.0000 mysql event on_completion enum 8 24 utf8 utf8_general_ci enum('DROP','PRESERVE') 3.0000 mysql event sql_mode set 478 1434 utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') 3.0000 mysql event comment char 64 192 utf8 utf8_bin char(64) -NULL mysql event originator int NULL NULL NULL NULL int(10) +NULL mysql event originator int NULL NULL NULL NULL int(10) unsigned 1.0000 mysql event time_zone char 64 64 latin1 latin1_swedish_ci char(64) 3.0000 mysql event character_set_client char 32 96 utf8 utf8_bin char(32) 3.0000 mysql event collation_connection char 32 96 utf8 utf8_bin char(32) @@ -342,7 +342,7 @@ NULL mysql func ret tinyint NULL NULL NULL NULL tinyint(1) NULL mysql general_log event_time timestamp NULL NULL NULL NULL timestamp 1.0000 mysql general_log user_host mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext NULL mysql general_log thread_id int NULL NULL NULL NULL int(11) -NULL mysql general_log server_id int NULL NULL NULL NULL int(11) +NULL mysql general_log server_id int NULL NULL NULL NULL int(10) unsigned 3.0000 mysql general_log command_type varchar 64 192 utf8 utf8_general_ci varchar(64) 1.0000 mysql general_log argument mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext NULL mysql help_category help_category_id smallint NULL NULL NULL NULL smallint(5) unsigned @@ -434,7 +434,7 @@ NULL mysql slow_log rows_examined int NULL NULL NULL NULL int(11) 3.0000 mysql slow_log db varchar 512 1536 utf8 utf8_general_ci varchar(512) NULL mysql slow_log last_insert_id int NULL NULL NULL NULL int(11) NULL mysql slow_log insert_id int NULL NULL NULL NULL int(11) -NULL mysql slow_log server_id int NULL NULL NULL NULL int(11) +NULL mysql slow_log server_id int NULL NULL NULL NULL int(10) unsigned 1.0000 mysql slow_log sql_text mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext 3.0000 mysql tables_priv Host char 60 180 utf8 utf8_bin char(60) 3.0000 mysql tables_priv Db char 64 192 utf8 utf8_bin char(64) diff --git a/mysql-test/suite/funcs_1/r/is_routines.result b/mysql-test/suite/funcs_1/r/is_routines.result index e7a900f5c0b..14a7107778c 100644 --- a/mysql-test/suite/funcs_1/r/is_routines.result +++ b/mysql-test/suite/funcs_1/r/is_routines.result @@ -111,10 +111,11 @@ CREATE FUNCTION function_for_routines() RETURNS INT RETURN 0; SELECT specific_name,routine_catalog,routine_schema,routine_name,routine_type, routine_body,external_name,external_language,parameter_style,sql_path FROM information_schema.routines -WHERE routine_catalog IS NOT NULL OR external_name IS NOT NULL +WHERE routine_schema = 'test' AND +(routine_catalog IS NOT NULL OR external_name IS NOT NULL OR external_language IS NOT NULL OR sql_path IS NOT NULL OR routine_body <> 'SQL' OR parameter_style <> 'SQL' - OR specific_name <> routine_name; + OR specific_name <> routine_name); specific_name routine_catalog routine_schema routine_name routine_type routine_body external_name external_language parameter_style sql_path DROP PROCEDURE sp_for_routines; DROP FUNCTION function_for_routines; diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result index 7e21ddf1544..3efb361dc82 100644 --- a/mysql-test/suite/funcs_1/r/storedproc.result +++ b/mysql-test/suite/funcs_1/r/storedproc.result @@ -18241,8 +18241,6 @@ END// CALL sp70_n(-1e+40); f1 -10000000000000000000000000000000000000000 -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 CALL sp70_n( -10000000000000000000000000000000000000000 ); f1 -10000000000000000000000000000000000000000 @@ -18255,8 +18253,6 @@ END// CALL sp71_nu(1.00e+40); f1 10000000000000000000000000000000000000000 -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 CALL sp71_nu( 10000000000000000000000000000000000000000 ); f1 10000000000000000000000000000000000000000 @@ -18269,8 +18265,6 @@ END// CALL sp72_nuz(1.00e+40); f1 0000000000000000000000010000000000000000000000000000000000000000 -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 CALL sp72_nuz( 10000000000000000000000000000000000000000 ); f1 0000000000000000000000010000000000000000000000000000000000000000 @@ -18283,8 +18277,6 @@ END// CALL sp73_n_z(1.00e+40); f1 0000000000000000000000010000000000000000000000000000000000000000 -Warnings: -Note 1265 Data truncated for column 'f1' at row 1 CALL sp73_n_z( 10000000000000000000000000000000000000000 ); f1 0000000000000000000000010000000000000000000000000000000000000000 diff --git a/mysql-test/suite/funcs_1/storedproc/storedproc_06.inc b/mysql-test/suite/funcs_1/storedproc/storedproc_06.inc index d0fc6092959..f2df99fb5a3 100644 --- a/mysql-test/suite/funcs_1/storedproc/storedproc_06.inc +++ b/mysql-test/suite/funcs_1/storedproc/storedproc_06.inc @@ -53,7 +53,6 @@ flush privileges; DROP PROCEDURE IF EXISTS sp1; --enable_warnings -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (user1a, localhost, user_1, , db_storedproc_1); --source suite/funcs_1/include/show_connection.inc diff --git a/mysql-test/suite/funcs_1/storedproc/storedproc_10.inc b/mysql-test/suite/funcs_1/storedproc/storedproc_10.inc index 69378541b51..83f5f2105c5 100644 --- a/mysql-test/suite/funcs_1/storedproc/storedproc_10.inc +++ b/mysql-test/suite/funcs_1/storedproc/storedproc_10.inc @@ -58,7 +58,6 @@ GRANT CREATE ROUTINE ON db_storedproc.* TO 'user_1'@'localhost'; GRANT SELECT ON db_storedproc.* TO 'user_2'@'localhost'; FLUSH PRIVILEGES; -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (user2_1, localhost, user_1, , db_storedproc); --source suite/funcs_1/include/show_connection.inc diff --git a/mysql-test/suite/funcs_1/datadict/charset_collation.inc b/mysql-test/suite/funcs_1/t/charset_collation.test index a1991346cfc..186eb1f5b85 100644 --- a/mysql-test/suite/funcs_1/datadict/charset_collation.inc +++ b/mysql-test/suite/funcs_1/t/charset_collation.test @@ -1,58 +1,16 @@ -# suite/funcs_1/datadict/charset_collation.inc +# suite/funcs_1/t/charset_collation.test # # Tests checking the content of the information_schema tables # character_sets # collations # collation_character_set_applicability # -# -# The amount and properties of character_sets/collations depend on the -# build type -# 2007-12 MySQL 5.0, 2008-06 MySQL 5.1 -# --------------------------------------------------------------------- -# -# Variant 1 fits to -# version_comment MySQL Enterprise Server (Commercial) -# version_comment MySQL Enterprise Server (GPL) -# version_comment MySQL Classic Server (Commercial) -# version_comment MySQL Pushbuild Edition, build <number> -# (version_comment Source distribution -# and -# compile was without "max" - > no collation 'utf8_general_ci') -# -# Variant 2 fits to -# version_comment MySQL Enterprise Server (GPL) -# version_comment MySQL Classic Server (Commercial) -# version_comment MySQL Pushbuild Edition, build <number> -# (version_comment Source distribution -# and -# compile was without "max" - > collation 'utf8_general_ci' exists) -# -# Difference between variant 1 and 2 is the collation 'utf8_general_ci'. -# -# Variant 3 fits to -# version_comment MySQL Community Server (GPL) -# version_comment MySQL Cluster Server (Commercial) -# version_comment MySQL Advanced Server (GPL) 5.1 -# version_comment MySQL Advanced Server (Commercial) 5.1 -# -# Difference between variant 3 and 2 is within the collation properties -# IS_COMPILED and SORTLEN. -# -# 2008-06 All time excluded variant is "vanilla". -# How to build "vanilla": -# ./BUILD/autorun.sh -# ./configure -# ./make -# Some properties of "vanilla" -# version_comment Source distribution -# Compared to the variants 1 to 3 a lot of character sets are missing. -# Example: "ucs2_bin" is in variant 1 to 3 but not in "vanilla". -# # Created: -# 2007-12-18 mleich - remove the unstable character_set/collation subtests -# from include/datadict-master.inc -# - create this new test +# 2009-04-28 mleich Replace the charset_collation_* test which failed too often +# because of changes +# - in general available character sets and collations +# - in build types +# (Bug#40545, Bug#40209, Bug#40618, Bug#38346) # # Create a low privileged user. @@ -61,8 +19,6 @@ DROP USER dbdict_test@localhost; CREATE USER dbdict_test@localhost; --echo # Establish connection con (user=dbdict_test) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); ---replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (con,localhost,dbdict_test,,); ################################################################################ # @@ -98,32 +54,48 @@ connect (con,localhost,dbdict_test,,); # combinations for which the current user and PUBLIC have no # USAGE privilege. # -# Notes (2007-12-19 mleich): +# Notes (2009-04-28 mleich): # - The requirements are outdated because grant/revoke privilege for using a # characterset/collation were never implemented. -# Therefore the tests should simply check the content of these tables. -# +# Therefore the tests focus on the completeness and correctness of the +# content (rows and columns) of these tables. # - The amount of collations/character sets grows with new MySQL releases. -# -# - Even within the same release the amount of records within these tables +# Even within the same release the amount of records within these tables # can differ between different build types (community, enterprise, source,...) -# +# Therefore we limit the queries to character sets and collations which +# - exist in all build types +# - have in all build types the same "state". +# The character set +# - utf8 is used for Metadata +# - ascii is a quite usual +# The collations <character set>_general_ci and <character set>_bin seem +# to be available all time. # ################################################################################ + +let $char_set_condition= character_set_name IN ('utf8','latin1','binary'); +let $collation_condition= + (collation_name LIKE CONCAT(character_set_name,'_general_ci') + OR + collation_name LIKE CONCAT(character_set_name,'_bin')); --echo -SELECT * +eval SELECT * FROM information_schema.character_sets +WHERE $char_set_condition ORDER BY character_set_name; --echo -SELECT * +eval SELECT * FROM information_schema.collations +WHERE $char_set_condition + AND $collation_condition ORDER BY collation_name; -echo; --echo -SELECT * +eval SELECT * FROM information_schema.collation_character_set_applicability +WHERE $char_set_condition + AND $collation_condition ORDER BY collation_name, character_set_name; diff --git a/mysql-test/suite/funcs_1/t/charset_collation_1.test b/mysql-test/suite/funcs_1/t/charset_collation_1.test deleted file mode 100644 index 15777062a72..00000000000 --- a/mysql-test/suite/funcs_1/t/charset_collation_1.test +++ /dev/null @@ -1,32 +0,0 @@ -# Tests checking the content of the information_schema tables -# character_sets -# collations -# collation_character_set_applicability -# -# Content variant 1 which should fit to -# Enterprise or Classic builds (binaries provided by MySQL) -# Pushbuilds -# Source builds without "max" -# -# Please read suite/funcs_1/datadict/charset_collation.inc for -# additional information. -# -# Created: -# 2007-12-18 mleich - remove the unstable character_set/collation subtests -# from include/datadict-master.inc -# - create this new test -# - -if (`SELECT EXISTS (SELECT 1 FROM information_schema.collations - WHERE collation_name = 'utf8_general_cs') - OR ( @@version_comment NOT LIKE '%Source%' - AND @@version_comment NOT LIKE '%Enterprise%' - AND @@version_comment NOT LIKE '%Classic%' - AND @@version_comment NOT LIKE '%Pushbuild%') - OR (SELECT count(*) = 0 FROM information_schema.collations - WHERE collation_name = 'ucs2_bin')`) -{ - skip Test needs Enterprise, Classic , regular Pushbuild or Source-without-max build; -} - ---source suite/funcs_1/datadict/charset_collation.inc diff --git a/mysql-test/suite/funcs_1/t/charset_collation_2.test b/mysql-test/suite/funcs_1/t/charset_collation_2.test deleted file mode 100644 index d4924953b7d..00000000000 --- a/mysql-test/suite/funcs_1/t/charset_collation_2.test +++ /dev/null @@ -1,24 +0,0 @@ -# Tests checking the content of the information_schema tables -# character_sets -# collations -# collation_character_set_applicability -# -# Content variant 2 (compile from source with "max") -# -# Please read suite/funcs_1/datadict/charset_collation.inc for -# additional information. -# -# Created: -# 2007-12-18 mleich - remove the unstable character_set/collation subtests -# from include/datadict-master.inc -# - create this new test -# - -if (`SELECT @@version_comment NOT LIKE '%Source%' - OR NOT EXISTS (SELECT 1 FROM information_schema.collations - WHERE collation_name = 'utf8_general_cs')`) -{ - skip Test needs Source build with "max"; -} - ---source suite/funcs_1/datadict/charset_collation.inc diff --git a/mysql-test/suite/funcs_1/t/charset_collation_3.test b/mysql-test/suite/funcs_1/t/charset_collation_3.test deleted file mode 100644 index e88b44e4a0f..00000000000 --- a/mysql-test/suite/funcs_1/t/charset_collation_3.test +++ /dev/null @@ -1,25 +0,0 @@ -# Tests checking the content of the information_schema tables -# character_sets -# collations -# collation_character_set_applicability -# -# Content variant 3 which should fit to -# Community and Cluster builds (binaries provided by MySQL) -# -# Please read suite/funcs_1/datadict/charset_collation.inc for -# additional information. -# -# Created: -# 2007-12-18 mleich - remove the unstable character_set/collation subtests -# from include/datadict-master.inc -# - create this new test -# - -if (`SELECT @@version_comment NOT LIKE '%Community%' - AND @@version_comment NOT LIKE '%Cluster%' - AND @@version_comment NOT LIKE '%Advanced%'`) -{ - skip Test needs Community, Cluster or Advanced build; -} - ---source suite/funcs_1/datadict/charset_collation.inc diff --git a/mysql-test/suite/funcs_1/t/disabled.def b/mysql-test/suite/funcs_1/t/disabled.def index 69a69c60708..3f260ca49ba 100644 --- a/mysql-test/suite/funcs_1/t/disabled.def +++ b/mysql-test/suite/funcs_1/t/disabled.def @@ -11,6 +11,3 @@ ############################################################################## ndb_trig_1011ext: Bug#32656 NDB: Duplicate key error aborts transaction in handler. Doesn't talk back to SQL -charset_collation_1: Bug#38346, Bug#40209, Bug#40545, Bug#40618 -charset_collation_2: Bug#38346, Bug#40209, Bug#40545, Bug#40618 -charset_collation_3: Bug#38346, Bug#40209, Bug#40545, Bug#40618 diff --git a/mysql-test/suite/funcs_1/t/is_basics_mixed.test b/mysql-test/suite/funcs_1/t/is_basics_mixed.test index 7d03dc5f8b0..235b91c67d0 100644 --- a/mysql-test/suite/funcs_1/t/is_basics_mixed.test +++ b/mysql-test/suite/funcs_1/t/is_basics_mixed.test @@ -55,7 +55,6 @@ DROP USER 'testuser1'@'localhost'; CREATE USER 'testuser1'@'localhost'; # Low privileged user --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , test); SELECT DATABASE(); diff --git a/mysql-test/suite/funcs_1/t/is_column_privileges.test b/mysql-test/suite/funcs_1/t/is_column_privileges.test index 925d07b9657..cb8c50c01b7 100644 --- a/mysql-test/suite/funcs_1/t/is_column_privileges.test +++ b/mysql-test/suite/funcs_1/t/is_column_privileges.test @@ -132,7 +132,6 @@ WITH GRANT OPTION; eval $select; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict); eval $select; diff --git a/mysql-test/suite/funcs_1/t/is_column_privileges_is_mysql_test.test b/mysql-test/suite/funcs_1/t/is_column_privileges_is_mysql_test.test index 98d01c60838..33269fe929c 100644 --- a/mysql-test/suite/funcs_1/t/is_column_privileges_is_mysql_test.test +++ b/mysql-test/suite/funcs_1/t/is_column_privileges_is_mysql_test.test @@ -46,7 +46,6 @@ eval $my_show2; eval $my_show3; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict); eval $my_select; diff --git a/mysql-test/suite/funcs_1/t/is_columns.test b/mysql-test/suite/funcs_1/t/is_columns.test index 20b832ca5c3..efb52acd48c 100644 --- a/mysql-test/suite/funcs_1/t/is_columns.test +++ b/mysql-test/suite/funcs_1/t/is_columns.test @@ -148,7 +148,6 @@ eval $my_show2; eval $my_show3; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict); --source suite/funcs_1/datadict/datadict_bug_12777.inc diff --git a/mysql-test/suite/funcs_1/t/is_schema_privileges.test b/mysql-test/suite/funcs_1/t/is_schema_privileges.test index c1fc70b03f7..1f408d71b39 100644 --- a/mysql-test/suite/funcs_1/t/is_schema_privileges.test +++ b/mysql-test/suite/funcs_1/t/is_schema_privileges.test @@ -116,7 +116,6 @@ let $show_testuser1 = SHOW GRANTS FOR 'testuser1'@'localhost'; let $show_testuser2 = SHOW GRANTS FOR 'testuser2'@'localhost'; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , test); GRANT SELECT ON db_datadict_4.* TO 'testuser2'@'localhost'; diff --git a/mysql-test/suite/funcs_1/t/is_schema_privileges_is_mysql_test.test b/mysql-test/suite/funcs_1/t/is_schema_privileges_is_mysql_test.test index d7b703ed04a..3f60f71fe9a 100644 --- a/mysql-test/suite/funcs_1/t/is_schema_privileges_is_mysql_test.test +++ b/mysql-test/suite/funcs_1/t/is_schema_privileges_is_mysql_test.test @@ -46,7 +46,6 @@ eval $my_show2; eval $my_show3; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict); eval $my_select; diff --git a/mysql-test/suite/funcs_1/t/is_schemata_is_mysql_test.test b/mysql-test/suite/funcs_1/t/is_schemata_is_mysql_test.test index b5f13ab323c..9bfbf0cf335 100644 --- a/mysql-test/suite/funcs_1/t/is_schemata_is_mysql_test.test +++ b/mysql-test/suite/funcs_1/t/is_schemata_is_mysql_test.test @@ -46,7 +46,6 @@ eval $my_show2; eval $my_show3; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict); eval $my_select; diff --git a/mysql-test/suite/funcs_1/t/is_statistics.test b/mysql-test/suite/funcs_1/t/is_statistics.test index e202e7392ea..458892a6d91 100644 --- a/mysql-test/suite/funcs_1/t/is_statistics.test +++ b/mysql-test/suite/funcs_1/t/is_statistics.test @@ -140,7 +140,6 @@ eval $my_show1; eval $my_show2; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , test); # nothing visible for testuser1 diff --git a/mysql-test/suite/funcs_1/t/is_table_constraints.test b/mysql-test/suite/funcs_1/t/is_table_constraints.test index 730e805c91e..a64b3bfaa6e 100644 --- a/mysql-test/suite/funcs_1/t/is_table_constraints.test +++ b/mysql-test/suite/funcs_1/t/is_table_constraints.test @@ -132,7 +132,6 @@ eval $my_show1; eval $my_show2; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict); SHOW GRANTS FOR 'testuser1'@'localhost'; diff --git a/mysql-test/suite/funcs_1/t/is_table_privileges.test b/mysql-test/suite/funcs_1/t/is_table_privileges.test index 27ce22816a2..5ea0dd7c6a7 100644 --- a/mysql-test/suite/funcs_1/t/is_table_privileges.test +++ b/mysql-test/suite/funcs_1/t/is_table_privileges.test @@ -116,7 +116,6 @@ WHERE table_name LIKE 'tb%' ORDER BY grantee,table_schema,table_name,privilege_type; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict); --replace_result $other_engine_type <other_engine_type> diff --git a/mysql-test/suite/funcs_1/t/is_user_privileges.test b/mysql-test/suite/funcs_1/t/is_user_privileges.test index 5f8c29ca39d..1d0d3e51aae 100644 --- a/mysql-test/suite/funcs_1/t/is_user_privileges.test +++ b/mysql-test/suite/funcs_1/t/is_user_privileges.test @@ -114,7 +114,6 @@ eval $my_select1; eval $my_select2; --echo # Establish connection testuser1 (user=testuser1) -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (testuser1, localhost, testuser1, , db_datadict); eval $my_select1; diff --git a/mysql-test/suite/funcs_1/t/myisam_views.test b/mysql-test/suite/funcs_1/t/myisam_views.test index 461bc0e3549..fe72843cfaf 100644 --- a/mysql-test/suite/funcs_1/t/myisam_views.test +++ b/mysql-test/suite/funcs_1/t/myisam_views.test @@ -1,5 +1,7 @@ #### suite/funcs_1/t/myisam_views.test +--source include/no_valgrind_without_big.inc + # MyISAM tables should be used # # Set $engine_type diff --git a/mysql-test/suite/funcs_1/t/ndb_storedproc_06.tes b/mysql-test/suite/funcs_1/t/ndb_storedproc_06.tes deleted file mode 100644 index ce061da2299..00000000000 --- a/mysql-test/suite/funcs_1/t/ndb_storedproc_06.tes +++ /dev/null @@ -1,9 +0,0 @@ -#### suite/funcs_1/t/innodb_storedproc_06.test -# -# 1. Check if InnoDB is available ---source include/have_innodb.inc - -# 2. Set $engine_type -let $engine_type= innodb; - ---source suite/funcs_1/storedproc/storedproc_06.inc diff --git a/mysql-test/suite/funcs_1/t/ndb_storedproc_08.tes b/mysql-test/suite/funcs_1/t/ndb_storedproc_08.tes deleted file mode 100644 index c8c289c5f49..00000000000 --- a/mysql-test/suite/funcs_1/t/ndb_storedproc_08.tes +++ /dev/null @@ -1,9 +0,0 @@ -#### suite/funcs_1/t/innodb_storedproc_08.test -# -# 1. Check if InnoDB is available ---source include/have_innodb.inc - -# 2. Set $engine_type -let $engine_type= innodb; - ---source suite/funcs_1/storedproc/storedproc_08.inc diff --git a/mysql-test/suite/funcs_1/t/storedproc.test b/mysql-test/suite/funcs_1/t/storedproc.test index 6877b751ed2..16c4d61bf58 100644 --- a/mysql-test/suite/funcs_1/t/storedproc.test +++ b/mysql-test/suite/funcs_1/t/storedproc.test @@ -10,6 +10,17 @@ # ############################################################################ +# Bug#37746 - Arithmetic range ("int") is smaller than expected +# This code is in place to ensure this test is only skipped +# for the Win64 platform +if(`SELECT CONVERT(@@version_compile_os using latin1) IN ("Win64")`) +{ +--skip Bug#37746 2009-07-07 pcrews Arithmetic range ("int") is smaller than expected +} + + + + # This test cannot be used for the embedded server because we check here # privileges. --source include/not_embedded.inc @@ -817,7 +828,6 @@ CREATE PROCEDURE sp11() insert into mysql.t1 values('a'); --replace_column 13 created 14 modified SELECT security_type from mysql.proc where specific_name='sp11'; -let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (u_1, localhost, user_1, , db_storedproc); --source suite/funcs_1/include/show_connection.inc @@ -22430,7 +22440,9 @@ BEGIN END// delimiter ;// +--disable_warnings CALL sp70_n(-1e+40); +--enable_warnings eval CALL sp70_n( $minus_40 ); @@ -22446,7 +22458,9 @@ BEGIN END// delimiter ;// +--disable_warnings CALL sp71_nu(1.00e+40); +--enable_warnings eval CALL sp71_nu( $plus_40 ); @@ -22462,7 +22476,9 @@ BEGIN END// delimiter ;// +--disable_warnings CALL sp72_nuz(1.00e+40); +--enable_warnings eval CALL sp72_nuz( $plus_40 ); @@ -22478,7 +22494,9 @@ BEGIN END// delimiter ;// +--disable_warnings CALL sp73_n_z(1.00e+40); +--enable_warnings eval CALL sp73_n_z( $plus_40 ); diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03.inc b/mysql-test/suite/funcs_1/triggers/triggers_03.inc index e5bea5b2005..9ef6a9ac9af 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03.inc @@ -62,7 +62,6 @@ let $message= Testcase 3.5.3.2/6:; grant SELECT on priv_db.t1 to test_yesprivs@localhost; show grants for test_yesprivs@localhost; - let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK connect (no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_columns.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_columns.inc index 60928ba8f35..475063587d4 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_columns.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_columns.inc @@ -36,7 +36,6 @@ let $message= ####### Testcase for column privileges of triggers: #######; grant SELECT,UPDATE on priv_db.* to test_noprivs@localhost; show grants for test_noprivs@localhost; - let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_db_level.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_db_level.inc index cb9d8ddc78b..e5933eb84a8 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_db_level.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_db_level.inc @@ -37,7 +37,6 @@ let $message= Testcase for db level:; show grants for test_noprivs@localhost; # no trigger privilege->create trigger must fail: - let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); let $message= no trigger privilege on db level for create:; diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_db_table_mix.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_db_table_mix.inc index de9cf61f641..82f4a28f664 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_db_table_mix.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_db_table_mix.inc @@ -41,7 +41,6 @@ let $message= ####### Testcase for mix of db and table level: #######; grant SELECT,INSERT on priv2_db.* to test_noprivs@localhost; show grants for test_noprivs@localhost; - let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); use priv1_db; diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_definer.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_definer.inc index 18c8a3ebcd5..f1efff990f1 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_definer.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_definer.inc @@ -27,7 +27,6 @@ let $message= ######### Testcase for definer: ########; revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; - let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_global_db_mix.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_global_db_mix.inc index cd90d25aefd..b6f4af7e0a7 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_global_db_mix.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_global_db_mix.inc @@ -38,7 +38,6 @@ let $message= #### Testcase for mix of user(global) and db level: ####; grant SELECT,INSERT on *.* to test_noprivs@localhost; show grants for test_noprivs@localhost; - let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_prepare.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_prepare.inc index f1b3bbe2cb4..ea7c385768c 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_prepare.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_prepare.inc @@ -32,7 +32,6 @@ let $message= #### Testcase for trigger privilege on execution time ########; revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; revoke ALL PRIVILEGES, GRANT OPTION FROM test_useprivs@localhost; - let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_table_level.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_table_level.inc index 9cc272c09bc..94f30fe13c2 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_table_level.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_table_level.inc @@ -30,7 +30,6 @@ let $message= ######### Testcase for table level: ########; set password for test_noprivs@localhost = password('PWD'); revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost; - let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); diff --git a/mysql-test/suite/funcs_1/triggers/triggers_03e_transaction.inc b/mysql-test/suite/funcs_1/triggers/triggers_03e_transaction.inc index 53ce49c728c..e43f4ce97a3 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_03e_transaction.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_03e_transaction.inc @@ -27,7 +27,6 @@ let $message= ######### Testcase for transactions: ########; revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost; - let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); diff --git a/mysql-test/suite/funcs_1/triggers/triggers_0407.inc b/mysql-test/suite/funcs_1/triggers/triggers_0407.inc index af45017ae6a..d68b3d79086 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_0407.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_0407.inc @@ -22,7 +22,6 @@ let $message= Testcase: 3.5:; create User test_super@localhost; set password for test_super@localhost = password('PWD'); grant ALL on *.* to test_super@localhost with grant OPTION; - let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK connect (con1_general,localhost,test_general,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK diff --git a/mysql-test/suite/funcs_1/triggers/triggers_08.inc b/mysql-test/suite/funcs_1/triggers/triggers_08.inc index 4b4050b996d..087f18e8e6b 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_08.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_08.inc @@ -23,7 +23,6 @@ let $message= Testcase: 3.5:; create User test_super@localhost; set password for test_super@localhost = password('PWD'); grant ALL on *.* to test_super@localhost with grant OPTION; - let $MASTER_MYSOCK= query_get_value(SHOW VARIABLES LIKE 'socket', Value, 1); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK connect (con2_general,localhost,test_general,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK); --replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK diff --git a/mysql-test/suite/ibmdb2i/include/have_i54.inc b/mysql-test/suite/ibmdb2i/include/have_i54.inc new file mode 100755 index 00000000000..7054e196153 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/include/have_i54.inc @@ -0,0 +1,20 @@ +# Check for IBM i 6.1 or later +--disable_query_log +system uname -rv > $MYSQLTEST_VARDIR/tmp/version; +--disable_warnings +drop table if exists uname_vr; +--enable_warnings +create temporary table uname_vr (r int, v int); +--disable_warnings +eval LOAD DATA INFILE "$MYSQLTEST_VARDIR/tmp/version" into table uname_vr fields terminated by ' '; +--enable_warnings +let $ok = `select count(*) from uname_vr where v = 5 and r = 4`; +drop table uname_vr; +remove_file $MYSQLTEST_VARDIR/tmp/version; +--enable_query_log +if (!$ok) +{ + skip "Need IBM i 5.4 or later"; +} + + diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44232.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44232.result new file mode 100755 index 00000000000..8276b401073 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44232.result @@ -0,0 +1,4 @@ +create table t1 (c char(1) character set armscii8) engine=ibmdb2i; +ERROR HY000: Can't create table 'test.t1' (errno: 2504) +create table t1 (c char(1) character set eucjpms ) engine=ibmdb2i; +ERROR HY000: Can't create table 'test.t1' (errno: 2504) diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44610.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44610.result new file mode 100755 index 00000000000..311e800e1b0 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44610.result @@ -0,0 +1,18 @@ +create table ABC (i int) engine=ibmdb2i; +drop table ABC; +create table `1234567890ABC` (i int) engine=ibmdb2i; +drop table `1234567890ABC`; +create table `!@#$%` (i int) engine=ibmdb2i; +drop table `!@#$%`; +create table `ABCD#########` (i int) engine=ibmdb2i; +drop table `ABCD#########`; +create table `_` (i int) engine=ibmdb2i; +drop table `_`; +create table `abc##def` (i int) engine=ibmdb2i; +drop table `abc##def`; +set names utf8; +create table Ä° (s1 int) engine=ibmdb2i; +drop table Ä°; +create table Ä°Ä° (s1 int) engine=ibmdb2i; +drop table Ä°Ä°; +set names latin1; diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45196.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45196.result new file mode 100644 index 00000000000..916e1d93ee5 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45196.result @@ -0,0 +1,33 @@ +drop table if exists t1; +create table t1 (c char(10), index(c)) collate ucs2_czech_ci engine=ibmdb2i; +insert into t1 values ("ch"),("h"),("i"); +select * from t1 order by c; +c +h +ch +i +drop table t1; +create table t1 (c char(10), index(c)) collate utf8_czech_ci engine=ibmdb2i; +insert into t1 values ("ch"),("h"),("i"); +select * from t1 order by c; +c +h +ch +i +drop table t1; +create table t1 (c char(10), index(c)) collate ucs2_danish_ci engine=ibmdb2i; +insert into t1 values("abc"),("abcd"),("aaaa"); +select c from t1 order by c; +c +abc +abcd +aaaa +drop table t1; +create table t1 (c char(10), index(c)) collate utf8_danish_ci engine=ibmdb2i; +insert into t1 values("abc"),("abcd"),("aaaa"); +select c from t1 order by c; +c +abc +abcd +aaaa +drop table t1; diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45793.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45793.result new file mode 100644 index 00000000000..2392b746877 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45793.result @@ -0,0 +1,7 @@ +drop table if exists t1; +create table t1 (c char(10), index(c)) charset macce engine=ibmdb2i; +insert into t1 values ("test"); +select * from t1 order by c; +c +test +drop table t1; diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45983.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45983.result new file mode 100644 index 00000000000..b9f4dcfc656 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45983.result @@ -0,0 +1,20 @@ +set ibmdb2i_create_index_option=1; +drop schema if exists test1; +create schema test1; +use test1; +CREATE TABLE t1 (f int primary key, index(f)) engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (f char(10) collate utf8_bin primary key, index(f)) engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (f char(10) collate latin1_swedish_ci primary key, index(f)) engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (f char(10) collate latin1_swedish_ci primary key, i int, index i(i,f)) engine=ibmdb2i; +drop table t1; +create table fd (SQSSEQ CHAR(10)) engine=ibmdb2i; +select * from fd; +SQSSEQ +*HEX +*HEX +*HEX +*HEX +drop table fd; diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_collations.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_collations.result new file mode 100644 index 00000000000..4f7d71cab2d --- /dev/null +++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_collations.result @@ -0,0 +1,1204 @@ +drop table if exists t1, ffd, fd; +CREATE TABLE t1 (armscii8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate armscii8_bin engine=ibmdb2i; +CREATE TABLE t1 (armscii8_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate armscii8_general_ci engine=ibmdb2i; +CREATE TABLE t1 (ascii_bin integer, c char(10), v varchar(20), index(c), index(v)) collate ascii_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (ascii_bin char(10) primary key) collate ascii_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ascii_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ascii_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (ascii_general_ci char(10) primary key) collate ascii_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (big5_bin integer, c char(10), v varchar(20), index(c), index(v)) collate big5_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (big5_bin char(10) primary key) collate big5_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (big5_chinese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate big5_chinese_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (big5_chinese_ci char(10) primary key) collate big5_chinese_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp1250_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp1250_bin char(10) primary key) collate cp1250_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp1250_croatian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_croatian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp1250_croatian_ci char(10) primary key) collate cp1250_croatian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp1250_czech_cs integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_czech_cs engine=ibmdb2i; +CREATE TABLE t1 (cp1250_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp1250_general_ci char(10) primary key) collate cp1250_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp1250_polish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_polish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp1250_polish_ci char(10) primary key) collate cp1250_polish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp1251_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp1251_bin char(10) primary key) collate cp1251_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp1251_bulgarian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_bulgarian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp1251_bulgarian_ci char(10) primary key) collate cp1251_bulgarian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp1251_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp1251_general_ci char(10) primary key) collate cp1251_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp1251_general_cs integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_general_cs engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp1251_general_cs char(10) primary key) collate cp1251_general_cs engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp1251_ukrainian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_ukrainian_ci engine=ibmdb2i; +CREATE TABLE t1 (cp1256_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp1256_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp1256_bin char(10) primary key) collate cp1256_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp1256_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1256_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp1256_general_ci char(10) primary key) collate cp1256_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp1257_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp1257_bin engine=ibmdb2i; +CREATE TABLE t1 (cp1257_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1257_general_ci engine=ibmdb2i; +CREATE TABLE t1 (cp1257_lithuanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1257_lithuanian_ci engine=ibmdb2i; +CREATE TABLE t1 (cp850_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp850_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp850_bin char(10) primary key) collate cp850_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp850_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp850_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp850_general_ci char(10) primary key) collate cp850_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp852_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp852_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp852_bin char(10) primary key) collate cp852_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp852_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp852_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (cp852_general_ci char(10) primary key) collate cp852_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp866_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp866_bin engine=ibmdb2i; +CREATE TABLE t1 (cp866_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp866_general_ci engine=ibmdb2i; +CREATE TABLE t1 (cp932_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp932_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (cp932_bin char(10) primary key) collate cp932_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (cp932_japanese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp932_japanese_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (cp932_japanese_ci char(10) primary key) collate cp932_japanese_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (dec8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate dec8_bin engine=ibmdb2i; +CREATE TABLE t1 (dec8_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate dec8_swedish_ci engine=ibmdb2i; +CREATE TABLE t1 (eucjpms_bin integer, c char(10), v varchar(20), index(c), index(v)) collate eucjpms_bin engine=ibmdb2i; +CREATE TABLE t1 (eucjpms_japanese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate eucjpms_japanese_ci engine=ibmdb2i; +CREATE TABLE t1 (euckr_bin integer, c char(10), v varchar(20), index(c), index(v)) collate euckr_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (euckr_bin char(10) primary key) collate euckr_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (euckr_korean_ci integer, c char(10), v varchar(20), index(c), index(v)) collate euckr_korean_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (euckr_korean_ci char(10) primary key) collate euckr_korean_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (gb2312_bin integer, c char(10), v varchar(20), index(c), index(v)) collate gb2312_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (gb2312_bin char(10) primary key) collate gb2312_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (gb2312_chinese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate gb2312_chinese_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (gb2312_chinese_ci char(10) primary key) collate gb2312_chinese_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (gbk_bin integer, c char(10), v varchar(20), index(c), index(v)) collate gbk_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (gbk_bin char(10) primary key) collate gbk_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (gbk_chinese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate gbk_chinese_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (gbk_chinese_ci char(10) primary key) collate gbk_chinese_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (geostd8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate geostd8_bin engine=ibmdb2i; +CREATE TABLE t1 (geostd8_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate geostd8_general_ci engine=ibmdb2i; +CREATE TABLE t1 (greek_bin integer, c char(10), v varchar(20), index(c), index(v)) collate greek_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (greek_bin char(10) primary key) collate greek_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (greek_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate greek_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (greek_general_ci char(10) primary key) collate greek_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (hebrew_bin integer, c char(10), v varchar(20), index(c), index(v)) collate hebrew_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (hebrew_bin char(10) primary key) collate hebrew_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (hebrew_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate hebrew_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (hebrew_general_ci char(10) primary key) collate hebrew_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (hp8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate hp8_bin engine=ibmdb2i; +CREATE TABLE t1 (hp8_english_ci integer, c char(10), v varchar(20), index(c), index(v)) collate hp8_english_ci engine=ibmdb2i; +CREATE TABLE t1 (keybcs2_bin integer, c char(10), v varchar(20), index(c), index(v)) collate keybcs2_bin engine=ibmdb2i; +CREATE TABLE t1 (keybcs2_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate keybcs2_general_ci engine=ibmdb2i; +CREATE TABLE t1 (koi8r_bin integer, c char(10), v varchar(20), index(c), index(v)) collate koi8r_bin engine=ibmdb2i; +CREATE TABLE t1 (koi8r_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate koi8r_general_ci engine=ibmdb2i; +CREATE TABLE t1 (koi8u_bin integer, c char(10), v varchar(20), index(c), index(v)) collate koi8u_bin engine=ibmdb2i; +CREATE TABLE t1 (koi8u_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate koi8u_general_ci engine=ibmdb2i; +CREATE TABLE t1 (latin1_bin integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin1_bin char(10) primary key) collate latin1_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin1_danish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_danish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin1_danish_ci char(10) primary key) collate latin1_danish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin1_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin1_general_ci char(10) primary key) collate latin1_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin1_general_cs integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_general_cs engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin1_general_cs char(10) primary key) collate latin1_general_cs engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin1_german1_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_german1_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin1_german1_ci char(10) primary key) collate latin1_german1_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin1_german2_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_german2_ci engine=ibmdb2i; +CREATE TABLE t1 (latin1_spanish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_spanish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin1_spanish_ci char(10) primary key) collate latin1_spanish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin1_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_swedish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin1_swedish_ci char(10) primary key) collate latin1_swedish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin2_bin integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin2_bin char(10) primary key) collate latin2_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin2_croatian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_croatian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin2_croatian_ci char(10) primary key) collate latin2_croatian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin2_czech_cs integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_czech_cs engine=ibmdb2i; +CREATE TABLE t1 (latin2_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin2_general_ci char(10) primary key) collate latin2_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin2_hungarian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_hungarian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin2_hungarian_ci char(10) primary key) collate latin2_hungarian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin5_bin integer, c char(10), v varchar(20), index(c), index(v)) collate latin5_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin5_bin char(10) primary key) collate latin5_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin5_turkish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin5_turkish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (latin5_turkish_ci char(10) primary key) collate latin5_turkish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (latin7_bin integer, c char(10), v varchar(20), index(c), index(v)) collate latin7_bin engine=ibmdb2i; +CREATE TABLE t1 (latin7_estonian_cs integer, c char(10), v varchar(20), index(c), index(v)) collate latin7_estonian_cs engine=ibmdb2i; +CREATE TABLE t1 (latin7_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin7_general_ci engine=ibmdb2i; +CREATE TABLE t1 (latin7_general_cs integer, c char(10), v varchar(20), index(c), index(v)) collate latin7_general_cs engine=ibmdb2i; +CREATE TABLE t1 (macce_bin integer, c char(10), v varchar(20), index(c), index(v)) collate macce_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (macce_bin char(10) primary key) collate macce_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (macce_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate macce_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (macce_general_ci char(10) primary key) collate macce_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (macroman_bin integer, c char(10), v varchar(20), index(c), index(v)) collate macroman_bin engine=ibmdb2i; +CREATE TABLE t1 (macroman_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate macroman_general_ci engine=ibmdb2i; +CREATE TABLE t1 (sjis_bin integer, c char(10), v varchar(20), index(c), index(v)) collate sjis_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (sjis_bin char(10) primary key) collate sjis_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (sjis_japanese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate sjis_japanese_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (sjis_japanese_ci char(10) primary key) collate sjis_japanese_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (swe7_bin integer, c char(10), v varchar(20), index(c), index(v)) collate swe7_bin engine=ibmdb2i; +CREATE TABLE t1 (swe7_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate swe7_swedish_ci engine=ibmdb2i; +CREATE TABLE t1 (tis620_bin integer, c char(10), v varchar(20), index(c), index(v)) collate tis620_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (tis620_bin char(10) primary key) collate tis620_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (tis620_thai_ci integer, c char(10), v varchar(20), index(c), index(v)) collate tis620_thai_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 11 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 23 NULL 6 Using where +drop table t1; +create table t1 (tis620_thai_ci char(10) primary key) collate tis620_thai_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_bin integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_bin char(10) primary key) collate ucs2_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_czech_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_czech_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_czech_ci char(10) primary key) collate ucs2_czech_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_danish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_danish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_danish_ci char(10) primary key) collate ucs2_danish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_esperanto_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_esperanto_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_esperanto_ci char(10) primary key) collate ucs2_esperanto_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_estonian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_estonian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_estonian_ci char(10) primary key) collate ucs2_estonian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_general_ci char(10) primary key) collate ucs2_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_hungarian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_hungarian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_hungarian_ci char(10) primary key) collate ucs2_hungarian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_icelandic_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_icelandic_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_icelandic_ci char(10) primary key) collate ucs2_icelandic_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_latvian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_latvian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_latvian_ci char(10) primary key) collate ucs2_latvian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_lithuanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_lithuanian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_lithuanian_ci char(10) primary key) collate ucs2_lithuanian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_persian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_persian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_persian_ci char(10) primary key) collate ucs2_persian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_polish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_polish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_polish_ci char(10) primary key) collate ucs2_polish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_romanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_romanian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_romanian_ci char(10) primary key) collate ucs2_romanian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_roman_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_roman_ci engine=ibmdb2i; +CREATE TABLE t1 (ucs2_slovak_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_slovak_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_slovak_ci char(10) primary key) collate ucs2_slovak_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_slovenian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_slovenian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_slovenian_ci char(10) primary key) collate ucs2_slovenian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_spanish2_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_spanish2_ci engine=ibmdb2i; +CREATE TABLE t1 (ucs2_spanish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_spanish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_spanish_ci char(10) primary key) collate ucs2_spanish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_swedish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_swedish_ci char(10) primary key) collate ucs2_swedish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_turkish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_turkish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_turkish_ci char(10) primary key) collate ucs2_turkish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ucs2_unicode_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_unicode_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 21 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 43 NULL 6 Using where +drop table t1; +create table t1 (ucs2_unicode_ci char(10) primary key) collate ucs2_unicode_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ujis_bin integer, c char(10), v varchar(20), index(c), index(v)) collate ujis_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (ujis_bin char(10) primary key) collate ujis_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (ujis_japanese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ujis_japanese_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (ujis_japanese_ci char(10) primary key) collate ujis_japanese_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_bin engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_bin char(10) primary key) collate utf8_bin engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_czech_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_czech_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_czech_ci char(10) primary key) collate utf8_czech_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_danish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_danish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_danish_ci char(10) primary key) collate utf8_danish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_esperanto_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_esperanto_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_esperanto_ci char(10) primary key) collate utf8_esperanto_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_estonian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_estonian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_estonian_ci char(10) primary key) collate utf8_estonian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_general_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_general_ci char(10) primary key) collate utf8_general_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_hungarian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_hungarian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_hungarian_ci char(10) primary key) collate utf8_hungarian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_icelandic_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_icelandic_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_icelandic_ci char(10) primary key) collate utf8_icelandic_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_latvian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_latvian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_latvian_ci char(10) primary key) collate utf8_latvian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_lithuanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_lithuanian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_lithuanian_ci char(10) primary key) collate utf8_lithuanian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_persian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_persian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_persian_ci char(10) primary key) collate utf8_persian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_polish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_polish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_polish_ci char(10) primary key) collate utf8_polish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_romanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_romanian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_romanian_ci char(10) primary key) collate utf8_romanian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_roman_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_roman_ci engine=ibmdb2i; +CREATE TABLE t1 (utf8_slovak_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_slovak_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_slovak_ci char(10) primary key) collate utf8_slovak_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_slovenian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_slovenian_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_slovenian_ci char(10) primary key) collate utf8_slovenian_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_spanish2_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_spanish2_ci engine=ibmdb2i; +CREATE TABLE t1 (utf8_spanish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_spanish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_spanish_ci char(10) primary key) collate utf8_spanish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_swedish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_swedish_ci char(10) primary key) collate utf8_swedish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_turkish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_turkish_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_turkish_ci char(10) primary key) collate utf8_turkish_ci engine=ibmdb2i; +drop table t1; +CREATE TABLE t1 (utf8_unicode_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_unicode_ci engine=ibmdb2i; +insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); +insert into t1 select * from t1; +explain select c,v from t1 force index(c) where c like "ab%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 31 NULL 6 Using where +explain select c,v from t1 force index(v) where v like "de%"; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range v v 63 NULL 6 Using where +drop table t1; +create table t1 (utf8_unicode_ci char(10) primary key) collate utf8_unicode_ci engine=ibmdb2i; +drop table t1; +create table ffd (WHCHD1 CHAR(20), WHCSID decimal(5,0)) engine=ibmdb2i; +create table fd (SQSSEQ CHAR(10)) engine=ibmdb2i; +create temporary table intermed (row integer key auto_increment, cs char(30), ccsid integer); +insert into intermed (cs, ccsid) select * from ffd; +create temporary table intermed2 (row integer key auto_increment, srtseq char(10)); +insert into intermed2 (srtseq) select * from fd; +select ccsid, cs, srtseq from intermed inner join intermed2 on intermed.row = intermed2.row; +ccsid cs srtseq +500 "ascii_bin" QBLA101F4U +500 "ascii_general_ci" QALA101F4S +1200 "big5_bin" QBCHT04B0U +1200 "big5_chinese_ci" QACHT04B0S +1153 "cp1250_bin" QELA20481U +1153 "cp1250_croatian_ci" QALA20481S +1153 "cp1250_general_ci" QCLA20481S +1153 "cp1250_polish_ci" QDLA20481S +1025 "cp1251_bin" QCCYR0401U +1025 "cp1251_bulgarian_ci QACYR0401S +1025 "cp1251_general_ci" QBCYR0401S +1025 "cp1251_general_cs" QBCYR0401U +420 "cp1256_bin" QBARA01A4U +420 "cp1256_general_ci" QAARA01A4S +500 "cp850_bin" QDLA101F4U +500 "cp850_general_ci" QCLA101F4S +870 "cp852_bin" QBLA20366U +870 "cp852_general_ci" QALA20366S +1200 "cp932_bin" QBJPN04B0U +1200 "cp932_japanese_ci" QAJPN04B0S +1200 "euckr_bin" QBKOR04B0U +1200 "euckr_korean_ci" QAKOR04B0S +1200 "gb2312_bin" QBCHS04B0U +1200 "gb2312_chinese_ci" QACHS04B0S +1200 "gbk_bin" QDCHS04B0U +1200 "gbk_chinese_ci" QCCHS04B0S +875 "greek_bin" QBELL036BU +875 "greek_general_ci" QAELL036BS +424 "hebrew_bin" QBHEB01A8U +424 "hebrew_general_ci" QAHEB01A8S +1148 "latin1_bin" QFLA1047CU +1148 "latin1_danish_ci" QALA1047CS +1148 "latin1_general_ci" QBLA1047CS +1148 "latin1_general_cs" QBLA1047CU +1148 "latin1_german1_ci" QCLA1047CS +1148 "latin1_spanish_ci" QDLA1047CS +1148 "latin1_swedish_ci" QELA1047CS +870 "latin2_bin" QGLA20366U +870 "latin2_croatian_ci" QCLA20366S +870 "latin2_general_ci" QELA20366S +870 "latin2_hungarian_ci QFLA20366S +1026 "latin5_bin" QBTRK0402U +1026 "latin5_turkish_ci" QATRK0402S +870 "macce_bin" QILA20366U +870 "macce_general_ci" QHLA20366S +1200 "sjis_bin" QDJPN04B0U +1200 "sjis_japanese_ci" QCJPN04B0S +838 "tis620_bin" QBTHA0346U +838 "tis620_thai_ci" QATHA0346S +13488 "ucs2_bin" *HEX +13488 "ucs2_czech_ci" I34ACS_CZ +13488 "ucs2_danish_ci" I34ADA_DK +13488 "ucs2_esperanto_ci" I34AEO +13488 "ucs2_estonian_ci" I34AET +13488 "ucs2_general_ci" QAUCS04B0S +13488 "ucs2_hungarian_ci" I34AHU +13488 "ucs2_icelandic_ci" I34AIS +13488 "ucs2_latvian_ci" I34ALV +13488 "ucs2_lithuanian_ci" I34ALT +13488 "ucs2_persian_ci" I34AFA +13488 "ucs2_polish_ci" I34APL +13488 "ucs2_romanian_ci" I34ARO +13488 "ucs2_slovak_ci" I34ASK +13488 "ucs2_slovenian_ci" I34ASL +13488 "ucs2_spanish_ci" I34AES +13488 "ucs2_swedish_ci" I34ASW +13488 "ucs2_turkish_ci" I34ATR +13488 "ucs2_unicode_ci" I34AEN +1200 "ujis_bin" QFJPN04B0U +1200 "ujis_japanese_ci" QEJPN04B0S +1208 "utf8_bin" *HEX +1208 "utf8_czech_ci" I34ACS_CZ +1208 "utf8_danish_ci" I34ADA_DK +1208 "utf8_esperanto_ci" I34AEO +1208 "utf8_estonian_ci" I34AET +1200 "utf8_general_ci" QAUCS04B0S +1208 "utf8_hungarian_ci" I34AHU +1208 "utf8_icelandic_ci" I34AIS +1208 "utf8_latvian_ci" I34ALV +1208 "utf8_lithuanian_ci" I34ALT +1208 "utf8_persian_ci" I34AFA +1208 "utf8_polish_ci" I34APL +1208 "utf8_romanian_ci" I34ARO +1208 "utf8_slovak_ci" I34ASK +1208 "utf8_slovenian_ci" I34ASL +1208 "utf8_spanish_ci" I34AES +1208 "utf8_swedish_ci" I34ASW +1208 "utf8_turkish_ci" I34ATR +1208 "utf8_unicode_ci" I34AEN +drop table ffd, fd; diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44232.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44232.test new file mode 100755 index 00000000000..ea29b5abcd4 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44232.test @@ -0,0 +1,8 @@ +--source suite/ibmdb2i/include/have_ibmdb2i.inc +--source suite/ibmdb2i/include/have_i54.inc + +--error 1005 +create table t1 (c char(1) character set armscii8) engine=ibmdb2i; + +--error 1005 +create table t1 (c char(1) character set eucjpms ) engine=ibmdb2i; diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44610.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44610.test new file mode 100755 index 00000000000..da69b5d9148 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44610.test @@ -0,0 +1,28 @@ +source suite/ibmdb2i/include/have_ibmdb2i.inc; + +# Test RCDFMT generation for a variety of kinds of table names +create table ABC (i int) engine=ibmdb2i; +drop table ABC; + +create table `1234567890ABC` (i int) engine=ibmdb2i; +drop table `1234567890ABC`; + +create table `!@#$%` (i int) engine=ibmdb2i; +drop table `!@#$%`; + +create table `ABCD#########` (i int) engine=ibmdb2i; +drop table `ABCD#########`; + +create table `_` (i int) engine=ibmdb2i; +drop table `_`; + +create table `abc##def` (i int) engine=ibmdb2i; +drop table `abc##def`; + +set names utf8; +create table Ä° (s1 int) engine=ibmdb2i; +drop table Ä°; + +create table Ä°Ä° (s1 int) engine=ibmdb2i; +drop table Ä°Ä°; +set names latin1; diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45196.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45196.test new file mode 100644 index 00000000000..17b1d658975 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45196.test @@ -0,0 +1,26 @@ +source suite/ibmdb2i/include/have_ibmdb2i.inc; +source suite/ibmdb2i/include/have_i61.inc; + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (c char(10), index(c)) collate ucs2_czech_ci engine=ibmdb2i; +insert into t1 values ("ch"),("h"),("i"); +select * from t1 order by c; +drop table t1; + +create table t1 (c char(10), index(c)) collate utf8_czech_ci engine=ibmdb2i; +insert into t1 values ("ch"),("h"),("i"); +select * from t1 order by c; +drop table t1; + +create table t1 (c char(10), index(c)) collate ucs2_danish_ci engine=ibmdb2i; +insert into t1 values("abc"),("abcd"),("aaaa"); +select c from t1 order by c; +drop table t1; + +create table t1 (c char(10), index(c)) collate utf8_danish_ci engine=ibmdb2i; +insert into t1 values("abc"),("abcd"),("aaaa"); +select c from t1 order by c; +drop table t1; diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45793.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45793.test new file mode 100644 index 00000000000..93fb78ff421 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45793.test @@ -0,0 +1,11 @@ +source suite/ibmdb2i/include/have_ibmdb2i.inc; +source suite/ibmdb2i/include/have_i61.inc; + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (c char(10), index(c)) charset macce engine=ibmdb2i; +insert into t1 values ("test"); +select * from t1 order by c; +drop table t1; diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45983.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45983.test new file mode 100644 index 00000000000..695d8e90ada --- /dev/null +++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45983.test @@ -0,0 +1,47 @@ +source suite/ibmdb2i/include/have_ibmdb2i.inc; + +# Confirm that ibmdb2i_create_index_option causes additional *HEX sorted indexes to be created for all non-binary keys. + +set ibmdb2i_create_index_option=1; +--disable_warnings +drop schema if exists test1; +create schema test1; +use test1; +--enable_warnings + +--disable_abort_on_error +--error 0,255 +exec system "DLTF QGPL/FDOUT" > /dev/null; +--enable_abort_on_error + +#No additional index because no string fields in key +CREATE TABLE t1 (f int primary key, index(f)) engine=ibmdb2i; +--error 255 +exec system "DSPFD FILE(\"test1\"/PRIM0001) TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null; +--error 255 +exec system "DSPFD FILE(\"test1\"/\"f___H_t1\") TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null; +drop table t1; + +#No additional index because binary sorting +CREATE TABLE t1 (f char(10) collate utf8_bin primary key, index(f)) engine=ibmdb2i; +--error 255 +exec system "DSPFD FILE(\"test1\"/PRIM0001) TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null; +--error 255 +exec system "DSPFD FILE(\"test1\"/\"f___H_t1\") TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null; +drop table t1; + +CREATE TABLE t1 (f char(10) collate latin1_swedish_ci primary key, index(f)) engine=ibmdb2i; +exec system "DSPFD FILE(\"test1\"/PRIM0001) TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null; +exec system "DSPFD FILE(\"test1\"/\"f___H_t1\") TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null; +drop table t1; + +CREATE TABLE t1 (f char(10) collate latin1_swedish_ci primary key, i int, index i(i,f)) engine=ibmdb2i; +exec system "DSPFD FILE(\"test1\"/PRIM0001) TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null; +exec system "DSPFD FILE(\"test1\"/\"i___H_t1\") TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null; +drop table t1; + + +create table fd (SQSSEQ CHAR(10)) engine=ibmdb2i; +system system "CPYF FROMFILE(QGPL/FDOUT) TOFILE(\"test1\"/\"fd\") mbropt(*replace) fmtopt(*drop *map)" > /dev/null; +select * from fd; +drop table fd; diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_collations.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_collations.test new file mode 100644 index 00000000000..899f330d360 --- /dev/null +++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_collations.test @@ -0,0 +1,44 @@ +source suite/ibmdb2i/include/have_ibmdb2i.inc; +source suite/ibmdb2i/include/have_i61.inc; +--disable_warnings +drop table if exists t1, ffd, fd; +--enable_warnings + +--disable_abort_on_error +--error 0,255 +exec system "DLTF QGPL/FFDOUT" > /dev/null; +--error 0,255 +exec system "DLTF QGPL/FDOUT" > /dev/null; +--enable_abort_on_error +let $count= query_get_value(select count(*) from information_schema.COLLATIONS where COLLATION_NAME <> "binary", count(*),1); + +while ($count) +{ + let $collation = query_get_value(select COLLATION_NAME from information_schema.COLLATIONS where COLLATION_NAME <> "binary" order by COLLATION_NAME desc, COLLATION_NAME, $count); + error 0,1005,2504,2028; + eval CREATE TABLE t1 ($collation integer, c char(10), v varchar(20), index(c), index(v)) collate $collation engine=ibmdb2i; + if (!$mysql_errno) + { + insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb"); + insert into t1 select * from t1; + explain select c,v from t1 force index(c) where c like "ab%"; + explain select c,v from t1 force index(v) where v like "de%"; + drop table t1; + eval create table t1 ($collation char(10) primary key) collate $collation engine=ibmdb2i; + system system "DSPFFD FILE(\"test\"/\"t1\") OUTPUT(*OUTFILE) OUTFILE(QGPL/FFDOUT) OUTMBR(*FIRST *ADD)" > /dev/null; + system system "DSPFD FILE(\"test\"/\"t1\") TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null; + drop table t1; + } + dec $count; +} + +create table ffd (WHCHD1 CHAR(20), WHCSID decimal(5,0)) engine=ibmdb2i; +system system "CPYF FROMFILE(QGPL/FFDOUT) TOFILE(\"test\"/\"ffd\") mbropt(*replace) fmtopt(*drop *map)" > /dev/null; +create table fd (SQSSEQ CHAR(10)) engine=ibmdb2i; +system system "CPYF FROMFILE(QGPL/FDOUT) TOFILE(\"test\"/\"fd\") mbropt(*replace) fmtopt(*drop *map)" > /dev/null; +create temporary table intermed (row integer key auto_increment, cs char(30), ccsid integer); +insert into intermed (cs, ccsid) select * from ffd; +create temporary table intermed2 (row integer key auto_increment, srtseq char(10)); +insert into intermed2 (srtseq) select * from fd; +select ccsid, cs, srtseq from intermed inner join intermed2 on intermed.row = intermed2.row; +drop table ffd, fd; diff --git a/mysql-test/suite/ndb/my.cnf b/mysql-test/suite/ndb/my.cnf index 60769272ada..a19fdeee302 100644 --- a/mysql-test/suite/ndb/my.cnf +++ b/mysql-test/suite/ndb/my.cnf @@ -13,6 +13,7 @@ ndbcluster [ENV] NDB_CONNECTSTRING= @mysql_cluster.1.ndb_connectstring +MASTER_MYSOCK= @mysqld.1.1.socket MASTER_MYPORT= @mysqld.1.1.port MASTER_MYPORT1= @mysqld.2.1.port diff --git a/mysql-test/suite/ndb/r/ndb_binlog_format.result b/mysql-test/suite/ndb/r/ndb_binlog_format.result index bb02002ed58..6e1fc12130f 100644 --- a/mysql-test/suite/ndb/r/ndb_binlog_format.result +++ b/mysql-test/suite/ndb/r/ndb_binlog_format.result @@ -15,15 +15,15 @@ COMMIT; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info mysqld-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1), (1,2), (2,1), (2,2) -mysqld-bin.000001 # Query # # use `test`; BEGIN +mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES (1,1), (1,2), (2,1), (2,2) -mysqld-bin.000001 # Query # # use `test`; COMMIT +mysqld-bin.000001 # Query # # COMMIT mysqld-bin.000001 # Query # # use `test`; UPDATE t1, t2 SET m = 2, b = 3 WHERE n = c -mysqld-bin.000001 # Query # # use `test`; BEGIN +mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Query # # use `test`; INSERT INTO t3 VALUES (1,1), (1,2), (2,1), (2,2) mysqld-bin.000001 # Query # # use `test`; UPDATE t1, t3 SET m = 2, e = 3 WHERE n = f mysqld-bin.000001 # Query # # use `test`; UPDATE t3, t2 SET e = 2, b = 3 WHERE f = c -mysqld-bin.000001 # Query # # use `test`; COMMIT +mysqld-bin.000001 # Query # # COMMIT mysqld-bin.000001 # Query # # BEGIN mysqld-bin.000001 # Table_map # # table_id: # (test.t3) mysqld-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) diff --git a/mysql-test/suite/ndb_team/r/rpl_ndb_mix_innodb.result b/mysql-test/suite/ndb_team/r/rpl_ndb_mix_innodb.result index eba1222ea33..f9c077f38da 100644 --- a/mysql-test/suite/ndb_team/r/rpl_ndb_mix_innodb.result +++ b/mysql-test/suite/ndb_team/r/rpl_ndb_mix_innodb.result @@ -28,7 +28,7 @@ from mysql.ndb_apply_status; show binlog events from <start_pos> limit 1; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 <start_pos> Query 1 # use `test`; BEGIN +master-bin.000001 <start_pos> Query 1 # BEGIN # Now the insert, one step after @@ -53,7 +53,7 @@ from mysql.ndb_apply_status; <log_name> <start_pos> <end_pos> show binlog events from <start_pos> limit 1; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 <start_pos> Query 1 # use `test`; BEGIN +master-bin.000001 <start_pos> Query 1 # BEGIN show binlog events from <start_pos> limit 1,2; Log_name Pos Event_type Server_id End_log_pos Info diff --git a/mysql-test/suite/parts/r/partition_auto_increment_memory.result b/mysql-test/suite/parts/r/partition_auto_increment_memory.result index 77bab79f020..f4d783825f4 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_memory.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_memory.result @@ -381,12 +381,12 @@ Table Create Table t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`c1`) -) ENGINE=MEMORY AUTO_INCREMENT=28 DEFAULT CHARSET=latin1 +) ENGINE=MEMORY AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ SELECT * FROM t1 ORDER BY c1; c1 -27 +1 INSERT INTO t1 VALUES (100); INSERT INTO t1 VALUES (NULL); DELETE FROM t1 WHERE c1 >= 100; diff --git a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result index b5b001ec17a..6abf08b68a0 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result @@ -381,12 +381,12 @@ Table Create Table t1 CREATE TABLE `t1` ( `c1` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`c1`) -) ENGINE=MyISAM AUTO_INCREMENT=28 DEFAULT CHARSET=latin1 +) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c1) PARTITIONS 2 */ SELECT * FROM t1 ORDER BY c1; c1 -27 +1 INSERT INTO t1 VALUES (100); INSERT INTO t1 VALUES (NULL); DELETE FROM t1 WHERE c1 >= 100; diff --git a/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result b/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result new file mode 100644 index 00000000000..23736804784 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_begin_commit_rollback.result @@ -0,0 +1,109 @@ +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 DATABASE IF EXISTS db1; +CREATE DATABASE db1; +use db1; +CREATE TABLE db1.t1 (a INT) ENGINE=InnoDB; +CREATE TABLE db1.t2 (s CHAR(255)) ENGINE=MyISAM; +include/stop_slave.inc +[on master] +CREATE PROCEDURE db1.p1 () +BEGIN +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +END// +CREATE PROCEDURE db1.p2 () +BEGIN +INSERT INTO t1 VALUES (6); +INSERT INTO t1 VALUES (7); +INSERT INTO t1 VALUES (8); +INSERT INTO t1 VALUES (9); +INSERT INTO t1 VALUES (10); +INSERT INTO t2 VALUES ('executed db1.p2()'); +END// +INSERT INTO db1.t2 VALUES ('before call db1.p1()'); +use test; +BEGIN; +CALL db1.p1(); +COMMIT; +INSERT INTO db1.t2 VALUES ('after call db1.p1()'); +SELECT * FROM db1.t1; +a +1 +2 +3 +4 +5 +SELECT * FROM db1.t2; +s +before call db1.p1() +after call db1.p1() +[on slave] +start slave until master_log_file='master-bin.000001', master_log_pos=MASTER_POS; +# +# If we got non-zero here, then we're suffering BUG#43263 +# +SELECT 0 as 'Must be 0'; +Must be 0 +0 +SELECT * from db1.t1; +a +1 +2 +3 +4 +5 +SELECT * from db1.t2; +s +before call db1.p1() +[on master] +INSERT INTO db1.t2 VALUES ('before call db1.p2()'); +BEGIN; +CALL db1.p2(); +ROLLBACK; +INSERT INTO db1.t2 VALUES ('after call db1.p2()'); +SELECT * FROM db1.t1; +a +1 +2 +3 +4 +5 +SELECT * FROM db1.t2; +s +before call db1.p1() +after call db1.p1() +before call db1.p2() +executed db1.p2() +after call db1.p2() +[on slave] +start slave until master_log_file='master-bin.000001', master_log_pos=MASTER_POS; +# +# If we got non-zero here, then we're suffering BUG#43263 +# +SELECT 0 as 'Must be 0'; +Must be 0 +0 +SELECT * from db1.t1; +a +1 +2 +3 +4 +5 +SELECT * from db1.t2; +s +before call db1.p1() +executed db1.p2() +# +# Clean up +# +DROP DATABASE db1; +DROP DATABASE db1; diff --git a/mysql-test/suite/rpl/r/rpl_binlog_grant.result b/mysql-test/suite/rpl/r/rpl_binlog_grant.result index 72dc58effa1..4a789f361c6 100644 --- a/mysql-test/suite/rpl/r/rpl_binlog_grant.result +++ b/mysql-test/suite/rpl/r/rpl_binlog_grant.result @@ -23,7 +23,7 @@ master-bin.000001 4 Format_desc 1 106 Server ver: VERSION, Binlog ver: 4 master-bin.000001 106 Query 1 193 drop database if exists d1 master-bin.000001 193 Query 1 272 create database d1 master-bin.000001 272 Query 1 370 use `d1`; create table t (s1 int) engine=innodb -master-bin.000001 370 Query 1 436 use `d1`; BEGIN +master-bin.000001 370 Query 1 436 BEGIN master-bin.000001 436 Query 1 521 use `d1`; insert into t values (1) master-bin.000001 521 Xid 1 548 COMMIT /* XID */ master-bin.000001 548 Query 1 633 use `d1`; grant select on t to x@y @@ -44,11 +44,11 @@ master-bin.000001 4 Format_desc 1 106 Server ver: VERSION, Binlog ver: 4 master-bin.000001 106 Query 1 193 drop database if exists d1 master-bin.000001 193 Query 1 272 create database d1 master-bin.000001 272 Query 1 370 use `d1`; create table t (s1 int) engine=innodb -master-bin.000001 370 Query 1 436 use `d1`; BEGIN +master-bin.000001 370 Query 1 436 BEGIN master-bin.000001 436 Query 1 521 use `d1`; insert into t values (1) master-bin.000001 521 Xid 1 548 COMMIT /* XID */ master-bin.000001 548 Query 1 633 use `d1`; grant select on t to x@y -master-bin.000001 633 Query 1 699 use `d1`; BEGIN +master-bin.000001 633 Query 1 699 BEGIN master-bin.000001 699 Query 1 784 use `d1`; insert into t values (2) master-bin.000001 784 Xid 1 811 COMMIT /* XID */ master-bin.000001 811 Query 1 899 use `d1`; revoke select on t from x@y diff --git a/mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result b/mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result new file mode 100644 index 00000000000..0e3f83d0aa5 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result @@ -0,0 +1,135 @@ +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 PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb; +CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam; +CREATE TABLE t3(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb; +######################################################################################## +# 1 - SINGLE STATEMENT +######################################################################################## +*** Single statement on transactional table *** +Got one of the listed errors +*** Single statement on non-transactional table *** +*** After WL#2687 the difference between STATEMENT/MIXED and ROW will not exist. *** +Got one of the listed errors +*** Single statement on both transactional and non-transactional tables. *** +*** After WL#2687 we will be able to change the order of the tables. *** +Got one of the listed errors +SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; +START SLAVE SQL_THREAD; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; +BEGIN; +Got one of the listed errors +Got one of the listed errors +Got one of the listed errors +BEGIN; +Got one of the listed errors +Got one of the listed errors +Got one of the listed errors +BEGIN; +Got one of the listed errors +Got one of the listed errors +source include/diff_master_slave.inc; +######################################################################################## +# 3 - BEGIN - COMMIT +######################################################################################## +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; +BEGIN; +Got one of the listed errors +Got one of the listed errors +Got one of the listed errors +COMMIT; +source include/diff_master_slave.inc; +######################################################################################## +# 4 - BEGIN - ROLLBACK +######################################################################################## +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; +BEGIN; +Got one of the listed errors +Got one of the listed errors +Got one of the listed errors +ROLLBACK; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +source include/diff_master_slave.inc; +######################################################################################## +# 5 - PROCEDURE +######################################################################################## +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; +CREATE PROCEDURE p1(pd VARCHAR(30000)) +BEGIN +INSERT INTO t1 (a, data) VALUES (1, pd); +INSERT INTO t1 (a, data) VALUES (2, pd); +INSERT INTO t1 (a, data) VALUES (3, pd); +INSERT INTO t1 (a, data) VALUES (4, pd); +INSERT INTO t1 (a, data) VALUES (5, 's'); +END// +TRUNCATE TABLE t1; +TRUNCATE TABLE t1; +BEGIN; +Got one of the listed errors +COMMIT; +TRUNCATE TABLE t1; +BEGIN; +Got one of the listed errors +ROLLBACK; +source include/diff_master_slave.inc; +######################################################################################## +# 6 - XID +######################################################################################## +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; +BEGIN; +Got one of the listed errors +Got one of the listed errors +Got one of the listed errors +ROLLBACK TO sv; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +COMMIT; +source include/diff_master_slave.inc; +######################################################################################## +# 7 - NON-TRANS TABLE +######################################################################################## +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; +BEGIN; +Got one of the listed errors +Got one of the listed errors +Got one of the listed errors +Got one of the listed errors +Got one of the listed errors +COMMIT; +BEGIN; +Got one of the listed errors +COMMIT; +######################################################################################## +# CLEAN +######################################################################################## +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +DROP TABLE IF EXISTS t4; +DROP TABLE IF EXISTS t5; +DROP TABLE IF EXISTS t6; +DROP PROCEDURE p1; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +DROP TABLE IF EXISTS t4; +DROP TABLE IF EXISTS t5; +DROP TABLE IF EXISTS t6; +DROP PROCEDURE p1; diff --git a/mysql-test/suite/rpl/r/rpl_concurrency_error.result b/mysql-test/suite/rpl/r/rpl_concurrency_error.result new file mode 100644 index 00000000000..ba617667d5a --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_concurrency_error.result @@ -0,0 +1,119 @@ +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; +######################################################################## +# Environment +######################################################################## +CREATE TABLE t (i INT, PRIMARY KEY(i), f CHAR(8)) engine = Innodb; +CREATE TABLE n (d DATETIME, f CHAR(32)) engine = MyIsam; +CREATE TRIGGER tr AFTER UPDATE ON t FOR EACH ROW +BEGIN +INSERT INTO n VALUES ( now(), concat( 'updated t: ', old.f, ' -> ', new.f ) ); +END | +INSERT INTO t VALUES (4,'black'), (2,'red'), (3,'yelow'), (1,'cyan'); +######################################################################## +# Testing ER_LOCK_WAIT_TIMEOUT +######################################################################## +SET AUTOCOMMIT = 1; +BEGIN; +UPDATE t SET f = 'yellow 2' WHERE i = 3; +SET AUTOCOMMIT = 1; +BEGIN; +UPDATE t SET f = 'magenta 2' WHERE f = 'red'; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +INSERT INTO t VALUES (5 + (2 * 10),"brown"); +INSERT INTO n VALUES (now(),"brown"); +COMMIT; +ROLLBACK; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'magenta 2' WHERE f = 'red' +master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'yellow 2' WHERE i = 3 +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO t VALUES (5 + (2 * 10),"brown") +master-bin.000001 # Query # # use `test`; INSERT INTO n VALUES (now(),"brown") +master-bin.000001 # Query # # ROLLBACK +SET AUTOCOMMIT = 1; +BEGIN; +UPDATE t SET f = 'gray 2' WHERE i = 3; +SET AUTOCOMMIT = 1; +BEGIN; +UPDATE t SET f = 'dark blue 2' WHERE f = 'red'; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +INSERT INTO t VALUES (6 + (2 * 10),"brown"); +INSERT INTO n VALUES (now(),"brown"); +COMMIT; +COMMIT; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'dark blue 2' WHERE f = 'red' +master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'gray 2' WHERE i = 3 +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO t VALUES (6 + (2 * 10),"brown") +master-bin.000001 # Query # # use `test`; INSERT INTO n VALUES (now(),"brown") +master-bin.000001 # Xid # # COMMIT /* XID */ +SET AUTOCOMMIT = 0; +UPDATE t SET f = 'yellow 1' WHERE i = 3; +SET AUTOCOMMIT = 0; +UPDATE t SET f = 'magenta 1' WHERE f = 'red'; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +INSERT INTO t VALUES (5 + (1 * 10),"brown"); +INSERT INTO n VALUES (now(),"brown"); +COMMIT; +ROLLBACK; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'magenta 1' WHERE f = 'red' +master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'yellow 1' WHERE i = 3 +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO t VALUES (5 + (1 * 10),"brown") +master-bin.000001 # Query # # use `test`; INSERT INTO n VALUES (now(),"brown") +master-bin.000001 # Query # # ROLLBACK +SET AUTOCOMMIT = 0; +UPDATE t SET f = 'gray 1' WHERE i = 3; +SET AUTOCOMMIT = 0; +UPDATE t SET f = 'dark blue 1' WHERE f = 'red'; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +INSERT INTO t VALUES (6 + (1 * 10),"brown"); +INSERT INTO n VALUES (now(),"brown"); +COMMIT; +COMMIT; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'dark blue 1' WHERE f = 'red' +master-bin.000001 # Query # # ROLLBACK +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'gray 1' WHERE i = 3 +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO t VALUES (6 + (1 * 10),"brown") +master-bin.000001 # Query # # use `test`; INSERT INTO n VALUES (now(),"brown") +master-bin.000001 # Xid # # COMMIT /* XID */ +source include/diff_master_slave.inc; +source include/diff_master_slave.inc; +######################################################################## +# Cleanup +######################################################################## +DROP TRIGGER tr; +DROP TABLE t; +DROP TABLE n; diff --git a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result index 1e795a85ce1..033f71c16b7 100644 --- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result +++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result @@ -836,178 +836,178 @@ master-bin.000001 # Format_desc 1 # Server ver: # master-bin.000001 # Query 1 # CREATE DATABASE test_rpl master-bin.000001 # Query 1 # use `test_rpl`; CREATE TABLE t1 (a int auto_increment not null, b char(254), PRIMARY KEY(a)) ENGINE=innodb master-bin.000001 # Query 1 # use `test_rpl`; CREATE TABLE t2 (a int auto_increment not null, b char(254), PRIMARY KEY(a)) ENGINE=innodb -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 't1, text 1') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(2, 't1, text 2') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t2 VALUES(1, 't2, text 1') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 WHERE a = 1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test_rpl.t2) master-bin.000001 # Delete_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 't1, text 1') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test_rpl.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t2 SELECT * FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t2 VALUES (1, 't1, text 1') ON DUPLICATE KEY UPDATE b = 't2, text 1' master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 WHERE a = 2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 WHERE a = 2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Begin_load_query 1 # ;file_id=#;block_len=# master-bin.000001 # Execute_load_query 1 # use `test_rpl`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/rpl_mixed.dat' INTO TABLE t1 FIELDS TERMINATED BY '|' ;file_id=# master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 't1, text 1') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(2, 't1, text 2') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(3, 't1, text 3') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; REPLACE INTO t1 VALUES(1, 't1, text 11') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test_rpl.t1) master-bin.000001 # Update_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; REPLACE INTO t1 SET a=3, b='t1, text 33' master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 WHERE a = 2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 't1, text 1') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 'CCC') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(2, 'DDD') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t2 VALUES(1, 'DDD') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t2 VALUES(2, 'CCC') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 't1, text 1') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t2 VALUES(1, 't2, text 1') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 't1, text 1') master-bin.000001 # Xid 1 # # master-bin.000001 # Query 1 # use `test_rpl`; TRUNCATE t1 -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 't1, text 1') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t2 VALUES(1, 't2, text 1') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; UPDATE t1 SET b = 't1, text 1 updated' WHERE a = 1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; UPDATE t1, t2 SET t1.b = 'test', t2.b = 'test' master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES (1, 'start') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES (3, 'before savepoint s1') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES (5, 'before savepoint s2') master-bin.000001 # Query 1 # use `test_rpl`; SAVEPOINT s2 master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES (6, 'after savepoint s2') master-bin.000001 # Table_map 1 # table_id: # (test_rpl.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 WHERE a = 7 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # master-bin.000001 # Query 1 # use `test_rpl`; CREATE USER 'user_test_rpl'@'localhost' IDENTIFIED BY PASSWORD '*1111111111111111111111111111111111111111' @@ -1016,7 +1016,7 @@ master-bin.000001 # Query 1 # use `test_rpl`; REVOKE SELECT ON *.* FROM 'user_te master-bin.000001 # Query 1 # use `test_rpl`; SET PASSWORD FOR 'user_test_rpl'@'localhost'='*0000000000000000000000000000000000000000' master-bin.000001 # Query 1 # use `test_rpl`; RENAME USER 'user_test_rpl'@'localhost' TO 'user_test_rpl_2'@'localhost' master-bin.000001 # Query 1 # use `test_rpl`; DROP USER 'user_test_rpl_2'@'localhost' -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(100, 'test') master-bin.000001 # Xid 1 # # master-bin.000001 # Query 1 # use `test_rpl`; ANALYZE TABLE t1 @@ -1030,65 +1030,65 @@ master-bin.000001 # Query 1 # use `test_rpl`; CREATE DEFINER=`root`@`localhost` BEGIN UPDATE t1 SET b = UUID() WHERE a = 202; END -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(201, 'test 201') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; UPDATE t1 SET b = 'test' WHERE a = 201 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(202, 'test 202') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test_rpl.t1) master-bin.000001 # Update_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 WHERE a = 202 master-bin.000001 # Xid 1 # # master-bin.000001 # Query 1 # use `test_rpl`; ALTER PROCEDURE p1 COMMENT 'p1' master-bin.000001 # Query 1 # use `test_rpl`; DROP PROCEDURE p1 master-bin.000001 # Query 1 # use `test_rpl`; DROP PROCEDURE p2 -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # master-bin.000001 # Query 1 # use `test_rpl`; CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN INSERT INTO t2 SET a = NEW.a, b = NEW.b; END -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test_rpl.t1) master-bin.000001 # Table_map 1 # table_id: # (test_rpl.t2) master-bin.000001 # Write_rows 1 # table_id: # master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # master-bin.000001 # Query 1 # use `test_rpl`; DROP TRIGGER tr1 master-bin.000001 # Query 1 # use `test_rpl`; GRANT EVENT ON *.* TO 'root'@'localhost' -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 'test1') master-bin.000001 # Xid 1 # # master-bin.000001 # Query 1 # use `test_rpl`; CREATE EVENT e1 ON SCHEDULE EVERY '1' SECOND COMMENT 'e_second_comment' DO DELETE FROM t1 master-bin.000001 # Query 1 # use `test_rpl`; ALTER EVENT e1 RENAME TO e2 master-bin.000001 # Query 1 # use `test_rpl`; DROP EVENT e2 -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 'test1') master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(2, 'test2') master-bin.000001 # Xid 1 # # master-bin.000001 # Query 1 # use `test_rpl`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT * FROM t1 WHERE a = 1 @@ -1096,10 +1096,10 @@ master-bin.000001 # Query 1 # use `test_rpl`; CREATE ALGORITHM=UNDEFINED DEFINER master-bin.000001 # Query 1 # use `test_rpl`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT * FROM t1 WHERE a = 2 master-bin.000001 # Query 1 # use `test_rpl`; DROP VIEW v1 master-bin.000001 # Query 1 # use `test_rpl`; DROP VIEW v2 -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1 master-bin.000001 # Xid 1 # # -master-bin.000001 # Query 1 # use `test_rpl`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2 master-bin.000001 # Xid 1 # # drop database test_rpl; diff --git a/mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result b/mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result index 0551240eb8a..2e707fb62c1 100644 --- a/mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result +++ b/mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result @@ -19,10 +19,10 @@ 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 (a INT, b LONG) master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (1,1), (2,2) -master-bin.000001 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Query 1 # use `test`; COMMIT +master-bin.000001 # Query 1 # COMMIT **** On Slave **** SHOW SLAVE STATUS; Slave_IO_State # @@ -68,9 +68,9 @@ 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 (a INT, b LONG) slave-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES (1,1), (2,2) -slave-bin.000001 # Query 1 # use `test`; BEGIN +slave-bin.000001 # Query 1 # BEGIN slave-bin.000001 # Table_map 1 # table_id: # (test.t1) slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -slave-bin.000001 # Query 1 # use `test`; COMMIT +slave-bin.000001 # Query 1 # COMMIT DROP TABLE IF EXISTS t1; SET @@global.binlog_format= @old_binlog_format; diff --git a/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result b/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result index 1504c16bd7e..7920b9a981d 100644 --- a/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result +++ b/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result @@ -28,10 +28,10 @@ INSERT INTO t2 VALUES (3,3), (4,4); show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b INT) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT **** On Slave **** SHOW DATABASES; Database @@ -60,10 +60,10 @@ SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 4 Format_desc 1 106 Server ver: SERVER_VERSION, Binlog ver: 4 master-bin.000001 106 Query 1 192 use `test`; CREATE TABLE t1 (a INT) -master-bin.000001 192 Query 1 260 use `test`; BEGIN +master-bin.000001 192 Query 1 260 BEGIN master-bin.000001 260 Table_map 1 301 table_id: # (test.t1) master-bin.000001 301 Write_rows 1 340 table_id: # flags: STMT_END_F -master-bin.000001 340 Query 1 409 use `test`; COMMIT +master-bin.000001 340 Query 1 409 COMMIT DROP TABLE t1; ================ Test for BUG#17620 ================ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; diff --git a/mysql-test/suite/rpl/r/rpl_row_create_table.result b/mysql-test/suite/rpl/r/rpl_row_create_table.result index 29f58632fde..5bed9106009 100644 --- a/mysql-test/suite/rpl/r/rpl_row_create_table.result +++ b/mysql-test/suite/rpl/r/rpl_row_create_table.result @@ -150,10 +150,10 @@ a b SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info # 106 Query # 206 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE) -# 206 Query # 274 use `test`; BEGIN +# 206 Query # 274 BEGIN # 274 Table_map # 316 table_id: # (test.t7) # 316 Write_rows # 372 table_id: # flags: STMT_END_F -# 372 Query # 443 use `test`; ROLLBACK +# 372 Query # 443 ROLLBACK SELECT * FROM t7 ORDER BY a,b; a b 1 2 @@ -173,10 +173,10 @@ Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 106 Query # 174 use `test`; BEGIN +# 106 Query # 174 BEGIN # 174 Table_map # 216 table_id: # (test.t7) # 216 Write_rows # 272 table_id: # flags: STMT_END_F -# 272 Query # 343 use `test`; ROLLBACK +# 272 Query # 343 ROLLBACK SELECT * FROM t7 ORDER BY a,b; a b 1 2 @@ -299,35 +299,35 @@ a SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info # 106 Query # 192 use `test`; CREATE TABLE t1 (a INT) -# 192 Query # 260 use `test`; BEGIN +# 192 Query # 260 BEGIN # 260 Table_map # 301 table_id: # (test.t1) # 301 Write_rows # 345 table_id: # flags: STMT_END_F -# 345 Query # 414 use `test`; COMMIT -# 414 Query # 482 use `test`; BEGIN +# 345 Query # 414 COMMIT +# 414 Query # 482 BEGIN # 482 Query # 607 use `test`; CREATE TABLE `t2` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB # 607 Table_map # 648 table_id: # (test.t2) # 648 Write_rows # 692 table_id: # flags: STMT_END_F # 692 Xid # 719 COMMIT /* XID */ -# 719 Query # 787 use `test`; BEGIN +# 719 Query # 787 BEGIN # 787 Query # 912 use `test`; CREATE TABLE `t3` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB # 912 Table_map # 953 table_id: # (test.t3) # 953 Write_rows # 997 table_id: # flags: STMT_END_F # 997 Xid # 1024 COMMIT /* XID */ -# 1024 Query # 1092 use `test`; BEGIN +# 1024 Query # 1092 BEGIN # 1092 Query # 1217 use `test`; CREATE TABLE `t4` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB # 1217 Table_map # 1258 table_id: # (test.t4) # 1258 Write_rows # 1302 table_id: # flags: STMT_END_F # 1302 Xid # 1329 COMMIT /* XID */ -# 1329 Query # 1397 use `test`; BEGIN +# 1329 Query # 1397 BEGIN # 1397 Table_map # 1438 table_id: # (test.t1) # 1438 Write_rows # 1482 table_id: # flags: STMT_END_F -# 1482 Query # 1553 use `test`; ROLLBACK +# 1482 Query # 1553 ROLLBACK SHOW TABLES; Tables_in_test t1 @@ -393,12 +393,12 @@ a SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info # 106 Query # 192 use `test`; CREATE TABLE t1 (a INT) -# 192 Query # 260 use `test`; BEGIN +# 192 Query # 260 BEGIN # 260 Table_map # 301 table_id: # (test.t1) # 301 Write_rows # 345 table_id: # flags: STMT_END_F -# 345 Query # 414 use `test`; COMMIT +# 345 Query # 414 COMMIT # 414 Query # 514 use `test`; CREATE TABLE t2 (a INT) ENGINE=INNODB -# 514 Query # 582 use `test`; BEGIN +# 514 Query # 582 BEGIN # 582 Table_map # 623 table_id: # (test.t2) # 623 Write_rows # 667 table_id: # flags: STMT_END_F # 667 Table_map # 708 table_id: # (test.t2) @@ -431,12 +431,12 @@ SELECT * FROM t2 ORDER BY a; a SHOW BINLOG EVENTS FROM 106; Log_name Pos Event_type Server_id End_log_pos Info -# 106 Query # 174 use `test`; BEGIN +# 106 Query # 174 BEGIN # 174 Table_map # 215 table_id: # (test.t2) # 215 Write_rows # 259 table_id: # flags: STMT_END_F # 259 Table_map # 300 table_id: # (test.t2) # 300 Write_rows # 339 table_id: # flags: STMT_END_F -# 339 Query # 410 use `test`; ROLLBACK +# 339 Query # 410 ROLLBACK SELECT * FROM t2 ORDER BY a; a DROP TABLE t1,t2; @@ -468,12 +468,12 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # DROP DATABASE IF EXISTS mysqltest1 master-bin.000001 # Query # # CREATE DATABASE mysqltest1 master-bin.000001 # Query # # use `test`; CREATE TABLE mysqltest1.without_select (f1 BIGINT) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # use `test`; CREATE TABLE `mysqltest1`.`with_select` ( `f1` int(1) NOT NULL DEFAULT '0' ) master-bin.000001 # Table_map # # table_id: # (mysqltest1.with_select) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT DROP DATABASE mysqltest1; end of the tests diff --git a/mysql-test/suite/rpl/r/rpl_row_log.result b/mysql-test/suite/rpl/r/rpl_row_log.result index b76cc6aa15e..9593b009d1f 100644 --- a/mysql-test/suite/rpl/r/rpl_row_log.result +++ b/mysql-test/suite/rpl/r/rpl_row_log.result @@ -20,23 +20,23 @@ 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=MyISAM -master-bin.000001 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Query 1 # use `test`; COMMIT +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=MyISAM -master-bin.000001 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000001 # Query 1 # use `test`; COMMIT +master-bin.000001 # Query 1 # COMMIT show binlog events from 106 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=MyISAM show binlog events from 106 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=MyISAM -master-bin.000001 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # BEGIN show binlog events from 106 limit 2,1; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -192,26 +192,26 @@ insert into t2 values (1); show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; drop table t1 master-bin.000001 # Query # # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT master-bin.000001 # Rotate # # 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 t3 (a int)ENGINE=MyISAM master-bin.000002 # Query 1 # use `test`; create table t2 (n int)ENGINE=MyISAM -master-bin.000002 # Query 1 # use `test`; BEGIN +master-bin.000002 # Query 1 # BEGIN master-bin.000002 # Table_map 1 # table_id: # (test.t2) master-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F -master-bin.000002 # Query 1 # use `test`; COMMIT +master-bin.000002 # Query 1 # COMMIT show binary logs; Log_name File_size master-bin.000001 # @@ -224,26 +224,26 @@ 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=MyISAM -slave-bin.000001 # Query 1 # use `test`; BEGIN +slave-bin.000001 # Query 1 # BEGIN slave-bin.000001 # Table_map 1 # table_id: # (test.t1) slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -slave-bin.000001 # Query 1 # use `test`; COMMIT +slave-bin.000001 # Query 1 # 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=MyISAM -slave-bin.000001 # Query 1 # use `test`; BEGIN +slave-bin.000001 # Query 1 # BEGIN slave-bin.000001 # Table_map 1 # table_id: # (test.t1) slave-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -slave-bin.000001 # Query 1 # use `test`; COMMIT +slave-bin.000001 # Query 1 # COMMIT slave-bin.000001 # Query 1 # use `test`; create table t3 (a int)ENGINE=MyISAM 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 t2 (n int)ENGINE=MyISAM -slave-bin.000002 # Query 1 # use `test`; BEGIN +slave-bin.000002 # Query 1 # BEGIN slave-bin.000002 # Table_map 1 # table_id: # (test.t2) slave-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F -slave-bin.000002 # Query 1 # use `test`; COMMIT +slave-bin.000002 # Query 1 # COMMIT SHOW SLAVE STATUS; Slave_IO_State # Master_Host 127.0.0.1 @@ -301,14 +301,14 @@ insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id()); show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1(a int auto_increment primary key, b int) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT select * from t1; a b 1 1 diff --git a/mysql-test/suite/rpl/r/rpl_row_log_innodb.result b/mysql-test/suite/rpl/r/rpl_row_log_innodb.result index 809c50e1465..8526bad558b 100644 --- a/mysql-test/suite/rpl/r/rpl_row_log_innodb.result +++ b/mysql-test/suite/rpl/r/rpl_row_log_innodb.result @@ -20,13 +20,13 @@ 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 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F 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 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # COMMIT /* XID */ @@ -36,7 +36,7 @@ master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_in show binlog events from 106 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 # Query 1 # use `test`; BEGIN +master-bin.000001 # Query 1 # BEGIN show binlog events from 106 limit 2,1; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -192,13 +192,13 @@ insert into t2 values (1); show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Query # # use `test`; drop table t1 master-bin.000001 # Query # # use `test`; create table t1 (word char(20) not null)ENGINE=InnoDB -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ @@ -208,7 +208,7 @@ 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 t3 (a int)ENGINE=InnoDB master-bin.000002 # Query 1 # use `test`; create table t2 (n int)ENGINE=InnoDB -master-bin.000002 # Query 1 # use `test`; BEGIN +master-bin.000002 # Query 1 # BEGIN master-bin.000002 # Table_map 1 # table_id: # (test.t2) master-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000002 # Xid 1 # COMMIT /* XID */ @@ -301,14 +301,14 @@ insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id()); show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1(a int auto_increment primary key, b int) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT select * from t1; a b 1 1 diff --git a/mysql-test/suite/rpl/r/rpl_row_reset_slave.result b/mysql-test/suite/rpl/r/rpl_row_reset_slave.result index 6126ec4bacc..fa40d8760a8 100644 --- a/mysql-test/suite/rpl/r/rpl_row_reset_slave.result +++ b/mysql-test/suite/rpl/r/rpl_row_reset_slave.result @@ -174,3 +174,26 @@ start slave; show status like 'slave_open_temp_tables'; Variable_name Value Slave_open_temp_tables 0 +stop slave; +reset slave; +*** errno must be zero: 0 *** +change master to master_user='impossible_user_name'; +start slave; +ONE +1 +include/stop_slave.inc +change master to master_user='root'; +include/start_slave.inc +*** last errno must be zero: 0 *** +*** last error must be blank: *** +include/stop_slave.inc +change master to master_user='impossible_user_name'; +start slave; +ONE +1 +include/stop_slave.inc +reset slave; +*** io last errno must be zero: 0 *** +*** io last error must be blank: *** +*** sql last errno must be zero: 0 *** +*** sql last error must be blank: *** diff --git a/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result b/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result index a158fb5dfc4..3ed14a9cb6b 100644 --- a/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result +++ b/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result @@ -3,4 +3,4 @@ MASTER_CONNECT_RETRY=1, MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_MYPORT; START SLAVE; -Unable to use slave's temporary directory ../../../error - Can't read dir of '../../../error' (Errcode: 2) +12 diff --git a/mysql-test/suite/rpl/r/rpl_slave_skip.result b/mysql-test/suite/rpl/r/rpl_slave_skip.result index 747e8f235a8..6148de5d954 100644 --- a/mysql-test/suite/rpl/r/rpl_slave_skip.result +++ b/mysql-test/suite/rpl/r/rpl_slave_skip.result @@ -17,20 +17,20 @@ show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b INT) master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (c INT, d INT) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Update_rows # # table_id: # master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT SELECT * FROM t1; a b 1 1 @@ -39,8 +39,8 @@ a b SELECT * FROM t2; c d 1 2 -2 16 -3 54 +2 8 +3 18 **** On Slave **** START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=762; SHOW SLAVE STATUS; @@ -50,7 +50,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 1133 +Read_Master_Log_Pos 1115 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 diff --git a/mysql-test/suite/rpl/r/rpl_stm_loadfile.result b/mysql-test/suite/rpl/r/rpl_stm_loadfile.result index 72f58268d5f..ca76695f4d4 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_loadfile.result +++ b/mysql-test/suite/rpl/r/rpl_stm_loadfile.result @@ -10,7 +10,7 @@ CREATE TABLE test.t1 (a INT, blob_column LONGBLOB, PRIMARY KEY(a)); INSERT INTO test.t1 VALUES(1,'test'); UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=1; Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. create procedure test.p1() begin INSERT INTO test.t1 VALUES(2,'test'); @@ -18,7 +18,7 @@ UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=2; end| CALL test.p1(); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. SELECT * FROM test.t1 ORDER BY blob_column; a blob_column 1 abase diff --git a/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result b/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result index bb89d150af7..78d9d7c41eb 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result +++ b/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result @@ -174,3 +174,26 @@ start slave; show status like 'slave_open_temp_tables'; Variable_name Value Slave_open_temp_tables 1 +stop slave; +reset slave; +*** errno must be zero: 0 *** +change master to master_user='impossible_user_name'; +start slave; +ONE +1 +include/stop_slave.inc +change master to master_user='root'; +include/start_slave.inc +*** last errno must be zero: 0 *** +*** last error must be blank: *** +include/stop_slave.inc +change master to master_user='impossible_user_name'; +start slave; +ONE +1 +include/stop_slave.inc +reset slave; +*** io last errno must be zero: 0 *** +*** io last error must be blank: *** +*** sql last errno must be zero: 0 *** +*** sql last error must be blank: *** diff --git a/mysql-test/suite/rpl/r/rpl_temporary.result b/mysql-test/suite/rpl/r/rpl_temporary.result index 8a9ddaec9f6..631eb0677b0 100644 --- a/mysql-test/suite/rpl/r/rpl_temporary.result +++ b/mysql-test/suite/rpl/r/rpl_temporary.result @@ -6,6 +6,25 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; call mtr.add_suppression("Slave: Can\'t find record in \'user\' Error_code: 1032"); reset master; +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE t1 (a char(1)); +INSERT INTO t1 VALUES ('a'); +include/stop_slave.inc +include/start_slave.inc +INSERT INTO t1 VALUES ('b'); +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE `t1`(`a` tinyint,`b` char(1))engine=myisam; +INSERT INTO `t1` set `a`=128,`b`='128'; +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 +include/stop_slave.inc +include/start_slave.inc +INSERT INTO `t1` set `a`=128,`b`='128'; +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 +DROP TABLE t1; SET @save_select_limit=@@session.sql_select_limit; SET @@session.sql_select_limit=10, @@session.pseudo_thread_id=100; ERROR 42000: Access denied; you need the SUPER privilege for this operation diff --git a/mysql-test/suite/rpl/r/rpl_udf.result b/mysql-test/suite/rpl/r/rpl_udf.result index 56df5b30d93..ccf16271d01 100644 --- a/mysql-test/suite/rpl/r/rpl_udf.result +++ b/mysql-test/suite/rpl/r/rpl_udf.result @@ -182,19 +182,19 @@ CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM; affected rows: 0 INSERT INTO t1 VALUES(myfunc_int(100), myfunc_double(50.00)); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(10), myfunc_double(5.00)); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(200), myfunc_double(25.00)); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(1), myfunc_double(500.00)); Warnings: -Note 1592 Statement is not safe to log in statement format. +Note 1592 Statement may not be safe to log in statement format. affected rows: 1 SELECT * FROM t1 ORDER BY sum; sum price diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def index b7cb6da8127..af8eef764ed 100644 --- a/mysql-test/suite/rpl/t/disabled.def +++ b/mysql-test/suite/rpl/t/disabled.def @@ -10,4 +10,6 @@ # ############################################################################## -rpl_cross_version : BUG#42311 2009-03-27 joro rpl_cross_version fails on macosx +rpl_cross_version : Bug#42311 2009-03-27 joro rpl_cross_version fails on macosx +rpl_init_slave : Bug#44920 2009-07006 pcrews MTR2 is not processing master.opt input properly on Windows. *Must be done this way due to the nature of the bug* + diff --git a/mysql-test/suite/rpl/t/rpl_begin_commit_rollback-slave.opt b/mysql-test/suite/rpl/t/rpl_begin_commit_rollback-slave.opt new file mode 100644 index 00000000000..b4abda5893f --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_begin_commit_rollback-slave.opt @@ -0,0 +1 @@ +--innodb --replicate-do-db=db1 diff --git a/mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test b/mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test new file mode 100644 index 00000000000..ec56e6a4f38 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_begin_commit_rollback.test @@ -0,0 +1,125 @@ +source include/master-slave.inc; +source include/have_innodb.inc; +source include/have_binlog_format_statement.inc; + +disable_warnings; +DROP DATABASE IF EXISTS db1; +enable_warnings; + +CREATE DATABASE db1; + +use db1; + +CREATE TABLE db1.t1 (a INT) ENGINE=InnoDB; +CREATE TABLE db1.t2 (s CHAR(255)) ENGINE=MyISAM; + +sync_slave_with_master; +source include/stop_slave.inc; +connection master; +echo [on master]; + +DELIMITER //; +CREATE PROCEDURE db1.p1 () +BEGIN + INSERT INTO t1 VALUES (1); + INSERT INTO t1 VALUES (2); + INSERT INTO t1 VALUES (3); + INSERT INTO t1 VALUES (4); + INSERT INTO t1 VALUES (5); +END// + +CREATE PROCEDURE db1.p2 () +BEGIN + INSERT INTO t1 VALUES (6); + INSERT INTO t1 VALUES (7); + INSERT INTO t1 VALUES (8); + INSERT INTO t1 VALUES (9); + INSERT INTO t1 VALUES (10); + INSERT INTO t2 VALUES ('executed db1.p2()'); +END// +DELIMITER ;// + +INSERT INTO db1.t2 VALUES ('before call db1.p1()'); + +# Note: the master_log_pos is set to be the position of the BEGIN + 1, +# so before fix of BUG#43263 if the BEGIN is ignored, then all the +# INSERTS in p1 will be replicated in AUTOCOMMIT=1 mode and the slave +# SQL thread will stop right before the first INSERT. After fix of +# BUG#43263, BEGIN will not be ignored by the replication db rules, +# and then the whole transaction will be executed before slave SQL +# stop. +let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1); +let $master_pos= `SELECT $master_pos + 1`; + +use test; +BEGIN; +CALL db1.p1(); +COMMIT; + +# The position where the following START SLAVE UNTIL will stop at +let $master_end_trans_pos= query_get_value(SHOW MASTER STATUS, Position, 1); + +INSERT INTO db1.t2 VALUES ('after call db1.p1()'); +SELECT * FROM db1.t1; +SELECT * FROM db1.t2; + +connection slave; +echo [on slave]; + +replace_result $master_pos MASTER_POS; +eval start slave until master_log_file='master-bin.000001', master_log_pos=$master_pos; +source include/wait_for_slave_sql_to_stop.inc; +let $slave_sql_stop_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1); +let $result= query_get_value(SELECT $slave_sql_stop_pos - $master_end_trans_pos as result, result, 1); + +--echo # +--echo # If we got non-zero here, then we're suffering BUG#43263 +--echo # +eval SELECT $result as 'Must be 0'; +SELECT * from db1.t1; +SELECT * from db1.t2; + +connection master; +echo [on master]; + +INSERT INTO db1.t2 VALUES ('before call db1.p2()'); + +# See comments above. +let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1); +let $master_pos= `SELECT $master_pos + 1`; + +BEGIN; +CALL db1.p2(); +disable_warnings; +ROLLBACK; +enable_warnings; +let $master_end_trans_pos= query_get_value(SHOW MASTER STATUS, Position, 1); + +INSERT INTO db1.t2 VALUES ('after call db1.p2()'); +SELECT * FROM db1.t1; +SELECT * FROM db1.t2; + +connection slave; +echo [on slave]; + +replace_result $master_pos MASTER_POS; +eval start slave until master_log_file='master-bin.000001', master_log_pos=$master_pos; +source include/wait_for_slave_sql_to_stop.inc; + +let $slave_sql_stop_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1); +let $result= query_get_value(SELECT $slave_sql_stop_pos - $master_end_trans_pos as result, result, 1); + +--echo # +--echo # If we got non-zero here, then we're suffering BUG#43263 +--echo # +eval SELECT $result as 'Must be 0'; +SELECT * from db1.t1; +SELECT * from db1.t2; + +--echo # +--echo # Clean up +--echo # +connection master; +DROP DATABASE db1; +connection slave; +DROP DATABASE db1; diff --git a/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size-master.opt b/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size-master.opt new file mode 100644 index 00000000000..45631525481 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size-master.opt @@ -0,0 +1 @@ +--binlog_cache_size=4096 --max_binlog_cache_size=7680 diff --git a/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test b/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test new file mode 100644 index 00000000000..e1f1f8c54bb --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test @@ -0,0 +1,395 @@ +######################################################################################## +# This test verifies if the binlog is not corrupted when the cache buffer is not +# big enough to accommodate the changes and is divided in five steps: +# +# 1 - Single Statements: +# 1.1 - Single statement on transactional table. +# 1.2 - Single statement on non-transactional table. +# 1.3 - Single statement on both transactional and non-transactional tables. +# In both 1.2 and 1.3, an incident event is logged to notify the user that the +# master and slave are diverging. +# +# 2 - Transactions ended by an implicit commit. +# +# 3 - Transactions ended by a COMMIT. +# +# 4 - Transactions ended by a ROLLBACK. +# +# 5 - Transactions with a failing statement that updates a non-transactional +# table. In this case, a failure means that the statement does not get into +# the cache and an incident event is logged to notify the user that the master +# and slave are diverging. +# +######################################################################################## + +######################################################################################## +# Configuring the environment +######################################################################################## +--source include/have_innodb.inc +--source include/master-slave.inc +--source include/not_embedded.inc +--source include/not_windows.inc + +CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb; +CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam; +CREATE TABLE t3(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb; + +let $data = `select concat('"', repeat('a',2000), '"')`; + +--echo ######################################################################################## +--echo # 1 - SINGLE STATEMENT +--echo ######################################################################################## + +connection master; + +--echo *** Single statement on transactional table *** +--disable_query_log +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +eval INSERT INTO t1 (a, data) VALUES (1, + CONCAT($data, $data, $data, $data, $data)); +--enable_query_log + +--echo *** Single statement on non-transactional table *** +--echo *** After WL#2687 the difference between STATEMENT/MIXED and ROW will not exist. *** +--disable_query_log +--disable_warnings +if (`SELECT @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`) +{ + eval INSERT INTO t2 (a, data) VALUES (2, + CONCAT($data, $data, $data, $data, $data, $data)); + --echo Got one of the listed errors +} +if (`SELECT @@binlog_format = 'ROW'`) +{ + --error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE + eval INSERT INTO t2 (a, data) VALUES (2, + CONCAT($data, $data, $data, $data, $data, $data)); + + connection slave; + --source include/wait_for_slave_sql_to_stop.inc + SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; + START SLAVE SQL_THREAD; + --source include/wait_for_slave_sql_to_start.inc +} +--enable_warnings +--enable_query_log + +connection master; + +--disable_query_log +eval INSERT INTO t1 (a, data) VALUES (3, $data); +eval INSERT INTO t1 (a, data) VALUES (4, $data); +eval INSERT INTO t1 (a, data) VALUES (5, $data); +eval INSERT INTO t2 (a, data) VALUES (3, $data); +eval INSERT INTO t2 (a, data) VALUES (4, $data); +eval INSERT INTO t2 (a, data) VALUES (5, $data); +--enable_query_log + +--echo *** Single statement on both transactional and non-transactional tables. *** +--echo *** After WL#2687 we will be able to change the order of the tables. *** +--disable_query_log +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +eval UPDATE t2, t1 SET t2.data = CONCAT($data, $data, $data, $data), + t1.data = CONCAT($data, $data, $data, $data); +--enable_query_log + +connection slave; +--source include/wait_for_slave_sql_to_stop.inc +SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; +START SLAVE SQL_THREAD; +--source include/wait_for_slave_sql_to_start.inc + +#--echo ######################################################################################## +#--echo # 2 - BEGIN - IMPLICIT COMMIT by DDL +#--echo ######################################################################################## + +connection master; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; + +BEGIN; +--disable_query_log +--eval INSERT INTO t1 (a, data) VALUES (1, $data); +--eval INSERT INTO t1 (a, data) VALUES (2, $data); +--eval INSERT INTO t1 (a, data) VALUES (3, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (4, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (5, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (6, $data); +--eval INSERT INTO t1 (a, data) VALUES (7, 's'); +--eval INSERT INTO t2 (a, data) VALUES (8, 's'); +--eval INSERT INTO t1 (a, data) VALUES (9, 's'); +--enable_query_log + +--disable_query_log +ALTER TABLE t3 ADD COLUMN d int; +--enable_query_log + +--disable_query_log +--eval INSERT INTO t2 (a, data) VALUES (10, $data); +--eval INSERT INTO t2 (a, data) VALUES (11, $data); +--eval INSERT INTO t2 (a, data) VALUES (12, $data); +--eval INSERT INTO t2 (a, data) VALUES (13, $data); +--enable_query_log + +BEGIN; +--disable_query_log +--eval INSERT INTO t1 (a, data) VALUES (14, $data); +--eval INSERT INTO t1 (a, data) VALUES (15, $data); +--eval INSERT INTO t1 (a, data) VALUES (16, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (17, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (18, $data); +--eval INSERT INTO t1 (a, data) VALUES (19, 's'); +--eval INSERT INTO t2 (a, data) VALUES (20, 's'); +--eval INSERT INTO t1 (a, data) VALUES (21, 's'); +--enable_query_log + +if (`SELECT @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`) +{ + --disable_query_log + CREATE TABLE t4 SELECT * FROM t1; + --enable_query_log + --echo Got one of the listed errors +} +if (`SELECT @@binlog_format = 'ROW'`) +{ + --disable_query_log + --error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE + CREATE TABLE t4 SELECT * FROM t1; + --enable_query_log +} + +--disable_query_log +--eval INSERT INTO t2 (a, data) VALUES (15, $data); +--enable_query_log + +BEGIN; +--disable_query_log +--eval INSERT INTO t1 (a, data) VALUES (22, $data); +--eval INSERT INTO t1 (a, data) VALUES (23, $data); +--eval INSERT INTO t1 (a, data) VALUES (24, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (25, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (26, $data); +--eval INSERT INTO t1 (a, data) VALUES (27, 's'); +--eval INSERT INTO t2 (a, data) VALUES (28, 's'); +--eval INSERT INTO t1 (a, data) VALUES (29, 's'); +--enable_query_log + +--disable_query_log +CREATE TABLE t5 (a int); +--enable_query_log + +let $diff_statement= SELECT * FROM t1; +--source include/diff_master_slave.inc + +--echo ######################################################################################## +--echo # 3 - BEGIN - COMMIT +--echo ######################################################################################## + +connection master; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; + +BEGIN; +--disable_query_log +--eval INSERT INTO t1 (a, data) VALUES (1, $data); +--eval INSERT INTO t1 (a, data) VALUES (2, $data); +--eval INSERT INTO t1 (a, data) VALUES (3, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (4, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (5, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (6, $data); +--eval INSERT INTO t1 (a, data) VALUES (7, 's'); +--eval INSERT INTO t2 (a, data) VALUES (8, 's'); +--eval INSERT INTO t1 (a, data) VALUES (9, 's'); +--enable_query_log +COMMIT; + +let $diff_statement= SELECT * FROM t1; +--source include/diff_master_slave.inc + +--echo ######################################################################################## +--echo # 4 - BEGIN - ROLLBACK +--echo ######################################################################################## + +connection master; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; + +BEGIN; +--disable_query_log +--eval INSERT INTO t1 (a, data) VALUES (1, $data); +--eval INSERT INTO t1 (a, data) VALUES (2, $data); +--eval INSERT INTO t1 (a, data) VALUES (3, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (4, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (5, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (6, $data); +--eval INSERT INTO t1 (a, data) VALUES (7, 's'); +--eval INSERT INTO t2 (a, data) VALUES (8, 's'); +--eval INSERT INTO t1 (a, data) VALUES (9, 's'); +--enable_query_log +ROLLBACK; + +let $diff_statement= SELECT * FROM t1; +--source include/diff_master_slave.inc + +--echo ######################################################################################## +--echo # 5 - PROCEDURE +--echo ######################################################################################## + +connection master; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; + +DELIMITER //; + +CREATE PROCEDURE p1(pd VARCHAR(30000)) +BEGIN + INSERT INTO t1 (a, data) VALUES (1, pd); + INSERT INTO t1 (a, data) VALUES (2, pd); + INSERT INTO t1 (a, data) VALUES (3, pd); + INSERT INTO t1 (a, data) VALUES (4, pd); + INSERT INTO t1 (a, data) VALUES (5, 's'); +END// + +DELIMITER ;// + +TRUNCATE TABLE t1; + +--disable_query_log +eval CALL p1($data); +--enable_query_log + +TRUNCATE TABLE t1; + +BEGIN; +--disable_query_log +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +eval CALL p1($data); +--enable_query_log +COMMIT; + +TRUNCATE TABLE t1; + +BEGIN; +--disable_query_log +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +eval CALL p1($data); +--enable_query_log +ROLLBACK; + +let $diff_statement= SELECT * FROM t1; +--source include/diff_master_slave.inc + +--echo ######################################################################################## +--echo # 6 - XID +--echo ######################################################################################## + +connection master; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; + +BEGIN; +--disable_query_log +--eval INSERT INTO t1 (a, data) VALUES (1, $data); +--eval INSERT INTO t1 (a, data) VALUES (2, $data); +--eval INSERT INTO t1 (a, data) VALUES (3, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (4, $data); +SAVEPOINT sv; +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (5, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (6, $data); +--eval INSERT INTO t1 (a, data) VALUES (7, 's'); +--eval INSERT INTO t2 (a, data) VALUES (8, 's'); +--eval INSERT INTO t1 (a, data) VALUES (9, 's'); +--enable_query_log +ROLLBACK TO sv; +COMMIT; + +let $diff_statement= SELECT * FROM t1; +--source include/diff_master_slave.inc + +--echo ######################################################################################## +--echo # 7 - NON-TRANS TABLE +--echo ######################################################################################## + +connection master; +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +TRUNCATE TABLE t3; + +BEGIN; +--disable_query_log +--eval INSERT INTO t1 (a, data) VALUES (1, $data); +--eval INSERT INTO t1 (a, data) VALUES (2, $data); +--eval INSERT INTO t2 (a, data) VALUES (3, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (4, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (5, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (6, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (7, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval UPDATE t2 SET data= CONCAT($data, $data); +--eval INSERT INTO t1 (a, data) VALUES (8, 's'); +--eval INSERT INTO t1 (a, data) VALUES (9, 's'); +--eval INSERT INTO t2 (a, data) VALUES (10, 's'); +--eval INSERT INTO t1 (a, data) VALUES (11, 's'); +--enable_query_log +COMMIT; + +BEGIN; +--disable_query_log +--eval INSERT INTO t1 (a, data) VALUES (15, $data); +--eval INSERT INTO t1 (a, data) VALUES (16, $data); +--eval INSERT INTO t2 (a, data) VALUES (17, $data); +--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE +--eval INSERT INTO t1 (a, data) VALUES (18, $data); +--enable_query_log +COMMIT; + +connection slave; +--source include/wait_for_slave_sql_to_stop.inc + +--echo ######################################################################################## +--echo # CLEAN +--echo ######################################################################################## + +--disable_warnings +connection master; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +DROP TABLE IF EXISTS t4; +DROP TABLE IF EXISTS t5; +DROP TABLE IF EXISTS t6; +DROP PROCEDURE p1; +connection slave; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +DROP TABLE IF EXISTS t4; +DROP TABLE IF EXISTS t5; +DROP TABLE IF EXISTS t6; +DROP PROCEDURE p1; +--enable_warnings diff --git a/mysql-test/suite/rpl/t/rpl_concurrency_error-master.opt b/mysql-test/suite/rpl/t/rpl_concurrency_error-master.opt new file mode 100644 index 00000000000..a6ef074a120 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_concurrency_error-master.opt @@ -0,0 +1 @@ +--innodb-lock-wait-timeout=1 diff --git a/mysql-test/suite/rpl/t/rpl_concurrency_error.test b/mysql-test/suite/rpl/t/rpl_concurrency_error.test new file mode 100644 index 00000000000..da2951afb1a --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_concurrency_error.test @@ -0,0 +1,149 @@ +############################################################################### +#BUG#44581 Slave stops when transaction with non-transactional table gets +#lock wait timeout +# +# In STMT and MIXED modes, a statement that changes both non-transactional and +# transactional tables must be written to the binary log whenever there are +# changes to non-transactional tables. This means that the statement gets into +# the # binary log even when the changes to the transactional tables fail. In +# particular, in the presence of a failure such statement is annotated with the +# error number and wrapped in a begin/rollback. On the slave, while applying +# the statement, it is expected the same failure and the rollback prevents the +# transactional changes to be persisted. + +# This test aims to verify if a statement that updates both transactional and +# non-transacitonal tables and fails due to concurrency problems is correctly +# processed by the slave in the sense that the statements get into the binary +# log, the error is ignored and only the non-transactional tables are changed. +############################################################################### + +--source include/master-slave.inc +--source include/have_innodb.inc +--source include/have_binlog_format_statement.inc + +--echo ######################################################################## +--echo # Environment +--echo ######################################################################## +connection master; + +CREATE TABLE t (i INT, PRIMARY KEY(i), f CHAR(8)) engine = Innodb; +CREATE TABLE n (d DATETIME, f CHAR(32)) engine = MyIsam; + +DELIMITER |; +CREATE TRIGGER tr AFTER UPDATE ON t FOR EACH ROW +BEGIN + INSERT INTO n VALUES ( now(), concat( 'updated t: ', old.f, ' -> ', new.f ) ); +END | +DELIMITER ;| + +INSERT INTO t VALUES (4,'black'), (2,'red'), (3,'yelow'), (1,'cyan'); + +connect (conn1, 127.0.0.1,root,,); +connect (conn2, 127.0.0.1,root,,); + +--echo ######################################################################## +--echo # Testing ER_LOCK_WAIT_TIMEOUT +--echo ######################################################################## + +let $type=2; + +while ($type) +{ + let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1); + connection conn1; + if (`select $type = 2`) + { + SET AUTOCOMMIT = 1; + BEGIN; + } + if (`select $type = 1`) + { + SET AUTOCOMMIT = 0; + } + eval UPDATE t SET f = 'yellow $type' WHERE i = 3; + + connection conn2; + if (`select $type = 2`) + { + SET AUTOCOMMIT = 1; + BEGIN; + } + if (`select $type = 1`) + { + SET AUTOCOMMIT = 0; + } + --error ER_LOCK_WAIT_TIMEOUT + eval UPDATE t SET f = 'magenta $type' WHERE f = 'red'; + eval INSERT INTO t VALUES (5 + ($type * 10),"brown"); + INSERT INTO n VALUES (now(),"brown"); + + connection conn1; + COMMIT; + + connection conn2; + ROLLBACK; + --source include/show_binlog_events.inc + + let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1); + connection conn1; + if (`select $type = 2`) + { + SET AUTOCOMMIT = 1; + BEGIN; + } + if (`select $type = 1`) + { + SET AUTOCOMMIT = 0; + } + eval UPDATE t SET f = 'gray $type' WHERE i = 3; + + connection conn2; + if (`select $type = 2`) + { + SET AUTOCOMMIT = 1; + BEGIN; + } + if (`select $type = 1`) + { + SET AUTOCOMMIT = 0; + } + --error ER_LOCK_WAIT_TIMEOUT + eval UPDATE t SET f = 'dark blue $type' WHERE f = 'red'; + eval INSERT INTO t VALUES (6 + ($type * 10),"brown"); + INSERT INTO n VALUES (now(),"brown"); + + connection conn1; + COMMIT; + + connection conn2; + COMMIT; + --source include/show_binlog_events.inc + + dec $type; +} + +connection master; +sync_slave_with_master; + +connection master; +let $diff_statement= SELECT * FROM t order by i; +source include/diff_master_slave.inc; + +connection master; +let $diff_statement= SELECT * FROM n order by d, f; +source include/diff_master_slave.inc; + +--echo ######################################################################## +--echo # Cleanup +--echo ######################################################################## + +connection master; +DROP TRIGGER tr; +DROP TABLE t; +DROP TABLE n; + +sync_slave_with_master; + +connection master; +disconnect conn1; +disconnect conn2; diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test index 3a80fa43f20..68c41abf537 100644 --- a/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test +++ b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test @@ -20,5 +20,5 @@ eval CHANGE MASTER TO MASTER_USER='root', START SLAVE; source include/wait_for_slave_sql_to_stop.inc; -let $error=query_get_value("show slave status", Last_SQL_Error, 1); -echo $error; +let $errno=query_get_value("show slave status", Last_SQL_Errno, 1); +echo $errno; diff --git a/mysql-test/suite/rpl/t/rpl_sp.test b/mysql-test/suite/rpl/t/rpl_sp.test index ec6464fb095..9be630e9ae8 100644 --- a/mysql-test/suite/rpl/t/rpl_sp.test +++ b/mysql-test/suite/rpl/t/rpl_sp.test @@ -642,3 +642,6 @@ drop procedure ` mysqltestbug36570_p2`; drop function mysqltestbug36570_f1; --echo End of 5.0 tests --echo End of 5.1 tests + +# Cleanup +sync_slave_with_master; diff --git a/mysql-test/suite/rpl/t/rpl_temporary.test b/mysql-test/suite/rpl/t/rpl_temporary.test index 4e83d39710c..a59e4f2fd21 100644 --- a/mysql-test/suite/rpl/t/rpl_temporary.test +++ b/mysql-test/suite/rpl/t/rpl_temporary.test @@ -22,6 +22,77 @@ call mtr.add_suppression("Slave: Can\'t find record in \'user\' Error_code: 1032 sync_with_master; reset master; + +# ################################################################## +# BUG#41725: slave crashes when inserting into temporary table after +# stop/start slave +# +# This test checks that both reported issues (assertion failure and +# crash) go away. It is implemented as follows: +# +# case 1: assertion failure +# i) create and insert into temporary table on master +# ii) sync slave with master +# iii) stop and restart slave +# iv) insert into master another value +# v) sync slave with master +# +# +# case 2: crash (SIGSEV) +# i) create and insert into temporary table on master (insert +# produces warnings) +# ii) sync slave with master +# iii) stop and restart slave +# iv) insert into master more values +# v) sync slave with master + +# case 1: Assertion in Field_string::store() failed because current +# thread reference differed from table->in_use after slave +# restart + +connection master; + +disable_warnings; +DROP TABLE IF EXISTS t1; +enable_warnings; + +CREATE TEMPORARY TABLE t1 (a char(1)); +INSERT INTO t1 VALUES ('a'); +sync_slave_with_master; + +source include/stop_slave.inc; +source include/start_slave.inc; + +connection master; +INSERT INTO t1 VALUES ('b'); +sync_slave_with_master; + +# case 2: crash on sp_rcontext::find_handler because it used +# reference to invalid THD object after slave restart + +connection master; + +disable_warnings; +DROP TABLE IF EXISTS t1; +enable_warnings; +CREATE TEMPORARY TABLE `t1`(`a` tinyint,`b` char(1))engine=myisam; +INSERT INTO `t1` set `a`=128,`b`='128'; + +sync_slave_with_master; + +source include/stop_slave.inc; +source include/start_slave.inc; + +connection master; +INSERT INTO `t1` set `a`=128,`b`='128'; +sync_slave_with_master; + +# cleanup + +connection master; +DROP TABLE t1; +sync_slave_with_master; + connection master; connect (con1,localhost,root,,); diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_log.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_log.result index 5b6ca5f5097..540c430e757 100644 --- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_log.result +++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_log.result @@ -317,14 +317,14 @@ insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id()); show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query # # use `test`; create table t1(a int auto_increment primary key, b int) -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT -master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # COMMIT select * from t1; a b 1 1 diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_stm_innodb.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_stm_innodb.result index db9920dd79f..675a69d17a4 100644 --- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_stm_innodb.result +++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_stm_innodb.result @@ -28,7 +28,7 @@ from mysql.ndb_apply_status; show binlog events from <start_pos> limit 1; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 <start_pos> Query 1 # use `test`; BEGIN +master-bin.000001 <start_pos> Query 1 # BEGIN # Now the insert, one step after @@ -53,7 +53,7 @@ from mysql.ndb_apply_status; <log_name> <start_pos> <end_pos> show binlog events from <start_pos> limit 1; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 <start_pos> Query 1 # use `test`; BEGIN +master-bin.000001 <start_pos> Query 1 # BEGIN show binlog events from <start_pos> limit 1,2; Log_name Pos Event_type Server_id End_log_pos Info diff --git a/mysql-test/suite/rpl_ndb/t/disabled.def b/mysql-test/suite/rpl_ndb/t/disabled.def index 6908269d014..2f15112515e 100644 --- a/mysql-test/suite/rpl_ndb/t/disabled.def +++ b/mysql-test/suite/rpl_ndb/t/disabled.def @@ -11,3 +11,4 @@ ############################################################################## # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open +rpl_ndb_2ndb : Bug#45974: rpl_ndb_2ndb fails sporadically diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other-slave.opt b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other-slave.opt index 188b31efa8a..dff423702b4 100644 --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other-slave.opt +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other-slave.opt @@ -1 +1 @@ ---innodb --ndbcluster=0 --log-slave-updates=0 +--innodb --loose-ndbcluster=OFF --log-slave-updates=0 diff --git a/mysql-test/suite/sys_vars/r/innodb_data_home_dir_basic.result b/mysql-test/suite/sys_vars/r/innodb_data_home_dir_basic.result index e4bdd79b7c3..52a97bb6c95 100644 --- a/mysql-test/suite/sys_vars/r/innodb_data_home_dir_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_data_home_dir_basic.result @@ -1,16 +1,16 @@ '#---------------------BS_STVARS_025_01----------------------#' SELECT COUNT(@@GLOBAL.innodb_data_home_dir); COUNT(@@GLOBAL.innodb_data_home_dir) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_025_02----------------------#' SET @@GLOBAL.innodb_data_home_dir=1; ERROR HY000: Variable 'innodb_data_home_dir' is a read only variable Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.innodb_data_home_dir); COUNT(@@GLOBAL.innodb_data_home_dir) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_025_03----------------------#' SELECT @@GLOBAL.innodb_data_home_dir = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -20,8 +20,8 @@ NULL 1 Expected SELECT COUNT(@@GLOBAL.innodb_data_home_dir); COUNT(@@GLOBAL.innodb_data_home_dir) -1 -1 Expected +0 +0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='innodb_data_home_dir'; @@ -36,8 +36,8 @@ NULL '#---------------------BS_STVARS_025_05----------------------#' SELECT COUNT(@@innodb_data_home_dir); COUNT(@@innodb_data_home_dir) -1 -1 Expected +0 +0 Expected SELECT COUNT(@@local.innodb_data_home_dir); ERROR HY000: Variable 'innodb_data_home_dir' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' @@ -46,8 +46,8 @@ ERROR HY000: Variable 'innodb_data_home_dir' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.innodb_data_home_dir); COUNT(@@GLOBAL.innodb_data_home_dir) -1 -1 Expected +0 +0 Expected SELECT innodb_data_home_dir = @@SESSION.innodb_data_home_dir; ERROR 42S22: Unknown column 'innodb_data_home_dir' in 'field list' Expected error 'Readonly variable' diff --git a/mysql-test/suite/sys_vars/r/innodb_flush_method_basic.result b/mysql-test/suite/sys_vars/r/innodb_flush_method_basic.result index 8c8924cdd86..4a85748092d 100644 --- a/mysql-test/suite/sys_vars/r/innodb_flush_method_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_flush_method_basic.result @@ -1,16 +1,16 @@ '#---------------------BS_STVARS_029_01----------------------#' SELECT COUNT(@@GLOBAL.innodb_flush_method); COUNT(@@GLOBAL.innodb_flush_method) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_029_02----------------------#' SET @@GLOBAL.innodb_flush_method=1; ERROR HY000: Variable 'innodb_flush_method' is a read only variable Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.innodb_flush_method); COUNT(@@GLOBAL.innodb_flush_method) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_029_03----------------------#' SELECT @@GLOBAL.innodb_flush_method = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -20,8 +20,8 @@ NULL 1 Expected SELECT COUNT(@@GLOBAL.innodb_flush_method); COUNT(@@GLOBAL.innodb_flush_method) -1 -1 Expected +0 +0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='innodb_flush_method'; @@ -36,8 +36,8 @@ NULL '#---------------------BS_STVARS_029_05----------------------#' SELECT COUNT(@@innodb_flush_method); COUNT(@@innodb_flush_method) -1 -1 Expected +0 +0 Expected SELECT COUNT(@@local.innodb_flush_method); ERROR HY000: Variable 'innodb_flush_method' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' @@ -46,8 +46,8 @@ ERROR HY000: Variable 'innodb_flush_method' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.innodb_flush_method); COUNT(@@GLOBAL.innodb_flush_method) -1 -1 Expected +0 +0 Expected SELECT innodb_flush_method = @@SESSION.innodb_flush_method; ERROR 42S22: Unknown column 'innodb_flush_method' in 'field list' Expected error 'Readonly variable' diff --git a/mysql-test/suite/sys_vars/r/rpl_init_slave_func.result b/mysql-test/suite/sys_vars/r/rpl_init_slave_func.result index 5f730bff882..bdb586e84c2 100644 --- a/mysql-test/suite/sys_vars/r/rpl_init_slave_func.result +++ b/mysql-test/suite/sys_vars/r/rpl_init_slave_func.result @@ -12,7 +12,7 @@ DROP TABLE IF EXISTS t1; CREATE TEMPORARY TABLE t1 AS SELECT @@global.init_slave AS my_column; DESCRIBE t1; Field Type Null Key Default Extra -my_column varchar(59) NO +my_column varchar(59) YES NULL DROP TABLE t1; SELECT @@global.init_slave = 'SET @@global.max_connections = @@global.max_connections + 1'; @@global.init_slave = 'SET @@global.max_connections = @@global.max_connections + 1' diff --git a/mysql-test/suite/sys_vars/r/ssl_capath_basic.result b/mysql-test/suite/sys_vars/r/ssl_capath_basic.result index 3d161392917..f04b85b956f 100644 --- a/mysql-test/suite/sys_vars/r/ssl_capath_basic.result +++ b/mysql-test/suite/sys_vars/r/ssl_capath_basic.result @@ -1,16 +1,16 @@ '#---------------------BS_STVARS_046_01----------------------#' SELECT COUNT(@@GLOBAL.ssl_capath); COUNT(@@GLOBAL.ssl_capath) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_046_02----------------------#' SET @@GLOBAL.ssl_capath=1; ERROR HY000: Variable 'ssl_capath' is a read only variable Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.ssl_capath); COUNT(@@GLOBAL.ssl_capath) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_046_03----------------------#' SELECT @@GLOBAL.ssl_capath = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -20,8 +20,8 @@ NULL 1 Expected SELECT COUNT(@@GLOBAL.ssl_capath); COUNT(@@GLOBAL.ssl_capath) -1 -1 Expected +0 +0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='ssl_capath'; @@ -36,8 +36,8 @@ NULL '#---------------------BS_STVARS_046_05----------------------#' SELECT COUNT(@@ssl_capath); COUNT(@@ssl_capath) -1 -1 Expected +0 +0 Expected SELECT COUNT(@@local.ssl_capath); ERROR HY000: Variable 'ssl_capath' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' @@ -46,8 +46,8 @@ ERROR HY000: Variable 'ssl_capath' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.ssl_capath); COUNT(@@GLOBAL.ssl_capath) -1 -1 Expected +0 +0 Expected SELECT ssl_capath = @@SESSION.ssl_capath; ERROR 42S22: Unknown column 'ssl_capath' in 'field list' Expected error 'Readonly variable' diff --git a/mysql-test/suite/sys_vars/r/ssl_cipher_basic.result b/mysql-test/suite/sys_vars/r/ssl_cipher_basic.result index df0fc8b5aad..0eed40d0580 100644 --- a/mysql-test/suite/sys_vars/r/ssl_cipher_basic.result +++ b/mysql-test/suite/sys_vars/r/ssl_cipher_basic.result @@ -1,16 +1,16 @@ '#---------------------BS_STVARS_048_01----------------------#' SELECT COUNT(@@GLOBAL.ssl_cipher); COUNT(@@GLOBAL.ssl_cipher) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_048_02----------------------#' SET @@GLOBAL.ssl_cipher=1; ERROR HY000: Variable 'ssl_cipher' is a read only variable Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.ssl_cipher); COUNT(@@GLOBAL.ssl_cipher) -1 -1 Expected +0 +0 Expected '#---------------------BS_STVARS_048_03----------------------#' SELECT @@GLOBAL.ssl_cipher = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -20,8 +20,8 @@ NULL 1 Expected SELECT COUNT(@@GLOBAL.ssl_cipher); COUNT(@@GLOBAL.ssl_cipher) -1 -1 Expected +0 +0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='ssl_cipher'; @@ -36,8 +36,8 @@ NULL '#---------------------BS_STVARS_048_05----------------------#' SELECT COUNT(@@ssl_cipher); COUNT(@@ssl_cipher) -1 -1 Expected +0 +0 Expected SELECT COUNT(@@local.ssl_cipher); ERROR HY000: Variable 'ssl_cipher' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' @@ -46,8 +46,8 @@ ERROR HY000: Variable 'ssl_cipher' is a GLOBAL variable Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.ssl_cipher); COUNT(@@GLOBAL.ssl_cipher) -1 -1 Expected +0 +0 Expected SELECT ssl_cipher = @@SESSION.ssl_cipher; ERROR 42S22: Unknown column 'ssl_cipher' in 'field list' Expected error 'Readonly variable' diff --git a/mysql-test/suite/sys_vars/t/innodb_data_home_dir_basic.test b/mysql-test/suite/sys_vars/t/innodb_data_home_dir_basic.test index f3b02edf83b..acf3741d5fa 100644 --- a/mysql-test/suite/sys_vars/t/innodb_data_home_dir_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_data_home_dir_basic.test @@ -29,7 +29,7 @@ # Displaying default value # #################################################################### SELECT COUNT(@@GLOBAL.innodb_data_home_dir); ---echo 1 Expected +--echo 0 Expected --echo '#---------------------BS_STVARS_025_02----------------------#' @@ -42,7 +42,7 @@ SET @@GLOBAL.innodb_data_home_dir=1; --echo Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.innodb_data_home_dir); ---echo 1 Expected +--echo 0 Expected @@ -58,7 +58,7 @@ WHERE VARIABLE_NAME='innodb_data_home_dir'; --echo 1 Expected SELECT COUNT(@@GLOBAL.innodb_data_home_dir); ---echo 1 Expected +--echo 0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -82,7 +82,7 @@ SELECT @@innodb_data_home_dir = @@GLOBAL.innodb_data_home_dir; ################################################################################ SELECT COUNT(@@innodb_data_home_dir); ---echo 1 Expected +--echo 0 Expected --Error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT COUNT(@@local.innodb_data_home_dir); @@ -93,7 +93,7 @@ SELECT COUNT(@@SESSION.innodb_data_home_dir); --echo Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.innodb_data_home_dir); ---echo 1 Expected +--echo 0 Expected --Error ER_BAD_FIELD_ERROR SELECT innodb_data_home_dir = @@SESSION.innodb_data_home_dir; diff --git a/mysql-test/suite/sys_vars/t/innodb_flush_method_basic.test b/mysql-test/suite/sys_vars/t/innodb_flush_method_basic.test index 531df4a2464..75af00e33af 100644 --- a/mysql-test/suite/sys_vars/t/innodb_flush_method_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_flush_method_basic.test @@ -29,7 +29,7 @@ # Displaying default value # #################################################################### SELECT COUNT(@@GLOBAL.innodb_flush_method); ---echo 1 Expected +--echo 0 Expected --echo '#---------------------BS_STVARS_029_02----------------------#' @@ -42,7 +42,7 @@ SET @@GLOBAL.innodb_flush_method=1; --echo Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.innodb_flush_method); ---echo 1 Expected +--echo 0 Expected @@ -58,7 +58,7 @@ WHERE VARIABLE_NAME='innodb_flush_method'; --echo 1 Expected SELECT COUNT(@@GLOBAL.innodb_flush_method); ---echo 1 Expected +--echo 0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -82,7 +82,7 @@ SELECT @@innodb_flush_method = @@GLOBAL.innodb_flush_method; ################################################################################ SELECT COUNT(@@innodb_flush_method); ---echo 1 Expected +--echo 0 Expected --Error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT COUNT(@@local.innodb_flush_method); @@ -93,7 +93,7 @@ SELECT COUNT(@@SESSION.innodb_flush_method); --echo Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.innodb_flush_method); ---echo 1 Expected +--echo 0 Expected --Error ER_BAD_FIELD_ERROR SELECT innodb_flush_method = @@SESSION.innodb_flush_method; diff --git a/mysql-test/suite/sys_vars/t/ssl_capath_basic.test b/mysql-test/suite/sys_vars/t/ssl_capath_basic.test index c32b572fb1b..ece9fe992d9 100644 --- a/mysql-test/suite/sys_vars/t/ssl_capath_basic.test +++ b/mysql-test/suite/sys_vars/t/ssl_capath_basic.test @@ -27,7 +27,7 @@ # Displaying default value # #################################################################### SELECT COUNT(@@GLOBAL.ssl_capath); ---echo 1 Expected +--echo 0 Expected --echo '#---------------------BS_STVARS_046_02----------------------#' @@ -40,7 +40,7 @@ SET @@GLOBAL.ssl_capath=1; --echo Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.ssl_capath); ---echo 1 Expected +--echo 0 Expected @@ -56,7 +56,7 @@ WHERE VARIABLE_NAME='ssl_capath'; --echo 1 Expected SELECT COUNT(@@GLOBAL.ssl_capath); ---echo 1 Expected +--echo 0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -80,7 +80,7 @@ SELECT @@ssl_capath = @@GLOBAL.ssl_capath; ################################################################################ SELECT COUNT(@@ssl_capath); ---echo 1 Expected +--echo 0 Expected --Error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT COUNT(@@local.ssl_capath); @@ -91,7 +91,7 @@ SELECT COUNT(@@SESSION.ssl_capath); --echo Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.ssl_capath); ---echo 1 Expected +--echo 0 Expected --Error ER_BAD_FIELD_ERROR SELECT ssl_capath = @@SESSION.ssl_capath; diff --git a/mysql-test/suite/sys_vars/t/ssl_cipher_basic.test b/mysql-test/suite/sys_vars/t/ssl_cipher_basic.test index 425f7aae442..c58b22da2d5 100644 --- a/mysql-test/suite/sys_vars/t/ssl_cipher_basic.test +++ b/mysql-test/suite/sys_vars/t/ssl_cipher_basic.test @@ -27,7 +27,7 @@ # Displaying default value # #################################################################### SELECT COUNT(@@GLOBAL.ssl_cipher); ---echo 1 Expected +--echo 0 Expected --echo '#---------------------BS_STVARS_048_02----------------------#' @@ -40,7 +40,7 @@ SET @@GLOBAL.ssl_cipher=1; --echo Expected error 'Read only variable' SELECT COUNT(@@GLOBAL.ssl_cipher); ---echo 1 Expected +--echo 0 Expected @@ -56,7 +56,7 @@ WHERE VARIABLE_NAME='ssl_cipher'; --echo 1 Expected SELECT COUNT(@@GLOBAL.ssl_cipher); ---echo 1 Expected +--echo 0 Expected SELECT COUNT(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -80,7 +80,7 @@ SELECT @@ssl_cipher = @@GLOBAL.ssl_cipher; ################################################################################ SELECT COUNT(@@ssl_cipher); ---echo 1 Expected +--echo 0 Expected --Error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT COUNT(@@local.ssl_cipher); @@ -91,7 +91,7 @@ SELECT COUNT(@@SESSION.ssl_cipher); --echo Expected error 'Variable is a GLOBAL variable' SELECT COUNT(@@GLOBAL.ssl_cipher); ---echo 1 Expected +--echo 0 Expected --Error ER_BAD_FIELD_ERROR SELECT ssl_cipher = @@SESSION.ssl_cipher; diff --git a/mysql-test/t/archive_bitfield.test b/mysql-test/t/archive_bitfield.test index 1e4692270b5..2e90ce39708 100644 --- a/mysql-test/t/archive_bitfield.test +++ b/mysql-test/t/archive_bitfield.test @@ -94,5 +94,11 @@ INSERT INTO `t1` VALUES (NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'100000',b'010010',b'011111',4,5,5,5,5,5,5,5,5,5,3,2,1), (NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000000',b'001100',b'111111',4,5,5,5,5,5,5,5,5,5,3,2,1), (NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'000000',b'000000',4,5,5,5,5,5,5,5,5,5,3,2,1); +# Determine the number of open sessions +--source include/count_sessions.inc --exec $MYSQL_DUMP --hex-blob --compact --order-by-primary --skip-extended-insert --no-create-info test t1 drop table t1; +# Wait till the number of open sessions is <= the number before the run with $MYSQL_DUMP +# = The session caused by mysqldump has finished its disconnect +--source include/wait_until_count_sessions.inc + diff --git a/mysql-test/t/bug46080-master.opt b/mysql-test/t/bug46080-master.opt new file mode 100644 index 00000000000..f59740afe60 --- /dev/null +++ b/mysql-test/t/bug46080-master.opt @@ -0,0 +1 @@ +--skip-grant-tables --skip-name-resolve --safemalloc-mem-limit=4000000 diff --git a/mysql-test/t/bug46080.test b/mysql-test/t/bug46080.test new file mode 100644 index 00000000000..7e56e3ce421 --- /dev/null +++ b/mysql-test/t/bug46080.test @@ -0,0 +1,22 @@ +--echo # +--echo # Bug #46080: group_concat(... order by) crashes server when +--echo # sort_buffer_size cannot allocate +--echo # + +CREATE TABLE t1(a CHAR(255)); +INSERT INTO t1 VALUES ('a'); + +SET @@SESSION.sort_buffer_size=5*16*1000000; +SET @@SESSION.max_heap_table_size=5*1000000; + +--echo # Must not crash. +--disable_result_log +--error 0,5 +SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a; +--enable_result_log + +DROP TABLE t1; +SET @@SESSION.sort_buffer_size=default; +SET @@SESSION.max_heap_table_size=default; + +--echo End of 5.0 tests diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 50865215944..8e60d548c2f 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -269,3 +269,18 @@ SELECT HOUR(NULL), DROP TABLE t1; --echo End of 5.0 tests + +--echo # +--echo # Bug #44766: valgrind error when using convert() in a subquery +--echo # + +CREATE TABLE t1(a tinyint); +INSERT INTO t1 VALUES (127); +SELECT 1 FROM +( + SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1 +) AS s LIMIT 1; +DROP TABLE t1; + + +--echo End of 5.1 tests diff --git a/mysql-test/t/client_xml.test b/mysql-test/t/client_xml.test index 739b56f5ab1..0847e2b366b 100644 --- a/mysql-test/t/client_xml.test +++ b/mysql-test/t/client_xml.test @@ -18,6 +18,10 @@ create table t1 ( `a>b` text ); insert into t1 values (1, 2, 'a&b a<b a>b'); + +# Determine the number of open sessions +--source include/count_sessions.inc + --exec $MYSQL --xml test -e "select * from t1" --exec $MYSQL_DUMP --xml --skip-create test @@ -33,3 +37,8 @@ drop table t1; # Restore global concurrent_insert value set @@global.concurrent_insert= @old_concurrent_insert; + +# Wait till the number of open sessions is <= the number before the runs with +# $MYSQL and $MYSQL_DUMP +# = The session caused by mysql and mysqldump have finished their disconnect +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test index f609240646a..9a29e4ff861 100644 --- a/mysql-test/t/connect.test +++ b/mysql-test/t/connect.test @@ -55,7 +55,8 @@ disconnect con4; connect (fail_con,localhost,test,,test2); --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR -connect (fail_con,localhost,test,,""); +# Need to protect "" within '' so it's interpreted literally +connect (fail_con,localhost,test,,'""'); --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect (fail_con,localhost,test,zorro,test2); diff --git a/mysql-test/t/consistent_snapshot.test b/mysql-test/t/consistent_snapshot.test index 82edf2e22b2..fb1f3bc007c 100644 --- a/mysql-test/t/consistent_snapshot.test +++ b/mysql-test/t/consistent_snapshot.test @@ -12,9 +12,9 @@ connect (con1,localhost,root,,); --echo # Establish connection con2 (user=root) connect (con2,localhost,root,,); -### Test 1: -### - While a consistent snapshot transaction is executed, -### no external inserts should be visible to the transaction. +--echo ### Test 1: +--echo ### - While a consistent snapshot transaction is executed, +--echo ### no external inserts should be visible to the transaction. --echo # Switch to connection con1 connection con1; @@ -31,9 +31,9 @@ SELECT * FROM t1; # if consistent snapshot was set as expected, we # should see nothing. COMMIT; -### Test 2: -### - For any non-consistent snapshot transaction, external -### committed inserts should be visible to the transaction. +--echo ### Test 2: +--echo ### - For any non-consistent snapshot transaction, external +--echo ### committed inserts should be visible to the transaction. DELETE FROM t1; START TRANSACTION; # Now we omit WITH CONSISTENT SNAPSHOT @@ -48,6 +48,24 @@ SELECT * FROM t1; # if consistent snapshot was not set, as expected, we # should see 1. COMMIT; +--echo ### Test 3: +--echo ### - Bug#44664: valgrind warning for COMMIT_AND_CHAIN and ROLLBACK_AND_CHAIN +--echo ### Chaining a transaction does not retain consistency level. + +START TRANSACTION WITH CONSISTENT SNAPSHOT; +DELETE FROM t1; +COMMIT WORK AND CHAIN; + +--echo # Switch to connection con2 +connection con2; +INSERT INTO t1 VALUES(1); + +--echo # Switch to connection con1 +connection con1; +SELECT * FROM t1; # if consistent snapshot was not set, as expected, we +# should see 1. +COMMIT; + --echo # Switch to connection default + close connections con1 and con2 connection default; disconnect con1; diff --git a/mysql-test/t/count_distinct3.test b/mysql-test/t/count_distinct3.test index 2f7cf7e5260..ad2bbee95a3 100644 --- a/mysql-test/t/count_distinct3.test +++ b/mysql-test/t/count_distinct3.test @@ -3,6 +3,8 @@ # mysql-4.1 # +--source include/big_test.inc + --disable_warnings DROP TABLE IF EXISTS t1, t2; --enable_warnings diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index abc161d014c..cdf274190dd 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1800,10 +1800,11 @@ connect (con1,localhost,root,,); # EE_FILENOTFOUND 29 --error 29 select * from t1; +--disconnect con1 +--source include/wait_until_disconnected.inc connection default; unlock tables; drop table t1; ---disconnect con1 # # Bug#41441 repair csv table crashes debug server diff --git a/mysql-test/t/ctype_cp932_binlog_stm.test b/mysql-test/t/ctype_cp932_binlog_stm.test index 9e9716e5ddb..89df33a6df5 100644 --- a/mysql-test/t/ctype_cp932_binlog_stm.test +++ b/mysql-test/t/ctype_cp932_binlog_stm.test @@ -22,7 +22,7 @@ CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)| SELECT HEX(s1),HEX(s2),d FROM t4| DROP PROCEDURE bug18293| DROP TABLE t4| -SHOW BINLOG EVENTS FROM 369| +SHOW BINLOG EVENTS FROM 370| delimiter ;| --echo End of 5.0 tests @@ -31,8 +31,9 @@ delimiter ;| # #28436: Incorrect position in SHOW BINLOG EVENTS causes server coredump # Note: 364 is a magic position (found experimentally, depends on # the log's contents) that caused the server crash. + --error 1220 -SHOW BINLOG EVENTS FROM 364; +SHOW BINLOG EVENTS FROM 365; --echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment. CREATE TABLE t1 (a varchar(16)) character set cp932; diff --git a/mysql-test/t/ctype_gbk_binlog.test b/mysql-test/t/ctype_gbk_binlog.test new file mode 100644 index 00000000000..a8f653d1b1e --- /dev/null +++ b/mysql-test/t/ctype_gbk_binlog.test @@ -0,0 +1,36 @@ +-- source include/have_binlog_format_mixed_or_statement.inc +-- source include/have_gbk.inc + +SET NAMES gbk; +--character_set gbk + +CREATE TABLE t1 ( + f1 BLOB +) ENGINE=MyISAM DEFAULT CHARSET=gbk; + +delimiter |; +CREATE PROCEDURE p1(IN val BLOB) +BEGIN + SET @tval = val; + SET @sql_cmd = CONCAT_WS(' ', 'insert into t1(f1) values(?)'); + PREPARE stmt FROM @sql_cmd; + EXECUTE stmt USING @tval; + DEALLOCATE PREPARE stmt; +END| +delimiter ;| + +SET @`tcontent`:=_binary 0x50434B000900000000000000E9000000 COLLATE `binary`/*!*/; +CALL p1(@`tcontent`); + +FLUSH LOGS; +DROP PROCEDURE p1; +RENAME TABLE t1 to t2; + +let $MYSQLD_DATADIR= `select @@datadir`; +--exec $MYSQL_BINLOG --force-if-open --short-form $MYSQLD_DATADIR/master-bin.000001 | $MYSQL +SELECT hex(f1) FROM t2; +SELECT hex(f1) FROM t1; + +DROP PROCEDURE p1; +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/t/ctype_ldml.test b/mysql-test/t/ctype_ldml.test index 73a23a751e8..db9461bfbf7 100644 --- a/mysql-test/t/ctype_ldml.test +++ b/mysql-test/t/ctype_ldml.test @@ -37,6 +37,15 @@ UPDATE t1 SET col2=col1; SELECT * FROM t1 WHERE col1=col2 ORDER BY col1; DROP TABLE t1; +--echo # +--echo # Bug#43827 Server closes connections and restarts +--echo # +# Crash happened with a user-defined utf8 collation, +# on attempt to insert a string longer than the column can store. +CREATE TABLE t1 (c1 VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_test_ci); +INSERT INTO t1 SELECT REPEAT('a',11); +DROP TABLE t1; + # # Vietnamese experimental collation # diff --git a/mysql-test/t/ddl_i18n_koi8r.test b/mysql-test/t/ddl_i18n_koi8r.test index 2d94a899aad..fecef2f95d5 100644 --- a/mysql-test/t/ddl_i18n_koi8r.test +++ b/mysql-test/t/ddl_i18n_koi8r.test @@ -1128,15 +1128,22 @@ SHOW CREATE TABLE mysqltest2.t2| # # Cleanup. # +delimiter ;| ---connection default +--connection con2 --echo ---echo ---> connection: default - +--echo ---> connection: con2 --disconnect con2 +--source include/wait_until_disconnected.inc +--connection con3 +--echo +--echo ---> connection: con3 --disconnect con3 +--source include/wait_until_disconnected.inc +--connection default +--echo +--echo ---> connection: default +USE test; +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; -use test| - -DROP DATABASE mysqltest1| -DROP DATABASE mysqltest2| diff --git a/mysql-test/t/ddl_i18n_utf8.test b/mysql-test/t/ddl_i18n_utf8.test index 1d5415d9373..8788d0604f2 100644 --- a/mysql-test/t/ddl_i18n_utf8.test +++ b/mysql-test/t/ddl_i18n_utf8.test @@ -1128,15 +1128,22 @@ SHOW CREATE TABLE mysqltest2.t2| # # Cleanup. # +delimiter ;| ---connection default +--connection con2 --echo ---echo ---> connection: default - +--echo ---> connection: con2 --disconnect con2 +--source include/wait_until_disconnected.inc +--connection con3 +--echo +--echo ---> connection: con3 --disconnect con3 +--source include/wait_until_disconnected.inc +--connection default +--echo +--echo ---> connection: default +USE test; +DROP DATABASE mysqltest1; +DROP DATABASE mysqltest2; -use test| - -DROP DATABASE mysqltest1| -DROP DATABASE mysqltest2| diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 4e79fac584f..d28c19bbd18 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -273,8 +273,32 @@ select t2.* from ((select * from t1) as A inner join t2 on A.ID = t2.FID); select t2.* from (select * from t1) as A inner join t2 on A.ID = t2.FID; drop table t1, t2; +connection con1; disconnect con1; +--source include/wait_until_disconnected.inc connection default; drop user mysqltest_1; -# End of 4.1 tests +--echo # End of 4.1 tests + +# +# Bug #41156: List of derived tables acts like a chain of +# mutually-nested subqueries +# + +SELECT 0 FROM +(SELECT 0) t01, (SELECT 0) t02, (SELECT 0) t03, (SELECT 0) t04, (SELECT 0) t05, +(SELECT 0) t06, (SELECT 0) t07, (SELECT 0) t08, (SELECT 0) t09, (SELECT 0) t10, +(SELECT 0) t11, (SELECT 0) t12, (SELECT 0) t13, (SELECT 0) t14, (SELECT 0) t15, +(SELECT 0) t16, (SELECT 0) t17, (SELECT 0) t18, (SELECT 0) t19, (SELECT 0) t20, +(SELECT 0) t21, (SELECT 0) t22, (SELECT 0) t23, (SELECT 0) t24, (SELECT 0) t25, +(SELECT 0) t26, (SELECT 0) t27, (SELECT 0) t28, (SELECT 0) t29, (SELECT 0) t30, +(SELECT 0) t31, (SELECT 0) t32, (SELECT 0) t33, (SELECT 0) t34, (SELECT 0) t35, +(SELECT 0) t36, (SELECT 0) t37, (SELECT 0) t38, (SELECT 0) t39, (SELECT 0) t40, +(SELECT 0) t41, (SELECT 0) t42, (SELECT 0) t43, (SELECT 0) t44, (SELECT 0) t45, +(SELECT 0) t46, (SELECT 0) t47, (SELECT 0) t48, (SELECT 0) t49, (SELECT 0) t50, +(SELECT 0) t51, (SELECT 0) t52, (SELECT 0) t53, (SELECT 0) t54, (SELECT 0) t55, +(SELECT 0) t56, (SELECT 0) t57, (SELECT 0) t58, (SELECT 0) t59, (SELECT 0) t60, +(SELECT 0) t61; # 61 == MAX_TABLES + +--echo # End of 5.0 tests diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 760c29bbae6..5436b7166f4 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -10,8 +10,7 @@ # ############################################################################## kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild. -innodb_bug39438 : BUG#42383 2009-01-28 lsoares "This fails in embedded and on windows. Note that this test is not run on windows and on embedded in PB for main trees currently" +innodb_bug39438 : Bug#42383 2009-01-28 lsoares "This fails in embedded and on windows. Note that this test is not run on windows and on embedded in PB for main trees currently" query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically +init_connect : Bug#44920 2009-07-06 pcrews MTR not processing master.opt input properly on Windows. *Must be done this way due to the nature of the bug* -#concurrent_innodb_safelog: disabled for embedded server due to bug#43733 Select on processlist let the embedded server crash (concurrent_innodb_safelog). -#concurrent_innodb_unsafelog: disabled for embedded server due to bug#43733. diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index 91345886e93..bb4dd3e11f9 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -117,8 +117,11 @@ connection addconroot1; --reap connection addconroot2; --reap -disconnect addconroot1; disconnect addconroot2; +--source include/wait_until_disconnected.inc +connection addconroot1; +disconnect addconroot1; +--source include/wait_until_disconnected.inc connection default; --echo End of 5.0 tests diff --git a/mysql-test/t/events_grant.test b/mysql-test/t/events_grant.test index cff2475c5aa..8db4333cc03 100644 --- a/mysql-test/t/events_grant.test +++ b/mysql-test/t/events_grant.test @@ -97,7 +97,9 @@ DROP EVENT one_event; connection default; --echo "One event should not be there" SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; +connection ev_con1; disconnect ev_con1; +--source include/wait_until_disconnected.inc connection default; DROP USER ev_test@localhost; DROP DATABASE events_test2; @@ -106,9 +108,6 @@ DROP DATABASE events_test2; # End of tests # -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc +--source include/check_events_off.inc DROP DATABASE events_test; diff --git a/mysql-test/t/events_stress.test b/mysql-test/t/events_stress.test index 22959898b43..e51fa734256 100644 --- a/mysql-test/t/events_stress.test +++ b/mysql-test/t/events_stress.test @@ -109,7 +109,7 @@ connection conn3; --send DROP DATABASE events_conn3_db; connection default; ---send +# --send DROP DATABASE events_conn1_test2; DROP DATABASE events_conn1_test3; SET GLOBAL event_scheduler=off; @@ -135,3 +135,7 @@ DROP USER event_user3@localhost; # DROP DATABASE events_test; + +# Cleanup +SET GLOBAL event_scheduler=off; +--source include/check_events_off.inc diff --git a/mysql-test/t/events_trans_notembedded.test b/mysql-test/t/events_trans_notembedded.test index 3c151dd18b1..0353d183386 100644 --- a/mysql-test/t/events_trans_notembedded.test +++ b/mysql-test/t/events_trans_notembedded.test @@ -50,6 +50,7 @@ delete from t1; commit work; # Cleanup disconnect conn1; +--source include/wait_until_disconnected.inc connection default; drop user mysqltest_user1@localhost; drop database mysqltest_db2; diff --git a/mysql-test/t/fix_priv_tables.test b/mysql-test/t/fix_priv_tables.test index c7cd500f8d2..eeda9bc8d15 100644 --- a/mysql-test/t/fix_priv_tables.test +++ b/mysql-test/t/fix_priv_tables.test @@ -51,8 +51,13 @@ echo; -- disable_query_log # Run the mysql_fix_privilege_tables.sql using "mysql --force" +# Determine the number of open sessions +--source include/count_sessions.inc --exec $MYSQL --force mysql < $MYSQL_FIX_PRIVILEGE_TABLES > $MYSQLTEST_VARDIR/tmp/fix_priv_tables.log 2>&1 --remove_file $MYSQLTEST_VARDIR/tmp/fix_priv_tables.log +# Wait till the number of open sessions is <= the number before the run with $MYSQL +# = The session caused by mysql has finished its disconnect +--source include/wait_until_count_sessions.inc -- enable_query_log -- enable_result_log diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index c832cb79158..f27d4cf2fad 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -171,6 +171,7 @@ set session low_priority_updates=default; connect (con1,localhost,root,,); send select benchmark(200, (select sin(1))) > 1000; disconnect con1; +--source include/wait_until_disconnected.inc connection default; --echo End of 5.0 tests diff --git a/mysql-test/t/func_compress.test b/mysql-test/t/func_compress.test index 0a3a3823fee..d63130f190d 100644 --- a/mysql-test/t/func_compress.test +++ b/mysql-test/t/func_compress.test @@ -50,6 +50,7 @@ set @@global.max_allowed_packet=1048576*100; --connect (newconn, localhost, root,,) eval select compress(repeat('aaaaaaaaaa', IF('$LOW_MEMORY', 10, 10000000))) is null; disconnect newconn; +--source include/wait_until_disconnected.inc connection default; set @@global.max_allowed_packet=default; @@ -88,4 +89,24 @@ select *, uncompress(a) from t1; select *, uncompress(a), uncompress(a) is null from t1; drop table t1; +# +# Bug #44796: valgrind: too many my_longlong10_to_str_8bit warnings after +# uncompressed_length +# + +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1), (1111), (11111); + +# Disable warnings to avoid dependency on max_allowed_packet value +--disable_warnings +SELECT UNCOMPRESS(c1), UNCOMPRESSED_LENGTH(c1) FROM t1; +--enable_warnings + +# We do not need the results, just make sure there are no valgrind errors +--disable_result_log +EXPLAIN EXTENDED SELECT * FROM (SELECT UNCOMPRESSED_LENGTH(c1) FROM t1) AS s; +--enable_result_log + +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/mysql-test/t/func_concat.test b/mysql-test/t/func_concat.test index f2aa0d004e5..1c7e5823fb2 100644 --- a/mysql-test/t/func_concat.test +++ b/mysql-test/t/func_concat.test @@ -78,3 +78,37 @@ SELECT * FROM t1 WHERE CONCAT(c1,' ',c2) REGEXP 'First.*'; DROP TABLE t1; --echo # End of 5.0 tests + + +--echo # +--echo # Bug #44743: Join in combination with concat does not always work +--echo # +CREATE TABLE t1 ( + a VARCHAR(100) NOT NULL DEFAULT '0', + b VARCHAR(2) NOT NULL DEFAULT '', + c VARCHAR(2) NOT NULL DEFAULT '', + d TEXT NOT NULL, + PRIMARY KEY (a, b, c), + KEY (a) +) DEFAULT CHARSET=utf8; + +INSERT INTO t1 VALUES ('gui_A', 'a', 'b', 'str1'), + ('gui_AB', 'a', 'b', 'str2'), ('gui_ABC', 'a', 'b', 'str3'); + +CREATE TABLE t2 ( + a VARCHAR(100) NOT NULL DEFAULT '', + PRIMARY KEY (a) +) DEFAULT CHARSET=latin1; + +INSERT INTO t2 VALUES ('A'), ('AB'), ('ABC'); + +SELECT CONCAT('gui_', t2.a), t1.d FROM t2 + LEFT JOIN t1 ON t1.a = CONCAT('gui_', t2.a) AND t1.b = 'a' AND t1.c = 'b'; + +EXPLAIN SELECT CONCAT('gui_', t2.a), t1.d FROM t2 + LEFT JOIN t1 ON t1.a = CONCAT('gui_', t2.a) AND t1.b = 'a' AND t1.c = 'b'; + +DROP TABLE t1, t2; + + +--echo # End of 5.1 tests diff --git a/mysql-test/t/func_crypt.test b/mysql-test/t/func_crypt.test index cc3cdb9564d..6dedeaa0fef 100644 --- a/mysql-test/t/func_crypt.test +++ b/mysql-test/t/func_crypt.test @@ -56,3 +56,15 @@ explain extended select password('idkfa '), old_password('idkfa'); select encrypt('1234','_.'); # End of 4.1 tests + +--echo # +--echo # Bug #44767: invalid memory reads in password() and old_password() +--echo # functions +--echo # + +CREATE TABLE t1(c1 MEDIUMBLOB); +INSERT INTO t1 VALUES (REPEAT('a', 1024)); +SELECT OLD_PASSWORD(c1), PASSWORD(c1) FROM t1; +DROP TABLE t1; + +--echo End of 5.0 tests diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 3fc1697f146..adc074259ad 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -439,4 +439,21 @@ SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1; DROP TABLE t1; +# +# Bug #44399: crash with statement using TEXT columns, aggregates, GROUP BY, +# and HAVING +# + +CREATE TABLE t1(a TEXT, b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL); +INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1); +INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2); +SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a); +SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b HAVING b IN ( AVG( 1 ), 1 + b); +SELECT SUM( DISTINCT c ) FROM t1 GROUP BY c HAVING c IN ( AVG( 1 ), 1 + c); +SELECT SUM( DISTINCT d ) FROM t1 GROUP BY d HAVING d IN ( AVG( 1 ), 1 + d); +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY e HAVING e IN ( AVG( 1 ), 1 + e); +SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN + ((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index e67f5f29e3a..91fdce8addb 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -269,6 +269,15 @@ SELECT a, ROUND(a) FROM t1; DROP TABLE t1; +# +# Bug#45152 crash with round() function on longtext column in a derived table +# +CREATE TABLE t1(f1 LONGTEXT) engine=myisam; +INSERT INTO t1 VALUES ('a'); +SELECT 1 FROM (SELECT ROUND(f1) AS a FROM t1) AS s WHERE a LIKE 'a'; +SELECT 1 FROM (SELECT ROUND(f1, f1) AS a FROM t1) AS s WHERE a LIKE 'a'; +DROP TABLE t1; + --echo End of 5.0 tests # @@ -282,4 +291,22 @@ SELECT 1e300 / 1e-300; SELECT EXP(750); SELECT POW(10, 309); +--echo # +--echo # Bug #44768: SIGFPE crash when selecting rand from a view +--echo # containing null +--echo # + +CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a; +SELECT RAND(a) FROM v1; +DROP VIEW v1; + +SELECT RAND(a) FROM (SELECT NULL AS a) b; + +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (NULL); +SELECT RAND(i) FROM t1; +DROP TABLE t1; + +--echo # + --echo End of 5.1 tests diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test index 5f37cd2a13e..294efa8caf1 100644 --- a/mysql-test/t/func_set.test +++ b/mysql-test/t/func_set.test @@ -84,3 +84,16 @@ engine=myisam default charset=latin1; insert into t1 values (''),(null),(null),(''),(''),(''); select find_in_set(f1,f1) as a from t1,(select find_in_set(f1,f1) as b from t1) a; drop table t1; +# +# Bug#45168: assertion with convert() and empty set value +# +CREATE TABLE t1( a SET('a', 'b', 'c') ); +CREATE TABLE t2( a SET('a', 'b', 'c') ); + +INSERT INTO t1 VALUES ('d'); +INSERT INTO t2 VALUES (''); + +SELECT CONVERT( a USING latin1 ) FROM t1; +SELECT CONVERT( a USING latin1 ) FROM t2; + +DROP TABLE t1, t2; diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index ef406d2aeca..7cb7f7f72d2 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -1282,6 +1282,16 @@ INSERT INTO t1 VALUES ('2008-12-31','aaaaaa'); SELECT DATE_FORMAT(c, GET_FORMAT(DATE, 'eur')) h, CONCAT(UPPER(aa),', ', aa) i FROM t1; DROP TABLE t1; + +--echo # +--echo # BUG#44774: load_file function produces valgrind warnings +--echo # +CREATE TABLE t1 (a TINYBLOB); +INSERT INTO t1 VALUES ('aaaaaaaa'); +SELECT LOAD_FILE(a) FROM t1; +DROP TABLE t1; + + --echo End of 5.0 tests # diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 0dae4509518..4a60e777cc7 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -667,4 +667,28 @@ desc v1; drop view v1; drop table t1; +# +# Bug#44684: valgrind reports invalid reads in +# Item_func_spatial_collection::val_str +# +SELECT MultiPoint(12345,''); +SELECT MultiPoint(123451,''); +SELECT MultiPoint(1234512,''); +SELECT MultiPoint(12345123,''); + +SELECT MultiLineString(12345,''); +SELECT MultiLineString(123451,''); +SELECT MultiLineString(1234512,''); +SELECT MultiLineString(12345123,''); + +SELECT LineString(12345,''); +SELECT LineString(123451,''); +SELECT LineString(1234512,''); +SELECT LineString(12345123,''); + +SELECT Polygon(12345,''); +SELECT Polygon(123451,''); +SELECT Polygon(1234512,''); +SELECT Polygon(12345123,''); + --echo End of 5.1 tests diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 2e42bdbf06c..bcd393bd6ab 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1471,5 +1471,59 @@ DROP DATABASE dbbug33464; SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators; +# +# Bug#44658 Create procedure makes server crash when user does not have ALL privilege +# +CREATE USER user1; +CREATE USER user2; +GRANT CREATE ON db1.* TO 'user1'@'localhost'; +GRANT CREATE ROUTINE ON db1.* TO 'user1'@'localhost'; +GRANT CREATE ON db1.* TO 'user2'@'%'; +GRANT CREATE ROUTINE ON db1.* TO 'user2'@'%'; +FLUSH PRIVILEGES; +SHOW GRANTS FOR 'user1'@'localhost'; +connect (con1,localhost,user1,,); +--echo ** Connect as user1 and create a procedure. +--echo ** The creation will imply implicitly assigned +--echo ** EXECUTE and ALTER ROUTINE privileges to +--echo ** the current user user1@localhost. +SELECT @@GLOBAL.sql_mode; +SELECT @@SESSION.sql_mode; +CREATE DATABASE db1; +DELIMITER ||; +CREATE PROCEDURE db1.proc1(p1 INT) + BEGIN + SET @x = 0; + REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT; + END ;|| +DELIMITER ;|| + +connect (con2,localhost,user2,,); +--echo ** Connect as user2 and create a procedure. +--echo ** Implicitly assignment of privileges will +--echo ** fail because the user2@localhost is an +--echo ** unknown user. +DELIMITER ||; +CREATE PROCEDURE db1.proc2(p1 INT) + BEGIN + SET @x = 0; + REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT; + END ;|| +DELIMITER ;|| + +connection default; +SHOW GRANTS FOR 'user1'@'localhost'; +SHOW GRANTS FOR 'user2'; +disconnect con1; +disconnect con2; +DROP PROCEDURE db1.proc1; +DROP PROCEDURE db1.proc2; +REVOKE ALL ON db1.* FROM 'user1'@'localhost'; +REVOKE ALL ON db1.* FROM 'user2'@'%'; +DROP USER 'user1'; +DROP USER 'user1'@'localhost'; +DROP USER 'user2'; +DROP DATABASE db1; + # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index adfa77c881c..981be3efece 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -982,4 +982,39 @@ SELECT DISTINCT c FROM t1 WHERE d=4; DROP TABLE t1; +--echo # +--echo # Bug #45386: Wrong query result with MIN function in field list, +--echo # WHERE and GROUP BY clause +--echo # + +CREATE TABLE t (a INT, b INT, INDEX (a,b)); +INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1); +INSERT INTO t SELECT * FROM t; + +--echo # test MIN +--echo #should use range with index for group by +EXPLAIN +SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a; +--echo #should return 1 row +SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a; + +--echo # test MAX +--echo #should use range with index for group by +EXPLAIN +SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a; +--echo #should return 1 row +SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a; + +--echo # test 3 ranges and use the middle one +INSERT INTO t SELECT a, 2 FROM t; + +--echo #should use range with index for group by +EXPLAIN +SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a; +--echo #should return 1 row +SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a; + +DROP TABLE t; + + --echo End of 5.0 tests diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index b51eeb27331..637c6ba1c81 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -253,5 +253,13 @@ insert into t1 values (1, 1), (3, 3), (2, 2), (NULL, 1), (NULL, NULL), (0, 0); select * from t1 where a is null; drop table t1; +-- echo # +-- echo # bug#39918 - memory (heap) engine crashing while executing self join with delete +-- echo # + +CREATE TABLE t1(a INT, KEY USING BTREE (a)) ENGINE=MEMORY; +INSERT INTO t1 VALUES(1),(1); +DELETE a1 FROM t1 AS a1, t1 AS a2 WHERE a1.a=a2.a; +DROP TABLE t1; --echo End of 5.0 tests diff --git a/mysql-test/t/information_schema_db.test b/mysql-test/t/information_schema_db.test index 6353e94fd51..0ff1d05f364 100644 --- a/mysql-test/t/information_schema_db.test +++ b/mysql-test/t/information_schema_db.test @@ -53,7 +53,7 @@ order by table_name; end| delimiter ;| -create table t1 +create table t1 (f1 int(10) unsigned not null, f2 varchar(100) not null, primary key (f1), unique key (f2)); @@ -105,8 +105,8 @@ drop function f2; drop view v1, v2; # -# Bug#20543: select on information_schema strange warnings, view, different -# schemas/users +# Bug#20543 select on information_schema strange warnings, view, different +# schemas/users # # create database testdb_1; @@ -125,7 +125,7 @@ grant insert on v1 to testdb_2@localhost; create view v5 as select f1 from t1; grant show view on v5 to testdb_2@localhost; ---error 1227 +--error ER_SPECIFIC_ACCESS_DENIED_ERROR create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1; connection default; @@ -169,46 +169,53 @@ use testdb_1; revoke show view on v6 from testdb_2@localhost; connection testdb_2; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show fields from testdb_1.v5; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show create view testdb_1.v5; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show fields from testdb_1.v6; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show create view testdb_1.v6; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show fields from testdb_1.v7; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show create view testdb_1.v7; ---error 1345 +--error ER_VIEW_NO_EXPLAIN show create view v4; -#--error 1345 +#--error ER_VIEW_NO_EXPLAIN show fields from v4; show fields from v2; show fields from testdb_1.v1; show create view v2; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR show create view testdb_1.v1; -select table_name from information_schema.columns a +select table_name from information_schema.columns a where a.table_name = 'v2'; -select view_definition from information_schema.views a +select view_definition from information_schema.views a where a.table_name = 'v2'; -select view_definition from information_schema.views a +select view_definition from information_schema.views a where a.table_name = 'testdb_1.v1'; ---error 1356 +--error ER_VIEW_INVALID select * from v2; connection default; use test; drop view testdb_1.v1, v2, testdb_1.v3, v4; drop database testdb_1; +connection testdb_1; +disconnect testdb_1; +--source include/wait_until_disconnected.inc +connection testdb_2; +disconnect testdb_2; +--source include/wait_until_disconnected.inc +connection default; drop user testdb_1@localhost; drop user testdb_2@localhost; @@ -239,4 +246,7 @@ show create view testdb_1.v1; connection default; drop user mysqltest_1@localhost; drop database testdb_1; +connection user1; disconnect user1; +--source include/wait_until_disconnected.inc +connection default; diff --git a/mysql-test/t/init_file.test b/mysql-test/t/init_file.test index ceb5cae9743..7eb5381651d 100644 --- a/mysql-test/t/init_file.test +++ b/mysql-test/t/init_file.test @@ -14,7 +14,7 @@ SELECT * INTO @X FROM init_file.startup limit 0,1; SELECT * INTO @Y FROM init_file.startup limit 1,1; SELECT YEAR(@X)-YEAR(@Y); # Enable this DROP DATABASE only after resolving bug #42507 -# DROP DATABASE init_file; +DROP DATABASE init_file; --echo ok --echo end of 4.1 tests @@ -28,4 +28,9 @@ select * from t1; # 30, 3, 11, 13 select * from t2; # Enable this DROP TABLE only after resolving bug #42507 -#drop table t1, t2; +drop table t1, t2; + +# MTR will restart server anyway, but by forcing it we avoid being warned +# about the apparent side effect + +call mtr.force_restart(); diff --git a/mysql-test/t/innodb_bug21704.test b/mysql-test/t/innodb_bug21704.test new file mode 100644 index 00000000000..c649b61034c --- /dev/null +++ b/mysql-test/t/innodb_bug21704.test @@ -0,0 +1,96 @@ +-- source include/have_innodb.inc + +--echo # +--echo # Bug#21704: Renaming column does not update FK definition. +--echo # + +--echo +--echo # Test that it's not possible to rename columns participating in a +--echo # foreign key (either in the referencing or referenced table). +--echo + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +--enable_warnings + +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT ENGINE=INNODB; + +CREATE TABLE t2 (a INT PRIMARY KEY, b INT, + CONSTRAINT fk1 FOREIGN KEY (a) REFERENCES t1(a)) +ROW_FORMAT=COMPACT ENGINE=INNODB; + +CREATE TABLE t3 (a INT PRIMARY KEY, b INT, KEY(b), C INT, + CONSTRAINT fk2 FOREIGN KEY (b) REFERENCES t3 (a)) +ROW_FORMAT=COMPACT ENGINE=INNODB; + +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); +INSERT INTO t2 VALUES (1,1),(2,2),(3,3); +INSERT INTO t3 VALUES (1,1,1),(2,2,2),(3,3,3); + +--echo +--echo # Test renaming the column in the referenced table. +--echo + +# mysqltest first does replace_regex, then replace_result +--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' +--error ER_ERROR_ON_RENAME +ALTER TABLE t1 CHANGE a c INT; + +--echo # Ensure that online column rename works. + +--enable_info +ALTER TABLE t1 CHANGE b c INT; +--disable_info + +--echo +--echo # Test renaming the column in the referencing table +--echo + +# mysqltest first does replace_regex, then replace_result +--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' +--error ER_ERROR_ON_RENAME +ALTER TABLE t2 CHANGE a c INT; + +--echo # Ensure that online column rename works. + +--enable_info +ALTER TABLE t2 CHANGE b c INT; +--disable_info + +--echo +--echo # Test with self-referential constraints +--echo + +# mysqltest first does replace_regex, then replace_result +--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' +--error ER_ERROR_ON_RENAME +ALTER TABLE t3 CHANGE a d INT; + +# mysqltest first does replace_regex, then replace_result +--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' +--error ER_ERROR_ON_RENAME +ALTER TABLE t3 CHANGE b d INT; + +--echo # Ensure that online column rename works. + +--enable_info +ALTER TABLE t3 CHANGE c d INT; +--disable_info + +--echo +--echo # Cleanup. +--echo + +DROP TABLE t3; +DROP TABLE t2; +DROP TABLE t1; diff --git a/mysql-test/t/innodb_bug40565.test b/mysql-test/t/innodb_bug40565.test new file mode 100644 index 00000000000..d7aa0fd514a --- /dev/null +++ b/mysql-test/t/innodb_bug40565.test @@ -0,0 +1,10 @@ +# Bug #40565 Update Query Results in "1 Row Affected" But Should Be "Zero Rows" +-- source include/have_innodb.inc + +create table bug40565(value decimal(4,2)) engine=innodb; +insert into bug40565 values (1), (null); +--enable_info +update bug40565 set value=NULL; +update bug40565 set value=NULL; +--disable_info +drop table bug40565; diff --git a/mysql-test/t/innodb_bug42101-nonzero-master.opt b/mysql-test/t/innodb_bug42101-nonzero-master.opt new file mode 100644 index 00000000000..d71dbe17d5b --- /dev/null +++ b/mysql-test/t/innodb_bug42101-nonzero-master.opt @@ -0,0 +1 @@ +--innodb_commit_concurrency=1 diff --git a/mysql-test/t/innodb_bug42101-nonzero.test b/mysql-test/t/innodb_bug42101-nonzero.test new file mode 100644 index 00000000000..685fdf20489 --- /dev/null +++ b/mysql-test/t/innodb_bug42101-nonzero.test @@ -0,0 +1,21 @@ +# +# Bug#42101 Race condition in innodb_commit_concurrency +# http://bugs.mysql.com/42101 +# + +-- source include/have_innodb.inc + +--error ER_WRONG_ARGUMENTS +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=42; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=DEFAULT; +select @@innodb_commit_concurrency; +--error ER_WRONG_ARGUMENTS +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; diff --git a/mysql-test/t/innodb_bug42101.test b/mysql-test/t/innodb_bug42101.test new file mode 100644 index 00000000000..b6536490d48 --- /dev/null +++ b/mysql-test/t/innodb_bug42101.test @@ -0,0 +1,19 @@ +# +# Bug#42101 Race condition in innodb_commit_concurrency +# http://bugs.mysql.com/42101 +# + +-- source include/have_innodb.inc + +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +--error ER_WRONG_ARGUMENTS +set global innodb_commit_concurrency=1; +select @@innodb_commit_concurrency; +--error ER_WRONG_ARGUMENTS +set global innodb_commit_concurrency=42; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=0; +select @@innodb_commit_concurrency; +set global innodb_commit_concurrency=DEFAULT; +select @@innodb_commit_concurrency; diff --git a/mysql-test/t/innodb_bug45357.test b/mysql-test/t/innodb_bug45357.test new file mode 100644 index 00000000000..81727f352dd --- /dev/null +++ b/mysql-test/t/innodb_bug45357.test @@ -0,0 +1,10 @@ +-- source include/have_innodb.inc + +set session transaction isolation level read committed; + +create table bug45357(a int, b int,key(b))engine=innodb; +insert into bug45357 values (25170,6122); +update bug45357 set a=1 where b=30131; +delete from bug45357 where b < 20996; +delete from bug45357 where b < 7001; +drop table bug45357; diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index ad9e726f5b4..c643465b2f3 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -332,4 +332,133 @@ DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; +# +# Bug#43580: Issue with Innodb on multi-table update +# +CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE = INNODB; +CREATE TABLE t2 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; + +CREATE TABLE t3 (a INT, b INT KEY, KEY (a)) ENGINE = INNODB; +CREATE TABLE t4 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; + +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); + +INSERT INTO t3 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105), (6, 106); +INSERT INTO t4 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); + +UPDATE t1, t2 SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b; +--sorted_result +SELECT * FROM t2; + +UPDATE t3, t4 SET t3.a = t3.a + 100, t4.b = t3.a + 10 +WHERE t3.a BETWEEN 2 AND 4 AND t4.a = t3.b - 100; +--sorted_result +SELECT * FROM t4; + +DROP TABLE t1, t2, t3, t4; + +--echo # +--echo # Bug#44886: SIGSEGV in test_if_skip_sort_order() - +--echo # uninitialized variable used as subscript +--echo # + +CREATE TABLE t1 (a INT, b INT, c INT, d INT, PRIMARY KEY (b), KEY (a,c)) + ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,1,1,0); + +CREATE TABLE t2 (a INT, b INT, e INT, KEY (e)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,1,2); + +CREATE TABLE t3 (a INT, b INT) ENGINE=MyISAM; +INSERT INTO t3 VALUES (1, 1); + +SELECT * FROM t1, t2, t3 + WHERE t1.a = t3.a AND (t1.b = t3.b OR t1.d) AND t2.b = t1.b AND t2.e = 2 + GROUP BY t1.b; + +DROP TABLE t1, t2, t3; + +--echo # +--echo # Bug #45828: Optimizer won't use partial primary key if another +--echo # index can prevent filesort +--echo # + +# Create the table +CREATE TABLE `t1` ( + c1 int NOT NULL, + c2 int NOT NULL, + c3 int NOT NULL, + PRIMARY KEY (c1,c2), + KEY (c3) +) ENGINE=InnoDB; + +# populate with data +INSERT INTO t1 VALUES (5,2,1246276747); +INSERT INTO t1 VALUES (2,1,1246281721); +INSERT INTO t1 VALUES (7,3,1246281756); +INSERT INTO t1 VALUES (4,2,1246282139); +INSERT INTO t1 VALUES (3,1,1246282230); +INSERT INTO t1 VALUES (1,0,1246282712); +INSERT INTO t1 VALUES (8,3,1246282765); +INSERT INTO t1 SELECT c1+10,c2+10,c3+10 FROM t1; +INSERT INTO t1 SELECT c1+100,c2+100,c3+100 from t1; +INSERT INTO t1 SELECT c1+1000,c2+1000,c3+1000 from t1; +INSERT INTO t1 SELECT c1+10000,c2+10000,c3+10000 from t1; +INSERT INTO t1 SELECT c1+100000,c2+100000,c3+100000 from t1; +INSERT INTO t1 SELECT c1+1000000,c2+1000000,c3+1000000 from t1; + +# query and no rows will match the c1 condition, whereas all will match c3 +SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; + +# SHOULD use the pk. +# index on c3 will be used instead of primary key +EXPLAIN SELECT * FROM t1 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; + +# if we force the primary key, we can see the estimate is 1 +EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; + + +CREATE TABLE t2 ( + c1 int NOT NULL, + c2 int NOT NULL, + c3 int NOT NULL, + KEY (c1,c2), + KEY (c3) +) ENGINE=InnoDB; + +# SHOULD use the pk. +# if we switch it from a primary key to a regular index, it works correctly as well +explain SELECT * FROM t2 WHERE c1 = 99999999 AND c3 > 1 ORDER BY c3; + +DROP TABLE t1,t2; + + +--echo # +--echo # 36259: Optimizing with ORDER BY +--echo # + +CREATE TABLE t1 ( + a INT NOT NULL AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL, + d VARCHAR(5), + e INT NOT NULL, + PRIMARY KEY (a), KEY i2 (b,c,d) +) ENGINE=InnoDB; + +INSERT INTO t1 (b,c,d,e) VALUES (1,1,'a',1), (2,2,'b',2); +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +EXPLAIN SELECT * FROM t1 WHERE b=1 AND c=1 ORDER BY a; +EXPLAIN SELECT * FROM t1 FORCE INDEX(i2) WHERE b=1 and c=1 ORDER BY a; +EXPLAIN SELECT * FROM t1 FORCE INDEX(PRIMARY) WHERE b=1 AND c=1 ORDER BY a; + +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/log_tables_debug.test b/mysql-test/t/log_tables_debug.test new file mode 100644 index 00000000000..19a62614608 --- /dev/null +++ b/mysql-test/t/log_tables_debug.test @@ -0,0 +1,94 @@ +### t/log_tables_debug.test +# +# Log-related tests requiring a debug-build server. +# + +# extra clean-up required due to Bug#38124, set to 1 when behavior has +# changed (see explanation in log_state.test) +let $fixed_bug38124 = 0; + +--source include/have_debug.inc + +# Several subtests modify global variables. Save the initial values only here, +# but reset to the initial values per subtest. +SET @old_general_log= @@global.general_log; +SET @old_general_log_file= @@global.general_log_file; +SET @old_slow_query_log= @@global.slow_query_log; +SET @old_slow_query_log_file= @@global.slow_query_log_file; + + +--echo # +--echo # Bug#45387 Information about statement id for prepared +--echo # statements missed from general log +--echo # + +let MYSQLD_DATADIR= `SELECT @@datadir`; + +# set logging to our specific bug log to control the entries added +SET @@global.general_log = ON; +SET @@global.general_log_file = 'bug45387_general.log'; + +# turn on output of timestamps on all log file entries +SET SESSION debug='+d,reset_log_last_time'; + +let CONN_ID= `SELECT CONNECTION_ID()`; +FLUSH LOGS; + +# reset log settings +SET @@global.general_log = @old_general_log; +SET @@global.general_log_file = @old_general_log_file; +SET SESSION debug='-d'; + +perl; + # get the relevant info from the surrounding perl invocation + $datadir= $ENV{'MYSQLD_DATADIR'}; + $conn_id= $ENV{'CONN_ID'}; + + # loop through the log file looking for the stmt querying for conn id + open(FILE, "$datadir/bug45387_general.log") or + die("Unable to read log file $datadir/bug45387_general.log: $!\n"); + while(<FILE>) { + if (/\d{6}\s+\d+:\d+:\d+[ \t]+(\d+)[ \t]+Query[ \t]+SELECT CONNECTION_ID/) { + $found= $1; + break; + } + } + + # print the result + if ($found == $conn_id) { + print "Bug#45387: ID match.\n"; + } else { + print "Bug#45387: Expected ID '$conn_id', found '$found' in log file.\n"; + print "Contents of log file:\n"; + seek(FILE, 0, 0); + while($line= <FILE>) { + print $line; + } + } + + close(FILE); +EOF + +--remove_file $MYSQLD_DATADIR/bug45387_general.log + +--echo End of 5.1 tests + + +--echo # +--echo # Cleanup +--echo # + +# Reset global system variables to initial values if forgotten somewhere above. +SET global general_log = @old_general_log; +SET global general_log_file = @old_general_log_file; +SET global slow_query_log = @old_slow_query_log; +SET global slow_query_log_file = @old_slow_query_log_file; +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_general_log_file`; + eval SET @@global.general_log_file = '$my_var'; + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} diff --git a/mysql-test/t/lowercase_fs_off.test b/mysql-test/t/lowercase_fs_off.test index 414027cb485..878564c32ab 100644 --- a/mysql-test/t/lowercase_fs_off.test +++ b/mysql-test/t/lowercase_fs_off.test @@ -14,16 +14,18 @@ flush privileges; connect (sample,localhost,sample,password,d1); connection sample; select database(); ---error 1044 +--error ER_DBACCESS_DENIED_ERROR create database d2; ---error 1044 +--error ER_DBACCESS_DENIED_ERROR create database D1; disconnect sample; +--source include/wait_until_disconnected.inc connection master; drop user 'sample'@'localhost'; drop database if exists d1; disconnect master; +--source include/wait_until_disconnected.inc connection default; # End of 4.1 tests diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 5315c91daa6..8760876b7ee 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -1535,4 +1535,24 @@ SELECT * FROM m1; DROP VIEW v1; DROP TABLE m1, t1; + +--echo # +--echo # Bug #45796: invalid memory reads and writes when altering merge and +--echo # base tables +--echo # + +CREATE TABLE t1(c1 INT) ENGINE=MyISAM; +CREATE TABLE m1(c1 INT) ENGINE=MERGE UNION=(t1); +ALTER TABLE m1 ADD INDEX idx_c1(c1); +# Open the MERGE table and allocate buffers based on children's definition. +--error ER_WRONG_MRG_TABLE +SELECT * FROM m1; +# Change the child table definition. +ALTER TABLE t1 ADD INDEX idx_c1(c1); +# Check that old buffers are not reused +SELECT * FROM m1; + +DROP TABLE m1; +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/mysql-test/t/multi_update2.test b/mysql-test/t/multi_update2.test index 47f9bc7bad7..a04518f4964 100644 --- a/mysql-test/t/multi_update2.test +++ b/mysql-test/t/multi_update2.test @@ -2,14 +2,46 @@ # Test of update statement that uses many tables. # ---disable_warnings -DROP TABLE IF EXISTS t1,t2; ---enable_warnings +# +# If we are running with +# - Valgrind -> $VALGRIND_TEST <> 0 +# - debug tracing -> @@session.debug LIKE '%trace%' +# the resource consumption (storage space needed, runtime) will be extreme. +# Therefore we require that the option "--big-test" is also set. +# + +let $need_big= 0; +--disable_query_log +--error 0,ER_UNKNOWN_SYSTEM_VARIABLE +SET @aux = @@session.debug; +if (!$mysql_errno) +{ + # We have returncode 0 = the server system variable @@session.debug exists. + # But we only need "--big-test" in case of tracing. + if (`SELECT @@session.debug LIKE '%trace%'`) + { + let $need_big= 1; + } +} +--enable_query_log +if ($VALGRIND_TEST) +{ + # We are running with Valgrind + inc $need_big; +} +if (`SELECT '$BIG_TEST' = '' AND $need_big = 1`) +{ + --skip Need "--big-test" when running with the option "--debug" or "--valgrind" +} # # Bug#1820 Rows not deleted from second table on multi-table delete # +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +--enable_warnings + CREATE TABLE t1 ( a INT NOT NULL, b INT NOT NULL) ; --echo # The protocolling of many inserts into t1 is suppressed. --disable_query_log diff --git a/mysql-test/t/myisam_debug.test b/mysql-test/t/myisam_debug.test index a73187cd2ca..913668c5f22 100644 --- a/mysql-test/t/myisam_debug.test +++ b/mysql-test/t/myisam_debug.test @@ -1,5 +1,8 @@ --source include/have_debug.inc +# We disable this test in embedded mode because of BUG#43733 +--source include/not_embedded.inc + --echo # --echo # BUG#40827 - Killing insert-select to MyISAM can cause table corruption --echo # diff --git a/mysql-test/t/mysql-bug45236.test b/mysql-test/t/mysql-bug45236.test new file mode 100644 index 00000000000..efc10ed19ea --- /dev/null +++ b/mysql-test/t/mysql-bug45236.test @@ -0,0 +1,45 @@ +# +# Bug #45236: large blob inserts from mysqldump fail, possible memory issue ? +# +# This test consumes a significant amount of resources. +# Therefore it should be kept separated from other tests. +# Otherwise we might suffer from problems like +# Bug#43801 mysql.test takes too long, fails due to expired timeout +# on debx86-b in PB +# + +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# Have to change the global variable as the session variable is +# read-only. +SET @old_max_allowed_packet= @@global.max_allowed_packet; +# ~1 MB blob length + some space for the rest of INSERT query +SET @@global.max_allowed_packet = 1024 * 1024 + 1024; + +# Create a new connection since the global max_allowed_packet +# has no effect onr the current one +connect (con1, localhost, root,,); + +CREATE TABLE t1(data LONGBLOB); +INSERT INTO t1 SELECT CONCAT(REPEAT('1', 1024*1024 - 27), + "\'\r dummydb dummyhost"); + +let $outfile= $MYSQLTEST_VARDIR/tmp/bug41486.sql; +--error 0,1 +remove_file $outfile; +--exec $MYSQL_DUMP --compact -t test t1 > $outfile +# Check that the mysql client does not interpret the "\r" sequence as a command +--exec $MYSQL --max_allowed_packet=1M test < $outfile 2>&1 + +DROP TABLE t1; + +# Cleanup +disconnect con1; +--source include/wait_until_disconnected.inc +remove_file $outfile; +connection default; +SET @@global.max_allowed_packet = @old_max_allowed_packet; diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 91679c8c2ff..2bb9a02e9d7 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -342,6 +342,21 @@ EOF remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql; +# +# Bug #39101: client -i (--ignore-spaces) option does not seem to work +# +--exec $MYSQL -i -e "SELECT COUNT (*)" +--exec $MYSQL --ignore-spaces -e "SELECT COUNT (*)" +--exec $MYSQL -b -i -e "SELECT COUNT (*)" + +# +# Bug#37268 'binary' character set makes CLI-internal commands case sensitive +# +--replace_regex /\([0-9]*\)/(errno)/ +--error 1 +--exec $MYSQL --default-character-set=binary test -e "CONNECT test invalid_hostname" 2>&1 +--exec $MYSQL --default-character-set=binary test -e "DELIMITER //" 2>&1 + --echo End of 5.0 tests # @@ -370,7 +385,7 @@ drop tables t1, t2; # # Bug #27884: mysql --html does not quote HTML special characters in output # ---exec $MYSQL --html test -e "select '< & >' as \`<\`" +--exec $MYSQL --html test -e "select '< & >' as '<'" --echo --echo End of tests diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 46060649784..7767abe43d0 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -367,4 +367,16 @@ echo *** Unsigned server_id $s_id_max is found: $s_id_unsigned ***; eval SET @@global.server_id= $save_server_id; --remove_file $binlog_file +# +# Bug #41943: mysqlbinlog.exe crashes if --hexdump option is used +# + +RESET MASTER; +FLUSH LOGS; + +# We do not need the results, just make sure that mysqlbinlog does not crash +--exec $MYSQL_BINLOG --hexdump --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 >/dev/null + +--echo End of 5.0 tests + --echo End of 5.1 tests diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 64d1036e264..ec96124e14b 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1,6 +1,5 @@ # Embedded server doesn't support external clients --source include/not_embedded.inc ---source include/have_log_bin.inc # Binlog is required --source include/have_log_bin.inc @@ -1955,6 +1954,59 @@ SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT; ########################################################################### +--echo +--echo Bug #34861 - mysqldump with --tab gives weird output for triggers. +--echo + +CREATE TABLE t1 (f1 INT); +CREATE TRIGGER tr1 BEFORE UPDATE ON t1 FOR EACH ROW SET @f1 = 1; +CREATE PROCEDURE pr1 () SELECT "Meow"; +CREATE EVENT ev1 ON SCHEDULE AT '2030-01-01 00:00:00' DO SELECT "Meow"; + +--echo +SHOW TRIGGERS; +SHOW EVENTS; +SELECT name,body FROM mysql.proc WHERE NAME = 'pr1'; + +--echo +--echo dump table; if anything goes to stdout, it ends up here: --------------- +--exec $MYSQL_DUMP --compact --routines --triggers --events --result-file=$MYSQLTEST_VARDIR/tmp/test_34861.sql --tab=$MYSQLTEST_VARDIR/tmp/ test + +--echo +--echo drop everything +DROP EVENT ev1; +DROP TRIGGER tr1; +DROP TABLE t1; +DROP PROCEDURE pr1; + +--echo +--echo reload table; this should restore table and trigger +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql +SHOW TRIGGERS; +SHOW EVENTS; +SELECT name,body FROM mysql.proc WHERE NAME = 'pr1'; + +--echo +--echo reload db; this should restore routines and events +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/test_34861.sql +SHOW TRIGGERS; +SHOW EVENTS; +SELECT name,body FROM mysql.proc WHERE NAME = 'pr1'; + +--echo +--echo cleanup +--remove_file $MYSQLTEST_VARDIR/tmp/t1.txt +--remove_file $MYSQLTEST_VARDIR/tmp/t1.sql +--remove_file $MYSQLTEST_VARDIR/tmp/test_34861.sql +--disable_warnings +DROP EVENT IF EXISTS ev1; +DROP PROCEDURE IF EXISTS pr1; +DROP TRIGGER IF EXISTS tr1; +DROP TABLE IF EXISTS t1; +--enable_warnings + +########################################################################### + --echo # --echo # End of 5.1 tests --echo # diff --git a/mysql-test/t/mysqldump_restore.test b/mysql-test/t/mysqldump_restore.test new file mode 100644 index 00000000000..835ee3ee9e9 --- /dev/null +++ b/mysql-test/t/mysqldump_restore.test @@ -0,0 +1,111 @@ +############################################################################### +# mysqldump_restore.test +# +# Purpose: Tests if mysqldump output can be used to successfully restore +# tables and data. +# We CREATE a table, mysqldump it to a file, ALTER the original +# table's name, recreate the table from the mysqldump file, then +# utilize include/diff_tables to compare the original and recreated +# tables. +# +# We use several examples from mysqldump.test here and include +# the relevant bug numbers and headers from that test. +# +# NOTE: This test is not currently complete and offers only basic +# cases of mysqldump output being restored. +# Also, does NOT work with -X (xml) output! +# +# Author: pcrews +# Created: 2009-05-21 +# Last Change: +# Change date: +############################################################################### + +# Embedded server doesn't support external clients +--source include/not_embedded.inc +--source include/have_log_bin.inc + +--echo # Set concurrent_insert = 0 to prevent random errors +--echo # will reset to original value at the end of the test +SET @old_concurrent_insert = @@global.concurrent_insert; +SET @@global.concurrent_insert = 0; + +# Define mysqldumpfile here. It is used to capture mysqldump output +# in order to test the output's ability to restore an exact copy of the table +let $mysqldumpfile = $MYSQLTEST_VARDIR/tmp/mysqldumpfile.sql; + +--echo # Pre-test cleanup +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo # Begin tests +--echo # +--echo # Bug#2005 Long decimal comparison bug. +--echo # +CREATE TABLE t1 (a DECIMAL(64, 20)); +INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), +("0987654321098765432109876543210987654321"); +--exec $MYSQL_DUMP --compact test t1 > $mysqldumpfile +let $table_name = test.t1; +--source include/mysqldump.inc + +--echo # +--echo # Bug#3361 mysqldump quotes DECIMAL values inconsistently +--echo # +CREATE TABLE t1 (a DECIMAL(10,5), b FLOAT); +# Check at first how mysql work with quoted decimal +INSERT INTO t1 VALUES (1.2345, 2.3456); +INSERT INTO t1 VALUES ('1.2345', 2.3456); +INSERT INTO t1 VALUES ("1.2345", 2.3456); +SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI_QUOTES'; +INSERT INTO t1 VALUES (1.2345, 2.3456); +INSERT INTO t1 VALUES ('1.2345', 2.3456); +--error ER_BAD_FIELD_ERROR +INSERT INTO t1 VALUES ("1.2345", 2.3456); +SET SQL_MODE=@OLD_SQL_MODE; + +# check how mysqldump make quoting +--exec $MYSQL_DUMP --compact test t1 > $mysqldumpfile +let $table_name = test.t1; +--source include/mysqldump.inc + +--echo # +--echo # Bug#1994 mysqldump does not correctly dump UCS2 data +--echo # Bug#4261 mysqldump 10.7 (mysql 4.1.2) --skip-extended-insert drops NULL from inserts +--echo # +CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r; +INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL); +--exec $MYSQL_DUMP --skip-comments --skip-extended-insert test t1 > $mysqldumpfile +let $table_name = test.t1; +--source include/mysqldump.inc + +--echo # +--echo # WL#2319 Exclude Tables from dump +--echo # +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +INSERT INTO t2 VALUES (4),(5),(6); +--exec $MYSQL_DUMP --skip-comments --ignore-table=test.t1 test > $mysqldumpfile +let $table_name = test.t2; +--source include/mysqldump.inc +DROP TABLE t1; + +--echo # +--echo # Bug#8830 mysqldump --skip-extended-insert causes --hex-blob to dump wrong values +--echo # +CREATE TABLE t1 (`b` blob); +INSERT INTO `t1` VALUES (0x602010000280100005E71A); +--exec $MYSQL_DUMP --skip-extended-insert --hex-blob test --skip-comments t1 > $mysqldumpfile +let $table_name = test.t1; +--source include/mysqldump.inc + +--echo # End tests + +--echo # Cleanup +--echo # Reset concurrent_insert to its original value +SET @@global.concurrent_insert = @old_concurrent_insert; +--echo # remove mysqldumpfile +--error 0,1 +--remove_file $mysqldumpfile diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 55cd041aaf5..578b2bf5c6c 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1780,6 +1780,56 @@ remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp; --error 1 --exec echo "copy_file from_file;" | $MYSQL_TEST 2>&1 + +# ---------------------------------------------------------------------------- +# test for move_file +# ---------------------------------------------------------------------------- + +# - Check that if source file does not exist, nothing will be created. + +--error 1 +file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; +--error 1 +file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; +--error 1 +move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp; +--error 1 +file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; +--error 1 +file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; + +# - Check that if source file exists, everything works properly. + +--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +file1 +EOF + +move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp; +--error 1 +file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; +file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; + +# - Check that if destination file exists, everything works properly. +# (file2.tmp exists from the previous check; file1.tmp needs to be created) + +--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +file1 +EOF + +move_file $MYSQLTEST_VARDIR/tmp/file1.tmp $MYSQLTEST_VARDIR/tmp/file2.tmp; +--error 1 +file_exists $MYSQLTEST_VARDIR/tmp/file1.tmp; +file_exists $MYSQLTEST_VARDIR/tmp/file2.tmp; +remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp; + +# - Check usage. + +--error 1 +--exec echo "move_file ;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "move_file from_file;" | $MYSQL_TEST 2>&1 + # ---------------------------------------------------------------------------- # test for chmod # ---------------------------------------------------------------------------- @@ -2037,6 +2087,10 @@ let $value= query_get_value(SELECT 'A B' AS "MyColumn", MyColumn, 1); let $value= query_get_value(SELECT 1 AS "My Column", My Column, 1); --echo value= $value # +# 4.1 Query containing , protected by quotes, quotes also on column +let $value= query_get_value('SELECT 1 as a, 2 as b', "b", 1); +--echo value= $value +# #------------ Negative tests ------------ # 5. Incomplete statement including missing parameters # 5.1 incomplete statement diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test index 240a977fdca..baa1603faab 100644 --- a/mysql-test/t/openssl_1.test +++ b/mysql-test/t/openssl_1.test @@ -238,7 +238,18 @@ DROP TABLE t1; --enable_query_log select 'is still running; no cipher request crashed the server' as result from dual; -## +# +# Bug#42158: leak: SSL_get_peer_certificate() doesn't have matching X509_free() +# + +GRANT SELECT ON test.* TO bug42158@localhost REQUIRE X509; +FLUSH PRIVILEGES; +connect(con1,localhost,bug42158,,,,,SSL); +SHOW STATUS LIKE 'Ssl_cipher'; +disconnect con1; +connection default; +DROP USER bug42158@localhost; + --echo End of 5.1 tests # Wait till we reached the initial number of concurrent sessions diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index ce89609de39..8b4af201af2 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1935,7 +1935,58 @@ INSERT INTO t1 VALUES (10), (100), (200), (300), (400); EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a>=200; DROP TABLE t1; ---echo End of 5.1 tests +# +# Bug#44821: select distinct on partitioned table returns wrong results +# +CREATE TABLE t1 ( a INT, b INT, c INT, KEY bc(b, c) ) +PARTITION BY KEY (a, b) PARTITIONS 3 +; + +INSERT INTO t1 VALUES +(17, 1, -8), +(3, 1, -7), +(23, 1, -6), +(22, 1, -5), +(11, 1, -4), +(21, 1, -3), +(19, 1, -2), +(30, 1, -1), + +(20, 1, 1), +(16, 1, 2), +(18, 1, 3), +(9, 1, 4), +(15, 1, 5), +(28, 1, 6), +(29, 1, 7), +(25, 1, 8), +(10, 1, 9), +(13, 1, 10), +(27, 1, 11), +(24, 1, 12), +(12, 1, 13), +(26, 1, 14), +(14, 1, 15) +; + +SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c; + +EXPLAIN +SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c; +DROP TABLE t1; + +--echo # +--echo # Bug #45807: crash accessing partitioned table and sql_mode +--echo # contains ONLY_FULL_GROUP_BY +--echo # + +SET SESSION SQL_MODE='ONLY_FULL_GROUP_BY'; +CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM + PARTITION BY HASH(id) PARTITIONS 2; +DROP TABLE t1; +SET SESSION SQL_MODE=DEFAULT; + +--echo End of 5.1 tests SET @@global.general_log= @old_general_log; diff --git a/mysql-test/t/query_cache_debug.test b/mysql-test/t/query_cache_debug.test index 8cf5e9d4b16..d30cd458e99 100644 --- a/mysql-test/t/query_cache_debug.test +++ b/mysql-test/t/query_cache_debug.test @@ -112,3 +112,148 @@ DROP TABLE t1,t2; SET GLOBAL concurrent_insert= DEFAULT; SET GLOBAL query_cache_size= DEFAULT; SET GLOBAL query_cache_type= DEFAULT; + + +--echo # +--echo # Bug43758 Query cache can lock up threads in 'freeing items' state +--echo # +FLUSH STATUS; +SET GLOBAL query_cache_type=DEMAND; +SET GLOBAL query_cache_size= 1024*768; +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3,t4,t5; +--enable_warnings +CREATE TABLE t1 (a VARCHAR(100)); +CREATE TABLE t2 (a VARCHAR(100)); +CREATE TABLE t3 (a VARCHAR(100)); +CREATE TABLE t4 (a VARCHAR(100)); +CREATE TABLE t5 (a VARCHAR(100)); + +INSERT INTO t1 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t2 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t3 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t4 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t5 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); + +connect (thd2, localhost, root, ,test); +connect (thd3, localhost, root, ,test); +connect (thd1, localhost, root, ,test); + +connection thd1; +--echo =================================== Connection thd1 +--echo ** +--echo ** Load Query Cache with a result set and one table. +--echo ** +SELECT SQL_CACHE * FROM t1; +--echo ************************************************************************* +--echo ** We want to accomplish the following state: +--echo ** - Query cache status: TABLE_FLUSH_IN_PROGRESS +--echo ** - THD1: invalidate_table_internal (iterating query blocks) +--echo ** - THD2: query_cache_insert (cond_wait) +--echo ** - THD3: query_cache_insert (cond_wait) +--echo ** - No thread should be holding the structure_guard_mutex. +--echo ** +--echo ** First step is to place a DELETE-statement on the debug hook just +--echo ** before the mutex lock in invalidate_table_internal. +--echo ** This will allow new result sets to be written into the QC. +--echo ** +SET SESSION debug='+d,wait_in_query_cache_invalidate1'; +SET SESSION debug='+d,wait_in_query_cache_invalidate2'; +--send DELETE FROM t1 WHERE a like '%a%'; + +connection default; +--echo =================================== Connection default +--echo ** Assert that the expect process status is obtained. +LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 1 FROM information_schema.processlist WHERE state= 'wait_in_query_cache_invalidate1'; +--source include/wait_condition.inc +-- echo ** + +connection thd2; +--echo =================================== Connection thd2 +--echo ** On THD2: Insert a result into the cache. This attempt will be blocked +--echo ** because of a debug hook placed just before the mutex lock after which +--echo ** the first part of the result set is written. +SET SESSION debug='+d,wait_in_query_cache_insert'; +--send SELECT SQL_CACHE * FROM t2 UNION SELECT * FROM t3 + +connection thd3; +--echo =================================== Connection thd3 +--echo ** On THD3: Insert another result into the cache and block on the same +--echo ** debug hook. +SET SESSION debug='+d,wait_in_query_cache_insert'; +--send SELECT SQL_CACHE * FROM t4 UNION SELECT * FROM t5; + +connection default; +--echo =================================== Connection default +--echo ** Assert that the two SELECT-stmt threads to reach the hook. +LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 2 FROM information_schema.processlist WHERE state='wait_in_query_cache_insert'; +--source include/wait_condition.inc +--echo ** +--echo ** + +--echo ** Signal the DELETE thread, THD1, to continue. It will enter the mutex +--echo ** lock and set query cache status to TABLE_FLUSH_IN_PROGRESS and then +--echo ** unlock the mutex before stopping on the next debug hook. +SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate1' LIMIT 1 INTO @flush_thread_id; +KILL QUERY @flush_thread_id; +--echo ** Assert that we reach the next debug hook. +LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 1 FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate2'; +--source include/wait_condition.inc + +--echo ** +--echo ** Signal the remaining debug hooks blocking THD2 and THD3. +--echo ** The threads will grab the guard mutex enter the wait condition and +--echo ** and finally release the mutex. The threads will continue to wait +--echo ** until a broadcast signal reaches them causing both threads to +--echo ** come alive and check the condition. +SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id ASC LIMIT 1 INTO @thread_id; +KILL QUERY @thread_id; +SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id DESC LIMIT 1 INTO @thread_id; +KILL QUERY @thread_id; + +--echo ** +--echo ** Finally signal the DELETE statement on THD1 one last time. +--echo ** The stmt will complete the query cache invalidation and return +--echo ** cache status to NO_FLUSH_IN_PROGRESS. On the status change +--echo ** One signal will be sent to the thread group waiting for executing +--echo ** invalidations and a broadcast signal will be sent to the thread +--echo ** group holding result set writers. +SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate2' LIMIT 1 INTO @flush_thread_id; +KILL QUERY @flush_thread_id; + +--echo ** +--echo ************************************************************************* +--echo ** No tables should be locked +connection thd2; +--echo =================================== Connection thd2 +reap; +DELETE FROM t1; +DELETE FROM t2; +DELETE FROM t3; + +connection thd3; +--echo =================================== Connection thd3 +reap; +DELETE FROM t4; +DELETE FROM t5; + +connection thd1; +--echo =================================== Connection thd1 +reap; + +--echo ** Done. + +connection default; +disconnect thd1; +disconnect thd2; +disconnect thd3; +SET GLOBAL query_cache_size= 0; + +connection default; +--echo # Restore defaults +RESET QUERY CACHE; +FLUSH STATUS; +DROP TABLE t1,t2,t3,t4,t5; +SET GLOBAL query_cache_size= DEFAULT; +SET GLOBAL query_cache_type= DEFAULT; +exit; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 715bdf0e667..7d3785ecccc 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3799,4 +3799,90 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; DROP TABLE t1; + +--echo # +--echo # Bug#45266: Uninitialized variable lead to an empty result. +--echo # +--disable_warnings +drop table if exists A,AA,B,BB; +CREATE TABLE `A` ( + `pk` int(11) NOT NULL AUTO_INCREMENT, + `date_key` date NOT NULL, + `date_nokey` date NOT NULL, + `datetime_key` datetime NOT NULL, + `int_nokey` int(11) NOT NULL, + `time_key` time NOT NULL, + `time_nokey` time NOT NULL, + PRIMARY KEY (`pk`), + KEY `date_key` (`date_key`), + KEY `time_key` (`time_key`), + KEY `datetime_key` (`datetime_key`) +); + +CREATE TABLE `AA` ( + `pk` int(11) NOT NULL AUTO_INCREMENT, + `int_nokey` int(11) NOT NULL, + `time_key` time NOT NULL, + KEY `time_key` (`time_key`), + PRIMARY KEY (`pk`) +); + +CREATE TABLE `B` ( + `date_nokey` date NOT NULL, + `date_key` date NOT NULL, + `time_key` time NOT NULL, + `datetime_nokey` datetime NOT NULL, + `varchar_key` varchar(1) NOT NULL, + KEY `date_key` (`date_key`), + KEY `time_key` (`time_key`), + KEY `varchar_key` (`varchar_key`) +); + +INSERT INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x'); + +CREATE TABLE `BB` ( + `pk` int(11) NOT NULL AUTO_INCREMENT, + `int_nokey` int(11) NOT NULL, + `date_key` date NOT NULL, + `varchar_nokey` varchar(1) NOT NULL, + `date_nokey` date NOT NULL, + PRIMARY KEY (`pk`), + KEY `date_key` (`date_key`) +); + +INSERT INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18'); +# Test #1 +SELECT table1 . `pk` AS field1 + FROM + (BB AS table1 INNER JOIN + (AA AS table2 STRAIGHT_JOIN A AS table3 + ON ( table3 . `date_key` = table2 . `pk` )) + ON ( table3 . `datetime_key` = table2 . `int_nokey` )) + WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`) + GROUP BY field1 ; + +SELECT table3 .`date_key` field1 + FROM + B table1 LEFT JOIN B table3 JOIN + (BB table6 JOIN A table7 ON table6 .`varchar_nokey`) + ON table6 .`int_nokey` ON table6 .`date_key` + WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1; + +# Test #2 +SELECT table4 . `time_nokey` AS field1 FROM + (AA AS table1 CROSS JOIN + (AA AS table2 STRAIGHT_JOIN + (B AS table3 STRAIGHT_JOIN A AS table4 + ON ( table4 . `date_key` = table3 . `time_key` )) + ON ( table4 . `pk` = table3 . `date_nokey` )) + ON ( table4 . `time_key` = table3 . `datetime_nokey` )) + WHERE ( table4 . `time_key` < table1 . `time_key` AND + table1 . `int_nokey` != 'f') + GROUP BY field1 ORDER BY field1 , field1; + +SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2; +--enable_warnings + +drop table A,AA,B,BB; +--echo #end of test for bug#45266 --echo End of 5.1 tests diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 8d7c6d75a34..66b960c938f 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -2435,3 +2435,16 @@ delimiter ;$$ # LOAD DATA INFILE '../../tmp/proc.txt' INTO TABLE mysql.proc; remove_file $MYSQLTEST_VARDIR/tmp/proc.txt; + +# +# Bug #38159: Function parsing problem generates misleading error message +# + +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1), (2,2); +--error ER_FUNC_INEXISTENT_NAME_COLLISION +SELECT MAX (a) FROM t1 WHERE b = 999999; +SELECT AVG (a) FROM t1 WHERE b = 999999; +--error ER_SP_DOES_NOT_EXIST +SELECT non_existent (a) FROM t1 WHERE b = 999999; +DROP TABLE t1; diff --git a/mysql-test/t/sp-fib.test b/mysql-test/t/sp-fib.test new file mode 100644 index 00000000000..24a51b99c2d --- /dev/null +++ b/mysql-test/t/sp-fib.test @@ -0,0 +1,54 @@ +# Fibonacci, for recursion test. (Yet Another Numerical series :) +# Split from main.sp due to problems reported in Bug#15866 + +--disable_warnings +drop table if exists t3; +--enable_warnings +create table t3 ( f bigint unsigned not null ); + +# We deliberately do it the awkward way, fetching the last two +# values from the table, in order to exercise various statements +# and table accesses at each turn. +--disable_warnings +drop procedure if exists fib; +--enable_warnings + +# Now for multiple statements... +delimiter |; + +create procedure fib(n int unsigned) +begin + if n > 1 then + begin + declare x, y bigint unsigned; + declare c cursor for select f from t3 order by f desc limit 2; + open c; + fetch c into y; + fetch c into x; + insert into t3 values (x+y); + call fib(n-1); + ## Close the cursor AFTER the recursion to ensure that the stack + ## frame is somewhat intact. + close c; + end; + end if; +end| + +# Enable recursion +set @@max_sp_recursion_depth= 20| + +insert into t3 values (0), (1)| + +# The small number of recursion levels is intentional. +# We need to avoid +# Bug#15866 main.sp fails (thread stack limit +# insufficient for recursive call "fib(20)") +# which affects some platforms. +call fib(4)| + +select * from t3 order by f asc| + +drop table t3| +drop procedure fib| +set @@max_sp_recursion_depth= 0| + diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index fdf6ed8f382..5eeac457958 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -1561,61 +1561,6 @@ drop procedure ip| show procedure status where name like '%p%' and db='test'| -# Fibonacci, for recursion test. (Yet Another Numerical series :) -# ---disable_warnings -drop table if exists t3| ---enable_warnings -create table t3 ( f bigint unsigned not null )| - -# We deliberately do it the awkward way, fetching the last two -# values from the table, in order to exercise various statements -# and table accesses at each turn. ---disable_warnings -drop procedure if exists fib| ---enable_warnings -create procedure fib(n int unsigned) -begin - if n > 1 then - begin - declare x, y bigint unsigned; - declare c cursor for select f from t3 order by f desc limit 2; - - open c; - fetch c into y; - fetch c into x; - close c; - insert into t3 values (x+y); - call fib(n-1); - end; - end if; -end| - -# Enable recursion -set @@max_sp_recursion_depth= 20| - -# Minimum test: recursion of 3 levels - -insert into t3 values (0), (1)| - -call fib(3)| - -select * from t3 order by f asc| - -truncate table t3| - -# The original test, 20 levels, ran into memory limits on some machines -# and builds. Try 10 instead... - -insert into t3 values (0), (1)| - -call fib(10)| - -select * from t3 order by f asc| -drop table t3| -drop procedure fib| -set @@max_sp_recursion_depth= 0| - # # Comment & suid # diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test index f540126c405..ecb37c1299c 100644 --- a/mysql-test/t/sp_notembedded.test +++ b/mysql-test/t/sp_notembedded.test @@ -346,6 +346,32 @@ drop table t1; set session low_priority_updates=default; # +# Bug#44798 MySQL engine crashes when creating stored procedures with execute_priv=N +# +INSERT INTO mysql.user (Host, User, Password, Select_priv, Insert_priv, Update_priv, +Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, +Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, +Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv, +Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, +Create_user_priv, ssl_type, ssl_cipher, x509_issuer, x509_subject, max_questions, +max_updates, max_connections, max_user_connections) +VALUES('%', 'mysqltest_1', password(''), 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', +'N', 'N', 'N', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'N', '', +'', '', '', '0', '0', '0', '0'); +FLUSH PRIVILEGES; + +connect (con1, localhost, mysqltest_1,,); +connection con1; +CREATE PROCEDURE p1(i INT) BEGIN END; +disconnect con1; +connection default; +DROP PROCEDURE p1; + +DELETE FROM mysql.user WHERE User='mysqltest_1'; +FLUSH PRIVILEGES; + + +# # Restore global concurrent_insert value. Keep in the end of the test file. # diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test index acc9cc7979e..4a9f34443cb 100644 --- a/mysql-test/t/sql_mode.test +++ b/mysql-test/t/sql_mode.test @@ -308,3 +308,39 @@ flush privileges; --connection default drop user mysqltest_32753@localhost; + +# +# Bug#45100: Incomplete DROP USER in case of SQL_MODE = 'PAD_CHAR_TO_FULL_LENGTH' +# + +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +--enable_warnings + +# Generate some prerequisites +CREATE USER 'user_PCTFL'@'localhost' identified by 'PWD'; +CREATE USER 'user_no_PCTFL'@'localhost' identified by 'PWD'; + +CREATE TABLE t1 (f1 BIGINT); +CREATE TABLE t2 (f1 CHAR(3) NOT NULL, f2 CHAR(20)); + +# Grant privilege on a TABLE +GRANT ALL ON t1 TO 'user_PCTFL'@'localhost','user_no_PCTFL'@'localhost'; +# Grant privilege on some COLUMN of a table +GRANT SELECT(f1) ON t2 TO 'user_PCTFL'@'localhost','user_no_PCTFL'@'localhost'; + +SET @OLD_SQL_MODE = @@SESSION.SQL_MODE; +SET SESSION SQL_MODE = 'PAD_CHAR_TO_FULL_LENGTH'; +DROP USER 'user_PCTFL'@'localhost'; +SET SESSION SQL_MODE = @OLD_SQL_MODE; +DROP USER 'user_no_PCTFL'@'localhost'; + +FLUSH PRIVILEGES; + +SELECT * FROM mysql.db WHERE Host = 'localhost' AND User LIKE 'user_%PCTFL'; +SELECT * FROM mysql.tables_priv WHERE Host = 'localhost' AND User LIKE 'user_%PCTFL'; +SELECT * FROM mysql.columns_priv WHERE Host = 'localhost' AND User LIKE 'user_%PCTFL'; + +# Cleanup +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test index 5842f59af5c..5da210f5a69 100644 --- a/mysql-test/t/status.test +++ b/mysql-test/t/status.test @@ -12,6 +12,12 @@ set @old_concurrent_insert= @@global.concurrent_insert; set @@global.concurrent_insert= 0; +# Disable logging to table, since this will also cause table locking and unlocking, which will +# show up in SHOW STATUS and may cause sporadic failures + +SET @old_log_output = @@global.log_output; +SET GLOBAL LOG_OUTPUT = 'FILE'; + # PS causes different statistics --disable_ps_protocol @@ -350,6 +356,7 @@ DROP FUNCTION f1; # Restore global concurrent_insert value. Keep in the end of the test file. --connection default set @@global.concurrent_insert= @old_concurrent_insert; +SET GLOBAL log_output = @old_log_output; # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 9a5556c518d..1e55f9d5993 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -2370,4 +2370,30 @@ drop trigger trg1; drop trigger trg2; drop table t1, t2; +# +# Bug#44653: Server crash noticed when executing random queries with partitions. +# +CREATE TABLE t1 ( a INT, b INT ); +CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY, b INT ); + +INSERT INTO t1 (a) VALUES (1); + +delimiter //; +CREATE TRIGGER tr1 +BEFORE INSERT ON t2 +FOR EACH ROW +BEGIN + UPDATE a_nonextisting_table SET a = 1; +END// +delimiter ;// + +--disable_abort_on_error +CREATE TABLE IF NOT EXISTS t2 ( a INT, b INT ) SELECT a, b FROM t1; +--enable_abort_on_error + +# Caused failed assertion +SELECT * FROM t2; + +DROP TABLE t1, t2; + --echo End of 5.1 tests. diff --git a/mysql-test/t/trigger_notembedded.test b/mysql-test/t/trigger_notembedded.test index 9588ec6e3ed..7a7e6c6bc85 100644 --- a/mysql-test/t/trigger_notembedded.test +++ b/mysql-test/t/trigger_notembedded.test @@ -909,4 +909,27 @@ select * from t1; drop table t1; disconnect flush; +# +# Bug#45412 SHOW CREATE TRIGGER does not require privileges to disclose trigger data +# +CREATE DATABASE db1; +CREATE TABLE db1.t1 (a char(30)) ENGINE=MEMORY; +CREATE TRIGGER db1.trg AFTER INSERT ON db1.t1 FOR EACH ROW + INSERT INTO db1.t1 VALUES('Some very sensitive data goes here'); + +CREATE USER 'no_rights'@'localhost'; +REVOKE ALL ON *.* FROM 'no_rights'@'localhost'; +FLUSH PRIVILEGES; + +connect (con1,localhost,no_rights,,); +SELECT trigger_name FROM INFORMATION_SCHEMA.TRIGGERS + WHERE trigger_schema = 'db1'; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +SHOW CREATE TRIGGER db1.trg; + +connection default; +disconnect con1; +DROP USER 'no_rights'@'localhost'; +DROP DATABASE db1; + --echo End of 5.1 tests. diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 4cf9ea63dad..cd3c3f81510 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -1257,3 +1257,32 @@ select cast(-3.4 as decimal(2,1)); select cast(99.6 as decimal(2,0)); select cast(-13.4 as decimal(2,1)); select cast(98.6 as decimal(2,0)); + +--echo # +--echo # Bug #45262: Bad effects with CREATE TABLE and DECIMAL +--echo # + +CREATE TABLE t1 SELECT .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +DESCRIBE t1; +SELECT my_col FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT 1 + .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +DESCRIBE t1; +SELECT my_col FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT 1 * .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +DESCRIBE t1; +SELECT my_col FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT 1 / .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +DESCRIBE t1; +SELECT my_col FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col; +DESCRIBE t1; +SELECT my_col FROM t1; +DROP TABLE t1; diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test index 5fc763be7fe..5bb521601e5 100644 --- a/mysql-test/t/type_time.test +++ b/mysql-test/t/type_time.test @@ -77,3 +77,16 @@ insert into t1 values('2007-07-02', 1); insert into t1 values('2007-07-02', 2); SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2; drop table t1; + + +--echo # +--echo # Bug #44792: valgrind warning when casting from time to time +--echo # + +CREATE TABLE t1 (c TIME); +INSERT INTO t1 VALUES ('0:00:00'); +SELECT CAST(c AS TIME) FROM t1; +DROP TABLE t1; + + +--echo End of 5.0 tests diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index ece7099f66e..ec169838d59 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -1089,4 +1089,16 @@ CREATE TABLE t2 AS SELECT d FROM t1 UNION SELECT d FROM t1; SHOW FIELDS FROM t2; DROP TABLE t1, t2; +# +# Bug#43612 crash with explain extended, union, order by +# +CREATE TABLE t1(a INT); +EXPLAIN EXTENDED +SELECT a FROM t1 +UNION +SELECT a FROM t1 +ORDER BY a; +DROP TABLE t1; + + --echo End of 5.0 tests diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index fd4e538ea6c..c0740458a88 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -286,6 +286,18 @@ select @lastid != id, @lastid, @lastid := id from t1; drop table t1; # +# Bug#42009: SELECT into variable gives different results to direct SELECT +# +CREATE TABLE t1(a INT, b INT); +INSERT INTO t1 VALUES (0, 0), (2, 1), (2, 3), (1, 1), (30, 20); +SELECT a, b INTO @a, @b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; +SELECT @a, @b; +SELECT a, b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; +DROP TABLE t1; + +--echo End of 5.0 tests + +# # Bug#42188: crash and/or memory corruption with user variables in trigger # diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 6da20409639..1580d7f36d7 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -1201,4 +1201,29 @@ SET GLOBAL server_id = -1; SELECT @@GLOBAL.server_id; SET GLOBAL server_id = @old_server_id; +# +# Bug #42778: delete order by null global variable causes +# assertion .\filesort.cc, line 797 +# + +SELECT @@GLOBAL.INIT_FILE, @@GLOBAL.INIT_FILE IS NULL; + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (); +SET @bug42778= @@sql_safe_updates; +SET @@sql_safe_updates= 0; +DELETE FROM t1 ORDER BY (@@GLOBAL.INIT_FILE) ASC LIMIT 10; +SET @@sql_safe_updates= @bug42778; + +DROP TABLE t1; + +--echo # +--echo # BUG#10206 - InnoDB: Transaction requiring Max_BinLog_Cache_size > 4GB always rollsback +--echo # + +SET @old_max_binlog_cache_size = @@GLOBAL.max_binlog_cache_size; +--echo # Set the max_binlog_cache_size to size more than 4GB. +SET GLOBAL max_binlog_cache_size = 5 * 1024 * 1024 * 1024; +SELECT @@GLOBAL.max_binlog_cache_size; +SET GLOBAL max_binlog_cache_size = @old_max_binlog_cache_size; --echo End of 5.1 tests diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index c9d01266e9e..7bec02e6fb6 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -3681,6 +3681,61 @@ DROP VIEW v1; DROP TABLE t1; --echo # ----------------------------------------------------------------- +--echo # -- Bug#40825: Error 1356 while selecting from a view +--echo # -- with a "HAVING" clause though query works +--echo # ----------------------------------------------------------------- +--echo + +CREATE TABLE t1 (c INT); + +--echo + +CREATE VIEW v1 (view_column) AS SELECT c AS alias FROM t1 HAVING alias; +SHOW CREATE VIEW v1; +SELECT * FROM v1; + +--echo + +DROP VIEW v1; +DROP TABLE t1; + +--echo +--echo # -- End of test case for Bug#40825 +--echo + +--echo # +--echo # Bug #45806 crash when replacing into a view with a join! +--echo # +CREATE TABLE t1(a INT UNIQUE); +CREATE VIEW v1 AS SELECT t1.a FROM t1, t1 AS a; +INSERT INTO t1 VALUES (1), (2); + +REPLACE INTO v1(a) SELECT 1 FROM t1,t1 AS c; +SELECT * FROM v1; +REPLACE INTO v1(a) SELECT 3 FROM t1,t1 AS c; +SELECT * FROM v1; +DELETE FROM t1 WHERE a=3; +INSERT INTO v1(a) SELECT 1 FROM t1,t1 AS c +ON DUPLICATE KEY UPDATE `v1`.`a`= 1; +SELECT * FROM v1; + +CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a; + +REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c; +SELECT * FROM v2; +REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c; +SELECT * FROM v2; +INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c +ON DUPLICATE KEY UPDATE `v2`.`a`= 1; +SELECT * FROM v2; + +DROP VIEW v1; +DROP VIEW v2; +DROP TABLE t1; + +--echo # -- End of test case for Bug#45806 + +--echo # ----------------------------------------------------------------- --echo # -- End of 5.0 tests. --echo # ----------------------------------------------------------------- @@ -3836,6 +3891,17 @@ drop procedure p; ########################################################################### + +--echo # +--echo # Bug #44860: ALTER TABLE on view crashes server +--echo # +CREATE TABLE t1 (a INT); +CREATE VIEW v1 AS SELECT a FROM t1; +ALTER TABLE v1; +DROP VIEW v1; +DROP TABLE t1; + + --echo # ----------------------------------------------------------------- --echo # -- End of 5.1 tests. --echo # ----------------------------------------------------------------- diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test index 04ecf518577..7b1c6a268d5 100644 --- a/mysql-test/t/xa.test +++ b/mysql-test/t/xa.test @@ -124,6 +124,31 @@ drop table t1; --echo End of 5.0 tests +# +# Bug#44672: Assertion failed: thd->transaction.xid_state.xid.is_null() +# + +xa start 'a'; +xa end 'a'; +xa rollback 'a'; +xa start 'a'; +xa end 'a'; +xa rollback 'a'; + +# +# Bug#45548: XA transaction without access to InnoDB tables crashes the server +# + +xa start 'a'; +xa end 'a'; +xa prepare 'a'; +xa commit 'a'; + +xa start 'a'; +xa end 'a'; +xa prepare 'a'; +xa commit 'a'; + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysys/hash.c b/mysys/hash.c index e7b5352af34..63933abb085 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -45,6 +45,32 @@ static uint calc_hash(const HASH *hash, const uchar *key, size_t length) return nr1; } +/** + @brief Initialize the hash + + @details + + Initialize the hash, by defining and giving valid values for + its elements. The failure to allocate memory for the + hash->array element will not result in a fatal failure. The + dynamic array that is part of the hash will allocate memory + as required during insertion. + + @param[in,out] hash The hash that is initialized + @param[in] charset The charater set information + @param[in] size The hash size + @param[in] key_offest The key offset for the hash + @param[in] key_length The length of the key used in + the hash + @param[in] get_key get the key for the hash + @param[in] free_element pointer to the function that + does cleanup + @param[in] CALLER_INFO_PROTO flag that define the behaviour + of the hash + @return inidicates success or failure of initialization + @retval 0 success + @retval 1 failure +*/ my_bool _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset, ulong size, size_t key_offset, size_t key_length, @@ -55,12 +81,6 @@ _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset, DBUG_PRINT("enter",("hash: 0x%lx size: %u", (long) hash, (uint) size)); hash->records=0; - if (my_init_dynamic_array_ci(&hash->array, sizeof(HASH_LINK), size, - growth_size)) - { - hash->free=0; /* Allow call to my_hash_free */ - DBUG_RETURN(1); - } hash->key_offset=key_offset; hash->key_length=key_length; hash->blength=1; @@ -68,7 +88,8 @@ _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset, hash->free=free_element; hash->flags=flags; hash->charset=charset; - DBUG_RETURN(0); + DBUG_RETURN(my_init_dynamic_array_ci(&hash->array, + sizeof(HASH_LINK), size, growth_size)); } @@ -114,6 +135,7 @@ void my_hash_free(HASH *hash) my_hash_free_elements(hash); hash->free= 0; delete_dynamic(&hash->array); + hash->blength= 0; DBUG_VOID_RETURN; } diff --git a/mysys/mf_format.c b/mysys/mf_format.c index f199132626b..6afa2938fa3 100644 --- a/mysys/mf_format.c +++ b/mysys/mf_format.c @@ -79,7 +79,7 @@ char * fn_format(char * to, const char *name, const char *dir, /* To long path, return original or NULL */ size_t tmp_length; if (flag & MY_SAFE_PATH) - return NullS; + DBUG_RETURN(NullS); tmp_length= strlength(startpos); DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext, (uint) length)); diff --git a/mysys/mf_getdate.c b/mysys/mf_getdate.c index 3a8e1be6a0b..9475bebd107 100644 --- a/mysys/mf_getdate.c +++ b/mysys/mf_getdate.c @@ -45,15 +45,15 @@ void get_date(register char * to, int flag, time_t date) skr=date ? (time_t) date : my_time(0); #if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT) if (flag & GETDATE_GMT) - localtime_r(&skr,&tm_tmp); - else gmtime_r(&skr,&tm_tmp); + else + localtime_r(&skr,&tm_tmp); start_time= &tm_tmp; #else if (flag & GETDATE_GMT) - start_time= localtime(&skr); - else start_time= gmtime(&skr); + else + start_time= localtime(&skr); #endif if (flag & GETDATE_SHORT_DATE) sprintf(to,"%02d%02d%02d", diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 4b74cdbf266..fd3c2501226 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -20,6 +20,7 @@ #include <mysys_err.h> #include <my_getopt.h> #include <errno.h> +#include <m_string.h> typedef void (*init_func_p)(const struct my_option *option, uchar* *variable, longlong value); @@ -410,7 +411,8 @@ invalid value '%s'", argument= optend; } else if (optp->arg_type == OPT_ARG && - (optp->var_type & GET_TYPE_MASK) == GET_BOOL) + (((optp->var_type & GET_TYPE_MASK) == GET_BOOL) || + (optp->var_type & GET_TYPE_MASK) == GET_ENUM)) { if (optend == disabled_my_option) *((my_bool*) value)= (my_bool) 0; @@ -648,8 +650,18 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument, return EXIT_OUT_OF_MEMORY; break; case GET_ENUM: - if (((*(int*)result_pos)= find_type(argument, opts->typelib, 2) - 1) < 0) - return EXIT_ARGUMENT_INVALID; + if (((*(int*)result_pos)= + find_type(argument, opts->typelib, 2) - 1) < 0) + { + /* + Accept an integer representation of the enumerated item. + */ + char *endptr; + unsigned int arg= (unsigned int) strtol(argument, &endptr, 10); + if (*endptr || arg >= opts->typelib->count) + return EXIT_ARGUMENT_INVALID; + *(int*)result_pos= arg; + } break; case GET_SET: *((ulonglong*)result_pos)= find_typeset(argument, opts->typelib, &err); diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index ee7c36b097d..152225f86b1 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -116,10 +116,15 @@ case $PLATFORM in esac # Change the distribution to a long descriptive name +# For the cluster product, concentrate on the second part +VERSION_NAME=@VERSION@ +case $VERSION_NAME in + *-ndb-* ) VERSION_NAME=`echo $VERSION_NAME | sed -e 's/[.0-9]*-ndb-//'` ;; +esac if [ x"$SHORT_PRODUCT_TAG" != x"" ] ; then - NEW_NAME=mysql-$SHORT_PRODUCT_TAG-@VERSION@-$PLATFORM$SUFFIX + NEW_NAME=mysql-$SHORT_PRODUCT_TAG-$VERSION_NAME-$PLATFORM$SUFFIX else - NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-@VERSION@-$PLATFORM$SUFFIX + NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-$VERSION_NAME-$PLATFORM$SUFFIX fi # ---------------------------------------------------------------------- diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index 5eb5a5643f1..3360d8459f8 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -126,7 +126,7 @@ if [ -e $DESTDIR ] ; then usage fi -trap 'echo "Clearning up and exiting..." ; rm -fr $DESTDIR; exit 1' ERR +trap 'echo "Cleaning up and exiting..." ; rm -fr $DESTDIR; exit 1' ERR # ---------------------------------------------------------------------- # Adjust target name if needed, release with debug info has another name diff --git a/scripts/mysql_find_rows.sh b/scripts/mysql_find_rows.sh index 77eacc8a9b4..967a8196ebd 100644 --- a/scripts/mysql_find_rows.sh +++ b/scripts/mysql_find_rows.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000, 2004 MySQL AB # # This program is free software; you can redistribute it and/or modify diff --git a/scripts/mysql_fix_extensions.sh b/scripts/mysql_fix_extensions.sh index fbc72406f5e..6d4e017f678 100644 --- a/scripts/mysql_fix_extensions.sh +++ b/scripts/mysql_fix_extensions.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # This is a utility for MySQL. It is not needed by any standard part # of MySQL. diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh index b1ea26a9b7d..5fa6b969e39 100644 --- a/scripts/mysql_setpermission.sh +++ b/scripts/mysql_setpermission.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl ## Emacs, this is -*- perl -*- mode? :-) ## ## Permission setter for MySQL diff --git a/scripts/mysql_zap.sh b/scripts/mysql_zap.sh index 3bb92aaec2e..f78212e2578 100644 --- a/scripts/mysql_zap.sh +++ b/scripts/mysql_zap.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2002, 2004 MySQL AB # # This program is free software; you can redistribute it and/or modify diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index bcaf9f8af8e..0153a3afa7c 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # **************************** package MySQLaccess; #use strict; diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index f35be69c151..430c74874eb 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -1,7 +1,7 @@ #!/usr/bin/perl use Getopt::Long; -use POSIX qw(strftime); +use POSIX qw(strftime getcwd); $|=1; $VER="2.16"; @@ -295,6 +295,7 @@ sub start_mysqlds() { @options = defaults_for_group($groups[$i]); + $basedir_found= 0; # The default $mysqld_found= 1; # The default $mysqld_found= 0 if (!length($mysqld)); $com= "$mysqld"; @@ -310,6 +311,14 @@ sub start_mysqlds() $com= $options[$j]; $mysqld_found= 1; } + elsif ("--basedir=" eq substr($options[$j], 0, 10)) + { + $basedir= $options[$j]; + $basedir =~ s/^--basedir=//; + $basedir_found= 1; + $options[$j]= quote_shell_word($options[$j]); + $tmp.= " $options[$j]"; + } else { $options[$j]= quote_shell_word($options[$j]); @@ -337,7 +346,16 @@ sub start_mysqlds() print "group [$groups[$i]] separately.\n"; exit(1); } + if ($basedir_found) + { + $curdir=getcwd(); + chdir($basedir) or die "Can't change to datadir $basedir"; + } system($com); + if ($basedir_found) + { + chdir($curdir) or die "Can't change back to original dir $curdir"; + } } if (!$i && !$opt_no_log) { diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 34dc019a82a..23b5efcaf2b 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -67,7 +67,7 @@ my_which () ret=0 for file do - for dir in "$PATH" + for dir in $PATH do if [ -f "$dir/$file" ] then diff --git a/sql-bench/as3ap.sh b/sql-bench/as3ap.sh index d84219a37eb..1c672377fd3 100644 --- a/sql-bench/as3ap.sh +++ b/sql-bench/as3ap.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2001, 2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/bench-count-distinct.sh b/sql-bench/bench-count-distinct.sh index 31558aa0b2e..5cc9fb555af 100644 --- a/sql-bench/bench-count-distinct.sh +++ b/sql-bench/bench-count-distinct.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2001, 2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh index 588e518a648..919ddcedf16 100644 --- a/sql-bench/bench-init.pl.sh +++ b/sql-bench/bench-init.pl.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2003, 2005 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/compare-results.sh b/sql-bench/compare-results.sh index 145c4894ca2..fec65497c57 100644 --- a/sql-bench/compare-results.sh +++ b/sql-bench/compare-results.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2001, 2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/copy-db.sh b/sql-bench/copy-db.sh index f74fa68a081..e0c290d2453 100644 --- a/sql-bench/copy-db.sh +++ b/sql-bench/copy-db.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000, 2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/crash-me.sh b/sql-bench/crash-me.sh index b28bdba7f9f..cc8659513c2 100644 --- a/sql-bench/crash-me.sh +++ b/sql-bench/crash-me.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # -*- perl -*- # Copyright (C) 2000-2006 MySQL AB # diff --git a/sql-bench/innotest1.sh b/sql-bench/innotest1.sh index 8675de19ae4..1c5450a1d9e 100644 --- a/sql-bench/innotest1.sh +++ b/sql-bench/innotest1.sh @@ -1,4 +1,4 @@ -#!@PERL@
+#!/usr/bin/perl
############################################################################
# Stress test for MySQL/InnoDB combined database
# (c) 2002 Innobase Oy & MySQL AB
diff --git a/sql-bench/innotest1a.sh b/sql-bench/innotest1a.sh index 93f8a2a443b..876100e5de4 100644 --- a/sql-bench/innotest1a.sh +++ b/sql-bench/innotest1a.sh @@ -1,4 +1,4 @@ -#!@PERL@
+#!/usr/bin/perl
############################################################################
# Stress test for MySQL/InnoDB combined database
# (c) 2002 Innobase Oy & MySQL AB
diff --git a/sql-bench/innotest1b.sh b/sql-bench/innotest1b.sh index 48fe96ebe7d..3f6c9f5bd5f 100644 --- a/sql-bench/innotest1b.sh +++ b/sql-bench/innotest1b.sh @@ -1,4 +1,4 @@ -#!@PERL@
+#!/usr/bin/perl
############################################################################
# Stress test for MySQL/InnoDB combined database
# (c) 2002 Innobase Oy & MySQL AB
diff --git a/sql-bench/innotest2.sh b/sql-bench/innotest2.sh index aea44003903..cfeb0527970 100644 --- a/sql-bench/innotest2.sh +++ b/sql-bench/innotest2.sh @@ -1,4 +1,4 @@ -#!@PERL@
+#!/usr/bin/perl
############################################################################
# Stress test for MySQL/InnoDB combined database
# (c) 2002 Innobase Oy & MySQL AB
diff --git a/sql-bench/innotest2a.sh b/sql-bench/innotest2a.sh index 3d4bb9933da..f77ed3ddadd 100644 --- a/sql-bench/innotest2a.sh +++ b/sql-bench/innotest2a.sh @@ -1,4 +1,4 @@ -#!@PERL@
+#!/usr/bin/perl
############################################################################
# Stress test for MySQL/Innobase combined database
# (c) 2000 Innobase Oy & MySQL AB
diff --git a/sql-bench/innotest2b.sh b/sql-bench/innotest2b.sh index 272b6dcffd0..72a71d06c73 100644 --- a/sql-bench/innotest2b.sh +++ b/sql-bench/innotest2b.sh @@ -1,4 +1,4 @@ -#!@PERL@
+#!/usr/bin/perl
############################################################################
# Stress test for MySQL/Innobase combined database
# (c) 2000 Innobase Oy & MySQL AB
diff --git a/sql-bench/run-all-tests.sh b/sql-bench/run-all-tests.sh index 50ac8d0cbe3..a4b03428d94 100644 --- a/sql-bench/run-all-tests.sh +++ b/sql-bench/run-all-tests.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2001, 2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/server-cfg.sh b/sql-bench/server-cfg.sh index a7492f67d1a..5ed7fdf482c 100644 --- a/sql-bench/server-cfg.sh +++ b/sql-bench/server-cfg.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # -*- perl -*- # Copyright (C) 2000-2006 MySQL AB # diff --git a/sql-bench/test-ATIS.sh b/sql-bench/test-ATIS.sh index 6d102fd3977..79b38a95506 100644 --- a/sql-bench/test-ATIS.sh +++ b/sql-bench/test-ATIS.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2001, 2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/test-alter-table.sh b/sql-bench/test-alter-table.sh index eb06582dc0b..36db26f4bf3 100644 --- a/sql-bench/test-alter-table.sh +++ b/sql-bench/test-alter-table.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2001, 2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/test-big-tables.sh b/sql-bench/test-big-tables.sh index 0226967bc54..33694a42e17 100644 --- a/sql-bench/test-big-tables.sh +++ b/sql-bench/test-big-tables.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2001, 2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/test-connect.sh b/sql-bench/test-connect.sh index 84175c357aa..d0f3f0791a4 100644 --- a/sql-bench/test-connect.sh +++ b/sql-bench/test-connect.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2001, 2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/test-create.sh b/sql-bench/test-create.sh index 63672519e61..40fd9c49ae8 100644 --- a/sql-bench/test-create.sh +++ b/sql-bench/test-create.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/test-insert.sh b/sql-bench/test-insert.sh index badc52c99d6..387cb48e494 100644 --- a/sql-bench/test-insert.sh +++ b/sql-bench/test-insert.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/test-select.sh b/sql-bench/test-select.sh index 809755ab4d7..41e8205196e 100644 --- a/sql-bench/test-select.sh +++ b/sql-bench/test-select.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2001, 2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/test-transactions.sh b/sql-bench/test-transactions.sh index 5723c856564..edbfef0e3ce 100644 --- a/sql-bench/test-transactions.sh +++ b/sql-bench/test-transactions.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2001, 2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-bench/test-wisconsin.sh b/sql-bench/test-wisconsin.sh index 38ab93e7f4a..1974461a7c4 100644 --- a/sql-bench/test-wisconsin.sh +++ b/sql-bench/test-wisconsin.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2001, 2003 MySQL AB # # This library is free software; you can redistribute it and/or diff --git a/sql-common/client.c b/sql-common/client.c index d2c7e02551d..2cbc15ad746 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -120,6 +120,7 @@ const char *def_shared_memory_base_name= default_shared_memory_base_name; static void mysql_close_free_options(MYSQL *mysql); static void mysql_close_free(MYSQL *mysql); +static void mysql_prune_stmt_list(MYSQL *mysql); #if !(defined(__WIN__) || defined(__NETWARE__)) static int wait_for_data(my_socket fd, uint timeout); @@ -476,6 +477,9 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) DWORD error_code = 0; DWORD event_access_rights= SYNCHRONIZE | EVENT_MODIFY_STATE; char *shared_memory_base_name = mysql->options.shared_memory_base_name; + static const char *name_prefixes[] = {"","Global\\"}; + const char *prefix; + int i; /* get enough space base-name + '_' + longest suffix we might ever send @@ -490,9 +494,18 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) shared_memory_base_name is unique value for each server unique_part is uniquel value for each object (events and file-mapping) */ - suffix_pos = strxmov(tmp, "Global\\", shared_memory_base_name, "_", NullS); - strmov(suffix_pos, "CONNECT_REQUEST"); - if (!(event_connect_request= OpenEvent(event_access_rights, FALSE, tmp))) + for (i = 0; i< array_elements(name_prefixes); i++) + { + prefix= name_prefixes[i]; + suffix_pos = strxmov(tmp, prefix , shared_memory_base_name, "_", NullS); + strmov(suffix_pos, "CONNECT_REQUEST"); + event_connect_request= OpenEvent(event_access_rights, FALSE, tmp); + if (event_connect_request) + { + break; + } + } + if (!event_connect_request) { error_allow = CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR; goto err; @@ -544,7 +557,7 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) unique_part is uniquel value for each object (events and file-mapping) number_of_connection is number of connection between server and client */ - suffix_pos = strxmov(tmp, "Global\\", shared_memory_base_name, "_", connect_number_char, + suffix_pos = strxmov(tmp, prefix , shared_memory_base_name, "_", connect_number_char, "_", NullS); strmov(suffix_pos, "DATA"); if ((handle_file_map = OpenFileMapping(FILE_MAP_WRITE,FALSE,tmp)) == NULL) @@ -924,6 +937,7 @@ void end_server(MYSQL *mysql) vio_delete(mysql->net.vio); reset_sigpipe(mysql); mysql->net.vio= 0; /* Marker */ + mysql_prune_stmt_list(mysql); } net_end(&mysql->net); free_old_query(mysql); @@ -2526,30 +2540,9 @@ my_bool mysql_reconnect(MYSQL *mysql) tmp_mysql.reconnect= 1; tmp_mysql.free_me= mysql->free_me; - /* - For each stmt in mysql->stmts, move it to tmp_mysql if it is - in state MYSQL_STMT_INIT_DONE, otherwise close it. - */ - { - LIST *element= mysql->stmts; - for (; element; element= element->next) - { - MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; - if (stmt->state != MYSQL_STMT_INIT_DONE) - { - stmt->mysql= 0; - stmt->last_errno= CR_SERVER_LOST; - strmov(stmt->last_error, ER(CR_SERVER_LOST)); - strmov(stmt->sqlstate, unknown_sqlstate); - } - else - { - tmp_mysql.stmts= list_add(tmp_mysql.stmts, &stmt->list); - } - /* No need to call list_delete for statement here */ - } - mysql->stmts= NULL; - } + /* Move prepared statements (if any) over to the new mysql object */ + tmp_mysql.stmts= mysql->stmts; + mysql->stmts= 0; /* Don't free options as these are now used in tmp_mysql */ bzero((char*) &mysql->options,sizeof(mysql->options)); @@ -2639,6 +2632,46 @@ static void mysql_close_free(MYSQL *mysql) } +/** + For use when the connection to the server has been lost (in which case + the server has discarded all information about prepared statements + associated with the connection). + + Mark all statements in mysql->stmts by setting stmt->mysql= 0 if the + statement has transitioned beyond the MYSQL_STMT_INIT_DONE state, and + unlink the statement from the mysql->stmts list. + + The remaining pruned list of statements (if any) is kept in mysql->stmts. + + @param mysql pointer to the MYSQL object + + @return none +*/ +static void mysql_prune_stmt_list(MYSQL *mysql) +{ + LIST *element= mysql->stmts; + LIST *pruned_list= 0; + + for (; element; element= element->next) + { + MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; + if (stmt->state != MYSQL_STMT_INIT_DONE) + { + stmt->mysql= 0; + stmt->last_errno= CR_SERVER_LOST; + strmov(stmt->last_error, ER(CR_SERVER_LOST)); + strmov(stmt->sqlstate, unknown_sqlstate); + } + else + { + pruned_list= list_add(pruned_list, element); + } + } + + mysql->stmts= pruned_list; +} + + /* Clear connection pointer of every statement: this is necessary to give error on attempt to use a prepared statement of closed diff --git a/sql/field.cc b/sql/field.cc index d11b509075b..ed085de1db3 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1165,7 +1165,7 @@ bool Field_num::get_int(CHARSET_INFO *cs, const char *from, uint len, if (unsigned_flag) { - if (((ulonglong) *rnd > unsigned_max) && (*rnd= (longlong) unsigned_max) || + if ((((ulonglong) *rnd > unsigned_max) && (*rnd= (longlong) unsigned_max)) || error == MY_ERRNO_ERANGE) { goto out_of_range; @@ -1350,7 +1350,7 @@ void Field::copy_from_tmp(int row_offset) if (null_ptr) { *null_ptr= (uchar) ((null_ptr[0] & (uchar) ~(uint) null_bit) | - null_ptr[row_offset] & (uchar) null_bit); + (null_ptr[row_offset] & (uchar) null_bit)); } } @@ -4081,8 +4081,8 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs) int error; char *end; double nr= my_strntod(cs,(char*) from,len,&end,&error); - if (error || (!len || (uint) (end-from) != len && - table->in_use->count_cuted_fields)) + if (error || (!len || ((uint) (end-from) != len && + table->in_use->count_cuted_fields))) { set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, (error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1); @@ -4343,8 +4343,8 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs) int error; char *end; double nr= my_strntod(cs,(char*) from, len, &end, &error); - if (error || (!len || (uint) (end-from) != len && - table->in_use->count_cuted_fields)) + if (error || (!len || ((uint) (end-from) != len && + table->in_use->count_cuted_fields))) { set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, (error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1); @@ -5196,7 +5196,7 @@ int Field_time::store(longlong nr, bool unsigned_val) MYSQL_TIMESTAMP_TIME, 1); error= 1; } - else if (nr > (longlong) TIME_MAX_VALUE || nr < 0 && unsigned_val) + else if (nr > (longlong) TIME_MAX_VALUE || (nr < 0 && unsigned_val)) { tmp= TIME_MAX_VALUE; set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, @@ -5307,7 +5307,7 @@ bool Field_time::get_time(MYSQL_TIME *ltime) ltime->neg= 1; tmp=-tmp; } - ltime->day= 0; + ltime->year= ltime->month= ltime->day= 0; ltime->hour= (int) (tmp/10000); tmp-=ltime->hour*10000; ltime->minute= (int) tmp/100; @@ -5361,7 +5361,7 @@ int Field_year::store(const char *from, uint len,CHARSET_INFO *cs) int error; longlong nr= cs->cset->strntoull10rnd(cs, from, len, 0, &end, &error); - if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155 || + if (nr < 0 || (nr >= 100 && nr <= 1900) || nr > 2155 || error == MY_ERRNO_ERANGE) { *ptr=0; @@ -5405,7 +5405,7 @@ int Field_year::store(double nr) int Field_year::store(longlong nr, bool unsigned_val) { ASSERT_COLUMN_MARKED_FOR_WRITE; - if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155) + if (nr < 0 || (nr >= 100 && nr <= 1900) || nr > 2155) { *ptr= 0; set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); @@ -6429,16 +6429,16 @@ int Field_str::store(double nr) /* Calculate the exponent from the 'e'-format conversion */ if (anr < 1.0 && anr > 0) { - for (exp= 0; anr < 1e-100; exp-= 100, anr*= 1e100); - for (; anr < 1e-10; exp-= 10, anr*= 1e10); - for (i= 1; anr < 1 / log_10[i]; exp--, i++); + for (exp= 0; anr < 1e-100; exp-= 100, anr*= 1e100) ; + for (; anr < 1e-10; exp-= 10, anr*= 1e10) ; + for (i= 1; anr < 1 / log_10[i]; exp--, i++) ; exp--; } else { - for (exp= 0; anr > 1e100; exp+= 100, anr/= 1e100); - for (; anr > 1e10; exp+= 10, anr/= 1e10); - for (i= 1; anr > log_10[i]; exp++, i++); + for (exp= 0; anr > 1e100; exp+= 100, anr/= 1e100) ; + for (; anr > 1e10; exp+= 10, anr/= 1e10) ; + for (i= 1; anr > log_10[i]; exp++, i++) ; } max_length= local_char_length - neg; @@ -8833,7 +8833,7 @@ bool Field_num::eq_def(Field *field) Field_num *from_num= (Field_num*) field; if (unsigned_flag != from_num->unsigned_flag || - zerofill && !from_num->zerofill && !zero_pack() || + (zerofill && !from_num->zerofill && !zero_pack()) || dec != from_num->dec) return 0; return 1; @@ -8974,7 +8974,7 @@ int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs) ASSERT_COLUMN_MARKED_FOR_WRITE; int delta; - for (; length && !*from; from++, length--); // skip left 0's + for (; length && !*from; from++, length--) ; // skip left 0's delta= bytes_in_rec - length; if (delta < -1 || @@ -9306,7 +9306,7 @@ Field_bit::unpack(uchar *to, const uchar *from, uint param_data, and slave have the same sizes, then use the old unpack() method. */ if (param_data == 0 || - (from_bit_len == bit_len) && (from_len == bytes_in_rec)) + ((from_bit_len == bit_len) && (from_len == bytes_in_rec))) { if (bit_len > 0) { @@ -9385,7 +9385,7 @@ int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs) int delta; uchar bits= (uchar) (field_length & 7); - for (; length && !*from; from++, length--); // skip left 0's + for (; length && !*from; from++, length--) ; // skip left 0's delta= bytes_in_rec - length; if (delta < 0 || diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 11d0bb9cc82..3574534722e 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -99,7 +99,7 @@ static void do_field_to_null_str(Copy_field *copy) static void do_outer_field_to_null_str(Copy_field *copy) { if (*copy->null_row || - copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit)) + (copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit))) { bzero(copy->to_ptr,copy->from_length); copy->to_null_ptr[0]=1; // Always bit 1 @@ -212,7 +212,7 @@ static void do_copy_null(Copy_field *copy) static void do_outer_field_null(Copy_field *copy) { if (*copy->null_row || - copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit)) + (copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit))) { *copy->to_null_ptr|=copy->to_bit; copy->to_field->reset(); @@ -665,9 +665,9 @@ Copy_field::get_copy_func(Field *to,Field *from) */ if (to->real_type() != from->real_type() || !compatible_db_low_byte_first || - ((to->table->in_use->variables.sql_mode & + (((to->table->in_use->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) && - to->type() == MYSQL_TYPE_DATE || + to->type() == MYSQL_TYPE_DATE) || to->type() == MYSQL_TYPE_DATETIME)) { if (from->real_type() == MYSQL_TYPE_ENUM || @@ -770,8 +770,8 @@ int field_conv(Field *to,Field *from) to->table->s->db_low_byte_first == from->table->s->db_low_byte_first && (!(to->table->in_use->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) || - to->type() != MYSQL_TYPE_DATE && - to->type() != MYSQL_TYPE_DATETIME) && + (to->type() != MYSQL_TYPE_DATE && + to->type() != MYSQL_TYPE_DATETIME)) && (from->real_type() != MYSQL_TYPE_VARCHAR || ((Field_varstring*)from)->length_bytes == ((Field_varstring*)to)->length_bytes)) diff --git a/sql/gstream.cc b/sql/gstream.cc index 0c8011549f3..e2bb41b8541 100644 --- a/sql/gstream.cc +++ b/sql/gstream.cc @@ -75,7 +75,7 @@ bool Gis_read_stream::get_next_number(double *d) skip_space(); if ((m_cur >= m_limit) || - (*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+') + ((*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+')) { set_error_msg("Numeric constant expected"); return 1; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 3454f3558e8..ddb90427fdc 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1247,7 +1247,7 @@ int ha_ndbcluster::add_index_handle(THD *thd, NDBDICT *dict, KEY *key_info, } if (idx_type == UNIQUE_ORDERED_INDEX || idx_type == UNIQUE_INDEX) { - char unique_index_name[FN_LEN]; + char unique_index_name[FN_LEN + 1]; static const char* unique_suffix= "$unique"; m_has_unique_index= TRUE; strxnmov(unique_index_name, FN_LEN, index_name, unique_suffix, NullS); @@ -5150,7 +5150,7 @@ int ha_ndbcluster::create(const char *name, uchar *data= NULL, *pack_data= NULL; bool create_from_engine= (create_info->table_options & HA_OPTION_CREATE_FROM_ENGINE); bool is_truncate= (thd->lex->sql_command == SQLCOM_TRUNCATE); - char tablespace[FN_LEN]; + char tablespace[FN_LEN + 1]; NdbDictionary::Table::SingleUserMode single_user_mode= NdbDictionary::Table::SingleUserModeLocked; DBUG_ENTER("ha_ndbcluster::create"); @@ -5613,7 +5613,7 @@ int ha_ndbcluster::create_index(const char *name, KEY *key_info, NDB_INDEX_TYPE idx_type, uint idx_no) { int error= 0; - char unique_name[FN_LEN]; + char unique_name[FN_LEN + 1]; static const char* unique_suffix= "$unique"; DBUG_ENTER("ha_ndbcluster::create_ordered_index"); DBUG_PRINT("info", ("Creating index %u: %s", idx_no, name)); @@ -6661,7 +6661,7 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db, size_t len; uchar* data= NULL; Ndb* ndb; - char key[FN_REFLEN]; + char key[FN_REFLEN + 1]; DBUG_ENTER("ndbcluster_discover"); DBUG_PRINT("enter", ("db: %s, name: %s", db, name)); @@ -6672,7 +6672,7 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db, ERR_RETURN(ndb->getNdbError()); } NDBDICT* dict= ndb->getDictionary(); - build_table_filename(key, sizeof(key), db, name, "", 0); + build_table_filename(key, sizeof(key) - 1, db, name, "", 0); /* ndb_share reference temporary */ NDB_SHARE *share= get_share(key, 0, FALSE); if (share) @@ -6837,9 +6837,9 @@ int ndbcluster_drop_database_impl(const char *path) drop_list.push_back(thd->strdup(elmt.name)); } // Drop any tables belonging to database - char full_path[FN_REFLEN]; + char full_path[FN_REFLEN + 1]; char *tmp= full_path + - build_table_filename(full_path, sizeof(full_path), dbname, "", "", 0); + build_table_filename(full_path, sizeof(full_path) - 1, dbname, "", "", 0); if (ndb->setDatabaseName(dbname)) { ERR_RETURN(ndb->getNdbError()); @@ -6908,7 +6908,7 @@ int ndb_create_table_from_engine(THD *thd, const char *db, int ndbcluster_find_all_files(THD *thd) { Ndb* ndb; - char key[FN_REFLEN]; + char key[FN_REFLEN + 1]; NDBDICT *dict; int unhandled, retries= 5, skipped; DBUG_ENTER("ndbcluster_find_all_files"); @@ -6966,7 +6966,7 @@ int ndbcluster_find_all_files(THD *thd) /* check if database exists */ char *end= key + - build_table_filename(key, sizeof(key), elmt.database, "", "", 0); + build_table_filename(key, sizeof(key) - 1, elmt.database, "", "", 0); if (my_access(key, F_OK)) { /* no such database defined, skip table */ @@ -7047,7 +7047,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, { // extra bracket to avoid gcc 2.95.3 warning uint i; Ndb* ndb; - char name[FN_REFLEN]; + char name[FN_REFLEN + 1]; HASH ndb_tables, ok_tables; NDBDICT::List list; @@ -7117,7 +7117,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, DBUG_PRINT("info", ("%s", file_name->str)); if (hash_search(&ndb_tables, (uchar*) file_name->str, file_name->length)) { - build_table_filename(name, sizeof(name), db, file_name->str, reg_ext, 0); + build_table_filename(name, sizeof(name) - 1, db, + file_name->str, reg_ext, 0); if (my_access(name, F_OK)) { pthread_mutex_lock(&LOCK_open); @@ -7139,7 +7140,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, } // Check for .ndb file with this name - build_table_filename(name, sizeof(name), db, file_name->str, ha_ndb_ext, 0); + build_table_filename(name, sizeof(name) - 1, db, + file_name->str, ha_ndb_ext, 0); DBUG_PRINT("info", ("Check access for %s", name)); if (my_access(name, F_OK)) { @@ -7182,7 +7184,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, /* setup logging to binlog for all discovered tables */ { char *end, *end1= name + - build_table_filename(name, sizeof(name), db, "", "", 0); + build_table_filename(name, sizeof(name) - 1, db, "", "", 0); for (i= 0; i < ok_tables.records; i++) { file_name_str= (char*)hash_element(&ok_tables, i); @@ -7204,7 +7206,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, file_name_str= (char*) hash_element(&ndb_tables, i); if (!hash_search(&ok_tables, (uchar*) file_name_str, strlen(file_name_str))) { - build_table_filename(name, sizeof(name), db, file_name_str, reg_ext, 0); + build_table_filename(name, sizeof(name) - 1, + db, file_name_str, reg_ext, 0); if (my_access(name, F_OK)) { DBUG_PRINT("info", ("%s must be discovered", file_name_str)); @@ -7584,7 +7587,7 @@ void ndbcluster_print_error(int error, const NdbOperation *error_op) void ha_ndbcluster::set_dbname(const char *path_name, char *dbname) { char *end, *ptr, *tmp_name; - char tmp_buff[FN_REFLEN]; + char tmp_buff[FN_REFLEN + 1]; tmp_name= tmp_buff; /* Scan name from the end */ @@ -7610,7 +7613,7 @@ void ha_ndbcluster::set_dbname(const char *path_name, char *dbname) ptr++; } #endif - filename_to_tablename(tmp_name, dbname, FN_REFLEN); + filename_to_tablename(tmp_name, dbname, sizeof(tmp_buff) - 1); } /** @@ -7630,7 +7633,7 @@ void ha_ndbcluster::set_tabname(const char *path_name, char * tabname) { char *end, *ptr, *tmp_name; - char tmp_buff[FN_REFLEN]; + char tmp_buff[FN_REFLEN + 1]; tmp_name= tmp_buff; /* Scan name from the end */ @@ -7651,7 +7654,7 @@ ha_ndbcluster::set_tabname(const char *path_name, char * tabname) ptr++; } #endif - filename_to_tablename(tmp_name, tabname, FN_REFLEN); + filename_to_tablename(tmp_name, tabname, sizeof(tmp_buff) - 1); } /** @@ -7837,11 +7840,12 @@ uint8 ha_ndbcluster::table_cache_type() uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname, Uint64 *commit_count) { - char name[FN_REFLEN]; + char name[FN_REFLEN + 1]; NDB_SHARE *share; DBUG_ENTER("ndb_get_commitcount"); - build_table_filename(name, sizeof(name), dbname, tabname, "", 0); + build_table_filename(name, sizeof(name) - 1, + dbname, tabname, "", 0); DBUG_PRINT("enter", ("name: %s", name)); pthread_mutex_lock(&ndbcluster_mutex); if (!(share=(NDB_SHARE*) hash_search(&ndbcluster_open_tables, @@ -9945,7 +9949,7 @@ bool ha_ndbcluster::check_if_incompatible_data(HA_CREATE_INFO *create_info, ai=1; } - char tablespace_name[FN_LEN]; + char tablespace_name[FN_LEN + 1]; if (get_tablespace_name(current_thd, tablespace_name, FN_LEN)) { if (create_info->tablespace) diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index baf86d739eb..f705af8bf47 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -788,7 +788,7 @@ static int ndbcluster_create_ndb_apply_status_table(THD *thd) if (g_ndb_cluster_connection->get_no_ready() <= 0) DBUG_RETURN(0); - char buf[1024], *end; + char buf[1024 + 1], *end; if (ndb_extra_logging) sql_print_information("NDB: Creating " NDB_REP_DB "." NDB_APPLY_TABLE); @@ -798,7 +798,7 @@ static int ndbcluster_create_ndb_apply_status_table(THD *thd) if so, remove it since there is none in Ndb */ { - build_table_filename(buf, sizeof(buf), + build_table_filename(buf, sizeof(buf) - 1, NDB_REP_DB, NDB_APPLY_TABLE, reg_ext, 0); my_delete(buf, MYF(0)); } @@ -846,7 +846,7 @@ static int ndbcluster_create_schema_table(THD *thd) if (g_ndb_cluster_connection->get_no_ready() <= 0) DBUG_RETURN(0); - char buf[1024], *end; + char buf[1024 + 1], *end; if (ndb_extra_logging) sql_print_information("NDB: Creating " NDB_REP_DB "." NDB_SCHEMA_TABLE); @@ -856,7 +856,7 @@ static int ndbcluster_create_schema_table(THD *thd) if so, remove it since there is none in Ndb */ { - build_table_filename(buf, sizeof(buf), + build_table_filename(buf, sizeof(buf) - 1, NDB_REP_DB, NDB_SCHEMA_TABLE, reg_ext, 0); my_delete(buf, MYF(0)); } @@ -1321,8 +1321,8 @@ int ndbcluster_log_schema_op(THD *thd, NDB_SHARE *share, NDB_SCHEMA_OBJECT *ndb_schema_object; { - char key[FN_REFLEN]; - build_table_filename(key, sizeof(key), db, table_name, "", 0); + char key[FN_REFLEN + 1]; + build_table_filename(key, sizeof(key) - 1, db, table_name, "", 0); ndb_schema_object= ndb_get_schema_object(key, TRUE, FALSE); } @@ -1674,7 +1674,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, if (is_remote_change && is_online_alter_table) { const char *tabname= table_share->table_name.str; - char key[FN_REFLEN]; + char key[FN_REFLEN + 1]; uchar *data= 0, *pack_data= 0; size_t length, pack_length; int error; @@ -1683,7 +1683,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, DBUG_PRINT("info", ("Detected frm change of table %s.%s", dbname, tabname)); - build_table_filename(key, FN_LEN-1, dbname, tabname, NullS, 0); + build_table_filename(key, FN_LEN - 1, dbname, tabname, NullS, 0); /* If the there is no local table shadowing the altered table and it has an frm that is different than the one on disk then @@ -1855,9 +1855,11 @@ static void ndb_binlog_query(THD *thd, Cluster_schema *schema) else thd->server_id= schema->any_value; thd->db= schema->db; + int errcode = query_error_code(thd, thd->killed == THD::NOT_KILLED); thd->binlog_query(THD::STMT_QUERY_TYPE, schema->query, schema->query_length, FALSE, - schema->name[0] == 0 || thd->db[0] == 0); + schema->name[0] == 0 || thd->db[0] == 0, + errcode); thd->server_id= thd_server_id_save; thd->db= thd_db_save; } @@ -1924,8 +1926,8 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, break; case SOT_TRUNCATE_TABLE: { - char key[FN_REFLEN]; - build_table_filename(key, sizeof(key), + char key[FN_REFLEN + 1]; + build_table_filename(key, sizeof(key) - 1, schema->db, schema->name, "", 0); /* ndb_share reference temporary, free below */ NDB_SHARE *share= get_share(key, 0, FALSE, FALSE); @@ -2171,8 +2173,8 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd, int log_query= 0; { enum SCHEMA_OP_TYPE schema_type= (enum SCHEMA_OP_TYPE)schema->type; - char key[FN_REFLEN]; - build_table_filename(key, sizeof(key), schema->db, schema->name, "", 0); + char key[FN_REFLEN + 1]; + build_table_filename(key, sizeof(key) - 1, schema->db, schema->name, "", 0); if (schema_type == SOT_CLEAR_SLOCK) { pthread_mutex_lock(&ndbcluster_mutex); @@ -2506,8 +2508,8 @@ ndb_rep_event_name(String *event_name,const char *db, const char *tbl) bool ndbcluster_check_if_local_table(const char *dbname, const char *tabname) { - char key[FN_REFLEN]; - char ndb_file[FN_REFLEN]; + char key[FN_REFLEN + 1]; + char ndb_file[FN_REFLEN + 1]; DBUG_ENTER("ndbcluster_check_if_local_table"); build_table_filename(key, FN_LEN-1, dbname, tabname, reg_ext, 0); @@ -2532,9 +2534,9 @@ ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname) DBUG_PRINT("info", ("Looking for files in directory %s", dbname)); LEX_STRING *tabname; List<LEX_STRING> files; - char path[FN_REFLEN]; + char path[FN_REFLEN + 1]; - build_table_filename(path, sizeof(path), dbname, "", "", 0); + build_table_filename(path, sizeof(path) - 1, dbname, "", "", 0); if (find_files(thd, &files, dbname, path, NullS, 0) != FIND_FILES_OK) { DBUG_PRINT("info", ("Failed to find files")); diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 67bc3156260..74742f58028 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3179,6 +3179,7 @@ int ha_partition::delete_row(const uchar *buf) int ha_partition::delete_all_rows() { int error; + bool truncate= FALSE; handler **file; THD *thd= ha_thd(); DBUG_ENTER("ha_partition::delete_all_rows"); @@ -3190,12 +3191,16 @@ int ha_partition::delete_all_rows() ha_data->next_auto_inc_val= 0; ha_data->auto_inc_initialized= FALSE; unlock_auto_increment(); + truncate= TRUE; } file= m_file; do { if ((error= (*file)->ha_delete_all_rows())) DBUG_RETURN(error); + /* Ignore the error */ + if (truncate) + (void) (*file)->ha_reset_auto_increment(0); } while (*(++file)); DBUG_RETURN(0); } diff --git a/sql/handler.cc b/sql/handler.cc index d22ee220dc1..e65ceba4181 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1073,6 +1073,13 @@ int ha_commit_trans(THD *thd, bool all) user, or an implicit commit issued by a DDL. */ THD_TRANS *trans= all ? &thd->transaction.all : &thd->transaction.stmt; + /* + "real" is a nick name for a transaction for which a commit will + make persistent changes. E.g. a 'stmt' transaction inside a 'all' + transation is not 'real': even though it's possible to commit it, + the changes are not durable as they might be rolled back if the + enclosing 'all' transaction is rolled back. + */ bool is_real_trans= all || thd->transaction.all.ha_list == 0; Ha_trx_info *ha_info= trans->ha_list; my_xid xid= thd->transaction.xid_state.xid.get_my_xid(); @@ -1184,16 +1191,9 @@ end: if (rw_trans) start_waiting_global_read_lock(thd); } - else if (all) - { - /* - A COMMIT of an empty transaction. There may be savepoints. - Destroy them. If the transaction is not empty - savepoints are cleared in ha_commit_one_phase() - or ha_rollback_trans(). - */ + /* Free resources and perform other cleanup even for 'empty' transactions. */ + else if (is_real_trans) thd->transaction.cleanup(); - } #endif /* USING_TRANSACTIONS */ DBUG_RETURN(error); } @@ -1206,6 +1206,13 @@ int ha_commit_one_phase(THD *thd, bool all) { int error=0; THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt; + /* + "real" is a nick name for a transaction for which a commit will + make persistent changes. E.g. a 'stmt' transaction inside a 'all' + transation is not 'real': even though it's possible to commit it, + the changes are not durable as they might be rolled back if the + enclosing 'all' transaction is rolled back. + */ bool is_real_trans=all || thd->transaction.all.ha_list == 0; Ha_trx_info *ha_info= trans->ha_list, *ha_info_next; DBUG_ENTER("ha_commit_one_phase"); @@ -1227,8 +1234,6 @@ int ha_commit_one_phase(THD *thd, bool all) } trans->ha_list= 0; trans->no_2pc=0; - if (is_real_trans) - thd->transaction.xid_state.xid.null(); if (all) { #ifdef HAVE_QUERY_CACHE @@ -1236,9 +1241,11 @@ int ha_commit_one_phase(THD *thd, bool all) query_cache.invalidate(thd->transaction.changed_tables); #endif thd->variables.tx_isolation=thd->session_tx_isolation; - thd->transaction.cleanup(); } } + /* Free resources and perform other cleanup even for 'empty' transactions. */ + if (is_real_trans) + thd->transaction.cleanup(); #endif /* USING_TRANSACTIONS */ DBUG_RETURN(error); } @@ -1249,6 +1256,13 @@ int ha_rollback_trans(THD *thd, bool all) int error=0; THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt; Ha_trx_info *ha_info= trans->ha_list, *ha_info_next; + /* + "real" is a nick name for a transaction for which a commit will + make persistent changes. E.g. a 'stmt' transaction inside a 'all' + transation is not 'real': even though it's possible to commit it, + the changes are not durable as they might be rolled back if the + enclosing 'all' transaction is rolled back. + */ bool is_real_trans=all || thd->transaction.all.ha_list == 0; DBUG_ENTER("ha_rollback_trans"); @@ -1294,18 +1308,13 @@ int ha_rollback_trans(THD *thd, bool all) } trans->ha_list= 0; trans->no_2pc=0; - if (is_real_trans) - { - if (thd->transaction_rollback_request) - thd->transaction.xid_state.rm_error= thd->main_da.sql_errno(); - else - thd->transaction.xid_state.xid.null(); - } + if (is_real_trans && thd->transaction_rollback_request) + thd->transaction.xid_state.rm_error= thd->main_da.sql_errno(); if (all) thd->variables.tx_isolation=thd->session_tx_isolation; } /* Always cleanup. Even if there nht==0. There may be savepoints. */ - if (all) + if (is_real_trans) thd->transaction.cleanup(); #endif /* USING_TRANSACTIONS */ if (all) @@ -2283,8 +2292,8 @@ int handler::update_auto_increment() DBUG_ASSERT(next_insert_id >= auto_inc_interval_for_cur_row.minimum()); if ((nr= table->next_number_field->val_int()) != 0 || - table->auto_increment_field_not_null && - thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO) + (table->auto_increment_field_not_null && + thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO)) { /* Update next_insert_id if we had already generated a value in this @@ -3574,7 +3583,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name) int error; uchar *frmblob; size_t frmlen; - char path[FN_REFLEN]; + char path[FN_REFLEN + 1]; HA_CREATE_INFO create_info; TABLE table; TABLE_SHARE share; @@ -3593,7 +3602,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name) frmblob and frmlen are set, write the frm to disk */ - build_table_filename(path, FN_REFLEN-1, db, name, "", 0); + build_table_filename(path, sizeof(path) - 1, db, name, "", 0); // Save the frm file error= writefrm(path, frmblob, frmlen); my_free(frmblob, MYF(0)); @@ -4770,7 +4779,7 @@ fl_log_iterator_buffer_init(struct handler_iterator *iterator) if ((ptr= (uchar*)my_malloc(ALIGN_SIZE(sizeof(fl_buff)) + ((ALIGN_SIZE(sizeof(LEX_STRING)) + sizeof(enum log_status) + - + FN_REFLEN) * + + FN_REFLEN + 1) * (uint) dirp->number_off_files), MYF(0))) == 0) { @@ -4798,7 +4807,7 @@ fl_log_iterator_buffer_init(struct handler_iterator *iterator) name_ptr= strxnmov(buff->names[buff->entries].str= name_ptr, FN_REFLEN, fl_dir, file->name, NullS); buff->names[buff->entries].length= (name_ptr - - buff->names[buff->entries].str) - 1; + buff->names[buff->entries].str); buff->statuses[buff->entries]= st; buff->entries++; } diff --git a/sql/item.cc b/sql/item.cc index 4d9dc50226f..4d9004fff26 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -417,6 +417,7 @@ Item::Item(THD *thd, Item *item): name(item->name), orig_name(item->orig_name), max_length(item->max_length), + name_length(item->name_length), marker(item->marker), decimals(item->decimals), maybe_null(item->maybe_null), @@ -424,7 +425,9 @@ Item::Item(THD *thd, Item *item): unsigned_flag(item->unsigned_flag), with_sum_func(item->with_sum_func), fixed(item->fixed), + is_autogenerated_name(item->is_autogenerated_name), collation(item->collation), + with_subselect(item->with_subselect), cmp_context(item->cmp_context) { next= thd->free_list; // Put in free list @@ -1504,10 +1507,6 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) { set(dt); } - else - { - // Do nothing - } } else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) && left_is_superset(this, &dt)) @@ -2261,8 +2260,10 @@ Item_decimal::Item_decimal(const char *str_arg, uint length, name= (char*) str_arg; decimals= (uint8) decimal_value.frac; fixed= 1; - max_length= my_decimal_precision_to_length(decimal_value.intg + decimals, - decimals, unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg + + decimals, + decimals, + unsigned_flag); } Item_decimal::Item_decimal(longlong val, bool unsig) @@ -2270,8 +2271,10 @@ Item_decimal::Item_decimal(longlong val, bool unsig) int2my_decimal(E_DEC_FATAL_ERROR, val, unsig, &decimal_value); decimals= (uint8) decimal_value.frac; fixed= 1; - max_length= my_decimal_precision_to_length(decimal_value.intg + decimals, - decimals, unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg + + decimals, + decimals, + unsigned_flag); } @@ -2280,8 +2283,10 @@ Item_decimal::Item_decimal(double val, int precision, int scale) double2my_decimal(E_DEC_FATAL_ERROR, val, &decimal_value); decimals= (uint8) decimal_value.frac; fixed= 1; - max_length= my_decimal_precision_to_length(decimal_value.intg + decimals, - decimals, unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg + + decimals, + decimals, + unsigned_flag); } @@ -2301,8 +2306,10 @@ Item_decimal::Item_decimal(my_decimal *value_par) my_decimal2decimal(value_par, &decimal_value); decimals= (uint8) decimal_value.frac; fixed= 1; - max_length= my_decimal_precision_to_length(decimal_value.intg + decimals, - decimals, unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg + + decimals, + decimals, + unsigned_flag); } @@ -2312,8 +2319,8 @@ Item_decimal::Item_decimal(const uchar *bin, int precision, int scale) &decimal_value, precision, scale); decimals= (uint8) decimal_value.frac; fixed= 1; - max_length= my_decimal_precision_to_length(precision, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, decimals, + unsigned_flag); } @@ -2368,8 +2375,10 @@ void Item_decimal::set_decimal_value(my_decimal *value_par) my_decimal2decimal(value_par, &decimal_value); decimals= (uint8) decimal_value.frac; unsigned_flag= !decimal_value.sign(); - max_length= my_decimal_precision_to_length(decimal_value.intg + decimals, - decimals, unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg + + decimals, + decimals, + unsigned_flag); } @@ -2472,8 +2481,9 @@ longlong_from_string_with_check (CHARSET_INFO *cs, const char *cptr, char *end) TODO: Give error if we wanted a signed integer and we got an unsigned one */ - if (err > 0 || - (end != org_end && !check_if_only_end_space(cs, end, org_end))) + if (!current_thd->no_errors && + (err > 0 || + (end != org_end && !check_if_only_end_space(cs, end, org_end)))) { push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE, @@ -2640,8 +2650,9 @@ void Item_param::set_decimal(const char *str, ulong length) str2my_decimal(E_DEC_FATAL_ERROR, str, &decimal_value, &end); state= DECIMAL_VALUE; decimals= decimal_value.frac; - max_length= my_decimal_precision_to_length(decimal_value.precision(), - decimals, unsigned_flag); + max_length= + my_decimal_precision_to_length_no_truncation(decimal_value.precision(), + decimals, unsigned_flag); maybe_null= 0; DBUG_VOID_RETURN; } @@ -2771,8 +2782,8 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry) CHARSET_INFO *tocs= thd->variables.collation_connection; uint32 dummy_offset; - value.cs_info.character_set_of_placeholder= - value.cs_info.character_set_client= fromcs; + value.cs_info.character_set_of_placeholder= fromcs; + value.cs_info.character_set_client= thd->variables.character_set_client; /* Setup source and destination character sets so that they are different only if conversion is necessary: this will @@ -2797,8 +2808,9 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry) my_decimal2decimal(ent_value, &decimal_value); state= DECIMAL_VALUE; decimals= ent_value->frac; - max_length= my_decimal_precision_to_length(ent_value->precision(), - decimals, unsigned_flag); + max_length= + my_decimal_precision_to_length_no_truncation(ent_value->precision(), + decimals, unsigned_flag); item_type= Item::DECIMAL_ITEM; break; } @@ -3268,9 +3280,57 @@ Item_param::set_param_type_and_swap_value(Item_param *src) } /**************************************************************************** + Item_copy +****************************************************************************/ +Item_copy *Item_copy::create (Item *item) +{ + switch (item->result_type()) + { + case STRING_RESULT: + return new Item_copy_string (item); + case REAL_RESULT: + return new Item_copy_float (item); + case INT_RESULT: + return item->unsigned_flag ? + new Item_copy_uint (item) : new Item_copy_int (item); + case DECIMAL_RESULT: + return new Item_copy_decimal (item); + + case ROW_RESULT: + DBUG_ASSERT (0); + } + /* should not happen */ + return NULL; +} + +/**************************************************************************** Item_copy_string ****************************************************************************/ +double Item_copy_string::val_real() +{ + int err_not_used; + char *end_not_used; + return (null_value ? 0.0 : + my_strntod(str_value.charset(), (char*) str_value.ptr(), + str_value.length(), &end_not_used, &err_not_used)); +} + +longlong Item_copy_string::val_int() +{ + int err; + return null_value ? LL(0) : my_strntoll(str_value.charset(),str_value.ptr(), + str_value.length(),10, (char**) 0, + &err); +} + + +int Item_copy_string::save_in_field(Field *field, bool no_conversions) +{ + return save_str_value_in_field(field, &str_value); +} + + void Item_copy_string::copy() { String *res=item->val_str(&str_value); @@ -3293,12 +3353,163 @@ my_decimal *Item_copy_string::val_decimal(my_decimal *decimal_value) { // Item_copy_string is used without fix_fields call if (null_value) - return 0; + return (my_decimal *) 0; string2my_decimal(E_DEC_FATAL_ERROR, &str_value, decimal_value); return (decimal_value); } +/**************************************************************************** + Item_copy_int +****************************************************************************/ + +void Item_copy_int::copy() +{ + cached_value= item->val_int(); + null_value=item->null_value; +} + +static int save_int_value_in_field (Field *field, longlong nr, + bool null_value, bool unsigned_flag); + +int Item_copy_int::save_in_field(Field *field, bool no_conversions) +{ + return save_int_value_in_field(field, cached_value, + null_value, unsigned_flag); +} + + +String *Item_copy_int::val_str(String *str) +{ + if (null_value) + return (String *) 0; + + str->set(cached_value, &my_charset_bin); + return str; +} + + +my_decimal *Item_copy_int::val_decimal(my_decimal *decimal_value) +{ + if (null_value) + return (my_decimal *) 0; + + int2my_decimal(E_DEC_FATAL_ERROR, cached_value, unsigned_flag, decimal_value); + return decimal_value; +} + + +/**************************************************************************** + Item_copy_uint +****************************************************************************/ + +String *Item_copy_uint::val_str(String *str) +{ + if (null_value) + return (String *) 0; + + str->set((ulonglong) cached_value, &my_charset_bin); + return str; +} + + +/**************************************************************************** + Item_copy_float +****************************************************************************/ + +String *Item_copy_float::val_str(String *str) +{ + if (null_value) + return (String *) 0; + else + { + double nr= val_real(); + str->set_real(nr,decimals, &my_charset_bin); + return str; + } +} + + +my_decimal *Item_copy_float::val_decimal(my_decimal *decimal_value) +{ + if (null_value) + return (my_decimal *) 0; + else + { + double nr= val_real(); + double2my_decimal(E_DEC_FATAL_ERROR, nr, decimal_value); + return decimal_value; + } +} + + +int Item_copy_float::save_in_field(Field *field, bool no_conversions) +{ + if (null_value) + return set_field_to_null(field); + field->set_notnull(); + return field->store(cached_value); +} + + +/**************************************************************************** + Item_copy_decimal +****************************************************************************/ + +int Item_copy_decimal::save_in_field(Field *field, bool no_conversions) +{ + if (null_value) + return set_field_to_null(field); + field->set_notnull(); + return field->store_decimal(&cached_value); +} + + +String *Item_copy_decimal::val_str(String *result) +{ + if (null_value) + return (String *) 0; + result->set_charset(&my_charset_bin); + my_decimal2string(E_DEC_FATAL_ERROR, &cached_value, 0, 0, 0, result); + return result; +} + + +double Item_copy_decimal::val_real() +{ + if (null_value) + return 0.0; + else + { + double result; + my_decimal2double(E_DEC_FATAL_ERROR, &cached_value, &result); + return result; + } +} + + +longlong Item_copy_decimal::val_int() +{ + if (null_value) + return LL(0); + else + { + longlong result; + my_decimal2int(E_DEC_FATAL_ERROR, &cached_value, unsigned_flag, &result); + return result; + } +} + + +void Item_copy_decimal::copy() +{ + my_decimal *nr= item->val_decimal(&cached_value); + if (nr && nr != &cached_value) + memcpy (&cached_value, nr, sizeof (my_decimal)); + null_value= item->null_value; +} + + /* Functions to convert item to field (for send_fields) */ @@ -4207,16 +4418,22 @@ mark_non_agg_field: Fields from outer selects added to the aggregate function outer_fields list as its unknown at the moment whether it's aggregated or not. + We're using either the select lex of the cached table (if present) + or the field's resolution context. context->select_lex is + safe for use because it's either the SELECT we want to use + (the current level) or a stub added by non-SELECT queries. */ + SELECT_LEX *select_lex= cached_table ? + cached_table->select_lex : context->select_lex; if (!thd->lex->in_sum_func) - cached_table->select_lex->full_group_by_flag|= NON_AGG_FIELD_USED; + select_lex->full_group_by_flag|= NON_AGG_FIELD_USED; else { if (outer_fixed) thd->lex->in_sum_func->outer_fields.push_back(this); else if (thd->lex->in_sum_func->nest_level != thd->lex->current_select->nest_level) - cached_table->select_lex->full_group_by_flag|= NON_AGG_FIELD_USED; + select_lex->full_group_by_flag|= NON_AGG_FIELD_USED; } } return FALSE; @@ -4873,7 +5090,10 @@ int Item_null::save_safe_in_field(Field *field) /* This implementation can lose str_value content, so if the Item uses str_value to store something, it should - reimplement it's ::save_in_field() as Item_string, for example, does + reimplement it's ::save_in_field() as Item_string, for example, does. + + Note: all Item_XXX::val_str(str) methods must NOT rely on the fact that + str != str_value. For example, see fix for bug #44743. */ int Item::save_in_field(Field *field, bool no_conversions) @@ -4943,10 +5163,9 @@ int Item_uint::save_in_field(Field *field, bool no_conversions) return Item_int::save_in_field(field, no_conversions); } - -int Item_int::save_in_field(Field *field, bool no_conversions) +static int save_int_value_in_field (Field *field, longlong nr, + bool null_value, bool unsigned_flag) { - longlong nr=val_int(); if (null_value) return set_field_to_null(field); field->set_notnull(); @@ -4954,6 +5173,12 @@ int Item_int::save_in_field(Field *field, bool no_conversions) } +int Item_int::save_in_field(Field *field, bool no_conversions) +{ + return save_int_value_in_field (field, val_int(), null_value, unsigned_flag); +} + + int Item_decimal::save_in_field(Field *field, bool no_conversions) { field->set_notnull(); @@ -5810,7 +6035,8 @@ void Item_ref::print(String *str, enum_query_type query_type) !table_name && name && alias_name_used) { THD *thd= current_thd; - append_identifier(thd, str, name, (uint) strlen(name)); + append_identifier(thd, str, (*ref)->real_item()->name, + (*ref)->real_item()->name_length); } else (*ref)->print(str, query_type); @@ -7082,8 +7308,9 @@ bool Item_type_holder::join_types(THD *thd, Item *item) int item_prec = max(prev_decimal_int_part, item_int_part) + decimals; int precision= min(item_prec, DECIMAL_MAX_PRECISION); unsigned_flag&= item->unsigned_flag; - max_length= my_decimal_precision_to_length(precision, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, + decimals, + unsigned_flag); } switch (Field::result_merge_type(fld_type)) diff --git a/sql/item.h b/sql/item.h index 96a4e9f7a31..3dfcd7c2612 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2443,48 +2443,203 @@ public: #include "item_xmlfunc.h" #endif -class Item_copy_string :public Item +/** + Base class to implement typed value caching Item classes + + Item_copy_ classes are very similar to the corresponding Item_ + classes (e.g. Item_copy_int is similar to Item_int) but they add + the following additional functionality to Item_ : + 1. Nullability + 2. Possibility to store the value not only on instantiation time, + but also later. + Item_copy_ classes are a functionality subset of Item_cache_ + classes, as e.g. they don't support comparisons with the original Item + as Item_cache_ classes do. + Item_copy_ classes are used in GROUP BY calculation. + TODO: Item_copy should be made an abstract interface and Item_copy_ + classes should inherit both the respective Item_ class and the interface. + Ideally we should drop Item_copy_ classes altogether and merge + their functionality to Item_cache_ (and these should be made to inherit + from Item_). +*/ + +class Item_copy :public Item { +protected: + + /** + Stores the type of the resulting field that would be used to store the data + in the cache. This is to avoid calls to the original item. + */ enum enum_field_types cached_field_type; -public: + + /** The original item that is copied */ Item *item; - Item_copy_string(Item *i) :item(i) + + /** + Stores the result type of the original item, so it can be returned + without calling the original item's method + */ + Item_result cached_result_type; + + /** + Constructor of the Item_copy class + + stores metadata information about the original class as well as a + pointer to it. + */ + Item_copy(Item *i) { + item= i; null_value=maybe_null=item->maybe_null; decimals=item->decimals; max_length=item->max_length; name=item->name; cached_field_type= item->field_type(); + cached_result_type= item->result_type(); + unsigned_flag= item->unsigned_flag; } + +public: + /** + Factory method to create the appropriate subclass dependent on the type of + the original item. + + @param item the original item. + */ + static Item_copy *create (Item *item); + + /** + Update the cache with the value of the original item + + This is the method that updates the cached value. + It must be explicitly called by the user of this class to store the value + of the orginal item in the cache. + */ + virtual void copy() = 0; + + Item *get_item() { return item; } + /** All of the subclasses should have the same type tag */ enum Type type() const { return COPY_STR_ITEM; } - enum Item_result result_type () const { return STRING_RESULT; } enum_field_types field_type() const { return cached_field_type; } - double val_real() + enum Item_result result_type () const { return cached_result_type; } + + void make_field(Send_field *field) { item->make_field(field); } + table_map used_tables() const { return (table_map) 1L; } + bool const_item() const { return 0; } + bool is_null() { return null_value; } + + /* + Override the methods below as pure virtual to make sure all the + sub-classes implement them. + */ + + virtual String *val_str(String*) = 0; + virtual my_decimal *val_decimal(my_decimal *) = 0; + virtual double val_real() = 0; + virtual longlong val_int() = 0; + virtual int save_in_field(Field *field, bool no_conversions) = 0; +}; + +/** + Implementation of a string cache. + + Uses Item::str_value for storage +*/ +class Item_copy_string : public Item_copy +{ +public: + Item_copy_string (Item *item) : Item_copy(item) {} + + String *val_str(String*); + my_decimal *val_decimal(my_decimal *); + double val_real(); + longlong val_int(); + void copy(); + int save_in_field(Field *field, bool no_conversions); +}; + + +class Item_copy_int : public Item_copy +{ +protected: + longlong cached_value; +public: + Item_copy_int (Item *i) : Item_copy(i) {} + int save_in_field(Field *field, bool no_conversions); + + virtual String *val_str(String*); + virtual my_decimal *val_decimal(my_decimal *); + virtual double val_real() { - int err_not_used; - char *end_not_used; - return (null_value ? 0.0 : - my_strntod(str_value.charset(), (char*) str_value.ptr(), - str_value.length(), &end_not_used, &err_not_used)); + return null_value ? 0.0 : (double) cached_value; } - longlong val_int() + virtual longlong val_int() + { + return null_value ? LL(0) : cached_value; + } + virtual void copy(); +}; + + +class Item_copy_uint : public Item_copy_int +{ +public: + Item_copy_uint (Item *item) : Item_copy_int(item) + { + unsigned_flag= 1; + } + + String *val_str(String*); + double val_real() { - int err; - return null_value ? LL(0) : my_strntoll(str_value.charset(),str_value.ptr(), - str_value.length(),10, (char**) 0, - &err); + return null_value ? 0.0 : (double) (ulonglong) cached_value; } +}; + + +class Item_copy_float : public Item_copy +{ +protected: + double cached_value; +public: + Item_copy_float (Item *i) : Item_copy(i) {} + int save_in_field(Field *field, bool no_conversions); + String *val_str(String*); my_decimal *val_decimal(my_decimal *); - void make_field(Send_field *field) { item->make_field(field); } - void copy(); - int save_in_field(Field *field, bool no_conversions) + double val_real() { - return save_str_value_in_field(field, &str_value); + return null_value ? 0.0 : cached_value; } - table_map used_tables() const { return (table_map) 1L; } - bool const_item() const { return 0; } - bool is_null() { return null_value; } + longlong val_int() + { + return (longlong) rint(val_real()); + } + void copy() + { + cached_value= item->val_real(); + null_value= item->null_value; + } +}; + + +class Item_copy_decimal : public Item_copy +{ +protected: + my_decimal cached_value; +public: + Item_copy_decimal (Item *i) : Item_copy(i) {} + int save_in_field(Field *field, bool no_conversions); + + String *val_str(String*); + my_decimal *val_decimal(my_decimal *) + { + return null_value ? NULL: &cached_value; + } + double val_real(); + longlong val_int(); + void copy(); }; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index a9bfea1b806..1ff9ca6a419 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1484,8 +1484,8 @@ longlong Item_func_truth::val_int() bool Item_in_optimizer::fix_left(THD *thd, Item **ref) { - if (!args[0]->fixed && args[0]->fix_fields(thd, args) || - !cache && !(cache= Item_cache::get_cache(args[0]))) + if ((!args[0]->fixed && args[0]->fix_fields(thd, args)) || + (!cache && !(cache= Item_cache::get_cache(args[0])))) return 1; cache->setup(args[0]); @@ -2724,16 +2724,6 @@ void Item_func_case::fix_length_and_dec() nagg++; if (!(found_types= collect_cmp_types(agg, nagg))) return; - if (with_sum_func || current_thd->lex->current_select->group_list.elements) - { - /* - See TODO commentary in the setup_copy_fields function: - item in a group may be wrapped with an Item_copy_string item. - That item has a STRING_RESULT result type, so we need - to take this type into account. - */ - found_types |= (1 << item_cmp_type(left_result_type, STRING_RESULT)); - } for (i= 0; i <= (uint)DECIMAL_RESULT; i++) { @@ -2770,8 +2760,9 @@ void Item_func_case::fix_length_and_dec() agg_num_lengths(args[i + 1]); if (else_expr_num != -1) agg_num_lengths(args[else_expr_num]); - max_length= my_decimal_precision_to_length(max_length + decimals, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(max_length + + decimals, decimals, + unsigned_flag); } } @@ -3006,8 +2997,8 @@ int cmp_longlong(void *cmp_arg, One of the args is unsigned and is too big to fit into the positive signed range. Report no match. */ - if (a->unsigned_flag && ((ulonglong) a->val) > (ulonglong) LONGLONG_MAX || - b->unsigned_flag && ((ulonglong) b->val) > (ulonglong) LONGLONG_MAX) + if ((a->unsigned_flag && ((ulonglong) a->val) > (ulonglong) LONGLONG_MAX) || + (b->unsigned_flag && ((ulonglong) b->val) > (ulonglong) LONGLONG_MAX)) return a->unsigned_flag ? 1 : -1; /* Although the signedness differs both args can fit into the signed diff --git a/sql/item_func.cc b/sql/item_func.cc index 876aee719a3..0af3c4954cd 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -452,11 +452,45 @@ Field *Item_func::tmp_table_field(TABLE *table) return make_string_field(table); break; case DECIMAL_RESULT: - field= new Field_new_decimal(my_decimal_precision_to_length(decimal_precision(), - decimals, - unsigned_flag), - maybe_null, name, decimals, unsigned_flag); + { + uint8 dec= decimals; + uint8 intg= decimal_precision() - dec; + uint32 len= max_length; + + /* + Trying to put too many digits overall in a DECIMAL(prec,dec) + will always throw a warning. We must limit dec to + DECIMAL_MAX_SCALE however to prevent an assert() later. + */ + + if (dec > 0) + { + int overflow; + + dec= min(dec, DECIMAL_MAX_SCALE); + + /* + If the value still overflows the field with the corrected dec, + we'll throw out decimals rather than integers. This is still + bad and of course throws a truncation warning. + */ + + const int required_length= + my_decimal_precision_to_length(intg + dec, dec, + unsigned_flag); + + overflow= required_length - len; + + if (overflow > 0) + dec= max(0, dec - overflow); // too long, discard fract + else + /* Corrected value fits. */ + len= required_length; + } + + field= new Field_new_decimal(len, maybe_null, name, dec, unsigned_flag); break; + } case ROW_RESULT: default: // This case should never be chosen @@ -545,8 +579,8 @@ void Item_func::count_decimal_length() set_if_smaller(unsigned_flag, args[i]->unsigned_flag); } int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION); - max_length= my_decimal_precision_to_length(precision, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, decimals, + unsigned_flag); } @@ -1141,16 +1175,15 @@ void Item_func_additive_op::result_precision() decimals= max(args[0]->decimals, args[1]->decimals); int arg1_int= args[0]->decimal_precision() - args[0]->decimals; int arg2_int= args[1]->decimal_precision() - args[1]->decimals; - int est_prec= max(arg1_int, arg2_int) + 1 + decimals; - int precision= min(est_prec, DECIMAL_MAX_PRECISION); + int precision= max(arg1_int, arg2_int) + 1 + decimals; /* Integer operations keep unsigned_flag if one of arguments is unsigned */ if (result_type() == INT_RESULT) unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag; else unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag; - max_length= my_decimal_precision_to_length(precision, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, decimals, + unsigned_flag); } @@ -1255,7 +1288,8 @@ void Item_func_mul::result_precision() decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE); uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision(); uint precision= min(est_prec, DECIMAL_MAX_PRECISION); - max_length= my_decimal_precision_to_length(precision, decimals,unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, decimals, + unsigned_flag); } @@ -1311,8 +1345,8 @@ void Item_func_div::result_precision() else unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag; decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE); - max_length= my_decimal_precision_to_length(precision, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, decimals, + unsigned_flag); } @@ -1944,8 +1978,8 @@ void Item_func_round::fix_length_and_dec() unsigned_flag= args[0]->unsigned_flag; if (!args[1]->const_item()) { - max_length= args[0]->max_length; decimals= args[0]->decimals; + max_length= float_length(decimals); if (args[0]->result_type() == DECIMAL_RESULT) { max_length++; @@ -1965,8 +1999,8 @@ void Item_func_round::fix_length_and_dec() if (args[0]->decimals == NOT_FIXED_DEC) { - max_length= args[0]->max_length; decimals= min(decimals_to_set, NOT_FIXED_DEC); + max_length= float_length(decimals); hybrid_type= REAL_RESULT; return; } @@ -1999,8 +2033,9 @@ void Item_func_round::fix_length_and_dec() precision-= decimals_delta - length_increase; decimals= min(decimals_to_set, DECIMAL_MAX_SCALE); - max_length= my_decimal_precision_to_length(precision, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, + decimals, + unsigned_flag); break; } default: @@ -2143,9 +2178,6 @@ bool Item_func_rand::fix_fields(THD *thd,Item **ref) if (!rand && !(rand= (struct rand_struct*) thd->stmt_arena->alloc(sizeof(*rand)))) return TRUE; - - if (args[0]->const_item()) - seed_random (args[0]); } else { @@ -2175,8 +2207,21 @@ void Item_func_rand::update_used_tables() double Item_func_rand::val_real() { DBUG_ASSERT(fixed == 1); - if (arg_count && !args[0]->const_item()) - seed_random (args[0]); + if (arg_count) + { + if (!args[0]->const_item()) + seed_random(args[0]); + else if (first_eval) + { + /* + Constantness of args[0] may be set during JOIN::optimize(), if arg[0] + is a field item of "constant" table. Thus, we have to evaluate + seed_random() for constant arg there but not at the fix_fields method. + */ + first_eval= FALSE; + seed_random(args[0]); + } + } return my_rnd(rand); } @@ -2233,8 +2278,9 @@ void Item_func_min_max::fix_length_and_dec() } } else if ((cmp_type == DECIMAL_RESULT) || (cmp_type == INT_RESULT)) - max_length= my_decimal_precision_to_length(max_int_part+decimals, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(max_int_part + + decimals, decimals, + unsigned_flag); cached_field_type= agg_field_type(args, arg_count); } @@ -4178,6 +4224,41 @@ Item_func_set_user_var::check(bool use_result_field) /** + @brief Evaluate and store item's result. + This function is invoked on "SELECT ... INTO @var ...". + + @param item An item to get value from. +*/ + +void Item_func_set_user_var::save_item_result(Item *item) +{ + DBUG_ENTER("Item_func_set_user_var::save_item_result"); + + switch (cached_result_type) { + case REAL_RESULT: + save_result.vreal= item->val_result(); + break; + case INT_RESULT: + save_result.vint= item->val_int_result(); + unsigned_flag= item->unsigned_flag; + break; + case STRING_RESULT: + save_result.vstr= item->str_result(&value); + break; + case DECIMAL_RESULT: + save_result.vdec= item->val_decimal_result(&decimal_buff); + break; + case ROW_RESULT: + default: + // Should never happen + DBUG_ASSERT(0); + break; + } + DBUG_VOID_RETURN; +} + + +/** This functions is invoked on SET \@variable or \@variable:= expression. @@ -4418,8 +4499,8 @@ int Item_func_set_user_var::save_in_field(Field *field, bool no_conversions, update(); if (result_type() == STRING_RESULT || - result_type() == REAL_RESULT && - field->result_type() == STRING_RESULT) + (result_type() == REAL_RESULT && + field->result_type() == STRING_RESULT)) { String *result; CHARSET_INFO *cs= collation.collation; @@ -4835,10 +4916,20 @@ bool Item_func_get_system_var::is_written_to_binlog() } +void Item_func_get_system_var::update_null_value() +{ + THD *thd= current_thd; + int save_no_errors= thd->no_errors; + thd->no_errors= TRUE; + Item::update_null_value(); + thd->no_errors= save_no_errors; +} + + void Item_func_get_system_var::fix_length_and_dec() { char *cptr; - maybe_null=0; + maybe_null= TRUE; max_length= 0; if (var->check_type(var_type)) @@ -5747,6 +5838,14 @@ Item_func_sp::func_name() const } +int my_missing_function_error(const LEX_STRING &token, const char *func_name) +{ + if (token.length && is_lex_native_function (&token)) + return my_error(ER_FUNC_INEXISTENT_NAME_COLLISION, MYF(0), func_name); + else + return my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", func_name); +} + /** @brief Initialize the result field by creating a temporary dummy table @@ -5779,7 +5878,7 @@ Item_func_sp::init_result_field(THD *thd) if (!(m_sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, m_name, &thd->sp_func_cache, TRUE))) { - my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", m_name->m_qname.str); + my_missing_function_error (m_name->m_name, m_name->m_qname.str); context->process_error(thd); DBUG_RETURN(TRUE); } diff --git a/sql/item_func.h b/sql/item_func.h index d23d821baf6..514f93a39ea 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -378,7 +378,8 @@ public: Item_decimal_typecast(Item *a, int len, int dec) :Item_func(a) { decimals= dec; - max_length= my_decimal_precision_to_length(len, dec, unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(len, dec, + unsigned_flag); } String *val_str(String *str); double val_real(); @@ -696,14 +697,16 @@ public: class Item_func_rand :public Item_real_func { struct rand_struct *rand; + bool first_eval; // TRUE if val_real() is called 1st time public: - Item_func_rand(Item *a) :Item_real_func(a), rand(0) {} + Item_func_rand(Item *a) :Item_real_func(a), rand(0), first_eval(TRUE) {} Item_func_rand() :Item_real_func() {} double val_real(); const char *func_name() const { return "rand"; } bool const_item() const { return 0; } void update_used_tables(); bool fix_fields(THD *thd, Item **ref); + void cleanup() { first_eval= TRUE; Item_real_func::cleanup(); } private: void seed_random (Item * val); }; @@ -1341,6 +1344,7 @@ public: bool send(Protocol *protocol, String *str_arg); void make_field(Send_field *tmp_field); bool check(bool use_result_field); + void save_item_result(Item *item); bool update(); enum Item_result result_type () const { return cached_result_type; } bool fix_fields(THD *thd, Item **ref); @@ -1452,6 +1456,7 @@ public: LEX_STRING *component_arg, const char *name_arg, size_t name_len_arg); enum Functype functype() const { return GSYSVAR_FUNC; } + void update_null_value(); void fix_length_and_dec(); void print(String *str, enum_query_type query_type); bool const_item() const { return true; } diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 24a92c78e9c..a34204b7181 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -416,7 +416,10 @@ String *Item_func_spatial_collection::val_str(String *str) else { enum Geometry::wkbType wkb_type; - const char *data= res->ptr() + 4/*SRID*/ + 1; + const uint data_offset= 4/*SRID*/ + 1; + if (res->length() < data_offset + sizeof(uint32)) + goto err; + const char *data= res->ptr() + data_offset; /* In the case of named collection we must check that items @@ -439,7 +442,7 @@ String *Item_func_spatial_collection::val_str(String *str) break; case Geometry::wkb_linestring: - if (str->append(data, POINT_DATA_SIZE, 512)) + if (len < POINT_DATA_SIZE || str->append(data, POINT_DATA_SIZE, 512)) goto err; break; case Geometry::wkb_polygon: @@ -448,11 +451,15 @@ String *Item_func_spatial_collection::val_str(String *str) double x1, y1, x2, y2; const char *org_data= data; - if (len < 4 + 2 * POINT_DATA_SIZE) + if (len < 4) goto err; n_points= uint4korr(data); data+= 4; + + if (n_points < 2 || len < 4 + n_points * POINT_DATA_SIZE) + goto err; + float8get(x1, data); data+= SIZEOF_STORED_DOUBLE; float8get(y1, data); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 267036e4a3d..be94f19f597 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1629,16 +1629,17 @@ String *Item_func_password::val_str(String *str) return 0; if (res->length() == 0) return &my_empty_string; - make_scrambled_password(tmp_value, res->c_ptr()); + my_make_scrambled_password(tmp_value, res->ptr(), res->length()); str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH, res->charset()); return str; } -char *Item_func_password::alloc(THD *thd, const char *password) +char *Item_func_password::alloc(THD *thd, const char *password, + size_t pass_len) { char *buff= (char *) thd->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH+1); if (buff) - make_scrambled_password(buff, password); + my_make_scrambled_password(buff, password, pass_len); return buff; } @@ -1652,16 +1653,17 @@ String *Item_func_old_password::val_str(String *str) return 0; if (res->length() == 0) return &my_empty_string; - make_scrambled_password_323(tmp_value, res->c_ptr()); + my_make_scrambled_password_323(tmp_value, res->ptr(), res->length()); str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH_323, res->charset()); return str; } -char *Item_func_old_password::alloc(THD *thd, const char *password) +char *Item_func_old_password::alloc(THD *thd, const char *password, + size_t pass_len) { char *buff= (char *) thd->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1); if (buff) - make_scrambled_password_323(buff, password); + my_make_scrambled_password_323(buff, password, pass_len); return buff; } @@ -2706,7 +2708,13 @@ String *Item_func_conv_charset::val_str(String *str) DBUG_ASSERT(fixed == 1); if (use_cached_value) return null_value ? 0 : &str_value; - String *arg= args[0]->val_str(str); + /* + Here we don't pass 'str' as a parameter to args[0]->val_str() + as 'str' may point to 'str_value' (e.g. see Item::save_in_field()), + which we use below to convert string. + Use argument's 'str_value' instead. + */ + String *arg= args[0]->val_str(&args[0]->str_value); uint dummy_errors; if (!arg) { @@ -2943,7 +2951,7 @@ String *Item_load_file::val_str(String *str) ) goto err; - (void) fn_format(path, file_name->c_ptr(), mysql_real_data_home, "", + (void) fn_format(path, file_name->c_ptr_safe(), mysql_real_data_home, "", MY_RELATIVE_PATH | MY_UNPACK_FILENAME); /* Read only allowed from within dir specified by secure_file_priv */ @@ -2969,7 +2977,7 @@ String *Item_load_file::val_str(String *str) } if (tmp_value.alloc(stat_info.st_size)) goto err; - if ((file = my_open(file_name->c_ptr(), O_RDONLY, MYF(0))) < 0) + if ((file = my_open(file_name->ptr(), O_RDONLY, MYF(0))) < 0) goto err; if (my_read(file, (uchar*) tmp_value.ptr(), stat_info.st_size, MYF(MY_NABP))) { @@ -3219,7 +3227,21 @@ longlong Item_func_uncompressed_length::val_int() if (res->is_empty()) return 0; /* - res->ptr() using is safe because we have tested that string is not empty, + If length is <= 4 bytes, data is corrupt. This is the best we can do + to detect garbage input without decompressing it. + */ + if (res->length() <= 4) + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_ZLIB_Z_DATA_ERROR, + ER(ER_ZLIB_Z_DATA_ERROR)); + null_value= 1; + return 0; + } + + /* + res->ptr() using is safe because we have tested that string is at least + 5 bytes long. res->c_ptr() is not used because: - we do not need \0 terminated string to get first 4 bytes - c_ptr() tests simbol after string end (uninitialiozed memory) which diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 5265f608344..2cdb45100ae 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -268,7 +268,7 @@ public: String *val_str(String *str); void fix_length_and_dec() { max_length= SCRAMBLED_PASSWORD_CHAR_LENGTH; } const char *func_name() const { return "password"; } - static char *alloc(THD *thd, const char *password); + static char *alloc(THD *thd, const char *password, size_t pass_len); }; @@ -287,7 +287,7 @@ public: String *val_str(String *str); void fix_length_and_dec() { max_length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; } const char *func_name() const { return "old_password"; } - static char *alloc(THD *thd, const char *password); + static char *alloc(THD *thd, const char *password, size_t pass_len); }; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 3981b91a27c..00c09679737 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1314,8 +1314,8 @@ Item_in_subselect::row_value_transformer(JOIN *join) Item *item_having_part2= 0; for (uint i= 0; i < cols_num; i++) { - DBUG_ASSERT(left_expr->fixed && - select_lex->ref_pointer_array[i]->fixed || + DBUG_ASSERT((left_expr->fixed && + select_lex->ref_pointer_array[i]->fixed) || (select_lex->ref_pointer_array[i]->type() == REF_ITEM && ((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() == Item_ref::OUTER_REF)); @@ -1392,8 +1392,8 @@ Item_in_subselect::row_value_transformer(JOIN *join) for (uint i= 0; i < cols_num; i++) { Item *item, *item_isnull; - DBUG_ASSERT(left_expr->fixed && - select_lex->ref_pointer_array[i]->fixed || + DBUG_ASSERT((left_expr->fixed && + select_lex->ref_pointer_array[i]->fixed) || (select_lex->ref_pointer_array[i]->type() == REF_ITEM && ((Item_ref*)(select_lex->ref_pointer_array[i]))->ref_type() == Item_ref::OUTER_REF)); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index a6d8bb8a52d..38251294053 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -798,8 +798,9 @@ void Item_sum_sum::fix_length_and_dec() { /* SUM result can't be longer than length(arg) + length(MAX_ROWS) */ int precision= args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS; - max_length= my_decimal_precision_to_length(precision, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, + decimals, + unsigned_flag); curr_dec_buff= 0; hybrid_type= DECIMAL_RESULT; my_decimal_set_zero(dec_buffs); @@ -1233,8 +1234,9 @@ void Item_sum_avg::fix_length_and_dec() { int precision= args[0]->decimal_precision() + prec_increment; decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE); - max_length= my_decimal_precision_to_length(precision, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, + decimals, + unsigned_flag); f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION); f_scale= args[0]->decimals; dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale); @@ -1439,8 +1441,9 @@ void Item_sum_variance::fix_length_and_dec() { int precision= args[0]->decimal_precision()*2 + prec_increment; decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE); - max_length= my_decimal_precision_to_length(precision, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, + decimals, + unsigned_flag); break; } @@ -2640,8 +2643,8 @@ bool Item_sum_count_distinct::setup(THD *thd) enum enum_field_types f_type= f->type(); tree_key_length+= f->pack_length(); if ((f_type == MYSQL_TYPE_VARCHAR) || - !f->binary() && (f_type == MYSQL_TYPE_STRING || - f_type == MYSQL_TYPE_VAR_STRING)) + (!f->binary() && (f_type == MYSQL_TYPE_STRING || + f_type == MYSQL_TYPE_VAR_STRING))) { all_binary= FALSE; break; @@ -3324,8 +3327,13 @@ bool Item_func_group_concat::add() TREE_ELEMENT *el= 0; // Only for safety if (row_eligible && tree) + { el= tree_insert(tree, table->record[0] + table->s->null_bytes, 0, tree->custom_arg); + /* check if there was enough memory to insert the row */ + if (!el) + return 1; + } /* If the row is not a duplicate (el->count == 1) we can dump the row here in case of GROUP_CONCAT(DISTINCT...) diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 8caff22eab9..d79b0b02998 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -446,7 +446,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, strict_week_number= (*ptr=='V' || *ptr=='v'); tmp= (char*) val + min(val_len, 2); if ((week_number= (int) my_strtoll10(val, &tmp, &error)) < 0 || - strict_week_number && !week_number || + (strict_week_number && !week_number) || week_number > 53) goto err; val= tmp; @@ -542,10 +542,10 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, %V,%v require %X,%x resprectively, %U,%u should be used with %Y and not %X or %x */ - if (strict_week_number && + if ((strict_week_number && (strict_week_number_year < 0 || - strict_week_number_year_type != sunday_first_n_first_week_non_iso) || - !strict_week_number && strict_week_number_year >= 0) + strict_week_number_year_type != sunday_first_n_first_week_non_iso)) || + (!strict_week_number && strict_week_number_year >= 0)) goto err; /* Number of days since year 0 till 1st Jan of this year */ diff --git a/sql/log.cc b/sql/log.cc index ed2eff6625d..8bb6ba8e9c6 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -153,7 +153,8 @@ private: class binlog_trx_data { public: binlog_trx_data() - : at_least_one_stmt(0), m_pending(0), before_stmt_pos(MY_OFF_T_UNDEF) + : at_least_one_stmt(0), incident(FALSE), m_pending(0), + before_stmt_pos(MY_OFF_T_UNDEF) { trans_log.end_of_file= max_binlog_cache_size; } @@ -184,6 +185,7 @@ public: delete pending(); set_pending(0); reinit_io_cache(&trans_log, WRITE_CACHE, pos, 0, 0); + trans_log.end_of_file= max_binlog_cache_size; if (pos < before_stmt_pos) before_stmt_pos= MY_OFF_T_UNDEF; @@ -206,6 +208,7 @@ public: if (!empty()) truncate(0); before_stmt_pos= MY_OFF_T_UNDEF; + incident= FALSE; trans_log.end_of_file= max_binlog_cache_size; DBUG_ASSERT(empty()); } @@ -222,11 +225,22 @@ public: IO_CACHE trans_log; // The transaction cache + void set_incident(void) + { + incident= TRUE; + } + + bool has_incident(void) + { + return(incident); + } + /** Boolean that is true if there is at least one statement in the transaction cache. */ bool at_least_one_stmt; + bool incident; private: /* @@ -942,7 +956,7 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length, bool error= FALSE; Log_event_handler **current_handler; bool is_command= FALSE; - char user_host_buff[MAX_USER_HOST_SIZE]; + char user_host_buff[MAX_USER_HOST_SIZE + 1]; Security_context *sctx= thd->security_ctx; uint user_host_len= 0; ulonglong query_utime, lock_utime; @@ -1008,7 +1022,7 @@ bool LOGGER::general_log_write(THD *thd, enum enum_server_command command, { bool error= FALSE; Log_event_handler **current_handler= general_log_handler_list; - char user_host_buff[MAX_USER_HOST_SIZE]; + char user_host_buff[MAX_USER_HOST_SIZE + 1]; Security_context *sctx= thd->security_ctx; ulong id; uint user_host_len= 0; @@ -1391,7 +1405,8 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, */ if (end_ev != NULL) { - thd->binlog_flush_pending_rows_event(TRUE); + if (thd->binlog_flush_pending_rows_event(TRUE)) + DBUG_RETURN(1); /* Doing a commit or a rollback including non-transactional tables, i.e., ending a transaction where we might write the transaction @@ -1402,7 +1417,8 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, were, we would have to ensure that we're not ending a statement inside a stored function. */ - error= mysql_bin_log.write(thd, &trx_data->trans_log, end_ev); + error= mysql_bin_log.write(thd, &trx_data->trans_log, end_ev, + trx_data->has_incident()); trx_data->reset(); /* @@ -1428,7 +1444,11 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, */ thd->binlog_remove_pending_rows_event(TRUE); if (all || !(thd->options & (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT))) + { + if (trx_data->has_incident()) + mysql_bin_log.write_incident(thd, TRUE); trx_data->reset(); + } else // ...statement trx_data->truncate(trx_data->before_stmt_pos); @@ -1502,8 +1522,7 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) YESNO(thd->transaction.stmt.modified_non_trans_table))); if (!in_transaction || all) { - Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE); - qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE) + Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, TRUE, 0); error= binlog_end_trans(thd, trx_data, &qev, all); goto end; } @@ -1545,9 +1564,11 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all) YESNO(all), YESNO(thd->transaction.all.modified_non_trans_table), YESNO(thd->transaction.stmt.modified_non_trans_table))); - if (all && thd->transaction.all.modified_non_trans_table || - !all && thd->transaction.stmt.modified_non_trans_table || - (thd->options & OPTION_KEEP_LOG)) + if ((all && thd->transaction.all.modified_non_trans_table) || + (!all && thd->transaction.stmt.modified_non_trans_table && + !mysql_bin_log.check_write_error(thd)) || + ((thd->options & OPTION_KEEP_LOG) && + !mysql_bin_log.check_write_error(thd))) { /* We write the transaction cache with a rollback last if we have @@ -1557,18 +1578,25 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all) transactional table in that statement as well, which needs to be rolled back on the slave. */ - Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, FALSE); - qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE) + Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, TRUE, 0); error= binlog_end_trans(thd, trx_data, &qev, all); } - else if (all && !thd->transaction.all.modified_non_trans_table || - !all && !thd->transaction.stmt.modified_non_trans_table) + else { /* - If we have modified only transactional tables, we can truncate - the transaction cache without writing anything to the binary - log. + We reach this point if either only transactional tables were modified or + the effect of a statement that did not get into the binlog needs to be + rolled back. In the latter case, if a statement changed non-transactional + tables or had the OPTION_KEEP_LOG associated, we write an incident event + to the binlog in order to stop slaves and notify users that some changes + on the master did not get into the binlog and slaves will be inconsistent. + On the other hand, if a statement is transactional, we just safely roll it + back. */ + if ((thd->transaction.stmt.modified_non_trans_table || + (thd->options & OPTION_KEEP_LOG)) && + mysql_bin_log.check_write_error(thd)) + trx_data->set_incident(); error= binlog_end_trans(thd, trx_data, 0, all); } if (!all) @@ -1576,6 +1604,44 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all) DBUG_RETURN(error); } +void MYSQL_BIN_LOG::set_write_error(THD *thd) +{ + DBUG_ENTER("MYSQL_BIN_LOG::set_write_error"); + + write_error= 1; + + if (check_write_error(thd)) + DBUG_VOID_RETURN; + + if (my_errno == EFBIG) + my_message(ER_TRANS_CACHE_FULL, ER(ER_TRANS_CACHE_FULL), MYF(MY_WME)); + else + my_error(ER_ERROR_ON_WRITE, MYF(MY_WME), name, errno); + + DBUG_VOID_RETURN; +} + +bool MYSQL_BIN_LOG::check_write_error(THD *thd) +{ + DBUG_ENTER("MYSQL_BIN_LOG::check_write_error"); + + bool checked= FALSE; + + if (!thd->is_error()) + DBUG_RETURN(checked); + + switch (thd->main_da.sql_errno()) + { + case ER_TRANS_CACHE_FULL: + case ER_ERROR_ON_WRITE: + case ER_BINLOG_LOGGING_IMPOSSIBLE: + checked= TRUE; + break; + } + + DBUG_RETURN(checked); +} + /** @note How do we handle this (unlikely but legal) case: @@ -1606,10 +1672,11 @@ static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv) binlog_trans_log_savepos(thd, (my_off_t*) sv); /* Write it to the binary log */ - + + int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); int const error= thd->binlog_query(THD::STMT_QUERY_TYPE, - thd->query, thd->query_length, TRUE, FALSE); + thd->query, thd->query_length, TRUE, FALSE, errcode); DBUG_RETURN(error); } @@ -1625,9 +1692,10 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv) if (unlikely(thd->transaction.all.modified_non_trans_table || (thd->options & OPTION_KEEP_LOG))) { + int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); int error= thd->binlog_query(THD::STMT_QUERY_TYPE, - thd->query, thd->query_length, TRUE, FALSE); + thd->query, thd->query_length, TRUE, FALSE, errcode); DBUG_RETURN(error); } binlog_trans_log_truncate(thd, *(my_off_t*)sv); @@ -2065,6 +2133,9 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host, /* Test if someone closed between the is_open test and lock */ if (is_open()) { + /* for testing output of timestamp and thread id */ + DBUG_EXECUTE_IF("reset_log_last_time", last_time= 0;); + /* Note that my_b_write() assumes it knows the length for this */ if (event_time != last_time) { @@ -2073,7 +2144,7 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host, localtime_r(&event_time, &start); time_buff_len= my_snprintf(local_time_buff, MAX_TIME_SIZE, - "%02d%02d%02d %2d:%02d:%02d", + "%02d%02d%02d %2d:%02d:%02d\t", start.tm_year % 100, start.tm_mon + 1, start.tm_mday, start.tm_hour, start.tm_min, start.tm_sec); @@ -3851,6 +3922,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd, if (pending->write(file)) { pthread_mutex_unlock(&LOCK_log); + set_write_error(thd); DBUG_RETURN(1); } @@ -3925,7 +3997,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info) */ bool const end_stmt= thd->prelocked_mode && thd->lex->requires_prelocking(); - thd->binlog_flush_pending_rows_event(end_stmt); + if (thd->binlog_flush_pending_rows_event(end_stmt)) + DBUG_RETURN(error); pthread_mutex_lock(&LOCK_log); @@ -3976,8 +4049,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info) DBUG_PRINT("info", ("Using trans_log: cache: %d, trans_log_pos: %lu", event_info->get_cache_stmt(), (ulong) trans_log_pos)); - if (trans_log_pos == 0) - thd->binlog_start_trans_and_stmt(); + thd->binlog_start_trans_and_stmt(); file= trans_log; } /* @@ -4055,7 +4127,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info) Write the SQL command */ - if (event_info->write(file)) + if (event_info->write(file) || + DBUG_EVALUATE_IF("injecting_fault_writing", 1, 0)) goto err; if (file == &log_file) // we are writing to the real log (disk) @@ -4069,13 +4142,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info) err: if (error) - { - if (my_errno == EFBIG) - my_message(ER_TRANS_CACHE_FULL, ER(ER_TRANS_CACHE_FULL), MYF(0)); - else - my_error(ER_ERROR_ON_WRITE, MYF(0), name, errno); - write_error=1; - } + set_write_error(thd); } if (event_info->flags & LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F) @@ -4327,6 +4394,58 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE *cache, bool lock_log, bool sync_log) return 0; // All OK } +/* + Helper function to get the error code of the query to be binlogged. + */ +int query_error_code(THD *thd, bool not_killed) +{ + int error; + + if (not_killed) + { + error= thd->is_error() ? thd->main_da.sql_errno() : 0; + + /* thd->main_da.sql_errno() might be ER_SERVER_SHUTDOWN or + ER_QUERY_INTERRUPTED, So here we need to make sure that error + is not set to these errors when specified not_killed by the + caller. + */ + if (error == ER_SERVER_SHUTDOWN || error == ER_QUERY_INTERRUPTED) + error= 0; + } + else + { + /* killed status for DELAYED INSERT thread should never be used */ + DBUG_ASSERT(!(thd->system_thread & SYSTEM_THREAD_DELAYED_INSERT)); + error= thd->killed_errno(); + } + + return error; +} + +bool MYSQL_BIN_LOG::write_incident(THD *thd, bool lock) +{ + uint error= 0; + DBUG_ENTER("MYSQL_BIN_LOG::write_incident"); + LEX_STRING const write_error_msg= + { C_STRING_WITH_LEN("error writing to the binary log") }; + Incident incident= INCIDENT_LOST_EVENTS; + Incident_log_event ev(thd, incident, write_error_msg); + if (lock) + pthread_mutex_lock(&LOCK_log); + ev.write(&log_file); + if (lock) + { + if (!error && !(error= flush_and_sync())) + { + signal_update(); + rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED); + } + pthread_mutex_unlock(&LOCK_log); + } + DBUG_RETURN(error); +} + /** Write a cached log entry to the binary log. - To support transaction over replication, we wrap the transaction @@ -4339,6 +4458,9 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE *cache, bool lock_log, bool sync_log) @param cache The cache to copy to the binlog @param commit_event The commit event to print after writing the contents of the cache. + @param incident Defines if an incident event should be created to + notify that some non-transactional changes did + not get into the binlog. @note We only come here if there is something in the cache. @@ -4348,7 +4470,8 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE *cache, bool lock_log, bool sync_log) 'cache' needs to be reinitialized after this functions returns. */ -bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event) +bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event, + bool incident) { DBUG_ENTER("MYSQL_BIN_LOG::write(THD *, IO_CACHE *, Log_event *)"); VOID(pthread_mutex_lock(&LOCK_log)); @@ -4370,19 +4493,8 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event) transaction is either a BEGIN..COMMIT block or a single statement in autocommit mode. */ - Query_log_event qinfo(thd, STRING_WITH_LEN("BEGIN"), TRUE, FALSE); - /* - Imagine this is rollback due to net timeout, after all - statements of the transaction succeeded. Then we want a - zero-error code in BEGIN. In other words, if there was a - really serious error code it's already in the statement's - events, there is no need to put it also in this internally - generated event, and as this event is generated late it would - lead to false alarms. - - This is safer than thd->clear_error() against kills at shutdown. - */ - qinfo.error_code= 0; + Query_log_event qinfo(thd, STRING_WITH_LEN("BEGIN"), TRUE, TRUE, 0); + /* Now this Query_log_event has artificial log_pos 0. It must be adjusted to reflect the real position in the log. Not doing it @@ -4408,6 +4520,10 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event) if (commit_event && commit_event->write(&log_file)) goto err; + + if (incident && write_incident(thd, FALSE)) + goto err; + if (flush_and_sync()) goto err; DBUG_EXECUTE_IF("half_binlogged_transaction", abort();); diff --git a/sql/log.h b/sql/log.h index d54df8add3b..d306d6f7182 100644 --- a/sql/log.h +++ b/sql/log.h @@ -356,9 +356,12 @@ public: void new_file(); bool write(Log_event* event_info); // binary log write - bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event); + bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event, bool incident); + bool write_incident(THD *thd, bool lock); int write_cache(IO_CACHE *cache, bool lock_log, bool flush_and_sync); + void set_write_error(THD *thd); + bool check_write_error(THD *thd); void start_union_events(THD *thd, query_id_t query_id_param); void stop_union_events(THD *thd); @@ -581,4 +584,6 @@ enum enum_binlog_format { }; extern TYPELIB binlog_format_typelib; +int query_error_code(THD *thd, bool not_killed); + #endif /* LOG_H */ diff --git a/sql/log_event.cc b/sql/log_event.cc index a10a36f3b43..5f77ab3dcc4 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -369,6 +369,34 @@ int convert_handler_error(int error, THD* thd, TABLE *table) return (actual_error); } +inline bool concurrency_error_code(int error) +{ + switch (error) + { + case ER_LOCK_WAIT_TIMEOUT: + case ER_LOCK_DEADLOCK: + case ER_XA_RBDEADLOCK: + return TRUE; + default: + return (FALSE); + } +} + +inline bool unexpected_error_code(int unexpected_error) +{ + switch (unexpected_error) + { + case ER_NET_READ_ERROR: + case ER_NET_ERROR_ON_WRITE: + case ER_QUERY_INTERRUPTED: + case ER_SERVER_SHUTDOWN: + case ER_NEW_ABORTING_CONNECTION: + return(TRUE); + default: + return(FALSE); + } +} + /* pretty_print_str() */ @@ -791,8 +819,8 @@ Log_event::do_shall_skip(Relay_log_info *rli) (ulong) server_id, (ulong) ::server_id, rli->replicate_same_server_id, rli->slave_skip_counter)); - if (server_id == ::server_id && !rli->replicate_same_server_id || - rli->slave_skip_counter == 1 && rli->is_in_group()) + if ((server_id == ::server_id && !rli->replicate_same_server_id) || + (rli->slave_skip_counter == 1 && rli->is_in_group())) return EVENT_SKIP_IGNORE; else if (rli->slave_skip_counter > 0) return EVENT_SKIP_COUNT; @@ -2316,19 +2344,16 @@ Query_log_event::Query_log_event() query_length - size of the `query_arg' array using_trans - there is a modified transactional table suppress_use - suppress the generation of 'USE' statements - killed_status_arg - an optional with default to THD::KILLED_NO_VALUE - if the value is different from the default, the arg - is set to the current thd->killed value. - A caller might need to masquerade thd->killed with - THD::NOT_KILLED. + errcode - the error code of the query + DESCRIPTION Creates an event for binlogging - The value for local `killed_status' can be supplied by caller. + The value for `errcode' should be supplied by caller. */ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length, bool using_trans, - bool suppress_use, - THD::killed_state killed_status_arg) + bool suppress_use, int errcode) + :Log_event(thd_arg, (thd_arg->thread_specific_used ? LOG_EVENT_THREAD_SPECIFIC_F : 0) | @@ -2349,22 +2374,7 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, { time_t end_time; - if (killed_status_arg == THD::KILLED_NO_VALUE) - killed_status_arg= thd_arg->killed; - error_code= - (killed_status_arg == THD::NOT_KILLED) ? - (thd_arg->is_error() ? thd_arg->main_da.sql_errno() : 0) : - ((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ? 0 : - thd_arg->killed_errno()); - - /* thd_arg->main_da.sql_errno() might be ER_SERVER_SHUTDOWN or - ER_QUERY_INTERRUPTED, So here we need to make sure that - error_code is not set to these errors when specified NOT_KILLED - by the caller - */ - if ((killed_status_arg == THD::NOT_KILLED) && - (error_code == ER_SERVER_SHUTDOWN || error_code == ER_QUERY_INTERRUPTED)) - error_code= 0; + error_code= errcode; time(&end_time); exec_time = (ulong) (end_time - thd_arg->start_time); @@ -2751,7 +2761,8 @@ void Query_log_event::print_query_header(IO_CACHE* file, if (!(flags & LOG_EVENT_SUPPRESS_USE_F) && db) { - if ((different_db= memcmp(print_event_info->db, db, db_len + 1))) + different_db= memcmp(print_event_info->db, db, db_len + 1); + if (different_db) memcpy(print_event_info->db, db, db_len + 1); if (db[0] && different_db) my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter); @@ -3008,7 +3019,10 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli, ::do_apply_event(), then the companion SET also have so we don't need to reset_one_shot_variables(). */ - if (rpl_filter->db_ok(thd->db)) + if (!strncmp(query_arg, "BEGIN", q_len_arg) || + !strncmp(query_arg, "COMMIT", q_len_arg) || + !strncmp(query_arg, "ROLLBACK", q_len_arg) || + rpl_filter->db_ok(thd->db)) { thd->set_time((time_t)when); thd->query_length= q_len_arg; @@ -3020,7 +3034,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli, DBUG_PRINT("query",("%s",thd->query)); if (ignored_error_code((expected_error= error_code)) || - !check_expected_error(thd,rli,expected_error)) + !unexpected_error_code(expected_error)) { if (flags2_inited) /* @@ -3152,8 +3166,8 @@ compare_errors: actual_error= thd->is_error() ? thd->main_da.sql_errno() : 0; DBUG_PRINT("info",("expected_error: %d sql_errno: %d", expected_error, actual_error)); - if ((expected_error != actual_error) && - expected_error && + if ((expected_error && expected_error != actual_error && + !concurrency_error_code(expected_error)) && !ignored_error_code(actual_error) && !ignored_error_code(expected_error)) { @@ -3172,7 +3186,8 @@ Default database: '%s'. Query: '%s'", /* If we get the same error code as expected, or they should be ignored. */ - else if (expected_error == actual_error || + else if ((expected_error == actual_error && + !concurrency_error_code(expected_error)) || ignored_error_code(actual_error)) { DBUG_PRINT("info",("error ignored")); @@ -3344,8 +3359,8 @@ void Start_log_event_v3::print(FILE* file, PRINT_EVENT_INFO* print_event_info) my_b_printf(&cache," at startup"); my_b_printf(&cache, "\n"); if (flags & LOG_EVENT_BINLOG_IN_USE_F) - my_b_printf(&cache, "# Warning: this binlog was not closed properly. " - "Most probably mysqld crashed writing it.\n"); + my_b_printf(&cache, "# Warning: this binlog is either in use or was not " + "closed properly.\n"); } if (!is_artificial_event() && created) { @@ -4366,7 +4381,7 @@ void Load_log_event::print(FILE* file_arg, PRINT_EVENT_INFO* print_event_info, { if (i) my_b_printf(&cache, ","); - my_b_printf(&cache, field); + my_b_printf(&cache, "%s", field); field += field_lens[i] + 1; } @@ -6619,9 +6634,9 @@ Execute_load_query_log_event(THD *thd_arg, const char* query_arg, uint fn_pos_end_arg, enum_load_dup_handling dup_handling_arg, bool using_trans, bool suppress_use, - THD::killed_state killed_err_arg): + int errcode): Query_log_event(thd_arg, query_arg, query_length_arg, using_trans, - suppress_use, killed_err_arg), + suppress_use, errcode), file_id(thd_arg->file_id), fn_pos_start(fn_pos_start_arg), fn_pos_end(fn_pos_end_arg), dup_handling(dup_handling_arg) { @@ -6694,7 +6709,7 @@ void Execute_load_query_log_event::print(FILE* file, { my_b_write(&cache, (uchar*) query, fn_pos_start); my_b_printf(&cache, " LOCAL INFILE \'"); - my_b_printf(&cache, local_fname); + my_b_printf(&cache, "%s", local_fname); my_b_printf(&cache, "\'"); if (dup_handling == LOAD_DUP_REPLACE) my_b_printf(&cache, " REPLACE"); @@ -6912,8 +6927,8 @@ Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid, solution, to be able to terminate a started statement in the binary log: the extraneous events will be removed in the future. */ - DBUG_ASSERT(tbl_arg && tbl_arg->s && tid != ~0UL || - !tbl_arg && !cols && tid == ~0UL); + DBUG_ASSERT((tbl_arg && tbl_arg->s && tid != ~0UL) || + (!tbl_arg && !cols && tid == ~0UL)); if (thd_arg->options & OPTION_NO_FOREIGN_KEY_CHECKS) set_flags(NO_FOREIGN_KEY_CHECKS_F); @@ -7105,7 +7120,7 @@ int Rows_log_event::do_add_row_data(uchar *row_data, size_t length) #endif DBUG_ASSERT(m_rows_buf <= m_rows_cur); - DBUG_ASSERT(!m_rows_buf || m_rows_end && m_rows_buf < m_rows_end); + DBUG_ASSERT(!m_rows_buf || (m_rows_end && m_rows_buf < m_rows_end)); DBUG_ASSERT(m_rows_cur <= m_rows_end); /* The cast will always work since m_rows_cur <= m_rows_end */ @@ -7360,6 +7375,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) // Do event specific preparations error= do_before_row_operations(rli); + // row processing loop while (error == 0 && m_curr_row < m_rows_end) @@ -7861,10 +7877,11 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, /* Now set the size of the data to the size of the field metadata array - plus one or two bytes for number of elements in the field metadata array. + plus one or three bytes (see pack.c:net_store_length) for number of + elements in the field metadata array. */ if (m_field_metadata_size > 255) - m_data_size+= m_field_metadata_size + 2; + m_data_size+= m_field_metadata_size + 3; else m_data_size+= m_field_metadata_size + 1; @@ -9311,7 +9328,7 @@ Incident_log_event::print(FILE *file, Write_on_release_cache cache(&print_event_info->head_cache, file); print_header(&cache, print_event_info, FALSE); - my_b_printf(&cache, "\n# Incident: %s", description()); + my_b_printf(&cache, "\n# Incident: %s\nRELOAD DATABASE; # Shall generate syntax error\n", description()); } #endif diff --git a/sql/log_event.h b/sql/log_event.h index bda53da8ab0..8202dddcc76 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -676,6 +676,7 @@ typedef struct st_print_event_info #ifdef MYSQL_CLIENT uint verbose; table_mapping m_table_map; + table_mapping m_table_map_ignored; #endif /* @@ -1623,8 +1624,7 @@ public: #ifndef MYSQL_CLIENT Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length, - bool using_trans, bool suppress_use, - THD::killed_state killed_err_arg= THD::KILLED_NO_VALUE); + bool using_trans, bool suppress_use, int error); const char* get_db() { return db; } #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); @@ -2875,8 +2875,7 @@ public: uint fn_pos_end_arg, enum_load_dup_handling dup_handling_arg, bool using_trans, bool suppress_use, - THD::killed_state - killed_err_arg= THD::KILLED_NO_VALUE); + int errcode); #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); #endif /* HAVE_REPLICATION */ diff --git a/sql/my_decimal.h b/sql/my_decimal.h index 0e79f70ab4e..21669e82c44 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -183,6 +183,19 @@ inline uint my_decimal_length_to_precision(uint length, uint scale, (unsigned_flag || !length ? 0:1)); } +inline uint32 my_decimal_precision_to_length_no_truncation(uint precision, + uint8 scale, + bool unsigned_flag) +{ + /* + When precision is 0 it means that original length was also 0. Thus + unsigned_flag is ignored in this case. + */ + DBUG_ASSERT(precision || !scale); + return (uint32)(precision + (scale > 0 ? 1 : 0) + + (unsigned_flag || !precision ? 0 : 1)); +} + inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale, bool unsigned_flag) { @@ -192,8 +205,8 @@ inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale, */ DBUG_ASSERT(precision || !scale); set_if_smaller(precision, DECIMAL_MAX_PRECISION); - return (uint32)(precision + (scale>0 ? 1:0) + - (unsigned_flag || !precision ? 0:1)); + return my_decimal_precision_to_length_no_truncation(precision, scale, + unsigned_flag); } inline diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 69a789284b0..de02abc48e3 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1413,14 +1413,14 @@ enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table); /* sql_prepare.cc */ -void mysql_stmt_prepare(THD *thd, const char *packet, uint packet_length); -void mysql_stmt_execute(THD *thd, char *packet, uint packet_length); -void mysql_stmt_close(THD *thd, char *packet); +void mysqld_stmt_prepare(THD *thd, const char *packet, uint packet_length); +void mysqld_stmt_execute(THD *thd, char *packet, uint packet_length); +void mysqld_stmt_close(THD *thd, char *packet); void mysql_sql_stmt_prepare(THD *thd); void mysql_sql_stmt_execute(THD *thd); void mysql_sql_stmt_close(THD *thd); -void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length); -void mysql_stmt_reset(THD *thd, char *packet); +void mysqld_stmt_fetch(THD *thd, char *packet, uint packet_length); +void mysqld_stmt_reset(THD *thd, char *packet); void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length); void reinit_stmt_before_use(THD *thd, LEX *lex); @@ -1935,7 +1935,8 @@ extern uint max_user_connections; extern ulong what_to_log,flush_time; extern ulong query_buff_size; extern ulong max_prepared_stmt_count, prepared_stmt_count; -extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit; +extern ulong binlog_cache_size, open_files_limit; +extern ulonglong max_binlog_cache_size; extern ulong max_binlog_size, max_relay_log_size; extern ulong opt_binlog_rows_event_max_size; extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size; @@ -2253,6 +2254,16 @@ char *fn_rext(char *name); #if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS uint strconvert(CHARSET_INFO *from_cs, const char *from, CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors); +/* depends on errmsg.txt Database `db`, Table `t` ... */ +#define EXPLAIN_FILENAME_MAX_EXTRA_LENGTH 63 +enum enum_explain_filename_mode +{ + EXPLAIN_ALL_VERBOSE= 0, + EXPLAIN_PARTITIONS_VERBOSE, + EXPLAIN_PARTITIONS_AS_COMMENT +}; +uint explain_filename(const char *from, char *to, uint to_length, + enum_explain_filename_mode explain_mode); uint filename_to_tablename(const char *from, char *to, uint to_length); uint tablename_to_filename(const char *from, char *to, uint to_length); uint check_n_cut_mysql50_prefix(const char *from, char *to, uint to_length); @@ -2311,6 +2322,12 @@ extern void turn_parser_debug_on(); SQL_CRYPT *get_crypt_for_frm(void); #endif +/* password.c */ +extern "C" void my_make_scrambled_password_323(char *to, const char *password, + size_t pass_len); +extern "C" void my_make_scrambled_password(char *to, const char *password, + size_t pass_len); + #include "sql_view.h" /* Some inline functions for more speed */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 080f78993a1..f7ee7b025f9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -507,7 +507,8 @@ ulong slave_net_timeout, slave_trans_retries; ulong slave_exec_mode_options; const char *slave_exec_mode_str= "STRICT"; ulong thread_cache_size=0, thread_pool_size= 0; -ulong binlog_cache_size=0, max_binlog_cache_size=0; +ulong binlog_cache_size=0; +ulonglong max_binlog_cache_size=0; ulong query_cache_size=0; ulong refresh_version; /* Increments on each reload */ query_id_t global_query_id; @@ -982,6 +983,7 @@ static void close_connections(void) } (void) pthread_mutex_unlock(&LOCK_thread_count); + close_active_mi(); DBUG_PRINT("quit",("close_connections thread")); DBUG_VOID_RETURN; } @@ -1663,7 +1665,6 @@ static void network_init(void) opt_enable_named_pipe) { - pipe_name[sizeof(pipe_name)-1]= 0; /* Safety if too long string */ strxnmov(pipe_name, sizeof(pipe_name)-1, "\\\\.\\pipe\\", mysqld_unix_port, NullS); bzero((char*) &saPipeSecurity, sizeof(saPipeSecurity)); @@ -4779,8 +4780,9 @@ void handle_connection_in_main_thread(THD *thd) safe_mutex_assert_owner(&LOCK_thread_count); thread_cache_size=0; // Safety threads.append(thd); - (void) pthread_mutex_unlock(&LOCK_thread_count); - handle_one_connection((void*) thd); + pthread_mutex_unlock(&LOCK_thread_count); + thd->start_utime= my_micro_time(); + handle_one_connection(thd); } @@ -4805,7 +4807,7 @@ void create_thread_to_handle_connection(THD *thd) thread_created++; threads.append(thd); DBUG_PRINT("info",(("creating thread %lu"), thd->thread_id)); - thd->connect_utime= thd->start_utime= my_micro_time(); + thd->prior_thr_create_utime= thd->start_utime= my_micro_time(); if ((error=pthread_create(&thd->real_id,&connection_attrib, handle_one_connection, (void*) thd))) @@ -6582,7 +6584,7 @@ log and this option does nothing anymore.", {"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE, "Can be used to restrict the total size used to cache a multi-transaction query.", (uchar**) &max_binlog_cache_size, (uchar**) &max_binlog_cache_size, 0, - GET_ULONG, REQUIRED_ARG, ULONG_MAX, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0}, + GET_ULL, REQUIRED_ARG, ULONG_MAX, IO_SIZE, ULONGLONG_MAX, 0, IO_SIZE, 0}, {"max_binlog_size", OPT_MAX_BINLOG_SIZE, "Binary log will be rotated automatically when the size exceeds this \ value. Will also apply to relay logs if max_relay_log_size is 0. \ diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 147874611ce..e3aef02637f 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3760,8 +3760,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, DBUG_PRINT("info", ("index_merge scans cost %g", imerge_cost)); if (imerge_too_expensive || (imerge_cost > read_time) || - (non_cpk_scan_records+cpk_scan_records >= param->table->file->stats.records) && - read_time != DBL_MAX) + ((non_cpk_scan_records+cpk_scan_records >= param->table->file->stats.records) && + read_time != DBL_MAX)) { /* Bail out if it is obvious that both index_merge and ROR-union will be @@ -7950,7 +7950,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, goto err; quick->records= records; - if (cp_buffer_from_ref(thd, table, ref) && thd->is_fatal_error || + if ((cp_buffer_from_ref(thd, table, ref) && thd->is_fatal_error) || !(range= new(alloc) QUICK_RANGE())) goto err; // out of memory @@ -8556,7 +8556,7 @@ int QUICK_RANGE_SELECT::get_next_prefix(uint prefix_length, result= file->read_range_first(last_range->min_keypart_map ? &start_key : 0, last_range->max_keypart_map ? &end_key : 0, test(last_range->flag & EQ_RANGE), - sorted); + TRUE); if (last_range->flag == (UNIQUE_RANGE | EQ_RANGE)) last_range= 0; // Stop searching @@ -8826,7 +8826,7 @@ int QUICK_RANGE_SELECT::cmp_prev(QUICK_RANGE *range_arg) cmp= key_cmp(key_part_info, range_arg->min_key, range_arg->min_length); - if (cmp > 0 || cmp == 0 && !(range_arg->flag & NEAR_MIN)) + if (cmp > 0 || (cmp == 0 && !(range_arg->flag & NEAR_MIN))) return 0; return 1; // outside of range } @@ -10886,8 +10886,14 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min_in_range() /* Compare the found key with max_key. */ int cmp_res= key_cmp(index_info->key_part, max_key, real_prefix_len + min_max_arg_len); - if (!((cur_range->flag & NEAR_MAX) && (cmp_res == -1) || - (cmp_res <= 0))) + /* + The key is outside of the range if: + the interval is open and the key is equal to the maximum boundry + or + the key is greater than the maximum + */ + if (((cur_range->flag & NEAR_MAX) && cmp_res == 0) || + cmp_res > 0) { result= HA_ERR_KEY_NOT_FOUND; continue; @@ -11004,8 +11010,14 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range() /* Compare the found key with min_key. */ int cmp_res= key_cmp(index_info->key_part, min_key, real_prefix_len + min_max_arg_len); - if (!((cur_range->flag & NEAR_MIN) && (cmp_res == 1) || - (cmp_res >= 0))) + /* + The key is outside of the range if: + the interval is open and the key is equal to the minimum boundry + or + the key is less than the minimum + */ + if (((cur_range->flag & NEAR_MIN) && cmp_res == 0) || + cmp_res < 0) continue; } /* If we got to this point, the current key qualifies as MAX. */ diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 3ccc1e5cf41..8e7265ba1ad 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -744,8 +744,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, } else if (eq_type) { - if (!is_null && !cond->val_int() || - is_null && !test(part->field->is_null())) + if ((!is_null && !cond->val_int()) || + (is_null && !test(part->field->is_null()))) return 0; // Impossible test } else if (is_field_part) diff --git a/sql/parse_file.cc b/sql/parse_file.cc index f2dbeba1bbf..3d65fa1de31 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -231,7 +231,7 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name, including dir name, file name itself, and an extension, and with unpack_filename() executed over it. */ - path_end= strxnmov(path, FN_REFLEN, file_name->str, NullS) - path; + path_end= strxnmov(path, sizeof(path) - 1, file_name->str, NullS) - path; } // temporary file name @@ -314,7 +314,7 @@ my_bool rename_in_schema_file(THD *thd, const char *schema, const char *old_name, const char *new_db, const char *new_name) { - char old_path[FN_REFLEN], new_path[FN_REFLEN], arc_path[FN_REFLEN]; + char old_path[FN_REFLEN + 1], new_path[FN_REFLEN + 1], arc_path[FN_REFLEN + 1]; build_table_filename(old_path, sizeof(old_path) - 1, schema, old_name, reg_ext, 0); diff --git a/sql/password.c b/sql/password.c index 1ff67888ea4..9204c660b77 100644 --- a/sql/password.c +++ b/sql/password.c @@ -137,20 +137,39 @@ void hash_password(ulong *result, const char *password, uint password_len) Create password to be stored in user database from raw string Used for pre-4.1 password handling SYNOPSIS - make_scrambled_password_323() + my_make_scrambled_password_323() to OUT store scrambled password here password IN user-supplied password + pass_len IN length of password string */ -void make_scrambled_password_323(char *to, const char *password) +void my_make_scrambled_password_323(char *to, const char *password, + size_t pass_len) { ulong hash_res[2]; - hash_password(hash_res, password, (uint) strlen(password)); + hash_password(hash_res, password, (uint) pass_len); sprintf(to, "%08lx%08lx", hash_res[0], hash_res[1]); } /* + Wrapper around my_make_scrambled_password_323() to maintain client lib ABI + compatibility. + In server code usage of my_make_scrambled_password_323() is preferred to + avoid strlen(). + SYNOPSIS + make_scrambled_password_323() + to OUT store scrambled password here + password IN NULL-terminated string with user-supplied password +*/ + +void make_scrambled_password_323(char *to, const char *password) +{ + my_make_scrambled_password_323(to, password, strlen(password)); +} + + +/* Scramble string with password. Used in pre 4.1 authentication phase. SYNOPSIS @@ -383,20 +402,21 @@ my_crypt(char *to, const uchar *s1, const uchar *s2, uint len) The result of this function is used as return value from PASSWORD() and is stored in the database. SYNOPSIS - make_scrambled_password() + my_make_scrambled_password() buf OUT buffer of size 2*SHA1_HASH_SIZE + 2 to store hex string - password IN NULL-terminated password string + password IN password string + pass_len IN length of password string */ -void -make_scrambled_password(char *to, const char *password) +void my_make_scrambled_password(char *to, const char *password, + size_t pass_len) { SHA1_CONTEXT sha1_context; uint8 hash_stage2[SHA1_HASH_SIZE]; mysql_sha1_reset(&sha1_context); /* stage 1: hash password */ - mysql_sha1_input(&sha1_context, (uint8 *) password, (uint) strlen(password)); + mysql_sha1_input(&sha1_context, (uint8 *) password, (uint) pass_len); mysql_sha1_result(&sha1_context, (uint8 *) to); /* stage 2: hash stage1 output */ mysql_sha1_reset(&sha1_context); @@ -410,6 +430,23 @@ make_scrambled_password(char *to, const char *password) /* + Wrapper around my_make_scrambled_password() to maintain client lib ABI + compatibility. + In server code usage of my_make_scrambled_password() is preferred to + avoid strlen(). + SYNOPSIS + make_scrambled_password() + buf OUT buffer of size 2*SHA1_HASH_SIZE + 2 to store hex string + password IN NULL-terminated password string +*/ + +void make_scrambled_password(char *to, const char *password) +{ + my_make_scrambled_password(to, password, strlen(password)); +} + + +/* Produce an obscure octet sequence from password and random string, recieved from the server. This sequence corresponds to the password, but password can not be easily restored from it. The sequence diff --git a/sql/rpl_reporting.cc b/sql/rpl_reporting.cc index 28f257790c7..a09140de3c4 100644 --- a/sql/rpl_reporting.cc +++ b/sql/rpl_reporting.cc @@ -13,6 +13,7 @@ Slave_reporting_capability::report(loglevel level, int err_code, va_list args; va_start(args, msg); + pthread_mutex_lock(&err_lock); switch (level) { case ERROR_LEVEL: @@ -38,6 +39,7 @@ Slave_reporting_capability::report(loglevel level, int err_code, my_vsnprintf(pbuff, pbuffsize, msg, args); + pthread_mutex_unlock(&err_lock); va_end(args); /* If the msg string ends with '.', do not add a ',' it would be ugly */ @@ -46,3 +48,8 @@ Slave_reporting_capability::report(loglevel level, int err_code, (pbuff[0] && *(strend(pbuff)-1) == '.') ? "" : ",", err_code); } + +Slave_reporting_capability::~Slave_reporting_capability() +{ + pthread_mutex_destroy(&err_lock); +} diff --git a/sql/rpl_reporting.h b/sql/rpl_reporting.h index 2e3fa3cea83..ce33407e516 100644 --- a/sql/rpl_reporting.h +++ b/sql/rpl_reporting.h @@ -16,6 +16,8 @@ class Slave_reporting_capability { public: + /** lock used to synchronize m_last_error on 'SHOW SLAVE STATUS' **/ + mutable pthread_mutex_t err_lock; /** Constructor. @@ -24,6 +26,7 @@ public: Slave_reporting_capability(char const *thread_name) : m_thread_name(thread_name) { + pthread_mutex_init(&err_lock, MY_MUTEX_INIT_FAST); } /** @@ -44,7 +47,9 @@ public: STATUS</code>. */ void clear_error() { + pthread_mutex_lock(&err_lock); m_last_error.clear(); + pthread_mutex_unlock(&err_lock); } /** @@ -72,6 +77,7 @@ public: Error const& last_error() const { return m_last_error; } + virtual ~Slave_reporting_capability()= 0; private: /** Last error produced by the I/O or SQL thread respectively. @@ -79,6 +85,10 @@ private: mutable Error m_last_error; char const *const m_thread_name; + + // not implemented + Slave_reporting_capability(const Slave_reporting_capability& rhs); + Slave_reporting_capability& operator=(const Slave_reporting_capability& rhs); }; #endif // RPL_REPORTING_H diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index e93417374fe..18fbae9bb9d 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -104,9 +104,16 @@ int init_relay_log_info(Relay_log_info* rli, rli->tables_to_lock= 0; rli->tables_to_lock_count= 0; - fn_format(rli->slave_patternload_file, PREFIX_SQL_LOAD, slave_load_tmpdir, "", - MY_PACK_FILENAME | MY_UNPACK_FILENAME | - MY_RETURN_REAL_PATH); + char pattern[FN_REFLEN]; + if (fn_format(pattern, PREFIX_SQL_LOAD, slave_load_tmpdir, "", + MY_SAFE_PATH | MY_RETURN_REAL_PATH) == NullS) + { + pthread_mutex_unlock(&rli->data_lock); + sql_print_error("Unable to use slave's temporary directory %s", + slave_load_tmpdir); + DBUG_RETURN(1); + } + unpack_filename(rli->slave_patternload_file, pattern); rli->slave_patternload_file_size= strlen(rli->slave_patternload_file); /* @@ -940,6 +947,7 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset, if (count_relay_log_space(rli)) { *errmsg= "Error counting relay log space"; + error=1; goto err; } if (!just_reset) diff --git a/sql/set_var.cc b/sql/set_var.cc index bc8c91342e6..0b89333ce03 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -359,8 +359,8 @@ static sys_var_const sys_lower_case_table_names(&vars, &lower_case_table_names); static sys_var_thd_ulong_session_readonly sys_max_allowed_packet(&vars, "max_allowed_packet", &SV::max_allowed_packet); -static sys_var_long_ptr sys_max_binlog_cache_size(&vars, "max_binlog_cache_size", - &max_binlog_cache_size); +static sys_var_ulonglong_ptr sys_max_binlog_cache_size(&vars, "max_binlog_cache_size", + &max_binlog_cache_size); static sys_var_long_ptr sys_max_binlog_size(&vars, "max_binlog_size", &max_binlog_size, fix_max_binlog_size); diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index f9b66990e93..42bca02984d 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -6076,7 +6076,7 @@ ER_SLAVE_INCIDENT ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT eng "Table has no partition for some existing values" ER_BINLOG_UNSAFE_STATEMENT - eng "Statement is not safe to log in statement format." + eng "Statement may not be safe to log in statement format." swe "Detta är inte säkert att logga i statement-format." ER_SLAVE_FATAL_ERROR eng "Fatal error: %s" @@ -6177,3 +6177,27 @@ ER_TOO_LONG_TABLE_COMMENT ER_TOO_LONG_FIELD_COMMENT eng "Comment for field '%-.64s' is too long (max = %lu)" por "Comentário para o campo '%-.64s' é longo demais (max = %lu)" + +ER_FUNC_INEXISTENT_NAME_COLLISION 42000 + eng "FUNCTION %s does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual" + +# When updating these, please update EXPLAIN_FILENAME_MAX_EXTRA_LENGTH in +# mysql_priv.h with the new maximal additional length for explain_filename. +ER_DATABASE_NAME + eng "Database `%s`" + swe "Databas `%s`" +ER_TABLE_NAME + eng "Table `%s`" + swe "Tabell `%s`" +ER_PARTITION_NAME + eng "Partition `%s`" + swe "Partition `%s`" +ER_SUBPARTITION_NAME + eng "Subpartition `%s`" + swe "Subpartition `%s`" +ER_TEMPORARY_NAME + eng "Temporary" + swe "Temporär" +ER_RENAMED_NAME + eng "Renamed" + swe "Namnändrad" diff --git a/sql/slave.cc b/sql/slave.cc index a6264dfb0ac..81be7064f89 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -389,6 +389,13 @@ void init_slave_skip_errors(const char* arg) DBUG_VOID_RETURN; } +static void set_thd_in_use_temporary_tables(Relay_log_info *rli) +{ + TABLE *table; + + for (table= rli->save_temporary_tables ; table ; table= table->next) + table->in_use= rli->sql_thd; +} int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock) { @@ -404,8 +411,8 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock) DBUG_PRINT("info",("Terminating IO thread")); mi->abort_slave=1; if ((error=terminate_slave_thread(mi->io_thd, io_lock, - &mi->stop_cond, - &mi->slave_running, + &mi->stop_cond, + &mi->slave_running, skip_lock)) && !force_all) DBUG_RETURN(error); @@ -415,8 +422,8 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock) DBUG_PRINT("info",("Terminating SQL thread")); mi->rli.abort_slave=1; if ((error=terminate_slave_thread(mi->rli.sql_thd, sql_lock, - &mi->rli.stop_cond, - &mi->rli.slave_running, + &mi->rli.stop_cond, + &mi->rli.slave_running, skip_lock)) && !force_all) DBUG_RETURN(error); @@ -424,6 +431,7 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock) DBUG_RETURN(0); } + /** Wait for a slave thread to terminate. @@ -660,7 +668,7 @@ static int end_slave_on_walk(Master_info* mi, uchar* /*unused*/) /* - Free all resources used by slave + Release slave threads at time of executing shutdown. SYNOPSIS end_slave() @@ -686,15 +694,32 @@ void end_slave() once multi-master code is ready. */ terminate_slave_threads(active_mi,SLAVE_FORCE_ALL); + } + pthread_mutex_unlock(&LOCK_active_mi); + DBUG_VOID_RETURN; +} + +/** + Free all resources used by slave threads at time of executing shutdown. + The routine must be called after all possible users of @c active_mi + have left. + + SYNOPSIS + close_active_mi() + +*/ +void close_active_mi() +{ + pthread_mutex_lock(&LOCK_active_mi); + if (active_mi) + { end_master_info(active_mi); delete active_mi; active_mi= 0; } pthread_mutex_unlock(&LOCK_active_mi); - DBUG_VOID_RETURN; } - static bool io_slave_killed(THD* thd, Master_info* mi) { DBUG_ENTER("io_slave_killed"); @@ -802,7 +827,7 @@ int init_strvar_from_file(char *var, int max_size, IO_CACHE *f, up to and including newline. */ int c; - while (((c=my_b_get(f)) != '\n' && c != my_b_EOF)); + while (((c=my_b_get(f)) != '\n' && c != my_b_EOF)) ; } DBUG_RETURN(0); } @@ -1485,6 +1510,8 @@ bool show_master_info(THD* thd, Master_info* mi) pthread_mutex_lock(&mi->data_lock); pthread_mutex_lock(&mi->rli.data_lock); + pthread_mutex_lock(&mi->err_lock); + pthread_mutex_lock(&mi->rli.err_lock); protocol->store(mi->host, &my_charset_bin); protocol->store(mi->user, &my_charset_bin); protocol->store((uint32) mi->port); @@ -1584,6 +1611,8 @@ bool show_master_info(THD* thd, Master_info* mi) // Last_SQL_Error protocol->store(mi->rli.last_error().message, &my_charset_bin); + pthread_mutex_unlock(&mi->rli.err_lock); + pthread_mutex_unlock(&mi->err_lock); pthread_mutex_unlock(&mi->rli.data_lock); pthread_mutex_unlock(&mi->data_lock); @@ -1855,25 +1884,6 @@ static ulong read_event(MYSQL* mysql, Master_info *mi, bool* suppress_warnings) DBUG_RETURN(len - 1); } - -int check_expected_error(THD* thd, Relay_log_info const *rli, - int expected_error) -{ - DBUG_ENTER("check_expected_error"); - - switch (expected_error) { - case ER_NET_READ_ERROR: - case ER_NET_ERROR_ON_WRITE: - case ER_QUERY_INTERRUPTED: - case ER_SERVER_SHUTDOWN: - case ER_NEW_ABORTING_CONNECTION: - DBUG_RETURN(1); - default: - DBUG_RETURN(0); - } -} - - /* Check if the current error is of temporary nature of not. Some errors are temporary in nature, such as @@ -2227,7 +2237,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli) "the slave_transaction_retries variable.", slave_trans_retries); } - else if (exec_res && !temp_err || + else if ((exec_res && !temp_err) || (opt_using_transactions && rli->group_relay_log_pos == rli->event_relay_log_pos)) { @@ -2389,6 +2399,7 @@ pthread_handler_t handle_slave_io(void *arg) pthread_detach_this_thread(); thd->thread_stack= (char*) &thd; // remember where our stack is + mi->clear_error(); if (init_slave_thread(thd, SLAVE_THD_IO)) { pthread_cond_broadcast(&mi->start_cond); @@ -2503,6 +2514,7 @@ requesting master dump") || goto connected; }); + DBUG_ASSERT(mi->last_error().number == 0); while (!io_slave_killed(thd,mi)) { ulong event_len; @@ -2667,14 +2679,21 @@ err: LOAD DATA INFILE. */ static -int check_temp_dir(char* tmp_dir, char *tmp_file) +int check_temp_dir(char* tmp_file) { int fd; MY_DIR *dirp; + char tmp_dir[FN_REFLEN]; + size_t tmp_dir_size; DBUG_ENTER("check_temp_dir"); /* + Get the directory from the temporary file. + */ + dirname_part(tmp_dir, tmp_file, &tmp_dir_size); + + /* Check if the directory exists. */ if (!(dirp=my_dir(tmp_dir,MYF(MY_WME)))) @@ -2749,6 +2768,7 @@ pthread_handler_t handle_slave_sql(void *arg) } thd->init_for_queries(); thd->temporary_tables = rli->save_temporary_tables; // restore temp tables + set_thd_in_use_temporary_tables(rli); // (re)set sql_thd in use for saved temp tables pthread_mutex_lock(&LOCK_thread_count); threads.append(thd); pthread_mutex_unlock(&LOCK_thread_count); @@ -2829,7 +2849,7 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, llstr(rli->group_master_log_pos,llbuff),rli->group_relay_log_name, llstr(rli->group_relay_log_pos,llbuff1)); - if (check_temp_dir(slave_load_tmpdir, rli->slave_patternload_file)) + if (check_temp_dir(rli->slave_patternload_file)) { rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), "Unable to use slave's temporary directory %s - %s", @@ -2995,6 +3015,7 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ DBUG_ASSERT(rli->sql_thd == thd); THD_CHECK_SENTRY(thd); rli->sql_thd= 0; + set_thd_in_use_temporary_tables(rli); // (re)set sql_thd in use for saved temp tables pthread_mutex_lock(&LOCK_thread_count); THD_CHECK_SENTRY(thd); delete thd; @@ -3693,6 +3714,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, if (!slave_was_killed) { + mi->clear_error(); // clear possible left over reconnect error if (reconnect) { if (!suppress_warnings && global_system_variables.log_warnings) diff --git a/sql/slave.h b/sql/slave.h index abd63315e62..a44a7eed83e 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -171,10 +171,10 @@ bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report, bool rpl_master_erroneous_autoinc(THD* thd); const char *print_slave_db_safe(const char *db); -int check_expected_error(THD* thd, Relay_log_info const *rli, int error_code); void skip_load_data_infile(NET* net); -void end_slave(); /* clean up */ +void end_slave(); /* release slave threads */ +void close_active_mi(); /* clean up slave threads data */ void clear_until_condition(Relay_log_info* rli); void clear_slave_error(Relay_log_info* rli); void end_relay_log_info(Relay_log_info* rli); diff --git a/sql/sp.cc b/sql/sp.cc index 8c8149d0afc..29e228f5e45 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -941,7 +941,7 @@ sp_create_routine(THD *thd, int type, sp_head *sp) /* Such a statement can always go directly to binlog, no trans cache */ thd->binlog_query(THD::MYSQL_QUERY_TYPE, log_query.c_ptr(), log_query.length(), - FALSE, FALSE, THD::NOT_KILLED); + FALSE, FALSE, 0); thd->variables.sql_mode= 0; } @@ -1308,13 +1308,20 @@ 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'. + + @param thd Thread handler + @param routines List of needles in the hay stack + @param any Any of the needles are good enough + + @return + @retval FALSE Found. + @retval TRUE Not found */ -int -sp_exist_routines(THD *thd, TABLE_LIST *routines, bool any, bool no_error) +bool +sp_exist_routines(THD *thd, TABLE_LIST *routines, bool any) { TABLE_LIST *routine; - bool result= 0; bool sp_object_found; DBUG_ENTER("sp_exists_routine"); for (routine= routines; routine; routine= routine->next_global) @@ -1336,21 +1343,16 @@ sp_exist_routines(THD *thd, TABLE_LIST *routines, bool any, bool no_error) if (sp_object_found) { if (any) - DBUG_RETURN(1); - result= 1; + break; } else if (!any) { - if (!no_error) - { - my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION or PROCEDURE", - routine->table_name); - DBUG_RETURN(-1); - } - DBUG_RETURN(0); + my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION or PROCEDURE", + routine->table_name); + DBUG_RETURN(TRUE); } } - DBUG_RETURN(result); + DBUG_RETURN(FALSE); } @@ -39,8 +39,8 @@ sp_head * sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp, bool cache_only); -int -sp_exist_routines(THD *thd, TABLE_LIST *procs, bool any, bool no_error); +bool +sp_exist_routines(THD *thd, TABLE_LIST *procs, bool any); int sp_routine_exists_in_table(THD *thd, int type, sp_name *name); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 1dba8a45926..8a8a5b06cc1 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1779,8 +1779,9 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, thd->options= binlog_save_options; if (thd->binlog_evt_union.unioned_events) { + int errcode = query_error_code(thd, thd->killed == THD::NOT_KILLED); Query_log_event qinfo(thd, binlog_buf.ptr(), binlog_buf.length(), - thd->binlog_evt_union.unioned_events_trans, FALSE); + thd->binlog_evt_union.unioned_events_trans, FALSE, errcode); if (mysql_bin_log.write(&qinfo) && thd->binlog_evt_union.unioned_events_trans) { diff --git a/sql/spatial.h b/sql/spatial.h index dbf5da6665b..86c2ed8c197 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -116,12 +116,12 @@ struct MBR int touches(const MBR *mbr) { /* The following should be safe, even if we compare doubles */ - return ((((mbr->xmin == xmax) || (mbr->xmax == xmin)) && - (((mbr->ymin >= ymin) && (mbr->ymin <= ymax)) || - ((mbr->ymax >= ymin) && (mbr->ymax <= ymax)))) || - (((mbr->ymin == ymax) || (mbr->ymax == ymin)) && - (((mbr->xmin >= xmin) && (mbr->xmin <= xmax)) || - ((mbr->xmax >= xmin) && (mbr->xmax <= xmax))))); + return ((mbr->xmin == xmax || mbr->xmax == xmin) && + ((mbr->ymin >= ymin && mbr->ymin <= ymax) || + (mbr->ymax >= ymin && mbr->ymax <= ymax))) || + ((mbr->ymin == ymax || mbr->ymax == ymin) && + ((mbr->xmin >= xmin && mbr->xmin <= xmax) || + (mbr->xmax >= xmin && mbr->xmax <= xmax))); } int within(const MBR *mbr) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b1dbb7031ce..ab18a2d1d04 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -936,6 +936,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, #ifdef HAVE_OPENSSL Vio *vio=thd->net.vio; SSL *ssl= (SSL*) vio->ssl_arg; + X509 *cert; #endif /* @@ -964,8 +965,11 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, */ if (vio_type(vio) == VIO_TYPE_SSL && SSL_get_verify_result(ssl) == X509_V_OK && - SSL_get_peer_certificate(ssl)) + (cert= SSL_get_peer_certificate(ssl))) + { user_access= acl_user->access; + X509_free(cert); + } break; case SSL_TYPE_SPECIFIED: /* Client should have specified attrib */ /* @@ -974,7 +978,6 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, If cipher name is specified, we compare it to actual cipher in use. */ - X509 *cert; if (vio_type(vio) != VIO_TYPE_SSL || SSL_get_verify_result(ssl) != X509_V_OK) break; @@ -1014,6 +1017,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, sql_print_information("X509 issuer mismatch: should be '%s' " "but is '%s'", acl_user->x509_issuer, ptr); free(ptr); + X509_free(cert); user_access=NO_ACCESS; break; } @@ -1033,12 +1037,15 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, sql_print_information("X509 subject mismatch: should be '%s' but is '%s'", acl_user->x509_subject, ptr); free(ptr); + X509_free(cert); user_access=NO_ACCESS; break; } user_access= acl_user->access; free(ptr); } + /* Deallocate the X509 certificate. */ + X509_free(cert); break; #else /* HAVE_OPENSSL */ default: @@ -1185,12 +1192,12 @@ static void acl_update_user(const char *user, const char *host, for (uint i=0 ; i < acl_users.elements ; i++) { ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*); - if (!acl_user->user && !user[0] || - acl_user->user && !strcmp(user,acl_user->user)) + if ((!acl_user->user && !user[0]) || + (acl_user->user && !strcmp(user,acl_user->user))) { - if (!acl_user->host.hostname && !host[0] || - acl_user->host.hostname && - !my_strcasecmp(system_charset_info, host, acl_user->host.hostname)) + if ((!acl_user->host.hostname && !host[0]) || + (acl_user->host.hostname && + !my_strcasecmp(system_charset_info, host, acl_user->host.hostname))) { acl_user->access=privileges; if (mqh->specified_limits & USER_RESOURCES::QUERIES_PER_HOUR) @@ -1268,16 +1275,16 @@ static void acl_update_db(const char *user, const char *host, const char *db, for (uint i=0 ; i < acl_dbs.elements ; i++) { ACL_DB *acl_db=dynamic_element(&acl_dbs,i,ACL_DB*); - if (!acl_db->user && !user[0] || - acl_db->user && - !strcmp(user,acl_db->user)) + if ((!acl_db->user && !user[0]) || + (acl_db->user && + !strcmp(user,acl_db->user))) { - if (!acl_db->host.hostname && !host[0] || - acl_db->host.hostname && - !strcmp(host, acl_db->host.hostname)) + if ((!acl_db->host.hostname && !host[0]) || + (acl_db->host.hostname && + !strcmp(host, acl_db->host.hostname))) { - if (!acl_db->db && !db[0] || - acl_db->db && !strcmp(db,acl_db->db)) + if ((!acl_db->db && !db[0]) || + (acl_db->db && !strcmp(db,acl_db->db))) { if (privileges) acl_db->access=privileges; @@ -1486,8 +1493,8 @@ bool acl_check_host(const char *host, const char *ip) return 0; VOID(pthread_mutex_lock(&acl_cache->lock)); - if (host && hash_search(&acl_check_hosts,(uchar*) host,strlen(host)) || - ip && hash_search(&acl_check_hosts,(uchar*) ip, strlen(ip))) + if ((host && hash_search(&acl_check_hosts,(uchar*) host,strlen(host))) || + (ip && hash_search(&acl_check_hosts,(uchar*) ip, strlen(ip)))) { VOID(pthread_mutex_unlock(&acl_cache->lock)); return 0; // Found host @@ -1648,7 +1655,7 @@ bool change_password(THD *thd, const char *host, const char *user, new_password)); thd->clear_error(); thd->binlog_query(THD::MYSQL_QUERY_TYPE, buff, query_length, - FALSE, FALSE, THD::NOT_KILLED); + FALSE, FALSE, 0); } end: close_thread_tables(thd); @@ -1704,8 +1711,8 @@ find_acl_user(const char *host, const char *user, my_bool exact) host, acl_user->host.hostname ? acl_user->host.hostname : "")); - if (!acl_user->user && !user[0] || - acl_user->user && !strcmp(user,acl_user->user)) + if ((!acl_user->user && !user[0]) || + (acl_user->user && !strcmp(user,acl_user->user))) { if (exact ? !my_strcasecmp(system_charset_info, host, acl_user->host.hostname ? @@ -2988,8 +2995,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, { if (!(rights & CREATE_ACL)) { - char buf[FN_REFLEN]; - build_table_filename(buf, sizeof(buf), table_list->db, + char buf[FN_REFLEN + 1]; + build_table_filename(buf, sizeof(buf) - 1, table_list->db, table_list->table_name, reg_ext, 0); fn_format(buf, buf, "", "", MY_UNPACK_FILENAME | MY_RESOLVE_SYMLINKS | MY_RETURN_REAL_PATH | MY_APPEND_EXT); @@ -3191,26 +3198,24 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, } -/* +/** Store routine level grants in the privilege tables - SYNOPSIS - mysql_routine_grant() - thd Thread handle - table_list List of routines to give grant - is_proc true indicates routine list are procedures - user_list List of users to give grant - rights Table level grant - revoke_grant Set to 1 if this is a REVOKE command + @param thd Thread handle + @param table_list List of routines to give grant + @param is_proc Is this a list of procedures? + @param user_list List of users to give grant + @param rights Table level grant + @param revoke_grant Is this is a REVOKE command? - RETURN - 0 ok - 1 error + @return + @retval FALSE Success. + @retval TRUE An error occurred. */ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, List <LEX_USER> &user_list, ulong rights, - bool revoke_grant, bool no_error) + bool revoke_grant, bool write_to_binlog) { List_iterator <LEX_USER> str_list (user_list); LEX_USER *Str, *tmp_Str; @@ -3221,22 +3226,20 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, if (!initialized) { - if (!no_error) - my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), - "--skip-grant-tables"); + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), + "--skip-grant-tables"); DBUG_RETURN(TRUE); } if (rights & ~PROC_ACLS) { - if (!no_error) - my_message(ER_ILLEGAL_GRANT_FOR_TABLE, ER(ER_ILLEGAL_GRANT_FOR_TABLE), - MYF(0)); + my_message(ER_ILLEGAL_GRANT_FOR_TABLE, ER(ER_ILLEGAL_GRANT_FOR_TABLE), + MYF(0)); DBUG_RETURN(TRUE); } if (!revoke_grant) { - if (sp_exist_routines(thd, table_list, is_proc, no_error)<0) + if (sp_exist_routines(thd, table_list, is_proc)) DBUG_RETURN(TRUE); } @@ -3317,9 +3320,8 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, { if (revoke_grant) { - if (!no_error) - my_error(ER_NONEXISTING_PROC_GRANT, MYF(0), - Str->user.str, Str->host.str, table_name); + my_error(ER_NONEXISTING_PROC_GRANT, MYF(0), + Str->user.str, Str->host.str, table_name); result= TRUE; continue; } @@ -3344,16 +3346,14 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, } thd->mem_root= old_root; pthread_mutex_unlock(&acl_cache->lock); - if (!result && !no_error) + + if (write_to_binlog) { write_bin_log(thd, TRUE, thd->query, thd->query_length); } rw_unlock(&LOCK_grant); - if (!result && !no_error) - my_ok(thd); - /* Tables are automatically closed */ DBUG_RETURN(result); } @@ -5319,16 +5319,13 @@ static int handle_grant_struct(uint struct_no, bool drop, uint elements; const char *user; const char *host; - ACL_USER *acl_user; - ACL_DB *acl_db; - GRANT_NAME *grant_name; + ACL_USER *acl_user= NULL; + ACL_DB *acl_db= NULL; + GRANT_NAME *grant_name= NULL; DBUG_ENTER("handle_grant_struct"); DBUG_PRINT("info",("scan struct: %u search: '%s'@'%s'", struct_no, user_from->user.str, user_from->host.str)); - LINT_INIT(acl_user); - LINT_INIT(acl_db); - LINT_INIT(grant_name); LINT_INIT(user); LINT_INIT(host); @@ -5696,6 +5693,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list) List_iterator <LEX_USER> user_list(list); TABLE_LIST tables[GRANT_TABLES]; bool some_users_deleted= FALSE; + ulong old_sql_mode= thd->variables.sql_mode; DBUG_ENTER("mysql_drop_user"); /* @@ -5709,6 +5707,8 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list) if ((result= open_grant_tables(thd, tables))) DBUG_RETURN(result != 1); + thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH; + rw_wrlock(&LOCK_grant); VOID(pthread_mutex_lock(&acl_cache->lock)); @@ -5741,6 +5741,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list) rw_unlock(&LOCK_grant); close_thread_tables(thd); + thd->variables.sql_mode= old_sql_mode; DBUG_RETURN(result); } @@ -6150,21 +6151,20 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name, } -/* +/** Grant EXECUTE,ALTER privilege for a stored procedure - SYNOPSIS - sp_grant_privileges() - thd The current thread. - db DB of the stored procedure - name Name of the stored procedure + @param thd The current thread. + @param sp_db + @param sp_name + @param is_proc - RETURN - 0 OK. - < 0 Error. Error message not yet sent. + @return + @retval FALSE Success + @retval TRUE An error occured. Error message not yet sent. */ -int sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, +bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, bool is_proc) { Security_context *sctx= thd->security_ctx; @@ -6174,6 +6174,7 @@ int sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, bool result; ACL_USER *au; char passwd_buff[SCRAMBLED_PASSWORD_CHAR_LENGTH+1]; + Dummy_error_handler error_handler; DBUG_ENTER("sp_grant_privileges"); if (!(combo=(LEX_USER*) thd->alloc(sizeof(st_lex_user)))) @@ -6224,8 +6225,11 @@ int sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, } else { - my_error(ER_PASSWD_LENGTH, MYF(0), SCRAMBLED_PASSWORD_CHAR_LENGTH); - return -1; + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_PASSWD_LENGTH, + ER(ER_PASSWD_LENGTH), + SCRAMBLED_PASSWORD_CHAR_LENGTH); + return TRUE; } combo->password.str= passwd_buff; } @@ -6239,10 +6243,17 @@ int sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, DBUG_RETURN(TRUE); thd->lex->ssl_type= SSL_TYPE_NOT_SPECIFIED; + thd->lex->ssl_cipher= thd->lex->x509_subject= thd->lex->x509_issuer= 0; bzero((char*) &thd->lex->mqh, sizeof(thd->lex->mqh)); + /* + Only care about whether the operation failed or succeeded + as all errors will be handled later. + */ + thd->push_internal_handler(&error_handler); result= mysql_routine_grant(thd, tables, is_proc, user_list, - DEFAULT_CREATE_PROC_ACLS, 0, 1); + DEFAULT_CREATE_PROC_ACLS, FALSE, FALSE); + thd->pop_internal_handler(); DBUG_RETURN(result); } diff --git a/sql/sql_acl.h b/sql/sql_acl.h index 9ae17a4bf02..a8090fba2e7 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -233,7 +233,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list, bool revoke); bool mysql_routine_grant(THD *thd, TABLE_LIST *table, bool is_proc, List <LEX_USER> &user_list, ulong rights, - bool revoke, bool no_error); + bool revoke, bool write_to_binlog); my_bool grant_init(); void grant_free(void); my_bool grant_reload(THD *thd); @@ -264,7 +264,7 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant, const char *db, const char *table); bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name, bool is_proc); -int sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, +bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, bool is_proc); bool check_routine_level_acl(THD *thd, const char *db, const char *name, bool is_proc); diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 9ca6e0a0a2b..d273b3319ee 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -246,7 +246,7 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len) } DBUG_RETURN(0); } - for (str++; *(end - 1) == '0'; end--); // jump over zeros at the end + for (str++; *(end - 1) == '0'; end--) ; // jump over zeros at the end if (str == end) // number was something like '123.000' { char *endpos= (char*) str; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 0dc29f7e3c2..88e1620b152 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -473,13 +473,14 @@ static TABLE_SHARE @todo Rework alternative ways to deal with ER_NO_SUCH TABLE. */ - if (share || thd->is_error() && thd->main_da.sql_errno() != ER_NO_SUCH_TABLE) + if (share || (thd->is_error() && thd->main_da.sql_errno() != ER_NO_SUCH_TABLE)) DBUG_RETURN(share); /* Table didn't exist. Check if some engine can provide it */ - if ((tmp= ha_create_table_from_engine(thd, table_list->db, - table_list->table_name)) < 0) + tmp= ha_create_table_from_engine(thd, table_list->db, + table_list->table_name); + if (tmp < 0) { /* No such table in any engine. @@ -1431,11 +1432,10 @@ static inline uint tmpkeyval(THD *thd, TABLE *table) void close_temporary_tables(THD *thd) { TABLE *table; - TABLE *next; + TABLE *next= NULL; TABLE *prev_table; /* Assume thd->options has OPTION_QUOTE_SHOW_CREATE */ bool was_quote_show= TRUE; - LINT_INIT(next); if (!thd->temporary_tables) return; @@ -1541,7 +1541,7 @@ void close_temporary_tables(THD *thd) thd->variables.character_set_client= system_charset_info; Query_log_event qinfo(thd, s_query.ptr(), s_query.length() - 1 /* to remove trailing ',' */, - 0, FALSE, THD::NOT_KILLED); + 0, FALSE, 0); thd->variables.character_set_client= cs_save; mysql_bin_log.write(&qinfo); thd->variables.pseudo_thread_id= save_pseudo_thread_id; @@ -2432,7 +2432,7 @@ bool lock_table_name_if_not_cached(THD *thd, const char *db, bool check_if_table_exists(THD *thd, TABLE_LIST *table, bool *exists) { - char path[FN_REFLEN]; + char path[FN_REFLEN + 1]; int rc; DBUG_ENTER("check_if_table_exists"); @@ -2617,8 +2617,8 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, distance > 0 - we have lock mode higher then we require distance == 0 - we have lock mode exactly which we need */ - if (best_distance < 0 && distance > best_distance || - distance >= 0 && distance < best_distance) + if ((best_distance < 0 && distance > best_distance) || + (distance >= 0 && distance < best_distance)) { best_distance= distance; best_table= table; @@ -2649,7 +2649,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, real fix will be made after definition cache will be made) */ { - char path[FN_REFLEN]; + char path[FN_REFLEN + 1]; enum legacy_db_type not_used; build_table_filename(path, sizeof(path) - 1, table_list->db, table_list->table_name, reg_ext, 0); @@ -2963,6 +2963,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, table->insert_values= 0; table->fulltext_searched= 0; table->file->ft_handler= 0; + table->reginfo.impossible_range= 0; /* Catch wrong handling of the auto_increment_field_not_null. */ DBUG_ASSERT(!table->auto_increment_field_not_null); table->auto_increment_field_not_null= FALSE; @@ -4015,9 +4016,10 @@ retry: /* this DELETE FROM is needed even with row-based binlogging */ end = strxmov(strmov(query, "DELETE FROM `"), share->db.str,"`.`",share->table_name.str,"`", NullS); + int errcode= query_error_code(thd, TRUE); thd->binlog_query(THD::STMT_QUERY_TYPE, query, (ulong)(end-query), - FALSE, FALSE, THD::NOT_KILLED); + FALSE, FALSE, errcode); my_free(query, MYF(0)); } else @@ -5585,6 +5587,13 @@ static void update_field_dependencies(THD *thd, Field *field, TABLE *table) other_bitmap= table->read_set; } + /* + The test-and-set mechanism in the bitmap is not reliable during + multi-UPDATE statements under MARK_COLUMNS_READ mode + (thd->mark_used_columns == MARK_COLUMNS_READ), as this bitmap contains + only those columns that are used in the SET clause. I.e they are being + set here. See multi_update::prepare() + */ if (bitmap_fast_test_and_set(current_bitmap, field->field_index)) { if (thd->mark_used_columns == MARK_COLUMNS_WRITE) @@ -6332,7 +6341,7 @@ find_field_in_tables(THD *thd, Item_ident *item, (report_error == REPORT_ALL_ERRORS || report_error == REPORT_EXCEPT_NON_UNIQUE)) { - char buff[NAME_LEN*2+1]; + char buff[NAME_LEN*2 + 2]; if (db && db[0]) { strxnmov(buff,sizeof(buff)-1,db,".",table_name,NullS); @@ -6405,8 +6414,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter, (and not an item that happens to have a name). */ bool is_ref_by_name= 0; - uint unaliased_counter; - LINT_INIT(unaliased_counter); // Dependent on found_unaliased + uint unaliased_counter= 0; *resolution= NOT_RESOLVED; @@ -7431,7 +7439,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, thd->lex->current_select->cur_pos_in_select_list= 0; while ((item= it++)) { - if (!item->fixed && item->fix_fields(thd, it.ref()) || + if ((!item->fixed && item->fix_fields(thd, it.ref())) || (item= *(it.ref()))->check_cols(1)) { thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; @@ -7745,8 +7753,8 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, DBUG_ASSERT(tables->is_leaf_for_name_resolution()); - if (table_name && my_strcasecmp(table_alias_charset, table_name, - tables->alias) || + if ((table_name && my_strcasecmp(table_alias_charset, table_name, + tables->alias)) || (db_name && strcmp(tables->db,db_name))) continue; @@ -7777,8 +7785,8 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, information_schema table, or a nested table reference. See the comment for TABLE_LIST. */ - if (!(table && !tables->view && (table->grant.privilege & SELECT_ACL) || - tables->view && (tables->grant.privilege & SELECT_ACL)) && + if (!((table && !tables->view && (table->grant.privilege & SELECT_ACL)) || + (tables->view && (tables->grant.privilege & SELECT_ACL))) && !any_privileges) { field_iterator.set(tables); @@ -7832,7 +7840,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, */ if (any_privileges) { - DBUG_ASSERT(tables->field_translation == NULL && table || + DBUG_ASSERT((tables->field_translation == NULL && table) || tables->is_natural_join); DBUG_ASSERT(item->type() == Item::FIELD_ITEM); Item_field *fld= (Item_field*) item; @@ -7971,7 +7979,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, if (*conds) { thd->where="where clause"; - if (!(*conds)->fixed && (*conds)->fix_fields(thd, conds) || + if ((!(*conds)->fixed && (*conds)->fix_fields(thd, conds)) || (*conds)->check_cols(1)) goto err_no_arena; } @@ -7991,8 +7999,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, { /* Make a join an a expression */ thd->where="on clause"; - if (!embedded->on_expr->fixed && - embedded->on_expr->fix_fields(thd, &embedded->on_expr) || + if ((!embedded->on_expr->fixed && + embedded->on_expr->fix_fields(thd, &embedded->on_expr)) || embedded->on_expr->check_cols(1)) goto err_no_arena; select_lex->cond_count++; @@ -8147,8 +8155,8 @@ fill_record_n_invoke_before_triggers(THD *thd, List<Item> &fields, enum trg_event_type event) { return (fill_record(thd, fields, values, ignore_errors) || - triggers && triggers->process_triggers(thd, event, - TRG_ACTION_BEFORE, TRUE)); + (triggers && triggers->process_triggers(thd, event, + TRG_ACTION_BEFORE, TRUE))); } @@ -8242,8 +8250,8 @@ fill_record_n_invoke_before_triggers(THD *thd, Field **ptr, enum trg_event_type event) { return (fill_record(thd, ptr, values, ignore_errors) || - triggers && triggers->process_triggers(thd, event, - TRG_ACTION_BEFORE, TRUE)); + (triggers && triggers->process_triggers(thd, event, + TRG_ACTION_BEFORE, TRUE))); } diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 32faeae9dcc..df19fd05417 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -352,11 +352,6 @@ TODO list: #define RW_UNLOCK(M) {DBUG_PRINT("lock", ("rwlock unlock 0x%lx",(ulong)(M))); \ if (!rw_unlock(M)) DBUG_PRINT("lock", ("rwlock unlock ok")); \ else DBUG_PRINT("lock", ("rwlock unlock FAILED %d", errno)); } -#define STRUCT_LOCK(M) {DBUG_PRINT("lock", ("%d struct lock...",__LINE__)); \ - pthread_mutex_lock(M);DBUG_PRINT("lock", ("struct lock OK"));} -#define STRUCT_UNLOCK(M) { \ - DBUG_PRINT("lock", ("%d struct unlock...",__LINE__)); \ - pthread_mutex_unlock(M);DBUG_PRINT("lock", ("struct unlock OK"));} #define BLOCK_LOCK_WR(B) {DBUG_PRINT("lock", ("%d LOCK_WR 0x%lx",\ __LINE__,(ulong)(B))); \ B->query()->lock_writing();} @@ -403,8 +398,6 @@ static void debug_wait_for_kill(const char *info) #define RW_WLOCK(M) rw_wrlock(M) #define RW_RLOCK(M) rw_rdlock(M) #define RW_UNLOCK(M) rw_unlock(M) -#define STRUCT_LOCK(M) pthread_mutex_lock(M) -#define STRUCT_UNLOCK(M) pthread_mutex_unlock(M) #define BLOCK_LOCK_WR(B) B->query()->lock_writing() #define BLOCK_LOCK_RD(B) B->query()->lock_reading() #define BLOCK_UNLOCK_WR(B) B->query()->unlock_writing() @@ -420,6 +413,140 @@ TYPELIB query_cache_type_typelib= /** + Serialize access to the query cache. + If the lock cannot be granted the thread hangs in a conditional wait which + is signalled on each unlock. + + The lock attempt will also fail without wait if lock_and_suspend() is in + effect by another thread. This enables a quick path in execution to skip waits + when the outcome is known. + + @return + @retval FALSE An exclusive lock was taken + @retval TRUE The locking attempt failed +*/ + +bool Query_cache::try_lock(void) +{ + bool interrupt= FALSE; + DBUG_ENTER("Query_cache::try_lock"); + + pthread_mutex_lock(&structure_guard_mutex); + while (1) + { + if (m_cache_lock_status == Query_cache::UNLOCKED) + { + m_cache_lock_status= Query_cache::LOCKED; +#ifndef DBUG_OFF + THD *thd= current_thd; + if (thd) + m_cache_lock_thread_id= thd->thread_id; +#endif + break; + } + else if (m_cache_lock_status == Query_cache::LOCKED_NO_WAIT) + { + /* + If query cache is protected by a LOCKED_NO_WAIT lock this thread + should avoid using the query cache as it is being evicted. + */ + interrupt= TRUE; + break; + } + else + { + DBUG_ASSERT(m_cache_lock_status == Query_cache::LOCKED); + pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex); + } + } + pthread_mutex_unlock(&structure_guard_mutex); + + DBUG_RETURN(interrupt); +} + + +/** + Serialize access to the query cache. + If the lock cannot be granted the thread hangs in a conditional wait which + is signalled on each unlock. + + This method also suspends the query cache so that other threads attempting to + lock the cache with try_lock() will fail directly without waiting. + + It is used by all methods which flushes or destroys the whole cache. + */ + +void Query_cache::lock_and_suspend(void) +{ + DBUG_ENTER("Query_cache::lock_and_suspend"); + + pthread_mutex_lock(&structure_guard_mutex); + while (m_cache_lock_status != Query_cache::UNLOCKED) + pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex); + m_cache_lock_status= Query_cache::LOCKED_NO_WAIT; +#ifndef DBUG_OFF + THD *thd= current_thd; + if (thd) + m_cache_lock_thread_id= thd->thread_id; +#endif + /* Wake up everybody, a whole cache flush is starting! */ + pthread_cond_broadcast(&COND_cache_status_changed); + pthread_mutex_unlock(&structure_guard_mutex); + + DBUG_VOID_RETURN; +} + +/** + Serialize access to the query cache. + If the lock cannot be granted the thread hangs in a conditional wait which + is signalled on each unlock. + + It is used by all methods which invalidates one or more tables. + */ + +void Query_cache::lock(void) +{ + DBUG_ENTER("Query_cache::lock"); + + pthread_mutex_lock(&structure_guard_mutex); + while (m_cache_lock_status != Query_cache::UNLOCKED) + pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex); + m_cache_lock_status= Query_cache::LOCKED; +#ifndef DBUG_OFF + THD *thd= current_thd; + if (thd) + m_cache_lock_thread_id= thd->thread_id; +#endif + pthread_mutex_unlock(&structure_guard_mutex); + + DBUG_VOID_RETURN; +} + + +/** + Set the query cache to UNLOCKED and signal waiting threads. +*/ + +void Query_cache::unlock(void) +{ + DBUG_ENTER("Query_cache::unlock"); + pthread_mutex_lock(&structure_guard_mutex); +#ifndef DBUG_OFF + THD *thd= current_thd; + if (thd) + DBUG_ASSERT(m_cache_lock_thread_id == thd->thread_id); +#endif + DBUG_ASSERT(m_cache_lock_status == Query_cache::LOCKED || + m_cache_lock_status == Query_cache::LOCKED_NO_WAIT); + m_cache_lock_status= Query_cache::UNLOCKED; + DBUG_PRINT("Query_cache",("Sending signal")); + pthread_cond_signal(&COND_cache_status_changed); + pthread_mutex_unlock(&structure_guard_mutex); + DBUG_VOID_RETURN; +} + + +/** Helper function for determine if a SELECT statement has a SQL_NO_CACHE directive. @@ -713,14 +840,8 @@ void query_cache_insert(NET *net, const char *packet, ulong length) DBUG_EXECUTE_IF("wait_in_query_cache_insert", debug_wait_for_kill("wait_in_query_cache_insert"); ); - STRUCT_LOCK(&query_cache.structure_guard_mutex); - bool interrupt; - query_cache.wait_while_table_flush_is_in_progress(&interrupt); - if (interrupt) - { - STRUCT_UNLOCK(&query_cache.structure_guard_mutex); + if (query_cache.try_lock()) DBUG_VOID_RETURN; - } Query_cache_block *query_block= (Query_cache_block*)net->query_cache_query; if (!query_block) @@ -729,7 +850,7 @@ void query_cache_insert(NET *net, const char *packet, ulong length) We lost the writer and the currently processed query has been invalidated; there is nothing left to do. */ - STRUCT_UNLOCK(&query_cache.structure_guard_mutex); + query_cache.unlock(); DBUG_VOID_RETURN; } @@ -755,7 +876,7 @@ void query_cache_insert(NET *net, const char *packet, ulong length) query_cache.free_query(query_block); query_cache.refused++; // append_result_data no success => we need unlock - STRUCT_UNLOCK(&query_cache.structure_guard_mutex); + query_cache.unlock(); DBUG_VOID_RETURN; } @@ -777,14 +898,8 @@ void query_cache_abort(NET *net) if (net->query_cache_query == 0) DBUG_VOID_RETURN; - STRUCT_LOCK(&query_cache.structure_guard_mutex); - bool interrupt; - query_cache.wait_while_table_flush_is_in_progress(&interrupt); - if (interrupt) - { - STRUCT_UNLOCK(&query_cache.structure_guard_mutex); + if (query_cache.try_lock()) DBUG_VOID_RETURN; - } /* While we were waiting another thread might have changed the status @@ -803,8 +918,7 @@ void query_cache_abort(NET *net) DBUG_EXECUTE("check_querycache",query_cache.check_integrity(1);); } - STRUCT_UNLOCK(&query_cache.structure_guard_mutex); - + query_cache.unlock(); DBUG_VOID_RETURN; } @@ -832,15 +946,8 @@ void query_cache_end_of_result(THD *thd) emb_count_querycache_size(thd)); #endif - STRUCT_LOCK(&query_cache.structure_guard_mutex); - - bool interrupt; - query_cache.wait_while_table_flush_is_in_progress(&interrupt); - if (interrupt) - { - STRUCT_UNLOCK(&query_cache.structure_guard_mutex); + if (query_cache.try_lock()) DBUG_VOID_RETURN; - } query_block= ((Query_cache_block*) thd->net.query_cache_query); if (query_block) @@ -869,10 +976,9 @@ void query_cache_end_of_result(THD *thd) */ DBUG_ASSERT(0); query_cache.free_query(query_block); - STRUCT_UNLOCK(&query_cache.structure_guard_mutex); + query_cache.unlock(); DBUG_VOID_RETURN; } - last_result_block= header->result()->prev; allign_size= ALIGN_SIZE(last_result_block->used); len= max(query_cache.min_allocation_unit, allign_size); @@ -885,13 +991,11 @@ void query_cache_end_of_result(THD *thd) /* Drop the writer. */ header->writer(0); thd->net.query_cache_query= 0; - BLOCK_UNLOCK_WR(query_block); DBUG_EXECUTE("check_querycache",query_cache.check_integrity(1);); } - - STRUCT_UNLOCK(&query_cache.structure_guard_mutex); + query_cache.unlock(); DBUG_VOID_RETURN; } @@ -950,11 +1054,7 @@ ulong Query_cache::resize(ulong query_cache_size_arg) query_cache_size_arg)); DBUG_ASSERT(initialized); - STRUCT_LOCK(&structure_guard_mutex); - while (is_flushing()) - pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex); - m_cache_status= Query_cache::FLUSH_IN_PROGRESS; - STRUCT_UNLOCK(&structure_guard_mutex); + lock_and_suspend(); /* Wait for all readers and writers to exit. When the list of all queries @@ -986,13 +1086,10 @@ ulong Query_cache::resize(ulong query_cache_size_arg) query_cache_size= query_cache_size_arg; new_query_cache_size= init_cache(); - STRUCT_LOCK(&structure_guard_mutex); - m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS; - pthread_cond_signal(&COND_cache_status_changed); if (new_query_cache_size) DBUG_EXECUTE("check_querycache",check_integrity(1);); - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); DBUG_RETURN(new_query_cache_size); } @@ -1089,15 +1186,16 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", */ ha_release_temporary_latches(thd); - STRUCT_LOCK(&structure_guard_mutex); - if (query_cache_size == 0 || is_flushing()) + /* + A table- or a full flush operation can potentially take a long time to + finish. We choose not to wait for them and skip caching statements + instead. + */ + if (try_lock()) + DBUG_VOID_RETURN; + if (query_cache_size == 0) { - /* - A table- or a full flush operation can potentially take a long time to - finish. We choose not to wait for them and skip caching statements - instead. - */ - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); DBUG_VOID_RETURN; } DUMP(this); @@ -1105,7 +1203,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", if (ask_handler_allowance(thd, tables_used)) { refused++; - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); DBUG_VOID_RETURN; } @@ -1153,7 +1251,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", DBUG_PRINT("qcache", ("insertion in query hash")); header->unlock_n_destroy(); free_memory_block(query_block); - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); goto end; } if (!register_all_tables(query_block, tables_used, local_tables)) @@ -1163,7 +1261,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", hash_delete(&queries, (uchar *) query_block); header->unlock_n_destroy(); free_memory_block(query_block); - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); goto end; } double_linked_list_simple_include(query_block, &queries_blocks); @@ -1173,7 +1271,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", header->writer(net); header->tables_type(tables_type); - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); // init_n_lock make query block locked BLOCK_UNLOCK_WR(query_block); @@ -1182,7 +1280,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", { // We have not enough memory to store query => do nothing refused++; - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); DBUG_PRINT("warning", ("Can't allocate query")); } } @@ -1190,7 +1288,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", { // Another thread is processing the same query => do nothing refused++; - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); DBUG_PRINT("qcache", ("Another thread process same query")); } } @@ -1282,18 +1380,17 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) } } - STRUCT_LOCK(&structure_guard_mutex); + /* + Try to obtain an exclusive lock on the query cache. If the cache is + disabled or if a full cache flush is in progress, the attempt to + get the lock is aborted. + */ + if (try_lock()) + goto err; if (query_cache_size == 0) goto err_unlock; - if (is_flushing()) - { - /* Return; Query cache is temporarily disabled while we flush. */ - DBUG_PRINT("qcache",("query cache disabled")); - goto err_unlock; - } - /* Check that we haven't forgot to reset the query cache variables; make sure there are no attached query cache writer to this thread. @@ -1427,7 +1524,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", DBUG_PRINT("qcache", ("Temporary table detected: '%s.%s'", table_list.db, table_list.alias)); - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); /* We should not store result of this query because it contain temporary tables => assign following variable to make check @@ -1448,7 +1545,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", DBUG_PRINT("qcache", ("probably no SELECT access to %s.%s => return to normal processing", table_list.db, table_list.alias)); - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); thd->lex->safe_to_cache_query=0; // Don't try to cache this BLOCK_UNLOCK_RD(query_block); DBUG_RETURN(-1); // Privilege error @@ -1491,7 +1588,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", } move_to_query_list_end(query_block); hits++; - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); /* Send cached result to client @@ -1530,7 +1627,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", DBUG_RETURN(1); // Result sent to client err_unlock: - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); err: DBUG_RETURN(0); // Query was not cached } @@ -1651,47 +1748,6 @@ void Query_cache::invalidate(THD *thd, const char *key, uint32 key_length, /** - Synchronize the thread with any flushing operations. - - This helper function is called whenever a thread needs to operate on the - query cache structure (example: during invalidation). If a table flush is in - progress this function will wait for it to stop. If a full flush is in - progress, the function will set the interrupt parameter to indicate that the - current operation is redundant and should be interrupted. - - @param[out] interrupt This out-parameter will be set to TRUE if the calling - function is redundant and should be interrupted. - - @return If the interrupt-parameter is TRUE then m_cache_status is set to - NO_FLUSH_IN_PROGRESS. If the interrupt-parameter is FALSE then - m_cache_status is set to FLUSH_IN_PROGRESS. - The structure_guard_mutex will in any case be locked. -*/ - -void Query_cache::wait_while_table_flush_is_in_progress(bool *interrupt) -{ - while (is_flushing()) - { - /* - If there already is a full flush in progress query cache isn't enabled - and additional flushes are redundant; just return instead. - */ - if (m_cache_status == Query_cache::FLUSH_IN_PROGRESS) - { - *interrupt= TRUE; - return; - } - /* - If a table flush is in progress; wait on cache status to change. - */ - if (m_cache_status == Query_cache::TABLE_FLUSH_IN_PROGRESS) - pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex); - } - *interrupt= FALSE; -} - - -/** Remove all cached queries that uses the given database. */ @@ -1700,14 +1756,11 @@ void Query_cache::invalidate(char *db) bool restart= FALSE; DBUG_ENTER("Query_cache::invalidate (db)"); - STRUCT_LOCK(&structure_guard_mutex); - bool interrupt; - wait_while_table_flush_is_in_progress(&interrupt); - if (interrupt) - { - STRUCT_UNLOCK(&structure_guard_mutex); - return; - } + /* + Lock the query cache and queue all invalidation attempts to avoid + the risk of a race between invalidation, cache inserts and flushes. + */ + lock(); THD *thd= current_thd; @@ -1763,7 +1816,7 @@ void Query_cache::invalidate(char *db) } while (restart); } // end if( tables_blocks ) } - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); DBUG_VOID_RETURN; } @@ -1787,7 +1840,10 @@ void Query_cache::invalidate_by_MyISAM_filename(const char *filename) void Query_cache::flush() { DBUG_ENTER("Query_cache::flush"); - STRUCT_LOCK(&structure_guard_mutex); + DBUG_EXECUTE_IF("wait_in_query_cache_flush1", + debug_wait_for_kill("wait_in_query_cache_flush1");); + + lock_and_suspend(); if (query_cache_size > 0) { DUMP(this); @@ -1796,7 +1852,7 @@ void Query_cache::flush() } DBUG_EXECUTE("check_querycache",query_cache.check_integrity(1);); - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); DBUG_VOID_RETURN; } @@ -1815,18 +1871,16 @@ void Query_cache::pack(ulong join_limit, uint iteration_limit) { DBUG_ENTER("Query_cache::pack"); - bool interrupt; - STRUCT_LOCK(&structure_guard_mutex); - wait_while_table_flush_is_in_progress(&interrupt); - if (interrupt) - { - STRUCT_UNLOCK(&structure_guard_mutex); + /* + If the entire qc is being invalidated we can bail out early + instead of waiting for the lock. + */ + if (try_lock()) DBUG_VOID_RETURN; - } if (query_cache_size == 0) { - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); DBUG_VOID_RETURN; } @@ -1836,7 +1890,7 @@ void Query_cache::pack(ulong join_limit, uint iteration_limit) pack_cache(); } while ((++i < iteration_limit) && join_results(join_limit)); - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); DBUG_VOID_RETURN; } @@ -1851,9 +1905,9 @@ void Query_cache::destroy() else { /* Underlying code expects the lock. */ - STRUCT_LOCK(&structure_guard_mutex); + lock_and_suspend(); free_cache(); - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); pthread_cond_destroy(&COND_cache_status_changed); pthread_mutex_destroy(&structure_guard_mutex); @@ -1872,7 +1926,7 @@ void Query_cache::init() DBUG_ENTER("Query_cache::init"); pthread_mutex_init(&structure_guard_mutex,MY_MUTEX_INIT_FAST); pthread_cond_init(&COND_cache_status_changed, NULL); - m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS; + m_cache_lock_status= Query_cache::UNLOCKED; initialized = 1; DBUG_VOID_RETURN; } @@ -2112,23 +2166,9 @@ void Query_cache::free_cache() void Query_cache::flush_cache() { - /* - If there is flush in progress, wait for it to finish, and then do - our flush. This is necessary because something could be added to - the cache before we acquire the lock again, and some code (like - Query_cache::free_cache()) depends on the fact that after the - flush the cache is empty. - */ - while (is_flushing()) - pthread_cond_wait(&COND_cache_status_changed, &structure_guard_mutex); - - /* - Setting 'FLUSH_IN_PROGRESS' will prevent other threads from using - the cache while we are in the middle of the flush, and we release - the lock so that other threads won't block. - */ - m_cache_status= Query_cache::FLUSH_IN_PROGRESS; - STRUCT_UNLOCK(&structure_guard_mutex); + + DBUG_EXECUTE_IF("wait_in_query_cache_flush2", + debug_wait_for_kill("wait_in_query_cache_flush2");); my_hash_reset(&queries); while (queries_blocks != 0) @@ -2136,10 +2176,6 @@ void Query_cache::flush_cache() BLOCK_LOCK_WR(queries_blocks); free_query_internal(queries_blocks); } - - STRUCT_LOCK(&structure_guard_mutex); - m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS; - pthread_cond_signal(&COND_cache_status_changed); } /* @@ -2319,10 +2355,6 @@ Query_cache::write_block_data(ulong data_len, uchar* data, } -/* - On success STRUCT_UNLOCK(&query_cache.structure_guard_mutex) will be done. -*/ - my_bool Query_cache::append_result_data(Query_cache_block **current_block, ulong data_len, uchar* data, @@ -2342,10 +2374,6 @@ Query_cache::append_result_data(Query_cache_block **current_block, if (*current_block == 0) { DBUG_PRINT("qcache", ("allocated first result data block %lu", data_len)); - /* - STRUCT_UNLOCK(&structure_guard_mutex) Will be done by - write_result_data if success; - */ DBUG_RETURN(write_result_data(current_block, data_len, data, query_block, Query_cache_block::RES_BEG)); } @@ -2376,10 +2404,6 @@ Query_cache::append_result_data(Query_cache_block **current_block, DBUG_PRINT("qcache", ("allocate new block for %lu bytes", data_len-last_block_free_space)); Query_cache_block *new_block = 0; - /* - On success STRUCT_UNLOCK(&structure_guard_mutex) will be done - by the next call - */ success = write_result_data(&new_block, data_len-last_block_free_space, (uchar*)(((uchar*)data)+last_block_free_space), query_block, @@ -2394,7 +2418,7 @@ Query_cache::append_result_data(Query_cache_block **current_block, else { // It is success (nobody can prevent us write data) - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); } // Now finally write data to the last block @@ -2432,7 +2456,7 @@ my_bool Query_cache::write_result_data(Query_cache_block **result_block, if (success) { // It is success (nobody can prevent us write data) - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); uint headers_len = (ALIGN_SIZE(sizeof(Query_cache_block)) + ALIGN_SIZE(sizeof(Query_cache_result))); #ifndef EMBEDDED_LIBRARY @@ -2590,36 +2614,23 @@ void Query_cache::invalidate_table(THD *thd, TABLE *table) void Query_cache::invalidate_table(THD *thd, uchar * key, uint32 key_length) { - bool interrupt; - STRUCT_LOCK(&structure_guard_mutex); - wait_while_table_flush_is_in_progress(&interrupt); - if (interrupt) - { - STRUCT_UNLOCK(&structure_guard_mutex); - return; - } + DBUG_EXECUTE_IF("wait_in_query_cache_invalidate1", + debug_wait_for_kill("wait_in_query_cache_invalidate1"); ); /* - Setting 'TABLE_FLUSH_IN_PROGRESS' will temporarily disable the cache - so that structural changes to cache won't block the entire server. - However, threads requesting to change the query cache will still have - to wait for the flush to finish. + Lock the query cache and queue all invalidation attempts to avoid + the risk of a race between invalidation, cache inserts and flushes. */ - m_cache_status= Query_cache::TABLE_FLUSH_IN_PROGRESS; - STRUCT_UNLOCK(&structure_guard_mutex); + lock(); + + DBUG_EXECUTE_IF("wait_in_query_cache_invalidate2", + debug_wait_for_kill("wait_in_query_cache_invalidate2"); ); + if (query_cache_size > 0) invalidate_table_internal(thd, key, key_length); - STRUCT_LOCK(&structure_guard_mutex); - m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS; - - /* - net_real_write might be waiting on a change on the m_cache_status - variable. - */ - pthread_cond_signal(&COND_cache_status_changed); - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); } @@ -2628,7 +2639,7 @@ void Query_cache::invalidate_table(THD *thd, uchar * key, uint32 key_length) The caller must ensure that no other thread is trying to work with the query cache when this function is executed. - @pre structure_guard_mutex is acquired or TABLE_FLUSH_IN_PROGRESS is set. + @pre structure_guard_mutex is acquired or LOCKED is set. */ void @@ -2646,7 +2657,7 @@ Query_cache::invalidate_table_internal(THD *thd, uchar *key, uint32 key_length) /** Invalidate a linked list of query cache blocks. - Each block tries to aquire a block level lock before + Each block tries to acquire a block level lock before free_query is a called. This function will in turn affect related table- and result-blocks. @@ -4170,10 +4181,7 @@ my_bool Query_cache::check_integrity(bool locked) DBUG_ENTER("check_integrity"); if (!locked) - STRUCT_LOCK(&structure_guard_mutex); - - while (is_flushing()) - pthread_cond_wait(&COND_cache_status_changed,&structure_guard_mutex); + lock_and_suspend(); if (hash_check(&queries)) { @@ -4422,7 +4430,7 @@ my_bool Query_cache::check_integrity(bool locked) } DBUG_ASSERT(result == 0); if (!locked) - STRUCT_UNLOCK(&structure_guard_mutex); + unlock(); DBUG_RETURN(result); } diff --git a/sql/sql_cache.h b/sql/sql_cache.h index f2c33eff614..777ddd39280 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -272,12 +272,12 @@ public: private: +#ifndef DBUG_OFF + my_thread_id m_cache_lock_thread_id; +#endif pthread_cond_t COND_cache_status_changed; - - enum Cache_status { NO_FLUSH_IN_PROGRESS, FLUSH_IN_PROGRESS, - TABLE_FLUSH_IN_PROGRESS }; - - Cache_status m_cache_status; + enum Cache_lock_status { UNLOCKED, LOCKED_NO_WAIT, LOCKED }; + Cache_lock_status m_cache_lock_status; void free_query_internal(Query_cache_block *point); void invalidate_table_internal(THD *thd, uchar *key, uint32 key_length); @@ -380,8 +380,6 @@ protected: Query_cache_block *pprev); my_bool join_results(ulong join_limit); - void wait_while_table_flush_is_in_progress(bool *interrupt); - /* Following function control structure_guard_mutex by themself or don't need structure_guard_mutex @@ -469,11 +467,6 @@ protected: friend void query_cache_end_of_result(THD *thd); friend void query_cache_abort(NET *net); - bool is_flushing(void) - { - return (m_cache_status != Query_cache::NO_FLUSH_IN_PROGRESS); - } - /* The following functions are only used when debugging We don't protect these with ifndef DBUG_OFF to not have to recompile @@ -491,6 +484,11 @@ protected: Query_cache_block_table * point, const char *name); my_bool in_blocks(Query_cache_block * point); + + bool try_lock(void); + void lock(void); + void lock_and_suspend(void); + void unlock(void); }; extern Query_cache query_cache; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b73822f5a48..48ddb42f0d8 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -27,6 +27,7 @@ #include "mysql_priv.h" #include "rpl_rli.h" +#include "rpl_filter.h" #include "rpl_record.h" #include "slave.h" #include <my_bitmap.h> @@ -546,6 +547,7 @@ THD::THD() first_successful_insert_id_in_prev_stmt_for_binlog(0), first_successful_insert_id_in_cur_stmt(0), stmt_depends_on_first_successful_insert_id_in_prev_stmt(FALSE), + examined_row_count(0), global_read_lock(0), is_fatal_error(0), transaction_rollback_request(0), @@ -590,7 +592,7 @@ THD::THD() // Must be reset to handle error with THD's created for init of mysqld lex->current_select= 0; start_time=(time_t) 0; - start_utime= 0L; + start_utime= prior_thr_create_utime= 0L; utime_after_lock= 0L; current_linfo = 0; slave_thread = 0; @@ -674,31 +676,40 @@ THD::THD() void THD::push_internal_handler(Internal_error_handler *handler) { - /* - TODO: The current implementation is limited to 1 handler at a time only. - THD and sp_rcontext need to be modified to use a common handler stack. - */ - DBUG_ASSERT(m_internal_handler == NULL); - m_internal_handler= handler; + if (m_internal_handler) + { + handler->m_prev_internal_handler= m_internal_handler; + m_internal_handler= handler; + } + else + { + m_internal_handler= handler; + } } bool THD::handle_error(uint sql_errno, const char *message, MYSQL_ERROR::enum_warning_level level) { - if (m_internal_handler) + if (!m_internal_handler) + return FALSE; + + for (Internal_error_handler *error_handler= m_internal_handler; + error_handler; + error_handler= m_internal_handler->m_prev_internal_handler) { - return m_internal_handler->handle_error(sql_errno, message, level, this); + if (error_handler->handle_error(sql_errno, message, level, this)) + return TRUE; } - return FALSE; // 'FALSE', as per coding style + return FALSE; } void THD::pop_internal_handler() { DBUG_ASSERT(m_internal_handler != NULL); - m_internal_handler= NULL; + m_internal_handler= m_internal_handler->m_prev_internal_handler; } extern "C" @@ -2599,7 +2610,7 @@ bool select_dumpvar::send_data(List<Item> &items) { Item_func_set_user_var *suv= new Item_func_set_user_var(mv->s, item); suv->fix_fields(thd, 0); - suv->check(0); + suv->save_item_result(item); suv->update(); } } @@ -3649,7 +3660,7 @@ show_query_type(THD::enum_binlog_query_type qtype) */ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, ulong query_len, bool is_trans, bool suppress_use, - THD::killed_state killed_status_arg) + int errcode) { DBUG_ENTER("THD::binlog_query"); DBUG_PRINT("enter", ("qtype: %s query: '%s'", @@ -3674,7 +3685,8 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, we should print a warning. */ if (sql_log_bin_toplevel && lex->is_stmt_unsafe() && - variables.binlog_format == BINLOG_FORMAT_STMT) + variables.binlog_format == BINLOG_FORMAT_STMT && + binlog_filter->db_ok(this->db)) { /* A warning can be elevated a error when STRICT sql mode. @@ -3716,7 +3728,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, */ { Query_log_event qinfo(this, query_arg, query_len, is_trans, suppress_use, - killed_status_arg); + errcode); qinfo.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F; /* Binlog table maps will be irrelevant after a Query_log_event diff --git a/sql/sql_class.h b/sql/sql_class.h index ce4524fb982..36e696f2da6 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1036,7 +1036,10 @@ show_system_thread(enum_thread_type thread) class Internal_error_handler { protected: - Internal_error_handler() {} + Internal_error_handler() : + m_prev_internal_handler(NULL) + {} + virtual ~Internal_error_handler() {} public: @@ -1069,6 +1072,28 @@ public: const char *message, MYSQL_ERROR::enum_warning_level level, THD *thd) = 0; +private: + Internal_error_handler *m_prev_internal_handler; + friend class THD; +}; + + +/** + Implements the trivial error handler which cancels all error states + and prevents an SQLSTATE to be set. +*/ + +class Dummy_error_handler : public Internal_error_handler +{ +public: + bool handle_error(uint sql_errno, + const char *message, + MYSQL_ERROR::enum_warning_level level, + THD *thd) + { + /* Ignore error */ + return TRUE; + } }; @@ -1345,7 +1370,8 @@ public: /* remote (peer) port */ uint16 peer_port; time_t start_time, user_time; - ulonglong connect_utime, thr_create_utime; // track down slow pthread_create + // track down slow pthread_create + ulonglong prior_thr_create_utime, thr_create_utime; ulonglong start_utime, utime_after_lock; thr_lock_type update_lock_default; @@ -1439,6 +1465,14 @@ public: { changed_tables= 0; savepoints= 0; + /* + If rm_error is raised, it means that this piece of a distributed + transaction has failed and must be rolled back. But the user must + rollback it explicitly, so don't start a new distributed XA until + then. + */ + if (!xid_state.rm_error) + xid_state.xid.null(); #ifdef USING_TRANSACTIONS free_root(&mem_root,MYF(MY_KEEP_PREALLOC)); #endif @@ -1889,7 +1923,7 @@ public: int binlog_query(enum_binlog_query_type qtype, char const *query, ulong query_len, bool is_trans, bool suppress_use, - THD::killed_state killed_err_arg= THD::KILLED_NO_VALUE); + int errcode); #endif /* @@ -2210,6 +2244,9 @@ public: thd_scheduler scheduler; public: + inline Internal_error_handler *get_internal_handler() + { return m_internal_handler; } + /** Add an internal error handler to the thread execution context. @param handler the exception handler to add diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index e4d7cf6feb5..98574a07a4e 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1074,8 +1074,8 @@ static void prepare_new_connection_state(THD* thd) pthread_handler_t handle_one_connection(void *arg) { THD *thd= (THD*) arg; - ulong launch_time= (ulong) ((thd->thr_create_utime= my_micro_time()) - - thd->connect_utime); + + thd->thr_create_utime= my_micro_time(); if (thread_scheduler.init_new_connection_thread()) { @@ -1084,8 +1084,20 @@ pthread_handler_t handle_one_connection(void *arg) thread_scheduler.end_thread(thd,0); return 0; } - if (launch_time >= slow_launch_time*1000000L) - statistic_increment(slow_launch_threads,&LOCK_status); + + /* + If a thread was created to handle this connection: + increment slow_launch_threads counter if it took more than + slow_launch_time seconds to create the thread. + */ + if (thd->prior_thr_create_utime) + { + ulong launch_time= (ulong) (thd->thr_create_utime - + thd->prior_thr_create_utime); + if (launch_time >= slow_launch_time*1000000L) + statistic_increment(slow_launch_threads, &LOCK_status); + thd->prior_thr_create_utime= 0; + } /* handle_one_connection() is normally the only way a thread would diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 5a266c3fac9..98d17fdd318 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -181,8 +181,7 @@ uchar* dboptions_get_key(my_dbopt_t *opt, size_t *length, static inline void write_to_binlog(THD *thd, char *query, uint q_len, char *db, uint db_len) { - Query_log_event qinfo(thd, query, q_len, 0, 0, THD::NOT_KILLED); - qinfo.error_code= 0; + Query_log_event qinfo(thd, query, q_len, 0, 0, 0); qinfo.db= db; qinfo.db_len= db_len; mysql_bin_log.write(&qinfo); @@ -538,13 +537,13 @@ err1: bool load_db_opt_by_name(THD *thd, const char *db_name, HA_CREATE_INFO *db_create_info) { - char db_opt_path[FN_REFLEN]; + char db_opt_path[FN_REFLEN + 1]; /* Pass an empty file name, and the database options file name as extension to avoid table name to file name encoding. */ - (void) build_table_filename(db_opt_path, sizeof(db_opt_path), + (void) build_table_filename(db_opt_path, sizeof(db_opt_path) - 1, db_name, "", MY_DB_OPT_FILE, 0); return load_db_opt(thd, db_opt_path, db_create_info); @@ -646,7 +645,7 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); /* Check directory */ - path_len= build_table_filename(path, sizeof(path), db, "", "", 0); + path_len= build_table_filename(path, sizeof(path) - 1, db, "", "", 0); path[path_len-1]= 0; // Remove last '/' from path if (my_stat(path,&stat_info,MYF(0))) @@ -723,8 +722,9 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, if (mysql_bin_log.is_open()) { + int errcode= query_error_code(thd, TRUE); Query_log_event qinfo(thd, query, query_length, 0, - /* suppress_use */ TRUE, THD::NOT_KILLED); + /* suppress_use */ TRUE, errcode); /* Write should use the database being created as the "current @@ -791,7 +791,7 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) We pass MY_DB_OPT_FILE as "extension" to avoid "table name to file name" encoding. */ - build_table_filename(path, sizeof(path), db, "", MY_DB_OPT_FILE, 0); + build_table_filename(path, sizeof(path) - 1, db, "", MY_DB_OPT_FILE, 0); if ((error=write_db_opt(thd, path, create_info))) goto exit; @@ -811,8 +811,9 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) if (mysql_bin_log.is_open()) { + int errcode= query_error_code(thd, TRUE); Query_log_event qinfo(thd, thd->query, thd->query_length, 0, - /* suppress_use */ TRUE, THD::NOT_KILLED); + /* suppress_use */ TRUE, errcode); /* Write should use the database being created as the "current @@ -883,7 +884,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); - length= build_table_filename(path, sizeof(path), db, "", "", 0); + length= build_table_filename(path, sizeof(path) - 1, db, "", "", 0); strmov(path+length, MY_DB_OPT_FILE); // Append db option file name del_dbopt(path); // Remove dboption hash entry path[length]= '\0'; // Remove file name @@ -958,8 +959,9 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) } if (mysql_bin_log.is_open()) { + int errcode= query_error_code(thd, TRUE); Query_log_event qinfo(thd, query, query_length, 0, - /* suppress_use */ TRUE, THD::NOT_KILLED); + /* suppress_use */ TRUE, errcode); /* Write should use the database being created as the "current database" and not the threads current database, which is the @@ -1839,7 +1841,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db) for (uint idx=0 ; idx < nfiles && !thd->killed ; idx++) { FILEINFO *file= dirp->dir_entry + idx; - char *extension, tname[FN_REFLEN]; + char *extension, tname[FN_REFLEN + 1]; LEX_STRING table_str; DBUG_PRINT("info",("Examining: %s", file->name)); @@ -1928,7 +1930,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db) for (uint idx=0 ; idx < nfiles ; idx++) { FILEINFO *file= dirp->dir_entry + idx; - char oldname[FN_REFLEN], newname[FN_REFLEN]; + char oldname[FN_REFLEN + 1], newname[FN_REFLEN + 1]; DBUG_PRINT("info",("Examining: %s", file->name)); /* skiping . and .. and MY_DB_OPT_FILE */ @@ -1958,8 +1960,9 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db) /* Step8: logging */ if (mysql_bin_log.is_open()) { + int errcode= query_error_code(thd, TRUE); Query_log_event qinfo(thd, thd->query, thd->query_length, - 0, TRUE, THD::NOT_KILLED); + 0, TRUE, errcode); thd->clear_error(); mysql_bin_log.write(&qinfo); } @@ -1997,10 +2000,10 @@ exit: bool check_db_dir_existence(const char *db_name) { - char db_dir_path[FN_REFLEN]; + char db_dir_path[FN_REFLEN + 1]; uint db_dir_path_len; - db_dir_path_len= build_table_filename(db_dir_path, sizeof(db_dir_path), + db_dir_path_len= build_table_filename(db_dir_path, sizeof(db_dir_path) - 1, db_name, "", "", 0); if (db_dir_path_len && db_dir_path[db_dir_path_len - 1] == FN_LIBCHAR) diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 1b42e522491..677098d275a 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -389,8 +389,12 @@ cleanup: FALSE : transactional_table; + int errcode= 0; if (error < 0) thd->clear_error(); + else + errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); + /* [binlog]: If 'handler::delete_all_rows()' was called and the storage engine does not inject the rows itself, we replicate @@ -402,9 +406,9 @@ cleanup: */ int log_result= thd->binlog_query(query_type, thd->query, thd->query_length, - is_trans, FALSE, killed_status); + is_trans, FALSE, errcode); - if (log_result && transactional_table) + if (log_result) { error=1; } @@ -582,6 +586,11 @@ int mysql_multi_delete_prepare(THD *thd) } } } + /* + Reset the exclude flag to false so it doesn't interfare + with further calls to unique_table + */ + lex->select_lex.exclude_from_table_unique_test= FALSE; DBUG_RETURN(FALSE); } @@ -617,11 +626,24 @@ multi_delete::initialize_tables(JOIN *join) DBUG_RETURN(1); table_map tables_to_delete_from=0; + delete_while_scanning= 1; for (walk= delete_tables; walk; walk= walk->next_local) + { tables_to_delete_from|= walk->table->map; + if (delete_while_scanning && + unique_table(thd, walk, join->tables_list, false)) + { + /* + If the table we are going to delete from appears + in join, we need to defer delete. So the delete + doesn't interfers with the scaning of results. + */ + delete_while_scanning= 0; + } + } + walk= delete_tables; - delete_while_scanning= 1; for (JOIN_TAB *tab=join->join_tab, *end=join->join_tab+join->tables; tab < end; tab++) @@ -784,7 +806,7 @@ void multi_delete::abort() /* the error was handled or nothing deleted and no side effects return */ if (error_handled || - !thd->transaction.stmt.modified_non_trans_table && !deleted) + (!thd->transaction.stmt.modified_non_trans_table && !deleted)) DBUG_VOID_RETURN; /* Something already deleted so we have to invalidate cache */ @@ -818,9 +840,10 @@ void multi_delete::abort() */ if (mysql_bin_log.is_open()) { + int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query, thd->query_length, - transactional_tables, FALSE); + transactional_tables, FALSE, errcode); } thd->transaction.all.modified_non_trans_table= true; } @@ -961,11 +984,14 @@ bool multi_delete::send_eof() { if (mysql_bin_log.is_open()) { + int errcode= 0; if (local_error == 0) thd->clear_error(); + else + errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); if (thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query, thd->query_length, - transactional_tables, FALSE, killed_status) && + transactional_tables, FALSE, errcode) && !normal_tables) { local_error=1; // Log write failed: roll back the SQL statement @@ -1025,7 +1051,7 @@ static bool mysql_truncate_by_delete(THD *thd, TABLE_LIST *table_list) bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) { HA_CREATE_INFO create_info; - char path[FN_REFLEN]; + char path[FN_REFLEN + 1]; TABLE *table; bool error; uint path_length; @@ -1062,7 +1088,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) goto end; } - path_length= build_table_filename(path, sizeof(path), table_list->db, + path_length= build_table_filename(path, sizeof(path) - 1, table_list->db, table_list->table_name, reg_ext, 0); if (!dont_send_ok) diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 41be98621a6..37adf5c403a 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -179,6 +179,7 @@ exit: { if (thd->is_error() && (thd->main_da.sql_errno() == ER_BAD_FIELD_ERROR || + thd->main_da.sql_errno() == ER_FUNC_INEXISTENT_NAME_COLLISION || thd->main_da.sql_errno() == ER_SP_DOES_NOT_EXIST)) { thd->clear_error(); diff --git a/sql/sql_help.cc b/sql/sql_help.cc index f51ad318568..2818aa5082c 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -526,7 +526,7 @@ int send_variant_2_list(MEM_ROOT *mem_root, Protocol *protocol, String **end= pointers + names->elements; List_iterator<String> it(*names); - for (pos= pointers; pos!=end; (*pos++= it++)); + for (pos= pointers; pos!=end; (*pos++= it++)) ; my_qsort(pointers,names->elements,sizeof(String*),string_ptr_cmp); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 6c27766ec86..104c81ca984 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -301,9 +301,7 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list, List<Item> &update_fields, table_map *map) { TABLE *table= insert_table_list->table; - my_bool timestamp_mark; - - LINT_INIT(timestamp_mark); + my_bool timestamp_mark= 0; if (table->timestamp_field) { @@ -393,7 +391,7 @@ void upgrade_lock_type(THD *thd, thr_lock_type *lock_type, bool is_multi_insert) { if (duplic == DUP_UPDATE || - duplic == DUP_REPLACE && *lock_type == TL_WRITE_CONCURRENT_INSERT) + (duplic == DUP_REPLACE && *lock_type == TL_WRITE_CONCURRENT_INSERT)) { *lock_type= TL_WRITE_DEFAULT; return; @@ -858,11 +856,13 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, */ query_cache_invalidate3(thd, table_list, 1); } - if (changed && error <= 0 || thd->transaction.stmt.modified_non_trans_table - || was_insert_delayed) + if ((changed && error <= 0) || + thd->transaction.stmt.modified_non_trans_table || + was_insert_delayed) { if (mysql_bin_log.is_open()) { + int errcode= 0; if (error <= 0) { /* @@ -877,6 +877,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, /* todo: consider removing */ thd->clear_error(); } + else + errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + /* bug#22725: A query which per-row-loop can not be interrupted with @@ -893,8 +896,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query, thd->query_length, transactional_table, FALSE, - (error>0) ? thd->killed : THD::NOT_KILLED) && - transactional_table) + errcode)) { error=1; } @@ -1114,6 +1116,33 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list, /* + Get extra info for tables we insert into + + @param table table(TABLE object) we insert into, + might be NULL in case of view + @param table(TABLE_LIST object) or view we insert into +*/ + +static void prepare_for_positional_update(TABLE *table, TABLE_LIST *tables) +{ + if (table) + { + if(table->reginfo.lock_type != TL_WRITE_DELAYED) + table->prepare_for_position(); + return; + } + + DBUG_ASSERT(tables->view); + List_iterator<TABLE_LIST> it(*tables->view_tables); + TABLE_LIST *tbl; + while ((tbl= it++)) + prepare_for_positional_update(tbl->table, tbl); + + return; +} + + +/* Prepare items in INSERT statement SYNOPSIS @@ -1262,9 +1291,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, Only call prepare_for_posistion() if we are not performing a DELAYED operation. It will instead be executed by delayed insert thread. */ - if ((duplic == DUP_UPDATE || duplic == DUP_REPLACE) && - (table->reginfo.lock_type != TL_WRITE_DELAYED)) - table->prepare_for_position(); + if (duplic == DUP_UPDATE || duplic == DUP_REPLACE) + prepare_for_positional_update(table, table_list); DBUG_RETURN(FALSE); } @@ -2667,6 +2695,12 @@ bool Delayed_insert::handle_inserts(void) thd.variables.time_zone = row->time_zone; } + /* if the delayed insert was killed, the killed status is + ignored while binlogging */ + int errcode= 0; + if (thd.killed == THD::NOT_KILLED) + errcode= query_error_code(&thd, TRUE); + /* If the query has several rows to insert, only the first row will come here. In row-based binlogging, this means that the first row will be @@ -2677,7 +2711,7 @@ bool Delayed_insert::handle_inserts(void) */ thd.binlog_query(THD::ROW_QUERY_TYPE, row->query.str, row->query.length, - FALSE, FALSE); + FALSE, FALSE, errcode); thd.time_zone_used = backup_time_zone_used; thd.variables.time_zone = backup_time_zone; @@ -3090,7 +3124,10 @@ bool select_insert::send_data(List<Item> &values) store_values(values); thd->count_cuted_fields= CHECK_FIELD_IGNORE; if (thd->is_error()) + { + table->auto_increment_field_not_null= FALSE; DBUG_RETURN(1); + } if (table_list) // Not CREATE ... SELECT { switch (table_list->view_check_option(thd, info.ignore)) { @@ -3101,6 +3138,9 @@ bool select_insert::send_data(List<Item> &values) } } + // Release latches in case bulk insert takes a long time + ha_release_temporary_latches(thd); + error= write_record(thd, table, &info); table->auto_increment_field_not_null= FALSE; @@ -3173,7 +3213,8 @@ bool select_insert::send_eof() table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); - if (changed= (info.copied || info.deleted || info.updated)) + changed= (info.copied || info.deleted || info.updated); + if (changed) { /* We must invalidate the table in the query cache before binlog writing @@ -3194,11 +3235,14 @@ bool select_insert::send_eof() */ if (mysql_bin_log.is_open()) { + int errcode= 0; if (!error) thd->clear_error(); + else + errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query, thd->query_length, - trans_table, FALSE, killed_status); + trans_table, FALSE, errcode); } table->file->ha_release_auto_increment(); @@ -3265,8 +3309,11 @@ void select_insert::abort() { if (thd->transaction.stmt.modified_non_trans_table) { if (mysql_bin_log.is_open()) + { + int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query, thd->query_length, - transactional_table, FALSE); + transactional_table, FALSE, errcode); + } if (!thd->current_stmt_binlog_row_based && !can_rollback_data()) thd->transaction.all.modified_non_trans_table= TRUE; if (changed) @@ -3658,10 +3705,14 @@ select_create::binlog_show_create_table(TABLE **tables, uint count) DBUG_ASSERT(result == 0); /* store_create_info() always return 0 */ if (mysql_bin_log.is_open()) + { + int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); thd->binlog_query(THD::STMT_QUERY_TYPE, query.ptr(), query.length(), /* is_trans */ TRUE, - /* suppress_use */ FALSE); + /* suppress_use */ FALSE, + errcode); + } } void select_create::store_values(List<Item> &values) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index b96ac91679b..444a8ae0736 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -433,6 +433,16 @@ bool is_keyword(const char *name, uint len) return get_hash_symbol(name,len,0)!=0; } +/** + Check if name is a sql function + + @param name checked name + + @return is this a native function or not + @retval 0 name is a function + @retval 1 name isn't a function +*/ + bool is_lex_native_function(const LEX_STRING *name) { DBUG_ASSERT(name != NULL); @@ -770,7 +780,7 @@ bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted) int MYSQLlex(void *arg, void *yythd) { - reg1 uchar c; + reg1 uchar c= 0; bool comment_closed; int tokval, result_state; uint length; @@ -788,7 +798,6 @@ int MYSQLlex(void *arg, void *yythd) lip->start_token(); state=lip->next_state; lip->next_state=MY_LEX_OPERATOR_OR_IDENT; - LINT_INIT(c); for (;;) { switch (state) { @@ -917,7 +926,7 @@ int MYSQLlex(void *arg, void *yythd) else #endif { - for (result_state= c; ident_map[c= lip->yyGet()]; result_state|= c); + for (result_state= c; ident_map[c= lip->yyGet()]; result_state|= c) ; /* If there were non-ASCII characters, mark that we must convert */ result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; } @@ -929,7 +938,7 @@ int MYSQLlex(void *arg, void *yythd) If we find a space then this can't be an identifier. We notice this below by checking start != lex->ptr. */ - for (; state_map[c] == MY_LEX_SKIP ; c= lip->yyGet()); + for (; state_map[c] == MY_LEX_SKIP ; c= lip->yyGet()) ; } if (start == lip->get_ptr() && c == '.' && ident_map[lip->yyPeek()]) lip->next_state=MY_LEX_IDENT_SEP; @@ -1002,7 +1011,7 @@ int MYSQLlex(void *arg, void *yythd) } else if (c == 'b') { - while ((c= lip->yyGet()) == '0' || c == '1'); + while ((c= lip->yyGet()) == '0' || c == '1') ; if ((lip->yyLength() >= 3) && !ident_map[c]) { /* Skip '0b' */ @@ -1061,7 +1070,7 @@ int MYSQLlex(void *arg, void *yythd) else #endif { - for (result_state=0; ident_map[c= lip->yyGet()]; result_state|= c); + for (result_state=0; ident_map[c= lip->yyGet()]; result_state|= c) ; /* If there were non-ASCII characters, mark that we must convert */ result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; } @@ -1161,7 +1170,7 @@ int MYSQLlex(void *arg, void *yythd) case MY_LEX_BIN_NUMBER: // Found b'bin-string' lip->yySkip(); // Accept opening ' - while ((c= lip->yyGet()) == '0' || c == '1'); + while ((c= lip->yyGet()) == '0' || c == '1') ; if (c != '\'') return(ABORT_SYM); // Illegal hex constant lip->yySkip(); // Accept closing ' @@ -1436,7 +1445,7 @@ int MYSQLlex(void *arg, void *yythd) [(global | local | session) .]variable_name */ - for (result_state= 0; ident_map[c= lip->yyGet()]; result_state|= c); + for (result_state= 0; ident_map[c= lip->yyGet()]; result_state|= c) ; /* If there were non-ASCII characters, mark that we must convert */ result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 62106a2500b..22b7d2e359c 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1976,4 +1976,6 @@ extern bool is_lex_native_function(const LEX_STRING *name); @} (End of group Semantic_Analysis) */ +int my_missing_function_error(const LEX_STRING &token, const char *name); + #endif /* MYSQL_SERVER */ diff --git a/sql/sql_load.cc b/sql/sql_load.cc index d4f499b8d44..1758a6df5f9 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -86,7 +86,7 @@ static int read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, static bool write_execute_load_query_log_event(THD *thd, bool duplicates, bool ignore, bool transactional_table, - THD::killed_state killed_status); + int errcode); #endif /* EMBEDDED_LIBRARY */ /* @@ -483,10 +483,12 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, /* If the file was not empty, wrote_create_file is true */ if (lf_info.wrote_create_file) { + int errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); + if (thd->transaction.stmt.modified_non_trans_table) write_execute_load_query_log_event(thd, handle_duplicates, ignore, transactional_table, - killed_status); + errcode); else { Delete_file_log_event d(thd, db, transactional_table); @@ -528,8 +530,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, read_info.end_io_cache(); if (lf_info.wrote_create_file) { + int errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); write_execute_load_query_log_event(thd, handle_duplicates, ignore, - transactional_table,killed_status); + transactional_table, errcode); } } } @@ -553,7 +556,7 @@ err: static bool write_execute_load_query_log_event(THD *thd, bool duplicates, bool ignore, bool transactional_table, - THD::killed_state killed_err_arg) + int errcode) { Execute_load_query_log_event e(thd, thd->query, thd->query_length, @@ -561,7 +564,7 @@ static bool write_execute_load_query_log_event(THD *thd, (uint) ((char*)thd->lex->fname_end - (char*)thd->query), (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE : (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR), - transactional_table, FALSE, killed_err_arg); + transactional_table, FALSE, errcode); e.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F; return mysql_bin_log.write(&e); } @@ -747,9 +750,9 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, real_item= item->real_item(); - if (!read_info.enclosed && + if ((!read_info.enclosed && (enclosed_length && length == 4 && - !memcmp(pos, STRING_WITH_LEN("NULL"))) || + !memcmp(pos, STRING_WITH_LEN("NULL")))) || (length == 1 && read_info.found_null)) { @@ -1148,8 +1151,8 @@ int READ_INFO::read_field() } // End of enclosed field if followed by field_term or line_term if (chr == my_b_EOF || - chr == line_term_char && terminator(line_term_ptr, - line_term_length)) + (chr == line_term_char && terminator(line_term_ptr, + line_term_length))) { // Maybe unexpected linefeed enclosed=1; found_end_of_line=1; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6dbe4a4fd8d..542ce992537 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -195,11 +195,8 @@ bool begin_trans(THD *thd) error= -1; else { - LEX *lex= thd->lex; thd->options|= OPTION_BEGIN; thd->server_status|= SERVER_STATUS_IN_TRANS; - if (lex->start_transaction_opt & MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT) - error= ha_start_consistent_snapshot(thd); } return error; } @@ -1168,12 +1165,12 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } case COM_STMT_EXECUTE: { - mysql_stmt_execute(thd, packet, packet_length); + mysqld_stmt_execute(thd, packet, packet_length); break; } case COM_STMT_FETCH: { - mysql_stmt_fetch(thd, packet, packet_length); + mysqld_stmt_fetch(thd, packet, packet_length); break; } case COM_STMT_SEND_LONG_DATA: @@ -1183,17 +1180,17 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } case COM_STMT_PREPARE: { - mysql_stmt_prepare(thd, packet, packet_length); + mysqld_stmt_prepare(thd, packet, packet_length); break; } case COM_STMT_CLOSE: { - mysql_stmt_close(thd, packet); + mysqld_stmt_close(thd, packet); break; } case COM_STMT_RESET: { - mysql_stmt_reset(thd, packet); + mysqld_stmt_reset(thd, packet); break; } case COM_QUERY: @@ -1353,7 +1350,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (check_access(thd, CREATE_ACL, db.str , 0, 1, 0, is_schema_db(db.str))) break; - general_log_print(thd, command, packet); + general_log_print(thd, command, "%.*s", db.length, db.str); bzero(&create_info, sizeof(create_info)); mysql_create_db(thd, (lower_case_table_names == 2 ? alias.str : db.str), &create_info, 0); @@ -1378,7 +1375,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0)); break; } - general_log_write(thd, command, db.str, db.length); + general_log_write(thd, command, "%.*s", db.length, db.str); mysql_rm_db(thd, db.str, 0, 0); break; } @@ -1563,14 +1560,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, break; } - /* If commit fails, we should be able to reset the OK status. */ - thd->main_da.can_overwrite_status= TRUE; - ha_autocommit_or_rollback(thd, thd->is_error()); - thd->main_da.can_overwrite_status= FALSE; - - thd->transaction.stmt.reset(); - - /* report error issued during command execution */ if (thd->killed_errno()) { @@ -1583,6 +1572,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd->mysys_var->abort= 0; } + /* If commit fails, we should be able to reset the OK status. */ + thd->main_da.can_overwrite_status= TRUE; + ha_autocommit_or_rollback(thd, thd->is_error()); + thd->main_da.can_overwrite_status= FALSE; + + thd->transaction.stmt.reset(); + net_end_statement(thd); query_cache_end_of_result(thd); @@ -3883,7 +3879,9 @@ end_with_restore_list: res= mysql_routine_grant(thd, all_tables, lex->type == TYPE_ENUM_PROCEDURE, lex->users_list, grants, - lex->sql_command == SQLCOM_REVOKE, 0); + lex->sql_command == SQLCOM_REVOKE, TRUE); + if (!res) + my_ok(thd); } else { @@ -4027,6 +4025,11 @@ end_with_restore_list: } if (begin_trans(thd)) goto error; + if (lex->start_transaction_opt & MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT) + { + if (ha_start_consistent_snapshot(thd)) + goto error; + } my_ok(thd); break; case SQLCOM_COMMIT: @@ -5167,7 +5170,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, if (schema_db) { - if (!(sctx->master_access & FILE_ACL) && (want_access & FILE_ACL) || + if ((!(sctx->master_access & FILE_ACL) && (want_access & FILE_ACL)) || (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL))) { if (!no_errors) @@ -5201,7 +5204,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, DBUG_RETURN(FALSE); } if (((want_access & ~sctx->master_access) & ~(DB_ACLS | EXTRA_ACL)) || - ! db && dont_check_global_grants) + (! db && dont_check_global_grants)) { // We can never grant this DBUG_PRINT("error",("No possible access")); if (!no_errors) @@ -5479,7 +5482,7 @@ bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table) if (!check_access(thd, access, table->db, &table->grant.privilege, 0, 1, test(table->schema_table)) && - !check_grant(thd, access, table, 0, 1, 1)) + !check_grant(thd, access, table, 0, 1, 1)) DBUG_RETURN(0); } } @@ -5735,7 +5738,7 @@ mysql_new_select(LEX *lex, bool move_down) /* Don't evaluate this subquery during statement prepare even if it's a constant one. The flag is switched off in the end of - mysql_stmt_prepare. + mysqld_stmt_prepare. */ if (thd->stmt_arena->is_stmt_prepare()) select_lex->uncacheable|= UNCACHEABLE_PREPARE; @@ -7799,7 +7802,7 @@ bool parse_sql(THD *thd, /* Check that if MYSQLparse() failed, thd->is_error() is set. */ DBUG_ASSERT(!mysql_parse_status || - mysql_parse_status && thd->is_error()); + (mysql_parse_status && thd->is_error())); /* Reset parser state. */ diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 4a50650b6f4..284eaebbe87 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -918,6 +918,9 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, 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 and real name to table name and get database name from file name. + TODO: Consider generalizing or refactoring Lex::add_table_to_list() so + it can be used in all places where we create TABLE_LIST objects. + Also consider creating appropriate constructors for TABLE_LIST. */ bzero((void*)&tables, sizeof(TABLE_LIST)); @@ -925,6 +928,13 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, tables.table= table; tables.next_local= 0; tables.next_name_resolution_table= 0; + /* + Cache the table in Item_fields. All the tables can be cached except + the trigger pseudo table. + */ + tables.cacheable_table= TRUE; + context= thd->lex->current_context(); + tables.select_lex= context->select_lex; strmov(db_name_string, table->s->normalized_path.str); dir_length= dirname_length(db_name_string); db_name_string[dir_length - 1]= 0; @@ -932,7 +942,6 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, db_name= &db_name_string[home_dir_length]; tables.db= db_name; - context= thd->lex->current_context(); table->map= 1; //To ensure correct calculation of const item table->get_fields_in_item_tree= TRUE; save_table_list= context->table_list; @@ -964,8 +973,9 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, save_use_only_table_context= thd->lex->use_only_table_context; thd->lex->use_only_table_context= TRUE; + thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS; - error= func_expr->fix_fields(thd, (Item**)0); + error= func_expr->fix_fields(thd, (Item**)&func_expr); thd->lex->use_only_table_context= save_use_only_table_context; @@ -5090,7 +5100,7 @@ static bool mysql_change_partitions(ALTER_PARTITION_PARAM_TYPE *lpt) handler *file= lpt->table->file; DBUG_ENTER("mysql_change_partitions"); - build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "", 0); + build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0); if ((error= file->ha_change_partitions(lpt->create_info, path, &lpt->copied, &lpt->deleted, lpt->pack_frm_data, lpt->pack_frm_len))) @@ -5130,7 +5140,7 @@ static bool mysql_rename_partitions(ALTER_PARTITION_PARAM_TYPE *lpt) int error; DBUG_ENTER("mysql_rename_partitions"); - build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "", 0); + build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0); if ((error= lpt->table->file->ha_rename_partitions(path))) { if (error != 1) @@ -5171,7 +5181,7 @@ static bool mysql_drop_partitions(ALTER_PARTITION_PARAM_TYPE *lpt) int error; DBUG_ENTER("mysql_drop_partitions"); - build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "", 0); + build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0); if ((error= lpt->table->file->ha_drop_partitions(path))) { lpt->table->file->print_error(error, MYF(0)); @@ -5516,10 +5526,10 @@ static bool write_log_drop_shadow_frm(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= NULL; - char shadow_path[FN_REFLEN]; + char shadow_path[FN_REFLEN + 1]; DBUG_ENTER("write_log_drop_shadow_frm"); - build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt); + build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt); pthread_mutex_lock(&LOCK_gdl); if (write_log_replace_delete_frm(lpt, 0UL, NULL, (const char*)shadow_path, FALSE)) @@ -5559,15 +5569,15 @@ static bool write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry; - char path[FN_REFLEN]; - char shadow_path[FN_REFLEN]; + char path[FN_REFLEN + 1]; + char shadow_path[FN_REFLEN + 1]; DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry; DBUG_ENTER("write_log_rename_frm"); part_info->first_log_entry= NULL; - build_table_filename(path, sizeof(path), lpt->db, + build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0); - build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt); + build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt); pthread_mutex_lock(&LOCK_gdl); if (write_log_replace_delete_frm(lpt, 0UL, shadow_path, path, TRUE)) goto error; @@ -5610,16 +5620,16 @@ static bool write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry; - char tmp_path[FN_REFLEN]; - char path[FN_REFLEN]; + char tmp_path[FN_REFLEN + 1]; + char path[FN_REFLEN + 1]; uint next_entry= 0; DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry; DBUG_ENTER("write_log_drop_partition"); part_info->first_log_entry= NULL; - build_table_filename(path, sizeof(path), lpt->db, + build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0); - build_table_filename(tmp_path, sizeof(tmp_path), lpt->db, + build_table_filename(tmp_path, sizeof(tmp_path) - 1, lpt->db, lpt->table_name, "#", 0); pthread_mutex_lock(&LOCK_gdl); if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path, @@ -5669,14 +5679,14 @@ static bool write_log_add_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= NULL; - char tmp_path[FN_REFLEN]; - char path[FN_REFLEN]; + char tmp_path[FN_REFLEN + 1]; + char path[FN_REFLEN + 1]; uint next_entry= 0; DBUG_ENTER("write_log_add_change_partition"); - build_table_filename(path, sizeof(path), lpt->db, + build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0); - build_table_filename(tmp_path, sizeof(tmp_path), lpt->db, + build_table_filename(tmp_path, sizeof(tmp_path) - 1, lpt->db, lpt->table_name, "#", 0); pthread_mutex_lock(&LOCK_gdl); if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path, @@ -5723,16 +5733,16 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) partition_info *part_info= lpt->part_info; DDL_LOG_MEMORY_ENTRY *log_entry; DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry; - char path[FN_REFLEN]; - char shadow_path[FN_REFLEN]; + char path[FN_REFLEN + 1]; + char shadow_path[FN_REFLEN + 1]; DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry; uint next_entry= 0; DBUG_ENTER("write_log_final_change_partition"); part_info->first_log_entry= NULL; - build_table_filename(path, sizeof(path), lpt->db, + build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0); - build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt); + build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt); pthread_mutex_lock(&LOCK_gdl); if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path, lpt->alter_info->flags & ALTER_REORGANIZE_PARTITION)) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 1465b6d2d30..da168d36429 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -29,6 +29,18 @@ extern struct st_mysql_plugin *mysqld_builtins[]; +/** + @note The order of the enumeration is critical. + @see construct_options +*/ +static const char *global_plugin_typelib_names[]= + { "OFF", "ON", "FORCE", NULL }; +enum enum_plugin_load_policy {PLUGIN_OFF, PLUGIN_ON, PLUGIN_FORCE}; +static TYPELIB global_plugin_typelib= + { array_elements(global_plugin_typelib_names)-1, + "", global_plugin_typelib_names, NULL }; + + char *opt_plugin_load= NULL; char *opt_plugin_dir_ptr; char opt_plugin_dir[FN_REFLEN]; @@ -192,7 +204,7 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv); static bool plugin_load_list(MEM_ROOT *tmp_root, int *argc, char **argv, const char *list); static int test_plugin_options(MEM_ROOT *, struct st_plugin_int *, - int *, char **, my_bool); + int *, char **); static bool register_builtin(struct st_mysql_plugin *, struct st_plugin_int *, struct st_plugin_int **); static void unlock_variables(THD *thd, struct system_variables *vars); @@ -751,7 +763,7 @@ static bool plugin_add(MEM_ROOT *tmp_root, tmp.name.length= name_len; tmp.ref_count= 0; tmp.state= PLUGIN_IS_UNINITIALIZED; - if (test_plugin_options(tmp_root, &tmp, argc, argv, true)) + if (test_plugin_options(tmp_root, &tmp, argc, argv)) tmp.state= PLUGIN_IS_DISABLED; if ((tmp_plugin_ptr= plugin_insert_or_reuse(&tmp))) @@ -997,7 +1009,6 @@ static int plugin_initialize(struct st_plugin_int *plugin) DBUG_ENTER("plugin_initialize"); safe_mutex_assert_owner(&LOCK_plugin); - if (plugin_type_initialize[plugin->plugin->type]) { if ((*plugin_type_initialize[plugin->plugin->type])(plugin)) @@ -1083,6 +1094,20 @@ uchar *get_bookmark_hash_key(const uchar *buff, size_t *length, return (uchar*) var->key; } +static inline void convert_dash_to_underscore(char *str, int len) +{ + for (char *p= str; p <= str+len; p++) + if (*p == '-') + *p= '_'; +} + +static inline void convert_underscore_to_dash(char *str, int len) +{ + for (char *p= str; p <= str+len; p++) + if (*p == '_') + *p= '-'; +} + /* The logic is that we first load and initialize all compiled in plugins. @@ -1094,11 +1119,12 @@ uchar *get_bookmark_hash_key(const uchar *buff, size_t *length, int plugin_init(int *argc, char **argv, int flags) { uint i; - bool def_enabled, is_myisam; + bool is_myisam; struct st_mysql_plugin **builtins; struct st_mysql_plugin *plugin; struct st_plugin_int tmp, *plugin_ptr, **reap; MEM_ROOT tmp_root; + bool reaped_mandatory_plugin= FALSE; DBUG_ENTER("plugin_init"); if (initialized) @@ -1142,17 +1168,13 @@ int plugin_init(int *argc, char **argv, int flags) !my_strnncoll(&my_charset_latin1, (const uchar*) plugin->name, 6, (const uchar*) "InnoDB", 6)) continue; - /* by default, ndbcluster and federated are disabled */ - def_enabled= - my_strcasecmp(&my_charset_latin1, plugin->name, "NDBCLUSTER") != 0 && - my_strcasecmp(&my_charset_latin1, plugin->name, "FEDERATED") != 0; bzero(&tmp, sizeof(tmp)); tmp.plugin= plugin; tmp.name.str= (char *)plugin->name; tmp.name.length= strlen(plugin->name); tmp.state= 0; free_root(&tmp_root, MYF(MY_MARK_BLOCKS_FREE)); - if (test_plugin_options(&tmp_root, &tmp, argc, argv, def_enabled)) + if (test_plugin_options(&tmp_root, &tmp, argc, argv)) tmp.state= PLUGIN_IS_DISABLED; else tmp.state= PLUGIN_IS_UNINITIALIZED; @@ -1227,6 +1249,8 @@ int plugin_init(int *argc, char **argv, int flags) while ((plugin_ptr= *(--reap))) { pthread_mutex_unlock(&LOCK_plugin); + if (plugin_ptr->is_mandatory) + reaped_mandatory_plugin= TRUE; plugin_deinitialize(plugin_ptr, true); pthread_mutex_lock(&LOCK_plugin); plugin_del(plugin_ptr); @@ -1234,6 +1258,8 @@ int plugin_init(int *argc, char **argv, int flags) pthread_mutex_unlock(&LOCK_plugin); my_afree(reap); + if (reaped_mandatory_plugin) + goto err; end: free_root(&tmp_root, MYF(0)); @@ -1299,7 +1325,7 @@ bool plugin_register_builtin(THD *thd, struct st_mysql_plugin *plugin) pthread_mutex_lock(&LOCK_plugin); rw_wrlock(&LOCK_system_variables_hash); - if (test_plugin_options(thd->mem_root, &tmp, &dummy_argc, NULL, true)) + if (test_plugin_options(thd->mem_root, &tmp, &dummy_argc, NULL)) goto end; tmp.state= PLUGIN_IS_UNINITIALIZED; if ((result= register_builtin(plugin, &tmp, &ptr))) @@ -2889,59 +2915,78 @@ my_bool get_one_plugin_option(int optid __attribute__((unused)), } +/** + Creates a set of my_option objects associated with a specified plugin- + handle. + + @param mem_root Memory allocator to be used. + @param tmp A pointer to a plugin handle + @param[out] options A pointer to a pre-allocated static array + + The set is stored in the pre-allocated static array supplied to the function. + The size of the array is calculated as (number_of_plugin_varaibles*2+3). The + reason is that each option can have a prefix '--plugin-' in addtion to the + shorter form '--<plugin-name>'. There is also space allocated for + terminating NULL pointers. + + @return + @retval -1 An error occurred + @retval 0 Success +*/ + static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, - my_option *options, my_bool **enabled, - bool can_disable) + my_option *options) { const char *plugin_name= tmp->plugin->name; - uint namelen= strlen(plugin_name), optnamelen; - uint buffer_length= namelen * 4 + (can_disable ? 75 : 10); - char *name= (char*) alloc_root(mem_root, buffer_length) + 1; - char *optname, *p; + const LEX_STRING plugin_dash = { C_STRING_WITH_LEN("plugin-") }; + uint plugin_name_len= strlen(plugin_name); + uint optnamelen; + const int max_comment_len= 180; + char *comment= (char *) alloc_root(mem_root, max_comment_len + 1); + char *optname; + int index= 0, offset= 0; st_mysql_sys_var *opt, **plugin_option; st_bookmark *v; + + /** Used to circumvent the const attribute on my_option::name */ + char *plugin_name_ptr, *plugin_name_with_prefix_ptr; + DBUG_ENTER("construct_options"); - DBUG_PRINT("plugin", ("plugin: '%s' enabled: %d can_disable: %d", - plugin_name, **enabled, can_disable)); + options[0].name= plugin_name_ptr= (char*) alloc_root(mem_root, + plugin_name_len + 1); + strcpy(plugin_name_ptr, plugin_name); + my_casedn_str(&my_charset_latin1, plugin_name_ptr); + convert_underscore_to_dash(plugin_name_ptr, plugin_name_len); /* support --skip-plugin-foo syntax */ - memcpy(name, plugin_name, namelen + 1); - my_casedn_str(&my_charset_latin1, name); - strxmov(name + namelen + 1, "plugin-", name, NullS); - /* Now we have namelen + 1 + 7 + namelen + 1 == namelen * 2 + 9. */ - - for (p= name + namelen*2 + 8; p > name; p--) - if (*p == '_') - *p= '-'; + options[1].name= plugin_name_with_prefix_ptr= (char*) alloc_root(mem_root, + plugin_name_len + + plugin_dash.length + 1); + strxmov(plugin_name_with_prefix_ptr, plugin_dash.str, options[0].name, NullS); - if (can_disable) - { - strxmov(name + namelen*2 + 10, "Enable ", plugin_name, " plugin. " - "Disable with --skip-", name," (will save memory).", NullS); - /* - Now we have namelen * 2 + 10 (one char unused) + 7 + namelen + 9 + - 20 + namelen + 20 + 1 == namelen * 4 + 67. - */ + options[0].id= options[1].id= 256; /* must be >255. dup id ok */ + options[0].var_type= options[1].var_type= GET_ENUM; + options[0].arg_type= options[1].arg_type= OPT_ARG; + options[0].def_value= options[1].def_value= 1; /* ON */ + options[0].typelib= options[1].typelib= &global_plugin_typelib; - options[0].comment= name + namelen*2 + 10; - } + strxnmov(comment, max_comment_len, "Enable or disable ", plugin_name, + " plugin. Possible values are ON, OFF, FORCE (don't start " + "if the plugin fails to load).", NullS); + options[0].comment= comment; /* - NOTE: 'name' is one char above the allocated buffer! - NOTE: This code assumes that 'my_bool' and 'char' are of same size. + Allocate temporary space for the value of the tristate. + This option will have a limited lifetime and is not used beyond + server initialization. + GET_ENUM value is an integer. */ - *((my_bool *)(name -1))= **enabled; - *enabled= (my_bool *)(name - 1); - + options[0].value= options[1].value= (uchar **)alloc_root(mem_root, + sizeof(int)); + *((uint*) options[0].value)= *((uint*) options[1].value)= + (uint) options[0].def_value; - options[1].name= (options[0].name= name) + namelen + 1; - options[0].id= options[1].id= 256; /* must be >255. dup id ok */ - options[0].var_type= options[1].var_type= GET_BOOL; - options[0].arg_type= options[1].arg_type= NO_ARG; - options[0].def_value= options[1].def_value= **enabled; - options[0].value= options[0].u_max_value= - options[1].value= options[1].u_max_value= (uchar**) (name - 1); options+= 2; /* @@ -2955,7 +3000,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, opt= *plugin_option; if (!(opt->flags & PLUGIN_VAR_THDLOCAL)) continue; - if (!(register_var(name, opt->name, opt->flags))) + if (!(register_var(plugin_name_ptr, opt->name, opt->flags))) continue; switch (opt->flags & PLUGIN_VAR_TYPEMASK) { case PLUGIN_VAR_BOOL: @@ -3020,7 +3065,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, if (!opt->update) { opt->update= update_func_str; - if (!(opt->flags & PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY)) + if (!(opt->flags & (PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY))) { opt->flags|= PLUGIN_VAR_READONLY; sql_print_warning("Server variable %s of plugin %s was forced " @@ -3062,14 +3107,14 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, if (!(opt->flags & PLUGIN_VAR_THDLOCAL)) { optnamelen= strlen(opt->name); - optname= (char*) alloc_root(mem_root, namelen + optnamelen + 2); - strxmov(optname, name, "-", opt->name, NullS); - optnamelen= namelen + optnamelen + 1; + optname= (char*) alloc_root(mem_root, plugin_name_len + optnamelen + 2); + strxmov(optname, plugin_name_ptr, "-", opt->name, NullS); + optnamelen= plugin_name_len + optnamelen + 1; } else { /* this should not fail because register_var should create entry */ - if (!(v= find_bookmark(name, opt->name, opt->flags))) + if (!(v= find_bookmark(plugin_name_ptr, opt->name, opt->flags))) { sql_print_error("Thread local variable '%s' not allocated " "in plugin '%s'.", opt->name, plugin_name); @@ -3085,10 +3130,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, (optnamelen= v->name_len) + 1); } - /* convert '_' to '-' */ - for (p= optname; *p; p++) - if (*p == '_') - *p= '-'; + convert_underscore_to_dash(optname, optnamelen); options->name= optname; options->comment= opt->comment; @@ -3103,10 +3145,13 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, else options->value= options->u_max_value= *(uchar***) (opt + 1); + char *option_name_ptr; options[1]= options[0]; - options[1].name= p= (char*) alloc_root(mem_root, optnamelen + 8); - options[1].comment= 0; // hidden - strxmov(p, "plugin-", optname, NullS); + options[1].name= option_name_ptr= (char*) alloc_root(mem_root, + plugin_dash.length + + optnamelen + 1); + options[1].comment= 0; /* Hidden from the help text */ + strxmov(option_name_ptr, plugin_dash.str, optname, NullS); options+= 2; } @@ -3120,55 +3165,57 @@ static my_option *construct_help_options(MEM_ROOT *mem_root, { st_mysql_sys_var **opt; my_option *opts; - my_bool dummy, can_disable; - my_bool *dummy2= &dummy; uint count= EXTRA_OPTIONS; DBUG_ENTER("construct_help_options"); - for (opt= p->plugin->system_vars; opt && *opt; opt++, count+= 2); + for (opt= p->plugin->system_vars; opt && *opt; opt++, count+= 2) + ; if (!(opts= (my_option*) alloc_root(mem_root, sizeof(my_option) * count))) DBUG_RETURN(NULL); bzero(opts, sizeof(my_option) * count); - dummy= TRUE; /* plugin is enabled. */ - - can_disable= - my_strcasecmp(&my_charset_latin1, p->name.str, "MyISAM") && - my_strcasecmp(&my_charset_latin1, p->name.str, "MEMORY"); - - if (construct_options(mem_root, p, opts, &dummy2, can_disable)) + if (construct_options(mem_root, p, opts)) DBUG_RETURN(NULL); DBUG_RETURN(opts); } -/* - SYNOPSIS - test_plugin_options() - tmp_root temporary scratch space - plugin internal plugin structure - argc user supplied arguments - argv user supplied arguments - default_enabled default plugin enable status - RETURNS: - 0 SUCCESS - plugin should be enabled/loaded - NOTE: - Requires that a write-lock is held on LOCK_system_variables_hash +/** + Create and register system variables supplied from the plugin and + assigns initial values from corresponding command line arguments. + + @param tmp_root Temporary scratch space + @param[out] plugin Internal plugin structure + @param argc Number of command line arguments + @param argv Command line argument vector + + The plugin will be updated with a policy on how to handle errors during + initialization. + + @note Requires that a write-lock is held on LOCK_system_variables_hash + + @return How initialization of the plugin should be handled. + @retval 0 Initialization should proceed. + @retval 1 Plugin is disabled. + @retval -1 An error has occurred. */ + static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, - int *argc, char **argv, my_bool default_enabled) + int *argc, char **argv) { struct sys_var_chain chain= { NULL, NULL }; - my_bool enabled_saved= default_enabled, can_disable; - my_bool *enabled= &default_enabled; + my_bool can_disable; + bool disable_plugin; + enum_plugin_load_policy plugin_load_policy= PLUGIN_ON; + MEM_ROOT *mem_root= alloc_root_inited(&tmp->mem_root) ? &tmp->mem_root : &plugin_mem_root; st_mysql_sys_var **opt; my_option *opts= NULL; - char *p, *varname; + char *varname; int error; st_mysql_sys_var *o; sys_var *v; @@ -3177,13 +3224,17 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, DBUG_ENTER("test_plugin_options"); DBUG_ASSERT(tmp->plugin && tmp->name.str); + /* + The 'federated' and 'ndbcluster' storage engines are always disabled by + default. + */ + if (!(my_strcasecmp(&my_charset_latin1, tmp->name.str, "federated") && + my_strcasecmp(&my_charset_latin1, tmp->name.str, "ndbcluster"))) + plugin_load_policy= PLUGIN_OFF; + for (opt= tmp->plugin->system_vars; opt && *opt; opt++) count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */ - can_disable= - my_strcasecmp(&my_charset_latin1, tmp->name.str, "MyISAM") && - my_strcasecmp(&my_charset_latin1, tmp->name.str, "MEMORY"); - if (count > EXTRA_OPTIONS || (*argc > 1)) { if (!(opts= (my_option*) alloc_root(tmp_root, sizeof(my_option) * count))) @@ -3193,12 +3244,18 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, } bzero(opts, sizeof(my_option) * count); - if (construct_options(tmp_root, tmp, opts, &enabled, can_disable)) + if (construct_options(tmp_root, tmp, opts)) { sql_print_error("Bad options for plugin '%s'.", tmp->name.str); DBUG_RETURN(-1); } + /* + We adjust the default value to account for the hardcoded exceptions + we have set for the federated and ndbcluster storage engines. + */ + opts[0].def_value= opts[1].def_value= (int)plugin_load_policy; + error= handle_options(argc, &argv, opts, get_one_plugin_option); (*argc)++; /* add back one for the program name */ @@ -3208,64 +3265,79 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, tmp->name.str); goto err; } + /* + Set plugin loading policy from option value. First element in the option + list is always the <plugin name> option value. + */ + plugin_load_policy= (enum_plugin_load_policy)*(uint*)opts[0].value; } - if (!*enabled && !can_disable) + disable_plugin= (plugin_load_policy == PLUGIN_OFF); + /* + The 'MyISAM' and 'Memory' storage engines currently can't be disabled. + */ + can_disable= + my_strcasecmp(&my_charset_latin1, tmp->name.str, "MyISAM") && + my_strcasecmp(&my_charset_latin1, tmp->name.str, "MEMORY"); + + tmp->is_mandatory= (plugin_load_policy == PLUGIN_FORCE) || !can_disable; + + if (disable_plugin && !can_disable) { sql_print_warning("Plugin '%s' cannot be disabled", tmp->name.str); - *enabled= TRUE; + disable_plugin= FALSE; } - error= 1; + /* + If the plugin is disabled it should not be initialized. + */ + if (disable_plugin) + { + if (global_system_variables.log_warnings) + sql_print_information("Plugin '%s' is disabled.", + tmp->name.str); + if (opts) + my_cleanup_options(opts); + DBUG_RETURN(1); + } - if (*enabled) + error= 1; + for (opt= tmp->plugin->system_vars; opt && *opt; opt++) { - for (opt= tmp->plugin->system_vars; opt && *opt; opt++) + if (((o= *opt)->flags & PLUGIN_VAR_NOSYSVAR)) + continue; + if ((var= find_bookmark(tmp->name.str, o->name, o->flags))) + v= new (mem_root) sys_var_pluginvar(var->key + 1, o); + else { - if (((o= *opt)->flags & PLUGIN_VAR_NOSYSVAR)) - continue; - - if ((var= find_bookmark(tmp->name.str, o->name, o->flags))) - v= new (mem_root) sys_var_pluginvar(var->key + 1, o); - else - { - len= tmp->name.length + strlen(o->name) + 2; - varname= (char*) alloc_root(mem_root, len); - strxmov(varname, tmp->name.str, "-", o->name, NullS); - my_casedn_str(&my_charset_latin1, varname); - - for (p= varname; *p; p++) - if (*p == '-') - *p= '_'; - - v= new (mem_root) sys_var_pluginvar(varname, o); - } - DBUG_ASSERT(v); /* check that an object was actually constructed */ - - /* - Add to the chain of variables. - Done like this for easier debugging so that the - pointer to v is not lost on optimized builds. - */ - v->chain_sys_var(&chain); + len= tmp->name.length + strlen(o->name) + 2; + varname= (char*) alloc_root(mem_root, len); + strxmov(varname, tmp->name.str, "-", o->name, NullS); + my_casedn_str(&my_charset_latin1, varname); + convert_dash_to_underscore(varname, len-1); + v= new (mem_root) sys_var_pluginvar(varname, o); } - if (chain.first) + DBUG_ASSERT(v); /* check that an object was actually constructed */ + /* + Add to the chain of variables. + Done like this for easier debugging so that the + pointer to v is not lost on optimized builds. + */ + v->chain_sys_var(&chain); + } /* end for */ + if (chain.first) + { + chain.last->next = NULL; + if (mysql_add_sys_var_chain(chain.first, NULL)) { - chain.last->next = NULL; - if (mysql_add_sys_var_chain(chain.first, NULL)) - { - sql_print_error("Plugin '%s' has conflicting system variables", - tmp->name.str); - goto err; - } - tmp->system_vars= chain.first; + sql_print_error("Plugin '%s' has conflicting system variables", + tmp->name.str); + goto err; } - DBUG_RETURN(0); + tmp->system_vars= chain.first; } - - if (enabled_saved && global_system_variables.log_warnings) - sql_print_information("Plugin '%s' disabled by command line option", - tmp->name.str); + DBUG_RETURN(0); + err: if (opts) my_cleanup_options(opts); diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index 8ae38d58845..004d0d5abb7 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -79,6 +79,7 @@ struct st_plugin_int void *data; /* plugin type specific, e.g. handlerton */ MEM_ROOT mem_root; /* memory for dynamic plugin structures */ sys_var *system_vars; /* server variables for this plugin */ + bool is_mandatory; /* If true then plugin must not fail to load */ }; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index cd11b6d4c24..e7e821dd4ae 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -716,9 +716,9 @@ static void setup_one_conversion_function(THD *thd, Item_param *param, prepared statement, parameter markers are replaced with variable names. Example: @verbatim - mysql_stmt_prepare("UPDATE t1 SET a=a*1.25 WHERE a=?") + mysqld_stmt_prepare("UPDATE t1 SET a=a*1.25 WHERE a=?") --> general logs gets [Prepare] UPDATE t1 SET a*1.25 WHERE a=?" - mysql_stmt_execute(stmt); + mysqld_stmt_execute(stmt); --> general and binary logs get [Execute] UPDATE t1 SET a*1.25 WHERE a=1" @endverbatim @@ -1434,8 +1434,8 @@ static bool mysql_test_set_fields(Prepared_statement *stmt, THD *thd= stmt->thd; set_var_base *var; - if (tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE) || - open_normal_and_derived_tables(thd, tables, 0)) + if ((tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE)) + || open_normal_and_derived_tables(thd, tables, 0)) goto error; while ((var= it++)) @@ -1470,13 +1470,13 @@ static bool mysql_test_call_fields(Prepared_statement *stmt, THD *thd= stmt->thd; Item *item; - if (tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE) || + if ((tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE)) || open_normal_and_derived_tables(thd, tables, 0)) goto err; while ((item= it++)) { - if (!item->fixed && item->fix_fields(thd, it.ref()) || + if ((!item->fixed && item->fix_fields(thd, it.ref())) || item->check_cols(1)) goto err; } @@ -2056,11 +2056,11 @@ static bool init_param_array(Prepared_statement *stmt) to the client, otherwise an error message is set in THD. */ -void mysql_stmt_prepare(THD *thd, const char *packet, uint packet_length) +void mysqld_stmt_prepare(THD *thd, const char *packet, uint packet_length) { Prepared_statement *stmt; bool error; - DBUG_ENTER("mysql_stmt_prepare"); + DBUG_ENTER("mysqld_stmt_prepare"); DBUG_PRINT("prep_query", ("%s", packet)); @@ -2227,9 +2227,8 @@ void mysql_sql_stmt_prepare(THD *thd) LEX_STRING *name= &lex->prepared_stmt_name; Prepared_statement *stmt; const char *query; - uint query_len; + uint query_len= 0; DBUG_ENTER("mysql_sql_stmt_prepare"); - LINT_INIT(query_len); DBUG_ASSERT(thd->protocol == &thd->protocol_text); if ((stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name))) @@ -2423,7 +2422,7 @@ static void reset_stmt_params(Prepared_statement *stmt) client, otherwise an error message is set in THD. */ -void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length) +void mysqld_stmt_execute(THD *thd, char *packet_arg, uint packet_length) { uchar *packet= (uchar*)packet_arg; // GCC 4.0.1 workaround ulong stmt_id= uint4korr(packet); @@ -2433,7 +2432,7 @@ void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length) uchar *packet_end= packet + packet_length; Prepared_statement *stmt; bool open_cursor; - DBUG_ENTER("mysql_stmt_execute"); + DBUG_ENTER("mysqld_stmt_execute"); packet+= 9; /* stmt_id + 5 bytes of flags */ @@ -2444,7 +2443,7 @@ void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length) { char llbuf[22]; my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), sizeof(llbuf), - llstr(stmt_id, llbuf), "mysql_stmt_execute"); + llstr(stmt_id, llbuf), "mysqld_stmt_execute"); DBUG_VOID_RETURN; } @@ -2461,6 +2460,9 @@ void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length) stmt->execute_loop(&expanded_query, open_cursor, packet, packet_end); + /* Close connection socket; for use with client testing (Bug#43560). */ + DBUG_EXECUTE_IF("close_conn_after_stmt_execute", vio_close(thd->net.vio);); + DBUG_VOID_RETURN; } @@ -2522,7 +2524,7 @@ void mysql_sql_stmt_execute(THD *thd) @param packet_length Length of packet */ -void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) +void mysqld_stmt_fetch(THD *thd, char *packet, uint packet_length) { /* assume there is always place for 8-16 bytes */ ulong stmt_id= uint4korr(packet); @@ -2530,7 +2532,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) Prepared_statement *stmt; Statement stmt_backup; Server_side_cursor *cursor; - DBUG_ENTER("mysql_stmt_fetch"); + DBUG_ENTER("mysqld_stmt_fetch"); /* First of all clear possible warnings from the previous command */ mysql_reset_thd_for_next_command(thd); @@ -2539,7 +2541,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) { char llbuf[22]; my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), sizeof(llbuf), - llstr(stmt_id, llbuf), "mysql_stmt_fetch"); + llstr(stmt_id, llbuf), "mysqld_stmt_fetch"); DBUG_VOID_RETURN; } @@ -2580,9 +2582,9 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) This function resets statement to the state it was right after prepare. It can be used to: - - clear an error happened during mysql_stmt_send_long_data + - clear an error happened during mysqld_stmt_send_long_data - cancel long data stream for all placeholders without - having to call mysql_stmt_execute. + having to call mysqld_stmt_execute. - close an open cursor Sends 'OK' packet in case of success (statement was reset) or 'ERROR' packet (unrecoverable error/statement not found/etc). @@ -2591,12 +2593,12 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) @param packet Packet with stmt id */ -void mysql_stmt_reset(THD *thd, char *packet) +void mysqld_stmt_reset(THD *thd, char *packet) { /* There is always space for 4 bytes in buffer */ ulong stmt_id= uint4korr(packet); Prepared_statement *stmt; - DBUG_ENTER("mysql_stmt_reset"); + DBUG_ENTER("mysqld_stmt_reset"); /* First of all clear possible warnings from the previous command */ mysql_reset_thd_for_next_command(thd); @@ -2606,7 +2608,7 @@ void mysql_stmt_reset(THD *thd, char *packet) { char llbuf[22]; my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), sizeof(llbuf), - llstr(stmt_id, llbuf), "mysql_stmt_reset"); + llstr(stmt_id, llbuf), "mysqld_stmt_reset"); DBUG_VOID_RETURN; } @@ -2614,7 +2616,7 @@ void mysql_stmt_reset(THD *thd, char *packet) /* Clear parameters from data which could be set by - mysql_stmt_send_long_data() call. + mysqld_stmt_send_long_data() call. */ reset_stmt_params(stmt); @@ -2635,12 +2637,12 @@ void mysql_stmt_reset(THD *thd, char *packet) we don't send any reply to this command. */ -void mysql_stmt_close(THD *thd, char *packet) +void mysqld_stmt_close(THD *thd, char *packet) { /* There is always space for 4 bytes in packet buffer */ ulong stmt_id= uint4korr(packet); Prepared_statement *stmt; - DBUG_ENTER("mysql_stmt_close"); + DBUG_ENTER("mysqld_stmt_close"); thd->main_da.disable_status(); @@ -2739,7 +2741,7 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) stmt->state= Query_arena::ERROR; stmt->last_errno= ER_WRONG_ARGUMENTS; sprintf(stmt->last_error, ER(ER_WRONG_ARGUMENTS), - "mysql_stmt_send_long_data"); + "mysqld_stmt_send_long_data"); DBUG_VOID_RETURN; } #endif @@ -2843,7 +2845,7 @@ void Prepared_statement::setup_set_params() Decide if we have to expand the query (because we must write it to logs or because we want to look it up in the query cache) or not. */ - if (mysql_bin_log.is_open() && is_update_query(lex->sql_command) || + if ((mysql_bin_log.is_open() && is_update_query(lex->sql_command)) || opt_log || opt_slow_log || query_cache_is_cacheable_query(lex)) { @@ -3163,7 +3165,7 @@ Prepared_statement::set_parameters(String *expanded_query, if (res) { my_error(ER_WRONG_ARGUMENTS, MYF(0), - is_sql_ps ? "EXECUTE" : "mysql_stmt_execute"); + is_sql_ps ? "EXECUTE" : "mysqld_stmt_execute"); reset_stmt_params(this); } return res; @@ -3294,7 +3296,7 @@ Prepared_statement::reprepare() &cur_db_changed)) return TRUE; - error= (name.str && copy.set_name(&name) || + error= ((name.str && copy.set_name(&name)) || copy.prepare(query, query_length) || validate_metadata(©)); @@ -3618,11 +3620,11 @@ error: } -/** Common part of DEALLOCATE PREPARE and mysql_stmt_close. */ +/** Common part of DEALLOCATE PREPARE and mysqld_stmt_close. */ void Prepared_statement::deallocate() { - /* We account deallocate in the same manner as mysql_stmt_close */ + /* We account deallocate in the same manner as mysqld_stmt_close */ status_var_increment(thd->status_var.com_stmt_close); /* Statement map calls delete stmt on erase */ thd->stmt_map.erase(this); diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index d4331b12cd4..0e0b8eb60b9 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -244,7 +244,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, char *new_table_alias, bool skip_error) { int rc= 1; - char name[FN_REFLEN]; + char name[FN_REFLEN + 1]; const char *new_alias, *old_alias; frm_type_enum frm_type; enum legacy_db_type table_type; @@ -261,14 +261,16 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, old_alias= ren_table->table_name; new_alias= new_table_name; } - build_table_filename(name, sizeof(name), + DBUG_ASSERT(new_alias); + + build_table_filename(name, sizeof(name) - 1, new_db, new_alias, reg_ext, 0); if (!access(name,F_OK)) { my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias); DBUG_RETURN(1); // This can't be skipped } - build_table_filename(name, sizeof(name), + build_table_filename(name, sizeof(name) - 1, ren_table->db, old_alias, reg_ext, 0); frm_type= mysql_frm_type(thd, name, &table_type); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 06c6c022780..476c8aaaefb 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -147,7 +147,7 @@ static int send_file(THD *thd) if (errmsg) { sql_print_error("Failed in send_file() %s", errmsg); - DBUG_PRINT("error", (errmsg)); + DBUG_PRINT("error", ("%s", errmsg)); } DBUG_RETURN(error); } @@ -1043,6 +1043,7 @@ int reset_slave(THD *thd, Master_info* mi) Reset errors (the idea is that we forget about the old master). */ + mi->clear_error(); mi->rli.clear_error(); mi->rli.clear_until_condition(); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index cdae1581a0c..401745bd9b8 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1350,7 +1350,7 @@ JOIN::optimize() join_tab[const_tables].type != JT_ALL && join_tab[const_tables].type != JT_FT && join_tab[const_tables].type != JT_REF_OR_NULL && - (order && simple_order || group_list && simple_group)) + ((order && simple_order) || (group_list && simple_group))) { if (add_ref_to_table_cond(thd,&join_tab[const_tables])) { DBUG_RETURN(1); @@ -1868,9 +1868,9 @@ JOIN::exec() like SEC_TO_TIME(SUM(...)). */ - if (curr_join->group_list && (!test_if_subpart(curr_join->group_list, + if ((curr_join->group_list && (!test_if_subpart(curr_join->group_list, curr_join->order) || - curr_join->select_distinct) || + curr_join->select_distinct)) || (curr_join->select_distinct && curr_join->tmp_table_param.using_indirect_summary_function)) { /* Must copy to another table */ @@ -2344,9 +2344,10 @@ mysql_select(THD *thd, Item ***rref_pointer_array, } else { - if (err= join->prepare(rref_pointer_array, tables, wild_num, - conds, og_num, order, group, having, proc_param, - select_lex, unit)) + err= join->prepare(rref_pointer_array, tables, wild_num, + conds, og_num, order, group, having, proc_param, + select_lex, unit); + if (err) { goto err; } @@ -2361,9 +2362,10 @@ mysql_select(THD *thd, Item ***rref_pointer_array, DBUG_RETURN(TRUE); thd_proc_info(thd, "init"); thd->used_tables=0; // Updated by setup_fields - if (err= join->prepare(rref_pointer_array, tables, wild_num, - conds, og_num, order, group, having, proc_param, - select_lex, unit)) + err= join->prepare(rref_pointer_array, tables, wild_num, + conds, og_num, order, group, having, proc_param, + select_lex, unit); + if (err) { goto err; } @@ -2430,7 +2432,6 @@ static ha_rows get_quick_record_count(THD *thd, SQL_SELECT *select, if (select) { select->head=table; - table->reginfo.impossible_range=0; if ((error= select->test_quick_select(thd, *(key_map *)keys,(table_map) 0, limit, 0)) == 1) DBUG_RETURN(select->quick->records); @@ -3841,7 +3842,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab, if (use->key == prev->key && use->table == prev->table) { if (prev->keypart+1 < use->keypart || - prev->keypart == use->keypart && found_eq_constant) + (prev->keypart == use->keypart && found_eq_constant)) continue; /* remove */ } else if (use->keypart != 0) // First found must be 0 @@ -5146,8 +5147,8 @@ best_extension_by_limited_search(JOIN *join, { if (best_record_count > current_record_count || best_read_time > current_read_time || - idx == join->const_tables && // 's' is the first table in the QEP - s->table == join->sort_by_table) + (idx == join->const_tables && // 's' is the first table in the QEP + s->table == join->sort_by_table)) { if (best_record_count >= current_record_count && best_read_time >= current_read_time && @@ -5273,7 +5274,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, double current_read_time=read_time+best; if (best_record_count > current_record_count || best_read_time > current_read_time || - idx == join->const_tables && s->table == join->sort_by_table) + (idx == join->const_tables && s->table == join->sort_by_table)) { if (best_record_count >= current_record_count && best_read_time >= current_read_time && @@ -6220,8 +6221,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) the index if we are using limit and this is the first table */ - if (cond && - (!tab->keys.is_subset(tab->const_keys) && i > 0) || + if ((cond && + !tab->keys.is_subset(tab->const_keys) && i > 0) || (!tab->const_keys.is_clear_all() && i == join->const_tables && join->unit->select_limit_cnt < join->best_positions[i].records_read && @@ -7354,7 +7355,7 @@ static bool check_simple_equality(Item *left_item, Item *right_item, left_item_equal->merge(right_item_equal); /* Remove the merged multiple equality from the list */ List_iterator<Item_equal> li(cond_equal->current_level); - while ((li++) != right_item_equal); + while ((li++) != right_item_equal) ; li.remove(); } } @@ -9390,13 +9391,17 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, +1: for decimal point */ - overflow= my_decimal_precision_to_length(intg + dec, dec, - item->unsigned_flag) - len; + const int required_length= + my_decimal_precision_to_length(intg + dec, dec, + item->unsigned_flag); + + overflow= required_length - len; if (overflow > 0) dec= max(0, dec - overflow); // too long, discard fract else - len -= item->decimals - dec; // corrected value fits + /* Corrected value fits. */ + len= required_length; } new_field= new Field_new_decimal(len, maybe_null, item->name, @@ -10032,9 +10037,9 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, reclength=1; // Dummy select /* Use packed rows if there is blobs or a lot of space to gain */ if (blob_count || - string_total_length >= STRING_TOTAL_LENGTH_TO_PACK_ROWS && + (string_total_length >= STRING_TOTAL_LENGTH_TO_PACK_ROWS && (reclength / string_total_length <= RATIO_TO_PACK_ROWS || - string_total_length / string_count >= AVG_STRING_LENGTH_TO_PACK_ROWS)) + string_total_length / string_count >= AVG_STRING_LENGTH_TO_PACK_ROWS))) use_packed_rows= 1; share->reclength= reclength; @@ -10602,6 +10607,9 @@ free_tmp_table(THD *thd, TABLE *entry) save_proc_info=thd->proc_info; thd_proc_info(thd, "removing tmp table"); + // Release latches since this can take a long time + ha_release_temporary_latches(thd); + if (entry->file) { if (entry->db_stat) @@ -10647,6 +10655,10 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, table->file->print_error(error,MYF(0)); DBUG_RETURN(1); } + + // Release latches since this can take a long time + ha_release_temporary_latches(thd); + new_table= *table; share= *table->s; new_table.s= &share; @@ -10828,9 +10840,8 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) { int rc= 0; enum_nested_loop_state error= NESTED_LOOP_OK; - JOIN_TAB *join_tab; + JOIN_TAB *join_tab= NULL; DBUG_ENTER("do_select"); - LINT_INIT(join_tab); join->procedure=procedure; join->tmp_table= table; /* Save for easy recursion */ @@ -12651,7 +12662,10 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx, one row). The sorting doesn't matter. */ if (key_part == key_part_end && reverse == 0) + { + *used_key_parts= 0; DBUG_RETURN(1); + } } else DBUG_RETURN(0); @@ -13066,9 +13080,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, */ uint nr; key_map keys; - uint best_key_parts; - int best_key_direction; - ha_rows best_records; + uint best_key_parts= 0; + int best_key_direction= 0; + ha_rows best_records= 0; double read_time; int best_key= -1; bool is_best_covering= FALSE; @@ -13078,9 +13092,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, ha_rows table_records= table->file->stats.records; bool group= join->group && order == join->group_list; ha_rows ref_key_quick_rows= HA_POS_ERROR; - LINT_INIT(best_key_parts); - LINT_INIT(best_key_direction); - LINT_INIT(best_records); /* If not used with LIMIT, only use keys if the whole query can be @@ -13121,12 +13132,20 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, for (nr=0; nr < table->s->keys ; nr++) { int direction; + if (keys.is_set(nr) && (direction= test_if_order_by_key(order, table, nr, &used_key_parts))) { + /* + At this point we are sure that ref_key is a non-ordering + key (where "ordering key" is a key that will return rows + in the order required by ORDER BY). + */ + DBUG_ASSERT (ref_key != (int) nr); + bool is_covering= table->covering_keys.is_set(nr) || - nr == table->s->primary_key && - table->file->primary_key_is_clustered(); + (nr == table->s->primary_key && + table->file->primary_key_is_clustered()); /* Don't use an index scan with ORDER BY without limit. @@ -13139,7 +13158,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, */ if (is_covering || select_limit != HA_POS_ERROR || - ref_key < 0 && (group || table->force_index)) + (ref_key < 0 && (group || table->force_index))) { double rec_per_key; double index_scan_time; @@ -13148,7 +13167,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, select_limit= table_records; if (group) { - rec_per_key= keyinfo->rec_per_key[used_key_parts-1]; + rec_per_key= used_key_parts ? keyinfo->rec_per_key[used_key_parts-1] + : 1; set_if_bigger(rec_per_key, 1); /* With a grouping query each group containing on average @@ -13203,13 +13223,13 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, */ index_scan_time= select_limit/rec_per_key * min(rec_per_key, table->file->scan_time()); - if (is_covering || - ref_key < 0 && (group || table->force_index) || + if ((ref_key < 0 && is_covering) || + (ref_key < 0 && (group || table->force_index)) || index_scan_time < read_time) { ha_rows quick_records= table_records; - if (is_best_covering && !is_covering || - is_covering && ref_key_quick_rows < select_limit) + if ((is_best_covering && !is_covering) || + (is_covering && ref_key_quick_rows < select_limit)) continue; if (table->quick_keys.is_set(nr)) quick_records= table->quick_rows[nr]; @@ -13417,8 +13437,8 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order, */ if ((order != join->group_list || !(join->select_options & SELECT_BIG_RESULT) || - select && select->quick && - select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) && + (select && select->quick && + select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)) && test_if_skip_sort_order(tab,order,select_limit,0, is_order_by ? &table->keys_in_use_for_order_by : &table->keys_in_use_for_group_by)) @@ -13479,8 +13499,24 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order, tab->records= table->sort.found_records; // For SQL_CALC_ROWS if (select) { + /* + We need to preserve tablesort's output resultset here, because + QUICK_INDEX_MERGE_SELECT::~QUICK_INDEX_MERGE_SELECT (called by + SQL_SELECT::cleanup()) may free it assuming it's the result of the quick + select operation that we no longer need. Note that all the other parts of + this data structure are cleaned up when + QUICK_INDEX_MERGE_SELECT::get_next encounters end of data, so the next + SQL_SELECT::cleanup() call changes sort.io_cache alone. + */ + IO_CACHE *tablesort_result_cache; + + tablesort_result_cache= table->sort.io_cache; + table->sort.io_cache= NULL; + select->cleanup(); // filesort did select tab->select= 0; + table->quick_keys.clear_all(); // as far as we cleanup select->quick + table->sort.io_cache= tablesort_result_cache; } tab->select_cond=0; tab->last_inner= 0; @@ -13854,7 +13890,7 @@ SORT_FIELD *make_unireg_sortorder(ORDER *order, uint *length, pos->field= ((Item_sum*) item)->get_tmp_table_field(); else if (item->type() == Item::COPY_STR_ITEM) { // Blob patch - pos->item= ((Item_copy_string*) item)->item; + pos->item= ((Item_copy*) item)->get_item(); } else pos->item= *order->item; @@ -14243,8 +14279,8 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, /* Lookup the current GROUP field in the FROM clause. */ order_item_type= order_item->type(); from_field= (Field*) not_found_field; - if (is_group_field && - order_item_type == Item::FIELD_ITEM || + if ((is_group_field && + order_item_type == Item::FIELD_ITEM) || order_item_type == Item::REF_ITEM) { from_field= find_field_in_tables(thd, (Item_ident*) order_item, tables, @@ -14679,7 +14715,7 @@ get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables) if (!map || (map & (RAND_TABLE_BIT | OUTER_REF_TABLE_BIT))) DBUG_RETURN(0); - for (; !(map & tables->table->map); tables= tables->next_leaf); + for (; !(map & tables->table->map); tables= tables->next_leaf) ; if (map != tables->table->map) DBUG_RETURN(0); // More than one table DBUG_PRINT("exit",("sort by table: %d",tables->table->tablenr)); @@ -14925,7 +14961,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, pos= item; if (item->field->flags & BLOB_FLAG) { - if (!(pos= new Item_copy_string(pos))) + if (!(pos= Item_copy::create(pos))) goto err; /* Item_copy_string::copy for function can call @@ -14979,7 +15015,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, on how the value is to be used: In some cases this may be an argument in a group function, like: IF(ISNULL(col),0,COUNT(*)) */ - if (!(pos=new Item_copy_string(pos))) + if (!(pos= Item_copy::create(pos))) goto err; if (i < border) // HAVING, ORDER and GROUP BY { @@ -15032,8 +15068,8 @@ copy_fields(TMP_TABLE_PARAM *param) (*ptr->do_copy)(ptr); List_iterator_fast<Item> it(param->copy_funcs); - Item_copy_string *item; - while ((item = (Item_copy_string*) it++)) + Item_copy *item; + while ((item = (Item_copy*) it++)) item->copy(); } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index d08b3a248c4..d07e951bfd1 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -601,7 +601,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) if (open_normal_and_derived_tables(thd, table_list, 0)) { if (!table_list->view || - thd->is_error() && thd->main_da.sql_errno() != ER_VIEW_INVALID) + (thd->is_error() && thd->main_da.sql_errno() != ER_VIEW_INVALID)) DBUG_RETURN(TRUE); /* @@ -2819,8 +2819,8 @@ make_table_name_list(THD *thd, List<LEX_STRING> *table_names, LEX *lex, LOOKUP_FIELD_VALUES *lookup_field_vals, bool with_i_schema, LEX_STRING *db_name) { - char path[FN_REFLEN]; - build_table_filename(path, sizeof(path), db_name->str, "", "", 0); + char path[FN_REFLEN + 1]; + build_table_filename(path, sizeof(path) - 1, db_name->str, "", "", 0); if (!lookup_field_vals->wild_table_value && lookup_field_vals->table_value.str) { @@ -2982,8 +2982,8 @@ static int fill_schema_table_names(THD *thd, TABLE *table, else { enum legacy_db_type not_used; - char path[FN_REFLEN]; - (void) build_table_filename(path, sizeof(path), db_name->str, + char path[FN_REFLEN + 1]; + (void) build_table_filename(path, sizeof(path) - 1, db_name->str, table_name->str, reg_ext, 0); switch (mysql_frm_type(thd, path, ¬_used)) { case FRMTYPE_ERROR: @@ -3238,10 +3238,10 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) if lookup value is empty string then it's impossible table name or db name */ - if (lookup_field_vals.db_value.str && - !lookup_field_vals.db_value.str[0] || - lookup_field_vals.table_value.str && - !lookup_field_vals.table_value.str[0]) + if ((lookup_field_vals.db_value.str && + !lookup_field_vals.db_value.str[0]) || + (lookup_field_vals.table_value.str && + !lookup_field_vals.table_value.str[0])) { error= 0; goto err; @@ -3470,7 +3470,7 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond) MY_STAT stat_info; if (!lookup_field_vals.db_value.str[0]) DBUG_RETURN(0); - path_len= build_table_filename(path, sizeof(path), + path_len= build_table_filename(path, sizeof(path) - 1, lookup_field_vals.db_value.str, "", "", 0); path[path_len-1]= 0; if (!my_stat(path,&stat_info,MYF(0))) @@ -4116,10 +4116,10 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, TYPE_ENUM_PROCEDURE)) return 0; - if (lex->sql_command == SQLCOM_SHOW_STATUS_PROC && - proc_table->field[2]->val_int() == TYPE_ENUM_PROCEDURE || - lex->sql_command == SQLCOM_SHOW_STATUS_FUNC && - proc_table->field[2]->val_int() == TYPE_ENUM_FUNCTION || + if ((lex->sql_command == SQLCOM_SHOW_STATUS_PROC && + proc_table->field[2]->val_int() == TYPE_ENUM_PROCEDURE) || + (lex->sql_command == SQLCOM_SHOW_STATUS_FUNC && + proc_table->field[2]->val_int() == TYPE_ENUM_FUNCTION) || (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0) { restore_record(table, s->default_values); @@ -7071,6 +7071,12 @@ bool show_create_trigger(THD *thd, const sp_name *trg_name) if (!lst) return TRUE; + if (check_table_access(thd, TRIGGER_ACL, lst, 1, TRUE)) + { + my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "TRIGGER"); + return TRUE; + } + /* Open the table by name in order to load Table_triggers_list object. diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 1dd7b55d136..7759985ba85 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -322,12 +322,24 @@ bool String::set_or_copy_aligned(const char *str,uint32 arg_length, return copy_aligned(str, arg_length, offset, cs); } - /* Copy with charset conversion */ + +/** + Copies the character data into this String, with optional character set + conversion. + + @return + FALSE ok + TRUE Could not allocate result buffer + +*/ bool String::copy(const char *str, uint32 arg_length, CHARSET_INFO *from_cs, CHARSET_INFO *to_cs, uint *errors) { uint32 offset; + + DBUG_ASSERT(!str || str != Ptr); + if (!needs_conversion(arg_length, from_cs, to_cs, &offset)) { *errors= 0; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2744619e138..e752421223a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -68,6 +68,234 @@ static void wait_for_kill_signal(THD *thd) #endif +/** + @brief Helper function for explain_filename +*/ +static char* add_identifier(char *to_p, const char * end_p, + const char* name, uint name_len, int errcode) +{ + uint res; + uint errors; + const char *conv_name; + char tmp_name[FN_REFLEN]; + char conv_string[FN_REFLEN]; + + DBUG_ENTER("add_identifier"); + if (!name[name_len]) + conv_name= name; + else + { + strnmov(tmp_name, name, name_len); + tmp_name[name_len]= 0; + conv_name= tmp_name; + } + res= strconvert(&my_charset_filename, conv_name, system_charset_info, + conv_string, FN_REFLEN, &errors); + if (!res || errors) + conv_name= name; + else + { + DBUG_PRINT("info", ("conv '%s' -> '%s'", conv_name, conv_string)); + conv_name= conv_string; + } + + if (errcode) + to_p+= my_snprintf(to_p, end_p - to_p, ER(errcode), conv_name); + else + to_p+= my_snprintf(to_p, end_p - to_p, "`%s`", conv_name); + return to_p; +} + + +/** + @brief Explain a path name by split it to database, table etc. + + @details Break down the path name to its logic parts + (database, table, partition, subpartition). + filename_to_tablename cannot be used on partitions, due to the #P# part. + There can be up to 6 '#', #P# for partition, #SP# for subpartition + and #TMP# or #REN# for temporary or renamed partitions. + This should be used when something should be presented to a user in a + diagnostic, error etc. when it would be useful to know what a particular + file [and directory] means. Such as SHOW ENGINE STATUS, error messages etc. + + @param from Path name in my_charset_filename + Null terminated in my_charset_filename, normalized + to use '/' as directory separation character. + @param to Explained name in system_charset_info + @param to_length Size of to buffer + @param explain_mode Requested output format. + EXPLAIN_ALL_VERBOSE -> + [Database `db`, ]Table `tbl`[,[ Temporary| Renamed] + Partition `p` [, Subpartition `sp`]] + EXPLAIN_PARTITIONS_VERBOSE -> `db`.`tbl` + [[ Temporary| Renamed] Partition `p` + [, Subpartition `sp`]] + EXPLAIN_PARTITIONS_AS_COMMENT -> `db`.`tbl` |* + [,[ Temporary| Renamed] Partition `p` + [, Subpartition `sp`]] *| + (| is really a /, and it is all in one line) + + @retval Length of returned string +*/ + +uint explain_filename(const char *from, + char *to, + uint to_length, + enum_explain_filename_mode explain_mode) +{ + uint res= 0; + char *to_p= to; + char *end_p= to_p + to_length; + const char *db_name= NULL; + int db_name_len= 0; + const char *table_name; + int table_name_len= 0; + const char *part_name= NULL; + int part_name_len= 0; + const char *subpart_name= NULL; + int subpart_name_len= 0; + enum enum_file_name_type {NORMAL, TEMP, RENAMED} name_type= NORMAL; + const char *tmp_p; + DBUG_ENTER("explain_filename"); + DBUG_PRINT("enter", ("from '%s'", from)); + tmp_p= from; + table_name= from; + /* + If '/' then take last directory part as database. + '/' is the directory separator, not FN_LIB_CHAR + */ + while ((tmp_p= strchr(tmp_p, '/'))) + { + db_name= table_name; + /* calculate the length */ + db_name_len= tmp_p - db_name; + tmp_p++; + table_name= tmp_p; + } + tmp_p= table_name; + while (!res && (tmp_p= strchr(tmp_p, '#'))) + { + tmp_p++; + switch (tmp_p[0]) { + case 'P': + case 'p': + if (tmp_p[1] == '#') + part_name= tmp_p + 2; + else + res= 1; + tmp_p+= 2; + break; + case 'S': + case 's': + if ((tmp_p[1] == 'P' || tmp_p[1] == 'p') && tmp_p[2] == '#') + { + part_name_len= tmp_p - part_name - 1; + subpart_name= tmp_p + 3; + } + else + res= 2; + tmp_p+= 3; + break; + case 'T': + case 't': + if ((tmp_p[1] == 'M' || tmp_p[1] == 'm') && + (tmp_p[2] == 'P' || tmp_p[2] == 'p') && + tmp_p[3] == '#' && !tmp_p[4]) + name_type= TEMP; + else + res= 3; + tmp_p+= 4; + break; + case 'R': + case 'r': + if ((tmp_p[1] == 'E' || tmp_p[1] == 'e') && + (tmp_p[2] == 'N' || tmp_p[2] == 'n') && + tmp_p[3] == '#' && !tmp_p[4]) + name_type= RENAMED; + else + res= 4; + tmp_p+= 4; + break; + default: + res= 5; + } + } + if (res) + { + /* Better to give something back if we fail parsing, than nothing at all */ + DBUG_PRINT("info", ("Error in explain_filename: %u", res)); + sql_print_warning("Invalid (old?) table or database name '%s'", from); + DBUG_RETURN(my_snprintf(to, to_length, + "<result %u when explaining filename '%s'>", + res, from)); + } + if (part_name) + { + table_name_len= part_name - table_name - 3; + if (subpart_name) + subpart_name_len= strlen(subpart_name); + else + part_name_len= strlen(part_name); + if (name_type != NORMAL) + { + if (subpart_name) + subpart_name_len-= 5; + else + part_name_len-= 5; + } + } + if (db_name) + { + if (explain_mode == EXPLAIN_ALL_VERBOSE) + { + to_p= add_identifier(to_p, end_p, db_name, db_name_len, + ER_DATABASE_NAME); + to_p= strnmov(to_p, ", ", end_p - to_p); + } + else + { + to_p= add_identifier(to_p, end_p, db_name, db_name_len, 0); + to_p= strnmov(to_p, ".", end_p - to_p); + } + } + if (explain_mode == EXPLAIN_ALL_VERBOSE) + to_p= add_identifier(to_p, end_p, table_name, table_name_len, + ER_TABLE_NAME); + else + to_p= add_identifier(to_p, end_p, table_name, table_name_len, 0); + if (part_name) + { + if (explain_mode == EXPLAIN_PARTITIONS_AS_COMMENT) + to_p= strnmov(to_p, " /* ", end_p - to_p); + else if (explain_mode == EXPLAIN_PARTITIONS_VERBOSE) + to_p= strnmov(to_p, " ", end_p - to_p); + else + to_p= strnmov(to_p, ", ", end_p - to_p); + if (name_type != NORMAL) + { + if (name_type == TEMP) + to_p= strnmov(to_p, ER(ER_TEMPORARY_NAME), end_p - to_p); + else + to_p= strnmov(to_p, ER(ER_RENAMED_NAME), end_p - to_p); + to_p= strnmov(to_p, " ", end_p - to_p); + } + to_p= add_identifier(to_p, end_p, part_name, part_name_len, + ER_PARTITION_NAME); + if (subpart_name) + { + to_p= strnmov(to_p, ", ", end_p - to_p); + to_p= add_identifier(to_p, end_p, subpart_name, subpart_name_len, + ER_SUBPARTITION_NAME); + } + if (explain_mode == EXPLAIN_PARTITIONS_AS_COMMENT) + to_p= strnmov(to_p, " */", end_p - to_p); + } + DBUG_PRINT("exit", ("to '%s'", to)); + DBUG_RETURN(to_p - to); +} + + /* Translate a file name to a table name (WL #1324). @@ -1287,7 +1515,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) /* Build shadow frm file name */ - build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt); + build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt); strxmov(shadow_frm_name, shadow_path, reg_ext, NullS); if (flags & WFRM_WRITE_SHADOW) { @@ -1362,7 +1590,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) /* Build frm file name */ - build_table_filename(path, sizeof(path), lpt->db, + build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0); strxmov(frm_name, path, reg_ext, NullS); /* @@ -1460,10 +1688,13 @@ void write_bin_log(THD *thd, bool clear_error, { if (mysql_bin_log.is_open()) { + int errcode= 0; if (clear_error) thd->clear_error(); + else + errcode= query_error_code(thd, TRUE); thd->binlog_query(THD::STMT_QUERY_TYPE, - query, query_length, FALSE, FALSE, THD::NOT_KILLED); + query, query_length, FALSE, FALSE, errcode); } } @@ -1561,7 +1792,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, bool dont_log_query) { TABLE_LIST *table; - char path[FN_REFLEN], *alias; + char path[FN_REFLEN + 1], *alias; uint path_length; String wrong_tables; int error= 0; @@ -1691,13 +1922,14 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, } alias= (lower_case_table_names == 2) ? table->alias : table->table_name; /* remove .frm file and engine files */ - path_length= build_table_filename(path, sizeof(path), db, alias, reg_ext, + path_length= build_table_filename(path, sizeof(path) - 1, db, alias, + reg_ext, table->internal_tmp_table ? FN_IS_TMP : 0); } if (drop_temporary || - (table_type == NULL && - (access(path, F_OK) && + ((table_type == NULL && + access(path, F_OK) && ha_create_table_from_engine(thd, db, alias)) || (!drop_view && mysql_frm_type(thd, path, &frm_db_type) != FRMTYPE_TABLE))) @@ -1779,7 +2011,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, if (!dont_log_query) { if (!thd->current_stmt_binlog_row_based || - non_temp_tables_count > 0 && !tmp_table_deleted) + (non_temp_tables_count > 0 && !tmp_table_deleted)) { /* In this case, we are either using statement-based @@ -1847,11 +2079,11 @@ err_with_placeholders: bool quick_rm_table(handlerton *base,const char *db, const char *table_name, uint flags) { - char path[FN_REFLEN]; + char path[FN_REFLEN + 1]; bool error= 0; DBUG_ENTER("quick_rm_table"); - uint path_length= build_table_filename(path, sizeof(path), + uint path_length= build_table_filename(path, sizeof(path) - 1, db, table_name, reg_ext, flags); if (my_delete(path,MYF(0))) error= 1; /* purecov: inspected */ @@ -2488,8 +2720,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, } /* Don't pack rows in old tables if the user has requested this */ if ((sql_field->flags & BLOB_FLAG) || - sql_field->sql_type == MYSQL_TYPE_VARCHAR && - create_info->row_type != ROW_TYPE_FIXED) + (sql_field->sql_type == MYSQL_TYPE_VARCHAR && + create_info->row_type != ROW_TYPE_FIXED)) (*db_options)|= HA_OPTION_PACK_RECORD; it2.rewind(); } @@ -2958,7 +3190,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->sql_type == MYSQL_TYPE_VARCHAR || sql_field->pack_flag & FIELDFLAG_BLOB))) { - if (column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB) || + if ((column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB)) || sql_field->sql_type == MYSQL_TYPE_VARCHAR) key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY; else @@ -3240,7 +3472,7 @@ bool mysql_create_table_no_lock(THD *thd, bool internal_tmp_table, uint select_field_count) { - char path[FN_REFLEN]; + char path[FN_REFLEN + 1]; uint path_length; const char *alias; uint db_options, key_count; @@ -3448,7 +3680,7 @@ bool mysql_create_table_no_lock(THD *thd, } else { - path_length= build_table_filename(path, sizeof(path), db, alias, reg_ext, + path_length= build_table_filename(path, sizeof(path) - 1, db, alias, reg_ext, internal_tmp_table ? FN_IS_TMP : 0); } @@ -3762,7 +3994,8 @@ mysql_rename_table(handlerton *base, const char *old_db, const char *new_name, uint flags) { THD *thd= current_thd; - char from[FN_REFLEN], to[FN_REFLEN], lc_from[FN_REFLEN], lc_to[FN_REFLEN]; + char from[FN_REFLEN + 1], to[FN_REFLEN + 1], + lc_from[FN_REFLEN + 1], lc_to[FN_REFLEN + 1]; char *from_base= from, *to_base= to; char tmp_name[NAME_LEN+1]; handler *file; @@ -3774,9 +4007,9 @@ mysql_rename_table(handlerton *base, const char *old_db, file= (base == NULL ? 0 : get_new_handler((TABLE_SHARE*) 0, thd->mem_root, base)); - build_table_filename(from, sizeof(from), old_db, old_name, "", + build_table_filename(from, sizeof(from) - 1, old_db, old_name, "", flags & FN_FROM_IS_TMP); - build_table_filename(to, sizeof(to), new_db, new_name, "", + build_table_filename(to, sizeof(to) - 1, new_db, new_name, "", flags & FN_TO_IS_TMP); /* @@ -3789,13 +4022,13 @@ mysql_rename_table(handlerton *base, const char *old_db, { strmov(tmp_name, old_name); my_casedn_str(files_charset_info, tmp_name); - build_table_filename(lc_from, sizeof(lc_from), old_db, tmp_name, "", + build_table_filename(lc_from, sizeof(lc_from) - 1, old_db, tmp_name, "", flags & FN_FROM_IS_TMP); from_base= lc_from; strmov(tmp_name, new_name); my_casedn_str(files_charset_info, tmp_name); - build_table_filename(lc_to, sizeof(lc_to), new_db, tmp_name, "", + build_table_filename(lc_to, sizeof(lc_to) - 1, new_db, tmp_name, "", flags & FN_TO_IS_TMP); to_base= lc_to; } @@ -3926,16 +4159,16 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table, else { char* backup_dir= thd->lex->backup_dir; - char src_path[FN_REFLEN], dst_path[FN_REFLEN], uname[FN_REFLEN]; + char src_path[FN_REFLEN], dst_path[FN_REFLEN + 1], uname[FN_REFLEN]; char* table_name= table->table_name; char* db= table->db; - VOID(tablename_to_filename(table->table_name, uname, sizeof(uname))); + VOID(tablename_to_filename(table->table_name, uname, sizeof(uname) - 1)); if (fn_format_relative_to_data_home(src_path, uname, backup_dir, reg_ext)) DBUG_RETURN(-1); // protect buffer overflow - build_table_filename(dst_path, sizeof(dst_path), + build_table_filename(dst_path, sizeof(dst_path) - 1, db, table_name, reg_ext, 0); if (lock_and_wait_for_table_name(thd,table)) @@ -4547,7 +4780,7 @@ send_result_message: const char *err_msg= thd->main_da.message(); if (!thd->vio_ok()) { - sql_print_error(err_msg); + sql_print_error("%s", err_msg); } else { @@ -4857,7 +5090,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, HA_CREATE_INFO *create_info) { TABLE *name_lock= 0; - char src_path[FN_REFLEN], dst_path[FN_REFLEN]; + char src_path[FN_REFLEN], dst_path[FN_REFLEN + 1]; uint dst_path_length; char *db= table->db; char *table_name= table->table_name; @@ -4867,7 +5100,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, #ifdef WITH_PARTITION_STORAGE_ENGINE char tmp_path[FN_REFLEN]; #endif - char ts_name[FN_LEN]; + char ts_name[FN_LEN + 1]; DBUG_ENTER("mysql_create_like_table"); @@ -4916,7 +5149,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, goto err; if (!name_lock) goto table_exists; - dst_path_length= build_table_filename(dst_path, sizeof(dst_path), + dst_path_length= build_table_filename(dst_path, sizeof(dst_path) - 1, db, table_name, reg_ext, 0); if (!access(dst_path, F_OK)) goto table_exists; @@ -5314,7 +5547,7 @@ compare_tables(TABLE *table, create_info->used_fields & HA_CREATE_USED_ENGINE || create_info->used_fields & HA_CREATE_USED_CHARSET || create_info->used_fields & HA_CREATE_USED_DEFAULT_CHARSET || - create_info->used_fields & HA_CREATE_USED_ROW_FORMAT || + (table->s->row_type != create_info->row_type) || create_info->used_fields & HA_CREATE_USED_PACK_KEYS || create_info->used_fields & HA_CREATE_USED_MAX_ROWS || (alter_info->flags & (ALTER_RECREATE | ALTER_FOREIGN_KEY)) || @@ -5358,8 +5591,8 @@ compare_tables(TABLE *table, /* Don't pack rows in old tables if the user has requested this. */ if (create_info->row_type == ROW_TYPE_DYNAMIC || (tmp_new_field->flags & BLOB_FLAG) || - tmp_new_field->sql_type == MYSQL_TYPE_VARCHAR && - create_info->row_type != ROW_TYPE_FIXED) + (tmp_new_field->sql_type == MYSQL_TYPE_VARCHAR && + create_info->row_type != ROW_TYPE_FIXED)) create_info->table_options|= HA_OPTION_PACK_RECORD; /* Check if field was renamed */ @@ -5657,7 +5890,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (!create_info->tablespace && create_info->storage_media != HA_SM_MEMORY) { - char *tablespace= static_cast<char *>(thd->alloc(FN_LEN)); + char *tablespace= static_cast<char *>(thd->alloc(FN_LEN + 1)); /* Regular alter table of disk stored table (no tablespace/storage change) Copy tablespace name @@ -6024,10 +6257,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, { TABLE *table, *new_table= 0, *name_lock= 0; int error= 0; - char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN]; + char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN + 1]; char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias; char index_file[FN_REFLEN], data_file[FN_REFLEN]; - char path[FN_REFLEN]; + char path[FN_REFLEN + 1]; char reg_path[FN_REFLEN+1]; ha_rows copied,deleted; handlerton *old_db_type, *new_db_type, *save_old_db_type; @@ -6040,21 +6273,15 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, #endif bool need_lock_for_indexes= TRUE; KEY *key_info_buffer; - uint index_drop_count; - uint *index_drop_buffer; - uint index_add_count; - uint *index_add_buffer; - uint candidate_key_count; + uint index_drop_count= 0; + uint *index_drop_buffer= NULL; + uint index_add_count= 0; + uint *index_add_buffer= NULL; + uint candidate_key_count= 0; bool committed= 0; bool no_pk; DBUG_ENTER("mysql_alter_table"); - LINT_INIT(index_add_count); - LINT_INIT(index_drop_count); - LINT_INIT(index_add_buffer); - LINT_INIT(index_drop_buffer); - LINT_INIT(candidate_key_count); - /* Check if we attempt to alter mysql.slow_log or mysql.general_log table and return an error if @@ -6108,8 +6335,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, db=table_list->db; if (!new_db || !my_strcasecmp(table_alias_charset, new_db, db)) new_db= db; - build_table_filename(reg_path, sizeof(reg_path), db, table_name, reg_ext, 0); - build_table_filename(path, sizeof(path), db, table_name, "", 0); + build_table_filename(reg_path, sizeof(reg_path) - 1, db, table_name, reg_ext, 0); + build_table_filename(path, sizeof(path) - 1, db, table_name, "", 0); mysql_ha_rm_tables(thd, table_list, FALSE); @@ -6140,6 +6367,20 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (frm_type == FRMTYPE_VIEW && !(alter_info->flags & ~ALTER_RENAME)) { /* + The following branch handles "ALTER VIEW v1 /no arguments/;" + This feature is not documented one. + However, before "OPTIMIZE TABLE t1;" was implemented, + ALTER TABLE with no alter_specifications was used to force-rebuild + the table. That's why this grammar is allowed. That's why we ignore + it for views. So just do nothing in such a case. + */ + if (!new_name) + { + my_ok(thd); + DBUG_RETURN(FALSE); + } + + /* Avoid problems with a rename on a table that we have locked or if the user is trying to to do this in a transcation context */ @@ -6166,7 +6407,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, { thd->clear_error(); Query_log_event qinfo(thd, thd->query, thd->query_length, - 0, FALSE, THD::NOT_KILLED); + 0, FALSE, 0); mysql_bin_log.write(&qinfo); } my_ok(thd); @@ -6242,7 +6483,7 @@ view_err: DBUG_RETURN(TRUE); } - build_table_filename(new_name_buff, sizeof(new_name_buff), + build_table_filename(new_name_buff, sizeof(new_name_buff) - 1, new_db, new_name_buff, reg_ext, 0); if (!access(new_name_buff, F_OK)) { @@ -6293,7 +6534,10 @@ view_err: } if (create_info->row_type == ROW_TYPE_NOT_USED) + { create_info->row_type= table->s->row_type; + create_info->used_fields |= HA_CREATE_USED_ROW_FORMAT; + } DBUG_PRINT("info", ("old type: %s new type: %s", ha_resolve_storage_engine_name(old_db_type), @@ -6740,9 +6984,9 @@ view_err: } else { - char path[FN_REFLEN]; + char path[FN_REFLEN + 1]; /* table is a normal table: Create temporary table in same directory */ - build_table_filename(path, sizeof(path), new_db, tmp_name, "", + build_table_filename(path, sizeof(path) - 1, new_db, tmp_name, "", FN_IS_TMP); /* Open our intermediate table */ new_table=open_temporary_table(thd, path, new_db, tmp_name,0); @@ -6972,12 +7216,12 @@ view_err: } else if (mysql_rename_table(new_db_type, new_db, tmp_name, new_db, new_alias, FN_FROM_IS_TMP) || - (new_name != table_name || new_db != db) && // we also do rename + ((new_name != table_name || new_db != db) && // we also do rename (need_copy_table != ALTER_TABLE_METADATA_ONLY || mysql_rename_table(save_old_db_type, db, table_name, new_db, new_alias, NO_FRM_RENAME)) && Table_triggers_list::change_table_name(thd, db, table_name, - new_db, new_alias)) + new_db, new_alias))) { /* Try to get everything back. */ error=1; @@ -7070,7 +7314,7 @@ view_err: */ char path[FN_REFLEN]; TABLE *t_table; - build_table_filename(path, sizeof(path), new_db, table_name, "", 0); + build_table_filename(path + 1, sizeof(path) - 1, new_db, table_name, "", 0); t_table= open_temporary_table(thd, path, new_db, tmp_name, 0); if (t_table) { diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 8cab8fff2f3..c055268ecca 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -344,7 +344,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) need second part of condition below, since check_access() function also checks that db is specified. */ - if (!thd->lex->spname->m_db.length || create && !tables->db_length) + if (!thd->lex->spname->m_db.length || (create && !tables->db_length)) { my_error(ER_NO_DB_ERROR, MYF(0)); DBUG_RETURN(TRUE); diff --git a/sql/sql_union.cc b/sql/sql_union.cc index fd3036e3d80..cbf94ad7181 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -653,10 +653,22 @@ bool st_select_lex_unit::cleanup() join->tables= 0; } error|= fake_select_lex->cleanup(); - if (fake_select_lex->order_list.elements) + /* + There are two cases when we should clean order items: + 1. UNION with SELECTs which all enclosed into braces + in this case global_parameters == fake_select_lex + 2. UNION where last SELECT is not enclosed into braces + in this case global_parameters == 'last select' + So we should use global_parameters->order_list for + proper order list clean up. + Note: global_parameters and fake_select_lex are always + initialized for UNION + */ + DBUG_ASSERT(global_parameters); + if (global_parameters->order_list.elements) { ORDER *ord; - for (ord= (ORDER*)fake_select_lex->order_list.first; ord; ord= ord->next) + for (ord= (ORDER*)global_parameters->order_list.first; ord; ord= ord->next) (*ord->item)->cleanup(); } } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 1a8c43f46aa..17cc683e14a 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -795,12 +795,15 @@ int mysql_update(THD *thd, { if (mysql_bin_log.is_open()) { + int errcode= 0; if (error < 0) thd->clear_error(); + else + errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); + if (thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query, thd->query_length, - transactional_table, FALSE, killed_status) && - transactional_table) + transactional_table, FALSE, errcode)) { error=1; // Rollback update } @@ -1031,7 +1034,6 @@ reopen_tables: DBUG_RETURN(TRUE); } - table->mark_columns_needed_for_update(); DBUG_PRINT("info",("setting table `%s` for update", tl->alias)); /* If table will be updated we should not downgrade lock for it and @@ -1275,12 +1277,40 @@ int multi_update::prepare(List<Item> ¬_used_values, } /* + We gather the set of columns read during evaluation of SET expression in + TABLE::tmp_set by pointing TABLE::read_set to it and then restore it after + setup_fields(). + */ + for (table_ref= leaves; table_ref; table_ref= table_ref->next_leaf) + { + TABLE *table= table_ref->table; + if (tables_to_update & table->map) + { + DBUG_ASSERT(table->read_set == &table->def_read_set); + table->read_set= &table->tmp_set; + bitmap_clear_all(table->read_set); + } + } + + /* We have to check values after setup_tables to get covering_keys right in reference tables */ - if (setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0)) - DBUG_RETURN(1); + int error= setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0); + + for (table_ref= leaves; table_ref; table_ref= table_ref->next_leaf) + { + TABLE *table= table_ref->table; + if (tables_to_update & table->map) + { + table->read_set= &table->def_read_set; + bitmap_union(table->read_set, &table->tmp_set); + } + } + + if (error) + DBUG_RETURN(1); /* Save tables beeing updated in update_tables @@ -1375,6 +1405,8 @@ int multi_update::prepare(List<Item> ¬_used_values, a row in this table will never be read twice. This is true under the following conditions: + - No column is both written to and read in SET expressions. + - We are doing a table scan and the data is in a separate file (MyISAM) or if we don't update a clustered key. @@ -1389,6 +1421,9 @@ int multi_update::prepare(List<Item> ¬_used_values, WARNING This code is a bit dependent of how make_join_readinfo() works. + The field table->tmp_set is used for keeping track of which fields are + read during evaluation of the SET expression. See multi_update::prepare. + RETURN 0 Not safe to update 1 Safe to update @@ -1409,6 +1444,8 @@ static bool safe_update_on_fly(THD *thd, JOIN_TAB *join_tab, case JT_REF_OR_NULL: return !is_key_used(table, join_tab->ref.key, table->write_set); case JT_ALL: + if (bitmap_is_overlapping(&table->tmp_set, table->write_set)) + return FALSE; /* If range search on index */ if (join_tab->quick) return !join_tab->quick->is_keys_used(table->write_set); @@ -1464,17 +1501,18 @@ multi_update::initialize_tables(JOIN *join) ORDER group; TMP_TABLE_PARAM *tmp_param; - table->mark_columns_needed_for_update(); if (ignore) table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); if (table == main_table) // First table in join { if (safe_update_on_fly(thd, join->join_tab, table_ref, all_tables)) { - table_to_update= main_table; // Update table on the fly + table->mark_columns_needed_for_update(); + table_to_update= table; // Update table on the fly continue; } } + table->mark_columns_needed_for_update(); table->prepare_for_position(); /* @@ -1775,7 +1813,7 @@ void multi_update::abort() { /* the error was handled or nothing deleted and no side effects return */ if (error_handled || - !thd->transaction.stmt.modified_non_trans_table && !updated) + (!thd->transaction.stmt.modified_non_trans_table && !updated)) return; /* Something already updated so we have to invalidate cache */ @@ -1812,9 +1850,10 @@ void multi_update::abort() got caught and if happens later the killed error is written into repl event. */ + int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query, thd->query_length, - transactional_tables, FALSE); + transactional_tables, FALSE, errcode); } thd->transaction.all.modified_non_trans_table= TRUE; } @@ -2040,12 +2079,14 @@ bool multi_update::send_eof() { if (mysql_bin_log.is_open()) { + int errcode= 0; if (local_error == 0) thd->clear_error(); + else + errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); if (thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query, thd->query_length, - transactional_tables, FALSE, killed_status) && - trans_safe) + transactional_tables, FALSE, errcode)) { local_error= 1; // Rollback update } diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 4f207f78688..2a4c5c950fe 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -661,8 +661,9 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, buff.append(STRING_WITH_LEN(" AS ")); buff.append(views->source.str, views->source.length); + int errcode= query_error_code(thd, TRUE); thd->binlog_query(THD::STMT_QUERY_TYPE, - buff.ptr(), buff.length(), FALSE, FALSE, THD::NOT_KILLED); + buff.ptr(), buff.length(), FALSE, FALSE, errcode); } VOID(pthread_mutex_unlock(&LOCK_open)); @@ -800,7 +801,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, char md5[MD5_BUFF_LENGTH]; bool can_be_merged; - char dir_buff[FN_REFLEN], path_buff[FN_REFLEN]; + char dir_buff[FN_REFLEN + 1], path_buff[FN_REFLEN + 1]; LEX_STRING dir, file, path; int error= 0; DBUG_ENTER("mysql_register_view"); @@ -877,11 +878,11 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, } loop_out: /* print file name */ - dir.length= build_table_filename(dir_buff, sizeof(dir_buff), + dir.length= build_table_filename(dir_buff, sizeof(dir_buff) - 1, view->db, "", "", 0); dir.str= dir_buff; - path.length= build_table_filename(path_buff, sizeof(path_buff), + path.length= build_table_filename(path_buff, sizeof(path_buff) - 1, view->db, view->table_name, reg_ext, 0); path.str= path_buff; @@ -1568,7 +1569,7 @@ err: bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) { - char path[FN_REFLEN]; + char path[FN_REFLEN + 1]; TABLE_LIST *view; String non_existant_views; char *wrong_object_db= NULL, *wrong_object_name= NULL; @@ -1583,7 +1584,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) { TABLE_SHARE *share; frm_type_enum type= FRMTYPE_ERROR; - build_table_filename(path, sizeof(path), + build_table_filename(path, sizeof(path) - 1, view->db, view->table_name, reg_ext, 0); if (access(path, F_OK) || @@ -1928,7 +1929,7 @@ mysql_rename_view(THD *thd, { LEX_STRING pathstr; File_parser *parser; - char path_buff[FN_REFLEN]; + char path_buff[FN_REFLEN + 1]; bool error= TRUE; DBUG_ENTER("mysql_rename_view"); @@ -1941,7 +1942,7 @@ mysql_rename_view(THD *thd, is_equal(&view_type, parser->type())) { TABLE_LIST view_def; - char dir_buff[FN_REFLEN]; + char dir_buff[FN_REFLEN + 1]; LEX_STRING dir, file; /* diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 0b158ff7574..7d6a7ade540 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5925,7 +5925,7 @@ alter_list_item: MYSQL_YYABORT; } if (check_table_name($3->table.str,$3->table.length) || - $3->db.str && check_db_name(&$3->db)) + ($3->db.str && check_db_name(&$3->db))) { my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str); MYSQL_YYABORT; @@ -6079,8 +6079,8 @@ slave_until: | UNTIL_SYM slave_until_opts { LEX *lex=Lex; - if ((lex->mi.log_file_name || lex->mi.pos) && - (lex->mi.relay_log_name || lex->mi.relay_log_pos) || + if (((lex->mi.log_file_name || lex->mi.pos) && + (lex->mi.relay_log_name || lex->mi.relay_log_pos)) || !((lex->mi.log_file_name && lex->mi.pos) || (lex->mi.relay_log_name && lex->mi.relay_log_pos))) { @@ -8493,6 +8493,7 @@ table_factor: MYSQL_YYABORT; sel->add_joined_table($$); lex->pop_context(); + lex->nest_level--; } else if ($4 || $6) { @@ -8501,7 +8502,11 @@ table_factor: MYSQL_YYABORT; } else + { + /* nested join: FROM (t1 JOIN t2 ...), + nest_level is the same as in the outer query */ $$= $3; + } } ; @@ -12118,15 +12123,16 @@ text_or_password: | PASSWORD '(' TEXT_STRING ')' { $$= $3.length ? YYTHD->variables.old_passwords ? - Item_func_old_password::alloc(YYTHD, $3.str) : - Item_func_password::alloc(YYTHD, $3.str) : + Item_func_old_password::alloc(YYTHD, $3.str, $3.length) : + Item_func_password::alloc(YYTHD, $3.str, $3.length) : $3.str; if ($$ == NULL) MYSQL_YYABORT; } | OLD_PASSWORD '(' TEXT_STRING ')' { - $$= $3.length ? Item_func_old_password::alloc(YYTHD, $3.str) : + $$= $3.length ? Item_func_old_password::alloc(YYTHD, $3.str, + $3.length) : $3.str; if ($$ == NULL) MYSQL_YYABORT; @@ -12588,7 +12594,7 @@ grant_user: (char *) YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1); if (buff == NULL) MYSQL_YYABORT; - make_scrambled_password_323(buff, $4.str); + my_make_scrambled_password_323(buff, $4.str, $4.length); $1->password.str= buff; $1->password.length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; } @@ -12598,7 +12604,7 @@ grant_user: (char *) YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH+1); if (buff == NULL) MYSQL_YYABORT; - make_scrambled_password(buff, $4.str); + my_make_scrambled_password(buff, $4.str, $4.length); $1->password.str= buff; $1->password.length= SCRAMBLED_PASSWORD_CHAR_LENGTH; } diff --git a/sql/structs.h b/sql/structs.h index 0a20eee0e9a..a58c18f97c5 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -107,6 +107,10 @@ typedef struct st_reginfo { /* Extra info about reg */ struct st_join_table *join_tab; /* Used by SELECT() */ enum thr_lock_type lock_type; /* How database is used */ bool not_exists_optimize; + /* + TRUE <=> range optimizer found that there is no rows satisfying + table conditions. + */ bool impossible_range; } REGINFO; diff --git a/sql/table.cc b/sql/table.cc index d24ee4c6a27..60a27e136b1 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -464,34 +464,35 @@ inline bool is_system_table_name(const char *name, uint length) CHARSET_INFO *ci= system_charset_info; return ( - /* mysql.proc table */ - length == 4 && - my_tolower(ci, name[0]) == 'p' && - my_tolower(ci, name[1]) == 'r' && - my_tolower(ci, name[2]) == 'o' && - my_tolower(ci, name[3]) == 'c' || - - length > 4 && - ( - /* one of mysql.help* tables */ - my_tolower(ci, name[0]) == 'h' && - my_tolower(ci, name[1]) == 'e' && - my_tolower(ci, name[2]) == 'l' && - my_tolower(ci, name[3]) == 'p' || - - /* one of mysql.time_zone* tables */ - my_tolower(ci, name[0]) == 't' && - my_tolower(ci, name[1]) == 'i' && - my_tolower(ci, name[2]) == 'm' && - my_tolower(ci, name[3]) == 'e' || - - /* mysql.event table */ - my_tolower(ci, name[0]) == 'e' && - my_tolower(ci, name[1]) == 'v' && - my_tolower(ci, name[2]) == 'e' && - my_tolower(ci, name[3]) == 'n' && - my_tolower(ci, name[4]) == 't' - ) + /* mysql.proc table */ + (length == 4 && + my_tolower(ci, name[0]) == 'p' && + my_tolower(ci, name[1]) == 'r' && + my_tolower(ci, name[2]) == 'o' && + my_tolower(ci, name[3]) == 'c') || + + (length > 4 && + ( + /* one of mysql.help* tables */ + (my_tolower(ci, name[0]) == 'h' && + my_tolower(ci, name[1]) == 'e' && + my_tolower(ci, name[2]) == 'l' && + my_tolower(ci, name[3]) == 'p') || + + /* one of mysql.time_zone* tables */ + (my_tolower(ci, name[0]) == 't' && + my_tolower(ci, name[1]) == 'i' && + my_tolower(ci, name[2]) == 'm' && + my_tolower(ci, name[3]) == 'e') || + + /* mysql.event table */ + (my_tolower(ci, name[0]) == 'e' && + my_tolower(ci, name[1]) == 'v' && + my_tolower(ci, name[2]) == 'e' && + my_tolower(ci, name[3]) == 'n' && + my_tolower(ci, name[4]) == 't') + ) + ) ); } @@ -779,7 +780,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, strpos=disk_buff+6; if (!(rec_per_key= (ulong*) alloc_root(&share->mem_root, - sizeof(ulong*)*key_parts))) + sizeof(ulong)*key_parts))) goto err; for (i=0 ; i < keys ; i++, keyinfo++) @@ -3314,8 +3315,8 @@ bool TABLE_LIST::prep_check_option(THD *thd, uint8 check_opt_type) { const char *save_where= thd->where; thd->where= "check option"; - if (!check_option->fixed && - check_option->fix_fields(thd, &check_option) || + if ((!check_option->fixed && + check_option->fix_fields(thd, &check_option)) || check_option->check_cols(1)) { DBUG_RETURN(TRUE); @@ -3341,6 +3342,7 @@ void TABLE_LIST::hide_view_error(THD *thd) if (thd->main_da.sql_errno() == ER_BAD_FIELD_ERROR || thd->main_da.sql_errno() == ER_SP_DOES_NOT_EXIST || + thd->main_da.sql_errno() == ER_FUNC_INEXISTENT_NAME_COLLISION || thd->main_da.sql_errno() == ER_PROCACCESS_DENIED_ERROR || thd->main_da.sql_errno() == ER_COLUMNACCESS_DENIED_ERROR || thd->main_da.sql_errno() == ER_TABLEACCESS_DENIED_ERROR || @@ -4030,7 +4032,7 @@ void Field_iterator_table_ref::set_field_iterator() /* Necesary, but insufficient conditions. */ DBUG_ASSERT(table_ref->is_natural_join || table_ref->nested_join || - table_ref->join_columns && + (table_ref->join_columns && /* This is a merge view. */ ((table_ref->field_translation && table_ref->join_columns->elements == @@ -4039,7 +4041,7 @@ void Field_iterator_table_ref::set_field_iterator() /* This is stored table or a tmptable view. */ (!table_ref->field_translation && table_ref->join_columns->elements == - table_ref->table->s->fields))); + table_ref->table->s->fields)))); field_it= &natural_join_it; DBUG_PRINT("info",("field_it for '%s' is Field_iterator_natural_join", table_ref->alias)); diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc index 6bf43b51df0..0764fe8be33 100644 --- a/sql/thr_malloc.cc +++ b/sql/thr_malloc.cc @@ -21,7 +21,7 @@ extern "C" { void sql_alloc_error_handler(void) { - sql_print_error(ER(ER_OUT_OF_RESOURCES)); + sql_print_error("%s", ER(ER_OUT_OF_RESOURCES)); THD *thd= current_thd; if (thd) diff --git a/sql/time.cc b/sql/time.cc index a6619cf4cee..962b65e454c 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -111,8 +111,8 @@ uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year) if (l_time->month == 1 && l_time->day <= 7-weekday) { if (!week_year && - (first_weekday && weekday != 0 || - !first_weekday && weekday >= 4)) + ((first_weekday && weekday != 0) || + (!first_weekday && weekday >= 4))) return 0; week_year= 1; (*year)--; @@ -129,8 +129,8 @@ uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year) if (week_year && days >= 52*7) { weekday= (weekday + calc_days_in_year(*year)) % 7; - if (!first_weekday && weekday < 4 || - first_weekday && weekday == 0) + if ((!first_weekday && weekday < 4) || + (first_weekday && weekday == 0)) { (*year)++; return 1; diff --git a/sql/tztime.cc b/sql/tztime.cc index 2a94e179600..c7a4ad049ec 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -447,8 +447,8 @@ prepare_tz_info(TIME_ZONE_INFO *sp, MEM_ROOT *storage) } if (end_t == MY_TIME_T_MAX || - (cur_off_and_corr > 0) && - (end_t >= MY_TIME_T_MAX - cur_off_and_corr)) + ((cur_off_and_corr > 0) && + (end_t >= MY_TIME_T_MAX - cur_off_and_corr))) /* end of t space */ break; diff --git a/sql/uniques.cc b/sql/uniques.cc index 858bedb04cd..7b6b628f924 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -603,9 +603,9 @@ bool Unique::get(TABLE *table) outfile=table->sort.io_cache=(IO_CACHE*) my_malloc(sizeof(IO_CACHE), MYF(MY_ZEROFILL)); - if (!outfile || ! my_b_inited(outfile) && + if (!outfile || (! my_b_inited(outfile) && open_cached_file(outfile,mysql_tmpdir,TEMP_PREFIX,READ_RECORD_BUFFER, - MYF(MY_WME))) + MYF(MY_WME)))) return 1; reinit_io_cache(outfile,WRITE_CACHE,0L,0,0); diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 5e2a4ad5da3..1146b2eb73a 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1474,8 +1474,8 @@ int ha_archive::info(uint flag) stats.mean_rec_length= table->s->reclength + buffer.alloced_length(); stats.data_file_length= file_stat.st_size; - stats.create_time= file_stat.st_ctime; - stats.update_time= file_stat.st_mtime; + stats.create_time= (ulong) file_stat.st_ctime; + stats.update_time= (ulong) file_stat.st_mtime; stats.max_data_file_length= share->rows_recorded * stats.mean_rec_length; } stats.delete_length= 0; diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 1f4e1ae48b9..8deb8693960 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -2828,34 +2828,32 @@ int ha_federated::info(uint flag) if (!(row= mysql_fetch_row(result))) goto error; - if (flag & (HA_STATUS_VARIABLE | HA_STATUS_CONST)) - { - /* - deleted is set in ha_federated::info - */ - /* - need to figure out what this means as far as federated is concerned, - since we don't have a "file" + /* + deleted is set in ha_federated::info + */ + /* + need to figure out what this means as far as federated is concerned, + since we don't have a "file" - data_file_length = ? - index_file_length = ? - delete_length = ? - */ - if (row[4] != NULL) - stats.records= (ha_rows) my_strtoll10(row[4], (char**) 0, + data_file_length = ? + index_file_length = ? + delete_length = ? + */ + if (row[4] != NULL) + stats.records= (ha_rows) my_strtoll10(row[4], (char**) 0, &error); - if (row[5] != NULL) - stats.mean_rec_length= (ulong) my_strtoll10(row[5], (char**) 0, &error); + if (row[5] != NULL) + stats.mean_rec_length= (ulong) my_strtoll10(row[5], (char**) 0, &error); - stats.data_file_length= stats.records * stats.mean_rec_length; + stats.data_file_length= stats.records * stats.mean_rec_length; - if (row[12] != NULL) - stats.update_time= (time_t) my_strtoll10(row[12], (char**) 0, + if (row[12] != NULL) + stats.update_time= (ulong) my_strtoll10(row[12], (char**) 0, &error); - if (row[13] != NULL) - stats.check_time= (time_t) my_strtoll10(row[13], (char**) 0, + if (row[13] != NULL) + stats.check_time= (ulong) my_strtoll10(row[13], (char**) 0, &error); - } + /* size of IO operations (This is based on a good guess, no high science involved) diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index 19863d83874..fb7c13e4e41 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -419,6 +419,14 @@ int ha_heap::delete_all_rows() return 0; } + +int ha_heap::reset_auto_increment(ulonglong value) +{ + file->s->auto_increment= value; + return 0; +} + + int ha_heap::external_lock(THD *thd, int lock_type) { return 0; // No external locking diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h index 5c5ad43658e..22722129f4c 100644 --- a/storage/heap/ha_heap.h +++ b/storage/heap/ha_heap.h @@ -98,6 +98,7 @@ public: int reset(); int external_lock(THD *thd, int lock_type); int delete_all_rows(void); + int reset_auto_increment(ulonglong value); int disable_indexes(uint mode); int enable_indexes(uint mode); int indexes_are_disabled(void); diff --git a/storage/ibmdb2i/db2i_charsetSupport.cc b/storage/ibmdb2i/db2i_charsetSupport.cc index 559b526b7fd..83bf1b9448b 100644 --- a/storage/ibmdb2i/db2i_charsetSupport.cc +++ b/storage/ibmdb2i/db2i_charsetSupport.cc @@ -129,8 +129,8 @@ struct IconvMap { struct HashKey { - uint16 direction; // This is a uint16 instead of a uchar to avoid garbage data in the key from compiler padding - uint16 db2CCSID; + uint32 direction; // These are uint32s to avoid garbage data in the key from compiler padding + uint32 db2CCSID; const CHARSET_INFO* myCharset; } hashKey; iconv_t iconvDesc; @@ -245,11 +245,16 @@ static int32 getNewTextDesc(const int32 inType, else if ((inType == Qlg_TypeAS400CCSID) && (outType == Qlg_TypeAix41)) { // Override non-standard charsets - if (unlikely(strcmp("1148", in) == 0)) + if (strcmp("1148", in) == 0) { strcpy(out, "IBM-1148"); DBUG_RETURN(0); } + else if (unlikely(strcmp("1153", in) == 0)) + { + strcpy(out, "IBM-1153"); + DBUG_RETURN(0); + } } char argBuf[sizeof(ArgList)+15]; @@ -379,6 +384,11 @@ static int32 convertTextDesc(const int32 inType, const int32 outType, const char strcpy(outDesc,"IBM-1256"); DBUG_RETURN(0); } + else if (strcmp("macce", inDescOverride) == 0) + { + strcpy(outDesc,"IBM-1282"); + DBUG_RETURN(0); + } } else if (outType == Qlg_TypeAS400CCSID) { @@ -583,6 +593,11 @@ int32 getAssociatedCCSID(const uint16 inCcsid, const int inEncodingScheme, uint1 *outCcsid = 1148; DBUG_RETURN(0); } + else if ((inCcsid == 1250) && (inEncodingScheme == 0x1100)) + { + *outCcsid = 1153; + DBUG_RETURN(0); + } if (!ptrInited) { diff --git a/storage/ibmdb2i/db2i_collationSupport.cc b/storage/ibmdb2i/db2i_collationSupport.cc index a41f211a689..65a17fd2452 100644 --- a/storage/ibmdb2i/db2i_collationSupport.cc +++ b/storage/ibmdb2i/db2i_collationSupport.cc @@ -44,7 +44,7 @@ OF SUCH DAMAGE. between corresponding array slots but is incomplete without case-sensitivity markers dynamically added to the mySqlSortSequence names. */ -#define MAX_COLLATION 89 +#define MAX_COLLATION 87 static const char* mySQLCollation[MAX_COLLATION] = { {"ascii_general"}, @@ -52,7 +52,6 @@ static const char* mySQLCollation[MAX_COLLATION] = {"big5_chinese"}, {"big5"}, {"cp1250_croatian"}, - {"cp1250_czech"}, {"cp1250_general"}, {"cp1250_polish"}, {"cp1250"}, @@ -84,7 +83,6 @@ static const char* mySQLCollation[MAX_COLLATION] = {"latin1_swedish"}, {"latin1"}, {"latin2_croatian"}, - {"latin2_czech"}, {"latin2_general"}, {"latin2_hungarian"}, {"latin2"}, @@ -146,7 +144,6 @@ static const char* mySqlSortSequence[MAX_COLLATION] = {"QACHT04B0"}, {"QBCHT04B0"}, {"QALA20481"}, - {"QBLA20481"}, {"QCLA20481"}, {"QDLA20481"}, {"QELA20481"}, @@ -178,7 +175,6 @@ static const char* mySqlSortSequence[MAX_COLLATION] = {"QELA1047C"}, {"QFLA1047C"}, {"QCLA20366"}, - {"QDLA20366"}, {"QELA20366"}, {"QFLA20366"}, {"QGLA20366"}, @@ -190,8 +186,8 @@ static const char* mySqlSortSequence[MAX_COLLATION] = {"QDJPN04B0"}, {"QATHA0346"}, {"QBTHA0346"}, - {"ACS"}, - {"ADA"}, + {"ACS_CZ"}, + {"ADA_DK"}, {"AEO"}, {"AET"}, {"QAUCS04B0"}, @@ -211,8 +207,8 @@ static const char* mySqlSortSequence[MAX_COLLATION] = {"*HEX"}, {"QEJPN04B0"}, {"QFJPN04B0"}, - {"ACS"}, - {"ADA"}, + {"ACS_CZ"}, + {"ADA_DK"}, {"AEO"}, {"AET"}, {"QAUCS04B0"}, diff --git a/storage/ibmdb2i/db2i_conversion.cc b/storage/ibmdb2i/db2i_conversion.cc index bdb8085d937..9a85eb01c9b 100644 --- a/storage/ibmdb2i/db2i_conversion.cc +++ b/storage/ibmdb2i/db2i_conversion.cc @@ -137,7 +137,9 @@ int ha_ibmdb2i::convertFieldChars(enum_conversionDirection direction, char* output, size_t ilen, size_t olen, - size_t* outDataLen) + size_t* outDataLen, + bool tacitErrors, + size_t* substChars) { DBUG_PRINT("ha_ibmdb2i::convertFieldChars",("Direction: %d; length = %d", direction, ilen)); @@ -157,26 +159,26 @@ int ha_ibmdb2i::convertFieldChars(enum_conversionDirection direction, size_t initOLen= olen; size_t substitutedChars = 0; int rc = iconv(conversion, (char**)&input, &ilen, &output, &olen, &substitutedChars ); + if (outDataLen) *outDataLen = initOLen - olen; + if (substChars) *substChars = substitutedChars; if (unlikely(rc < 0)) { int er = errno; if (er == EILSEQ) { - getErrTxt(DB2I_ERR_ILL_CHAR, table->field[fieldID]->field_name); + if (!tacitErrors) getErrTxt(DB2I_ERR_ILL_CHAR, table->field[fieldID]->field_name); return (DB2I_ERR_ILL_CHAR); } else { - getErrTxt(DB2I_ERR_ICONV,er); + if (!tacitErrors) getErrTxt(DB2I_ERR_ICONV,er); return (DB2I_ERR_ICONV); } } - if (unlikely(substitutedChars)) + if (unlikely(substitutedChars) && (!tacitErrors)) { warning(ha_thd(), DB2I_ERR_SUB_CHARS, table->field[fieldID]->field_name); } - - if (outDataLen) *outDataLen = initOLen - olen; return (0); } @@ -555,12 +557,12 @@ int ha_ibmdb2i::getFieldTypeMapping(Field* field, return 1; if (fieldCharSet->mbmaxlen > 1) { - if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2 + if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2 { sprintf(stringBuildBuffer, "GRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters db2Ccsid = 13488; } - else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 && + else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 && strcmp(fieldCharSet->name, "utf8_general_ci") != 0) { sprintf(stringBuildBuffer, "CHAR(%d)", max(fieldLength, 1)); // Number of bytes @@ -584,12 +586,12 @@ int ha_ibmdb2i::getFieldTypeMapping(Field* field, { if (fieldCharSet->mbmaxlen > 1) { - if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2 + if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2 { sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters db2Ccsid = 13488; } - else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 && + else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 && strcmp(fieldCharSet->name, "utf8_general_ci") != 0) { sprintf(stringBuildBuffer, "VARCHAR(%d)", max(fieldLength, 1)); // Number of bytes @@ -611,12 +613,12 @@ int ha_ibmdb2i::getFieldTypeMapping(Field* field, { if (fieldCharSet->mbmaxlen > 1) { - if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2 + if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2 { sprintf(stringBuildBuffer, "LONG VARGRAPHIC "); db2Ccsid = 13488; } - else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 && + else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 && strcmp(fieldCharSet->name, "utf8_general_ci") != 0) { sprintf(stringBuildBuffer, "LONG VARCHAR "); @@ -639,12 +641,12 @@ int ha_ibmdb2i::getFieldTypeMapping(Field* field, if (fieldCharSet->mbmaxlen > 1) { - if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2 + if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2 { sprintf(stringBuildBuffer, "DBCLOB(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters db2Ccsid = 13488; } - else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 && + else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 && strcmp(fieldCharSet->name, "utf8_general_ci") != 0) { sprintf(stringBuildBuffer, "CLOB(%d)", max(fieldLength, 1)); // Number of bytes @@ -671,11 +673,15 @@ int ha_ibmdb2i::getFieldTypeMapping(Field* field, return rtnCode; } - // Check whether there is a character conversion available. - iconv_t temp; - int32 rc = getConversion(toDB2, fieldCharSet, db2Ccsid, temp); - if (unlikely(rc)) - return rc; + if (db2Ccsid != 1208 && + db2Ccsid != 13488) + { + // Check whether there is a character conversion available. + iconv_t temp; + int32 rc = getConversion(toDB2, fieldCharSet, db2Ccsid, temp); + if (unlikely(rc)) + return rc; + } sprintf(stringBuildBuffer, " CCSID %d ", db2Ccsid); mapping.append(stringBuildBuffer); @@ -1085,7 +1091,7 @@ int32 ha_ibmdb2i::convertMySQLtoDB2(Field* field, const DB2Field& db2Field, char if (bytesToStore) memcpy(db2Buf, dataToStore, bytesToStore); if (bytesToPad) - wmemset((wchar_t*)(db2Buf + bytesToStore), 0x0020, bytesToPad/2); + memset16((db2Buf + bytesToStore), 0x0020, bytesToPad/2); } else { @@ -1108,7 +1114,7 @@ int32 ha_ibmdb2i::convertMySQLtoDB2(Field* field, const DB2Field& db2Field, char bytesToStore = db2BytesToStore; } if (db2BytesToStore < maxDb2BytesToStore) // If need to pad - wmemset((wchar_t*)(db2Buf + db2BytesToStore), 0x0020, (maxDb2BytesToStore - db2BytesToStore)/2); + memset16((db2Buf + db2BytesToStore), 0x0020, (maxDb2BytesToStore - db2BytesToStore)/2); } if (db2FieldType == QMY_VARGRAPHIC) diff --git a/storage/ibmdb2i/db2i_misc.h b/storage/ibmdb2i/db2i_misc.h index 9e20f01208b..f0b527aaad0 100644 --- a/storage/ibmdb2i/db2i_misc.h +++ b/storage/ibmdb2i/db2i_misc.h @@ -109,5 +109,21 @@ bool isOrdinaryIdentifier(const char* s) } return true; } + +/** + Fill memory with a 16-bit word. + @param p Pointer to space to fill. + @param v Value to fill + @param l Length of space (in 16-bit words) +*/ +void memset16(void* p, uint16 v, size_t l) +{ + uint16* p2=(uint16*)p; + while (l--) + { + *(p2++) = v; + } +} + #endif diff --git a/storage/ibmdb2i/db2i_myconv.h b/storage/ibmdb2i/db2i_myconv.h index a9e87474505..98032748148 100644 --- a/storage/ibmdb2i/db2i_myconv.h +++ b/storage/ibmdb2i/db2i_myconv.h @@ -220,6 +220,7 @@ INTERN size_t myconv_dmap(myconv_t cd, } else { *pOut=dmapS2S[*pIn]; if (*pOut == 0x00) { + errno=EILSEQ; /* 116 */ *outBytesLeft-=(*inBytesLeft-inLen); *inBytesLeft=inLen; *outBuf=pOut; diff --git a/storage/ibmdb2i/db2i_rir.cc b/storage/ibmdb2i/db2i_rir.cc index a80a181c9ac..091c4d98383 100644 --- a/storage/ibmdb2i/db2i_rir.cc +++ b/storage/ibmdb2i/db2i_rir.cc @@ -51,7 +51,6 @@ static inline int getKeyCntFromMap(key_part_map keypart_map) return (cnt); } - /** @brief Given a starting key and an ending key, estimate the number of rows that @@ -270,81 +269,163 @@ ha_rows ha_ibmdb2i::records_in_range(uint inx, DB2Field& db2Field = db2Table->db2Field(field->field_index); litDefPtr->DataType = db2Field.getType(); /* - Convert the literal to DB2 format. - */ - rc = convertMySQLtoDB2(field, - db2Field, - literalPtr, - (uchar*)minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0)); - if (rc != 0) break; - litDefPtr->Offset = (uint32_t)(literalPtr - literalsPtr); - litDefPtr->Length = db2Field.getByteLengthInRecord(); - tempLen = litDefPtr->Length; - /* - Do additional conversion of a character or graphic value. - */ - CHARSET_INFO* fieldCharSet = field->charset(); + Convert the literal to DB2 format + */ if ((field->type() != MYSQL_TYPE_BIT) && // Don't do conversion on BIT data (field->charset() != &my_charset_bin) && // Don't do conversion on BINARY data - (litDefPtr->DataType == QMY_CHAR || litDefPtr->DataType == QMY_VARCHAR || - litDefPtr->DataType == QMY_GRAPHIC || litDefPtr->DataType == QMY_VARGRAPHIC)) + (litDefPtr->DataType == QMY_CHAR || + litDefPtr->DataType == QMY_VARCHAR || + litDefPtr->DataType == QMY_GRAPHIC || + litDefPtr->DataType == QMY_VARGRAPHIC)) { - if (litDefPtr->DataType == QMY_VARCHAR || - litDefPtr->DataType == QMY_VARGRAPHIC) - tempPtr = literalPtr + sizeof(uint16); - else - tempPtr = literalPtr; - /* The following code checks to determine if MySQL is passing a - partial key. DB2 will accept a partial field value, but only - in the last field position of the key composite (and only if - there is no ICU sort sequence on the index). */ - tempMinPtr = (char*)minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0); - if (field->type() == MYSQL_TYPE_VARCHAR) - { - /* MySQL always stores key lengths as 2 bytes, little-endian. */ - tempLen = *(uint8*)tempMinPtr + ((*(uint8*)(tempMinPtr+1)) << 8); - tempMinPtr = (char*)((char*)tempMinPtr + 2); - } - else - tempLen = field->field_length; - - /* Determine if we are dealing with a partial key and if so, find the end of the partial key. */ - if (litDefPtr->DataType == QMY_CHAR || litDefPtr->DataType == QMY_VARCHAR ) - { /* Char or varchar. If UTF8, no conversion is done to DB2 graphic.) */ - endOfMinPtr = (char*)memchr(tempMinPtr,field->charset()->min_sort_char,tempLen); - if (endOfMinPtr) - endOfLiteralPtr = tempPtr + ((uint32_t)(endOfMinPtr - tempMinPtr)); - } - else - { - if (strncmp(fieldCharSet->csname, "utf8", sizeof("utf8")) == 0) - { /* The MySQL charset is UTF8 but we are converting to graphic on DB2. Divide number of UTF8 bytes - by 3 to get the number of characters, then multiple by 2 for double-byte graphic.*/ - endOfMinPtr = (char*)memchr(tempMinPtr,field->charset()->min_sort_char,tempLen); - if (endOfMinPtr) - endOfLiteralPtr = tempPtr + (((uint32_t)((endOfMinPtr - tempMinPtr)) / 3) * 2); - } - else - { /* The DB2 data type is graphic or vargraphic, and we are not converting from UTF8 to graphic. */ - endOfMinPtr = (char*)wmemchr((wchar_t*)tempMinPtr,field->charset()->min_sort_char,tempLen/2); - if (endOfMinPtr) - endOfLiteralPtr = tempPtr + (endOfMinPtr - tempMinPtr); + // Most of the code is required by the considerable wrangling needed + // to prepare partial keys for use by DB2 + // 1. UTF8 (CCSID 1208) data can be copied across unmodified if it is + // utf8_bin. Otherwise, we need to convert the min and max + // characters into the min and max characters employed + // by the DB2 sort sequence. This is complicated by the fact that + // the character widths are not always equal. + // 2. Likewise, UCS2 (CCSID 13488) data can be copied across unmodified + // if it is ucs2_bin or ucs2_general_ci. Otherwise, we need to + // convert the min and max characters into the min and max characters + // employed by the DB2 sort sequence. + // 3. All other data will use standard iconv conversions. If an + // unconvertible character is encountered, we assume it is the min + // char and fill the remainder of the DB2 key with 0s. This may not + // always be accurate, but it is probably sufficient for range + // estimations. + const char* keyData = minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0); + char* db2Data = literalPtr; + uint16 outLen = db2Field.getByteLengthInRecord(); + uint16 inLen; + if (litDefPtr->DataType == QMY_VARCHAR || + litDefPtr->DataType == QMY_VARGRAPHIC) + { + inLen = *(uint8*)keyData + ((*(uint8*)(keyData+1)) << 8); + keyData += 2; + outLen -= sizeof(uint16); + db2Data += sizeof(uint16); + } + else + { + inLen = field->max_display_length(); + } + + size_t convertedBytes = 0; + if (db2Field.getCCSID() == 1208) + { + DBUG_ASSERT(inLen <= outLen); + if (strcmp(field->charset()->name, "utf8_bin")) + { + const char* end = keyData+inLen; + const char* curKey = keyData; + char* curDB2 = db2Data; + uint32 min = field->charset()->min_sort_char; + while ((curKey < end) && (curDB2 < db2Data+outLen-3)) + { + my_wc_t temp; + int len = field->charset()->cset->mb_wc(field->charset(), + &temp, + (const uchar*)curKey, + (const uchar*)end); + if (temp != min) + { + DBUG_ASSERT(len <= 3); + switch (len) + { + case 3: *(curDB2+2) = *(curKey+2); + case 2: *(curDB2+1) = *(curKey+1); + case 1: *(curDB2) = *(curKey); + } + curDB2 += len; + } + else + { + *(curDB2++) = 0xEF; + *(curDB2++) = 0xBF; + *(curDB2++) = 0xBF; + } + curKey += len; + } + convertedBytes = curDB2 - db2Data; + } + else + { + memcpy(db2Data, keyData, inLen); + convertedBytes = inLen; + } + rc = 0; + } + else if (db2Field.getCCSID() == 13488) + { + DBUG_ASSERT(inLen <= outLen); + if (strcmp(field->charset()->name, "ucs2_bin") && + strcmp(field->charset()->name, "ucs2_general_ci")) + { + const char* end = keyData+inLen; + const uint16* curKey = (uint16*)keyData; + uint16* curDB2 = (uint16*)db2Data; + uint16 min = field->charset()->min_sort_char; + while (curKey < (uint16*)end) + { + if (*curKey != min) + *curDB2 = *curKey; + else + *curDB2 = 0xFFFF; + ++curKey; + ++curDB2; } - } - /* Enforce here that a partial is only allowed on the last field position - of the key composite */ - if (endOfLiteralPtr) - { - if ((partsInUse + 1) < minKeyCnt) - { - rc = HA_POS_ERROR; - break; - } - endByte = endOfLiteralPtr - tempPtr; - /* We're making an assumption that if MySQL gives us a partial key, - the length of the partial is the same for both the min_key and max_key. */ - } + } + else + { + memcpy(db2Data, keyData, inLen); + } + convertedBytes = inLen; + rc = 0; + } + else + { + rc = convertFieldChars(toDB2, + field->field_index, + keyData, + db2Data, + inLen, + outLen, + &convertedBytes, + true); + + if (rc == DB2I_ERR_ILL_CHAR) + { + // If an illegal character is encountered, we fill the remainder + // of the key with 0x00. This was implemented as a corollary to + // Bug#45012, though it should probably remain even after that + // bug is fixed. + memset(db2Data+convertedBytes, 0x00, outLen-convertedBytes); + convertedBytes = outLen; + rc = 0; + } + } + + if (!rc && + (litDefPtr->DataType == QMY_VARGRAPHIC || + litDefPtr->DataType == QMY_VARCHAR)) + { + *(uint16*)(db2Data-sizeof(uint16)) = + convertedBytes / (litDefPtr->DataType == QMY_VARGRAPHIC ? 2 : 1); + } + } + else // Non-character fields + { + rc = convertMySQLtoDB2(field, + db2Field, + literalPtr, + (uchar*)minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0)); + } + + if (rc != 0) break; + litDefPtr->Offset = (uint32_t)(literalPtr - literalsPtr); + litDefPtr->Length = db2Field.getByteLengthInRecord(); literalPtr = literalPtr + litDefPtr->Length; // Bump pointer for next literal } /* If there is a max_key value for this field, and if the max_key value is @@ -389,28 +470,168 @@ ha_rows ha_ibmdb2i::records_in_range(uint inx, /* Convert the literal to DB2 format */ - rc = convertMySQLtoDB2(field, - db2Field, - literalPtr, - (uchar*)maxPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0)); + if ((field->type() != MYSQL_TYPE_BIT) && // Don't do conversion on BIT data + (field->charset() != &my_charset_bin) && // Don't do conversion on BINARY data + (litDefPtr->DataType == QMY_CHAR || + litDefPtr->DataType == QMY_VARCHAR || + litDefPtr->DataType == QMY_GRAPHIC || + litDefPtr->DataType == QMY_VARGRAPHIC)) + { + // We need to handle char fields in a special way in order to account + // for partial keys. Refer to the note above for a description of the + // basic design. + char* keyData = maxPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0); + char* db2Data = literalPtr; + uint16 outLen = db2Field.getByteLengthInRecord(); + uint16 inLen; + if (litDefPtr->DataType == QMY_VARCHAR || + litDefPtr->DataType == QMY_VARGRAPHIC) + { + inLen = *(uint8*)keyData + ((*(uint8*)(keyData+1)) << 8); + keyData += 2; + outLen -= sizeof(uint16); + db2Data += sizeof(uint16); + } + else + { + inLen = field->max_display_length(); + } + + size_t convertedBytes; + if (db2Field.getCCSID() == 1208) + { + if (strcmp(field->charset()->name, "utf8_bin")) + { + const char* end = keyData+inLen; + const char* curKey = keyData; + char* curDB2 = db2Data; + uint32 max = field->charset()->max_sort_char; + while (curKey < end && (curDB2 < db2Data+outLen-3)) + { + my_wc_t temp; + int len = field->charset()->cset->mb_wc(field->charset(), &temp, (const uchar*)curKey, (const uchar*)end); + if (temp != max) + { + DBUG_ASSERT(len <= 3); + switch (len) + { + case 3: *(curDB2+2) = *(curKey+2); + case 2: *(curDB2+1) = *(curKey+1); + case 1: *(curDB2) = *(curKey); + } + curDB2 += len; + } + else + { + *(curDB2++) = 0xE4; + *(curDB2++) = 0xB6; + *(curDB2++) = 0xBF; + } + curKey += len; + } + convertedBytes = curDB2 - db2Data; + } + else + { + DBUG_ASSERT(inLen <= outLen); + memcpy(db2Data, keyData, inLen); + convertedBytes = inLen; + } + rc = 0; + } + else if (db2Field.getCCSID() == 13488) + { + if (strcmp(field->charset()->name, "ucs2_bin") && + strcmp(field->charset()->name, "ucs2_general_ci")) + { + char* end = keyData+inLen; + uint16* curKey = (uint16*)keyData; + uint16* curDB2 = (uint16*)db2Data; + uint16 max = field->charset()->max_sort_char; + while (curKey < (uint16*)end) + { + if (*curKey != max) + *curDB2 = *curKey; + else + *curDB2 = 0x4DBF; + ++curKey; + ++curDB2; + } + } + else + { + memcpy(db2Data, keyData, outLen); + } + rc = 0; + } + else + { + size_t substituteChars = 0; + rc = convertFieldChars(toDB2, + field->field_index, + keyData, + db2Data, + inLen, + outLen, + &convertedBytes, + true, + &substituteChars); + + if (rc == DB2I_ERR_ILL_CHAR) + { + // If an illegal character is encountered, we fill the remainder + // of the key with 0xFF. This was implemented to work around + // Bug#45012, though it should probably remain even after that + // bug is fixed. + memset(db2Data+convertedBytes, 0xFF, outLen-convertedBytes); + rc = 0; + } + else if ((substituteChars && + (litDefPtr->DataType == QMY_VARCHAR || + litDefPtr->DataType == QMY_CHAR)) || + strcmp(field->charset()->name, "cp1251_bulgarian_ci") == 0) + { + // When iconv translates the max_sort_char with a substitute + // character, we have no way to know whether this affects + // the sort order of the key. Therefore, to be safe, when + // we know that substitute characters have been used in a + // single-byte string, we traverse the translated key + // in reverse, replacing substitue characters with 0xFF, which + // always sorts with the greatest weight in DB2 sort sequences. + // cp1251_bulgarian_ci is also handled this way because the + // max_sort_char is a control character which does not sort + // equivalently in DB2. + DBUG_ASSERT(inLen == outLen); + char* tmpKey = keyData + inLen - 1; + char* tmpDB2 = db2Data + outLen - 1; + while (*tmpKey == field->charset()->max_sort_char && + *tmpDB2 != 0xFF) + { + *tmpDB2 = 0xFF; + --tmpKey; + --tmpDB2; + } + } + } + + if (!rc && + (litDefPtr->DataType == QMY_VARGRAPHIC || + litDefPtr->DataType == QMY_VARCHAR)) + { + *(uint16*)(db2Data-sizeof(uint16)) = + outLen / (litDefPtr->DataType == QMY_VARGRAPHIC ? 2 : 1); + } + } + else + { + rc = convertMySQLtoDB2(field, + db2Field, + literalPtr, + (uchar*)maxPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0)); + } if (rc != 0) break; litDefPtr->Offset = (uint32_t)(literalPtr - literalsPtr); litDefPtr->Length = db2Field.getByteLengthInRecord(); - tempLen = litDefPtr->Length; - /* - Now convert a character or graphic value. - */ - if ((field->type() != MYSQL_TYPE_BIT) && - (litDefPtr->DataType == QMY_CHAR || litDefPtr->DataType == QMY_VARCHAR || - litDefPtr->DataType == QMY_GRAPHIC || litDefPtr->DataType == QMY_VARGRAPHIC)) - { - if (litDefPtr->DataType == QMY_VARCHAR || litDefPtr->DataType == QMY_VARGRAPHIC) - { - tempPtr = literalPtr + sizeof(uint16); - } - else - tempPtr = literalPtr; - } literalPtr = literalPtr + litDefPtr->Length; // Bump pointer for next literal } boundsPtr->HiBound.Position = literalCnt; diff --git a/storage/ibmdb2i/ha_ibmdb2i.cc b/storage/ibmdb2i/ha_ibmdb2i.cc index 46c84de4aee..0fc2d1e83dc 100644 --- a/storage/ibmdb2i/ha_ibmdb2i.cc +++ b/storage/ibmdb2i/ha_ibmdb2i.cc @@ -2230,34 +2230,19 @@ int ha_ibmdb2i::create(const char *name, TABLE *table_arg, } } - bool primaryHasStringField = false; - + String fieldDefinition(128); + if (table_arg->s->primary_key != MAX_KEY && !isTemporary) { - KEY& curKey = table_arg->key_info[table_arg->s->primary_key]; - query.append(STRING_WITH_LEN(", PRIMARY KEY( ")); - for (int j = 0; j < curKey.key_parts; ++j) - { - if (j != 0) - { - query.append( STRING_WITH_LEN(" , ") ); - } - Field* field = curKey.key_part[j].field; - convertMySQLNameToDB2Name(field->field_name, colName, sizeof(colName)); - query.append(colName); - enum_field_types type = field->real_type(); - if (type == MYSQL_TYPE_VARCHAR || type == MYSQL_TYPE_BLOB || - type == MYSQL_TYPE_STRING) - { - rc = updateAssociatedSortSequence(field->charset(), - &fileSortSequenceType, - fileSortSequence, - fileSortSequenceLibrary); - if (rc) DBUG_RETURN (rc); - primaryHasStringField = true; - } - } - query.append(STRING_WITH_LEN(" ) ")); + query.append(STRING_WITH_LEN(", PRIMARY KEY ")); + rc = buildIndexFieldList(fieldDefinition, + table_arg->key_info[table_arg->s->primary_key], + true, + &fileSortSequenceType, + fileSortSequence, + fileSortSequenceLibrary); + if (rc) DBUG_RETURN(rc); + query.append(fieldDefinition); } rc = buildDB2ConstraintString(thd->lex, @@ -2273,11 +2258,29 @@ int ha_ibmdb2i::create(const char *name, TABLE *table_arg, if (isTemporary) query.append(STRING_WITH_LEN(" ON COMMIT PRESERVE ROWS ")); - + + if (create_info->alias) + generateAndAppendRCDFMT(create_info->alias, query); + else if (((TABLE_LIST*)(thd->lex->select_lex.table_list.first))->table_name) + generateAndAppendRCDFMT((char*)((TABLE_LIST*)(thd->lex->select_lex.table_list.first))->table_name, query); + DBUG_PRINT("ha_ibmdb2i::create", ("Sent to DB2: %s",query.c_ptr())); SqlStatementStream sqlStream(query.length()); sqlStream.addStatement(query,fileSortSequence,fileSortSequenceLibrary); + if (table_arg->s->primary_key != MAX_KEY && + !isTemporary && + (THDVAR(thd, create_index_option)==1) && + (fileSortSequenceType != 'B') && + (fileSortSequenceType != ' ')) + { + rc = generateShadowIndex(sqlStream, + table_arg->key_info[table_arg->s->primary_key], + libName, + fileName, + fieldDefinition); + if (rc) DBUG_RETURN(rc); + } for (uint i = 0; i < table_arg->s->keys; ++i) { if (i != table_arg->s->primary_key || isTemporary) @@ -3007,61 +3010,126 @@ int32 ha_ibmdb2i::buildCreateIndexStatement(SqlStatementStream& sqlStream, } String fieldDefinition(128); - fieldDefinition.length(0); - fieldDefinition.append(STRING_WITH_LEN(" ( ")); + rc = buildIndexFieldList(fieldDefinition, + key, + isPrimary, + &fileSortSequenceType, + fileSortSequence, + fileSortSequenceLibrary); + + if (rc) DBUG_RETURN(rc); + + query.append(fieldDefinition); + + if ((THDVAR(ha_thd(), create_index_option)==1) && + (fileSortSequenceType != 'B') && + (fileSortSequenceType != ' ')) + { + rc = generateShadowIndex(sqlStream, + key, + db2LibName, + db2FileName, + fieldDefinition); + if (rc) DBUG_RETURN(rc); + } + + DBUG_PRINT("ha_ibmdb2i::buildCreateIndexStatement", ("Sent to DB2: %s",query.c_ptr_safe())); + sqlStream.addStatement(query,fileSortSequence,fileSortSequenceLibrary); + + DBUG_RETURN(0); +} + +/** + Generate the SQL syntax for the list of fields to be assigned to the + specified key. The corresponding sort sequence is also calculated. + + @param[out] appendHere The string to receive the generated SQL + @param key The key to evaluate + @param isPrimary True if this is being generated on behalf of the primary key + @param[out] fileSortSequenceType The type of the associated sort sequence + @param[out] fileSortSequence The name of the associated sort sequence + @param[out] fileSortSequenceLibrary The library of the associated sort sequence + + @return 0 if successful; error value otherwise +*/ +int32 ha_ibmdb2i::buildIndexFieldList(String& appendHere, + const KEY& key, + bool isPrimary, + char* fileSortSequenceType, + char* fileSortSequence, + char* fileSortSequenceLibrary) +{ + DBUG_ENTER("ha_ibmdb2i::buildIndexFieldList"); + appendHere.append(STRING_WITH_LEN(" ( ")); for (int j = 0; j < key.key_parts; ++j) { char colName[MAX_DB2_COLNAME_LENGTH+1]; if (j != 0) { - fieldDefinition.append(STRING_WITH_LEN(" , ")); + appendHere.append(STRING_WITH_LEN(" , ")); } - Field* field = key.key_part[j].field; - convertMySQLNameToDB2Name(field->field_name, colName, sizeof(colName)); - fieldDefinition.append(colName); + + KEY_PART_INFO& kpi = key.key_part[j]; + Field* field = kpi.field; + + convertMySQLNameToDB2Name(field->field_name, + colName, + sizeof(colName)); + appendHere.append(colName); + + int32 rc; rc = updateAssociatedSortSequence(field->charset(), - &fileSortSequenceType, + fileSortSequenceType, fileSortSequence, fileSortSequenceLibrary); if (rc) DBUG_RETURN (rc); } - fieldDefinition.append(STRING_WITH_LEN(" ) ")); - - query.append(fieldDefinition); - - if ((THDVAR(ha_thd(), create_index_option)==1) && - (fileSortSequenceType != 'B')) - { - String shadowQuery(256); - shadowQuery.length(0); - - shadowQuery.append(STRING_WITH_LEN("CREATE INDEX ")); - - shadowQuery.append(db2LibName); - shadowQuery.append('.'); - if (db2i_table::appendQualifiedIndexFileName(key.name, db2FileName, shadowQuery, db2i_table::ASCII_SQL, typeHex)) - { - getErrTxt(DB2I_ERR_INVALID_NAME,"index","*generated*"); - DBUG_RETURN(DB2I_ERR_INVALID_NAME ); - } - - shadowQuery.append(STRING_WITH_LEN(" ON ")); - - shadowQuery.append(db2LibName); - shadowQuery.append('.'); - shadowQuery.append(db2FileName); - shadowQuery.append(fieldDefinition); - DBUG_PRINT("ha_ibmdb2i::buildCreateIndexStatement", ("Sent to DB2: %s",shadowQuery.c_ptr_safe())); - sqlStream.addStatement(shadowQuery,"*HEX","QSYS"); - } - DBUG_PRINT("ha_ibmdb2i::buildCreateIndexStatement", ("Sent to DB2: %s",query.c_ptr_safe())); - sqlStream.addStatement(query,fileSortSequence,fileSortSequenceLibrary); - + appendHere.append(STRING_WITH_LEN(" ) ")); + DBUG_RETURN(0); } +/** + Generate an SQL statement that defines a *HEX sorted index to implement + the ibmdb2i_create_index. + + @param[out] stream The stream to append the generated statement to + @param key The key to evaluate + @param[out] libName The library containg the table + @param[out] fileName The DB2-compatible name of the table + @param[out] fieldDefinition The list of the fields in the index, in SQL syntax + + @return 0 if successful; error value otherwise +*/ +int32 ha_ibmdb2i::generateShadowIndex(SqlStatementStream& stream, + const KEY& key, + const char* libName, + const char* fileName, + const String& fieldDefinition) +{ + String shadowQuery(256); + shadowQuery.length(0); + shadowQuery.append(STRING_WITH_LEN("CREATE INDEX ")); + shadowQuery.append(libName); + shadowQuery.append('.'); + if (db2i_table::appendQualifiedIndexFileName(key.name, fileName, shadowQuery, db2i_table::ASCII_SQL, typeHex)) + { + getErrTxt(DB2I_ERR_INVALID_NAME,"index","*generated*"); + return DB2I_ERR_INVALID_NAME; + } + shadowQuery.append(STRING_WITH_LEN(" ON ")); + shadowQuery.append(libName); + shadowQuery.append('.'); + shadowQuery.append(fileName); + shadowQuery.append(fieldDefinition); + DBUG_PRINT("ha_ibmdb2i::generateShadowIndex", ("Sent to DB2: %s",shadowQuery.c_ptr_safe())); + stream.addStatement(shadowQuery,"*HEX","QSYS"); + return 0; +} + + void ha_ibmdb2i::doInitialRead(char orientation, uint32 rowsToBuffer, ILEMemHandle key, diff --git a/storage/ibmdb2i/ha_ibmdb2i.h b/storage/ibmdb2i/ha_ibmdb2i.h index e90f152919c..b2a43232f2d 100644 --- a/storage/ibmdb2i/ha_ibmdb2i.h +++ b/storage/ibmdb2i/ha_ibmdb2i.h @@ -383,7 +383,15 @@ private: int32 prepareWriteBufferForLobs(); uint32 adjustLobBuffersForRead(); bool lobFieldsRequested(); - int convertFieldChars(enum_conversionDirection direction, uint16 fieldID, const char* input, char* output, size_t ilen, size_t olen, size_t* outDataLen); + int convertFieldChars(enum_conversionDirection direction, + uint16 fieldID, + const char* input, + char* output, + size_t ilen, + size_t olen, + size_t* outDataLen, + bool tacitErrors=FALSE, + size_t* substChars=NULL); /** Fast integer log2 function @@ -522,6 +530,13 @@ private: bool isPrimary, const char* db2LibName, const char* db2FileName); + + int32 buildIndexFieldList(String& appendHere, + const KEY& key, + bool isPrimary, + char* fileSortSequenceType, + char* fileSortSequence, + char* fileSortSequenceLibrary); // Specify NULL for data when using the data pointed to by field int32 convertMySQLtoDB2(Field* field, const DB2Field& db2Field, char* db2Buf, const uchar* data = NULL); @@ -746,5 +761,62 @@ private: free_root(&conversionBufferMemroot, MYF(0)); } } - + + +/** + Generate a valid RCDFMT name based on the name of the table. + + The RCDFMT name is devised by munging the name of the table, + uppercasing all ascii alpha-numeric characters and replacing all other + characters with underscores until up to ten characters have been generated. + + @param tableName The name of the table, as given on the MySQL + CREATE TABLE statement + @param[out] query The string to receive the generated RCDFMT name +*/ + static void generateAndAppendRCDFMT(const char* tableName, String& query) + { + char rcdfmt[11]; + + // The RCDFMT name must begin with an alpha character. + // We enforce this by skipping to the first alpha character in the table + // name. If no alpha character exists, we use 'X' for the RCDFMT name; + + while (*tableName && + (!my_isascii(*tableName) || + !my_isalpha(system_charset_info, *tableName))) + { + tableName += my_mbcharlen(system_charset_info, *tableName); + } + + if (unlikely(!(*tableName))) + { + rcdfmt[0]= 'X'; + rcdfmt[1]= 0; + } + else + { + int r= 0; + while ((r < sizeof(rcdfmt)-1) && *tableName) + { + if (my_isascii(*tableName) && + my_isalnum(system_charset_info, *tableName)) + rcdfmt[r] = my_toupper(system_charset_info, *tableName); + else + rcdfmt[r] = '_'; + + ++r; + tableName += my_mbcharlen(system_charset_info, *tableName); + } + rcdfmt[r]= 0; + } + query.append(STRING_WITH_LEN(" RCDFMT ")); + query.append(rcdfmt); + } + + int32 generateShadowIndex(SqlStatementStream& stream, + const KEY& key, + const char* libName, + const char* fileName, + const String& fieldDefinition); }; diff --git a/storage/innobase/Makefile.am b/storage/innobase/Makefile.am index 7410bf7e591..3df9a6bf988 100644 --- a/storage/innobase/Makefile.am +++ b/storage/innobase/Makefile.am @@ -50,13 +50,14 @@ noinst_HEADERS= include/btr0btr.h include/btr0btr.ic \ include/eval0eval.h include/eval0eval.ic \ include/eval0proc.h include/eval0proc.ic \ include/fil0fil.h include/fsp0fsp.h \ - include/fsp0fsp.ic include/fut0fut.h \ + include/fsp0fsp.ic include/fsp0types.h \ + include/fut0fut.h \ include/fut0fut.ic include/fut0lst.h \ include/fut0lst.ic include/ha0ha.h \ include/ha0ha.ic include/hash0hash.h \ include/hash0hash.ic include/ibuf0ibuf.h \ include/ibuf0ibuf.ic include/ibuf0types.h \ - include/lock0iter.h \ + include/lock0iter.h \ include/lock0lock.h include/lock0lock.ic \ include/lock0priv.h include/lock0priv.ic \ include/lock0types.h include/log0log.h \ diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c index 54acdf73db6..d2a2e4d2157 100644 --- a/storage/innobase/btr/btr0cur.c +++ b/storage/innobase/btr/btr0cur.c @@ -23,6 +23,7 @@ Created 10/16/1994 Heikki Tuuri #include "btr0cur.ic" #endif +#include "mtr0log.h" #include "page0page.h" #include "rem0rec.h" #include "rem0cmp.h" diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index c7a57d6a2b8..8cb196bf983 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -2616,7 +2616,7 @@ scan_more: } else if (quote) { /* Within quotes: do not look for starting quotes or comments. */ - } else if (*sptr == '"' || *sptr == '`') { + } else if (*sptr == '"' || *sptr == '`' || *sptr == '\'') { /* Starting quote: remember the quote character. */ quote = *sptr; } else if (*sptr == '#' @@ -3932,7 +3932,7 @@ dict_table_print_low( (ulong) UT_LIST_GET_LEN(table->indexes), (ulong) table->stat_n_rows); - for (i = 0; i + 1 < (ulint) table->n_cols; i++) { + for (i = 0; i < (ulint) table->n_cols; i++) { dict_col_print_low(table, dict_table_get_nth_col(table, i)); fputs("; ", stderr); } diff --git a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c index c63d67cae60..42e5166c9e4 100644 --- a/storage/innobase/fil/fil0fil.c +++ b/storage/innobase/fil/fil0fil.c @@ -2745,7 +2745,7 @@ fil_open_single_table_tablespace( "InnoDB: and MySQL removed the .ibd file for this.\n" "InnoDB: Please refer to\n" "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" - "innodb-troubleshooting.html\n" + "innodb-troubleshooting-datadict.html\n" "InnoDB: for how to resolve the issue.\n", stderr); mem_free(filepath); @@ -2786,7 +2786,7 @@ fil_open_single_table_tablespace( " IMPORT TABLESPACE?\n" "InnoDB: Please refer to\n" "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" - "innodb-troubleshooting.html\n" + "innodb-troubleshooting-datadict.html\n" "InnoDB: for how to resolve the issue.\n", (ulong) space_id, (ulong) id); @@ -3477,7 +3477,7 @@ fil_space_for_table_exists_in_mem( error_exit: fputs("InnoDB: Please refer to\n" "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/" - "innodb-troubleshooting.html\n" + "innodb-troubleshooting-datadict.html\n" "InnoDB: for how to resolve the issue.\n", stderr); mem_free(path); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index e9c3f62c9dc..2f29ca62000 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -101,6 +101,7 @@ static long innobase_mirrored_log_groups, innobase_log_files_in_group, innobase_additional_mem_pool_size, innobase_file_io_threads, innobase_lock_wait_timeout, innobase_force_recovery, innobase_open_files, innobase_autoinc_lock_mode; +static ulong innobase_commit_concurrency = 0; static long long innobase_buffer_pool_size, innobase_log_file_size; @@ -165,6 +166,52 @@ static handler *innobase_create_handler(handlerton *hton, static const char innobase_hton_name[]= "InnoDB"; +/** @brief Initialize the default value of innodb_commit_concurrency. + +Once InnoDB is running, the innodb_commit_concurrency must not change +from zero to nonzero. (Bug #42101) + +The initial default value is 0, and without this extra initialization, +SET GLOBAL innodb_commit_concurrency=DEFAULT would set the parameter +to 0, even if it was initially set to nonzero at the command line +or configuration file. */ +static +void +innobase_commit_concurrency_init_default(void); +/*==========================================*/ + +/***************************************************************** +Check for a valid value of innobase_commit_concurrency. */ +static +int +innobase_commit_concurrency_validate( +/*=================================*/ + /* out: 0 for valid + innodb_commit_concurrency */ + THD* thd, /* in: thread handle */ + struct st_mysql_sys_var* var, /* in: pointer to system + variable */ + void* save, /* out: immediate result + for update function */ + struct st_mysql_value* value) /* in: incoming string */ +{ + long long intbuf; + ulong commit_concurrency; + + DBUG_ENTER("innobase_commit_concurrency_validate"); + + if (value->val_int(value, &intbuf)) { + /* The value is NULL. That is invalid. */ + DBUG_RETURN(1); + } + + *reinterpret_cast<ulong*>(save) = commit_concurrency + = static_cast<ulong>(intbuf); + + /* Allow the value to be updated, as long as it remains zero + or nonzero. */ + DBUG_RETURN(!(!commit_concurrency == !innobase_commit_concurrency)); +} static MYSQL_THDVAR_BOOL(support_xa, PLUGIN_VAR_OPCMDARG, "Enable InnoDB support for the XA two-phase commit", @@ -1742,6 +1789,8 @@ innobase_init( (char*)"latin1_swedish_ci")); memcpy(srv_latin1_ordering, my_charset_latin1.sort_order, 256); + innobase_commit_concurrency_init_default(); + /* Since we in this module access directly the fields of a trx struct, and due to different headers and flags it might happen that mutex_t has a different size in this module and in InnoDB @@ -1951,11 +2000,11 @@ innobase_commit( Note, the position is current because of prepare_commit_mutex */ retry: - if (srv_commit_concurrency > 0) { + if (innobase_commit_concurrency > 0) { pthread_mutex_lock(&commit_cond_m); commit_threads++; - if (commit_threads > srv_commit_concurrency) { + if (commit_threads > innobase_commit_concurrency) { commit_threads--; pthread_cond_wait(&commit_cond, &commit_cond_m); @@ -1972,7 +2021,7 @@ retry: innobase_commit_low(trx); - if (srv_commit_concurrency > 0) { + if (innobase_commit_concurrency > 0) { pthread_mutex_lock(&commit_cond_m); commit_threads--; pthread_cond_signal(&commit_cond); @@ -6012,7 +6061,7 @@ ha_innobase::info( nor the CHECK TABLE time, nor the UPDATE or INSERT time. */ if (os_file_get_status(path,&stat_info)) { - stats.create_time = stat_info.ctime; + stats.create_time = (ulong) stat_info.ctime; } } @@ -8128,6 +8177,97 @@ innobase_set_cursor_view( } +/*********************************************************************** +Check whether any of the given columns is being renamed in the table. */ +static +bool +column_is_being_renamed( +/*====================*/ + /* out: true if any of col_names is + being renamed in table */ + TABLE* table, /* in: MySQL table */ + uint n_cols, /* in: number of columns */ + const char** col_names) /* in: names of the columns */ +{ + uint j; + uint k; + Field* field; + const char* col_name; + + for (j = 0; j < n_cols; j++) { + col_name = col_names[j]; + for (k = 0; k < table->s->fields; k++) { + field = table->field[k]; + if ((field->flags & FIELD_IS_RENAMED) + && innobase_strcasecmp(field->field_name, + col_name) == 0) { + return(true); + } + } + } + + return(false); +} + +/*********************************************************************** +Check whether a column in table "table" is being renamed and if this column +is part of a foreign key, either part of another table, referencing this +table or part of this table, referencing another table. */ +static +bool +foreign_key_column_is_being_renamed( +/*================================*/ + /* out: true if a column that + participates in a foreign key definition + is being renamed */ + row_prebuilt_t* prebuilt, /* in: InnoDB prebuilt struct */ + TABLE* table) /* in: MySQL table */ +{ + dict_foreign_t* foreign; + + /* check whether there are foreign keys at all */ + if (UT_LIST_GET_LEN(prebuilt->table->foreign_list) == 0 + && UT_LIST_GET_LEN(prebuilt->table->referenced_list) == 0) { + /* no foreign keys involved with prebuilt->table */ + + return(false); + } + + row_mysql_lock_data_dictionary(prebuilt->trx); + + /* Check whether any column in the foreign key constraints which refer + to this table is being renamed. */ + for (foreign = UT_LIST_GET_FIRST(prebuilt->table->referenced_list); + foreign != NULL; + foreign = UT_LIST_GET_NEXT(referenced_list, foreign)) { + + if (column_is_being_renamed(table, foreign->n_fields, + foreign->referenced_col_names)) { + + row_mysql_unlock_data_dictionary(prebuilt->trx); + return(true); + } + } + + /* Check whether any column in the foreign key constraints in the + table is being renamed. */ + for (foreign = UT_LIST_GET_FIRST(prebuilt->table->foreign_list); + foreign != NULL; + foreign = UT_LIST_GET_NEXT(foreign_list, foreign)) { + + if (column_is_being_renamed(table, foreign->n_fields, + foreign->foreign_col_names)) { + + row_mysql_unlock_data_dictionary(prebuilt->trx); + return(true); + } + } + + row_mysql_unlock_data_dictionary(prebuilt->trx); + + return(false); +} + bool ha_innobase::check_if_incompatible_data( HA_CREATE_INFO* info, uint table_changes) @@ -8144,6 +8284,13 @@ bool ha_innobase::check_if_incompatible_data( return COMPATIBLE_DATA_NO; } + /* Check if a column participating in a foreign key is being renamed. + There is no mechanism for updating InnoDB foreign key definitions. */ + if (foreign_key_column_is_being_renamed(prebuilt, table)) { + + return COMPATIBLE_DATA_NO; + } + /* Check that row format didn't change */ if ((info->used_fields & HA_CREATE_USED_ROW_FORMAT) && get_row_type() != info->row_type) { @@ -8289,10 +8436,10 @@ static MYSQL_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size, "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.", NULL, NULL, 8*1024*1024L, 1024*1024L, LONGLONG_MAX, 1024*1024L); -static MYSQL_SYSVAR_ULONG(commit_concurrency, srv_commit_concurrency, +static MYSQL_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency, PLUGIN_VAR_RQCMDARG, "Helps in performance tuning in heavily concurrent environments.", - NULL, NULL, 0, 0, 1000, 0); + innobase_commit_concurrency_validate, NULL, 0, 0, 1000, 0); static MYSQL_SYSVAR_ULONG(concurrency_tickets, srv_n_free_tickets_to_enter, PLUGIN_VAR_RQCMDARG, @@ -8431,3 +8578,21 @@ mysql_declare_plugin(innobase) NULL /* reserved */ } mysql_declare_plugin_end; + +/** @brief Initialize the default value of innodb_commit_concurrency. + +Once InnoDB is running, the innodb_commit_concurrency must not change +from zero to nonzero. (Bug #42101) + +The initial default value is 0, and without this extra initialization, +SET GLOBAL innodb_commit_concurrency=DEFAULT would set the parameter +to 0, even if it was initially set to nonzero at the command line +or configuration file. */ +static +void +innobase_commit_concurrency_init_default(void) +/*==========================================*/ +{ + MYSQL_SYSVAR_NAME(commit_concurrency).def_val + = innobase_commit_concurrency; +} diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h index 82e95a2e920..17bfbeec2c1 100644 --- a/storage/innobase/include/fsp0fsp.h +++ b/storage/innobase/include/fsp0fsp.h @@ -15,29 +15,7 @@ Created 12/18/1995 Heikki Tuuri #include "fut0lst.h" #include "ut0byte.h" #include "page0types.h" - -/* If records are inserted in order, there are the following -flags to tell this (their type is made byte for the compiler -to warn if direction and hint parameters are switched in -fseg_alloc_free_page): */ -#define FSP_UP ((byte)111) /* alphabetically upwards */ -#define FSP_DOWN ((byte)112) /* alphabetically downwards */ -#define FSP_NO_DIR ((byte)113) /* no order */ - -/* File space extent size in pages */ -#define FSP_EXTENT_SIZE 64 - -/* On a page of any file segment, data may be put starting from this offset: */ -#define FSEG_PAGE_DATA FIL_PAGE_DATA - -/* File segment header which points to the inode describing the file segment */ -typedef byte fseg_header_t; - -#define FSEG_HDR_SPACE 0 /* space id of the inode */ -#define FSEG_HDR_PAGE_NO 4 /* page number of the inode */ -#define FSEG_HDR_OFFSET 8 /* byte offset of the inode */ - -#define FSEG_HEADER_SIZE 10 +#include "fsp0types.h" /************************************************************************** Initializes the file space system. */ @@ -350,40 +328,6 @@ fseg_print( fseg_header_t* header, /* in: segment header */ mtr_t* mtr); /* in: mtr */ -/* Flags for fsp_reserve_free_extents */ -#define FSP_NORMAL 1000000 -#define FSP_UNDO 2000000 -#define FSP_CLEANING 3000000 - -/* Number of pages described in a single descriptor page: currently each page -description takes less than 1 byte; a descriptor page is repeated every -this many file pages */ -#define XDES_DESCRIBED_PER_PAGE UNIV_PAGE_SIZE - -/* The space low address page map */ -/*--------------------------------------*/ - /* The following two pages are repeated - every XDES_DESCRIBED_PER_PAGE pages in - every tablespace. */ -#define FSP_XDES_OFFSET 0 /* extent descriptor */ -#define FSP_IBUF_BITMAP_OFFSET 1 /* insert buffer bitmap */ - /* The ibuf bitmap pages are the ones whose - page number is the number above plus a - multiple of XDES_DESCRIBED_PER_PAGE */ - -#define FSP_FIRST_INODE_PAGE_NO 2 /* in every tablespace */ - /* The following pages exist - in the system tablespace (space 0). */ -#define FSP_IBUF_HEADER_PAGE_NO 3 /* in tablespace 0 */ -#define FSP_IBUF_TREE_ROOT_PAGE_NO 4 /* in tablespace 0 */ - /* The ibuf tree root page number in - tablespace 0; its fseg inode is on the page - number FSP_FIRST_INODE_PAGE_NO */ -#define FSP_TRX_SYS_PAGE_NO 5 /* in tablespace 0 */ -#define FSP_FIRST_RSEG_PAGE_NO 6 /* in tablespace 0 */ -#define FSP_DICT_HDR_PAGE_NO 7 /* in tablespace 0 */ -/*--------------------------------------*/ - #ifndef UNIV_NONINL #include "fsp0fsp.ic" #endif diff --git a/storage/innobase/include/fsp0types.h b/storage/innobase/include/fsp0types.h new file mode 100644 index 00000000000..6756d9d285c --- /dev/null +++ b/storage/innobase/include/fsp0types.h @@ -0,0 +1,89 @@ +/***************************************************************************** + +Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA + +*****************************************************************************/ + +/****************************************************** +File space management types + +Created May 26, 2009 Vasil Dimov +*******************************************************/ + +#ifndef fsp0types_h +#define fsp0types_h + +#include "univ.i" + +#include "fil0fil.h" /* for FIL_PAGE_DATA */ + +/* If records are inserted in order, there are the following +flags to tell this (their type is made byte for the compiler +to warn if direction and hint parameters are switched in +fseg_alloc_free_page): */ +#define FSP_UP ((byte)111) /* alphabetically upwards */ +#define FSP_DOWN ((byte)112) /* alphabetically downwards */ +#define FSP_NO_DIR ((byte)113) /* no order */ + +/* File space extent size in pages */ +#define FSP_EXTENT_SIZE 64 + +/* On a page of any file segment, data may be put starting from this offset: */ +#define FSEG_PAGE_DATA FIL_PAGE_DATA + +/* File segment header which points to the inode describing the file segment */ +typedef byte fseg_header_t; + +#define FSEG_HDR_SPACE 0 /* space id of the inode */ +#define FSEG_HDR_PAGE_NO 4 /* page number of the inode */ +#define FSEG_HDR_OFFSET 8 /* byte offset of the inode */ + +#define FSEG_HEADER_SIZE 10 + +/* Flags for fsp_reserve_free_extents */ +#define FSP_NORMAL 1000000 +#define FSP_UNDO 2000000 +#define FSP_CLEANING 3000000 + +/* Number of pages described in a single descriptor page: currently each page +description takes less than 1 byte; a descriptor page is repeated every +this many file pages */ +#define XDES_DESCRIBED_PER_PAGE UNIV_PAGE_SIZE + +/* The space low address page map */ +/*--------------------------------------*/ + /* The following two pages are repeated + every XDES_DESCRIBED_PER_PAGE pages in + every tablespace. */ +#define FSP_XDES_OFFSET 0 /* extent descriptor */ +#define FSP_IBUF_BITMAP_OFFSET 1 /* insert buffer bitmap */ + /* The ibuf bitmap pages are the ones whose + page number is the number above plus a + multiple of XDES_DESCRIBED_PER_PAGE */ + +#define FSP_FIRST_INODE_PAGE_NO 2 /* in every tablespace */ + /* The following pages exist + in the system tablespace (space 0). */ +#define FSP_IBUF_HEADER_PAGE_NO 3 /* in tablespace 0 */ +#define FSP_IBUF_TREE_ROOT_PAGE_NO 4 /* in tablespace 0 */ + /* The ibuf tree root page number in + tablespace 0; its fseg inode is on the page + number FSP_FIRST_INODE_PAGE_NO */ +#define FSP_TRX_SYS_PAGE_NO 5 /* in tablespace 0 */ +#define FSP_FIRST_RSEG_PAGE_NO 6 /* in tablespace 0 */ +#define FSP_DICT_HDR_PAGE_NO 7 /* in tablespace 0 */ +/*--------------------------------------*/ + +#endif /* fsp0types_h */ diff --git a/storage/innobase/include/mtr0log.ic b/storage/innobase/include/mtr0log.ic index 5b1d1ed34d9..1626f1e77e5 100644 --- a/storage/innobase/include/mtr0log.ic +++ b/storage/innobase/include/mtr0log.ic @@ -9,6 +9,8 @@ Created 12/7/1995 Heikki Tuuri #include "mach0data.h" #include "ut0lst.h" #include "buf0buf.h" +#include "fsp0types.h" +#include "trx0sys.h" /************************************************************ Opens a buffer to mlog. It must be closed with mlog_close. */ @@ -174,6 +176,28 @@ mlog_write_initial_log_record_fast( space = buf_block_get_space(block); offset = buf_block_get_page_no(block); + /* check whether the page is in the doublewrite buffer; + the doublewrite buffer is located in pages + FSP_EXTENT_SIZE, ..., 3 * FSP_EXTENT_SIZE - 1 in the + system tablespace */ + if (space == TRX_SYS_SPACE + && offset >= FSP_EXTENT_SIZE && offset < 3 * FSP_EXTENT_SIZE) { + if (trx_doublewrite_buf_is_being_created) { + /* Do nothing: we only come to this branch in an + InnoDB database creation. We do not redo log + anything for the doublewrite buffer pages. */ + return(log_ptr); + } else { + fprintf(stderr, + "Error: trying to redo log a record of type " + "%d on page %lu of space %lu in the " + "doublewrite buffer, continuing anyway.\n" + "Please post a bug report to " + "bugs.mysql.com.\n", + type, offset, space); + } + } + mach_write_to_1(log_ptr, type); log_ptr++; log_ptr += mach_write_compressed(log_ptr, space); diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 9ff3c225eb0..67144a41d3d 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -109,7 +109,6 @@ extern ulint srv_max_dirty_pages_pct; extern ulint srv_force_recovery; extern ulong srv_thread_concurrency; -extern ulong srv_commit_concurrency; extern ulint srv_max_n_threads; diff --git a/storage/innobase/include/trx0rseg.ic b/storage/innobase/include/trx0rseg.ic index eb1893587a6..577cd0dee7b 100644 --- a/storage/innobase/include/trx0rseg.ic +++ b/storage/innobase/include/trx0rseg.ic @@ -7,6 +7,7 @@ Created 3/26/1996 Heikki Tuuri *******************************************************/ #include "srv0srv.h" +#include "mtr0log.h" /********************************************************************** Gets a rollback segment header. */ diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index a8da5cd51a3..bad3c9d570c 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -13,15 +13,12 @@ Created 3/26/1996 Heikki Tuuri #include "trx0types.h" #include "mtr0mtr.h" -#include "mtr0log.h" #include "ut0byte.h" #include "mem0mem.h" #include "sync0sync.h" #include "ut0lst.h" #include "buf0buf.h" #include "fil0fil.h" -#include "fut0lst.h" -#include "fsp0fsp.h" #include "read0types.h" /* In a MySQL replication slave, in crash recovery we store the master log @@ -45,6 +42,8 @@ extern trx_sys_t* trx_sys; /* Doublewrite system */ extern trx_doublewrite_t* trx_doublewrite; +/* Set to TRUE when the doublewrite buffer is being created */ +extern ibool trx_doublewrite_buf_is_being_created; extern ibool trx_doublewrite_must_reset_space_ids; extern ibool trx_sys_multiple_tablespace_format; @@ -302,6 +301,7 @@ trx_sys_print_mysql_master_log_pos(void); /* Space id and page no where the trx system file copy resides */ #define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */ +#include "fsp0fsp.h" #define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO /* The offset of the transaction system header on the page */ diff --git a/storage/innobase/include/trx0sys.ic b/storage/innobase/include/trx0sys.ic index 86b71df08d6..55bcc12a414 100644 --- a/storage/innobase/include/trx0sys.ic +++ b/storage/innobase/include/trx0sys.ic @@ -9,6 +9,7 @@ Created 3/26/1996 Heikki Tuuri #include "srv0srv.h" #include "trx0trx.h" #include "data0type.h" +#include "mtr0log.h" /* The typedef for rseg slot in the file copy */ typedef byte trx_sysf_rseg_t; diff --git a/storage/innobase/page/page0cur.c b/storage/innobase/page/page0cur.c index 70b7de194fd..ea011843890 100644 --- a/storage/innobase/page/page0cur.c +++ b/storage/innobase/page/page0cur.c @@ -538,7 +538,7 @@ page_cur_open_on_rnd_user_rec( rnd = page_rnd % page_get_n_recs(page); } else { - rnd = (ulint) page_cur_lcg_prng() % page_get_n_recs(page); + rnd = (ulint) (page_cur_lcg_prng() % page_get_n_recs(page)); } rec = page_get_infimum_rec(page); diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index 2d9ed4fc944..6ec466cf995 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -1529,9 +1529,14 @@ row_unlock_for_mysql( index = btr_pcur_get_btr_cur(clust_pcur)->index; } + if (UNIV_UNLIKELY(!(index->type & DICT_CLUSTERED))) { + /* This is not a clustered index record. We + do not know how to unlock the record. */ + goto no_unlock; + } + /* If the record has been modified by this transaction, do not unlock it. */ - ut_a(index->type & DICT_CLUSTERED); if (index->trx_id_offset) { rec_trx_id = trx_read_trx_id(rec @@ -1568,7 +1573,7 @@ row_unlock_for_mysql( prebuilt->select_lock_type); } } - +no_unlock: mtr_commit(&mtr); } diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index b8b63052394..71e74ab848b 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -285,7 +285,6 @@ computer. Bigger computers need bigger values. Value 0 will disable the concurrency check. */ ulong srv_thread_concurrency = 0; -ulong srv_commit_concurrency = 0; os_fast_mutex_t srv_conc_mutex; /* this mutex protects srv_conc data structures */ diff --git a/storage/innobase/trx/trx0purge.c b/storage/innobase/trx/trx0purge.c index f0e85ef1604..f0f300d918e 100644 --- a/storage/innobase/trx/trx0purge.c +++ b/storage/innobase/trx/trx0purge.c @@ -14,6 +14,7 @@ Created 3/26/1996 Heikki Tuuri #include "fsp0fsp.h" #include "mach0data.h" +#include "mtr0log.h" #include "trx0rseg.h" #include "trx0trx.h" #include "trx0roll.h" diff --git a/storage/innobase/trx/trx0rec.c b/storage/innobase/trx/trx0rec.c index 50f8b011463..38ad53fcfb0 100644 --- a/storage/innobase/trx/trx0rec.c +++ b/storage/innobase/trx/trx0rec.c @@ -23,6 +23,7 @@ Created 3/26/1996 Heikki Tuuri #include "que0que.h" #include "trx0purge.h" #include "row0row.h" +#include "mtr0log.h" /*=========== UNDO LOG RECORD CREATION AND DECODING ====================*/ diff --git a/storage/innobase/trx/trx0sys.c b/storage/innobase/trx/trx0sys.c index 40348dd4199..19c5159e15f 100644 --- a/storage/innobase/trx/trx0sys.c +++ b/storage/innobase/trx/trx0sys.c @@ -13,7 +13,7 @@ Created 3/26/1996 Heikki Tuuri #endif #include "fsp0fsp.h" -#include "mtr0mtr.h" +#include "mtr0log.h" #include "trx0trx.h" #include "trx0rseg.h" #include "trx0undo.h" @@ -25,6 +25,7 @@ Created 3/26/1996 Heikki Tuuri /* The transaction system */ trx_sys_t* trx_sys = NULL; trx_doublewrite_t* trx_doublewrite = NULL; +ibool trx_doublewrite_buf_is_being_created = FALSE; /* The following is set to TRUE when we are upgrading from the old format data files to the new >= 4.1.x format multiple tablespaces format data files */ @@ -180,6 +181,7 @@ trx_sys_create_doublewrite_buf(void) start_again: mtr_start(&mtr); + trx_doublewrite_buf_is_being_created = TRUE; page = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr); #ifdef UNIV_SYNC_DEBUG @@ -196,6 +198,7 @@ start_again: trx_doublewrite_init(doublewrite); mtr_commit(&mtr); + trx_doublewrite_buf_is_being_created = FALSE; } else { fprintf(stderr, "InnoDB: Doublewrite buffer not found:" @@ -274,14 +277,8 @@ start_again: buf_page_dbg_add_level(new_page, SYNC_NO_ORDER_CHECK); #endif /* UNIV_SYNC_DEBUG */ - /* Make a dummy change to the page to ensure it will - be written to disk in a flush */ - - mlog_write_ulint(new_page + FIL_PAGE_DATA, - TRX_SYS_DOUBLEWRITE_MAGIC_N, - MLOG_4BYTES, &mtr); - if (i == FSP_EXTENT_SIZE / 2) { + ut_a(page_no == FSP_EXTENT_SIZE); mlog_write_ulint(doublewrite + TRX_SYS_DOUBLEWRITE_BLOCK1, page_no, MLOG_4BYTES, &mtr); @@ -291,6 +288,7 @@ start_again: page_no, MLOG_4BYTES, &mtr); } else if (i == FSP_EXTENT_SIZE / 2 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) { + ut_a(page_no == 2 * FSP_EXTENT_SIZE); mlog_write_ulint(doublewrite + TRX_SYS_DOUBLEWRITE_BLOCK2, page_no, MLOG_4BYTES, &mtr); diff --git a/storage/innobase/trx/trx0undo.c b/storage/innobase/trx/trx0undo.c index b31580d0ce0..deb6c85e6e3 100644 --- a/storage/innobase/trx/trx0undo.c +++ b/storage/innobase/trx/trx0undo.c @@ -14,6 +14,7 @@ Created 3/26/1996 Heikki Tuuri #include "fsp0fsp.h" #include "mach0data.h" +#include "mtr0log.h" #include "trx0rseg.h" #include "trx0trx.h" #include "srv0srv.h" diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index e82246638ff..d0e5f5a5c88 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -95,7 +95,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, if (!thd->vio_ok()) { - sql_print_error(msgbuf); + sql_print_error("%s", msgbuf); return; } @@ -1112,6 +1112,9 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool do_optimize) param.out_flag= 0; strmov(fixed_name,file->filename); + // Release latches since this can take a long time + ha_release_temporary_latches(thd); + // Don't lock tables if we have used LOCK TABLE if (!thd->locked_tables && mi_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK)) @@ -1784,7 +1787,7 @@ int ha_myisam::info(uint flag) stats.data_file_length= misam_info.data_file_length; stats.index_file_length= misam_info.index_file_length; stats.delete_length= misam_info.delete_length; - stats.check_time= misam_info.check_time; + stats.check_time= (ulong) misam_info.check_time; stats.mean_rec_length= misam_info.mean_reclength; } if (flag & HA_STATUS_CONST) @@ -1792,7 +1795,7 @@ int ha_myisam::info(uint flag) TABLE_SHARE *share= table->s; stats.max_data_file_length= misam_info.max_data_file_length; stats.max_index_file_length= misam_info.max_index_file_length; - stats.create_time= misam_info.create_time; + stats.create_time= (ulong) misam_info.create_time; ref_length= misam_info.reflength; share->db_options_in_use= misam_info.options; stats.block_size= myisam_block_size; /* record block size */ @@ -1807,7 +1810,7 @@ int ha_myisam::info(uint flag) if (share->key_parts) memcpy((char*) table->key_info[0].rec_per_key, (char*) misam_info.rec_per_key, - sizeof(table->key_info[0].rec_per_key[0])*share->key_parts); + sizeof(table->key_info[0].rec_per_key[0])*share->key_parts); if (share->tmp_table == NO_TMP_TABLE) pthread_mutex_unlock(&share->mutex); @@ -1831,7 +1834,7 @@ int ha_myisam::info(uint flag) my_store_ptr(dup_ref, ref_length, misam_info.dupp_key_pos); } if (flag & HA_STATUS_TIME) - stats.update_time = misam_info.update_time; + stats.update_time = (ulong) misam_info.update_time; if (flag & HA_STATUS_AUTO) stats.auto_increment_value= misam_info.auto_increment; @@ -1867,6 +1870,12 @@ int ha_myisam::delete_all_rows() return mi_delete_all_rows(file); } +int ha_myisam::reset_auto_increment(ulonglong value) +{ + file->s->state.auto_increment= value; + return 0; +} + int ha_myisam::delete_table(const char *name) { return mi_delete_table(name); diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index ca44ae9ad87..55a5eac92de 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -101,6 +101,7 @@ class ha_myisam: public handler int reset(void); int external_lock(THD *thd, int lock_type); int delete_all_rows(void); + int reset_auto_increment(ulonglong value); int disable_indexes(uint mode); int enable_indexes(uint mode); int indexes_are_disabled(void); diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index ac0be2f01cc..75678375ce7 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -287,8 +287,8 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, { "key_buffer_size", OPT_KEY_BUFFER_SIZE, "", (uchar**) &check_param.use_buffers, (uchar**) &check_param.use_buffers, 0, - GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD, - (long) ~0L, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0}, + GET_ULL, REQUIRED_ARG, USE_BUFFER_INIT, MALLOC_OVERHEAD, + SIZE_T_MAX, MALLOC_OVERHEAD, IO_SIZE, 0}, { "key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, "", (uchar**) &opt_key_cache_block_size, (uchar**) &opt_key_cache_block_size, 0, @@ -1102,7 +1102,7 @@ static int myisamchk(MI_CHECK *param, char * filename) { if (param->testflag & (T_EXTEND | T_MEDIUM)) VOID(init_key_cache(dflt_key_cache,opt_key_cache_block_size, - param->use_buffers, 0, 0)); + (size_t) param->use_buffers, 0, 0)); VOID(init_io_cache(¶m->read_cache,datafile, (uint) param->read_buffer_length, READ_CACHE, @@ -1525,8 +1525,8 @@ static int mi_sort_records(MI_CHECK *param, if (share->state.key_root[sort_key] == HA_OFFSET_ERROR) DBUG_RETURN(0); /* Nothing to do */ - init_key_cache(dflt_key_cache, opt_key_cache_block_size, param->use_buffers, - 0, 0); + init_key_cache(dflt_key_cache, opt_key_cache_block_size, + (size_t) param->use_buffers, 0, 0); if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length, WRITE_CACHE,share->pack.header_length,1, MYF(MY_WME | MY_WAIT_IF_FULL))) diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index 7e25309ae70..19510d0eae1 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -545,7 +545,8 @@ int ha_myisammrg::attach_children(void) if (myrg_attach_children(this->file, this->test_if_locked | current_thd->open_options, - myisammrg_attach_children_callback, this)) + myisammrg_attach_children_callback, this, + (my_bool *) &need_compat_check)) { DBUG_PRINT("error", ("my_errno %d", my_errno)); DBUG_RETURN(my_errno ? my_errno : -1); @@ -925,11 +926,11 @@ int ha_myisammrg::info(uint flag) with such a number, it'll be an error later anyway. */ bzero((char*) table->key_info[0].rec_per_key, - sizeof(table->key_info[0].rec_per_key) * table->s->key_parts); + sizeof(table->key_info[0].rec_per_key[0]) * table->s->key_parts); #endif memcpy((char*) table->key_info[0].rec_per_key, (char*) mrg_info.rec_per_key, - sizeof(table->key_info[0].rec_per_key) * + sizeof(table->key_info[0].rec_per_key[0]) * min(file->keys, table->s->key_parts)); } } diff --git a/storage/myisammrg/myrg_create.c b/storage/myisammrg/myrg_create.c index df81b730bfd..eaed470daec 100644 --- a/storage/myisammrg/myrg_create.c +++ b/storage/myisammrg/myrg_create.c @@ -46,7 +46,7 @@ int myrg_create(const char *name, const char **table_names, fn_same(buff,name,4); *(end=strend(buff))='\n'; end[1]=0; - if (my_write(file,(char*) buff,(uint) (end-buff+1), + if (my_write(file,(uchar*) buff,(uint) (end-buff+1), MYF(MY_WME | MY_NABP))) goto err; } diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c index 14ba2853b22..01420f47a0c 100644 --- a/storage/myisammrg/myrg_open.c +++ b/storage/myisammrg/myrg_open.c @@ -365,11 +365,14 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, The callback returns the MyISAM table handle of the child table. Check table definition match. - @param[in] m_info MERGE parent table structure - @param[in] handle_locking if contains HA_OPEN_FOR_REPAIR, warn about - incompatible child tables, but continue - @param[in] callback function to call for each child table - @param[in] callback_param data pointer to give to the callback + @param[in] m_info MERGE parent table structure + @param[in] handle_locking if contains HA_OPEN_FOR_REPAIR, warn about + incompatible child tables, but continue + @param[in] callback function to call for each child table + @param[in] callback_param data pointer to give to the callback + @param[in] need_compat_check pointer to ha_myisammrg::need_compat_check + (we need this one to decide if previously + allocated buffers can be reused). @return status @retval 0 OK @@ -382,7 +385,7 @@ MYRG_INFO *myrg_parent_open(const char *parent_name, int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, MI_INFO *(*callback)(void*), - void *callback_param) + void *callback_param, my_bool *need_compat_check) { ulonglong file_offset; MI_INFO *myisam; @@ -423,6 +426,11 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, m_info->reclength= myisam->s->base.reclength; min_keys= myisam->s->base.keys; key_parts= myisam->s->base.key_parts; + if (*need_compat_check && m_info->rec_per_key_part) + { + my_free((char *) m_info->rec_per_key_part, MYF(0)); + m_info->rec_per_key_part= NULL; + } if (!m_info->rec_per_key_part) { if(!(m_info->rec_per_key_part= (ulong*) diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 1ed758bc105..2ea48ddab2f 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -7992,6 +7992,7 @@ static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(size_t)) static my_bool my_coll_init_uca(CHARSET_INFO *cs, void *(*alloc)(size_t)) { cs->pad_char= ' '; + cs->ctype= my_charset_utf8_unicode_ci.ctype; return create_tailoring(cs, alloc); } diff --git a/strings/ctype.c b/strings/ctype.c index 446eb168804..17ad1256e74 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -328,7 +328,9 @@ my_string_repertoire(CHARSET_INFO *cs, const char *str, ulong length) { my_wc_t wc; int chlen; - for (; (chlen= cs->cset->mb_wc(cs, &wc, str, strend)) > 0; str+= chlen) + for (; + (chlen= cs->cset->mb_wc(cs, &wc, (uchar*) str, (uchar*) strend)) > 0; + str+= chlen) { if (wc > 0x7F) return MY_REPERTOIRE_UNICODE30; diff --git a/strings/decimal.c b/strings/decimal.c index a7770fbb2e1..616d5291482 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -306,7 +306,7 @@ int decimal_actual_fraction(decimal_t *from) { for (i= DIG_PER_DEC1 - ((frac - 1) % DIG_PER_DEC1); *buf0 % powers10[i++] == 0; - frac--); + frac--) ; } return frac; } @@ -500,7 +500,7 @@ static void digits_bounds(decimal_t *from, int *start_result, int *end_result) stop= (int) ((buf_end - from->buf + 1) * DIG_PER_DEC1); i= 1; } - for (; *buf_end % powers10[i++] == 0; stop--); + for (; *buf_end % powers10[i++] == 0; stop--) ; *end_result= stop; /* index of position after last decimal digit (from 0) */ } @@ -1011,7 +1011,7 @@ static int ull2dec(ulonglong from, decimal_t *to) sanity(to); - for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE); + for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE) ; if (unlikely(intg1 > to->len)) { intg1=to->len; diff --git a/support-files/build-tags b/support-files/build-tags index 6c80d2638e9..b5386dc79c3 100755 --- a/support-files/build-tags +++ b/support-files/build-tags @@ -4,7 +4,7 @@ rm -f TAGS filter='\.cc$\|\.c$\|\.h$\|\.yy$' list="find . -type f" -bzr root >/dev/null 2>/dev/null && list="bzr ls --kind=file --versioned" +bzr root >/dev/null 2>/dev/null && list="bzr ls --from-root -R --kind=file --versioned" $list |grep $filter |while read f; do diff --git a/tests/Makefile.am b/tests/Makefile.am index fbd58b88b9c..ddc6da86e1c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -56,7 +56,7 @@ bug25714_SOURCES= bug25714.c bug25714_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) # Fix for mit-threads -DEFS = -DUNDEF_THREADS_HACK +DEFS = -DMYSQL_CLIENT_NO_THREADS thread_test.o: thread_test.c $(COMPILE) -c $(INCLUDES) $< diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 6025063846a..b836293442a 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -103,7 +103,7 @@ if (!opt_silent) \ static void print_error(const char *msg); static void print_st_error(MYSQL_STMT *stmt, const char *msg); -static void client_disconnect(void); +static void client_disconnect(MYSQL* mysql, my_bool drop_db); /* @@ -271,10 +271,20 @@ mysql_simple_prepare(MYSQL *mysql_arg, const char *query) } -/* Connect to the server */ - -static void client_connect(ulong flag) +/** + Connect to the server with options given by arguments to this application, + stored in global variables opt_host, opt_user, opt_password, opt_db, + opt_port and opt_unix_socket. + + @param flag[in] client_flag passed on to mysql_real_connect + @param protocol[in] MYSQL_PROTOCOL_* to use for this connection + @param auto_reconnect[in] set to 1 for auto reconnect + + @return pointer to initialized and connected MYSQL object +*/ +static MYSQL* client_connect(ulong flag, uint protocol, my_bool auto_reconnect) { + MYSQL* mysql; int rc; static char query[MAX_TEST_QUERY_LENGTH]; myheader_r("client_connect"); @@ -291,6 +301,7 @@ static void client_connect(ulong flag) } /* enable local infile, in non-binary builds often disabled by default */ mysql_options(mysql, MYSQL_OPT_LOCAL_INFILE, 0); + mysql_options(mysql, MYSQL_OPT_PROTOCOL, &protocol); if (!(mysql_real_connect(mysql, opt_host, opt_user, opt_password, opt_db ? opt_db:"test", opt_port, @@ -302,7 +313,7 @@ static void client_connect(ulong flag) fprintf(stdout, "\n Check the connection options using --help or -?\n"); exit(1); } - mysql->reconnect= 1; + mysql->reconnect= auto_reconnect; if (!opt_silent) fprintf(stdout, "OK"); @@ -329,12 +340,14 @@ static void client_connect(ulong flag) if (!opt_silent) fprintf(stdout, "OK"); + + return mysql; } /* Close the connection */ -static void client_disconnect() +static void client_disconnect(MYSQL* mysql, my_bool drop_db) { static char query[MAX_TEST_QUERY_LENGTH]; @@ -342,13 +355,16 @@ static void client_disconnect() if (mysql) { - if (!opt_silent) - fprintf(stdout, "\n dropping the test database '%s' ...", current_db); - strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS); + if (drop_db) + { + if (!opt_silent) + fprintf(stdout, "\n dropping the test database '%s' ...", current_db); + strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS); - mysql_query(mysql, query); - if (!opt_silent) - fprintf(stdout, "OK"); + mysql_query(mysql, query); + if (!opt_silent) + fprintf(stdout, "OK"); + } if (!opt_silent) fprintf(stdout, "\n closing the connection ..."); @@ -2464,6 +2480,9 @@ static void test_ps_query_cache() myheader("test_ps_query_cache"); + rc= mysql_query(mysql, "SET SQL_MODE=''"); + myquery(rc); + /* prepare the table */ rc= mysql_query(mysql, "drop table if exists t1"); @@ -2506,6 +2525,9 @@ static void test_ps_query_cache() mysql_close(lmysql); DIE_UNLESS(0); } + rc= mysql_query(lmysql, "SET SQL_MODE=''"); + myquery(rc); + if (!opt_silent) fprintf(stdout, "OK"); } @@ -4240,6 +4262,10 @@ static void test_fetch_date() myheader("test_fetch_date"); + /* Will not work if sql_mode is NO_ZERO_DATE (implicit if TRADITIONAL) /*/ + rc= mysql_query(mysql, "SET SQL_MODE=''"); + myquery(rc); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result"); myquery(rc); @@ -4954,6 +4980,9 @@ static void test_stmt_close() /* set AUTOCOMMIT to ON*/ mysql_autocommit(lmysql, TRUE); + rc= mysql_query(lmysql, "SET SQL_MODE = ''"); + myquery(rc); + rc= mysql_query(lmysql, "DROP TABLE IF EXISTS test_stmt_close"); myquery(rc); @@ -12088,6 +12117,9 @@ static void test_bug6058() myheader("test_bug6058"); + rc= mysql_query(mysql, "SET SQL_MODE=''"); + myquery(rc); + stmt_text= "SELECT CAST('0000-00-00' AS DATE)"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); @@ -13303,6 +13335,9 @@ static void test_bug8378() if (!opt_silent) fprintf(stdout, "OK"); + rc= mysql_query(lmysql, "SET SQL_MODE=''"); + myquery(rc); + len= mysql_real_escape_string(lmysql, out, TEST_BUG8378_IN, 4); /* No escaping should have actually happened. */ @@ -16390,12 +16425,27 @@ static void test_change_user() myquery(rc); sprintf(buff, + "grant select on %s.* to %s@'localhost' identified by '%s'", + db, + user_pw, + pw); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, "grant select on %s.* to %s@'%%'", db, user_no_pw); rc= mysql_query(mysql, buff); myquery(rc); + sprintf(buff, + "grant select on %s.* to %s@'localhost'", + db, + user_no_pw); + rc= mysql_query(mysql, buff); + myquery(rc); + /* Try some combinations */ rc= mysql_change_user(mysql, NULL, NULL, NULL); @@ -16552,6 +16602,14 @@ static void test_change_user() rc= mysql_query(mysql, buff); myquery(rc); + sprintf(buff, "drop user %s@'localhost'", user_pw); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, "drop user %s@'localhost'", user_no_pw); + rc= mysql_query(mysql, buff); + myquery(rc); + DBUG_VOID_RETURN; } @@ -17220,6 +17278,11 @@ static void test_bug31669() rc= mysql_query(mysql, query); myquery(rc); + strxmov(query, "GRANT ALL PRIVILEGES ON *.* TO '", user, "'@'localhost' IDENTIFIED BY " + "'", buff, "' WITH GRANT OPTION", NullS); + rc= mysql_query(mysql, query); + myquery(rc); + rc= mysql_query(mysql, "FLUSH PRIVILEGES"); myquery(rc); @@ -17257,7 +17320,7 @@ static void test_bug31669() strxmov(query, "DELETE FROM mysql.user WHERE User='", user, "'", NullS); rc= mysql_query(mysql, query); myquery(rc); - DIE_UNLESS(mysql_affected_rows(mysql) == 1); + DIE_UNLESS(mysql_affected_rows(mysql) == 2); #endif DBUG_VOID_RETURN; @@ -17469,6 +17532,9 @@ static void test_wl4166_2() myheader("test_wl4166_2"); + rc= mysql_query(mysql, "SET SQL_MODE=''"); + myquery(rc); + rc= mysql_query(mysql, "drop table if exists t1"); myquery(rc); rc= mysql_query(mysql, "create table t1 (c_int int, d_date date)"); @@ -17663,6 +17729,100 @@ static void test_bug40365(void) /** + Subtest for Bug#43560. Verifies that a loss of connection on the server side + is handled well by the mysql_stmt_execute() call, i.e., no SIGSEGV due to + a vio socket that is cleared upon closed connection. + + Assumes the presence of the close_conn_after_stmt_execute debug feature in + the server. Verifies that it is connected to a debug server before proceeding + with the test. + */ +static void test_bug43560(void) +{ + MYSQL* conn; + uint rc; + MYSQL_STMT *stmt= 0; + MYSQL_BIND bind; + my_bool is_null= 0; + char buffer[256]; + const uint BUFSIZE= sizeof(buffer); + const char* values[] = {"eins", "zwei", "drei", "viele", NULL}; + const char insert_str[] = "INSERT INTO t1 (c2) VALUES (?)"; + unsigned long length; + + DBUG_ENTER("test_bug43560"); + myheader("test_bug43560"); + + /* Make sure we only run against a debug server. */ + if (!strstr(mysql->server_version, "debug")) + { + fprintf(stdout, "Skipping test_bug43560: server not DEBUG version\n"); + DBUG_VOID_RETURN; + } + + /* + Set up a separate connection for this test to avoid messing up the + general MYSQL object used in other subtests. Use TCP protocol to avoid + problems with the buffer semantics of AF_UNIX, and turn off auto reconnect. + */ + conn= client_connect(0, MYSQL_PROTOCOL_TCP, 0); + + rc= mysql_query(conn, "DROP TABLE IF EXISTS t1"); + myquery(rc); + rc= mysql_query(conn, + "CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 CHAR(10))"); + myquery(rc); + + stmt= mysql_stmt_init(conn); + check_stmt(stmt); + rc= mysql_stmt_prepare(stmt, insert_str, strlen(insert_str)); + check_execute(stmt, rc); + + bind.buffer_type= MYSQL_TYPE_STRING; + bind.buffer_length= BUFSIZE; + bind.buffer= buffer; + bind.is_null= &is_null; + bind.length= &length; + rc= mysql_stmt_bind_param(stmt, &bind); + check_execute(stmt, rc); + + /* First execute; should succeed. */ + strncpy(buffer, values[0], BUFSIZE); + length= strlen(buffer); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + /* + Set up the server to close this session's server-side socket after + next execution of prep statement. + */ + rc= mysql_query(conn,"SET SESSION debug='+d,close_conn_after_stmt_execute'"); + myquery(rc); + + /* Second execute; should fail due to socket closed during execution. */ + strncpy(buffer, values[1], BUFSIZE); + length= strlen(buffer); + rc= mysql_stmt_execute(stmt); + DIE_UNLESS(rc && mysql_stmt_errno(stmt) == CR_SERVER_LOST); + + /* + Third execute; should fail (connection already closed), or SIGSEGV in + case of a Bug#43560 type regression in which case the whole test fails. + */ + strncpy(buffer, values[2], BUFSIZE); + length= strlen(buffer); + rc= mysql_stmt_execute(stmt); + DIE_UNLESS(rc && mysql_stmt_errno(stmt) == CR_SERVER_LOST); + + client_disconnect(conn, 0); + rc= mysql_query(mysql, "DROP TABLE t1"); + myquery(rc); + + DBUG_VOID_RETURN; +} + + +/** Bug#36326: nested transaction and select */ @@ -18090,6 +18250,7 @@ static struct my_tests_st my_tests[]= { { "test_wl4166_2", test_wl4166_2 }, { "test_bug38486", test_bug38486 }, { "test_bug40365", test_bug40365 }, + { "test_bug43560", test_bug43560 }, #ifdef HAVE_QUERY_CACHE { "test_bug36326", test_bug36326 }, #endif @@ -18218,7 +18379,8 @@ int main(int argc, char **argv) (char**) embedded_server_groups)) DIE("Can't initialize MySQL server"); - client_connect(0); /* connect to server */ + /* connect to server with no flags, default protocol, auto reconnect true */ + mysql= client_connect(0, MYSQL_PROTOCOL_DEFAULT, 1); total_time= 0; for (iter_count= 1; iter_count <= opt_count; iter_count++) @@ -18248,7 +18410,7 @@ int main(int argc, char **argv) fprintf(stderr, "\n\nGiven test not found: '%s'\n", *argv); fprintf(stderr, "See legal test names with %s -T\n\nAborting!\n", my_progname); - client_disconnect(); + client_disconnect(mysql, 1); free_defaults(defaults_argv); exit(1); } @@ -18261,7 +18423,7 @@ int main(int argc, char **argv) /* End of tests */ } - client_disconnect(); /* disconnect from server */ + client_disconnect(mysql, 1); /* disconnect from server */ free_defaults(defaults_argv); print_test_output(); |