From c80fc3501b525999140b82367b71728dfd059f89 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 8 Jul 2009 16:50:17 +0300 Subject: [PATCH 1/6] fixed check-cpu to correctly recognize mac CPUs From 45b687c087beab11815c17546db933b8ab7191ee Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 15 Jul 2009 16:46:25 +0300 Subject: [PATCH 2/6] Bug #45287: phase 1 : 32 bit compilation warnings Fixed the following problems: 1. cmake 2.6 warning because of a changed default on how the dependencies to libraries with a specified path are resolved. Fixed by requiring cmake 2.6. 2. Removed an obsolete pre-NT4 hack including defining Windows system defines to alter the behavior of windows.h. 3. Disabled warning C4065 on compiling sql_yacc.cc because of a know incompatibility in some of the newer bison binaries. --- CMakeLists.txt | 2 +- include/config-win.h | 9 --------- sql/sql_yacc.yy | 6 ++++++ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91c3a804eea..9f53a9fb146 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR) PROJECT(MySql) diff --git a/include/config-win.h b/include/config-win.h index ab463a7c142..05bdfd2c226 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -15,15 +15,6 @@ /* Defines for Win32 to make it compatible for MySQL */ -#ifdef __WIN2000__ -/* We have to do this define before including windows.h to get the AWE API -functions */ -#define _WIN32_WINNT 0x0500 -#else -/* Get NT 4.0 functions */ -#define _WIN32_WINNT 0x0400 -#endif - #if defined(_MSC_VER) && _MSC_VER >= 1400 /* Avoid endless warnings about sprintf() etc. being unsafe. */ #define _CRT_SECURE_NO_DEPRECATE 1 diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 49b7fafcc0b..cde2e8dac3e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -41,6 +41,12 @@ #include #include +/* this is to get the bison compilation windows warnings out */ +#ifdef _MSC_VER +/* warning C4065: switch statement contains 'default' but no 'case' labels */ +#pragma warning (disable : 4065) +#endif + int yylex(void *yylval, void *yythd); const LEX_STRING null_lex_str={0,0}; From fae95a4933899edfd560735a3977a947e5551410 Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Thu, 16 Jul 2009 01:23:57 +0200 Subject: [PATCH 3/6] Bug#45781 infinite hang/crash in "opening tables" after handler tries to open merge table The MERGE table storage engine does not support the HA_CAN_SQL_HANDLE feature and any attempt to open the merge table will fail with ER_ILLEGAL_HA. After an error occurred the tables that was opened must be closed again or they will be left in an inconsistent state. However, the assumption made in the code for closing and register handler tables was that only one table will be opened, and this is not true for MERGE tables which will cause multiple tables to open. The next time a SELECT operation was issued on the merge table it caused the system to freeze. This patch fixes this issue by making sure that all tables which are opened also are closed in the event of an error. mysql-test/r/merge.result: Added test case for bug 45781 mysql-test/t/merge.test: Added test case for bug 45781 sql/sql_handler.cc: * mysql_ha_open() was never ment to open more than one table. If we encounter more tables, we should close all tables related to the current substatement and raise an exception. --- mysql-test/r/merge.result | 20 ++++++++++++++++++++ mysql-test/t/merge.test | 24 ++++++++++++++++++++++++ sql/sql_handler.cc | 29 ++++++++++++++++++++++++++--- 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index bf9108459d7..934085ab796 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -2141,4 +2141,24 @@ SELECT * FROM m1; c1 DROP TABLE m1; DROP TABLE t1; +# +# Bug45781 infinite hang/crash in "opening tables" after handler tries to +# open merge table +# +DROP TABLE IF EXISTS m1,t1; +CREATE TABLE t1(a int)engine=myisam; +CREATE TABLE t2(a int)engine=myisam; +CREATE TABLE t3(a int)engine=myisam; +CREATE TABLE t4(a int)engine=myisam; +CREATE TABLE t5(a int)engine=myisam; +CREATE TABLE t6(a int)engine=myisam; +CREATE TABLE t7(a int)engine=myisam; +CREATE TABLE m1(a int)engine=merge union=(t1,t2,t3,t4,t5,t6,t7); +SELECT 1 FROM m1; +1 +HANDLER m1 OPEN; +ERROR HY000: Table storage engine for 'm1' doesn't have this option +DROP TABLE m1,t1,t2,t3,t4,t5,t6,t7; +SELECT 1 FROM m1; +ERROR 42S02: Table 'test.m1' doesn't exist End of 5.1 tests diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 8760876b7ee..0d90468fc8d 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -1555,4 +1555,28 @@ SELECT * FROM m1; DROP TABLE m1; DROP TABLE t1; +--echo # +--echo # Bug45781 infinite hang/crash in "opening tables" after handler tries to +--echo # open merge table +--echo # + +--disable_warnings +DROP TABLE IF EXISTS m1,t1; +--enable_warnings + +CREATE TABLE t1(a int)engine=myisam; +CREATE TABLE t2(a int)engine=myisam; +CREATE TABLE t3(a int)engine=myisam; +CREATE TABLE t4(a int)engine=myisam; +CREATE TABLE t5(a int)engine=myisam; +CREATE TABLE t6(a int)engine=myisam; +CREATE TABLE t7(a int)engine=myisam; +CREATE TABLE m1(a int)engine=merge union=(t1,t2,t3,t4,t5,t6,t7); +SELECT 1 FROM m1; +--error ER_ILLEGAL_HA +HANDLER m1 OPEN; +DROP TABLE m1,t1,t2,t3,t4,t5,t6,t7; +--error ER_NO_SUCH_TABLE +SELECT 1 FROM m1; # Should not hang! + --echo End of 5.1 tests diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 16810e29343..1e92d95573a 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -252,14 +252,37 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) /* for now HANDLER can be used only for real TABLES */ tables->required_type= FRMTYPE_TABLE; + /* + We use open_tables() here, rather than, say, + open_ltable() or open_table() because we would like to be able + to open a temporary table. + */ error= open_tables(thd, &tables, &counter, 0); - /* restore the state and merge the opened table into handler_tables list */ if (thd->open_tables) { - thd->open_tables->next= thd->handler_tables; - thd->handler_tables= thd->open_tables; + if (thd->open_tables->next) + { + /* + We opened something that is more than a single table. + This happens with MERGE engine. Don't try to link + this mess into thd->handler_tables list, close it + and report an error. We must do it right away + because mysql_ha_close_table(), called down the road, + can close a single table only. + */ + close_thread_tables(thd); + my_error(ER_ILLEGAL_HA, MYF(0), tables->alias); + error= 1; + } + else + { + /* Merge the opened table into handler_tables list. */ + thd->open_tables->next= thd->handler_tables; + thd->handler_tables= thd->open_tables; + } } + /* Restore the state. */ thd->open_tables= backup_open_tables; if (error) From 7a91bf8c9131e3622684684b6e45c0282c4701e3 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 16 Jul 2009 15:19:22 +0300 Subject: [PATCH 4/6] Bug #46003 and bug #46034: backported the fixes from azalea. --- sql/sql_base.cc | 8 +++++++- sql/sql_select.cc | 24 +++++++++++++++++------- sql/sql_select.h | 3 ++- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 0f86a3dd311..56ab50835b6 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5095,7 +5095,13 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List &fields, /* make * substituting permanent */ SELECT_LEX *select_lex= thd->lex->current_select; select_lex->with_wild= 0; - select_lex->item_list= fields; + /* + The assignment below is translated to memcpy() call (at least on some + platforms). memcpy() expects that source and destination areas do not + overlap. That problem was detected by valgrind. + */ + if (&select_lex->item_list != &fields) + select_lex->item_list= fields; thd->restore_active_arena(arena, &backup); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 672ebaf9259..60f4880fe70 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1748,7 +1748,8 @@ JOIN::exec() curr_join->having= curr_join->tmp_having= 0; // Allready done /* Change sum_fields reference to calculated fields in tmp_table */ - curr_join->all_fields= *curr_all_fields; + if (curr_join != this) + curr_join->all_fields= *curr_all_fields; if (!items1) { items1= items0 + all_fields.elements; @@ -1767,8 +1768,11 @@ JOIN::exec() fields_list.elements, all_fields)) DBUG_VOID_RETURN; } - curr_join->tmp_all_fields1= tmp_all_fields1; - curr_join->tmp_fields_list1= tmp_fields_list1; + if (curr_join != this) + { + curr_join->tmp_all_fields1= tmp_all_fields1; + curr_join->tmp_fields_list1= tmp_fields_list1; + } curr_join->items1= items1; } curr_all_fields= &tmp_all_fields1; @@ -1913,8 +1917,11 @@ JOIN::exec() tmp_fields_list2, tmp_all_fields2, fields_list.elements, tmp_all_fields1)) DBUG_VOID_RETURN; - curr_join->tmp_fields_list2= tmp_fields_list2; - curr_join->tmp_all_fields2= tmp_all_fields2; + if (curr_join != this) + { + curr_join->tmp_fields_list2= tmp_fields_list2; + curr_join->tmp_all_fields2= tmp_all_fields2; + } } curr_fields_list= &curr_join->tmp_fields_list2; curr_all_fields= &curr_join->tmp_all_fields2; @@ -1969,8 +1976,11 @@ JOIN::exec() tmp_table_param.save_copy_field= curr_join->tmp_table_param.copy_field; tmp_table_param.save_copy_field_end= curr_join->tmp_table_param.copy_field_end; - curr_join->tmp_all_fields3= tmp_all_fields3; - curr_join->tmp_fields_list3= tmp_fields_list3; + if (curr_join != this) + { + curr_join->tmp_all_fields3= tmp_all_fields3; + curr_join->tmp_fields_list3= tmp_fields_list3; + } } else { diff --git a/sql/sql_select.h b/sql/sql_select.h index 75a905043d2..c328737c1c6 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -416,7 +416,8 @@ public: group_optimized_away= 0; all_fields= fields_arg; - fields_list= fields_arg; + if (&fields_list != &fields_arg) /* Avoid valgrind-warning */ + fields_list= fields_arg; bzero((char*) &keyuse,sizeof(keyuse)); tmp_table_param.init(); tmp_table_param.end_write_records= HA_POS_ERROR; From 097c7b38c83134092c0820b6129f1d29603b6d16 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 16 Jul 2009 15:37:38 +0300 Subject: [PATCH 5/6] Bug #45287: phase 2 : 5.0 64 bit compilation warnings Fixed various compilation warnings when compiling on a 64 bit windows. --- client/mysql_upgrade.c | 2 +- client/mysqldump.c | 4 ++-- dbug/dbug.c | 13 +++++++------ include/my_sys.h | 2 +- sql/mysqld.cc | 4 ++-- sql/opt_range.cc | 2 +- sql/set_var.cc | 2 +- sql/sp.cc | 6 +++--- sql/sql_acl.cc | 8 ++++---- sql/sql_parse.cc | 2 +- sql/sql_profile.cc | 2 +- sql/sql_show.cc | 4 ++-- sql/sql_yacc.yy | 23 ++++++++++++----------- tests/mysql_client_test.c | 4 ++-- 14 files changed, 40 insertions(+), 38 deletions(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index e3500c81fb9..ff414fff592 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -387,7 +387,7 @@ static void find_tool(char *tool_executable_name, const char *tool_name, last_fn_libchar -= 6; } - len= last_fn_libchar - self_name; + len= (int) (last_fn_libchar - self_name); my_snprintf(tool_executable_name, FN_REFLEN, "%.*s%c%s", len, self_name, FN_LIBCHAR, tool_name); diff --git a/client/mysqldump.c b/client/mysqldump.c index fa6c21ed273..1918a657316 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3122,7 +3122,7 @@ static my_bool dump_all_views_in_db(char *database) for (numrows= 0 ; (table= getTableName(1)); ) { char *end= strmov(afterdot, table); - if (include_table(hash_key,end - hash_key)) + if (include_table(hash_key,(uint) (end - hash_key))) { numrows++; dynstr_append_checked(&query, quote_name(table, table_buff, 1)); @@ -3143,7 +3143,7 @@ static my_bool dump_all_views_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))) get_view_structure(table, database); } if (opt_xml) diff --git a/dbug/dbug.c b/dbug/dbug.c index baf080f5e27..1704db79b36 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -855,8 +855,9 @@ void _db_pop_() } \ } while (0) -int _db_explain_ (CODE_STATE *cs, char *buf, size_t len) -{ +int _db_explain_ (CODE_STATE *cs, char *buf, size_t len_arg) +{ + uint len= (uint) len_arg; char *start=buf, *end=buf+len-4; get_code_state_or_return *buf=0; @@ -1267,7 +1268,7 @@ static struct link *ListAdd(struct link *head, start= ctlp; while (ctlp < end && *ctlp != ',') ctlp++; - len=ctlp-start; + len=(int) (ctlp-start); new_malloc= (struct link *) DbugMalloc(sizeof(struct link)+len); memcpy(new_malloc->str, start, len); new_malloc->str[len]=0; @@ -1303,7 +1304,7 @@ static struct link *ListDel(struct link *head, { const char *start; struct link **cur; - int len; + size_t len; while (ctlp < end) { @@ -1357,7 +1358,7 @@ static struct link *ListCopy(struct link *orig) head= NULL; while (orig != NULL) { - len= strlen(orig->str); + len= (int) strlen(orig->str); new_malloc= (struct link *) DbugMalloc(sizeof(struct link)+len); memcpy(new_malloc->str, orig->str, len); new_malloc->str[len]= 0; @@ -1827,7 +1828,7 @@ static void DBUGOpenFile(CODE_STATE *cs, { if (end) { - int len=end-name; + size_t len=(size_t) (end-name); memcpy(cs->stack->name, name, len); cs->stack->name[len]=0; } diff --git a/include/my_sys.h b/include/my_sys.h index bfb1a672641..4254ec3dbcb 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -512,7 +512,7 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *); ((info)->write_pos + (Count) <=(info)->write_end ?\ (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\ ((info)->write_pos+=(Count)),0) : \ - (*(info)->write_function)((info),(Buffer),(Count))) + (*(info)->write_function)((info),(Buffer), (uint)(Count))) #define my_b_get(info) \ ((info)->read_pos != (info)->read_end ?\ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 592ae3e755a..ee54c2a5a2d 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3036,7 +3036,7 @@ static int init_common_variables(const char *conf_file_name, int argc, sys_init_connect.value_length= 0; if ((sys_init_connect.value= opt_init_connect)) - sys_init_connect.value_length= strlen(opt_init_connect); + sys_init_connect.value_length= (uint) strlen(opt_init_connect); else sys_init_connect.value=my_strdup("",MYF(0)); sys_init_connect.is_os_charset= TRUE; @@ -7840,7 +7840,7 @@ static void fix_paths(void) } convert_dirname(mysql_real_data_home,mysql_real_data_home,NullS); my_realpath(mysql_unpacked_real_data_home, mysql_real_data_home, MYF(0)); - mysql_unpacked_real_data_home_len= strlen(mysql_unpacked_real_data_home); + mysql_unpacked_real_data_home_len= (int) strlen(mysql_unpacked_real_data_home); if (mysql_unpacked_real_data_home[mysql_unpacked_real_data_home_len-1] == FN_LIBCHAR) --mysql_unpacked_real_data_home_len; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 571a342fa17..32f9b0df4c0 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -792,7 +792,7 @@ SEL_TREE::SEL_TREE(SEL_TREE *arg, PARAM *param): Sql_alloc() SEL_IMERGE::SEL_IMERGE (SEL_IMERGE *arg, PARAM *param) : Sql_alloc() { - uint elements= (arg->trees_end - arg->trees); + uint elements= (uint) (arg->trees_end - arg->trees); if (elements > PREALLOCED_TREES) { uint size= elements * sizeof (SEL_TREE **); diff --git a/sql/set_var.cc b/sql/set_var.cc index aebebb3b465..c885f7160e9 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3528,7 +3528,7 @@ int set_var_password::check(THD *thd) { DBUG_ASSERT(thd->security_ctx->priv_user); user->user.str= (char *) thd->security_ctx->priv_user; - user->user.length= strlen(thd->security_ctx->priv_user); + user->user.length= (uint) strlen(thd->security_ctx->priv_user); } /* Returns 1 as the function sends error to client */ return check_change_password(thd, user->host.str, user->user.str, diff --git a/sql/sp.cc b/sql/sp.cc index 2450e9564d0..1471eb31eed 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -430,9 +430,9 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, type, NULL, 0, name->m_name.str, name->m_name.length, - params, strlen(params), - returns, strlen(returns), - body, strlen(body), + params, (ulong) strlen(params), + returns, (ulong) strlen(returns), + body, (ulong) strlen(body), &chistics, &definer_user_name, &definer_host_name)) { ret= SP_INTERNAL_ERROR; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 34d7e773ca2..ab4e518d5dd 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5988,15 +5988,15 @@ static bool update_schema_privilege(THD *thd, TABLE *table, char *buff, int i= 2; CHARSET_INFO *cs= system_charset_info; restore_record(table, s->default_values); - table->field[0]->store(buff, strlen(buff), cs); + table->field[0]->store(buff, (uint) strlen(buff), cs); if (db) - table->field[i++]->store(db, strlen(db), cs); + table->field[i++]->store(db, (uint) strlen(db), cs); if (t_name) - table->field[i++]->store(t_name, strlen(t_name), cs); + table->field[i++]->store(t_name, (uint) strlen(t_name), cs); if (column) table->field[i++]->store(column, col_length, cs); table->field[i++]->store(priv, priv_length, cs); - table->field[i]->store(is_grantable, strlen(is_grantable), cs); + table->field[i]->store(is_grantable, (uint) strlen(is_grantable), cs); return schema_table_store_record(thd, table); } #endif diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index bcde4a971d0..33b601b7d7e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -8231,7 +8231,7 @@ int test_if_data_home_dir(const char *dir) (void) fn_format(path, dir, "", "", (MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS)); - dir_len= strlen(path); + dir_len= (int) strlen(path); if (mysql_unpacked_real_data_home_len<= dir_len) { if (dir_len > mysql_unpacked_real_data_home_len && diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index f87f92471a3..90cbd02dd1b 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -119,7 +119,7 @@ int make_profile_table_for_show(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; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 8387c087836..fdd31cf3eeb 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -287,7 +287,7 @@ find_files(THD *thd, List *files, const char *db, #ifndef NO_EMBEDDED_ACCESS_CHECKS uint col_access=thd->col_access; #endif - uint wild_length= 0; + size_t wild_length= 0; TABLE_LIST table_list; DBUG_ENTER("find_files"); @@ -3738,7 +3738,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) if (item->decimals > 0) item->max_length+= 1; item->set_name(fields_info->field_name, - strlen(fields_info->field_name), cs); + (uint) strlen(fields_info->field_name), cs); break; case MYSQL_TYPE_STRING: default: diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index cde2e8dac3e..b38b6e96890 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -51,7 +51,7 @@ int yylex(void *yylval, void *yythd); const LEX_STRING null_lex_str={0,0}; -#define yyoverflow(A,B,C,D,E,F) {ulong val= *(F); if (my_yyoverflow((B), (D), &val)) { yyerror((char*) (A)); return 2; } else { *(F)= (YYSIZE_T)val; }} +#define yyoverflow(A,B,C,D,E,F) {ulong val= (ulong) *(F); if (my_yyoverflow((B), (D), &val)) { yyerror((char*) (A)); return 2; } else { *(F)= (YYSIZE_T)val; }} #undef WARN_DEPRECATED /* this macro is also defined in mysql_priv.h */ #define WARN_DEPRECATED(A,B) \ @@ -2239,9 +2239,9 @@ sp_proc_stmt: lex->tok_end otherwise. */ if (yychar == YYEMPTY) - i->m_query.length= lip->ptr - sp->m_tmp_query; + i->m_query.length= (uint) (lip->ptr - sp->m_tmp_query); else - i->m_query.length= lip->tok_end - sp->m_tmp_query; + i->m_query.length= (uint) (lip->tok_end - sp->m_tmp_query); if (!(i->m_query.str= strmake_root(thd->mem_root, sp->m_tmp_query, i->m_query.length)) || @@ -9027,9 +9027,10 @@ simple_ident: Item_splocal *splocal; splocal= new Item_splocal($1, spv->offset, spv->type, - lip->tok_start_prev - - lex->sphead->m_tmp_query, - lip->tok_end - lip->tok_start_prev); + (uint) (lip->tok_start_prev - + lex->sphead->m_tmp_query), + (uint) (lip->tok_end - + lip->tok_start_prev)); if (splocal == NULL) MYSQL_YYABORT; #ifndef DBUG_OFF @@ -9743,9 +9744,9 @@ option_type_value: lip->tok_end otherwise. */ if (yychar == YYEMPTY) - qbuff.length= lip->ptr - sp->m_tmp_query; + qbuff.length= (uint) (lip->ptr - sp->m_tmp_query); else - qbuff.length= lip->tok_end - sp->m_tmp_query; + qbuff.length= (uint) (lip->tok_end - sp->m_tmp_query); if (!(qbuff.str= alloc_root(thd->mem_root, qbuff.length + 5))) MYSQL_YYABORT; @@ -11065,7 +11066,7 @@ view_select_aux: char *stmt_beg= (lex->sphead ? (char *)lex->sphead->m_tmp_query : thd->query); - lex->create_view_select_start= $2 - stmt_beg; + lex->create_view_select_start= (uint) ($2 - stmt_beg); } | '(' remember_name select_paren ')' union_opt { @@ -11074,7 +11075,7 @@ view_select_aux: char *stmt_beg= (lex->sphead ? (char *)lex->sphead->m_tmp_query : thd->query); - lex->create_view_select_start= $2 - stmt_beg; + lex->create_view_select_start= (uint) ($2 - stmt_beg); } ; @@ -11119,7 +11120,7 @@ trigger_tail: lex->stmt_definition_begin= $2; lex->ident.str= $7; - lex->ident.length= $10 - $7; + lex->ident.length= (uint) ($10 - $7); lex->sphead= sp; lex->spname= $3; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index ce1a1a99b04..2896d5dffdc 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -16248,14 +16248,14 @@ static void test_bug38486(void) stmt= mysql_stmt_init(mysql); mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*)&type); stmt_text= "CREATE TABLE t1 (a INT)"; - mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + mysql_stmt_prepare(stmt, stmt_text, (ulong) strlen(stmt_text)); mysql_stmt_execute(stmt); mysql_stmt_close(stmt); stmt= mysql_stmt_init(mysql); mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*)&type); stmt_text= "INSERT INTO t1 VALUES (1)"; - mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + mysql_stmt_prepare(stmt, stmt_text, (ulong) strlen(stmt_text)); mysql_stmt_execute(stmt); mysql_stmt_close(stmt); From 1a4bc9a1e429697f86f63f2599e49a4f2d29cd32 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 16 Jul 2009 16:13:26 +0300 Subject: [PATCH 6/6] Bug #46042: backported the fix for the valgrind warning from 5.1 --- strings/strmake.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/strings/strmake.c b/strings/strmake.c index 05b5878d99c..acc220bbf1c 100644 --- a/strings/strmake.c +++ b/strings/strmake.c @@ -41,9 +41,9 @@ char *strmake(register char *dst, register const char *src, uint length) write a character rather than '\0' as this makes spotting these problems in the results easier. */ - uint n= strlen(src) + 1; - if (n <= length) - memset(dst + n, (int) 'Z', length - n + 1); + uint n= 0; + while (n < length && src[n++]); + memset(dst + n, (int) 'Z', length - n + 1); #endif while (length--)