From 54fbbf9591e21cda9f7b26c2d795d88f51827f07 Mon Sep 17 00:00:00 2001 From: Ignacio Galarza Date: Tue, 10 Feb 2009 17:47:54 -0500 Subject: [PATCH 01/88] Bug#29125 Windows Server X64: so many compiler warnings - Remove bothersome warning messages. This change focuses on the warnings that are covered by the ignore file: support-files/compiler_warnings.supp. - Strings are guaranteed to be max uint in length --- client/mysql.cc | 7 +- client/mysql_upgrade.c | 2 +- client/mysqladmin.cc | 2 +- client/mysqlbinlog.cc | 16 +- client/mysqlcheck.c | 9 +- client/mysqldump.c | 30 +- client/mysqltest.c | 78 ++-- client/sql_string.cc | 2 +- extra/comp_err.c | 2 +- extra/yassl/src/buffer.cpp | 4 +- extra/yassl/src/cert_wrapper.cpp | 14 +- extra/yassl/src/ssl.cpp | 6 +- extra/yassl/src/yassl_imp.cpp | 2 +- extra/yassl/src/yassl_int.cpp | 12 +- extra/yassl/taocrypt/include/block.hpp | 2 +- extra/yassl/taocrypt/src/algebra.cpp | 2 +- extra/yassl/taocrypt/src/asn.cpp | 2 +- heap/hp_write.c | 2 +- include/my_sys.h | 2 +- innobase/include/pars0pars.h | 2 +- innobase/pars/pars0pars.c | 4 +- innobase/rem/rem0cmp.c | 2 +- libmysql/libmysql.c | 6 +- libmysql/manager.c | 4 +- myisam/mi_check.c | 6 +- myisam/mi_open.c | 5 +- myisam/mi_packrec.c | 2 +- myisam/mi_search.c | 2 +- myisam/rt_index.c | 10 +- mysys/base64.c | 2 +- mysys/default.c | 6 +- mysys/mf_iocache2.c | 4 +- mysys/my_static.c | 4 +- mysys/safemalloc.c | 2 +- mysys/string.c | 4 +- server-tools/instance-manager/buffer.cc | 2 +- server-tools/instance-manager/commands.cc | 18 +- server-tools/instance-manager/instance.cc | 2 +- server-tools/instance-manager/instance_map.cc | 2 +- .../instance-manager/instance_options.cc | 8 +- server-tools/instance-manager/listener.cc | 33 +- .../instance-manager/mysql_connection.cc | 4 +- server-tools/instance-manager/options.cc | 2 +- server-tools/instance-manager/parse.cc | 2 +- server-tools/instance-manager/parse.h | 2 +- server-tools/instance-manager/parse_output.cc | 8 +- server-tools/instance-manager/protocol.cc | 12 +- server-tools/instance-manager/user_map.cc | 2 +- sql-common/client.c | 2 +- sql-common/my_user.c | 4 +- sql/gen_lex_hash.cc | 6 +- sql/ha_archive.cc | 6 +- sql/ha_federated.cc | 30 +- sql/ha_innodb.cc | 2 +- sql/handler.cc | 7 +- sql/item.cc | 2 +- sql/item_func.cc | 4 +- sql/item_strfunc.cc | 14 +- sql/item_strfunc.h | 2 +- sql/item_timefunc.cc | 64 ++-- sql/lock.cc | 4 +- sql/log.cc | 4 +- sql/log_event.cc | 36 +- sql/mysqld.cc | 6 +- sql/net_serv.cc | 4 +- sql/opt_range.cc | 46 +-- sql/opt_sum.cc | 6 +- sql/parse_file.cc | 10 +- sql/protocol.cc | 6 +- sql/set_var.cc | 16 +- sql/slave.cc | 14 +- sql/sp.cc | 10 +- sql/sp_head.cc | 16 +- sql/spatial.cc | 2 +- sql/sql_acl.cc | 62 ++-- sql/sql_base.cc | 10 +- sql/sql_cache.cc | 10 +- sql/sql_crypt.cc | 2 +- sql/sql_db.cc | 18 +- sql/sql_derived.cc | 2 +- sql/sql_error.cc | 2 +- sql/sql_handler.cc | 16 +- sql/sql_help.cc | 10 +- sql/sql_insert.cc | 2 +- sql/sql_lex.cc | 4 +- sql/sql_load.cc | 4 +- sql/sql_parse.cc | 38 +- sql/sql_prepare.cc | 8 +- sql/sql_repl.cc | 8 +- sql/sql_select.cc | 40 +- sql/sql_show.cc | 162 ++++---- sql/sql_string.cc | 4 +- sql/sql_table.cc | 8 +- sql/sql_trigger.cc | 36 +- sql/sql_udf.cc | 2 +- sql/sql_view.cc | 16 +- sql/table.cc | 8 +- sql/udf_example.c | 4 +- sql/uniques.cc | 2 +- sql/unireg.cc | 2 +- strings/ctype-mb.c | 4 +- strings/ctype-simple.c | 10 +- strings/ctype-ucs2.c | 2 +- strings/my_vsnprintf.c | 2 +- strings/xml.c | 4 +- tests/bug25714.c | 4 +- tests/mysql_client_test.c | 348 +++++++++--------- vio/viosocket.c | 2 +- 108 files changed, 786 insertions(+), 751 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 88ddd40fa68..d8af7b9c7e5 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1226,7 +1226,7 @@ sig_handler mysql_sigint(int sig) goto err; /* kill_buffer is always big enough because max length of %lu is 15 */ sprintf(kill_buffer, "KILL /*!50000 QUERY */ %lu", mysql_thread_id(&mysql)); - mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer)); + mysql_real_query(kill_mysql, kill_buffer, (uint) strlen(kill_buffer)); mysql_close(kill_mysql); tee_fprintf(stdout, "Query aborted by Ctrl+C\n"); @@ -3449,7 +3449,7 @@ static void print_warnings() /* Get the warnings */ query= "show warnings"; - mysql_real_query_for_lazy(query, strlen(query)); + mysql_real_query_for_lazy(query, (uint) strlen(query)); mysql_store_result_for_lazy(&result); /* Bail out when no warnings */ @@ -4329,7 +4329,8 @@ server_version_string(MYSQL *con) MYSQL_ROW cur = mysql_fetch_row(result); if (cur && cur[0]) { - bufp = strxnmov(bufp, sizeof buf - (bufp - buf), " ", cur[0], NullS); + bufp = strxnmov(bufp, (uint) (sizeof buf - (bufp - buf)), " ", cur[0], + NullS); } mysql_free_result(result); } diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 74e8c9dd577..e3500c81fb9 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -429,7 +429,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res, MYF(MY_WME))) < 0) die("Failed to create temporary file for defaults"); - if (my_write(fd, query, strlen(query), + if (my_write(fd, query, (uint) strlen(query), MYF(MY_FNABP | MY_WME))) { my_close(fd, MYF(0)); diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 54f67c5df2d..24b95be8626 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -844,7 +844,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) bool old= (find_type(argv[0], &command_typelib, 2) == ADMIN_OLD_PASSWORD); #ifdef __WIN__ - uint pw_len= strlen(pw); + uint pw_len= (uint) strlen(pw); if (pw_len > 1 && pw[0] == '\'' && pw[pw_len-1] == '\'') printf("Warning: single quotes were not trimmed from the password by" " your command\nline client, as you might have expected.\n"); diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index f0a4c8d2abf..ed072902730 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -105,7 +105,7 @@ static MYSQL* safe_connect(); class Load_log_processor { char target_dir_name[FN_REFLEN]; - int target_dir_name_len; + size_t target_dir_name_len; /* When we see first event corresponding to some LOAD DATA statement in @@ -275,7 +275,7 @@ File Load_log_processor::prepare_new_file_for_old_format(Load_log_event *le, File file; fn_format(filename, le->fname, target_dir_name, "", 1); - len= strlen(filename); + len= (uint) strlen(filename); tail= filename + len; if ((file= create_unique_file(filename,tail)) < 0) @@ -284,7 +284,7 @@ File Load_log_processor::prepare_new_file_for_old_format(Load_log_event *le, return -1; } - le->set_fname_outside_temp_buf(filename,len+strlen(tail)); + le->set_fname_outside_temp_buf(filename,len+(uint) strlen(tail)); return file; } @@ -369,7 +369,7 @@ int Load_log_processor::process_first_event(const char *bname, uint blen, uint file_id, Create_file_log_event *ce) { - uint full_len= target_dir_name_len + blen + 9 + 9 + 1; + size_t full_len= target_dir_name_len + blen + 9 + 9 + 1; int error= 0; char *fname, *ptr; File file; @@ -403,7 +403,7 @@ int Load_log_processor::process_first_event(const char *bname, uint blen, } if (ce) - ce->set_fname_outside_temp_buf(fname, strlen(fname)); + ce->set_fname_outside_temp_buf(fname, (uint) strlen(fname)); if (my_write(file, (byte*)block, block_len, MYF(MY_WME|MY_NABP))) error= -1; @@ -416,7 +416,7 @@ int Load_log_processor::process_first_event(const char *bname, uint blen, int Load_log_processor::process(Create_file_log_event *ce) { const char *bname= ce->fname + dirname_length(ce->fname); - uint blen= ce->fname_len - (bname-ce->fname); + uint blen= (uint) (ce->fname_len - (bname-ce->fname)); return process_first_event(bname, blen, ce->block, ce->block_len, ce->file_id, ce); @@ -864,7 +864,7 @@ static my_time_t convert_str_to_timestamp(const char* str) long dummy_my_timezone; my_bool dummy_in_dst_time_gap; /* We require a total specification (date AND time) */ - if (str_to_datetime(str, strlen(str), &l_time, 0, &was_cut) != + if (str_to_datetime(str, (uint) strlen(str), &l_time, 0, &was_cut) != MYSQL_TIMESTAMP_DATETIME || was_cut) { fprintf(stderr, "Incorrect date and time argument: %s\n", str); @@ -1109,7 +1109,7 @@ could be out of memory"); int4store(buf, (uint32)start_position); int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags); - size_s tlen = strlen(logname); + size_t tlen= strlen(logname); if (tlen > UINT_MAX) { fprintf(stderr,"Log name too long\n"); diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 513d1974ed0..15922e672a6 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -328,7 +328,7 @@ static int get_options(int *argc, char ***argv) if (!what_to_do) { - int pnlen = strlen(my_progname); + size_t pnlen= strlen(my_progname); if (pnlen < 6) /* name too short */ what_to_do = DO_CHECK; @@ -414,7 +414,8 @@ static int process_selected_tables(char *db, char **table_names, int tables) space is for more readable output in logs and in case of error */ char *table_names_comma_sep, *end; - int i, tot_length = 0; + size_t tot_length= 0; + int i= 0; for (i = 0; i < tables; i++) tot_length+= fixed_name_length(*(table_names + i)) + 2; @@ -430,7 +431,7 @@ static int process_selected_tables(char *db, char **table_names, int tables) *end++= ','; } *--end = 0; - handle_request_for_tables(table_names_comma_sep + 1, tot_length - 1); + handle_request_for_tables(table_names_comma_sep + 1, (uint) (tot_length - 1)); my_free(table_names_comma_sep, MYF(0)); } else @@ -452,7 +453,7 @@ static uint fixed_name_length(const char *name) else if (*p == '.') extra_length+= 2; } - return (p - name) + extra_length; + return (uint) ((p - name) + extra_length); } diff --git a/client/mysqldump.c b/client/mysqldump.c index ced34f16212..5bc3d402c2c 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -662,7 +662,7 @@ static void free_table_ent(char *key) byte* get_table_key(const char *entry, uint *length, my_bool not_used __attribute__((unused))) { - *length= strlen(entry); + *length= (uint) strlen(entry); return (byte*) entry; } @@ -778,7 +778,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_set_charset= 0; opt_compatible_mode_str= argument; opt_compatible_mode= find_set(&compatible_mode_typelib, - argument, strlen(argument), + argument, (uint) strlen(argument), &err_ptr, &err_len); if (err_len) { @@ -791,7 +791,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), uint size_for_sql_mode= 0; const char **ptr; for (ptr= compatible_mode_names; *ptr; ptr++) - size_for_sql_mode+= strlen(*ptr); + size_for_sql_mode+= (uint) strlen(*ptr); size_for_sql_mode+= sizeof(compatible_mode_names)-1; DBUG_ASSERT(sizeof(compatible_mode_normal_str)>=size_for_sql_mode); } @@ -1039,7 +1039,7 @@ static int switch_character_set_results(MYSQL *mysql, const char *cs_name) "SET SESSION character_set_results = '%s'", (const char *) cs_name); - return mysql_real_query(mysql, query_buffer, query_length); + return mysql_real_query(mysql, query_buffer, (uint) query_length); } @@ -1371,7 +1371,8 @@ static void print_xml_tag(FILE * xml_file, const char* sbeg, fputs(attribute_name, xml_file); fputc('\"', xml_file); - print_quoted_xml(xml_file, attribute_value, strlen(attribute_value)); + print_quoted_xml(xml_file, attribute_value, + (uint) strlen(attribute_value)); fputc('\"', xml_file); attribute_name= va_arg(arg_list, char *); @@ -1411,7 +1412,7 @@ static void print_xml_null_tag(FILE * xml_file, const char* sbeg, fputs("<", xml_file); fputs(stag_atr, xml_file); fputs("\"", xml_file); - print_quoted_xml(xml_file, sval, strlen(sval)); + print_quoted_xml(xml_file, sval, (uint) strlen(sval)); fputs("\" xsi:nil=\"true\" />", xml_file); fputs(line_end, xml_file); check_io(xml_file); @@ -1509,7 +1510,7 @@ static uint dump_routines_for_db(char *db) DBUG_ENTER("dump_routines_for_db"); DBUG_PRINT("enter", ("db: '%s'", db)); - mysql_real_escape_string(mysql, db_name_buff, db, strlen(db)); + mysql_real_escape_string(mysql, db_name_buff, db, (uint) strlen(db)); /* nice comments */ if (opt_comments) @@ -1601,13 +1602,13 @@ static uint dump_routines_for_db(char *db) Allocate memory for new query string: original string from SHOW statement and version-specific comments. */ - query_str= alloc_query_str(strlen(row[2]) + 23); + query_str= alloc_query_str((uint) strlen(row[2]) + 23); query_str_tail= strnmov(query_str, row[2], - definer_begin - row[2]); + (uint) (definer_begin - row[2])); query_str_tail= strmov(query_str_tail, "*/ /*!50020"); query_str_tail= strnmov(query_str_tail, definer_begin, - definer_end - definer_begin); + (uint) (definer_end - definer_begin)); query_str_tail= strxmov(query_str_tail, "*/ /*!50003", definer_end, NullS); } @@ -2216,7 +2217,7 @@ static void dump_triggers_for_table(char *table, char host_name_str[HOSTNAME_LENGTH + 1]; char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3]; - parse_user(row[7], strlen(row[7]), user_name_str, &user_name_len, + parse_user(row[7], (uint) strlen(row[7]), user_name_str, &user_name_len, host_name_str, &host_name_len); fprintf(sql_file, @@ -3054,7 +3055,7 @@ static int dump_all_tables_in_db(char *database) while ((table= getTableName(0))) { char *end= strmov(afterdot, table); - if (include_table(hash_key, end - hash_key)) + if (include_table(hash_key, (uint) (end - hash_key))) { dump_table(table,database); my_free(order_by, MYF(MY_ALLOW_ZERO_PTR)); @@ -3622,7 +3623,7 @@ static char *primary_key_fields(const char *table_name) do { quoted_field= quote_name(row[4], buff, 0); - result_length+= strlen(quoted_field) + 1; /* + 1 for ',' or \0 */ + result_length+= (uint) strlen(quoted_field) + 1; /* + 1 for ',' or \0 */ } while ((row= mysql_fetch_row(res)) && atoi(row[3]) > 1); } @@ -3682,7 +3683,8 @@ static int replace(DYNAMIC_STRING *ds_str, return 1; init_dynamic_string_checked(&ds_tmp, "", ds_str->length + replace_len, 256); - dynstr_append_mem_checked(&ds_tmp, ds_str->str, start - ds_str->str); + dynstr_append_mem_checked(&ds_tmp, ds_str->str, + (uint) (start - ds_str->str)); dynstr_append_mem_checked(&ds_tmp, replace_str, replace_len); dynstr_append_checked(&ds_tmp, start + search_len); dynstr_set_checked(ds_str, ds_tmp.str); diff --git a/client/mysqltest.c b/client/mysqltest.c index d7fbb6f1f18..64b9f4a5a16 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -801,7 +801,7 @@ void check_command_args(struct st_command *command, ptr++; if (ptr > start) { - init_dynamic_string(arg->ds, 0, ptr-start, 32); + init_dynamic_string(arg->ds, 0, (uint) (ptr - start), 32); do_eval(arg->ds, start, ptr, FALSE); } else @@ -1156,16 +1156,16 @@ void warning_msg(const char *fmt, ...) len= my_snprintf(buff, sizeof(buff), "in included file %s ", cur_file->file_name); dynstr_append_mem(&ds_warning_messages, - buff, len); + buff, (uint) len); } len= my_snprintf(buff, sizeof(buff), "at line %d: ", start_lineno); dynstr_append_mem(&ds_warning_messages, - buff, len); + buff, (uint) len); } len= my_vsnprintf(buff, sizeof(buff), fmt, args); - dynstr_append_mem(&ds_warning_messages, buff, len); + dynstr_append_mem(&ds_warning_messages, buff, (uint) len); dynstr_append(&ds_warning_messages, "\n"); va_end(args); @@ -1185,7 +1185,7 @@ void log_msg(const char *fmt, ...) len= my_vsnprintf(buff, sizeof(buff)-1, fmt, args); va_end(args); - dynstr_append_mem(&ds_res, buff, len); + dynstr_append_mem(&ds_res, buff, (uint) len); dynstr_append(&ds_res, "\n"); DBUG_VOID_RETURN; @@ -1222,7 +1222,7 @@ void cat_file(DYNAMIC_STRING* ds, const char* filename) /* Add fake newline instead of cr and output the line */ *p= '\n'; p++; /* Step past the "fake" newline */ - dynstr_append_mem(ds, start, p-start); + dynstr_append_mem(ds, start, (uint) (p - start)); p++; /* Step past the "fake" newline */ start= p; } @@ -1230,7 +1230,7 @@ void cat_file(DYNAMIC_STRING* ds, const char* filename) p++; } /* Output any chars that migh be left */ - dynstr_append_mem(ds, start, p-start); + dynstr_append_mem(ds, start, (uint) (p - start)); } my_close(fd, MYF(0)); } @@ -1770,9 +1770,9 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val, int val_alloc_len; VAR *tmp_var; if (!name_len && name) - name_len = strlen(name); + name_len = (uint) strlen(name); if (!val_len && val) - val_len = strlen(val) ; + val_len = (uint) strlen(val) ; val_alloc_len = val_len + 16; /* room to grow */ if (!(tmp_var=v) && !(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var) + name_len+1, MYF(MY_WME)))) @@ -1815,7 +1815,7 @@ VAR* var_from_env(const char *name, const char *def_val) if (!(tmp = getenv(name))) tmp = def_val; - v = var_init(0, name, strlen(name), tmp, strlen(tmp)); + v = var_init(0, name, (uint) strlen(name), tmp, (uint) strlen(tmp)); my_hash_insert(&var_hash, (byte*)v); return v; } @@ -1864,7 +1864,7 @@ VAR* var_get(const char *var_name, const char **var_name_end, my_bool raw, { sprintf(v->str_val, "%d", v->int_val); v->int_dirty = 0; - v->str_val_len = strlen(v->str_val); + v->str_val_len = (uint) strlen(v->str_val); } if (var_name_end) *var_name_end = var_name ; @@ -1927,7 +1927,7 @@ void var_set(const char *var_name, const char *var_name_end, { sprintf(v->str_val, "%d", v->int_val); v->int_dirty= 0; - v->str_val_len= strlen(v->str_val); + v->str_val_len= (uint) strlen(v->str_val); } my_snprintf(buf, sizeof(buf), "%.*s=%.*s", v->name_len, v->name, @@ -2006,7 +2006,7 @@ void var_query_set(VAR *var, const char *query, const char** query_end) ++query; /* Eval the query, thus replacing all environment variables */ - init_dynamic_string(&ds_query, 0, (end - query) + 32, 256); + init_dynamic_string(&ds_query, 0, (uint) ((end - query) + 32), 256); do_eval(&ds_query, query, end, FALSE); if (mysql_real_query(mysql, ds_query.str, ds_query.length)) @@ -2223,7 +2223,7 @@ void eval_expr(VAR *v, const char *p, const char **p_end) struct st_command command; memset(&command, 0, sizeof(command)); command.query= (char*)p; - command.first_word_len= len; + command.first_word_len= (uint) len; command.first_argument= command.query + len; command.end= (char*)*p_end; var_set_query_get_value(&command, v); @@ -2413,7 +2413,7 @@ static int replace(DYNAMIC_STRING *ds_str, return 1; init_dynamic_string(&ds_tmp, "", ds_str->length + replace_len, 256); - dynstr_append_mem(&ds_tmp, ds_str->str, start - ds_str->str); + dynstr_append_mem(&ds_tmp, ds_str->str, (uint) (start - ds_str->str)); dynstr_append_mem(&ds_tmp, replace_str, replace_len); dynstr_append(&ds_tmp, start + search_len); dynstr_set(ds_str, ds_tmp.str); @@ -2468,7 +2468,7 @@ void do_exec(struct st_command *command) if (builtin_echo[0] && strncmp(cmd, "echo", 4) == 0) { /* Replace echo with our "builtin" echo */ - replace(&ds_cmd, "echo", 4, builtin_echo, strlen(builtin_echo)); + replace(&ds_cmd, "echo", 4, builtin_echo, (uint) strlen(builtin_echo)); } #ifdef __WIN__ @@ -4627,7 +4627,7 @@ void do_delimiter(struct st_command* command) die("Can't set empty delimiter"); strmake(delimiter, p, sizeof(delimiter) - 1); - delimiter_length= strlen(delimiter); + delimiter_length= (uint) strlen(delimiter); DBUG_PRINT("exit", ("delimiter: %s", delimiter)); command->last_argument= p + delimiter_length; @@ -4753,9 +4753,11 @@ int read_line(char *buf, int size) } else if ((c == '{' && (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5, - (uchar*) buf, min(5, p - buf), 0) || + (uchar*) buf, min(5, (uint) (p - buf)), + 0) || !my_strnncoll_simple(charset_info, (const uchar*) "if", 2, - (uchar*) buf, min(2, p - buf), 0)))) + (uchar*) buf, min(2, (uint) (p - buf)), + 0)))) { /* Only if and while commands can be terminated by { */ *p++= c; @@ -5117,7 +5119,7 @@ int read_command(struct st_command** command_ptr) command->first_argument= p; command->end= strend(command->query); - command->query_len= (command->end - command->query); + command->query_len= (uint) (command->end - command->query); parser.read_lines++; DBUG_RETURN(0); } @@ -6459,7 +6461,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) else { query = command->query; - query_len = strlen(query); + query_len = (uint) strlen(query); } /* @@ -6520,7 +6522,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) */ view_created= 1; query= (char*)"SELECT * FROM mysqltest_tmp_v"; - query_len = strlen(query); + query_len = (uint) strlen(query); /* Collect warnings from create of the view that should otherwise @@ -6568,7 +6570,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) sp_created= 1; query= (char*)"CALL mysqltest_tmp_sp()"; - query_len = strlen(query); + query_len = (uint) strlen(query); } dynstr_free(&query_str); } @@ -6661,7 +6663,7 @@ void init_re_comp(my_regex_t *re, const char* str) if (err) { char erbuf[100]; - int len= my_regerror(err, re, erbuf, sizeof(erbuf)); + size_t len= my_regerror(err, re, erbuf, sizeof(erbuf)); die("error %s, %d/%d `%s'\n", re_eprint(err), len, (int)sizeof(erbuf), erbuf); } @@ -6717,7 +6719,7 @@ int match_re(my_regex_t *re, char *str) { char erbuf[100]; - int len= my_regerror(err, re, erbuf, sizeof(erbuf)); + size_t len= my_regerror(err, re, erbuf, sizeof(erbuf)); die("error %s, %d/%d `%s'\n", re_eprint(err), len, (int)sizeof(erbuf), erbuf); } @@ -7579,7 +7581,7 @@ void replace_strings_append(REPLACE *rep, DYNAMIC_STRING* ds, if (!(rep_str = ((REPLACE_STRING*) rep_pos))->replace_string) { /* No match found */ - dynstr_append_mem(ds, start, from - start - 1); + dynstr_append_mem(ds, start, (uint) (from - start - 1)); DBUG_PRINT("exit", ("Found no more string to replace, appended: %s", start)); DBUG_VOID_RETURN; } @@ -7590,11 +7592,11 @@ void replace_strings_append(REPLACE *rep, DYNAMIC_STRING* ds, rep_str->from_offset, rep_str->replace_string)); /* Append part of original string before replace string */ - dynstr_append_mem(ds, start, (from - rep_str->to_offset) - start); + dynstr_append_mem(ds, start, (uint) ((from - rep_str->to_offset) - start)); /* Append replace string */ dynstr_append_mem(ds, rep_str->replace_string, - strlen(rep_str->replace_string)); + (uint) strlen(rep_str->replace_string)); if (!*(from-=rep_str->from_offset) && rep_pos->found != 2) { @@ -7689,7 +7691,7 @@ struct st_replace_regex* init_replace_regex(char* expr) char* buf,*expr_end; char* p; char* buf_p; - uint expr_len= strlen(expr); + size_t expr_len= strlen(expr); char last_c = 0; struct st_regex reg; @@ -7866,7 +7868,7 @@ void free_replace_regex() */ #define SECURE_REG_BUF if (buf_len < need_buf_len) \ { \ - int off= res_p - buf; \ + size_t off= res_p - buf; \ buf= (char*)my_realloc(buf,need_buf_len,MYF(MY_WME+MY_FAE)); \ res_p= buf + off; \ buf_len= need_buf_len; \ @@ -7898,7 +7900,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, char *res_p,*str_p,*str_end; buf_len= *buf_len_p; - len= strlen(string); + len= (uint) strlen(string); str_end= string + len; /* start with a buffer of a reasonable size that hopefully will not @@ -7950,7 +7952,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, we need at least what we have so far in the buffer + the part before this match */ - need_buf_len= (res_p - buf) + (int) subs[0].rm_so; + need_buf_len= (uint) (res_p - buf) + (int) subs[0].rm_so; /* on this pass, calculate the memory for the result buffer */ while (expr_p < replace_end) @@ -8040,8 +8042,8 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, } else /* no match this time, just copy the string as is */ { - int left_in_str= str_end-str_p; - need_buf_len= (res_p-buf) + left_in_str; + size_t left_in_str= str_end-str_p; + need_buf_len= (uint) ((res_p-buf) + left_in_str); SECURE_REG_BUF memcpy(res_p,str_p,left_in_str); res_p += left_in_str; @@ -8708,7 +8710,7 @@ void replace_dynstr_append_mem(DYNAMIC_STRING *ds, if (!multi_reg_replace(glob_replace_regex, (char*)val)) { val= glob_replace_regex->buf; - len= strlen(val); + len= (uint) strlen(val); } } @@ -8725,7 +8727,7 @@ void replace_dynstr_append_mem(DYNAMIC_STRING *ds, /* Append zero-terminated string to ds, with optional replace */ void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val) { - replace_dynstr_append_mem(ds, val, strlen(val)); + replace_dynstr_append_mem(ds, val, (uint) strlen(val)); } /* Append uint to ds, with optional replace */ @@ -8733,7 +8735,7 @@ void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val) { char buff[22]; /* This should be enough for any int */ char *end= longlong10_to_str(val, buff, 10); - replace_dynstr_append_mem(ds, buff, end - buff); + replace_dynstr_append_mem(ds, buff, (uint) (end - buff)); } @@ -8771,7 +8773,7 @@ void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input) while (*start && *start != '\n') start++; start++; /* Skip past \n */ - dynstr_append_mem(ds, ds_input->str, start - ds_input->str); + dynstr_append_mem(ds, ds_input->str, (uint) (start - ds_input->str)); /* Insert line(s) in array */ while (*start) diff --git a/client/sql_string.cc b/client/sql_string.cc index 9d887ff031c..0f93d1d40f8 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -468,7 +468,7 @@ bool String::append(const char *s,uint32 arg_length) bool String::append(const char *s) { - return append(s, strlen(s)); + return append(s, (uint) strlen(s)); } diff --git a/extra/comp_err.c b/extra/comp_err.c index 79f591e45fb..8814a045f36 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -660,7 +660,7 @@ static ha_checksum checksum_format_specifier(const char* msg) case 'u': case 'x': case 's': - chksum= my_checksum(chksum, start, p-start); + chksum= my_checksum(chksum, start, (uint) (p - start)); start= 0; /* Not in format specifier anymore */ break; diff --git a/extra/yassl/src/buffer.cpp b/extra/yassl/src/buffer.cpp index 0c3f23b0cb8..66107dbe0a9 100644 --- a/extra/yassl/src/buffer.cpp +++ b/extra/yassl/src/buffer.cpp @@ -106,7 +106,7 @@ void input_buffer::add_size(uint i) uint input_buffer::get_capacity() const { - return end_ - buffer_; + return (uint) (end_ - buffer_); } @@ -223,7 +223,7 @@ uint output_buffer::get_size() const uint output_buffer::get_capacity() const { - return end_ - buffer_; + return (uint) (end_ - buffer_); } diff --git a/extra/yassl/src/cert_wrapper.cpp b/extra/yassl/src/cert_wrapper.cpp index 5eacf9083f9..8caca8f9649 100644 --- a/extra/yassl/src/cert_wrapper.cpp +++ b/extra/yassl/src/cert_wrapper.cpp @@ -236,7 +236,7 @@ uint CertManager::get_privateKeyLength() const int CertManager::Validate() { CertList::reverse_iterator last = peerList_.rbegin(); - int count = peerList_.size(); + size_t count= peerList_.size(); while ( count > 1 ) { TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length()); @@ -269,13 +269,13 @@ int CertManager::Validate() else peerKeyType_ = dsa_sa_algo; - int iSz = strlen(cert.GetIssuer()) + 1; - int sSz = strlen(cert.GetCommonName()) + 1; - int bSz = strlen(cert.GetBeforeDate()) + 1; - int aSz = strlen(cert.GetAfterDate()) + 1; + size_t iSz= strlen(cert.GetIssuer()) + 1; + size_t sSz= strlen(cert.GetCommonName()) + 1; + size_t bSz= strlen(cert.GetBeforeDate()) + 1; + size_t aSz= strlen(cert.GetAfterDate()) + 1; peerX509_ = NEW_YS X509(cert.GetIssuer(), iSz, cert.GetCommonName(), - sSz, cert.GetBeforeDate(), bSz, - cert.GetAfterDate(), aSz); + sSz, cert.GetBeforeDate(), (int) bSz, + cert.GetAfterDate(), (int) aSz); } return 0; } diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index f09a43be56e..781cfa36a70 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -604,13 +604,13 @@ char* X509_NAME_oneline(X509_NAME* name, char* buffer, int sz) { if (!name->GetName()) return buffer; - int len = strlen(name->GetName()) + 1; - int copySz = min(len, sz); + size_t len= strlen(name->GetName()) + 1; + int copySz = min((int) len, sz); if (!buffer) { buffer = (char*)malloc(len); if (!buffer) return buffer; - copySz = len; + copySz = (int) len; } if (copySz == 0) diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp index b43d9c27355..4ee0fb99d3a 100644 --- a/extra/yassl/src/yassl_imp.cpp +++ b/extra/yassl/src/yassl_imp.cpp @@ -532,7 +532,7 @@ void Parameters::SetCipherNames() for (int j = 0; j < suites; j++) { int index = suites_[j*2 + 1]; // every other suite is suite id - int len = strlen(cipher_names[index]) + 1; + size_t len = strlen(cipher_names[index]) + 1; strncpy(cipher_list_[pos++], cipher_names[index], len); } cipher_list_[pos][0] = 0; diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index 0b6cb89e77e..ba8ee8f66ab 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -1034,7 +1034,7 @@ void SSL::fillData(Data& data) { if (GetError()) return; uint dataSz = data.get_length(); // input, data size to fill - uint elements = buffers_.getData().size(); + size_t elements = buffers_.getData().size(); data.set_length(0); // output, actual data filled dataSz = min(dataSz, bufferedData()); @@ -1064,7 +1064,7 @@ void SSL::PeekData(Data& data) { if (GetError()) return; uint dataSz = data.get_length(); // input, data size to fill - uint elements = buffers_.getData().size(); + size_t elements = buffers_.getData().size(); data.set_length(0); // output, actual data filled dataSz = min(dataSz, bufferedData()); @@ -1098,7 +1098,7 @@ void SSL::flushBuffer() buffers_.getHandShake().end(), SumBuffer()).total_; output_buffer out(sz); - uint elements = buffers_.getHandShake().size(); + size_t elements = buffers_.getHandShake().size(); for (uint i = 0; i < elements; i++) { output_buffer* front = buffers_.getHandShake().front(); @@ -1906,7 +1906,7 @@ bool SSL_CTX::SetCipherList(const char* list) int idx = 0; for(;;) { - int len; + size_t len; prev = haystack; haystack = strstr(haystack, needle); @@ -2354,10 +2354,10 @@ ASN1_STRING* X509_NAME::GetEntry(int i) memcpy(entry_.data, &name_[i], sz_ - i); if (entry_.data[sz_ -i - 1]) { entry_.data[sz_ - i] = 0; - entry_.length = sz_ - i; + entry_.length = (int) (sz_ - i); } else - entry_.length = sz_ - i - 1; + entry_.length = (int) (sz_ - i - 1); entry_.type = 0; return &entry_; diff --git a/extra/yassl/taocrypt/include/block.hpp b/extra/yassl/taocrypt/include/block.hpp index 529a91eee08..bb34db5e07f 100644 --- a/extra/yassl/taocrypt/include/block.hpp +++ b/extra/yassl/taocrypt/include/block.hpp @@ -78,7 +78,7 @@ typename A::pointer StdReallocate(A& a, T* p, typename A::size_type oldSize, if (preserve) { A b = A(); typename A::pointer newPointer = b.allocate(newSize, 0); - memcpy(newPointer, p, sizeof(T) * min(oldSize, newSize)); + memcpy(newPointer, p, sizeof(T) * min((word32) oldSize, (word32) newSize)); a.deallocate(p, oldSize); STL::swap(a, b); return newPointer; diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp index cb597c41552..c221ce3d6cb 100644 --- a/extra/yassl/taocrypt/src/algebra.cpp +++ b/extra/yassl/taocrypt/src/algebra.cpp @@ -288,7 +288,7 @@ void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base, r = buckets[i][buckets[i].size()-1]; if (buckets[i].size() > 1) { - for (int j = buckets[i].size()-2; j >= 1; j--) + for (int j= (unsigned int) (buckets[i].size()) - 2; j >= 1; j--) { Accumulate(buckets[i][j], buckets[i][j+1]); Accumulate(r, buckets[i][j]); diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp index a06ab658c7b..3b1c1c2136a 100644 --- a/extra/yassl/taocrypt/src/asn.cpp +++ b/extra/yassl/taocrypt/src/asn.cpp @@ -213,7 +213,7 @@ void PublicKey::AddToEnd(const byte* data, word32 len) Signer::Signer(const byte* k, word32 kSz, const char* n, const byte* h) : key_(k, kSz) { - int sz = strlen(n); + size_t sz = strlen(n); memcpy(name_, n, sz); name_[sz] = 0; diff --git a/heap/hp_write.c b/heap/hp_write.c index 19215fcf017..6aa34acf2c3 100644 --- a/heap/hp_write.c +++ b/heap/hp_write.c @@ -69,7 +69,7 @@ int heap_write(HP_INFO *info, const byte *record) err: if (my_errno == HA_ERR_FOUND_DUPP_KEY) DBUG_PRINT("info",("Duplicate key: %d", (int) (keydef - share->keydef))); - info->errkey= keydef - share->keydef; + info->errkey= (int) (keydef - share->keydef); /* We don't need to delete non-inserted key from rb-tree. Also, if we got ENOMEM, the key wasn't inserted, so don't try to delete it diff --git a/include/my_sys.h b/include/my_sys.h index 5dc73bf84d9..f3429b02967 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -250,7 +250,7 @@ extern int NEAR my_umask, /* Default creation mask */ NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */ NEAR my_dont_interrupt; /* call remember_intr when set */ extern my_bool NEAR mysys_uses_curses, my_use_symdir; -extern ulong sf_malloc_cur_memory, sf_malloc_max_memory; +extern size_t sf_malloc_cur_memory, sf_malloc_max_memory; extern ulong my_default_record_cache_size; extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io, diff --git a/innobase/include/pars0pars.h b/innobase/include/pars0pars.h index 62a41a881e8..5c81e331487 100644 --- a/innobase/include/pars0pars.h +++ b/innobase/include/pars0pars.h @@ -484,7 +484,7 @@ struct for_node_struct{ definition */ que_node_t* loop_start_limit;/* initial value of loop variable */ que_node_t* loop_end_limit; /* end value of loop variable */ - int loop_end_value; /* evaluated value for the end value: + lint loop_end_value; /* evaluated value for the end value: it is calculated only when the loop is entered, and will not change within the loop */ diff --git a/innobase/pars/pars0pars.c b/innobase/pars/pars0pars.c index c62184abd85..562870b6bed 100644 --- a/innobase/pars/pars0pars.c +++ b/innobase/pars/pars0pars.c @@ -1679,8 +1679,8 @@ pars_get_lex_chars( { int len; - len = pars_sym_tab_global->string_len - - pars_sym_tab_global->next_char_pos; + len= (uint) (pars_sym_tab_global->string_len + - pars_sym_tab_global->next_char_pos); if (len == 0) { #ifdef YYDEBUG /* fputs("SQL string ends\n", stderr); */ diff --git a/innobase/rem/rem0cmp.c b/innobase/rem/rem0cmp.c index 6a463b7d4cf..a0c28e117ac 100644 --- a/innobase/rem/rem0cmp.c +++ b/innobase/rem/rem0cmp.c @@ -587,7 +587,7 @@ cmp_dtuple_rec_with_match( dtuple_byte = cmp_collate(dtuple_byte); } - ret = dtuple_byte - rec_byte; + ret = (uint) (dtuple_byte - rec_byte); if (UNIV_UNLIKELY(ret)) { if (ret < 0) { ret = -1; diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index dd66a325169..485e8fa3967 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3552,7 +3552,7 @@ static void fetch_string_with_conversion(MYSQL_BIND *param, char *value, */ char *start= value + param->offset; char *end= value + length; - ulong copy_length; + size_t copy_length; if (start < end) { copy_length= end - start; @@ -3807,11 +3807,11 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, if (field->flags & ZEROFILL_FLAG && length < field->length && field->length < MAX_DOUBLE_STRING_REP_LENGTH - 1) { - bmove_upp((char*) buff + field->length, buff + length, length); + bmove_upp((char*) buff + field->length, buff + length, (uint) length); bfill((char*) buff, field->length - length, '0'); length= field->length; } - fetch_string_with_conversion(param, buff, length); + fetch_string_with_conversion(param, buff, (uint) length); } break; diff --git a/libmysql/manager.c b/libmysql/manager.c index 631bfa26cb2..3260ddcd685 100644 --- a/libmysql/manager.c +++ b/libmysql/manager.c @@ -159,7 +159,7 @@ MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con, goto err; } sprintf(msg_buf,"%-.16s %-.16s\n",user,passwd); - msg_len=strlen(msg_buf); + msg_len= (uint) strlen(msg_buf); if (my_net_write(&con->net,msg_buf,msg_len) || net_flush(&con->net)) { con->last_errno=con->net.last_errno; @@ -219,7 +219,7 @@ int STDCALL mysql_manager_command(MYSQL_MANAGER* con,const char* cmd, int cmd_len) { if (!cmd_len) - cmd_len=strlen(cmd); + cmd_len= (uint) strlen(cmd); if (my_net_write(&con->net,(char*)cmd,cmd_len) || net_flush(&con->net)) { con->last_errno=errno; diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 4f8883f377e..285a31d34c6 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -659,7 +659,7 @@ void mi_collect_stats_nonulls_first(HA_KEYSEG *keyseg, ulonglong *notnull, uchar *key) { uint first_null, kp; - first_null= ha_find_null(keyseg, key) - keyseg; + first_null= (uint) (ha_find_null(keyseg, key) - keyseg); /* All prefix tuples that don't include keypart_{first_null} are not-null tuples (and all others aren't), increment counters for them. @@ -715,7 +715,7 @@ int mi_collect_stats_nonulls_next(HA_KEYSEG *keyseg, ulonglong *notnull, seg= keyseg + diffs[0] - 1; /* Find first NULL in last_key */ - first_null_seg= ha_find_null(seg, last_key + diffs[1]) - keyseg; + first_null_seg= (uint) (ha_find_null(seg, last_key + diffs[1]) - keyseg); for (kp= 0; kp < first_null_seg; kp++) notnull[kp]++; @@ -3913,7 +3913,7 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) key_block++; sort_info->key_block=key_block; sort_param->keyinfo=& sort_info->info->s->ft2_keyinfo; - ft_buf->count=(ft_buf->buf - p)/val_len; + ft_buf->count=(uint) (ft_buf->buf - p)/val_len; /* flushing buffer to second-level tree */ for (error=0; !error && p < ft_buf->buf; p+= val_len) diff --git a/myisam/mi_open.c b/myisam/mi_open.c index 8e2f61a3b4b..d9b7f6453db 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -112,7 +112,8 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) share_buff.state.rec_per_key_part=rec_per_key_part; share_buff.state.key_root=key_root; share_buff.state.key_del=key_del; - share_buff.key_cache= multi_key_cache_search(name_buff, strlen(name_buff)); + share_buff.key_cache= multi_key_cache_search(name_buff, + (uint) strlen(name_buff)); DBUG_EXECUTE_IF("myisam_pretend_crashed_table_on_open", if (strstr(name, "/t1")) @@ -314,7 +315,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) (char*) key_del, (sizeof(my_off_t) * share->state.header.max_block_size)); strmov(share->unique_file_name, name_buff); - share->unique_name_length= strlen(name_buff); + share->unique_name_length= (uint) strlen(name_buff); strmov(share->index_file_name, index_name); strmov(share->data_file_name, data_name); diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c index 63d624a1445..ddcf0f33e61 100644 --- a/myisam/mi_packrec.c +++ b/myisam/mi_packrec.c @@ -254,7 +254,7 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) MYF(MY_HOLD_ON_ERROR)); /* Fix the table addresses in the tree heads. */ { - long diff=PTR_BYTE_DIFF(decode_table,share->decode_tables); + my_ptrdiff_t diff=PTR_BYTE_DIFF(decode_table,share->decode_tables); share->decode_tables=decode_table; for (i=0 ; i < trees ; i++) share->decode_trees[i].table=ADD_TO_PTR(share->decode_trees[i].table, diff --git a/myisam/mi_search.c b/myisam/mi_search.c index 530be5e042f..795c7ee55c3 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -408,7 +408,7 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, } from+=keyseg->length; page=from+nod_flag; - length=from-vseg; + length= (uint) (from - vseg); } if (page > end) diff --git a/myisam/rt_index.c b/myisam/rt_index.c index df8964edc20..494eccd38e4 100644 --- a/myisam/rt_index.c +++ b/myisam/rt_index.c @@ -95,7 +95,7 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, _mi_kpos(nod_flag, k), level + 1))) { case 0: /* found - exit from recursion */ - *saved_key = k - page_buf; + *saved_key = (uint) (k - page_buf); goto ok; case 1: /* not found - continue searching */ info->rtree_recursion_depth = level; @@ -117,7 +117,7 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, info->lastkey_length = k_len + info->s->base.rec_reflength; memcpy(info->lastkey, k, info->lastkey_length); info->rtree_recursion_depth = level; - *saved_key = last - page_buf; + *saved_key = (uint) (last - page_buf); if (after_key < last) { @@ -314,7 +314,7 @@ static int rtree_get_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint key_length, _mi_kpos(nod_flag, k), level + 1))) { case 0: /* found - exit from recursion */ - *saved_key = k - page_buf; + *saved_key = (uint) (k - page_buf); goto ok; case 1: /* not found - continue searching */ info->rtree_recursion_depth = level; @@ -333,7 +333,7 @@ static int rtree_get_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint key_length, memcpy(info->lastkey, k, info->lastkey_length); info->rtree_recursion_depth = level; - *saved_key = k - page_buf; + *saved_key = (uint) (k - page_buf); if (after_key < last) { @@ -420,7 +420,7 @@ int rtree_get_next(MI_INFO *info, uint keynr, uint key_length) info->lastkey_length = k_len + info->s->base.rec_reflength; memcpy(info->lastkey, key, k_len + info->s->base.rec_reflength); - *(int*)info->int_keypos = key - info->buff; + *(uint*)info->int_keypos = (uint) (key - info->buff); if (after_key >= info->int_maxpos) { info->buff_used = 1; diff --git a/mysys/base64.c b/mysys/base64.c index 47b93942784..a471e846b97 100644 --- a/mysys/base64.c +++ b/mysys/base64.c @@ -193,7 +193,7 @@ base64_decode(const char *src, size_t size, void *dst) { return -1; } - return d - dst_base; + return (int) (d - dst_base); } diff --git a/mysys/default.c b/mysys/default.c index b709b33e2f8..0067e95ffbe 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -182,7 +182,7 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv, /* Handle --defaults-group-suffix= */ uint i; const char **extra_groups; - const uint instance_len= strlen(my_defaults_group_suffix); + const size_t instance_len= strlen(my_defaults_group_suffix); struct handle_option_ctx *ctx= (struct handle_option_ctx*) func_ctx; char *ptr; TYPELIB *group= ctx->group; @@ -194,11 +194,11 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv, for (i= 0; i < group->count; i++) { - uint len; + size_t len; extra_groups[i]= group->type_names[i]; /** copy group */ len= strlen(extra_groups[i]); - if (!(ptr= alloc_root(ctx->alloc, len+instance_len+1))) + if (!(ptr= alloc_root(ctx->alloc, (uint) (len+instance_len+1)))) goto err; extra_groups[i+group->count]= ptr; diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index 30e9f19a189..214e7716683 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -368,9 +368,9 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) else { /* %% or unknown code */ - if (my_b_write(info, backtrack, fmt-backtrack)) + if (my_b_write(info, backtrack, (uint) (fmt - backtrack))) goto err; - out_length+= fmt-backtrack; + out_length+= (uint) (fmt - backtrack); } } return out_length; diff --git a/mysys/my_static.c b/mysys/my_static.c index 77dbffb911e..1858d830f41 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -74,8 +74,8 @@ uint sf_malloc_prehunc=0, /* If you have problem with core- */ sf_malloc_endhunc=0, /* dump when malloc-message.... */ /* set theese to 64 or 128 */ sf_malloc_quick=0; /* set if no calls to sanity */ -ulong sf_malloc_cur_memory= 0L; /* Current memory usage */ -ulong sf_malloc_max_memory= 0L; /* Maximum memory usage */ +size_t sf_malloc_cur_memory= 0L; /* Current memory usage */ +size_t sf_malloc_max_memory= 0L; /* Maximum memory usage */ uint sf_malloc_count= 0; /* Number of times NEW() was called */ byte *sf_min_adress= (byte*) ~(unsigned long) 0L, *sf_max_adress= (byte*) 0L; diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index 1cdbd1ecbf2..8c611a8556b 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -173,7 +173,7 @@ gptr _mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags) data[size + 3]= MAGICEND3; irem->filename= (my_string) filename; irem->linenum= lineno; - irem->datasize= size; + irem->datasize= (uint32) size; irem->prev= NULL; /* Add this remember structure to the linked list */ diff --git a/mysys/string.c b/mysys/string.c index df78f2b98b5..6dcb034531e 100644 --- a/mysys/string.c +++ b/mysys/string.c @@ -150,12 +150,12 @@ my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...) /* Search for quote in each string and replace with escaped quote */ while(*(next_pos= strcend(cur_pos, quote_str[0])) != '\0') { - ret&= dynstr_append_mem(str, cur_pos, next_pos - cur_pos); + ret&= dynstr_append_mem(str, cur_pos, (uint) (next_pos - cur_pos)); ret&= dynstr_append_mem(str ,"\\", 1); ret&= dynstr_append_mem(str, quote_str, quote_len); cur_pos= next_pos + 1; } - ret&= dynstr_append_mem(str, cur_pos, next_pos - cur_pos); + ret&= dynstr_append_mem(str, cur_pos, (uint) (next_pos - cur_pos)); append= va_arg(dirty_text, char *); } va_end(dirty_text); diff --git a/server-tools/instance-manager/buffer.cc b/server-tools/instance-manager/buffer.cc index a782c2ae33e..57dd1c72f23 100644 --- a/server-tools/instance-manager/buffer.cc +++ b/server-tools/instance-manager/buffer.cc @@ -100,7 +100,7 @@ err: int Buffer::get_size() { - return buffer_size; + return (uint) buffer_size; } diff --git a/server-tools/instance-manager/commands.cc b/server-tools/instance-manager/commands.cc index 01afa703a47..bb3763ce8c5 100644 --- a/server-tools/instance-manager/commands.cc +++ b/server-tools/instance-manager/commands.cc @@ -52,11 +52,11 @@ static inline int put_to_buff(Buffer *buff, const char *str, uint *position) { - uint len= strlen(str); - if (buff->append(*position, str, len)) + size_t len= strlen(str); + if (buff->append(*position, str, (uint) len)) return 1; - *position+= len; + *position+= (uint) len; return 0; } @@ -201,7 +201,7 @@ int Show_instance_status::execute(struct st_net *net, Instance *instance; store_to_protocol_packet(&send_buff, (char*) instance_name, &position); - if (!(instance= instance_map->find(instance_name, strlen(instance_name)))) + if (!(instance= instance_map->find(instance_name, (uint) strlen(instance_name)))) goto err; if (instance->is_running()) store_to_protocol_packet(&send_buff, (char*) "online", &position); @@ -272,7 +272,7 @@ int Show_instance_options::execute(struct st_net *net, ulong connection_id) { Instance *instance; - if (!(instance= instance_map->find(instance_name, strlen(instance_name)))) + if (!(instance= instance_map->find(instance_name, (uint) strlen(instance_name)))) goto err; store_to_protocol_packet(&send_buff, (char*) "instance_name", &position); store_to_protocol_packet(&send_buff, (char*) instance_name, &position); @@ -452,7 +452,7 @@ int Show_instance_log::execute(struct st_net *net, ulong connection_id) File fd; if ((instance= instance_map->find(instance_name, - strlen(instance_name))) == NULL) + (uint) strlen(instance_name))) == NULL) goto err; logpath= instance->options.logs[log_type]; @@ -479,13 +479,13 @@ int Show_instance_log::execute(struct st_net *net, ulong connection_id) buff_size= (size - offset); - read_buff.reserve(0, buff_size); + read_buff.reserve(0, (uint) buff_size); /* read in one chunk */ read_len= (int)my_seek(fd, file_stat.st_size - size, MY_SEEK_SET, MYF(0)); if ((read_len= my_read(fd, (byte*) read_buff.buffer, - buff_size, MYF(0))) < 0) + (uint) buff_size, MYF(0))) < 0) return ER_READ_FILE; store_to_protocol_packet(&send_buff, read_buff.buffer, &position, read_len); @@ -569,7 +569,7 @@ int Show_instance_log_files::execute(struct st_net *net, ulong connection_id) Instance *instance; if ((instance= instance_map-> - find(instance_name, strlen(instance_name))) == NULL) + find(instance_name, (uint) strlen(instance_name))) == NULL) goto err; { diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc index 58fe7569db7..e08bf2f66df 100644 --- a/server-tools/instance-manager/instance.cc +++ b/server-tools/instance-manager/instance.cc @@ -173,7 +173,7 @@ static int start_process(Instance_options *instance_options, int cmdlen= 0; for (int i= 0; instance_options->argv[i] != 0; i++) - cmdlen+= strlen(instance_options->argv[i]) + 3; + cmdlen+= (uint) strlen(instance_options->argv[i]) + 3; cmdlen++; /* make room for the null */ char *cmdline= new char[cmdlen]; diff --git a/server-tools/instance-manager/instance_map.cc b/server-tools/instance-manager/instance_map.cc index 39fd20cbc2d..571826edd7b 100644 --- a/server-tools/instance-manager/instance_map.cc +++ b/server-tools/instance-manager/instance_map.cc @@ -112,7 +112,7 @@ int Instance_map::process_one_option(const char *group, const char *option) || group[sizeof(prefix)] == '\0')) { if (!(instance= (Instance *) hash_search(&hash, (byte *) group, - strlen(group)))) + (uint) strlen(group)))) { if (!(instance= new Instance)) goto err; diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc index d4ca2ad570f..9d88bb0e669 100644 --- a/server-tools/instance-manager/instance_options.cc +++ b/server-tools/instance-manager/instance_options.cc @@ -257,7 +257,7 @@ int Instance_options::fill_log_options() strmov(hostname, "mysql"); hostname[MAX_LOG_OPTION_LENGTH - 1]= 0; /* Safety */ - hostname_length= strlen(hostname); + hostname_length= (uint) strlen(hostname); for (log_files= logs_st; log_files->name; log_files++) @@ -392,7 +392,7 @@ int Instance_options::complete_initialization(const char *default_path, if (!mysqld_path) { // Need one extra byte, as convert_dirname() adds a slash at the end. - if (!(mysqld_path= alloc_root(&alloc, strlen(default_path) + 2))) + if (!(mysqld_path= alloc_root(&alloc, (uint) strlen(default_path) + 2))) goto err; strcpy((char *)mysqld_path, default_path); } @@ -401,7 +401,7 @@ int Instance_options::complete_initialization(const char *default_path, end= convert_dirname((char*)mysqld_path, mysqld_path, NullS); end[-1]= 0; - mysqld_path_len= strlen(mysqld_path); + mysqld_path_len= (uint) strlen(mysqld_path); if (mysqld_port) mysqld_port_val= atoi(strchr(mysqld_port, '=') + 1); @@ -572,7 +572,7 @@ void Instance_options::print_argv() int Instance_options::init(const char *instance_name_arg) { - instance_name_len= strlen(instance_name_arg); + instance_name_len= (uint) strlen(instance_name_arg); init_alloc_root(&alloc, MEM_ROOT_BLOCK_SIZE, 0); diff --git a/server-tools/instance-manager/listener.cc b/server-tools/instance-manager/listener.cc index a950ecf4ed3..36f0cbe85e1 100644 --- a/server-tools/instance-manager/listener.cc +++ b/server-tools/instance-manager/listener.cc @@ -35,23 +35,28 @@ #include "portability.h" +#ifndef __WIN__ static void set_non_blocking(int socket) { -#ifndef __WIN__ int flags= fcntl(socket, F_GETFL, 0); fcntl(socket, F_SETFL, flags | O_NONBLOCK); #else +static void set_non_blocking(SOCKET socket) +{ u_long arg= 1; ioctlsocket(socket, FIONBIO, &arg); #endif } +#ifndef __WIN__ static void set_no_inherit(int socket) { -#ifndef __WIN__ int flags= fcntl(socket, F_GETFD, 0); fcntl(socket, F_SETFD, flags | FD_CLOEXEC); +#else +static void set_no_inherit(SOCKET socket) +{ #endif } @@ -71,7 +76,11 @@ private: ulong total_connection_count; Thread_info thread_info; +#ifdef __WIN__ + SOCKET sockets[2]; +#else int sockets[2]; +#endif int num_sockets; fd_set read_fds; private: @@ -110,9 +119,10 @@ Listener_thread::~Listener_thread() void Listener_thread::run() { - int i, n= 0; + int i= 0; #ifndef __WIN__ + int n= 0; /* we use this var to check whether we are running on LinuxThreads */ pid_t thread_pid; @@ -121,6 +131,8 @@ void Listener_thread::run() struct sockaddr_un unix_socket_address; /* set global variable */ linuxthreads= (thread_pid != manager_pid); +#else + SOCKET n= 0; #endif thread_registry.register_thread(&thread_info); @@ -159,7 +171,11 @@ void Listener_thread::run() signal during shutdown. This results in failing assert (Thread_registry::~Thread_registry). Valgrind 2.2 works fine. */ +#ifdef __WIN__ + int rc= select(0, &read_fds_arg, 0, 0, &tv); +#else int rc= select(n, &read_fds_arg, 0, 0, &tv); +#endif if (rc == 0 || rc == -1) { @@ -175,11 +191,18 @@ void Listener_thread::run() /* Assuming that rc > 0 as we asked to wait forever */ if (FD_ISSET(sockets[socket_index], &read_fds_arg)) { +#ifdef __WIN__ + SOCKET client_fd= accept(sockets[socket_index], 0, 0); + /* accept may return INVALID_SOCKET on failure */ + if (client_fd != INVALID_SOCKET) + { +#else int client_fd= accept(sockets[socket_index], 0, 0); /* accept may return -1 (failure or spurious wakeup) */ if (client_fd >= 0) // connection established { set_no_inherit(client_fd); +#endif Vio *vio= vio_new(client_fd, socket_index == 0 ? VIO_TYPE_SOCKET : VIO_TYPE_TCPIP, @@ -230,7 +253,11 @@ int Listener_thread::create_tcp_socket() /* value to be set by setsockopt */ int arg= 1; +#ifdef __WIN__ + SOCKET ip_socket= socket(AF_INET, SOCK_STREAM, 0); +#else int ip_socket= socket(AF_INET, SOCK_STREAM, 0); +#endif if (ip_socket == INVALID_SOCKET) { log_error("Listener_thead::run(): socket(AF_INET) failed, %s", diff --git a/server-tools/instance-manager/mysql_connection.cc b/server-tools/instance-manager/mysql_connection.cc index 2b377d60ad0..1803108c39d 100644 --- a/server-tools/instance-manager/mysql_connection.cc +++ b/server-tools/instance-manager/mysql_connection.cc @@ -241,7 +241,7 @@ int Mysql_connection_thread::check_connection() /* write connection message and read reply */ enum { MIN_HANDSHAKE_SIZE= 2 }; - if (net_write_command(&net, protocol_version, "", 0, buff, pos - buff) || + if (net_write_command(&net, protocol_version, "", 0, buff, (uint) (pos - buff)) || (pkt_len= my_net_read(&net)) == packet_error || pkt_len < MIN_HANDSHAKE_SIZE) { @@ -275,7 +275,7 @@ int Mysql_connection_thread::check_connection() net_send_error(&net, ER_ACCESS_DENIED_ERROR); return 1; } - if (user_map.authenticate(user, password-user-2, password, scramble)) + if (user_map.authenticate(user, (uint) (password - user - 2), password, scramble)) { net_send_error(&net, ER_ACCESS_DENIED_ERROR); return 1; diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc index f7eab075952..9eb148c4e3b 100644 --- a/server-tools/instance-manager/options.cc +++ b/server-tools/instance-manager/options.cc @@ -59,7 +59,7 @@ char **Options::saved_argv= NULL; bool Options::is_forced_default_file= 0; static const char * const ANGEL_PID_FILE_SUFFIX= ".angel.pid"; -static const int ANGEL_PID_FILE_SUFFIX_LEN= strlen(ANGEL_PID_FILE_SUFFIX); +static const int ANGEL_PID_FILE_SUFFIX_LEN= (uint) strlen(ANGEL_PID_FILE_SUFFIX); /* List of options, accepted by the instance manager. diff --git a/server-tools/instance-manager/parse.cc b/server-tools/instance-manager/parse.cc index 71f69b596c1..bbbadf3e91a 100644 --- a/server-tools/instance-manager/parse.cc +++ b/server-tools/instance-manager/parse.cc @@ -177,7 +177,7 @@ Command *parse_command(Instance_map *map, const char *text) get_word(&text, &option_len, NONSPACE); option= text; if ((tmp= strchr(text, '=')) != NULL) - option_len= tmp - text; + option_len= (uint) (tmp - text); text+= option_len; get_word(&text, &word_len); diff --git a/server-tools/instance-manager/parse.h b/server-tools/instance-manager/parse.h index 5e9f33beb11..9f7f7d7933c 100644 --- a/server-tools/instance-manager/parse.h +++ b/server-tools/instance-manager/parse.h @@ -58,7 +58,7 @@ inline void get_word(const char **text, uint *word_len, (*word_end != '\0')) ++word_end; - *word_len= word_end - *text; + *word_len= (uint) (word_end - *text); } #endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_H */ diff --git a/server-tools/instance-manager/parse_output.cc b/server-tools/instance-manager/parse_output.cc index f8ddf5a2d08..377671b4401 100644 --- a/server-tools/instance-manager/parse_output.cc +++ b/server-tools/instance-manager/parse_output.cc @@ -30,11 +30,11 @@ void trim_space(const char **text, uint *word_len) start++; *text= start; - int len= strlen(start); + size_t len= strlen(start); const char *end= start + len - 1; while (end > start && my_isspace(&my_charset_latin1, *end)) end--; - *word_len= (end - start)+1; + *word_len= (uint) (end - start)+1; } /* @@ -65,7 +65,7 @@ int parse_output_and_get_value(const char *command, const char *word, uint flag) { FILE *output; - uint wordlen; + size_t wordlen; /* should be enough to store the string from the output */ enum { MAX_LINE_LEN= 512 }; char linebuf[MAX_LINE_LEN]; @@ -111,7 +111,7 @@ int parse_output_and_get_value(const char *command, const char *word, strmake(result, linep, found_word_len); } else /* currently there are only two options */ - strmake(result, linep, input_buffer_len - 1); + strmake(result, linep, (uint) (input_buffer_len - 1)); rc= 0; break; } diff --git a/server-tools/instance-manager/protocol.cc b/server-tools/instance-manager/protocol.cc index 6c7a7f0ecfa..faeee4e95e9 100644 --- a/server-tools/instance-manager/protocol.cc +++ b/server-tools/instance-manager/protocol.cc @@ -53,11 +53,11 @@ int net_send_ok(struct st_net *net, unsigned long connection_id, int2store(pos, 0); pos+= 2; - uint position= pos - buff.buffer; /* we might need it for message */ + uint position= (uint) (pos - buff.buffer); /* we might need it for message */ if (message != NULL) { - buff.reserve(position, 9 + strlen(message)); + buff.reserve(position, 9 + (uint) strlen(message)); store_to_protocol_packet(&buff, message, &position); } @@ -82,7 +82,7 @@ int net_send_error(struct st_net *net, uint sql_errno) memcpy(pos, errno_to_sqlstate(sql_errno), SQLSTATE_LENGTH); pos+= SQLSTATE_LENGTH; pos= strmake(pos, err, MYSQL_ERRMSG_SIZE - 1) + 1; - return my_net_write(net, buff, pos - buff) || net_flush(net); + return my_net_write(net, buff, (uint) (pos - buff)) || net_flush(net); } @@ -98,7 +98,7 @@ int net_send_error_323(struct st_net *net, uint sql_errno) int2store(pos, sql_errno); pos+= 2; pos= strmake(pos, err, MYSQL_ERRMSG_SIZE - 1) + 1; - return my_net_write(net, buff, pos - buff) || net_flush(net); + return my_net_write(net, buff, (uint) (pos - buff)) || net_flush(net); } char *net_store_length(char *pkg, uint length) @@ -123,7 +123,7 @@ int store_to_protocol_packet(Buffer *buf, const char *string, uint *position, /* reserve max amount of bytes needed to store length */ if (buf->reserve(*position, 9)) goto err; - currpos= (net_store_length(buf->buffer + *position, + currpos= (uint) (net_store_length(buf->buffer + *position, (ulonglong) string_len) - buf->buffer); if (buf->append(currpos, string, string_len)) goto err; @@ -139,7 +139,7 @@ int store_to_protocol_packet(Buffer *buf, const char *string, uint *position) { uint string_len; - string_len= strlen(string); + string_len= (uint) strlen(string); return store_to_protocol_packet(buf, string, position, string_len); } diff --git a/server-tools/instance-manager/user_map.cc b/server-tools/instance-manager/user_map.cc index 2f77d2f59c1..7871cad7814 100644 --- a/server-tools/instance-manager/user_map.cc +++ b/server-tools/instance-manager/user_map.cc @@ -55,7 +55,7 @@ int User::init(const char *line) goto err; password= name_end + 1; } - user_length= name_end - name_begin; + user_length= (uint) (name_end - name_begin); if (user_length > USERNAME_LENGTH) goto err; diff --git a/sql-common/client.c b/sql-common/client.c index 519deac2bc5..27cc110401c 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -3145,7 +3145,7 @@ int STDCALL mysql_set_character_set(MYSQL *mysql, const char *cs_name) if (mysql_get_server_version(mysql) < 40100) return 0; sprintf(buff, "SET NAMES %s", cs_name); - if (!mysql_real_query(mysql, buff, strlen(buff))) + if (!mysql_real_query(mysql, buff, (uint) strlen(buff))) { mysql->charset= cs; } diff --git a/sql-common/my_user.c b/sql-common/my_user.c index fa5b80413bf..8d54275b2fd 100644 --- a/sql-common/my_user.c +++ b/sql-common/my_user.c @@ -44,8 +44,8 @@ void parse_user(const char *user_id_str, uint user_id_len, } else { - *user_name_len= p - user_id_str; - *host_name_len= user_id_len - *user_name_len - 1; + *user_name_len= (uint) (p - user_id_str); + *host_name_len= (uint) (user_id_len - *user_name_len - 1); memcpy(user_name_str, user_id_str, *user_name_len); memcpy(host_name_str, p + 1, *host_name_len); diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 2d78999017a..ef671ac7f9d 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -199,7 +199,7 @@ void insert_symbols() for (cur= symbols; ilength,&max_len); - insert_into_hash(root,cur->name,0,i,0); + insert_into_hash(root,cur->name,0,(uint) i,0); } } @@ -511,7 +511,7 @@ static inline SYMBOL *get_hash_symbol(const char *s,\n\ res= symbols+ires;\n\ else\n\ res= sql_functions-ires-1;\n\ - register uint count= cur_str-s;\n\ + register uint count= (uint) (cur_str - s);\n\ return lex_casecmp(cur_str,res->name+count,len-count) ? 0 : res;\n\ }\n\ \n\ @@ -540,7 +540,7 @@ static inline SYMBOL *get_hash_symbol(const char *s,\n\ register int16 ires= (int16)(cur_struct>>16);\n\ if (ires==array_elements(symbols)) return 0;\n\ register SYMBOL *res= symbols+ires;\n\ - register uint count= cur_str-s;\n\ + register uint count= (uint) (cur_str - s);\n\ return lex_casecmp(cur_str,res->name+count,len-count)!=0 ? 0 : res;\n\ }\n\ \n\ diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc index 0c558bf2515..04dbe678d4d 100644 --- a/sql/ha_archive.cc +++ b/sql/ha_archive.cc @@ -851,7 +851,7 @@ int ha_archive::get_row(gzFile file_to_read, byte *buf) total_blob_length += ((Field_blob*) table->field[*ptr])->get_length(); /* Adjust our row buffer if we need be */ - buffer.alloc(total_blob_length); + buffer.alloc((uint) total_blob_length); last= (char *)buffer.ptr(); /* Loop through our blobs and read them */ @@ -862,10 +862,10 @@ int ha_archive::get_row(gzFile file_to_read, byte *buf) size_t size= ((Field_blob*) table->field[*ptr])->get_length(); if (size) { - read= gzread(file_to_read, last, size); + read= gzread(file_to_read, last, (uint) size); if ((size_t) read != size) DBUG_RETURN(HA_ERR_END_OF_FILE); - ((Field_blob*) table->field[*ptr])->set_ptr(size, last); + ((Field_blob*) table->field[*ptr])->set_ptr((uint) size, last); last += size; } } diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index d4144a41a2a..6944dc5a030 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -640,7 +640,7 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, share->database[share->table_name - share->database]= '\0'; share->table_name++; - share->table_name_length= strlen(share->table_name); + share->table_name_length= (uint) strlen(share->table_name); /* make sure there's not an extra / */ if ((strchr(share->table_name, '/'))) @@ -726,7 +726,7 @@ uint ha_federated::convert_row_to_internal_format(byte *record, index variable to move us through the row at the same iterative step as the field */ - int x= field - table->field; + size_t x= (field - table->field); my_ptrdiff_t old_ptr; old_ptr= (my_ptrdiff_t) (record - table->record[0]); (*field)->move_field(old_ptr); @@ -750,7 +750,7 @@ static bool emit_key_part_name(String *to, KEY_PART_INFO *part) { DBUG_ENTER("emit_key_part_name"); if (append_ident(to, part->field->field_name, - strlen(part->field->field_name), ident_quote_char)) + (uint) strlen(part->field->field_name), ident_quote_char)) DBUG_RETURN(1); // Out of memory DBUG_RETURN(0); } @@ -1290,13 +1290,13 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table) for (field= table->field; *field; field++) { append_ident(&query, (*field)->field_name, - strlen((*field)->field_name), ident_quote_char); + (uint) strlen((*field)->field_name), ident_quote_char); query.append(FEDERATED_COMMA); } - query.length(query.length()- strlen(FEDERATED_COMMA)); + query.length(query.length() - (uint) strlen(FEDERATED_COMMA)); query.append(FEDERATED_FROM); - tmp_share.table_name_length= strlen(tmp_share.table_name); + tmp_share.table_name_length= (uint) strlen(tmp_share.table_name); append_ident(&query, tmp_share.table_name, tmp_share.table_name_length, ident_quote_char); @@ -1528,7 +1528,7 @@ bool ha_federated::append_stmt_insert(String *query) append_ident(&insert_string, share->table_name, share->table_name_length, ident_quote_char); insert_string.append(FEDERATED_OPENPAREN); - tmp_length= insert_string.length() - strlen(FEDERATED_COMMA); + tmp_length= insert_string.length() - (uint) strlen(FEDERATED_COMMA); /* loop through the field pointer array, add any fields to both the values @@ -1538,7 +1538,7 @@ bool ha_federated::append_stmt_insert(String *query) { /* append the field name */ append_ident(&insert_string, (*field)->field_name, - strlen((*field)->field_name), ident_quote_char); + (uint) strlen((*field)->field_name), ident_quote_char); /* append commas between both fields and fieldnames */ /* @@ -1554,7 +1554,7 @@ bool ha_federated::append_stmt_insert(String *query) /* remove trailing comma */ - insert_string.length(insert_string.length() - strlen(FEDERATED_COMMA)); + insert_string.length(insert_string.length() - (uint) strlen(FEDERATED_COMMA)); /* if there were no fields, we don't want to add a closing paren @@ -1667,7 +1667,7 @@ int ha_federated::write_row(byte *buf) if (values_string.length() > tmp_length) { /* chops off leading commas */ - values_string.length(values_string.length() - strlen(FEDERATED_COMMA)); + values_string.length(values_string.length() - (uint) strlen(FEDERATED_COMMA)); } /* we always want to append this, even if there aren't any fields */ values_string.append(FEDERATED_CLOSEPAREN); @@ -1950,10 +1950,10 @@ int ha_federated::update_row(const byte *old_data, byte *new_data) for (Field **field= table->field; *field; field++) { - uint field_name_length= strlen((*field)->field_name); - append_ident(&where_string, (*field)->field_name, field_name_length, + size_t field_name_length= strlen((*field)->field_name); + append_ident(&where_string, (*field)->field_name, (uint) field_name_length, ident_quote_char); - append_ident(&update_string, (*field)->field_name, field_name_length, + append_ident(&update_string, (*field)->field_name, (uint) field_name_length, ident_quote_char); update_string.append(FEDERATED_EQ); @@ -2044,7 +2044,7 @@ int ha_federated::delete_row(const byte *buf) Field *cur_field= *field; data_string.length(0); append_ident(&delete_string, (*field)->field_name, - strlen((*field)->field_name), ident_quote_char); + (uint) strlen((*field)->field_name), ident_quote_char); if (cur_field->is_null()) { @@ -2359,7 +2359,7 @@ int ha_federated::rnd_init(bool scan) stored_result= 0; } - if (real_query(share->select_query, strlen(share->select_query))) + if (real_query(share->select_query, (uint) strlen(share->select_query))) goto error; stored_result= mysql_store_result(mysql); diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 83e2d025f18..088ef55134f 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -7012,7 +7012,7 @@ ha_innobase::get_error_message(int error, String *buf) { trx_t* trx = check_trx_exists(current_thd); - buf->copy(trx->detailed_error, strlen(trx->detailed_error), + buf->copy(trx->detailed_error, (uint) strlen(trx->detailed_error), system_charset_info); return FALSE; diff --git a/sql/handler.cc b/sql/handler.cc index 71d184ad84b..d069d56caae 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -188,7 +188,8 @@ retest: { if (!my_strnncoll(&my_charset_latin1, (const uchar *)name, namelen, - (const uchar *)(*types)->name, strlen((*types)->name))) + (const uchar *)(*types)->name, + (uint) strlen((*types)->name))) return (enum db_type) (*types)->db_type; } @@ -200,10 +201,10 @@ retest: if (!my_strnncoll(&my_charset_latin1, (const uchar *)name, namelen, (const uchar *)table_alias->alias, - strlen(table_alias->alias))) + (uint) strlen(table_alias->alias))) { name= table_alias->type; - namelen= strlen(name); + namelen= (uint) strlen(name); goto retest; } } diff --git a/sql/item.cc b/sql/item.cc index bc1ae683e93..4c2582e2c5c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6281,7 +6281,7 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **items) if (check_grant_column(thd, table_grants, triggers->trigger_table->s->db, triggers->trigger_table->s->table_name, field_name, - strlen(field_name), thd->security_ctx)) + (uint) strlen(field_name), thd->security_ctx)) return TRUE; } #endif // NO_EMBEDDED_ACCESS_CHECKS diff --git a/sql/item_func.cc b/sql/item_func.cc index 913b32ccb88..8aa2565d928 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2758,7 +2758,7 @@ longlong Item_func_find_in_set::val_int() if (is_last_item && !is_separator) str_end= substr_end; if (!my_strnncoll(cs, (const uchar *) str_begin, - str_end - str_begin, + (uint) (str_end - str_begin), find_str, find_str_len)) return (longlong) position; else @@ -4792,7 +4792,7 @@ Item_func_get_system_var(sys_var *var_arg, enum_var_type var_type_arg, :var(var_arg), var_type(var_type_arg), component(*component_arg) { /* set_name() will allocate the name */ - set_name(name_arg, name_len_arg, system_charset_info); + set_name(name_arg, (uint) name_len_arg, system_charset_info); } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 34f974042a5..a43ad8d8137 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1743,17 +1743,17 @@ bool Item_func_user::init(const char *user, const char *host) if (user) { CHARSET_INFO *cs= str_value.charset(); - uint res_length= (strlen(user)+strlen(host)+2) * cs->mbmaxlen; + size_t res_length= (strlen(user)+strlen(host)+2) * cs->mbmaxlen; - if (str_value.alloc(res_length)) + if (str_value.alloc((uint) res_length)) { null_value=1; return TRUE; } - res_length=cs->cset->snprintf(cs, (char*)str_value.ptr(), res_length, + res_length=cs->cset->snprintf(cs, (char*)str_value.ptr(), (uint) res_length, "%s@%s", user, host); - str_value.length(res_length); + str_value.length((uint) res_length); str_value.mark_as_const(); } return FALSE; @@ -2433,7 +2433,7 @@ String *Item_func_rpad::val_str(String *str) memcpy(to,ptr_pad,(size_t) pad_byte_length); to+= pad_byte_length; } - res->length(to- (char*) res->ptr()); + res->length((uint) (to- (char*) res->ptr())); return (res); err: @@ -2701,7 +2701,7 @@ String *Item_func_charset::val_str(String *str) CHARSET_INFO *cs= args[0]->collation.collation; null_value= 0; - str->copy(cs->csname, strlen(cs->csname), + str->copy(cs->csname, (uint) strlen(cs->csname), &my_charset_latin1, collation.collation, &dummy_errors); return str; } @@ -2713,7 +2713,7 @@ String *Item_func_collation::val_str(String *str) CHARSET_INFO *cs= args[0]->collation.collation; null_value= 0; - str->copy(cs->name, strlen(cs->name), + str->copy(cs->name, (uint) strlen(cs->name), &my_charset_latin1, collation.collation, &dummy_errors); return str; } diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 23ac20a4017..9794a092648 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -362,7 +362,7 @@ public: Item_func_encode(Item *a, char *seed_arg): Item_str_func(a), sql_crypt(seed_arg) { - seed.copy(seed_arg, strlen(seed_arg), default_charset_info); + seed.copy(seed_arg, (uint) strlen(seed_arg), default_charset_info); } String *val_str(String *); void fix_length_and_dec(); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 38d9d62bd99..22ca8a925db 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -384,7 +384,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, if (tmp - val > 6) tmp= (char*) val + 6; l_time->second_part= (int) my_strtoll10(val, &tmp, &error); - frac_part= 6 - (tmp - val); + frac_part= 6 - (uint) (tmp - val); if (frac_part > 0) l_time->second_part*= (ulong) log_10_int[frac_part]; val= tmp; @@ -635,14 +635,14 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, if (!l_time->month) return 1; str->append(locale->month_names->type_names[l_time->month-1], - strlen(locale->month_names->type_names[l_time->month-1]), + (uint) strlen(locale->month_names->type_names[l_time->month-1]), system_charset_info); break; case 'b': if (!l_time->month) return 1; str->append(locale->ab_month_names->type_names[l_time->month-1], - strlen(locale->ab_month_names->type_names[l_time->month-1]), + (uint) strlen(locale->ab_month_names->type_names[l_time->month-1]), system_charset_info); break; case 'W': @@ -651,7 +651,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, weekday= calc_weekday(calc_daynr(l_time->year,l_time->month, l_time->day),0); str->append(locale->day_names->type_names[weekday], - strlen(locale->day_names->type_names[weekday]), + (uint) strlen(locale->day_names->type_names[weekday]), system_charset_info); break; case 'a': @@ -660,13 +660,13 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, weekday=calc_weekday(calc_daynr(l_time->year,l_time->month, l_time->day),0); str->append(locale->ab_day_names->type_names[weekday], - strlen(locale->ab_day_names->type_names[weekday]), + (uint) strlen(locale->ab_day_names->type_names[weekday]), system_charset_info); break; case 'D': if (type == MYSQL_TIMESTAMP_TIME) return 1; - length= int10_to_str(l_time->day, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 1, '0'); if (l_time->day >= 10 && l_time->day <= 19) str->append(STRING_WITH_LEN("th")); @@ -689,62 +689,62 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, } break; case 'Y': - length= int10_to_str(l_time->year, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(l_time->year, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 4, '0'); break; case 'y': - length= int10_to_str(l_time->year%100, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(l_time->year%100, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 2, '0'); break; case 'm': - length= int10_to_str(l_time->month, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(l_time->month, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 2, '0'); break; case 'c': - length= int10_to_str(l_time->month, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(l_time->month, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 1, '0'); break; case 'd': - length= int10_to_str(l_time->day, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 2, '0'); break; case 'e': - length= int10_to_str(l_time->day, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 1, '0'); break; case 'f': - length= int10_to_str(l_time->second_part, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(l_time->second_part, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 6, '0'); break; case 'H': - length= int10_to_str(l_time->hour, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(l_time->hour, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 2, '0'); break; case 'h': case 'I': hours_i= (l_time->hour%24 + 11)%12+1; - length= int10_to_str(hours_i, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(hours_i, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 2, '0'); break; case 'i': /* minutes */ - length= int10_to_str(l_time->minute, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(l_time->minute, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 2, '0'); break; case 'j': if (type == MYSQL_TIMESTAMP_TIME) return 1; - length= int10_to_str(calc_daynr(l_time->year,l_time->month, + length= (uint) (int10_to_str(calc_daynr(l_time->year,l_time->month, l_time->day) - - calc_daynr(l_time->year,1,1) + 1, intbuff, 10) - intbuff; + calc_daynr(l_time->year,1,1) + 1, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 3, '0'); break; case 'k': - length= int10_to_str(l_time->hour, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(l_time->hour, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 1, '0'); break; case 'l': hours_i= (l_time->hour%24 + 11)%12+1; - length= int10_to_str(hours_i, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(hours_i, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 1, '0'); break; case 'p': @@ -763,7 +763,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, break; case 'S': case 's': - length= int10_to_str(l_time->second, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(l_time->second, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 2, '0'); break; case 'T': @@ -781,11 +781,11 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, uint year; if (type == MYSQL_TIMESTAMP_TIME) return 1; - length= int10_to_str(calc_week(l_time, + length= (uint) (int10_to_str(calc_week(l_time, (*ptr) == 'U' ? WEEK_FIRST_WEEKDAY : WEEK_MONDAY_FIRST, &year), - intbuff, 10) - intbuff; + intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 2, '0'); } break; @@ -795,12 +795,12 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, uint year; if (type == MYSQL_TIMESTAMP_TIME) return 1; - length= int10_to_str(calc_week(l_time, + length= (uint) (int10_to_str(calc_week(l_time, ((*ptr) == 'V' ? (WEEK_YEAR | WEEK_FIRST_WEEKDAY) : (WEEK_YEAR | WEEK_MONDAY_FIRST)), &year), - intbuff, 10) - intbuff; + intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 2, '0'); } break; @@ -815,7 +815,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, WEEK_YEAR | WEEK_FIRST_WEEKDAY : WEEK_YEAR | WEEK_MONDAY_FIRST), &year); - length= int10_to_str(year, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(year, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 4, '0'); } break; @@ -824,7 +824,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, return 1; weekday=calc_weekday(calc_daynr(l_time->year,l_time->month, l_time->day),1); - length= int10_to_str(weekday, intbuff, 10) - intbuff; + length= (uint) (int10_to_str(weekday, intbuff, 10) - intbuff); str->append_with_prefill(intbuff, length, 1, '0'); break; @@ -875,7 +875,7 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, value= value*LL(10) + (longlong) (*str - '0'); if (transform_msec && i == count - 1) // microseconds always last { - long msec_length= 6 - (str - start); + long msec_length= 6 - (uint) (str - start); if (msec_length > 0) value*= (long) log_10_int[msec_length]; } @@ -1063,7 +1063,7 @@ String* Item_func_monthname::val_str(String* str) } null_value=0; month_name= locale->month_names->type_names[month-1]; - str->copy(month_name, strlen(month_name), &my_charset_utf8_bin, + str->copy(month_name, (uint) strlen(month_name), &my_charset_utf8_bin, collation.collation, &err); return str; } @@ -1207,7 +1207,7 @@ String* Item_func_dayname::val_str(String* str) return (String*) 0; day_name= locale->day_names->type_names[weekday]; - str->copy(day_name, strlen(day_name), &my_charset_utf8_bin, + str->copy(day_name, (uint) strlen(day_name), &my_charset_utf8_bin, collation.collation, &err); return str; } @@ -3222,14 +3222,14 @@ String *Item_func_get_format::val_str(String *str) format++) { uint format_name_len; - format_name_len= strlen(format_name); + format_name_len= (uint) strlen(format_name); if (val_len == format_name_len && !my_strnncoll(&my_charset_latin1, (const uchar *) val->ptr(), val_len, (const uchar *) format_name, val_len)) { const char *format_str= get_date_time_format_str(format, type); - str->set(format_str, strlen(format_str), &my_charset_bin); + str->set(format_str, (uint) strlen(format_str), &my_charset_bin); return str; } } diff --git a/sql/lock.cc b/sql/lock.cc index 47458702033..e22eecd9b73 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -347,7 +347,7 @@ void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock) for (i= 0; i < sql_lock->table_count; i++) { TABLE *tbl= *table; - tbl->lock_position= table - sql_lock->table; + tbl->lock_position= (uint) (table - sql_lock->table); tbl->lock_data_start= found; found+= tbl->lock_count; table++; @@ -740,7 +740,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, { my_error(ER_OPEN_AS_READONLY,MYF(0),table->alias); /* Clear the lock type of the lock data that are stored already. */ - sql_lock->lock_count= locks - sql_lock->locks; + sql_lock->lock_count= (uint) (locks - sql_lock->locks); reset_lock_data(sql_lock); my_free((gptr) sql_lock,MYF(0)); DBUG_RETURN(0); diff --git a/sql/log.cc b/sql/log.cc index c411f7c8238..d979dd101e0 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -487,7 +487,7 @@ const char *MYSQL_LOG::generate_name(const char *log_name, { if (!log_name || !log_name[0]) { - strmake(buff, pidfile_name, FN_REFLEN - strlen(suffix) - 1); + strmake(buff, pidfile_name, (uint) (FN_REFLEN - strlen(suffix) - 1)); return (const char *) fn_format(buff, buff, "", suffix, MYF(MY_REPLACE_EXT|MY_REPLACE_DIR)); @@ -728,7 +728,7 @@ bool MYSQL_LOG::open(const char *log_name, file. As every time we write to the index file, we sync it. */ if (my_b_write(&index_file, (byte*) log_file_name, - strlen(log_file_name)) || + (uint) strlen(log_file_name)) || my_b_write(&index_file, (byte*) "\n", 1) || flush_io_cache(&index_file) || my_sync(index_file.file, MYF(MY_WME))) diff --git a/sql/log_event.cc b/sql/log_event.cc index ef419aaee40..2f4923c4b4f 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -268,7 +268,7 @@ append_query_string(CHARSET_INFO *csinfo, from->ptr(), from->length()); *ptr++='\''; } - to->length(orig_len + ptr - beg); + to->length((uint) (orig_len + ptr - beg)); return 0; } #endif @@ -556,7 +556,7 @@ int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos) protocol->store(log_name, &my_charset_bin); protocol->store((ulonglong) pos); event_type = get_type_str(); - protocol->store(event_type, strlen(event_type), &my_charset_bin); + protocol->store(event_type, (uint) strlen(event_type), &my_charset_bin); protocol->store((uint32) server_id); protocol->store((ulonglong) log_pos); pack_info(protocol); @@ -1106,7 +1106,7 @@ void Query_log_event::pack_info(Protocol *protocol) memcpy(pos, query, q_len); pos+= q_len; } - protocol->store(buf, pos-buf, &my_charset_bin); + protocol->store(buf, (uint) (pos - buf), &my_charset_bin); my_free(buf, MYF(MY_ALLOW_ZERO_PTR)); } #endif @@ -1437,7 +1437,7 @@ get_str_len_and_pointer(const Log_event::Byte **src, if (length > 0) { if (*src + length >= end) - return *src + length - end + 1; // Number of bytes missing + return (int) (*src + length - end + 1); // Number of bytes missing *dst= (char *)*src + 1; // Will be copied later } *len= length; @@ -1908,7 +1908,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli, Thank you. */ thd->catalog= catalog_len ? (char *) catalog : (char *)""; - thd->set_db(new_db, strlen(new_db)); /* allocates a copy of 'db' */ + thd->set_db(new_db, (uint) strlen(new_db)); /* allocates a copy of 'db' */ thd->variables.auto_increment_increment= auto_increment_increment; thd->variables.auto_increment_offset= auto_increment_offset; @@ -2771,7 +2771,7 @@ void Load_log_event::pack_info(Protocol *protocol) if (!(buf= my_malloc(get_query_buffer_length(), MYF(MY_WME)))) return; print_query(TRUE, buf, &end, 0, 0); - protocol->store(buf, end-buf, &my_charset_bin); + protocol->store(buf, (uint) (end - buf), &my_charset_bin); my_free(buf, MYF(0)); } #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ @@ -2978,7 +2978,7 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len, table_name = fields + field_block_len; db = table_name + table_name_len + 1; fname = db + db_len + 1; - fname_len = strlen(fname); + fname_len = (uint) strlen(fname); // null termination is accomplished by the caller doing buf[event_len]=0 DBUG_RETURN(0); @@ -3144,7 +3144,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, bool use_rli_only_for_errors) { const char *new_db= rewrite_db(db); - thd->set_db(new_db, strlen(new_db)); + thd->set_db(new_db, (uint) strlen(new_db)); DBUG_ASSERT(thd->query == 0); thd->query_length= 0; // Should not be needed thd->query_error= 0; @@ -3237,7 +3237,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, print_query(FALSE, load_data_query, &end, (char **)&thd->lex->fname_start, (char **)&thd->lex->fname_end); *end= 0; - thd->query_length= end - load_data_query; + thd->query_length= (uint) (end - load_data_query); thd->query= load_data_query; if (sql_ex.opt_flags & REPLACE_FLAG) @@ -3857,7 +3857,7 @@ void User_var_log_event::pack_info(Protocol* protocol) break; case INT_RESULT: buf= my_malloc(val_offset + 22, MYF(MY_WME)); - event_len= longlong10_to_str(uint8korr(val), buf + val_offset,-10)-buf; + event_len= (uint) (longlong10_to_str(uint8korr(val), buf + val_offset,-10) - buf); break; case DECIMAL_RESULT: { @@ -3883,7 +3883,7 @@ void User_var_log_event::pack_info(Protocol* protocol) char *p= strxmov(buf + val_offset, "_", cs->csname, " ", NullS); p= str_to_hex(p, val, val_len); p= strxmov(p, " COLLATE ", cs->name, NullS); - event_len= p-buf; + event_len= (uint) (p - buf); } break; case ROW_RESULT: @@ -4204,7 +4204,7 @@ void Slave_log_event::pack_info(Protocol *protocol) pos= strmov(pos, master_log); pos= strmov(pos, ",pos="); pos= longlong10_to_str(master_pos, pos, 10); - protocol->store(buf, pos-buf, &my_charset_bin); + protocol->store(buf, (uint) (pos - buf), &my_charset_bin); } #endif /* !MYSQL_CLIENT */ @@ -4222,8 +4222,8 @@ Slave_log_event::Slave_log_event(THD* thd_arg, // TODO: re-write this better without holding both locks at the same time pthread_mutex_lock(&mi->data_lock); pthread_mutex_lock(&rli->data_lock); - master_host_len = strlen(mi->host); - master_log_len = strlen(rli->group_master_log_name); + master_host_len= (uint) strlen(mi->host); + master_log_len= (uint) strlen(rli->group_master_log_name); // on OOM, just do not initialize the structure and print the error if ((mem_pool = (char*)my_malloc(get_data_size() + 1, MYF(MY_WME)))) @@ -4292,7 +4292,7 @@ void Slave_log_event::init_from_mem_pool(int data_size) master_pos = uint8korr(mem_pool + SL_MASTER_POS_OFFSET); master_port = uint2korr(mem_pool + SL_MASTER_PORT_OFFSET); master_host = mem_pool + SL_MASTER_HOST_OFFSET; - master_host_len = strlen(master_host); + master_host_len= (uint) strlen(master_host); // safety master_log = master_host + master_host_len + 1; if (master_log > mem_pool + data_size) @@ -4300,7 +4300,7 @@ void Slave_log_event::init_from_mem_pool(int data_size) master_host = 0; return; } - master_log_len = strlen(master_log); + master_log_len= (uint) strlen(master_log); } @@ -5222,7 +5222,7 @@ void Execute_load_query_log_event::pack_info(Protocol *protocol) } pos= strmov(pos, " ;file_id="); pos= int10_to_str((long) file_id, pos, 10); - protocol->store(buf, pos-buf, &my_charset_bin); + protocol->store(buf, (uint) (pos - buf), &my_charset_bin); my_free(buf, MYF(MY_ALLOW_ZERO_PTR)); } @@ -5265,7 +5265,7 @@ Execute_load_query_log_event::exec_event(struct st_relay_log_info* rli) p= strmake(p, STRING_WITH_LEN(" INTO")); p= strmake(p, query+fn_pos_end, q_len-fn_pos_end); - error= Query_log_event::exec_event(rli, buf, p-buf); + error= Query_log_event::exec_event(rli, buf, (uint) (p - buf)); /* Forging file name for deletion in same buffer */ *fname_end= 0; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ca68976d939..f43bc9ea1a6 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2813,7 +2813,7 @@ static bool init_global_datetime_format(timestamp_type format_type, */ opt_date_time_formats[format_type]= str; } - if (!(*var_ptr= date_time_format_make(format_type, str, strlen(str)))) + if (!(*var_ptr= date_time_format_make(format_type, str, (uint) strlen(str)))) { fprintf(stderr, "Wrong date/time format specifier: %s\n", str); return 1; @@ -3039,7 +3039,7 @@ static int init_common_variables(const char *conf_file_name, int argc, sys_init_slave.value_length= 0; if ((sys_init_slave.value= opt_init_slave)) - sys_init_slave.value_length= strlen(opt_init_slave); + sys_init_slave.value_length= (uint) strlen(opt_init_slave); else sys_init_slave.value=my_strdup("",MYF(0)); sys_init_slave.is_os_charset= TRUE; @@ -7334,7 +7334,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case OPT_STORAGE_ENGINE: { if ((enum db_type)((global_system_variables.table_type= - ha_resolve_by_name(argument, strlen(argument)))) == + ha_resolve_by_name(argument, (uint) strlen(argument)))) == DB_TYPE_UNKNOWN) { fprintf(stderr,"Unknown/unsupported table type: %s\n",argument); diff --git a/sql/net_serv.cc b/sql/net_serv.cc index a40764577fd..627a5fae5e3 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -253,7 +253,7 @@ static int net_data_is_ready(my_socket sd) tv.tv_sec= tv.tv_usec= 0; - if ((res= select(sd+1, &sfds, NULL, NULL, &tv)) < 0) + if ((res= select((int) (sd + 1), &sfds, NULL, NULL, &tv)) < 0) return 0; else return test(res ? FD_ISSET(sd, &sfds) : 0); @@ -501,7 +501,7 @@ net_write_buff(NET *net,const char *packet,ulong len) { ulong left_length; if (net->compress && net->max_packet > MAX_PACKET_LENGTH) - left_length= MAX_PACKET_LENGTH - (net->write_pos - net->buff); + left_length= (ulong) (MAX_PACKET_LENGTH - (net->write_pos - net->buff)); else left_length= (ulong) (net->buff_end - net->write_pos); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ebebfafb5d8..938254f9ce2 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -673,7 +673,7 @@ int SEL_IMERGE::or_sel_tree(PARAM *param, SEL_TREE *tree) if (trees_next == trees_end) { const int realloc_ratio= 2; /* Double size for next round */ - uint old_elements= (trees_end - trees); + uint old_elements= (uint) (trees_end - trees); uint old_size= sizeof(SEL_TREE**) * old_elements; uint new_size= old_size * realloc_ratio; SEL_TREE **new_trees; @@ -2398,7 +2398,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, { SEL_TREE **ptree; TRP_INDEX_MERGE *imerge_trp= NULL; - uint n_child_scans= imerge->trees_next - imerge->trees; + uint n_child_scans= (uint) (imerge->trees_next - imerge->trees); TRP_RANGE **range_scans; TRP_RANGE **cur_child; TRP_RANGE **cpk_scan= NULL; @@ -2997,7 +2997,7 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info, tuple_arg= tuple_arg->next_key_part; tuple_arg->store_min(key_part[tuple_arg->part].store_length, &key_ptr, 0); } - min_range.length= max_range.length= ((char*) key_ptr - (char*) key_val); + min_range.length= max_range.length= (uint) ((char*) key_ptr - (char*) key_val); records= (info->param->table->file-> records_in_range(scan->keynr, &min_range, &max_range)); if (cur_covered) @@ -3297,7 +3297,7 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, intersect_scans_best);); *are_all_covering= intersect->is_covering; - uint best_num= intersect_scans_best - intersect_scans; + uint best_num= (uint) (intersect_scans_best - intersect_scans); ror_intersect_cpy(intersect, intersect_best); /* @@ -3474,7 +3474,7 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, TRP_ROR_INTERSECT *trp; if (!(trp= new (param->mem_root) TRP_ROR_INTERSECT)) DBUG_RETURN(trp); - uint best_num= (ror_scan_mark - tree->ror_scans); + uint best_num= (uint) (ror_scan_mark - tree->ror_scans); if (!(trp->first_scan= (ROR_SCAN_INFO**)alloc_root(param->mem_root, sizeof(ROR_SCAN_INFO*)* best_num))) @@ -3594,7 +3594,7 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, "ROR scans");); if (key_to_read) { - idx= key_to_read - tree->keys; + idx= (uint) (key_to_read - tree->keys); if ((read_plan= new (param->mem_root) TRP_RANGE(*key_to_read, idx))) { read_plan->records= best_records; @@ -4755,7 +4755,7 @@ tree_and(PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) tree1->type= SEL_TREE::IMPOSSIBLE; DBUG_RETURN(tree1); } - result_keys.set_bit(key1 - tree1->keys); + result_keys.set_bit((uint) (key1 - tree1->keys)); #ifdef EXTRA_DEBUG if (*key1 && param->alloced_sel_args < SEL_ARG::MAX_SEL_ARGS) (*key1)->test_use_count(*key1); @@ -4837,7 +4837,7 @@ tree_or(PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) if (*key1) { result=tree1; // Added to tree1 - result_keys.set_bit(key1 - tree1->keys); + result_keys.set_bit((uint) (key1 - tree1->keys)); #ifdef EXTRA_DEBUG if (param->alloced_sel_args < SEL_ARG::MAX_SEL_ARGS) (*key1)->test_use_count(*key1); @@ -6956,8 +6956,8 @@ int QUICK_RANGE_SELECT::get_next() } } - uint count= min(multi_range_length, ranges.elements - - (cur_range - (QUICK_RANGE**) ranges.buffer)); + uint count= min(multi_range_length, (uint) (ranges.elements - + (cur_range - (QUICK_RANGE**) ranges.buffer))); if (count == 0) { /* Ranges have already been used up before. None is left for read. */ @@ -7047,7 +7047,7 @@ int QUICK_RANGE_SELECT::get_next_prefix(uint prefix_length, byte *cur_prefix) DBUG_RETURN(result); } - uint count= ranges.elements - (cur_range - (QUICK_RANGE**) ranges.buffer); + uint count= (uint) (ranges.elements - (cur_range - (QUICK_RANGE**) ranges.buffer)); if (count == 0) { /* Ranges have already been used up before. None is left for read. */ @@ -7102,7 +7102,7 @@ int QUICK_RANGE_SELECT_GEOM::get_next() DBUG_RETURN(result); } - uint count= ranges.elements - (cur_range - (QUICK_RANGE**) ranges.buffer); + uint count= (uint) (ranges.elements - (cur_range - (QUICK_RANGE**) ranges.buffer)); if (count == 0) { /* Ranges have already been used up before. None is left for read. */ @@ -7435,18 +7435,18 @@ void QUICK_RANGE_SELECT::add_keys_and_lengths(String *key_names, String *used_lengths) { char buf[64]; - uint length; + size_t length; KEY *key_info= head->key_info + index; key_names->append(key_info->name); length= longlong2str(max_used_key_length, buf, 10) - buf; - used_lengths->append(buf, length); + used_lengths->append(buf, (uint) length); } void QUICK_INDEX_MERGE_SELECT::add_keys_and_lengths(String *key_names, String *used_lengths) { char buf[64]; - uint length; + size_t length; bool first= TRUE; QUICK_RANGE_SELECT *quick; @@ -7464,7 +7464,7 @@ void QUICK_INDEX_MERGE_SELECT::add_keys_and_lengths(String *key_names, KEY *key_info= head->key_info + quick->index; key_names->append(key_info->name); length= longlong2str(quick->max_used_key_length, buf, 10) - buf; - used_lengths->append(buf, length); + used_lengths->append(buf, (uint) length); } if (pk_quick_select) { @@ -7473,7 +7473,7 @@ void QUICK_INDEX_MERGE_SELECT::add_keys_and_lengths(String *key_names, key_names->append(key_info->name); length= longlong2str(pk_quick_select->max_used_key_length, buf, 10) - buf; used_lengths->append(','); - used_lengths->append(buf, length); + used_lengths->append(buf, (uint) length); } } @@ -7481,7 +7481,7 @@ void QUICK_ROR_INTERSECT_SELECT::add_keys_and_lengths(String *key_names, String *used_lengths) { char buf[64]; - uint length; + size_t length; bool first= TRUE; QUICK_RANGE_SELECT *quick; List_iterator_fast it(quick_selects); @@ -7497,7 +7497,7 @@ void QUICK_ROR_INTERSECT_SELECT::add_keys_and_lengths(String *key_names, } key_names->append(key_info->name); length= longlong2str(quick->max_used_key_length, buf, 10) - buf; - used_lengths->append(buf, length); + used_lengths->append(buf, (uint) length); } if (cpk_quick) @@ -7507,7 +7507,7 @@ void QUICK_ROR_INTERSECT_SELECT::add_keys_and_lengths(String *key_names, key_names->append(key_info->name); length= longlong2str(cpk_quick->max_used_key_length, buf, 10) - buf; used_lengths->append(','); - used_lengths->append(buf, length); + used_lengths->append(buf, (uint) length); } } @@ -8010,7 +8010,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree) } /* If we got to this point, cur_index_info passes the test. */ - key_infix_parts= key_infix_len ? + key_infix_parts= key_infix_len ? (uint) (first_non_infix_part - first_non_group_part) : 0; used_key_parts= cur_group_key_parts + key_infix_parts; @@ -8346,7 +8346,7 @@ get_field_keypart(KEY *index, Field *field) for (part= index->key_part, end= part + index->key_parts; part < end; part++) { if (field->eq(part->field)) - return part - index->key_part + 1; + return (uint) (part - index->key_part + 1); } return 0; } @@ -9601,7 +9601,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::add_keys_and_lengths(String *key_names, char buf[64]; uint length; key_names->append(index_info->name); - length= longlong2str(max_used_key_length, buf, 10) - buf; + length= (uint) (longlong2str(max_used_key_length, buf, 10) - buf); used_lengths->append(buf, length); } diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 39db1344588..f8603f06fa0 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -636,12 +636,12 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, key_part_map org_key_part_used= *key_part_used; if (eq_type || between || max_fl == less_fl) { - uint length= (key_ptr-ref->key_buff)+part->store_length; + size_t length= (key_ptr-ref->key_buff)+part->store_length; if (ref->key_length < length) /* Ultimately ref->key_length will contain the length of the search key */ - ref->key_length= length; + ref->key_length= (uint) length; if (!*prefix_len && part+1 == field_part) - *prefix_len= length; + *prefix_len= (uint) length; if (is_field_part && eq_type) *prefix_len= ref->key_length; diff --git a/sql/parse_file.cc b/sql/parse_file.cc index c4b07ed9dac..03e0d25b885 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -215,7 +215,7 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name, dir->str, file_name->str, (ulong) base)); fn_format(path, file_name->str, dir->str, 0, MY_UNPACK_FILENAME); - path_end= strlen(path); + path_end= (uint) strlen(path); // temporary file name path[path_end]='~'; @@ -411,7 +411,7 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root, sign++; if (*sign != '\n') goto frm_error; - parser->file_type.length= sign - parser->file_type.str; + parser->file_type.length= (uint) (sign - parser->file_type.str); // EOS for file signature just for safety *sign= '\0'; @@ -456,7 +456,7 @@ parse_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str) if (eol >= end) return 0; - str->length= eol - ptr; + str->length= (uint) (eol - ptr); if (!(str->str= alloc_root(mem_root, str->length+1))) return 0; @@ -521,7 +521,7 @@ read_escaped_string(char *ptr, char *eol, LEX_STRING *str) else *write_pos= c; } - str->str[str->length= write_pos-str->str]= '\0'; // just for safety + str->str[str->length= (uint) (write_pos - str->str)]= '\0'; // just for safety return FALSE; } @@ -548,7 +548,7 @@ parse_escaped_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str) char *eol= strchr(ptr, '\n'); if (eol == 0 || eol >= end || - !(str->str= alloc_root(mem_root, (eol - ptr) + 1)) || + !(str->str= alloc_root(mem_root, (uint) ((eol - ptr) + 1))) || read_escaped_string(ptr, eol, str)) return 0; diff --git a/sql/protocol.cc b/sql/protocol.cc index ff58d96f59b..996ede5d6a2 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -306,7 +306,7 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) pos+=2; } if (message) - pos=net_store_data((char*) pos, message, strlen(message)); + pos=net_store_data((char*) pos, message, (uint) strlen(message)); VOID(my_net_write(net,buff,(uint) (pos-buff))); VOID(net_flush(net)); /* We can't anymore send an error to the client */ @@ -724,8 +724,8 @@ bool Protocol::store(const char *from, CHARSET_INFO *cs) { if (!from) return store_null(); - uint length= strlen(from); - return store(from, length, cs); + size_t length= strlen(from); + return store(from, (uint) length, cs); } diff --git a/sql/set_var.cc b/sql/set_var.cc index a29abe6581f..735bb5279bd 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1927,7 +1927,7 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) pthread_mutex_lock(&LOCK_global_system_variables); char *str= (char*) value_ptr(thd, var_type, base); if (str) - tmp= new Item_string(str, strlen(str), + tmp= new Item_string(str, (uint) strlen(str), charset(thd), DERIVATION_SYSCONST); else { @@ -2079,7 +2079,7 @@ void sys_var_thd_date_time_format::set_default(THD *thd, enum_var_type type) { const char *format; if ((format= opt_date_time_formats[date_time_type])) - res= date_time_format_make(date_time_type, format, strlen(format)); + res= date_time_format_make(date_time_type, format, (uint) strlen(format)); } else { @@ -3166,10 +3166,10 @@ static byte *get_tmpdir(THD *thd) static struct my_option *find_option(struct my_option *opt, const char *name) { - uint length=strlen(name); + size_t length=strlen(name); for (; opt->name; opt++) { - if (!getopt_compare_strings(opt->name, name, length) && + if (!getopt_compare_strings(opt->name, name, (uint) length) && !opt->name[length]) { /* @@ -3210,7 +3210,7 @@ void set_var_init() var < end; var++) { - (*var)->name_length= strlen((*var)->name); + (*var)->name_length= (uint) strlen((*var)->name); (*var)->option_limits= find_option(my_long_options, (*var)->name); my_hash_insert(&system_variable_hash, (byte*) *var); } @@ -3249,7 +3249,7 @@ sys_var *find_sys_var(const char *str, uint length) sys_var *var= (sys_var*) hash_search(&system_variable_hash, (byte*) str, length ? length : - strlen(str)); + (uint) strlen(str)); if (!var) my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str); return var; @@ -3479,7 +3479,7 @@ int set_var_password::check(THD *thd) if (*thd->security_ctx->priv_host != 0) { user->host.str= (char *) thd->security_ctx->priv_host; - user->host.length= strlen(thd->security_ctx->priv_host); + user->host.length= (uint) strlen(thd->security_ctx->priv_host); } else { @@ -3495,7 +3495,7 @@ int set_var_password::check(THD *thd) } /* Returns 1 as the function sends error to client */ return check_change_password(thd, user->host.str, user->user.str, - password, strlen(password)) ? 1 : 0; + password, (uint) strlen(password)) ? 1 : 0; #else return 0; #endif diff --git a/sql/slave.cc b/sql/slave.cc index b4e74f8e68d..cc82710dec7 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1003,7 +1003,7 @@ int db_ok_with_wild_table(const char *db) int len; end= strmov(hash_key, db); *end++= '.'; - len= end - hash_key ; + len= (uint) (end - hash_key); if (wild_do_table_inited && find_wild(&replicate_wild_do_table, hash_key, len)) return 1; @@ -1189,7 +1189,7 @@ void skip_load_data_infile(NET *net) bool net_request_file(NET* net, const char* fname) { DBUG_ENTER("net_request_file"); - DBUG_RETURN(net_write_command(net, 251, fname, strlen(fname), "", 0)); + DBUG_RETURN(net_write_command(net, 251, fname, (uint) strlen(fname), "", 0)); } @@ -1581,7 +1581,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, save_db = thd->db; save_db_length= thd->db_length; DBUG_ASSERT(db != 0); - thd->reset_db((char*)db, strlen(db)); + thd->reset_db((char*)db, (uint) strlen(db)); mysql_parse(thd, thd->query, packet_len, &found_semicolon); // run create table thd->db = save_db; // leave things the way the were before thd->db_length= save_db_length; @@ -2314,11 +2314,11 @@ int register_slave_on_master(MYSQL* mysql) if (!report_host) return 0; - report_host_len= strlen(report_host); + report_host_len= (uint) strlen(report_host); if (report_user) - report_user_len= strlen(report_user); + report_user_len= (uint) strlen(report_user); if (report_password) - report_password_len= strlen(report_password); + report_password_len= (uint) strlen(report_password); /* 30 is a good safety margin */ if (report_host_len + report_user_len + report_password_len + 30 > sizeof(buf)) @@ -3043,7 +3043,7 @@ static int request_table_dump(MYSQL* mysql, const char* db, const char* table) *p++ = table_len; memcpy(p, table, table_len); - if (simple_command(mysql, COM_TABLE_DUMP, buf, p - buf + table_len, 1)) + if (simple_command(mysql, COM_TABLE_DUMP, buf, (uint) (p - buf + table_len), 1)) { sql_print_error("request_table_dump: Error sending the table dump \ command"); diff --git a/sql/sp.cc b/sql/sp.cc index d2a12f2190f..3af51b82521 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -414,7 +414,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, thd->lex= &newlex; newlex.current_select= NULL; - parse_user(definer, strlen(definer), + parse_user(definer, (uint) strlen(definer), definer_user_name.str, &definer_user_name.length, definer_host_name.str, &definer_host_name.length); @@ -929,7 +929,7 @@ sp_drop_db_routines(THD *thd, char *db) if (!(table= open_proc_table_for_update(thd))) goto err; - table->field[MYSQL_PROC_FIELD_DB]->store(db, strlen(db), system_charset_info); + table->field[MYSQL_PROC_FIELD_DB]->store(db, (uint) strlen(db), system_charset_info); key_len= table->key_info->key_part[0].store_length; ret= SP_OK; @@ -1099,8 +1099,8 @@ sp_exist_routines(THD *thd, TABLE_LIST *routines, bool any, bool no_error) sp_name *name; LEX_STRING lex_db; LEX_STRING lex_name; - lex_db.length= strlen(routine->db); - lex_name.length= strlen(routine->table_name); + lex_db.length= (uint) strlen(routine->db); + lex_name.length= (uint) strlen(routine->table_name); lex_db.str= thd->strmake(routine->db, lex_db.length); lex_name.str= thd->strmake(routine->table_name, lex_name.length); name= new sp_name(lex_db, lex_name, true); @@ -1918,7 +1918,7 @@ sp_use_new_db(THD *thd, LEX_STRING new_db, LEX_STRING *old_db, if (thd->db) { - old_db->length= (strmake(old_db->str, thd->db, old_db->length - 1) - + old_db->length= (uint) (strmake(old_db->str, thd->db, old_db->length - 1) - old_db->str); } else diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 3ec6dd5cf06..b51d97e66c5 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -381,7 +381,7 @@ sp_name::sp_name(THD *thd, char *key, uint key_len) m_qname.length= key_len - 1; if ((m_name.str= strchr(m_qname.str, '.'))) { - m_db.length= m_name.str - key; + m_db.length= (uint) (m_name.str - key); m_db.str= strmake_root(thd->mem_root, key, m_db.length); m_name.str++; m_name.length= m_qname.length - m_db.length - 1; @@ -447,7 +447,7 @@ sp_head::operator new(size_t size) throw() sp_head *sp; init_sql_alloc(&own_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC); - sp= (sp_head *) alloc_root(&own_root, size); + sp= (sp_head *) alloc_root(&own_root, (uint) size); if (sp == NULL) DBUG_RETURN(NULL); sp->main_mem_root= own_root; @@ -598,7 +598,7 @@ sp_head::init_strings(THD *thd, LEX *lex) if (m_param_begin && m_param_end) { - m_params.length= m_param_end - m_param_begin; + m_params.length= (uint) (m_param_end - m_param_begin); m_params.str= strmake_root(root, (char *)m_param_begin, m_params.length); } @@ -611,9 +611,9 @@ sp_head::init_strings(THD *thd, LEX *lex) */ endp= skip_rear_comments(thd->charset(), (char*) m_body_begin, (char*) endp); - m_body.length= endp - m_body_begin; + m_body.length= (uint) (endp - m_body_begin); m_body.str= strmake_root(root, m_body_begin, m_body.length); - m_defstr.length= endp - lip->buf; + m_defstr.length= (uint) (endp - lip->buf); m_defstr.str= strmake_root(root, lip->buf, m_defstr.length); DBUG_VOID_RETURN; } @@ -3606,7 +3606,7 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check) memcpy(tname+tlen, table->table_name, table->table_name_length); tlen+= table->table_name_length; tname[tlen++]= '\0'; - alen= strlen(table->alias); + alen= (uint) strlen(table->alias); memcpy(tname+tlen, table->alias, alen); tlen+= alen; tname[tlen]= '\0'; @@ -3771,9 +3771,9 @@ sp_add_to_query_tables(THD *thd, LEX *lex, thd->fatal_error(); return NULL; } - table->db_length= strlen(db); + table->db_length= (uint) strlen(db); table->db= thd->strmake(db, table->db_length); - table->table_name_length= strlen(name); + table->table_name_length= (uint) strlen(name); table->table_name= thd->strmake(name, table->table_name_length); table->alias= thd->strdup(name); table->lock_type= locktype; diff --git a/sql/spatial.cc b/sql/spatial.cc index 69d0c15748a..80506f16d0f 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -54,7 +54,7 @@ static Geometry::Class_info **ci_collection_end= Geometry::Class_info::Class_info(const char *name, int type_id, void(*create_func)(void *)): - m_name(name, strlen(name)), m_type_id(type_id), m_create_func(create_func) + m_name(name, (uint) strlen(name)), m_type_id(type_id), m_create_func(create_func) { ci_collection[type_id]= this; } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 22135d376fe..44407691abb 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -313,8 +313,8 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) } const char *password= get_field(thd->mem_root, table->field[2]); - uint password_len= password ? strlen(password) : 0; - set_user_salt(&user, password, password_len); + size_t password_len= password ? strlen(password) : 0; + set_user_salt(&user, password, (uint) password_len); if (user.salt_len == 0 && password_len != 0) { switch (password_len) { @@ -1405,7 +1405,7 @@ int check_change_password(THD *thd, const char *host, const char *user, MYF(0)); return(1); } - uint len=strlen(new_password); + size_t len= strlen(new_password); if (len && len != SCRAMBLED_PASSWORD_CHAR_LENGTH && len != SCRAMBLED_PASSWORD_CHAR_LENGTH_323) { @@ -1439,14 +1439,14 @@ bool change_password(THD *thd, const char *host, const char *user, /* Buffer should be extended when password length is extended. */ char buff[512]; ulong query_length; - uint new_password_len= strlen(new_password); + size_t new_password_len= strlen(new_password); bool result= 1; DBUG_ENTER("change_password"); DBUG_PRINT("enter",("host: '%s' user: '%s' new_password: '%s'", host,user,new_password)); DBUG_ASSERT(host != 0); // Ensured by parent - if (check_change_password(thd, host, user, new_password, new_password_len)) + if (check_change_password(thd, host, user, new_password, (uint) new_password_len)) DBUG_RETURN(1); bzero((char*) &tables, sizeof(tables)); @@ -1483,12 +1483,12 @@ bool change_password(THD *thd, const char *host, const char *user, goto end; } /* update loaded acl entry: */ - set_user_salt(acl_user, new_password, new_password_len); + set_user_salt(acl_user, new_password, (uint) new_password_len); if (update_user_table(thd, table, acl_user->host.hostname ? acl_user->host.hostname : "", acl_user->user ? acl_user->user : "", - new_password, new_password_len)) + new_password, (uint) new_password_len)) { VOID(pthread_mutex_unlock(&acl_cache->lock)); /* purecov: deadcode */ goto end; @@ -1641,11 +1641,11 @@ bool hostname_requires_resolving(const char *hostname) char cur; if (!hostname) return FALSE; - int namelen= strlen(hostname); - int lhlen= strlen(my_localhost); + size_t namelen= strlen(hostname); + size_t lhlen= strlen(my_localhost); if ((namelen == lhlen) && - !my_strnncoll(system_charset_info, (const uchar *)hostname, namelen, - (const uchar *)my_localhost, strlen(my_localhost))) + !my_strnncoll(system_charset_info, (const uchar *)hostname, (uint) namelen, + (const uchar *)my_localhost, (uint) strlen(my_localhost))) return FALSE; for (; (cur=*hostname); hostname++) { @@ -1873,13 +1873,13 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, table->field[next_field+3]->store("", 0, &my_charset_latin1); if (lex->ssl_cipher) table->field[next_field+1]->store(lex->ssl_cipher, - strlen(lex->ssl_cipher), system_charset_info); + (uint) strlen(lex->ssl_cipher), system_charset_info); if (lex->x509_issuer) table->field[next_field+2]->store(lex->x509_issuer, - strlen(lex->x509_issuer), system_charset_info); + (uint) strlen(lex->x509_issuer), system_charset_info); if (lex->x509_subject) table->field[next_field+3]->store(lex->x509_subject, - strlen(lex->x509_subject), system_charset_info); + (uint) strlen(lex->x509_subject), system_charset_info); break; case SSL_TYPE_NOT_SPECIFIED: break; @@ -4186,10 +4186,10 @@ static void add_user_option(String *grant, ulong value, const char *name) { char buff[22], *p; // just as in int2str grant->append(' '); - grant->append(name, strlen(name)); + grant->append(name, (uint) strlen(name)); grant->append(' '); p=int10_to_str(value, buff, 10); - grant->append(buff,p-buff); + grant->append(buff,(uint) (p - buff)); } } @@ -4327,7 +4327,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) { ssl_options++; global.append(STRING_WITH_LEN("ISSUER \'")); - global.append(acl_user->x509_issuer,strlen(acl_user->x509_issuer)); + global.append(acl_user->x509_issuer,(uint) strlen(acl_user->x509_issuer)); global.append('\''); } if (acl_user->x509_subject) @@ -4335,7 +4335,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) if (ssl_options++) global.append(' '); global.append(STRING_WITH_LEN("SUBJECT \'")); - global.append(acl_user->x509_subject,strlen(acl_user->x509_subject), + global.append(acl_user->x509_subject,(uint) strlen(acl_user->x509_subject), system_charset_info); global.append('\''); } @@ -4344,7 +4344,7 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) if (ssl_options++) global.append(' '); global.append(STRING_WITH_LEN("CIPHER '")); - global.append(acl_user->ssl_cipher,strlen(acl_user->ssl_cipher), + global.append(acl_user->ssl_cipher,(uint) strlen(acl_user->ssl_cipher), system_charset_info); global.append('\''); } @@ -4424,13 +4424,13 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) } } db.append (STRING_WITH_LEN(" ON ")); - append_identifier(thd, &db, acl_db->db, strlen(acl_db->db)); + append_identifier(thd, &db, acl_db->db, (uint) strlen(acl_db->db)); db.append (STRING_WITH_LEN(".* TO '")); db.append(lex_user->user.str, lex_user->user.length, system_charset_info); db.append (STRING_WITH_LEN("'@'")); // host and lex_user->host are equal except for case - db.append(host, strlen(host), system_charset_info); + db.append(host, (uint) strlen(host), system_charset_info); db.append ('\''); if (want_access & GRANT_ACL) db.append(STRING_WITH_LEN(" WITH GRANT OPTION")); @@ -4536,16 +4536,16 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) } global.append(STRING_WITH_LEN(" ON ")); append_identifier(thd, &global, grant_table->db, - strlen(grant_table->db)); + (uint) strlen(grant_table->db)); global.append('.'); append_identifier(thd, &global, grant_table->tname, - strlen(grant_table->tname)); + (uint) strlen(grant_table->tname)); global.append(STRING_WITH_LEN(" TO '")); global.append(lex_user->user.str, lex_user->user.length, system_charset_info); global.append(STRING_WITH_LEN("'@'")); // host and lex_user->host are equal except for case - global.append(host, strlen(host), system_charset_info); + global.append(host, (uint) strlen(host), system_charset_info); global.append('\''); if (table_access & GRANT_ACL) global.append(STRING_WITH_LEN(" WITH GRANT OPTION")); @@ -4642,16 +4642,16 @@ static int show_routine_grants(THD* thd, LEX_USER *lex_user, HASH *hash, global.append(type,typelen); global.append(' '); append_identifier(thd, &global, grant_proc->db, - strlen(grant_proc->db)); + (uint) strlen(grant_proc->db)); global.append('.'); append_identifier(thd, &global, grant_proc->tname, - strlen(grant_proc->tname)); + (uint) strlen(grant_proc->tname)); global.append(STRING_WITH_LEN(" TO '")); global.append(lex_user->user.str, lex_user->user.length, system_charset_info); global.append(STRING_WITH_LEN("'@'")); // host and lex_user->host are equal except for case - global.append(host, strlen(host), system_charset_info); + global.append(host, (uint) strlen(host), system_charset_info); global.append('\''); if (proc_access & GRANT_ACL) global.append(STRING_WITH_LEN(" WITH GRANT OPTION")); @@ -5769,11 +5769,11 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name, { LEX_USER lex_user; lex_user.user.str= grant_proc->user; - lex_user.user.length= strlen(grant_proc->user); + lex_user.user.length= (uint) strlen(grant_proc->user); lex_user.host.str= grant_proc->host.hostname ? grant_proc->host.hostname : (char*)""; lex_user.host.length= grant_proc->host.hostname ? - strlen(grant_proc->host.hostname) : 0; + (uint) strlen(grant_proc->host.hostname) : 0; if (!replace_routine_table(thd,grant_proc,tables[4].table,lex_user, grant_proc->db, grant_proc->tname, is_proc, ~(ulong)0, 1)) @@ -5852,8 +5852,8 @@ int sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name, tables->db= (char*)sp_db; tables->table_name= tables->alias= (char*)sp_name; - combo->host.length= strlen(combo->host.str); - combo->user.length= strlen(combo->user.str); + combo->host.length= (uint) strlen(combo->host.str); + combo->user.length= (uint) strlen(combo->user.str); combo->host.str= thd->strmake(combo->host.str,combo->host.length); combo->user.str= thd->strmake(combo->user.str,combo->user.length); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 881c6a421e8..812c060fe15 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -780,10 +780,10 @@ void close_temporary_tables(THD *thd) We are going to add 4 ` around the db/table names and possible more due to special characters in the names */ - append_identifier(thd, &s_query, table->s->db, strlen(table->s->db)); + append_identifier(thd, &s_query, table->s->db, (uint) strlen(table->s->db)); s_query.q_append('.'); append_identifier(thd, &s_query, table->s->table_name, - strlen(table->s->table_name)); + (uint) strlen(table->s->table_name)); s_query.q_append(','); next= table->next; close_temporary(table, 1); @@ -3690,7 +3690,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length, if (field_ptr && *field_ptr) { - *cached_field_index_ptr= field_ptr - table->field; + *cached_field_index_ptr= (uint) (field_ptr - table->field); field= *field_ptr; } else @@ -5992,7 +5992,7 @@ my_bool mysql_rm_tmp_tables(void) if (!bcmp(file->name,tmp_file_prefix,tmp_file_prefix_length)) { char *ext= fn_ext(file->name); - uint ext_len= strlen(ext); + size_t ext_len= strlen(ext); uint filePath_len= my_snprintf(filePath, sizeof(filePath), "%s%s", tmpdir, file->name); if (!bcmp(reg_ext, ext, ext_len)) @@ -6264,7 +6264,7 @@ open_new_frm(THD *thd, const char *path, const char *alias, DBUG_ENTER("open_new_frm"); pathstr.str= (char*) path; - pathstr.length= strlen(path); + pathstr.length= (uint) strlen(path); if ((parser= sql_parse_prepare(&pathstr, mem_root, 1))) { diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index b55fa148e24..fe3f0a09670 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -3126,7 +3126,7 @@ Query_cache::process_and_count_tables(THD *thd, TABLE_LIST *tables_used, { ha_myisammrg *handler = (ha_myisammrg *)tables_used->table->file; MYRG_INFO *file = handler->myrg_info(); - table_count+= (file->end_table - file->open_tables); + table_count+= (uint) (file->end_table - file->open_tables); } } } @@ -3313,7 +3313,7 @@ my_bool Query_cache::move_by_type(byte **border, *pprev = block->pprev, *pnext = block->pnext, *new_block =(Query_cache_block *) *border; - uint tablename_offset = block->table()->table() - block->table()->db(); + size_t tablename_offset= block->table()->table() - block->table()->db(); char *data = (char*) block->data(); byte *key; uint key_length; @@ -3625,7 +3625,7 @@ uint Query_cache::filename_2_table_key (char *key, const char *path, filename= tablename + dirname_length(tablename + 2) + 2; /* Find start of databasename */ for (dbname= filename - 2 ; dbname[-1] != FN_LIBCHAR ; dbname--) ; - *db_length= (filename - dbname) - 1; + *db_length= (uint) ((filename - dbname) - 1); DBUG_PRINT("qcache", ("table '%-.*s.%s'", *db_length, dbname, filename)); DBUG_RETURN((uint) (strmov(strmake(key, dbname, *db_length) + 1, @@ -3934,8 +3934,8 @@ my_bool Query_cache::check_integrity(bool locked) } else { - int idx = (((byte*)bin) - ((byte*)bins)) / - sizeof(Query_cache_memory_bin); + int idx = (int) ((((byte*)bin) - ((byte*)bins)) / + sizeof(Query_cache_memory_bin)); if (in_list(bins[idx].free_blocks, block, "free memory")) result = 1; } diff --git a/sql/sql_crypt.cc b/sql/sql_crypt.cc index 367b9e38e56..38dfc869b3a 100644 --- a/sql/sql_crypt.cc +++ b/sql/sql_crypt.cc @@ -31,7 +31,7 @@ SQL_CRYPT::SQL_CRYPT(const char *password) { ulong rand_nr[2]; - hash_password(rand_nr,password, strlen(password)); + hash_password(rand_nr,password, (uint) strlen(password)); crypt_init(rand_nr); } diff --git a/sql/sql_db.cc b/sql/sql_db.cc index c3cf7429222..80fea3ef1b1 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -239,7 +239,7 @@ void del_dbopt(const char *path) my_dbopt_t *opt; rw_wrlock(&LOCK_dboptions); if ((opt= (my_dbopt_t *)hash_search(&dboptions, (const byte*) path, - strlen(path)))) + (uint) strlen(path)))) hash_delete(&dboptions, (byte*) opt); rw_unlock(&LOCK_dboptions); } @@ -582,7 +582,7 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, # database does not exist. */ qinfo.db = db; - qinfo.db_len = strlen(db); + qinfo.db_len = (uint) strlen(db); /* These DDL methods and logging protected with LOCK_mysql_create_db */ mysql_bin_log.write(&qinfo); @@ -653,7 +653,7 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) default. */ qinfo.db = db; - qinfo.db_len = strlen(db); + qinfo.db_len = (uint) strlen(db); thd->clear_error(); /* These DDL methods and logging protected with LOCK_mysql_create_db */ @@ -777,7 +777,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) default. */ qinfo.db = db; - qinfo.db_len = strlen(db); + qinfo.db_len = (uint) strlen(db); thd->clear_error(); /* These DDL methods and logging protected with LOCK_mysql_create_db */ @@ -797,18 +797,18 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) goto exit; /* not much else we can do */ query_pos= query_data_start= strmov(query,"drop table "); query_end= query + MAX_DROP_TABLE_Q_LEN; - db_len= strlen(db); + db_len= (uint) strlen(db); for (tbl= dropped_tables; tbl; tbl= tbl->next_local) { uint tbl_name_len; /* 3 for the quotes and the comma*/ - tbl_name_len= strlen(tbl->table_name) + 3; + tbl_name_len= (uint) strlen(tbl->table_name) + 3; if (query_pos + tbl_name_len + 1 >= query_end) { /* These DDL methods and logging protected with LOCK_mysql_create_db */ - write_to_binlog(thd, query, query_pos -1 - query, db, db_len); + write_to_binlog(thd, query, (uint) (query_pos - 1 - query), db, db_len); query_pos= query_data_start; } @@ -821,7 +821,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) if (query_pos != query_data_start) { /* These DDL methods and logging protected with LOCK_mysql_create_db */ - write_to_binlog(thd, query, query_pos -1 - query, db, db_len); + write_to_binlog(thd, query, (uint) (query_pos - 1 - query), db, db_len); } } @@ -938,7 +938,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, /* Drop the table nicely */ *extension= 0; // Remove extension TABLE_LIST *table_list=(TABLE_LIST*) - thd->calloc(sizeof(*table_list)+ strlen(db)+strlen(file->name)+2); + thd->calloc((uint) (sizeof(*table_list)+ strlen(db)+strlen(file->name)+2)); if (!table_list) goto err; table_list->db= (char*) (table_list+1); diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 84622398f6f..830d1b7c36f 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -177,7 +177,7 @@ exit: orig_table_list->derived_result= derived_result; orig_table_list->table= table; orig_table_list->table_name= (char*) table->s->table_name; - orig_table_list->table_name_length= strlen((char*)table->s->table_name); + orig_table_list->table_name_length= (uint) strlen((char*)table->s->table_name); table->derived_select_number= first_select->select_number; table->s->tmp_table= NON_TRANSACTIONAL_TMP_TABLE; #ifndef NO_EMBEDDED_ACCESS_CHECKS diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 344a0c00db8..8f825f83df1 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -243,7 +243,7 @@ bool mysqld_show_warnings(THD *thd, ulong levels_to_show) protocol->store(warning_level_names[err->level], warning_level_length[err->level], system_charset_info); protocol->store((uint32) err->code); - protocol->store(err->msg, strlen(err->msg), system_charset_info); + protocol->store(err->msg, (uint) strlen(err->msg), system_charset_info); if (protocol->write()) DBUG_RETURN(TRUE); } diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 822f2b2c419..67f9992499b 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -90,7 +90,7 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags); static char *mysql_ha_hash_get_key(TABLE_LIST *tables, uint *key_len_p, my_bool first __attribute__((unused))) { - *key_len_p= strlen(tables->alias) + 1 ; /* include '\0' in comparisons */ + *key_len_p= (uint) strlen(tables->alias) + 1 ; /* include '\0' in comparisons */ return tables->alias; } @@ -202,7 +202,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) else if (! reopen) /* Otherwise we have 'tables' already. */ { if (hash_search(&thd->handler_tables_hash, (byte*) tables->alias, - strlen(tables->alias) + 1)) + (uint) strlen(tables->alias) + 1)) { DBUG_PRINT("info",("duplicate '%s'", tables->alias)); if (! reopen) @@ -259,9 +259,9 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) if (! reopen) { /* copy the TABLE_LIST struct */ - dblen= strlen(tables->db) + 1; - namelen= strlen(tables->table_name) + 1; - aliaslen= strlen(tables->alias) + 1; + dblen= (uint) strlen(tables->db) + 1; + namelen= (uint) strlen(tables->table_name) + 1; + aliaslen= (uint) strlen(tables->alias) + 1; if (!(my_multi_malloc(MYF(MY_WME), &hash_tables, sizeof(*hash_tables), &db, dblen, @@ -324,7 +324,7 @@ bool mysql_ha_close(THD *thd, TABLE_LIST *tables) if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, (byte*) tables->alias, - strlen(tables->alias) + 1))) + (uint) strlen(tables->alias) + 1))) { mysql_ha_close_table(thd, hash_tables); hash_delete(&thd->handler_tables_hash, (byte*) hash_tables); @@ -396,7 +396,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, retry: if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, (byte*) tables->alias, - strlen(tables->alias) + 1))) + (uint) strlen(tables->alias) + 1))) { table= hash_tables->table; DBUG_PRINT("info-in-hash",("'%s'.'%s' as '%s' tab %p", @@ -779,7 +779,7 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags) if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, (byte*) table->alias, - strlen(table->alias) + 1))) + (uint) strlen(table->alias) + 1))) { if (! (mode_flags & MYSQL_HA_REOPEN_ON_USAGE)) { diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 6036a687274..e369a72fa9f 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -628,7 +628,7 @@ bool mysqld_help(THD *thd, const char *mask) List topics_list, categories_list, subcategories_list; String name, description, example; int count_topics, count_categories, error; - uint mlen= strlen(mask); + size_t mlen= strlen(mask); size_t i; MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("mysqld_help"); @@ -668,7 +668,7 @@ bool mysqld_help(THD *thd, const char *mask) tables[i].table->file->init_table_handle_for_HANDLER(); if (!(select= - prepare_select_for_name(thd,mask,mlen,tables,tables[0].table, + prepare_select_for_name(thd,mask,(uint) mlen,tables,tables[0].table, used_fields[help_topic_name].field,&error))) goto error; @@ -681,7 +681,7 @@ bool mysqld_help(THD *thd, const char *mask) { int key_id; if (!(select= - prepare_select_for_name(thd,mask,mlen,tables,tables[3].table, + prepare_select_for_name(thd,mask,(uint) mlen,tables,tables[3].table, used_fields[help_keyword_name].field,&error))) goto error; @@ -698,7 +698,7 @@ bool mysqld_help(THD *thd, const char *mask) int16 category_id; Field *cat_cat_id= used_fields[help_category_parent_category_id].field; if (!(select= - prepare_select_for_name(thd,mask,mlen,tables,tables[1].table, + prepare_select_for_name(thd,mask,(uint) mlen,tables,tables[1].table, used_fields[help_category_name].field,&error))) goto error; @@ -759,7 +759,7 @@ bool mysqld_help(THD *thd, const char *mask) send_variant_2_list(mem_root,protocol, &topics_list, "N", 0)) goto error; if (!(select= - prepare_select_for_name(thd,mask,mlen,tables,tables[1].table, + prepare_select_for_name(thd,mask,(uint) mlen,tables,tables[1].table, used_fields[help_category_name].field,&error))) goto error; search_categories(thd, tables[1].table, used_fields, diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 4eddcd17df1..2fe0a30f519 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1819,7 +1819,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list) pthread_mutex_lock(&LOCK_thread_count); thread_count++; pthread_mutex_unlock(&LOCK_thread_count); - di->thd.set_db(table_list->db, strlen(table_list->db)); + di->thd.set_db(table_list->db, (uint) strlen(table_list->db)); di->thd.query= my_strdup(table_list->table_name, MYF(MY_WME)); if (di->thd.db == NULL || di->thd.query == NULL) { diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 71aa80b8170..4c53772bc25 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -858,7 +858,7 @@ int MYSQLlex(void *arg, void *yythd) case MY_LEX_HEX_NUMBER: // Found x'hexstring' yyGet(); // Skip ' while (my_isxdigit(cs,(c = yyGet()))) ; - length=(lip->ptr - lip->tok_start); // Length of hexnum+3 + length=(uint) (lip->ptr - lip->tok_start); // Length of hexnum+3 if (!(length & 1) || c != '\'') { return(ABORT_SYM); // Illegal hex constant @@ -872,7 +872,7 @@ int MYSQLlex(void *arg, void *yythd) case MY_LEX_BIN_NUMBER: // Found b'bin-string' yyGet(); // Skip ' while ((c= yyGet()) == '0' || c == '1'); - length= (lip->ptr - lip->tok_start); // Length of bin-num + 3 + length= (uint) (lip->ptr - lip->tok_start); // Length of bin-num + 3 if (c != '\'') return(ABORT_SYM); // Illegal hex constant yyGet(); // get_token makes an unget diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 5477610bb05..5b9f8ea441d 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -526,8 +526,8 @@ static bool write_execute_load_query_log_event(THD *thd, { Execute_load_query_log_event e(thd, thd->query, thd->query_length, - (char*)thd->lex->fname_start - (char*)thd->query, - (char*)thd->lex->fname_end - (char*)thd->query, + (uint) ((char*)thd->lex->fname_start - (char*)thd->query), + (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); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1d3632fd468..8ee88cefd99 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -250,7 +250,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, USER_RESOURCES *mqh) { int return_val= 0; - uint temp_len, user_len; + size_t temp_len, user_len; char temp_user[USER_HOST_BUFF_SIZE]; struct user_conn *uc; @@ -261,7 +261,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1; (void) pthread_mutex_lock(&LOCK_user_conn); if (!(uc = (struct user_conn *) hash_search(&hash_user_connections, - (byte*) temp_user, temp_len))) + (byte*) temp_user, (uint) temp_len))) { /* First connection for user; Create a user connection object */ if (!(uc= ((struct user_conn*) @@ -275,7 +275,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, uc->user=(char*) (uc+1); memcpy(uc->user,temp_user,temp_len+1); uc->host= uc->user + user_len + 1; - uc->len= temp_len; + uc->len= (uint) temp_len; uc->connections= uc->questions= uc->updates= uc->conn_per_hour= 0; uc->user_resources= *mqh; uc->intime= thd->thr_create_time; @@ -328,7 +328,7 @@ int check_user(THD *thd, enum enum_server_command command, bool check_count) { DBUG_ENTER("check_user"); - LEX_STRING db_str= { (char *) db, db ? strlen(db) : 0 }; + LEX_STRING db_str= { (char *) db, db ? (uint) strlen(db) : 0 }; #ifdef NO_EMBEDDED_ACCESS_CHECKS thd->main_security_ctx.master_access= GLOBAL_ACLS; // Full rights @@ -1036,7 +1036,7 @@ static int check_connection(THD *thd) char *user= end; char *passwd= strend(user)+1; - uint user_len= passwd - user - 1; + size_t user_len= passwd - user - 1; char *db= passwd; char db_buff[NAME_LEN + 1]; // buffer to store db in utf8 char user_buff[USERNAME_LENGTH + 1]; // buffer to store user in utf8 @@ -1051,10 +1051,10 @@ static int check_connection(THD *thd) *passwd > 127 and become 2**32-127 after casting to uint. */ uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ? - (uchar)(*passwd++) : strlen(passwd); + (uchar)(*passwd++) : (uint) strlen(passwd); db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ? db + passwd_len + 1 : 0; - uint db_len= db ? strlen(db) : 0; + size_t db_len= db ? strlen(db) : 0; if (passwd + passwd_len + db_len > (char *)net->read_pos + pkt_len) { @@ -1067,13 +1067,13 @@ static int check_connection(THD *thd) { db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1, system_charset_info, - db, db_len, + db, (uint) db_len, thd->charset(), &dummy_errors)]= 0; db= db_buff; } user_buff[user_len= copy_and_convert(user_buff, sizeof(user_buff)-1, - system_charset_info, user, user_len, + system_charset_info, user, (uint) user_len, thd->charset(), &dummy_errors)]= '\0'; user= user_buff; @@ -1769,7 +1769,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, statistic_increment(thd->status_var.com_stat[SQLCOM_CHANGE_DB], &LOCK_status); thd->convert_string(&tmp, system_charset_info, - packet, strlen(packet), thd->charset()); + packet, (uint) strlen(packet), thd->charset()); if (!mysql_change_db(thd, &tmp, FALSE)) { mysql_log.write(thd,command,"%s",thd->db); @@ -1832,7 +1832,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, */ char db_buff[NAME_LEN+1]; // buffer to store db in utf8 char *db= passwd; - uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ? + size_t passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ? (uchar)(*passwd++) : strlen(passwd); db+= passwd_len + 1; #ifndef EMBEDDED_LIBRARY @@ -1846,7 +1846,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* Convert database name to utf8 */ uint dummy_errors; db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1, - system_charset_info, db, strlen(db), + system_charset_info, db, (uint) strlen(db), thd->charset(), &dummy_errors)]= 0; db= db_buff; @@ -1865,7 +1865,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* Clear variables that are allocated */ thd->user_connect= 0; - int res= check_user(thd, COM_CHANGE_USER, passwd, passwd_len, db, FALSE); + int res= check_user(thd, COM_CHANGE_USER, passwd, (uint) passwd_len, db, FALSE); if (res) { @@ -2011,7 +2011,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, table_list.schema_table= schema_table; } - thd->query_length= strlen(packet); // for simplicity: don't optimize + thd->query_length= (uint) strlen(packet); // for simplicity: don't optimize if (!(thd->query=fields=thd->memdup(packet,thd->query_length+1))) break; mysql_log.write(thd,command,"%s %s",table_list.table_name, fields); @@ -3917,7 +3917,7 @@ end_with_restore_list: #endif case SQLCOM_CHANGE_DB: { - LEX_STRING db_str= { (char *) select_lex->db, strlen(select_lex->db) }; + LEX_STRING db_str= { (char *) select_lex->db, (uint) strlen(select_lex->db) }; if (!mysql_change_db(thd, &db_str, FALSE)) send_ok(thd); @@ -6148,7 +6148,7 @@ void create_select_for_variable(const char *var_name) mysql_init_select(lex); lex->sql_command= SQLCOM_SELECT; tmp.str= (char*) var_name; - tmp.length=strlen(var_name); + tmp.length=(uint) strlen(var_name); bzero((char*) &null_lex_string.str, sizeof(null_lex_string)); /* We set the name of Item to @@session.var_name because that then is used @@ -6157,7 +6157,7 @@ void create_select_for_variable(const char *var_name) if ((var= get_system_var(thd, OPT_SESSION, tmp, null_lex_string))) { end= strxmov(buff, "@@session.", var_name, NullS); - var->set_name(buff, end-buff, system_charset_info); + var->set_name(buff, (uint) (end - buff), system_charset_info); add_item_to_list(thd, var); } DBUG_VOID_RETURN; @@ -7900,10 +7900,10 @@ void get_default_definer(THD *thd, LEX_USER *definer) const Security_context *sctx= thd->security_ctx; definer->user.str= (char *) sctx->priv_user; - definer->user.length= strlen(definer->user.str); + definer->user.length= (uint) strlen(definer->user.str); definer->host.str= (char *) sctx->priv_host; - definer->host.length= strlen(definer->host.str); + definer->host.length= (uint) strlen(definer->host.str); } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 9e144f5ae9b..a07fcc37856 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -726,13 +726,13 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array, Item_param *param= *it; if (param->state != Item_param::LONG_DATA_VALUE) { - if (is_param_null(null_array, it - begin)) + if (is_param_null(null_array, (uint) (it - begin))) param->set_null(); else { if (read_pos >= data_end) DBUG_RETURN(1); - param->set_param_func(param, &read_pos, data_end - read_pos); + param->set_param_func(param, &read_pos, (uint) (data_end - read_pos)); if (param->state == Item_param::NO_VALUE) DBUG_RETURN(1); } @@ -764,13 +764,13 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array, Item_param *param= *it; if (param->state != Item_param::LONG_DATA_VALUE) { - if (is_param_null(null_array, it - begin)) + if (is_param_null(null_array, (uint) (it - begin))) param->set_null(); else { if (read_pos >= data_end) DBUG_RETURN(1); - param->set_param_func(param, &read_pos, data_end - read_pos); + param->set_param_func(param, &read_pos, (uint) (data_end - read_pos)); if (param->state == Item_param::NO_VALUE) DBUG_RETURN(1); } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 5bbff69f197..5966176012f 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -202,7 +202,7 @@ void adjust_linfo_offsets(my_off_t purge_offset) bool log_in_use(const char* log_name) { - int log_name_len = strlen(log_name) + 1; + size_t log_name_len = strlen(log_name) + 1; THD *tmp; bool result = 0; @@ -1284,8 +1284,8 @@ int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1, const char* log_file_name2, ulonglong log_pos2) { int res; - uint log_file_name1_len= strlen(log_file_name1); - uint log_file_name2_len= strlen(log_file_name2); + size_t log_file_name1_len= strlen(log_file_name1); + size_t log_file_name2_len= strlen(log_file_name2); // We assume that both log names match up to '.' if (log_file_name1_len == log_file_name2_len) @@ -1580,7 +1580,7 @@ int log_loaded_block(IO_CACHE* file) lf_info->last_pos_in_file >= my_b_get_pos_in_file(file)) DBUG_RETURN(0); - for (block_len= my_b_get_bytes_in_buffer(file); block_len > 0; + for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0; buffer += min(block_len, max_event_size), block_len -= min(block_len, max_event_size)) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a341cf5e0e9..c797e25850a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7605,7 +7605,7 @@ static int compare_fields_by_table_order(Item_field *field1, if (outer_ref) return cmp; JOIN_TAB **idx= (JOIN_TAB **) table_join_idx; - cmp= idx[field2->field->table->tablenr]-idx[field1->field->table->tablenr]; + cmp= (uint) (idx[field2->field->table->tablenr] - idx[field1->field->table->tablenr]); return cmp < 0 ? -1 : (cmp ? 1 : 0); } @@ -9632,7 +9632,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, table->s->default_values= table->record[1]+alloc_length; } copy_func[0]=0; // End marker - param->func_count= copy_func - param->items_to_copy; + param->func_count= (uint) (copy_func - param->items_to_copy); recinfo=param->start_recinfo; null_flags=(uchar*) table->record[0]; @@ -15205,10 +15205,10 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, item_list.push_back(new Item_int((int32) join->select_lex->select_number)); item_list.push_back(new Item_string(join->select_lex->type, - strlen(join->select_lex->type), cs)); + (uint) strlen(join->select_lex->type), cs)); for (uint i=0 ; i < 7; i++) item_list.push_back(item_null); - item_list.push_back(new Item_string(message,strlen(message),cs)); + item_list.push_back(new Item_string(message,(uint) strlen(message),cs)); if (result->send_data(item_list)) join->error= 1; } @@ -15227,7 +15227,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, item_list.push_back(new Item_null); /* select_type */ item_list.push_back(new Item_string(join->select_lex->type, - strlen(join->select_lex->type), + (uint) strlen(join->select_lex->type), cs)); /* table */ { @@ -15254,7 +15254,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, } /* type */ item_list.push_back(new Item_string(join_type_str[JT_ALL], - strlen(join_type_str[JT_ALL]), + (uint) strlen(join_type_str[JT_ALL]), cs)); /* possible_keys */ item_list.push_back(item_null); @@ -15303,7 +15303,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, join->select_lex->select_number)); /* select_type */ item_list.push_back(new Item_string(join->select_lex->type, - strlen(join->select_lex->type), + (uint) strlen(join->select_lex->type), cs)); if (tab->type == JT_ALL && tab->select && tab->select->quick) { @@ -15328,12 +15328,12 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, { TABLE_LIST *real_table= table->pos_in_table_list; item_list.push_back(new Item_string(real_table->alias, - strlen(real_table->alias), + (uint) strlen(real_table->alias), cs)); } /* type */ item_list.push_back(new Item_string(join_type_str[tab->type], - strlen(join_type_str[tab->type]), + (uint) strlen(join_type_str[tab->type]), cs)); /* Build "possible_keys" value and add it to item_list */ if (!tab->keys.is_clear_all()) @@ -15346,7 +15346,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, if (tmp1.length()) tmp1.append(','); tmp1.append(table->key_info[j].name, - strlen(table->key_info[j].name), + (uint) strlen(table->key_info[j].name), system_charset_info); } } @@ -15362,17 +15362,17 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, KEY *key_info=table->key_info+ tab->ref.key; register uint length; item_list.push_back(new Item_string(key_info->name, - strlen(key_info->name), + (uint) strlen(key_info->name), system_charset_info)); - length= longlong2str(tab->ref.key_length, keylen_str_buf, 10) - - keylen_str_buf; + length= (uint) (longlong2str(tab->ref.key_length, keylen_str_buf, 10) - + keylen_str_buf); item_list.push_back(new Item_string(keylen_str_buf, length, system_charset_info)); for (store_key **ref=tab->ref.key_copy ; *ref ; ref++) { if (tmp2.length()) tmp2.append(','); - tmp2.append((*ref)->name(), strlen((*ref)->name()), + tmp2.append((*ref)->name(), (uint) strlen((*ref)->name()), system_charset_info); } item_list.push_back(new Item_string(tmp2.ptr(),tmp2.length(),cs)); @@ -15382,9 +15382,9 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, KEY *key_info=table->key_info+ tab->index; register uint length; item_list.push_back(new Item_string(key_info->name, - strlen(key_info->name),cs)); - length= longlong2str(key_info->key_length, keylen_str_buf, 10) - - keylen_str_buf; + (uint) strlen(key_info->name),cs)); + length= (uint) (longlong2str(key_info->key_length, keylen_str_buf, 10) - + keylen_str_buf); item_list.push_back(new Item_string(keylen_str_buf, length, system_charset_info)); @@ -15417,7 +15417,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, key_read=1; if (tab->info) - item_list.push_back(new Item_string(tab->info,strlen(tab->info),cs)); + item_list.push_back(new Item_string(tab->info,(uint) strlen(tab->info),cs)); else if (tab->packed_info & TAB_INFO_HAVE_VALUE) { if (tab->packed_info & TAB_INFO_USING_INDEX) @@ -15741,7 +15741,7 @@ void TABLE_LIST::print(THD *thd, String *str) if (schema_table) { append_identifier(thd, str, schema_table_name, - strlen(schema_table_name)); + (uint) strlen(schema_table_name)); cmp_name= schema_table_name; } else @@ -15766,7 +15766,7 @@ void TABLE_LIST::print(THD *thd, String *str) } } - append_identifier(thd, str, t_alias, strlen(t_alias)); + append_identifier(thd, str, t_alias, (uint) strlen(t_alias)); } if (use_index) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index d6bb3427fe4..5f4ece810b8 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -352,9 +352,9 @@ find_files(THD *thd, List *files, const char *db, if (db && !(col_access & TABLE_ACLS)) { table_list.db= (char*) db; - table_list.db_length= strlen(db); + table_list.db_length= (uint) strlen(db); table_list.table_name= file->name; - table_list.table_name_length= strlen(file->name); + table_list.table_name_length= (uint) strlen(file->name); table_list.grant.privilege=col_access; if (check_grant(thd, TABLE_ACLS, &table_list, 1, 1, 1)) continue; @@ -520,12 +520,12 @@ bool mysqld_show_create_db(THD *thd, char *dbname, DBUG_RETURN(TRUE); protocol->prepare_for_resend(); - protocol->store(dbname, strlen(dbname), system_charset_info); + protocol->store(dbname, (uint) strlen(dbname), system_charset_info); buffer.length(0); buffer.append(STRING_WITH_LEN("CREATE DATABASE ")); if (create_options & HA_LEX_CREATE_IF_NOT_EXISTS) buffer.append(STRING_WITH_LEN("/*!32312 IF NOT EXISTS*/ ")); - append_identifier(thd, &buffer, dbname, strlen(dbname)); + append_identifier(thd, &buffer, dbname, (uint) strlen(dbname)); if (create.default_table_charset) { @@ -897,7 +897,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) else alias= (lower_case_table_names == 2 ? table->alias : share->table_name); - append_identifier(thd, packet, alias, strlen(alias)); + append_identifier(thd, packet, alias, (uint) strlen(alias)); packet->append(STRING_WITH_LEN(" (\n")); for (ptr=table->field ; (field= *ptr); ptr++) @@ -908,7 +908,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) packet->append(STRING_WITH_LEN(",\n")); packet->append(STRING_WITH_LEN(" ")); - append_identifier(thd,packet,field->field_name, strlen(field->field_name)); + append_identifier(thd,packet,field->field_name, (uint) strlen(field->field_name)); packet->append(' '); // check for surprises from the previous call to Field::sql_type() if (type.ptr() != tmp) @@ -995,7 +995,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) packet->append(STRING_WITH_LEN("KEY ")); if (!found_primary) - append_identifier(thd, packet, key_info->name, strlen(key_info->name)); + append_identifier(thd, packet, key_info->name, (uint) strlen(key_info->name)); if (!(thd->variables.sql_mode & MODE_NO_KEY_OPTIONS) && !limited_mysql_mode && !foreign_db_mode) @@ -1022,7 +1022,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) if (key_part->field) append_identifier(thd,packet,key_part->field->field_name, - strlen(key_part->field->field_name)); + (uint) strlen(key_part->field->field_name)); if (key_part->field && (key_part->length != table->field[key_part->fieldnr-1]->key_length() && @@ -1046,7 +1046,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) if ((for_str= file->get_foreign_key_create_info())) { - packet->append(for_str, strlen(for_str)); + packet->append(for_str, (uint) strlen(for_str)); file->free_foreign_key_create_info(for_str); } @@ -1451,7 +1451,7 @@ static bool show_status_array(THD *thd, const char *wild, char buff[1024], *prefix_end; /* the variable name should not be longer then 80 characters */ char name_buffer[80]; - int len; + size_t len; LEX_STRING null_lex_str; CHARSET_INFO *charset= system_charset_info; DBUG_ENTER("show_status_array"); @@ -1460,11 +1460,11 @@ static bool show_status_array(THD *thd, const char *wild, null_lex_str.length= 0; prefix_end=strnmov(name_buffer, prefix, sizeof(name_buffer)-1); - len=name_buffer + sizeof(name_buffer) - prefix_end; + len= name_buffer + sizeof(name_buffer) - prefix_end; for (; variables->name; variables++) { - strnmov(prefix_end, variables->name, len); + strnmov(prefix_end, variables->name, (uint) len); name_buffer[sizeof(name_buffer)-1]=0; /* Safety */ SHOW_TYPE show_type=variables->type; if (show_type == SHOW_VARS) @@ -1780,7 +1780,7 @@ static bool show_status_array(THD *thd, const char *wild, const char *p= SSL_get_cipher_list((SSL*) thd->net.vio->ssl_arg,i); if (p == NULL) break; - to= strnmov(to, p, buff_end-to-1); + to= strnmov(to, p, (uint) (buff_end-to-1)); *to++= ':'; } if (to != buff) @@ -1809,7 +1809,7 @@ static bool show_status_array(THD *thd, const char *wild, break; } restore_record(table, s->default_values); - table->field[0]->store(name_buffer, strlen(name_buffer), + table->field[0]->store(name_buffer, (uint) strlen(name_buffer), system_charset_info); table->field[1]->store(pos, (uint32) (end - pos), charset); if (schema_table_store_record(thd, table)) @@ -1928,9 +1928,9 @@ int make_table_list(THD *thd, SELECT_LEX *sel, Table_ident *table_ident; LEX_STRING ident_db, ident_table; ident_db.str= db; - ident_db.length= strlen(db); + ident_db.length= (uint) strlen(db); ident_table.str= table; - ident_table.length= strlen(table); + ident_table.length= (uint) strlen(table); table_ident= new Table_ident(thd, ident_db, ident_table, 1); sel->init_query(); if (!sel->add_table_to_list(thd, table_ident, 0, 0, TL_READ, @@ -1960,12 +1960,12 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table) const char *field_name1= schema_table->idx_field1 >= 0 ? field_info[schema_table->idx_field1].field_name : ""; const char *field_name2= schema_table->idx_field2 >= 0 ? field_info[schema_table->idx_field2].field_name : ""; if (table->table != item_field->field->table || - (cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1), + (cs->coll->strnncollsp(cs, (uchar *) field_name1, (uint) strlen(field_name1), (uchar *) item_field->field_name, - strlen(item_field->field_name), 0) && - cs->coll->strnncollsp(cs, (uchar *) field_name2, strlen(field_name2), + (uint) strlen(item_field->field_name), 0) && + cs->coll->strnncollsp(cs, (uchar *) field_name2, (uint) strlen(field_name2), (uchar *) item_field->field_name, - strlen(item_field->field_name), 0))) + (uint) strlen(item_field->field_name), 0))) return 0; } else if (item->type() == Item::REF_ITEM) @@ -2296,9 +2296,9 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) { restore_record(table, s->default_values); table->field[schema_table->idx_field1]-> - store(base_name, strlen(base_name), system_charset_info); + store(base_name, (uint) strlen(base_name), system_charset_info); table->field[schema_table->idx_field2]-> - store(file_name, strlen(file_name),system_charset_info); + store(file_name, (uint) strlen(file_name),system_charset_info); if (!partial_cond || partial_cond->val_int()) { if (schema_table_idx == SCH_TABLE_NAMES) @@ -2406,9 +2406,9 @@ bool store_schema_shemata(THD* thd, TABLE *table, const char *db_name, CHARSET_INFO *cs) { restore_record(table, s->default_values); - table->field[1]->store(db_name, strlen(db_name), system_charset_info); - table->field[2]->store(cs->csname, strlen(cs->csname), system_charset_info); - table->field[3]->store(cs->name, strlen(cs->name), system_charset_info); + table->field[1]->store(db_name, (uint) strlen(db_name), system_charset_info); + table->field[2]->store(cs->csname, (uint) strlen(cs->csname), system_charset_info); + table->field[3]->store(cs->name, (uint) strlen(cs->name), system_charset_info); return schema_table_store_record(thd, table); } @@ -2474,8 +2474,8 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, DBUG_ENTER("get_schema_tables_record"); restore_record(table, s->default_values); - table->field[1]->store(base_name, strlen(base_name), cs); - table->field[2]->store(file_name, strlen(file_name), cs); + table->field[1]->store(base_name, (uint) strlen(base_name), cs); + table->field[2]->store(file_name, (uint) strlen(file_name), cs); if (res) { /* @@ -2488,7 +2488,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs); else table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs); - table->field[20]->store(error, strlen(error), cs); + table->field[20]->store(error, (uint) strlen(error), cs); thd->clear_error(); } else if (tables->view) @@ -2518,7 +2518,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, table->field[i]->set_notnull(); } tmp_buff= file->table_type(); - table->field[4]->store(tmp_buff, strlen(tmp_buff), cs); + table->field[4]->store(tmp_buff, (uint) strlen(tmp_buff), cs); table->field[5]->store((longlong) share->frm_version, TRUE); enum row_type row_type = file->get_row_type(); switch (row_type) { @@ -2545,7 +2545,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, tmp_buff= "Compact"; break; } - table->field[6]->store(tmp_buff, strlen(tmp_buff), cs); + table->field[6]->store(tmp_buff, (uint) strlen(tmp_buff), cs); if (!tables->schema_table) { table->field[7]->store((longlong) file->records, TRUE); @@ -2587,7 +2587,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, } tmp_buff= (share->table_charset ? share->table_charset->name : "default"); - table->field[17]->store(tmp_buff, strlen(tmp_buff), cs); + table->field[17]->store(tmp_buff, (uint) strlen(tmp_buff), cs); if (file->table_flags() & (ulong) HA_HAS_CHECKSUM) { table->field[18]->store((longlong) file->checksum(), TRUE); @@ -2643,7 +2643,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, table->field[20]->store(comment, (comment == share->comment.str ? share->comment.length : - strlen(comment)), cs); + (uint) strlen(comment)), cs); if (comment != share->comment.str) my_free(comment, MYF(0)); } @@ -2689,8 +2689,8 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, count= 0; file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); restore_record(show_table, s->default_values); - base_name_length= strlen(base_name); - file_name_length= strlen(file_name); + base_name_length= (uint) strlen(base_name); + file_name_length= (uint) strlen(file_name); for (ptr=show_table->field; (field= *ptr) ; ptr++) { @@ -2735,13 +2735,13 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, #endif table->field[1]->store(base_name, base_name_length, cs); table->field[2]->store(file_name, file_name_length, cs); - table->field[3]->store(field->field_name, strlen(field->field_name), + table->field[3]->store(field->field_name, (uint) strlen(field->field_name), cs); table->field[4]->store((longlong) count, TRUE); field->sql_type(type); table->field[14]->store(type.ptr(), type.length(), cs); tmp_buff= strchr(type.ptr(), '('); - table->field[7]->store(type.ptr(), + table->field[7]->store(type.ptr(), (uint) (tmp_buff ? tmp_buff - type.ptr() : type.length()), cs); @@ -2753,7 +2753,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, pos=(byte*) ((flags & NOT_NULL_FLAG) ? "NO" : "YES"); table->field[6]->store((const char*) pos, - strlen((const char*) pos), cs); + (uint) strlen((const char*) pos), cs); is_blob= (field->type() == FIELD_TYPE_BLOB); if (field->has_charset() || is_blob || field->real_type() == MYSQL_TYPE_VARCHAR || // For varbinary type @@ -2821,18 +2821,18 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, { pos=(byte*) field->charset()->csname; table->field[12]->store((const char*) pos, - strlen((const char*) pos), cs); + (uint) strlen((const char*) pos), cs); table->field[12]->set_notnull(); pos=(byte*) field->charset()->name; table->field[13]->store((const char*) pos, - strlen((const char*) pos), cs); + (uint) strlen((const char*) pos), cs); table->field[13]->set_notnull(); } pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" : (field->flags & UNIQUE_KEY_FLAG) ? "UNI" : (field->flags & MULTIPLE_KEY_FLAG) ? "MUL":""); table->field[15]->store((const char*) pos, - strlen((const char*) pos), cs); + (uint) strlen((const char*) pos), cs); end= tmp; if (field->unireg_check == Field::NEXT_NUMBER) @@ -2865,10 +2865,10 @@ int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond) { const char *comment; restore_record(table, s->default_values); - table->field[0]->store(tmp_cs->csname, strlen(tmp_cs->csname), scs); - table->field[1]->store(tmp_cs->name, strlen(tmp_cs->name), scs); + table->field[0]->store(tmp_cs->csname, (uint) strlen(tmp_cs->csname), scs); + table->field[1]->store(tmp_cs->name, (uint) strlen(tmp_cs->name), scs); comment= tmp_cs->comment ? tmp_cs->comment : ""; - table->field[2]->store(comment, strlen(comment), scs); + table->field[2]->store(comment, (uint) strlen(comment), scs); table->field[3]->store((longlong) tmp_cs->mbmaxlen, TRUE); if (schema_table_store_record(thd, table)) return 1; @@ -2902,13 +2902,13 @@ int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond) { const char *tmp_buff; restore_record(table, s->default_values); - table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs); - table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs); + table->field[0]->store(tmp_cl->name, (uint) strlen(tmp_cl->name), scs); + table->field[1]->store(tmp_cl->csname , (uint) strlen(tmp_cl->csname), scs); table->field[2]->store((longlong) tmp_cl->number, TRUE); tmp_buff= (tmp_cl->state & MY_CS_PRIMARY) ? "Yes" : ""; - table->field[3]->store(tmp_buff, strlen(tmp_buff), scs); + table->field[3]->store(tmp_buff, (uint) strlen(tmp_buff), scs); tmp_buff= (tmp_cl->state & MY_CS_COMPILED)? "Yes" : ""; - table->field[4]->store(tmp_buff, strlen(tmp_buff), scs); + table->field[4]->store(tmp_buff, (uint) strlen(tmp_buff), scs); table->field[5]->store((longlong) tmp_cl->strxfrm_multiply, TRUE); if (schema_table_store_record(thd, table)) return 1; @@ -2938,8 +2938,8 @@ int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond) !my_charset_same(tmp_cs,tmp_cl)) continue; restore_record(table, s->default_values); - table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs); - table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs); + table->field[0]->store(tmp_cl->name, (uint) strlen(tmp_cl->name), scs); + table->field[1]->store(tmp_cl->csname , (uint) strlen(tmp_cl->csname), scs); if (schema_table_store_record(thd, table)) return 1; } @@ -3110,16 +3110,16 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) { restore_record(table, s->default_values); - table->field[1]->store(base_name, strlen(base_name), cs); - table->field[2]->store(file_name, strlen(file_name), cs); + table->field[1]->store(base_name, (uint) strlen(base_name), cs); + table->field[2]->store(file_name, (uint) strlen(file_name), cs); table->field[3]->store((longlong) ((key_info->flags & HA_NOSAME) ? 0 : 1), TRUE); - table->field[4]->store(base_name, strlen(base_name), cs); - table->field[5]->store(key_info->name, strlen(key_info->name), cs); + table->field[4]->store(base_name, (uint) strlen(base_name), cs); + table->field[5]->store(key_info->name, (uint) strlen(key_info->name), cs); table->field[6]->store((longlong) (j+1), TRUE); str=(key_part->field ? key_part->field->field_name : "?unknown field?"); - table->field[7]->store(str, strlen(str), cs); + table->field[7]->store(str, (uint) strlen(str), cs); if (show_table->file->index_flags(i, j, 0) & HA_READ_ORDER) { table->field[8]->store(((key_part->key_part_flag & @@ -3146,9 +3146,9 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, } uint flags= key_part->field ? key_part->field->flags : 0; const char *pos=(char*) ((flags & NOT_NULL_FLAG) ? "" : "YES"); - table->field[12]->store(pos, strlen(pos), cs); + table->field[12]->store(pos, (uint) strlen(pos), cs); pos= show_table->file->index_type(i); - table->field[13]->store(pos, strlen(pos), cs); + table->field[13]->store(pos, (uint) strlen(pos), cs); if (!show_table->s->keys_in_use.is_set(i)) table->field[14]->store(STRING_WITH_LEN("disabled"), cs); else @@ -3264,7 +3264,7 @@ static int get_schema_views_record(THD *thd, TABLE_LIST *tables, table->field[5]->store(STRING_WITH_LEN("YES"), cs); else table->field[5]->store(STRING_WITH_LEN("NO"), cs); - definer_len= (strxmov(definer, tables->definer.user.str, "@", + definer_len= (uint) (strxmov(definer, tables->definer.user.str, "@", tables->definer.host.str, NullS) - definer); table->field[6]->store(definer, definer_len, cs); if (tables->view_suid) @@ -3289,10 +3289,10 @@ bool store_constraints(THD *thd, TABLE *table, const char *db, { CHARSET_INFO *cs= system_charset_info; restore_record(table, s->default_values); - table->field[1]->store(db, strlen(db), cs); + table->field[1]->store(db, (uint) strlen(db), cs); table->field[2]->store(key_name, key_len, cs); - table->field[3]->store(db, strlen(db), cs); - table->field[4]->store(tname, strlen(tname), cs); + table->field[3]->store(db, (uint) strlen(db), cs); + table->field[4]->store(tname, (uint) strlen(tname), cs); table->field[5]->store(con_type, con_len, cs); return schema_table_store_record(thd, table); } @@ -3329,14 +3329,14 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables, if (i == primary_key && !strcmp(key_info->name, primary_key_name)) { if (store_constraints(thd, table, base_name, file_name, key_info->name, - strlen(key_info->name), + (uint) strlen(key_info->name), STRING_WITH_LEN("PRIMARY KEY"))) DBUG_RETURN(1); } else if (key_info->flags & HA_NOSAME) { if (store_constraints(thd, table, base_name, file_name, key_info->name, - strlen(key_info->name), + (uint) strlen(key_info->name), STRING_WITH_LEN("UNIQUE"))) DBUG_RETURN(1); } @@ -3349,7 +3349,7 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables, { if (store_constraints(thd, table, base_name, file_name, f_key_info->forein_id->str, - strlen(f_key_info->forein_id->str), + (uint) strlen(f_key_info->forein_id->str), "FOREIGN KEY", 11)) DBUG_RETURN(1); } @@ -3371,12 +3371,12 @@ static bool store_trigger(THD *thd, TABLE *table, const char *db, ulong sql_mode_len; restore_record(table, s->default_values); - table->field[1]->store(db, strlen(db), cs); + table->field[1]->store(db, (uint) strlen(db), cs); table->field[2]->store(trigger_name->str, trigger_name->length, cs); table->field[3]->store(trg_event_type_names[event].str, trg_event_type_names[event].length, cs); - table->field[5]->store(db, strlen(db), cs); - table->field[6]->store(tname, strlen(tname), cs); + table->field[5]->store(db, (uint) strlen(db), cs); + table->field[6]->store(tname, (uint) strlen(tname), cs); table->field[9]->store(trigger_stmt->str, trigger_stmt->length, cs); table->field[10]->store(STRING_WITH_LEN("ROW"), cs); table->field[11]->store(trg_action_time_type_names[timing].str, @@ -3460,10 +3460,10 @@ void store_key_column_usage(TABLE *table, const char*db, const char *tname, const char *con_type, uint con_len, longlong idx) { CHARSET_INFO *cs= system_charset_info; - table->field[1]->store(db, strlen(db), cs); + table->field[1]->store(db, (uint) strlen(db), cs); table->field[2]->store(key_name, key_len, cs); - table->field[4]->store(db, strlen(db), cs); - table->field[5]->store(tname, strlen(tname), cs); + table->field[4]->store(db, (uint) strlen(db), cs); + table->field[5]->store(tname, (uint) strlen(tname), cs); table->field[6]->store(con_type, con_len, cs); table->field[7]->store((longlong) idx, TRUE); } @@ -3507,9 +3507,9 @@ static int get_schema_key_column_usage_record(THD *thd, restore_record(table, s->default_values); store_key_column_usage(table, base_name, file_name, key_info->name, - strlen(key_info->name), + (uint) strlen(key_info->name), key_part->field->field_name, - strlen(key_part->field->field_name), + (uint) strlen(key_part->field->field_name), (longlong) f_idx); if (schema_table_store_record(thd, table)) DBUG_RETURN(1); @@ -3573,8 +3573,8 @@ int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond) for (; open_list ; open_list=open_list->next) { restore_record(table, s->default_values); - table->field[0]->store(open_list->db, strlen(open_list->db), cs); - table->field[1]->store(open_list->table, strlen(open_list->table), cs); + table->field[0]->store(open_list->db, (uint) strlen(open_list->db), cs); + table->field[1]->store(open_list->table, (uint) strlen(open_list->table), cs); table->field[2]->store((longlong) open_list->in_use, TRUE); table->field[3]->store((longlong) open_list->locked, TRUE); if (schema_table_store_record(thd, table)) @@ -3706,7 +3706,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) DBUG_RETURN(0); } item->set_name(fields_info->field_name, - strlen(fields_info->field_name), cs); + (uint) strlen(fields_info->field_name), cs); break; } field_list.push_back(item); @@ -3759,7 +3759,7 @@ int make_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) if (field) { field->set_name(field_info->old_name, - strlen(field_info->old_name), + (uint) strlen(field_info->old_name), system_charset_info); if (add_item_to_list(thd, field)) return 1; @@ -3828,7 +3828,7 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) field= new Item_field(context, NullS, NullS, field_info->field_name); if (add_item_to_list(thd, field)) return 1; - field->set_name(field_info->old_name, strlen(field_info->old_name), + field->set_name(field_info->old_name, (uint) strlen(field_info->old_name), system_charset_info); } return 0; @@ -3854,7 +3854,7 @@ int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) if (field) { field->set_name(field_info->old_name, - strlen(field_info->old_name), + (uint) strlen(field_info->old_name), system_charset_info); if (add_item_to_list(thd, field)) return 1; @@ -3879,7 +3879,7 @@ int make_character_sets_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) if (field) { field->set_name(field_info->old_name, - strlen(field_info->old_name), + (uint) strlen(field_info->old_name), system_charset_info); if (add_item_to_list(thd, field)) return 1; @@ -3904,7 +3904,7 @@ int make_proc_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) if (field) { field->set_name(field_info->old_name, - strlen(field_info->old_name), + (uint) strlen(field_info->old_name), system_charset_info); if (add_item_to_list(thd, field)) return 1; @@ -3950,7 +3950,7 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list) table_list->schema_table_name, table_list->alias); table_list->table_name= (char*) table->s->table_name; - table_list->table_name_length= strlen(table->s->table_name); + table_list->table_name_length= (uint) strlen(table->s->table_name); table_list->table= table; table->next= thd->derived_tables; thd->derived_tables= table; @@ -4026,7 +4026,7 @@ int make_schema_select(THD *thd, SELECT_LEX *sel, make_lex_string(thd, &db, INFORMATION_SCHEMA_NAME.str, INFORMATION_SCHEMA_NAME.length, 0); make_lex_string(thd, &table, schema_table->table_name, - strlen(schema_table->table_name), 0); + (uint) strlen(schema_table->table_name), 0); if (schema_table->old_format(thd, schema_table) || /* Handle old syntax */ !sel->add_table_to_list(thd, new Table_ident(thd, db, table, 0), 0, 0, TL_READ, (List *) 0, diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 75e47dd0c8e..e7051883d36 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -468,7 +468,7 @@ bool String::append(const char *s,uint32 arg_length) bool String::append(const char *s) { - return append(s, strlen(s)); + return append(s, (uint) strlen(s)); } @@ -1003,7 +1003,7 @@ outp: } } *from_end_pos= from; - res= to - to_start; + res= (uint) (to - to_start); } return (uint32) res; } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index eefe2a5596e..45707246f90 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -66,8 +66,8 @@ static void set_tmp_file_path(char *buf, size_t bufsize, THD *thd); uint build_table_path(char *buff, size_t bufflen, const char *db, const char *table, const char *ext) { - strxnmov(buff, bufflen-1, mysql_data_home, "/", db, "/", table, ext, - NullS); + strxnmov(buff, (uint) (bufflen - 1), mysql_data_home, "/", db, "/", table, + ext, NullS); return unpack_filename(buff,buff); } @@ -2537,7 +2537,7 @@ send_result_message: case HA_ADMIN_WRONG_CHECKSUM: { protocol->store(STRING_WITH_LEN("note"), system_charset_info); - protocol->store(ER(ER_VIEW_CHECKSUM), strlen(ER(ER_VIEW_CHECKSUM)), + protocol->store(ER(ER_VIEW_CHECKSUM), (uint) strlen(ER(ER_VIEW_CHECKSUM)), system_charset_info); break; } @@ -4443,7 +4443,7 @@ static bool check_engine(THD *thd, const char *table_name, static void set_tmp_file_path(char *buf, size_t bufsize, THD *thd) { - char *p= strnmov(buf, mysql_tmpdir, bufsize); + char *p= strnmov(buf, mysql_tmpdir, (uint) bufsize); my_snprintf(p, bufsize - (p - buf), "%s%lx_%lx_%x%s", tmp_file_prefix, current_pid, thd->thread_id, thd->tmp_table++, reg_ext); diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index d3b5289cd68..930e3601699 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -459,12 +459,12 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, strxnmov(dir_buff, FN_REFLEN, mysql_data_home, "/", tables->db, "/", NullS); dir.length= unpack_filename(dir_buff, dir_buff); dir.str= dir_buff; - file.length= strxnmov(file_buff, FN_REFLEN, tables->table_name, - triggers_file_ext, NullS) - file_buff; + file.length= (uint) (strxnmov(file_buff, FN_REFLEN, tables->table_name, + triggers_file_ext, NullS) - file_buff); file.str= file_buff; - trigname_file.length= strxnmov(trigname_buff, FN_REFLEN, + trigname_file.length= (uint) (strxnmov(trigname_buff, FN_REFLEN, lex->spname->m_name.str, - trigname_file_ext, NullS) - trigname_buff; + trigname_file_ext, NullS) - trigname_buff); trigname_file.str= trigname_buff; strxnmov(trigname_path, FN_REFLEN, dir_buff, trigname_buff, NullS); @@ -524,8 +524,8 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, definer_host= lex->definer->host; trg_definer->str= trg_definer_holder; - trg_definer->length= strxmov(trg_definer->str, definer_user.str, "@", - definer_host.str, NullS) - trg_definer->str; + trg_definer->length= (uint) (strxmov(trg_definer->str, definer_user.str, "@", + definer_host.str, NullS) - trg_definer->str); } else { @@ -559,9 +559,9 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, } stmt_query->append(thd->lex->stmt_definition_begin, - (char *) thd->lex->sphead->m_body_begin - + (uint) ((char *) thd->lex->sphead->m_body_begin - thd->lex->stmt_definition_begin + - thd->lex->sphead->m_body.length); + thd->lex->sphead->m_body.length)); trg_def->str= stmt_query->c_ptr(); trg_def->length= stmt_query->length(); @@ -651,8 +651,8 @@ static bool save_trigger_file(Table_triggers_list *triggers, const char *db, strxnmov(dir_buff, FN_REFLEN, mysql_data_home, "/", db, "/", NullS); dir.length= unpack_filename(dir_buff, dir_buff); dir.str= dir_buff; - file.length= strxnmov(file_buff, FN_REFLEN, table_name, triggers_file_ext, - NullS) - file_buff; + file.length= (uint) (strxnmov(file_buff, FN_REFLEN, table_name, triggers_file_ext, + NullS) - file_buff); file.str= file_buff; return sql_create_definition_file(&dir, &file, &triggers_file_type, @@ -960,7 +960,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, save_db.str= thd->db; save_db.length= thd->db_length; - thd->reset_db((char*) db, strlen(db)); + thd->reset_db((char*) db, (uint) strlen(db)); while ((trg_create_str= it++)) { trg_sql_mode= itm++; @@ -1153,8 +1153,8 @@ bool Table_triggers_list::get_trigger_info(THD *thd, trg_event_type event, } else { - definer->length= strxmov(definer->str, body->m_definer_user.str, "@", - body->m_definer_host.str, NullS) - definer->str; + definer->length= (uint) (strxmov(definer->str, body->m_definer_user.str, "@", + body->m_definer_host.str, NullS) - definer->str); } DBUG_RETURN(0); @@ -1350,7 +1350,7 @@ Table_triggers_list::change_table_name_in_triggers(THD *thd, /* Construct CREATE TRIGGER statement with new table name. */ buff.length(0); - before_on_len= on_table_name->str - def->str; + before_on_len= (uint) (on_table_name->str - def->str); buff.append(def->str, before_on_len); buff.append(STRING_WITH_LEN("ON ")); append_identifier(thd, &buff, new_table_name->str, new_table_name->length); @@ -1420,8 +1420,8 @@ Table_triggers_list::change_table_name_in_trignames(const char *db_name, while ((trigger= it_name++) != stopper) { - trigname_file.length= strxnmov(trigname_buff, FN_REFLEN, trigger->str, - trigname_file_ext, NullS) - trigname_buff; + trigname_file.length= (uint) (strxnmov(trigname_buff, FN_REFLEN, trigger->str, + trigname_file_ext, NullS) - trigname_buff); trigname_file.str= trigname_buff; trigname.trigger_table= *new_table_name; @@ -1482,8 +1482,8 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db, } if (table.triggers) { - LEX_STRING_WITH_INIT old_table_name(old_table, strlen(old_table)); - LEX_STRING_WITH_INIT new_table_name(new_table, strlen(new_table)); + LEX_STRING_WITH_INIT old_table_name(old_table, (uint) strlen(old_table)); + LEX_STRING_WITH_INIT new_table_name(new_table, (uint) strlen(new_table)); /* Since triggers should be in the same schema as their subject tables moving table with them between two schemas raises too many questions. diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 6520c1a661e..f1b16a627ac 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -182,7 +182,7 @@ void udf_init() DBUG_PRINT("info",("init udf record")); LEX_STRING name; name.str=get_field(&mem, table->field[0]); - name.length = strlen(name.str); + name.length = (uint) strlen(name.str); char *dl_name= get_field(&mem, table->field[2]); bool new_dl=0; Item_udftype udftype=UDFTYPE_FUNCTION; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 41a638b2618..9e0fa87d5f5 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -775,11 +775,11 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, } view->source.str= thd->query + thd->lex->create_view_select_start; - view->source.length= (char *)skip_rear_comments(thd->charset(), + view->source.length= (uint) ((char *)skip_rear_comments(thd->charset(), (char *)view->source.str, (char *)thd->query + thd->query_length) - - view->source.str; + view->source.str); view->file_version= 1; view->calc_md5(md5); if (!(view->md5.str= thd->memdup(md5, 32))) @@ -831,10 +831,10 @@ loop_out: mysql_data_home, view->db); unpack_filename(dir_buff, dir_buff); dir.str= dir_buff; - dir.length= strlen(dir_buff); + dir.length= (uint) strlen(dir_buff); file.str= file_buff; - file.length= (strxnmov(file_buff, FN_REFLEN, view->table_name, reg_ext, + file.length= (uint) (strxnmov(file_buff, FN_REFLEN, view->table_name, reg_ext, NullS) - file_buff); /* init timestamp */ if (!view->timestamp.str) @@ -848,7 +848,7 @@ loop_out: path.str= path_buff; fn_format(path_buff, file.str, dir.str, 0, MY_UNPACK_FILENAME); - path.length= strlen(path_buff); + path.length= (uint) strlen(path_buff); if (!access(path.str, F_OK)) { @@ -1828,7 +1828,7 @@ mysql_rename_view(THD *thd, (void) unpack_filename(view_path, view_path); pathstr.str= (char *)view_path; - pathstr.length= strlen(view_path); + pathstr.length= (uint) strlen(view_path); if ((parser= sql_parse_prepare(&pathstr, thd->mem_root, 1)) && is_equal(&view_type, parser->type())) @@ -1860,10 +1860,10 @@ mysql_rename_view(THD *thd, (void) unpack_filename(dir_buff, dir_buff); pathstr.str= (char*)dir_buff; - pathstr.length= strlen(dir_buff); + pathstr.length= (uint) strlen(dir_buff); file.str= file_buff; - file.length= (strxnmov(file_buff, FN_REFLEN, new_name, reg_ext, NullS) + file.length= (uint) (strxnmov(file_buff, FN_REFLEN, new_name, reg_ext, NullS) - file_buff); if (sql_create_definition_file(&pathstr, &file, view_file_type, diff --git a/sql/table.cc b/sql/table.cc index 3abd2c24c94..b5126633469 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -471,7 +471,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, for (count= 0; count < interval->count; count++) { char *val= (char*) interval->type_names[count]; - interval->type_lengths[count]= strlen(val); + interval->type_lengths[count]= (uint) strlen(val); } interval->type_lengths[count]= 0; } @@ -916,7 +916,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, the correct null_bytes can now be set, since bitfields have been taken into account */ - share->null_bytes= (null_pos - (uchar*) outparam->null_flags + + share->null_bytes= (uint) (null_pos - (uchar*) outparam->null_flags + (null_bit_pos + 7) / 8); share->last_null_bit_pos= null_bit_pos; @@ -3000,8 +3000,8 @@ Field_iterator_table_ref::get_or_create_column_ref(THD *thd, TABLE_LIST *parent_ /* The field belongs to a merge view or information schema table. */ Field_translator *translated_field= view_field_it.field_translator(); nj_col= new Natural_join_column(translated_field, table_ref); - field_count= table_ref->field_translation_end - - table_ref->field_translation; + field_count= (uint) (table_ref->field_translation_end - + table_ref->field_translation); } else { diff --git a/sql/udf_example.c b/sql/udf_example.c index 4ca6133da03..db48984eed8 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -1099,7 +1099,7 @@ char * is_const(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)), sprintf(result, "not const"); } *is_null= 0; - *length= strlen(result); + *length= (uint) strlen(result); return result; } @@ -1133,7 +1133,7 @@ char * check_const_len(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)), char *is_null, char *error __attribute__((unused))) { strmov(result, initid->ptr); - *length= strlen(result); + *length= (uint) strlen(result); *is_null= 0; return result; } diff --git a/sql/uniques.cc b/sql/uniques.cc index 7c197d2a2e9..a0d1beaf0f9 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -131,7 +131,7 @@ static double get_merge_buffers_cost(uint *buff_elems, uint elem_size, total_buf_elems+= *pbuf; *last= total_buf_elems; - int n_buffers= last - first + 1; + size_t n_buffers= last - first + 1; /* Using log2(n)=log(n)/log(2) formula */ return 2*((double)total_buf_elems*elem_size) / IO_SIZE + diff --git a/sql/unireg.cc b/sql/unireg.cc index d37bb09d0e8..d658365abd0 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -119,7 +119,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, /* Calculate extra data segment length */ str_db_type.str= (char *) ha_get_storage_engine(create_info->db_type); - str_db_type.length= strlen(str_db_type.str); + str_db_type.length= (uint) strlen(str_db_type.str); create_info->extra_size= (2 + str_db_type.length + 2 + create_info->connect_string.length); diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index b370714e464..1e0523e86bc 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -37,7 +37,7 @@ uint my_caseup_str_mb(CHARSET_INFO * cs, char *str) str++; } } - return str - str_orig; + return (uint) (str - str_orig); } uint my_casedn_str_mb(CHARSET_INFO * cs, char *str) @@ -57,7 +57,7 @@ uint my_casedn_str_mb(CHARSET_INFO * cs, char *str) str++; } } - return str - str_orig; + return (uint) (str - str_orig); } uint my_caseup_mb(CHARSET_INFO * cs, char *src, uint srclen, diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 99e02e02014..35f0979b461 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -193,7 +193,7 @@ uint my_caseup_str_8bit(CHARSET_INFO * cs,char *str) char *str_orig= str; while ((*str= (char) map[(uchar) *str]) != 0) str++; - return str - str_orig; + return (uint) (str - str_orig); } @@ -203,7 +203,7 @@ uint my_casedn_str_8bit(CHARSET_INFO * cs,char *str) char *str_orig= str; while ((*str= (char) map[(uchar) *str]) != 0) str++; - return str - str_orig; + return (uint) (str - str_orig); } @@ -1516,7 +1516,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), } } - digits= str - beg; + digits= (int) (str - beg); /* Continue to accumulate into ulonglong */ for (dot= NULL, ull= ul; str < end; str++) @@ -1553,7 +1553,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), } else { - shift= dot - str; + shift= (int) (dot - str); for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++); } goto exp; @@ -1577,7 +1577,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), /* Unknown character, exit the loop */ break; } - shift= dot ? dot - str : 0; /* Right shift */ + shift= dot ? (int) (dot - str) : 0; /* Right shift */ addon= 0; exp: /* [ E [ ] ] */ diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index dd8d1395ad4..65e4182d564 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1001,7 +1001,7 @@ ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs __attribute__((unused)), *b++= (char) wc; } - res= my_strntoull10rnd_8bit(cs, buf, b - buf, unsign_fl, endptr, err); + res= my_strntoull10rnd_8bit(cs, buf, (uint) (b - buf), unsign_fl, endptr, err); *endptr= (char*) nptr + 2 * (uint) (*endptr- buf); return res; } diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index 93d228a1954..c1c68b48b13 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -107,7 +107,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) char *par = va_arg(ap, char *); DBUG_ASSERT(to <= end); if (to + abs(width) + 1 > end) - width= end - to - 1; /* sign doesn't matter */ + width= (uint) (end - to - 1); /* sign doesn't matter */ memmove(to, par, abs(width)); to+= width; continue; diff --git a/strings/xml.c b/strings/xml.c index 5f8283f2ea8..850d22da352 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -147,7 +147,7 @@ static int my_xml_enter(MY_XML_PARSER *st, const char *str, uint len) memcpy(st->attrend,str,len); st->attrend+=len; st->attrend[0]='\0'; - return st->enter ? st->enter(st,st->attr,st->attrend-st->attr) : MY_XML_OK; + return st->enter ? st->enter(st,st->attr, (uint) (st->attrend - st->attr)) : MY_XML_OK; } @@ -179,7 +179,7 @@ static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen) return MY_XML_ERROR; } - rc = p->leave_xml ? p->leave_xml(p,p->attr,p->attrend-p->attr) : MY_XML_OK; + rc = p->leave_xml ? p->leave_xml(p,p->attr, (uint) (p->attrend - p->attr)) : MY_XML_OK; *e='\0'; p->attrend=e; diff --git a/tests/bug25714.c b/tests/bug25714.c index 88485aa1962..b9c0708f352 100644 --- a/tests/bug25714.c +++ b/tests/bug25714.c @@ -54,14 +54,14 @@ int main (int argc, char **argv) printf("%s\n", mysql_error(&conn)); } - OK = mysql_real_query (&conn, query4, strlen(query4)); + OK = mysql_real_query (&conn, query4, (uint) strlen(query4)); assert(0 == OK); printf("%ld inserted\n", (long) mysql_insert_id(&conn)); - OK = mysql_real_query (&conn, query5, strlen(query5)); + OK = mysql_real_query (&conn, query5, (uint) strlen(query5)); assert(0 == OK); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 0fddffebf82..e873336dac9 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -256,7 +256,7 @@ static MYSQL_STMT *STDCALL mysql_simple_prepare(MYSQL *mysql_arg, const char *query) { MYSQL_STMT *stmt= mysql_stmt_init(mysql_arg); - if (stmt && mysql_stmt_prepare(stmt, query, strlen(query))) + if (stmt && mysql_stmt_prepare(stmt, query, (uint) strlen(query))) { mysql_stmt_close(stmt); return 0; @@ -436,7 +436,7 @@ static void my_print_result_metadata(MYSQL_RES *result) for(i= 0; i< field_count; i++) { field= mysql_fetch_field(result); - j= strlen(field->name); + j= (uint) strlen(field->name); if (j < field->max_length) j= field->max_length; if (j < 4 && !IS_NOT_NULL(field->flags)) @@ -959,7 +959,7 @@ void stmt_fetch_init(Stmt_fetch *fetch, unsigned stmt_no_arg, fetch->handle= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(fetch->handle, fetch->query, strlen(fetch->query)); + rc= mysql_stmt_prepare(fetch->handle, fetch->query, (uint) strlen(fetch->query)); check_execute(fetch->handle, rc); /* @@ -1069,7 +1069,7 @@ my_bool fetch_n(const char **query_list, unsigned query_count, for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch) { /* Init will exit(1) in case of error */ - stmt_fetch_init(fetch, fetch - fetch_array, + stmt_fetch_init(fetch, (uint) (fetch - fetch_array), query_list[fetch - fetch_array]); } @@ -2341,7 +2341,7 @@ static void test_ps_conj_select() int_data= 1; strmov(str_data, "hh"); - str_length= strlen(str_data); + str_length= (uint) strlen(str_data); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -2852,9 +2852,9 @@ static void test_long_data() data= (char *)"Michael"; /* supply data in pieces */ - rc= mysql_stmt_send_long_data(stmt, 1, data, strlen(data)); + rc= mysql_stmt_send_long_data(stmt, 1, data, (uint) strlen(data)); data= (char *)" 'Monty' Widenius"; - rc= mysql_stmt_send_long_data(stmt, 1, data, strlen(data)); + rc= mysql_stmt_send_long_data(stmt, 1, data, (uint) strlen(data)); check_execute(stmt, rc); rc= mysql_stmt_send_long_data(stmt, 2, "Venu (venu@mysql.com)", 4); check_execute(stmt, rc); @@ -8430,7 +8430,7 @@ static void test_mem_overun() sprintf(field, "c%d int", i); strxmov(buffer, buffer, field, ", ", NullS); } - length= strlen(buffer); + length= (uint) strlen(buffer); buffer[length-2]= ')'; buffer[--length]= '\0'; @@ -8442,7 +8442,7 @@ static void test_mem_overun() { strxmov(buffer, buffer, "1, ", NullS); } - length= strlen(buffer); + length= (uint) strlen(buffer); buffer[length-2]= ')'; buffer[--length]= '\0'; @@ -8970,7 +8970,7 @@ static void test_bug1500() data= "Dogs"; my_bind[0].buffer_type= MYSQL_TYPE_STRING; my_bind[0].buffer= (void *) data; - my_bind[0].buffer_length= strlen(data); + my_bind[0].buffer_length= (uint) strlen(data); my_bind[0].is_null= 0; my_bind[0].length= 0; @@ -8995,7 +8995,7 @@ static void test_bug1500() data= "Grave"; my_bind[0].buffer_type= MYSQL_TYPE_STRING; my_bind[0].buffer= (void *) data; - my_bind[0].buffer_length= strlen(data); + my_bind[0].buffer_length= (uint) strlen(data); rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); @@ -9026,7 +9026,7 @@ static void test_bug1946() stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc= mysql_real_query(mysql, query, strlen(query)); + rc= mysql_real_query(mysql, query, (uint) strlen(query)); DIE_UNLESS(rc != 0); if (!opt_silent) fprintf(stdout, "Got error (as expected):\n"); @@ -10042,7 +10042,7 @@ static void test_bug3035() myheader("test_bug3035"); stmt_text= "DROP TABLE IF EXISTS t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "CREATE TABLE t1 (i8 TINYINT, ui8 TINYINT UNSIGNED, " @@ -10050,7 +10050,7 @@ static void test_bug3035() "i32 INT, ui32 INT UNSIGNED, " "i64 BIGINT, ui64 BIGINT UNSIGNED, " "id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); bzero((char*) bind_array, sizeof(bind_array)); @@ -10091,7 +10091,7 @@ static void test_bug3035() stmt_text= "INSERT INTO t1 (i8, ui8, i16, ui16, i32, ui32, i64, ui64) " "VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); mysql_stmt_bind_param(stmt, bind_array); @@ -10124,7 +10124,7 @@ static void test_bug3035() "cast(ui64 as signed), ui64, cast(ui64 as signed)" "FROM t1 ORDER BY id ASC"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -10194,7 +10194,7 @@ static void test_bug3035() mysql_stmt_close(stmt); stmt_text= "DROP TABLE t1"; - mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); } @@ -10257,7 +10257,7 @@ static void test_bug1664() stmt= mysql_stmt_init(mysql); check_stmt(stmt); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); verify_param_count(stmt, 2); @@ -10266,7 +10266,7 @@ static void test_bug1664() my_bind[0].buffer_type= MYSQL_TYPE_STRING; my_bind[0].buffer= (void *)str_data; - my_bind[0].buffer_length= strlen(str_data); + my_bind[0].buffer_length= (uint) strlen(str_data); my_bind[1].buffer= (void *)&int_data; my_bind[1].buffer_type= MYSQL_TYPE_LONG; @@ -10281,7 +10281,7 @@ static void test_bug1664() not break following execution. */ data= ""; - rc= mysql_stmt_send_long_data(stmt, 0, data, strlen(data)); + rc= mysql_stmt_send_long_data(stmt, 0, data, (uint) strlen(data)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -10295,7 +10295,7 @@ static void test_bug1664() /* This should pass OK */ data= (char *)"Data"; - rc= mysql_stmt_send_long_data(stmt, 0, data, strlen(data)); + rc= mysql_stmt_send_long_data(stmt, 0, data, (uint) strlen(data)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -10332,7 +10332,7 @@ static void test_bug1664() */ data= (char *)"SomeOtherData"; - rc= mysql_stmt_send_long_data(stmt, 0, data, strlen(data)); + rc= mysql_stmt_send_long_data(stmt, 0, data, (uint) strlen(data)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -10350,13 +10350,13 @@ static void test_bug1664() /* Now let us test how mysql_stmt_reset works. */ stmt= mysql_stmt_init(mysql); check_stmt(stmt); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); data= (char *)"SomeData"; - rc= mysql_stmt_send_long_data(stmt, 0, data, strlen(data)); + rc= mysql_stmt_send_long_data(stmt, 0, data, (uint) strlen(data)); check_execute(stmt, rc); rc= mysql_stmt_reset(stmt); @@ -10482,7 +10482,7 @@ static void test_ps_i18n() myheader("test_ps_i18n"); stmt_text= "DROP TABLE IF EXISTS t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); /* @@ -10493,37 +10493,37 @@ static void test_ps_i18n() stmt_text= "CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255))"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "SET CHARACTER_SET_CLIENT=koi8r, " "CHARACTER_SET_CONNECTION=cp1251, " "CHARACTER_SET_RESULTS=koi8r"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); bzero((char*) bind_array, sizeof(bind_array)); bind_array[0].buffer_type= MYSQL_TYPE_STRING; bind_array[0].buffer= (void *) koi8; - bind_array[0].buffer_length= strlen(koi8); + bind_array[0].buffer_length= (uint) strlen(koi8); bind_array[1].buffer_type= MYSQL_TYPE_STRING; bind_array[1].buffer= (void *) koi8; - bind_array[1].buffer_length= strlen(koi8); + bind_array[1].buffer_length= (uint) strlen(koi8); stmt= mysql_stmt_init(mysql); check_stmt(stmt); stmt_text= "INSERT INTO t1 (c1, c2) VALUES (?, ?)"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); mysql_stmt_bind_param(stmt, bind_array); - mysql_stmt_send_long_data(stmt, 0, koi8, strlen(koi8)); + mysql_stmt_send_long_data(stmt, 0, koi8, (uint) strlen(koi8)); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -10531,7 +10531,7 @@ static void test_ps_i18n() stmt_text= "SELECT c1, c2 FROM t1"; /* c1 and c2 are binary so no conversion will be done on select */ - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -10559,7 +10559,7 @@ static void test_ps_i18n() DIE_UNLESS(rc == MYSQL_NO_DATA); stmt_text= "DROP TABLE IF EXISTS t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); /* @@ -10572,26 +10572,26 @@ static void test_ps_i18n() stmt_text= "CREATE TABLE t1 (c1 VARCHAR(255) CHARACTER SET cp1251, " "c2 VARCHAR(255) CHARACTER SET cp1251)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "INSERT INTO t1 (c1, c2) VALUES (?, ?)"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); /* this data must be converted */ bind_array[0].buffer_type= MYSQL_TYPE_STRING; bind_array[0].buffer= (void *) koi8; - bind_array[0].buffer_length= strlen(koi8); + bind_array[0].buffer_length= (uint) strlen(koi8); bind_array[1].buffer_type= MYSQL_TYPE_STRING; bind_array[1].buffer= (void *) koi8; - bind_array[1].buffer_length= strlen(koi8); + bind_array[1].buffer_length= (uint) strlen(koi8); mysql_stmt_bind_param(stmt, bind_array); - mysql_stmt_send_long_data(stmt, 0, koi8, strlen(koi8)); + mysql_stmt_send_long_data(stmt, 0, koi8, (uint) strlen(koi8)); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -10599,15 +10599,15 @@ static void test_ps_i18n() /* this data must not be converted */ bind_array[0].buffer_type= MYSQL_TYPE_BLOB; bind_array[0].buffer= (void *) cp1251; - bind_array[0].buffer_length= strlen(cp1251); + bind_array[0].buffer_length= (uint) strlen(cp1251); bind_array[1].buffer_type= MYSQL_TYPE_BLOB; bind_array[1].buffer= (void *) cp1251; - bind_array[1].buffer_length= strlen(cp1251); + bind_array[1].buffer_length= (uint) strlen(cp1251); mysql_stmt_bind_param(stmt, bind_array); - mysql_stmt_send_long_data(stmt, 0, cp1251, strlen(cp1251)); + mysql_stmt_send_long_data(stmt, 0, cp1251, (uint) strlen(cp1251)); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -10617,7 +10617,7 @@ static void test_ps_i18n() stmt_text= "SELECT c1, c2 FROM t1"; /* c1 and c2 are binary so no conversion will be done on select */ - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -10644,10 +10644,10 @@ static void test_ps_i18n() mysql_stmt_close(stmt); stmt_text= "DROP TABLE t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "SET NAMES DEFAULT"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); } @@ -10668,22 +10668,22 @@ static void test_bug3796() /* Create and fill test table */ stmt_text= "DROP TABLE IF EXISTS t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "CREATE TABLE t1 (a INT, b VARCHAR(30))"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "INSERT INTO t1 VALUES(1, 'ONE'), (2, 'TWO')"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); /* Create statement handle and prepare it with select */ stmt= mysql_stmt_init(mysql); stmt_text= "SELECT concat(?, b) FROM t1"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); /* Bind input buffers */ @@ -10691,7 +10691,7 @@ static void test_bug3796() my_bind[0].buffer_type= MYSQL_TYPE_STRING; my_bind[0].buffer= (void *) concat_arg0; - my_bind[0].buffer_length= strlen(concat_arg0); + my_bind[0].buffer_length= (uint) strlen(concat_arg0); mysql_stmt_bind_param(stmt, my_bind); @@ -10728,7 +10728,7 @@ static void test_bug3796() mysql_stmt_close(stmt); stmt_text= "DROP TABLE IF EXISTS t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); } @@ -10750,7 +10750,7 @@ static void test_bug4026() stmt= mysql_stmt_init(mysql); stmt_text= "SELECT ?, ?"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); /* Bind input buffers */ @@ -10828,7 +10828,7 @@ static void test_bug4079() stmt= mysql_stmt_init(mysql); stmt_text= "SELECT 1 < (SELECT a FROM t1)"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); /* Execute the select statement */ @@ -10867,7 +10867,7 @@ static void test_bug4236() /* mysql_stmt_execute() of statement with statement id= 0 crashed server */ stmt_text= "SELECT 1"; /* We need to prepare statement to pass by possible check in libmysql */ - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); /* Hack to check that server works OK if statement wasn't found */ backup.stmt_id= stmt->stmt_id; @@ -10899,7 +10899,7 @@ static void test_bug4030() stmt= mysql_stmt_init(mysql); stmt_text= "SELECT '23:59:59.123456', '2003-12-31', " "'2003-12-31 23:59:59.123456'"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -11010,7 +11010,7 @@ static void test_view() myquery(rc); stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); strmov(str_data, "TEST"); @@ -11064,7 +11064,7 @@ static void test_view_where() myquery(rc); stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); for (i= 0; i < 3; i++) @@ -11146,7 +11146,7 @@ static void test_view_2where() length[i] = 1; } stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); rc= mysql_stmt_bind_param(stmt, my_bind); @@ -11197,7 +11197,7 @@ static void test_view_star() } stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); rc= mysql_stmt_bind_param(stmt, my_bind); @@ -11245,11 +11245,11 @@ static void test_view_insert() myquery(rc); insert_stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(insert_stmt, query, strlen(query)); + rc= mysql_stmt_prepare(insert_stmt, query, (uint) strlen(query)); check_execute(insert_stmt, rc); query= "select * from t1"; select_stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(select_stmt, query, strlen(query)); + rc= mysql_stmt_prepare(select_stmt, query, (uint) strlen(query)); check_execute(select_stmt, rc); bzero((char*) my_bind, sizeof(my_bind)); @@ -11304,7 +11304,7 @@ static void test_left_join_view() rc= mysql_query(mysql,"create view v1 (x) as select a from t1 where a > 1"); myquery(rc); stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); for (i= 0; i < 3; i++) @@ -11372,7 +11372,7 @@ static void test_view_insert_fields() my_bind[i].length= &l[i]; } stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); @@ -11383,7 +11383,7 @@ static void test_view_insert_fields() query= "select * from t1"; stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -11409,20 +11409,20 @@ static void test_bug5126() myheader("test_bug5126"); stmt_text= "DROP TABLE IF EXISTS t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "CREATE TABLE t1 (a mediumint, b int)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "INSERT INTO t1 VALUES (8386608, 1)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt= mysql_stmt_init(mysql); stmt_text= "SELECT a, b FROM t1"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -11457,20 +11457,20 @@ static void test_bug4231() myheader("test_bug4231"); stmt_text= "DROP TABLE IF EXISTS t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "CREATE TABLE t1 (a int)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "INSERT INTO t1 VALUES (1)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt= mysql_stmt_init(mysql); stmt_text= "SELECT a FROM t1 WHERE ? = ?"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); /* Bind input buffers */ @@ -11514,7 +11514,7 @@ static void test_bug4231() mysql_stmt_close(stmt); stmt_text= "DROP TABLE t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); } @@ -11543,7 +11543,7 @@ static void test_bug5399() { sprintf(buff, "select %d", (int) (stmt - stmt_list)); *stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(*stmt, buff, strlen(buff)); + rc= mysql_stmt_prepare(*stmt, buff, (uint) strlen(buff)); check_execute(*stmt, rc); mysql_stmt_bind_result(*stmt, my_bind); } @@ -11620,7 +11620,7 @@ static void test_bug5194() myheader("test_bug5194"); stmt_text= "drop table if exists t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); stmt_text= "create table if not exists t1" "(c1 float, c2 float, c3 float, c4 float, c5 float, c6 float, " @@ -11665,7 +11665,7 @@ static void test_bug5194() "c235 float, c236 float, c237 float, c238 float, c239 float, c240 float, " "c241 float, c242 float, c243 float, c244 float, c245 float, c246 float, " "c247 float, c248 float, c249 float, c250 float)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); my_bind= (MYSQL_BIND*) malloc(MAX_PARAM_COUNT * sizeof(MYSQL_BIND)); @@ -11692,7 +11692,7 @@ static void test_bug5194() for (i= 1; i < COLUMN_COUNT; ++i) strcat(param_str, "?, "); strcat(param_str, "?)"); - param_str_length= strlen(param_str); + param_str_length= (uint) strlen(param_str); /* setup bind array */ bzero((char*) my_bind, MAX_PARAM_COUNT * sizeof(MYSQL_BIND)); @@ -11723,7 +11723,7 @@ static void test_bug5194() } *query_ptr= '\0'; - rc= mysql_stmt_prepare(stmt, query, query_ptr - query); + rc= mysql_stmt_prepare(stmt, query, (uint) (query_ptr - query)); if (rc && nrows * COLUMN_COUNT > uint16_max) { if (!opt_silent) @@ -11752,7 +11752,7 @@ static void test_bug5194() free(query); free(param_str); stmt_text= "drop table t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); } @@ -11767,7 +11767,7 @@ static void test_bug5315() stmt_text= "SELECT 1"; stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); DIE_UNLESS(rc == 0); mysql_change_user(mysql, opt_user, opt_password, current_db); rc= mysql_stmt_execute(stmt); @@ -11780,7 +11780,7 @@ static void test_bug5315() /* check that connection is OK */ mysql_stmt_close(stmt); stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); DIE_UNLESS(rc == 0); rc= mysql_stmt_execute(stmt); DIE_UNLESS(rc == 0); @@ -11803,13 +11803,13 @@ static void test_bug6049() stmt_text= "SELECT MAKETIME(-25, 12, 12)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); res= mysql_store_result(mysql); row= mysql_fetch_row(res); stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -11852,13 +11852,13 @@ static void test_bug6058() stmt_text= "SELECT CAST('0000-00-00' AS DATE)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); res= mysql_store_result(mysql); row= mysql_fetch_row(res); stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -11896,7 +11896,7 @@ static void test_bug6059() stmt_text= "SELECT 'foo' INTO OUTFILE 'x.3'"; stmt= mysql_stmt_init(mysql); - (void) mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + (void) mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); DIE_UNLESS(mysql_stmt_field_count(stmt) == 0); mysql_stmt_close(stmt); } @@ -11913,13 +11913,13 @@ static void test_bug6046() myheader("test_bug6046"); stmt_text= "DROP TABLE IF EXISTS t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "CREATE TABLE t1 (a int, b int)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "INSERT INTO t1 VALUES (1,1),(2,2),(3,1),(4,2)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt= mysql_stmt_init(mysql); @@ -11927,7 +11927,7 @@ static void test_bug6046() stmt_text= "SELECT t1.a FROM t1 NATURAL JOIN t1 as X1 " "WHERE t1.b > ? ORDER BY t1.a"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); b= 1; @@ -12063,7 +12063,7 @@ static void test_bug6096() myheader("test_bug6096"); stmt_text= "drop table if exists t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); mysql_query(mysql, "set sql_mode=''"); @@ -12073,24 +12073,24 @@ static void test_bug6096() " c_double double, c_varchar varchar(20), " " c_char char(20), c_time time, c_date date, " " c_datetime datetime)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "insert into t1 values (-100, -20000, 30000000, 4, 8, 1.0, " "2.0, 'abc', 'def', now(), now(), now())"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "select * from t1"; /* Run select in prepared and non-prepared mode and compare metadata */ - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); query_result= mysql_store_result(mysql); query_field_list= mysql_fetch_fields(query_result); query_field_count= mysql_num_fields(query_result); stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -12147,7 +12147,7 @@ static void test_bug6096() mysql_free_result(query_result); mysql_free_result(stmt_metadata); stmt_text= "drop table t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); } @@ -12168,12 +12168,12 @@ static void test_datetime_ranges() myheader("test_datetime_ranges"); stmt_text= "drop table if exists t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "create table t1 (year datetime, month datetime, day datetime, " "hour datetime, min datetime, sec datetime)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt= mysql_simple_prepare(mysql, @@ -12212,7 +12212,7 @@ static void test_datetime_ranges() mysql_stmt_close(stmt); stmt_text= "delete from t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt= mysql_simple_prepare(mysql, "INSERT INTO t1 (year, month, day) " @@ -12240,11 +12240,11 @@ static void test_datetime_ranges() mysql_stmt_close(stmt); stmt_text= "drop table t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "create table t1 (day_ovfl time, day time, hour time, min time, sec time)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt= mysql_simple_prepare(mysql, @@ -12281,7 +12281,7 @@ static void test_datetime_ranges() mysql_stmt_close(stmt); stmt_text= "drop table t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); } @@ -12307,7 +12307,7 @@ static void test_bug4172() stmt= mysql_stmt_init(mysql); stmt_text= "SELECT f, d, e FROM t1"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -12332,7 +12332,7 @@ static void test_bug4172() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); res= mysql_store_result(mysql); row= mysql_fetch_row(res); @@ -12363,20 +12363,20 @@ static void test_conversion() myheader("test_conversion"); stmt_text= "DROP TABLE IF EXISTS t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "CREATE TABLE t1 (a TEXT) DEFAULT CHARSET latin1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "SET character_set_connection=utf8, character_set_client=utf8, " " character_set_results=latin1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt= mysql_stmt_init(mysql); stmt_text= "INSERT INTO t1 (a) VALUES (?)"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); bzero((char*) my_bind, sizeof(my_bind)); @@ -12394,7 +12394,7 @@ static void test_conversion() check_execute(stmt, rc); stmt_text= "SELECT a FROM t1"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -12411,10 +12411,10 @@ static void test_conversion() mysql_stmt_close(stmt); stmt_text= "DROP TABLE t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "SET NAMES DEFAULT"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); } @@ -12430,16 +12430,16 @@ static void test_rewind(void) myheader("test_rewind"); stmt_text= "CREATE TABLE t1 (a int)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "INSERT INTO t1 VALUES(2),(3),(4)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt= mysql_stmt_init(mysql); stmt_text= "SELECT * FROM t1"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); bzero((char*) &my_bind, sizeof(MYSQL_BIND)); @@ -12474,7 +12474,7 @@ static void test_rewind(void) DIE_UNLESS(rc == MYSQL_NO_DATA); stmt_text= "DROP TABLE t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); rc= mysql_stmt_free_result(stmt); rc= mysql_stmt_close(stmt); @@ -12502,7 +12502,7 @@ static void test_truncation() "d double, d_1 double, ch char(30), ch_1 char(30), " "tx text, tx_1 text, ch_2 char(30) " ")"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "insert into t1 VALUES (" "-10, " /* i8 */ @@ -12520,7 +12520,7 @@ static void test_truncation() "'12345.67 ', " /* tx_1 */ "'12345.67abc'" /* ch_2 */ ")"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "select i8 c1, i8 c2, ui8 c3, i16_1 c4, ui16 c5, " @@ -12530,7 +12530,7 @@ static void test_truncation() "from t1"; stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -12738,7 +12738,7 @@ static void test_truncation_option() stmt_text= "select -1"; stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -12784,7 +12784,7 @@ static void test_bug6761(void) myheader("test_bug6761"); stmt_text= "CREATE TABLE t1 (a int, b char(255), c decimal)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); res= mysql_list_fields(mysql, "t1", "%"); @@ -12792,7 +12792,7 @@ static void test_bug6761(void) mysql_free_result(res); stmt_text= "DROP TABLE t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); } @@ -12812,17 +12812,17 @@ static void test_bug8330() stmt_text= "drop table if exists t1"; /* in case some previos test failed */ - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "create table t1 (a int, b int)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); bzero((char*) my_bind, sizeof(my_bind)); for (i=0; i < 2; i++) { stmt[i]= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt[i], query, strlen(query)); + rc= mysql_stmt_prepare(stmt[i], query, (uint) strlen(query)); check_execute(stmt[i], rc); my_bind[i].buffer_type= MYSQL_TYPE_LONG; @@ -12843,7 +12843,7 @@ static void test_bug8330() mysql_stmt_close(stmt[1]); stmt_text= "drop table t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); } @@ -13028,7 +13028,7 @@ static void test_bug8378() sprintf(buf, "SELECT '%s'", out); - rc=mysql_real_query(lmysql, buf, strlen(buf)); + rc=mysql_real_query(lmysql, buf, (uint) strlen(buf)); myquery(rc); mysql_close(lmysql); @@ -13045,19 +13045,19 @@ static void test_bug8722() myheader("test_bug8722"); /* Prepare test data */ stmt_text= "drop table if exists t1, v1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "CREATE TABLE t1 (c1 varchar(10), c2 varchar(10), c3 varchar(10)," " c4 varchar(10), c5 varchar(10), c6 varchar(10)," " c7 varchar(10), c8 varchar(10), c9 varchar(10)," "c10 varchar(10))"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "INSERT INTO t1 VALUES (1,2,3,4,5,6,7,8,9,10)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "CREATE VIEW v1 AS SELECT * FROM t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); /* Note: if you uncomment following block everything works fine */ /* @@ -13068,11 +13068,11 @@ static void test_bug8722() stmt= mysql_stmt_init(mysql); stmt_text= "select * from v1"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); mysql_stmt_close(stmt); stmt_text= "drop table if exists t1, v1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); } @@ -13083,7 +13083,7 @@ MYSQL_STMT *open_cursor(const char *query) const ulong type= (ulong)CURSOR_TYPE_READ_ONLY; MYSQL_STMT *stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type); @@ -13134,7 +13134,7 @@ static void test_bug9159() myquery(rc); stmt= mysql_stmt_init(mysql); - mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void *)&type); mysql_stmt_execute(stmt); @@ -13376,7 +13376,7 @@ static void test_bug9643() (void*) &prefetch_rows); check_execute(stmt, rc); stmt_text= "select * from t1"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); bzero((char*) my_bind, sizeof(my_bind)); @@ -13432,7 +13432,7 @@ static void test_bug11111() stmt= mysql_stmt_init(mysql); - mysql_stmt_prepare(stmt, query, strlen(query)); + mysql_stmt_prepare(stmt, query, (uint) strlen(query)); mysql_stmt_execute(stmt); bzero((char*) my_bind, sizeof(my_bind)); @@ -13490,7 +13490,7 @@ static void test_bug10729() rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type); check_execute(stmt, rc); stmt_text= "select name from t1"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); bzero((char*) my_bind, sizeof(my_bind)); @@ -13600,7 +13600,7 @@ static void test_bug10736() rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type); check_execute(stmt, rc); stmt_text= "select name from t1 where name=(select name from t1 where id=2)"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); bzero((char*) my_bind, sizeof(my_bind)); @@ -13650,7 +13650,7 @@ static void test_bug10794() "name varchar(20) not null)"); stmt= mysql_stmt_init(mysql); stmt_text= "insert into t1 (id, name) values (?, ?)"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); bzero((char*) my_bind, sizeof(my_bind)); my_bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -13664,12 +13664,12 @@ static void test_bug10794() { id_val= (i+1)*10; sprintf(a, "a%d", i); - a_len= strlen(a); /* safety against broken sprintf */ + a_len= (uint) strlen(a); /* safety against broken sprintf */ rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); } stmt_text= "select name from t1"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); type= (ulong) CURSOR_TYPE_READ_ONLY; mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); stmt1= mysql_stmt_init(mysql); @@ -13691,7 +13691,7 @@ static void test_bug10794() mysql_stmt_free_result(stmt); mysql_stmt_reset(stmt); stmt_text= "select name from t1 where id=10"; - rc= mysql_stmt_prepare(stmt1, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt1, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt1, rc); rc= mysql_stmt_bind_result(stmt1, my_bind); check_execute(stmt1, rc); @@ -13741,7 +13741,7 @@ static void test_bug11172() myquery(rc); stmt= mysql_stmt_init(mysql); stmt_text= "SELECT id, hired FROM t1 WHERE hired=?"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); type= (ulong) CURSOR_TYPE_READ_ONLY; @@ -13813,7 +13813,7 @@ static void test_bug11656() stmt_text= "select distinct test_kind, test_id from t1 " "where server in (?, ?)"; stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); type= (ulong) CURSOR_TYPE_READ_ONLY; mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); @@ -13825,7 +13825,7 @@ static void test_bug11656() { my_bind[i].buffer_type= MYSQL_TYPE_STRING; my_bind[i].buffer= (gptr *)&buf[i]; - my_bind[i].buffer_length= strlen(buf[i]); + my_bind[i].buffer_length= (uint) strlen(buf[i]); } mysql_stmt_bind_param(stmt, my_bind); @@ -13930,7 +13930,7 @@ static void test_bug11183() stmt= mysql_stmt_init(mysql); DIE_UNLESS(stmt != 0); - rc= mysql_stmt_prepare(stmt, bug_statement, strlen(bug_statement)); + rc= mysql_stmt_prepare(stmt, bug_statement, (uint) strlen(bug_statement)); check_execute(stmt, rc); rc= mysql_query(mysql, "drop table t1"); @@ -13976,7 +13976,7 @@ static void test_bug11037() stmt_text= "select id FROM t1"; stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); /* expected error */ rc = mysql_stmt_fetch(stmt); @@ -14044,7 +14044,7 @@ static void test_bug10760() con1: insert into t1 (id) values (1) */ stmt_text= "select id from t1 order by 1"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -14077,7 +14077,7 @@ static void test_bug10760() else { stmt_text= "select id from t1 order by 1"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_query(mysql, "alter table t1 engine=InnoDB"); @@ -14180,7 +14180,7 @@ static void test_bug11909() myheader("test_bug11909"); stmt_text= "drop table if exists t1"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "create table t1 (" @@ -14189,7 +14189,7 @@ static void test_bug11909() " workdept varchar(6) not null, salary double not null," " bonus float not null, primary key (empno)" ") default charset=latin1 collate=latin1_bin"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "insert into t1 values " @@ -14198,7 +14198,7 @@ static void test_bug11909() "(30, 'SALLY', 'A', 'KWAN', 'C01', 38250, 800)," "(50, 'JOHN', 'B', 'GEYER', 'E01', 40175, 800), " "(60, 'IRVING', 'F', 'STERN', 'D11', 32250, 500)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); /* ****** Begin of trace ****** */ @@ -14296,7 +14296,7 @@ static void test_bug11901() myheader("test_bug11901"); stmt_text= "drop table if exists t1, t2"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "create table t1 (" @@ -14306,7 +14306,7 @@ static void test_bug11901() " bonus float not null, primary key (empno), " " unique key (workdept, empno) " ") default charset=latin1 collate=latin1_bin"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "insert into t1 values " @@ -14343,7 +14343,7 @@ static void test_bug11901() "(330, 'WING', '', 'LEE', 'E21', 25370, 500), " "(340, 'JASON', 'R', 'GOUNOT', 'E21', 23840, 500)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "create table t2 (" @@ -14352,7 +14352,7 @@ static void test_bug11901() " admrdept varchar(6) not null, refcntd int(11) not null," " refcntu int(11) not null, primary key (deptno)" ") default charset=latin1 collate=latin1_bin"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); stmt_text= "insert into t2 values " @@ -14365,7 +14365,7 @@ static void test_bug11901() "('E01', 'SUPPORT SERVICES', 50, '', 'A00', 0, 0), " "('E11', 'OPERATIONS', 90, '', 'E01', 0, 0), " "('E21', 'SOFTWARE SUPPORT', 100,'', 'E01', 0, 0)"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + rc= mysql_real_query(mysql, stmt_text, (uint) strlen(stmt_text)); myquery(rc); /* ****** Begin of trace ****** */ @@ -14435,7 +14435,7 @@ static void test_bug11904() stmt_text= "SELECT id, MIN(name) FROM bug11904b GROUP BY id"; - rc= mysql_stmt_prepare(stmt1, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt1, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt1, rc); memset(my_bind, 0, sizeof(my_bind)); @@ -14511,14 +14511,14 @@ static void test_bug12243() stmt_text= "select a from t1"; - rc= mysql_stmt_prepare(stmt1, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt1, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt1, rc); rc= mysql_stmt_execute(stmt1); check_execute(stmt1, rc); rc= mysql_stmt_fetch(stmt1); check_execute(stmt1, rc); - rc= mysql_stmt_prepare(stmt2, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt2, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt2, rc); rc= mysql_stmt_execute(stmt2); check_execute(stmt2, rc); @@ -14624,7 +14624,7 @@ static void test_bug14210() stmt_text= "select a from t1"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); while ((rc= mysql_stmt_fetch(stmt)) == 0) @@ -14678,7 +14678,7 @@ static void test_bug13488() rc= mysql_stmt_attr_set(stmt1,STMT_ATTR_CURSOR_TYPE, (const void *)&type); check_execute(stmt1, rc); - rc= mysql_stmt_prepare(stmt1, query, strlen(query)); + rc= mysql_stmt_prepare(stmt1, query, (uint) strlen(query)); check_execute(stmt1, rc); rc= mysql_stmt_execute(stmt1); @@ -14733,7 +14733,7 @@ static void test_bug13524() rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); check_execute(stmt, rc); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -14792,7 +14792,7 @@ static void test_bug14845() rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); check_execute(stmt, rc); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -14828,7 +14828,7 @@ static void test_bug15510() stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -15000,7 +15000,7 @@ static void test_bug15613() /* II. Check SELECT metadata */ stmt_text= ("select t, tt, mt, lt, vl, vb, vu from t1"); - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); metadata= mysql_stmt_result_metadata(stmt); field= mysql_fetch_fields(metadata); if (!opt_silent) @@ -15194,7 +15194,7 @@ static void test_bug14169() myquery(rc); stmt= mysql_stmt_init(mysql); stmt_text= "select f2,group_concat(f1) from t1 group by f2"; - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + rc= mysql_stmt_prepare(stmt, stmt_text, (uint) strlen(stmt_text)); myquery(rc); res= mysql_stmt_result_metadata(stmt); field= mysql_fetch_fields(res); @@ -15437,7 +15437,7 @@ static void test_bug20152() myquery(rc); stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, query, strlen(query)); + rc= mysql_stmt_prepare(stmt, query, (uint) strlen(query)); check_execute(stmt, rc); rc= mysql_stmt_bind_param(stmt, my_bind); check_execute(stmt, rc); @@ -15482,11 +15482,11 @@ static void test_bug15752() printf("Unable connect to MySQL server: %s\n", mysql_error(&mysql_local)); DIE_UNLESS(0); } - rc= mysql_real_query(&mysql_local, query, strlen(query)); + rc= mysql_real_query(&mysql_local, query, (uint) strlen(query)); myquery(rc); mysql_free_result(mysql_store_result(&mysql_local)); - rc= mysql_real_query(&mysql_local, query, strlen(query)); + rc= mysql_real_query(&mysql_local, query, (uint) strlen(query)); DIE_UNLESS(rc && mysql_errno(&mysql_local) == CR_COMMANDS_OUT_OF_SYNC); if (! opt_silent) @@ -15501,7 +15501,7 @@ static void test_bug15752() /* The second problem is not reproducible: add the test case */ for (i = 0; i < ITERATION_COUNT; i++) { - if (mysql_real_query(&mysql_local, query, strlen(query))) + if (mysql_real_query(&mysql_local, query, (uint) strlen(query))) { printf("\ni=%d %s failed: %s\n", i, query, mysql_error(&mysql_local)); break; @@ -15548,7 +15548,7 @@ static void test_bug21206() for (fetch= fetch_array; fetch < fetch_array + cursor_count; ++fetch) { /* Init will exit(1) in case of error */ - stmt_fetch_init(fetch, fetch - fetch_array, query); + stmt_fetch_init(fetch, (uint) (fetch - fetch_array), query); } for (fetch= fetch_array; fetch < fetch_array + cursor_count; ++fetch) @@ -15643,7 +15643,7 @@ static void test_bug23383() stmt= mysql_stmt_init(mysql); DIE_UNLESS(stmt != 0); - rc= mysql_stmt_prepare(stmt, insert_query, strlen(insert_query)); + rc= mysql_stmt_prepare(stmt, insert_query, (uint) strlen(insert_query)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -15656,7 +15656,7 @@ static void test_bug23383() row_count= mysql_stmt_affected_rows(stmt); DIE_UNLESS(row_count == (my_ulonglong)-1); - rc= mysql_stmt_prepare(stmt, update_query, strlen(update_query)); + rc= mysql_stmt_prepare(stmt, update_query, (uint) strlen(update_query)); check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); @@ -15722,7 +15722,7 @@ static void test_bug21635() rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)"); myquery(rc); - rc= mysql_real_query(mysql, query, query_end - query); + rc= mysql_real_query(mysql, query, (uint) (query_end - query)); myquery(rc); result= mysql_use_result(mysql); diff --git a/vio/viosocket.c b/vio/viosocket.c index 84fdd6f57e4..13fbf5d98d8 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -67,7 +67,7 @@ int vio_read_buff(Vio *vio, gptr buf, int size) if (vio->read_pos < vio->read_end) { - rc= min(vio->read_end - vio->read_pos, size); + rc= min((int) (vio->read_end - vio->read_pos), size); memcpy(buf, vio->read_pos, rc); vio->read_pos+= rc; /* From cb6581d89459a4c45e9146a40e1f0119a2e8e325 Mon Sep 17 00:00:00 2001 From: Sergey Petrunia Date: Mon, 23 Feb 2009 19:16:48 +0300 Subject: [PATCH 02/88] - Backport @@optimizer_switch support from 6.0 - Add support for setting it as a server commandline argument - Add support for those switches: = no_index_merge = no_index_merge_union = no_index_merge_sort_union = no_index_merge_intersection mysql-test/r/index_merge_myisam.result: Testcases for index_merge related @@optimizer_switch flags. mysql-test/t/index_merge_myisam.test: Testcases for index_merge related @@optimizer_switch flags. sql/set_var.cc: - Backport @@optimizer_switch support from 6.0 - Add support for setting it as a server commandline argument sql/sql_class.h: - Backport @@optimizer_switch support from 6.0 sql/sql_select.h: - Backport @@optimizer_switch support from 6.0 --- mysql-test/r/index_merge_myisam.result | 117 +++++++++++++++++++++++++ mysql-test/t/index_merge_myisam.test | 107 ++++++++++++++++++++++ sql/mysql_priv.h | 6 ++ sql/mysqld.cc | 31 +++++++ sql/opt_range.cc | 65 +++++++++----- sql/set_var.cc | 52 +++++++++++ sql/set_var.h | 19 +++- sql/sql_class.h | 2 + sql/sql_select.h | 6 ++ 9 files changed, 382 insertions(+), 23 deletions(-) diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result index 19826aca43a..cc2110ced32 100644 --- a/mysql-test/r/index_merge_myisam.result +++ b/mysql-test/r/index_merge_myisam.result @@ -1391,3 +1391,120 @@ WHERE `RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND `TESTID`='' AND `UCCHECK`=''; drop table t1; +# +# @@optimizer_switch support and check +# +select @@optimizer_switch; +@@optimizer_switch + +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, c int, filler char(100), +key(a), key(b), key(c)); +insert into t1 select +A.a * B.a*10 + C.a*100, +A.a * B.a*10 + C.a*100, +A.a, +'filler' +from t0 A, t0 B, t0 C; +This should use union: +explain select * from t1 where a=1 or b=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 2 Using union(a,b); Using where +This should use ALL: +set optimizer_switch='no_index_merge'; +explain select * from t1 where a=1 or b=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a,b NULL NULL NULL 1000 Using where +This should use sort-union: +set optimizer_switch='no_index_merge_union'; +explain select * from t1 where a=1 or b=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 2 Using sort_union(a,b); Using where +This will use sort-union: +set optimizer_switch=''; +explain select * from t1 where a<1 or b <1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 38 Using sort_union(a,b); Using where +This should use ALL: +set optimizer_switch='no_index_merge_sort_union'; +explain select * from t1 where a<1 or b <1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a,b NULL NULL NULL 1000 Using where +This should use ALL: +set optimizer_switch='no_index_merge'; +explain select * from t1 where a<1 or b <1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a,b NULL NULL NULL 1000 Using where +This will use sort-union: +set optimizer_switch='no_index_merge_union'; +explain select * from t1 where a<1 or b <1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 38 Using sort_union(a,b); Using where +alter table t1 add d int, add key(d); +update t1 set d=a; +This will use sort_union: +set optimizer_switch=''; +explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b,c,d a,b 5,5 NULL 3 Using sort_union(a,b); Using where +And if we disable sort_union, union: +set optimizer_switch='no_index_merge_sort_union'; +explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b,c,d c,d 5,5 NULL 100 Using union(c,d); Using where +drop table t1; +create table t1 ( +a int, b int, c int, +filler1 char(200), filler2 char(200), +key(a),key(b),key(c) +); +insert into t1 +select A.a+10*B.a, A.a+10*B.a, A.a+10*B.a+100*C.a, 'foo', 'bar' +from t0 A, t0 B, t0 C, t0 D where D.a<5; +This should be intersect: +set optimizer_switch=''; +explain select * from t1 where a=10 and b=10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where +No intersect when index_merge is disabled: +set optimizer_switch='no_index_merge'; +explain select * from t1 where a=10 and b=10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a,b a 5 const 49 Using where +No intersect if it is disabled: +set optimizer_switch='no_index_merge_intersection'; +explain select * from t1 where a=10 and b=10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a,b a 5 const 49 Using where +Do intersect when union was disabled +set optimizer_switch='no_index_merge_union'; +explain select * from t1 where a=10 and b=10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where +Do intersect when sort_union was disabled +set optimizer_switch='no_index_merge_sort_union'; +explain select * from t1 where a=10 and b=10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where +This will use intersection inside a union: +set optimizer_switch=''; +explain select * from t1 where a=10 and b=10 or c=10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b,c a,b,c 5,5,5 NULL 6 Using union(intersect(a,b),c); Using where +Should be only union left: +set optimizer_switch='no_index_merge_intersection'; +explain select * from t1 where a=10 and b=10 or c=10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b,c a,c 5,5 NULL 54 Using union(a,c); Using where +This will switch to sort-union (intersection will be gone, too, +thats a known limitation: +set optimizer_switch='no_index_merge_union'; +explain select * from t1 where a=10 and b=10 or c=10; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge a,b,c a,c 5,5 NULL 54 Using sort_union(a,c); Using where +set optimizer_switch=default; +show variables like 'optimizer_switch'; +Variable_name Value +optimizer_switch +drop table t0, t1; diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test index 8fdda2b772b..13997cfd427 100644 --- a/mysql-test/t/index_merge_myisam.test +++ b/mysql-test/t/index_merge_myisam.test @@ -19,3 +19,110 @@ let $merge_table_support= 1; --source include/index_merge2.inc --source include/index_merge_2sweeps.inc --source include/index_merge_ror_cpk.inc + +--echo # +--echo # @@optimizer_switch support and check +--echo # +select @@optimizer_switch; + +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, c int, filler char(100), + key(a), key(b), key(c)); +insert into t1 select + A.a * B.a*10 + C.a*100, + A.a * B.a*10 + C.a*100, + A.a, + 'filler' +from t0 A, t0 B, t0 C; + +--echo This should use union: +explain select * from t1 where a=1 or b=1; + +--echo This should use ALL: +set optimizer_switch='no_index_merge'; +explain select * from t1 where a=1 or b=1; + +--echo This should use sort-union: +set optimizer_switch='no_index_merge_union'; +explain select * from t1 where a=1 or b=1; + +--echo This will use sort-union: +set optimizer_switch=''; +explain select * from t1 where a<1 or b <1; + +--echo This should use ALL: +set optimizer_switch='no_index_merge_sort_union'; +explain select * from t1 where a<1 or b <1; + + +--echo This should use ALL: +set optimizer_switch='no_index_merge'; +explain select * from t1 where a<1 or b <1; + +--echo This will use sort-union: +set optimizer_switch='no_index_merge_union'; +explain select * from t1 where a<1 or b <1; + +alter table t1 add d int, add key(d); +update t1 set d=a; + +--echo This will use sort_union: +set optimizer_switch=''; +explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4); + +--echo And if we disable sort_union, union: +set optimizer_switch='no_index_merge_sort_union'; +explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4); + +drop table t1; + +# Now test that intersection can be disabled +create table t1 ( + a int, b int, c int, + filler1 char(200), filler2 char(200), + key(a),key(b),key(c) +); + +insert into t1 +select A.a+10*B.a, A.a+10*B.a, A.a+10*B.a+100*C.a, 'foo', 'bar' +from t0 A, t0 B, t0 C, t0 D where D.a<5; + +--echo This should be intersect: +set optimizer_switch=''; +explain select * from t1 where a=10 and b=10; + +--echo No intersect when index_merge is disabled: +set optimizer_switch='no_index_merge'; +explain select * from t1 where a=10 and b=10; + +--echo No intersect if it is disabled: +set optimizer_switch='no_index_merge_intersection'; +explain select * from t1 where a=10 and b=10; + +--echo Do intersect when union was disabled +set optimizer_switch='no_index_merge_union'; +explain select * from t1 where a=10 and b=10; + +--echo Do intersect when sort_union was disabled +set optimizer_switch='no_index_merge_sort_union'; +explain select * from t1 where a=10 and b=10; + +# Now take union-of-intersection and see how we can disable parts of it +--echo This will use intersection inside a union: +set optimizer_switch=''; +explain select * from t1 where a=10 and b=10 or c=10; + +--echo Should be only union left: +set optimizer_switch='no_index_merge_intersection'; +explain select * from t1 where a=10 and b=10 or c=10; + +--echo This will switch to sort-union (intersection will be gone, too, +--echo thats a known limitation: +set optimizer_switch='no_index_merge_union'; +explain select * from t1 where a=10 and b=10 or c=10; + +set optimizer_switch=default; +show variables like 'optimizer_switch'; +drop table t0, t1; + diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 3fba9248940..21741bc2eaf 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -523,6 +523,12 @@ protected: #define MODE_NO_ENGINE_SUBSTITUTION (MODE_HIGH_NOT_PRECEDENCE*2) #define MODE_PAD_CHAR_TO_FULL_LENGTH (ULL(1) << 31) +/* @@optimizer_switch flags */ +#define OPTIMIZER_SWITCH_NO_INDEX_MERGE 1 +#define OPTIMIZER_SWITCH_NO_INDEX_MERGE_UNION 2 +#define OPTIMIZER_SWITCH_NO_INDEX_MERGE_SORT_UNION 4 +#define OPTIMIZER_SWITCH_NO_INDEX_MERGE_INTERSECT 8 + /* Replication uses 8 bytes to store SQL_MODE in the binary log. The day you use strictly more than 64 bits by adding one more define above, you should diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 88b923244e7..959a1e21fac 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -297,6 +297,24 @@ static const unsigned int sql_mode_names_len[]= TYPELIB sql_mode_typelib= { array_elements(sql_mode_names)-1,"", sql_mode_names, (unsigned int *)sql_mode_names_len }; + +static const char *optimizer_switch_names[]= +{ + "no_index_merge","no_index_merge_union","no_index_merge_sort_union", + "no_index_merge_intersection", NullS +}; +/* Corresponding defines are named OPTIMIZER_SWITCH_XXX */ +static const unsigned int optimizer_switch_names_len[]= +{ + sizeof("no_index_merge") - 1, + sizeof("no_index_merge_union") - 1, + sizeof("ni_index_merge_sort_union") - 1, + sizeof("no_index_merge_intersection") - 1 +}; +TYPELIB optimizer_switch_typelib= { array_elements(optimizer_switch_names)-1,"", + optimizer_switch_names, + (unsigned int *)optimizer_switch_names_len }; + static const char *tc_heuristic_recover_names[]= { "COMMIT", "ROLLBACK", NullS @@ -362,6 +380,7 @@ static ulong max_used_connections; static ulong my_bind_addr; /**< the address we bind to */ static volatile ulong cached_thread_count= 0; static const char *sql_mode_str= "OFF"; +static const char *optimizer_switch_str=""; static char *mysqld_user, *mysqld_chroot, *log_error_file_ptr; static char *opt_init_slave, *language_ptr, *opt_init_connect; static char *default_character_set_name; @@ -5565,6 +5584,7 @@ enum options_mysqld OPT_SYSDATE_IS_NOW, OPT_OPTIMIZER_SEARCH_DEPTH, OPT_OPTIMIZER_PRUNE_LEVEL, + OPT_OPTIMIZER_SWITCH, OPT_UPDATABLE_VIEWS_WITH_LIMIT, OPT_SP_AUTOMATIC_PRIVILEGES, OPT_MAX_SP_RECURSION_DEPTH, @@ -6717,6 +6737,10 @@ The minimum value for this variable is 4096.", (uchar**) &global_system_variables.optimizer_search_depth, (uchar**) &max_system_variables.optimizer_search_depth, 0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0}, + {"optimizer_switch", OPT_OPTIMIZER_SWITCH, + "optimizer_switch=option[,option[,option...]] where option can be one of: no_index_merge, no_index_merge_union, no_index_merge_sort_union, no_index_merge_intersection", + (uchar**) &optimizer_switch_str, (uchar**) &optimizer_switch_str, 0, GET_STR, REQUIRED_ARG, 0, + 0, 0, 0, 0, 0}, {"plugin_dir", OPT_PLUGIN_DIR, "Directory for plugins.", (uchar**) &opt_plugin_dir_ptr, (uchar**) &opt_plugin_dir_ptr, 0, @@ -8206,6 +8230,13 @@ mysqld_get_one_option(int optid, sql_mode); break; } + case OPT_OPTIMIZER_SWITCH: + { + optimizer_switch_str= argument; + global_system_variables.optimizer_switch= + find_bit_type_or_exit(argument, &optimizer_switch_typelib, opt->name); + break; + } case OPT_ONE_THREAD: global_system_variables.thread_handling= SCHEDULER_ONE_THREAD_PER_CONNECTION; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 9f8f17eb4ba..aaa745bd413 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2386,7 +2386,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, objects are not allowed so don't use ROR-intersection for table deletes. */ - if ((thd->lex->sql_command != SQLCOM_DELETE)) + if ((thd->lex->sql_command != SQLCOM_DELETE) && + !optimizer_flag(thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE)) { /* Get best non-covering ROR-intersection plan and prepare data for @@ -2410,25 +2411,28 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, } else { - /* Try creating index_merge/ROR-union scan. */ - SEL_IMERGE *imerge; - TABLE_READ_PLAN *best_conj_trp= NULL, *new_conj_trp; - LINT_INIT(new_conj_trp); /* no empty index_merge lists possible */ - DBUG_PRINT("info",("No range reads possible," - " trying to construct index_merge")); - List_iterator_fast it(tree->merges); - while ((imerge= it++)) + if (!optimizer_flag(thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE)) { - new_conj_trp= get_best_disjunct_quick(¶m, imerge, best_read_time); - if (new_conj_trp) - set_if_smaller(param.table->quick_condition_rows, - new_conj_trp->records); - if (!best_conj_trp || (new_conj_trp && new_conj_trp->read_cost < - best_conj_trp->read_cost)) - best_conj_trp= new_conj_trp; + /* Try creating index_merge/ROR-union scan. */ + SEL_IMERGE *imerge; + TABLE_READ_PLAN *best_conj_trp= NULL, *new_conj_trp; + LINT_INIT(new_conj_trp); /* no empty index_merge lists possible */ + DBUG_PRINT("info",("No range reads possible," + " trying to construct index_merge")); + List_iterator_fast it(tree->merges); + while ((imerge= it++)) + { + new_conj_trp= get_best_disjunct_quick(¶m, imerge, best_read_time); + if (new_conj_trp) + set_if_smaller(param.table->quick_condition_rows, + new_conj_trp->records); + if (!best_conj_trp || (new_conj_trp && new_conj_trp->read_cost < + best_conj_trp->read_cost)) + best_conj_trp= new_conj_trp; + } + if (best_conj_trp) + best_trp= best_conj_trp; } - if (best_conj_trp) - best_trp= best_conj_trp; } } @@ -3767,11 +3771,19 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, "full table scan, bailing out")); DBUG_RETURN(NULL); } - if (all_scans_rors) + + /* + If all scans happen to be ROR, proceed to generate a ROR-union plan (it's + guaranteed to be cheaper than non-ROR union), unless ROR-unions are + disabled in @@optimizer_switch + */ + if (all_scans_rors && + !optimizer_flag(param->thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE_UNION)) { roru_read_plans= (TABLE_READ_PLAN**)range_scans; goto skip_to_ror_scan; } + if (cpk_scan) { /* @@ -3785,8 +3797,11 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, imerge_cost += get_sweep_read_cost(param, non_cpk_scan_records); DBUG_PRINT("info",("index_merge cost with rowid-to-row scan: %g", imerge_cost)); - if (imerge_cost > read_time) + if (imerge_cost > read_time || + optimizer_flag(param->thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE_SORT_UNION)) + { goto build_ror_index_merge; + } /* Add Unique operations cost */ unique_calc_buff_size= @@ -3822,7 +3837,9 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, } build_ror_index_merge: - if (!all_scans_ror_able || param->thd->lex->sql_command == SQLCOM_DELETE) + if (!all_scans_ror_able || + param->thd->lex->sql_command == SQLCOM_DELETE || + optimizer_flag(param->thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE_UNION)) DBUG_RETURN(imerge_trp); /* Ok, it is possible to build a ROR-union, try it. */ @@ -4495,7 +4512,8 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, double min_cost= DBL_MAX; DBUG_ENTER("get_best_ror_intersect"); - if ((tree->n_ror_scans < 2) || !param->table->file->stats.records) + if ((tree->n_ror_scans < 2) || !param->table->file->stats.records || + optimizer_flag(param->thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE_INTERSECT)) DBUG_RETURN(NULL); /* @@ -4685,6 +4703,9 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, ROR_SCAN_INFO **ror_scans_end= tree->ror_scans_end; DBUG_ENTER("get_best_covering_ror_intersect"); + if (optimizer_flag(param->thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE_INTERSECT)) + DBUG_RETURN(NULL); + for (ROR_SCAN_INFO **scan= tree->ror_scans; scan != ror_scans_end; ++scan) (*scan)->key_components= param->table->key_info[(*scan)->keynr].key_parts; diff --git a/sql/set_var.cc b/sql/set_var.cc index f14068fcfcb..96eaa3c9c2b 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -468,6 +468,8 @@ static sys_var_thd_ulong sys_optimizer_prune_level(&vars, "optimizer_prun &SV::optimizer_prune_level); static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth", &SV::optimizer_search_depth); +static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch", + &SV::optimizer_switch); static sys_var_const sys_pid_file(&vars, "pid_file", OPT_GLOBAL, SHOW_CHAR, (uchar*) pidfile_name); @@ -3837,6 +3839,56 @@ ulong fix_sql_mode(ulong sql_mode) } +bool +sys_var_thd_optimizer_switch:: +symbolic_mode_representation(THD *thd, ulonglong val, LEX_STRING *rep) +{ + char buff[STRING_BUFFER_USUAL_SIZE*8]; + String tmp(buff, sizeof(buff), &my_charset_latin1); + + tmp.length(0); + + for (uint i= 0; val; val>>= 1, i++) + { + if (val & 1) + { + tmp.append(optimizer_switch_typelib.type_names[i], + optimizer_switch_typelib.type_lengths[i]); + tmp.append(','); + } + } + + if (tmp.length()) + tmp.length(tmp.length() - 1); /* trim the trailing comma */ + + rep->str= thd->strmake(tmp.ptr(), tmp.length()); + + rep->length= rep->str ? tmp.length() : 0; + + return rep->length != tmp.length(); +} + + +uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type, + LEX_STRING *base) +{ + LEX_STRING opts; + ulonglong val= ((type == OPT_GLOBAL) ? global_system_variables.*offset : + thd->variables.*offset); + (void) symbolic_mode_representation(thd, val, &opts); + return (uchar *) opts.str; +} + + +void sys_var_thd_optimizer_switch::set_default(THD *thd, enum_var_type type) +{ + if (type == OPT_GLOBAL) + global_system_variables.*offset= 0; + else + thd->variables.*offset= global_system_variables.*offset; +} + + /**************************************************************************** Named list handling ****************************************************************************/ diff --git a/sql/set_var.h b/sql/set_var.h index b6c67d1ab4a..f07facde0b0 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -31,7 +31,7 @@ typedef struct system_variables SV; typedef struct my_locale_st MY_LOCALE; extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib, - slave_exec_mode_typelib; + optimizer_switch_typelib, slave_exec_mode_typelib; typedef int (*sys_check_func)(THD *, set_var *); typedef bool (*sys_update_func)(THD *, set_var *); @@ -532,6 +532,23 @@ public: }; +class sys_var_thd_optimizer_switch :public sys_var_thd_enum +{ +public: + sys_var_thd_optimizer_switch(sys_var_chain *chain, const char *name_arg, + ulong SV::*offset_arg) + :sys_var_thd_enum(chain, name_arg, offset_arg, &optimizer_switch_typelib) + {} + bool check(THD *thd, set_var *var) + { + return check_set(thd, var, enum_names); + } + void set_default(THD *thd, enum_var_type type); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + static bool symbolic_mode_representation(THD *thd, ulonglong sql_mode, + LEX_STRING *rep); +}; + extern void fix_sql_mode_var(THD *thd, enum_var_type type); class sys_var_thd_sql_mode :public sys_var_thd_enum diff --git a/sql/sql_class.h b/sql/sql_class.h index 3439e5b4f74..dd285eb0645 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -321,6 +321,8 @@ struct system_variables ulong net_write_timeout; ulong optimizer_prune_level; ulong optimizer_search_depth; + /* A bitmap for switching optimizations on/off */ + ulong optimizer_switch; ulong preload_buff_size; ulong profiling_history_size; ulong query_cache_type; diff --git a/sql/sql_select.h b/sql/sql_select.h index 7d794b71f4d..353c2b1d610 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -729,3 +729,9 @@ bool error_if_full_join(JOIN *join); int report_error(TABLE *table, int error); int safe_index_read(JOIN_TAB *tab); COND *remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value); + +inline bool optimizer_flag(THD *thd, uint flag) +{ + return (thd->variables.optimizer_switch & flag); +} + From f7cf8e57c12f435980bafb4f4b9c657a722345a4 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 27 Feb 2009 11:26:06 +0200 Subject: [PATCH 03/88] Fix for bug #40552: Race condition around default_directories in load_defaults() load_defaults(), my_search_option_files() and my_print_default_files() utilized a global variable containing a pointer to thread local memory. This could lead to race conditions when those functions were called with high concurrency. Fixed by changing the interface of the said functions to avoid the necessity for using a global variable. Since we cannot change load_defaults() prototype for API compatibility reasons, it was renamed my_load_defaults(). Now load_defaults() is a thread-unsafe wrapper around a thread-safe version, my_load_defaults(). mysys/default.c: 1. Added a thread-safe version of load_defaults(), changed load_defaults() with the old interface to be a thread-unsafe wrapper around the thread-safe version. 2. Always use a private MEM_ROOT in my_print_default_files, don't use a global variable. sql-common/client.c: Use a thread-safe version of load_defaults(). --- include/my_sys.h | 7 +- mysys/default.c | 67 ++++++++++++++----- server-tools/instance-manager/instance_map.cc | 3 +- server-tools/instance-manager/options.cc | 4 +- server-tools/instance-manager/options.h | 3 + sql-common/client.c | 2 +- 6 files changed, 66 insertions(+), 20 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index 5335b65822f..180bfe0f07d 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -842,14 +842,17 @@ extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len); extern int get_defaults_options(int argc, char **argv, char **defaults, char **extra_defaults, char **group_suffix); +extern int my_load_defaults(const char *conf_file, const char **groups, + int *argc, char ***argv, const char ***); extern int load_defaults(const char *conf_file, const char **groups, - int *argc, char ***argv); + int *argc, char ***argv); extern int modify_defaults_file(const char *file_location, const char *option, const char *option_value, const char *section_name, int remove_option); extern int my_search_option_files(const char *conf_file, int *argc, char ***argv, uint *args_used, - Process_option_func func, void *func_ctx); + Process_option_func func, void *func_ctx, + const char **default_directories); extern void free_defaults(char **argv); extern void my_print_default_files(const char *conf_file); extern void print_defaults(const char *conf_file, const char **groups); diff --git a/mysys/default.c b/mysys/default.c index 6b2b31d43ec..cdd9462c1d1 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -151,7 +151,7 @@ static char *remove_end_comment(char *ptr); int my_search_option_files(const char *conf_file, int *argc, char ***argv, uint *args_used, Process_option_func func, - void *func_ctx) + void *func_ctx, const char **default_directories) { const char **dirs, *forced_default_file, *forced_extra_defaults; int error= 0; @@ -359,9 +359,8 @@ int get_defaults_options(int argc, char **argv, return org_argc - argc; } - /* - Read options from configurations files + Wrapper around my_load_defaults() for interface compatibility. SYNOPSIS load_defaults() @@ -372,6 +371,35 @@ int get_defaults_options(int argc, char **argv, argc Pointer to argc of original program argv Pointer to argv of original program + NOTES + + This function is NOT thread-safe as it uses a global pointer internally. + See also notes for my_load_defaults(). + + RETURN + 0 ok + 1 The given conf_file didn't exists +*/ +int load_defaults(const char *conf_file, const char **groups, + int *argc, char ***argv) +{ + return my_load_defaults(conf_file, groups, argc, argv, &default_directories); +} + +/* + Read options from configurations files + + SYNOPSIS + my_load_defaults() + conf_file Basename for configuration file to search for. + If this is a path, then only this file is read. + groups Which [group] entrys to read. + Points to an null terminated array of pointers + argc Pointer to argc of original program + argv Pointer to argv of original program + default_directories Pointer to a location where a pointer to the list + of default directories will be stored + IMPLEMENTATION Read options from configuration files and put them BEFORE the arguments @@ -386,13 +414,18 @@ int get_defaults_options(int argc, char **argv, that was put in *argv RETURN - 0 ok - 1 The given conf_file didn't exists + - If successful, 0 is returned. If 'default_directories' is not NULL, + a pointer to the array of default directory paths is stored to a location + it points to. That stored value must be passed to my_search_option_files() + later. + + - 1 is returned if the given conf_file didn't exist. In this case, the + value pointed to by default_directories is undefined. */ -int load_defaults(const char *conf_file, const char **groups, - int *argc, char ***argv) +int my_load_defaults(const char *conf_file, const char **groups, + int *argc, char ***argv, const char ***default_directories) { DYNAMIC_ARRAY args; TYPELIB group; @@ -402,10 +435,11 @@ int load_defaults(const char *conf_file, const char **groups, MEM_ROOT alloc; char *ptr,**res; struct handle_option_ctx ctx; + const char **dirs; DBUG_ENTER("load_defaults"); init_alloc_root(&alloc,512,0); - if ((default_directories= init_default_directories(&alloc)) == NULL) + if ((dirs= init_default_directories(&alloc)) == NULL) goto err; /* Check if the user doesn't want any default option processing @@ -426,6 +460,8 @@ int load_defaults(const char *conf_file, const char **groups, (*argc)--; *argv=res; *(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */ + if (default_directories) + *default_directories= dirs; DBUG_RETURN(0); } @@ -444,7 +480,8 @@ int load_defaults(const char *conf_file, const char **groups, ctx.group= &group; error= my_search_option_files(conf_file, argc, argv, &args_used, - handle_default_option, (void *) &ctx); + handle_default_option, (void *) &ctx, + dirs); /* Here error contains <> 0 only if we have a fully specified conf_file or a forced default file @@ -490,6 +527,10 @@ int load_defaults(const char *conf_file, const char **groups, puts(""); exit(0); } + + if (error == 0 && default_directories) + *default_directories= dirs; + DBUG_RETURN(error); err: @@ -895,15 +936,11 @@ void my_print_default_files(const char *conf_file) fputs(conf_file,stdout); else { - /* - If default_directories is already initialized, use it. Otherwise, - use a private MEM_ROOT. - */ - const char **dirs = default_directories; + const char **dirs; MEM_ROOT alloc; init_alloc_root(&alloc,512,0); - if (!dirs && (dirs= init_default_directories(&alloc)) == NULL) + if ((dirs= init_default_directories(&alloc)) == NULL) { fputs("Internal error initializing default directories list", stdout); } diff --git a/server-tools/instance-manager/instance_map.cc b/server-tools/instance-manager/instance_map.cc index d7328d51cfe..b137370b50a 100644 --- a/server-tools/instance-manager/instance_map.cc +++ b/server-tools/instance-manager/instance_map.cc @@ -536,7 +536,8 @@ int Instance_map::load() */ if (my_search_option_files(Options::Main::config_file, &argc, (char ***) &argv, &args_used, - process_option, (void*) this)) + process_option, (void*) this, + Options::default_directories)) log_info("Falling back to compiled-in defaults."); return complete_initialization(); diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc index 7eba3187dd9..6f084e7c63e 100644 --- a/server-tools/instance-manager/options.cc +++ b/server-tools/instance-manager/options.cc @@ -86,6 +86,7 @@ const char *Options::Main::bind_address= NULL; /* No default value */ uint Options::Main::monitoring_interval= DEFAULT_MONITORING_INTERVAL; uint Options::Main::port_number= DEFAULT_PORT; my_bool Options::Main::mysqld_safe_compatible= FALSE; +const char **Options::default_directories= NULL; /* Options::User_management */ @@ -439,7 +440,8 @@ int Options::load(int argc, char **argv) log_info("Loading config file '%s'...", (const char *) Main::config_file); - load_defaults(Main::config_file, default_groups, &argc, &saved_argv); + my_load_defaults(Main::config_file, default_groups, &argc, + &saved_argv, &default_directories); if ((handle_options(&argc, &saved_argv, my_long_options, get_one_option))) return ERR_INVALID_USAGE; diff --git a/server-tools/instance-manager/options.h b/server-tools/instance-manager/options.h index 0202ca271c9..5d4df51faae 100644 --- a/server-tools/instance-manager/options.h +++ b/server-tools/instance-manager/options.h @@ -91,6 +91,9 @@ struct Options #endif public: + /* Array of paths to be passed to my_search_option_files() later */ + static const char **default_directories; + static int load(int argc, char **argv); static void cleanup(); diff --git a/sql-common/client.c b/sql-common/client.c index 63c746a3f5a..91a47b6a6f8 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1021,7 +1021,7 @@ void mysql_read_default_options(struct st_mysql_options *options, argc=1; argv=argv_buff; argv_buff[0]= (char*) "client"; groups[0]= (char*) "client"; groups[1]= (char*) group; groups[2]=0; - load_defaults(filename, groups, &argc, &argv); + my_load_defaults(filename, groups, &argc, &argv, NULL); if (argc != 1) /* If some default option */ { char **option=argv; From 67ed4223131f1554e30a8ca4c49352461f62e44e Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Fri, 6 Mar 2009 20:19:29 +0200 Subject: [PATCH 04/88] Bug #40559 assertion failed in check_binlog_magic The reason of the bug is in that the test makes a trick with relay log files and did not reset fully at the end. If mtr does not restart the test the new SQL thread tried to work with the old time session data. Fixed with deploying RESET slave at the clean-up. mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test: adding RESET slave to force active mi and rli data struct to be reset. The slave SQL thread will deal with a fresh structures each time it restarts. --- .../suite/binlog/r/binlog_auto_increment_bug33029.result | 1 + .../suite/binlog/t/binlog_auto_increment_bug33029.test | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result b/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result index 8df0568a755..8226469fcf7 100644 --- a/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result +++ b/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result @@ -38,4 +38,5 @@ DROP PROCEDURE IF EXISTS p2; DROP FUNCTION IF EXISTS f1; DROP TRIGGER IF EXISTS tr1; stop slave sql_thread; +reset slave; SET @@global.relay_log_purge= @old_relay_log_purge; diff --git a/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test b/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test index f20cc33f820..5297767675c 100644 --- a/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test +++ b/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test @@ -52,9 +52,10 @@ DROP FUNCTION IF EXISTS f1; DROP TRIGGER IF EXISTS tr1; enable_warnings; +stop slave sql_thread; +reset slave; +source include/wait_for_slave_sql_to_stop.inc; remove_file $MYSQLD_DATADIR/slave-relay-bin.000001; remove_file $MYSQLD_DATADIR/slave-relay-bin.index; -stop slave sql_thread; -source include/wait_for_slave_sql_to_stop.inc; SET @@global.relay_log_purge= @old_relay_log_purge; From 989ee96b64b9eb510a62857c0ca7ef7dbdf28f2b Mon Sep 17 00:00:00 2001 From: Sergey Petrunia Date: Tue, 10 Mar 2009 11:49:30 +0300 Subject: [PATCH 05/88] Post-merge fixes --- sql/mysqld.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 199d5ba1073..5fdcd04de87 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8254,7 +8254,10 @@ mysqld_get_one_option(int optid, { optimizer_switch_str= argument; global_system_variables.optimizer_switch= - find_bit_type_or_exit(argument, &optimizer_switch_typelib, opt->name); + find_bit_type_or_exit(argument, &optimizer_switch_typelib, opt->name, + &error); + if (error) + return 1; break; } case OPT_ONE_THREAD: From c1f335237bd0cbf00b6860ba5f18cd1deff7d94c Mon Sep 17 00:00:00 2001 From: Narayanan V Date: Wed, 11 Mar 2009 12:41:59 +0530 Subject: [PATCH 06/88] Bug#42937 strings/CHARSET_INFO.txt not included in source distributions The reference manual has instructions for adding new character sets, and refers to the string/CHARSET_INFO.txt file. This file is currently not present in the distribution. Modify the build to include this file in the distribution. strings/Makefile.am: modify EXTRA_DIST to include the CHARSET_INFO file. --- strings/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/Makefile.am b/strings/Makefile.am index ffca972459b..f0d6585dee4 100644 --- a/strings/Makefile.am +++ b/strings/Makefile.am @@ -52,7 +52,7 @@ EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc bmove_upp-sparc.s strappend-sparc.s strend-sparc.s \ strinstr-sparc.s strmake-sparc.s strmov-sparc.s \ strnmov-sparc.s strstr-sparc.s strxmov-sparc.s \ - t_ctype.h CMakeLists.txt + t_ctype.h CMakeLists.txt CHARSET_INFO.txt libmystrings_a_LIBADD= conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c From 5e566b8effbcf992ccd077eb1ddee499cd98b057 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 11 Mar 2009 14:52:50 +0100 Subject: [PATCH 07/88] Bug #43532 mtr should not rely on diff to report test results mtr on Windows does not give decent diff due to missing diff install Modified to look for 'mtrdiff' if diff not available. --- client/mysqltest.cc | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 89b9c78a049..1dae7c4c90c 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -1445,6 +1445,7 @@ 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 @@ -1452,11 +1453,12 @@ static int run_tool(const char *tool_path, DYNAMIC_STRING *ds_res, ...) not present. */ -int diff_check() +int diff_check (const char *diff_name) { char buf[512]= {0}; FILE *res_file; - const char *cmd = "diff -v"; + char cmd[128]; + my_snprintf (cmd, sizeof(cmd), "%s -v", diff_name); int have_diff = 0; if (!(res_file= popen(cmd, "r"))) @@ -1488,7 +1490,7 @@ void show_diff(DYNAMIC_STRING* ds, const char* filename1, const char* filename2) { DYNAMIC_STRING ds_tmp; - int have_diff = 0; + const char *diff_name = 0; if (init_dynamic_string(&ds_tmp, "", 256, 256)) die("Out of memory"); @@ -1501,15 +1503,20 @@ void show_diff(DYNAMIC_STRING* ds, the way it's implemented does not work with default 'diff' on Solaris. */ #ifdef __WIN__ - have_diff = diff_check(); + if (diff_check("diff")) + diff_name = "diff"; + else if (diff_check("mtrdiff")) + diff_name = "mtrdiff"; + else + diff_name = 0; #else - have_diff = 1; + diff_name = "diff"; // Otherwise always assume it's called diff #endif - if (have_diff) + if (diff_name) { /* First try with unified diff */ - if (run_tool("diff", + if (run_tool(diff_name, &ds_tmp, /* Get output from diff in ds_tmp */ "-u", filename1, @@ -1520,7 +1527,7 @@ void show_diff(DYNAMIC_STRING* ds, dynstr_set(&ds_tmp, ""); /* Fallback to context diff with "diff -c" */ - if (run_tool("diff", + if (run_tool(diff_name, &ds_tmp, /* Get output from diff in ds_tmp */ "-c", filename1, @@ -1531,20 +1538,20 @@ void show_diff(DYNAMIC_STRING* ds, dynstr_set(&ds_tmp, ""); /* Fallback to simple diff with "diff" */ - if (run_tool("diff", + if (run_tool(diff_name, &ds_tmp, /* Get output from diff in ds_tmp */ filename1, filename2, "2>&1", NULL) > 1) /* Most "diff" tools return >1 if error */ { - have_diff= 0; + diff_name= 0; } } } } - if (! have_diff) + if (! diff_name) { /* Fallback to dump both files to result file and inform From e976b27ea65c365953199ac6be9b80479d149525 Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Wed, 11 Mar 2009 19:09:56 +0100 Subject: [PATCH 08/88] Bug#36751: Segmentation fault in ctype-bin.c:308; Linux 86_64, with-max-indexes=128 mysqld is optimized for the default case (up to 64-indices); for a greater number of indices it goes through a different code path. As that code-path is a compile-time option and can not easily be covered in standard tests, bitrot occurred. key-fields need an explicit initialization in the non- optimized case; this setup was presumably not added when a new key- vector was added. Changeset adds the necessary initialisations. No test case added due to dependence on compile-time option. sql/sql_select.cc: Init merge_keys as well. If we don't, things blow up badly outside of the optimized-for-64-keys case! sql/table.cc: Init merge_keys as well. If we don't, things blow up badly outside of the optimized-for-64-keys case! --- sql/sql_select.cc | 1 + sql/table.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bea748562eb..825d3c870d8 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9788,6 +9788,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, table->in_use= thd; table->quick_keys.init(); table->covering_keys.init(); + table->merge_keys.init(); table->keys_in_use_for_query.init(); table->s= share; diff --git a/sql/table.cc b/sql/table.cc index 17454ffb012..f67929ad96b 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1652,6 +1652,7 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, goto err; outparam->quick_keys.init(); outparam->covering_keys.init(); + outparam->merge_keys.init(); outparam->keys_in_use_for_query.init(); /* Allocate handler */ From fd35040890864139eba77c16c4292c28eadf0f10 Mon Sep 17 00:00:00 2001 From: Sergey Petrunia Date: Wed, 11 Mar 2009 23:13:39 +0300 Subject: [PATCH 09/88] Change optimizer_switch from no_xxx to xxx=on/xx=off. mysql-test/r/index_merge_myisam.result: Testcases mysql-test/t/index_merge_myisam.test: Testcases sql/strfunc.cc: Change optimizer_switch from no_xxx to xxx=on/xx=off. - Add functions to parse the new syntax --- mysql-test/r/index_merge_myisam.result | 73 +++++++--- mysql-test/t/index_merge_myisam.test | 75 +++++++--- sql/mysql_priv.h | 21 ++- sql/mysqld.cc | 34 +++-- sql/opt_range.cc | 14 +- sql/set_var.cc | 61 +++++++-- sql/set_var.h | 6 +- sql/strfunc.cc | 182 +++++++++++++++++++++++++ 8 files changed, 388 insertions(+), 78 deletions(-) diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result index cc2110ced32..ab112257492 100644 --- a/mysql-test/r/index_merge_myisam.result +++ b/mysql-test/r/index_merge_myisam.result @@ -1392,11 +1392,46 @@ WHERE `TESTID`='' AND `UCCHECK`=''; drop table t1; # -# @@optimizer_switch support and check +# Generic @@optimizer_switch tests (move those into a separate file if +# we get another @@optimizer_switch user) # select @@optimizer_switch; @@optimizer_switch - +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on +set optimizer_switch='index_merge=off,index_merge_union=off'; +select @@optimizer_switch; +@@optimizer_switch +index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on +set optimizer_switch='index_merge_union=on'; +select @@optimizer_switch; +@@optimizer_switch +index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on +set optimizer_switch='default,index_merge_sort_union=off'; +select @@optimizer_switch; +@@optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on +set optimizer_switch=4; +ERROR 42000: Variable 'optimizer_switch' can't be set to the value of '4' +set optimizer_switch=NULL; +ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'NULL' +set optimizer_switch='default,index_merge'; +ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge' +set optimizer_switch='index_merge=index_merge'; +ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge=index_merge' +set optimizer_switch='index_merge=on,but...'; +ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'but...' +set optimizer_switch='index_merge='; +ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge=' +set optimizer_switch='index_merge'; +ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge' +set optimizer_switch='on'; +ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'on' +# +# Check index_merge's @@optimizer_switch flags +# +select @@optimizer_switch; +@@optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1 (a int, b int, c int, filler char(100), @@ -1412,44 +1447,44 @@ explain select * from t1 where a=1 or b=1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 2 Using union(a,b); Using where This should use ALL: -set optimizer_switch='no_index_merge'; +set optimizer_switch='default,index_merge=off'; explain select * from t1 where a=1 or b=1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL a,b NULL NULL NULL 1000 Using where This should use sort-union: -set optimizer_switch='no_index_merge_union'; +set optimizer_switch='default,index_merge_union=off'; explain select * from t1 where a=1 or b=1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 2 Using sort_union(a,b); Using where This will use sort-union: -set optimizer_switch=''; +set optimizer_switch=default; explain select * from t1 where a<1 or b <1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 38 Using sort_union(a,b); Using where This should use ALL: -set optimizer_switch='no_index_merge_sort_union'; +set optimizer_switch='default,index_merge_sort_union=off'; explain select * from t1 where a<1 or b <1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL a,b NULL NULL NULL 1000 Using where This should use ALL: -set optimizer_switch='no_index_merge'; +set optimizer_switch='default,index_merge=off'; explain select * from t1 where a<1 or b <1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL a,b NULL NULL NULL 1000 Using where This will use sort-union: -set optimizer_switch='no_index_merge_union'; +set optimizer_switch='default,index_merge_union=off'; explain select * from t1 where a<1 or b <1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 38 Using sort_union(a,b); Using where alter table t1 add d int, add key(d); update t1 set d=a; This will use sort_union: -set optimizer_switch=''; +set optimizer_switch=default; explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b,c,d a,b 5,5 NULL 3 Using sort_union(a,b); Using where And if we disable sort_union, union: -set optimizer_switch='no_index_merge_sort_union'; +set optimizer_switch='default,index_merge_sort_union=off'; explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b,c,d c,d 5,5 NULL 100 Using union(c,d); Using where @@ -1463,48 +1498,48 @@ insert into t1 select A.a+10*B.a, A.a+10*B.a, A.a+10*B.a+100*C.a, 'foo', 'bar' from t0 A, t0 B, t0 C, t0 D where D.a<5; This should be intersect: -set optimizer_switch=''; +set optimizer_switch=default; explain select * from t1 where a=10 and b=10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where No intersect when index_merge is disabled: -set optimizer_switch='no_index_merge'; +set optimizer_switch='default,index_merge=off'; explain select * from t1 where a=10 and b=10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref a,b a 5 const 49 Using where No intersect if it is disabled: -set optimizer_switch='no_index_merge_intersection'; +set optimizer_switch='default,index_merge_intersection=off'; explain select * from t1 where a=10 and b=10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref a,b a 5 const 49 Using where Do intersect when union was disabled -set optimizer_switch='no_index_merge_union'; +set optimizer_switch='default,index_merge_union=off'; explain select * from t1 where a=10 and b=10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where Do intersect when sort_union was disabled -set optimizer_switch='no_index_merge_sort_union'; +set optimizer_switch='default,index_merge_sort_union=off'; explain select * from t1 where a=10 and b=10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where This will use intersection inside a union: -set optimizer_switch=''; +set optimizer_switch=default; explain select * from t1 where a=10 and b=10 or c=10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b,c a,b,c 5,5,5 NULL 6 Using union(intersect(a,b),c); Using where Should be only union left: -set optimizer_switch='no_index_merge_intersection'; +set optimizer_switch='default,index_merge_intersection=off'; explain select * from t1 where a=10 and b=10 or c=10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b,c a,c 5,5 NULL 54 Using union(a,c); Using where This will switch to sort-union (intersection will be gone, too, thats a known limitation: -set optimizer_switch='no_index_merge_union'; +set optimizer_switch='default,index_merge_union=off'; explain select * from t1 where a=10 and b=10 or c=10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b,c a,c 5,5 NULL 54 Using sort_union(a,c); Using where set optimizer_switch=default; show variables like 'optimizer_switch'; Variable_name Value -optimizer_switch +optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on drop table t0, t1; diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test index 13997cfd427..d6945ec9cf4 100644 --- a/mysql-test/t/index_merge_myisam.test +++ b/mysql-test/t/index_merge_myisam.test @@ -21,7 +21,47 @@ let $merge_table_support= 1; --source include/index_merge_ror_cpk.inc --echo # ---echo # @@optimizer_switch support and check +--echo # Generic @@optimizer_switch tests (move those into a separate file if +--echo # we get another @@optimizer_switch user) +--echo # + +select @@optimizer_switch; + +set optimizer_switch='index_merge=off,index_merge_union=off'; +select @@optimizer_switch; + +set optimizer_switch='index_merge_union=on'; +select @@optimizer_switch; + +set optimizer_switch='default,index_merge_sort_union=off'; +select @@optimizer_switch; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch=4; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch=NULL; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='default,index_merge'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='index_merge=index_merge'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='index_merge=on,but...'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='index_merge='; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='index_merge'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='on'; + +--echo # +--echo # Check index_merge's @@optimizer_switch flags --echo # select @@optimizer_switch; @@ -40,39 +80,39 @@ from t0 A, t0 B, t0 C; explain select * from t1 where a=1 or b=1; --echo This should use ALL: -set optimizer_switch='no_index_merge'; +set optimizer_switch='default,index_merge=off'; explain select * from t1 where a=1 or b=1; --echo This should use sort-union: -set optimizer_switch='no_index_merge_union'; +set optimizer_switch='default,index_merge_union=off'; explain select * from t1 where a=1 or b=1; --echo This will use sort-union: -set optimizer_switch=''; +set optimizer_switch=default; explain select * from t1 where a<1 or b <1; --echo This should use ALL: -set optimizer_switch='no_index_merge_sort_union'; +set optimizer_switch='default,index_merge_sort_union=off'; explain select * from t1 where a<1 or b <1; --echo This should use ALL: -set optimizer_switch='no_index_merge'; +set optimizer_switch='default,index_merge=off'; explain select * from t1 where a<1 or b <1; --echo This will use sort-union: -set optimizer_switch='no_index_merge_union'; +set optimizer_switch='default,index_merge_union=off'; explain select * from t1 where a<1 or b <1; alter table t1 add d int, add key(d); update t1 set d=a; --echo This will use sort_union: -set optimizer_switch=''; +set optimizer_switch=default; explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4); --echo And if we disable sort_union, union: -set optimizer_switch='no_index_merge_sort_union'; +set optimizer_switch='default,index_merge_sort_union=off'; explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4); drop table t1; @@ -89,40 +129,41 @@ select A.a+10*B.a, A.a+10*B.a, A.a+10*B.a+100*C.a, 'foo', 'bar' from t0 A, t0 B, t0 C, t0 D where D.a<5; --echo This should be intersect: -set optimizer_switch=''; +set optimizer_switch=default; explain select * from t1 where a=10 and b=10; --echo No intersect when index_merge is disabled: -set optimizer_switch='no_index_merge'; +set optimizer_switch='default,index_merge=off'; explain select * from t1 where a=10 and b=10; --echo No intersect if it is disabled: -set optimizer_switch='no_index_merge_intersection'; +set optimizer_switch='default,index_merge_intersection=off'; explain select * from t1 where a=10 and b=10; --echo Do intersect when union was disabled -set optimizer_switch='no_index_merge_union'; +set optimizer_switch='default,index_merge_union=off'; explain select * from t1 where a=10 and b=10; --echo Do intersect when sort_union was disabled -set optimizer_switch='no_index_merge_sort_union'; +set optimizer_switch='default,index_merge_sort_union=off'; explain select * from t1 where a=10 and b=10; # Now take union-of-intersection and see how we can disable parts of it --echo This will use intersection inside a union: -set optimizer_switch=''; +set optimizer_switch=default; explain select * from t1 where a=10 and b=10 or c=10; --echo Should be only union left: -set optimizer_switch='no_index_merge_intersection'; +set optimizer_switch='default,index_merge_intersection=off'; explain select * from t1 where a=10 and b=10 or c=10; --echo This will switch to sort-union (intersection will be gone, too, --echo thats a known limitation: -set optimizer_switch='no_index_merge_union'; +set optimizer_switch='default,index_merge_union=off'; explain select * from t1 where a=10 and b=10 or c=10; set optimizer_switch=default; show variables like 'optimizer_switch'; + drop table t0, t1; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 3b8e65d532f..f2ce7471922 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -523,11 +523,18 @@ protected: #define MODE_NO_ENGINE_SUBSTITUTION (MODE_HIGH_NOT_PRECEDENCE*2) #define MODE_PAD_CHAR_TO_FULL_LENGTH (ULL(1) << 31) -/* @@optimizer_switch flags */ -#define OPTIMIZER_SWITCH_NO_INDEX_MERGE 1 -#define OPTIMIZER_SWITCH_NO_INDEX_MERGE_UNION 2 -#define OPTIMIZER_SWITCH_NO_INDEX_MERGE_SORT_UNION 4 -#define OPTIMIZER_SWITCH_NO_INDEX_MERGE_INTERSECT 8 +/* @@optimizer_switch flags. These must be in sync with optimizer_switch_typelib */ +#define OPTIMIZER_SWITCH_INDEX_MERGE 1 +#define OPTIMIZER_SWITCH_INDEX_MERGE_UNION 2 +#define OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION 4 +#define OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT 8 +#define OPTIMIZER_SWITCH_LAST 16 + +#define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \ + OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \ + OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \ + OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT) + /* Replication uses 8 bytes to store SQL_MODE in the binary log. The day you @@ -1831,6 +1838,10 @@ extern enum_field_types agg_field_type(Item **items, uint nitems); /* strfunc.cc */ ulonglong find_set(TYPELIB *lib, const char *x, uint length, CHARSET_INFO *cs, char **err_pos, uint *err_len, bool *set_warning); +ulonglong find_set_from_flags(TYPELIB *lib, uint default_set, + ulonglong cur_set, ulonglong default_set, + const char *str, uint length, CHARSET_INFO *cs, + char **err_pos, uint *err_len, bool *set_warning); uint find_type(const TYPELIB *lib, const char *find, uint length, bool part_match); uint find_type2(const TYPELIB *lib, const char *find, uint length, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5fdcd04de87..2c465452c13 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -302,16 +302,17 @@ TYPELIB sql_mode_typelib= { array_elements(sql_mode_names)-1,"", static const char *optimizer_switch_names[]= { - "no_index_merge","no_index_merge_union","no_index_merge_sort_union", - "no_index_merge_intersection", NullS + "index_merge","index_merge_union","index_merge_sort_union", + "index_merge_intersection", "default", NullS }; /* Corresponding defines are named OPTIMIZER_SWITCH_XXX */ static const unsigned int optimizer_switch_names_len[]= { - sizeof("no_index_merge") - 1, - sizeof("no_index_merge_union") - 1, - sizeof("ni_index_merge_sort_union") - 1, - sizeof("no_index_merge_intersection") - 1 + sizeof("index_merge") - 1, + sizeof("index_merge_union") - 1, + sizeof("index_merge_sort_union") - 1, + sizeof("index_merge_intersection") - 1, + sizeof("default") - 1 }; TYPELIB optimizer_switch_typelib= { array_elements(optimizer_switch_names)-1,"", optimizer_switch_names, @@ -7656,7 +7657,8 @@ static int mysql_init_variables(void) when collecting index statistics for MyISAM tables. */ global_system_variables.myisam_stats_method= MI_STATS_METHOD_NULLS_NOT_EQUAL; - + + global_system_variables.optimizer_switch= OPTIMIZER_SWITCH_DEFAULT; /* Variables that depends on compile options */ #ifndef DBUG_OFF default_dbug_option=IF_WIN("d:t:i:O,\\mysqld.trace", @@ -8252,12 +8254,22 @@ mysqld_get_one_option(int optid, } case OPT_OPTIMIZER_SWITCH: { + bool not_used; + char *error= 0; + uint error_len= 0; optimizer_switch_str= argument; global_system_variables.optimizer_switch= - find_bit_type_or_exit(argument, &optimizer_switch_typelib, opt->name, - &error); - if (error) - return 1; + (ulong)find_set_from_flags(&optimizer_switch_typelib, + optimizer_switch_typelib.count, + global_system_variables.optimizer_switch, + global_system_variables.optimizer_switch, + argument, strlen(argument), NULL, + &error, &error_len, ¬_used); + if (error) + { + fprintf(stderr, "Invalid optimizer_switch flag: %s\n", error); + return 1; + } break; } case OPT_ONE_THREAD: diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 719ff2a4a7e..1184068a377 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2387,7 +2387,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, table deletes. */ if ((thd->lex->sql_command != SQLCOM_DELETE) && - !optimizer_flag(thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE)) + optimizer_flag(thd, OPTIMIZER_SWITCH_INDEX_MERGE)) { /* Get best non-covering ROR-intersection plan and prepare data for @@ -2411,7 +2411,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, } else { - if (!optimizer_flag(thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE)) + if (optimizer_flag(thd, OPTIMIZER_SWITCH_INDEX_MERGE)) { /* Try creating index_merge/ROR-union scan. */ SEL_IMERGE *imerge; @@ -3778,7 +3778,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, disabled in @@optimizer_switch */ if (all_scans_rors && - !optimizer_flag(param->thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE_UNION)) + optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_UNION)) { roru_read_plans= (TABLE_READ_PLAN**)range_scans; goto skip_to_ror_scan; @@ -3798,7 +3798,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, DBUG_PRINT("info",("index_merge cost with rowid-to-row scan: %g", imerge_cost)); if (imerge_cost > read_time || - optimizer_flag(param->thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE_SORT_UNION)) + !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION)) { goto build_ror_index_merge; } @@ -3839,7 +3839,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, build_ror_index_merge: if (!all_scans_ror_able || param->thd->lex->sql_command == SQLCOM_DELETE || - optimizer_flag(param->thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE_UNION)) + !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_UNION)) DBUG_RETURN(imerge_trp); /* Ok, it is possible to build a ROR-union, try it. */ @@ -4513,7 +4513,7 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree, DBUG_ENTER("get_best_ror_intersect"); if ((tree->n_ror_scans < 2) || !param->table->file->stats.records || - optimizer_flag(param->thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE_INTERSECT)) + !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT)) DBUG_RETURN(NULL); /* @@ -4703,7 +4703,7 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, ROR_SCAN_INFO **ror_scans_end= tree->ror_scans_end; DBUG_ENTER("get_best_covering_ror_intersect"); - if (optimizer_flag(param->thd, OPTIMIZER_SWITCH_NO_INDEX_MERGE_INTERSECT)) + if (!optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT)) DBUG_RETURN(NULL); for (ROR_SCAN_INFO **scan= tree->ror_scans; scan != ror_scans_end; ++scan) diff --git a/sql/set_var.cc b/sql/set_var.cc index e964d8f957c..e631b8fdba7 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3926,17 +3926,17 @@ symbolic_mode_representation(THD *thd, ulonglong val, LEX_STRING *rep) { char buff[STRING_BUFFER_USUAL_SIZE*8]; String tmp(buff, sizeof(buff), &my_charset_latin1); - + int i; + ulonglong bit; tmp.length(0); - - for (uint i= 0; val; val>>= 1, i++) + + for (i= 0, bit=1; bit != OPTIMIZER_SWITCH_LAST; i++, bit= bit << 1) { - if (val & 1) - { - tmp.append(optimizer_switch_typelib.type_names[i], - optimizer_switch_typelib.type_lengths[i]); - tmp.append(','); - } + tmp.append(optimizer_switch_typelib.type_names[i], + optimizer_switch_typelib.type_lengths[i]); + tmp.append('='); + tmp.append((val & bit)? "on":"off"); + tmp.append(','); } if (tmp.length()) @@ -3961,12 +3961,45 @@ uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type, } -void sys_var_thd_optimizer_switch::set_default(THD *thd, enum_var_type type) +/* + Check (and actually parse) string representation of @@optimizer_switch. +*/ + +bool sys_var_thd_optimizer_switch::check(THD *thd, set_var *var) { - if (type == OPT_GLOBAL) - global_system_variables.*offset= 0; - else - thd->variables.*offset= global_system_variables.*offset; + bool not_used; + char buff[STRING_BUFFER_USUAL_SIZE], *error= 0; + uint error_len= 0; + String str(buff, sizeof(buff), system_charset_info), *res; + + if (!(res= var->value->val_str(&str))) + { + strmov(buff, "NULL"); + goto err; + } + + if (res->length() == 0) + { + buff[0]= 0; + goto err; + } + + var->save_result.ulong_value= + (ulong)find_set_from_flags(&optimizer_switch_typelib, + optimizer_switch_typelib.count, + thd->variables.optimizer_switch, + global_system_variables.optimizer_switch, + res->c_ptr(), res->length(), NULL, + &error, &error_len, ¬_used); + if (error_len) + { + strmake(buff, error, min(sizeof(buff) - 1, error_len)); + goto err; + } + return FALSE; +err: + my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, buff); + return TRUE; } diff --git a/sql/set_var.h b/sql/set_var.h index f07facde0b0..eee4bc51b7e 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -539,11 +539,7 @@ public: ulong SV::*offset_arg) :sys_var_thd_enum(chain, name_arg, offset_arg, &optimizer_switch_typelib) {} - bool check(THD *thd, set_var *var) - { - return check_set(thd, var, enum_names); - } - void set_default(THD *thd, enum_var_type type); + bool check(THD *thd, set_var *var); uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); static bool symbolic_mode_representation(THD *thd, ulonglong sql_mode, LEX_STRING *rep); diff --git a/sql/strfunc.cc b/sql/strfunc.cc index c03365cfc2b..aad91a2a16a 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -88,6 +88,188 @@ ulonglong find_set(TYPELIB *lib, const char *str, uint length, CHARSET_INFO *cs, } +static const char *on_off_default_names[]= +{ + "off","on","default", NullS +}; + +static const unsigned int on_off_default_names_len[]= +{ + sizeof("off") - 1, + sizeof("on") - 1, + sizeof("default") - 1 +}; + +static TYPELIB on_off_default_typelib= {array_elements(on_off_default_names)-1, + "", on_off_default_names, + (unsigned int *)on_off_default_names_len}; + + +/* + Given a string, find the first field_separator char, minding the charset +*/ + +static uint parse_name(TYPELIB *lib, const char **strpos, const char *end, + CHARSET_INFO *cs) +{ + const char *pos= *strpos; + const char *start= pos; + + /* Find the length */ + if (cs && cs->mbminlen > 1) + { + int mblen= 0; + for ( ; pos < end; pos+= mblen) + { + my_wc_t wc; + if ((mblen= cs->cset->mb_wc(cs, &wc, (const uchar *) pos, + (const uchar *) end)) < 1) + mblen= 1; // Not to hang on a wrong multibyte sequence + if (wc == (my_wc_t) '=' || wc == (my_wc_t) ',') + break; + } + } + else + for (; pos != end && *pos != '=' && *pos !=',' ; pos++); + + uint var_len= (uint) (pos - start); + /* Determine which flag it is*/ + uint find= cs ? find_type2(lib, start, var_len, cs) : + find_type(lib, start, var_len, (bool) 0); + *strpos= pos; + return find; +} + + +/* Read next character from the buffer in a charset-aware way */ + +static my_wc_t get_next_char(const char **pos, const char *end, CHARSET_INFO *cs) +{ + my_wc_t wc; + if (*pos == end) + return (my_wc_t)-1; + + if (cs && cs->mbminlen > 1) + { + int mblen; + if ((mblen= cs->cset->mb_wc(cs, &wc, (const uchar *) *pos, + (const uchar *) end)) < 1) + mblen= 1; // Not to hang on a wrong multibyte sequence + *pos += mblen; + return wc; + } + else + return *((*pos)++); +} + + +/* + Parse a string representation of set of flags + + SYNOPSIS + find_set_from_flags() + lib Flag names + default_name Number of "default" in the typelib + cur_set Current set of flags (start from this state) + default_set Default set of flags (use this for assign-default + keyword and flag=default assignments) + str String representation (see below) + length Length of the above + cs Charset used for the string + err_pos OUT If error, set to point to start of wrong set string + err_len OUT If error, set to the length of wrong set string + set_warning OUT TRUE <=> Some string in set couldn't be used + + DESCRIPTION + Parse a set of flag assignments, that is, parse a string in form: + + param_name1=value1,param_name2=value2,... + + where the names are specified in the TYPELIB, and each value can be + either 'on','off', or 'default'. Besides param=val assignments, we + support "default" keyword (keyword #default_name in the typelib) which + means assign everything the default. + + RETURN + FALSE Ok + TRUE Error +*/ + +ulonglong find_set_from_flags(TYPELIB *lib, uint default_name, + ulonglong cur_set, ulonglong default_set, + const char *str, uint length, CHARSET_INFO *cs, + char **err_pos, uint *err_len, bool *set_warning) +{ + CHARSET_INFO *strip= cs ? cs : &my_charset_latin1; + const char *end= str + strip->cset->lengthsp(strip, str, length); + ulonglong flags= cur_set; + *err_pos= 0; // No error yet + if (str != end) + { + const char *start= str; + for (;;) + { + my_wc_t chr; + const char *pos= start; + uint flag, value; + + if (!(flag= parse_name(lib, &pos, end, cs))) + { + *err_pos= (char*) start; + *err_len= pos - start; + *set_warning= 1; + break; + } + + if (flag == default_name) + { + flags= default_set; + } + else + { + if ((chr= get_next_char(&pos, end, cs)) != '=') + { + *err_pos= (char*)start; + *err_len= pos - start; + *set_warning= 1; + break; + } + + if (!(value= parse_name(&on_off_default_typelib, &pos, end, cs))) + { + *err_pos= (char*) start; + *err_len= pos - start; + *set_warning= 1; + break; + } + + ulonglong bit= ((longlong) 1 << (flag - 1)); + if (value == 1) // this is 'xxx=off' + flags &= ~bit; + else if (value == 2) // this is 'xxx=on' + flags |= bit; + else // this is 'xxx=default' + { + bit= default_set & bit; + flags= (flags & ~bit) | bit; + } + } + + if (pos >= end) + break; + if ((chr= get_next_char(&pos, end, cs)) != ',') + { + *err_pos= (char*)start; + *err_len= pos - start; + *set_warning= 1; + } + start=pos; + } + } + return flags; +} + + /* Function to find a string in a TYPELIB (Same format as mysys/typelib.c) From 99524127985de26ee61ccc7fd93165f5c14b450b Mon Sep 17 00:00:00 2001 From: Leonard Zhou Date: Thu, 12 Mar 2009 17:48:41 +0800 Subject: [PATCH 10/88] BUG#39858 rpl.rpl_rotate (rpl.rpl_rotate_logs) failed on pushbuild: result mismatch The method to purge binary log files produces different results in some platforms. The reason is that the purge time is calculated based on table modified time and that can't guarantee to purge master-bin.000002 in all platforms.(eg. windows) Use a new way that sets the time to purge binlog file 1 second after the last modified time of master-bin.000002. That can be sure that the file is always deleted in any platform. mysql-test/suite/rpl/r/rpl_rotate_logs.result: Test result mysql-test/suite/rpl/t/rpl_rotate_logs.test: Test file --- mysql-test/suite/rpl/r/rpl_rotate_logs.result | 4 +--- mysql-test/suite/rpl/t/rpl_rotate_logs.test | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_rotate_logs.result b/mysql-test/suite/rpl/r/rpl_rotate_logs.result index 6314a9a61fb..013ba87ec0b 100644 --- a/mysql-test/suite/rpl/r/rpl_rotate_logs.result +++ b/mysql-test/suite/rpl/r/rpl_rotate_logs.result @@ -87,9 +87,7 @@ show binary logs; Log_name File_size master-bin.000002 # master-bin.000003 # -select @time_for_purge:=DATE_ADD(UPDATE_TIME, INTERVAL 1 SECOND) -from information_schema.tables -where TABLE_SCHEMA="test" and TABLE_NAME="t2"; +SELECT @time_for_purge:=DATE_ADD('tmpval', INTERVAL 1 SECOND); purge master logs before (@time_for_purge); show binary logs; Log_name File_size diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs.test b/mysql-test/suite/rpl/t/rpl_rotate_logs.test index 2bad7b27272..e06099fd707 100644 --- a/mysql-test/suite/rpl/t/rpl_rotate_logs.test +++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test @@ -112,14 +112,24 @@ source include/show_master_logs.inc; purge binary logs to 'master-bin.000002'; source include/show_binary_logs.inc; -# Calculate time to use in "purge master logs before" by taking -# last modification time of t2 and adding 1 second -# This is donw in order to handle the case where file system -# time differs from mysqld's time +# Set the purge time 1 second after the last modify time of master-bin.000002. +perl; +open F, ">>".$ENV{'MYSQLTEST_VARDIR'}.'/tmp/rpl_rotate_logs.tmp' or die "Tmp file rpl_rotate_logs.tmp not found"; +my $binlogpath = $ENV{'MYSQLTEST_VARDIR'}.'/mysqld.1/data/master-bin.000002'; +my @array = stat($binlogpath); +my $filemodifytime = $array[9]; +my @t = localtime $filemodifytime; +my $modifytime = sprintf "%04u-%02u-%02u %02u:%02u:%02u",$t[5]+1900,$t[4]+1,$t[3],$t[2],$t[1],$t[0]; +printf F ("let \$tmpval = %s;",$modifytime); +close F; +EOF + +--source $MYSQLTEST_VARDIR/tmp/rpl_rotate_logs.tmp +remove_file $MYSQLTEST_VARDIR/tmp/rpl_rotate_logs.tmp; + --disable_result_log -select @time_for_purge:=DATE_ADD(UPDATE_TIME, INTERVAL 1 SECOND) - from information_schema.tables - where TABLE_SCHEMA="test" and TABLE_NAME="t2"; +--replace_result $tmpval tmpval +--eval SELECT @time_for_purge:=DATE_ADD('$tmpval', INTERVAL 1 SECOND) --enable_result_log purge master logs before (@time_for_purge); From 8b9502ae58fad3857c6c0567700d158415f2d4c0 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 12 Mar 2009 16:07:13 +0100 Subject: [PATCH 11/88] Bug #43597 Fix for Bug 43410 breaks build on Power Mac due to incomplete sys/resource.h Added include of sys/time.h --- mysql-test/lib/My/SafeProcess/safe_process.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc index 6ad45a3226e..dc7b7da28c7 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process.cc @@ -45,6 +45,7 @@ #include #include +#include #include #include #include From a5dc03fb684ffed13b6915534727317837473ce1 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 13 Mar 2009 12:51:25 +0400 Subject: [PATCH 12/88] Bug#42610 Dynamic plugin broken in 5.1.31 --added ability to obtain plugin variables from my.cnf on INSTALL PLUGIN stage --option 'ignore-builtin-innodb' disables all InnoDB builtin plugins (including I_S plugins) sql/mysql_priv.h: --added ability to obtain plugin variables from my.cnf on INSTALL PLUGIN stage sql/mysqld.cc: --added ability to obtain plugin variables from my.cnf on INSTALL PLUGIN stage sql/sql_plugin.cc: --added ability to obtain plugin variables from my.cnf on INSTALL PLUGIN stage --option 'ignore-builtin-innodb' disables all InnoDB builtin plugins (including I_S plugins) --- sql/mysql_priv.h | 3 +++ sql/mysqld.cc | 8 +++++++- sql/sql_plugin.cc | 35 +++++++++++++++++++++++------------ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index a2fbddd667a..2c938fc96a2 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -2047,6 +2047,9 @@ extern SHOW_COMP_OPTION have_geometry, have_rtree_keys; extern SHOW_COMP_OPTION have_crypt; extern SHOW_COMP_OPTION have_compress; +extern int orig_argc; +extern char **orig_argv; +extern const char *load_default_groups[]; #ifndef __WIN__ extern pthread_t signal_thread; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 921bcfcf68e..b88e6b641dd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -648,6 +648,9 @@ static int defaults_argc; static char **defaults_argv; static char *opt_bin_logname; +int orig_argc; +char **orig_argv; + static my_socket unix_sock,ip_sock; struct rand_struct sql_rand; ///< used by sql_class.cc:THD::THD() @@ -2923,7 +2926,7 @@ pthread_handler_t handle_shutdown(void *arg) #endif #if !defined(EMBEDDED_LIBRARY) -static const char *load_default_groups[]= { +const char *load_default_groups[]= { #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE "mysql_cluster", #endif @@ -3221,6 +3224,8 @@ static int init_common_variables(const char *conf_file_name, int argc, SQLCOM_END + 8); #endif + orig_argc=argc; + orig_argv=argv; load_defaults(conf_file_name, groups, &argc, &argv); defaults_argv=argv; defaults_argc=argc; @@ -3886,6 +3891,7 @@ server."); if ((ho_error= handle_options(&defaults_argc, &tmp_argv, no_opts, mysqld_get_one_option))) unireg_abort(ho_error); + my_getopt_skip_unknown= TRUE; if (defaults_argc) { diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 60f205ec8e8..223ba6ef42e 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1139,8 +1139,9 @@ int plugin_init(int *argc, char **argv, int flags) for (plugin= *builtins; plugin->info; plugin++) { if (opt_ignore_builtin_innodb && - !my_strcasecmp(&my_charset_latin1, plugin->name, "InnoDB")) - continue; + !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 && @@ -1633,8 +1634,8 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl { TABLE_LIST tables; TABLE *table; - int error, argc; - char *argv[2]; + int error, argc=orig_argc; + char **argv=orig_argv; struct st_plugin_int *tmp; DBUG_ENTER("mysql_install_plugin"); @@ -1650,21 +1651,31 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl pthread_mutex_lock(&LOCK_plugin); rw_wrlock(&LOCK_system_variables_hash); - /* handle_options() assumes arg0 (program name) always exists */ - argv[0]= const_cast(""); // without a cast gcc emits a warning - argv[1]= 0; - argc= 1; + + load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv); error= plugin_add(thd->mem_root, name, dl, &argc, argv, REPORT_TO_USER); + if (argv) + free_defaults(argv); rw_unlock(&LOCK_system_variables_hash); if (error || !(tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN))) goto err; - if (plugin_initialize(tmp)) + if (tmp->state == PLUGIN_IS_DISABLED) { - my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str, - "Plugin initialization function failed."); - goto deinit; + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_CANT_INITIALIZE_UDF, ER(ER_CANT_INITIALIZE_UDF), + name->str, "Plugin is disabled"); + } + else + { + DBUG_ASSERT(tmp->state == PLUGIN_IS_UNINITIALIZED); + if (plugin_initialize(tmp)) + { + my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str, + "Plugin initialization function failed."); + goto deinit; + } } /* From 7ac3f3f1beabcc9187a271b17f660d9ea7cddfb1 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 13 Mar 2009 11:16:32 +0200 Subject: [PATCH 13/88] addendum to bug #36540 : fix the funcs_1 test suite. --- mysql-test/suite/funcs_1/r/is_columns_mysql.result | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql.result b/mysql-test/suite/funcs_1/r/is_columns_mysql.result index 9d1f316a9bf..2f1f61c0525 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result +++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.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 select,insert,update,references NULL mysql event name 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references NULL mysql event on_completion 14 DROP NO enum 8 24 NULL NULL utf8 utf8_general_ci enum('DROP','PRESERVE') select,insert,update,references -NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL int(10) select,insert,update,references +NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references 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') select,insert,update,references NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event status 13 ENABLED NO enum 18 54 NULL NULL utf8 utf8_general_ci enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') select,insert,update,references @@ -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 select,insert,update,references NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references -NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned PRI select,insert,update,references @@ -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 select,insert,update,references NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references @@ -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) From 7b2d7bea5e8315f25def764ba220e089ce288a52 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 13 Mar 2009 14:25:50 +0400 Subject: [PATCH 14/88] compilation(embedded server) failure fix --- sql/mysqld.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b88e6b641dd..7fe498ae147 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2925,18 +2925,16 @@ pthread_handler_t handle_shutdown(void *arg) } #endif -#if !defined(EMBEDDED_LIBRARY) const char *load_default_groups[]= { #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE "mysql_cluster", #endif "mysqld","server", MYSQL_BASE_VERSION, 0, 0}; -#if defined(__WIN__) +#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) static const int load_default_groups_sz= sizeof(load_default_groups)/sizeof(load_default_groups[0]); #endif -#endif /*!EMBEDDED_LIBRARY*/ /** From 60beb4c3da759bd716ac7c49ee4103ca31abcf93 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 13 Mar 2009 13:13:55 +0200 Subject: [PATCH 15/88] Bug #43614: make distcheck failure (ndb/Makefile is made, but not subdirs of ndb) There are some recursive targets that automake generates which reference DIST_SUBDIRS. It's critical, then, for such subdirs to exist even if they won't be built as part of SUBDIRS. During a VPATH build, it is the configure script which creates the subdirs (when it processes the AC_CONFIG_FILES() for each subdir's Makefile). If autoconf doesn't create a subdir's Makefile, then the recursive make will fail when it is unable to cd into that subdir. This isn't a problem in non-VPATH builds, because the subdirs are all present in the source tarball. So the problem only shows up during 'make distcheck', which does a VPATH build. The fix is to look, when configure is being created by autoconf, for any plugin subdirectories. These are the dynamic subdirectories which need to be handled specially. It's enough to tell autoconf to generate a Makefile for any Makefile.am found in the plugin directory - all plugin subdirectories using automake (i.e., listed in the plugin's DIST_SUBDIRS) will have a Makefile.am. This is done by calling 'find'. This means that 'find' must be in the PATH on the host that is running autoconf. 'find' is NOT needed when calling configure, so it is not an additional dependency for the user. Finally, ha_ndbcluster.m4 had called AC_CONFIG_FILES() on all those subdir Makefiles, but only when the plugin was actually being built. So it didn't work in the case that NDB was not being built. All of those Makefiles have to be removed from this static list, since the plugin machinery is now adding them automatically. autoconf fails if a file is duplicated in AC_CONFIG_FILES(). --- config/ac-macros/ha_ndbcluster.m4 | 40 ++++--------------------------- config/ac-macros/plugins.m4 | 17 +++++++++++-- 2 files changed, 20 insertions(+), 37 deletions(-) diff --git a/config/ac-macros/ha_ndbcluster.m4 b/config/ac-macros/ha_ndbcluster.m4 index 5ee136f2266..3718b64f688 100644 --- a/config/ac-macros/ha_ndbcluster.m4 +++ b/config/ac-macros/ha_ndbcluster.m4 @@ -330,41 +330,11 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [ AC_SUBST([NDB_SIZEOF_LONG]) AC_SUBST([NDB_SIZEOF_LONG_LONG]) - AC_CONFIG_FILES(storage/ndb/include/Makefile dnl - storage/ndb/src/Makefile storage/ndb/src/common/Makefile dnl - storage/ndb/docs/Makefile dnl - storage/ndb/tools/Makefile dnl - storage/ndb/src/common/debugger/Makefile dnl - storage/ndb/src/common/debugger/signaldata/Makefile dnl - storage/ndb/src/common/portlib/Makefile dnl - storage/ndb/src/common/util/Makefile dnl - storage/ndb/src/common/logger/Makefile dnl - storage/ndb/src/common/transporter/Makefile dnl - storage/ndb/src/common/mgmcommon/Makefile dnl - storage/ndb/src/kernel/Makefile dnl - storage/ndb/src/kernel/error/Makefile dnl - storage/ndb/src/kernel/blocks/Makefile dnl - storage/ndb/src/kernel/blocks/dbdict/Makefile dnl - storage/ndb/src/kernel/blocks/dbdih/Makefile dnl - storage/ndb/src/kernel/blocks/dblqh/Makefile dnl - storage/ndb/src/kernel/blocks/dbtup/Makefile dnl - storage/ndb/src/kernel/blocks/backup/Makefile dnl - storage/ndb/src/kernel/vm/Makefile dnl - storage/ndb/src/mgmapi/Makefile dnl - storage/ndb/src/ndbapi/Makefile dnl - storage/ndb/src/mgmsrv/Makefile dnl - storage/ndb/src/mgmclient/Makefile dnl - storage/ndb/src/cw/Makefile dnl - storage/ndb/src/cw/cpcd/Makefile dnl - storage/ndb/test/Makefile dnl - storage/ndb/test/src/Makefile dnl - storage/ndb/test/ndbapi/Makefile dnl - storage/ndb/test/ndbapi/bank/Makefile dnl - storage/ndb/test/tools/Makefile dnl - storage/ndb/test/run-test/Makefile dnl - storage/ndb/include/ndb_version.h storage/ndb/include/ndb_global.h dnl - storage/ndb/include/ndb_types.h dnl - ) + AC_CONFIG_FILES([ + storage/ndb/include/ndb_version.h + storage/ndb/include/ndb_global.h + storage/ndb/include/ndb_types.h + ]) ]) AC_SUBST(TEST_NDBCLUSTER) diff --git a/config/ac-macros/plugins.m4 b/config/ac-macros/plugins.m4 index e1da6fd11f5..5d15afeda99 100644 --- a/config/ac-macros/plugins.m4 +++ b/config/ac-macros/plugins.m4 @@ -477,10 +477,23 @@ dnl Although this is "pretty", it breaks libmysqld build # Even if we don't build a plugin, we bundle its source into the dist # file. So its Makefile (and Makefiles for any subdirs) must be # generated for 'make dist' to work. - m4_syscmd(test -f "$6/configure") + m4_syscmd([test -f "]$6[/configure"]) ifelse(m4_sysval, 0, [AC_CONFIG_SUBDIRS($6)], - [AC_CONFIG_FILES($6/Makefile)] + [ + # autoconf doesn't provide an automatic way to configure DIST_SUBDIRS of + # a subdir; for our purposes, it's enough to just check for existing + # Makefile.am files and add them in here +dnl +dnl Warning, don't try to quote the m4_esyscmd() macro, it doesn't +dnl work. Quoting here is tricky. +dnl +dnl The $FIND or $SED variable can be set by the user when calling autoconf itself +dnl to if they need to pass a specific path. This is *NOT* used when calling +dnl running configure! +dnl + AC_CONFIG_FILES(m4_esyscmd([${FIND-find} "]$6[" -name Makefile.am -print | ${SED-sed} 's,\.am$,,'])) + ] ) ifelse( From f35b4218eaa2bf831ab682b3674851a1cc6ee65a Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 13 Mar 2009 15:51:25 +0200 Subject: [PATCH 16/88] Bug #22047 : Time in SHOW PROCESSLIST for SQL thread in replication seems to become negative THD::start_time has a dual meaning : it's either the time since the process entered a given state or is the transaction time returned by e.g. NOW(). This causes problems, as sometimes THD::start_time may be set to a value that is correct and needed when used as a base for NOW(), but these times may be arbitrary (SET @@timestamp) or non-local (coming from the master through the replication feed). If one such non-local time is set there's no way to return a correct value for e.g. SHOW PROCESSLIST or SELECT ... FROM INFORMATION_SCHEMA.PROCESSLIST. Fixed by making the Time column in SHOW PROCESSLIST SIGNED LONG instead of UNSIGNED LONG and doing the correct conversions. Note that no reliable test suite can be constructed, since it would require knowing the local time and can't be achieved by the means of the current test suite. sql/sql_show.cc: Bug #22047: make the Time in SHOW PROCESSLIST LONG from LONG UNSIGNED --- sql/sql_show.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a3ccf770a3c..fee3d076436 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1338,7 +1338,8 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) field_list.push_back(field=new Item_empty_string("db",NAME_LEN)); field->maybe_null=1; field_list.push_back(new Item_empty_string("Command",16)); - field_list.push_back(new Item_return_int("Time",7, FIELD_TYPE_LONG)); + field_list.push_back(field= new Item_return_int("Time",7, FIELD_TYPE_LONG)); + field->unsigned_flag= 0; field_list.push_back(field=new Item_empty_string("State",30)); field->maybe_null=1; field_list.push_back(field=new Item_empty_string("Info",max_query_length)); @@ -1439,7 +1440,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) else protocol->store(command_name[thd_info->command], system_charset_info); if (thd_info->start_time) - protocol->store((uint32) (now - thd_info->start_time)); + protocol->store_long ((longlong) (now - thd_info->start_time)); else protocol->store_null(); protocol->store(thd_info->state_info, system_charset_info); From aa640b7d0b2f490a972e252d5e783c96d0b0f916 Mon Sep 17 00:00:00 2001 From: Magnus Svensson Date: Fri, 13 Mar 2009 16:06:50 +0100 Subject: [PATCH 17/88] Bug#43361 msyql_client_test output lost - Print the output(if any) from the command that failed, in many cases this will make it possible to immediately see what went wrong. --- client/mysqltest.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 89b9c78a049..3dcffada2fb 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -2653,7 +2653,8 @@ void do_exec(struct st_command *command) log_msg("exec of '%s' failed, error: %d, status: %d, errno: %d", ds_cmd.str, error, status, errno); dynstr_free(&ds_cmd); - die("command \"%s\" failed", command->first_argument); + die("command \"%s\" failed\n\nOutput from before failure:\n%s\n", + command->first_argument, ds_res.str); } DBUG_PRINT("info", From 99eeb9fbbc812ac96d53a215f94aa329e767c88c Mon Sep 17 00:00:00 2001 From: Jonathan Perkin Date: Fri, 13 Mar 2009 21:01:19 +0100 Subject: [PATCH 18/88] Raise version number after cloning 5.1.33 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 069da9ef36e..d86218bd782 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.33) +AM_INIT_AUTOMAKE(mysql, 5.1.34) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 From 6551e173f9912225fca3aaada563d95aaac987f8 Mon Sep 17 00:00:00 2001 From: Sergey Petrunia Date: Sat, 14 Mar 2009 21:58:23 +0300 Subject: [PATCH 19/88] @@optimizer_switch backport and change from no_xxx to xx=on|off: post-review fixes mysql-test/r/index_merge_myisam.result: More tests mysql-test/t/index_merge_myisam.test: More tests --- mysql-test/r/index_merge_myisam.result | 21 +++- mysql-test/t/index_merge_myisam.test | 19 ++++ sql/mysql_priv.h | 1 + sql/mysqld.cc | 17 +++- sql/set_var.cc | 8 ++ sql/set_var.h | 1 + sql/strfunc.cc | 128 ++++++++++++++----------- 7 files changed, 136 insertions(+), 59 deletions(-) diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result index ab112257492..8a935d87457 100644 --- a/mysql-test/r/index_merge_myisam.result +++ b/mysql-test/r/index_merge_myisam.result @@ -1426,12 +1426,31 @@ set optimizer_switch='index_merge'; ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge' set optimizer_switch='on'; ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'on' +set optimizer_switch='index_merge=on,index_merge=off'; +ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge=off' +set optimizer_switch='index_merge_union=on,index_merge_union=default'; +ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge_union=default' +set optimizer_switch='default,index_merge=on,index_merge=off,default'; +ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge=off,default' +set optimizer_switch=default; +set optimizer_switch='index_merge=off,index_merge_union=off,default'; +select @@optimizer_switch; +@@optimizer_switch +index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on +set optimizer_switch=default; +select @@global.optimizer_switch; +@@global.optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on +set @@global.optimizer_switch=default; +select @@global.optimizer_switch; +@@global.optimizer_switch +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on # # Check index_merge's @@optimizer_switch flags # select @@optimizer_switch; @@optimizer_switch -index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1 (a int, b int, c int, filler char(100), diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test index d6945ec9cf4..dccaecef20a 100644 --- a/mysql-test/t/index_merge_myisam.test +++ b/mysql-test/t/index_merge_myisam.test @@ -60,6 +60,25 @@ set optimizer_switch='index_merge'; --error ER_WRONG_VALUE_FOR_VAR set optimizer_switch='on'; +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='index_merge=on,index_merge=off'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='index_merge_union=on,index_merge_union=default'; + +--error ER_WRONG_VALUE_FOR_VAR +set optimizer_switch='default,index_merge=on,index_merge=off,default'; + +set optimizer_switch=default; +set optimizer_switch='index_merge=off,index_merge_union=off,default'; +select @@optimizer_switch; +set optimizer_switch=default; + +# Check setting defaults for global vars +select @@global.optimizer_switch; +set @@global.optimizer_switch=default; +select @@global.optimizer_switch; + --echo # --echo # Check index_merge's @@optimizer_switch flags --echo # diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index f2ce7471922..6acac86a1e0 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -530,6 +530,7 @@ protected: #define OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT 8 #define OPTIMIZER_SWITCH_LAST 16 +/* The following must be kept in sync with optimizer_switch_str in mysqld.cc */ #define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \ OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \ OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e34449cd2ac..f0785842040 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -383,7 +383,10 @@ static ulong max_used_connections; static ulong my_bind_addr; /**< the address we bind to */ static volatile ulong cached_thread_count= 0; static const char *sql_mode_str= "OFF"; -static const char *optimizer_switch_str=""; +/* Text representation for OPTIMIZER_SWITCH_DEFAULT */ +static const char *optimizer_switch_str="index_merge=on,index_merge_union=on," + "index_merge_sort_union=on," + "index_merge_intersection=on"; static char *mysqld_user, *mysqld_chroot, *log_error_file_ptr; static char *opt_init_slave, *language_ptr, *opt_init_connect; static char *default_character_set_name; @@ -6747,8 +6750,11 @@ The minimum value for this variable is 4096.", (uchar**) &max_system_variables.optimizer_search_depth, 0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0}, {"optimizer_switch", OPT_OPTIMIZER_SWITCH, - "optimizer_switch=option[,option[,option...]] where option can be one of: no_index_merge, no_index_merge_union, no_index_merge_sort_union, no_index_merge_intersection", - (uchar**) &optimizer_switch_str, (uchar**) &optimizer_switch_str, 0, GET_STR, REQUIRED_ARG, 0, + "optimizer_switch=option=val[,option=val...], where option={index_merge, " + "index_merge_union, index_merge_sort_union, index_merge_intersection} and " + "val={on, off, default}.", + (uchar**) &optimizer_switch_str, (uchar**) &optimizer_switch_str, 0, GET_STR, REQUIRED_ARG, + /*OPTIMIZER_SWITCH_DEFAULT*/0, 0, 0, 0, 0, 0}, {"plugin_dir", OPT_PLUGIN_DIR, "Directory for plugins.", @@ -8267,7 +8273,10 @@ mysqld_get_one_option(int optid, &error, &error_len, ¬_used); if (error) { - fprintf(stderr, "Invalid optimizer_switch flag: %s\n", error); + char buf[512]; + char *cbuf= buf; + cbuf += my_snprintf(buf, 512, "Error in parsing optimizer_switch setting near %*s\n", error_len, error); + sql_perror(buf); return 1; } break; diff --git a/sql/set_var.cc b/sql/set_var.cc index e631b8fdba7..3464661dff9 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -4003,6 +4003,14 @@ err: } +void sys_var_thd_optimizer_switch::set_default(THD *thd, enum_var_type type) +{ + if (type == OPT_GLOBAL) + global_system_variables.*offset= OPTIMIZER_SWITCH_DEFAULT; + else + thd->variables.*offset= global_system_variables.*offset; +} + /**************************************************************************** Named list handling ****************************************************************************/ diff --git a/sql/set_var.h b/sql/set_var.h index eee4bc51b7e..10e6e0f9c35 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -540,6 +540,7 @@ public: :sys_var_thd_enum(chain, name_arg, offset_arg, &optimizer_switch_typelib) {} bool check(THD *thd, set_var *var); + void set_default(THD *thd, enum_var_type type); uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); static bool symbolic_mode_representation(THD *thd, ulonglong sql_mode, LEX_STRING *rep); diff --git a/sql/strfunc.cc b/sql/strfunc.cc index aad91a2a16a..1fb9c1a8451 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -106,7 +106,24 @@ static TYPELIB on_off_default_typelib= {array_elements(on_off_default_names)-1, /* - Given a string, find the first field_separator char, minding the charset + Parse a TYPELIB name from the buffer + + SYNOPSIS + parse_name() + lib Set of names to scan for. + strpos INOUT Start of the buffer (updated to point to the next + character after the name) + end End of the buffer + cs Charset used in the buffer + + DESCRIPTION + Parse a TYPELIB name from the buffer. The buffer is assumed to contain + one of the names specified in the TYPELIB, followed by comma, '=', or + end of the buffer. + + RETURN + 0 No matching name + >0 Offset+1 in typelib for matched name */ static uint parse_name(TYPELIB *lib, const char **strpos, const char *end, @@ -133,7 +150,7 @@ static uint parse_name(TYPELIB *lib, const char **strpos, const char *end, for (; pos != end && *pos != '=' && *pos !=',' ; pos++); uint var_len= (uint) (pos - start); - /* Determine which flag it is*/ + /* Determine which flag it is */ uint find= cs ? find_type2(lib, start, var_len, cs) : find_type(lib, start, var_len, (bool) 0); *strpos= pos; @@ -164,7 +181,7 @@ static my_wc_t get_next_char(const char **pos, const char *end, CHARSET_INFO *cs /* - Parse a string representation of set of flags + Parse and apply a set of flag assingments SYNOPSIS find_set_from_flags() @@ -173,11 +190,12 @@ static my_wc_t get_next_char(const char **pos, const char *end, CHARSET_INFO *cs cur_set Current set of flags (start from this state) default_set Default set of flags (use this for assign-default keyword and flag=default assignments) - str String representation (see below) - length Length of the above - cs Charset used for the string - err_pos OUT If error, set to point to start of wrong set string - err_len OUT If error, set to the length of wrong set string + str String to be parsed + length Length of the string + cs String charset + err_pos OUT If error, set to point to start of wrong set string + NULL on success + err_len OUT If error, set to the length of wrong set string set_warning OUT TRUE <=> Some string in set couldn't be used DESCRIPTION @@ -186,13 +204,17 @@ static my_wc_t get_next_char(const char **pos, const char *end, CHARSET_INFO *cs param_name1=value1,param_name2=value2,... where the names are specified in the TYPELIB, and each value can be - either 'on','off', or 'default'. Besides param=val assignments, we - support "default" keyword (keyword #default_name in the typelib) which - means assign everything the default. + either 'on','off', or 'default'. Setting the same name twice is not + allowed. + + Besides param=val assignments, we support the "default" keyword (keyword + #default_name in the typelib). It can be used one time, if specified it + causes us to build the new set over the default_set rather than cur_set + value. RETURN - FALSE Ok - TRUE Error + Parsed set value if (*errpos == NULL) + Otherwise undefined */ ulonglong find_set_from_flags(TYPELIB *lib, uint default_name, @@ -202,71 +224,69 @@ ulonglong find_set_from_flags(TYPELIB *lib, uint default_name, { CHARSET_INFO *strip= cs ? cs : &my_charset_latin1; const char *end= str + strip->cset->lengthsp(strip, str, length); - ulonglong flags= cur_set; + ulonglong flags_to_set= 0, flags_to_clear= 0; + bool set_defaults= 0; *err_pos= 0; // No error yet if (str != end) { const char *start= str; for (;;) { - my_wc_t chr; const char *pos= start; - uint flag, value; + uint flag_no, value; - if (!(flag= parse_name(lib, &pos, end, cs))) - { - *err_pos= (char*) start; - *err_len= pos - start; - *set_warning= 1; - break; - } + if (!(flag_no= parse_name(lib, &pos, end, cs))) + goto err; - if (flag == default_name) + if (flag_no == default_name) { - flags= default_set; + /* Using 'default' twice isn't allowed. */ + if (set_defaults) + goto err; + set_defaults= TRUE; } else { - if ((chr= get_next_char(&pos, end, cs)) != '=') + ulonglong bit= ((longlong) 1 << (flag_no - 1)); + /* parse the '=on|off|default' */ + if ((flags_to_clear | flags_to_set) & bit || + get_next_char(&pos, end, cs) != '=' || + !(value= parse_name(&on_off_default_typelib, &pos, end, cs))) { - *err_pos= (char*)start; - *err_len= pos - start; - *set_warning= 1; - break; - } - - if (!(value= parse_name(&on_off_default_typelib, &pos, end, cs))) - { - *err_pos= (char*) start; - *err_len= pos - start; - *set_warning= 1; - break; + goto err; } - ulonglong bit= ((longlong) 1 << (flag - 1)); - if (value == 1) // this is 'xxx=off' - flags &= ~bit; - else if (value == 2) // this is 'xxx=on' - flags |= bit; - else // this is 'xxx=default' + if (value == 1) // this is '=off' + flags_to_clear|= bit; + else if (value == 2) // this is '=on' + flags_to_set|= bit; + else // this is '=default' { - bit= default_set & bit; - flags= (flags & ~bit) | bit; + if (default_set & bit) + flags_to_set|= bit; + else + flags_to_clear|= bit; } } - if (pos >= end) break; - if ((chr= get_next_char(&pos, end, cs)) != ',') - { - *err_pos= (char*)start; - *err_len= pos - start; - *set_warning= 1; - } + + if (get_next_char(&pos, end, cs) != ',') + goto err; + start=pos; + continue; + err: + *err_pos= (char*)start; + *err_len= end - start; + *set_warning= TRUE; + break; } } - return flags; + ulonglong res= set_defaults? default_set : cur_set; + res|= flags_to_set; + res&= ~flags_to_clear; + return res; } From d28683dee459b253298c13e4291a82a869bbcdfc Mon Sep 17 00:00:00 2001 From: Patrick Crews Date: Sun, 15 Mar 2009 12:25:14 -0400 Subject: [PATCH 20/88] Bug#41307: Tests using include/ndb_backup.inc won't work on Windows due to 'grep' call. Revised patch incorporating cleaner test code brought up during review. Removed the use of grep and accomplished same actions via SQL / use of the server. Runs as before on *nix systems and now runs on Windows without Cygwin as well. --- mysql-test/include/ndb_backup.inc | 44 +++++++++++++++++++-------- mysql-test/r/ndb_restore.result | 6 ++-- mysql-test/r/ndb_restore_print.result | 18 +++++++---- 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/mysql-test/include/ndb_backup.inc b/mysql-test/include/ndb_backup.inc index 3239030bb64..752155a8dbd 100644 --- a/mysql-test/include/ndb_backup.inc +++ b/mysql-test/include/ndb_backup.inc @@ -3,29 +3,49 @@ # in test cases and can be reused. # ###################################################### -# Bug#41307: Tests using include/ndb_backup.inc won't work on Windows due to -# 'grep' call -# This test is disabled on Windows via the next line until the above bug is -# resolved ---source include/not_windows.inc - --exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "start backup" >> $NDB_TOOLS_OUTPUT -# there is no neat way to find the backupid, this is a hack to find it... +# To find the backupid, we must dump this data to a table, and SELECT +# what we want into an outfile. This could be accomplished with grep, but +# grep isn't Windows-portable ---exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $MYSQLTEST_VARDIR/tmp.dat +--disable_query_log +# create a table to help us out +--disable_warnings # leave this on until done with the entire process +# cleanup +DROP TABLE IF EXISTS helper1; +CREATE TABLE helper1(c1 VARCHAR(20)); +# dump raw data to file +let $ndb_backup_file1= $MYSQLTEST_VARDIR/ndb_backup_tmp.dat; +let $ndb_backup_file2= $MYSQLTEST_VARDIR/tmp.dat; +--error 0,1 +--remove_file $ndb_backup_file1 +--exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 > $ndb_backup_file1 +# load the table from the raw data file +eval LOAD DATA INFILE '$ndb_backup_file1' INTO TABLE helper1; +--remove_file $ndb_backup_file1 +# output what we need +eval SELECT * FROM helper1 WHERE c1 LIKE '%520093696%' +INTO OUTFILE '$ndb_backup_file2'; +# cleanup +DROP TABLE helper1; +--enable_warnings +--enable_query_log -CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; DELETE FROM test.backup_info; -LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +--replace_result $MYSQLTEST_VARDIR +eval LOAD DATA INFILE '$ndb_backup_file2' +INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +--remove_file $ndb_backup_file2 --replace_column 1 SELECT @the_backup_id:=backup_id FROM test.backup_info; - -let the_backup_id=`select @the_backup_id`; +let $the_backup_id=`SELECT @the_backup_id`; DROP TABLE test.backup_info; diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result index c48333f6ea8..05a94b143f3 100644 --- a/mysql-test/r/ndb_restore.result +++ b/mysql-test/r/ndb_restore.result @@ -129,9 +129,11 @@ create table t7 engine=myisam as select * from t7_c; create table t8 engine=myisam as select * from t8_c; create table t9 engine=myisam as select * from t9_c; create table t10 engine=myisam as select * from t10_c; -CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; DELETE FROM test.backup_info; -LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +LOAD DATA INFILE '/tmp.dat' +INTO TABLE test.backup_info FIELDS TERMINATED BY ','; SELECT @the_backup_id:=backup_id FROM test.backup_info; @the_backup_id:=backup_id diff --git a/mysql-test/r/ndb_restore_print.result b/mysql-test/r/ndb_restore_print.result index e05f8e43d1a..8b50303c2dc 100644 --- a/mysql-test/r/ndb_restore_print.result +++ b/mysql-test/r/ndb_restore_print.result @@ -227,9 +227,11 @@ hex(h3) NULL hex(i1) NULL hex(i2) NULL hex(i3) NULL -CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; DELETE FROM test.backup_info; -LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +LOAD DATA INFILE '/tmp.dat' +INTO TABLE test.backup_info FIELDS TERMINATED BY ','; SELECT @the_backup_id:=backup_id FROM test.backup_info; @the_backup_id:=backup_id @@ -261,9 +263,11 @@ create table t4 (pk int key, a int) engine ndb; insert into t2 values (1,11),(2,12),(3,13),(4,14),(5,15); insert into t3 values (1,21),(2,22),(3,23),(4,24),(5,25); insert into t4 values (1,31),(2,32),(3,33),(4,34),(5,35); -CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; DELETE FROM test.backup_info; -LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +LOAD DATA INFILE '/tmp.dat' +INTO TABLE test.backup_info FIELDS TERMINATED BY ','; SELECT @the_backup_id:=backup_id FROM test.backup_info; @the_backup_id:=backup_id @@ -305,9 +309,11 @@ create table t1 insert into t1 values(1, 8388607, 16777215); insert into t1 values(2, -8388608, 0); insert into t1 values(3, -1, 1); -CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; DELETE FROM test.backup_info; -LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +LOAD DATA INFILE '/tmp.dat' +INTO TABLE test.backup_info FIELDS TERMINATED BY ','; SELECT @the_backup_id:=backup_id FROM test.backup_info; @the_backup_id:=backup_id From 0fd7a359da836ab3233023dcd1b7c6ab09c90be6 Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Mon, 16 Mar 2009 09:02:10 +0400 Subject: [PATCH 21/88] Fix for bug #42957: no results from select where .. (col=col and col=col) or ... (false expression) Problem: optimizer didn't take into account a singular case when we eliminated all the predicates at the AND level of WHERE. That may lead to wrong results. Fix: replace (a=a AND a=a...) with TRUE if we eliminated all the predicates. mysql-test/r/select.result: Fix for bug #42957: no results from select where .. (col=col and col=col) or ... (false expression) - test result. mysql-test/t/select.test: Fix for bug #42957: no results from select where .. (col=col and col=col) or ... (false expression) - test case. sql/sql_select.cc: Fix for bug #42957: no results from select where .. (col=col and col=col) or ... (false expression) - replacing equality predicates by multiple equality items check if we eliminate all the predicates at the AND level and replace them with TRUE if so. --- mysql-test/r/select.result | 28 ++++++++++++++++++++++++++++ mysql-test/t/select.test | 16 ++++++++++++++++ sql/sql_select.cc | 9 ++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 621c11906cb..0771c7fb370 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4416,4 +4416,32 @@ date_nokey Warnings: Warning 1292 Incorrect date value: '10:41:7' for column 'date_nokey' at row 1 DROP TABLE A,C; +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select '1' AS `a`,'1' AS `b` from `test`.`t1` where 1 +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +a b +1 1 +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found +Warnings: +Note 1003 select '0' AS `a`,'0' AS `b`,'0' AS `c` from `test`.`t1` where 1 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found +Warnings: +Note 1003 select '0' AS `a`,'0' AS `b`,'0' AS `c` from `test`.`t1` where 1 +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found +Warnings: +Note 1003 select '0' AS `a`,'0' AS `b`,'0' AS `c` from `test`.`t1` where 1 +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index ccdb53ec11f..8981ddbe2e4 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3769,4 +3769,20 @@ SELECT date_nokey FROM C DROP TABLE A,C; +# +# Bug #42957: no results from +# select where .. (col=col and col=col) or ... (false expression) +# +CREATE TABLE t1 (a INT NOT NULL, b INT); +INSERT INTO t1 VALUES (1, 1); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2; +DROP TABLE t1; + +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL); +EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20; +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 End of 5.1 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bea748562eb..3bf94bc828f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7625,7 +7625,7 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond, if (and_level) { /* - Retrieve all conjucts of this level detecting the equality + Retrieve all conjuncts of this level detecting the equality that are subject to substitution by multiple equality items and removing each such predicate from the conjunction after having found/created a multiple equality whose inference the predicate is. @@ -7641,6 +7641,13 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond, li.remove(); } + /* + Check if we eliminated all the predicates of the level, e.g. + (a=a AND b=b AND a=a) + */ + if (!(args->elements + cond_equal.current_level.elements + eq_list.elements)) + return new Item_int((longlong) 1,1); + List_iterator_fast it(cond_equal.current_level); while ((item_equal= it++)) { From b42c29cfe33b5c5aab33661357fa4eb309e86132 Mon Sep 17 00:00:00 2001 From: Leonard Zhou Date: Mon, 16 Mar 2009 16:21:29 +0800 Subject: [PATCH 22/88] BUG#22504 load data infile sql statement in replication architecture get error The problem is issued because we set wrong start position and stop position of query string into binlog. That two values are stored as part of head info of query string. When we parse binlog, we first get position values then get the query string according position values. But seems that two values are not calculated correctly after the parse of Yacc. We don't want to touch so much of yacc because it may influence other codes. So just add one space after 'INTO' key word when parsing. This can easily resolve the problem. mysql-test/suite/rpl/r/rpl_loaddatalocal.result: Test result mysql-test/suite/rpl/t/rpl_loaddatalocal.test: Test case sql/log_event.cc: Add space after 'INTO'. --- .../suite/rpl/r/rpl_loaddatalocal.result | 25 ++++++++++++++ mysql-test/suite/rpl/r/rpl_stm_log.result | 2 +- mysql-test/suite/rpl/t/rpl_loaddatalocal.test | 34 +++++++++++++++++++ sql/log_event.cc | 4 +-- 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_loaddatalocal.result b/mysql-test/suite/rpl/r/rpl_loaddatalocal.result index 96de55e9dcf..93ef33f3fc0 100644 --- a/mysql-test/suite/rpl/r/rpl_loaddatalocal.result +++ b/mysql-test/suite/rpl/r/rpl_loaddatalocal.result @@ -29,3 +29,28 @@ a 2 3 drop table t1; +==== Bug22504 Initialize ==== +[on master] +SET sql_mode='ignore_space'; +CREATE TABLE t1(a int); +insert into t1 values (1), (2), (3), (4); +select * into outfile 'MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1; +truncate table t1; +load data local infile 'MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' into table t1; +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +[on slave] +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +==== Clean up ==== +[on master] +DROP TABLE t1; +[on slave] diff --git a/mysql-test/suite/rpl/r/rpl_stm_log.result b/mysql-test/suite/rpl/r/rpl_stm_log.result index 715d4976a95..bcefc6f9d3d 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_log.result +++ b/mysql-test/suite/rpl/r/rpl_stm_log.result @@ -218,7 +218,7 @@ slave-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL) slave-bin.000001 # Query 1 # use `test`; drop table t1 slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM slave-bin.000001 # Begin_load_query 1 # ;file_id=1;block_len=581 -slave-bin.000001 # Execute_load_query 1 # use `test`; load data INFILE '../../tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1 +slave-bin.000001 # Execute_load_query 1 # use `test`; load data INFILE '../../tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1 slave-bin.000001 # Query 1 # use `test`; 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; diff --git a/mysql-test/suite/rpl/t/rpl_loaddatalocal.test b/mysql-test/suite/rpl/t/rpl_loaddatalocal.test index 0de402f301a..23c802ab3de 100644 --- a/mysql-test/suite/rpl/t/rpl_loaddatalocal.test +++ b/mysql-test/suite/rpl/t/rpl_loaddatalocal.test @@ -64,3 +64,37 @@ drop table t1; save_master_pos; connection slave; sync_with_master; + + +# +# Bug22504 load data infile sql statement in replication architecture get error +# +--echo ==== Bug22504 Initialize ==== + +--echo [on master] +--connection master + +SET sql_mode='ignore_space'; +CREATE TABLE t1(a int); +insert into t1 values (1), (2), (3), (4); +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +eval select * into outfile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1; +truncate table t1; +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +eval load data local infile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' into table t1; +--remove_file $MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile +SELECT * FROM t1 ORDER BY a; + +--echo [on slave] +sync_slave_with_master; +SELECT * FROM t1 ORDER BY a; + +--echo ==== Clean up ==== + +--echo [on master] +connection master; +DROP TABLE t1; + +--echo [on slave] +sync_slave_with_master; + diff --git a/sql/log_event.cc b/sql/log_event.cc index 0e400ac2705..5d959412d36 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -6618,7 +6618,7 @@ void Execute_load_query_log_event::print(FILE* file, my_b_printf(&cache, "\'"); if (dup_handling == LOAD_DUP_REPLACE) my_b_printf(&cache, " REPLACE"); - my_b_printf(&cache, " INTO"); + my_b_printf(&cache, " INTO "); my_b_write(&cache, (uchar*) query + fn_pos_end, q_len-fn_pos_end); my_b_printf(&cache, "\n%s\n", print_event_info->delimiter); } @@ -6699,7 +6699,7 @@ Execute_load_query_log_event::do_apply_event(Relay_log_info const *rli) /* Ordinary load data */ break; } - p= strmake(p, STRING_WITH_LEN(" INTO")); + p= strmake(p, STRING_WITH_LEN(" INTO ")); p= strmake(p, query+fn_pos_end, q_len-fn_pos_end); error= Query_log_event::do_apply_event(rli, buf, p-buf); From c924f116f65d96818be88dae79018a83e19411b5 Mon Sep 17 00:00:00 2001 From: Chad MILLER Date: Mon, 16 Mar 2009 14:54:28 -0400 Subject: [PATCH 23/88] Bug#39326: mysqld_safe doesn't use --basedir value in search of \ my_print_defaults Now use basedir to set an unset ledir and to find the location of my_print_defaults . --- scripts/mysqld_safe.sh | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 5e7a177a546..502c981c72a 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -212,15 +212,26 @@ fi MY_PWD=`pwd` # Check for the directories we would expect from a binary release install -if test -f "$relpkgdata"/english/errmsg.sys -a -x ./bin/mysqld +if test -n "$MY_BASEDIR_VERSION" -a -d "$MY_BASEDIR_VERSION" then - MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are - ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is + # BASEDIR is already overridden on command line. Do not re-set. + + # Use BASEDIR to discover le. + if test -x "$MY_BASEDIR_VERSION/libexec/mysqld" + then + ledir="$MY_BASEDIR_VERSION/libexec" + else + ledir="$MY_BASEDIR_VERSION/bin" + fi +elif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/bin/mysqld" +then + MY_BASEDIR_VERSION="$MY_PWD" # Where bin, share and data are + ledir="$MY_PWD/bin" # Where mysqld is # Check for the directories we would expect from a source install -elif test -f "$relpkgdata"/english/errmsg.sys -a -x ./libexec/mysqld +elif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/libexec/mysqld" then - MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are - ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is + MY_BASEDIR_VERSION="$MY_PWD" # Where libexec, share and var are + ledir="$MY_PWD/libexec" # Where mysqld is # Since we didn't find anything, used the compiled-in defaults else MY_BASEDIR_VERSION=@prefix@ @@ -274,7 +285,10 @@ export MYSQL_HOME # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe] # and then merge with the command line arguments -if test -x ./bin/my_print_defaults +if test -x "$MY_BASEDIR_VERSION/bin/my_print_defaults" +then + print_defaults="$MY_BASEDIR_VERSION/bin/my_print_defaults" +elif test -x ./bin/my_print_defaults then print_defaults="./bin/my_print_defaults" elif test -x @bindir@/my_print_defaults From 3b32eea2a2d2e1d1cb1a0605a2f73ecbbc502aa5 Mon Sep 17 00:00:00 2001 From: Chad MILLER Date: Mon, 16 Mar 2009 15:28:06 -0400 Subject: [PATCH 24/88] Fix several quoting problems, and clean up IFS on failure in my_which(). --- scripts/mysqld_safe.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 502c981c72a..960c3e39bab 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -18,7 +18,7 @@ niceness=0 logging=init want_syslog=0 syslog_tag= -user=@MYSQLD_USER@ +user='@MYSQLD_USER@' pid_file= err_log= @@ -64,9 +64,10 @@ my_which () { save_ifs="${IFS-UNSET}" IFS=: + ret=0 for file do - for dir in $PATH + for dir in "$PATH" do if [ -f "$dir/$file" ] then @@ -74,15 +75,18 @@ my_which () continue 2 fi done - return 1 # Failure, didn't find file in path + + ret=1 #signal an error + break done + if [ "$save_ifs" = UNSET ] then unset IFS else IFS="$save_ifs" fi - return 0 # Success + return $ret # Success } log_generic () { @@ -234,8 +238,8 @@ then ledir="$MY_PWD/libexec" # Where mysqld is # Since we didn't find anything, used the compiled-in defaults else - MY_BASEDIR_VERSION=@prefix@ - ledir=@libexecdir@ + MY_BASEDIR_VERSION='@prefix@' + ledir='@libexecdir@' fi @@ -413,7 +417,7 @@ then MYSQLD=mysqld fi -if test ! -x $ledir/$MYSQLD +if test ! -x "$ledir/$MYSQLD" then log_error "The file $ledir/$MYSQLD does not exist or is not executable. Please cd to the mysql installation @@ -425,7 +429,7 @@ fi if test -z "$pid_file" then - pid_file=$DATADIR/`@HOSTNAME@`.pid + pid_file="$DATADIR/`@HOSTNAME@`.pid" else case "$pid_file" in /* ) ;; From 95618bb3f3c2dd8c9f0f760ef36e638096166138 Mon Sep 17 00:00:00 2001 From: Chad MILLER Date: Tue, 17 Mar 2009 15:31:07 -0400 Subject: [PATCH 25/88] Bug#42675: Dangling pointer leads to a client crash (mysys/my_error.c \ patch enclosed) One call to my_error_unregister_all() would free pointers, but leave one pointer to just-freed memory still assigned. That's the bug. Subsequent calls of this function would try to follow pointers into deallocated, garbage memory and almost certainly SEGV. Now, after freeing a linked list, unset the initial pointer. --- mysys/my_error.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mysys/my_error.c b/mysys/my_error.c index 07656dda979..06f2ef6ba0f 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -252,11 +252,16 @@ const char **my_error_unregister(int first, int last) void my_error_unregister_all(void) { - struct my_err_head *list, *next; - for (list= my_errmsgs_globerrs.meh_next; list; list= next) + struct my_err_head *cursor, *saved_next; + + for (cursor= my_errmsgs_globerrs.meh_next; cursor != NULL; cursor= saved_next) { - next= list->meh_next; - my_free((uchar*) list, MYF(0)); + /* We need this ptr, but we're about to free its container, so save it. */ + saved_next= cursor->meh_next; + + my_free((uchar*) cursor, MYF(0)); } + my_errmsgs_globerrs.meh_next= NULL; /* Freed in first iteration above. */ + my_errmsgs_list= &my_errmsgs_globerrs; } From 35d47c36317c46a1fd1bc7c9ea2042bd011783fe Mon Sep 17 00:00:00 2001 From: Chad MILLER Date: Tue, 17 Mar 2009 15:43:00 -0400 Subject: [PATCH 26/88] Fix indentation. tab -> spaces --- mysys/my_error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/my_error.c b/mysys/my_error.c index 06f2ef6ba0f..2cf704d0089 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -256,7 +256,7 @@ void my_error_unregister_all(void) for (cursor= my_errmsgs_globerrs.meh_next; cursor != NULL; cursor= saved_next) { - /* We need this ptr, but we're about to free its container, so save it. */ + /* We need this ptr, but we're about to free its container, so save it. */ saved_next= cursor->meh_next; my_free((uchar*) cursor, MYF(0)); From 5867396a8d1574090ea90af24bcb97a5cb841457 Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Mon, 16 Mar 2009 16:11:45 +0100 Subject: [PATCH 27/88] Bug#36446: Attempt to set @@join_buffer_size to its minimum value produces spurious warning If a sys-var has a base and a block-size>1, and then a user-supplied value >= minimum ended up below minimum thanks to block-size alignment, we threw a warning. This meant for instance that when getting, then setting the minimum, we'd see a warning. This was needlessly confusing. (updated patch) --- mysql-test/r/variables.result | 7 +++++++ mysql-test/t/variables.test | 15 +++++++++++++++ mysys/my_getopt.c | 6 ++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 7c9a9145ad1..f27d0b9fdd5 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -27,6 +27,7 @@ set @my_slow_launch_time =@@global.slow_launch_time; set @my_storage_engine =@@global.storage_engine; set @my_thread_cache_size =@@global.thread_cache_size; set @my_max_allowed_packet =@@global.max_allowed_packet; +set @my_join_buffer_size =@@global.join_buffer_size; set @`test`=1; select @test, @`test`, @TEST, @`TEST`, @"teSt"; @test @`test` @TEST @`TEST` @"teSt" @@ -1018,6 +1019,11 @@ show variables like 'hostname'; Variable_name Value hostname # End of 5.0 tests +set join_buffer_size=1; +Warnings: +Warning 1292 Truncated incorrect join_buffer_size value: '1' +set @save_join_buffer_size=@@join_buffer_size; +set join_buffer_size=@save_join_buffer_size; set global binlog_cache_size =@my_binlog_cache_size; set global connect_timeout =@my_connect_timeout; set global delayed_insert_timeout =@my_delayed_insert_timeout; @@ -1048,6 +1054,7 @@ set global slow_launch_time =@my_slow_launch_time; set global storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; set global max_allowed_packet =@my_max_allowed_packet; +set global join_buffer_size =@my_join_buffer_size; show global variables where Variable_name='table_definition_cache' or Variable_name='table_lock_wait_timeout'; Variable_name Value diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index e224d3b0244..6da20409639 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -36,6 +36,7 @@ set @my_slow_launch_time =@@global.slow_launch_time; set @my_storage_engine =@@global.storage_engine; set @my_thread_cache_size =@@global.thread_cache_size; set @my_max_allowed_packet =@@global.max_allowed_packet; +set @my_join_buffer_size =@@global.join_buffer_size; # case insensitivity tests (new in 5.0) set @`test`=1; select @test, @`test`, @TEST, @`TEST`, @"teSt"; @@ -780,6 +781,18 @@ show variables like 'hostname'; --echo End of 5.0 tests +# +# Bug#36446: Attempt to set @@join_buffer_size to its minimum value +# produces spurious warning +# + +# set to 1 so mysqld will correct to minimum (+ warn) +set join_buffer_size=1; +# save minimum +set @save_join_buffer_size=@@join_buffer_size; +# set minimum +set join_buffer_size=@save_join_buffer_size; + # This is at the very after the versioned tests, since it involves doing # cleanup # @@ -816,6 +829,8 @@ set global slow_launch_time =@my_slow_launch_time; set global storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; set global max_allowed_packet =@my_max_allowed_packet; +set global join_buffer_size =@my_join_buffer_size; + # # Bug#28580 Repeatation of status variables # diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 48174a40c21..54410fc3d1e 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -846,7 +846,8 @@ longlong getopt_ll_limit_value(longlong num, const struct my_option *optp, if (num < optp->min_value) { num= optp->min_value; - adjusted= TRUE; + if (old < optp->min_value) + adjusted= TRUE; } if (fix) @@ -917,7 +918,8 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp, if (num < (ulonglong) optp->min_value) { num= (ulonglong) optp->min_value; - adjusted= TRUE; + if (old < optp->min_value) + adjusted= TRUE; } if (fix) From 0165ca88cf3c5b028af4dbfb9edccde6eda87c53 Mon Sep 17 00:00:00 2001 From: Sergey Petrunia Date: Mon, 16 Mar 2009 20:02:55 +0300 Subject: [PATCH 28/88] @@optimizer_switch switch from no_xxx to xxx={on|off} syntax: - Fix valgrind warning on attempt to run a "SET optimizer_switch=number" statement. Need to call c_ptr_safe() as strings returned by non-string items are not necessarily null-terminated. --- sql/set_var.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/set_var.cc b/sql/set_var.cc index 7d20c0f46a7..bc8c91342e6 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3990,7 +3990,7 @@ bool sys_var_thd_optimizer_switch::check(THD *thd, set_var *var) optimizer_switch_typelib.count, thd->variables.optimizer_switch, global_system_variables.optimizer_switch, - res->c_ptr(), res->length(), NULL, + res->c_ptr_safe(), res->length(), NULL, &error, &error_len, ¬_used); if (error_len) { From 076eb7a67acca18aaa68dbac5f1a10b07700097d Mon Sep 17 00:00:00 2001 From: Sergey Petrunia Date: Mon, 16 Mar 2009 20:45:03 +0300 Subject: [PATCH 29/88] Fix wrong parameter name which caused compile failure on windows --- sql/mysql_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index d83c24bf6ca..ba9bee6e054 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1839,7 +1839,7 @@ extern enum_field_types agg_field_type(Item **items, uint nitems); /* strfunc.cc */ ulonglong find_set(TYPELIB *lib, const char *x, uint length, CHARSET_INFO *cs, char **err_pos, uint *err_len, bool *set_warning); -ulonglong find_set_from_flags(TYPELIB *lib, uint default_set, +ulonglong find_set_from_flags(TYPELIB *lib, uint default_name, ulonglong cur_set, ulonglong default_set, const char *str, uint length, CHARSET_INFO *cs, char **err_pos, uint *err_len, bool *set_warning); From 5b9903e1c88cc1b2fb3420598138d23318219517 Mon Sep 17 00:00:00 2001 From: Patrick Crews Date: Mon, 16 Mar 2009 17:36:14 -0400 Subject: [PATCH 30/88] Bug#41307: Tests using include/ndb_backup.inc won't work on Windows due to 'grep' call. Re-recording of .result files for additional tests that use this include file. --- .../suite/ndb/r/ndb_restore_partition.result | 15 +++++++++------ .../suite/ndb_team/r/ndb_dd_backuprestore.result | 15 +++++++++------ .../suite/parts/r/ndb_dd_backuprestore.result | 15 +++++++++------ mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result | 5 +++-- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/mysql-test/suite/ndb/r/ndb_restore_partition.result b/mysql-test/suite/ndb/r/ndb_restore_partition.result index 58a35437a2e..b984c76a91d 100644 --- a/mysql-test/suite/ndb/r/ndb_restore_partition.result +++ b/mysql-test/suite/ndb/r/ndb_restore_partition.result @@ -125,8 +125,9 @@ create table t6 engine=myisam as select * from t6_c; create table t7 engine=myisam as select * from t7_c; create table t8 engine=myisam as select * from t8_c; create table t9 engine=myisam as select * from t9_c; -CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP; -LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; +LOAD DATA INFILE '/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; DROP TABLE test.backup_info; drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; select count(*) from t1; @@ -244,8 +245,9 @@ PARTITION BY LINEAR HASH (`relatta`) PARTITIONS 4; ALTER TABLE t7_c PARTITION BY LINEAR KEY (`dardtestard`); -CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP; -LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; +LOAD DATA INFILE '/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; DROP TABLE test.backup_info; drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; select count(*) from t1; @@ -448,8 +450,9 @@ select * from t9_c) a; count(*) 3 drop table t1_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; -CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP; -LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; +LOAD DATA INFILE '/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; DROP TABLE test.backup_info; Create table test/def/t2_c failed: Translate frm error drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; diff --git a/mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result b/mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result index 102a96a15f4..12a65a433a3 100644 --- a/mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result +++ b/mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result @@ -27,8 +27,9 @@ pk1 c2 c3 hex(c4) 3 Sweden 498 1 4 Sweden 497 1 5 Sweden 496 1 -CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP; -LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; +LOAD DATA INFILE '/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; DROP TABLE test.backup_info; DROP TABLE test.t1; ALTER TABLESPACE table_space1 @@ -91,8 +92,9 @@ LENGTH(data) SELECT LENGTH(data) FROM test.t4 WHERE c1 = 2; LENGTH(data) 16384 -CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP; -LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; +LOAD DATA INFILE '/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; DROP TABLE test.backup_info; DROP TABLE test.t1; DROP TABLE test.t2; @@ -317,8 +319,9 @@ pk1 c2 c3 hex(c4) 248 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 4 1 247 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 6 1 246 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 8 1 -CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP; -LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; +LOAD DATA INFILE '/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; DROP TABLE test.backup_info; DROP TABLE test.t1; DROP TABLE test.t2; diff --git a/mysql-test/suite/parts/r/ndb_dd_backuprestore.result b/mysql-test/suite/parts/r/ndb_dd_backuprestore.result index 102a96a15f4..12a65a433a3 100644 --- a/mysql-test/suite/parts/r/ndb_dd_backuprestore.result +++ b/mysql-test/suite/parts/r/ndb_dd_backuprestore.result @@ -27,8 +27,9 @@ pk1 c2 c3 hex(c4) 3 Sweden 498 1 4 Sweden 497 1 5 Sweden 496 1 -CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP; -LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; +LOAD DATA INFILE '/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; DROP TABLE test.backup_info; DROP TABLE test.t1; ALTER TABLESPACE table_space1 @@ -91,8 +92,9 @@ LENGTH(data) SELECT LENGTH(data) FROM test.t4 WHERE c1 = 2; LENGTH(data) 16384 -CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP; -LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; +LOAD DATA INFILE '/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; DROP TABLE test.backup_info; DROP TABLE test.t1; DROP TABLE test.t2; @@ -317,8 +319,9 @@ pk1 c2 c3 hex(c4) 248 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 4 1 247 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 6 1 246 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 8 1 -CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP; -LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; +LOAD DATA INFILE '/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; DROP TABLE test.backup_info; DROP TABLE test.t1; DROP TABLE test.t2; diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result index c788893e055..3ef5e2b7e53 100644 --- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result +++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result @@ -25,8 +25,9 @@ hex(c2) hex(c3) c1 0 1 BCDEF 1 0 CD 0 0 DEFGHIJKL -CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP; -LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info +(id INT, backup_id INT) ENGINE = MEMORY; +LOAD DATA INFILE '/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; DROP TABLE test.backup_info; UPDATE t1 SET c2=0 WHERE c3="row2"; SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3; From 44f6c2937d1cd39fdb3038cb2cee07b45ab41d4c Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Tue, 17 Mar 2009 11:04:15 +0400 Subject: [PATCH 31/88] Code clean-up. sql/sql_select.cc: the if() separate arguments checks are slightly faster. --- sql/sql_select.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3bf94bc828f..b86eb814eba 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7643,10 +7643,12 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond, /* Check if we eliminated all the predicates of the level, e.g. - (a=a AND b=b AND a=a) + (a=a AND b=b AND a=a). */ - if (!(args->elements + cond_equal.current_level.elements + eq_list.elements)) - return new Item_int((longlong) 1,1); + if (!args->elements && + !cond_equal.current_level.elements && + !eq_list.elements) + return new Item_int((longlong) 1, 1); List_iterator_fast it(cond_equal.current_level); while ((item_equal= it++)) From 8d5c0b9a9b45c840af3fef65a1c1461d19a94802 Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Tue, 17 Mar 2009 14:43:43 +0100 Subject: [PATCH 32/88] Fix for bug 39484 after review. I inserted the review results (also including the patches itself): "Release_lock("hello")" is now also successful when delivering NULL, replaced two sleeps by wait_condition. The last two "sleep 1" have not been replaced as all tried wait conditions leaded to nondeterministic results, especially to succeeding concurrent updates. To replace the sleeps there should be some time planned (or internal knowledge of the server may help). --- mysql-test/include/concurrent.inc | 53 +++++++++++++------ mysql-test/r/concurrent_innodb_safelog.result | 28 +++------- .../r/concurrent_innodb_unsafelog.result | 28 +++------- 3 files changed, 52 insertions(+), 57 deletions(-) diff --git a/mysql-test/include/concurrent.inc b/mysql-test/include/concurrent.inc index 3b34a5b1ede..fe670cef08e 100644 --- a/mysql-test/include/concurrent.inc +++ b/mysql-test/include/concurrent.inc @@ -11,6 +11,11 @@ # $engine_type storage engine to be tested # # Last update: +# 2009-02-13 HH "Release_lock("hello")" is now also successful when delivering NULL, +# replaced two sleeps by wait_condition. The last two "sleep 1" have not been +# replaced as all tried wait conditions leaded to nondeterministic results, especially +# to succeeding concurrent updates. To replace the sleeps there should be some time +# planned (or internal knowledge of the server may help). # 2006-08-02 ML test refactored # old name was t/innodb_concurrent.test # main code went into include/concurrent.inc @@ -21,7 +26,6 @@ # connection default; - # # Show prerequisites for this test. # @@ -50,8 +54,6 @@ GRANT USAGE ON test.* TO mysqltest@localhost; # # Preparatory cleanup. # -DO release_lock("hello"); -DO release_lock("hello2"); --disable_warnings drop table if exists t1; --enable_warnings @@ -86,13 +88,14 @@ drop table if exists t1; connection thread2; --echo ** Start transaction for thread 2 begin; - --echo ** Update will cause a table scan and a new ULL will + --echo ** Update will cause a table scan and a new ULL will --echo ** be created and blocked on the first row where tipo=11. send update t1 set eta=1+get_lock("hello",10)*0 where tipo=11; - sleep 1; --echo ** connection thread1 connection thread1; + let $wait_condition= select count(*)= 1 from information_schema.processlist where state= 'User lock'; + --source include/wait_condition.inc --echo ** Start new transaction for thread 1 begin; --echo ** Update on t1 will cause a table scan which will be blocked because @@ -111,7 +114,9 @@ drop table if exists t1; } --echo ** Release user level name lock from thread 1. This will cause the ULL --echo ** on thread 2 to end its wait. - select release_lock("hello"); +# Due to Bug#32782 User lock hash fails to find lock, which probably also cause Bug#39484 (main.concurrent_innodb_safelog fails sporadically) the success of the following +# is also guaranteed for NULL. Replaced SELECT by DO (no result). + DO release_lock("hello"); --echo ** Table is now updated with a new eta on tipo=22 for thread 1. select * from t1; @@ -119,7 +124,9 @@ drop table if exists t1; connection thread2; --echo ** Release the lock and collect result from update on thread 2 reap; - select release_lock("hello"); +# Due to Bug#32782 User lock hash fails to find lock, which probably also cause Bug#39484 (main.concurrent_innodb_safelog fails sporadically) the success of the following +# is also guaranteed for NULL. Replaced SELECT by DO (no result). + DO release_lock("hello"); --echo ** Table should have eta updates where tipo=11 but updates made by --echo ** thread 1 shouldn't be visible yet. select * from t1; @@ -183,10 +190,11 @@ drop table t1; --echo ** This will cause a hang on the first row where tipo=1 until the --echo ** blocking ULL is released. send update t1 set eta=1+get_lock("hello",10)*0 where tipo=1; - sleep 1; - --echo ** connection thread1 +--echo ** connection thread1 connection thread1; + let $wait_condition= select count(*)= 1 from information_schema.processlist where state= 'User lock'; + --source include/wait_condition.inc --echo ** Start transaction on thread 1 begin; --echo ** Update on t1 will cause a table scan which will be blocked because @@ -204,7 +212,9 @@ drop table t1; update t1 set tipo=1 where tipo=2; } --echo ** Release ULL. This will release the next waiting ULL on thread 2. - select release_lock("hello"); +# Due to Bug#32782 User lock hash fails to find lock, which probably also cause Bug#39484 (main.concurrent_innodb_safelog fails sporadically)the success of the following +# is also guaranteed for NULL. Replaced SELECT by DO (no result). + DO release_lock("hello"); --echo ** The table should still be updated with updates for thread 1 only: select * from t1; @@ -212,7 +222,9 @@ drop table t1; connection thread2; --echo ** Release the lock and collect result from thread 2: reap; - select release_lock("hello"); +# Due to Bug#32782 User lock hash fails to find lock, which probably also cause Bug#39484 (main.concurrent_innodb_safelog fails sporadically) the success of the following +# is also guaranteed for NULL. Replaced SELECT by DO (no result). + DO release_lock("hello"); --echo ** Seen from thread 2 the table should have been updated on four --echo ** places. select * from t1; @@ -264,15 +276,18 @@ drop table t1; --echo ** Update will create a table scan which creates a ULL where a=2; --echo ** this will hang waiting on thread 1. send update t1 set b=10+get_lock(concat("hello",a),10)*0 where a=2; - sleep 1; --echo ** connection thread1 connection thread1; + let $wait_condition= select count(*)= 1 from information_schema.processlist where state= 'User lock'; + --source include/wait_condition.inc --echo ** Insert new values to t1 from thread 1; this created an implicit --echo ** commit since there are no on-going transactions. insert into t1 values (1,1); --echo ** Release the ULL (thread 2 updates will finish). - select release_lock("hello2"); +# Due to Bug#32782 User lock hash fails to find lock, which probably also cause Bug#39484 (main.concurrent_innodb_safelog fails sporadically) the success of the following +# is also guaranteed for NULL. Replaced SELECT by DO (no result). + DO release_lock("hello2"); --echo ** ..but thread 1 will still see t1 as if nothing has happend: select * from t1; @@ -280,7 +295,9 @@ drop table t1; connection thread2; --echo ** Collect results from thread 2 and release the lock. reap; - select release_lock("hello2"); +# Due to Bug#32782 User lock hash fails to find lock, which probably also cause Bug#39484 (main.concurrent_innodb_safelog fails sporadically) the success of the following +# is also guaranteed for NULL. Replaced SELECT by DO (no result). + DO release_lock("hello2"); --echo ** The table should look like the original+updates for thread 2, --echo ** and consist of new rows: select * from t1; @@ -534,6 +551,9 @@ drop table t1; connection thread2; begin; send delete from t1 where tipo=2; +# The sleep has not been replaced as all tried wait conditions leaded to sporadically +# succeding update in the following thread. Also the used status variables '%lock%' and +# 'innodb_deleted_rows' and infos in processlist where not sucessful. sleep 1; --echo ** connection thread1 @@ -594,8 +614,11 @@ drop table t1; connection thread2; begin; send delete from t1 where tipo=2; +# The sleep has not been replaced as all tried wait conditions leaded to sporadically +# succeding update in the following thread. Also the used status variables '%lock%' and +# 'innodb_deleted_rows' and infos in processlist where not sucessful. sleep 1; - + --echo ** connection thread1 connection thread1; begin; diff --git a/mysql-test/r/concurrent_innodb_safelog.result b/mysql-test/r/concurrent_innodb_safelog.result index 92d274993d9..e6adaac1068 100644 --- a/mysql-test/r/concurrent_innodb_safelog.result +++ b/mysql-test/r/concurrent_innodb_safelog.result @@ -7,8 +7,6 @@ SELECT @@global.innodb_locks_unsafe_for_binlog; 0 # keep_locks == 1 GRANT USAGE ON test.* TO mysqltest@localhost; -DO release_lock("hello"); -DO release_lock("hello2"); drop table if exists t1; ** @@ -36,7 +34,7 @@ get_lock("hello",10) ** connection thread2 ** Start transaction for thread 2 begin; -** Update will cause a table scan and a new ULL will +** Update will cause a table scan and a new ULL will ** be created and blocked on the first row where tipo=11. update t1 set eta=1+get_lock("hello",10)*0 where tipo=11; ** connection thread1 @@ -51,9 +49,7 @@ update t1 set eta=2 where tipo=22; ERROR HY000: Lock wait timeout exceeded; try restarting transaction ** Release user level name lock from thread 1. This will cause the ULL ** on thread 2 to end its wait. -select release_lock("hello"); -release_lock("hello") -1 +DO release_lock("hello"); ** Table is now updated with a new eta on tipo=22 for thread 1. select * from t1; eta tipo c @@ -70,9 +66,7 @@ eta tipo c 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk ** connection thread2 ** Release the lock and collect result from update on thread 2 -select release_lock("hello"); -release_lock("hello") -1 +DO release_lock("hello"); ** Table should have eta updates where tipo=11 but updates made by ** thread 1 shouldn't be visible yet. select * from t1; @@ -194,9 +188,7 @@ begin; update t1 set tipo=1 where tipo=2; ERROR HY000: Lock wait timeout exceeded; try restarting transaction ** Release ULL. This will release the next waiting ULL on thread 2. -select release_lock("hello"); -release_lock("hello") -1 +DO release_lock("hello"); ** The table should still be updated with updates for thread 1 only: select * from t1; eta tipo c @@ -213,9 +205,7 @@ eta tipo c 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk ** connection thread2 ** Release the lock and collect result from thread 2: -select release_lock("hello"); -release_lock("hello") -1 +DO release_lock("hello"); ** Seen from thread 2 the table should have been updated on four ** places. select * from t1; @@ -319,9 +309,7 @@ update t1 set b=10+get_lock(concat("hello",a),10)*0 where a=2; ** commit since there are no on-going transactions. insert into t1 values (1,1); ** Release the ULL (thread 2 updates will finish). -select release_lock("hello2"); -release_lock("hello2") -1 +DO release_lock("hello2"); ** ..but thread 1 will still see t1 as if nothing has happend: select * from t1; a b @@ -332,9 +320,7 @@ a b 1 1 ** connection thread2 ** Collect results from thread 2 and release the lock. -select release_lock("hello2"); -release_lock("hello2") -1 +DO release_lock("hello2"); ** The table should look like the original+updates for thread 2, ** and consist of new rows: select * from t1; diff --git a/mysql-test/r/concurrent_innodb_unsafelog.result b/mysql-test/r/concurrent_innodb_unsafelog.result index 2a6c15d38c1..e9c53d4cfa0 100644 --- a/mysql-test/r/concurrent_innodb_unsafelog.result +++ b/mysql-test/r/concurrent_innodb_unsafelog.result @@ -7,8 +7,6 @@ SELECT @@global.innodb_locks_unsafe_for_binlog; 1 # keep_locks == 0 GRANT USAGE ON test.* TO mysqltest@localhost; -DO release_lock("hello"); -DO release_lock("hello2"); drop table if exists t1; ** @@ -36,7 +34,7 @@ get_lock("hello",10) ** connection thread2 ** Start transaction for thread 2 begin; -** Update will cause a table scan and a new ULL will +** Update will cause a table scan and a new ULL will ** be created and blocked on the first row where tipo=11. update t1 set eta=1+get_lock("hello",10)*0 where tipo=11; ** connection thread1 @@ -50,9 +48,7 @@ begin; update t1 set eta=2 where tipo=22; ** Release user level name lock from thread 1. This will cause the ULL ** on thread 2 to end its wait. -select release_lock("hello"); -release_lock("hello") -1 +DO release_lock("hello"); ** Table is now updated with a new eta on tipo=22 for thread 1. select * from t1; eta tipo c @@ -69,9 +65,7 @@ eta tipo c 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk ** connection thread2 ** Release the lock and collect result from update on thread 2 -select release_lock("hello"); -release_lock("hello") -1 +DO release_lock("hello"); ** Table should have eta updates where tipo=11 but updates made by ** thread 1 shouldn't be visible yet. select * from t1; @@ -192,9 +186,7 @@ begin; ** do not match the WHERE condition are released. update t1 set tipo=1 where tipo=2; ** Release ULL. This will release the next waiting ULL on thread 2. -select release_lock("hello"); -release_lock("hello") -1 +DO release_lock("hello"); ** The table should still be updated with updates for thread 1 only: select * from t1; eta tipo c @@ -211,9 +203,7 @@ eta tipo c 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk ** connection thread2 ** Release the lock and collect result from thread 2: -select release_lock("hello"); -release_lock("hello") -1 +DO release_lock("hello"); ** Seen from thread 2 the table should have been updated on four ** places. select * from t1; @@ -317,9 +307,7 @@ update t1 set b=10+get_lock(concat("hello",a),10)*0 where a=2; ** commit since there are no on-going transactions. insert into t1 values (1,1); ** Release the ULL (thread 2 updates will finish). -select release_lock("hello2"); -release_lock("hello2") -1 +DO release_lock("hello2"); ** ..but thread 1 will still see t1 as if nothing has happend: select * from t1; a b @@ -330,9 +318,7 @@ a b 1 1 ** connection thread2 ** Collect results from thread 2 and release the lock. -select release_lock("hello2"); -release_lock("hello2") -1 +DO release_lock("hello2"); ** The table should look like the original+updates for thread 2, ** and consist of new rows: select * from t1; From fb4e68b6870401f1c87e5efb2d4b2a70911b363f Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Tue, 17 Mar 2009 18:24:35 +0100 Subject: [PATCH 33/88] 36446: fix Windows warning --- mysys/my_getopt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 54410fc3d1e..4b74cdbf266 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -918,7 +918,7 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp, if (num < (ulonglong) optp->min_value) { num= (ulonglong) optp->min_value; - if (old < optp->min_value) + if (old < (ulonglong) optp->min_value) adjusted= TRUE; } From 9e655bfffcda0a016943c96c4d911049d38f4c40 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 17 Mar 2009 23:28:24 +0100 Subject: [PATCH 34/88] Bug #43715 Link errors when trying to link mysql_embedded.exe The reason for the error is incorrectly specified link dependencies for mysql_embedded, mysqltest_embedded and mysql_client_test_embedded in CMakeLists.txt (ADD_DEPENDENCIES should be TARGET_LINK_LIBRARIES) libmysqld/CMakeLists.txt: changed library type for libmysqld to SHARED instead of MODULE. MODULE in CMake notation is a shared library that is used only in dlopen/dlsym/LoadLibrary scenarios. Hence it was impossible to use TARGET_LINK_LIBRARIES with a MODULE. libmysqld/examples/CMakeLists.txt: Use TARGET_LINK_LIBRARIES (instead of previously incorrectly used ADD_DEPENDENCIES) to specify link dependency from libmysqld --- libmysqld/CMakeLists.txt | 2 +- libmysqld/examples/CMakeLists.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index 1582f0898d8..1c8f80768d4 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -201,6 +201,6 @@ ADD_LIBRARY(mysqlserver STATIC ${LIBMYSQLD_SOURCES}) ADD_DEPENDENCIES(mysqlserver GenServerSource GenError) TARGET_LINK_LIBRARIES(mysqlserver) -ADD_LIBRARY(libmysqld MODULE cmake_dummy.c libmysqld.def) +ADD_LIBRARY(libmysqld SHARED cmake_dummy.c libmysqld.def) ADD_DEPENDENCIES(libmysqld mysqlserver) TARGET_LINK_LIBRARIES(libmysqld mysqlserver wsock32) diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt index fa9711b54da..5194836a728 100644 --- a/libmysqld/examples/CMakeLists.txt +++ b/libmysqld/examples/CMakeLists.txt @@ -30,12 +30,12 @@ ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc ../../client/mysql.cc ../../client/readline.cc ../../client/sql_string.cc) TARGET_LINK_LIBRARIES(mysql_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32) -ADD_DEPENDENCIES(mysql_embedded libmysqld) +TARGET_LINK_LIBRARIES(mysql_embedded libmysqld) ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc) TARGET_LINK_LIBRARIES(mysqltest_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32) -ADD_DEPENDENCIES(mysqltest_embedded libmysqld) +TARGET_LINK_LIBRARIES(mysqltest_embedded libmysqld) ADD_EXECUTABLE(mysql_client_test_embedded ../../tests/mysql_client_test.c) TARGET_LINK_LIBRARIES(mysql_client_test_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32) -ADD_DEPENDENCIES(mysql_client_test_embedded libmysqld) +TARGET_LINK_LIBRARIES(mysql_client_test_embedded libmysqld) From 497db6ac0f1efb1a962158d9ee108b0236b88e5c Mon Sep 17 00:00:00 2001 From: Satya B Date: Wed, 18 Mar 2009 11:16:21 +0530 Subject: [PATCH 35/88] Fix for BUG#32880 - Repairing Archive table fails with internal error 144 Any statement reading corrupt archive data file (CHECK/REPAIR/SELECT/UPDATE/DELETE) may cause assertion failure in debug builds. This assertion has been removed and an error is returned instead. Also fixed that CHECK/REPAIR returns vague error message when it mets corruption in archive data file. This is fixed by returning proper error code. mysql-test/r/archive.result: A test case for BUG#32880 mysql-test/std_data/bug32880.ARN: corrupted archive table to test check and repair table operation mysql-test/std_data/bug32880.ARZ: corrupted archive table to test check and repair table operation mysql-test/std_data/bug32880.frm: corrupted archive table to test check and repair table operation mysql-test/t/archive.test: A test case for BUG#32880 storage/archive/ha_archive.cc: Fixed unpack_row() to return the error instead of throwing assertion and also fixed repair() to throw better error when repair table operation fails on corrupted archive table --- mysql-test/r/archive.result | 19 +++++++++++++++++++ mysql-test/std_data/bug32880.ARN | Bin 0 -> 131 bytes mysql-test/std_data/bug32880.ARZ | Bin 0 -> 8744 bytes mysql-test/std_data/bug32880.frm | Bin 0 -> 8578 bytes mysql-test/t/archive.test | 15 +++++++++++++++ storage/archive/ha_archive.cc | 6 ++---- 6 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 mysql-test/std_data/bug32880.ARN create mode 100644 mysql-test/std_data/bug32880.ARZ create mode 100644 mysql-test/std_data/bug32880.frm diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index 8c26ea1ff82..02acccb234e 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -12695,3 +12695,22 @@ a b 1 NULL 2 NULL DROP TABLE t1; +# +# BUG#32880 - Repairing Archive table fails with internal error 144 +# + +# Test with an existing table which is corrupted +# Copy t1 from std_data +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` blob +) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check error Corrupt +REPAIR TABLE t1; +Table Op Msg_type Msg_text +test.t1 repair error Corrupt +DROP TABLE t1; diff --git a/mysql-test/std_data/bug32880.ARN b/mysql-test/std_data/bug32880.ARN new file mode 100644 index 0000000000000000000000000000000000000000..643b0dfbad59af05495571978acc8b5eeaf8b509 GIT binary patch literal 131 zcmeyz%qYO%$AAi8dqei4wVSWE@5vi;Yx=ZHHrNyljV=3 gvkA%YRCc;{PVKA|P+c6Av6_|P_LJg8GZ+~d03i_-e*gdg literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/bug32880.ARZ b/mysql-test/std_data/bug32880.ARZ new file mode 100644 index 0000000000000000000000000000000000000000..4e151822647f1b7e0f3f2b9952ef543f9a7954ce GIT binary patch literal 8744 zcmeI&ze>YE90%}kE^WOwLQ_+U|G-v?pi7-QR7DDkP{ct*5RxuFL%>0bOI#ep7w|I1m=0(}aH((^7}($&Gi!uKHg{qC2`-SL@!GuQDk05EFlmmMEA5AD2YV{h9gHUv8Q z`pMQ~=9GO`*BoHqe5%gZ3yCt2?j*CS`S)`S)UraS12nSrP z3Q&Lo|5iXi<#(HBwzPz!i{q2i%YMFu2?Z!X0SZun0u-PC1t>rP3Q&Lo3nnmf(tdyi zyY=5)*MUG6rY)k1Qoiju8oF*q7p@TX-R3U`3J{U*nGi!1gy)$}HtzK{uI`{H3MtJQ zwTC(|Jpfdsh6=j-!j4H4hF@dZzFK<>&h~=%@NQ@It^K_9ep_1ET#l1|@{+`fS*+Bg Wb>pSU>r>;WvOc)BNhQ>$RK5X*A2h-M literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/bug32880.frm b/mysql-test/std_data/bug32880.frm new file mode 100644 index 0000000000000000000000000000000000000000..66a4c7d7538ef06353e4b38b8699203736844857 GIT binary patch literal 8578 zcmeI&u?oU45C-5s*H%+Hw8i4$($%TXT|`9CO&r|YClT?@dj)_ z@U6LrNs9<546x7zIYNj<3M77Shhm}0?Fy7bp=p46*l?u)1t>rP3Q&Lo6rcbFC_n)U zP~d9?1TMVooxMt9tPbn#?zjm@m{5QM6rcbFC_n)UP=Epypa2CZ@M8jJqo4kN90r0G z6BWoY3J!ZrweF)uBvQ@m4+Alz)0qkB5lfc&CbN^aiFAS@5o`S&<)s4dOTcxmcX$FK Cm=+HJ literal 0 HcmV?d00001 diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 7139d95ab49..0d521f95b38 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1599,3 +1599,18 @@ INSERT INTO t1 VALUES (NULL, NULL),(NULL, NULL); FLUSH TABLE t1; SELECT * FROM t1 ORDER BY a; DROP TABLE t1; + +--echo # +--echo # BUG#32880 - Repairing Archive table fails with internal error 144 +--echo # +--echo +--echo # Test with an existing table which is corrupted +--echo # Copy t1 from std_data +let $MYSQLD_DATADIR= `select @@datadir`; +copy_file std_data/bug32880.frm $MYSQLD_DATADIR/test/t1.frm; +copy_file std_data/bug32880.ARZ $MYSQLD_DATADIR/test/t1.ARZ; +copy_file std_data/bug32880.ARN $MYSQLD_DATADIR/test/t1.ARN; +SHOW CREATE TABLE t1; +CHECK TABLE t1; +REPAIR TABLE t1; +DROP TABLE t1; diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 7edfca53751..d20ab3bf723 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1076,11 +1076,9 @@ int ha_archive::unpack_row(azio_stream *file_to_read, uchar *record) read= azread(file_to_read, record_buffer->buffer, row_len, &error); - DBUG_ASSERT(row_len == read); - if (read != row_len || error) { - DBUG_RETURN(-1); + DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); } /* Copy null bits */ @@ -1257,7 +1255,7 @@ int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt) int rc= optimize(thd, check_opt); if (rc) - DBUG_RETURN(HA_ERR_CRASHED_ON_REPAIR); + DBUG_RETURN(HA_ADMIN_CORRUPT); share->crashed= FALSE; DBUG_RETURN(0); From 73a7d99331d8fd0819fb9f7a10081e393590a94d Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 18 Mar 2009 11:18:24 +0300 Subject: [PATCH 36/88] Fix for bug#41486: extra character appears in BLOB for every ~40Mb after mysqldump/import When the input string exceeds the maximum allowed size for the internal buffer, batch_readline() returns a truncated string. Since there was no way for a caller to determine whether the string was truncated or not, the command line client assumed batch_readline() to always return the whole input string and appended a newline character. This resulted in garbled data when importing dumps containing strings longer than the maximum input buffer size. Fixed by adding a flag to the batch_readline() interface to signal a truncated string to the caller. Other minor problems fixed during patch implementation: - The maximum allowed buffer size for batch_readline() was set up depending on the client's max_allowed_packet value. It does not actully make any sense, as those variables are not related. The input buffer size limit is now always set to 1 MB. - fill_buffer() did not always set the EOF flag. - The input buffer could actually grow twice as the specified limit due to insufficient checks in intern_read_line(). client/my_readline.h: Changed the interface of batch_readline(). client/mysql.cc: Honor the truncated flag returned by batch_readline() and do not append the newline character if it was set. Since we can't change the interfaces for readline()/fgets() used in the interactive mode, always assume the returned string was not truncated. In addition, always set the batch_readline() internal buffer to 1 MB, independently from the client's max_allowed_packet. client/readline.cc: Added the 'truncated' argument do batch_readline() to signal truncated string to a caller. Fixed fill_buffer() to set the EOF flag correctly. Fixed checks in intern_read_line() to not allow the internal buffer grow past the specified limit. mysql-test/r/mysql.result: Added a test case for bug #41486. mysql-test/t/mysql.test: Added a test case for bug #41486. --- client/my_readline.h | 2 +- client/mysql.cc | 22 +++++++++++-------- client/readline.cc | 46 +++++++++++++++++++++++++++++---------- mysql-test/r/mysql.result | 11 ++++++++++ mysql-test/t/mysql.test | 27 +++++++++++++++++++++++ 5 files changed, 86 insertions(+), 22 deletions(-) diff --git a/client/my_readline.h b/client/my_readline.h index 47be7fa9294..32d6da4c626 100644 --- a/client/my_readline.h +++ b/client/my_readline.h @@ -29,5 +29,5 @@ typedef struct st_line_buffer extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file); extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, my_string str); -extern char *batch_readline(LINE_BUFFER *buffer); +extern char *batch_readline(LINE_BUFFER *buffer, bool *truncated); extern void batch_readline_end(LINE_BUFFER *buffer); diff --git a/client/mysql.cc b/client/mysql.cc index 1a025345190..0a4587d1c92 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -112,6 +112,8 @@ extern "C" { #define PROMPT_CHAR '\\' #define DEFAULT_DELIMITER ";" +#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L) + typedef struct st_status { int exit_status; @@ -1035,7 +1037,7 @@ static void fix_history(String *final_command); static COMMANDS *find_command(char *name,char cmd_name); static bool add_line(String &buffer,char *line,char *in_string, - bool *ml_comment); + bool *ml_comment, bool truncated); static void remove_cntrl(String &buffer); static void print_table_data(MYSQL_RES *result); static void print_table_data_html(MYSQL_RES *result); @@ -1117,7 +1119,7 @@ int main(int argc,char *argv[]) exit(1); } if (status.batch && !status.line_buff && - !(status.line_buff=batch_readline_init(opt_max_allowed_packet+512,stdin))) + !(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, stdin))) { free_defaults(defaults_argv); my_end(0); @@ -1766,13 +1768,14 @@ static int read_and_execute(bool interactive) ulong line_number=0; bool ml_comment= 0; COMMANDS *com; + bool truncated= 0; status.exit_status=1; for (;;) { if (!interactive) { - line=batch_readline(status.line_buff); + line=batch_readline(status.line_buff, &truncated); /* Skip UTF8 Byte Order Marker (BOM) 0xEFBBBF. Editors like "notepad" put this marker in @@ -1891,7 +1894,7 @@ static int read_and_execute(bool interactive) #endif continue; } - if (add_line(glob_buffer,line,&in_string,&ml_comment)) + if (add_line(glob_buffer,line,&in_string,&ml_comment, truncated)) break; } /* if in batch mode, send last query even if it doesn't end with \g or go */ @@ -1977,7 +1980,7 @@ static COMMANDS *find_command(char *name,char cmd_char) static bool add_line(String &buffer,char *line,char *in_string, - bool *ml_comment) + bool *ml_comment, bool truncated) { uchar inchar; char buff[80], *pos, *out; @@ -2224,9 +2227,10 @@ static bool add_line(String &buffer,char *line,char *in_string, { uint length=(uint) (out-line); - if (length < 9 || - my_strnncoll (charset_info, - (uchar *)line, 9, (const uchar *) "delimiter", 9)) + if (!truncated && + (length < 9 || + my_strnncoll (charset_info, + (uchar *)line, 9, (const uchar *) "delimiter", 9))) { /* Don't add a new line in case there's a DELIMITER command to be @@ -3886,7 +3890,7 @@ static int com_source(String *buffer, char *line) return put_info(buff, INFO_ERROR, 0); } - if (!(line_buff=batch_readline_init(opt_max_allowed_packet+512,sql_file))) + if (!(line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, sql_file))) { my_fclose(sql_file,MYF(0)); return put_info("Can't initialize batch_readline", INFO_ERROR, 0); diff --git a/client/readline.cc b/client/readline.cc index ad42ed2ee10..726d9cd9415 100644 --- a/client/readline.cc +++ b/client/readline.cc @@ -24,7 +24,7 @@ static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size, ulong max_size); static bool init_line_buffer_from_string(LINE_BUFFER *buffer,my_string str); static uint fill_buffer(LINE_BUFFER *buffer); -static char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length); +static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated); LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file) @@ -42,12 +42,13 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file) } -char *batch_readline(LINE_BUFFER *line_buff) +char *batch_readline(LINE_BUFFER *line_buff, bool *truncated) { char *pos; ulong out_length; + DBUG_ASSERT(truncated != NULL); - if (!(pos=intern_read_line(line_buff,&out_length))) + if (!(pos=intern_read_line(line_buff,&out_length, truncated))) return 0; if (out_length && pos[out_length-1] == '\n') if (--out_length && pos[out_length-1] == '\r') /* Remove '\n' */ @@ -149,6 +150,14 @@ static uint fill_buffer(LINE_BUFFER *buffer) read_count=(buffer->bufread - bufbytes)/IO_SIZE; if ((read_count*=IO_SIZE)) break; + if (buffer->bufread * 2 > buffer->max_size) + { + /* + So we must grow the buffer but we cannot due to the max_size limit. + Return 0 w/o setting buffer->eof to signal this condition. + */ + return 0; + } buffer->bufread *= 2; if (!(buffer->buffer = (char*) my_realloc(buffer->buffer, buffer->bufread+1, @@ -172,11 +181,15 @@ static uint fill_buffer(LINE_BUFFER *buffer) DBUG_PRINT("fill_buff", ("Got %d bytes", read_count)); - /* Kludge to pretend every nonempty file ends with a newline. */ - if (!read_count && bufbytes && buffer->end[-1] != '\n') + if (!read_count) { - buffer->eof = read_count = 1; - *buffer->end = '\n'; + buffer->eof = 1; + /* Kludge to pretend every nonempty file ends with a newline. */ + if (bufbytes && buffer->end[-1] != '\n') + { + read_count = 1; + *buffer->end = '\n'; + } } buffer->end_of_line=(buffer->start_of_line=buffer->buffer)+bufbytes; buffer->end+=read_count; @@ -186,7 +199,7 @@ static uint fill_buffer(LINE_BUFFER *buffer) -char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length) +char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated) { char *pos; uint length; @@ -200,14 +213,23 @@ char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length) pos++; if (pos == buffer->end) { - if ((uint) (pos - buffer->start_of_line) < buffer->max_size) + /* + fill_buffer() can return 0 either on EOF in which case we abort + or when the internal buffer has hit the size limit. In the latter case + return what we have read so far and signal string truncation. + */ + if (!(length=fill_buffer(buffer)) || length == (uint) -1) { - if (!(length=fill_buffer(buffer)) || length == (uint) -1) - DBUG_RETURN(0); - continue; + if (buffer->eof) + DBUG_RETURN(0); } + else + continue; pos--; /* break line here */ + *truncated= 1; } + else + *truncated= 0; buffer->end_of_line=pos+1; *out_length=(ulong) (pos + 1 - buffer->eof - buffer->start_of_line); DBUG_RETURN(buffer->start_of_line); diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 10537f6da16..a6087e0134b 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -192,4 +192,15 @@ delimiter 1 1 1 +set @old_max_allowed_packet = @@global.max_allowed_packet; +set @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024; +set @@max_allowed_packet = @@global.max_allowed_packet; +CREATE TABLE t1(data LONGBLOB); +INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024); +SELECT LENGTH(data) FROM t1; +LENGTH(data) +2097152 +DROP TABLE t1; +set @@global.max_allowed_packet = @old_max_allowed_packet; +set @@max_allowed_packet = @@global.max_allowed_packet; End of 5.0 tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 594d10e46a5..0030f624be6 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -331,4 +331,31 @@ EOF remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql; +# +# Bug #41486: extra character appears in BLOB for every ~40Mb after +# mysqldump/import +# + +# Have to change the global variable as the mysql client will use +# a separate session +set @old_max_allowed_packet = @@global.max_allowed_packet; +# 2 MB blob length + some space for the rest of INSERT query +set @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024; +set @@max_allowed_packet = @@global.max_allowed_packet; + +CREATE TABLE t1(data LONGBLOB); +INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024); + +--exec $MYSQL_DUMP test t1 >$MYSQLTEST_VARDIR/tmp/bug41486.sql +# Check that the mysql client does not insert extra newlines when loading +# strings longer than client's max_allowed_packet +--exec $MYSQL --max_allowed_packet=1M test < $MYSQLTEST_VARDIR/tmp/bug41486.sql 2>&1 +SELECT LENGTH(data) FROM t1; + +remove_file $MYSQLTEST_VARDIR/tmp/bug41486.sql; +DROP TABLE t1; + +set @@global.max_allowed_packet = @old_max_allowed_packet; +set @@max_allowed_packet = @@global.max_allowed_packet; + --echo End of 5.0 tests From b97083dfc76eac4dab7566786ae875ce8a1415ba Mon Sep 17 00:00:00 2001 From: Alfranio Correia Date: Wed, 18 Mar 2009 10:31:17 +0000 Subject: [PATCH 37/88] Bug #42861 Assigning invalid directories to --slave-load-tmpdir crashes the slave Compiling with debug and assigning an invalid directory to --slave-load-tmpdir was crashing the slave due to the following assertion DBUG_ASSERT(! is_set() || can_overwrite_status). This assertion assumes that a thread can change its state once (i.e. ok,error, etc) before aborting, cleaning/resuming or completing its execution unless the overwrite flag (i.e. can_overwrite_status) is true. The Append_block_log_event::do_apply_event which is responsible for creating temporary file(s) was not cleaning the thread state. Thus a failure while trying to create a file in an invalid temporary directory was causing the crash. To fix the problem we check if the temporary directory is valid before starting the SQL Thread and reset the thread state before creating a file in Append_block_log_event::do_apply_event. --- .../suite/rpl/r/rpl_slave_load_in.result | 9 ++++ .../r/rpl_slave_load_remove_tmpfile.result | 15 ++++++ .../r/rpl_slave_load_tmpdir_not_exist.result | 2 + mysql-test/suite/rpl/t/rpl_slave_load_in.test | 19 +++++++- .../t/rpl_slave_load_remove_tmpfile-slave.opt | 1 + .../rpl/t/rpl_slave_load_remove_tmpfile.test | 46 +++++++++++++++++++ .../rpl_slave_load_tmpdir_not_exist-slave.opt | 1 + .../t/rpl_slave_load_tmpdir_not_exist.test | 15 ++++++ sql/log_event.cc | 12 ++++- sql/slave.cc | 43 +++++++++++++++++ 10 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result create mode 100644 mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result create mode 100644 mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile-slave.opt create mode 100644 mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test create mode 100644 mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist-slave.opt create mode 100644 mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test diff --git a/mysql-test/suite/rpl/r/rpl_slave_load_in.result b/mysql-test/suite/rpl/r/rpl_slave_load_in.result index 0685d024f26..2cc83fd0a19 100644 --- a/mysql-test/suite/rpl/r/rpl_slave_load_in.result +++ b/mysql-test/suite/rpl/r/rpl_slave_load_in.result @@ -5,6 +5,15 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; create table t1(a int not null auto_increment, b int, primary key(a)); +create table t2(a int not null auto_increment, b int, primary key(a)) engine=innodb; load data infile '../../std_data/rpl_loaddata.dat' into table t1; +start transaction; +insert into t2(b) values (1); +insert into t2(b) values (2); +load data infile '../../std_data/rpl_loaddata.dat' into table t2; +load data infile '../../std_data/rpl_loaddata.dat' into table t2; +commit; Comparing tables master:test.t1 and slave:test.t1 +Comparing tables master:test.t2 and slave:test.t2 drop table t1; +drop table t2; diff --git a/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result b/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result new file mode 100644 index 00000000000..abb6a598c53 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result @@ -0,0 +1,15 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +create table t1(a int not null auto_increment, b int, primary key(a)) engine=innodb; +start transaction; +insert into t1(b) values (1); +insert into t1(b) values (2); +load data infile '../../std_data/rpl_loaddata.dat' into table t1; +commit; +Error in Begin_load_query event: write to '../../tmp/SQL_LOAD-2-1-1.data' failed +drop table t1; +drop table t1; 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 new file mode 100644 index 00000000000..4cd2cfd33d7 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result @@ -0,0 +1,2 @@ +start slave; +Unable to use slave's temporary directory ../../../error - Can't read dir of '../../../error' (Errcode: 2) diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_in.test b/mysql-test/suite/rpl/t/rpl_slave_load_in.test index f920c136d43..54ebdffce69 100644 --- a/mysql-test/suite/rpl/t/rpl_slave_load_in.test +++ b/mysql-test/suite/rpl/t/rpl_slave_load_in.test @@ -3,10 +3,11 @@ # event while the "--secure-file-priv" option is set. # # The test is divided in two steps: -# 1 - Creates a table and populates it through "LOAD DATA INFILE". +# 1 - Creates tables and populates them through "LOAD DATA INFILE". # 2 - Compares the master and slave. ########################################################################## -source include/master-slave.inc; +--source include/have_innodb.inc +--source include/master-slave.inc ########################################################################## # Loading data @@ -14,8 +15,17 @@ source include/master-slave.inc; connection master; create table t1(a int not null auto_increment, b int, primary key(a)); +create table t2(a int not null auto_increment, b int, primary key(a)) engine=innodb; + load data infile '../../std_data/rpl_loaddata.dat' into table t1; +start transaction; + insert into t2(b) values (1); + insert into t2(b) values (2); + load data infile '../../std_data/rpl_loaddata.dat' into table t2; + load data infile '../../std_data/rpl_loaddata.dat' into table t2; +commit; + ########################################################################## # Checking Consistency ########################################################################## @@ -25,11 +35,16 @@ let $diff_table_1=master:test.t1; let $diff_table_2=slave:test.t1; source include/diff_tables.inc; +let $diff_table_1=master:test.t2; +let $diff_table_2=slave:test.t2; +source include/diff_tables.inc; + ########################################################################## # Clean up ########################################################################## connection master; drop table t1; +drop table t2; sync_slave_with_master; diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile-slave.opt b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile-slave.opt new file mode 100644 index 00000000000..51e410f911f --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile-slave.opt @@ -0,0 +1 @@ +--loose-debug=d,remove_slave_load_file_before_write diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test new file mode 100644 index 00000000000..be7741f2e4b --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test @@ -0,0 +1,46 @@ +########################################################################## +# This test verifies if the slave fails gracefully when the temporary +# file used to load data is removed while it is about to be used it. +# Similar errors are caught if the temporary directory is removed. +# +# Steps: +# 1 - Creates a table and populates it through "LOAD DATA INFILE". +# 2 - Catches error. +########################################################################## +--source include/have_binlog_format_mixed_or_statement.inc +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/master-slave.inc + +########################################################################## +# Loading data +########################################################################## +connection master; + +create table t1(a int not null auto_increment, b int, primary key(a)) engine=innodb; + +start transaction; + insert into t1(b) values (1); + insert into t1(b) values (2); + load data infile '../../std_data/rpl_loaddata.dat' into table t1; +commit; + +########################################################################## +# Catch Error +########################################################################## +connection slave; +source include/wait_for_slave_sql_to_stop.inc; + +let $error=query_get_value("show slave status", Last_SQL_Error, 1); +echo $error; + +########################################################################## +# Clean up +########################################################################## +connection master; + +drop table t1; + +connection slave; + +drop table t1; diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist-slave.opt b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist-slave.opt new file mode 100644 index 00000000000..c4f91e97e3e --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist-slave.opt @@ -0,0 +1 @@ +--slave-load-tmpdir=../../../error 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 new file mode 100644 index 00000000000..dbdb8e79e4e --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test @@ -0,0 +1,15 @@ +########################################################################## +# This test verifies if the start slave fails gracefuly when an +# invalid directory is used to set --slave-load-tmpdir. +########################################################################## +connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,); +connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,); +connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,); +connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,); + +connection slave; +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; diff --git a/sql/log_event.cc b/sql/log_event.cc index 1941a304e8e..1cfbcfc2e0e 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -382,7 +382,7 @@ static void cleanup_load_tmpdir() uint i; char fname[FN_REFLEN], prefbuf[31], *p; - if (!(dirp=my_dir(slave_load_tmpdir,MYF(MY_WME)))) + if (!(dirp=my_dir(slave_load_tmpdir,MYF(0)))) return; /* @@ -6178,6 +6178,12 @@ int Append_block_log_event::do_apply_event(Relay_log_info const *rli) thd_proc_info(thd, proc_info); if (get_create_or_append()) { + /* + Usually lex_start() is called by mysql_parse(), but we need it here + as the present method does not call mysql_parse(). + */ + lex_start(thd); + mysql_reset_thd_for_next_command(thd); my_delete(fname, MYF(0)); // old copy may exist already if ((fd= my_create(fname, CREATE_MODE, O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, @@ -6197,6 +6203,10 @@ int Append_block_log_event::do_apply_event(Relay_log_info const *rli) get_type_str(), fname); goto err; } + + DBUG_EXECUTE_IF("remove_slave_load_file_before_write", + my_close(fd,MYF(0)); fd= -1; my_delete(fname, MYF(0));); + if (my_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP))) { rli->report(ERROR_LEVEL, my_errno, diff --git a/sql/slave.cc b/sql/slave.cc index 22c61b3ec6c..8c29cb8a72f 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2632,6 +2632,41 @@ err: DBUG_RETURN(0); // Can't return anything here } +/* + Check the temporary directory used by commands like + LOAD DATA INFILE. + */ +static +int check_temp_dir(char* tmp_dir, char *tmp_file) +{ + int fd; + MY_DIR *dirp; + + DBUG_ENTER("check_temp_dir"); + + /* + Check if the directory exists. + */ + if (!(dirp=my_dir(tmp_dir,MYF(MY_WME)))) + DBUG_RETURN(1); + my_dirend(dirp); + + /* + Check permissions to create a file. + */ + if ((fd= my_create(tmp_file, CREATE_MODE, + O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW, + MYF(MY_WME))) < 0) + DBUG_RETURN(1); + + /* + Clean up. + */ + my_close(fd, MYF(0)); + my_delete(tmp_file, MYF(0)); + + DBUG_RETURN(0); +} /** Slave SQL thread entry point. @@ -2763,6 +2798,14 @@ 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)) + { + rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), + "Unable to use slave's temporary directory %s - %s", + slave_load_tmpdir, thd->main_da.message()); + goto err; + } + /* execute init_slave variable */ if (sys_init_slave.value_length) { From 0ba1cc2523f1c7603627d0d683355d042ea85b65 Mon Sep 17 00:00:00 2001 From: Guangbao Ni Date: Wed, 18 Mar 2009 13:48:23 +0000 Subject: [PATCH 38/88] Bug #42217 mysql.procs_priv does not get replicated mysql.procs_priv table itself does not get replicated. Inserting routine privilege record into mysql.procs_priv table is triggered by creating function/procedure statements according to current user's privileges. Because the current user of SQL thread has GLOBAL_ACL, which doesn't need any check mysql.procs_priv privilege when create/alter/execute routines. Corresponding GLOBAL_ACL privilege user doesn't insert routine privilege record into mysql.procs_priv when creating a routine. Fixed by switching the current user of SQL thread to definer user if the definer user exists on slave. That populates procs_priv, otherwise to keep the SQL thread user and procs_priv remains unchanged. mysql-test/suite/rpl/r/rpl_do_grant.result: Test case result for routine privilege when definer user exist or not on slave mysql-test/suite/rpl/t/rpl_do_grant.test: Test case result for routine privilege when definer user exist or not on slave sql/sql_parse.cc: Switch current user of SQL thread to definer user if the definer user existes on slave when checking whether the routine privilege is needed to insert mysql.procs_priv table or not. --- mysql-test/suite/rpl/r/rpl_do_grant.result | 78 +++++++++++++++++ mysql-test/suite/rpl/t/rpl_do_grant.test | 97 ++++++++++++++++++++++ sql/sql_parse.cc | 36 +++++++- 3 files changed, 210 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl/r/rpl_do_grant.result b/mysql-test/suite/rpl/r/rpl_do_grant.result index f7f1ce66656..69bcfad4347 100644 --- a/mysql-test/suite/rpl/r/rpl_do_grant.result +++ b/mysql-test/suite/rpl/r/rpl_do_grant.result @@ -89,3 +89,81 @@ show grants for rpl_do_grant2@localhost; ERROR 42000: There is no such grant defined for user 'rpl_do_grant2' on host 'localhost' show grants for rpl_do_grant2@localhost; ERROR 42000: There is no such grant defined for user 'rpl_do_grant2' on host 'localhost' +DROP DATABASE IF EXISTS bug42217_db; +CREATE DATABASE bug42217_db; +GRANT CREATE ROUTINE ON bug42217_db.* TO 'create_rout_db'@'localhost' + IDENTIFIED BY 'create_rout_db' WITH GRANT OPTION; +USE bug42217_db; +CREATE FUNCTION upgrade_del_func() RETURNS CHAR(30) +BEGIN +RETURN "INSIDE upgrade_del_func()"; +END// +USE bug42217_db; +SELECT * FROM mysql.procs_priv; +Host Db User Routine_name Routine_type Grantor Proc_priv Timestamp +localhost bug42217_db create_rout_db upgrade_del_func FUNCTION create_rout_db@localhost Execute,Alter Routine # +SELECT upgrade_del_func(); +upgrade_del_func() +INSIDE upgrade_del_func() +SELECT * FROM mysql.procs_priv; +Host Db User Routine_name Routine_type Grantor Proc_priv Timestamp +localhost bug42217_db create_rout_db upgrade_del_func FUNCTION create_rout_db@localhost Execute,Alter Routine # +SHOW GRANTS FOR 'create_rout_db'@'localhost'; +Grants for create_rout_db@localhost +GRANT USAGE ON *.* TO 'create_rout_db'@'localhost' IDENTIFIED BY PASSWORD '*08792480350CBA057BDE781B9DF183B263934601' +GRANT CREATE ROUTINE ON `bug42217_db`.* TO 'create_rout_db'@'localhost' WITH GRANT OPTION +GRANT EXECUTE, ALTER ROUTINE ON FUNCTION `bug42217_db`.`upgrade_del_func` TO 'create_rout_db'@'localhost' +USE bug42217_db; +SHOW CREATE FUNCTION upgrade_del_func; +Function sql_mode Create Function character_set_client collation_connection Database Collation +upgrade_del_func CREATE DEFINER=`create_rout_db`@`localhost` FUNCTION `upgrade_del_func`() RETURNS char(30) CHARSET latin1 +BEGIN +RETURN "INSIDE upgrade_del_func()"; +END latin1 latin1_swedish_ci latin1_swedish_ci +SELECT upgrade_del_func(); +upgrade_del_func() +INSIDE upgrade_del_func() +"Check whether the definer user will be able to execute the replicated routine on slave" +USE bug42217_db; +SHOW CREATE FUNCTION upgrade_del_func; +Function sql_mode Create Function character_set_client collation_connection Database Collation +upgrade_del_func CREATE DEFINER=`create_rout_db`@`localhost` FUNCTION `upgrade_del_func`() RETURNS char(30) CHARSET latin1 +BEGIN +RETURN "INSIDE upgrade_del_func()"; +END latin1 latin1_swedish_ci latin1_swedish_ci +SELECT upgrade_del_func(); +upgrade_del_func() +INSIDE upgrade_del_func() +DELETE FROM mysql.procs_priv; +FLUSH PRIVILEGES; +USE bug42217_db; +"Can't execute the replicated routine on slave like before after procs privilege is deleted " +SELECT upgrade_del_func(); +ERROR 42000: execute command denied to user 'create_rout_db'@'localhost' for routine 'bug42217_db.upgrade_del_func' +"Test the user who creates a function on master doesn't exist on slave." +"Hence SQL thread ACL_GLOBAL privilege jumps in and no mysql.procs_priv is inserted" +DROP USER 'create_rout_db'@'localhost'; +CREATE FUNCTION upgrade_alter_func() RETURNS CHAR(30) +BEGIN +RETURN "INSIDE upgrade_alter_func()"; +END// +SELECT upgrade_alter_func(); +upgrade_alter_func() +INSIDE upgrade_alter_func() +SHOW CREATE FUNCTION upgrade_alter_func; +Function sql_mode Create Function character_set_client collation_connection Database Collation +upgrade_alter_func CREATE DEFINER=`create_rout_db`@`localhost` FUNCTION `upgrade_alter_func`() RETURNS char(30) CHARSET latin1 +BEGIN +RETURN "INSIDE upgrade_alter_func()"; +END latin1 latin1_swedish_ci latin1_swedish_ci +"Should no privilege record for upgrade_alter_func in mysql.procs_priv" +SELECT * FROM mysql.procs_priv; +Host Db User Routine_name Routine_type Grantor Proc_priv Timestamp +SELECT upgrade_alter_func(); +ERROR HY000: The user specified as a definer ('create_rout_db'@'localhost') does not exist +USE bug42217_db; +DROP FUNCTION upgrade_del_func; +DROP FUNCTION upgrade_alter_func; +DROP DATABASE bug42217_db; +DROP USER 'create_rout_db'@'localhost'; +"End of test" diff --git a/mysql-test/suite/rpl/t/rpl_do_grant.test b/mysql-test/suite/rpl/t/rpl_do_grant.test index 5615900c2dd..806de780086 100644 --- a/mysql-test/suite/rpl/t/rpl_do_grant.test +++ b/mysql-test/suite/rpl/t/rpl_do_grant.test @@ -112,3 +112,100 @@ show grants for rpl_do_grant2@localhost; sync_slave_with_master; --error 1141 show grants for rpl_do_grant2@localhost; + +##################################################### +# Purpose +# Test whether mysql.procs_priv get replicated +# Related bugs: +# BUG42217 mysql.procs_priv does not get replicated +##################################################### +connection master; + +--disable_warnings +DROP DATABASE IF EXISTS bug42217_db; +--enable_warnings +CREATE DATABASE bug42217_db; + +GRANT CREATE ROUTINE ON bug42217_db.* TO 'create_rout_db'@'localhost' + IDENTIFIED BY 'create_rout_db' WITH GRANT OPTION; + +connect (create_rout_db_master, localhost, create_rout_db, create_rout_db, bug42217_db,$MASTER_MYPORT,); +connect (create_rout_db_slave, localhost, create_rout_db, create_rout_db, bug42217_db, $SLAVE_MYPORT,); + +connection create_rout_db_master; + + +USE bug42217_db; + +DELIMITER //; +CREATE FUNCTION upgrade_del_func() RETURNS CHAR(30) +BEGIN + RETURN "INSIDE upgrade_del_func()"; +END// + +DELIMITER ;// + +connection master; + +USE bug42217_db; +--replace_column 8 # +SELECT * FROM mysql.procs_priv; +SELECT upgrade_del_func(); + +sync_slave_with_master; +--replace_column 8 # +SELECT * FROM mysql.procs_priv; +SHOW GRANTS FOR 'create_rout_db'@'localhost'; + +USE bug42217_db; +SHOW CREATE FUNCTION upgrade_del_func; +SELECT upgrade_del_func(); + +--echo "Check whether the definer user will be able to execute the replicated routine on slave" +connection create_rout_db_slave; +USE bug42217_db; +SHOW CREATE FUNCTION upgrade_del_func; +SELECT upgrade_del_func(); + +connection slave; +DELETE FROM mysql.procs_priv; +FLUSH PRIVILEGES; +USE bug42217_db; +--echo "Can't execute the replicated routine on slave like before after procs privilege is deleted " +--error 1370 +SELECT upgrade_del_func(); + +--echo "Test the user who creates a function on master doesn't exist on slave." +--echo "Hence SQL thread ACL_GLOBAL privilege jumps in and no mysql.procs_priv is inserted" +DROP USER 'create_rout_db'@'localhost'; + +connection create_rout_db_master; +DELIMITER //; +CREATE FUNCTION upgrade_alter_func() RETURNS CHAR(30) +BEGIN + RETURN "INSIDE upgrade_alter_func()"; +END// +DELIMITER ;// + +connection master; +SELECT upgrade_alter_func(); + +sync_slave_with_master; +SHOW CREATE FUNCTION upgrade_alter_func; +--echo "Should no privilege record for upgrade_alter_func in mysql.procs_priv" +--replace_column 8 # +SELECT * FROM mysql.procs_priv; +--error 1449 +SELECT upgrade_alter_func(); + +###### CLEAN UP SECTION ############## +disconnect create_rout_db_master; +disconnect create_rout_db_slave; +connection master; +USE bug42217_db; +DROP FUNCTION upgrade_del_func; +DROP FUNCTION upgrade_alter_func; +DROP DATABASE bug42217_db; +DROP USER 'create_rout_db'@'localhost'; + +--echo "End of test" diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f7e895d150f..94725b1b53f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4129,9 +4129,32 @@ end_with_restore_list: res= (sp_result= lex->sphead->create(thd)); switch (sp_result) { - case SP_OK: + case SP_OK: { #ifndef NO_EMBEDDED_ACCESS_CHECKS /* only add privileges if really neccessary */ + + Security_context security_context; + bool restore_backup_context= false; + Security_context *backup= NULL; + LEX_USER *definer= thd->lex->definer; + /* + Check if the definer exists on slave, + then use definer privilege to insert routine privileges to mysql.procs_priv. + + For current user of SQL thread has GLOBAL_ACL privilege, + which doesn't any check routine privileges, + so no routine privilege record will insert into mysql.procs_priv. + */ + if (thd->slave_thread && is_acl_user(definer->host.str, definer->user.str)) + { + security_context.change_security_context(thd, + &thd->lex->definer->user, + &thd->lex->definer->host, + &thd->lex->sphead->m_db, + &backup); + restore_backup_context= true; + } + if (sp_automatic_privileges && !opt_noacl && check_routine_access(thd, DEFAULT_CREATE_PROC_ACLS, lex->sphead->m_db.str, name, @@ -4143,8 +4166,19 @@ end_with_restore_list: ER_PROC_AUTO_GRANT_FAIL, ER(ER_PROC_AUTO_GRANT_FAIL)); } + + /* + Restore current user with GLOBAL_ACL privilege of SQL thread + */ + if (restore_backup_context) + { + DBUG_ASSERT(thd->slave_thread == 1); + thd->security_ctx->restore_security_context(thd, backup); + } + #endif break; + } case SP_WRITE_ROW_FAILED: my_error(ER_SP_ALREADY_EXISTS, MYF(0), SP_TYPE_STRING(lex), name); break; From 1fd4ed8ed84d88a97438004b71e37a0d82392bc3 Mon Sep 17 00:00:00 2001 From: Chad MILLER Date: Wed, 18 Mar 2009 08:49:05 -0400 Subject: [PATCH 39/88] Using autoconf definitions instead of manually appending to CFLAGS is smarter, and according to a contributer, it is necessary for plugin authors using "--with-debug". --- configure.in | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index 069da9ef36e..cf7d6926cb9 100644 --- a/configure.in +++ b/configure.in @@ -1678,14 +1678,17 @@ if test "$with_debug" = "yes" then # Medium debug. AC_DEFINE([DBUG_ON], [1], [Use libdbug]) - CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DSAFE_MUTEX $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DSAFE_MUTEX $CXXFLAGS" + AC_DEFINE([SAFE_MUTEX], [1], [Use safe mutexes]) + CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC $CFLAGS" + CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX $CXXFLAGS" elif test "$with_debug" = "full" then # Full debug. Very slow in some cases AC_DEFINE([DBUG_ON], [1], [Use libdbug]) - CFLAGS="$DEBUG_CFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS" + AC_DEFINE([SAFE_MUTEX], [1], [Use safe mutexes]) + AC_DEFINE([SAFEMALLOC], [1], [Use safe malloc]) + CFLAGS="$DEBUG_CFLAGS $CFLAGS" + CXXFLAGS="$DEBUG_CXXFLAGS $CXXFLAGS" else # Optimized version. No debug AC_DEFINE([DBUG_OFF], [1], [Don't use libdbug]) From 6290bc7e61ed97fb7af629c5e4c6f6d9e3ccc9b0 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 18 Mar 2009 14:52:31 +0200 Subject: [PATCH 40/88] addendum to the 22047 fix : updated funcs_1 test suite --- mysql-test/suite/funcs_1/r/is_columns_is.result | 5 +++-- mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result | 4 ++-- mysql-test/suite/funcs_1/r/processlist_val_no_prot.result | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index 94aa75c6db2..ccb94c63d46 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.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) select NULL information_schema PROCESSLIST INFO 8 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select NULL information_schema PROCESSLIST STATE 7 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select -NULL information_schema PROCESSLIST TIME 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(7) select +NULL information_schema PROCESSLIST TIME 6 0 NO int NULL NULL 10 0 NULL NULL int(7) select NULL information_schema PROCESSLIST USER 2 NO varchar 16 48 NULL NULL utf8 utf8_general_ci varchar(16) select NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select @@ -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/processlist_priv_no_prot.result b/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result index d862b7424e0..3d341292be1 100644 --- a/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result +++ b/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result @@ -27,7 +27,7 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', - `TIME` bigint(7) NOT NULL DEFAULT '0', + `TIME` int(7) NOT NULL DEFAULT '0', `STATE` varchar(64) DEFAULT NULL, `INFO` longtext ) ENGINE=MyISAM DEFAULT CHARSET=utf8 @@ -97,7 +97,7 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', - `TIME` bigint(7) NOT NULL DEFAULT '0', + `TIME` int(7) NOT NULL DEFAULT '0', `STATE` varchar(64) DEFAULT NULL, `INFO` longtext ) ENGINE=MyISAM DEFAULT CHARSET=utf8 diff --git a/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result b/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result index 482e143fd23..b0cae801fd6 100644 --- a/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result +++ b/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result @@ -17,7 +17,7 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', - `TIME` bigint(7) NOT NULL DEFAULT '0', + `TIME` int(7) NOT NULL DEFAULT '0', `STATE` varchar(64) DEFAULT NULL, `INFO` longtext ) ENGINE=MyISAM DEFAULT CHARSET=utf8 From 4d32be13fe8f3e4d027e2d0039cc55f28e4ba8ab Mon Sep 17 00:00:00 2001 From: "Bernt M. Johnsen" Date: Wed, 18 Mar 2009 15:07:13 +0100 Subject: [PATCH 41/88] Bug#43329 prepared for commit on 5.0 --- mysql-test/r/union.result | 16 ++++++------ mysql-test/t/union.test | 51 ++++++++++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 6007fdd403a..04bd818df89 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1447,12 +1447,12 @@ SELECT a FROM t1 UNION SELECT a FROM t1 ) alias; -SELECT a INTO OUTFILE 'union.out.file' FROM ( +SELECT a INTO OUTFILE '/tmp/union.out.file' FROM ( SELECT a FROM t1 UNION SELECT a FROM t1 WHERE 0 ) alias; -SELECT a INTO DUMPFILE 'union.out.file2' FROM ( +SELECT a INTO DUMPFILE '/tmp/union.out.file' FROM ( SELECT a FROM t1 UNION SELECT a FROM t1 WHERE 0 @@ -1465,21 +1465,21 @@ SELECT a INTO @v FROM t1 SELECT a FROM ( SELECT a FROM t1 UNION -SELECT a INTO OUTFILE 'union.out.file3' FROM t1 +SELECT a INTO OUTFILE '/tmp/union.out.file' FROM t1 ) alias; SELECT a FROM ( SELECT a FROM t1 UNION -SELECT a INTO DUMPFILE 'union.out.file4' FROM t1 +SELECT a INTO DUMPFILE '/tmp/union.out.file' FROM t1 ) alias; SELECT a FROM t1 UNION SELECT a INTO @v FROM t1; -SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file5' FROM t1; -SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file6' FROM t1; +SELECT a FROM t1 UNION SELECT a INTO OUTFILE '/tmp/union.out.file' FROM t1; +SELECT a FROM t1 UNION SELECT a INTO DUMPFILE '/tmp/union.out.file' FROM t1; SELECT a INTO @v FROM t1 UNION SELECT a FROM t1; ERROR HY000: Incorrect usage of UNION and INTO -SELECT a INTO OUTFILE 'union.out.file7' FROM t1 UNION SELECT a FROM t1; +SELECT a INTO OUTFILE '/tmp/union.out.file' FROM t1 UNION SELECT a FROM t1; ERROR HY000: Incorrect usage of UNION and INTO -SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1; +SELECT a INTO DUMPFILE '/tmp/union.out.file' FROM t1 UNION SELECT a FROM t1; ERROR HY000: Incorrect usage of UNION and INTO DROP TABLE t1; CREATE TABLE t1 (a INT); diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 44f21abda19..3c792f28d4f 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -933,17 +933,25 @@ SELECT a INTO @v FROM ( SELECT a FROM t1 ) alias; -SELECT a INTO OUTFILE 'union.out.file' FROM ( - SELECT a FROM t1 - UNION - SELECT a FROM t1 WHERE 0 -) alias; +--let $outfile = $MYSQLTEST_VARDIR/tmp/union.out.file +--error 0,1 +--remove_file $outfile -SELECT a INTO DUMPFILE 'union.out.file2' FROM ( +--replace_result $MYSQLTEST_VARDIR +eval SELECT a INTO OUTFILE '$outfile' FROM ( SELECT a FROM t1 UNION SELECT a FROM t1 WHERE 0 ) alias; +--remove_file $outfile + +--replace_result $MYSQLTEST_VARDIR +eval SELECT a INTO DUMPFILE '$outfile' FROM ( + SELECT a FROM t1 + UNION + SELECT a FROM t1 WHERE 0 +) alias; +--remove_file $outfile # # INTO will not be allowed in subqueries in version 5.1 and above. @@ -954,27 +962,42 @@ SELECT a FROM ( SELECT a INTO @v FROM t1 ) alias; -SELECT a FROM ( +--replace_result $MYSQLTEST_VARDIR +eval SELECT a FROM ( SELECT a FROM t1 UNION - SELECT a INTO OUTFILE 'union.out.file3' FROM t1 + SELECT a INTO OUTFILE '$outfile' FROM t1 ) alias; +--remove_file $outfile -SELECT a FROM ( +--replace_result $MYSQLTEST_VARDIR +eval SELECT a FROM ( SELECT a FROM t1 UNION - SELECT a INTO DUMPFILE 'union.out.file4' FROM t1 + SELECT a INTO DUMPFILE '$outfile' FROM t1 ) alias; +--remove_file $outfile SELECT a FROM t1 UNION SELECT a INTO @v FROM t1; -SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file5' FROM t1; -SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file6' FROM t1; + +--replace_result $MYSQLTEST_VARDIR +eval SELECT a FROM t1 UNION SELECT a INTO OUTFILE '$outfile' FROM t1; +--remove_file $outfile + +--replace_result $MYSQLTEST_VARDIR +eval SELECT a FROM t1 UNION SELECT a INTO DUMPFILE '$outfile' FROM t1; +--remove_file $outfile + --error ER_WRONG_USAGE SELECT a INTO @v FROM t1 UNION SELECT a FROM t1; + +--replace_result $MYSQLTEST_VARDIR --error ER_WRONG_USAGE -SELECT a INTO OUTFILE 'union.out.file7' FROM t1 UNION SELECT a FROM t1; +eval SELECT a INTO OUTFILE '$outfile' FROM t1 UNION SELECT a FROM t1; + +--replace_result $MYSQLTEST_VARDIR --error ER_WRONG_USAGE -SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1; +eval SELECT a INTO DUMPFILE '$outfile' FROM t1 UNION SELECT a FROM t1; DROP TABLE t1; From 09c1a26b681ad9755ca2a0c52616dec7267134f3 Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Wed, 18 Mar 2009 17:23:39 +0100 Subject: [PATCH 42/88] Due to bug#43733 I disabled "concurrent_innodb_(un)safelog.test" for embedded server. --- mysql-test/include/concurrent.inc | 2 ++ mysql-test/t/disabled.def | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mysql-test/include/concurrent.inc b/mysql-test/include/concurrent.inc index fe670cef08e..2180ec4cc9c 100644 --- a/mysql-test/include/concurrent.inc +++ b/mysql-test/include/concurrent.inc @@ -25,6 +25,8 @@ # new wrapper t/concurrent_innodb_safelog.test # +--source include/not_embedded.inc + connection default; # # Show prerequisites for this test. diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 3f61176e37b..eab0542314a 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -11,3 +11,5 @@ ############################################################################## 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" +#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. From cad09dab8f8685341274ecfe74db43088b970386 Mon Sep 17 00:00:00 2001 From: Satya B Date: Thu, 19 Mar 2009 11:36:37 +0530 Subject: [PATCH 43/88] Fix for BUG#21360 - mysqldump error on federated tables When loading dump created by mysqldump tool an error is thrown saying storage engine for the table doesn't have an option. mysqldump tries to re-insert the data into the federated table which causes the error. Since the data is already available on the remote server, mysqldump shouldn't try to dump the data again for FEDERATED tables. As stated in the bug page, it can be considered similar to the MERGE ENGINE with "view only" nature. Fixed by adding the "FEDERATED ENGINE" to the exception list to ignore the data. client/mysqldump.c: Fixed check_if_ignore_table() to ignore FEDERATED engine when dumping the table data. mysql-test/r/federated.result: Result file for BUG#21360 mysql-test/t/federated.test: Testcase for BUG#21360 --- client/mysqldump.c | 3 ++- mysql-test/r/federated.result | 20 ++++++++++++++++++++ mysql-test/t/federated.test | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index af6a6d10121..8ffc83b5684 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3576,7 +3576,8 @@ char check_if_ignore_table(const char *table_name, char *table_type) If these two types, we do want to skip dumping the table */ if (!opt_no_data && - (!strcmp(table_type,"MRG_MyISAM") || !strcmp(table_type,"MRG_ISAM"))) + (!strcmp(table_type,"MRG_MyISAM") || !strcmp(table_type,"MRG_ISAM") || + !strcmp(table_type,"FEDERATED"))) result= IGNORE_DATA; } mysql_free_result(res); diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result index f0de3e9b04a..026886cb07d 100644 --- a/mysql-test/r/federated.result +++ b/mysql-test/r/federated.result @@ -2094,6 +2094,26 @@ SELECT t1.a FROM t1, t1 as t2 WHERE t2.b NOT LIKE t1.b; a DROP TABLE t1; DROP TABLE t1; +# +# BUG#21360 - mysqldump error on federated tables +# +#Switch to Connection Slave +CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id)); +INSERT INTO t1 VALUES ('text1'),('text2'),('text3'),('text4'); +#Switch to Connection Master +CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id)) ENGINE=FEDERATED +CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1'; +# Dump table t1 using mysqldump tool +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t1` ( + `id` varchar(20) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=FEDERATED DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE t1; +#Switch to Connection Slave +DROP TABLE t1; End of 5.0 tests SET @@GLOBAL.CONCURRENT_INSERT= @OLD_MASTER_CONCURRENT_INSERT; SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT; diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test index c977cb65fa0..ee9d1981558 100644 --- a/mysql-test/t/federated.test +++ b/mysql-test/t/federated.test @@ -1843,6 +1843,28 @@ DROP TABLE t1; connection master; DROP TABLE t1; +--echo # +--echo # BUG#21360 - mysqldump error on federated tables +--echo # +connection slave; +--echo #Switch to Connection Slave +CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id)); +INSERT INTO t1 VALUES ('text1'),('text2'),('text3'),('text4'); + +connection master; +--echo #Switch to Connection Master +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id)) ENGINE=FEDERATED + CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; +--echo # Dump table t1 using mysqldump tool +--replace_result $SLAVE_MYPORT SLAVE_PORT +--exec $MYSQL_DUMP --compact test t1 +DROP TABLE t1; + +connection slave; +--echo #Switch to Connection Slave +DROP TABLE t1; + connection default; --echo End of 5.0 tests From af016f72b90163d1a5e2d9d3368cc6d7f9f2394c Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Thu, 19 Mar 2009 12:20:28 +0400 Subject: [PATCH 44/88] Bug#41627 Illegal mix of collations in LEAST / GREATEST / CASE Don't throw an error after checking the first and the second arguments. Continue with checking the third and higher arguments and if some of them is stronger according to coercibility rules, then this argument's collation is set as result collation. mysql-test/r/ctype_collate.result: test result mysql-test/t/ctype_collate.test: test case sql/item.cc: Don't throw an error after checking the first and the second arguments. Continue with checking the third and higher arguments and if some of them is stronger according to coercibility rules, then this argument's collation is set as result collation. --- mysql-test/r/ctype_collate.result | 19 +++++++++++++++++++ mysql-test/t/ctype_collate.test | 14 ++++++++++++++ sql/item.cc | 19 ++++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result index 7e9513f06e9..8bcd488cb69 100644 --- a/mysql-test/r/ctype_collate.result +++ b/mysql-test/r/ctype_collate.result @@ -611,3 +611,22 @@ check table t1 extended; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; +select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci); +least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) +a +create table t1 +select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) as f1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` varchar(1) character set latin5 NOT NULL default '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate +latin5_turkish_ci then 2 else 3 end; +case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate +latin5_turkish_ci then 2 else 3 end +3 +select concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci); +concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) +abc diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test index cfef8dfe81a..6b6abbcfbcc 100644 --- a/mysql-test/t/ctype_collate.test +++ b/mysql-test/t/ctype_collate.test @@ -229,3 +229,17 @@ insert into t1 set a=0x6c; insert into t1 set a=0x4c98; check table t1 extended; drop table t1; + +# +# Bug#41627 Illegal mix of collations in LEAST / GREATEST / CASE +# +select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci); +create table t1 +select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) as f1; +show create table t1; +drop table t1; + +select case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate +latin5_turkish_ci then 2 else 3 end; + +select concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci); diff --git a/sql/item.cc b/sql/item.cc index f32828629cf..c80d1b7a455 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1498,7 +1498,8 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) else { // Cannot apply conversion - set(0, DERIVATION_NONE, 0); + set(&my_charset_bin, DERIVATION_NONE, + (dt.repertoire|repertoire)); return 1; } } @@ -1581,15 +1582,31 @@ bool agg_item_collations(DTCollation &c, const char *fname, { uint i; Item **arg; + bool unknown_cs= 0; + c.set(av[0]->collation); for (i= 1, arg= &av[item_sep]; i < count; i++, arg++) { if (c.aggregate((*arg)->collation, flags)) { + if (c.derivation == DERIVATION_NONE && + c.collation == &my_charset_bin) + { + unknown_cs= 1; + continue; + } my_coll_agg_error(av, count, fname, item_sep); return TRUE; } } + + if (unknown_cs && + c.derivation != DERIVATION_EXPLICIT) + { + my_coll_agg_error(av, count, fname, item_sep); + return TRUE; + } + if ((flags & MY_COLL_DISALLOW_NONE) && c.derivation == DERIVATION_NONE) { From 8c7789c313cdd18d06e6659dbb850900c597c040 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Thu, 19 Mar 2009 12:37:34 +0400 Subject: [PATCH 45/88] Bug#41268 Help Text for \c is misleading in client command line interface fixed help message client/mysql.cc: fixed help message --- client/mysql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index 0a4587d1c92..a2857620647 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1199,7 +1199,7 @@ int main(int argc,char *argv[]) #endif sprintf(buff, "%s", #ifndef NOT_YET - "Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n"); + "Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n"); #else "Type 'help [[%]function name[%]]' to get help on usage of function.\n"); #endif From afcfe81fea26b9f746ee7043c41d8dff52333067 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Thu, 19 Mar 2009 13:02:23 +0300 Subject: [PATCH 46/88] Fixed test failures in 5.1/6.0 introduced by the patch for bug #41486. Session max_allowed_packet is read-only as of MySQL 5.1.31. In addition, the global variable now has no effect on the current session. --- mysql-test/r/mysql.result | 2 -- mysql-test/t/mysql.test | 14 ++++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index a6087e0134b..cef5e08ec6b 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -194,7 +194,6 @@ delimiter 1 set @old_max_allowed_packet = @@global.max_allowed_packet; set @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024; -set @@max_allowed_packet = @@global.max_allowed_packet; CREATE TABLE t1(data LONGBLOB); INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024); SELECT LENGTH(data) FROM t1; @@ -202,5 +201,4 @@ LENGTH(data) 2097152 DROP TABLE t1; set @@global.max_allowed_packet = @old_max_allowed_packet; -set @@max_allowed_packet = @@global.max_allowed_packet; End of 5.0 tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 0030f624be6..f352c08fb5b 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -336,12 +336,16 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql; # mysqldump/import # -# Have to change the global variable as the mysql client will use -# a separate session +# Have to change the global variable as the session variable is +# read-only. set @old_max_allowed_packet = @@global.max_allowed_packet; # 2 MB blob length + some space for the rest of INSERT query set @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024; -set @@max_allowed_packet = @@global.max_allowed_packet; + +# Create a new connection since the global max_allowed_packet +# has no effect for the current connection +connect (con1, localhost, root,,); +connection con1; CREATE TABLE t1(data LONGBLOB); INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024); @@ -355,7 +359,9 @@ SELECT LENGTH(data) FROM t1; remove_file $MYSQLTEST_VARDIR/tmp/bug41486.sql; DROP TABLE t1; +connection default; +disconnect con1; + set @@global.max_allowed_packet = @old_max_allowed_packet; -set @@max_allowed_packet = @@global.max_allowed_packet; --echo End of 5.0 tests From 28f4090bda66bd4eb33ab0fd25fe2c29d24975a4 Mon Sep 17 00:00:00 2001 From: Staale Smedseng Date: Thu, 19 Mar 2009 11:27:45 +0100 Subject: [PATCH 47/88] Bug #42502 huge memory leak possible with timezone functions Unknown timezone specifications are properly rejected by the server, but are copied into tz_storage before rejection, and hence is retained until end of server life. With sufficiently large bogus timezone specs, it is easy to exhaust system memory. Allocation of memory for a copy of the timezone name is delayed until after verification of validity, at the cost of a memcpy of the timezone info. This only happens once, future lookups will hit the cached structure. --- sql/tztime.cc | 77 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/sql/tztime.cc b/sql/tztime.cc index d3d952e3c1e..d73a1ca0111 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1871,6 +1871,12 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) #ifdef ABBR_ARE_USED char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))]; #endif + /* + Used as a temporary tz_info until we decide that we actually want to + allocate and keep the tz info and tz name in tz_storage. + */ + TIME_ZONE_INFO tmp_tz_info; + memset(&tmp_tz_info, 0, sizeof(TIME_ZONE_INFO)); DBUG_ENTER("tz_load_from_open_tables"); @@ -1914,7 +1920,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) Most probably user has mistyped time zone name, so no need to bark here unless we need it for debugging. */ - sql_print_error("Can't find description of time zone '%s'", tz_name_buff); + sql_print_error("Can't find description of time zone '%.*s'", + tz_name->length(), tz_name->ptr()); #endif goto end; } @@ -1943,8 +1950,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) /* If Uses_leap_seconds == 'Y' */ if (table->field[1]->val_int() == 1) { - tz_info->leapcnt= tz_leapcnt; - tz_info->lsis= tz_lsis; + tmp_tz_info.leapcnt= tz_leapcnt; + tmp_tz_info.lsis= tz_lsis; } (void)table->file->ha_index_end(); @@ -1981,18 +1988,18 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) #ifdef ABBR_ARE_USED // FIXME should we do something with duplicates here ? table->field[4]->val_str(&abbr, &abbr); - if (tz_info->charcnt + abbr.length() + 1 > sizeof(chars)) + if (tmp_tz_info.charcnt + abbr.length() + 1 > sizeof(chars)) { sql_print_error("Error while loading time zone description from " "mysql.time_zone_transition_type table: not enough " "room for abbreviations"); goto end; } - ttis[ttid].tt_abbrind= tz_info->charcnt; - memcpy(chars + tz_info->charcnt, abbr.ptr(), abbr.length()); - tz_info->charcnt+= abbr.length(); - chars[tz_info->charcnt]= 0; - tz_info->charcnt++; + ttis[ttid].tt_abbrind= tmp_tz_info.charcnt; + memcpy(chars + tmp_tz_info.charcnt, abbr.ptr(), abbr.length()); + tmp_tz_info.charcnt+= abbr.length(); + chars[tmp_tz_info.charcnt]= 0; + tmp_tz_info.charcnt++; DBUG_PRINT("info", ("time_zone_transition_type table: tz_id=%u tt_id=%u tt_gmtoff=%ld " @@ -2005,9 +2012,9 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) #endif /* ttid is increasing because we are reading using index */ - DBUG_ASSERT(ttid >= tz_info->typecnt); + DBUG_ASSERT(ttid >= tmp_tz_info.typecnt); - tz_info->typecnt= ttid + 1; + tmp_tz_info.typecnt= ttid + 1; res= table->file->index_next_same(table->record[0], (byte*)table->field[0]->ptr, 4); @@ -2040,14 +2047,14 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) ttime= (my_time_t)table->field[1]->val_int(); ttid= (uint)table->field[2]->val_int(); - if (tz_info->timecnt + 1 > TZ_MAX_TIMES) + if (tmp_tz_info.timecnt + 1 > TZ_MAX_TIMES) { sql_print_error("Error while loading time zone description from " "mysql.time_zone_transition table: " "too much transitions"); goto end; } - if (ttid + 1 > tz_info->typecnt) + if (ttid + 1 > tmp_tz_info.typecnt) { sql_print_error("Error while loading time zone description from " "mysql.time_zone_transition table: " @@ -2055,9 +2062,9 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) goto end; } - ats[tz_info->timecnt]= ttime; - types[tz_info->timecnt]= ttid; - tz_info->timecnt++; + ats[tmp_tz_info.timecnt]= ttime; + types[tmp_tz_info.timecnt]= ttid; + tmp_tz_info.timecnt++; DBUG_PRINT("info", ("time_zone_transition table: tz_id: %u tt_time: %lu tt_id: %u", @@ -2081,6 +2088,34 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) (void)table->file->ha_index_end(); table= 0; + /* + Let us check how correct our time zone description is. We don't check for + tz->timecnt < 1 since it is ok for GMT. + */ + if (tmp_tz_info.typecnt < 1) + { + sql_print_error("loading time zone without transition types"); + goto end; + } + + /* Allocate memory for the timezone info and timezone name in tz_storage. */ + if (!(alloc_buff= (char*) alloc_root(&tz_storage, sizeof(TIME_ZONE_INFO) + + tz_name->length() + 1))) + { + sql_print_error("Out of memory while loading time zone description"); + return 0; + } + + /* Move the temporary tz_info into the allocated area */ + tz_info= (TIME_ZONE_INFO *)alloc_buff; + memcpy(tz_info, &tmp_tz_info, sizeof(TIME_ZONE_INFO)); + tz_name_buff= alloc_buff + sizeof(TIME_ZONE_INFO); + /* + By writing zero to the end we guarantee that we can call ptr() + instead of c_ptr() for time zone name. + */ + strmake(tz_name_buff, tz_name->ptr(), tz_name->length()); + /* Now we will allocate memory and init TIME_ZONE_INFO structure. */ @@ -2112,15 +2147,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) tz_info->ttis= (TRAN_TYPE_INFO *)alloc_buff; memcpy(tz_info->ttis, ttis, tz_info->typecnt * sizeof(TRAN_TYPE_INFO)); - /* - Let us check how correct our time zone description and build - reversed map. We don't check for tz->timecnt < 1 since it ok for GMT. - */ - if (tz_info->typecnt < 1) - { - sql_print_error("loading time zone without transition types"); - goto end; - } + /* Build reversed map. */ if (prepare_tz_info(tz_info, &tz_storage)) { sql_print_error("Unable to build mktime map for time zone"); From 667a004c530db9d4ef516f75ab65e763deb23d46 Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Thu, 19 Mar 2009 12:21:38 +0100 Subject: [PATCH 48/88] Reviewed patch for Bug#39862. --- mysql-test/suite/sys_vars/t/concurrent_insert_func.test | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/sys_vars/t/concurrent_insert_func.test b/mysql-test/suite/sys_vars/t/concurrent_insert_func.test index cdeb76d9cac..1a600ffd7f6 100644 --- a/mysql-test/suite/sys_vars/t/concurrent_insert_func.test +++ b/mysql-test/suite/sys_vars/t/concurrent_insert_func.test @@ -11,6 +11,11 @@ # Creation Date: 2008-03-07 # # Author: Salman Rawala # # # +# Modified: HHunger 2009-02-23 Inserted a wait condition right after the # +# "INSERT ..record_6" to wait for the end of # +# the insert. # +# mleich This test needs some inporovements # +# # # Description: Test Cases of Dynamic System Variable "concurrent_insert" # # that checks functionality of this variable # # # @@ -62,7 +67,6 @@ connection test_con1; INSERT INTO t1(name) VALUES('Record_4'); SELECT * FROM t1; - --echo ## unlocking tables ## --echo connection default; connection default; @@ -106,6 +110,8 @@ UNLOCK TABLES; --echo ## table contens after UNLOCK ## SELECT * FROM t1; INSERT INTO t1(name) VALUES('Record_6'); +let $wait_condition= SELECT COUNT(*) = 5 FROM t1; +--source include/wait_condition.inc --echo connection test_con1; connection test_con1; From eb5ef513271a23a06aa7369175fbdbf799218446 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Thu, 19 Mar 2009 15:19:53 +0300 Subject: [PATCH 49/88] Fix default.conf --- .bzr-mysql/default.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index 63057f42ac6..f044f8e62da 100644 --- a/.bzr-mysql/default.conf +++ b/.bzr-mysql/default.conf @@ -1,4 +1,4 @@ [MYSQL] post_commit_to = "commits@lists.mysql.com" post_push_to = "commits@lists.mysql.com" -tree_name = "mysql-5.1-mtr" +tree_name = "mysql-5.1" From 9bdcb6ba6ebbb5747c7be7d8c9620574c74601d6 Mon Sep 17 00:00:00 2001 From: Chad MILLER Date: Thu, 19 Mar 2009 09:37:30 -0400 Subject: [PATCH 50/88] Copy include/config.h to include/my_config.h at configure-time. Also, continue to update it at make-time. One shouldn't need to run "make" on server source to get the stuff we say plugins should use. --- configure.in | 1 + include/Makefile.am | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/configure.in b/configure.in index cf7d6926cb9..2235d46d62d 100644 --- a/configure.in +++ b/configure.in @@ -2815,6 +2815,7 @@ AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl include/mysql_version.h plugin/Makefile win/Makefile) AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h) +AC_CONFIG_COMMANDS([my_config.h], cp include/config.h include/my_config.h) # Ensure that table handlers gets all modifications to CFLAGS/CXXFLAGS AC_CONFIG_COMMANDS_POST(ac_configure_args="$ac_configure_args CFLAGS='$CFLAGS' CXXFLAGS='$CXXFLAGS'") diff --git a/include/Makefile.am b/include/Makefile.am index 64f73af8606..de13a418c0c 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -15,9 +15,8 @@ # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # MA 02111-1307, USA -BUILT_SOURCES = $(HEADERS_GEN_MAKE) link_sources -HEADERS_GEN_CONFIGURE = mysql_version.h -HEADERS_GEN_MAKE = my_config.h +BUILT_SOURCES = link_sources +HEADERS_GEN_CONFIGURE = mysql_version.h my_config.h HEADERS_ABI = mysql.h mysql_com.h mysql_time.h \ my_list.h my_alloc.h typelib.h mysql/plugin.h pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \ @@ -26,8 +25,7 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \ decimal.h errmsg.h my_global.h my_net.h \ my_getopt.h sslopt-longopts.h my_dir.h \ sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ - m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) \ - $(HEADERS_GEN_MAKE) + m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) noinst_HEADERS = config-win.h config-netware.h my_bit.h \ heap.h my_bitmap.h my_uctype.h \ From 6f572a8eaf5c0cea89d6eaa7c7631841d389e358 Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Thu, 19 Mar 2009 18:42:43 +0100 Subject: [PATCH 51/88] Bug#43153: Version comment is too long mysql-client used static buffer to concatenate server- version and version_comment. Sufficiently long comments could get cut off. This was harmless, but looked daft. Now using a dynamic buffer instead. client/mysql.cc: Use dynamic rather than static buffer for server information. If we can get both version and comment, concat them and use that. Otherwise, try to use just version. If that fails too, return empty string so overly trusting callers do not crash. Release memory as needed. --- client/mysql.cc | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 6f32cc768e4..3e96ed0603e 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -49,7 +49,7 @@ const char *VER= "14.14"; #define MAX_COLUMN_LENGTH 1024 /* Buffer to hold 'version' and 'version_comment' */ -#define MAX_SERVER_VERSION_LENGTH 128 +static char *server_version= NULL; /* Array of options to pass to libemysqld */ #define MAX_SERVER_ARGS 64 @@ -1236,6 +1236,7 @@ sig_handler mysql_end(int sig) glob_buffer.free(); old_buffer.free(); processed_prompt.free(); + my_free(server_version,MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_mysql_unix_port,MYF(MY_ALLOW_ZERO_PTR)); my_free(histfile,MYF(MY_ALLOW_ZERO_PTR)); @@ -4365,16 +4366,11 @@ select_limit, max_join_size); static const char * server_version_string(MYSQL *con) { - static char buf[MAX_SERVER_VERSION_LENGTH] = ""; - /* Only one thread calls this, so no synchronization is needed */ - if (buf[0] == '\0') + if (server_version == NULL) { - char *bufp = buf; MYSQL_RES *result; - bufp= strnmov(buf, mysql_get_server_info(con), sizeof buf); - /* "limit 1" is protection against SQL_SELECT_LIMIT=0 */ if (!mysql_query(con, "select @@version_comment limit 1") && (result = mysql_use_result(con))) @@ -4382,17 +4378,32 @@ server_version_string(MYSQL *con) MYSQL_ROW cur = mysql_fetch_row(result); if (cur && cur[0]) { - bufp = strxnmov(bufp, sizeof buf - (bufp - buf), " ", cur[0], NullS); + /* version, space, comment, \0 */ + size_t len= strlen(mysql_get_server_info(con)) + strlen(cur[0]) + 2; + + if ((server_version= (char *) my_malloc(len, MYF(MY_WME)))) + { + char *bufp; + bufp = strmov(server_version, mysql_get_server_info(con)); + bufp = strmov(bufp, " "); + (void) strmov(bufp, cur[0]); + } } mysql_free_result(result); } - /* str*nmov doesn't guarantee NUL-termination */ - if (bufp == buf + sizeof buf) - buf[sizeof buf - 1] = '\0'; + /* + If for some reason we didn't get a version_comment, we'll + keep things simple. + */ + + if (server_version == NULL) + { + server_version= strdup(mysql_get_server_info(con)); + } } - return buf; + return server_version ? server_version : ""; } static int From 27e3214b494b0cec3bdb5de927d18bc04323f6fb Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Thu, 19 Mar 2009 17:20:15 -0300 Subject: [PATCH 52/88] Bug#43461: invalid comparison with string literal in default.c Don't compare string literals as it results in unspecified behavior. mysys/default.c: Test for a empty string. --- mysys/default.c | 2 +- mysys/my_new.cc | 5 +++-- sql/sql_class.cc | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mysys/default.c b/mysys/default.c index 0067e95ffbe..362aa0d4605 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -1083,7 +1083,7 @@ static const char **init_default_directories(MEM_ROOT *alloc) if ((env= getenv("ETC"))) errors += add_directory(alloc, env, dirs); #elif defined(DEFAULT_SYSCONFDIR) - if (DEFAULT_SYSCONFDIR != "") + if (DEFAULT_SYSCONFDIR[0]) errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs); #endif /* __EMX__ || __OS2__ */ diff --git a/mysys/my_new.cc b/mysys/my_new.cc index babfe04d695..7da54ffac87 100644 --- a/mysys/my_new.cc +++ b/mysys/my_new.cc @@ -46,8 +46,9 @@ void operator delete[] (void *ptr) throw () C_MODE_START -int __cxa_pure_virtual() { - assert("Pure virtual method called." == "Aborted"); +int __cxa_pure_virtual() +{ + assert(! "Aborted: pure virtual method called."); return 0; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 88b7dfb46d7..74bc669a049 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1758,7 +1758,7 @@ void Query_arena::set_query_arena(Query_arena *set) void Query_arena::cleanup_stmt() { - DBUG_ASSERT("Query_arena::cleanup_stmt()" == "not implemented"); + DBUG_ASSERT(! "Query_arena::cleanup_stmt() not implemented"); } /* From 07d3da54fc7e75926fbd8f4c23805f6a6f89618e Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 20 Mar 2009 13:18:29 +0200 Subject: [PATCH 53/88] reverting a bogus fix into 5.1-bugteam --- configure.in | 12 ++++-------- include/Makefile.am | 8 +++++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/configure.in b/configure.in index 7c7b7eddf0a..d86218bd782 100644 --- a/configure.in +++ b/configure.in @@ -1678,17 +1678,14 @@ if test "$with_debug" = "yes" then # Medium debug. AC_DEFINE([DBUG_ON], [1], [Use libdbug]) - AC_DEFINE([SAFE_MUTEX], [1], [Use safe mutexes]) - CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX $CXXFLAGS" + CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DSAFE_MUTEX $CFLAGS" + CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DSAFE_MUTEX $CXXFLAGS" elif test "$with_debug" = "full" then # Full debug. Very slow in some cases AC_DEFINE([DBUG_ON], [1], [Use libdbug]) - AC_DEFINE([SAFE_MUTEX], [1], [Use safe mutexes]) - AC_DEFINE([SAFEMALLOC], [1], [Use safe malloc]) - CFLAGS="$DEBUG_CFLAGS $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS $CXXFLAGS" + CFLAGS="$DEBUG_CFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS" + CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS" else # Optimized version. No debug AC_DEFINE([DBUG_OFF], [1], [Don't use libdbug]) @@ -2815,7 +2812,6 @@ AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl include/mysql_version.h plugin/Makefile win/Makefile) AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h) -AC_CONFIG_COMMANDS([my_config.h], cp include/config.h include/my_config.h) # Ensure that table handlers gets all modifications to CFLAGS/CXXFLAGS AC_CONFIG_COMMANDS_POST(ac_configure_args="$ac_configure_args CFLAGS='$CFLAGS' CXXFLAGS='$CXXFLAGS'") diff --git a/include/Makefile.am b/include/Makefile.am index de13a418c0c..64f73af8606 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -15,8 +15,9 @@ # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # MA 02111-1307, USA -BUILT_SOURCES = link_sources -HEADERS_GEN_CONFIGURE = mysql_version.h my_config.h +BUILT_SOURCES = $(HEADERS_GEN_MAKE) link_sources +HEADERS_GEN_CONFIGURE = mysql_version.h +HEADERS_GEN_MAKE = my_config.h HEADERS_ABI = mysql.h mysql_com.h mysql_time.h \ my_list.h my_alloc.h typelib.h mysql/plugin.h pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \ @@ -25,7 +26,8 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \ decimal.h errmsg.h my_global.h my_net.h \ my_getopt.h sslopt-longopts.h my_dir.h \ sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ - m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) + m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) \ + $(HEADERS_GEN_MAKE) noinst_HEADERS = config-win.h config-netware.h my_bit.h \ heap.h my_bitmap.h my_uctype.h \ From 26adc3cdc75815533fe47f978d6fa04d8562b643 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 20 Mar 2009 13:35:00 +0200 Subject: [PATCH 54/88] Fixed a prototype to match the actual function signature (addendum to the fix for 29125). --- mysys/hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/hash.c b/mysys/hash.c index 0b44782aeb5..e7b5352af34 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -33,7 +33,7 @@ typedef struct st_hash_info { uchar *data; /* data for current entry */ } HASH_LINK; -static uint my_hash_mask(uint hashnr, uint buffmax, uint maxlength); +static uint my_hash_mask(size_t hashnr, size_t buffmax, size_t maxlength); static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink); static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key, size_t length); From e8cc09dc8df647f7786a7914cecf449570f2394e Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 20 Mar 2009 16:27:53 +0200 Subject: [PATCH 55/88] fixed compilation warnings. addendum to the fix for bug 29125 --- client/mysql_upgrade.c | 2 +- mysys/base64.c | 2 +- sql/log_event.cc | 3 --- sql/sql_cache.cc | 4 ++-- sql/sql_servers.cc | 4 ++-- sql/sql_view.cc | 3 ++- storage/csv/transparent_file.cc | 4 ++-- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index f7e9a14b33e..190bb2383e9 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -373,7 +373,7 @@ static void find_tool(char *tool_executable_name, const char *tool_name, } else { - size_t len; + int len; /* mysql_upgrade was run absolutely or relatively. We can find a sibling diff --git a/mysys/base64.c b/mysys/base64.c index f7d9c8b0d09..ab66715c929 100644 --- a/mysys/base64.c +++ b/mysys/base64.c @@ -223,7 +223,7 @@ base64_decode(const char *src_base, size_t len, The variable 'i' is set to 'len' when padding has been read, so it does not actually reflect the number of bytes read from 'src'. */ - return i != len ? -1 : (uint) (d - dst_base); + return i != len ? -1 : (int) (d - dst_base); } diff --git a/sql/log_event.cc b/sql/log_event.cc index a222534e8b7..dc886aa3309 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1289,7 +1289,6 @@ void Log_event::print_header(IO_CACHE* file, ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7], ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15], ptr[16], ptr[17], ptr[18]); - DBUG_ASSERT(bytes_written >= 0); DBUG_ASSERT(static_cast(bytes_written) < sizeof(emit_buf)); my_b_write(file, (uchar*) emit_buf, bytes_written); ptr += LOG_EVENT_MINIMAL_HEADER_LEN; @@ -1320,7 +1319,6 @@ void Log_event::print_header(IO_CACHE* file, "# %8.8lx %-48.48s |%16s|\n", (unsigned long) (hexdump_from + (i & 0xfffffff0)), hex_string, char_string); - DBUG_ASSERT(bytes_written >= 0); DBUG_ASSERT(static_cast(bytes_written) < sizeof(emit_buf)); my_b_write(file, (uchar*) emit_buf, bytes_written); hex_string[0]= 0; @@ -1340,7 +1338,6 @@ void Log_event::print_header(IO_CACHE* file, "# %8.8lx %-48.48s |%s|\n", (unsigned long) (hexdump_from + (i & 0xfffffff0)), hex_string, char_string); - DBUG_ASSERT(bytes_written >= 0); DBUG_ASSERT(static_cast(bytes_written) < sizeof(emit_buf)); my_b_write(file, (uchar*) emit_buf, bytes_written); } diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 25907d4ec20..32faeae9dcc 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1114,7 +1114,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", { memcpy(thd->query+thd->query_length+1, thd->db, thd->db_length); DBUG_PRINT("qcache", ("database: %s length: %u", - thd->db, thd->db_length)); + thd->db, (unsigned) thd->db_length)); } else { @@ -1307,7 +1307,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) { memcpy(sql+query_length+1, thd->db, thd->db_length); DBUG_PRINT("qcache", ("database: '%s' length: %u", - thd->db, thd->db_length)); + thd->db, (unsigned)thd->db_length)); } else { diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc index b1c856c87aa..f8a8dea18ff 100644 --- a/sql/sql_servers.cc +++ b/sql/sql_servers.cc @@ -1290,8 +1290,8 @@ FOREIGN_SERVER *get_server_by_name(MEM_ROOT *mem, const char *server_name, (uchar*) server_name, server_name_length))) { - DBUG_PRINT("info", ("server_name %s length %d not found!", - server_name, server_name_length)); + DBUG_PRINT("info", ("server_name %s length %u not found!", + server_name, (unsigned) server_name_length)); server= (FOREIGN_SERVER *) NULL; } /* otherwise, make copy of server */ diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 96448f7e5c2..65157ae4255 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -61,7 +61,8 @@ static void make_unique_view_field_name(Item *target, char *name= (target->orig_name ? target->orig_name : target->name); - size_t name_len, attempt; + size_t name_len; + uint attempt; char buff[NAME_LEN+1]; List_iterator_fast itc(item_list); diff --git a/storage/csv/transparent_file.cc b/storage/csv/transparent_file.cc index a200fa6ac36..fad7cd796e5 100644 --- a/storage/csv/transparent_file.cc +++ b/storage/csv/transparent_file.cc @@ -82,7 +82,7 @@ char Transparent_file::get_value(off_t offset) size_t bytes_read; /* check boundaries */ - if ((lower_bound <= offset) && (offset < upper_bound)) + if ((lower_bound <= offset) && (((my_off_t) offset) < upper_bound)) return buff[offset - lower_bound]; VOID(my_seek(filedes, offset, MY_SEEK_SET, MYF(0))); @@ -95,7 +95,7 @@ char Transparent_file::get_value(off_t offset) upper_bound= lower_bound + bytes_read; /* end of file */ - if (upper_bound == offset) + if (upper_bound == (my_off_t) offset) return 0; return buff[0]; From 0bab3f2ffdb57889d7f4b98fc78d77c12e821f06 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 20 Mar 2009 16:49:43 +0200 Subject: [PATCH 56/88] Fixed the failing tests. Addendum to the fix for bug #22504. --- mysql-test/r/mysqlbinlog.result | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index 34d695a0272..b55a96b6f30 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -44,16 +44,16 @@ SET TIMESTAMP=1000000000/*!*/; insert into t2 values () /*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 /*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 /*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 /*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 /*!*/; DELIMITER ; # End of log file @@ -144,16 +144,16 @@ SET TIMESTAMP=1000000000/*!*/; insert into t2 values () /*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 /*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 /*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 /*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 /*!*/; DELIMITER ; # End of log file @@ -359,29 +359,29 @@ SET @@session.collation_database=DEFAULT/*!*/; create table t1 (a varchar(64) character set utf8) /*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 /*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=7/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 /*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=DEFAULT/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 /*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1 /*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=7/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO table t1 /*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.collation_database=DEFAULT/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO table t1 +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO table t1 /*!*/; SET TIMESTAMP=1000000000/*!*/; -load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r +load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r /*!*/; SET TIMESTAMP=1000000000/*!*/; drop table t1 From 2aff261018dbe14b9996fd817a3d39a5690d4b7f Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Fri, 20 Mar 2009 18:11:22 +0100 Subject: [PATCH 57/88] Reviewed fix for bug#37962 also including the revised result files for failing system variable tests. --- .../inc/slave_transaction_retries_basic.inc | 1 + .../suite/sys_vars/inc/sync_binlog_basic.inc | 1 + .../r/binlog_cache_size_basic_32.result | 2 +- .../r/bulk_insert_buffer_size_basic_32.result | 4 + .../r/delayed_insert_limit_basic_32.result | 2 +- .../r/delayed_insert_limit_func.result | 202 +++++---------- .../r/delayed_queue_size_basic_32.result | 2 +- .../sys_vars/r/event_scheduler_func.result | 44 ---- .../sys_vars/r/ft_boolean_syntax_func.result | 4 +- .../r/interactive_timeout_func.result | 17 +- .../r/join_buffer_size_basic_32.result | 4 +- .../r/key_buffer_size_basic_32.result | 10 +- .../r/key_cache_age_threshold_basic_32.result | 8 +- .../r/key_cache_block_size_basic_32.result | 6 +- .../key_cache_division_limit_basic_32.result | 4 +- .../sys_vars/r/log_warnings_basic_32.result | 4 + .../r/max_binlog_cache_size_basic_32.result | 4 +- .../r/max_connect_errors_basic_32.result | 4 +- .../r/max_heap_table_size_basic_32.result | 20 +- .../r/max_seeks_for_key_basic_32.result | 4 +- .../sys_vars/r/max_tmp_tables_basic_32.result | 8 +- .../r/max_write_lock_count_basic_32.result | 4 +- .../r/min_examined_row_limit_basic_32.result | 4 + .../r/multi_range_count_basic_32.result | 4 +- .../myisam_max_sort_file_size_basic_32.result | 6 + .../r/myisam_repair_threads_basic_32.result | 4 +- .../r/myisam_sort_buffer_size_basic_32.result | 4 +- .../r/net_retry_count_basic_32.result | 4 +- .../r/query_alloc_block_size_basic_32.result | 4 +- .../r/query_cache_limit_basic_32.result | 4 + .../query_cache_min_res_unit_basic_32.result | 4 + .../r/query_cache_size_basic_32.result | 4 + .../query_cache_wlock_invalidate_func.result | 13 +- .../r/range_alloc_block_size_basic_32.result | 4 +- .../sys_vars/r/read_buffer_size_basic.result | 6 - .../r/read_rnd_buffer_size_basic.result | 6 - .../sys_vars/r/rpl_init_slave_func.result | 2 +- .../r/rpl_max_binlog_size_func.result | 5 +- .../r/rpl_recovery_rank_basic_32.result | 6 + .../sys_vars/r/server_id_basic_32.result | 4 + .../slave_transaction_retries_basic_32.result | 2 + .../sys_vars/r/slow_query_log_func.result | 4 +- .../r/sql_low_priority_updates_func.result | 2 - .../sys_vars/r/sync_binlog_basic_32.result | 26 +- .../sys_vars/r/tmp_table_size_basic.result | 4 +- ...ansaction_alloc_block_size_basic_32.result | 2 +- .../transaction_prealloc_size_basic_32.result | 2 +- .../sys_vars/r/wait_timeout_basic_32.result | 2 +- .../sys_vars/t/delayed_insert_limit_func.test | 233 ++++++++++-------- .../sys_vars/t/event_scheduler_func.test | 91 ------- .../t/innodb_max_dirty_pages_pct_func.test | 2 +- .../sys_vars/t/interactive_timeout_func.test | 76 +++--- .../t/query_cache_wlock_invalidate_func.test | 21 +- .../suite/sys_vars/t/rpl_init_slave_func.test | 2 +- .../sys_vars/t/rpl_max_binlog_size_func.test | 6 +- .../suite/sys_vars/t/slow_query_log_func.test | 6 +- .../t/sql_low_priority_updates_func.test | 56 +++-- .../suite/sys_vars/t/timestamp_func.test | 2 +- .../suite/sys_vars/t/wait_timeout_func.test | 2 +- 59 files changed, 451 insertions(+), 537 deletions(-) delete mode 100644 mysql-test/suite/sys_vars/r/event_scheduler_func.result delete mode 100644 mysql-test/suite/sys_vars/t/event_scheduler_func.test diff --git a/mysql-test/suite/sys_vars/inc/slave_transaction_retries_basic.inc b/mysql-test/suite/sys_vars/inc/slave_transaction_retries_basic.inc index 6bbed3b1982..28ba8791b0a 100644 --- a/mysql-test/suite/sys_vars/inc/slave_transaction_retries_basic.inc +++ b/mysql-test/suite/sys_vars/inc/slave_transaction_retries_basic.inc @@ -23,6 +23,7 @@ # # ############################################################################### +--source include/not_embedded.inc --source include/load_sysvars.inc ################################################################### diff --git a/mysql-test/suite/sys_vars/inc/sync_binlog_basic.inc b/mysql-test/suite/sys_vars/inc/sync_binlog_basic.inc index b66509bbb5e..04adab85ac8 100644 --- a/mysql-test/suite/sys_vars/inc/sync_binlog_basic.inc +++ b/mysql-test/suite/sys_vars/inc/sync_binlog_basic.inc @@ -23,6 +23,7 @@ # # ############################################################################### +--source include/not_embedded.inc --source include/load_sysvars.inc ################################################################## diff --git a/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_32.result b/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_32.result index 6267c5493da..2f439c8f834 100644 --- a/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_32.result @@ -44,7 +44,7 @@ SET @@global.binlog_cache_size = 10000.01; ERROR 42000: Incorrect argument type to variable 'binlog_cache_size' SET @@global.binlog_cache_size = -1024; Warnings: -Warning 1292 Truncated incorrect binlog_cache_size value: '0' +Warning 1292 Truncated incorrect binlog_cache_size value: '-1024' SELECT @@global.binlog_cache_size; @@global.binlog_cache_size 4096 diff --git a/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_32.result b/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_32.result index 1194a0e7ce7..3e071f76f98 100644 --- a/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_32.result @@ -68,6 +68,8 @@ SELECT @@global.bulk_insert_buffer_size; @@global.bulk_insert_buffer_size 4294967295 SET @@global.bulk_insert_buffer_size = -1024; +Warnings: +Warning 1292 Truncated incorrect bulk_insert_buffer_size value: '-1024' SELECT @@global.bulk_insert_buffer_size; @@global.bulk_insert_buffer_size 0 @@ -84,6 +86,8 @@ SELECT @@session.bulk_insert_buffer_size; @@session.bulk_insert_buffer_size 4294967295 SET @@session.bulk_insert_buffer_size = -2; +Warnings: +Warning 1292 Truncated incorrect bulk_insert_buffer_size value: '-2' SELECT @@session.bulk_insert_buffer_size; @@session.bulk_insert_buffer_size 0 diff --git a/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_32.result b/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_32.result index cb6820b2941..f55c966dc38 100644 --- a/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_32.result +++ b/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_32.result @@ -35,7 +35,7 @@ SELECT @@global.delayed_insert_limit; 1 SET @@global.delayed_insert_limit = -1024; Warnings: -Warning 1292 Truncated incorrect delayed_insert_limit value: '0' +Warning 1292 Truncated incorrect delayed_insert_limit value: '-1024' SELECT @@global.delayed_insert_limit; @@global.delayed_insert_limit 1 diff --git a/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result b/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result index d7129d24498..0496efa4296 100644 --- a/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result +++ b/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result @@ -3,98 +3,75 @@ Creating connection con0 Creating connection con1 SET @global_delayed_insert_limit = @@GLOBAL.delayed_insert_limit; -CREATE TABLE t1 (a varchar(100)); +CREATE TABLE t1 (a VARCHAR(100),b VARCHAR(100),c VARCHAR(100)); '#--------------------FN_DYNVARS_25_01-------------------------#' -SET GLOBAL delayed_insert_limit = 9; -** Connection con0 ** -SET GLOBAL delayed_insert_limit = 9; -** Connection con1 ** -SET GLOBAL delayed_insert_limit = 9; -** Connection default ** -SET GLOBAL delayed_insert_limit = 9; -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'); -INSERT INTO t1 VALUES('6'); +SET GLOBAL delayed_insert_limit = 14; +INSERT INTO t1 VALUES('1','1','1'); +INSERT INTO t1 VALUES('2','1','1'); +INSERT INTO t1 VALUES('3','1','1'); +INSERT INTO t1 VALUES('4','1','1'); +INSERT INTO t1 VALUES('5','1','1'); +INSERT INTO t1 VALUES('6','1','1'); LOCK TABLE t1 WRITE; ** Connection con1 ** -INSERT DELAYED INTO t1 VALUES('7'); -INSERT DELAYED INTO t1 VALUES('8'); -INSERT DELAYED INTO t1 VALUES('9'); -INSERT DELAYED INTO t1 VALUES('10'); -INSERT DELAYED INTO t1 VALUES('11'); -INSERT DELAYED INTO t1 VALUES('12'); -INSERT DELAYED INTO t1 VALUES('13'); -INSERT DELAYED INTO t1 VALUES('14'); -INSERT DELAYED INTO t1 VALUES('15'); -INSERT DELAYED INTO t1 VALUES('16'); -INSERT DELAYED INTO t1 VALUES('17'); -INSERT DELAYED INTO t1 VALUES('18'); -INSERT DELAYED INTO t1 VALUES('19'); -INSERT DELAYED INTO t1 VALUES('20'); -INSERT DELAYED INTO t1 VALUES('21'); -INSERT DELAYED INTO t1 VALUES('22');| +INSERT DELAYED INTO t1 VALUES('7','1','1'); +INSERT DELAYED INTO t1 VALUES('8','1','1'); +INSERT DELAYED INTO t1 VALUES('9','1','1'); +INSERT DELAYED INTO t1 VALUES('10','1','1'); +INSERT DELAYED INTO t1 VALUES('11','1','1'); +INSERT DELAYED INTO t1 VALUES('12','1','1'); +INSERT DELAYED INTO t1 VALUES('13','1','1'); +INSERT DELAYED INTO t1 VALUES('14','1','1'); +INSERT DELAYED INTO t1 VALUES('15','1','1'); +INSERT DELAYED INTO t1 VALUES('16','1','1'); +INSERT DELAYED INTO t1 VALUES('17','1','1'); +INSERT DELAYED INTO t1 VALUES('18','1','1'); +INSERT DELAYED INTO t1 VALUES('19','1','1'); +INSERT DELAYED INTO t1 VALUES('20','1','1'); +INSERT DELAYED INTO t1 VALUES('21','1','1'); +INSERT DELAYED INTO t1 VALUES('22','1','1'); +INSERT DELAYED INTO t1 VALUES('23','1','1'); +INSERT DELAYED INTO t1 VALUES('24','1','1'); +INSERT DELAYED INTO t1 VALUES('25','1','1'); +INSERT DELAYED INTO t1 VALUES('26','1','1'); +INSERT DELAYED INTO t1 VALUES('27','1','1'); +INSERT DELAYED INTO t1 VALUES('28','1','1'); +INSERT DELAYED INTO t1 VALUES('29','1','1'); +INSERT DELAYED INTO t1 VALUES('30','1','1'); +INSERT DELAYED INTO t1 VALUES('31','1','1'); +INSERT DELAYED INTO t1 VALUES('32','1','1'); +INSERT DELAYED INTO t1 VALUES('33','1','1'); +INSERT DELAYED INTO t1 VALUES('34','1','1'); +INSERT DELAYED INTO t1 VALUES('35','1','1'); +INSERT DELAYED INTO t1 VALUES('36','1','1'); +INSERT DELAYED INTO t1 VALUES('37','1','1'); +INSERT DELAYED INTO t1 VALUES('38','1','1'); +INSERT DELAYED INTO t1 VALUES('39','1','1'); +INSERT DELAYED INTO t1 VALUES('40','1','1'); +INSERT DELAYED INTO t1 VALUES('41','1','1'); +INSERT DELAYED INTO t1 VALUES('42','1','1'); +INSERT DELAYED INTO t1 VALUES('43','1','1');| ** Connection con0 ** -SELECT * FROM t1;| +SELECT COUNT(*) FROM t1; ** Connection default ** -Waiting for 1 sec +** Wait till con0 is blocked ** UNLOCK TABLES; +** Connection con1 ** +Asynchronous "reap" result ** Connection con0 ** -a -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -'Bug#35386: insert delayed inserts 1 + limit rows instead of just limit rows' +Asynchronous "reap" result +The next result suffers from +'# Bug#35386 insert delayed inserts 1 + limit rows instead of just limit rows' +COUNT(*) +21 ** Connection default ** -Waiting for 1 sec Checking if the delayed insert continued afterwards -SELECT * FROM t1; -a -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -DELETE FROM t1; +SELECT COUNT(*) FROM t1; +COUNT(*) +43 +DROP TABLE t1; '#--------------------FN_DYNVARS_25_02-------------------------#' -SET GLOBAL delayed_insert_limit = 20; -** Connection con0 ** -SET GLOBAL delayed_insert_limit = 20; -** Connection con1 ** -SET GLOBAL delayed_insert_limit = 20; -** Connection default ** +CREATE TABLE t1 (a VARCHAR(100)); SET GLOBAL delayed_insert_limit = 20; INSERT INTO t1 VALUES('1'); INSERT INTO t1 VALUES('2'); @@ -123,64 +100,21 @@ INSERT DELAYED INTO t1 VALUES('21'); INSERT DELAYED INTO t1 VALUES('22');| ** Connection con0 ** Asynchronous execute -SELECT * FROM t1;| +SELECT COUNT(*) = 22 FROM t1; ** Connection default ** -Waiting for 1 sec +** Wait till con0 is blocked ** UNLOCK TABLES; +** Connection con1 ** ** Connection con0 ** -Asynchronous execute result -a +Asynchronous "reap" result +COUNT(*) = 22 1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 ** Connection default** -Waiting for 1 sec Checking if the delayed insert gives the same result afterwards -SELECT * FROM t1; -a +SELECT COUNT(*) = 22 FROM t1; +COUNT(*) = 22 1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -DELETE FROM t1; -Switching to default -Disconnecting from con1, con0 +** Connection default** DROP TABLE t1; SET @@GLOBAL.delayed_insert_limit = @global_delayed_insert_limit; +Disconnecting from con1, con0 diff --git a/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_32.result b/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_32.result index 6bfa6f0de40..3b356c6d866 100644 --- a/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_32.result @@ -35,7 +35,7 @@ SELECT @@global.delayed_queue_size; 1 SET @@global.delayed_queue_size = -1024; Warnings: -Warning 1292 Truncated incorrect delayed_queue_size value: '0' +Warning 1292 Truncated incorrect delayed_queue_size value: '-1024' SELECT @@global.delayed_queue_size; @@global.delayed_queue_size 1 diff --git a/mysql-test/suite/sys_vars/r/event_scheduler_func.result b/mysql-test/suite/sys_vars/r/event_scheduler_func.result deleted file mode 100644 index 8da942e919c..00000000000 --- a/mysql-test/suite/sys_vars/r/event_scheduler_func.result +++ /dev/null @@ -1,44 +0,0 @@ -drop table if exists t1; -## Creating new table ## -CREATE TABLE t1 -( -id INT NOT NULL auto_increment, -PRIMARY KEY (id), -name VARCHAR(30) -); -'#--------------------FN_DYNVARS_018_01-------------------------#' -## Setting initial value of variable to ON ## -SET @@global.event_scheduler = ON; -SELECT @@event_scheduler; -@@event_scheduler -ON -## Creating new event ## -CREATE EVENT test_event_1 -ON SCHEDULE EVERY 3 SECOND -DO -INSERT into t1(name) values('Record_1'); -SELECT * from t1; -id name -1 Record_1 -2 Record_1 -DROP EVENT test_event_1; -DELETE from t1; -select * from t1; -id name -'#--------------------FN_DYNVARS_018_02-------------------------#' -## Setting value of variable to OFF ## -SET @@global.event_scheduler = OFF; -SELECT @@event_scheduler; -@@event_scheduler -OFF -## Creating new event ## -CREATE EVENT test_event_1 -ON SCHEDULE EVERY 3 SECOND -DO -INSERT into t1(name) values('Record_2'); -## Table should be empty ## -SELECT * from t1; -id name -DROP EVENT test_event_1; -## Dropping table ## -DROP table t1; diff --git a/mysql-test/suite/sys_vars/r/ft_boolean_syntax_func.result b/mysql-test/suite/sys_vars/r/ft_boolean_syntax_func.result index 4a3159c77c3..0096c553155 100644 --- a/mysql-test/suite/sys_vars/r/ft_boolean_syntax_func.result +++ b/mysql-test/suite/sys_vars/r/ft_boolean_syntax_func.result @@ -70,7 +70,7 @@ FROM articles WHERE MATCH (title,body) AGAINST ('+security configuring' IN BOOLEAN MODE); id title body relevance 8 MySQL Security When configured properly, MySQL ... 1 -9 Database Security Configuring MySQL for ... 1.3333333730698 +9 Database Security Configuring MySQL for ... 1.33333337306976 SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"faster than"' IN BOOLEAN MODE); id title body @@ -91,7 +91,7 @@ AGAINST ('+MySQL +(>show <()~*:""&|'--' SET @@global.ft_boolean_syntax='~ /!@#$%^&*()-'; SELECT * FROM articles WHERE MATCH (title,body) diff --git a/mysql-test/suite/sys_vars/r/interactive_timeout_func.result b/mysql-test/suite/sys_vars/r/interactive_timeout_func.result index b97f7c90908..2ecd32f53bd 100644 --- a/mysql-test/suite/sys_vars/r/interactive_timeout_func.result +++ b/mysql-test/suite/sys_vars/r/interactive_timeout_func.result @@ -9,22 +9,27 @@ name VARCHAR(30) '#--------------------FN_DYNVARS_052_01-------------------------#' ## Setting initial value of variable to 1 ## SET @@global.interactive_timeout = 1; -## Creating new interactive connection test_con1 ## +## Creating new connection test_con1 ## ## Inserting record in table ## INSERT into t1(name) values('Record_1'); -## Setting session value of interactive_timeout ## +## Setting session value of interactive_timeout ## SET @@session.interactive_timeout = 1; -## Verifying values of variable ## +## Verifying values of variable ## SELECT @@session.interactive_timeout; @@session.interactive_timeout 1 SELECT @@global.interactive_timeout; @@global.interactive_timeout 1 -## Using sleep to check timeout ## +connection default; +## Using sleep to check timeout ## +sleep 2; +connection test_con1; SELECT * from t1; id name 1 Record_1 -'Bug#35377: Error should appear here because interactive_timeout value'; -'is 1 and connection remains idle for 5 secs'; INSERT into t1(name) values('Record_2'); +connection default; +disconnect test_con1; +DROP TABLE t1; +SET @@global.interactive_timeout= 28800; diff --git a/mysql-test/suite/sys_vars/r/join_buffer_size_basic_32.result b/mysql-test/suite/sys_vars/r/join_buffer_size_basic_32.result index e3016a2b22c..2318c6d7055 100644 --- a/mysql-test/suite/sys_vars/r/join_buffer_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/join_buffer_size_basic_32.result @@ -75,7 +75,7 @@ SELECT @@global.join_buffer_size=8200 OR @@global.join_buffer_size= 8228; 1 SET @@global.join_buffer_size = -1024; Warnings: -Warning 1292 Truncated incorrect join_buffer_size value: '0' +Warning 1292 Truncated incorrect join_buffer_size value: '-1024' SELECT @@global.join_buffer_size=8200 OR @@global.join_buffer_size= 8228; @@global.join_buffer_size=8200 OR @@global.join_buffer_size= 8228 1 @@ -109,7 +109,7 @@ SELECT @@session.join_buffer_size=8200 OR @@session.join_buffer_size= 8228; 1 SET @@session.join_buffer_size = -2; Warnings: -Warning 1292 Truncated incorrect join_buffer_size value: '0' +Warning 1292 Truncated incorrect join_buffer_size value: '-2' SELECT @@session.join_buffer_size=8200 OR @@session.join_buffer_size= 8228; @@session.join_buffer_size=8200 OR @@session.join_buffer_size= 8228 1 diff --git a/mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result b/mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result index 7221da16ed8..eea782701bb 100644 --- a/mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result @@ -17,8 +17,6 @@ SELECT @@global.key_buffer_size BETWEEN 8 AND 36; @@global.key_buffer_size BETWEEN 8 AND 36 1 SET @@global.key_buffer_size = 1800; -Warnings: -Warning 1292 Truncated incorrect key_buffer_size value: '1800' SELECT @@global.key_buffer_size BETWEEN 8 AND 36; @@global.key_buffer_size BETWEEN 8 AND 36 1 @@ -55,13 +53,13 @@ SELECT @@global.key_buffer_size BETWEEN 8 AND 36; @@global.key_buffer_size BETWEEN 8 AND 36 1 '#----------------------FN_DYNVARS_055_06------------------------#' -SELECT @@global.key_buffer_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +SELECT @@global.key_buffer_size = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='key_buffer_size'; @@global.key_buffer_size = VARIABLE_VALUE 1 -SELECT @@key_buffer_size = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.SESSION_VARIABLES +SELECT @@key_buffer_size = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='key_buffer_size'; @@key_buffer_size = VARIABLE_VALUE 1 diff --git a/mysql-test/suite/sys_vars/r/key_cache_age_threshold_basic_32.result b/mysql-test/suite/sys_vars/r/key_cache_age_threshold_basic_32.result index 023b23ea425..c79e7beb198 100644 --- a/mysql-test/suite/sys_vars/r/key_cache_age_threshold_basic_32.result +++ b/mysql-test/suite/sys_vars/r/key_cache_age_threshold_basic_32.result @@ -37,10 +37,14 @@ SELECT @@global.key_cache_age_threshold; 'Bug# 34877 : Invalid Values are coming in variable on assigning valid values and Out Of Memory Warnings are coming'; '#--------------------FN_DYNVARS_056_04-------------------------#' SET @@global.key_cache_age_threshold = -1; +Warnings: +Warning 1292 Truncated incorrect key_cache_age_threshold value: '18446744073709551615' SELECT @@global.key_cache_age_threshold; @@global.key_cache_age_threshold 4294967200 SET @@global.key_cache_age_threshold = 42949672951; +Warnings: +Warning 1292 Truncated incorrect key_cache_age_threshold value: '42949672951' SELECT @@global.key_cache_age_threshold; @@global.key_cache_age_threshold 4294967200 @@ -50,9 +54,11 @@ SELECT @@global.key_cache_age_threshold; @@global.key_cache_age_threshold 4294967200 SET @@global.key_cache_age_threshold = -1024; +Warnings: +Warning 1292 Truncated incorrect key_cache_age_threshold value: '18446744073709550592' SELECT @@global.key_cache_age_threshold; @@global.key_cache_age_threshold -4294966200 +4294967200 SET @@global.key_cache_age_threshold = 99; Warnings: Warning 1292 Truncated incorrect key_cache_age_threshold value: '99' diff --git a/mysql-test/suite/sys_vars/r/key_cache_block_size_basic_32.result b/mysql-test/suite/sys_vars/r/key_cache_block_size_basic_32.result index ac78acb8244..46ce1f26b29 100644 --- a/mysql-test/suite/sys_vars/r/key_cache_block_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/key_cache_block_size_basic_32.result @@ -36,13 +36,13 @@ SELECT @@global.key_cache_block_size; '#--------------------FN_DYNVARS_057_04-------------------------#' SET @@global.key_cache_block_size = -1; Warnings: -Warning 1292 Truncated incorrect key_cache_block_size value: '4294967295' +Warning 1292 Truncated incorrect key_cache_block_size value: '18446744073709551615' SELECT @@global.key_cache_block_size; @@global.key_cache_block_size 16384 SET @@global.key_cache_block_size = 42949672951; Warnings: -Warning 1292 Truncated incorrect key_cache_block_size value: '4294967287' +Warning 1292 Truncated incorrect key_cache_block_size value: '42949672951' SELECT @@global.key_cache_block_size; @@global.key_cache_block_size 16384 @@ -53,7 +53,7 @@ SELECT @@global.key_cache_block_size; 16384 SET @@global.key_cache_block_size = -1024; Warnings: -Warning 1292 Truncated incorrect key_cache_block_size value: '4294966272' +Warning 1292 Truncated incorrect key_cache_block_size value: '18446744073709550592' SELECT @@global.key_cache_block_size; @@global.key_cache_block_size 16384 diff --git a/mysql-test/suite/sys_vars/r/key_cache_division_limit_basic_32.result b/mysql-test/suite/sys_vars/r/key_cache_division_limit_basic_32.result index 5902dbcdf89..cd0cdcbca05 100644 --- a/mysql-test/suite/sys_vars/r/key_cache_division_limit_basic_32.result +++ b/mysql-test/suite/sys_vars/r/key_cache_division_limit_basic_32.result @@ -35,7 +35,7 @@ SELECT @@global.key_cache_division_limit; '#--------------------FN_DYNVARS_058_04-------------------------#' SET @@global.key_cache_division_limit = -1; Warnings: -Warning 1292 Truncated incorrect key_cache_division_limit value: '4294967295' +Warning 1292 Truncated incorrect key_cache_division_limit value: '18446744073709551615' SELECT @@global.key_cache_division_limit; @@global.key_cache_division_limit 100 @@ -52,7 +52,7 @@ SELECT @@global.key_cache_division_limit; 100 SET @@global.key_cache_division_limit = -1024; Warnings: -Warning 1292 Truncated incorrect key_cache_division_limit value: '4294966272' +Warning 1292 Truncated incorrect key_cache_division_limit value: '18446744073709550592' SELECT @@global.key_cache_division_limit; @@global.key_cache_division_limit 100 diff --git a/mysql-test/suite/sys_vars/r/log_warnings_basic_32.result b/mysql-test/suite/sys_vars/r/log_warnings_basic_32.result index 900bb487706..92b0f4e5e91 100644 --- a/mysql-test/suite/sys_vars/r/log_warnings_basic_32.result +++ b/mysql-test/suite/sys_vars/r/log_warnings_basic_32.result @@ -76,6 +76,8 @@ SELECT @@global.log_warnings; @@global.log_warnings 4294967295 SET @@global.log_warnings = -1024; +Warnings: +Warning 1292 Truncated incorrect log_warnings value: '-1024' SELECT @@global.log_warnings; @@global.log_warnings 0 @@ -96,6 +98,8 @@ SELECT @@session.log_warnings; @@session.log_warnings 4294967295 SET @@session.log_warnings = -2; +Warnings: +Warning 1292 Truncated incorrect log_warnings value: '-2' SELECT @@session.log_warnings; @@session.log_warnings 0 diff --git a/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_32.result b/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_32.result index a594295c0f5..1b3b65010b2 100644 --- a/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_32.result @@ -39,7 +39,7 @@ SELECT @@global.max_binlog_cache_size; '#--------------------FN_DYNVARS_072_04-------------------------#' SET @@global.max_binlog_cache_size = -1; Warnings: -Warning 1292 Truncated incorrect max_binlog_cache_size value: '0' +Warning 1292 Truncated incorrect max_binlog_cache_size value: '-1' SELECT @@global.max_binlog_cache_size; @@global.max_binlog_cache_size 4096 @@ -56,7 +56,7 @@ SELECT @@global.max_binlog_cache_size; 4294963200 SET @@global.max_binlog_cache_size = -1024; Warnings: -Warning 1292 Truncated incorrect max_binlog_cache_size value: '0' +Warning 1292 Truncated incorrect max_binlog_cache_size value: '-1024' SELECT @@global.max_binlog_cache_size; @@global.max_binlog_cache_size 4096 diff --git a/mysql-test/suite/sys_vars/r/max_connect_errors_basic_32.result b/mysql-test/suite/sys_vars/r/max_connect_errors_basic_32.result index b786e0ce31a..42e64f1b418 100644 --- a/mysql-test/suite/sys_vars/r/max_connect_errors_basic_32.result +++ b/mysql-test/suite/sys_vars/r/max_connect_errors_basic_32.result @@ -39,7 +39,7 @@ SELECT @@global.max_connect_errors; '#--------------------FN_DYNVARS_073_04-------------------------#' SET @@global.max_connect_errors = -1; Warnings: -Warning 1292 Truncated incorrect max_connect_errors value: '0' +Warning 1292 Truncated incorrect max_connect_errors value: '-1' SELECT @@global.max_connect_errors; @@global.max_connect_errors 1 @@ -56,7 +56,7 @@ SELECT @@global.max_connect_errors; 4294967295 SET @@global.max_connect_errors = -1024; Warnings: -Warning 1292 Truncated incorrect max_connect_errors value: '0' +Warning 1292 Truncated incorrect max_connect_errors value: '-1024' SELECT @@global.max_connect_errors; @@global.max_connect_errors 1 diff --git a/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_32.result b/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_32.result index 04eaa3ddd19..deedb9ae43c 100644 --- a/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_32.result @@ -40,10 +40,14 @@ SELECT @@global.max_heap_table_size; @@global.max_heap_table_size 64512 SET @@global.max_heap_table_size = 4294967294; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '4294967294' SELECT @@global.max_heap_table_size; @@global.max_heap_table_size 4294966272 SET @@global.max_heap_table_size = 4294967295; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '4294967295' SELECT @@global.max_heap_table_size; @@global.max_heap_table_size 4294966272 @@ -62,10 +66,14 @@ SELECT @@session.max_heap_table_size; @@session.max_heap_table_size 64512 SET @@session.max_heap_table_size = 4294967294; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '4294967294' SELECT @@session.max_heap_table_size; @@session.max_heap_table_size 4294966272 SET @@session.max_heap_table_size = 4294967295; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '4294967295' SELECT @@session.max_heap_table_size; @@session.max_heap_table_size 4294966272 @@ -73,13 +81,13 @@ SELECT @@session.max_heap_table_size; '#------------------FN_DYNVARS_077_05-----------------------#' SET @@global.max_heap_table_size = -1; Warnings: -Warning 1292 Truncated incorrect max_heap_table_size value: '0' +Warning 1292 Truncated incorrect max_heap_table_size value: '-1' SELECT @@global.max_heap_table_size; @@global.max_heap_table_size 16384 SET @@global.max_heap_table_size = -1024; Warnings: -Warning 1292 Truncated incorrect max_heap_table_size value: '0' +Warning 1292 Truncated incorrect max_heap_table_size value: '-1024' SELECT @@global.max_heap_table_size; @@global.max_heap_table_size 16384 @@ -96,6 +104,8 @@ SELECT @@global.max_heap_table_size; @@global.max_heap_table_size 16384 SET @@global.max_heap_table_size = 4294967296; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '4294967296' SELECT @@global.max_heap_table_size; @@global.max_heap_table_size 4294966272 @@ -111,7 +121,7 @@ SELECT @@global.max_heap_table_size; 4294966272 SET @@session.max_heap_table_size = -1; Warnings: -Warning 1292 Truncated incorrect max_heap_table_size value: '0' +Warning 1292 Truncated incorrect max_heap_table_size value: '-1' SELECT @@session.max_heap_table_size; @@session.max_heap_table_size 16384 @@ -122,12 +132,16 @@ SELECT @@session.max_heap_table_size; @@session.max_heap_table_size 16384 SET @@session.max_heap_table_size = 4294967296; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '4294967296' SELECT @@session.max_heap_table_size; @@session.max_heap_table_size 4294966272 SET @@session.max_heap_table_size = 65530.34.; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1 SET @@session.max_heap_table_size = 10737418241; +Warnings: +Warning 1292 Truncated incorrect max_heap_table_size value: '10737418241' SELECT @@session.max_heap_table_size; @@session.max_heap_table_size 4294966272 diff --git a/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_32.result b/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_32.result index 64828fbe619..9a58ad44cff 100644 --- a/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_32.result +++ b/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_32.result @@ -77,7 +77,7 @@ SELECT @@global.max_seeks_for_key; 1 SET @@global.max_seeks_for_key = -1024; Warnings: -Warning 1292 Truncated incorrect max_seeks_for_key value: '0' +Warning 1292 Truncated incorrect max_seeks_for_key value: '-1024' SELECT @@global.max_seeks_for_key; @@global.max_seeks_for_key 1 @@ -105,7 +105,7 @@ SELECT @@session.max_seeks_for_key; 1 SET @@session.max_seeks_for_key = -2; Warnings: -Warning 1292 Truncated incorrect max_seeks_for_key value: '0' +Warning 1292 Truncated incorrect max_seeks_for_key value: '-2' SELECT @@session.max_seeks_for_key; @@session.max_seeks_for_key 1 diff --git a/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_32.result b/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_32.result index 5f959069661..1346d24ca47 100644 --- a/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_32.result +++ b/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_32.result @@ -71,7 +71,7 @@ SELECT @@session.max_tmp_tables; '#------------------FN_DYNVARS_086_05-----------------------#' SET @@global.max_tmp_tables = -1024; Warnings: -Warning 1292 Truncated incorrect max_tmp_tables value: '0' +Warning 1292 Truncated incorrect max_tmp_tables value: '-1024' SELECT @@global.max_tmp_tables; @@global.max_tmp_tables 1 @@ -83,7 +83,7 @@ SELECT @@global.max_tmp_tables; 4294967295 SET @@global.max_tmp_tables = -1; Warnings: -Warning 1292 Truncated incorrect max_tmp_tables value: '0' +Warning 1292 Truncated incorrect max_tmp_tables value: '-1' SELECT @@global.max_tmp_tables; @@global.max_tmp_tables 1 @@ -111,7 +111,7 @@ SELECT @@session.max_tmp_tables; 4294967295 SET @@session.max_tmp_tables = -1; Warnings: -Warning 1292 Truncated incorrect max_tmp_tables value: '0' +Warning 1292 Truncated incorrect max_tmp_tables value: '-1' SELECT @@session.max_tmp_tables; @@session.max_tmp_tables 1 @@ -123,7 +123,7 @@ SELECT @@session.max_tmp_tables; 4294967295 SET @@session.max_tmp_tables = -001; Warnings: -Warning 1292 Truncated incorrect max_tmp_tables value: '0' +Warning 1292 Truncated incorrect max_tmp_tables value: '-1' SELECT @@session.max_tmp_tables; @@session.max_tmp_tables 1 diff --git a/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_32.result b/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_32.result index 0c9c3c00c1f..24af37260b7 100644 --- a/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_32.result +++ b/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_32.result @@ -37,7 +37,7 @@ SELECT @@global.max_write_lock_count; '#------------------FN_DYNVARS_088_04-----------------------#' SET @@global.max_write_lock_count = -1024; Warnings: -Warning 1292 Truncated incorrect max_write_lock_count value: '0' +Warning 1292 Truncated incorrect max_write_lock_count value: '-1024' SELECT @@global.max_write_lock_count; @@global.max_write_lock_count 1 @@ -49,7 +49,7 @@ SELECT @@global.max_write_lock_count; 4294967295 SET @@global.max_write_lock_count = -1; Warnings: -Warning 1292 Truncated incorrect max_write_lock_count value: '0' +Warning 1292 Truncated incorrect max_write_lock_count value: '-1' SELECT @@global.max_write_lock_count; @@global.max_write_lock_count 1 diff --git a/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_32.result b/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_32.result index c0315944a8a..c40640ffa3a 100644 --- a/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_32.result +++ b/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_32.result @@ -82,6 +82,8 @@ SELECT @@global.min_examined_row_limit; @@global.min_examined_row_limit 429496726 SET @@global.min_examined_row_limit = -1024; +Warnings: +Warning 1292 Truncated incorrect min_examined_row_limit value: '-1024' SELECT @@global.min_examined_row_limit; @@global.min_examined_row_limit 0 @@ -108,6 +110,8 @@ SELECT @@session.min_examined_row_limit; @@session.min_examined_row_limit 4294967295 SET @@session.min_examined_row_limit = -1; +Warnings: +Warning 1292 Truncated incorrect min_examined_row_limit value: '-1' SELECT @@session.min_examined_row_limit; @@session.min_examined_row_limit 0 diff --git a/mysql-test/suite/sys_vars/r/multi_range_count_basic_32.result b/mysql-test/suite/sys_vars/r/multi_range_count_basic_32.result index f6ac6490479..33222f781f2 100644 --- a/mysql-test/suite/sys_vars/r/multi_range_count_basic_32.result +++ b/mysql-test/suite/sys_vars/r/multi_range_count_basic_32.result @@ -83,7 +83,7 @@ SELECT @@global.multi_range_count; 4294967295 SET @@global.multi_range_count = -1024; Warnings: -Warning 1292 Truncated incorrect multi_range_count value: '0' +Warning 1292 Truncated incorrect multi_range_count value: '-1024' SELECT @@global.multi_range_count; @@global.multi_range_count 1 @@ -117,7 +117,7 @@ SELECT @@session.multi_range_count; 4294967295 SET @@session.multi_range_count = -1; Warnings: -Warning 1292 Truncated incorrect multi_range_count value: '0' +Warning 1292 Truncated incorrect multi_range_count value: '-1' SELECT @@session.multi_range_count; @@session.multi_range_count 1 diff --git a/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_32.result b/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_32.result index 7467537eaba..b2a8603de92 100644 --- a/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_32.result @@ -48,14 +48,20 @@ SET @@local.myisam_max_sort_file_size = 4; ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL '#------------------FN_DYNVARS_094_05-----------------------#' SET @@global.myisam_max_sort_file_size = -1; +Warnings: +Warning 1292 Truncated incorrect myisam_max_sort_file_size value: '-1' SELECT @@global.myisam_max_sort_file_size; @@global.myisam_max_sort_file_size 0 SET @@global.myisam_max_sort_file_size = -2147483648; +Warnings: +Warning 1292 Truncated incorrect myisam_max_sort_file_size value: '-2147483648' SELECT @@global.myisam_max_sort_file_size; @@global.myisam_max_sort_file_size 0 SET @@global.myisam_max_sort_file_size = -2147483649; +Warnings: +Warning 1292 Truncated incorrect myisam_max_sort_file_size value: '-2147483649' SELECT @@global.myisam_max_sort_file_size; @@global.myisam_max_sort_file_size 0 diff --git a/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_32.result b/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_32.result index c91128e3f4c..64321814746 100644 --- a/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_32.result +++ b/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_32.result @@ -61,7 +61,7 @@ SELECT @@global.myisam_repair_threads ; 1 SET @@global.myisam_repair_threads = -1024; Warnings: -Warning 1292 Truncated incorrect myisam_repair_threads value: '0' +Warning 1292 Truncated incorrect myisam_repair_threads value: '-1024' SELECT @@global.myisam_repair_threads ; @@global.myisam_repair_threads 1 @@ -104,7 +104,7 @@ SELECT @@session.myisam_repair_threads ; 1 SET @@session.myisam_repair_threads = -2; Warnings: -Warning 1292 Truncated incorrect myisam_repair_threads value: '0' +Warning 1292 Truncated incorrect myisam_repair_threads value: '-2' SELECT @@session.myisam_repair_threads ; @@session.myisam_repair_threads 1 diff --git a/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_32.result b/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_32.result index 74d2fb3ec86..2657d599df7 100644 --- a/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_32.result @@ -61,7 +61,7 @@ SELECT @@global.myisam_sort_buffer_size ; 4 SET @@global.myisam_sort_buffer_size = -1024; Warnings: -Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '0' +Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '-1024' SELECT @@global.myisam_sort_buffer_size ; @@global.myisam_sort_buffer_size 4 @@ -104,7 +104,7 @@ SELECT @@session.myisam_sort_buffer_size ; 4 SET @@session.myisam_sort_buffer_size = -2; Warnings: -Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '0' +Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '-2' SELECT @@session.myisam_sort_buffer_size ; @@session.myisam_sort_buffer_size 4 diff --git a/mysql-test/suite/sys_vars/r/net_retry_count_basic_32.result b/mysql-test/suite/sys_vars/r/net_retry_count_basic_32.result index 3923df539e7..7a8b99ac55c 100644 --- a/mysql-test/suite/sys_vars/r/net_retry_count_basic_32.result +++ b/mysql-test/suite/sys_vars/r/net_retry_count_basic_32.result @@ -77,7 +77,7 @@ SELECT @@global.net_retry_count; 1 SET @@global.net_retry_count = -1024; Warnings: -Warning 1292 Truncated incorrect net_retry_count value: '0' +Warning 1292 Truncated incorrect net_retry_count value: '-1024' SELECT @@global.net_retry_count; @@global.net_retry_count 1 @@ -111,7 +111,7 @@ SELECT @@session.net_retry_count; 1 SET @@session.net_retry_count = -2; Warnings: -Warning 1292 Truncated incorrect net_retry_count value: '0' +Warning 1292 Truncated incorrect net_retry_count value: '-2' SELECT @@session.net_retry_count; @@session.net_retry_count 1 diff --git a/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_32.result b/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_32.result index 32b9371977c..2ea0831a36d 100644 --- a/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_32.result @@ -86,7 +86,7 @@ SELECT @@global.query_alloc_block_size; 1024 SET @@global.query_alloc_block_size = -1; Warnings: -Warning 1292 Truncated incorrect query_alloc_block_size value: '0' +Warning 1292 Truncated incorrect query_alloc_block_size value: '-1' SELECT @@global.query_alloc_block_size; @@global.query_alloc_block_size 1024 @@ -120,7 +120,7 @@ SELECT @@session.query_alloc_block_size; 1024 SET @@session.query_alloc_block_size = -2; Warnings: -Warning 1292 Truncated incorrect query_alloc_block_size value: '0' +Warning 1292 Truncated incorrect query_alloc_block_size value: '-2' SELECT @@session.query_alloc_block_size; @@session.query_alloc_block_size 1024 diff --git a/mysql-test/suite/sys_vars/r/query_cache_limit_basic_32.result b/mysql-test/suite/sys_vars/r/query_cache_limit_basic_32.result index bb66233732d..4fab29b8952 100644 --- a/mysql-test/suite/sys_vars/r/query_cache_limit_basic_32.result +++ b/mysql-test/suite/sys_vars/r/query_cache_limit_basic_32.result @@ -32,6 +32,8 @@ SELECT @@global.query_cache_limit; 1048575 '#--------------------FN_DYNVARS_131_04-------------------------#' SET @@global.query_cache_limit = -1; +Warnings: +Warning 1292 Truncated incorrect query_cache_limit value: '-1' SELECT @@global.query_cache_limit; @@global.query_cache_limit 0 @@ -53,6 +55,8 @@ SELECT @@global.query_cache_limit; @@global.query_cache_limit 4294967295 SET @@global.query_cache_limit = -1024; +Warnings: +Warning 1292 Truncated incorrect query_cache_limit value: '-1024' SELECT @@global.query_cache_limit; @@global.query_cache_limit 0 diff --git a/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_32.result b/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_32.result index e0d8a0d2a30..b6e274d6ad2 100644 --- a/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_32.result +++ b/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_32.result @@ -42,6 +42,8 @@ SELECT @@global.query_cache_min_res_unit; 1048576 '#--------------------FN_DYNVARS_132_04-------------------------#' SET @@global.query_cache_min_res_unit = -1; +Warnings: +Warning 1292 Truncated incorrect query_cache_min_res_unit value: '-1' SELECT @@global.query_cache_min_res_unit; @@global.query_cache_min_res_unit 512 @@ -61,6 +63,8 @@ SELECT @@global.query_cache_min_res_unit; @@global.query_cache_min_res_unit 512 SET @@global.query_cache_min_res_unit = -1024; +Warnings: +Warning 1292 Truncated incorrect query_cache_min_res_unit value: '-1024' SELECT @@global.query_cache_min_res_unit; @@global.query_cache_min_res_unit 512 diff --git a/mysql-test/suite/sys_vars/r/query_cache_size_basic_32.result b/mysql-test/suite/sys_vars/r/query_cache_size_basic_32.result index 1793726b2f1..5ceb02182b3 100644 --- a/mysql-test/suite/sys_vars/r/query_cache_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/query_cache_size_basic_32.result @@ -41,6 +41,8 @@ SELECT @@global.query_cache_size; 1047552 '#--------------------FN_DYNVARS_133_04-------------------------#' SET @@global.query_cache_size = -1; +Warnings: +Warning 1292 Truncated incorrect query_cache_size value: '-1' SELECT @@global.query_cache_size; @@global.query_cache_size 0 @@ -61,6 +63,8 @@ SELECT @@global.query_cache_size; @@global.query_cache_size 0 SET @@global.query_cache_size = -1024; +Warnings: +Warning 1292 Truncated incorrect query_cache_size value: '-1024' SELECT @@global.query_cache_size; @@global.query_cache_size 0 diff --git a/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result b/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result index 71ee11a5235..6b90b61a035 100644 --- a/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result +++ b/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result @@ -53,7 +53,7 @@ LOCK TABLE t1 WRITE; ** Asynchronous Execution ** SELECT * FROM t1; ** Connection con0 ** -Sleeping 2 Seconds before unlock +wait until table is locked UNLOCK TABLES; ** Connection con1 ** ** Asynchronous Result ** @@ -108,8 +108,17 @@ id value 1 val1 2 val2 3 val3 +SELECT * FROM t1; +id value +1 val1 +2 val2 +3 val3 +SELECT * FROM t1; +id value +1 val1 +2 val2 +3 val3 ** Connection con0 ** -Sleeping 2 Seconds before unlock UNLOCK TABLES; ** Connection con1 ** '#----------------------------FN_DYNVARS_136_05------------------------#' diff --git a/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_32.result b/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_32.result index 95e22dfcf14..9e3b7851d8a 100644 --- a/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_32.result @@ -79,7 +79,7 @@ SELECT @@global.range_alloc_block_size; 4096 SET @@global.range_alloc_block_size = -1024; Warnings: -Warning 1292 Truncated incorrect range_alloc_block_size value: '0' +Warning 1292 Truncated incorrect range_alloc_block_size value: '-1024' SELECT @@global.range_alloc_block_size; @@global.range_alloc_block_size 4096 @@ -107,7 +107,7 @@ SELECT @@session.range_alloc_block_size; 4096 SET @@session.range_alloc_block_size = -2; Warnings: -Warning 1292 Truncated incorrect range_alloc_block_size value: '0' +Warning 1292 Truncated incorrect range_alloc_block_size value: '-2' SELECT @@session.range_alloc_block_size; @@session.range_alloc_block_size 4096 diff --git a/mysql-test/suite/sys_vars/r/read_buffer_size_basic.result b/mysql-test/suite/sys_vars/r/read_buffer_size_basic.result index 046ba977c23..6aee841c939 100644 --- a/mysql-test/suite/sys_vars/r/read_buffer_size_basic.result +++ b/mysql-test/suite/sys_vars/r/read_buffer_size_basic.result @@ -155,15 +155,11 @@ SELECT @@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228 ; 'Bug: FN_DYNVARS_138_08- Errors are not coming on assigning TRUE/FALSE to variable' '#---------------------FN_DYNVARS_138_09----------------------#' SET @@global.read_buffer_size = 9000; -Warnings: -Warning 1292 Truncated incorrect read_buffer_size value: '9000' SELECT @@read_buffer_size = @@global.read_buffer_size; @@read_buffer_size = @@global.read_buffer_size 0 '#---------------------FN_DYNVARS_138_10----------------------#' SET @@read_buffer_size = 9000; -Warnings: -Warning 1292 Truncated incorrect read_buffer_size value: '9000' SELECT @@read_buffer_size = @@local.read_buffer_size; @@read_buffer_size = @@local.read_buffer_size 1 @@ -172,8 +168,6 @@ SELECT @@local.read_buffer_size = @@session.read_buffer_size; 1 '#---------------------FN_DYNVARS_138_11----------------------#' SET read_buffer_size = 9100; -Warnings: -Warning 1292 Truncated incorrect read_buffer_size value: '9100' SELECT @@read_buffer_size= 8200 OR @@read_buffer_size= 8228 ; @@read_buffer_size= 8200 OR @@read_buffer_size= 8228 1 diff --git a/mysql-test/suite/sys_vars/r/read_rnd_buffer_size_basic.result b/mysql-test/suite/sys_vars/r/read_rnd_buffer_size_basic.result index 817d5a2324a..f2645e4d527 100644 --- a/mysql-test/suite/sys_vars/r/read_rnd_buffer_size_basic.result +++ b/mysql-test/suite/sys_vars/r/read_rnd_buffer_size_basic.result @@ -154,15 +154,11 @@ SELECT @@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 822 1 '#---------------------FN_DYNVARS_140_09----------------------#' SET @@global.read_rnd_buffer_size = 9000; -Warnings: -Warning 1292 Truncated incorrect read_rnd_buffer_size value: '9000' SELECT @@read_rnd_buffer_size = @@global.read_rnd_buffer_size; @@read_rnd_buffer_size = @@global.read_rnd_buffer_size 0 '#---------------------FN_DYNVARS_140_10----------------------#' SET @@read_rnd_buffer_size = 9000; -Warnings: -Warning 1292 Truncated incorrect read_rnd_buffer_size value: '9000' SELECT @@read_rnd_buffer_size = @@local.read_rnd_buffer_size; @@read_rnd_buffer_size = @@local.read_rnd_buffer_size 1 @@ -171,8 +167,6 @@ SELECT @@local.read_rnd_buffer_size = @@session.read_rnd_buffer_size; 1 '#---------------------FN_DYNVARS_140_11----------------------#' SET read_rnd_buffer_size = 9100; -Warnings: -Warning 1292 Truncated incorrect read_rnd_buffer_size value: '9100' SELECT @@read_rnd_buffer_size= 8200 OR @@read_rnd_buffer_size= 8228; @@read_rnd_buffer_size= 8200 OR @@read_rnd_buffer_size= 8228 1 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 0d1f4d483d8..5f730bff882 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 longtext NO NULL +my_column varchar(59) NO 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/rpl_max_binlog_size_func.result b/mysql-test/suite/sys_vars/r/rpl_max_binlog_size_func.result index 0d0a1ae03c4..57b70814698 100644 --- a/mysql-test/suite/sys_vars/r/rpl_max_binlog_size_func.result +++ b/mysql-test/suite/sys_vars/r/rpl_max_binlog_size_func.result @@ -1,8 +1,11 @@ DROP TABLE IF EXISTS t1; -'--- check if log file is rotated after 4096 bytes ----' +'--- check if log file is rotated after 4096 bytes ----' SET @saved_max_binlog_size= @@global.max_binlog_size; SET @@global.max_binlog_size = 4096; CREATE TABLE t1(a CHAR(5)); +SELECT COUNT(*) FROM t1; +COUNT(*) +50 'mylog.000002 exists' SET @@global.max_binlog_size= @saved_max_binlog_size; DROP TABLE t1; diff --git a/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_32.result b/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_32.result index 2f0c9beea9c..3b7ecf9dc4a 100644 --- a/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_32.result +++ b/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_32.result @@ -51,14 +51,20 @@ SET @@local.rpl_recovery_rank = 4; ERROR HY000: Variable 'rpl_recovery_rank' is a GLOBAL variable and should be set with SET GLOBAL '#------------------FN_DYNVARS_142_04-----------------------#' SET @@global.rpl_recovery_rank = -1; +Warnings: +Warning 1292 Truncated incorrect rpl_recovery_rank value: '-1' SELECT @@global.rpl_recovery_rank; @@global.rpl_recovery_rank 0 SET @@global.rpl_recovery_rank = -2147483648; +Warnings: +Warning 1292 Truncated incorrect rpl_recovery_rank value: '-2147483648' SELECT @@global.rpl_recovery_rank; @@global.rpl_recovery_rank 0 SET @@global.rpl_recovery_rank = -2147483649; +Warnings: +Warning 1292 Truncated incorrect rpl_recovery_rank value: '-2147483649' SELECT @@global.rpl_recovery_rank; @@global.rpl_recovery_rank 0 diff --git a/mysql-test/suite/sys_vars/r/server_id_basic_32.result b/mysql-test/suite/sys_vars/r/server_id_basic_32.result index b1e74736a10..12d49248f54 100644 --- a/mysql-test/suite/sys_vars/r/server_id_basic_32.result +++ b/mysql-test/suite/sys_vars/r/server_id_basic_32.result @@ -52,10 +52,14 @@ SET @@local.server_id = 4; ERROR HY000: Variable 'server_id' is a GLOBAL variable and should be set with SET GLOBAL '#------------------FN_DYNVARS_144_05-----------------------#' SET @@global.server_id = -1; +Warnings: +Warning 1292 Truncated incorrect server_id value: '-1' SELECT @@global.server_id; @@global.server_id 0 SET @@global.server_id = -2147483648; +Warnings: +Warning 1292 Truncated incorrect server_id value: '-2147483648' SELECT @@global.server_id; @@global.server_id 0 diff --git a/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_32.result b/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_32.result index 5b77c500aa0..1b6edb18f8d 100644 --- a/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_32.result +++ b/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_32.result @@ -57,6 +57,8 @@ SET @@local.slave_transaction_retries = 4; ERROR HY000: Variable 'slave_transaction_retries' is a GLOBAL variable and should be set with SET GLOBAL '#------------------FN_DYNVARS_149_05-----------------------#' SET @@global.slave_transaction_retries = -1; +Warnings: +Warning 1292 Truncated incorrect slave_transaction_retries value: '-1' SELECT @@global.slave_transaction_retries; @@global.slave_transaction_retries 0 diff --git a/mysql-test/suite/sys_vars/r/slow_query_log_func.result b/mysql-test/suite/sys_vars/r/slow_query_log_func.result index 83edb4c187e..d5485e2e6d7 100644 --- a/mysql-test/suite/sys_vars/r/slow_query_log_func.result +++ b/mysql-test/suite/sys_vars/r/slow_query_log_func.result @@ -17,8 +17,8 @@ TRUNCATE mysql.slow_log; SELECT sleep(2); sleep(2) 0 -SELECT count(*) FROM mysql.slow_log; -count(*) +SELECT count(*) > 0 FROM mysql.slow_log; +count(*) > 0 1 SET @@global.log_output = @global_log_output; SET @global.slow_query_log = @global_slow_query_log; diff --git a/mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result b/mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result index f0874ae7414..584ca4c6f8f 100644 --- a/mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result +++ b/mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result @@ -29,7 +29,6 @@ LOCK TABLE t1 READ; SELECT * FROM t1; UNLOCK TABLES;| ** Connection default ** -Sleeping for 1 secs UNLOCK TABLES; ** Connection con0 ** ** Asynchronous Result ** @@ -66,7 +65,6 @@ LOCK TABLE t1 READ; SELECT * FROM t1; UNLOCK TABLES;| ** Connection default ** -Sleeping for 1 secs UNLOCK TABLES; ** Connection con0 ** ** Asynchronous Result ** diff --git a/mysql-test/suite/sys_vars/r/sync_binlog_basic_32.result b/mysql-test/suite/sys_vars/r/sync_binlog_basic_32.result index 3d9bfb6d218..cae626ad63b 100644 --- a/mysql-test/suite/sys_vars/r/sync_binlog_basic_32.result +++ b/mysql-test/suite/sys_vars/r/sync_binlog_basic_32.result @@ -36,47 +36,57 @@ SELECT @@global.sync_binlog; 65536 '#--------------------FN_DYNVARS_168_04-------------------------#' SET @@global.sync_binlog = -1; +Warnings: +Warning 1292 Truncated incorrect sync_binlog value: '-1' SELECT @@global.sync_binlog; @@global.sync_binlog 0 SET @@global.sync_binlog = 4294967296; +Warnings: +Warning 1292 Truncated incorrect sync_binlog value: '4294967296' SELECT @@global.sync_binlog; @@global.sync_binlog -0 +4294967295 SET @@global.sync_binlog = 10240022115; +Warnings: +Warning 1292 Truncated incorrect sync_binlog value: '10240022115' SELECT @@global.sync_binlog; @@global.sync_binlog -1650087523 +4294967295 SET @@global.sync_binlog = 10000.01; ERROR 42000: Incorrect argument type to variable 'sync_binlog' SELECT @@global.sync_binlog; @@global.sync_binlog -1650087523 +4294967295 SET @@global.sync_binlog = -1024; +Warnings: +Warning 1292 Truncated incorrect sync_binlog value: '-1024' SELECT @@global.sync_binlog; @@global.sync_binlog 0 SET @@global.sync_binlog = 42949672950; +Warnings: +Warning 1292 Truncated incorrect sync_binlog value: '42949672950' SELECT @@global.sync_binlog; @@global.sync_binlog -4294967286 +4294967295 'Bug # 34837: Errors are not coming on assigning invalid values to variable'; SET @@global.sync_binlog = ON; ERROR 42000: Incorrect argument type to variable 'sync_binlog' SELECT @@global.sync_binlog; @@global.sync_binlog -4294967286 +4294967295 SET @@global.sync_binlog = 'test'; ERROR 42000: Incorrect argument type to variable 'sync_binlog' SELECT @@global.sync_binlog; @@global.sync_binlog -4294967286 +4294967295 '#-------------------FN_DYNVARS_168_05----------------------------#' SET @@session.sync_binlog = 0; ERROR HY000: Variable 'sync_binlog' is a GLOBAL variable and should be set with SET GLOBAL SELECT @@sync_binlog; @@sync_binlog -4294967286 +4294967295 '#----------------------FN_DYNVARS_168_06------------------------#' SELECT @@global.sync_binlog = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -88,7 +98,7 @@ SET sync_binlog = 1; ERROR HY000: Variable 'sync_binlog' is a GLOBAL variable and should be set with SET GLOBAL SELECT @@sync_binlog; @@sync_binlog -4294967286 +4294967295 SET local.sync_binlog = 1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sync_binlog = 1' at line 1 SELECT local.sync_binlog; diff --git a/mysql-test/suite/sys_vars/r/tmp_table_size_basic.result b/mysql-test/suite/sys_vars/r/tmp_table_size_basic.result index 3b4099d30ae..2ebeb8d61d8 100644 --- a/mysql-test/suite/sys_vars/r/tmp_table_size_basic.result +++ b/mysql-test/suite/sys_vars/r/tmp_table_size_basic.result @@ -51,7 +51,7 @@ SELECT @@global.tmp_table_size; 1024 SET @@global.tmp_table_size = -1024; Warnings: -Warning 1292 Truncated incorrect tmp_table_size value: '0' +Warning 1292 Truncated incorrect tmp_table_size value: '-1024' SELECT @@global.tmp_table_size; @@global.tmp_table_size 1024 @@ -100,6 +100,8 @@ SELECT @@session.tmp_table_size; SET @@session.tmp_table_size = "Test"; ERROR 42000: Incorrect argument type to variable 'tmp_table_size' SET @@session.tmp_table_size = 12345678901; +Warnings: +Warning 1292 Truncated incorrect tmp_table_size value: '12345678901' SELECT @@session.tmp_table_size IN (12345678901,4294967295); @@session.tmp_table_size IN (12345678901,4294967295) 1 diff --git a/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_32.result b/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_32.result index 4aaf67c4064..8c6a788862d 100644 --- a/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_32.result @@ -71,7 +71,7 @@ SELECT @@global.transaction_alloc_block_size; 1024 SET @@global.transaction_alloc_block_size = -1024; Warnings: -Warning 1292 Truncated incorrect transaction_alloc_block_size value: '0' +Warning 1292 Truncated incorrect transaction_alloc_block_size value: '-1024' SELECT @@global.transaction_alloc_block_size; @@global.transaction_alloc_block_size 1024 diff --git a/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_32.result b/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_32.result index 3df7a55595e..4912653a8e5 100644 --- a/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_32.result +++ b/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_32.result @@ -66,7 +66,7 @@ SELECT @@global.transaction_prealloc_size; 1024 SET @@global.transaction_prealloc_size = -1024; Warnings: -Warning 1292 Truncated incorrect transaction_prealloc_size value: '0' +Warning 1292 Truncated incorrect transaction_prealloc_size value: '-1024' SELECT @@global.transaction_prealloc_size; @@global.transaction_prealloc_size 1024 diff --git a/mysql-test/suite/sys_vars/r/wait_timeout_basic_32.result b/mysql-test/suite/sys_vars/r/wait_timeout_basic_32.result index ae03e677e56..c9bffc61b6f 100644 --- a/mysql-test/suite/sys_vars/r/wait_timeout_basic_32.result +++ b/mysql-test/suite/sys_vars/r/wait_timeout_basic_32.result @@ -44,7 +44,7 @@ Warnings: Warning 1292 Truncated incorrect wait_timeout value: '0' SET @@global.wait_timeout = -1024; Warnings: -Warning 1292 Truncated incorrect wait_timeout value: '0' +Warning 1292 Truncated incorrect wait_timeout value: '-1024' 'Bug # 34837: Errors are not coming on assigning invalid values to variable'; SET @@global.wait_timeout = ON; ERROR 42000: Incorrect argument type to variable 'wait_timeout' diff --git a/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test b/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test index 97e1f2daed1..61f7d801a1a 100644 --- a/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test +++ b/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test @@ -1,23 +1,26 @@ -############# mysql-test\t\sql_low_priority_updates_func.test ########################### -# # -# Variable Name: sql_low_priority_updates # -# Scope: GLOBAL # -# Access Type: Dynamic # -# Data Type: BOOLEAN # -# Default Value: 1 TRUE # -# Values: 1 TRUE, 0 FALSE # -# # -# # -# Creation Date: 2008-02-25 # -# Author: Sharique Abdullah # -# # -# Description: Test Cases of Dynamic System Variable "sql_low_priority_updates" # -# that checks behavior of this variable in the following ways # -# * Functionality based on different values # -# # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/set-option.html # -# # -######################################################################################### +################################################################################ +# # +# Variable Name: sql_low_priority_updates # +# Scope: GLOBAL # +# Access Type: Dynamic # +# Data Type: BOOLEAN # +# Default Value: 1 TRUE # +# Values: 1 TRUE, 0 FALSE # +# # +# # +# Creation Date: 2008-02-25 # +# Author: Sharique Abdullah # +# Modified: HHunger 2009-02-26 Replaced 2 sleeps by wait conditions # +# Modified: mleich 2009-03-18 Partially reimplemented # +# # +# Description: Test Cases of Dynamic System Variable "sql_low_priority_updates"# +# that checks behavior of this variable in the following ways # +# * Functionality based on different values # +# # +# Reference: # +# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # +# # +################################################################################ --echo ** Setup ** --echo @@ -29,8 +32,10 @@ --echo Creating connection con0 connect (con0,localhost,root,,); +let $con0_id=`SELECT CONNECTION_ID()`; --echo Creating connection con1 connect (con1,localhost,root,,); +let $con1_id=`SELECT CONNECTION_ID()`; connection default; @@ -40,31 +45,20 @@ SET @global_delayed_insert_limit = @@GLOBAL.delayed_insert_limit; # Create Table # -CREATE TABLE t1 (a varchar(100)); +CREATE TABLE t1 (a VARCHAR(100),b VARCHAR(100),c VARCHAR(100)); --echo '#--------------------FN_DYNVARS_25_01-------------------------#' -# -# Value less than the provided INSERTS (9) -# -SET GLOBAL delayed_insert_limit = 9; +# delayed_insert_limit is smaller than the number of inserted rows ---echo ** Connection con0 ** -connection con0; -SET GLOBAL delayed_insert_limit = 9; ---echo ** Connection con1 ** -connection con1; -SET GLOBAL delayed_insert_limit = 9; ---echo ** Connection default ** -connection default; -SET GLOBAL delayed_insert_limit = 9; +SET GLOBAL delayed_insert_limit = 14; -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'); -INSERT INTO t1 VALUES('6'); +INSERT INTO t1 VALUES('1','1','1'); +INSERT INTO t1 VALUES('2','1','1'); +INSERT INTO t1 VALUES('3','1','1'); +INSERT INTO t1 VALUES('4','1','1'); +INSERT INTO t1 VALUES('5','1','1'); +INSERT INTO t1 VALUES('6','1','1'); LOCK TABLE t1 WRITE; @@ -72,76 +66,94 @@ LOCK TABLE t1 WRITE; connection con1; delimiter |; - send -INSERT DELAYED INTO t1 VALUES('7'); -INSERT DELAYED INTO t1 VALUES('8'); -INSERT DELAYED INTO t1 VALUES('9'); -INSERT DELAYED INTO t1 VALUES('10'); -INSERT DELAYED INTO t1 VALUES('11'); -INSERT DELAYED INTO t1 VALUES('12'); -INSERT DELAYED INTO t1 VALUES('13'); -INSERT DELAYED INTO t1 VALUES('14'); -INSERT DELAYED INTO t1 VALUES('15'); -INSERT DELAYED INTO t1 VALUES('16'); -INSERT DELAYED INTO t1 VALUES('17'); -INSERT DELAYED INTO t1 VALUES('18'); -INSERT DELAYED INTO t1 VALUES('19'); -INSERT DELAYED INTO t1 VALUES('20'); -INSERT DELAYED INTO t1 VALUES('21'); -INSERT DELAYED INTO t1 VALUES('22');| - +INSERT DELAYED INTO t1 VALUES('7','1','1'); +INSERT DELAYED INTO t1 VALUES('8','1','1'); +INSERT DELAYED INTO t1 VALUES('9','1','1'); +INSERT DELAYED INTO t1 VALUES('10','1','1'); +INSERT DELAYED INTO t1 VALUES('11','1','1'); +INSERT DELAYED INTO t1 VALUES('12','1','1'); +INSERT DELAYED INTO t1 VALUES('13','1','1'); +INSERT DELAYED INTO t1 VALUES('14','1','1'); +INSERT DELAYED INTO t1 VALUES('15','1','1'); +INSERT DELAYED INTO t1 VALUES('16','1','1'); +INSERT DELAYED INTO t1 VALUES('17','1','1'); +INSERT DELAYED INTO t1 VALUES('18','1','1'); +INSERT DELAYED INTO t1 VALUES('19','1','1'); +INSERT DELAYED INTO t1 VALUES('20','1','1'); +INSERT DELAYED INTO t1 VALUES('21','1','1'); +INSERT DELAYED INTO t1 VALUES('22','1','1'); +INSERT DELAYED INTO t1 VALUES('23','1','1'); +INSERT DELAYED INTO t1 VALUES('24','1','1'); +INSERT DELAYED INTO t1 VALUES('25','1','1'); +INSERT DELAYED INTO t1 VALUES('26','1','1'); +INSERT DELAYED INTO t1 VALUES('27','1','1'); +INSERT DELAYED INTO t1 VALUES('28','1','1'); +INSERT DELAYED INTO t1 VALUES('29','1','1'); +INSERT DELAYED INTO t1 VALUES('30','1','1'); +INSERT DELAYED INTO t1 VALUES('31','1','1'); +INSERT DELAYED INTO t1 VALUES('32','1','1'); +INSERT DELAYED INTO t1 VALUES('33','1','1'); +INSERT DELAYED INTO t1 VALUES('34','1','1'); +INSERT DELAYED INTO t1 VALUES('35','1','1'); +INSERT DELAYED INTO t1 VALUES('36','1','1'); +INSERT DELAYED INTO t1 VALUES('37','1','1'); +INSERT DELAYED INTO t1 VALUES('38','1','1'); +INSERT DELAYED INTO t1 VALUES('39','1','1'); +INSERT DELAYED INTO t1 VALUES('40','1','1'); +INSERT DELAYED INTO t1 VALUES('41','1','1'); +INSERT DELAYED INTO t1 VALUES('42','1','1'); +INSERT DELAYED INTO t1 VALUES('43','1','1');| delimiter ;| --echo ** Connection con0 ** connection con0; - -delimiter |; - -send -SELECT * FROM t1;| - -delimiter ;| +let $wait_condition= + SELECT variable_value > 0 FROM information_schema.global_status + WHERE variable_name like 'Not_flushed_delayed_rows'; +--source include/wait_condition.inc +let $my_select= SELECT COUNT(*) BETWEEN 21 AND 43 FROM t1; +let $my_select= SELECT COUNT(*) FROM t1; +send; +eval $my_select; --echo ** Connection default ** connection default; - ---echo Waiting for 1 sec ---sleep 1 - +--echo ** Wait till con0 is blocked ** +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = 'Locked' AND info = '$my_select'; +--source include/wait_condition.inc UNLOCK TABLES; +--echo ** Connection con1 ** +connection con1; +--echo Asynchronous "reap" result +reap; + --echo ** Connection con0 ** connection con0; +--echo Asynchronous "reap" result +--echo The next result suffers from +--echo '# Bug#35386 insert delayed inserts 1 + limit rows instead of just limit rows' reap; ---echo 'Bug#35386: insert delayed inserts 1 + limit rows instead of just limit rows' --echo ** Connection default ** connection default; - ---echo Waiting for 1 sec ---sleep 1 +let $wait_condition= SELECT count(*) = 43 FROM t1; +--source include/wait_condition.inc --echo Checking if the delayed insert continued afterwards -SELECT * FROM t1; +SELECT COUNT(*) FROM t1; -DELETE FROM t1; +DROP TABLE t1; --echo '#--------------------FN_DYNVARS_25_02-------------------------#' -# -# Value 5 -# -SET GLOBAL delayed_insert_limit = 20; +# delayed_insert_limit is bigger than the number of inserted rows + +CREATE TABLE t1 (a VARCHAR(100)); ---echo ** Connection con0 ** -connection con0; -SET GLOBAL delayed_insert_limit = 20; ---echo ** Connection con1 ** -connection con1; -SET GLOBAL delayed_insert_limit = 20; ---echo ** Connection default ** -connection default; SET GLOBAL delayed_insert_limit = 20; INSERT INTO t1 VALUES('1'); @@ -181,49 +193,52 @@ delimiter ;| --echo ** Connection con0 ** connection con0; - +let $wait_condition= + SELECT variable_value > 0 FROM information_schema.global_status + WHERE variable_name like 'Not_flushed_delayed_rows'; +--source include/wait_condition.inc --echo Asynchronous execute -delimiter |; - -send -SELECT * FROM t1;| - -delimiter ;| +let $my_select= SELECT COUNT(*) = 22 FROM t1; +send; +eval $my_select; --echo ** Connection default ** connection default; - ---echo Waiting for 1 sec ---sleep 1 - +--echo ** Wait till con0 is blocked ** +let $wait_condition= + SELECT COUNT(*) = 1 FROM information_schema.processlist + WHERE state = 'Locked' AND info = '$my_select'; +--source include/wait_condition.inc UNLOCK TABLES; +--echo ** Connection con1 ** +connection con1; +reap; + --echo ** Connection con0 ** connection con0; ---echo Asynchronous execute result +--echo Asynchronous "reap" result reap; --echo ** Connection default** connection default; - ---echo Waiting for 1 sec ---sleep 1 --echo Checking if the delayed insert gives the same result afterwards -SELECT * FROM t1; +eval $my_select; -DELETE FROM t1; # # Cleanup # ---echo Switching to default +--echo ** Connection default** connection default; +DROP TABLE t1; +SET @@GLOBAL.delayed_insert_limit = @global_delayed_insert_limit; --echo Disconnecting from con1, con0 disconnect con0; disconnect con1; - -DROP TABLE t1; - -SET @@GLOBAL.delayed_insert_limit = @global_delayed_insert_limit; +let $wait_condition= + SELECT COUNT(*) = 0 FROM information_schema.processlist + WHERE id IN ($con0_id,$con1_id); +--source include/wait_condition.inc diff --git a/mysql-test/suite/sys_vars/t/event_scheduler_func.test b/mysql-test/suite/sys_vars/t/event_scheduler_func.test deleted file mode 100644 index f727b2b6833..00000000000 --- a/mysql-test/suite/sys_vars/t/event_scheduler_func.test +++ /dev/null @@ -1,91 +0,0 @@ -############## mysql-test\t\event_scheduler_func.test ########################## -# # -# Variable Name: event_scheduler # -# Scope: GLOBAL # -# Access Type: Dynamic # -# Data Type: Boolean # -# Default Value: OFF # -# Valid Values: ON, OFF & DISABLED # -# # -# # -# Creation Date: 2008-03-17 # -# Author: Salman Rawala # -# # -# Description: Test Cases of Dynamic System Variable "event_scheduler" # -# that checks functionality of this variable # -# # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # -# server-system-variables.html#option_mysqld_event_scheduler # -# # -################################################################################ - --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings - -######################### -# Creating new table # -######################### - ---echo ## Creating new table ## -CREATE TABLE t1 -( -id INT NOT NULL auto_increment, -PRIMARY KEY (id), -name VARCHAR(30) -); - ---echo '#--------------------FN_DYNVARS_018_01-------------------------#' -#################################################################### -# Setting initial value of event_scheduler to ON and verifying -# its behavior -#################################################################### - ---echo ## Setting initial value of variable to ON ## -SET @@global.event_scheduler = ON; -SELECT @@event_scheduler; - ---echo ## Creating new event ## -CREATE EVENT test_event_1 -ON SCHEDULE EVERY 3 SECOND -DO - INSERT into t1(name) values('Record_1'); - ---sleep 4 - -SELECT * from t1; - -DROP EVENT test_event_1; - ---sleep 1 -DELETE from t1; -select * from t1; - - ---echo '#--------------------FN_DYNVARS_018_02-------------------------#' -#################################################################### -# Setting initial value of event_scheduler to OFF and verifying -# its behavior -#################################################################### - ---echo ## Setting value of variable to OFF ## -SET @@global.event_scheduler = OFF; -SELECT @@event_scheduler; - ---echo ## Creating new event ## -CREATE EVENT test_event_1 -ON SCHEDULE EVERY 3 SECOND -DO - INSERT into t1(name) values('Record_2'); - ---sleep 4 - ---echo ## Table should be empty ## -SELECT * from t1; - -DROP EVENT test_event_1; ---echo ## Dropping table ## -DROP table t1; - diff --git a/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test b/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test index d077a3acf50..b577ae5fcc4 100644 --- a/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test +++ b/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test @@ -1,4 +1,4 @@ -################# mysql-test\t\innodb_max_dirty_pages_pct_func.test ########## +############################################################################### # # # Variable Name: innodb_max_dirty_pages_pct # # Scope: GLOBAL # diff --git a/mysql-test/suite/sys_vars/t/interactive_timeout_func.test b/mysql-test/suite/sys_vars/t/interactive_timeout_func.test index e3a210bf508..0df069ad73e 100644 --- a/mysql-test/suite/sys_vars/t/interactive_timeout_func.test +++ b/mysql-test/suite/sys_vars/t/interactive_timeout_func.test @@ -1,23 +1,26 @@ -############## mysql-test\t\interactive_timeout_func.test ##################### -# # -# Variable Name: interactive_timeout # -# Scope: GLOBAL | SESSION # -# Access Type: Dynamic # -# Data Type: numeric # -# Default Value:28800 # -# Minvalue: 1 # -# # -# # -# Creation Date: 2008-03-07 # -# Author: Salman Rawala # -# # -# Description: Test Cases of Dynamic System Variable interactive_timeout # -# that checks the functionality of this variable # -# # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # -# server-system-variables.html # -# # -############################################################################### +################################################################################ +# # +# Variable Name: interactive_timeout # +# Scope: GLOBAL | SESSION # +# Access Type: Dynamic # +# Data Type: numeric # +# Default Value:28800 # +# Minvalue: 1 # +# # +# # +# Creation Date: 2008-03-07 # +# Author: Salman Rawala # +# # +# Description: Test Cases of Dynamic System Variable interactive_timeout # +# that checks the functionality of this variable # +# Modified: HHunger 2009-02-26 Inserted clean up, beautifications. # +# It is not yet possible to set CLIENT_INTERACIVE # +# When connecting, so the test has not the # +# desired effect. See 'wait_timeout_func'. # +# Reference: # +# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # +# # +################################################################################ --disable_warnings @@ -42,29 +45,44 @@ name VARCHAR(30) # Setting initial value of interactive_timeout to 1 and verifying its # behavior ####################################################################### +let $start_value= `SELECT @@global.interactive_timeout`; --echo ## Setting initial value of variable to 1 ## SET @@global.interactive_timeout = 1; ---echo ## Creating new interactive connection test_con1 ## -connect (test_con1, localhost, root,); +--echo ## Creating new connection test_con1 ## +# Not yet possible to set CLEAN_INTERACTIVE flag +connect (test_con1, localhost, root,,,,,); connection test_con1; --echo ## Inserting record in table ## INSERT into t1(name) values('Record_1'); ---echo ## Setting session value of interactive_timeout ## +--echo ## Setting session value of interactive_timeout ## SET @@session.interactive_timeout = 1; ---echo ## Verifying values of variable ## +--echo ## Verifying values of variable ## SELECT @@session.interactive_timeout; SELECT @@global.interactive_timeout; ---echo ## Using sleep to check timeout ## -sleep 5; +--echo connection default; +connection default; +--echo ## Using sleep to check timeout ## +--echo sleep 2; +sleep 2; + +--echo connection test_con1; +connection test_con1; SELECT * from t1; ---echo 'Bug#35377: Error should appear here because interactive_timeout value'; ---echo 'is 1 and connection remains idle for 5 secs'; - INSERT into t1(name) values('Record_2'); + +--echo connection default; +connection default; + +--echo disconnect test_con1; +disconnect test_con1; +DROP TABLE t1; + +eval SET @@global.interactive_timeout= $start_value; + diff --git a/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test b/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test index 83b0c446b28..e5ced59d175 100644 --- a/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test +++ b/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test @@ -1,4 +1,4 @@ -############# mysql-test\t\query_cache_wlock_invalidate_func.test #################### +###################################################################################### # # # Variable Name: query_cache_wlock_invalidate # # Scope: GLOBAL & SESSION # @@ -10,6 +10,7 @@ # # # Creation Date: 2008-02-21 # # Author: Sharique Abdullah # +# Modified: HHunger 2009-02-27 Replaced sleeps, beautifications # # # # Description: Test Cases of Dynamic System Variable "query_cache_wlock_invalidate" # # that checks behavior of this variable in the following ways # @@ -18,8 +19,8 @@ # * Scope & Access method # # * Cache behaviors # # # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # -# server-system-variables.html#option_mysqld_query_cache_wlock_invalidate # +# Reference: # +# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # # # ###################################################################################### @@ -29,6 +30,8 @@ # Setup # +--source include/not_embedded.inc + # disabled due to differences in the result --disable_ps_protocol # @@ -135,8 +138,9 @@ send SELECT * FROM t1; --echo ** Connection con0 ** connection con0; ---echo Sleeping 2 Seconds before unlock ---sleep 2 +--echo wait until table is locked +let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist WHERE state= 'Locked'; +--source include/wait_condition.inc UNLOCK TABLES; --echo ** Connection con1 ** @@ -195,20 +199,17 @@ SELECT * FROM t1; --echo ** Connection con0 ** connection con0; - LOCK TABLE t1 WRITE; --echo ** Connection con1 ** connection con1; - --echo ** Should not be blocked ** SELECT * FROM t1; +SELECT * FROM t1; +SELECT * FROM t1; --echo ** Connection con0 ** connection con0; - ---echo Sleeping 2 Seconds before unlock ---sleep 2 UNLOCK TABLES; --echo ** Connection con1 ** diff --git a/mysql-test/suite/sys_vars/t/rpl_init_slave_func.test b/mysql-test/suite/sys_vars/t/rpl_init_slave_func.test index f17cc1289b1..f2c66eb3a0a 100644 --- a/mysql-test/suite/sys_vars/t/rpl_init_slave_func.test +++ b/mysql-test/suite/sys_vars/t/rpl_init_slave_func.test @@ -1,4 +1,4 @@ -###################### mysql-test\t\init_slave_func.test ##################### +############################################################################### # # # Variable Name: init_slave # # Scope: GLOBAL # diff --git a/mysql-test/suite/sys_vars/t/rpl_max_binlog_size_func.test b/mysql-test/suite/sys_vars/t/rpl_max_binlog_size_func.test index c00db582deb..efcec4561bd 100644 --- a/mysql-test/suite/sys_vars/t/rpl_max_binlog_size_func.test +++ b/mysql-test/suite/sys_vars/t/rpl_max_binlog_size_func.test @@ -7,9 +7,8 @@ source include/have_log_bin.inc; DROP TABLE IF EXISTS t1; --enable_warnings - #============================================================== ---echo '--- check if log file is rotated after 4096 bytes ----' +--echo '--- check if log file is rotated after 4096 bytes ----' #============================================================== SET @saved_max_binlog_size= @@global.max_binlog_size; @@ -24,8 +23,7 @@ INSERT INTO t1 VALUES ('mysql'); dec $a; } --enable_query_log - ---sleep 2 +SELECT COUNT(*) FROM t1; # if log file is not created then this will fail let $MYSQLD_DATADIR=`select @@datadir`; diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_func.test b/mysql-test/suite/sys_vars/t/slow_query_log_func.test index 9bcbeb14fd7..d2653f89de4 100644 --- a/mysql-test/suite/sys_vars/t/slow_query_log_func.test +++ b/mysql-test/suite/sys_vars/t/slow_query_log_func.test @@ -1,4 +1,3 @@ - # save SET @global_slow_query_log = @@global.slow_query_log; SET @global_log_output = @@global.log_output; @@ -16,6 +15,7 @@ SET @@global.log_output = 'TABLE'; SET @@global.slow_query_log = OFF; TRUNCATE mysql.slow_log; +# The sleep is the slow query SELECT sleep(2); SELECT count(*) FROM mysql.slow_log; @@ -26,9 +26,10 @@ SELECT count(*) FROM mysql.slow_log; SET @@global.slow_query_log = ON; TRUNCATE mysql.slow_log; +# The sleep is the slow query SELECT sleep(2); -SELECT count(*) FROM mysql.slow_log; +SELECT count(*) > 0 FROM mysql.slow_log; #restore SET @@global.log_output = @global_log_output; @@ -37,3 +38,4 @@ SET @global.slow_query_log = @global_slow_query_log; ############################################################################### # End of the functionality test for slow_query_log # ############################################################################### + diff --git a/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test b/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test index 6ff684af6cd..2ef6e34b0b3 100644 --- a/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test +++ b/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test @@ -1,23 +1,23 @@ -############# mysql-test\t\sql_low_priority_updates_func.test ################# -# # -# Variable Name: sql_low_priority_updates # -# Scope: GLOBAL & SESSION # -# Access Type: Dynamic # -# Data Type: BOOLEAN # -# Default Value: 1 TRUE # -# Values: 1 TRUE, 0 FALSE # -# # -# # -# Creation Date: 2008-02-25 # -# Author: Sharique Abdullah # -# # -# Description: Test Cases of Dynamic System Variable sql_low_priority_updates# -# that checks behavior of this variable in the following ways # -# * Functionality based on different values # -# # -# Reference: http://dev.mysql.com/doc/refman/5.1/en/set-option.html # -# # -############################################################################### +################################################################################ +# # +# Variable Name: sql_low_priority_updates # +# Scope: GLOBAL & SESSION # +# Access Type: Dynamic # +# Data Type: BOOLEAN # +# Default Value: 1 TRUE # +# Values: 1 TRUE, 0 FALSE # +# # +# # +# Creation Date: 2008-02-25 # +# Author: Sharique Abdullah # +# # +# Description: Test Cases of Dynamic System Variable sql_low_priority_updates # +# that checks behavior of this variable in the following ways # +# * Functionality based on different values # +# # +# Reference: http://dev.mysql.com/doc/refman/5.1/en/set-option.html # +# # +################################################################################ --source include/not_embedded.inc @@ -85,6 +85,9 @@ delimiter ;| --echo ** Connection con0 ** connection con0; +let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state='Locked' AND info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")'; +--source include/wait_condition.inc + --echo ** Asynchronous Execution ** delimiter |; @@ -98,9 +101,8 @@ delimiter ;| --echo ** Connection default ** connection default; ---echo Sleeping for 1 secs ---sleep 1 - +let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist WHERE state LIKE 'Locked'; +--source include/wait_condition.inc UNLOCK TABLES; --echo ** Connection con0 ** @@ -153,6 +155,9 @@ delimiter ;| --echo ** Connection con0 ** connection con0; +let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state='Locked' AND info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")'; +--source include/wait_condition.inc + --echo ** Asynchronous Execution ** delimiter |; @@ -166,9 +171,8 @@ delimiter ;| --echo ** Connection default ** connection default; ---echo Sleeping for 1 secs ---sleep 1 - +let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist WHERE state LIKE 'Locked'; +--source include/wait_condition.inc UNLOCK TABLES; --echo ** Connection con0 ** diff --git a/mysql-test/suite/sys_vars/t/timestamp_func.test b/mysql-test/suite/sys_vars/t/timestamp_func.test index e119f1b6253..e93614e89fb 100644 --- a/mysql-test/suite/sys_vars/t/timestamp_func.test +++ b/mysql-test/suite/sys_vars/t/timestamp_func.test @@ -1,4 +1,4 @@ -############# mysql-test\t\timestamp_func.test ############################# +############################################################################ # # # Variable Name: timestamp # # Scope: GLOBAL # diff --git a/mysql-test/suite/sys_vars/t/wait_timeout_func.test b/mysql-test/suite/sys_vars/t/wait_timeout_func.test index 6b7c8d016d2..e33c39016cc 100644 --- a/mysql-test/suite/sys_vars/t/wait_timeout_func.test +++ b/mysql-test/suite/sys_vars/t/wait_timeout_func.test @@ -1,4 +1,4 @@ -############## mysql-test\t\wait_timeout_func.test ############################ +############################################################################### # # # Variable Name: wait_timeout # # Scope: GLOBAL | SESSION # From c461c1b0cab1ce0233257603eb233d07306782bd Mon Sep 17 00:00:00 2001 From: Alfranio Correia Date: Mon, 23 Mar 2009 01:07:25 +0000 Subject: [PATCH 58/88] Post-fix BUG#42861. --- .../r/rpl_slave_load_remove_tmpfile.result | 40 ++++++++++++++++++- .../r/rpl_slave_load_tmpdir_not_exist.result | 4 +- .../rpl/t/rpl_slave_load_remove_tmpfile.test | 7 +++- .../t/rpl_slave_load_tmpdir_not_exist.test | 7 +++- 4 files changed, 51 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result b/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result index abb6a598c53..777f7d8427b 100644 --- a/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result +++ b/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result @@ -10,6 +10,44 @@ insert into t1(b) values (1); insert into t1(b) values (2); load data infile '../../std_data/rpl_loaddata.dat' into table t1; commit; -Error in Begin_load_query event: write to '../../tmp/SQL_LOAD-2-1-1.data' failed +show slave status; +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_MYPORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos # +Relay_Log_File # +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running Yes +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 9 +Last_Error Error in Begin_load_query event: write to '../../tmp/SQL_LOAD.data' failed +Skip_Counter 0 +Exec_Master_Log_Pos # +Relay_Log_Space # +Until_Condition None +Until_Log_File +Until_Log_Pos 0 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # +Master_SSL_Verify_Server_Cert No +Last_IO_Errno # +Last_IO_Error # +Last_SQL_Errno 9 +Last_SQL_Error Error in Begin_load_query event: write to '../../tmp/SQL_LOAD.data' failed drop table t1; drop table t1; 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 e438c69525d..a158fb5dfc4 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 @@ -1,6 +1,6 @@ CHANGE MASTER TO MASTER_USER='root', MASTER_CONNECT_RETRY=1, MASTER_HOST='127.0.0.1', -MASTER_PORT=12500; -start slave; +MASTER_PORT=MASTER_MYPORT; +START SLAVE; Unable to use slave's temporary directory ../../../error - Can't read dir of '../../../error' (Errcode: 2) diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test index be7741f2e4b..39f3b700f94 100644 --- a/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test +++ b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test @@ -11,6 +11,7 @@ --source include/have_innodb.inc --source include/have_debug.inc --source include/master-slave.inc +--source include/not_embedded.inc ########################################################################## # Loading data @@ -31,8 +32,10 @@ commit; connection slave; source include/wait_for_slave_sql_to_stop.inc; -let $error=query_get_value("show slave status", Last_SQL_Error, 1); -echo $error; +--replace_result $MASTER_MYPORT MASTER_MYPORT +--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 # +--replace_regex /SQL_LOAD-[0-9]-[0-9]-[0-9]*/SQL_LOAD/ +query_vertical show slave status; ########################################################################## # Clean up 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 ec5f9eb6654..3a80fa43f20 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 @@ -2,6 +2,9 @@ # This test verifies if the start slave fails gracefuly when an # invalid directory is used to set --slave-load-tmpdir. ########################################################################## +--source include/have_log_bin.inc +--source include/not_embedded.inc + connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,); connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,); connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,); @@ -9,12 +12,12 @@ connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,); connection slave; +--replace_result $MASTER_MYPORT MASTER_MYPORT eval CHANGE MASTER TO MASTER_USER='root', MASTER_CONNECT_RETRY=1, MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT; - -start slave; +START SLAVE; source include/wait_for_slave_sql_to_stop.inc; let $error=query_get_value("show slave status", Last_SQL_Error, 1); From 4093dcfb03e3f39bdfc7c65bea866a070bf3d11d Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Mon, 23 Mar 2009 05:08:32 +0100 Subject: [PATCH 59/88] Bug#43254: SQL_SELECT_LIMIT=0 crashes command line client When asking what database is selected, client expected to *always* get an answer from the server. We now handle failure more gracefully. See comments in ticket for a discussion of what happens, and how things interlock. client/mysql.cc: Handle empty result-sets gracefully, as opposed to just result sets with n>0 items that may themselves be empty. --- client/mysql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index 88ddd40fa68..e035cee16f9 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2625,7 +2625,7 @@ static void get_current_db() (res= mysql_use_result(&mysql))) { MYSQL_ROW row= mysql_fetch_row(res); - if (row[0]) + if (row && row[0]) current_db= my_strdup(row[0], MYF(MY_WME)); mysql_free_result(res); } From 596a9dbdfbee2b8313b074402107b86ed47b5b8a Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 23 Mar 2009 11:38:54 +0200 Subject: [PATCH 60/88] Disabled the failing test case until bug #43440 is resolved --- mysql-test/suite/rpl/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def index f3f329c4b5b..cb714c60ba4 100644 --- a/mysql-test/suite/rpl/t/disabled.def +++ b/mysql-test/suite/rpl/t/disabled.def @@ -11,3 +11,4 @@ ############################################################################## rpl_binlog_corruption : BUG#41793 2008-12-30 sven rpl_binlog_corruption disabled in main (needs new mtr) +rpl_temp_table_mix_row : BUG#43440 2009-03-23 joro rpl.rpl_temp_table_mix_row fails sporadicly From 9a561879c5b21973d9b7702a1162b2795f37f910 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Mon, 23 Mar 2009 16:51:39 +0400 Subject: [PATCH 61/88] remove compiler warnings --- client/mysqltest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 64b9f4a5a16..312012d7b8d 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -6665,7 +6665,7 @@ void init_re_comp(my_regex_t *re, const char* str) char erbuf[100]; size_t len= my_regerror(err, re, erbuf, sizeof(erbuf)); die("error %s, %d/%d `%s'\n", - re_eprint(err), len, (int)sizeof(erbuf), erbuf); + re_eprint(err), (int)len, (int)sizeof(erbuf), erbuf); } } @@ -6721,7 +6721,7 @@ int match_re(my_regex_t *re, char *str) char erbuf[100]; size_t len= my_regerror(err, re, erbuf, sizeof(erbuf)); die("error %s, %d/%d `%s'\n", - re_eprint(err), len, (int)sizeof(erbuf), erbuf); + re_eprint(err), (int)len, (int)sizeof(erbuf), erbuf); } return 0; } From 5eb0b4819ce876cd7e918bb1392873c23c12da79 Mon Sep 17 00:00:00 2001 From: Matthias Leich Date: Mon, 23 Mar 2009 15:22:31 +0100 Subject: [PATCH 62/88] Fix for Bug#43015 and Bug#43065 Details for Bug#43015 main.lock_multi: Weak code (sleeps etc.) ------------------------------------------------------------- - The fix for bug 42003 already removed a lot of the weaknesses mentioned. - Tests showed that there are unfortunately no improvements of this tests in MySQL 5.1 which could be ported back to 5.0. - Remove a superfluous "--sleep 1" around line 195 Details for Bug#43065 main.lock_multi: This test is too big if the disk is slow ------------------------------------------------------------------------------- - move the subtests for the bugs 38499 and 36691 into separate scripts - runtime under excessive parallel I/O load after applying the fix lock_multi [ pass ] 22887 lock_multi_bug38499 [ pass ] 536926 lock_multi_bug38691 [ pass ] 258498 --- mysql-test/r/lock_multi.result | 42 +-- mysql-test/r/lock_multi_bug38499.result | 19 + mysql-test/r/lock_multi_bug38691.result | 17 + mysql-test/t/lock_multi.test | 479 ++++++------------------ mysql-test/t/lock_multi_bug38499.test | 221 +++++++++++ mysql-test/t/lock_multi_bug38691.test | 141 +++++++ 6 files changed, 523 insertions(+), 396 deletions(-) create mode 100644 mysql-test/r/lock_multi_bug38499.result create mode 100644 mysql-test/r/lock_multi_bug38691.result create mode 100644 mysql-test/t/lock_multi_bug38499.test create mode 100644 mysql-test/t/lock_multi_bug38691.test diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result index 0430d560a7a..89e1ee87dba 100644 --- a/mysql-test/r/lock_multi.result +++ b/mysql-test/r/lock_multi.result @@ -51,10 +51,10 @@ ERROR HY000: Can't execute the query because you have a conflicting read lock UNLOCK TABLES; DROP DATABASE mysqltest_1; ERROR HY000: Can't drop database 'mysqltest_1'; database doesn't exist -use mysql; +USE mysql; LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE; FLUSH TABLES; -use mysql; +USE mysql; SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1; OPTIMIZE TABLES columns_priv, db, host, user; Table Op Msg_type Msg_text @@ -65,7 +65,7 @@ mysql.user optimize status OK UNLOCK TABLES; Select_priv N -use test; +USE test; use test; CREATE TABLE t1 (c1 int); LOCK TABLE t1 WRITE; @@ -93,43 +93,9 @@ create table t1 (a int); connection: locker lock tables t1 read; connection: writer -create table t2 like t1;; +create table t2 like t1; connection: default kill query ERROR 70100: Query execution was interrupted unlock tables; drop table t1; -CREATE TABLE t1 ( -a int(11) unsigned default NULL, -b varchar(255) default NULL, -UNIQUE KEY a (a), -KEY b (b) -); -INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); -CREATE TABLE t2 SELECT * FROM t1; -CREATE TABLE t3 SELECT * FROM t1; -# test altering of columns that multiupdate doesn't use -# normal mode -# PS mode -# test altering of columns that multiupdate uses -# normal mode -# PS mode -DROP TABLE t1, t2, t3; -CREATE TABLE t1( a INT, b INT ); -INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4); -# 1. test regular tables -# 1.1. test altering of columns that multiupdate doesn't use -# 1.1.1. normal mode -# 1.1.2. PS mode -# 1.2. test altering of columns that multiupdate uses -# 1.2.1. normal mode -# 1.2.2. PS mode -ALTER TABLE t1 ADD COLUMN a INT; -# 2. test UNIONs -# 2.1. test altering of columns that multiupdate doesn't use -# 2.1.1. normal mode -# 2.1.2. PS mode -# 2.2. test altering of columns that multiupdate uses -# 2.2.1. normal mode -# 2.2.2. PS mode -DROP TABLE t1; diff --git a/mysql-test/r/lock_multi_bug38499.result b/mysql-test/r/lock_multi_bug38499.result new file mode 100644 index 00000000000..fd0f2138a8d --- /dev/null +++ b/mysql-test/r/lock_multi_bug38499.result @@ -0,0 +1,19 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1( a INT, b INT ); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4); +# 1. test regular tables +# 1.1. test altering of columns that multiupdate doesn't use +# 1.1.1. normal mode +# 1.1.2. PS mode +# 1.2. test altering of columns that multiupdate uses +# 1.2.1. normal mode +# 1.2.2. PS mode +ALTER TABLE t1 ADD COLUMN a INT; +# 2. test UNIONs +# 2.1. test altering of columns that multiupdate doesn't use +# 2.1.1. normal mode +# 2.1.2. PS mode +# 2.2. test altering of columns that multiupdate uses +# 2.2.1. normal mode +# 2.2.2. PS mode +DROP TABLE t1; diff --git a/mysql-test/r/lock_multi_bug38691.result b/mysql-test/r/lock_multi_bug38691.result new file mode 100644 index 00000000000..74b9603d8e3 --- /dev/null +++ b/mysql-test/r/lock_multi_bug38691.result @@ -0,0 +1,17 @@ +DROP TABLE IF EXISTS t1,t2,t3; +CREATE TABLE t1 ( +a int(11) unsigned default NULL, +b varchar(255) default NULL, +UNIQUE KEY a (a), +KEY b (b) +); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +CREATE TABLE t2 SELECT * FROM t1; +CREATE TABLE t3 SELECT * FROM t1; +# test altering of columns that multiupdate doesn't use +# normal mode +# PS mode +# test altering of columns that multiupdate uses +# normal mode +# PS mode +DROP TABLE t1, t2, t3; diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index 089a60edb3d..d5c7beb5104 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -1,4 +1,8 @@ -- source include/not_embedded.inc + +# Save the initial number of concurrent sessions +--source include/count_sessions.inc + --disable_warnings drop table if exists t1,t2; --enable_warnings @@ -14,12 +18,23 @@ create table t1(n int); insert into t1 values (1); lock tables t1 write; connection writer; -send update low_priority t1 set n = 4; +send +update low_priority t1 set n = 4; connection reader; ---sleep 2 -send select n from t1; +# Sleep a bit till the update of connection writer is in work and hangs +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Locked'; +--source include/wait_show_condition.inc +send +select n from t1; connection locker; ---sleep 2 +# Sleep a bit till the select of connection reader is in work and hangs +# Here we cannot use include/wait_show_condition.inc because this routine +# cannot count the number of 'Locked' sessions or access two columns within +# the same query_get_value call. +--sleep 3 unlock tables; connection writer; reap; @@ -32,12 +47,23 @@ create table t1(n int); insert into t1 values (1); lock tables t1 read; connection writer; -send update low_priority t1 set n = 4; +send +update low_priority t1 set n = 4; connection reader; ---sleep 2 -send select n from t1; +# Sleep a bit till the update of connection writer is in work and hangs +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Locked'; +--source include/wait_show_condition.inc +# +send +select n from t1; connection locker; ---sleep 2 +# Sleep a bit till the select of connection reader is in work and hangs +# Here we cannot use include/wait_show_condition.inc. +--sleep 3 +# unlock tables; connection writer; reap; @@ -58,10 +84,13 @@ insert into t1 values(2,2); insert into t2 values(1,2); lock table t1 read; connection writer; ---sleep 2 -send update t1,t2 set c=a where b=d; +send +update t1,t2 set c=a where b=d; connection reader; ---sleep 2 +# Sleep a bit till the update of connection writer is finished +# Here we cannot use include/wait_show_condition.inc. +--sleep 3 +# select c from t2; connection writer; reap; @@ -70,7 +99,7 @@ drop table t1; drop table t2; # -# Test problem when using locks on many tables and droping a table that +# Test problem when using locks on many tables and dropping a table that # is to-be-locked by another thread # @@ -79,11 +108,18 @@ create table t1 (a int); create table t2 (a int); lock table t1 write, t2 write; connection reader; -send insert t1 select * from t2; +send +insert t1 select * from t2; connection locker; +# Sleep a bit till the insert of connection reader is in work and hangs +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Locked'; +--source include/wait_show_condition.inc drop table t2; connection reader; ---error 1146 +--error ER_NO_SUCH_TABLE reap; connection locker; drop table t1; @@ -91,7 +127,7 @@ drop table t1; # End of 4.1 tests # -# BUG#9998 - MySQL client hangs on USE "database" +# Bug#9998 MySQL client hangs on USE "database" # create table t1(a int); lock tables t1 write; @@ -102,7 +138,7 @@ unlock tables; drop table t1; # -# Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock +# Bug#19815 CREATE/RENAME/DROP DATABASE can deadlock on a global read lock # connect (con1,localhost,root,,); connect (con2,localhost,root,,); @@ -114,12 +150,18 @@ FLUSH TABLES WITH READ LOCK; # With bug in place: acquire LOCK_mysql_create_table and # wait in wait_if_global_read_lock(). connection con2; -send DROP DATABASE mysqltest_1; ---sleep 1 +send +DROP DATABASE mysqltest_1; # # With bug in place: try to acquire LOCK_mysql_create_table... # When fixed: Reject dropping db because of the read lock. connection con1; +# Wait a bit so that the session con2 is in state "Waiting for release of readlock" +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Waiting for release of readlock'; +--source include/wait_show_condition.inc --error ER_CANT_UPDATE_WITH_READLOCK DROP DATABASE mysqltest_1; UNLOCK TABLES; @@ -135,26 +177,33 @@ disconnect con2; --error ER_DB_DROP_EXISTS DROP DATABASE mysqltest_1; + # -# Bug#16986 - Deadlock condition with MyISAM tables +# Bug#16986 Deadlock condition with MyISAM tables # # Need a matching user in mysql.user for multi-table select --source include/add_anonymous_users.inc connection locker; -use mysql; +USE mysql; LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE; FLUSH TABLES; ---sleep 1 -# + + connection reader; -use mysql; -#NOTE: This must be a multi-table select, otherwise the deadlock will not occur -send SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1; ---sleep 1 +USE mysql; +# Note: This must be a multi-table select, otherwise the deadlock will not occur +send +SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1; # connection locker; +# Sleep a bit till the select of connection reader is in work and hangs +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Locked'; +--source include/wait_show_condition.inc # Make test case independent from earlier grants. --replace_result "Table is already up to date" "OK" OPTIMIZE TABLES columns_priv, db, host, user; @@ -162,7 +211,7 @@ UNLOCK TABLES; # connection reader; reap; -use test; +USE test; # connection locker; use test; @@ -177,11 +226,17 @@ LOCK TABLE t1 WRITE; # # This waits until t1 is unlocked. connection locker; -send FLUSH TABLES WITH READ LOCK; ---sleep 1 +send +FLUSH TABLES WITH READ LOCK; # # This must not block. connection writer; +# Sleep a bit till the flush of connection locker is in work and hangs +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Flushing tables'; +--source include/wait_show_condition.inc CREATE TABLE t2 (c1 int); UNLOCK TABLES; # @@ -201,12 +256,18 @@ LOCK TABLE t1 WRITE; # # This waits until t1 is unlocked. connection locker; -send FLUSH TABLES WITH READ LOCK; ---sleep 1 +send +FLUSH TABLES WITH READ LOCK; # # This must not block. connection writer; ---error 1100 +# Sleep a bit till the flush of connection locker is in work and hangs +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Flushing tables'; +--source include/wait_show_condition.inc +--error ER_TABLE_NOT_LOCKED CREATE TABLE t2 AS SELECT * FROM t1; UNLOCK TABLES; # @@ -220,8 +281,9 @@ DROP TABLE t1; --source include/delete_anonymous_users.inc + # -# Bug #17264: MySQL Server freeze +# Bug#17264 MySQL Server freeze # connection locker; # Disable warnings to allow test to run also without InnoDB @@ -230,17 +292,29 @@ create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) e --enable_warnings lock tables t1 write; connection writer; ---sleep 2 +# mleich: I have doubts if the next sleep is really necessary +# Therefore I set it to comment but don't remove it +# in case it hat to be enabled again. +# --sleep 2 delimiter //; -send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // +send +alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // delimiter ;// connection reader; ---sleep 2 +# Wait till connection writer is blocked +let $wait_timeout= 5; +let $show_statement= SHOW PROCESSLIST; +let $field= State; +let $condition= = 'Locked'; +--source include/wait_show_condition.inc delimiter //; -send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // +send +alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; // delimiter ;// connection locker; ---sleep 2 +# Wait till connection reader is blocked +# Here we cannot use include/wait_show_condition.inc. +--sleep 3 unlock tables; connection writer; reap; @@ -263,7 +337,7 @@ lock tables t1 read; --echo connection: writer connection writer; let $ID= `select connection_id()`; ---send create table t2 like t1; +send create table t2 like t1; --echo connection: default connection default; let $show_type= open tables where in_use=2 and name_locked=1; @@ -281,325 +355,14 @@ unlock tables; connection default; drop table t1; -# -# Bug #38691: segfault/abort in ``UPDATE ...JOIN'' while -# ``FLUSH TABLES WITH READ LOCK'' -# ---connection default -CREATE TABLE t1 ( - a int(11) unsigned default NULL, - b varchar(255) default NULL, - UNIQUE KEY a (a), - KEY b (b) -); - -INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); -CREATE TABLE t2 SELECT * FROM t1; -CREATE TABLE t3 SELECT * FROM t1; - ---echo # test altering of columns that multiupdate doesn't use - ---echo # normal mode - ---disable_query_log -let $i = 100; -while ($i) { ---dec $i - ---connection writer - send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) - SET a = NULL WHERE t1.b <> t2.b; - ---connection locker - ALTER TABLE t2 ADD COLUMN (c INT); - ALTER TABLE t2 DROP COLUMN c; - ---connection writer ---reap -} - ---echo # PS mode - ---connection writer -PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) - SET a = NULL WHERE t1.b <> t2.b'; - -let $i = 100; -while ($i) { ---dec $i - ---connection writer ---send EXECUTE stmt - ---connection locker - ALTER TABLE t2 ADD COLUMN (c INT); - ALTER TABLE t2 DROP COLUMN c; - ---connection writer ---reap -} ---enable_query_log - - ---echo # test altering of columns that multiupdate uses - ---echo # normal mode - ---connection default - ---disable_query_log -let $i = 100; -while ($i) { - dec $i; - ---connection locker ---error 0,1060 - ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL; - UPDATE t2 SET a=b; - ---connection writer ---send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b - ---connection locker ---error 0,1091 - ALTER TABLE t2 DROP COLUMN a; - ---connection writer ---error 0,1054 ---reap -} ---enable_query_log - ---echo # PS mode - ---disable_query_log -let $i = 100; -while ($i) { - dec $i; - ---connection locker ---error 0,1060 - ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL; - UPDATE t2 SET a=b; - ---connection writer - PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b'; ---send EXECUTE stmt - ---connection locker ---error 0,1091 - ALTER TABLE t2 DROP COLUMN a; - ---connection writer ---error 0,1054 ---reap - -} ---enable_query_log ---connection default -DROP TABLE t1, t2, t3; - -# -# Bug#38499: flush tables and multitable table update with derived table cause -# crash -# - -CREATE TABLE t1( a INT, b INT ); -INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4); - ---echo # 1. test regular tables ---echo # 1.1. test altering of columns that multiupdate doesn't use ---echo # 1.1.1. normal mode - ---disable_query_log -let $i = 100; -while ($i) { ---dec $i - ---connection writer - send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0; - ---connection locker - ALTER TABLE t1 ADD COLUMN (c INT); - ALTER TABLE t1 DROP COLUMN c; - ---connection writer ---reap -} - ---echo # 1.1.2. PS mode - ---connection writer -PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0'; - -let $i = 100; -while ($i) { ---dec $i - ---connection writer ---send EXECUTE stmt - ---connection locker - ALTER TABLE t1 ADD COLUMN (c INT); - ALTER TABLE t1 DROP COLUMN c; - ---connection writer ---reap -} ---enable_query_log - ---echo # 1.2. test altering of columns that multiupdate uses ---echo # 1.2.1. normal mode - ---connection default - ---disable_query_log -let $i = 100; -while ($i) { - dec $i; - ---connection locker ---error 0,1060 - ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL; - UPDATE t1 SET a=b; - ---connection writer ---send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0; - ---connection locker ---error 0,1091 - ALTER TABLE t1 DROP COLUMN a; - ---connection writer ---error 0,1054 # unknown column error ---reap -} ---enable_query_log - ---echo # 1.2.2. PS mode - ---disable_query_log -let $i = 100; -while ($i) { - dec $i; - ---connection locker ---error 0,1060 - ALTER TABLE t1 ADD COLUMN a INT; - UPDATE t1 SET a=b; - ---connection writer - PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0'; ---send EXECUTE stmt - ---connection locker ---error 0,1091 - ALTER TABLE t1 DROP COLUMN a; - ---connection writer ---error 0,1054 # Unknown column 'a' in 'field list' ---reap -} ---enable_query_log ---connection default -ALTER TABLE t1 ADD COLUMN a INT; - ---echo # 2. test UNIONs ---echo # 2.1. test altering of columns that multiupdate doesn't use ---echo # 2.1.1. normal mode - ---disable_query_log -let $i = 100; -while ($i) { ---dec $i - ---connection writer - send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0; - ---connection locker - ALTER TABLE t1 ADD COLUMN (c INT); - ALTER TABLE t1 DROP COLUMN c; - ---connection writer ---reap -} - ---echo # 2.1.2. PS mode - ---connection writer -PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0'; - -let $i = 100; -while ($i) { ---dec $i - ---connection writer ---send EXECUTE stmt - ---connection locker - ALTER TABLE t1 ADD COLUMN (c INT); - ALTER TABLE t1 DROP COLUMN c; - ---connection writer ---reap -} ---enable_query_log - ---echo # 2.2. test altering of columns that multiupdate uses ---echo # 2.2.1. normal mode - ---connection default - ---disable_query_log -let $i = 100; -while ($i) { - dec $i; - ---connection locker ---error 0,1060 - ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL; - UPDATE t1 SET a=b; - ---connection writer ---send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0; - ---connection locker ---error 0,1091 - ALTER TABLE t1 DROP COLUMN a; - ---connection writer ---error 0,1054 # Unknown column 'a' in 'field list' ---reap -} ---enable_query_log - ---echo # 2.2.2. PS mode - ---disable_query_log -let $i = 100; -while ($i) { - dec $i; - ---connection locker ---error 0,1060 - ALTER TABLE t1 ADD COLUMN a INT; - UPDATE t1 SET a=b; - ---connection writer - PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0'; ---send EXECUTE stmt - ---connection locker ---error 0,1091 - ALTER TABLE t1 DROP COLUMN a; - ---connection writer ---error 0,1054 # Unknown column 'a' in 'field list' ---reap -} ---enable_query_log ---connection default -DROP TABLE t1; +# Close connections used in many subtests +--disconnect reader +--disconnect locker +--disconnect writer # End of 5.0 tests + +# Wait till all disconnects are completed +--source include/wait_until_count_sessions.inc + diff --git a/mysql-test/t/lock_multi_bug38499.test b/mysql-test/t/lock_multi_bug38499.test new file mode 100644 index 00000000000..8178987e802 --- /dev/null +++ b/mysql-test/t/lock_multi_bug38499.test @@ -0,0 +1,221 @@ +# Bug38499 flush tables and multitable table update with derived table cause crash +# MySQL >= 5.0 +# + +# Save the initial number of concurrent sessions +--source include/count_sessions.inc + +connect (locker,localhost,root,,); +connect (writer,localhost,root,,); + +--connection default +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1( a INT, b INT ); +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4); + +--echo # 1. test regular tables +--echo # 1.1. test altering of columns that multiupdate doesn't use +--echo # 1.1.1. normal mode + +--disable_query_log +let $i = 100; +while ($i) { +--dec $i + +--connection writer + send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0; + +--connection locker + ALTER TABLE t1 ADD COLUMN (c INT); + ALTER TABLE t1 DROP COLUMN c; + +--connection writer +--reap +} + +--echo # 1.1.2. PS mode + +--connection writer +PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0'; + +let $i = 100; +while ($i) { +--dec $i + +--connection writer +--send EXECUTE stmt + +--connection locker + ALTER TABLE t1 ADD COLUMN (c INT); + ALTER TABLE t1 DROP COLUMN c; + +--connection writer +--reap +} +--enable_query_log + +--echo # 1.2. test altering of columns that multiupdate uses +--echo # 1.2.1. normal mode + +--connection default + +--disable_query_log +let $i = 100; +while ($i) { + dec $i; + +--connection locker +--error 0,ER_DUP_FIELDNAME + ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL; + UPDATE t1 SET a=b; + +--connection writer +--send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0; + +--connection locker +--error 0,ER_CANT_DROP_FIELD_OR_KEY + ALTER TABLE t1 DROP COLUMN a; + +--connection writer +--error 0,ER_BAD_FIELD_ERROR # unknown column error +--reap +} +--enable_query_log + +--echo # 1.2.2. PS mode + +--disable_query_log +let $i = 100; +while ($i) { + dec $i; + +--connection locker +--error 0,ER_DUP_FIELDNAME + ALTER TABLE t1 ADD COLUMN a INT; + UPDATE t1 SET a=b; + +--connection writer + PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0'; +--send EXECUTE stmt + +--connection locker +--error 0,ER_CANT_DROP_FIELD_OR_KEY + ALTER TABLE t1 DROP COLUMN a; + +--connection writer +--error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list' +--reap +} +--enable_query_log +--connection default +ALTER TABLE t1 ADD COLUMN a INT; + +--echo # 2. test UNIONs +--echo # 2.1. test altering of columns that multiupdate doesn't use +--echo # 2.1.1. normal mode + +--disable_query_log +let $i = 100; +while ($i) { +--dec $i + +--connection writer + send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0; + +--connection locker + ALTER TABLE t1 ADD COLUMN (c INT); + ALTER TABLE t1 DROP COLUMN c; + +--connection writer +--reap +} + +--echo # 2.1.2. PS mode + +--connection writer +PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0'; + +let $i = 100; +while ($i) { +--dec $i + +--connection writer +--send EXECUTE stmt + +--connection locker + ALTER TABLE t1 ADD COLUMN (c INT); + ALTER TABLE t1 DROP COLUMN c; + +--connection writer +--reap +} +--enable_query_log + +--echo # 2.2. test altering of columns that multiupdate uses +--echo # 2.2.1. normal mode + +--connection default + +--disable_query_log +let $i = 100; +while ($i) { + dec $i; + +--connection locker +--error 0,ER_DUP_FIELDNAME + ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL; + UPDATE t1 SET a=b; + +--connection writer +--send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0; + +--connection locker +--error 0,ER_CANT_DROP_FIELD_OR_KEY + ALTER TABLE t1 DROP COLUMN a; + +--connection writer +--error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list' +--reap +} +--enable_query_log + +--echo # 2.2.2. PS mode + +--disable_query_log +let $i = 100; +while ($i) { + dec $i; + +--connection locker +--error 0,ER_DUP_FIELDNAME + ALTER TABLE t1 ADD COLUMN a INT; + UPDATE t1 SET a=b; + +--connection writer + PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0'; +--send EXECUTE stmt + +--connection locker +--error 0,ER_CANT_DROP_FIELD_OR_KEY + ALTER TABLE t1 DROP COLUMN a; + +--connection writer +--error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list' +--reap +} +--enable_query_log +--connection default +DROP TABLE t1; + + +# Close connections +--disconnect locker +--disconnect writer + +# End of 5.0 tests + +# Wait till all disconnects are completed +--source include/wait_until_count_sessions.inc + diff --git a/mysql-test/t/lock_multi_bug38691.test b/mysql-test/t/lock_multi_bug38691.test new file mode 100644 index 00000000000..0458f31579e --- /dev/null +++ b/mysql-test/t/lock_multi_bug38691.test @@ -0,0 +1,141 @@ +# +# Bug#38691 segfault/abort in ``UPDATE ...JOIN'' while +# ``FLUSH TABLES WITH READ LOCK'' +# MySQL >= 5.0 +# + + +# Save the initial number of concurrent sessions +--source include/count_sessions.inc + +# Test to see if select will get the lock ahead of low priority update + +connect (locker,localhost,root,,); +connect (writer,localhost,root,,); + +--connection default +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3; +--enable_warnings + +CREATE TABLE t1 ( + a int(11) unsigned default NULL, + b varchar(255) default NULL, + UNIQUE KEY a (a), + KEY b (b) +); + +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +CREATE TABLE t2 SELECT * FROM t1; +CREATE TABLE t3 SELECT * FROM t1; + +--echo # test altering of columns that multiupdate doesn't use + +--echo # normal mode + +--disable_query_log +let $i = 100; +while ($i) { +--dec $i + +--connection writer + send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) + SET a = NULL WHERE t1.b <> t2.b; + +--connection locker + ALTER TABLE t2 ADD COLUMN (c INT); + ALTER TABLE t2 DROP COLUMN c; + +--connection writer +--reap +} + +--echo # PS mode + +--connection writer +PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) + SET a = NULL WHERE t1.b <> t2.b'; + +let $i = 100; +while ($i) { +--dec $i + +--connection writer +--send EXECUTE stmt + +--connection locker + ALTER TABLE t2 ADD COLUMN (c INT); + ALTER TABLE t2 DROP COLUMN c; + +--connection writer +--reap +} +--enable_query_log + + +--echo # test altering of columns that multiupdate uses + +--echo # normal mode + +--connection default + +--disable_query_log +let $i = 100; +while ($i) { + dec $i; + +--connection locker +--error 0,ER_DUP_FIELDNAME + ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL; + UPDATE t2 SET a=b; + +--connection writer +--send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b + +--connection locker +--error 0,ER_CANT_DROP_FIELD_OR_KEY + ALTER TABLE t2 DROP COLUMN a; + +--connection writer +--error 0,ER_BAD_FIELD_ERROR +--reap +} +--enable_query_log + +--echo # PS mode + +--disable_query_log +let $i = 100; +while ($i) { + dec $i; + +--connection locker +--error 0,ER_DUP_FIELDNAME + ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL; + UPDATE t2 SET a=b; + +--connection writer + PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b'; +--send EXECUTE stmt + +--connection locker +--error 0,ER_CANT_DROP_FIELD_OR_KEY + ALTER TABLE t2 DROP COLUMN a; + +--connection writer +--error 0,ER_BAD_FIELD_ERROR +--reap + +} +--enable_query_log +--connection default +DROP TABLE t1, t2, t3; + + +# Close connections +--disconnect locker +--disconnect writer + +# Wait till all disconnects are completed +--source include/wait_until_count_sessions.inc + From 5fdc5510ec1abcfe3f3f74a229ae3102533f46c4 Mon Sep 17 00:00:00 2001 From: Leonard Zhou Date: Tue, 24 Mar 2009 08:45:05 +0800 Subject: [PATCH 63/88] BUG#41719 delayed INSERT into timestamp col needs set time_zone for concurrent binlogging When do 'insert delayed' operation, the time_zone info doesn't be keeped in the row info. So when we do insert sometime later, time_zone didn't write into binlog. This will cause wrong result for timestamp column in slave. Our solution is that adding time_zone info with the delayed-row and restoring time_zone from row-info when execute that row in the furture by another thread. So we can write correct time_zone info into binlog and got correct result in slave. mysql-test/r/rpl_timezone.result: Test result mysql-test/t/rpl_timezone.test: Add test for bug#41719 sql/sql_insert.cc: Add time_zone info in the delayed-row and restore time_zone when execute the row in the furture by another thread. --- mysql-test/r/rpl_timezone.result | 18 ++++++++++++++++++ mysql-test/t/rpl_timezone.test | 25 +++++++++++++++++++++++++ sql/sql_insert.cc | 27 ++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/rpl_timezone.result b/mysql-test/r/rpl_timezone.result index 7a5d09ea6a7..2b179c0dc4a 100644 --- a/mysql-test/r/rpl_timezone.result +++ b/mysql-test/r/rpl_timezone.result @@ -153,4 +153,22 @@ a b SET @@session.time_zone = default; DROP TABLE t1; SET @@session.time_zone = default; +CREATE TABLE t1 (date timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, a int(11) default NULL); +SET @@session.time_zone='+01:00'; +insert into t1 values('2008-12-23 19:39:39',1); +SET @@session.time_zone='+02:00'; +insert delayed into t1 values ('2008-12-23 19:39:39',2); +flush table t1; +flush logs; +select * from t1; +date a +2008-12-23 20:39:39 1 +2008-12-23 19:39:39 2 +DROP TABLE t1; +select * from t1 order by a; +date a +2008-12-23 20:39:39 1 +2008-12-23 19:39:39 2 +DROP TABLE t1; +SET @@session.time_zone = default; End of 5.0 tests diff --git a/mysql-test/t/rpl_timezone.test b/mysql-test/t/rpl_timezone.test index 28ca250340e..efe56155659 100644 --- a/mysql-test/t/rpl_timezone.test +++ b/mysql-test/t/rpl_timezone.test @@ -154,5 +154,30 @@ connection master; DROP TABLE t1; SET @@session.time_zone = default; +# Bug#41719 delayed INSERT into timestamp col needs set time_zone for concurrent binlogging +# To test that time_zone is correctly binloging for 'insert delayed' statement +# Insert 2 values into timestamp col with different time_zone. Check result. + +--connection master +CREATE TABLE t1 (date timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, a int(11) default NULL); + +SET @@session.time_zone='+01:00'; +insert into t1 values('2008-12-23 19:39:39',1); + +--connection master1 +SET @@session.time_zone='+02:00'; +insert delayed into t1 values ('2008-12-23 19:39:39',2); +# Forces table t1 to be closed and flushes the query cache. +# This makes sure that 'delayed insert' is executed before next statement. +flush table t1; +flush logs; +select * from t1; +DROP TABLE t1; + +--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 | $MYSQL +--connection master1 +select * from t1 order by a; +DROP TABLE t1; +SET @@session.time_zone = default; --echo End of 5.0 tests diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 4eddcd17df1..ec16de318cc 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1605,10 +1605,11 @@ public: ulong auto_increment_increment; ulong auto_increment_offset; timestamp_auto_set_type timestamp_field_type; + Time_zone *time_zone; uint query_length; delayed_row(enum_duplicates dup_arg, bool ignore_arg, bool log_query_arg) - :record(0), query(0), dup(dup_arg), ignore(ignore_arg), log_query(log_query_arg) {} + :record(0), query(0), time_zone(0), dup(dup_arg), ignore(ignore_arg), log_query(log_query_arg) {} ~delayed_row() { x_free(record); @@ -2062,6 +2063,19 @@ int write_delayed(THD *thd,TABLE *table,enum_duplicates duplic, bool ignore, row->last_insert_id= thd->last_insert_id; row->timestamp_field_type= table->timestamp_field_type; + /* Add session variable timezone + Time_zone object will not be freed even the thread is ended. + So we can get time_zone object from thread which handling delayed statement. + See the comment of my_tz_find() for detail. + */ + if (thd->time_zone_used) + { + row->time_zone = thd->variables.time_zone; + } + else + { + row->time_zone = NULL; + } /* The session variable settings can always be copied. */ row->auto_increment_increment= thd->variables.auto_increment_increment; row->auto_increment_offset= thd->variables.auto_increment_offset; @@ -2515,8 +2529,19 @@ bool Delayed_insert::handle_inserts(void) } if (row->query && row->log_query && using_bin_log) { + bool backup_time_zone_used = thd.time_zone_used; + Time_zone *backup_time_zone = thd.variables.time_zone; + if (row->time_zone != NULL) + { + thd.time_zone_used = true; + thd.variables.time_zone = row->time_zone; + } + Query_log_event qinfo(&thd, row->query, row->query_length, 0, FALSE); mysql_bin_log.write(&qinfo); + + thd.time_zone_used = backup_time_zone_used; + thd.variables.time_zone = backup_time_zone; } if (table->s->blob_fields) free_delayed_insert_blobs(table); From ae3f8c7eab348ab9e91c4bf13666e32e658803ae Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 24 Mar 2009 13:02:01 +0400 Subject: [PATCH 64/88] compiler warning fix --- storage/csv/ha_tina.cc | 31 ++++++++++++++++--------------- storage/csv/ha_tina.h | 14 +++++++------- storage/csv/transparent_file.cc | 12 ++++++------ storage/csv/transparent_file.h | 10 +++++----- 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 1b623c18371..e18d4025777 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -397,12 +397,12 @@ static int free_share(TINA_SHARE *share) '\r''\n' -- DOS\Windows line ending */ -off_t find_eoln_buff(Transparent_file *data_buff, off_t begin, - off_t end, int *eoln_len) +my_off_t find_eoln_buff(Transparent_file *data_buff, my_off_t begin, + my_off_t end, int *eoln_len) { *eoln_len= 0; - for (off_t x= begin; x < end; x++) + for (my_off_t x= begin; x < end; x++) { /* Unix (includes Mac OS X) */ if (data_buff->get_value(x) == '\n') @@ -586,7 +586,7 @@ int ha_tina::chain_append() */ int ha_tina::find_current_row(uchar *buf) { - off_t end_offset, curr_offset= current_position; + my_off_t end_offset, curr_offset= current_position; int eoln_len; my_bitmap_map *org_bitmap; int error; @@ -836,7 +836,7 @@ int ha_tina::open(const char *name, int mode, uint open_options) during locking. This is needed to enable concurrent inserts. */ thr_lock_data_init(&share->lock, &lock, (void*) this); - ref_length=sizeof(off_t); + ref_length= sizeof(my_off_t); share->lock.get_status= tina_get_status; share->lock.update_status= tina_update_status; @@ -1140,7 +1140,7 @@ int ha_tina::rnd_pos(uchar * buf, uchar *pos) { DBUG_ENTER("ha_tina::rnd_pos"); ha_statistic_increment(&SSV::ha_read_rnd_count); - current_position= (off_t)my_get_ptr(pos,ref_length); + current_position= my_get_ptr(pos,ref_length); DBUG_RETURN(find_current_row(buf)); } @@ -1180,7 +1180,7 @@ int ha_tina::extra(enum ha_extra_function operation) to the given "hole", stored in the buffer. "Valid" here means, not listed in the chain of deleted records ("holes"). */ -bool ha_tina::get_write_pos(off_t *end_pos, tina_set *closest_hole) +bool ha_tina::get_write_pos(my_off_t *end_pos, tina_set *closest_hole) { if (closest_hole == chain_ptr) /* no more chains */ *end_pos= file_buff->end(); @@ -1200,7 +1200,7 @@ bool ha_tina::get_write_pos(off_t *end_pos, tina_set *closest_hole) int ha_tina::rnd_end() { char updated_fname[FN_REFLEN]; - off_t file_buffer_start= 0; + my_off_t file_buffer_start= 0; DBUG_ENTER("ha_tina::rnd_end"); free_root(&blobroot, MYF(0)); @@ -1223,17 +1223,17 @@ int ha_tina::rnd_end() my_qsort(chain, (size_t)(chain_ptr - chain), sizeof(tina_set), (qsort_cmp)sort_set); - off_t write_begin= 0, write_end; + my_off_t write_begin= 0, write_end; /* create the file to write updated table if it wasn't yet created */ if (open_update_temp_file_if_needed()) DBUG_RETURN(-1); /* write the file with updated info */ - while ((file_buffer_start != -1)) // while not end of file + while ((file_buffer_start != (my_off_t)-1)) // while not end of file { bool in_hole= get_write_pos(&write_end, ptr); - off_t write_length= write_end - write_begin; + my_off_t write_length= write_end - write_begin; /* if there is something to write, write it */ if (write_length) @@ -1241,14 +1241,15 @@ int ha_tina::rnd_end() if (my_write(update_temp_file, (uchar*) (file_buff->ptr() + (write_begin - file_buff->start())), - write_length, MYF_RW)) + (size_t)write_length, MYF_RW)) goto error; temp_file_length+= write_length; } if (in_hole) { /* skip hole */ - while (file_buff->end() <= ptr->end && file_buffer_start != -1) + while (file_buff->end() <= ptr->end && + file_buffer_start != (my_off_t)-1) file_buffer_start= file_buff->read_next(); write_begin= ptr->end; ptr++; @@ -1348,7 +1349,7 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) File repair_file; int rc; ha_rows rows_repaired= 0; - off_t write_begin= 0, write_end; + my_off_t write_begin= 0, write_end; DBUG_ENTER("ha_tina::repair"); /* empty file */ @@ -1423,7 +1424,7 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) write_end= min(file_buff->end(), current_position); if ((write_end - write_begin) && (my_write(repair_file, (uchar*)file_buff->ptr(), - write_end - write_begin, MYF_RW))) + (size_t) (write_end - write_begin), MYF_RW))) DBUG_RETURN(-1); write_begin= write_end; diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h index dc00ce214c9..02e0700a825 100644 --- a/storage/csv/ha_tina.h +++ b/storage/csv/ha_tina.h @@ -40,7 +40,7 @@ typedef struct st_tina_share { inserts, updates and deletes. The var is initialized along with the share initialization. */ - off_t saved_data_file_length; + my_off_t saved_data_file_length; pthread_mutex_t mutex; THR_LOCK lock; bool update_file_opened; @@ -53,18 +53,18 @@ typedef struct st_tina_share { } TINA_SHARE; struct tina_set { - off_t begin; - off_t end; + my_off_t begin; + my_off_t end; }; class ha_tina: public handler { THR_LOCK_DATA lock; /* MySQL lock */ TINA_SHARE *share; /* Shared lock info */ - off_t current_position; /* Current position in the file during a file scan */ - off_t next_position; /* Next position in the file scan */ + my_off_t current_position; /* Current position in the file during a file scan */ + my_off_t next_position; /* Next position in the file scan */ my_off_t local_saved_data_file_length; /* save position for reads */ - off_t temp_file_length; + my_off_t temp_file_length; uchar byte_buffer[IO_SIZE]; Transparent_file *file_buff; File data_file; /* File handler for readers */ @@ -85,7 +85,7 @@ class ha_tina: public handler MEM_ROOT blobroot; private: - bool get_write_pos(off_t *end_pos, tina_set *closest_hole); + bool get_write_pos(my_off_t *end_pos, tina_set *closest_hole); int open_update_temp_file_if_needed(); int init_tina_writer(); int init_data_file(); diff --git a/storage/csv/transparent_file.cc b/storage/csv/transparent_file.cc index fad7cd796e5..841c3efc476 100644 --- a/storage/csv/transparent_file.cc +++ b/storage/csv/transparent_file.cc @@ -45,17 +45,17 @@ uchar *Transparent_file::ptr() return buff; } -off_t Transparent_file::start() +my_off_t Transparent_file::start() { return lower_bound; } -off_t Transparent_file::end() +my_off_t Transparent_file::end() { return upper_bound; } -off_t Transparent_file::read_next() +my_off_t Transparent_file::read_next() { size_t bytes_read; @@ -64,11 +64,11 @@ off_t Transparent_file::read_next() always points to upper_bound byte */ if ((bytes_read= my_read(filedes, buff, buff_size, MYF(0))) == MY_FILE_ERROR) - return (off_t) -1; + return (my_off_t) -1; /* end of file */ if (!bytes_read) - return (off_t) -1; + return (my_off_t) -1; lower_bound= upper_bound; upper_bound+= bytes_read; @@ -77,7 +77,7 @@ off_t Transparent_file::read_next() } -char Transparent_file::get_value(off_t offset) +char Transparent_file::get_value(my_off_t offset) { size_t bytes_read; diff --git a/storage/csv/transparent_file.h b/storage/csv/transparent_file.h index 29da06d5ab7..0168e271e7d 100644 --- a/storage/csv/transparent_file.h +++ b/storage/csv/transparent_file.h @@ -23,7 +23,7 @@ class Transparent_file File filedes; uchar *buff; /* in-memory window to the file or mmaped area */ /* current window sizes */ - off_t lower_bound; + my_off_t lower_bound; my_off_t upper_bound; uint buff_size; @@ -34,8 +34,8 @@ public: void init_buff(File filedes_arg); uchar *ptr(); - off_t start(); - off_t end(); - char get_value (off_t offset); - off_t read_next(); + my_off_t start(); + my_off_t end(); + char get_value (my_off_t offset); + my_off_t read_next(); }; From f3a08d56ba5b601808ea825c6eb8ea0caa95a1ab Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Tue, 24 Mar 2009 16:52:35 +0200 Subject: [PATCH 65/88] Fixed initialization order warining. --- sql/sql_insert.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 97eab6d2202..6c27766ec86 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1658,8 +1658,8 @@ public: delayed_row(LEX_STRING const query_arg, enum_duplicates dup_arg, bool ignore_arg, bool log_query_arg) - : record(0), time_zone(0), dup(dup_arg), ignore(ignore_arg), log_query(log_query_arg), - forced_insert_id(0), query(query_arg) + : record(0), dup(dup_arg), ignore(ignore_arg), log_query(log_query_arg), + forced_insert_id(0), query(query_arg), time_zone(0) {} ~delayed_row() { From ed1e9d214c6a4c026f07fb000706ec5012681cc2 Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Tue, 24 Mar 2009 18:27:33 +0000 Subject: [PATCH 66/88] BUG#39701: Mixed binlog format does not switch to row mode on LOAD_FILE LOAD_FILE is not safe to replicate in STATEMENT mode, because it depends on a file (which is loaded on master and may not exist in slave(s)). This leads to scenarios on which the slave replicates the statement with 'load_file' and it will try to load the file from local file system. Given that the file may not exist in the slave filesystem the operation will not succeed (probably returning NULL), causing master and slave(s) to diverge. However, when using MIXED mode replication, this can be made to work, if the statement including LOAD_FILE is marked as unsafe, triggering a switch to ROW mode, meaning that the contents of the file are written to binlog as row events. Consequently, the contents from the file in the master will reach the slave via the binlog. This patch addresses this bug by marking the load_file function as unsafe. When in mixed mode and when LOAD_FILE is issued, there will be a switch to row mode. Furthermore, when in statement mode, the LOAD_FILE will raise a warning that the statement is unsafe in that mode. mysql-test/extra/rpl_tests/rpl_loadfile.test: Extra file that is "sourced" on both rpl_loadfile and rpl_stm_loadfile test files. mysql-test/suite/rpl/r/rpl_loadfile.result: Updated with the results from the test case added to this file. mysql-test/suite/rpl/r/rpl_stm_loadfile.result: Result file for rpl_loadfile test split with the warnings in statement mode. mysql-test/suite/rpl/t/rpl_loadfile.test: After splitting the original rpl_loadfile file, this one is only required to be executed in mixed or row format. Appended the test for 39701 to this file. mysql-test/suite/rpl/t/rpl_stm_loadfile.test: Split the original rpl_loadfile test because load_file now raises a warning when in statement mode. The goal of this split is two-fold: i) make the test case more resilient; ii) assert that warnings are indeed raised when in statement mode. sql/item_create.cc: Added the set_stmt_unsafe call to lex. --- mysql-test/extra/rpl_tests/rpl_loadfile.test | 36 +++ mysql-test/suite/rpl/r/rpl_loadfile.result | 18 ++ .../suite/rpl/r/rpl_stm_loadfile.result | 231 ++++++++++++++++++ mysql-test/suite/rpl/t/rpl_loadfile.test | 120 ++++++--- mysql-test/suite/rpl/t/rpl_stm_loadfile.test | 20 ++ sql/item_create.cc | 1 + 6 files changed, 397 insertions(+), 29 deletions(-) create mode 100644 mysql-test/extra/rpl_tests/rpl_loadfile.test create mode 100644 mysql-test/suite/rpl/r/rpl_stm_loadfile.result create mode 100644 mysql-test/suite/rpl/t/rpl_stm_loadfile.test diff --git a/mysql-test/extra/rpl_tests/rpl_loadfile.test b/mysql-test/extra/rpl_tests/rpl_loadfile.test new file mode 100644 index 00000000000..85620b58a97 --- /dev/null +++ b/mysql-test/extra/rpl_tests/rpl_loadfile.test @@ -0,0 +1,36 @@ +# Begin clean up test section +--disable_warnings +connection master; +DROP PROCEDURE IF EXISTS test.p1; +DROP TABLE IF EXISTS test.t1; +--enable_warnings + +# Section 1 test + +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; +delimiter |; +create procedure test.p1() +begin + INSERT INTO test.t1 VALUES(2,'test'); + UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=2; +end| +delimiter ;| + +CALL test.p1(); +SELECT * FROM test.t1 ORDER BY blob_column; +save_master_pos; +sync_slave_with_master; +connection slave; +# Need to allow some time when NDB engine is used for +# the injector thread to have time to populate binlog +let $wait_condition= SELECT INSTR(blob_column,'aberration') > 0 FROM test.t1 WHERE a = 2; +--source include/wait_condition.inc +SELECT * FROM test.t1 ORDER BY blob_column; + +# Cleanup +connection master; +DROP PROCEDURE IF EXISTS test.p1; +DROP TABLE test.t1; +sync_slave_with_master; diff --git a/mysql-test/suite/rpl/r/rpl_loadfile.result b/mysql-test/suite/rpl/r/rpl_loadfile.result index 7a5a7bc50c9..63710326086 100644 --- a/mysql-test/suite/rpl/r/rpl_loadfile.result +++ b/mysql-test/suite/rpl/r/rpl_loadfile.result @@ -225,3 +225,21 @@ aberration DROP PROCEDURE IF EXISTS test.p1; DROP TABLE test.t1; +**** Resetting master and slave **** +include/stop_slave.inc +RESET SLAVE; +RESET MASTER; +include/start_slave.inc +SELECT repeat('x',20) INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug_39701.data'; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (t text); +CREATE PROCEDURE p(file TEXT) +BEGIN +INSERT INTO t1 VALUES (LOAD_FILE(file)); +END| +include/stop_slave.inc +CALL p('MYSQLTEST_VARDIR/tmp/bug_39701.data'); +include/start_slave.inc +Comparing tables master:test.t1 and slave:test.t1 +DROP TABLE t1; +DROP PROCEDURE p; diff --git a/mysql-test/suite/rpl/r/rpl_stm_loadfile.result b/mysql-test/suite/rpl/r/rpl_stm_loadfile.result new file mode 100644 index 00000000000..d18befe6e4c --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_stm_loadfile.result @@ -0,0 +1,231 @@ +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 PROCEDURE IF EXISTS test.p1; +DROP TABLE IF EXISTS test.t1; +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: +Warning 1592 Statement is not safe to log in statement format. +create procedure test.p1() +begin +INSERT INTO test.t1 VALUES(2,'test'); +UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=2; +end| +CALL test.p1(); +Warnings: +Warning 1592 Statement is not safe to log in statement format. +SELECT * FROM test.t1 ORDER BY blob_column; +a blob_column +1 abase +abased +abasement +abasements +abases +abash +abashed +abashes +abashing +abasing +abate +abated +abatement +abatements +abater +abates +abating +Abba +abbe +abbey +abbeys +abbot +abbots +Abbott +abbreviate +abbreviated +abbreviates +abbreviating +abbreviation +abbreviations +Abby +abdomen +abdomens +abdominal +abduct +abducted +abduction +abductions +abductor +abductors +abducts +Abe +abed +Abel +Abelian +Abelson +Aberdeen +Abernathy +aberrant +aberration + +2 abase +abased +abasement +abasements +abases +abash +abashed +abashes +abashing +abasing +abate +abated +abatement +abatements +abater +abates +abating +Abba +abbe +abbey +abbeys +abbot +abbots +Abbott +abbreviate +abbreviated +abbreviates +abbreviating +abbreviation +abbreviations +Abby +abdomen +abdomens +abdominal +abduct +abducted +abduction +abductions +abductor +abductors +abducts +Abe +abed +Abel +Abelian +Abelson +Aberdeen +Abernathy +aberrant +aberration + +SELECT * FROM test.t1 ORDER BY blob_column; +a blob_column +1 abase +abased +abasement +abasements +abases +abash +abashed +abashes +abashing +abasing +abate +abated +abatement +abatements +abater +abates +abating +Abba +abbe +abbey +abbeys +abbot +abbots +Abbott +abbreviate +abbreviated +abbreviates +abbreviating +abbreviation +abbreviations +Abby +abdomen +abdomens +abdominal +abduct +abducted +abduction +abductions +abductor +abductors +abducts +Abe +abed +Abel +Abelian +Abelson +Aberdeen +Abernathy +aberrant +aberration + +2 abase +abased +abasement +abasements +abases +abash +abashed +abashes +abashing +abasing +abate +abated +abatement +abatements +abater +abates +abating +Abba +abbe +abbey +abbeys +abbot +abbots +Abbott +abbreviate +abbreviated +abbreviates +abbreviating +abbreviation +abbreviations +Abby +abdomen +abdomens +abdominal +abduct +abducted +abduction +abductions +abductor +abductors +abducts +Abe +abed +Abel +Abelian +Abelson +Aberdeen +Abernathy +aberrant +aberration + +DROP PROCEDURE IF EXISTS test.p1; +DROP TABLE test.t1; diff --git a/mysql-test/suite/rpl/t/rpl_loadfile.test b/mysql-test/suite/rpl/t/rpl_loadfile.test index 5aa4da41fe5..d12d43224df 100644 --- a/mysql-test/suite/rpl/t/rpl_loadfile.test +++ b/mysql-test/suite/rpl/t/rpl_loadfile.test @@ -11,43 +11,105 @@ # Includes -- source include/master-slave.inc +-- source include/have_binlog_format_mixed_or_row.inc +-- source extra/rpl_tests/rpl_loadfile.test + +# BUG#39701: Mixed binlog format does not switch to row mode on LOAD_FILE +# +# DESCRIPTION +# +# Problem: when using load_file string function and mixed binlogging format +# there was no switch to row based binlogging format. This leads +# to scenarios on which the slave replicates the statement and it +# will try to load the file from local file system, which in most +# likely it will not exist. +# +# Solution: +# Marking this function as unsafe for statement format, makes the +# statement using it to be logged in row based format. As such, data +# replicated from the master, becomes the content of the loaded file. +# Consequently, the slave receives the necessary data to complete +# the load_file instruction correctly. +# +# IMPLEMENTATION +# +# The test is implemented as follows: +# +# On Master, +# i) write to file the desired content. +# ii) create table and stored procedure with load_file +# iii) stop slave +# iii) execute load_file +# iv) remove file +# +# On Slave, +# v) start slave +# vi) sync it with master so that it gets the updates from binlog (which +# should have bin logged in row format). +# +# If the the binlog format does not change to row, then the assertion +# done in the following step fails. This happens because tables differ +# since the file does not exist anymore, meaning that when slave +# attempts to execute LOAD_FILE statement it inserts NULL on table +# instead of the same contents that the master loaded when it executed +# the procedure (which was executed when file existed). +# +# vii) assert that the contents of master and slave +# table are the same -# Begin clean up test section ---disable_warnings connection master; -DROP PROCEDURE IF EXISTS test.p1; -DROP TABLE IF EXISTS test.t1; ---enable_warnings +source include/reset_master_and_slave.inc; -# Section 1 test +connection master; +let $file= $MYSQLTEST_VARDIR/tmp/bug_39701.data; -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; -delimiter |; -create procedure test.p1() -begin - INSERT INTO test.t1 VALUES(2,'test'); - UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=2; -end| -delimiter ;| +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT repeat('x',20) INTO OUTFILE '$file' -CALL test.p1(); -SELECT * FROM test.t1 ORDER BY blob_column; -save_master_pos; -sync_slave_with_master; +disable_warnings; +DROP TABLE IF EXISTS t1; +enable_warnings; + +CREATE TABLE t1 (t text); +DELIMITER |; +CREATE PROCEDURE p(file TEXT) + BEGIN + INSERT INTO t1 VALUES (LOAD_FILE(file)); + END| +DELIMITER ;| + +# stop slave before issuing the load_file on master connection slave; -# Need to allow some time when NDB engine is used for -# the injector thread to have time to populate binlog -let $wait_condition= SELECT INSTR(blob_column,'aberration') > 0 FROM test.t1 WHERE a = 2; ---source include/wait_condition.inc -SELECT * FROM test.t1 ORDER BY blob_column; +source include/stop_slave.inc; + +connection master; + +# test: check that logging falls back to rbr. +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval CALL p('$file') + +# test: remove the file from the filesystem and assert that slave still +# gets the loaded file +remove_file $file; + +# now that the file is removed it is safe (regarding what we want to test) +# to start slave +connection slave; +source include/start_slave.inc; -# Cleanup connection master; -DROP PROCEDURE IF EXISTS test.p1; -DROP TABLE test.t1; sync_slave_with_master; -# End of 5.0 test case +# assertion: assert that the slave got the updates even +# if the file was removed before the slave started, +# meaning that contents were indeed transfered +# through binlog (in row format) +let $diff_table_1=master:test.t1; +let $diff_table_2=slave:test.t1; +source include/diff_tables.inc; + +# CLEAN UP +DROP TABLE t1; +DROP PROCEDURE p; +sync_slave_with_master; diff --git a/mysql-test/suite/rpl/t/rpl_stm_loadfile.test b/mysql-test/suite/rpl/t/rpl_stm_loadfile.test new file mode 100644 index 00000000000..3db8385a2f2 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_stm_loadfile.test @@ -0,0 +1,20 @@ +############################################################################# +# Original Author: JBM # +# Original Date: Aug/18/2005 # +############################################################################# +# TEST: To test the LOAD_FILE() in rbr # +############################################################################# +# Change Author: JBM +# Change Date: 2006-01-16 +# Change: Added Order by for NDB +# Change: Split the original test file. This one forces STATEMENT only because +# when in STATEMENT mode, the load_file will issue a warning, whereas +# in RBR or MIXED mode it does not (by lsoares). +########## + +# Includes +-- source include/master-slave.inc +-- source include/have_binlog_format_statement.inc + +-- source extra/rpl_tests/rpl_loadfile.test + diff --git a/sql/item_create.cc b/sql/item_create.cc index 349c47816ad..bf359b10caa 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -3791,6 +3791,7 @@ Create_func_load_file Create_func_load_file::s_singleton; Item* Create_func_load_file::create(THD *thd, Item *arg1) { + thd->lex->set_stmt_unsafe(); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); return new (thd->mem_root) Item_load_file(arg1); } From 8d4d3e1301ed8910a21c70cdb7b9e2f468bb7af6 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Tue, 24 Mar 2009 23:44:38 +0300 Subject: [PATCH 67/88] Fix for bug #43801: mysql.test takes too long, fails due to expired timeout on debx86-b in PB Moved the resource-intensive test case for bug #41486 into a separate test file to reduce execution time for mysql.test. mysql-test/include/wait_until_disconnected.inc: Used in mysql-bug41486.test. mysql-test/r/mysql-bug41486.result: Moved the resource-intensive test case for bug #41486 into a separate test file to reduce execution time for mysql.test. mysql-test/r/mysql.result: Moved the resource-intensive test case for bug #41486 into a separate test file to reduce execution time for mysql.test. mysql-test/t/mysql-bug41486.test: Moved the resource-intensive test case for bug #41486 into a separate test file to reduce execution time for mysql.test. mysql-test/t/mysql.test: Moved the resource-intensive test case for bug #41486 into a separate test file to reduce execution time for mysql.test. --- .../include/wait_until_disconnected.inc | 21 +++++++++ mysql-test/r/mysql-bug41486.result | 10 +++++ mysql-test/r/mysql.result | 9 ---- mysql-test/t/mysql-bug41486.test | 45 +++++++++++++++++++ mysql-test/t/mysql.test | 33 -------------- 5 files changed, 76 insertions(+), 42 deletions(-) create mode 100644 mysql-test/include/wait_until_disconnected.inc create mode 100644 mysql-test/r/mysql-bug41486.result create mode 100644 mysql-test/t/mysql-bug41486.test diff --git a/mysql-test/include/wait_until_disconnected.inc b/mysql-test/include/wait_until_disconnected.inc new file mode 100644 index 00000000000..a4362e52d01 --- /dev/null +++ b/mysql-test/include/wait_until_disconnected.inc @@ -0,0 +1,21 @@ +# +# Include this script to wait until the connection to the +# server has been dropped +--disable_result_log +--disable_query_log +let $counter= 500; +let $mysql_errno= 0; +while (!$mysql_errno) +{ + --error 0,1053,2002,2006,2013 + show status; + + dec $counter; + if (!$counter) + { + --die Server failed to dissapear + } + --sleep 0.1 +} +--enable_query_log +--enable_result_log diff --git a/mysql-test/r/mysql-bug41486.result b/mysql-test/r/mysql-bug41486.result new file mode 100644 index 00000000000..454b5888b49 --- /dev/null +++ b/mysql-test/r/mysql-bug41486.result @@ -0,0 +1,10 @@ +DROP TABLE IF EXISTS t1; +SET @old_max_allowed_packet= @@global.max_allowed_packet; +SET @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024; +CREATE TABLE t1(data LONGBLOB); +INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024); +SELECT LENGTH(data) FROM t1; +LENGTH(data) +2097152 +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 cef5e08ec6b..10537f6da16 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -192,13 +192,4 @@ delimiter 1 1 1 -set @old_max_allowed_packet = @@global.max_allowed_packet; -set @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024; -CREATE TABLE t1(data LONGBLOB); -INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024); -SELECT LENGTH(data) FROM t1; -LENGTH(data) -2097152 -DROP TABLE t1; -set @@global.max_allowed_packet = @old_max_allowed_packet; End of 5.0 tests diff --git a/mysql-test/t/mysql-bug41486.test b/mysql-test/t/mysql-bug41486.test new file mode 100644 index 00000000000..805c0f99480 --- /dev/null +++ b/mysql-test/t/mysql-bug41486.test @@ -0,0 +1,45 @@ +# +# Bug#41486 extra character appears in BLOB for every ~40Mb after +# mysqldump/import +# +# 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 +# + +--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; +# 2 MB blob length + some space for the rest of INSERT query +SET @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024; + +# Create a new connection since the global max_allowed_packet +# has no effect for the current connection +connect (con1, localhost, root,,); + +CREATE TABLE t1(data LONGBLOB); +INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024); + +let $outfile= $MYSQLTEST_VARDIR/tmp/bug41486.sql; +--error 0,1 +remove_file $outfile; +--exec $MYSQL_DUMP test t1 > $outfile +# Check that the mysql client does not insert extra newlines when loading +# strings longer than client's max_allowed_packet +--exec $MYSQL --max_allowed_packet=1M test < $outfile 2>&1 +SELECT LENGTH(data) FROM t1; + +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 f352c08fb5b..594d10e46a5 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -331,37 +331,4 @@ EOF remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql; -# -# Bug #41486: extra character appears in BLOB for every ~40Mb after -# mysqldump/import -# - -# Have to change the global variable as the session variable is -# read-only. -set @old_max_allowed_packet = @@global.max_allowed_packet; -# 2 MB blob length + some space for the rest of INSERT query -set @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024; - -# Create a new connection since the global max_allowed_packet -# has no effect for the current connection -connect (con1, localhost, root,,); -connection con1; - -CREATE TABLE t1(data LONGBLOB); -INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024); - ---exec $MYSQL_DUMP test t1 >$MYSQLTEST_VARDIR/tmp/bug41486.sql -# Check that the mysql client does not insert extra newlines when loading -# strings longer than client's max_allowed_packet ---exec $MYSQL --max_allowed_packet=1M test < $MYSQLTEST_VARDIR/tmp/bug41486.sql 2>&1 -SELECT LENGTH(data) FROM t1; - -remove_file $MYSQLTEST_VARDIR/tmp/bug41486.sql; -DROP TABLE t1; - -connection default; -disconnect con1; - -set @@global.max_allowed_packet = @old_max_allowed_packet; - --echo End of 5.0 tests From a49b057dc40391205d7428e1676e245053e75e42 Mon Sep 17 00:00:00 2001 From: Leonard Zhou Date: Wed, 25 Mar 2009 14:19:42 +0800 Subject: [PATCH 68/88] Fix test case erro in sles10-ia64-a. Reset master before next test. mysql-test/suite/rpl/r/rpl_timezone.result: Test result. mysql-test/suite/rpl/t/rpl_timezone.test: Reset master before next test. --- mysql-test/suite/rpl/r/rpl_timezone.result | 1 + mysql-test/suite/rpl/t/rpl_timezone.test | 1 + 2 files changed, 2 insertions(+) diff --git a/mysql-test/suite/rpl/r/rpl_timezone.result b/mysql-test/suite/rpl/r/rpl_timezone.result index f5e05bcb759..0b5c03b5300 100644 --- a/mysql-test/suite/rpl/r/rpl_timezone.result +++ b/mysql-test/suite/rpl/r/rpl_timezone.result @@ -122,6 +122,7 @@ a b SET @@session.time_zone = default; DROP TABLE t1; SET @@session.time_zone = default; +reset master; CREATE TABLE t1 (date timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, a int(11) default NULL); SET @@session.time_zone='+01:00'; insert into t1 values('2008-12-23 19:39:39',1); diff --git a/mysql-test/suite/rpl/t/rpl_timezone.test b/mysql-test/suite/rpl/t/rpl_timezone.test index 85f60ae01cf..40a2a4444b9 100644 --- a/mysql-test/suite/rpl/t/rpl_timezone.test +++ b/mysql-test/suite/rpl/t/rpl_timezone.test @@ -170,6 +170,7 @@ SET @@session.time_zone = default; # Insert 2 values into timestamp col with different time_zone. Check result. --connection master +reset master; CREATE TABLE t1 (date timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, a int(11) default NULL); SET @@session.time_zone='+01:00'; From d61ae8167f1f97fad4057acb6596d79d51b01559 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 25 Mar 2009 10:32:01 +0300 Subject: [PATCH 69/88] Fix for bug #43801: mysql.test takes too long, fails due to expired timeout on debx86-b in PB Turned off general log when importing DB dump in the test case for bug #41486 due to the bug in CSV engine code that makes logging long SQL query too slow. mysql-test/r/mysql-bug41486.result: Turned off general log when importing DB dump in the test case for bug #41486 due to the bug in CSV engine code that makes logging long SQL query too slow. mysql-test/t/mysql-bug41486.test: Turned off general log when importing DB dump in the test case for bug #41486 due to the bug in CSV engine code that makes logging long SQL query too slow. --- mysql-test/r/mysql-bug41486.result | 3 +++ mysql-test/t/mysql-bug41486.test | 3 +++ 2 files changed, 6 insertions(+) diff --git a/mysql-test/r/mysql-bug41486.result b/mysql-test/r/mysql-bug41486.result index 454b5888b49..02777ab587f 100644 --- a/mysql-test/r/mysql-bug41486.result +++ b/mysql-test/r/mysql-bug41486.result @@ -3,6 +3,9 @@ SET @old_max_allowed_packet= @@global.max_allowed_packet; SET @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024; CREATE TABLE t1(data LONGBLOB); INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024); +SET @old_general_log = @@global.general_log; +SET @@global.general_log = 0; +SET @@global.general_log = @old_general_log; SELECT LENGTH(data) FROM t1; LENGTH(data) 2097152 diff --git a/mysql-test/t/mysql-bug41486.test b/mysql-test/t/mysql-bug41486.test index 805c0f99480..7ea9f6d81c7 100644 --- a/mysql-test/t/mysql-bug41486.test +++ b/mysql-test/t/mysql-bug41486.test @@ -30,9 +30,12 @@ let $outfile= $MYSQLTEST_VARDIR/tmp/bug41486.sql; --error 0,1 remove_file $outfile; --exec $MYSQL_DUMP test t1 > $outfile +SET @old_general_log = @@global.general_log; +SET @@global.general_log = 0; # Check that the mysql client does not insert extra newlines when loading # strings longer than client's max_allowed_packet --exec $MYSQL --max_allowed_packet=1M test < $outfile 2>&1 +SET @@global.general_log = @old_general_log; SELECT LENGTH(data) FROM t1; DROP TABLE t1; From 79ad0a2c93a5be4cd6fd53dc9a7aa2dd5757ede8 Mon Sep 17 00:00:00 2001 From: Leonard Zhou Date: Wed, 25 Mar 2009 16:19:09 +0800 Subject: [PATCH 70/88] Fix the test case error in PB. --- mysql-test/r/rpl_timezone.result | 1 + mysql-test/t/rpl_timezone.test | 1 + 2 files changed, 2 insertions(+) diff --git a/mysql-test/r/rpl_timezone.result b/mysql-test/r/rpl_timezone.result index 2b179c0dc4a..ac23fb2ccd2 100644 --- a/mysql-test/r/rpl_timezone.result +++ b/mysql-test/r/rpl_timezone.result @@ -153,6 +153,7 @@ a b SET @@session.time_zone = default; DROP TABLE t1; SET @@session.time_zone = default; +reset master; CREATE TABLE t1 (date timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, a int(11) default NULL); SET @@session.time_zone='+01:00'; insert into t1 values('2008-12-23 19:39:39',1); diff --git a/mysql-test/t/rpl_timezone.test b/mysql-test/t/rpl_timezone.test index efe56155659..d62dba52c0a 100644 --- a/mysql-test/t/rpl_timezone.test +++ b/mysql-test/t/rpl_timezone.test @@ -159,6 +159,7 @@ SET @@session.time_zone = default; # Insert 2 values into timestamp col with different time_zone. Check result. --connection master +reset master; CREATE TABLE t1 (date timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, a int(11) default NULL); SET @@session.time_zone='+01:00'; From 1be22714122c09115b5d5930031e43e9240d1d01 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 25 Mar 2009 11:47:41 +0300 Subject: [PATCH 71/88] Disabled embedded server in the test case for bug #41486. --- mysql-test/t/mysql-bug41486.test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/t/mysql-bug41486.test b/mysql-test/t/mysql-bug41486.test index 7ea9f6d81c7..6e014bca7d1 100644 --- a/mysql-test/t/mysql-bug41486.test +++ b/mysql-test/t/mysql-bug41486.test @@ -9,6 +9,8 @@ # on debx86-b in PB # +-- source include/not_embedded.inc + --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings From 67f9a6d1782ff9f00769816fdf3dfb1e9763bba7 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Wed, 25 Mar 2009 12:53:56 +0200 Subject: [PATCH 72/88] Bug#42977 RBR logs for rows with more than 250 column results in corrupt binlog The issue happened to be two-fold. The table map event was recorded into binlog having an incorrect size when number of columns exceeded 251. The Row-based event had incorrect recording and restoring m_width member within the same as above conditions. Fixed with correcting m_data_size and m_width. mysql-test/suite/rpl/r/rpl_row_wide_table.result: the new test results. mysql-test/suite/rpl/t/rpl_row_wide_table.test: regression test for bug#42977. sql/log_event.cc: 0. all buffers that used in net_store_length() are augmented with 1 for safety to be able to contain the magic and the content of ulonglong as well; 1. Rows_log_event::get_data_size() yieled incorrect size |m_width/8| whereas it should be m_width; 2. Table_map_log_event::Table_map_log_event yieled incorrect value for `m_data_size' probably presuming 1-byte integer max for the column number; sql/rpl_utility.h: DBUG_PRINT_BITSET() macro is left 256-cols limited but has made safe and commented. --- .../suite/rpl/r/rpl_row_wide_table.result | 318 ++++++++++++++++ .../suite/rpl/t/rpl_row_wide_table.test | 339 ++++++++++++++++++ sql/log_event.cc | 14 +- sql/rpl_utility.h | 6 +- 4 files changed, 670 insertions(+), 7 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_row_wide_table.result create mode 100644 mysql-test/suite/rpl/t/rpl_row_wide_table.test diff --git a/mysql-test/suite/rpl/r/rpl_row_wide_table.result b/mysql-test/suite/rpl/r/rpl_row_wide_table.result new file mode 100644 index 00000000000..da96e84d1d5 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_row_wide_table.result @@ -0,0 +1,318 @@ +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 TABLE IF EXISTS t300; +create table t300 ( +f1 int, +f2 int, +f3 int, +f4 int, +f5 int, +f6 int, +f7 int, +f8 int, +f9 int, +f10 int, +f11 int, +f12 int, +f13 int, +f14 int, +f15 int, +f16 int, +f17 int, +f18 int, +f19 int, +f20 int, +f21 int, +f22 int, +f23 int, +f24 int, +f25 int, +f26 int, +f27 int, +f28 int, +f29 int, +f30 int, +f31 int, +f32 int, +f33 int, +f34 int, +f35 int, +f36 int, +f37 int, +f38 int, +f39 int, +f40 int, +f41 int, +f42 int, +f43 int, +f44 int, +f45 int, +f46 int, +f47 int, +f48 int, +f49 int, +f50 int, +f51 int, +f52 int, +f53 int, +f54 int, +f55 int, +f56 int, +f57 int, +f58 int, +f59 int, +f60 int, +f61 int, +f62 int, +f63 int, +f64 int, +f65 int, +f66 int, +f67 int, +f68 int, +f69 int, +f70 int, +f71 int, +f72 int, +f73 int, +f74 int, +f75 int, +f76 int, +f77 int, +f78 int, +f79 int, +f80 int, +f81 int, +f82 int, +f83 int, +f84 int, +f85 int, +f86 int, +f87 int, +f88 int, +f89 int, +f90 int, +f91 int, +f92 int, +f93 int, +f94 int, +f95 int, +f96 int, +f97 int, +f98 int, +f99 int, +f100 int, +f101 int, +f102 int, +f103 int, +f104 int, +f105 int, +f106 int, +f107 int, +f108 int, +f109 int, +f110 int, +f111 int, +f112 int, +f113 int, +f114 int, +f115 int, +f116 int, +f117 int, +f118 int, +f119 int, +f120 int, +f121 int, +f122 int, +f123 int, +f124 int, +f125 int, +f126 int, +f127 int, +f128 int, +f129 int, +f130 int, +f131 int, +f132 int, +f133 int, +f134 int, +f135 int, +f136 int, +f137 int, +f138 int, +f139 int, +f140 int, +f141 int, +f142 int, +f143 int, +f144 int, +f145 int, +f146 int, +f147 int, +f148 int, +f149 int, +f150 int, +f151 int, +f152 int, +f153 int, +f154 int, +f155 int, +f156 int, +f157 int, +f158 int, +f159 int, +f160 int, +f161 int, +f162 int, +f163 int, +f164 int, +f165 int, +f166 int, +f167 int, +f168 int, +f169 int, +f170 int, +f171 int, +f172 int, +f173 int, +f174 int, +f175 int, +f176 int, +f177 int, +f178 int, +f179 int, +f180 int, +f181 int, +f182 int, +f183 int, +f184 int, +f185 int, +f186 int, +f187 int, +f188 int, +f189 int, +f190 int, +f191 int, +f192 int, +f193 int, +f194 int, +f195 int, +f196 int, +f197 int, +f198 int, +f199 int, +f200 int, +f201 int, +f202 int, +f203 int, +f204 int, +f205 int, +f206 int, +f207 int, +f208 int, +f209 int, +f210 int, +f211 int, +f212 int, +f213 int, +f214 int, +f215 int, +f216 int, +f217 int, +f218 int, +f219 int, +f220 int, +f221 int, +f222 int, +f223 int, +f224 int, +f225 int, +f226 int, +f227 int, +f228 int, +f229 int, +f230 int, +f231 int, +f232 int, +f233 int, +f234 int, +f235 int, +f236 int, +f237 int, +f238 int, +f239 int, +f240 int, +f241 int, +f242 int, +f243 int, +f244 int, +f245 int, +f246 int, +f247 int, +f248 int, +f249 int, +f250 int, +f251 int, +f252 int, +f253 int, +f254 int, +f255 int, +f256 int, +f257 int, +f258 int, +f259 int, +f260 int, +f261 int, +f262 int, +f263 int, +f264 int, +f265 int, +f266 int, +f267 int, +f268 int, +f269 int, +f270 int, +f271 int, +f272 int, +f273 int, +f274 int, +f275 int, +f276 int, +f277 int, +f278 int, +f279 int, +f280 int, +f281 int, +f282 int, +f283 int, +f284 int, +f285 int, +f286 int, +f287 int, +f288 int, +f289 int, +f290 int, +f291 int, +f292 int, +f293 int, +f294 int, +f295 int, +f296 int, +f297 int, +f298 int, +f299 int, +f300 int, +primary key (f1)); +insert into t300 set f1= 1; +select f300 from t300; +f300 +NULL +select count(*) as one from t300; +one +1 +*** Cleanup *** +DROP TABLE t300; diff --git a/mysql-test/suite/rpl/t/rpl_row_wide_table.test b/mysql-test/suite/rpl/t/rpl_row_wide_table.test new file mode 100644 index 00000000000..7b17d7c4866 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_row_wide_table.test @@ -0,0 +1,339 @@ +################################################################## +# rpl_row_wide_table +# +# This test verifies that the table with number of attributes more +# than 250 is replicated. +# Related bugs: +# Bug #42977 RBR logs for rows with more than 250 column results +# in corrupt binlog +################################################################## + +-- source include/master-slave.inc +-- source include/have_binlog_format_row.inc + +--disable_warnings +DROP TABLE IF EXISTS t300; +--enable_warnings + +connection master; + +create table t300 ( +f1 int, +f2 int, +f3 int, +f4 int, +f5 int, +f6 int, +f7 int, +f8 int, +f9 int, +f10 int, +f11 int, +f12 int, +f13 int, +f14 int, +f15 int, +f16 int, +f17 int, +f18 int, +f19 int, +f20 int, +f21 int, +f22 int, +f23 int, +f24 int, +f25 int, +f26 int, +f27 int, +f28 int, +f29 int, +f30 int, +f31 int, +f32 int, +f33 int, +f34 int, +f35 int, +f36 int, +f37 int, +f38 int, +f39 int, +f40 int, +f41 int, +f42 int, +f43 int, +f44 int, +f45 int, +f46 int, +f47 int, +f48 int, +f49 int, +f50 int, +f51 int, +f52 int, +f53 int, +f54 int, +f55 int, +f56 int, +f57 int, +f58 int, +f59 int, +f60 int, +f61 int, +f62 int, +f63 int, +f64 int, +f65 int, +f66 int, +f67 int, +f68 int, +f69 int, +f70 int, +f71 int, +f72 int, +f73 int, +f74 int, +f75 int, +f76 int, +f77 int, +f78 int, +f79 int, +f80 int, +f81 int, +f82 int, +f83 int, +f84 int, +f85 int, +f86 int, +f87 int, +f88 int, +f89 int, +f90 int, +f91 int, +f92 int, +f93 int, +f94 int, +f95 int, +f96 int, +f97 int, +f98 int, +f99 int, +f100 int, +f101 int, +f102 int, +f103 int, +f104 int, +f105 int, +f106 int, +f107 int, +f108 int, +f109 int, +f110 int, +f111 int, +f112 int, +f113 int, +f114 int, +f115 int, +f116 int, +f117 int, +f118 int, +f119 int, +f120 int, +f121 int, +f122 int, +f123 int, +f124 int, +f125 int, +f126 int, +f127 int, +f128 int, +f129 int, +f130 int, +f131 int, +f132 int, +f133 int, +f134 int, +f135 int, +f136 int, +f137 int, +f138 int, +f139 int, +f140 int, +f141 int, +f142 int, +f143 int, +f144 int, +f145 int, +f146 int, +f147 int, +f148 int, +f149 int, +f150 int, +f151 int, +f152 int, +f153 int, +f154 int, +f155 int, +f156 int, +f157 int, +f158 int, +f159 int, +f160 int, +f161 int, +f162 int, +f163 int, +f164 int, +f165 int, +f166 int, +f167 int, +f168 int, +f169 int, +f170 int, +f171 int, +f172 int, +f173 int, +f174 int, +f175 int, +f176 int, +f177 int, +f178 int, +f179 int, +f180 int, +f181 int, +f182 int, +f183 int, +f184 int, +f185 int, +f186 int, +f187 int, +f188 int, +f189 int, +f190 int, +f191 int, +f192 int, +f193 int, +f194 int, +f195 int, +f196 int, +f197 int, +f198 int, +f199 int, +f200 int, +f201 int, +f202 int, +f203 int, +f204 int, +f205 int, +f206 int, +f207 int, +f208 int, +f209 int, +f210 int, +f211 int, +f212 int, +f213 int, +f214 int, +f215 int, +f216 int, +f217 int, +f218 int, +f219 int, +f220 int, +f221 int, +f222 int, +f223 int, +f224 int, +f225 int, +f226 int, +f227 int, +f228 int, +f229 int, +f230 int, +f231 int, +f232 int, +f233 int, +f234 int, +f235 int, +f236 int, +f237 int, +f238 int, +f239 int, +f240 int, +f241 int, +f242 int, +f243 int, +f244 int, +f245 int, +f246 int, +f247 int, +f248 int, +f249 int, +f250 int, +f251 int, +f252 int, +f253 int, +f254 int, +f255 int, +f256 int, +f257 int, +f258 int, +f259 int, +f260 int, +f261 int, +f262 int, +f263 int, +f264 int, +f265 int, +f266 int, +f267 int, +f268 int, +f269 int, +f270 int, +f271 int, +f272 int, +f273 int, +f274 int, +f275 int, +f276 int, +f277 int, +f278 int, +f279 int, +f280 int, +f281 int, +f282 int, +f283 int, +f284 int, +f285 int, +f286 int, +f287 int, +f288 int, +f289 int, +f290 int, +f291 int, +f292 int, +f293 int, +f294 int, +f295 int, +f296 int, +f297 int, +f298 int, +f299 int, +f300 int, + primary key (f1)); + +insert into t300 set f1= 1; + +sync_slave_with_master; + +# +# prove that slave processed the create as well as the insert +# +eval select f300 from t300; +select count(*) as one from t300; + +--echo *** Cleanup *** +connection master; +DROP TABLE t300; +sync_slave_with_master; + +# END of Test Case + diff --git a/sql/log_event.cc b/sql/log_event.cc index aa7e8c84a0f..6220bc276a6 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -6993,8 +6993,8 @@ int Rows_log_event::get_data_size() { int const type_code= get_type_code(); - uchar buf[sizeof(m_width)+1]; - uchar *end= net_store_length(buf, (m_width + 7) / 8); + uchar buf[sizeof(m_width) + 1]; + uchar *end= net_store_length(buf, m_width); DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", return 6 + no_bytes_in_map(&m_cols) + (end - buf) + @@ -7583,7 +7583,7 @@ bool Rows_log_event::write_data_body(IO_CACHE*file) Note that this should be the number of *bits*, not the number of bytes. */ - uchar sbuf[sizeof(m_width)]; + uchar sbuf[sizeof(m_width) + 1]; my_ptrdiff_t const data_size= m_rows_cur - m_rows_buf; bool res= false; uchar *const sbuf_end= net_store_length(sbuf, (size_t) m_width); @@ -7745,6 +7745,8 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, m_null_bits(0), m_meta_memory(NULL) { + uchar cbuf[sizeof(m_colcnt) + 1]; + uchar *cbuf_end; DBUG_ASSERT(m_table_id != ~0UL); /* In TABLE_SHARE, "db" and "table_name" are 0-terminated (see this comment in @@ -7761,7 +7763,9 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", m_data_size= 6;); m_data_size+= m_dblen + 2; // Include length and terminating \0 m_data_size+= m_tbllen + 2; // Include length and terminating \0 - m_data_size+= 1 + m_colcnt; // COLCNT and column types + cbuf_end= net_store_length(cbuf, (size_t) m_colcnt); + DBUG_ASSERT((cbuf_end - cbuf) <= sizeof(cbuf)); + m_data_size+= (cbuf_end - cbuf) + m_colcnt; // COLCNT and column types /* If malloc fails, caught in is_valid() */ if ((m_memory= (uchar*) my_malloc(m_colcnt, MYF(MY_WME)))) @@ -8053,7 +8057,7 @@ bool Table_map_log_event::write_data_body(IO_CACHE *file) uchar const dbuf[]= { (uchar) m_dblen }; uchar const tbuf[]= { (uchar) m_tbllen }; - uchar cbuf[sizeof(m_colcnt)]; + uchar cbuf[sizeof(m_colcnt) + 1]; uchar *const cbuf_end= net_store_length(cbuf, (size_t) m_colcnt); DBUG_ASSERT(static_cast(cbuf_end - cbuf) <= sizeof(cbuf)); diff --git a/sql/rpl_utility.h b/sql/rpl_utility.h index 8e2f4a7374f..1f4ca246ff1 100644 --- a/sql/rpl_utility.h +++ b/sql/rpl_utility.h @@ -294,12 +294,14 @@ namespace { } #endif +// NB. number of printed bit values is limited to sizeof(buf) - 1 #define DBUG_PRINT_BITSET(N,FRM,BS) \ do { \ char buf[256]; \ - for (uint i = 0 ; i < (BS)->n_bits ; ++i) \ + uint i; \ + for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \ buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \ - buf[(BS)->n_bits] = '\0'; \ + buf[i] = '\0'; \ DBUG_PRINT((N), ((FRM), buf)); \ } while (0) From 9536bd657b2c6d3228009189c7c17a028342b8f5 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 25 Mar 2009 15:37:21 +0200 Subject: [PATCH 73/88] Bug#43748: crash when non-super user tries to kill the replication threads (Pushing for Azundris) We allow security-contexts with NULL users (for system-threads and for unauthenticated users). If a non-SUPER-user tried to KILL such a thread, we tried to compare the user-fields to see whether they owned that thread. Comparing against NULL was not a good idea. If KILLer does not have SUPER-privilege, we specifically check whether both KILLer and KILLee have a non-NULL user before testing for string- equality. If either is NULL, we reject the KILL. mysql-test/r/rpl_temporary.result: Try to have a non-SUPER user KILL a system thread. mysql-test/t/rpl_temporary.test: Try to have a non-SUPER user KILL a system thread. sql/sql_parse.cc: Make sure security contexts of both KILLer *and* KILLee are non-NULL before testing for string-equality! --- mysql-test/r/rpl_temporary.result | 18 ++++++++++++++++ mysql-test/t/rpl_temporary.test | 36 +++++++++++++++++++++++++++++++ sql/sql_parse.cc | 21 +++++++++++++++++- 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/rpl_temporary.result b/mysql-test/r/rpl_temporary.result index 15c069ab68d..5eefced7564 100644 --- a/mysql-test/r/rpl_temporary.result +++ b/mysql-test/r/rpl_temporary.result @@ -4,6 +4,24 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; +FLUSH PRIVILEGES; +drop table if exists t999; +create temporary table t999( +id int, +user char(255), +host char(255), +db char(255), +Command char(255), +time int, +State char(255), +info char(255) +); +LOAD DATA INFILE "./tmp/bl_dump_thread_id" into table t999; +drop table t999; +GRANT USAGE ON *.* TO user43748@localhost; +KILL `select id from information_schema.processlist where command='Binlog Dump'`; +ERROR HY000: You are not owner of thread `select id from information_schema.processlist where command='Binlog Dump'` +DROP USER user43748@localhost; reset master; SET @save_select_limit=@@session.sql_select_limit; SET @@session.sql_select_limit=10, @@session.pseudo_thread_id=100; diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index 516f3a026c9..366fdf00c56 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -3,6 +3,42 @@ source include/add_anonymous_users.inc; source include/master-slave.inc; +# +# Bug#43748: crash when non-super user tries to kill the replication threads +# + +--connection master +save_master_pos; + +--connection slave +sync_with_master; + +--connection slave +FLUSH PRIVILEGES; + +# in 5.0, we need to do some hocus pocus to get a system-thread ID (-> $id) +--source include/get_binlog_dump_thread_id.inc + +# make a non-privileged user on slave. try to KILL system-thread as her. +GRANT USAGE ON *.* TO user43748@localhost; + +--connect (mysqltest_2_con,localhost,user43748,,test,$SLAVE_MYPORT,) +--connection mysqltest_2_con + +--replace_result $id "`select id from information_schema.processlist where command='Binlog Dump'`" +--error ER_KILL_DENIED_ERROR +eval KILL $id; + +--disconnect mysqltest_2_con + +--connection slave + +DROP USER user43748@localhost; + +--connection master + + + # Clean up old slave's binlogs. # The slave is started with --log-slave-updates # and this test does SHOW BINLOG EVENTS on the slave's diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2297283c92d..33adcfe3342 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7386,8 +7386,27 @@ void kill_one_thread(THD *thd, ulong id, bool only_kill_query) VOID(pthread_mutex_unlock(&LOCK_thread_count)); if (tmp) { + + /* + If we're SUPER, we can KILL anything, including system-threads. + No further checks. + + thd..user could in theory be NULL while we're still in + "unauthenticated" state. This is more a theoretical case. + + tmp..user will be NULL for system threads (cf Bug#43748). + We need to check so Jane Random User doesn't crash the server + when trying to kill a) system threads or b) unauthenticated + users' threads. + + If user of both killer and killee are non-null, proceed with + slayage if both are string-equal. + */ + if ((thd->security_ctx->master_access & SUPER_ACL) || - !strcmp(thd->security_ctx->user, tmp->security_ctx->user)) + ((thd->security_ctx->user != NULL) && + (tmp->security_ctx->user != NULL) && + !strcmp(thd->security_ctx->user, tmp->security_ctx->user))) { tmp->awake(only_kill_query ? THD::KILL_QUERY : THD::KILL_CONNECTION); error=0; From e46c139dd81081aceb27902ee4b632904cae292b Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Wed, 25 Mar 2009 17:10:27 +0100 Subject: [PATCH 74/88] Bug#43748: crash when non-super user tries to kill the replication threads Fine-tuning. Broke out comparison into method by suggestion of Davi. Clarified comments. Reverting test-case which I find too brittle; proper test case in 5.1+. --- mysql-test/r/rpl_temporary.result | 18 ---------------- mysql-test/t/rpl_temporary.test | 36 ------------------------------- sql/sql_class.cc | 7 ++++++ sql/sql_class.h | 1 + sql/sql_parse.cc | 17 +++++++-------- 5 files changed, 16 insertions(+), 63 deletions(-) diff --git a/mysql-test/r/rpl_temporary.result b/mysql-test/r/rpl_temporary.result index 5eefced7564..15c069ab68d 100644 --- a/mysql-test/r/rpl_temporary.result +++ b/mysql-test/r/rpl_temporary.result @@ -4,24 +4,6 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; -FLUSH PRIVILEGES; -drop table if exists t999; -create temporary table t999( -id int, -user char(255), -host char(255), -db char(255), -Command char(255), -time int, -State char(255), -info char(255) -); -LOAD DATA INFILE "./tmp/bl_dump_thread_id" into table t999; -drop table t999; -GRANT USAGE ON *.* TO user43748@localhost; -KILL `select id from information_schema.processlist where command='Binlog Dump'`; -ERROR HY000: You are not owner of thread `select id from information_schema.processlist where command='Binlog Dump'` -DROP USER user43748@localhost; reset master; SET @save_select_limit=@@session.sql_select_limit; SET @@session.sql_select_limit=10, @@session.pseudo_thread_id=100; diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index 366fdf00c56..516f3a026c9 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -3,42 +3,6 @@ source include/add_anonymous_users.inc; source include/master-slave.inc; -# -# Bug#43748: crash when non-super user tries to kill the replication threads -# - ---connection master -save_master_pos; - ---connection slave -sync_with_master; - ---connection slave -FLUSH PRIVILEGES; - -# in 5.0, we need to do some hocus pocus to get a system-thread ID (-> $id) ---source include/get_binlog_dump_thread_id.inc - -# make a non-privileged user on slave. try to KILL system-thread as her. -GRANT USAGE ON *.* TO user43748@localhost; - ---connect (mysqltest_2_con,localhost,user43748,,test,$SLAVE_MYPORT,) ---connection mysqltest_2_con - ---replace_result $id "`select id from information_schema.processlist where command='Binlog Dump'`" ---error ER_KILL_DENIED_ERROR -eval KILL $id; - ---disconnect mysqltest_2_con - ---connection slave - -DROP USER user43748@localhost; - ---connection master - - - # Clean up old slave's binlogs. # The slave is started with --log-slave-updates # and this test does SHOW BINLOG EVENTS on the slave's diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 74bc669a049..aa796d6acbd 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2144,6 +2144,13 @@ void Security_context::skip_grants() } +bool Security_context::user_matches(Security_context *them) +{ + return ((user != NULL) && (them->user != NULL) && + !strcmp(user, them->user)); +} + + /**************************************************************************** Handling of open and locked tables states. diff --git a/sql/sql_class.h b/sql/sql_class.h index 3e3dfcd08fa..47dbac0f17b 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -985,6 +985,7 @@ public: { return (*priv_host ? priv_host : (char *)"%"); } + bool user_matches(Security_context *); }; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 33adcfe3342..c2d789b30b5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7391,22 +7391,21 @@ void kill_one_thread(THD *thd, ulong id, bool only_kill_query) If we're SUPER, we can KILL anything, including system-threads. No further checks. - thd..user could in theory be NULL while we're still in - "unauthenticated" state. This is more a theoretical case. + KILLer: thd->security_ctx->user could in theory be NULL while + we're still in "unauthenticated" state. This is a theoretical + case (the code suggests this could happen, so we play it safe). - tmp..user will be NULL for system threads (cf Bug#43748). + KILLee: tmp->security_ctx->user will be NULL for system threads. We need to check so Jane Random User doesn't crash the server - when trying to kill a) system threads or b) unauthenticated - users' threads. + when trying to kill a) system threads or b) unauthenticated users' + threads (Bug#43748). - If user of both killer and killee are non-null, proceed with + If user of both killer and killee are non-NULL, proceed with slayage if both are string-equal. */ if ((thd->security_ctx->master_access & SUPER_ACL) || - ((thd->security_ctx->user != NULL) && - (tmp->security_ctx->user != NULL) && - !strcmp(thd->security_ctx->user, tmp->security_ctx->user))) + thd->security_ctx->user_matches(tmp->security_ctx)) { tmp->awake(only_kill_query ? THD::KILL_QUERY : THD::KILL_CONNECTION); error=0; From bce4c76ae0365f3f80edccc96b26f76f0090b64d Mon Sep 17 00:00:00 2001 From: Ramil Kalimullin Date: Wed, 25 Mar 2009 20:48:10 +0400 Subject: [PATCH 75/88] Fix for bug#35383: binlog playback and replication breaks due to name_const substitution Problem: "In general, statements executed within a stored procedure are written to the binary log using the same rules that would apply were the statements to be executed in standalone fashion. Some special care is taken when logging procedure statements because statement execution within procedures is not quite the same as in non-procedure context". For example, each reference to a local variable in SP's statements is replaced by NAME_CONST(var_name, var_value). Queries like "CREATE TABLE ... SELECT FUNC(local_var ..." are logged as "CREATE TABLE ... SELECT FUNC(NAME_CONST("local_var", var_value) ..." that leads to differrent field names and might result in "Incorrect column name" if var_value is long enough. Fix: in 5.x we'll issue a warning in such a case. In 6.0 we should get rid of NAME_CONST(). Note: this issue and change should be described in the documentation ("Binary Logging of Stored Programs"). mysql-test/r/binlog.result: Fix for bug#35383: binlog playback and replication breaks due to name_const substitution - test result. mysql-test/t/binlog.test: Fix for bug#35383: binlog playback and replication breaks due to name_const substitution - test case. sql/sp_head.cc: Fix for bug#35383: binlog playback and replication breaks due to name_const substitution - set thd->query_name_consts if there's NAME_CONST() substitution(s). sql/sql_parse.cc: Fix for bug#35383: binlog playback and replication breaks due to name_const substitution - issue a warning if there's NAME_CONST() substitution and binary logging is on for "CREATE TABLE ... SELECT ...". --- mysql-test/r/binlog.result | 40 ++++++++++++++++++++++++++++++++++++++ mysql-test/t/binlog.test | 40 ++++++++++++++++++++++++++++++++++++++ sql/sp_head.cc | 5 +++++ sql/sql_class.cc | 1 + sql/sql_class.h | 3 +++ sql/sql_parse.cc | 36 ++++++++++++++++++++++++++++++++++ 6 files changed, 125 insertions(+) diff --git a/mysql-test/r/binlog.result b/mysql-test/r/binlog.result index 80890a19b86..baab30ebbdd 100644 --- a/mysql-test/r/binlog.result +++ b/mysql-test/r/binlog.result @@ -604,6 +604,8 @@ END// CALL p1(); c1 c2 c3 d1 d2 d3 utf8_general_ci utf8_unicode_ci utf8_unicode_ci 2 2 2 +Warnings: +Warning 1105 Invoked routine ran a statement that may cause problems with binary log, see 'NAME_CONST issues' in 'Binary Logging of Stored Programs' section of the manual. SHOW BINLOG EVENTS FROM 1285; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 1285 Query 1 1483 use `bug39182`; CREATE TEMPORARY TABLE tmp1 @@ -613,4 +615,42 @@ DROP PROCEDURE p1; DROP TABLE t1; DROP DATABASE bug39182; USE test; +CREATE PROCEDURE p1(IN v1 INT) +BEGIN +CREATE TABLE t1 SELECT v1; +DROP TABLE t1; +END// +CREATE PROCEDURE p2() +BEGIN +DECLARE v1 INT; +CREATE TABLE t1 SELECT v1+1; +DROP TABLE t1; +END// +CREATE PROCEDURE p3(IN v1 INT) +BEGIN +CREATE TABLE t1 SELECT 1 FROM DUAL WHERE v1!=0; +DROP TABLE t1; +END// +CREATE PROCEDURE p4(IN v1 INT) +BEGIN +DECLARE v2 INT; +CREATE TABLE t1 SELECT 1, v1, v2; +DROP TABLE t1; +CREATE TABLE t1 SELECT 1, v1+1, v2; +DROP TABLE t1; +END// +CALL p1(1); +CALL p2(); +Warnings: +Warning 1105 Invoked routine ran a statement that may cause problems with binary log, see 'NAME_CONST issues' in 'Binary Logging of Stored Programs' section of the manual. +CALL p3(0); +Warnings: +Warning 1105 Invoked routine ran a statement that may cause problems with binary log, see 'NAME_CONST issues' in 'Binary Logging of Stored Programs' section of the manual. +CALL p4(0); +Warnings: +Warning 1105 Invoked routine ran a statement that may cause problems with binary log, see 'NAME_CONST issues' in 'Binary Logging of Stored Programs' section of the manual. +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; End of 5.0 tests diff --git a/mysql-test/t/binlog.test b/mysql-test/t/binlog.test index b9893e02e14..8ceb219402a 100644 --- a/mysql-test/t/binlog.test +++ b/mysql-test/t/binlog.test @@ -161,4 +161,44 @@ DROP TABLE t1; DROP DATABASE bug39182; USE test; +# +# Bug#35383: binlog playback and replication breaks due to +# name_const substitution +# +DELIMITER //; +CREATE PROCEDURE p1(IN v1 INT) +BEGIN + CREATE TABLE t1 SELECT v1; + DROP TABLE t1; +END// +CREATE PROCEDURE p2() +BEGIN + DECLARE v1 INT; + CREATE TABLE t1 SELECT v1+1; + DROP TABLE t1; +END// +CREATE PROCEDURE p3(IN v1 INT) +BEGIN + CREATE TABLE t1 SELECT 1 FROM DUAL WHERE v1!=0; + DROP TABLE t1; +END// +CREATE PROCEDURE p4(IN v1 INT) +BEGIN + DECLARE v2 INT; + CREATE TABLE t1 SELECT 1, v1, v2; + DROP TABLE t1; + CREATE TABLE t1 SELECT 1, v1+1, v2; + DROP TABLE t1; +END// +DELIMITER ;// + +CALL p1(1); +CALL p2(); +CALL p3(0); +CALL p4(0); +DROP PROCEDURE p1; +DROP PROCEDURE p2; +DROP PROCEDURE p3; +DROP PROCEDURE p4; + --echo End of 5.0 tests diff --git a/sql/sp_head.cc b/sql/sp_head.cc index b51d97e66c5..76b0f2e22d2 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -894,6 +894,8 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str) qbuf.length(0); cur= query_str->str; prev_pos= res= 0; + thd->query_name_consts= 0; + for (Item_splocal **splocal= sp_vars_uses.front(); splocal < sp_vars_uses.back(); splocal++) { @@ -927,6 +929,8 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str) res|= qbuf.append(')'); if (res) break; + + thd->query_name_consts++; } res|= qbuf.append(cur + prev_pos, query_str->length - prev_pos); if (res) @@ -2621,6 +2625,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp) *nextp= m_ip+1; thd->query= query; thd->query_length= query_length; + thd->query_name_consts= 0; } DBUG_RETURN(res); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 74bc669a049..07172dde549 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -219,6 +219,7 @@ THD::THD() one_shot_set= 0; file_id = 0; query_id= 0; + query_name_consts= 0; warn_id= 0; db_charset= global_system_variables.collation_database; bzero(ha_data, sizeof(ha_data)); diff --git a/sql/sql_class.h b/sql/sql_class.h index 3e3dfcd08fa..8a69e3729f2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1556,6 +1556,9 @@ public: sp_cache *sp_proc_cache; sp_cache *sp_func_cache; + /** number of name_const() substitutions, see sp_head.cc:subst_spvars() */ + uint query_name_consts; + /* If we do a purge of binary logs, log index info of the threads that are currently reading it needs to be adjusted. To do that diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 33adcfe3342..4cfb41dbc76 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3211,6 +3211,42 @@ mysql_execute_command(THD *thd) } if (select_lex->item_list.elements) // With select { + /* + If: + a) we inside an SP and there was NAME_CONST substitution, + b) binlogging is on, + c) we log the SP as separate statements + raise a warning, as it may cause problems + (see 'NAME_CONST issues' in 'Binary Logging of Stored Programs') + */ + if (thd->query_name_consts && + mysql_bin_log.is_open() && + !mysql_bin_log.is_query_in_union(thd, thd->query_id)) + { + List_iterator_fast it(select_lex->item_list); + Item *item; + uint splocal_refs= 0; + /* Count SP local vars in the top-level SELECT list */ + while ((item= it++)) + { + if (item->is_splocal()) + splocal_refs++; + } + /* + If it differs from number of NAME_CONST substitution applied, + we may have a SOME_FUNC(NAME_CONST()) in the SELECT list, + that may cause a problem with binary log (see BUG#35383), + raise a warning. + */ + if (splocal_refs != thd->query_name_consts) + push_warning(thd, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_UNKNOWN_ERROR, +"Invoked routine ran a statement that may cause problems with " +"binary log, see 'NAME_CONST issues' in 'Binary Logging of Stored Programs' " +"section of the manual."); + } + select_result *sel_result; select_lex->options|= SELECT_NO_UNLOCK; From 27cf68795e42b088e5b20551b60dce02a0b52e1d Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Thu, 26 Mar 2009 11:25:43 +0200 Subject: [PATCH 76/88] bug#42977 compilation warning fixed --- sql/log_event.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index 6220bc276a6..89094da3e94 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -7764,7 +7764,7 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, m_data_size+= m_dblen + 2; // Include length and terminating \0 m_data_size+= m_tbllen + 2; // Include length and terminating \0 cbuf_end= net_store_length(cbuf, (size_t) m_colcnt); - DBUG_ASSERT((cbuf_end - cbuf) <= sizeof(cbuf)); + DBUG_ASSERT(static_cast(cbuf_end - cbuf) <= sizeof(cbuf)); m_data_size+= (cbuf_end - cbuf) + m_colcnt; // COLCNT and column types /* If malloc fails, caught in is_valid() */ From d9a9f5c71f4da5ea44d1b4fc3cf22c9ab52b6d5f Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Thu, 26 Mar 2009 18:27:34 +0400 Subject: [PATCH 77/88] fixed archive test. It might be OOM error on boxes with low amount of memory. It leads to crash because there is no OOM check in ha_archive::unpack_row(). The fix: added OOM error check mysql-test/r/archive.result: remover test case mysql-test/std_data/bug32880.ARN: remover test case mysql-test/std_data/bug32880.ARZ: remover test case mysql-test/std_data/bug32880.frm: remover test case mysql-test/t/archive.test: remover test case --- mysql-test/r/archive.result | 19 ------------------- mysql-test/std_data/bug32880.ARN | Bin 131 -> 0 bytes mysql-test/std_data/bug32880.ARZ | Bin 8744 -> 0 bytes mysql-test/std_data/bug32880.frm | Bin 8578 -> 0 bytes mysql-test/t/archive.test | 15 --------------- storage/archive/ha_archive.cc | 6 +++++- 6 files changed, 5 insertions(+), 35 deletions(-) delete mode 100644 mysql-test/std_data/bug32880.ARN delete mode 100644 mysql-test/std_data/bug32880.ARZ delete mode 100644 mysql-test/std_data/bug32880.frm diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index 02acccb234e..8c26ea1ff82 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -12695,22 +12695,3 @@ a b 1 NULL 2 NULL DROP TABLE t1; -# -# BUG#32880 - Repairing Archive table fails with internal error 144 -# - -# Test with an existing table which is corrupted -# Copy t1 from std_data -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL, - `b` blob -) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -CHECK TABLE t1; -Table Op Msg_type Msg_text -test.t1 check error Corrupt -REPAIR TABLE t1; -Table Op Msg_type Msg_text -test.t1 repair error Corrupt -DROP TABLE t1; diff --git a/mysql-test/std_data/bug32880.ARN b/mysql-test/std_data/bug32880.ARN deleted file mode 100644 index 643b0dfbad59af05495571978acc8b5eeaf8b509..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 131 zcmeyz%qYO%$AAi8dqei4wVSWE@5vi;Yx=ZHHrNyljV=3 gvkA%YRCc;{PVKA|P+c6Av6_|P_LJg8GZ+~d03i_-e*gdg diff --git a/mysql-test/std_data/bug32880.ARZ b/mysql-test/std_data/bug32880.ARZ deleted file mode 100644 index 4e151822647f1b7e0f3f2b9952ef543f9a7954ce..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8744 zcmeI&ze>YE90%}kE^WOwLQ_+U|G-v?pi7-QR7DDkP{ct*5RxuFL%>0bOI#ep7w|I1m=0(}aH((^7}($&Gi!uKHg{qC2`-SL@!GuQDk05EFlmmMEA5AD2YV{h9gHUv8Q z`pMQ~=9GO`*BoHqe5%gZ3yCt2?j*CS`S)`S)UraS12nSrP z3Q&Lo|5iXi<#(HBwzPz!i{q2i%YMFu2?Z!X0SZun0u-PC1t>rP3Q&Lo3nnmf(tdyi zyY=5)*MUG6rY)k1Qoiju8oF*q7p@TX-R3U`3J{U*nGi!1gy)$}HtzK{uI`{H3MtJQ zwTC(|Jpfdsh6=j-!j4H4hF@dZzFK<>&h~=%@NQ@It^K_9ep_1ET#l1|@{+`fS*+Bg Wb>pSU>r>;WvOc)BNhQ>$RK5X*A2h-M diff --git a/mysql-test/std_data/bug32880.frm b/mysql-test/std_data/bug32880.frm deleted file mode 100644 index 66a4c7d7538ef06353e4b38b8699203736844857..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8578 zcmeI&u?oU45C-5s*H%+Hw8i4$($%TXT|`9CO&r|YClT?@dj)_ z@U6LrNs9<546x7zIYNj<3M77Shhm}0?Fy7bp=p46*l?u)1t>rP3Q&Lo6rcbFC_n)U zP~d9?1TMVooxMt9tPbn#?zjm@m{5QM6rcbFC_n)UP=Epypa2CZ@M8jJqo4kN90r0G z6BWoY3J!ZrweF)uBvQ@m4+Alz)0qkB5lfc&CbN^aiFAS@5o`S&<)s4dOTcxmcX$FK Cm=+HJ diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 0d521f95b38..7139d95ab49 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1599,18 +1599,3 @@ INSERT INTO t1 VALUES (NULL, NULL),(NULL, NULL); FLUSH TABLE t1; SELECT * FROM t1 ORDER BY a; DROP TABLE t1; - ---echo # ---echo # BUG#32880 - Repairing Archive table fails with internal error 144 ---echo # ---echo ---echo # Test with an existing table which is corrupted ---echo # Copy t1 from std_data -let $MYSQLD_DATADIR= `select @@datadir`; -copy_file std_data/bug32880.frm $MYSQLD_DATADIR/test/t1.frm; -copy_file std_data/bug32880.ARZ $MYSQLD_DATADIR/test/t1.ARZ; -copy_file std_data/bug32880.ARN $MYSQLD_DATADIR/test/t1.ARN; -SHOW CREATE TABLE t1; -CHECK TABLE t1; -REPAIR TABLE t1; -DROP TABLE t1; diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index d20ab3bf723..5e2a4ad5da3 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1071,7 +1071,11 @@ int ha_archive::unpack_row(azio_stream *file_to_read, uchar *record) row_len= uint4korr(size_buffer); DBUG_PRINT("ha_archive",("Unpack row length %u -> %u", row_len, (unsigned int)table->s->reclength)); - fix_rec_buff(row_len); + + if (fix_rec_buff(row_len)) + { + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + } DBUG_ASSERT(row_len <= record_buffer->length); read= azread(file_to_read, record_buffer->buffer, row_len, &error); From 9b1ee3c67dbfd72ccfe4497fbb0115c4553a5069 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 26 Mar 2009 16:47:58 +0200 Subject: [PATCH 78/88] removed an unix-ism in a test --- mysql-test/t/upgrade.test | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index a96d1f47cb2..437b0f47cc0 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -53,7 +53,9 @@ drop table `txu#p#p1`; # let $MYSQLD_DATADIR= `select @@datadir`; -system cp $MYSQL_TEST_DIR/std_data/old_table-323.frm $MYSQLD_DATADIR/test/t1.frm; +--error 0,1 +--remove_file $MYSQLD_DATADIR/test/t1.frm +--copy_file std_data/old_table-323.frm $MYSQLD_DATADIR/test/t1.frm truncate t1; drop table t1; From 2f3b4cc796006678129acfea64824a6b868f988d Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 26 Mar 2009 17:49:06 +0200 Subject: [PATCH 79/88] fixed unupdated test suites. --- mysql-test/suite/funcs_1/r/processlist_priv_ps.result | 4 ++-- mysql-test/suite/funcs_1/r/processlist_val_ps.result | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/processlist_priv_ps.result b/mysql-test/suite/funcs_1/r/processlist_priv_ps.result index 56230a0f806..2932467be2a 100644 --- a/mysql-test/suite/funcs_1/r/processlist_priv_ps.result +++ b/mysql-test/suite/funcs_1/r/processlist_priv_ps.result @@ -27,7 +27,7 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', - `TIME` bigint(7) NOT NULL DEFAULT '0', + `TIME` int(7) NOT NULL DEFAULT '0', `STATE` varchar(64) DEFAULT NULL, `INFO` longtext ) ENGINE=MyISAM DEFAULT CHARSET=utf8 @@ -97,7 +97,7 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', - `TIME` bigint(7) NOT NULL DEFAULT '0', + `TIME` int(7) NOT NULL DEFAULT '0', `STATE` varchar(64) DEFAULT NULL, `INFO` longtext ) ENGINE=MyISAM DEFAULT CHARSET=utf8 diff --git a/mysql-test/suite/funcs_1/r/processlist_val_ps.result b/mysql-test/suite/funcs_1/r/processlist_val_ps.result index 72ca56d0ffa..4e4cfa57e36 100644 --- a/mysql-test/suite/funcs_1/r/processlist_val_ps.result +++ b/mysql-test/suite/funcs_1/r/processlist_val_ps.result @@ -17,7 +17,7 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` ( `HOST` varchar(64) NOT NULL DEFAULT '', `DB` varchar(64) DEFAULT NULL, `COMMAND` varchar(16) NOT NULL DEFAULT '', - `TIME` bigint(7) NOT NULL DEFAULT '0', + `TIME` int(7) NOT NULL DEFAULT '0', `STATE` varchar(64) DEFAULT NULL, `INFO` longtext ) ENGINE=MyISAM DEFAULT CHARSET=utf8 From 68907b3478ae00f00111edeeacf018de0c7b36b6 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 27 Mar 2009 12:59:31 +0200 Subject: [PATCH 80/88] Worked around the problem described in bug #43884. --- mysql-test/suite/rpl/r/rpl_loadfile.result | 2 +- mysql-test/suite/rpl/t/rpl_loadfile.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_loadfile.result b/mysql-test/suite/rpl/r/rpl_loadfile.result index 63710326086..22f65c0b5e5 100644 --- a/mysql-test/suite/rpl/r/rpl_loadfile.result +++ b/mysql-test/suite/rpl/r/rpl_loadfile.result @@ -233,7 +233,7 @@ include/start_slave.inc SELECT repeat('x',20) INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug_39701.data'; DROP TABLE IF EXISTS t1; CREATE TABLE t1 (t text); -CREATE PROCEDURE p(file TEXT) +CREATE PROCEDURE p(file varchar(4096)) BEGIN INSERT INTO t1 VALUES (LOAD_FILE(file)); END| diff --git a/mysql-test/suite/rpl/t/rpl_loadfile.test b/mysql-test/suite/rpl/t/rpl_loadfile.test index d12d43224df..adb23d2c2bc 100644 --- a/mysql-test/suite/rpl/t/rpl_loadfile.test +++ b/mysql-test/suite/rpl/t/rpl_loadfile.test @@ -73,7 +73,7 @@ enable_warnings; CREATE TABLE t1 (t text); DELIMITER |; -CREATE PROCEDURE p(file TEXT) +CREATE PROCEDURE p(file varchar(4096)) BEGIN INSERT INTO t1 VALUES (LOAD_FILE(file)); END| From ffd9792ca5be5bd49c163e40caa15c4572a757cc Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Fri, 27 Mar 2009 12:20:37 +0100 Subject: [PATCH 81/88] Bug#43748: crash when non-super user tries to kill the replication threads Test was flakey on some machines and showed spurious reds for races. New-and-improved test makes do with fewer statements, no mysqltest-variables, and no backticks. Should hope- fully be more robust. Heck, it's debatable whether we should have a test for this, anyway. mysql-test/suite/rpl/r/rpl_temporary.result: streamlined mysql-test/suite/rpl/t/rpl_temporary.test: streamlined --- mysql-test/suite/rpl/r/rpl_temporary.result | 19 +++++++++------- mysql-test/suite/rpl/t/rpl_temporary.test | 24 ++++++++++----------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_temporary.result b/mysql-test/suite/rpl/r/rpl_temporary.result index c3b228e6089..8a9ddaec9f6 100644 --- a/mysql-test/suite/rpl/r/rpl_temporary.result +++ b/mysql-test/suite/rpl/r/rpl_temporary.result @@ -108,13 +108,16 @@ select * from t1; a 1 drop table t1; -Bug#43748 -make a non-privileged user on slave. +-- Bug#43748 +-- make a user on the slave that can list but not kill system threads. FLUSH PRIVILEGES; -GRANT USAGE ON *.* TO user43748@127.0.0.1 IDENTIFIED BY 'meow'; -try to KILL system-thread as non-privileged user. -KILL `select id from information_schema.processlist where command='Binlog Dump'`; -ERROR HY000: You are not owner of thread `select id from information_schema.processlist where command='Binlog Dump'` -throw out test-user on slave. +GRANT USAGE ON *.* TO user43748@127.0.0.1 IDENTIFIED BY 'meow'; +GRANT PROCESS ON *.* TO user43748@127.0.0.1; +-- try to KILL system-thread as that non-privileged user (on slave). +SELECT id INTO @id FROM information_schema.processlist WHERE user='system user' LIMIT 1; +KILL @id; +Got one of the listed errors +-- throw out test-user on slave. DROP USER user43748@127.0.0.1; -done. back to master. +-- done. back to master. +End of 5.1 tests diff --git a/mysql-test/suite/rpl/t/rpl_temporary.test b/mysql-test/suite/rpl/t/rpl_temporary.test index a236bcf3b7b..4e83d39710c 100644 --- a/mysql-test/suite/rpl/t/rpl_temporary.test +++ b/mysql-test/suite/rpl/t/rpl_temporary.test @@ -228,36 +228,34 @@ source include/delete_anonymous_users.inc; # Bug#43748: crash when non-super user tries to kill the replication threads # ---echo Bug#43748 +--echo -- Bug#43748 +--echo -- make a user on the slave that can list but not kill system threads. connection slave; ---echo make a non-privileged user on slave. - FLUSH PRIVILEGES; -GRANT USAGE ON *.* TO user43748@127.0.0.1 IDENTIFIED BY 'meow'; - -let $id = `SELECT id FROM information_schema.processlist WHERE user='system user' LIMIT 1`; +GRANT USAGE ON *.* TO user43748@127.0.0.1 IDENTIFIED BY 'meow'; +GRANT PROCESS ON *.* TO user43748@127.0.0.1; +--echo -- try to KILL system-thread as that non-privileged user (on slave). connect (cont43748,127.0.0.1,user43748,meow,test,$SLAVE_MYPORT,); connection cont43748; ---echo try to KILL system-thread as non-privileged user. +SELECT id INTO @id FROM information_schema.processlist WHERE user='system user' LIMIT 1; ---replace_result $id "`select id from information_schema.processlist where command='Binlog Dump'`" ---error ER_KILL_DENIED_ERROR -eval KILL $id; +--error ER_KILL_DENIED_ERROR,ER_NO_SUCH_THREAD +KILL @id; disconnect cont43748; +--echo -- throw out test-user on slave. connection slave; ---echo throw out test-user on slave. DROP USER user43748@127.0.0.1; +--echo -- done. back to master. connection master; ---echo done. back to master. -# End of tests +--echo End of 5.1 tests From 2c312d9737edb30b8d4abeb0e2e6c629e24ce075 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 27 Mar 2009 14:12:33 +0200 Subject: [PATCH 82/88] disabled a failing test suite due to bug #42311 --- mysql-test/suite/rpl/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def index cb714c60ba4..b5f158b2257 100644 --- a/mysql-test/suite/rpl/t/disabled.def +++ b/mysql-test/suite/rpl/t/disabled.def @@ -12,3 +12,4 @@ rpl_binlog_corruption : BUG#41793 2008-12-30 sven rpl_binlog_corruption disabled in main (needs new mtr) rpl_temp_table_mix_row : BUG#43440 2009-03-23 joro rpl.rpl_temp_table_mix_row fails sporadicly +rpl_cross_version : BUG#42311 2009-03-27 joro rpl_cross_version fails on macosx From 5f2bda83dd398f122c5691da705b6cbee8aaee88 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 27 Mar 2009 16:25:16 +0200 Subject: [PATCH 83/88] fixed a compilation warning --- sql/sql_insert.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index b79f979df05..48438ba033c 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1609,7 +1609,9 @@ public: uint query_length; delayed_row(enum_duplicates dup_arg, bool ignore_arg, bool log_query_arg) - :record(0), query(0), time_zone(0), dup(dup_arg), ignore(ignore_arg), log_query(log_query_arg) {} + :record(0), query(0), dup(dup_arg), ignore(ignore_arg), + log_query(log_query_arg), time_zone(0) + {} ~delayed_row() { x_free(record); From f56ad8c82c9bf37196c4d4bd4305735a5da4ad76 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 27 Mar 2009 16:29:56 +0200 Subject: [PATCH 84/88] tree name changed --- .bzr-mysql/default.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index 557df1b1ffe..f79c1cd6319 100644 --- a/.bzr-mysql/default.conf +++ b/.bzr-mysql/default.conf @@ -1,4 +1,4 @@ [MYSQL] post_commit_to = "commits@lists.mysql.com" post_push_to = "commits@lists.mysql.com" -tree_name = "mysql-5.0-bugteam" +tree_name = "mysql-5.0" From 9530e5c79e802aea3054fb02935e99263022d1b8 Mon Sep 17 00:00:00 2001 From: Jonathan Perkin Date: Mon, 30 Mar 2009 13:27:23 +0200 Subject: [PATCH 85/88] Raise version number after cloning 5.1.34 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index d86218bd782..391e9cb7a28 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.34) +AM_INIT_AUTOMAKE(mysql, 5.1.35) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 From 20f76540a18bff01350edb5878ab5015bd194055 Mon Sep 17 00:00:00 2001 From: Jonathan Perkin Date: Tue, 31 Mar 2009 16:04:02 +0200 Subject: [PATCH 86/88] Apply 64-bit fix from Azundris. --- mysys/safemalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index 36d07b475e9..c484f1d4c54 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -174,7 +174,7 @@ void *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags) data[size + 3]= MAGICEND3; irem->filename= (char *) filename; irem->linenum= lineno; - irem->datasize= (uint32) size; + irem->datasize= size; irem->prev= NULL; /* Add this remember structure to the linked list */ From d434e1269bf3553c0b7e17d917b1e8c8e2d236d5 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 1 Apr 2009 22:18:49 +0200 Subject: [PATCH 87/88] Add new headers to noinst_HEADERS (ibmdb2i storage engine) --- storage/ibmdb2i/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/ibmdb2i/Makefile.am b/storage/ibmdb2i/Makefile.am index 2436a764429..768ca15f4cf 100644 --- a/storage/ibmdb2i/Makefile.am +++ b/storage/ibmdb2i/Makefile.am @@ -27,6 +27,7 @@ DEFS = @DEFS@ noinst_HEADERS = ha_ibmdb2i.h db2i_collationSupport.h db2i_file.h \ db2i_ioBuffers.h db2i_blobCollection.h \ db2i_global.h db2i_misc.h db2i_charsetSupport.h db2i_errors.h \ + db2i_iconv.h db2i_myconv.h db2i_safeString.h db2i_sqlStatementStream.h \ db2i_ileBridge.h db2i_validatedPointer.h EXTRA_LTLIBRARIES = ha_ibmdb2i.la From 0e531e8bb9ed11401df600aa3744dc25932224ff Mon Sep 17 00:00:00 2001 From: Jonathan Perkin Date: Thu, 2 Apr 2009 13:17:38 +0200 Subject: [PATCH 88/88] Apply http://lists.mysql.com/commits/70427 to fix Win32 builds with VS 2005. --- include/config-win.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/config-win.h b/include/config-win.h index 26b08a5e4fb..3a21551ebbb 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -63,9 +63,6 @@ functions */ #endif #ifndef __WIN32__ #define __WIN32__ -#define _INTEGRAL_MAX_BITS 32 -#else -#define _INTEGRAL_MAX_BITS 64 #endif #endif /* _WIN64 */ #ifndef __WIN__