From fc83f787cbe0d594d7794dc58abcda385567a69d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Nov 2006 11:10:49 +0300 Subject: [PATCH 01/39] Fix for bug bug#23651 "Server crashes when trigger which uses stored function invoked from different connections". Invocation of trigger which was using stored function from different connections caused server crashes (for non-debug server this happened in highly concurrent environment, but debug server failed on assertion in relatively simple scenario). Item_func_sp was not safe to use in triggers (in other words for re-execution from different threads) as artificial TABLE object pointed by Item_func_sp::dummy_table referenced incorrect THD object. To fix the problem we force re-initialization of this object for each re-execution of statement. mysql-test/r/trigger.result: Added test for bug#23651 "Server crashes when trigger which uses stored function invoked from different connections". mysql-test/t/trigger.test: Added test for bug#23651 "Server crashes when trigger which uses stored function invoked from different connections". sql/item_func.cc: To make Item_func_sp safe for usage in triggers (in other words safe for re-execution in different threads) we need to ensure that artificial TABLE object pointed by Item_func_sp::dummy_table references correct THD object. To achieve this we simply force its re-initialization for each re-execution of statement. --- mysql-test/r/trigger.result | 15 +++++++++++++++ mysql-test/t/trigger.test | 20 ++++++++++++++++++++ sql/item_func.cc | 1 + 3 files changed, 36 insertions(+) diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 5d643057666..9d3ab9b1d7d 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1241,4 +1241,19 @@ i j 2 2 13 13 drop table t1; +drop table if exists t1; +drop function if exists f1; +create table t1 (i int); +create function f1() returns int return 10; +create trigger t1_bi before insert on t1 for each row set @a:= f1() + 10; +insert into t1 values (); +select @a; +@a +20 +insert into t1 values (); +select @a; +@a +20 +drop table t1; +drop function f1; End of 5.0 tests diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 92320648033..81334f9b8ef 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1499,4 +1499,24 @@ select * from t1; drop table t1; +# +# Bug #23651 "Server crashes when trigger which uses stored function +# invoked from different connections". +# +--disable_warnings +drop table if exists t1; +drop function if exists f1; +--enable_warnings +create table t1 (i int); +create function f1() returns int return 10; +create trigger t1_bi before insert on t1 for each row set @a:= f1() + 10; +insert into t1 values (); +select @a; +connection addconroot1; +insert into t1 values (); +select @a; +connection default; +drop table t1; +drop function f1; + --echo End of 5.0 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index a294bbd7a71..fd3d282364a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4845,6 +4845,7 @@ Item_func_sp::cleanup() result_field= NULL; } m_sp= NULL; + dummy_table->s= NULL; Item_func::cleanup(); } From 541e9c9ac5ef31933beed881ea4171e2d7a38b97 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Nov 2006 15:40:22 -0700 Subject: [PATCH 02/39] Bug#23703 (DROP TRIGGER needs an IF EXISTS) This change set implements the DROP TRIGGER IF EXISTS functionality. This fix is considered a bug and not a feature, because without it, there is no known method to write a database creation script that can create a trigger without failing, when executed on a database that may or may not contain already a trigger of the same name. Implementing this functionality closes an orthogonality gap between triggers and stored procedures / stored functions (which do support the DROP IF EXISTS syntax). In sql_trigger.cc, in mysql_create_or_drop_trigger, the code has been reordered to: - perform the tests that do not depend on the file system (access()), - get the locks (wait_if_global_read_lock, LOCK_open) - call access() - perform the operation - write to the binlog - unlock (LOCK_open, start_waiting_global_read_lock) This is to ensure that all the code that depends on the presence of the trigger file is executed in the same critical section, and prevents race conditions similar to the case fixed by Bug 14262 : - thread 1 executes DROP TRIGGER IF EXISTS, access() returns a failure - thread 2 executes CREATE TRIGGER - thread 2 logs CREATE TRIGGER - thread 1 logs DROP TRIGGER IF EXISTS The patch itself is based on code contributed by the MySQL community, under the terms of the Contributor License Agreement (See Bug 18161). mysql-test/r/rpl_trigger.result: DROP TRIGGER IF EXISTS mysql-test/r/trigger.result: DROP TRIGGER IF EXISTS mysql-test/t/rpl_trigger.test: DROP TRIGGER IF EXISTS mysql-test/t/trigger.test: DROP TRIGGER IF EXISTS sql/sql_trigger.cc: DROP TRIGGER IF EXISTS sql/sql_yacc.yy: DROP TRIGGER IF EXISTS --- mysql-test/r/rpl_trigger.result | 27 +++++++++ mysql-test/r/trigger.result | 22 +++++++ mysql-test/t/rpl_trigger.test | 37 ++++++++++++ mysql-test/t/trigger.test | 28 +++++++++ sql/sql_trigger.cc | 104 +++++++++++++++++++++++--------- sql/sql_yacc.yy | 5 +- 6 files changed, 194 insertions(+), 29 deletions(-) diff --git a/mysql-test/r/rpl_trigger.result b/mysql-test/r/rpl_trigger.result index 3c740bf8e64..f8573eec75f 100644 --- a/mysql-test/r/rpl_trigger.result +++ b/mysql-test/r/rpl_trigger.result @@ -941,3 +941,30 @@ c ---> Cleaning up... DROP TABLE t1; DROP TABLE t2; +drop table if exists t1; +create table t1(a int, b varchar(50)); +drop trigger not_a_trigger; +ERROR HY000: Trigger does not exist +drop trigger if exists not_a_trigger; +Warnings: +Note 1360 Trigger does not exist +create trigger t1_bi before insert on t1 +for each row set NEW.b := "In trigger t1_bi"; +insert into t1 values (1, "a"); +drop trigger if exists t1_bi; +insert into t1 values (2, "b"); +drop trigger if exists t1_bi; +Warnings: +Note 1360 Trigger does not exist +insert into t1 values (3, "c"); +select * from t1; +a b +1 In trigger t1_bi +2 b +3 c +select * from t1; +a b +1 In trigger t1_bi +2 b +3 c +drop table t1; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 9d3ab9b1d7d..9f34f60eb1a 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1256,4 +1256,26 @@ select @a; 20 drop table t1; drop function f1; +drop table if exists t1; +create table t1(a int, b varchar(50)); +drop trigger not_a_trigger; +ERROR HY000: Trigger does not exist +drop trigger if exists not_a_trigger; +Warnings: +Note 1360 Trigger does not exist +create trigger t1_bi before insert on t1 +for each row set NEW.b := "In trigger t1_bi"; +insert into t1 values (1, "a"); +drop trigger if exists t1_bi; +insert into t1 values (2, "b"); +drop trigger if exists t1_bi; +Warnings: +Note 1360 Trigger does not exist +insert into t1 values (3, "c"); +select * from t1; +a b +1 In trigger t1_bi +2 b +3 c +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/rpl_trigger.test b/mysql-test/t/rpl_trigger.test index d6e9410b1d3..faba89e7a73 100644 --- a/mysql-test/t/rpl_trigger.test +++ b/mysql-test/t/rpl_trigger.test @@ -423,6 +423,43 @@ DROP TABLE t2; --sync_with_master --connection master +# +# BUG#23703: DROP TRIGGER needs an IF EXISTS +# + +connection master; + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1(a int, b varchar(50)); + +-- error ER_TRG_DOES_NOT_EXIST +drop trigger not_a_trigger; + +drop trigger if exists not_a_trigger; + +create trigger t1_bi before insert on t1 +for each row set NEW.b := "In trigger t1_bi"; + +insert into t1 values (1, "a"); +drop trigger if exists t1_bi; +insert into t1 values (2, "b"); +drop trigger if exists t1_bi; +insert into t1 values (3, "c"); + +select * from t1; + +save_master_pos; +connection slave; +sync_with_master; + +select * from t1; + +connection master; + +drop table t1; # # End of tests diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 81334f9b8ef..a9395c12a63 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1519,4 +1519,32 @@ connection default; drop table t1; drop function f1; +# +# Bug#23703: DROP TRIGGER needs an IF EXISTS +# + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1(a int, b varchar(50)); + +-- error ER_TRG_DOES_NOT_EXIST +drop trigger not_a_trigger; + +drop trigger if exists not_a_trigger; + +create trigger t1_bi before insert on t1 +for each row set NEW.b := "In trigger t1_bi"; + +insert into t1 values (1, "a"); +drop trigger if exists t1_bi; +insert into t1 values (2, "b"); +drop trigger if exists t1_bi; +insert into t1 values (3, "c"); + +select * from t1; + +drop table t1; + --echo End of 5.0 tests diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 95734d31411..3552fc596f3 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -107,7 +107,9 @@ const LEX_STRING trg_event_type_names[]= }; -static TABLE_LIST *add_table_for_trigger(THD *thd, sp_name *trig); +static int +add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists, + TABLE_LIST ** table); class Handle_old_incorrect_sql_modes_hook: public Unknown_key_hook { @@ -156,6 +158,13 @@ private: */ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) { + /* + FIXME: The code below takes too many different paths depending on the + 'create' flag, so that the justification for a single function + 'mysql_create_or_drop_trigger', compared to two separate functions + 'mysql_create_trigger' and 'mysql_drop_trigger' is not apparent. + This is a good candidate for a minor refactoring. + */ TABLE *table; bool result= TRUE; String stmt_query; @@ -181,10 +190,6 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) DBUG_RETURN(TRUE); } - if (!create && - !(tables= add_table_for_trigger(thd, thd->lex->spname))) - DBUG_RETURN(TRUE); - /* We don't allow creating triggers on tables in the 'mysql' schema */ @@ -194,9 +199,6 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) DBUG_RETURN(TRUE); } - /* We should have only one table in table list. */ - DBUG_ASSERT(tables->next_global == 0); - /* TODO: We should check if user has TRIGGER privilege for table here. Now we just require SUPER privilege for creating/dropping because @@ -211,7 +213,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) DROP for example) so we do the check for privileges. For now there is already a stronger test right above; but when this stronger test will be removed, the test below will hold. Because triggers have the same - nature as functions regarding binlogging: their body is implicitely + nature as functions regarding binlogging: their body is implicitly binlogged, so they share the same danger, so trust_function_creators applies to them too. */ @@ -222,24 +224,52 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) DBUG_RETURN(TRUE); } - /* We do not allow creation of triggers on temporary tables. */ - if (create && find_temporary_table(thd, tables->db, tables->table_name)) - { - my_error(ER_TRG_ON_VIEW_OR_TEMP_TABLE, MYF(0), tables->alias); - DBUG_RETURN(TRUE); - } - /* We don't want perform our operations while global read lock is held - so we have to wait until its end and then prevent it from occuring + so we have to wait until its end and then prevent it from occurring again until we are done. (Acquiring LOCK_open is not enough because - global read lock is held without helding LOCK_open). + global read lock is held without holding LOCK_open). */ if (wait_if_global_read_lock(thd, 0, 1)) DBUG_RETURN(TRUE); VOID(pthread_mutex_lock(&LOCK_open)); + if (!create) + { + bool if_exists= thd->lex->drop_if_exists; + + if (add_table_for_trigger(thd, thd->lex->spname, if_exists, & tables)) + goto end; + + if (!tables) + { + DBUG_ASSERT(if_exists); + /* + Since the trigger does not exist, there is no associated table, + and therefore : + - no TRIGGER privileges to check, + - no trigger to drop, + - no table to lock/modify, + so the drop statement is successful. + */ + result= FALSE; + /* Still, we need to log the query ... */ + stmt_query.append(thd->query, thd->query_length); + goto end; + } + } + + /* We should have only one table in table list. */ + DBUG_ASSERT(tables->next_global == 0); + + /* We do not allow creation of triggers on temporary tables. */ + if (create && find_temporary_table(thd, tables->db, tables->table_name)) + { + my_error(ER_TRG_ON_VIEW_OR_TEMP_TABLE, MYF(0), tables->alias); + goto end; + } + if (lock_table_names(thd, tables)) goto end; @@ -1145,13 +1175,17 @@ bool Table_triggers_list::get_trigger_info(THD *thd, trg_event_type event, mysql_table_for_trigger() thd - current thread context trig - identifier for trigger + if_exists - treat a not existing trigger as a warning if TRUE + table - pointer to TABLE_LIST object for the table trigger (output) RETURN VALUE - 0 - error - # - pointer to TABLE_LIST object for the table + 0 Success + 1 Error */ -static TABLE_LIST *add_table_for_trigger(THD *thd, sp_name *trig) +static int +add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists, + TABLE_LIST **table) { LEX *lex= thd->lex; char path_buff[FN_REFLEN]; @@ -1162,6 +1196,7 @@ static TABLE_LIST *add_table_for_trigger(THD *thd, sp_name *trig) path_buff, &trigname.trigger_table); DBUG_ENTER("add_table_for_trigger"); + DBUG_ASSERT(table != NULL); strxnmov(path_buff, FN_REFLEN, mysql_data_home, "/", trig->m_db.str, "/", trig->m_name.str, trigname_file_ext, NullS); @@ -1170,30 +1205,45 @@ static TABLE_LIST *add_table_for_trigger(THD *thd, sp_name *trig) if (access(path_buff, F_OK)) { + if (if_exists) + { + push_warning_printf(thd, + MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_TRG_DOES_NOT_EXIST, + ER(ER_TRG_DOES_NOT_EXIST)); + *table= NULL; + DBUG_RETURN(0); + } + my_error(ER_TRG_DOES_NOT_EXIST, MYF(0)); - DBUG_RETURN(0); + DBUG_RETURN(1); } if (!(parser= sql_parse_prepare(&path, thd->mem_root, 1))) - DBUG_RETURN(0); + DBUG_RETURN(1); if (!is_equal(&trigname_file_type, parser->type())) { my_error(ER_WRONG_OBJECT, MYF(0), trig->m_name.str, trigname_file_ext+1, "TRIGGERNAME"); - DBUG_RETURN(0); + DBUG_RETURN(1); } if (parser->parse((gptr)&trigname, thd->mem_root, trigname_file_parameters, 1, &trigger_table_hook)) - DBUG_RETURN(0); + DBUG_RETURN(1); /* We need to reset statement table list to be PS/SP friendly. */ lex->query_tables= 0; lex->query_tables_last= &lex->query_tables; - DBUG_RETURN(sp_add_to_query_tables(thd, lex, trig->m_db.str, - trigname.trigger_table.str, TL_IGNORE)); + *table= sp_add_to_query_tables(thd, lex, trig->m_db.str, + trigname.trigger_table.str, TL_IGNORE); + + if (! *table) + DBUG_RETURN(1); + + DBUG_RETURN(0); } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6f24a42c07c..21325123baa 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -6098,11 +6098,12 @@ drop: lex->sql_command= SQLCOM_DROP_VIEW; lex->drop_if_exists= $3; } - | DROP TRIGGER_SYM sp_name + | DROP TRIGGER_SYM if_exists sp_name { LEX *lex= Lex; lex->sql_command= SQLCOM_DROP_TRIGGER; - lex->spname= $3; + lex->drop_if_exists= $3; + lex->spname= $4; } ; From e40e8052e89ada24a79c827cf38271beed756759 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Nov 2006 13:21:38 +0300 Subject: [PATCH 03/39] BUG#17047: CHAR() and IN() can return NULL without signaling NULL result The problem was that some functions (namely IN() starting with 4.1, and CHAR() starting with 5.0) were returning NULL in certain conditions, while they didn't set their maybe_null flag. Because of that there could be some problems with 'IS NULL' check, and statements that depend on the function value domain, like CREATE TABLE t1 SELECT 1 IN (2, NULL);. The fix is to set maybe_null correctly. mysql-test/r/func_in.result: Add result for bug#17047: CHAR() and IN() can return NULL without signaling NULL result. mysql-test/t/func_in.test: Add test case for bug#17047: CHAR() and IN() can return NULL without signaling NULL result. sql/item_cmpfunc.cc: Remove assignment to maybe_null, as it was already set in fix_fields() based on all arguments, not only on the first. --- mysql-test/r/func_in.result | 8 ++++++++ mysql-test/t/func_in.test | 22 +++++++++++++++++++++- sql/item_cmpfunc.cc | 1 - 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index 3cf2afc83d1..f74c63f7260 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -202,3 +202,11 @@ select count(*) from t1 where id not in (1,2); count(*) 1 drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 2ffe5a2d5f7..ffed2aac2a0 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -109,4 +109,24 @@ select count(*) from t1 where id not in (1); select count(*) from t1 where id not in (1,2); drop table t1; -# End of 4.1 tests + +# +# BUG#17047: CHAR() and IN() can return NULL without signaling NULL +# result +# +# The problem was in the IN() function that ignored maybe_null flags +# of all arguments except the first (the one _before_ the IN +# keyword, '1' in the test case below). +# +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 SELECT 1 IN (2, NULL); +--echo SELECT should return NULL. +SELECT * FROM t1; + +DROP TABLE t1; + + +--echo End of 4.1 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 6b6996160a1..859b4e0ecc1 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1998,7 +1998,6 @@ void Item_func_in::fix_length_and_dec() if (cmp_type == STRING_RESULT) in_item->cmp_charset= cmp_collation.collation; } - maybe_null= args[0]->maybe_null; max_length= 1; } From af22eb35e577ef17226faf662f2cffc4705bde26 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Nov 2006 14:06:51 +0300 Subject: [PATCH 04/39] Add 5.0 part of fix for bug 17047. mysql-test/r/func_str.result: Add result for bug#17047: CHAR() and IN() can return NULL without signaling NULL result. mysql-test/t/func_str.test: Add test case for bug#17047: CHAR() and IN() can return NULL without signaling NULL result. sql/item_strfunc.cc: Add Item_str_func::fix_fields() implementation, and set maybe_null to TRUE if we are in the SQL mode that requires some functions to return null even if they normally do not. sql/item_strfunc.h: Add declaration of Item_str_func::fix_fields(). Do not reset maybe_null in Item_func_char::fix_length_and_dec(). --- mysql-test/r/func_str.result | 13 +++++++++++++ mysql-test/t/func_str.test | 14 ++++++++++++++ sql/item_strfunc.cc | 14 ++++++++++++++ sql/item_strfunc.h | 6 +++--- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index c2c12f8d291..9588827d234 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -1148,4 +1148,17 @@ id select_type table type possible_keys key key_len ref rows Extra Warnings: Note 1003 select `test`.`t1`.`code` AS `code`,`test`.`t2`.`id` AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = _latin1'a12') and (length(`test`.`t1`.`code`) = 5)) DROP TABLE t1,t2; +SET @orig_sql_mode = @@SQL_MODE; +SET SQL_MODE=traditional; +SELECT CHAR(0xff,0x8f USING utf8); +CHAR(0xff,0x8f USING utf8) +NULL +Warnings: +Error 1300 Invalid utf8 character string: 'FF8F' +SELECT CHAR(0xff,0x8f USING utf8) IS NULL; +CHAR(0xff,0x8f USING utf8) IS NULL +1 +Warnings: +Error 1300 Invalid utf8 character string: 'FF8F' +SET SQL_MODE=@orig_sql_mode; End of 5.0 tests diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 45415882ac7..9255669f6e3 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -780,4 +780,18 @@ SELECT * FROM t1 INNER JOIN t2 ON code=id DROP TABLE t1,t2; + +# +# BUG#17047: CHAR() and IN() can return NULL without signaling NULL +# result +# +SET @orig_sql_mode = @@SQL_MODE; +SET SQL_MODE=traditional; + +SELECT CHAR(0xff,0x8f USING utf8); +SELECT CHAR(0xff,0x8f USING utf8) IS NULL; + +SET SQL_MODE=@orig_sql_mode; + + --echo End of 5.0 tests diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 31c2f44fc3e..b54f8fef90c 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -80,6 +80,20 @@ String *Item_str_func::check_well_formed_result(String *str) } +bool Item_str_func::fix_fields(THD *thd, Item **ref) +{ + bool res= Item_func::fix_fields(thd, ref); + /* + In Item_str_func::check_well_formed_result() we may set null_value + flag on the same condition as in test() below. + */ + maybe_null= (maybe_null || + test(thd->variables.sql_mode & + (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))); + return res; +} + + my_decimal *Item_str_func::val_decimal(my_decimal *decimal_value) { DBUG_ASSERT(fixed == 1); diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 528180b803d..fd2aaf19675 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -37,6 +37,7 @@ public: enum Item_result result_type () const { return STRING_RESULT; } void left_right_max_length(); String *check_well_formed_result(String *str); + bool fix_fields(THD *thd, Item **ref); }; class Item_func_md5 :public Item_str_func @@ -525,9 +526,8 @@ public: { collation.set(cs); } String *val_str(String *); void fix_length_and_dec() - { - maybe_null=0; - max_length=arg_count * collation.collation->mbmaxlen; + { + max_length= arg_count * collation.collation->mbmaxlen; } const char *func_name() const { return "char"; } }; From 779f9feda89f363a5b7a8baf4ecaaf57c5a4b75b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Nov 2006 08:18:10 +0200 Subject: [PATCH 05/39] Fix of debbuging mode of query cache (proposed by Monty reviewed by me). sql/sql_cache.cc: Call of BLOCK_UNLOCK_WR() moved before query_cache.check_integrity() call which privent lock of query cache during debugging. Comments added. --- sql/sql_cache.cc | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index ff033b69f98..1d8c79d0a1a 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -702,6 +702,7 @@ void query_cache_abort(NET *net) void query_cache_end_of_result(THD *thd) { + Query_cache_block *query_block; DBUG_ENTER("query_cache_end_of_result"); /* See the comment on double-check locking usage above. */ @@ -717,13 +718,9 @@ void query_cache_end_of_result(THD *thd) if (unlikely(query_cache.query_cache_size == 0 || query_cache.flush_in_progress)) - { - STRUCT_UNLOCK(&query_cache.structure_guard_mutex); - DBUG_VOID_RETURN; - } + goto end; - Query_cache_block *query_block= ((Query_cache_block*) - thd->net.query_cache_query); + query_block= ((Query_cache_block*) thd->net.query_cache_query); if (query_block) { DUMP(&query_cache); @@ -742,27 +739,25 @@ void query_cache_end_of_result(THD *thd) header->query())); query_cache.wreck(__LINE__, ""); - STRUCT_UNLOCK(&query_cache.structure_guard_mutex); - - DBUG_VOID_RETURN; + /* + We do not need call of BLOCK_UNLOCK_WR(query_block); here because + query_cache.wreck() switched query cache off but left content + untouched for investigation (it is debugging method). + */ + goto end; } #endif header->found_rows(current_thd->limit_found_rows); header->result()->type= Query_cache_block::RESULT; header->writer(0); thd->net.query_cache_query= 0; + BLOCK_UNLOCK_WR(query_block); DBUG_EXECUTE("check_querycache",query_cache.check_integrity(1);); - STRUCT_UNLOCK(&query_cache.structure_guard_mutex); - - BLOCK_UNLOCK_WR(query_block); - } - else - { - // Cache was flushed or resized and query was deleted => do nothing - STRUCT_UNLOCK(&query_cache.structure_guard_mutex); } +end: + STRUCT_UNLOCK(&query_cache.structure_guard_mutex); DBUG_VOID_RETURN; } @@ -3529,7 +3524,7 @@ uint Query_cache::filename_2_table_key (char *key, const char *path, #if defined(DBUG_OFF) && !defined(USE_QUERY_CACHE_INTEGRITY_CHECK) -void wreck(uint line, const char *message) {} +void wreck(uint line, const char *message) { query_cache_size = 0; } void bins_dump() {} void cache_dump() {} void queries_dump() {} @@ -3541,6 +3536,17 @@ my_bool in_blocks(Query_cache_block * point) { return 0; } #else + +/* + Debug method which switch query cache off but left content for + investigation. + + SYNOPSIS + Query_cache::wreck() + line line of the wreck() call + message message for logging +*/ + void Query_cache::wreck(uint line, const char *message) { THD *thd=current_thd; From 2d04b1914de45129569d08dceb74f647f3004563 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Nov 2006 12:21:32 +0300 Subject: [PATCH 06/39] BUG#23383: mysql_affected_rows() returns different values than mysql_stmt_affected_rows() The problem was that affected_rows for prepared statement wasn't updated in the client library on the error. The solution is to always update affected_rows, which will be equal to -1 on the error. libmysql/libmysql.c: Update status variables even in the case of an error. Some variables have a defined value on the error (like affected_rows is -1), others are undefined, so updating them won't harm. libmysqld/lib_sql.cc: Update status variables even in the case of an error. Some variables have a defined value on the error (like affected_rows is -1), others are undefined, so updating them won't harm. tests/mysql_client_test.c: Add test for bug#23383: mysql_affected_rows() returns different values than mysql_stmt_affected_rows(). --- libmysql/libmysql.c | 14 ++++--- libmysqld/lib_sql.cc | 14 ++++--- tests/mysql_client_test.c | 78 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 10 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 91c0b6b8864..a4dc382bc37 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2496,6 +2496,8 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) NET *net= &mysql->net; char buff[4 /* size of stmt id */ + 5 /* execution flags */]; + my_bool res; + DBUG_ENTER("execute"); DBUG_PRINT("enter",("packet: %s, length :%d",packet ? packet :" ", length)); @@ -2503,15 +2505,17 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) int4store(buff, stmt->stmt_id); /* Send stmt id to server */ buff[4]= (char) 0; /* no flags */ int4store(buff+5, 1); /* iteration count */ - if (cli_advanced_command(mysql, COM_EXECUTE, buff, sizeof(buff), - packet, length, 1, NULL) || - (*mysql->methods->read_query_result)(mysql)) + + res= test(cli_advanced_command(mysql, COM_EXECUTE, buff, sizeof(buff), + packet, length, 1, NULL) || + (*mysql->methods->read_query_result)(mysql)); + stmt->affected_rows= mysql->affected_rows; + stmt->insert_id= mysql->insert_id; + if (res) { set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); DBUG_RETURN(1); } - stmt->affected_rows= mysql->affected_rows; - stmt->insert_id= mysql->insert_id; DBUG_RETURN(0); } diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 1a3e10f08a8..93d47595010 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -224,20 +224,24 @@ static int emb_stmt_execute(MYSQL_STMT *stmt) { DBUG_ENTER("emb_stmt_execute"); char header[4]; + my_bool res; + int4store(header, stmt->stmt_id); THD *thd= (THD*)stmt->mysql->thd; thd->client_param_count= stmt->param_count; thd->client_params= stmt->params; - if (emb_advanced_command(stmt->mysql, COM_EXECUTE,0,0, - header, sizeof(header), 1, stmt) || - emb_mysql_read_query_result(stmt->mysql)) + + res= test(emb_advanced_command(stmt->mysql, COM_EXECUTE,0,0, + header, sizeof(header), 1, stmt) || + emb_mysql_read_query_result(stmt->mysql)); + stmt->affected_rows= stmt->mysql->affected_rows; + stmt->insert_id= stmt->mysql->insert_id; + if (res) { NET *net= &stmt->mysql->net; set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); DBUG_RETURN(1); } - stmt->affected_rows= stmt->mysql->affected_rows; - stmt->insert_id= stmt->mysql->insert_id; DBUG_RETURN(0); } diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index b1ee144e517..e123b2e42ae 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -11949,6 +11949,83 @@ static void test_bug21726() } +/* + BUG#23383: mysql_affected_rows() returns different values than + mysql_stmt_affected_rows() + + Test that both mysql_affected_rows() and mysql_stmt_affected_rows() + return -1 on error, 0 when no rows were affected, and (positive) row + count when some rows were affected. +*/ +static void test_bug23383() +{ + const char *insert_query= "INSERT INTO t1 VALUES (1), (2)"; + const char *update_query= "UPDATE t1 SET i= 4 WHERE i = 3"; + MYSQL_STMT *stmt; + my_ulonglong row_count; + int rc; + + DBUG_ENTER("test_bug23383"); + myheader("test_bug23383"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + myquery(rc); + + rc= mysql_query(mysql, "CREATE TABLE t1 (i INT UNIQUE)"); + myquery(rc); + + rc= mysql_query(mysql, insert_query); + myquery(rc); + row_count= mysql_affected_rows(mysql); + DIE_UNLESS(row_count == 2); + + rc= mysql_query(mysql, insert_query); + DIE_UNLESS(rc != 0); + row_count= mysql_affected_rows(mysql); + DIE_UNLESS(row_count == (my_ulonglong)-1); + + rc= mysql_query(mysql, update_query); + myquery(rc); + row_count= mysql_affected_rows(mysql); + DIE_UNLESS(row_count == 0); + + rc= mysql_query(mysql, "DELETE FROM t1"); + myquery(rc); + + stmt= mysql_stmt_init(mysql); + DIE_UNLESS(stmt != 0); + + rc= mysql_stmt_prepare(stmt, insert_query, strlen(insert_query)); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + row_count= mysql_stmt_affected_rows(stmt); + DIE_UNLESS(row_count == 2); + + rc= mysql_stmt_execute(stmt); + DIE_UNLESS(rc != 0); + row_count= mysql_stmt_affected_rows(stmt); + DIE_UNLESS(row_count == (my_ulonglong)-1); + + rc= mysql_stmt_prepare(stmt, update_query, strlen(update_query)); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + row_count= mysql_stmt_affected_rows(stmt); + DIE_UNLESS(row_count == 0); + + rc= mysql_stmt_close(stmt); + check_execute(stmt, rc); + + rc= mysql_query(mysql, "DROP TABLE t1"); + myquery(rc); + + DBUG_VOID_RETURN; +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -12176,6 +12253,7 @@ static struct my_tests_st my_tests[]= { { "test_bug15613", test_bug15613 }, { "test_bug20152", test_bug20152 }, { "test_bug21726", test_bug21726 }, + { "test_bug23383", test_bug23383 }, { 0, 0 } }; From 847e687327152b9f3a91f03444ea00e7874f7c12 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Nov 2006 13:56:11 +0300 Subject: [PATCH 07/39] Fix after manual merge: remove dead declaration. --- libmysqld/lib_sql.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index a33e7fa6100..93b1ed5c81d 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -277,7 +277,6 @@ static int emb_stmt_execute(MYSQL_STMT *stmt) { DBUG_ENTER("emb_stmt_execute"); char header[5]; - MYSQL_DATA *res; THD *thd; my_bool res; From 26dee875879e0149de0f4d97f3935ed716eab183 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Nov 2006 16:09:37 +0100 Subject: [PATCH 08/39] Maintain the (old) VC project files, ehere yaSSL is concerned: "mySTL" has become a subdirectory of "taocrypt", was a sibling previously. extra/yassl/taocrypt/benchmark/benchmark.dsp: "mySTL" has become a subdirectory of "taocrypt", was a sibling previously - adapt. extra/yassl/taocrypt/taocrypt.dsp: "mySTL" has become a subdirectory of "taocrypt", was a sibling previously - adapt. extra/yassl/taocrypt/taocrypt.vcproj: "mySTL" has become a subdirectory of "taocrypt", was a sibling previously - adapt. extra/yassl/taocrypt/test.dsp: "mySTL" has become a subdirectory of "taocrypt", was a sibling previously - adapt. extra/yassl/testsuite/testsuite.dsp: "mySTL" has become a subdirectory of "taocrypt", was a sibling previously - adapt. extra/yassl/yassl.dsp: "mySTL" has become a subdirectory of "taocrypt", was a sibling previously - adapt. extra/yassl/yassl.vcproj: "mySTL" has become a subdirectory of "taocrypt", was a sibling previously - adapt. --- extra/yassl/taocrypt/benchmark/benchmark.dsp | 4 ++-- extra/yassl/taocrypt/taocrypt.dsp | 4 ++-- extra/yassl/taocrypt/taocrypt.vcproj | 4 ++-- extra/yassl/taocrypt/test.dsp | 4 ++-- extra/yassl/testsuite/testsuite.dsp | 4 ++-- extra/yassl/yassl.dsp | 4 ++-- extra/yassl/yassl.vcproj | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/extra/yassl/taocrypt/benchmark/benchmark.dsp b/extra/yassl/taocrypt/benchmark/benchmark.dsp index ed8fef316bb..878dc2b2783 100644 --- a/extra/yassl/taocrypt/benchmark/benchmark.dsp +++ b/extra/yassl/taocrypt/benchmark/benchmark.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\include" /I "..\..\mySTL" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\include" /I "..\mySTL" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -65,7 +65,7 @@ LINK32=link.exe # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\..\mySTL" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\mySTL" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/extra/yassl/taocrypt/taocrypt.dsp b/extra/yassl/taocrypt/taocrypt.dsp index 19edf7b2f22..3f1b47990ad 100644 --- a/extra/yassl/taocrypt/taocrypt.dsp +++ b/extra/yassl/taocrypt/taocrypt.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "include" /I "..\mySTL" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "include" /I "mySTL" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -64,7 +64,7 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "include" /I "..\mySTL" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "include" /I "mySTL" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # SUBTRACT CPP /Fr # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" diff --git a/extra/yassl/taocrypt/taocrypt.vcproj b/extra/yassl/taocrypt/taocrypt.vcproj index 7eef7b82db7..7ffcb664346 100755 --- a/extra/yassl/taocrypt/taocrypt.vcproj +++ b/extra/yassl/taocrypt/taocrypt.vcproj @@ -21,7 +21,7 @@ Date: Tue, 21 Nov 2006 16:49:18 +0300 Subject: [PATCH 09/39] BUG#23159: prepared_stmt_count should be status variable Make Prepared_stmt_count a global status variable, accessible via SHOW STATUS LIKE 'Prepared_stmt_count';. Documentation should be updated. mysql-test/r/ps.result: Update result for bug#16365: Prepared Statements: DoS with too many open statements, according to bug#23159: prepared_stmt_count should be status variable. mysql-test/t/ps.test: Update test case for bug#16365: Prepared Statements: DoS with too many open statements, according to bug#23159: prepared_stmt_count should be status variable. sql/mysqld.cc: Add Prepared_stmt_count as global status variable. sql/set_var.cc: Remove prepared_stmt_count as system variable. --- mysql-test/r/ps.result | 101 +++++++++++++++++++++-------------------- mysql-test/t/ps.test | 57 ++++++++++------------- sql/mysqld.cc | 2 + sql/set_var.cc | 14 ------ 4 files changed, 79 insertions(+), 95 deletions(-) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 2bb5df6e6cf..94c51fdc18b 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -775,12 +775,12 @@ set @old_max_prepared_stmt_count= @@max_prepared_stmt_count; show variables like 'max_prepared_stmt_count'; Variable_name Value max_prepared_stmt_count 16382 -show variables like 'prepared_stmt_count'; +show status like 'prepared_stmt_count'; Variable_name Value -prepared_stmt_count 0 -select @@max_prepared_stmt_count, @@prepared_stmt_count; -@@max_prepared_stmt_count @@prepared_stmt_count -16382 0 +Prepared_stmt_count 0 +select @@max_prepared_stmt_count; +@@max_prepared_stmt_count +16382 set global max_prepared_stmt_count=-1; select @@max_prepared_stmt_count; @@max_prepared_stmt_count @@ -799,67 +799,70 @@ set max_prepared_stmt_count=1; ERROR HY000: Variable 'max_prepared_stmt_count' is a GLOBAL variable and should be set with SET GLOBAL set local max_prepared_stmt_count=1; ERROR HY000: Variable 'max_prepared_stmt_count' is a GLOBAL variable and should be set with SET GLOBAL -set local prepared_stmt_count=0; -ERROR HY000: Variable 'prepared_stmt_count' is a GLOBAL variable and should be set with SET GLOBAL -set @@prepared_stmt_count=0; -ERROR HY000: Variable 'prepared_stmt_count' is a GLOBAL variable and should be set with SET GLOBAL -set global prepared_stmt_count=1; -ERROR 42000: Incorrect argument type to variable 'prepared_stmt_count' set global max_prepared_stmt_count=1; select @@max_prepared_stmt_count; @@max_prepared_stmt_count 1 set global max_prepared_stmt_count=0; -select @@max_prepared_stmt_count, @@prepared_stmt_count; -@@max_prepared_stmt_count @@prepared_stmt_count -0 0 +select @@max_prepared_stmt_count; +@@max_prepared_stmt_count +0 +show status like 'prepared_stmt_count'; +Variable_name Value +Prepared_stmt_count 0 prepare stmt from "select 1"; ERROR HY000: Unknown error -select @@prepared_stmt_count; -@@prepared_stmt_count -0 +show status like 'prepared_stmt_count'; +Variable_name Value +Prepared_stmt_count 0 set global max_prepared_stmt_count=1; prepare stmt from "select 1"; -select @@prepared_stmt_count; -@@prepared_stmt_count -1 +show status like 'prepared_stmt_count'; +Variable_name Value +Prepared_stmt_count 1 prepare stmt1 from "select 1"; ERROR HY000: Unknown error -select @@prepared_stmt_count; -@@prepared_stmt_count -1 +show status like 'prepared_stmt_count'; +Variable_name Value +Prepared_stmt_count 1 deallocate prepare stmt; -select @@prepared_stmt_count; -@@prepared_stmt_count -0 +show status like 'prepared_stmt_count'; +Variable_name Value +Prepared_stmt_count 0 prepare stmt from "select 1"; -select @@prepared_stmt_count; -@@prepared_stmt_count -1 +show status like 'prepared_stmt_count'; +Variable_name Value +Prepared_stmt_count 1 prepare stmt from "select 2"; -select @@prepared_stmt_count; -@@prepared_stmt_count +show status like 'prepared_stmt_count'; +Variable_name Value +Prepared_stmt_count 1 +show status like 'prepared_stmt_count'; +Variable_name Value +Prepared_stmt_count 1 +select @@max_prepared_stmt_count; +@@max_prepared_stmt_count 1 -select @@prepared_stmt_count, @@max_prepared_stmt_count; -@@prepared_stmt_count @@max_prepared_stmt_count -1 1 set global max_prepared_stmt_count=0; prepare stmt from "select 1"; ERROR HY000: Unknown error execute stmt; ERROR HY000: Unknown prepared statement handler (stmt) given to EXECUTE -select @@prepared_stmt_count; -@@prepared_stmt_count -0 +show status like 'prepared_stmt_count'; +Variable_name Value +Prepared_stmt_count 0 prepare stmt from "select 1"; ERROR HY000: Unknown error -select @@prepared_stmt_count; -@@prepared_stmt_count -0 +show status like 'prepared_stmt_count'; +Variable_name Value +Prepared_stmt_count 0 set global max_prepared_stmt_count=3; -select @@max_prepared_stmt_count, @@prepared_stmt_count; -@@max_prepared_stmt_count @@prepared_stmt_count -3 0 +select @@max_prepared_stmt_count; +@@max_prepared_stmt_count +3 +show status like 'prepared_stmt_count'; +Variable_name Value +Prepared_stmt_count 0 prepare stmt from "select 1"; prepare stmt from "select 2"; prepare stmt1 from "select 3"; @@ -867,13 +870,13 @@ prepare stmt2 from "select 4"; ERROR HY000: Unknown error prepare stmt2 from "select 4"; ERROR HY000: Unknown error -select @@max_prepared_stmt_count, @@prepared_stmt_count; -@@max_prepared_stmt_count @@prepared_stmt_count -3 3 +select @@max_prepared_stmt_count; +@@max_prepared_stmt_count +3 +show status like 'prepared_stmt_count'; +Variable_name Value +Prepared_stmt_count 3 deallocate prepare stmt; -select @@max_prepared_stmt_count, @@prepared_stmt_count; -@@max_prepared_stmt_count @@prepared_stmt_count -3 0 set global max_prepared_stmt_count= @old_max_prepared_stmt_count; drop table if exists t1; create temporary table if not exists t1 (a1 int); diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 5b488ae4393..fbeaaa494e0 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -811,6 +811,9 @@ drop table t1; # Bug#16365 Prepared Statements: DoS with too many open statements # Check that the limit @@max_prpeared_stmt_count works. # +# This is also the test for bug#23159 prepared_stmt_count should be +# status variable. +# # Save the old value set @old_max_prepared_stmt_count= @@max_prepared_stmt_count; # @@ -820,17 +823,17 @@ set @old_max_prepared_stmt_count= @@max_prepared_stmt_count; # --disable_ps_protocol # -# A. Check that the new variables are present in SHOW VARIABLES list. +# A. Check that the new variables are present in SHOW VARIABLES and +# SHOW STATUS lists. # show variables like 'max_prepared_stmt_count'; -show variables like 'prepared_stmt_count'; +show status like 'prepared_stmt_count'; # -# B. Check that the new variables are selectable. +# B. Check that the new system variable is selectable. # -select @@max_prepared_stmt_count, @@prepared_stmt_count; +select @@max_prepared_stmt_count; # -# C. Check that max_prepared_stmt_count is settable (global only), -# whereas prepared_stmt_count is readonly. +# C. Check that max_prepared_stmt_count is settable (global only). # set global max_prepared_stmt_count=-1; select @@max_prepared_stmt_count; @@ -844,12 +847,6 @@ set @@max_prepared_stmt_count=1; set max_prepared_stmt_count=1; --error 1229 # ER_GLOBAL_VARIABLE set local max_prepared_stmt_count=1; ---error 1229 # ER_GLOBAL_VARIABLE -set local prepared_stmt_count=0; ---error 1229 # ER_GLOBAL_VARIABLE -set @@prepared_stmt_count=0; ---error 1232 # ER_WRONG_TYPE_FOR_VAR -set global prepared_stmt_count=1; # set to a reasonable limit works set global max_prepared_stmt_count=1; select @@max_prepared_stmt_count; @@ -857,47 +854,50 @@ select @@max_prepared_stmt_count; # D. Check that the variables actually work. # set global max_prepared_stmt_count=0; -select @@max_prepared_stmt_count, @@prepared_stmt_count; +select @@max_prepared_stmt_count; +show status like 'prepared_stmt_count'; --error 1105 # ER_UNKNOWN_ERROR prepare stmt from "select 1"; -select @@prepared_stmt_count; +show status like 'prepared_stmt_count'; set global max_prepared_stmt_count=1; prepare stmt from "select 1"; -select @@prepared_stmt_count; +show status like 'prepared_stmt_count'; --error 1105 # ER_UNKNOWN_ERROR prepare stmt1 from "select 1"; -select @@prepared_stmt_count; +show status like 'prepared_stmt_count'; deallocate prepare stmt; -select @@prepared_stmt_count; +show status like 'prepared_stmt_count'; # # E. Check that we can prepare a statement with the same name # successfully, without hitting the limit. # prepare stmt from "select 1"; -select @@prepared_stmt_count; +show status like 'prepared_stmt_count'; prepare stmt from "select 2"; -select @@prepared_stmt_count; +show status like 'prepared_stmt_count'; # # F. We can set the max below the current count. In this case no new # statements should be allowed to prepare. # -select @@prepared_stmt_count, @@max_prepared_stmt_count; +show status like 'prepared_stmt_count'; +select @@max_prepared_stmt_count; set global max_prepared_stmt_count=0; --error 1105 # ER_UNKNOWN_ERROR prepare stmt from "select 1"; # Result: the old statement is deallocated, the new is not created. --error 1243 # ER_UNKNOWN_STMT_HANDLER execute stmt; -select @@prepared_stmt_count; +show status like 'prepared_stmt_count'; --error 1105 # ER_UNKNOWN_ERROR prepare stmt from "select 1"; -select @@prepared_stmt_count; +show status like 'prepared_stmt_count'; # # G. Show that the variables are up to date even after a connection with all # statements in it was terminated. # set global max_prepared_stmt_count=3; -select @@max_prepared_stmt_count, @@prepared_stmt_count; +select @@max_prepared_stmt_count; +show status like 'prepared_stmt_count'; prepare stmt from "select 1"; connect (con1,localhost,root,,); connection con1; @@ -908,18 +908,11 @@ prepare stmt2 from "select 4"; connection default; --error 1105 # ER_UNKNOWN_ERROR prepare stmt2 from "select 4"; -select @@max_prepared_stmt_count, @@prepared_stmt_count; +select @@max_prepared_stmt_count; +show status like 'prepared_stmt_count'; disconnect con1; connection default; -# Wait for the connection to die: deal with a possible race deallocate prepare stmt; -let $count= `select @@prepared_stmt_count`; -if ($count) -{ ---sleep 2 - let $count= `select @@prepared_stmt_count`; -} -select @@max_prepared_stmt_count, @@prepared_stmt_count; # # Restore the old value. # diff --git a/sql/mysqld.cc b/sql/mysqld.cc index dbb1838c3d7..3327224be46 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5722,6 +5722,7 @@ struct show_var_st status_vars[]= { {"Open_streams", (char*) &my_stream_opened, SHOW_LONG_CONST}, {"Open_tables", (char*) 0, SHOW_OPENTABLES}, {"Opened_tables", (char*) &opened_tables, SHOW_LONG}, + {"Prepared_stmt_count", (char*) &prepared_stmt_count, SHOW_LONG_CONST}, #ifdef HAVE_QUERY_CACHE {"Qcache_free_blocks", (char*) &query_cache.free_memory_blocks, SHOW_LONG_CONST}, @@ -5892,6 +5893,7 @@ static void mysql_init_variables(void) binlog_cache_use= binlog_cache_disk_use= 0; max_used_connections= slow_launch_threads = 0; mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0; + prepared_stmt_count= 0; errmesg= 0; mysqld_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS; bzero((gptr) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list)); diff --git a/sql/set_var.cc b/sql/set_var.cc index 4433b6bf7d8..71ca382f9d9 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -119,7 +119,6 @@ static KEY_CACHE *create_key_cache(const char *name, uint length); void fix_sql_mode_var(THD *thd, enum_var_type type); static byte *get_error_count(THD *thd); static byte *get_warning_count(THD *thd); -static byte *get_prepared_stmt_count(THD *thd); static byte *get_have_innodb(THD *thd); /* @@ -482,9 +481,6 @@ static sys_var_readonly sys_warning_count("warning_count", OPT_SESSION, SHOW_LONG, get_warning_count); -static sys_var_readonly sys_prepared_stmt_count("prepared_stmt_count", - OPT_GLOBAL, SHOW_LONG, - get_prepared_stmt_count); /* alias for last_insert_id() to be compatible with Sybase */ #ifdef HAVE_REPLICATION @@ -604,7 +600,6 @@ sys_var *sys_variables[]= &sys_new_mode, &sys_old_passwords, &sys_preload_buff_size, - &sys_prepared_stmt_count, &sys_pseudo_thread_id, &sys_query_alloc_block_size, &sys_query_cache_size, @@ -860,7 +855,6 @@ struct show_var_st init_vars[]= { {"pid_file", (char*) pidfile_name, SHOW_CHAR}, {"port", (char*) &mysqld_port, SHOW_INT}, {sys_preload_buff_size.name, (char*) &sys_preload_buff_size, SHOW_SYS}, - {sys_prepared_stmt_count.name, (char*) &sys_prepared_stmt_count, SHOW_SYS}, {"protocol_version", (char*) &protocol_version, SHOW_INT}, {sys_query_alloc_block_size.name, (char*) &sys_query_alloc_block_size, SHOW_SYS}, @@ -2715,14 +2709,6 @@ static byte *get_have_innodb(THD *thd) } -static byte *get_prepared_stmt_count(THD *thd) -{ - pthread_mutex_lock(&LOCK_prepared_stmt_count); - thd->sys_var_tmp.ulong_value= prepared_stmt_count; - pthread_mutex_unlock(&LOCK_prepared_stmt_count); - return (byte*) &thd->sys_var_tmp.ulong_value; -} - /**************************************************************************** Main handling of variables: - Initialisation From fdc37f06668c97a305360223e2daa8863800ba9a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Nov 2006 16:57:23 +0300 Subject: [PATCH 10/39] Fix after manual merge. mysql-test/r/ps.result: Fix after manual merge: update for different error message. mysql-test/t/ps.test: Fix after manual merge: use right error codes. --- mysql-test/r/ps.result | 12 ++++++------ mysql-test/t/ps.test | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index b44c4c21780..eb07bb8e672 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -831,7 +831,7 @@ show status like 'prepared_stmt_count'; Variable_name Value Prepared_stmt_count 0 prepare stmt from "select 1"; -ERROR HY000: Unknown error +ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0) show status like 'prepared_stmt_count'; Variable_name Value Prepared_stmt_count 0 @@ -841,7 +841,7 @@ show status like 'prepared_stmt_count'; Variable_name Value Prepared_stmt_count 1 prepare stmt1 from "select 1"; -ERROR HY000: Unknown error +ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 1) show status like 'prepared_stmt_count'; Variable_name Value Prepared_stmt_count 1 @@ -865,14 +865,14 @@ select @@max_prepared_stmt_count; 1 set global max_prepared_stmt_count=0; prepare stmt from "select 1"; -ERROR HY000: Unknown error +ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0) execute stmt; ERROR HY000: Unknown prepared statement handler (stmt) given to EXECUTE show status like 'prepared_stmt_count'; Variable_name Value Prepared_stmt_count 0 prepare stmt from "select 1"; -ERROR HY000: Unknown error +ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 0) show status like 'prepared_stmt_count'; Variable_name Value Prepared_stmt_count 0 @@ -887,9 +887,9 @@ prepare stmt from "select 1"; prepare stmt from "select 2"; prepare stmt1 from "select 3"; prepare stmt2 from "select 4"; -ERROR HY000: Unknown error +ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 3) prepare stmt2 from "select 4"; -ERROR HY000: Unknown error +ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 3) select @@max_prepared_stmt_count; @@max_prepared_stmt_count 3 diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 459a77762bc..1c8d7b419a3 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -878,11 +878,11 @@ set global max_prepared_stmt_count=10000000000000000; select @@max_prepared_stmt_count; set global max_prepared_stmt_count=default; select @@max_prepared_stmt_count; ---error 1229 # ER_GLOBAL_VARIABLE +--error ER_GLOBAL_VARIABLE set @@max_prepared_stmt_count=1; ---error 1229 # ER_GLOBAL_VARIABLE +--error ER_GLOBAL_VARIABLE set max_prepared_stmt_count=1; ---error 1229 # ER_GLOBAL_VARIABLE +--error ER_GLOBAL_VARIABLE set local max_prepared_stmt_count=1; # set to a reasonable limit works set global max_prepared_stmt_count=1; @@ -893,13 +893,13 @@ select @@max_prepared_stmt_count; set global max_prepared_stmt_count=0; select @@max_prepared_stmt_count; show status like 'prepared_stmt_count'; ---error 1105 # ER_UNKNOWN_ERROR +--error ER_MAX_PREPARED_STMT_COUNT_REACHED prepare stmt from "select 1"; show status like 'prepared_stmt_count'; set global max_prepared_stmt_count=1; prepare stmt from "select 1"; show status like 'prepared_stmt_count'; ---error 1105 # ER_UNKNOWN_ERROR +--error ER_MAX_PREPARED_STMT_COUNT_REACHED prepare stmt1 from "select 1"; show status like 'prepared_stmt_count'; deallocate prepare stmt; @@ -919,13 +919,13 @@ show status like 'prepared_stmt_count'; show status like 'prepared_stmt_count'; select @@max_prepared_stmt_count; set global max_prepared_stmt_count=0; ---error 1105 # ER_UNKNOWN_ERROR +--error ER_MAX_PREPARED_STMT_COUNT_REACHED prepare stmt from "select 1"; # Result: the old statement is deallocated, the new is not created. ---error 1243 # ER_UNKNOWN_STMT_HANDLER +--error ER_UNKNOWN_STMT_HANDLER execute stmt; show status like 'prepared_stmt_count'; ---error 1105 # ER_UNKNOWN_ERROR +--error ER_MAX_PREPARED_STMT_COUNT_REACHED prepare stmt from "select 1"; show status like 'prepared_stmt_count'; # @@ -940,10 +940,10 @@ connect (con1,localhost,root,,); connection con1; prepare stmt from "select 2"; prepare stmt1 from "select 3"; ---error 1105 # ER_UNKNOWN_ERROR +--error ER_MAX_PREPARED_STMT_COUNT_REACHED prepare stmt2 from "select 4"; connection default; ---error 1105 # ER_UNKNOWN_ERROR +--error ER_MAX_PREPARED_STMT_COUNT_REACHED prepare stmt2 from "select 4"; select @@max_prepared_stmt_count; show status like 'prepared_stmt_count'; From 18770d2fe4956e9be33a73cfc790129c19c6305a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 22 Nov 2006 13:58:00 +0300 Subject: [PATCH 11/39] BUG#21635: MYSQL_FIELD struct's member strings seem to misbehave for expression cols. The problem was that MYSQL_FIELD::org_name was set for MIN() and MAX() functions (COUNT() is also mentioned in the bug report but was already fixed). After this patch for expressions MYSQL_FIELD::name is set to either expression itself or its alias, and other data origin fields of MYSQL_FILED (db, org_table, table, org_name) are empty strings. sql/item_sum.cc: For expressions only col_name should be non-empty string. tests/mysql_client_test.c: Add test case for bug#21635: MYSQL_FIELD struct's member strings seem to misbehave for expression cols. --- sql/item_sum.cc | 10 ++++-- tests/mysql_client_test.c | 68 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 3 deletions(-) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 5fd65fecbfc..87c768e9383 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -71,9 +71,13 @@ void Item_sum::make_field(Send_field *tmp_field) if (args[0]->type() == Item::FIELD_ITEM && keep_field_type()) { ((Item_field*) args[0])->field->make_field(tmp_field); - tmp_field->db_name=(char*)""; - tmp_field->org_table_name=tmp_field->table_name=(char*)""; - tmp_field->org_col_name=tmp_field->col_name=name; + /* For expressions only col_name should be non-empty string. */ + char *empty_string= (char*)""; + tmp_field->db_name= empty_string; + tmp_field->org_table_name= empty_string; + tmp_field->table_name= empty_string; + tmp_field->org_col_name= empty_string; + tmp_field->col_name= name; if (maybe_null) tmp_field->flags&= ~NOT_NULL_FLAG; } diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 6ae9dcb9476..eb9559499bf 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -11945,6 +11945,73 @@ static void test_bug21726() } +/* + BUG#21635: MYSQL_FIELD struct's member strings seem to misbehave for + expression cols + + Check that for MIN(), MAX(), COUNT() only MYSQL_FIELD::name is set + to either expression or its alias, and db, org_table, table, + org_name fields are empty strings. +*/ +static void test_bug21635() +{ + const char *expr[]= + { + "MIN(i)", "MIN(i)", + "MIN(i) AS A1", "A1", + "MAX(i)", "MAX(i)", + "MAX(i) AS A2", "A2", + "COUNT(i)", "COUNT(i)", + "COUNT(i) AS A3", "A3", + }; + const char *query_end; + MYSQL_RES *result; + MYSQL_FIELD *field; + unsigned int field_count, i; + int rc; + + DBUG_ENTER("test_bug21635"); + myheader("test_bug21635"); + + query_end= strxmov(query, "SELECT ", NullS); + for (i= 0; i < sizeof(expr) / sizeof(*expr) / 2; ++i) + query_end= strxmov(query_end, expr[i * 2], ", ", NullS); + query_end= strxmov(query_end - 2, " FROM t1 GROUP BY i", NullS); + DIE_UNLESS(query_end - query < MAX_TEST_QUERY_LENGTH); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + myquery(rc); + rc= mysql_query(mysql, "CREATE TABLE t1 (i INT)"); + myquery(rc); + rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)"); + myquery(rc); + + rc= mysql_real_query(mysql, query, query_end - query); + myquery(rc); + + result= mysql_use_result(mysql); + DIE_UNLESS(result); + + field_count= mysql_field_count(mysql); + for (i= 0; i < field_count; ++i) + { + field= mysql_fetch_field_direct(result, i); + printf("%s -> %s ... ", expr[i * 2], field->name); + fflush(stdout); + DIE_UNLESS(field->db[0] == 0 && field->org_table[0] == 0 && + field->table[0] == 0 && field->org_name[0] == 0); + DIE_UNLESS(strcmp(field->name, expr[i * 2 + 1]) == 0); + puts("OK"); + } + + mysql_free_result(result); + rc= mysql_query(mysql, "DROP TABLE t1"); + myquery(rc); + + DBUG_VOID_RETURN; +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -12172,6 +12239,7 @@ static struct my_tests_st my_tests[]= { { "test_bug15613", test_bug15613 }, { "test_bug20152", test_bug20152 }, { "test_bug21726", test_bug21726 }, + { "test_bug21635", test_bug21635 }, { 0, 0 } }; From a7aecabc85664e822741da2288af29439a78e644 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 22 Nov 2006 16:47:12 +0300 Subject: [PATCH 12/39] Cleanup: remove const. --- tests/mysql_client_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 4bc1fd5f9d4..98d7182d46f 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -12045,7 +12045,7 @@ static void test_bug21635() "COUNT(i)", "COUNT(i)", "COUNT(i) AS A3", "A3", }; - const char *query_end; + char *query_end; MYSQL_RES *result; MYSQL_FIELD *field; unsigned int field_count, i; From 247428a1426a927e48843da378b75d6ad6d77f8a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 22 Nov 2006 16:49:32 +0300 Subject: [PATCH 13/39] After merge fixes: remove const and add query buffer. --- tests/mysql_client_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 473a3f1f6c2..c88252e6190 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15403,7 +15403,8 @@ static void test_bug21635() "COUNT(i)", "COUNT(i)", "COUNT(i) AS A3", "A3", }; - const char *query_end; + char query[MAX_TEST_QUERY_LENGTH]; + char *query_end; MYSQL_RES *result; MYSQL_FIELD *field; unsigned int field_count, i; From cf9038e97973f8bbe387887af9b9f489316b3629 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Nov 2006 22:55:36 +0300 Subject: [PATCH 14/39] Fix for BUG##24415: Instance manager test im_daemon_life_cycle fails randomly. The problem was that the test case used command line tool (mysql) without specifying connect_timeout argument. In some cases, this lead to hanging of the test case. The fix is to specify --connect_timeout=1 when starting mysql. Also, the patch contains polishing and various cleanups to simplify analyzing of the problems further. The patch affects only test suite, no server codebase has been touched. mysql-test/lib/mtr_im.pl: Remember PID of the IM-spawner -- a process, that is used to fork IM-angel. mysql-test/lib/mtr_io.pl: Trim \n from the PID. mysql-test/lib/mtr_process.pl: Don't complain if it was IM-spawner, who died. mysql-test/r/im_daemon_life_cycle.result: Update the result file. mysql-test/r/im_life_cycle.result: Update the result file. mysql-test/t/im_daemon_life_cycle.imtest: Polishing: add more comments, be more verbose. mysql-test/t/im_life_cycle.imtest: Polishing: be more verbose. mysql-test/t/im_utils.imtest: Polishing: be more verbose. mysql-test/t/kill_n_check.sh: Log messages to the extrenal file so that they can be analyzed if test case failed. mysql-test/t/wait_for_process.sh: Log messages to the extrenal file so that they can be analyzed if test case failed. mysql-test/t/wait_for_socket.sh: Log messages to the extrenal file so that they can be analyzed if test case failed. mysql-test/t/log.sh: Dummy script to facilitate logging from test-scripts. mysql-test/t/utils.sh: A bunch of auxilary functions to facilitate logging. --- mysql-test/lib/mtr_im.pl | 4 +- mysql-test/lib/mtr_io.pl | 1 + mysql-test/lib/mtr_process.pl | 6 ++ mysql-test/r/im_daemon_life_cycle.result | 4 +- mysql-test/r/im_life_cycle.result | 4 +- mysql-test/t/im_daemon_life_cycle.imtest | 73 +++++++++------ mysql-test/t/im_life_cycle.imtest | 10 +-- mysql-test/t/im_utils.imtest | 4 +- mysql-test/t/kill_n_check.sh | 82 +++++++++++------ mysql-test/t/log.sh | 24 +++++ mysql-test/t/utils.sh | 55 ++++++++++++ mysql-test/t/wait_for_process.sh | 108 ++++++++++++++++------- mysql-test/t/wait_for_socket.sh | 60 ++++++++++--- 13 files changed, 327 insertions(+), 108 deletions(-) create mode 100755 mysql-test/t/log.sh create mode 100644 mysql-test/t/utils.sh diff --git a/mysql-test/lib/mtr_im.pl b/mysql-test/lib/mtr_im.pl index ca17516278e..967e92dfcdd 100644 --- a/mysql-test/lib/mtr_im.pl +++ b/mysql-test/lib/mtr_im.pl @@ -582,7 +582,7 @@ sub mtr_im_start($$) { mtr_add_arg($args, $opt); } - $im->{'pid'} = + $im->{'spawner_pid'} = mtr_spawn( $::exe_im, # path to the executable $args, # cmd-line args @@ -593,7 +593,7 @@ sub mtr_im_start($$) { { append_log_file => 1 } # append log files ); - unless ( $im->{'pid'} ) + unless ( $im->{'spawner_pid'} ) { mtr_error('Could not start Instance Manager.') } diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl index 984d834486c..5be1d2ffddb 100644 --- a/mysql-test/lib/mtr_io.pl +++ b/mysql-test/lib/mtr_io.pl @@ -39,6 +39,7 @@ sub mtr_get_pid_from_file ($) { # Read pid number from file my $pid= ; + chomp $pid; close FILE; return $pid if $pid=~ /^(\d+)/; diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 9d0c1f601ba..79285de88a7 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -937,6 +937,12 @@ sub check_expected_crash_and_restart($) } } } + + if ($::instance_manager->{'spawner_pid'} eq $ret_pid) + { + return; + } + mtr_warning("check_expected_crash_and_restart couldn't find an entry for pid: $ret_pid"); } diff --git a/mysql-test/r/im_daemon_life_cycle.result b/mysql-test/r/im_daemon_life_cycle.result index b842a5f3bf9..d80a34f8427 100644 --- a/mysql-test/r/im_daemon_life_cycle.result +++ b/mysql-test/r/im_daemon_life_cycle.result @@ -6,7 +6,7 @@ instance_name status mysqld1 online mysqld2 offline Killing the process... -Sleeping... +Waiting... Success: the process was restarted. Success: server is ready to accept connection on socket. @@ -16,7 +16,7 @@ Success: server is ready to accept connection on socket. START INSTANCE mysqld2; Success: the process has been started. Killing the process... -Sleeping... +Waiting... Success: the process was restarted. Success: server is ready to accept connection on socket. SHOW INSTANCE STATUS mysqld1; diff --git a/mysql-test/r/im_life_cycle.result b/mysql-test/r/im_life_cycle.result index 69f6bb5a490..a9ad85d5947 100644 --- a/mysql-test/r/im_life_cycle.result +++ b/mysql-test/r/im_life_cycle.result @@ -39,7 +39,7 @@ ERROR HY000: Bad instance name. Check that the instance with such a name exists -- 1.1.6. -------------------------------------------------------------------- Killing the process... -Sleeping... +Waiting... Success: the process was restarted. SHOW INSTANCES; instance_name status @@ -52,7 +52,7 @@ mysqld2 offline START INSTANCE mysqld2; Success: the process has been started. Killing the process... -Sleeping... +Waiting... Success: the process was killed. -------------------------------------------------------------------- diff --git a/mysql-test/t/im_daemon_life_cycle.imtest b/mysql-test/t/im_daemon_life_cycle.imtest index 65db9dee93f..acd615809f3 100644 --- a/mysql-test/t/im_daemon_life_cycle.imtest +++ b/mysql-test/t/im_daemon_life_cycle.imtest @@ -6,59 +6,73 @@ # ########################################################################### +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle im_daemon_life_cycle.imtest started. + +########################################################################### + --source include/im_check_env.inc -# Turn on reconnect, not on by default anymore +# Turn on reconnect, not on by default anymore. --enable_reconnect ########################################################################### - -# Kill the IM main process and check that the IM Angel will restart the main -# process. - ---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30 - +# +# The main daemon-life-cycle test case -- check that IM-angel will restart +# IM-main if it got killed: +# - kill IM-main and check that IM-angel will restart it; +# - wait for IM-main to start accepting connections before continue test +# case; +# ########################################################################### -# Wait for IM to start accepting connections. +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Main-test: starting... ---exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 30 +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Killing IM-main... +--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30 im_daemon_life_cycle + +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Waiting for IM-main to start accepting connections... +--exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 30 im_daemon_life_cycle + +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Main-test: done. ########################################################################### - # # BUG#12751: Instance Manager: client hangs +# - start nonguarded instance (mysqld2); +# - kill IM-main and get it restarted by IM-angel; +# - check that guarded instance (mysqld1) is accepting connections. +# - check that non-guarded instance (mysqld2) were not stopped. # +########################################################################### --echo --echo -------------------------------------------------------------------- --echo -- Test for BUG#12751 --echo -------------------------------------------------------------------- -# Give some time to begin accepting connections after restart. -# FIXME: race condition here. - ---sleep 3 +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle BUG12751: starting... # 1. Start mysqld; +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: starting... START INSTANCE mysqld2; -# FIXME: START INSTANCE should be synchronous. ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started -# 2. Restart IM-main: kill it and IM-angel will restart it; wait for IM to -# start accepting connections again. +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: waiting to start... +--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_daemon_life_cycle ---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30 +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: started. ---exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 30 +# 2. Restart IM-main; + +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Killing IM-main... +--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30 im_daemon_life_cycle + +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Waiting for IM-main to start accepting connections... +--exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 30 im_daemon_life_cycle # 3. Issue some statement -- connection should be re-established. -# Give some time to begin accepting connections after restart. -# FIXME: race condition here. - ---sleep 3 +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Checking that IM-main processing commands... --replace_column 3 VERSION SHOW INSTANCE STATUS mysqld1; @@ -67,6 +81,13 @@ SHOW INSTANCE STATUS mysqld1; # So, if it we do not stop it, it will be stopped by mysql-test-run.pl with # warning. +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: stopping... STOP INSTANCE mysqld2; -# FIXME: STOP INSTANCE should be synchronous. ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped + +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: waiting to stop... +--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_daemon_life_cycle +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: stopped. + +########################################################################### + +--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle BUG12751: done. diff --git a/mysql-test/t/im_life_cycle.imtest b/mysql-test/t/im_life_cycle.imtest index ddfb62d312e..3721b92e2b7 100644 --- a/mysql-test/t/im_life_cycle.imtest +++ b/mysql-test/t/im_life_cycle.imtest @@ -25,7 +25,7 @@ START INSTANCE mysqld2; # FIXME: START INSTANCE should be synchronous. ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started +--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_life_cycle # FIXME: Result of SHOW INSTANCES here is not deterministic unless START # INSTANCE is synchronous. Even waiting for mysqld to start by looking at @@ -58,7 +58,7 @@ SHOW VARIABLES LIKE 'port'; STOP INSTANCE mysqld2; # FIXME: STOP INSTANCE should be synchronous. ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped +--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_life_cycle # FIXME: Result of SHOW INSTANCES here is not deterministic unless START # INSTANCE is synchronous. Even waiting for mysqld to start by looking at @@ -121,7 +121,7 @@ STOP INSTANCE mysqld3; --echo -- 1.1.6. --echo -------------------------------------------------------------------- ---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30 +--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30 im_life_cycle # Give some time to IM to detect that mysqld was restarted. It should be # longer than monitoring interval. @@ -143,7 +143,7 @@ SHOW INSTANCES; START INSTANCE mysqld2; # FIXME: START INSTANCE should be synchronous. ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started +--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_life_cycle # FIXME: Result of SHOW INSTANCES here is not deterministic unless START # INSTANCE is synchronous. Even waiting for mysqld to start by looking at @@ -151,7 +151,7 @@ START INSTANCE mysqld2; # mysqld has started. # SHOW INSTANCES; ---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10 +--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10 im_life_cycle # FIXME: Result of SHOW INSTANCES here is not deterministic unless START # INSTANCE is synchronous. Even waiting for mysqld to start by looking at diff --git a/mysql-test/t/im_utils.imtest b/mysql-test/t/im_utils.imtest index 52878f6c2b5..0866b87204a 100644 --- a/mysql-test/t/im_utils.imtest +++ b/mysql-test/t/im_utils.imtest @@ -31,10 +31,10 @@ SHOW INSTANCE OPTIONS mysqld2; # START INSTANCE mysqld2; ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started +--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_utils STOP INSTANCE mysqld2; ---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped +--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_utils # # Check 'SHOW LOG FILES' command: diff --git a/mysql-test/t/kill_n_check.sh b/mysql-test/t/kill_n_check.sh index a54fb6ef8bb..96c402a638c 100755 --- a/mysql-test/t/kill_n_check.sh +++ b/mysql-test/t/kill_n_check.sh @@ -2,74 +2,101 @@ ########################################################################### -# NOTE: this script returns 0 (success) even in case of failure. This is -# because this script is executed under mysql-test-run[.pl] and it's better to -# examine particular problem in log file, than just having said that the test -# case has failed. +# NOTE: this script returns 0 (success) even in case of failure (except for +# usage-error). This is because this script is executed under +# mysql-test-run[.pl] and it's better to examine particular problem in log +# file, than just having said that the test case has failed. + +########################################################################### + +basename=`basename "$0"` +dirname=`dirname "$0"` + +########################################################################### + +. "$dirname/utils.sh" ########################################################################### check_restart() { if [ ! -r "$pid_path" ]; then + log_debug "No '$pid_path' found." user_msg='the process was killed' return 1 fi new_pid=`cat "$pid_path" 2>/dev/null` + err_code=$? - if [ $? -eq 0 -a "$original_pid" = "$new_pid" ]; then + log_debug "err_code: $err_code; original_pid: $original_pid; new_pid: $new_pid." + + if [ $err_code -eq 0 -a "$original_pid" = "$new_pid" ]; then + log_debug "The process was not restarted." user_msg='the process was not restarted' return 1 fi + log_debug "The process was restarted." user_msg='the process was restarted' return 0 } ########################################################################### -if [ $# -ne 3 ]; then - echo "Usage: kill_n_check.sh killed|restarted " - exit 0 +if [ $# -ne 4 ]; then + echo "Usage: $basename killed|restarted " + exit 1 fi pid_path="$1" expected_result="$2" total_timeout="$3" +test_id="$4" +log_file="$MYSQLTEST_VARDIR/log/$test_id.log" + +log_debug "-- $basename: starting --" +log_debug "pid_path: '$pid_path'" +log_debug "expected_result: '$expected_result'" +log_debug "total_timeout: '$total_timeout'" +log_debug "test_id: '$test_id'" +log_debug "log_file: '$log_file'" + +########################################################################### if [ "$expected_result" != 'killed' -a \ "$expected_result" != 'restarted' ]; then - echo "Error: invalid second argument ('killed' or 'restarted' expected)." - exit 0 + log_error "Invalid second argument ($expected_result): 'killed' or 'restarted' expected." + quit 0 fi if [ -z "$pid_path" ]; then - echo "Error: invalid PID path ($pid_path)." - exit 0 + log_error "Invalid PID path ($pid_path)." + quit 0 fi if [ ! -r "$pid_path" ]; then - echo "Error: PID file ($pid_path) does not exist." - exit 0 + log_error "PID file ($pid_path) does not exist." + quit 0 fi if [ -z "$total_timeout" ]; then - echo "Error: timeout is not specified." - exit 0 + log_error "Timeout is not specified." + quit 0 fi ########################################################################### original_pid=`cat "$pid_path"` +log_debug "original_pid: $original_pid." -echo "Killing the process..." +log_info "Killing the process..." kill -9 $original_pid ########################################################################### -echo "Sleeping..." +log_info "Waiting..." if [ "$expected_result" = "restarted" ]; then @@ -79,37 +106,42 @@ if [ "$expected_result" = "restarted" ]; then while true; do + log_debug "cur_attempt: $cur_attempt." + if check_restart; then - echo "Success: $user_msg." - exit 0 + log_info "Success: $user_msg." + quit 0 fi [ $cur_attempt -ge $total_timeout ] && break + log_debug "Sleeping for 1 second..." sleep 1 cur_attempt=`expr $cur_attempt + 1` done - echo "Error: $user_msg." - exit 0 + log_error "$user_msg." + quit 0 else # $expected_result == killed # Here we have to sleep for some long time to ensure that the process will # not be restarted. + log_debug "Sleeping for $total_timeout seconds..." sleep $total_timeout new_pid=`cat "$pid_path" 2>/dev/null` + log_debug "new_pid: $new_pid." if [ "$new_pid" -a "$new_pid" -ne "$original_pid" ]; then - echo "Error: the process was restarted." + log_error "The process was restarted." else - echo "Success: the process was killed." + log_info "Success: the process was killed." fi - exit 0 + quit 0 fi diff --git a/mysql-test/t/log.sh b/mysql-test/t/log.sh new file mode 100755 index 00000000000..20b265087cc --- /dev/null +++ b/mysql-test/t/log.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +########################################################################### + +basename=`basename "$0"` +dirname=`dirname "$0"` + +########################################################################### + +. "$dirname/utils.sh" + +########################################################################### + +if [ $# -lt 2 ]; then + echo "Usage: $basename log message ..." + exit 1 +fi + +test_id="$1" +log_file="$MYSQLTEST_VARDIR/log/$test_id.log" + +shift + +log_debug "$*" diff --git a/mysql-test/t/utils.sh b/mysql-test/t/utils.sh new file mode 100644 index 00000000000..b3f4744947d --- /dev/null +++ b/mysql-test/t/utils.sh @@ -0,0 +1,55 @@ +########################################################################### +# +# This file provides utility functions and is included by other scripts. +# +# The following global variables must be set before calling functions from this +# file: +# - basename -- base name of the calling script (main application); +# - log_file -- where to store log records; +# +########################################################################### + +log() +{ + [ -z "$log_file" ] && return; + + log_level="$1" + log_msg="$2" + ts=`date` + + echo "[$ts] [$basename] [$log_level] $log_msg" >> "$log_file"; +} + +########################################################################### + +log_debug() +{ + log 'DEBUG' "$1" +} + +########################################################################### + +log_info() +{ + log 'INFO' "$1" + echo "$1" +} + +########################################################################### + +log_error() +{ + log 'ERROR' "$1" + echo "Error: $1" +} + +########################################################################### + +quit() +{ + exit_status="$1" + + log_debug "-- $basename: finished (exit_status: $exit_status) --" + + exit $exit_status +} diff --git a/mysql-test/t/wait_for_process.sh b/mysql-test/t/wait_for_process.sh index df0f4a17e3a..4c2d89cfea6 100755 --- a/mysql-test/t/wait_for_process.sh +++ b/mysql-test/t/wait_for_process.sh @@ -2,11 +2,79 @@ ########################################################################### +# NOTE: this script returns 0 (success) even in case of failure (except for +# usage-error). This is because this script is executed under +# mysql-test-run[.pl] and it's better to examine particular problem in log +# file, than just having said that the test case has failed. + +########################################################################### + +basename=`basename "$0"` +dirname=`dirname "$0"` + +########################################################################### + +. "$dirname/utils.sh" + +########################################################################### + +check_started() +{ + if [ ! -r "$pid_path" ]; then + log_debug "No PID-file ($pid_path) found -- not started." + return 1 + fi + + new_pid=`cat "$pid_path" 2>/dev/null` + err_code=$? + + log_debug "err_code: $err_code; new_pid: $new_pid." + + if [ $? -ne 0 -o -z "$new_pid" ]; then + log_debug "The process was not started." + return 1 + fi + + log_debug "The process was started." + return 0 +} + +########################################################################### + +check_stopped() +{ + if [ -r "$pid_path" ]; then + log_debug "PID-file '$pid_path' exists -- not stopped." + return 1 + fi + + log_debug "No PID-file ($pid_path) found -- stopped." + return 0 +} + +########################################################################### + +if [ $# -ne 4 ]; then + echo "Usage: $basename started|stopped " + exit 1 +fi + pid_path="$1" total_attempts="$2" event="$3" +test_id="$4" +log_file="$MYSQLTEST_VARDIR/log/$test_id.log" -case "$3" in +log_debug "-- $basename: starting --" +log_debug "pid_path: '$pid_path'" +log_debug "total_attempts: '$total_attempts'" +log_debug "event: '$event'" +log_debug "test_id: '$test_id'" +log_debug "log_file: '$log_file'" + +########################################################################### + +case "$event" in started) check_fn='check_started'; ;; @@ -16,51 +84,31 @@ case "$3" in ;; *) - echo "Error: invalid third argument ('started' or 'stopped' expected)." - exit 0 + log_error "Invalid third argument ('started' or 'stopped' expected)." + quit 0 esac ########################################################################### -check_started() -{ - [ ! -r "$pid_path" ] && return 1 - - new_pid=`cat "$pid_path" 2>/dev/null` - - [ $? -eq 0 -a "$original_pid" = "$new_pid" ] && return 1 - - return 0 -} - -########################################################################### - -check_stopped() -{ - [ -r "$pid_path" ] && return 1 - - return 0 -} - -########################################################################### - cur_attempt=1 while true; do + log_debug "cur_attempt: $cur_attempt." + if ( eval $check_fn ); then - echo "Success: the process has been $event." - exit 0 + log_info "Success: the process has been $event." + quit 0 fi [ $cur_attempt -ge $total_attempts ] && break + log_debug "Sleeping for 1 second..." sleep 1 cur_attempt=`expr $cur_attempt + 1` done -echo "Error: the process has not been $event in $total_attempts secs." -exit 0 - +log_error "The process has not been $event in $total_attempts secs." +quit 0 diff --git a/mysql-test/t/wait_for_socket.sh b/mysql-test/t/wait_for_socket.sh index 3b900fa2208..1a73dff5244 100755 --- a/mysql-test/t/wait_for_socket.sh +++ b/mysql-test/t/wait_for_socket.sh @@ -2,9 +2,25 @@ ########################################################################### -if [ $# -ne 6 ]; then - echo "Usage: wait_for_socket.sh " - exit 0 +# NOTE: this script returns 0 (success) even in case of failure (except for +# usage-error). This is because this script is executed under +# mysql-test-run[.pl] and it's better to examine particular problem in log +# file, than just having said that the test case has failed. + +########################################################################### + +basename=`basename "$0"` +dirname=`dirname "$0"` + +########################################################################### + +. "$dirname/utils.sh" + +########################################################################### + +if [ $# -ne 7 ]; then + echo "Usage: wait_for_socket.sh " + exit 1 fi client_exe="$1" @@ -13,41 +29,57 @@ username="$3" password="$4" db="$5" total_timeout="$6" +test_id="$7" +log_file="$MYSQLTEST_VARDIR/log/$test_id.log" + +log_debug "-- $basename: starting --" +log_debug "client_exe: '$client_exe'" +log_debug "socket_path: '$socket_path'" +log_debug "username: '$username'" +log_debug "password: '$password'" +log_debug "db: '$db'" +log_debug "total_timeout: '$total_timeout'" +log_debug "test_id: '$test_id'" +log_debug "log_file: '$log_file'" ########################################################################### if [ -z "$client_exe" ]; then - echo "Error: invalid path to client executable ($client_exe)." - exit 0; + log_error "Invalid path to client executable ($client_exe)." + quit 0; fi if [ ! -x "$client_exe" ]; then - echo "Error: client by path '$client_exe' is not available." - exit 0; + log_error "Client by path '$client_exe' is not available." + quit 0; fi if [ -z "$socket_path" ]; then - echo "Error: invalid socket patch." - exit 0 + log_error "Invalid socket patch ($socket_path)." + quit 0 fi ########################################################################### -client_args="--silent --socket=$socket_path " +client_args="--silent --connect_timeout=1 --socket=$socket_path " [ -n "$username" ] && client_args="$client_args --user=$username " [ -n "$password" ] && client_args="$client_args --password=$password " [ -n "$db" ] && client_args="$client_args $db" +log_debug "client_args: '$client_args'" + ########################################################################### cur_attempt=1 while true; do + log_debug "cur_attempt: $cur_attempt." + if ( echo 'quit' | "$client_exe" $client_args >/dev/null 2>&1 ); then - echo "Success: server is ready to accept connection on socket." - exit 0 + log_info "Success: server is ready to accept connection on socket." + quit 0 fi [ $cur_attempt -ge $total_timeout ] && break @@ -58,5 +90,5 @@ while true; do done -echo "Error: server does not accept connections after $total_timeout seconds." -exit 0 +log_error "Server does not accept connections after $total_timeout seconds." +quit 0 From af1b3da56ff4b0168dcf6625897ba06256a5b84c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 27 Nov 2006 16:15:32 +0300 Subject: [PATCH 15/39] Bug#17254: Error for DEFINER security on VIEW provides too much info If a view was created with the DEFINER security and later the definer user was dropped then a SELECT from the view throws the error message saying that there is no definer user is registered. This is ok for a root but too much for a mere user. Now the st_table_list::prepare_view_securety_context() function reveals the absence of the definer only to a superuser and throws the 'access denied' error to others. mysql-test/t/view_grant.test: Added a test case for bug#17254: Error for DEFINER security on VIEW provides too much info mysql-test/r/view_grant.result: Added a test case for bug#17254: Error for DEFINER security on VIEW provides too much info sql/table.cc: Bug#17254: Error for DEFINER security on VIEW provides too much info Now the st_table_list::prepare_view_securety_context() function reveals the absence of the definer only to a superuser and throws the 'access denied' error to others. --- mysql-test/r/view_grant.result | 20 ++++++++++++++++++ mysql-test/t/view_grant.test | 37 ++++++++++++++++++++++++++++++++++ sql/table.cc | 13 +++++++++++- 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index 35e7afc0a7b..422d6c5faaf 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -712,3 +712,23 @@ DROP FUNCTION f1; DROP VIEW v2; DROP VIEW v1; DROP USER mysqltest_u1@localhost; +CREATE DATABASE db17254; +USE db17254; +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (10),(20); +CREATE USER def_17254@localhost; +GRANT SELECT ON db17254.* TO def_17254@localhost; +CREATE USER inv_17254@localhost; +GRANT SELECT ON db17254.t1 TO inv_17254@localhost; +GRANT CREATE VIEW ON db17254.* TO def_17254@localhost; +CREATE VIEW v1 AS SELECT * FROM t1; +DROP USER def_17254@localhost; +for a user +SELECT * FROM v1; +ERROR 42000: SELECT command denied to user 'inv_17254'@'localhost' for table 'v1 +' +for a superuser +SELECT * FROM v1; +ERROR HY000: There is no 'def_17254'@'localhost' registered +DROP USER inv_17254@localhost; +DROP DATABASE db17254; diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test index 8bc34cfe148..1da2250f65a 100644 --- a/mysql-test/t/view_grant.test +++ b/mysql-test/t/view_grant.test @@ -927,4 +927,41 @@ DROP VIEW v2; DROP VIEW v1; DROP USER mysqltest_u1@localhost; +# +# Bug#17254: Error for DEFINER security on VIEW provides too much info +# +connect (root,localhost,root,,); +connection root; +CREATE DATABASE db17254; +USE db17254; +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (10),(20); +CREATE USER def_17254@localhost; +GRANT SELECT ON db17254.* TO def_17254@localhost; +CREATE USER inv_17254@localhost; +GRANT SELECT ON db17254.t1 TO inv_17254@localhost; +GRANT CREATE VIEW ON db17254.* TO def_17254@localhost; + +connect (def,localhost,def_17254,,db17254); +connection def; +CREATE VIEW v1 AS SELECT * FROM t1; + +connection root; +DROP USER def_17254@localhost; + +connect (inv,localhost,inv_17254,,db17254); +connection inv; +--echo for a user +--error 1142 +SELECT * FROM v1; + +connection root; +--echo for a superuser +--error 1449 +SELECT * FROM v1; +DROP USER inv_17254@localhost; +DROP DATABASE db17254; +disconnect def; +disconnect inv; + # End of 5.0 tests. diff --git a/sql/table.cc b/sql/table.cc index 5d5d5095e7c..6bc43e48110 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2458,7 +2458,18 @@ bool st_table_list::prepare_view_securety_context(THD *thd) } else { - my_error(ER_NO_SUCH_USER, MYF(0), definer.user.str, definer.host.str); + if (thd->security_ctx->master_access & SUPER_ACL) + { + my_error(ER_NO_SUCH_USER, MYF(0), definer.user.str, definer.host.str); + + } + else + { + my_error(ER_ACCESS_DENIED_ERROR, MYF(0), + thd->security_ctx->priv_user, + thd->security_ctx->priv_host, + (thd->password ? ER(ER_YES) : ER(ER_NO))); + } DBUG_RETURN(TRUE); } } From 129a48b0b94e95e1a5750b496469a2089d14dc8b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 28 Nov 2006 00:47:21 +0200 Subject: [PATCH 16/39] Increased heap max length to > 4G for 64 bit machines Initialize key_part->type on open. This caused key_copy() to fail for bit_fields. (key_copy is used in HANDLER and opt_range) include/heap.h: Increased heap max length to > 4G for 64 bit machines mysql-test/r/show_check.result: Updated results after heap size change mysql-test/r/type_bit.result: Added test for bug in bit field handling (in handler and opt_range.cc) mysql-test/t/type_bit.test: Added test for bug in bit field handling (in handler and opt_range.cc) sql/ha_heap.cc: Increased heap max length to > 4G for 64 bit machines sql/item_sum.cc: Increased heap max length to > 4G for 64 bit machines sql/mysqld.cc: Increased heap max length to > 4G for 64 bit machines sql/set_var.cc: Increased heap max length to > 4G for 64 bit machines sql/sql_class.h: Increased heap max length to > 4G for 64 bit machines sql/sql_select.cc: Increased heap max length to > 4G for 64 bit machines sql/table.cc: Initialize key_part->type ; This was used for bit fields but only set in temporary tables sql/uniques.cc: Increased heap max length to > 4G for 64 bit machines --- include/heap.h | 8 ++++---- mysql-test/r/show_check.result | 2 +- mysql-test/r/type_bit.result | 8 ++++++++ mysql-test/t/type_bit.test | 11 +++++++++++ sql/ha_heap.cc | 2 +- sql/item_sum.cc | 4 ++-- sql/mysqld.cc | 15 +++++++++++---- sql/set_var.cc | 4 ++-- sql/sql_class.h | 17 +++++++++-------- sql/sql_select.cc | 2 +- sql/table.cc | 1 + sql/uniques.cc | 4 ++-- 12 files changed, 53 insertions(+), 25 deletions(-) diff --git a/include/heap.h b/include/heap.h index cfbb6113f86..4255ee52b18 100644 --- a/include/heap.h +++ b/include/heap.h @@ -46,8 +46,8 @@ typedef struct st_heapinfo /* Struct from heap_info */ ulong records; /* Records in database */ ulong deleted; /* Deleted records in database */ ulong max_records; - ulong data_length; - ulong index_length; + ulonglong data_length; + ulonglong index_length; uint reclength; /* Length of one record */ int errkey; ulonglong auto_increment; @@ -135,7 +135,7 @@ typedef struct st_heap_share HP_BLOCK block; HP_KEYDEF *keydef; ulong min_records,max_records; /* Params to open */ - ulong data_length,index_length,max_table_size; + ulonglong data_length,index_length,max_table_size; uint key_stat_version; /* version to indicate insert/delete */ uint records; /* records */ uint blength; /* records rounded up to 2^n */ @@ -187,7 +187,7 @@ typedef struct st_heap_create_info { uint auto_key; /* keynr [1 - maxkey] for auto key */ uint auto_key_type; - ulong max_table_size; + ulonglong max_table_size; ulonglong auto_increment; my_bool with_auto_increment; } HP_CREATE_INFO; diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 28cbdb16919..0dfb7c95f9a 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -296,7 +296,7 @@ SET sql_quote_show_create= @old_sql_quote_show_create; SET sql_mode= @old_sql_mode; select @@max_heap_table_size; @@max_heap_table_size -1047552 +1048576 CREATE TABLE t1 ( a int(11) default NULL, KEY a USING BTREE (a) diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index bd58e83bb3f..f3883077919 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -610,4 +610,12 @@ select hex(a), b from t1; hex(a) b 1 2 drop table t1; +create table t1(bit_field bit(2), int_field int, key a(bit_field)); +insert into t1 values (1,2); +handler t1 open as t1; +handler t1 read a=(1); +bit_field int_field + 2 +handler t1 close; +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index d46ba667665..48ad24ff6b7 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -261,4 +261,15 @@ insert into t1 (b, a) values ('2', '1'); select hex(a), b from t1; drop table t1; +# +# type was not properly initalized, which caused key_copy to fail +# + +create table t1(bit_field bit(2), int_field int, key a(bit_field)); +insert into t1 values (1,2); +handler t1 open as t1; +handler t1 read a=(1); +handler t1 close; +drop table t1; + --echo End of 5.0 tests diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 34ef888a029..3cf7593bd8a 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -631,7 +631,7 @@ int ha_heap::create(const char *name, TABLE *table_arg, } mem_per_row+= MY_ALIGN(share->reclength + 1, sizeof(char*)); max_rows = (ha_rows) (table->in_use->variables.max_heap_table_size / - mem_per_row); + (ulonglong) mem_per_row); if (table_arg->found_next_number_field) { keydef[share->next_number_index].flag|= HA_AUTO_KEY; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index f1e0001c994..de0f713f454 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3388,8 +3388,8 @@ bool Item_func_group_concat::setup(THD *thd) duplicate values (according to the syntax of this function). If there is no DISTINCT or ORDER BY clauses, we don't create this tree. */ - init_tree(tree, min(thd->variables.max_heap_table_size, - thd->variables.sortbuff_size/16), 0, + init_tree(tree, (uint) min(thd->variables.max_heap_table_size, + thd->variables.sortbuff_size/16), 0, tree_key_length, compare_key, 0, NULL, (void*) this); } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 36a5605b507..dd483b0b158 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -70,6 +70,12 @@ #define IF_PURIFY(A,B) (B) #endif +#if SIZEOF_CHARP == 4 +#define MAX_MEM_TABLE_SIZE ~(ulong) 0 +#else +#define MAX_MEM_TABLE_SIZE ~(ulonglong) 0 +#endif + /* stack traces are only supported on linux intel */ #if defined(__linux__) && defined(__i386__) && defined(USE_PSTACK) #define HAVE_STACK_TRACE_ON_SEGV @@ -5718,8 +5724,9 @@ The minimum value for this variable is 4096.", {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE, "Don't allow creation of heap tables bigger than this.", (gptr*) &global_system_variables.max_heap_table_size, - (gptr*) &max_system_variables.max_heap_table_size, 0, GET_ULONG, - REQUIRED_ARG, 16*1024*1024L, 16384, ~0L, MALLOC_OVERHEAD, 1024, 0}, + (gptr*) &max_system_variables.max_heap_table_size, 0, GET_ULL, + REQUIRED_ARG, 16*1024*1024L, 16384, MAX_MEM_TABLE_SIZE, + MALLOC_OVERHEAD, 1024, 0}, {"max_join_size", OPT_MAX_JOIN_SIZE, "Joins that are probably going to read more than max_join_size records return an error.", (gptr*) &global_system_variables.max_join_size, @@ -5994,8 +6001,8 @@ The minimum value for this variable is 4096.", {"tmp_table_size", OPT_TMP_TABLE_SIZE, "If an in-memory temporary table exceeds this size, MySQL will automatically convert it to an on-disk MyISAM table.", (gptr*) &global_system_variables.tmp_table_size, - (gptr*) &max_system_variables.tmp_table_size, 0, GET_ULONG, - REQUIRED_ARG, 32*1024*1024L, 1024, ~0L, 0, 1, 0}, + (gptr*) &max_system_variables.tmp_table_size, 0, GET_ULL, + REQUIRED_ARG, 32*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0}, {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE, "Allocation block size for transactions to be stored in binary log", (gptr*) &global_system_variables.trans_alloc_block_size, diff --git a/sql/set_var.cc b/sql/set_var.cc index 55c62a9a5a5..c3e93aae619 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -248,7 +248,7 @@ sys_var_thd_ulong sys_max_delayed_threads("max_delayed_threads", fix_max_connections); sys_var_thd_ulong sys_max_error_count("max_error_count", &SV::max_error_count); -sys_var_thd_ulong sys_max_heap_table_size("max_heap_table_size", +sys_var_thd_ulonglong sys_max_heap_table_size("max_heap_table_size", &SV::max_heap_table_size); sys_var_thd_ulong sys_pseudo_thread_id("pseudo_thread_id", &SV::pseudo_thread_id, @@ -415,7 +415,7 @@ sys_var_thd_enum sys_tx_isolation("tx_isolation", &SV::tx_isolation, &tx_isolation_typelib, fix_tx_isolation); -sys_var_thd_ulong sys_tmp_table_size("tmp_table_size", +sys_var_thd_ulonglong sys_tmp_table_size("tmp_table_size", &SV::tmp_table_size); sys_var_bool_ptr sys_timed_mutexes("timed_mutexes", &timed_mutexes); diff --git a/sql/sql_class.h b/sql/sql_class.h index 2467385b679..e3ae682edae 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -495,6 +495,8 @@ struct system_variables { ulonglong myisam_max_extra_sort_file_size; ulonglong myisam_max_sort_file_size; + ulonglong max_heap_table_size; + ulonglong tmp_table_size; ha_rows select_limit; ha_rows max_join_size; ulong auto_increment_increment, auto_increment_offset; @@ -503,7 +505,6 @@ struct system_variables ulong long_query_time; ulong max_allowed_packet; ulong max_error_count; - ulong max_heap_table_size; ulong max_length_for_sort_data; ulong max_sort_length; ulong max_tmp_tables; @@ -527,7 +528,6 @@ struct system_variables ulong div_precincrement; ulong sortbuff_size; ulong table_type; - ulong tmp_table_size; ulong tx_isolation; ulong completion_type; /* Determines which non-standard SQL behaviour should be enabled */ @@ -2068,7 +2068,8 @@ class user_var_entry class Unique :public Sql_alloc { DYNAMIC_ARRAY file_ptrs; - ulong max_elements, max_in_memory_size; + ulong max_elements; + ulonglong max_in_memory_size; IO_CACHE file; TREE tree; byte *record_pointers; @@ -2078,7 +2079,7 @@ class Unique :public Sql_alloc public: ulong elements; Unique(qsort_cmp2 comp_func, void *comp_func_fixed_arg, - uint size_arg, ulong max_in_memory_size_arg); + uint size_arg, ulonglong max_in_memory_size_arg); ~Unique(); ulong elements_in_tree() { return tree.elements_in_tree; } inline bool unique_add(void *ptr) @@ -2092,13 +2093,13 @@ public: bool get(TABLE *table); static double get_use_cost(uint *buffer, uint nkeys, uint key_size, - ulong max_in_memory_size); + ulonglong max_in_memory_size); inline static int get_cost_calc_buff_size(ulong nkeys, uint key_size, - ulong max_in_memory_size) + ulonglong max_in_memory_size) { - register ulong max_elems_in_tree= + register ulonglong max_elems_in_tree= (1 + max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size)); - return sizeof(uint)*(1 + nkeys/max_elems_in_tree); + return (int) (sizeof(uint)*(1 + nkeys/max_elems_in_tree)); } void reset(); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1d89cac584a..4758371f2e0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9254,7 +9254,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, param->recinfo=recinfo; store_record(table,s->default_values); // Make empty default record - if (thd->variables.tmp_table_size == ~(ulong) 0) // No limit + if (thd->variables.tmp_table_size == ~ (ulonglong) 0) // No limit table->s->max_rows= ~(ha_rows) 0; else table->s->max_rows= (((table->s->db_type == DB_TYPE_HEAP) ? diff --git a/sql/table.cc b/sql/table.cc index 5a2281775b1..eed90eb411f 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -730,6 +730,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, if (key_part->fieldnr) { // Should always be true ! Field *field=key_part->field=outparam->field[key_part->fieldnr-1]; + key_part->type= field->key_type(); if (field->null_ptr) { key_part->null_offset=(uint) ((byte*) field->null_ptr - diff --git a/sql/uniques.cc b/sql/uniques.cc index ad074f8b2b0..ac603791376 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -55,7 +55,7 @@ int unique_write_to_ptrs(gptr key, element_count count, Unique *unique) } Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg, - uint size_arg, ulong max_in_memory_size_arg) + uint size_arg, ulonglong max_in_memory_size_arg) :max_in_memory_size(max_in_memory_size_arg), size(size_arg), elements(0) { my_b_clear(&file); @@ -260,7 +260,7 @@ static double get_merge_many_buffs_cost(uint *buffer, */ double Unique::get_use_cost(uint *buffer, uint nkeys, uint key_size, - ulong max_in_memory_size) + ulonglong max_in_memory_size) { ulong max_elements_in_tree; ulong last_tree_elems; From 9221a5482bb39be7391f46d81e1e85dc41b47729 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 28 Nov 2006 15:44:11 +0200 Subject: [PATCH 17/39] BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) When implicitly converting string fields to numbers the string-to-number conversion error was not sent to the client. Added code to send the conversion error as warning. We also need to prevent generation of warnings from the places where val_xxx() methods are called for the sole purpose of updating the Item::null_value flag. To achieve that a special function is added (and called) : update_null_value(). This function will set the no_errors flag and will call val_xxx(). The warning generation in Field_string::val_xxx() will use the flag when generating the conversion warnings. mysql-test/r/compare.result: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - non-convertible strings in arithmetic operations mysql-test/r/func_gconcat.result: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - non-convertible strings in arithmetic operations mysql-test/r/func_group.result: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - non-convertible strings in arithmetic operations mysql-test/r/type_varchar.result: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - test case mysql-test/t/type_varchar.test: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - test case sql/field.cc: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - send conversion warning to the client sql/item.cc: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - send conversion warning to the client sql/item.h: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - added a special function to explicitly update the null_value sql/item_func.h: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - added a special function to explicitly update the null_value sql/item_subselect.h: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - added a special function to explicitly update the null_value sql/item_sum.cc: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - added a special function to explicitly update the null_value sql/item_sum.h: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - added a special function to explicitly update the null_value sql/sql_string.h: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - send conversion warning to the client --- mysql-test/r/compare.result | 4 +++ mysql-test/r/func_gconcat.result | 38 ++++++++++++++++++++ mysql-test/r/func_group.result | 7 ++++ mysql-test/r/type_varchar.result | 35 +++++++++++++++++++ mysql-test/t/type_varchar.test | 9 +++++ sql/field.cc | 60 +++++++++++++++++++++++++++----- sql/item.cc | 24 +++++++++---- sql/item.h | 6 ++++ sql/item_func.h | 4 +-- sql/item_subselect.h | 2 +- sql/item_sum.cc | 8 ++--- sql/item_sum.h | 4 +-- sql/sql_string.h | 6 ++++ 13 files changed, 183 insertions(+), 24 deletions(-) diff --git a/mysql-test/r/compare.result b/mysql-test/r/compare.result index da0ca8ddba1..c141b255716 100644 --- a/mysql-test/r/compare.result +++ b/mysql-test/r/compare.result @@ -46,6 +46,10 @@ create table t1 (a tinyint(1),b binary(1)); insert into t1 values (0x01,0x01); select * from t1 where a=b; a b +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '' select * from t1 where a=b and b=0x01; a b +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '' drop table if exists t1; diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 5dbbd891427..1b82ebc8b16 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -64,11 +64,49 @@ grp group_concat(a order by a,d+c-ascii(c)-a) 1 1 2 2,3 3 4,5,6,7,8,9 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a ' +Warning 1292 Truncated incorrect DOUBLE value: 'a ' +Warning 1292 Truncated incorrect DOUBLE value: 'a ' +Warning 1292 Truncated incorrect DOUBLE value: 'b ' +Warning 1292 Truncated incorrect DOUBLE value: 'b ' +Warning 1292 Truncated incorrect DOUBLE value: 'c ' +Warning 1292 Truncated incorrect DOUBLE value: 'a ' +Warning 1292 Truncated incorrect DOUBLE value: 'E ' +Warning 1292 Truncated incorrect DOUBLE value: 'b ' +Warning 1292 Truncated incorrect DOUBLE value: 'C ' +Warning 1292 Truncated incorrect DOUBLE value: 'b ' +Warning 1292 Truncated incorrect DOUBLE value: 'D ' +Warning 1292 Truncated incorrect DOUBLE value: 'd ' +Warning 1292 Truncated incorrect DOUBLE value: 'd ' +Warning 1292 Truncated incorrect DOUBLE value: 'd ' +Warning 1292 Truncated incorrect DOUBLE value: 'd ' +Warning 1292 Truncated incorrect DOUBLE value: 'c ' +Warning 1292 Truncated incorrect DOUBLE value: 'D ' select grp,group_concat(a order by d+c-ascii(c),a) from t1 group by grp; grp group_concat(a order by d+c-ascii(c),a) 1 1 2 3,2 3 7,8,4,6,9,5 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a ' +Warning 1292 Truncated incorrect DOUBLE value: 'a ' +Warning 1292 Truncated incorrect DOUBLE value: 'a ' +Warning 1292 Truncated incorrect DOUBLE value: 'b ' +Warning 1292 Truncated incorrect DOUBLE value: 'b ' +Warning 1292 Truncated incorrect DOUBLE value: 'c ' +Warning 1292 Truncated incorrect DOUBLE value: 'a ' +Warning 1292 Truncated incorrect DOUBLE value: 'E ' +Warning 1292 Truncated incorrect DOUBLE value: 'b ' +Warning 1292 Truncated incorrect DOUBLE value: 'C ' +Warning 1292 Truncated incorrect DOUBLE value: 'b ' +Warning 1292 Truncated incorrect DOUBLE value: 'D ' +Warning 1292 Truncated incorrect DOUBLE value: 'd ' +Warning 1292 Truncated incorrect DOUBLE value: 'd ' +Warning 1292 Truncated incorrect DOUBLE value: 'd ' +Warning 1292 Truncated incorrect DOUBLE value: 'd ' +Warning 1292 Truncated incorrect DOUBLE value: 'c ' +Warning 1292 Truncated incorrect DOUBLE value: 'D ' select grp,group_concat(c order by 1) from t1 group by grp; grp group_concat(c order by 1) 1 a diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 23517f7b603..020f807ece2 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -62,6 +62,13 @@ NULL NULL 1 7 2 20.25 3 45.483163247594 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a ' +Warning 1292 Truncated incorrect DOUBLE value: 'a ' +Warning 1292 Truncated incorrect DOUBLE value: 'b ' +Warning 1292 Truncated incorrect DOUBLE value: 'c ' +Warning 1292 Truncated incorrect DOUBLE value: 'C ' +Warning 1292 Truncated incorrect DOUBLE value: 'E ' create table t2 (grp int, a bigint unsigned, c char(10)); insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp; replace into t2 select grp, a, c from t1 limit 2,1; diff --git a/mysql-test/r/type_varchar.result b/mysql-test/r/type_varchar.result index 1d707b83a4d..4c1aee24642 100644 --- a/mysql-test/r/type_varchar.result +++ b/mysql-test/r/type_varchar.result @@ -453,3 +453,38 @@ id name_id id en cz 2 3 2 en string 2 cz string 2 3 3 3 en string 3 cz string 3 drop table t1, t2, t3; +CREATE TABLE t1 (a CHAR(2)); +INSERT INTO t1 VALUES (10), (50), (30), ('1a'), (60), ('t'); +SELECT a,(a + 0) FROM t1 ORDER BY a; +a (a + 0) +10 10 +1a 1 +30 30 +50 50 +60 60 +t 0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '1a' +Warning 1292 Truncated incorrect DOUBLE value: 't ' +SELECT a,(a DIV 2) FROM t1 ORDER BY a; +a (a DIV 2) +10 5 +1a 0 +30 15 +50 25 +60 30 +t 0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '1a' +Warning 1292 Truncated incorrect INTEGER value: 't ' +SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a; +a CAST(a AS SIGNED) +10 10 +1a 1 +30 30 +50 50 +60 60 +t 0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '1a' +Warning 1292 Truncated incorrect INTEGER value: 't' diff --git a/mysql-test/t/type_varchar.test b/mysql-test/t/type_varchar.test index 439e98471b2..cfb6472a7b4 100644 --- a/mysql-test/t/type_varchar.test +++ b/mysql-test/t/type_varchar.test @@ -187,3 +187,12 @@ left join t3 on t1.id=t3.id order by t3.id; --disable_metadata --enable_ps_protocol drop table t1, t2, t3; + +# +# Bug #11927: Warnings shown for CAST( chr as signed) but not (chr + 0) +# +CREATE TABLE t1 (a CHAR(2)); +INSERT INTO t1 VALUES (10), (50), (30), ('1a'), (60), ('t'); +SELECT a,(a + 0) FROM t1 ORDER BY a; +SELECT a,(a DIV 2) FROM t1 ORDER BY a; +SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a; diff --git a/sql/field.cc b/sql/field.cc index 61bbea5e615..a45caf4fa4e 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -47,6 +47,8 @@ uchar Field_null::null[1]={1}; const char field_separator=','; #define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE 320 +#define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128 +#define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128 #define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \ ((ulong) ((LL(1) << min(arg, 4) * 8) - LL(1))) @@ -5954,19 +5956,49 @@ int Field_longstr::store_decimal(const my_decimal *d) double Field_string::val_real(void) { - int not_used; - char *end_not_used; + int error; + char *end; CHARSET_INFO *cs= charset(); - return my_strntod(cs,ptr,field_length,&end_not_used,¬_used); + double result; + + result= my_strntod(cs,ptr,field_length,&end,&error); + if (!table->in_use->no_errors && + (error || (field_length != (uint32)(end - ptr) && + !check_if_only_end_space(cs, end, ptr + field_length)))) + { + char buf[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; + String tmp(buf, sizeof(buf), cs); + tmp.copy(ptr, field_length, cs); + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TRUNCATED_WRONG_VALUE, + ER(ER_TRUNCATED_WRONG_VALUE), + "DOUBLE", tmp.c_ptr()); + } + return result; } longlong Field_string::val_int(void) { - int not_used; - char *end_not_used; - CHARSET_INFO *cs=charset(); - return my_strntoll(cs,ptr,field_length,10,&end_not_used,¬_used); + int error; + char *end; + CHARSET_INFO *cs= charset(); + longlong result; + + result= my_strntoll(cs,ptr,field_length,10,&end,&error); + if (!table->in_use->no_errors && + (error || (field_length != (uint32)(end - ptr) && + !check_if_only_end_space(cs, end, ptr + field_length)))) + { + char buf[LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE]; + String tmp(buf, sizeof(buf), cs); + tmp.copy(ptr, field_length, cs); + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TRUNCATED_WRONG_VALUE, + ER(ER_TRUNCATED_WRONG_VALUE), + "INTEGER", tmp.c_ptr()); + } + return result; } @@ -5983,8 +6015,20 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)), my_decimal *Field_string::val_decimal(my_decimal *decimal_value) { - str2my_decimal(E_DEC_FATAL_ERROR, ptr, field_length, charset(), + int err= str2my_decimal(E_DEC_FATAL_ERROR, ptr, field_length, charset(), decimal_value); + if (!table->in_use->no_errors && err) + { + char buf[DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE]; + CHARSET_INFO *cs= charset(); + String tmp(buf, sizeof(buf), cs); + tmp.copy(ptr, field_length, cs); + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TRUNCATED_WRONG_VALUE, + ER(ER_TRUNCATED_WRONG_VALUE), + "DECIMAL", tmp.c_ptr()); + } + return decimal_value; } diff --git a/sql/item.cc b/sql/item.cc index 76f0332b4ab..79822fb0a12 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2175,12 +2175,6 @@ void Item_string::print(String *str) } -inline bool check_if_only_end_space(CHARSET_INFO *cs, char *str, char *end) -{ - return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end; -} - - double Item_string::val_real() { DBUG_ASSERT(fixed == 1); @@ -4764,6 +4758,22 @@ bool Item_field::send(Protocol *protocol, String *buffer) } +void Item_field::update_null_value() +{ + /* + need to set no_errors to prevent warnings about type conversion + popping up. + */ + THD *thd= field->table->in_use; + int no_errors; + + no_errors= thd->no_errors; + thd->no_errors= 1; + Item::update_null_value(); + thd->no_errors= no_errors; +} + + Item_ref::Item_ref(Name_resolution_context *context_arg, Item **item, const char *table_name_arg, const char *field_name_arg) @@ -6120,7 +6130,7 @@ bool Item_cache_row::null_inside() } else { - values[i]->val_int(); + values[i]->update_null_value(); if (values[i]->null_value) return 1; } diff --git a/sql/item.h b/sql/item.h index c1a04e4281d..20a674514b2 100644 --- a/sql/item.h +++ b/sql/item.h @@ -715,6 +715,11 @@ public: */ virtual bool is_null() { return 0; } + /* + Make sure the null_value member has a correct value. + */ + virtual void update_null_value () { (void) val_int(); } + /* Inform the item that there will be no distinction between its result being FALSE or NULL. @@ -1282,6 +1287,7 @@ public: bool get_date_result(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); bool is_null() { return field->is_null(); } + void update_null_value(); Item *get_tmp_table_item(THD *thd); bool collect_item_field_processor(byte * arg); bool find_item_in_field_list_processor(byte *arg); diff --git a/sql/item_func.h b/sql/item_func.h index 99f7d16855e..af4e4bdbcbc 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -157,7 +157,7 @@ public: return (null_value=args[0]->get_time(ltime)); } bool is_null() { - (void) val_int(); /* Discard result. It sets null_value as side-effect. */ + update_null_value(); return null_value; } void signal_divide_by_null(); @@ -241,7 +241,7 @@ public: virtual double real_op()= 0; virtual my_decimal *decimal_op(my_decimal *)= 0; virtual String *str_op(String *)= 0; - bool is_null() { (void) val_real(); return null_value; } + bool is_null() { update_null_value(); return null_value; } }; /* function where type of result detected by first argument */ diff --git a/sql/item_subselect.h b/sql/item_subselect.h index f1be99353cc..35ded79b75d 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -91,7 +91,7 @@ public: enum Type type() const; bool is_null() { - val_int(); + update_null_value(); return null_value; } bool fix_fields(THD *thd, Item **ref); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index fccbdfa7925..c6f29efa5ca 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1050,7 +1050,7 @@ bool Item_sum_count::add() count++; else { - (void) args[0]->val_int(); + args[0]->update_null_value(); if (!args[0]->null_value) count++; } @@ -1956,7 +1956,7 @@ void Item_sum_count::reset_field() nr=1; else { - (void) args[0]->val_int(); + args[0]->update_null_value(); if (!args[0]->null_value) nr=1; } @@ -2066,7 +2066,7 @@ void Item_sum_count::update_field() nr++; else { - (void) args[0]->val_int(); + args[0]->update_null_value(); if (!args[0]->null_value) nr++; } @@ -2546,7 +2546,7 @@ bool Item_sum_count_distinct::setup(THD *thd) return TRUE; // End of memory if (item->const_item()) { - (void) item->val_int(); + item->update_null_value(); if (item->null_value) always_null=1; } diff --git a/sql/item_sum.h b/sql/item_sum.h index a2b2f7cab92..42129008047 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -587,7 +587,7 @@ public: double val_real(); longlong val_int(); my_decimal *val_decimal(my_decimal *); - bool is_null() { (void) val_int(); return null_value; } + bool is_null() { update_null_value(); return null_value; } String *val_str(String*); enum_field_types field_type() const { @@ -649,7 +649,7 @@ public: { /* can't be fix_fields()ed */ return (longlong) rint(val_real()); } String *val_str(String*); my_decimal *val_decimal(my_decimal *); - bool is_null() { (void) val_int(); return null_value; } + bool is_null() { update_null_value(); return null_value; } enum_field_types field_type() const { return hybrid_type == DECIMAL_RESULT ? diff --git a/sql/sql_string.h b/sql/sql_string.h index 0659f684afe..812ab8b4d61 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -355,3 +355,9 @@ public: return (s->alloced && Ptr >= s->Ptr && Ptr < s->Ptr + s->str_length); } }; + +static inline bool check_if_only_end_space(CHARSET_INFO *cs, char *str, + char *end) +{ + return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end; +} From 762f4ac16715b13fffa24520513b947c5ccdf82c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 28 Nov 2006 18:06:47 +0200 Subject: [PATCH 18/39] Bug#24156: Loose index scan not used with CREATE TABLE ...SELECT and similar statements Currently the optimizer evaluates loose index scan only for top-level SELECT statements Extend loose index scan applicability by : - Test the applicability of loose scan for each sub-select, instead of the whole query. This change enables loose index scan for sub-queries. - allow non-select statements with SELECT parts (like, e.g. CREATE TABLE .. SELECT ...) to use loose index scan. mysql-test/r/group_min_max.result: Bug#24156: Loose index scan not used with CREATE TABLE ...SELECT and similar statements - test case mysql-test/t/group_min_max.test: Bug#24156: Loose index scan not used with CREATE TABLE ...SELECT and similar statements - test case sql/opt_range.cc: Bug#24156: Loose index scan not used with CREATE TABLE ...SELECT and similar statements - loose index scan will be tried over the current subselect (lex->current_select) instead of the whole query (lex->select_lex). - allow non-select statements with SELECT parts (like, e.g. CREATE TABLE .. SELECT ...) to use loose index scan. --- mysql-test/r/group_min_max.result | 124 ++++++++++++++++++++++++++++++ mysql-test/t/group_min_max.test | 60 +++++++++++++++ sql/opt_range.cc | 6 +- 3 files changed, 187 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index 0304919baf6..7583aa14db8 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -2162,3 +2162,127 @@ SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; MIN(c) 2 DROP TABLE t1,t2; +CREATE TABLE t1 (a INT, b INT, INDEX (a,b)); +INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5), +(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6); +EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range NULL a 5 NULL 8 Using index for group-by +FLUSH STATUS; +SELECT max(b), a FROM t1 GROUP BY a; +max(b) a +5 1 +3 2 +1 3 +6 4 +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 8 +Handler_read_next 0 +EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range NULL a 5 NULL 8 Using index for group-by +FLUSH STATUS; +CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a; +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 8 +Handler_read_next 0 +FLUSH STATUS; +SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b; +max(b) a +5 1 +3 2 +1 3 +6 4 +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 8 +Handler_read_next 0 +FLUSH STATUS; +(SELECT max(b), a FROM t1 GROUP BY a) UNION +(SELECT max(b), a FROM t1 GROUP BY a); +max(b) a +5 1 +3 2 +1 3 +6 4 +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 16 +Handler_read_next 0 +EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION +(SELECT max(b), a FROM t1 GROUP BY a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 range NULL a 5 NULL 8 Using index for group-by +2 UNION t1 range NULL a 5 NULL 8 Using index for group-by +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x +FROM t1 AS t1_outer; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index +2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS +(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index +2 SUBQUERY t1 index NULL a 10 NULL 8 Using index +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE +(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE +a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1_outer index NULL a 10 NULL 15 Using where; Using index +2 DEPENDENT SUBQUERY t1 index NULL a 10 NULL 8 Using index +EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING +a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1_outer range NULL a 5 NULL 8 Using index for group-by +2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by +EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2 +ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) +AND t1_outer1.b = t1_outer2.b; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index +1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index +2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by +EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x +FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using index +2 SUBQUERY t1_outer index NULL a 10 NULL 15 Using index +3 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by +CREATE TABLE t3 LIKE t1; +FLUSH STATUS; +INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a; +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 8 +Handler_read_next 0 +DELETE FROM t3; +FLUSH STATUS; +INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) +FROM t1 LIMIT 1; +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 8 +Handler_read_next 0 +FLUSH STATUS; +DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000; +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 8 +Handler_read_next 0 +FLUSH STATUS; +DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x +FROM t1) > 10000; +Warnings: +Error 1242 Subquery returns more than 1 row +SHOW STATUS LIKE 'handler_read__e%'; +Variable_name Value +Handler_read_key 8 +Handler_read_next 1 +DROP TABLE t1,t2,t3; diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index 08f0f54df60..5ed082f7583 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -810,3 +810,63 @@ explain SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a; DROP TABLE t1,t2; + +# +# Bug#24156: Loose index scan not used with CREATE TABLE ...SELECT and similar statements +# + +CREATE TABLE t1 (a INT, b INT, INDEX (a,b)); +INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5), + (2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6); +EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; +FLUSH STATUS; +SELECT max(b), a FROM t1 GROUP BY a; +SHOW STATUS LIKE 'handler_read__e%'; +EXPLAIN SELECT max(b), a FROM t1 GROUP BY a; +FLUSH STATUS; +CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a; +SHOW STATUS LIKE 'handler_read__e%'; +FLUSH STATUS; +SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b; +SHOW STATUS LIKE 'handler_read__e%'; +FLUSH STATUS; +(SELECT max(b), a FROM t1 GROUP BY a) UNION + (SELECT max(b), a FROM t1 GROUP BY a); +SHOW STATUS LIKE 'handler_read__e%'; +EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION + (SELECT max(b), a FROM t1 GROUP BY a); + +EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x + FROM t1 AS t1_outer; +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS + (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE + (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; +EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE + a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); +EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING + a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); +EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2 + ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) + AND t1_outer1.b = t1_outer2.b; +EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x + FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2; + +CREATE TABLE t3 LIKE t1; +FLUSH STATUS; +INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a; +SHOW STATUS LIKE 'handler_read__e%'; +DELETE FROM t3; +FLUSH STATUS; +INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) + FROM t1 LIMIT 1; +SHOW STATUS LIKE 'handler_read__e%'; +FLUSH STATUS; +DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000; +SHOW STATUS LIKE 'handler_read__e%'; +FLUSH STATUS; +DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x + FROM t1) > 10000; +SHOW STATUS LIKE 'handler_read__e%'; + +DROP TABLE t1,t2,t3; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 96239315026..596640fdf95 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -7445,7 +7445,7 @@ static TRP_GROUP_MIN_MAX * get_best_group_min_max(PARAM *param, SEL_TREE *tree) { THD *thd= param->thd; - JOIN *join= thd->lex->select_lex.join; + JOIN *join= thd->lex->current_select->join; TABLE *table= param->table; bool have_min= FALSE; /* TRUE if there is a MIN function. */ bool have_max= FALSE; /* TRUE if there is a MAX function. */ @@ -7466,7 +7466,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree) DBUG_ENTER("get_best_group_min_max"); /* Perform few 'cheap' tests whether this access method is applicable. */ - if (!join || (thd->lex->sql_command != SQLCOM_SELECT)) + if (!join) DBUG_RETURN(NULL); /* This is not a select statement. */ if ((join->tables != 1) || /* The query must reference one table. */ ((!join->group_list) && /* Neither GROUP BY nor a DISTINCT query. */ @@ -8316,7 +8316,7 @@ TRP_GROUP_MIN_MAX::make_quick(PARAM *param, bool retrieve_full_rows, DBUG_ENTER("TRP_GROUP_MIN_MAX::make_quick"); quick= new QUICK_GROUP_MIN_MAX_SELECT(param->table, - param->thd->lex->select_lex.join, + param->thd->lex->current_select->join, have_min, have_max, min_max_arg_part, group_prefix_len, used_key_parts, index_info, index, read_cost, records, From 89a71063402dcdf91e184e52b28bfe994885f97a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 28 Nov 2006 18:08:30 +0100 Subject: [PATCH 19/39] Makefile.am: Handle the case "sql_yacc.cc" is pregenerated or not, and that the case where the source and build tree is the same or not. sql/Makefile.am: Handle the case "sql_yacc.cc" is pregenerated or not, and that the case where the source and build tree is the same or not. --- sql/Makefile.am | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/Makefile.am b/sql/Makefile.am index 6c685ba67c6..cbb87f16d80 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -148,12 +148,15 @@ mysql_tzinfo_to_sql.o: $(mysql_tzinfo_to_sql_SOURCES) sql_yacc.cc: sql_yacc.yy sql_yacc.h: sql_yacc.yy +# Be careful here, note that we use VPATH and might or might not have +# a pregenerated "sql_yacc.cc" in $(srcdir) or one we just built in +# $(builddir). And it has to work if $(srcdir) == $(builddir). sql_yacc.o: sql_yacc.cc sql_yacc.h $(HEADERS) - @SED@ -e 's/__attribute__ ((__unused__))//' sql_yacc.cc > sql_yacc.cc-new + @SED@ -e 's/__attribute__ ((__unused__))//' $< > sql_yacc.cc-new @MV@ sql_yacc.cc-new sql_yacc.cc @echo "Note: The following compile may take a long time." @echo "If it fails, re-run configure with --with-low-memory" - $(CXXCOMPILE) $(LM_CFLAGS) -c $< + $(CXXCOMPILE) $(LM_CFLAGS) -c sql_yacc.cc # This generates lex_hash.h # NOTE Built sources should depend on their sources not the tool From af6185240ad6120cc6b74b331fce571353552621 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Nov 2006 09:23:54 +0400 Subject: [PATCH 20/39] fixed compilation failure on hpux the problem is that client tools are compiled with UNDEF_THREADS_HACK flag, and my thread-related additions to the mysqltest.c can't be compiled. Easy solution is to disable these in not-embedded case completely. client/mysqltest.c: it's used in embedded server only --- client/mysqltest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index b73ee831cf3..9fe427000d4 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -223,11 +223,13 @@ struct st_connection char *name; MYSQL_STMT* stmt; +#ifdef EMBEDDED_LIBRARY const char *cur_query; int cur_query_len; pthread_mutex_t mutex; pthread_cond_t cond; int query_done; +#endif /*EMBEDDED_LIBRARY*/ }; struct st_connection connections[128]; struct st_connection* cur_con, *next_con, *connections_end; From 3344298d197042b9636265c18ed54935e973de00 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Nov 2006 10:21:59 +0100 Subject: [PATCH 21/39] minor fix mysql-test/mysql-test-run.pl: remove dependency on Data::Dumper, it's not used anywhere --- mysql-test/mysql-test-run.pl | 1 - 1 file changed, 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index f3981dc7c70..a734408e049 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -63,7 +63,6 @@ use Getopt::Long; use Sys::Hostname; use IO::Socket; use IO::Socket::INET; -use Data::Dumper; use strict; use warnings; use diagnostics; From fe499575af62bebdc42f804645da089f8e268bc4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Nov 2006 14:52:11 +0300 Subject: [PATCH 22/39] Bug#20327: Marking of a wrong field leads to a wrong result on select with view, prepared statement and subquery. When a field of a view from an outer select is resolved the find_field_in_view function creates an Item_direct_view_ref object that references the corresponding view underlying field. After that the view_ref is marked as a dependent one. While resolving view underlying field it also get marked as a dependent one due to current_select still points to the subselect. Marking the view underlying field is wrong and lead to attaching conditions to a wrong table and thus to the wrong result of the whole statement. Now mark_select_range_as_dependent() function isn't called for fields from a view underlying table. sql/sql_base.cc: Bug#20327: Marking of a wrong field leads to a wrong result on select with view, prepared statement and subquery. Now mark_select_range_as_dependent() function isn't called for fields from a view underlying table. mysql-test/r/ps.result: Added a test case for bug#20327: Marking of a wrong field leads to a wrong result on select with view, prepared statement and subquery. mysql-test/t/ps.test: Added a test case for bug#20327: Marking of a wrong field leads to a wrong result on select with view,prepared statement and subquery. --- mysql-test/r/ps.result | 18 ++++++++++++++++++ mysql-test/t/ps.test | 22 ++++++++++++++++++++++ sql/sql_base.cc | 6 ++++++ 3 files changed, 46 insertions(+) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 048c3ae46d3..2493bd372ea 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1379,4 +1379,22 @@ i 1 DEALLOCATE PREPARE stmt; DROP TABLE t1, t2; +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES (1), (2); +SELECT t1.i FROM t1 JOIN v1 ON t1.i = v1.i +WHERE EXISTS (SELECT * FROM t1 WHERE v1.i = 1); +i +1 +PREPARE stmt FROM "SELECT t1.i FROM t1 JOIN v1 ON t1.i = v1.i +WHERE EXISTS (SELECT * FROM t1 WHERE v1.i = 1)"; +EXECUTE stmt; +i +1 +EXECUTE stmt; +i +1 +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; End of 5.0 tests. diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index f1e8e77d94e..be77c2533e9 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1437,4 +1437,26 @@ DEALLOCATE PREPARE stmt; DROP TABLE t1, t2; +# +# BUG#20327: Marking of a wrong field leads to a wrong result on select with +# view, prepared statement and subquery. +# +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT * FROM t1; + +INSERT INTO t1 VALUES (1), (2); + +let $query = SELECT t1.i FROM t1 JOIN v1 ON t1.i = v1.i + WHERE EXISTS (SELECT * FROM t1 WHERE v1.i = 1); +eval $query; +eval PREPARE stmt FROM "$query"; +# Statement execution should return '1'. +EXECUTE stmt; +# Check re-execution. +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; +DROP VIEW v1; +DROP TABLE t1; + --echo End of 5.0 tests. diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3984ceac6a9..314452fac89 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3303,6 +3303,12 @@ find_field_in_tables(THD *thd, Item_ident *item, { if (found == WRONG_GRANT) return (Field*) 0; + + /* + Only views fields should be marked as dependent, not an underlying + fields. + */ + if (!table_ref->belong_to_view) { SELECT_LEX *current_sel= thd->lex->current_select; SELECT_LEX *last_select= table_ref->select_lex; From c707c7eae738627bb39c2b9c1f050e90971e8959 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Nov 2006 15:51:53 +0300 Subject: [PATCH 23/39] BUG#20637: "load data concurrent infile" locks the table Note that we ignore CONCURRENT if LOAD DATA CONCURRENT is used from inside a stored routine and MySQL is compiled with Query Cache support (this is not in the manual). The problem was that the condition test of "we are inside stored routine" was reversed, thus CONCURRENT _worked only_ from stored routine. The solution is to use proper condition test. No test case is provided because the test case would require a large amount of input, and it's hard to tell is SELECT is really blocked or just slow (subject to race). sql/sql_yacc.yy: Fix the condition of TL_WRITE_CONCURRENT_INSERT on LOAD DATA CONCURRENT, which was reversed, and return valid value if we are in SP. --- sql/sql_yacc.yy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6f24a42c07c..7347a2aabb8 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7031,6 +7031,8 @@ load_data_lock: Ignore this option in SP to avoid problem with query cache */ if (Lex->sphead != 0) + $$= YYTHD->update_lock_default; + else #endif $$= TL_WRITE_CONCURRENT_INSERT; } From ea81119367f263307adb19481d87597796976a3e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Nov 2006 18:12:08 +0300 Subject: [PATCH 24/39] view_grant.result: Small fix for a test case mysql-test/r/view_grant.result: Small fix for a test case --- mysql-test/r/view_grant.result | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index 422d6c5faaf..1e8aa1d05db 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -725,8 +725,7 @@ CREATE VIEW v1 AS SELECT * FROM t1; DROP USER def_17254@localhost; for a user SELECT * FROM v1; -ERROR 42000: SELECT command denied to user 'inv_17254'@'localhost' for table 'v1 -' +ERROR 42000: SELECT command denied to user 'inv_17254'@'localhost' for table 'v1' for a superuser SELECT * FROM v1; ERROR HY000: There is no 'def_17254'@'localhost' registered From c2a9b34b92b65a0cbdced1364986b36d0422533c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Nov 2006 19:35:40 +0100 Subject: [PATCH 25/39] Makefile.am: "make distcheck" fix, "win" directory Makefile.am: "make distcheck" fix, "win" directory --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 1a0afdf25f4..d52951ec876 100644 --- a/Makefile.am +++ b/Makefile.am @@ -92,6 +92,7 @@ bin-dist: all # Create initial database files for Windows installations. dist-hook: rm -rf `find $(distdir) -type d -name SCCS -print` + mkdir -p "$(distdir)/win" if echo "$(distdir)" | grep -q '^/' ; then \ scripts/mysql_install_db --no-defaults --windows \ --basedir=$(top_srcdir) \ From 1a32976dea2da73fd119aeae600aa2c85706bd54 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Nov 2006 19:41:48 +0100 Subject: [PATCH 26/39] Makefile.am: Corrected change to create "win" directory Makefile.am: Corrected change to create "win" directory --- Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index d52951ec876..a3c3c2c08a0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -92,12 +92,13 @@ bin-dist: all # Create initial database files for Windows installations. dist-hook: rm -rf `find $(distdir) -type d -name SCCS -print` - mkdir -p "$(distdir)/win" if echo "$(distdir)" | grep -q '^/' ; then \ + mkdir -p "$(distdir)/win" ; \ scripts/mysql_install_db --no-defaults --windows \ --basedir=$(top_srcdir) \ --datadir="$(distdir)/win/data"; \ else \ + mkdir -p "$$(pwd)/$(distdir)/win" ; \ scripts/mysql_install_db --no-defaults --windows \ --basedir=$(top_srcdir) \ --datadir="$$(pwd)/$(distdir)/win/data"; \ From 3b1abddb25b722d12b5dbf224ca36e83df404e44 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Nov 2006 20:22:58 +0100 Subject: [PATCH 27/39] Makefile.am: Remove soft links before creating source TAR, to avoid file copies (bug#11865) Makefile.am: Remove soft links before creating source TAR, to avoid file copies (bug#11865) --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 12a867c1ad7..38e6a28b1b5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -91,6 +91,7 @@ bin-dist: all # Remove BK's "SCCS" subdirectories from source distribution dist-hook: rm -rf `find $(distdir) -type d -name SCCS -print` + rm -f `find $(distdir) -type l -print` tags: support-files/build-tags From 42fd48da99b2ba2641697ebb567af555fb270e9e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Nov 2006 22:14:08 +0200 Subject: [PATCH 28/39] Ignore some generated files Don't return from my_thread_global_end() until all threads have called my_thread_end() Bug#24387: Valgrind: my_thread_init (handle_sl sql, handle_one_conn, handle_slave_io) BitKeeper/etc/ignore: added *.gcda *.gcno include/my_pthread.h: Added my_thread_end_wait_time Removed not used thread variables mysys/my_thr_init.c: Add thread counters. Don't return from my_thread_global_end() until all threads have called my_thread_end() (Or a timeout (5 seconds) has elapsed) This fixed some valgrind warnings Bug#24387: Valgrind: my_thread_init (handle_sl sql, handle_one_conn, handle_slave_io) --- .bzrignore | 7 +++++++ include/my_pthread.h | 3 +-- mysys/my_thr_init.c | 50 +++++++++++++++++++++++++++++++++++--------- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/.bzrignore b/.bzrignore index d6086ba4a76..8455c05b220 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1323,3 +1323,10 @@ win/vs8cache.txt zlib/*.ds? zlib/*.vcproj mysql-test/r/*.warnings +bdb/dist/db.h +bdb/dist/db_config.h +bdb/dist/db_cxx.h +bdb/dist/db_int.h +bdb/dist/include.tcl +*.gcda +*.gcno diff --git a/include/my_pthread.h b/include/my_pthread.h index 3e4388413e0..300291610d3 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -677,14 +677,13 @@ struct st_my_thread_var }; extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const)); +extern uint my_thread_end_wait_time; #define my_thread_var (_my_thread_var()) #define my_errno my_thread_var->thr_errno /* Keep track of shutdown,signal, and main threads so that my_end() will not report errors with them */ -extern pthread_t shutdown_th, main_th, signal_th; - /* statistics_xxx functions are for not essential statistic */ #ifndef thread_safe_increment diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 4d23d01cd82..7800edd700d 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -30,7 +30,10 @@ pthread_key(struct st_my_thread_var, THR_KEY_mysys); #endif /* USE_TLS */ pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open, THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_myisam,THR_LOCK_heap, - THR_LOCK_net, THR_LOCK_charset; + THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads; +pthread_cond_t THR_COND_threads; +uint THR_thread_count= 0; +uint my_thread_end_wait_time= 5; #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) pthread_mutex_t LOCK_localtime_r; #endif @@ -79,7 +82,7 @@ my_bool my_thread_global_init(void) #endif #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP /* - Set mutex type to "errorcheck" a.k.a "adaptive" + Set mutex type to "errorcheck" */ pthread_mutexattr_init(&my_errorcheck_mutexattr); pthread_mutexattr_settype(&my_errorcheck_mutexattr, @@ -94,6 +97,8 @@ my_bool my_thread_global_init(void) pthread_mutex_init(&THR_LOCK_heap,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST); + pthread_mutex_init(&THR_LOCK_threads,MY_MUTEX_INIT_FAST); + pthread_cond_init (&THR_COND_threads, NULL); #if defined( __WIN__) || defined(OS2) win_pthread_init(); #endif @@ -114,6 +119,25 @@ my_bool my_thread_global_init(void) void my_thread_global_end(void) { + struct timespec abstime; + set_timespec(abstime, my_thread_end_wait_time); + my_bool all_threads_killed= 1; + + pthread_mutex_lock(&THR_LOCK_threads); + while (THR_thread_count) + { + int error= pthread_cond_timedwait(&THR_COND_threads, &THR_LOCK_threads, + &abstime); + if (error == ETIMEDOUT || error == ETIME) + { + if (THR_thread_count) + fprintf(stderr,"error in my_thread_global_end(): %d threads didn't exit\n", + THR_thread_count); + all_threads_killed= 0; + } + } + pthread_mutex_unlock(&THR_LOCK_threads); + pthread_key_delete(THR_KEY_mysys); #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP pthread_mutexattr_destroy(&my_fast_mutexattr); @@ -129,6 +153,11 @@ void my_thread_global_end(void) pthread_mutex_destroy(&THR_LOCK_heap); pthread_mutex_destroy(&THR_LOCK_net); pthread_mutex_destroy(&THR_LOCK_charset); + if (all_threads_killed) + { + pthread_mutex_destroy(&THR_LOCK_threads); + pthread_cond_destroy (&THR_COND_threads); + } #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) pthread_mutex_destroy(&LOCK_localtime_r); #endif @@ -154,9 +183,6 @@ my_bool my_thread_init(void) #ifdef EXTRA_DEBUG_THREADS fprintf(stderr,"my_thread_init(): thread_id=%ld\n",pthread_self()); #endif -#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX) - pthread_mutex_lock(&THR_LOCK_lock); -#endif #if !defined(__WIN__) || defined(USE_TLS) if (my_pthread_getspecific(struct st_my_thread_var *,THR_KEY_mysys)) @@ -174,7 +200,7 @@ my_bool my_thread_init(void) } pthread_setspecific(THR_KEY_mysys,tmp); -#else +#else /* defined(__WIN__) && !(defined(USE_TLS) */ /* Skip initialization if the thread specific variable is already initialized */ @@ -182,7 +208,6 @@ my_bool my_thread_init(void) goto end; tmp= &THR_KEY_mysys; #endif - tmp->id= ++thread_id; #if defined(__WIN__) && defined(EMBEDDED_LIBRARY) tmp->thread_self= (pthread_t)getpid(); #endif @@ -190,10 +215,11 @@ my_bool my_thread_init(void) pthread_cond_init(&tmp->suspend, NULL); tmp->init= 1; + pthread_mutex_lock(&THR_LOCK_threads); + tmp->id= ++thread_id; + ++THR_thread_count; + pthread_mutex_unlock(&THR_LOCK_threads); end: -#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX) - pthread_mutex_unlock(&THR_LOCK_lock); -#endif return error; } @@ -232,6 +258,10 @@ void my_thread_end(void) #if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS) pthread_setspecific(THR_KEY_mysys,0); #endif + pthread_mutex_lock(&THR_LOCK_threads); + if (--THR_thread_count == 0) + pthread_cond_signal(&THR_COND_threads); + pthread_mutex_unlock(&THR_LOCK_threads); } struct st_my_thread_var *_my_thread_var(void) From ef42631b5379254fc41fa42a2a75e23dd4fc1f64 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Nov 2006 12:58:05 +0200 Subject: [PATCH 29/39] func_gconcat.result, func_gconcat.test: disabled warnings because their order is undeterministic mysql-test/t/func_gconcat.test: disabled warnings because their order is undeterministic mysql-test/r/func_gconcat.result: disabled warnings because their order is undeterministic --- mysql-test/r/func_gconcat.result | 19 ------------------- mysql-test/t/func_gconcat.test | 2 ++ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 53bcbfafdd5..655cdc4131c 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -64,25 +64,6 @@ grp group_concat(a order by a,d+c-ascii(c)-a) 1 1 2 2,3 3 4,5,6,7,8,9 -Warnings: -Warning 1292 Truncated incorrect DOUBLE value: 'a ' -Warning 1292 Truncated incorrect DOUBLE value: 'a ' -Warning 1292 Truncated incorrect DOUBLE value: 'a ' -Warning 1292 Truncated incorrect DOUBLE value: 'b ' -Warning 1292 Truncated incorrect DOUBLE value: 'b ' -Warning 1292 Truncated incorrect DOUBLE value: 'c ' -Warning 1292 Truncated incorrect DOUBLE value: 'a ' -Warning 1292 Truncated incorrect DOUBLE value: 'E ' -Warning 1292 Truncated incorrect DOUBLE value: 'b ' -Warning 1292 Truncated incorrect DOUBLE value: 'C ' -Warning 1292 Truncated incorrect DOUBLE value: 'b ' -Warning 1292 Truncated incorrect DOUBLE value: 'D ' -Warning 1292 Truncated incorrect DOUBLE value: 'd ' -Warning 1292 Truncated incorrect DOUBLE value: 'd ' -Warning 1292 Truncated incorrect DOUBLE value: 'd ' -Warning 1292 Truncated incorrect DOUBLE value: 'd ' -Warning 1292 Truncated incorrect DOUBLE value: 'c ' -Warning 1292 Truncated incorrect DOUBLE value: 'D ' select grp,group_concat(a order by d+c-ascii(c),a) from t1 group by grp; grp group_concat(a order by d+c-ascii(c),a) 1 1 diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 610c93dfb0f..bdc267d56db 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -29,7 +29,9 @@ select grp,group_concat(c order by c) from t1 group by grp; select grp,group_concat(c order by c desc) from t1 group by grp; select grp,group_concat(d order by a) from t1 group by grp; select grp,group_concat(d order by a desc) from t1 group by grp; +--disable_warnings select grp,group_concat(a order by a,d+c-ascii(c)-a) from t1 group by grp; +--enable_warnings select grp,group_concat(a order by d+c-ascii(c),a) from t1 group by grp; select grp,group_concat(c order by 1) from t1 group by grp; select grp,group_concat(distinct c order by c) from t1 group by grp; From 5af42c1b25c72ca16bf1d8181007235640b46c73 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Nov 2006 13:16:12 +0100 Subject: [PATCH 30/39] minor fix to mtr_process.pl mysql-test/lib/mtr_process.pl: print extra message _once_ every 60 seconds --- mysql-test/lib/mtr_process.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 9d0c1f601ba..eef2f1b9dd5 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -1053,7 +1053,7 @@ sub sleep_until_file_created ($$$) { # Print extra message every 60 seconds my $seconds= ($loop * $sleeptime) / 1000; - if ( $seconds > 1 and int($seconds) % 60 == 0 ) + if ( $seconds > 1 and int($seconds * 10) % 600 == 0 ) { my $left= $timeout - $seconds; mtr_warning("Waited $seconds seconds for $pidfile to be created, " . From 7191e775394db0392b78b07e2662c766eeace59c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Nov 2006 18:25:05 +0200 Subject: [PATCH 31/39] Fixed portability issue in my_thr_init.c (was added in my last push) Fixed compiler warnings (detected by VC++): - Removed not used variables - Added casts - Fixed wrong assignments to bool - Fixed wrong calls with bool arguments - Added missing argument to store(longlong), which caused wrong store method to be called. client/mysqldump.c: Removed compiler warning heap/hp_clear.c: Removed compiler warning include/my_global.h: Removed compiler warning include/my_tree.h: Changed memory limits from int to ulong (Allowed me to get rid of some compiler warnings) myisam/mi_create.c: Removed compiler warning myisam/myisampack.c: Removed compiler warning mysys/base64.c: Removed compiler warning mysys/my_thr_init.c: Fixed portability issue (detected on windows) Added DBUG_ASSERT to detect if we call my_thread_end() too many times Don't wait if THR_thread_count == -1 (error condition) mysys/tree.c: Removed compiler warning sql/field.cc: Removed compiler warning Fixed wrong parameter to check_date() Added missing argument to store(longlong) sql/ha_archive.cc: Removed compiler warning sql/ha_federated.cc: Removed compiler warning sql/ha_innodb.cc: Removed not used variable sql/handler.cc: Removed not used variable Fixed wrong if (we didn't detect if rollback or commit failed). Not critical as value is not yet used sql/item.cc: Removed compiler warning sql/item_func.cc: Removed compiler warning sql/item_strfunc.cc: Removed compiler warning sql/item_timefunc.cc: Removed compiler warning sql/log.cc: Removed compiler warning sql/mysql_priv.h: Removed compiler warning sql/opt_range.cc: Removed compiler warning sql/password.c: Removed compiler warning sql/set_var.cc: Removed compiler warning sql/slave.cc: Removed compiler warning sql/sp.cc: Removed compiler warning sql/sp_cache.cc: Removed compiler warning sql/sp_head.cc: Removed compiler warning Adjusted argument to reserve() to not use up too much memory that we are probably not going to need sql/sql_acl.cc: Added missing argument to store(longlong) sql/sql_base.cc: Removed compiler warning sql/sql_db.cc: Removed compiler warning sql/sql_delete.cc: Removed compiler warning sql/sql_handler.cc: Removed not used variable sql/sql_lex.h: Removed not used variable sql/sql_prepare.cc: Removed not used variable sql/sql_rename.cc: Removed not used variable sql/sql_select.cc: Fixed that select_options are not 'cut' Removed some not used variables Removed compiler warnings by adding cast sql/sql_show.cc: Removed not used variables Added missing argument to store(longlong) Removed compiler warnings sql/sql_trigger.cc: Removed not used variables Added cast to remove compiler warnings sql/sql_update.cc: Fixed wrong set of bool variable sql/sql_view.cc: Removed not used variables Added cast to get rid of compiler warnings sql-common/client.c: Fixed compiler warning sql-common/my_time.c: Fixed wrong argument to check_date() Added casts to get rid of compiler warnings sql/sql_yacc.yy: Removed not used variable sql/uniques.cc: Changes memory size from uint to ulong Added casts to get rid of compiler warnings strings/ctype-simple.c: Fixed cast to get rid of compiler warnings --- client/mysqldump.c | 2 +- heap/hp_clear.c | 3 ++- include/my_global.h | 4 ++-- include/my_tree.h | 5 +++-- myisam/mi_create.c | 4 ++-- myisam/myisampack.c | 6 +++--- mysys/base64.c | 2 +- mysys/my_thr_init.c | 29 ++++++++++++++++++++--------- mysys/tree.c | 4 ++-- sql-common/client.c | 2 +- sql-common/my_time.c | 18 +++++++++--------- sql/field.cc | 26 +++++++++++++------------- sql/ha_archive.cc | 6 +++--- sql/ha_federated.cc | 6 ++---- sql/ha_innodb.cc | 1 - sql/handler.cc | 7 +++---- sql/item.cc | 4 +--- sql/item_func.cc | 7 ++++--- sql/item_strfunc.cc | 40 ++++++++++++++++++++-------------------- sql/item_timefunc.cc | 3 +-- sql/log.cc | 8 ++++---- sql/mysql_priv.h | 2 +- sql/opt_range.cc | 4 ++-- sql/password.c | 4 ++-- sql/set_var.cc | 2 +- sql/slave.cc | 2 +- sql/sp.cc | 15 +++++++-------- sql/sp_cache.cc | 1 - sql/sp_head.cc | 9 ++++++--- sql/sql_acl.cc | 2 +- sql/sql_base.cc | 2 +- sql/sql_db.cc | 2 +- sql/sql_delete.cc | 2 +- sql/sql_handler.cc | 1 - sql/sql_lex.h | 2 +- sql/sql_prepare.cc | 1 - sql/sql_rename.cc | 2 +- sql/sql_select.cc | 28 +++++++++++++--------------- sql/sql_show.cc | 6 ++---- sql/sql_trigger.cc | 9 ++++----- sql/sql_update.cc | 2 +- sql/sql_view.cc | 3 +-- sql/sql_yacc.yy | 1 - sql/uniques.cc | 38 ++++++++++++++++++++++---------------- strings/ctype-simple.c | 4 ++-- 45 files changed, 168 insertions(+), 163 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 2be60b2df9a..5b4983b4a4e 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2001,7 +2001,7 @@ continue_xml: write_footer(sql_file); my_fclose(sql_file, MYF(MY_WME)); } - DBUG_RETURN(num_fields); + DBUG_RETURN((uint) num_fields); } /* get_table_structure */ diff --git a/heap/hp_clear.c b/heap/hp_clear.c index 596d71ebe9c..b491f8eba15 100644 --- a/heap/hp_clear.c +++ b/heap/hp_clear.c @@ -36,7 +36,8 @@ void hp_clear(HP_SHARE *info) (byte*) 0)); info->block.levels=0; hp_clear_keys(info); - info->records=info->deleted=info->data_length=0; + info->records= info->deleted= 0; + info->data_length= 0; info->blength=1; info->changed=0; info->del_link=0; diff --git a/include/my_global.h b/include/my_global.h index f94cedbc91a..7c072b2fc5c 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1040,8 +1040,8 @@ typedef char bool; /* Ordinary boolean values 0 1 */ #define set_timespec_nsec(ABSTIME,NSEC) \ {\ ulonglong now= my_getsystime() + (NSEC/100); \ - (ABSTIME).tv_sec= (now / ULL(10000000)); \ - (ABSTIME).tv_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ + (ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \ + (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ } #endif /* !set_timespec_nsec */ #endif /* HAVE_TIMESPEC_TS_SEC */ diff --git a/include/my_tree.h b/include/my_tree.h index 03dc9d5c829..a047f914e55 100644 --- a/include/my_tree.h +++ b/include/my_tree.h @@ -59,7 +59,8 @@ typedef struct st_tree_element { typedef struct st_tree { TREE_ELEMENT *root,null_element; TREE_ELEMENT **parents[MAX_TREE_HEIGHT]; - uint offset_to_key,elements_in_tree,size_of_element,memory_limit,allocated; + uint offset_to_key,elements_in_tree,size_of_element; + ulong memory_limit, allocated; qsort_cmp2 compare; void *custom_arg; MEM_ROOT mem_root; @@ -69,7 +70,7 @@ typedef struct st_tree { } TREE; /* Functions on whole tree */ -void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit, +void init_tree(TREE *tree, ulong default_alloc_size, ulong memory_limit, int size, qsort_cmp2 compare, my_bool with_delete, tree_element_free free_element, void *custom_arg); void delete_tree(TREE*); diff --git a/myisam/mi_create.c b/myisam/mi_create.c index c6e9da03adf..7515438f3a4 100644 --- a/myisam/mi_create.c +++ b/myisam/mi_create.c @@ -428,8 +428,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, key_segs) share.state.rec_per_key_part[key_segs-1]=1L; length+=key_length; - keydef->block_length= MI_BLOCK_SIZE(length-real_length_diff, - pointer,MI_MAX_KEYPTR_SIZE); + keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff, + pointer,MI_MAX_KEYPTR_SIZE); if (keydef->block_length > MI_MAX_KEY_BLOCK_LENGTH || length >= MI_MAX_KEY_BUFF) { diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 79359e29a5d..ab67ab60105 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -1965,7 +1965,7 @@ static char *bindigits(ulonglong value, uint bits) DBUG_ASSERT(idx < sizeof(digits)); while (idx) - *(ptr++)= '0' + ((value >> (--idx)) & 1); + *(ptr++)= '0' + ((char) (value >> (--idx)) & (char) 1); *ptr= '\0'; return digits; } @@ -1995,7 +1995,7 @@ static char *hexdigits(ulonglong value) DBUG_ASSERT(idx < sizeof(digits)); while (idx) { - if ((*(ptr++)= '0' + ((value >> (4 * (--idx))) & 0xf)) > '9') + if ((*(ptr++)= '0' + ((char) (value >> (4 * (--idx))) & (char) 0xf)) > '9') *(ptr - 1)+= 'a' - '9' - 1; } *ptr= '\0'; @@ -2284,7 +2284,7 @@ static my_off_t write_huff_tree(HUFF_TREE *huff_tree, uint trees) errors++; break; } - idx+= code & 1; + idx+= (uint) code & 1; if (idx >= length) { VOID(fflush(stdout)); diff --git a/mysys/base64.c b/mysys/base64.c index b29c8ff8360..2d1b7f2aeba 100644 --- a/mysys/base64.c +++ b/mysys/base64.c @@ -40,7 +40,7 @@ base64_needed_encoded_length(int length_of_data) int base64_needed_decoded_length(int length_of_encoded_data) { - return ceil(length_of_encoded_data * 3 / 4); + return (int) ceil(length_of_encoded_data * 3 / 4); } diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 7800edd700d..0e921bbe8a0 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -120,20 +120,21 @@ my_bool my_thread_global_init(void) void my_thread_global_end(void) { struct timespec abstime; - set_timespec(abstime, my_thread_end_wait_time); my_bool all_threads_killed= 1; + set_timespec(abstime, my_thread_end_wait_time); pthread_mutex_lock(&THR_LOCK_threads); - while (THR_thread_count) + while (THR_thread_count > 0) { int error= pthread_cond_timedwait(&THR_COND_threads, &THR_LOCK_threads, &abstime); if (error == ETIMEDOUT || error == ETIME) { if (THR_thread_count) - fprintf(stderr,"error in my_thread_global_end(): %d threads didn't exit\n", + fprintf(stderr,"Error in my_thread_global_end(): %d threads didn't exit\n", THR_thread_count); all_threads_killed= 0; + break; } } pthread_mutex_unlock(&THR_LOCK_threads); @@ -228,10 +229,11 @@ void my_thread_end(void) { struct st_my_thread_var *tmp; tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); + DBUG_ASSERT(tmp); #ifdef EXTRA_DEBUG_THREADS - fprintf(stderr,"my_thread_end(): tmp=%p,thread_id=%ld\n", - tmp,pthread_self()); + fprintf(stderr,"my_thread_end(): tmp: 0x%lx thread_id=%ld\n", + (long) tmp, pthread_self()); #endif if (tmp && tmp->init) { @@ -253,15 +255,24 @@ void my_thread_end(void) #else tmp->init= 0; #endif + + /* + Decrement counter for number of running threads. We are using this + in my_thread_global_end() to wait until all threads have called + my_thread_end and thus freed all memory they have allocated in + my_thread_init() and DBUG_xxxx + */ + pthread_mutex_lock(&THR_LOCK_threads); + DBUG_ASSERT(THR_thread_count != 0); + if (--THR_thread_count == 0) + pthread_cond_signal(&THR_COND_threads); + pthread_mutex_unlock(&THR_LOCK_threads); } /* The following free has to be done, even if my_thread_var() is 0 */ #if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS) pthread_setspecific(THR_KEY_mysys,0); #endif - pthread_mutex_lock(&THR_LOCK_threads); - if (--THR_thread_count == 0) - pthread_cond_signal(&THR_COND_threads); - pthread_mutex_unlock(&THR_LOCK_threads); + } struct st_my_thread_var *_my_thread_var(void) diff --git a/mysys/tree.c b/mysys/tree.c index abbc99b2445..f295fa15575 100644 --- a/mysys/tree.c +++ b/mysys/tree.c @@ -84,7 +84,7 @@ static void rb_delete_fixup(TREE *tree,TREE_ELEMENT ***parent); static int test_rb_tree(TREE_ELEMENT *element); #endif -void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit, +void init_tree(TREE *tree, ulong default_alloc_size, ulong memory_limit, int size, qsort_cmp2 compare, my_bool with_delete, tree_element_free free_element, void *custom_arg) { @@ -128,7 +128,7 @@ void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit, } if (!(tree->with_delete=with_delete)) { - init_alloc_root(&tree->mem_root, default_alloc_size,0); + init_alloc_root(&tree->mem_root, (uint) default_alloc_size, 0); tree->mem_root.min_malloc=(sizeof(TREE_ELEMENT)+tree->size_of_element); } DBUG_VOID_RETURN; diff --git a/sql-common/client.c b/sql-common/client.c index 44b7940a503..c8984e29a34 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1217,7 +1217,7 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields, { uchar *pos; /* fields count may be wrong */ - DBUG_ASSERT ((field - result) < fields); + DBUG_ASSERT((uint) (field - result) < fields); cli_fetch_lengths(&lengths[0], row->data, default_value ? 8 : 7); field->catalog = strdup_root(alloc,(char*) row->data[0]); field->db = strdup_root(alloc,(char*) row->data[1]); diff --git a/sql-common/my_time.c b/sql-common/my_time.c index efef1d98673..40bc9c79b63 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -429,7 +429,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, goto err; } - if (check_date(l_time, not_zero_date, flags, was_cut)) + if (check_date(l_time, not_zero_date != 0, flags, was_cut)) goto err; l_time->time_type= (number_of_fields <= 3 ? @@ -530,15 +530,15 @@ my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time, if ((uint) (end-str) > 1 && str != end_of_days && my_isdigit(&my_charset_latin1, *str)) { /* Found days part */ - date[0]= value; + date[0]= (ulong) value; state= 1; /* Assume next is hours */ found_days= 1; } else if ((end-str) > 1 && *str == time_separator && my_isdigit(&my_charset_latin1, str[1])) { - date[0]=0; /* Assume we found hours */ - date[1]=value; + date[0]= 0; /* Assume we found hours */ + date[1]= (ulong) value; state=2; found_hours=1; str++; /* skip ':' */ @@ -547,9 +547,9 @@ my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time, { /* String given as one number; assume HHMMSS format */ date[0]= 0; - date[1]= value/10000; - date[2]= value/100 % 100; - date[3]= value % 100; + date[1]= (ulong) (value/10000); + date[2]= (ulong) (value/100 % 100); + date[3]= (ulong) (value % 100); state=4; goto fractional; } @@ -559,7 +559,7 @@ my_bool str_to_time(const char *str, uint length, MYSQL_TIME *l_time, { for (value=0; str != end && my_isdigit(&my_charset_latin1,*str) ; str++) value=value*10L + (long) (*str - '0'); - date[state++]=value; + date[state++]= (ulong) value; if (state == 4 || (end-str) < 2 || *str != time_separator || !my_isdigit(&my_charset_latin1,str[1])) break; @@ -594,7 +594,7 @@ fractional: value*= (long) log_10_int[field_length]; else if (field_length < 0) *warning|= MYSQL_TIME_WARN_TRUNCATED; - date[4]=value; + date[4]= (ulong) value; } else date[4]=0; diff --git a/sql/field.cc b/sql/field.cc index 1cfd0843179..e0b97e80ed4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4813,7 +4813,7 @@ int Field_time::store_time(TIME *ltime, timestamp_type type) (ltime->minute * 100 + ltime->second); if (ltime->neg) tmp= -tmp; - return Field_time::store((longlong) tmp); + return Field_time::store((longlong) tmp, FALSE); } @@ -5409,11 +5409,11 @@ int Field_newdate::store_time(TIME *ltime,timestamp_type type) if (type == MYSQL_TIMESTAMP_DATE || type == MYSQL_TIMESTAMP_DATETIME) { tmp=ltime->year*16*32+ltime->month*32+ltime->day; - if ((my_bool)check_date(ltime, tmp, - (TIME_FUZZY_DATE | - (current_thd->variables.sql_mode & - (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | - MODE_INVALID_DATES))), &error)) + if (check_date(ltime, tmp != 0, + (TIME_FUZZY_DATE | + (current_thd->variables.sql_mode & + (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | + MODE_INVALID_DATES))), &error)) { char buff[12]; String str(buff, sizeof(buff), &my_charset_latin1); @@ -5633,11 +5633,11 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type type) { tmp=((ltime->year*10000L+ltime->month*100+ltime->day)*LL(1000000)+ (ltime->hour*10000L+ltime->minute*100+ltime->second)); - if ((my_bool)check_date(ltime, tmp, - (TIME_FUZZY_DATE | - (current_thd->variables.sql_mode & - (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | - MODE_INVALID_DATES))), &error)) + if (check_date(ltime, tmp != 0, + (TIME_FUZZY_DATE | + (current_thd->variables.sql_mode & + (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | + MODE_INVALID_DATES))), &error)) { char buff[19]; String str(buff, sizeof(buff), &my_charset_latin1); @@ -8076,7 +8076,7 @@ int Field_bit::store_decimal(const my_decimal *val) { int err= 0; longlong i= convert_decimal2longlong(val, 1, &err); - return test(err | store(i)); + return test(err | store(i, TRUE)); } @@ -8229,7 +8229,7 @@ Field_bit_as_char::Field_bit_as_char(char *ptr_arg, uint32 len_arg, int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs) { int delta; - uchar bits= field_length & 7; + uchar bits= (uchar) (field_length & 7); for (; length && !*from; from++, length--); // skip left 0's delta= bytes_in_rec - length; diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc index 113008c4885..099f44c82f3 100644 --- a/sql/ha_archive.cc +++ b/sql/ha_archive.cc @@ -211,7 +211,7 @@ bool archive_db_init() max_zfile_size= INT_MAX16; break; case 8: - max_zfile_size= LONGLONG_MAX; + max_zfile_size= (z_off_t) LONGLONG_MAX; break; case 4: default: @@ -495,7 +495,7 @@ int ha_archive::init_archive_writer() } share->archive_write_open= TRUE; info(HA_STATUS_TIME); - share->approx_file_size= data_file_length; + share->approx_file_size= (ulong) data_file_length; DBUG_RETURN(0); } @@ -676,7 +676,7 @@ int ha_archive::real_write_row(byte *buf, gzFile writer) if (share->approx_file_size > max_zfile_size - total_row_length) { info(HA_STATUS_TIME); - share->approx_file_size= data_file_length; + share->approx_file_size= (ulong) data_file_length; if (share->approx_file_size > max_zfile_size - total_row_length) DBUG_RETURN(HA_ERR_RECORD_FILE_FULL); } diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index 6328803c743..9abfcdc61c6 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -1249,7 +1249,6 @@ bool ha_federated::create_where_from_key(String *to, if (tmp.append(FEDERATED_CLOSEPAREN)) DBUG_RETURN(1); -next_loop: if (store_length >= length) break; DBUG_PRINT("info", ("remainder %d", remainder)); @@ -1914,8 +1913,8 @@ int ha_federated::delete_row(const byte *buf) { DBUG_RETURN(stash_remote_error()); } - deleted+= mysql->affected_rows; - records-= mysql->affected_rows; + deleted+= (ha_rows) mysql->affected_rows; + records-= (ha_rows) mysql->affected_rows; DBUG_PRINT("info", ("rows deleted %ld rows deleted for all time %ld", (long) mysql->affected_rows, (long) deleted)); @@ -2270,7 +2269,6 @@ int ha_federated::rnd_next(byte *buf) int ha_federated::read_next(byte *buf, MYSQL_RES *result) { int retval; - my_ulonglong num_rows; MYSQL_ROW row; DBUG_ENTER("ha_federated::read_next"); diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index a1619d8e1a1..5548cb66e7f 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -2739,7 +2739,6 @@ ha_innobase::store_key_val_for_row( CHARSET_INFO* cs; ulint key_len; - ulint len; ulint true_len; int error=0; ulint blob_len; diff --git a/sql/handler.cc b/sql/handler.cc index 3f0411d6198..ae314afb991 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -474,7 +474,6 @@ int ha_init() { int error= 0; handlerton **types; - show_table_alias_st *table_alias; total_ha= savepoint_alloc_size= 0; if (ha_init_errors()) @@ -885,8 +884,8 @@ int ha_commit_or_rollback_by_xid(XID *xid, bool commit) if ((*types)->state == SHOW_OPTION_YES && (*types)->recover) { if ((*(commit ? (*types)->commit_by_xid : - (*types)->rollback_by_xid))(xid)); - res= 0; + (*types)->rollback_by_xid))(xid)) + res= 0; } } return res; @@ -1779,7 +1778,7 @@ void handler::print_error(int error, myf errflag) { /* Key is unknown */ str.copy("", 0, system_charset_info); - key_nr= -1; + key_nr= (uint) -1; } else { diff --git a/sql/item.cc b/sql/item.cc index 59d28c00416..6f0d2ff59a3 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -276,7 +276,6 @@ my_decimal *Item::val_decimal_from_date(my_decimal *decimal_value) { DBUG_ASSERT(fixed == 1); TIME ltime; - longlong date; if (get_date(<ime, TIME_FUZZY_DATE)) { my_decimal_set_zero(decimal_value); @@ -290,7 +289,6 @@ my_decimal *Item::val_decimal_from_time(my_decimal *decimal_value) { DBUG_ASSERT(fixed == 1); TIME ltime; - longlong date; if (get_time(<ime)) { my_decimal_set_zero(decimal_value); @@ -5646,7 +5644,7 @@ void Item_trigger_field::set_required_privilege(bool rw) } -bool Item_trigger_field::set_value(THD *thd, sp_rcontext */*ctx*/, Item **it) +bool Item_trigger_field::set_value(THD *thd, sp_rcontext * /*ctx*/, Item **it) { Item *item= sp_prepare_func_item(thd, it); diff --git a/sql/item_func.cc b/sql/item_func.cc index 0fc6e5f6c61..601d777d457 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2333,7 +2333,7 @@ longlong Item_func_locate::val_int() return 0; /* start is now sufficiently valid to pass to charpos function */ - start= a->charpos(start); + start= a->charpos((int) start); if (start + b->length() > a->length()) return 0; @@ -2343,7 +2343,8 @@ longlong Item_func_locate::val_int() return start + 1; if (!cmp_collation.collation->coll->instr(cmp_collation.collation, - a->ptr()+start, a->length()-start, + a->ptr()+start, + (uint) (a->length()-start), b->ptr(), b->length(), &match, 1)) return 0; @@ -4288,7 +4289,7 @@ bool Item_func_get_user_var::eq(const Item *item, bool binary_cmp) const bool Item_func_get_user_var::set_value(THD *thd, - sp_rcontext */*ctx*/, Item **it) + sp_rcontext * /*ctx*/, Item **it) { Item_func_set_user_var *suv= new Item_func_set_user_var(get_name(), *it); /* diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index c2f16ffac10..b4c4defd655 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -969,8 +969,8 @@ String *Item_func_insert::val_str(String *str) length= res->length() + 1; /* start and length are now sufficiently valid to pass to charpos function */ - start= res->charpos(start); - length= res->charpos(length, start); + start= res->charpos((int) start); + length= res->charpos((int) length, (uint32) start); /* Re-testing with corrected params */ if (start > res->length() + 1) @@ -978,8 +978,8 @@ String *Item_func_insert::val_str(String *str) if (length > res->length() - start) length= res->length() - start; - if (res->length() - length + res2->length() > - current_thd->variables.max_allowed_packet) + if ((ulonglong) (res->length() - length + res2->length()) > + (ulonglong) current_thd->variables.max_allowed_packet) { push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_ALLOWED_PACKET_OVERFLOWED, @@ -988,7 +988,7 @@ String *Item_func_insert::val_str(String *str) goto null; } res=copy_if_not_alloced(str,res,res->length()); - res->replace(start,length,*res2); + res->replace((uint32) start,(uint32) length,*res2); return res; null: null_value=1; @@ -1064,7 +1064,7 @@ String *Item_func_left::val_str(String *str) return &my_empty_string; if ((res->length() <= (ulonglong) length) || - (res->length() <= (char_pos= res->charpos(length)))) + (res->length() <= (char_pos= res->charpos((int) length)))) return res; tmp_value.set(*res, 0, char_pos); @@ -1156,17 +1156,17 @@ String *Item_func_substr::val_str(String *str) return &my_empty_string; start= ((start < 0) ? res->numchars() + start : start - 1); - start= res->charpos(start); + start= res->charpos((int) start); if ((start < 0) || ((uint) start + 1 > res->length())) return &my_empty_string; - length= res->charpos(length, start); + length= res->charpos((int) length, (uint32) start); tmp_length= res->length() - start; length= min(length, tmp_length); - if (!start && res->length() == (ulonglong) length) + if (!start && (longlong) res->length() == length) return res; - tmp_value.set(*res, (ulonglong) start, (ulonglong) length); + tmp_value.set(*res, (uint32) start, (uint32) length); return &tmp_value; } @@ -2214,7 +2214,7 @@ String *Item_func_repeat::val_str(String *str) char *to; /* must be longlong to avoid truncation */ longlong tmp_count= args[1]->val_int(); - long count= tmp_count; + long count= (long) tmp_count; String *res= args[0]->val_str(str); /* Assumes that the maximum length of a String is < INT_MAX32. */ @@ -2316,7 +2316,7 @@ String *Item_func_rpad::val_str(String *str) if (count <= (res_char_length= res->numchars())) { // String to pad is big enough - res->length(res->charpos(count)); // Shorten result if longer + res->length(res->charpos((int) count)); // Shorten result if longer return (res); } pad_char_length= rpad->numchars(); @@ -2333,7 +2333,7 @@ String *Item_func_rpad::val_str(String *str) if (args[2]->null_value || !pad_char_length) goto err; res_byte_length= res->length(); /* Must be done before alloc_buffer */ - if (!(res= alloc_buffer(res,str,&tmp_value,byte_count))) + if (!(res= alloc_buffer(res,str,&tmp_value, (ulong) byte_count))) goto err; to= (char*) res->ptr()+res_byte_length; @@ -2347,7 +2347,7 @@ String *Item_func_rpad::val_str(String *str) } if (count) { - pad_byte_length= rpad->charpos(count); + pad_byte_length= rpad->charpos((int) count); memcpy(to,ptr_pad,(size_t) pad_byte_length); to+= pad_byte_length; } @@ -2419,14 +2419,14 @@ String *Item_func_lpad::val_str(String *str) if (count <= res_char_length) { - res->length(res->charpos(count)); + res->length(res->charpos((int) count)); return res; } pad_char_length= pad->numchars(); byte_count= count * collation.collation->mbmaxlen; - if (byte_count > current_thd->variables.max_allowed_packet) + if ((ulonglong) byte_count > current_thd->variables.max_allowed_packet) { push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_ALLOWED_PACKET_OVERFLOWED, @@ -2435,7 +2435,8 @@ String *Item_func_lpad::val_str(String *str) goto err; } - if (args[2]->null_value || !pad_char_length || str->alloc(byte_count)) + if (args[2]->null_value || !pad_char_length || + str->alloc((uint32) byte_count)) goto err; str->length(0); @@ -2447,7 +2448,7 @@ String *Item_func_lpad::val_str(String *str) count-= pad_char_length; } if (count > 0) - str->append(pad->ptr(), pad->charpos(count), collation.collation); + str->append(pad->ptr(), pad->charpos((int) count), collation.collation); str->append(*res); null_value= 0; @@ -2777,7 +2778,7 @@ String *Item_load_file::val_str(String *str) tmp_value.length(stat_info.st_size); my_close(file, MYF(0)); null_value = 0; - return &tmp_value; + DBUG_RETURN(&tmp_value); err: null_value = 1; @@ -3267,4 +3268,3 @@ String *Item_func_uuid::val_str(String *str) strmov(s+18, clock_seq_and_node_str); return str; } - diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 9d9108dd301..ca593664299 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -110,7 +110,6 @@ static bool make_datetime_with_warn(date_time_format_types format, TIME *ltime, String *str) { int warning= 0; - bool rc; if (make_datetime(format, ltime, str)) return 1; @@ -1645,7 +1644,7 @@ double Item_func_sysdate_local::val_real() { DBUG_ASSERT(fixed == 1); store_now_in_TIME(<ime); - return (longlong) TIME_to_ulonglong_datetime(<ime); + return (double) TIME_to_ulonglong_datetime(<ime); } diff --git a/sql/log.cc b/sql/log.cc index 960fc4f60c2..71bdecdc536 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1676,14 +1676,14 @@ bool MYSQL_LOG::write(Log_event *event_info) } trans_log->end_of_file= max_binlog_cache_size; trans_register_ha(thd, - thd->options & (OPTION_NOT_AUTOCOMMIT | - OPTION_BEGIN), + test(thd->options & (OPTION_NOT_AUTOCOMMIT | + OPTION_BEGIN)), &binlog_hton); } else if (!my_b_tell(trans_log)) trans_register_ha(thd, - thd->options & (OPTION_NOT_AUTOCOMMIT | - OPTION_BEGIN), + test(thd->options & (OPTION_NOT_AUTOCOMMIT | + OPTION_BEGIN)), &binlog_hton); file= trans_log; } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index a63b714e0b0..c5ec6f02cdd 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -745,7 +745,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, bool mysql_select(THD *thd, Item ***rref_pointer_array, TABLE_LIST *tables, uint wild_num, List &list, COND *conds, uint og_num, ORDER *order, ORDER *group, - Item *having, ORDER *proc_param, ulong select_type, + Item *having, ORDER *proc_param, ulonglong select_type, select_result *result, SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex); void free_underlaid_joins(THD *thd, SELECT_LEX *select); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ef755d868d9..545f01d4755 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1924,7 +1924,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, key_parts->null_bit= key_part_info->null_bit; key_parts->image_type = (key_info->flags & HA_SPATIAL) ? Field::itMBR : Field::itRAW; - key_parts->flag= key_part_info->key_part_flag; + key_parts->flag= (uint8) key_part_info->key_part_flag; } param.real_keynr[param.keys++]=idx; } @@ -6240,7 +6240,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, key_part->length= key_info->key_part[part].length; key_part->store_length= key_info->key_part[part].store_length; key_part->null_bit= key_info->key_part[part].null_bit; - key_part->flag= key_info->key_part[part].key_part_flag; + key_part->flag= (uint8) key_info->key_part[part].key_part_flag; } if (insert_dynamic(&quick->ranges,(gptr)&range)) goto err; diff --git a/sql/password.c b/sql/password.c index 506e1aa36a2..594096b6ec9 100644 --- a/sql/password.c +++ b/sql/password.c @@ -406,7 +406,7 @@ make_scrambled_password(char *to, const char *password) mysql_sha1_result(&sha1_context, hash_stage2); /* convert hash_stage2 to hex string */ *to++= PVERSION41_CHAR; - octet2hex(to, hash_stage2, SHA1_HASH_SIZE); + octet2hex(to, (char*) hash_stage2, SHA1_HASH_SIZE); } @@ -520,5 +520,5 @@ void get_salt_from_password(uint8 *hash_stage2, const char *password) void make_password_from_salt(char *to, const uint8 *hash_stage2) { *to++= PVERSION41_CHAR; - octet2hex(to, hash_stage2, SHA1_HASH_SIZE); + octet2hex(to, (char*) hash_stage2, SHA1_HASH_SIZE); } diff --git a/sql/set_var.cc b/sql/set_var.cc index c3e93aae619..ebeffeba9bf 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -2836,7 +2836,7 @@ static bool set_option_autocommit(THD *thd, set_var *var) { /* The test is negative as the flag we use is NOT autocommit */ - ulong org_options=thd->options; + ulonglong org_options= thd->options; if (var->save_result.ulong_value != 0) thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag; diff --git a/sql/slave.cc b/sql/slave.cc index b5c1fff4222..d0396444ace 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1513,7 +1513,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, TABLE_LIST tables; int error= 1; handler *file; - ulong save_options; + ulonglong save_options; NET *net= &mysql->net; DBUG_ENTER("create_table_from_dump"); diff --git a/sql/sp.cc b/sql/sp.cc index 283f43f55b2..eae6e624d59 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -539,17 +539,17 @@ db_create_routine(THD *thd, int type, sp_head *sp) table->field[MYSQL_PROC_FIELD_NAME]-> store(sp->m_name.str, sp->m_name.length, system_charset_info); table->field[MYSQL_PROC_FIELD_TYPE]-> - store((longlong)type); + store((longlong)type, 1); table->field[MYSQL_PROC_FIELD_SPECIFIC_NAME]-> store(sp->m_name.str, sp->m_name.length, system_charset_info); if (sp->m_chistics->daccess != SP_DEFAULT_ACCESS) table->field[MYSQL_PROC_FIELD_ACCESS]-> - store((longlong)sp->m_chistics->daccess); + store((longlong)sp->m_chistics->daccess, 1); table->field[MYSQL_PROC_FIELD_DETERMINISTIC]-> - store((longlong)(sp->m_chistics->detistic ? 1 : 2)); + store((longlong)(sp->m_chistics->detistic ? 1 : 2), 1); if (sp->m_chistics->suid != SP_IS_DEFAULT_SUID) table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]-> - store((longlong)sp->m_chistics->suid); + store((longlong)sp->m_chistics->suid, 1); table->field[MYSQL_PROC_FIELD_PARAM_LIST]-> store(sp->m_params.str, sp->m_params.length, system_charset_info); if (sp->m_type == TYPE_ENUM_FUNCTION) @@ -566,7 +566,7 @@ db_create_routine(THD *thd, int type, sp_head *sp) ((Field_timestamp *)table->field[MYSQL_PROC_FIELD_CREATED])->set_time(); ((Field_timestamp *)table->field[MYSQL_PROC_FIELD_MODIFIED])->set_time(); table->field[MYSQL_PROC_FIELD_SQL_MODE]-> - store((longlong)thd->variables.sql_mode); + store((longlong)thd->variables.sql_mode, 1); if (sp->m_chistics->comment.str) table->field[MYSQL_PROC_FIELD_COMMENT]-> store(sp->m_chistics->comment.str, sp->m_chistics->comment.length, @@ -672,7 +672,6 @@ db_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics) { TABLE *table; int ret; - bool opened; DBUG_ENTER("db_update_routine"); DBUG_PRINT("enter", ("type: %d name: %.*s", type, name->m_name.length, name->m_name.str)); @@ -686,10 +685,10 @@ db_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics) ((Field_timestamp *)table->field[MYSQL_PROC_FIELD_MODIFIED])->set_time(); if (chistics->suid != SP_IS_DEFAULT_SUID) table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]-> - store((longlong)chistics->suid); + store((longlong)chistics->suid, 1); if (chistics->daccess != SP_DEFAULT_ACCESS) table->field[MYSQL_PROC_FIELD_ACCESS]-> - store((longlong)chistics->daccess); + store((longlong)chistics->daccess, 1); if (chistics->comment.str) table->field[MYSQL_PROC_FIELD_COMMENT]->store(chistics->comment.str, chistics->comment.length, diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index fea6a67f32c..f5912caddaf 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -124,7 +124,6 @@ void sp_cache_clear(sp_cache **cp) void sp_cache_insert(sp_cache **cp, sp_head *sp) { sp_cache *c; - ulong v; if (!(c= *cp)) { diff --git a/sql/sp_head.cc b/sql/sp_head.cc index a06bfe28a6f..152bc87aead 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -444,9 +444,12 @@ sp_head::operator delete(void *ptr, size_t size) sp_head::sp_head() :Query_arena(&main_mem_root, INITIALIZED_FOR_SP), m_flags(0), m_recursion_level(0), m_next_cached_sp(0), - m_first_instance(this), m_first_free_instance(this), m_last_cached_sp(this), m_cont_level(0) { + m_first_instance= this; + m_first_free_instance= this; + m_last_cached_sp= this; + m_return_field_def.charset = NULL; extern byte * @@ -1648,7 +1651,7 @@ sp_head::execute_procedure(THD *thd, List *args) Item_null *null_item= new Item_null(); if (!null_item || - nctx->set_variable(thd, i, (struct Item **)&null_item)) + nctx->set_variable(thd, i, (Item **)&null_item)) { err_status= TRUE; break; @@ -2789,7 +2792,7 @@ void sp_instr_freturn::print(String *str) { /* freturn type expr... */ - if (str->reserve(UINT_MAX+8+32)) // Add some for the expr. too + if (str->reserve(1024+8+32)) // Add some for the expr. too return; str->qs_append(STRING_WITH_LEN("freturn ")); str->qs_append((uint)m_type); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index d91da405c36..ab39cb250f6 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1898,7 +1898,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, table->field[next_field+2]->store((longlong) mqh.conn_per_hour, TRUE); if (table->s->fields >= 36 && (mqh.specified_limits & USER_RESOURCES::USER_CONNECTIONS)) - table->field[next_field+3]->store((longlong) mqh.user_conn); + table->field[next_field+3]->store((longlong) mqh.user_conn, TRUE); mqh_used= mqh_used || mqh.questions || mqh.updates || mqh.conn_per_hour; } if (old_row_exists) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7c652fdcd4f..d9be590fd70 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -686,7 +686,7 @@ void close_temporary_tables(THD *thd) /* We always quote db,table names though it is slight overkill */ if (found_user_tables && - !(was_quote_show= (thd->options & OPTION_QUOTE_SHOW_CREATE))) + !(was_quote_show= test(thd->options & OPTION_QUOTE_SHOW_CREATE))) { thd->options |= OPTION_QUOTE_SHOW_CREATE; } diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 43d09d288e5..1dd9406109c 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1172,7 +1172,7 @@ err: bool mysql_change_db(THD *thd, const char *name, bool no_access_check) { - int path_length, db_length; + int db_length; char *db_name; bool system_db= 0; #ifndef NO_EMBEDDED_ACCESS_CHECKS diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 38c12562fe3..b665113dd18 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -902,7 +902,7 @@ end: trunc_by_del: /* Probably InnoDB table */ - ulong save_options= thd->options; + ulonglong save_options= thd->options; table_list->lock_type= TL_WRITE; thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT); ha_enable_transaction(thd, FALSE); diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 0193d4d5355..7eb248f3706 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -338,7 +338,6 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, ha_rows select_limit_cnt, ha_rows offset_limit_cnt) { TABLE_LIST *hash_tables; - TABLE **table_ptr; TABLE *table; MYSQL_LOCK *lock; List list; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 5f968252cc3..be12467d097 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -397,7 +397,7 @@ protected: TABLE *table; /* temporary table using for appending UNION results */ select_result *result; - ulong found_rows_for_union; + ulonglong found_rows_for_union; bool res; public: bool prepared, // prepare phase already performed for UNION (unit) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 1e7601c0951..8c0235e9768 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2879,7 +2879,6 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) { Statement stmt_backup; Query_arena *old_stmt_arena; - Item *old_free_list; bool error= TRUE; statistic_increment(thd->status_var.com_stmt_execute, &LOCK_status); diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index c87a8696bbc..8beb9839177 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -257,7 +257,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, static TABLE_LIST * rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error) { - TABLE_LIST *ren_table,*new_table, *tmp_table; + TABLE_LIST *ren_table, *new_table; DBUG_ENTER("rename_tables"); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 03fbb3d5314..3d2f46a9982 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -82,7 +82,7 @@ static store_key *get_store_key(THD *thd, static bool make_simple_join(JOIN *join,TABLE *tmp_table); static void make_outerjoin_info(JOIN *join); static bool make_join_select(JOIN *join,SQL_SELECT *select,COND *item); -static void make_join_readinfo(JOIN *join,uint options); +static void make_join_readinfo(JOIN *join, ulonglong options); static bool only_eq_ref_tables(JOIN *join, ORDER *order, table_map tables); static void update_depend_map(JOIN *join); static void update_depend_map(JOIN *join, ORDER *order); @@ -90,7 +90,7 @@ static ORDER *remove_const(JOIN *join,ORDER *first_order,COND *cond, bool change_list, bool *simple_order); static int return_zero_rows(JOIN *join, select_result *res,TABLE_LIST *tables, List &fields, bool send_row, - uint select_options, const char *info, + ulonglong select_options, const char *info, Item *having); static COND *build_equal_items(THD *thd, COND *cond, COND_EQUAL *inherited, @@ -114,7 +114,7 @@ static bool resolve_nested_join (TABLE_LIST *table); static bool const_expression_in_where(COND *conds,Item *item, Item **comp_item); static bool open_tmp_table(TABLE *table); static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param, - ulong options); + ulonglong options); static int do_select(JOIN *join,List *fields,TABLE *tmp_table, Procedure *proc); @@ -1974,7 +1974,7 @@ bool mysql_select(THD *thd, Item ***rref_pointer_array, TABLE_LIST *tables, uint wild_num, List &fields, COND *conds, uint og_num, ORDER *order, ORDER *group, - Item *having, ORDER *proc_param, ulong select_options, + Item *having, ORDER *proc_param, ulonglong select_options, select_result *result, SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex) { @@ -4123,7 +4123,7 @@ choose_plan(JOIN *join, table_map join_tables) { uint search_depth= join->thd->variables.optimizer_search_depth; uint prune_level= join->thd->variables.optimizer_prune_level; - bool straight_join= join->select_options & SELECT_STRAIGHT_JOIN; + bool straight_join= test(join->select_options & SELECT_STRAIGHT_JOIN); DBUG_ENTER("choose_plan"); join->cur_embedding_map= 0; @@ -4725,8 +4725,6 @@ static void find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, double read_time) { - ha_rows rec; - double tmp; THD *thd= join->thd; if (!rest_tables) { @@ -5780,7 +5778,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) } static void -make_join_readinfo(JOIN *join, uint options) +make_join_readinfo(JOIN *join, ulonglong options) { uint i; @@ -6435,7 +6433,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, static int return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables, - List &fields, bool send_row, uint select_options, + List &fields, bool send_row, ulonglong select_options, const char *info, Item *having) { DBUG_ENTER("return_zero_rows"); @@ -6986,7 +6984,6 @@ static COND *build_equal_items_for_cond(COND *cond, Item_equal *item_equal; uint members; COND_EQUAL cond_equal; - COND *new_cond; cond_equal.upper_levels= inherited; if (cond->type() == Item::COND_ITEM) @@ -9323,10 +9320,11 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, if (thd->variables.tmp_table_size == ~ (ulonglong) 0) // No limit table->s->max_rows= ~(ha_rows) 0; else - table->s->max_rows= (((table->s->db_type == DB_TYPE_HEAP) ? - min(thd->variables.tmp_table_size, - thd->variables.max_heap_table_size) : - thd->variables.tmp_table_size)/ table->s->reclength); + table->s->max_rows= (ha_rows) (((table->s->db_type == DB_TYPE_HEAP) ? + min(thd->variables.tmp_table_size, + thd->variables.max_heap_table_size) : + thd->variables.tmp_table_size)/ + table->s->reclength); set_if_bigger(table->s->max_rows,1); // For dummy start options /* Push the LIMIT clause to the temporary table creation, so that we @@ -9628,7 +9626,7 @@ static bool open_tmp_table(TABLE *table) static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param, - ulong options) + ulonglong options) { int error; MI_KEYDEF keydef; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1d524418480..ee310ea6fe4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -464,7 +464,6 @@ bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create_info) { Security_context *sctx= thd->security_ctx; - int length; char buff[2048]; String buffer(buff, sizeof(buff), system_charset_info); #ifndef NO_EMBEDDED_ACCESS_CHECKS @@ -2367,7 +2366,6 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) INDEX_FIELD_VALUES idx_field_vals; List files; char *file_name; - uint length; bool with_i_schema; HA_CREATE_INFO create; TABLE *table= tables->table; @@ -2939,7 +2937,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, restore_record(table, s->default_values); if (!wild || !wild[0] || !wild_compare(sp_name.ptr(), wild, 0)) { - int enum_idx= proc_table->field[5]->val_int(); + int enum_idx= (int) proc_table->field[5]->val_int(); table->field[3]->store(sp_name.ptr(), sp_name.length(), cs); get_field(thd->mem_root, proc_table->field[3], &tmp_string); table->field[0]->store(tmp_string.ptr(), tmp_string.length(), cs); @@ -3105,7 +3103,7 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables, show_table->field[key_part->fieldnr-1]->key_length())) { table->field[10]->store((longlong) key_part->length / - key_part->field->charset()->mbmaxlen); + key_part->field->charset()->mbmaxlen, 1); table->field[10]->set_notnull(); } uint flags= key_part->field ? key_part->field->flags : 0; diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 95734d31411..817db2d8a79 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -326,7 +326,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, char dir_buff[FN_REFLEN], file_buff[FN_REFLEN], trigname_buff[FN_REFLEN], trigname_path[FN_REFLEN]; LEX_STRING dir, file, trigname_file; - LEX_STRING *trg_def, *name; + LEX_STRING *trg_def; LEX_STRING definer_user; LEX_STRING definer_host; ulonglong *trg_sql_mode; @@ -849,7 +849,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, DBUG_RETURN(1); List_iterator_fast it(triggers->definitions_list); - LEX_STRING *trg_create_str, *trg_name_str; + LEX_STRING *trg_create_str; ulonglong *trg_sql_mode; if (triggers->definition_modes_list.is_empty() && @@ -966,7 +966,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, goto err_with_lex_cleanup; } - lex.sphead->set_info(0, 0, &lex.sp_chistics, *trg_sql_mode); + lex.sphead->set_info(0, 0, &lex.sp_chistics, (ulong) *trg_sql_mode); triggers->bodies[lex.trg_chistics.event] [lex.trg_chistics.action_time]= lex.sphead; @@ -1287,7 +1287,6 @@ Table_triggers_list::change_table_name_in_triggers(THD *thd, { char path_buff[FN_REFLEN]; LEX_STRING *def, *on_table_name, new_def; - ulonglong *sql_mode; ulong save_sql_mode= thd->variables.sql_mode; List_iterator_fast it_def(definitions_list); List_iterator_fast it_on_table_name(on_table_names_list); @@ -1301,7 +1300,7 @@ Table_triggers_list::change_table_name_in_triggers(THD *thd, while ((def= it_def++)) { on_table_name= it_on_table_name++; - thd->variables.sql_mode= *(it_mode++); + thd->variables.sql_mode= (ulong) *(it_mode++); /* Construct CREATE TRIGGER statement with new table name. */ buff.length(0); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index dabda39d6b7..3b6aa5f1aa2 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -118,7 +118,7 @@ int mysql_update(THD *thd, enum enum_duplicates handle_duplicates, bool ignore) { bool using_limit= limit != HA_POS_ERROR; - bool safe_update= thd->options & OPTION_SAFE_UPDATES; + bool safe_update= test(thd->options & OPTION_SAFE_UPDATES); bool used_key_is_modified, transactional_table; bool can_compare_record; int res; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index c0cdaf59712..53844eb0fd2 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -197,7 +197,7 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view) lex->definer= &view->definer; } if (lex->create_view_algorithm == VIEW_ALGORITHM_UNDEFINED) - lex->create_view_algorithm= decoy.algorithm; + lex->create_view_algorithm= (uint8) decoy.algorithm; if (lex->create_view_suid == VIEW_SUID_DEFAULT) lex->create_view_suid= decoy.view_suid ? VIEW_SUID_DEFINER : VIEW_SUID_INVOKER; @@ -1477,7 +1477,6 @@ bool check_key_in_view(THD *thd, TABLE_LIST *view) TABLE *table; Field_translator *trans, *end_of_trans; KEY *key_info, *key_info_end; - uint i; DBUG_ENTER("check_key_in_view"); /* diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 676f3f0e6ab..6cbc01bdd46 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1626,7 +1626,6 @@ sp_decl: uint num_vars= pctx->context_var_count(); enum enum_field_types var_type= (enum enum_field_types) $4; Item *dflt_value_item= $5; - create_field *create_field_op; if (!dflt_value_item) { diff --git a/sql/uniques.cc b/sql/uniques.cc index ac603791376..c0343c0c085 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -59,14 +59,15 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg, :max_in_memory_size(max_in_memory_size_arg), size(size_arg), elements(0) { my_b_clear(&file); - init_tree(&tree, max_in_memory_size / 16, 0, size, comp_func, 0, NULL, - comp_func_fixed_arg); + init_tree(&tree, (ulong) (max_in_memory_size / 16), 0, size, comp_func, 0, + NULL, comp_func_fixed_arg); /* If the following fail's the next add will also fail */ my_init_dynamic_array(&file_ptrs, sizeof(BUFFPEK), 16, 16); /* If you change the following, change it in get_max_elements function, too. */ - max_elements= max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+size); + max_elements= (ulong) (max_in_memory_size / + ALIGN_SIZE(sizeof(TREE_ELEMENT)+size)); VOID(open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, MYF(MY_WME))); } @@ -267,8 +268,8 @@ double Unique::get_use_cost(uint *buffer, uint nkeys, uint key_size, int n_full_trees; /* number of trees in unique - 1 */ double result; - max_elements_in_tree= - max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size); + max_elements_in_tree= ((ulong) max_in_memory_size / + ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size)); n_full_trees= nkeys / max_elements_in_tree; last_tree_elems= nkeys % max_elements_in_tree; @@ -386,9 +387,11 @@ C_MODE_END /* DESCRIPTION + Function is very similar to merge_buffers, but instead of writing sorted unique keys to the output file, it invokes walk_action for each key. This saves I/O if you need to pass through all unique keys only once. + SYNOPSIS merge_walk() All params are 'IN' (but see comment for begin, end): @@ -416,7 +419,7 @@ C_MODE_END <> 0 error */ -static bool merge_walk(uchar *merge_buffer, uint merge_buffer_size, +static bool merge_walk(uchar *merge_buffer, ulong merge_buffer_size, uint key_length, BUFFPEK *begin, BUFFPEK *end, tree_walk_action walk_action, void *walk_action_arg, qsort_cmp2 compare, void *compare_arg, @@ -432,7 +435,8 @@ static bool merge_walk(uchar *merge_buffer, uint merge_buffer_size, /* we need space for one key when a piece of merge buffer is re-read */ merge_buffer_size-= key_length; uchar *save_key_buff= merge_buffer + merge_buffer_size; - uint max_key_count_per_piece= merge_buffer_size/(end-begin)/key_length; + uint max_key_count_per_piece= (uint) (merge_buffer_size/(end-begin) / + key_length); /* if piece_size is aligned reuse_freed_buffer will always hit */ uint piece_size= max_key_count_per_piece * key_length; uint bytes_read; /* to hold return value of read_to_buffer */ @@ -548,6 +552,9 @@ end: bool Unique::walk(tree_walk_action action, void *walk_action_arg) { + int res; + uchar *merge_buffer; + if (elements == 0) /* the whole tree is in memory */ return tree_walk(&tree, action, walk_action_arg, left_root_right); @@ -556,15 +563,14 @@ bool Unique::walk(tree_walk_action action, void *walk_action_arg) return 1; if (flush_io_cache(&file) || reinit_io_cache(&file, READ_CACHE, 0L, 0, 0)) return 1; - uchar *merge_buffer= (uchar *) my_malloc(max_in_memory_size, MYF(0)); - if (merge_buffer == 0) + if (!(merge_buffer= (uchar *) my_malloc((ulong) max_in_memory_size, MYF(0)))) return 1; - int res= merge_walk(merge_buffer, max_in_memory_size, size, - (BUFFPEK *) file_ptrs.buffer, - (BUFFPEK *) file_ptrs.buffer + file_ptrs.elements, - action, walk_action_arg, - tree.compare, tree.custom_arg, &file); - x_free(merge_buffer); + res= merge_walk(merge_buffer, (ulong) max_in_memory_size, size, + (BUFFPEK *) file_ptrs.buffer, + (BUFFPEK *) file_ptrs.buffer + file_ptrs.elements, + action, walk_action_arg, + tree.compare, tree.custom_arg, &file); + my_free((char*) merge_buffer, MYF(0)); return res; } @@ -615,7 +621,7 @@ bool Unique::get(TABLE *table) sort_param.sort_form=table; sort_param.rec_length= sort_param.sort_length= sort_param.ref_length= size; - sort_param.keys= max_in_memory_size / sort_param.sort_length; + sort_param.keys= (uint) (max_in_memory_size / sort_param.sort_length); sort_param.not_killable=1; if (!(sort_buffer=(uchar*) my_malloc((sort_param.keys+1) * diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 7484f3c0d92..fc9cbfc9d21 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1503,7 +1503,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), else { *error= 0; - return (ulonglong) (longlong) (long) -ul; + return (ulonglong) (longlong) -(long) ul; } } else @@ -1654,7 +1654,7 @@ ret_sign: return (ulonglong) LONGLONG_MIN; } *error= 0; - return (ulonglong) -ull; + return (ulonglong) -(longlong) ull; } else { From 140c3ee961f5a4a29cd5db3884fa17966decfc66 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Nov 2006 18:47:59 +0200 Subject: [PATCH 32/39] func_group.test, func_group.result, func_gconcat.result, func_gconcat.test: merge fix : removed undeterministic warnings mysql-test/r/func_gconcat.result: merge fix : removed undeterministic warnings mysql-test/r/func_group.result: merge fix : removed undeterministic warnings mysql-test/t/func_gconcat.test: merge fix : removed undeterministic warnings mysql-test/t/func_group.test: merge fix : removed undeterministic warnings --- mysql-test/r/func_gconcat.result | 19 ------------------- mysql-test/r/func_group.result | 7 ------- mysql-test/t/func_gconcat.test | 2 +- mysql-test/t/func_group.test | 2 ++ 4 files changed, 3 insertions(+), 27 deletions(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 655cdc4131c..6989b89833b 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -69,25 +69,6 @@ grp group_concat(a order by d+c-ascii(c),a) 1 1 2 3,2 3 7,8,4,6,9,5 -Warnings: -Warning 1292 Truncated incorrect DOUBLE value: 'a ' -Warning 1292 Truncated incorrect DOUBLE value: 'a ' -Warning 1292 Truncated incorrect DOUBLE value: 'a ' -Warning 1292 Truncated incorrect DOUBLE value: 'b ' -Warning 1292 Truncated incorrect DOUBLE value: 'b ' -Warning 1292 Truncated incorrect DOUBLE value: 'c ' -Warning 1292 Truncated incorrect DOUBLE value: 'a ' -Warning 1292 Truncated incorrect DOUBLE value: 'E ' -Warning 1292 Truncated incorrect DOUBLE value: 'b ' -Warning 1292 Truncated incorrect DOUBLE value: 'C ' -Warning 1292 Truncated incorrect DOUBLE value: 'b ' -Warning 1292 Truncated incorrect DOUBLE value: 'D ' -Warning 1292 Truncated incorrect DOUBLE value: 'd ' -Warning 1292 Truncated incorrect DOUBLE value: 'd ' -Warning 1292 Truncated incorrect DOUBLE value: 'd ' -Warning 1292 Truncated incorrect DOUBLE value: 'd ' -Warning 1292 Truncated incorrect DOUBLE value: 'c ' -Warning 1292 Truncated incorrect DOUBLE value: 'D ' select grp,group_concat(c order by 1) from t1 group by grp; grp group_concat(c order by 1) 1 a diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 020f807ece2..23517f7b603 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -62,13 +62,6 @@ NULL NULL 1 7 2 20.25 3 45.483163247594 -Warnings: -Warning 1292 Truncated incorrect DOUBLE value: 'a ' -Warning 1292 Truncated incorrect DOUBLE value: 'a ' -Warning 1292 Truncated incorrect DOUBLE value: 'b ' -Warning 1292 Truncated incorrect DOUBLE value: 'c ' -Warning 1292 Truncated incorrect DOUBLE value: 'C ' -Warning 1292 Truncated incorrect DOUBLE value: 'E ' create table t2 (grp int, a bigint unsigned, c char(10)); insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp; replace into t2 select grp, a, c from t1 limit 2,1; diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index bdc267d56db..3ff4b35873b 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -31,8 +31,8 @@ select grp,group_concat(d order by a) from t1 group by grp; select grp,group_concat(d order by a desc) from t1 group by grp; --disable_warnings select grp,group_concat(a order by a,d+c-ascii(c)-a) from t1 group by grp; ---enable_warnings select grp,group_concat(a order by d+c-ascii(c),a) from t1 group by grp; +--enable_warnings select grp,group_concat(c order by 1) from t1 group by grp; select grp,group_concat(distinct c order by c) from t1 group by grp; select grp,group_concat(distinct c order by c desc) from t1 group by grp; diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 089f5ed9911..bccd4d9e762 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -29,7 +29,9 @@ select count(distinct a),count(distinct grp) from t1; select sum(all a),count(all a),avg(all a),std(all a),variance(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1; select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp; +--disable_warnings select grp, sum(a)+count(a)+avg(a)+std(a)+variance(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp; +--enable_warnings create table t2 (grp int, a bigint unsigned, c char(10)); insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp; From 25226de9ea52d06667c2c7fbd99f5cd014764241 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Nov 2006 21:56:03 +0200 Subject: [PATCH 33/39] Fixed compiler warnings Don't assert if my_thread_end() is called twice (common case) client/mysql.cc: Removed not used variables client/mysqldump.c: Fixed compiler warnings client/mysqltest.c: Fixed compiler warnings cmd-line-utils/readline/bind.c: Fixed compiler warnings cmd-line-utils/readline/histfile.c: Fixed compiler warnings extra/replace.c: Fixed compiler warning on windows extra/yassl/taocrypt/include/algebra.hpp: Fixed compiler warnings heap/hp_write.c: Fixed compiler warnings innobase/os/os0file.c: Fixed compiler warnings libmysql/libmysql.c: Call my_end()/my_thread_end last. my_end() calls free_charsets(), which allowed me to move the call myisam/myisampack.c: Fixed compiler warnings myisammrg/myrg_rkey.c: Fixed compiler warnings mysys/my_thr_init.c: More comments Don't assert if my_thread_end() is called twice (common case) ndb/src/mgmapi/mgmapi.cpp: Fixed compiler warnings ndb/src/ndbapi/Ndb.cpp: Fixed compiler warnings ndb/src/ndbapi/NdbScanOperation.cpp: Fixed compiler warnings ndb/src/ndbapi/NdbTransaction.cpp: Fixed compiler warnings ndb/src/ndbapi/Ndblist.cpp: Fixed compiler warnings server-tools/instance-manager/guardian.cc: Removed not used variable server-tools/instance-manager/portability.h: Removed duplicated symbol sql/gen_lex_hash.cc: Fixed compiler warning sql/ha_archive.cc: Fixed compiler warnings sql/ha_ndbcluster.cc: Fixed compiler warnings sql/mysqld.cc: Fixed compiler warnings sql/sql_cache.cc: Fixed compiler warnings Fixed DBUG_PRINT strings to be consistent with 5.1 sql/tztime.cc: Fixed compiler warnings sql/uniques.cc: Fixed compiler warnings --- client/mysql.cc | 2 -- client/mysqldump.c | 2 +- client/mysqltest.c | 17 ++++----- cmd-line-utils/readline/bind.c | 4 ++- cmd-line-utils/readline/histfile.c | 3 +- extra/replace.c | 6 ++-- extra/yassl/taocrypt/include/algebra.hpp | 2 +- heap/hp_write.c | 2 +- innobase/os/os0file.c | 2 +- libmysql/libmysql.c | 10 ++++-- myisam/myisampack.c | 14 ++++---- myisammrg/myrg_rkey.c | 2 +- mysys/my_thr_init.c | 40 ++++++++++++++++----- ndb/src/mgmapi/mgmapi.cpp | 6 ++-- ndb/src/ndbapi/Ndb.cpp | 23 ++++++------ ndb/src/ndbapi/NdbScanOperation.cpp | 6 ++-- ndb/src/ndbapi/NdbTransaction.cpp | 3 +- ndb/src/ndbapi/Ndblist.cpp | 2 +- server-tools/instance-manager/guardian.cc | 2 -- server-tools/instance-manager/portability.h | 1 - sql/gen_lex_hash.cc | 5 +-- sql/ha_archive.cc | 13 +++---- sql/ha_ndbcluster.cc | 4 +-- sql/mysqld.cc | 2 +- sql/sql_cache.cc | 38 ++++++++++---------- sql/tztime.cc | 10 +++--- sql/uniques.cc | 4 +-- 27 files changed, 129 insertions(+), 96 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index d0965588b80..cd24e1d5ce2 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2397,7 +2397,6 @@ print_table_data(MYSQL_RES *result) const char *buffer; uint data_length; uint field_max_length; - bool right_justified; uint visible_length; uint extra_padding; @@ -3446,7 +3445,6 @@ server_version_string(MYSQL *mysql) { char *bufp = buf; MYSQL_RES *result; - MYSQL_ROW cur; bufp = strnmov(buf, mysql_get_server_info(mysql), sizeof buf); diff --git a/client/mysqldump.c b/client/mysqldump.c index 5b4983b4a4e..05765ef2a02 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1419,7 +1419,7 @@ static uint dump_routines_for_db(char *db) routine body of other routines that are not the creator of! */ DBUG_PRINT("info",("length of body for %s row[2] '%s' is %d", - routine_name, row[2], strlen(row[2]))); + routine_name, row[2], (int) strlen(row[2]))); if (strlen(row[2])) { char *query_str= NULL; diff --git a/client/mysqltest.c b/client/mysqltest.c index 2063d31251d..318e5064ab8 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -946,8 +946,8 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) die(NullS); if (!eval_result && (uint) stat_info.st_size != ds->length) { - DBUG_PRINT("info",("Size differs: result size: %u file size: %llu", - ds->length, stat_info.st_size)); + DBUG_PRINT("info",("Size differs: result size: %u file size: %lu", + ds->length, (ulong) stat_info.st_size)); DBUG_PRINT("info",("result: '%s'", ds->str)); DBUG_RETURN(RESULT_LENGTH_MISMATCH); } @@ -3130,14 +3130,15 @@ void do_connect(struct st_command *command) else if (!strncmp(con_options, "COMPRESS", 8)) con_compress= 1; else - die("Illegal option to connect: %.*s", end - con_options, con_options); + die("Illegal option to connect: %.*s", + (int) (end - con_options), con_options); /* Process next option */ con_options= end; } if (next_con == connections_end) die("Connection limit exhausted, you can have max %d connections", - (sizeof(connections)/sizeof(struct st_connection))); + (int) (sizeof(connections)/sizeof(struct st_connection))); if (find_connection_by_name(ds_connection_name.str)) die("Connection %s already exists", ds_connection_name.str); @@ -3458,10 +3459,10 @@ int read_line(char *buf, int size) DBUG_RETURN(0); } else if ((c == '{' && - (!my_strnncoll_simple(charset_info, "while", 5, - buf, min(5, p - buf), 0) || - !my_strnncoll_simple(charset_info, "if", 2, - buf, min(2, p - buf), 0)))) + (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5, + (uchar*) buf, min(5, p - buf), 0) || + !my_strnncoll_simple(charset_info, (const uchar*) "if", 2, + (uchar*) buf, min(2, p - buf), 0)))) { /* Only if and while commands can be terminated by { */ *p++= c; diff --git a/cmd-line-utils/readline/bind.c b/cmd-line-utils/readline/bind.c index ab1136c7da5..568c3e8776a 100644 --- a/cmd-line-utils/readline/bind.c +++ b/cmd-line-utils/readline/bind.c @@ -337,6 +337,7 @@ rl_generic_bind (type, keyseq, data, map) KEYMAP_ENTRY k; k.function = 0; + k.type= 0; /* If no keys to bind to, exit right away. */ if (!keyseq || !*keyseq) @@ -735,7 +736,8 @@ _rl_read_file (filename, sizep) file_size = (size_t)finfo.st_size; /* check for overflow on very large files */ - if (file_size != finfo.st_size || file_size + 1 < file_size) + if ((long long) file_size != (long long) finfo.st_size || + file_size + 1 < file_size) { if (file >= 0) close (file); diff --git a/cmd-line-utils/readline/histfile.c b/cmd-line-utils/readline/histfile.c index 7d340b346d4..a7d6a68098e 100644 --- a/cmd-line-utils/readline/histfile.c +++ b/cmd-line-utils/readline/histfile.c @@ -184,7 +184,8 @@ read_history_range (filename, from, to) file_size = (size_t)finfo.st_size; /* check for overflow on very large files */ - if (file_size != finfo.st_size || file_size + 1 < file_size) + if ((long long) file_size != (long long) finfo.st_size || + file_size + 1 < file_size) { errno = overflow_errno; goto error_and_exit; diff --git a/extra/replace.c b/extra/replace.c index 9acf1620d49..cad3589819b 100644 --- a/extra/replace.c +++ b/extra/replace.c @@ -1052,8 +1052,10 @@ static int convert_file(REPLACE *rep, my_string name) { int error; FILE *in,*out; - char dir_buff[FN_REFLEN], tempname[FN_REFLEN]; - char link_name[FN_REFLEN], *org_name = name; + char dir_buff[FN_REFLEN], tempname[FN_REFLEN], *org_name = name; +#ifdef HAVE_READLINK + char link_name[FN_REFLEN]; +#endif File temp_file; DBUG_ENTER("convert_file"); diff --git a/extra/yassl/taocrypt/include/algebra.hpp b/extra/yassl/taocrypt/include/algebra.hpp index 07fc405f093..535ce2599c4 100644 --- a/extra/yassl/taocrypt/include/algebra.hpp +++ b/extra/yassl/taocrypt/include/algebra.hpp @@ -75,7 +75,7 @@ public: typedef Integer Element; AbstractRing() : AbstractGroup() {m_mg.m_pRing = this;} - AbstractRing(const AbstractRing &source) {m_mg.m_pRing = this;} + AbstractRing(const AbstractRing &source) :AbstractGroup() {m_mg.m_pRing = this;} AbstractRing& operator=(const AbstractRing &source) {return *this;} virtual bool IsUnit(const Element &a) const =0; diff --git a/heap/hp_write.c b/heap/hp_write.c index 16f02999c93..c83ae65c966 100644 --- a/heap/hp_write.c +++ b/heap/hp_write.c @@ -68,7 +68,7 @@ int heap_write(HP_INFO *info, const byte *record) DBUG_RETURN(0); err: - DBUG_PRINT("info",("Duplicate key: %d", keydef - share->keydef)); + DBUG_PRINT("info",("Duplicate key: %d", (int) (keydef - share->keydef))); info->errkey= keydef - share->keydef; if (keydef->algorithm == HA_KEY_ALG_BTREE) { diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 075005c3611..5e5c4b19eb0 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -1718,7 +1718,7 @@ os_file_set_size( } /* Print about progress for each 100 MB written */ - if ((current_size + n_bytes) / (ib_longlong)(100 * 1024 * 1024) + if ((ib_longlong) (current_size + n_bytes) / (ib_longlong)(100 * 1024 * 1024) != current_size / (ib_longlong)(100 * 1024 * 1024)) { fprintf(stderr, " %lu00", diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 6a592f64e49..8c4eb2279e1 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -175,6 +175,9 @@ void STDCALL mysql_server_end() #ifdef EMBEDDED_LIBRARY end_embedded_server(); #endif + finish_client_errs(); + vio_end(); + /* If library called my_init(), free memory allocated by it */ if (!org_my_init_done) { @@ -185,10 +188,11 @@ void STDCALL mysql_server_end() #endif } else + { + free_charsets(); mysql_thread_end(); - finish_client_errs(); - free_charsets(); - vio_end(); + } + mysql_client_init= org_my_init_done= 0; #ifdef EMBEDDED_SERVER if (stderror_file) diff --git a/myisam/myisampack.c b/myisam/myisampack.c index ab67ab60105..912ed22d278 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -1105,18 +1105,18 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts) my_off_t total_count; char llbuf[32]; - DBUG_PRINT("info", ("column: %3u", count - huff_counts + 1)); + DBUG_PRINT("info", ("column: %3u", (uint) (count - huff_counts + 1))); if (verbose >= 2) - VOID(printf("column: %3u\n", count - huff_counts + 1)); + VOID(printf("column: %3u\n", (uint) (count - huff_counts + 1))); if (count->tree_buff) { DBUG_PRINT("info", ("number of distinct values: %u", - (count->tree_pos - count->tree_buff) / - count->field_length)); + (uint) ((count->tree_pos - count->tree_buff) / + count->field_length))); if (verbose >= 2) VOID(printf("number of distinct values: %u\n", - (count->tree_pos - count->tree_buff) / - count->field_length)); + (uint) ((count->tree_pos - count->tree_buff) / + count->field_length))); } total_count= 0; for (idx= 0; idx < 256; idx++) @@ -2280,7 +2280,7 @@ static my_off_t write_huff_tree(HUFF_TREE *huff_tree, uint trees) { VOID(fflush(stdout)); VOID(fprintf(stderr, "error: Huffman code too long: %u/%u\n", - bits, 8 * sizeof(code))); + bits, (uint) (8 * sizeof(code)))); errors++; break; } diff --git a/myisammrg/myrg_rkey.c b/myisammrg/myrg_rkey.c index f87b264081e..85464374d5d 100644 --- a/myisammrg/myrg_rkey.c +++ b/myisammrg/myrg_rkey.c @@ -88,7 +88,7 @@ int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key, mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table; mi->once_flags|= RRND_PRESERVE_LASTINX; DBUG_PRINT("info", ("using table no: %d", - info->current_table - info->open_tables + 1)); + (int) (info->current_table - info->open_tables + 1))); DBUG_DUMP("result key", (byte*) mi->lastkey, mi->lastkey_length); DBUG_RETURN(_myrg_mi_read_record(mi,buf)); } diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 0e921bbe8a0..fcae18d4686 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -98,7 +98,7 @@ my_bool my_thread_global_init(void) pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_threads,MY_MUTEX_INIT_FAST); - pthread_cond_init (&THR_COND_threads, NULL); + pthread_cond_init(&THR_COND_threads, NULL); #if defined( __WIN__) || defined(OS2) win_pthread_init(); #endif @@ -131,7 +131,8 @@ void my_thread_global_end(void) if (error == ETIMEDOUT || error == ETIME) { if (THR_thread_count) - fprintf(stderr,"Error in my_thread_global_end(): %d threads didn't exit\n", + fprintf(stderr, + "Error in my_thread_global_end(): %d threads didn't exit\n", THR_thread_count); all_threads_killed= 0; break; @@ -170,10 +171,23 @@ void my_thread_global_end(void) static long thread_id=0; /* - We can't use mutex_locks here if we are using windows as - we may have compiled the program with SAFE_MUTEX, in which - case the checking of mutex_locks will not work until - the pthread_self thread specific variable is initialized. + Allocate thread specific memory for the thread, used by mysys and dbug + + SYNOPSIS + my_thread_init() + + NOTES + We can't use mutex_locks here if we are using windows as + we may have compiled the program with SAFE_MUTEX, in which + case the checking of mutex_locks will not work until + the pthread_self thread specific variable is initialized. + + This function may called multiple times for a thread, for example + if one uses my_init() followed by mysql_server_init(). + + RETURN + 0 ok + 1 Fatal error; mysys/dbug functions can't be used */ my_bool my_thread_init(void) @@ -225,11 +239,22 @@ end: } +/* + Deallocate memory used by the thread for book-keeping + + SYNOPSIS + my_thread_end() + + NOTE + This may be called multiple times for a thread. + This happens for example when one calls 'mysql_server_init()' + mysql_server_end() and then ends with a mysql_end(). +*/ + void my_thread_end(void) { struct st_my_thread_var *tmp; tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); - DBUG_ASSERT(tmp); #ifdef EXTRA_DEBUG_THREADS fprintf(stderr,"my_thread_end(): tmp: 0x%lx thread_id=%ld\n", @@ -272,7 +297,6 @@ void my_thread_end(void) #if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS) pthread_setspecific(THR_KEY_mysys,0); #endif - } struct st_my_thread_var *_my_thread_var(void) diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index df69684784a..8aa4f7213de 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -178,7 +178,7 @@ ndb_mgm_create_handle() h->mgmd_version_minor= -1; h->mgmd_version_build= -1; - DBUG_PRINT("info", ("handle=0x%x", (UintPtr)h)); + DBUG_PRINT("info", ("handle: 0x%lx", (long)h)); DBUG_RETURN(h); } @@ -195,7 +195,7 @@ int ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv) { DBUG_ENTER("ndb_mgm_set_connectstring"); - DBUG_PRINT("info", ("handle=0x%x", (UintPtr)handle)); + DBUG_PRINT("info", ("handle: 0x%lx", (long)handle)); handle->cfg.~LocalConfig(); new (&(handle->cfg)) LocalConfig; if (!handle->cfg.init(mgmsrv, 0) || @@ -237,7 +237,7 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle) DBUG_ENTER("ndb_mgm_destroy_handle"); if(!handle) DBUG_VOID_RETURN; - DBUG_PRINT("info", ("handle=0x%x", (UintPtr)(* handle))); + DBUG_PRINT("info", ("handle: 0x%lx", (long)(* handle))); /** * important! only disconnect if connected * other code relies on this diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index c701fbf77e0..59a204be2a8 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -777,7 +777,7 @@ Ndb::getAutoIncrementValue(const char* aTableName, } if (getTupleIdFromNdb(info, tupleId, cacheSize) == -1) DBUG_RETURN(-1); - DBUG_PRINT("info", ("value %llu", (ulonglong)tupleId)); + DBUG_PRINT("info", ("value %lu", (ulong) tupleId)); DBUG_RETURN(0); } @@ -798,7 +798,7 @@ Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable, } if (getTupleIdFromNdb(info, tupleId, cacheSize) == -1) DBUG_RETURN(-1); - DBUG_PRINT("info", ("value %llu", (ulonglong)tupleId)); + DBUG_PRINT("info", ("value %lu", (ulong)tupleId)); DBUG_RETURN(0); } @@ -811,7 +811,7 @@ Ndb::getTupleIdFromNdb(Ndb_local_table_info* info, { assert(info->m_first_tuple_id < info->m_last_tuple_id); tupleId = ++info->m_first_tuple_id; - DBUG_PRINT("info", ("next cached value %llu", (ulonglong)tupleId)); + DBUG_PRINT("info", ("next cached value %lu", (ulong)tupleId)); } else { @@ -845,7 +845,7 @@ Ndb::readAutoIncrementValue(const char* aTableName, } if (readTupleIdFromNdb(info, tupleId) == -1) DBUG_RETURN(-1); - DBUG_PRINT("info", ("value %llu", (ulonglong)tupleId)); + DBUG_PRINT("info", ("value %lu", (ulong)tupleId)); DBUG_RETURN(0); } @@ -866,7 +866,7 @@ Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable, } if (readTupleIdFromNdb(info, tupleId) == -1) DBUG_RETURN(-1); - DBUG_PRINT("info", ("value %llu", (ulonglong)tupleId)); + DBUG_PRINT("info", ("value %lu", (ulong)tupleId)); DBUG_RETURN(0); } @@ -948,8 +948,8 @@ Ndb::setTupleIdInNdb(Ndb_local_table_info* info, { info->m_first_tuple_id = tupleId - 1; DBUG_PRINT("info", - ("Setting next auto increment cached value to %llu", - (ulonglong)tupleId)); + ("Setting next auto increment cached value to %lu", + (ulong)tupleId)); DBUG_RETURN(0); } } @@ -976,7 +976,8 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 & opValue, Uint32 op) { DBUG_ENTER("Ndb::opTupleIdOnNdb"); Uint32 aTableId = info->m_table_impl->m_tableId; - DBUG_PRINT("enter", ("table=%u value=%llu op=%u", aTableId, opValue, op)); + DBUG_PRINT("enter", ("table: %u value: %lu op: %u", + aTableId, (ulong) opValue, op)); NdbTransaction* tConnection; NdbOperation* tOperation= 0; // Compiler warning if not initialized @@ -1050,8 +1051,8 @@ Ndb::opTupleIdOnNdb(Ndb_local_table_info* info, Uint64 & opValue, Uint32 op) else { DBUG_PRINT("info", - ("Setting next auto increment value (db) to %llu", - (ulonglong)opValue)); + ("Setting next auto increment value (db) to %lu", + (ulong)opValue)); info->m_first_tuple_id = info->m_last_tuple_id = opValue - 1; } break; @@ -1247,7 +1248,7 @@ Ndb::internalize_index_name(const NdbTableImpl * table, if (!table) { DBUG_PRINT("error", ("!table")); - return ret; + DBUG_RETURN(ret); } if (fullyQualifiedNames) diff --git a/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index a0322f09256..92a1e476b45 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -653,9 +653,9 @@ NdbScanOperation::doSend(int ProcessorId) void NdbScanOperation::close(bool forceSend, bool releaseOp) { DBUG_ENTER("NdbScanOperation::close"); - DBUG_PRINT("enter", ("this=%x tcon=%x con=%x force=%d release=%d", - (UintPtr)this, - (UintPtr)m_transConnection, (UintPtr)theNdbCon, + DBUG_PRINT("enter", ("this: 0x%lx tcon: 0x%lx con: 0x%lx force: %d release: %d", + (long)this, + (long)m_transConnection, (long)theNdbCon, forceSend, releaseOp)); if(m_transConnection){ diff --git a/ndb/src/ndbapi/NdbTransaction.cpp b/ndb/src/ndbapi/NdbTransaction.cpp index 86dc92a86c1..36b1217c101 100644 --- a/ndb/src/ndbapi/NdbTransaction.cpp +++ b/ndb/src/ndbapi/NdbTransaction.cpp @@ -1007,7 +1007,8 @@ void NdbTransaction::releaseExecutedScanOperation(NdbIndexScanOperation* cursorOp) { DBUG_ENTER("NdbTransaction::releaseExecutedScanOperation"); - DBUG_PRINT("enter", ("this=0x%x op=0x%x", (UintPtr)this, (UintPtr)cursorOp)); + DBUG_PRINT("enter", ("this: 0x%lx op=0x%lx", + (long)this, (long)cursorOp)); releaseScanOperation(&m_firstExecutedScanOp, 0, cursorOp); diff --git a/ndb/src/ndbapi/Ndblist.cpp b/ndb/src/ndbapi/Ndblist.cpp index f82348fc91d..00ab4599fdf 100644 --- a/ndb/src/ndbapi/Ndblist.cpp +++ b/ndb/src/ndbapi/Ndblist.cpp @@ -361,7 +361,7 @@ void Ndb::releaseScanOperation(NdbIndexScanOperation* aScanOperation) { DBUG_ENTER("Ndb::releaseScanOperation"); - DBUG_PRINT("enter", ("op=%x", (UintPtr)aScanOperation)); + DBUG_PRINT("enter", ("op: 0x%lx", (long)aScanOperation)); #ifdef ndb_release_check_dup { NdbIndexScanOperation* tOp = theScanOpIdleList; while (tOp != NULL) { diff --git a/server-tools/instance-manager/guardian.cc b/server-tools/instance-manager/guardian.cc index 3587a599160..0a037b5b98a 100644 --- a/server-tools/instance-manager/guardian.cc +++ b/server-tools/instance-manager/guardian.cc @@ -222,8 +222,6 @@ void Guardian_thread::run() while (node != NULL) { - struct timespec timeout; - GUARD_NODE *current_node= (GUARD_NODE *) node->data; instance= ((GUARD_NODE *) node->data)->instance; process_instance(instance, current_node, &guarded_instances, node); diff --git a/server-tools/instance-manager/portability.h b/server-tools/instance-manager/portability.h index 23a5a5bd14c..7992a06c336 100644 --- a/server-tools/instance-manager/portability.h +++ b/server-tools/instance-manager/portability.h @@ -15,7 +15,6 @@ #define snprintf _snprintf #define SIGKILL 9 -#define SHUT_RDWR 0x2 /*TODO: fix this */ #define PROTOCOL_VERSION 10 diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 5a8bd48d699..2674b2e65f7 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -206,9 +206,10 @@ void insert_symbols() void insert_sql_functions() { - size_t i= 0; + int i= 0; SYMBOL *cur; - for (cur= sql_functions; ilength,&max_len); insert_into_hash(root,cur->name,0,-i-1,1); diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc index 099f44c82f3..e3f979952e0 100644 --- a/sql/ha_archive.cc +++ b/sql/ha_archive.cc @@ -327,8 +327,8 @@ int ha_archive::read_meta_file(File meta_file, ha_rows *rows) DBUG_PRINT("ha_archive::read_meta_file", ("Check %d", (uint)meta_buffer[0])); DBUG_PRINT("ha_archive::read_meta_file", ("Version %d", (uint)meta_buffer[1])); - DBUG_PRINT("ha_archive::read_meta_file", ("Rows %lld", *rows)); - DBUG_PRINT("ha_archive::read_meta_file", ("Checkpoint %lld", check_point)); + DBUG_PRINT("ha_archive::read_meta_file", ("Rows %lu", (ulong) *rows)); + DBUG_PRINT("ha_archive::read_meta_file", ("Checkpoint %lu", (ulong) check_point)); DBUG_PRINT("ha_archive::read_meta_file", ("Dirty %d", (int)meta_buffer[18])); if ((meta_buffer[0] != (uchar)ARCHIVE_CHECK_HEADER) || @@ -359,8 +359,8 @@ int ha_archive::write_meta_file(File meta_file, ha_rows rows, bool dirty) *(meta_buffer + 18)= (uchar)dirty; DBUG_PRINT("ha_archive::write_meta_file", ("Check %d", (uint)ARCHIVE_CHECK_HEADER)); DBUG_PRINT("ha_archive::write_meta_file", ("Version %d", (uint)ARCHIVE_VERSION)); - DBUG_PRINT("ha_archive::write_meta_file", ("Rows %llu", (ulonglong)rows)); - DBUG_PRINT("ha_archive::write_meta_file", ("Checkpoint %llu", check_point)); + DBUG_PRINT("ha_archive::write_meta_file", ("Rows %lu", (ulong)rows)); + DBUG_PRINT("ha_archive::write_meta_file", ("Checkpoint %lu", (ulong) check_point)); DBUG_PRINT("ha_archive::write_meta_file", ("Dirty %d", (uint)dirty)); VOID(my_seek(meta_file, 0, MY_SEEK_SET, MYF(0))); @@ -783,7 +783,7 @@ int ha_archive::rnd_init(bool scan) if (scan) { scan_rows= share->rows_recorded; - DBUG_PRINT("info", ("archive will retrieve %llu rows", scan_rows)); + DBUG_PRINT("info", ("archive will retrieve %lu rows", (ulong) scan_rows)); records= 0; /* @@ -1019,7 +1019,8 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) share->rows_recorded++; } } - DBUG_PRINT("info", ("recovered %llu archive rows", share->rows_recorded)); + DBUG_PRINT("info", ("recovered %lu archive rows", + (ulong) share->rows_recorded)); my_free((char*)buf, MYF(0)); if (rc && rc != HA_ERR_END_OF_FILE) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 739fae79565..2ef16ddacbf 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -822,8 +822,8 @@ int ha_ndbcluster::get_ndb_blobs_value(NdbBlob *last_ndb_blob, { char *buf= m_blobs_buffer + offset; uint32 len= 0xffffffff; // Max uint32 - DBUG_PRINT("value", ("read blob ptr=%x len=%u", - (UintPtr)buf, (uint)blob_len)); + DBUG_PRINT("value", ("read blob ptr: 0x%lx len: %u", + (long)buf, (uint)blob_len)); if (ndb_blob->readData(buf, len) != 0) DBUG_RETURN(-1); DBUG_ASSERT(len == blob_len); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index dd483b0b158..d8d75a28b75 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1538,7 +1538,7 @@ static void network_init(void) if (strlen(mysqld_unix_port) > (sizeof(UNIXaddr.sun_path) - 1)) { sql_print_error("The socket file path is too long (> %u): %s", - sizeof(UNIXaddr.sun_path) - 1, mysqld_unix_port); + (uint) sizeof(UNIXaddr.sun_path) - 1, mysqld_unix_port); unireg_abort(1); } if ((unix_sock= socket(AF_UNIX, SOCK_STREAM, 0)) < 0) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 5902374dff0..bd2f5c42695 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -902,7 +902,7 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu", if (thd->db_length) { memcpy(thd->query+thd->query_length+1, thd->db, thd->db_length); - DBUG_PRINT("qcache", ("database : %s length %u", + DBUG_PRINT("qcache", ("database: %s length: %u", thd->db, thd->db_length)); } else @@ -1048,7 +1048,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) (pre-space is removed in dispatch_command) First '/' looks like comment before command it is not - frequently appeared in real lihe, consequently we can + frequently appeared in real life, consequently we can check all such queries, too. */ if ((my_toupper(system_charset_info, sql[i]) != 'S' || @@ -1077,7 +1077,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) if (thd->db_length) { memcpy(sql+query_length+1, thd->db, thd->db_length); - DBUG_PRINT("qcache", ("database: '%s' length %u", + DBUG_PRINT("qcache", ("database: '%s' length: %u", thd->db, thd->db_length)); } else @@ -1230,9 +1230,9 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu", if (engine_data != table->engine_data()) { DBUG_PRINT("qcache", - ("Handler require invalidation queries of %s.%s %lld-%lld", - table_list.db, table_list.alias, - engine_data, table->engine_data())); + ("Handler require invalidation queries of %s.%s %lu-%lu", + table_list.db, table_list.alias, + (ulong) engine_data, (ulong) table->engine_data())); invalidate_table((byte *) table->db(), table->key_length()); } else @@ -1253,10 +1253,10 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu", #ifndef EMBEDDED_LIBRARY do { - DBUG_PRINT("qcache", ("Results (len: %lu used: %lu headers: %u)", + DBUG_PRINT("qcache", ("Results (len: %lu used: %lu headers: %lu)", result_block->length, result_block->used, - result_block->headers_len()+ - ALIGN_SIZE(sizeof(Query_cache_result)))); + (ulong) (result_block->headers_len()+ + ALIGN_SIZE(sizeof(Query_cache_result))))); Query_cache_result *result = result_block->result(); if (net_real_write(&thd->net, result->data(), @@ -1338,7 +1338,7 @@ void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used) for (; tables_used; tables_used= tables_used->next) { invalidate_table((byte*) tables_used->key, tables_used->key_length); - DBUG_PRINT("qcache", (" db %s, table %s", tables_used->key, + DBUG_PRINT("qcache", ("db: %s table: %s", tables_used->key, tables_used->key+ strlen(tables_used->key)+1)); } @@ -2349,7 +2349,7 @@ Query_cache::register_tables_from_list(TABLE_LIST *tables_used, { char key[MAX_DBKEY_LENGTH]; uint key_length; - DBUG_PRINT("qcache", ("view %s, db %s", + DBUG_PRINT("qcache", ("view: %s db: %s", tables_used->view_name.str, tables_used->view_db.str)); key_length= (uint) (strmov(strmov(key, tables_used->view_db.str) + 1, @@ -2470,11 +2470,11 @@ Query_cache::insert_table(uint key_len, char *key, table_block->table()->engine_data() != engine_data) { DBUG_PRINT("qcache", - ("Handler require invalidation queries of %s.%s %lld-%lld", + ("Handler require invalidation queries of %s.%s %lu-%lu", table_block->table()->db(), table_block->table()->table(), - engine_data, - table_block->table()->engine_data())); + (ulong) engine_data, + (ulong) table_block->table()->engine_data())); /* as far as we delete all queries with this table, table block will be deleted, too @@ -2972,7 +2972,7 @@ static TABLE_COUNTER_TYPE process_and_count_tables(TABLE_LIST *tables_used, table_count++; if (tables_used->view) { - DBUG_PRINT("qcache", ("view %s, db %s", + DBUG_PRINT("qcache", ("view: %s db: %s", tables_used->view_name.str, tables_used->view_db.str)); *tables_type|= HA_CACHE_TBL_NONTRANSACT; @@ -3038,7 +3038,7 @@ Query_cache::is_cacheable(THD *thd, uint32 query_len, char *query, LEX *lex, lex->safe_to_cache_query) { DBUG_PRINT("qcache", ("options: %lx %lx type: %u", - OPTION_TO_QUERY_CACHE, + (long) OPTION_TO_QUERY_CACHE, (long) lex->select_lex.options, (int) thd->variables.query_cache_type)); @@ -3058,7 +3058,7 @@ Query_cache::is_cacheable(THD *thd, uint32 query_len, char *query, LEX *lex, DBUG_PRINT("qcache", ("not interesting query: %d or not cacheable, options %lx %lx type: %u", (int) lex->sql_command, - OPTION_TO_QUERY_CACHE, + (long) OPTION_TO_QUERY_CACHE, (long) lex->select_lex.options, (int) thd->variables.query_cache_type)); DBUG_RETURN(0); @@ -3757,8 +3757,8 @@ my_bool Query_cache::check_integrity(bool locked) (((long)first_block) % (long)ALIGN_SIZE(1))) { DBUG_PRINT("error", - ("block 0x%lx do not aligned by %d", (ulong) block, - ALIGN_SIZE(1))); + ("block 0x%lx do not aligned by %d", (long) block, + (int) ALIGN_SIZE(1))); result = 1; } // Check memory allocation diff --git a/sql/tztime.cc b/sql/tztime.cc index fe23954bbb2..4becf4a9fcc 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1729,9 +1729,9 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap) tz_leapcnt++; DBUG_PRINT("info", - ("time_zone_leap_second table: tz_leapcnt=%u tt_time=%lld offset=%ld", - tz_leapcnt, (longlong)tz_lsis[tz_leapcnt-1].ls_trans, - tz_lsis[tz_leapcnt-1].ls_corr)); + ("time_zone_leap_second table: tz_leapcnt: %u tt_time: %lu offset=%ld", + tz_leapcnt, (ulong) tz_lsis[tz_leapcnt-1].ls_trans, + tz_lsis[tz_leapcnt-1].ls_corr)); res= table->file->index_next(table->record[0]); } @@ -2041,8 +2041,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) tz_info->timecnt++; DBUG_PRINT("info", - ("time_zone_transition table: tz_id=%u tt_time=%lld tt_id=%u", - tzid, (longlong)ttime, ttid)); + ("time_zone_transition table: tz_id: %u tt_time: %lu tt_id: %u", + tzid, (ulong) ttime, ttid)); res= table->file->index_next_same(table->record[0], (byte*)table->field[0]->ptr, 4); diff --git a/sql/uniques.cc b/sql/uniques.cc index c0343c0c085..c7bdbdeb207 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -428,8 +428,8 @@ static bool merge_walk(uchar *merge_buffer, ulong merge_buffer_size, BUFFPEK_COMPARE_CONTEXT compare_context = { compare, compare_arg }; QUEUE queue; if (end <= begin || - merge_buffer_size < key_length * (end - begin + 1) || - init_queue(&queue, end - begin, offsetof(BUFFPEK, key), 0, + merge_buffer_size < (ulong) (key_length * (end - begin + 1)) || + init_queue(&queue, (uint) (end - begin), offsetof(BUFFPEK, key), 0, buffpek_compare, &compare_context)) return 1; /* we need space for one key when a piece of merge buffer is re-read */ From 0bc42ce6336e6ae57376074d8755de2f58086549 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Nov 2006 22:45:55 +0100 Subject: [PATCH 34/39] late after-merge fix mysql-test/mysql-test-run.pl: late after-merge fix: re-add MTR_BUILD_THREAD=auto --- mysql-test/mysql-test-run.pl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a28bd651ab6..6aacbfdf1ad 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1233,9 +1233,15 @@ sub command_line_setup () { # But a fairly safe range seems to be 5001 - 32767 # -sub set_mtr_build_thread_ports() { +sub set_mtr_build_thread_ports($) { my $mtr_build_thread= shift; + if ( lc($mtr_build_thread) eq 'auto' ) { + print "Requesting build thread... "; + $ENV{'MTR_BUILD_THREAD'} = $mtr_build_thread = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299); + print "got ".$mtr_build_thread."\n"; + } + # Up to two masters, up to three slaves $opt_master_myport= $mtr_build_thread * 10 + 10000; # and 1 $opt_slave_myport= $opt_master_myport + 2; # and 3 4 From d2eabe30fffd797eb2aff7295ab2c3e5fcb8b277 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Dec 2006 23:09:14 +0100 Subject: [PATCH 35/39] mysql_upgrade.def Makefile.am: Added new "mysql_upgrade.def" for Netware (bug#23504) *.def: Allocate 128K stack for all executables (bug#23504) netware/comp_err.def: Allocate 128K stack for all executables (bug#23504) netware/isamchk.def: Allocate 128K stack for all executables (bug#23504) netware/isamlog.def: Allocate 128K stack for all executables (bug#23504) netware/libmysql.def: Allocate 128K stack for all executables (bug#23504) netware/my_print_defaults.def: Allocate 128K stack for all executables (bug#23504) netware/myisam_ftdump.def: Allocate 128K stack for all executables (bug#23504) netware/myisamchk.def: Allocate 128K stack for all executables (bug#23504) netware/myisamlog.def: Allocate 128K stack for all executables (bug#23504) netware/myisampack.def: Allocate 128K stack for all executables (bug#23504) netware/mysql.def: Allocate 128K stack for all executables (bug#23504) netware/mysql_install_db.def: Allocate 128K stack for all executables (bug#23504) netware/mysql_test_run.def: Allocate 128K stack for all executables (bug#23504) netware/mysql_waitpid.def: Allocate 128K stack for all executables (bug#23504) netware/mysqladmin.def: Allocate 128K stack for all executables (bug#23504) netware/mysqlbinlog.def: Allocate 128K stack for all executables (bug#23504) netware/mysqlcheck.def: Allocate 128K stack for all executables (bug#23504) netware/mysqld.def: Allocate 128K stack for all executables (bug#23504) netware/mysqld_safe.def: Allocate 128K stack for all executables (bug#23504) netware/mysqldump.def: Allocate 128K stack for all executables (bug#23504) netware/mysqlimport.def: Allocate 128K stack for all executables (bug#23504) netware/mysqlshow.def: Allocate 128K stack for all executables (bug#23504) netware/mysqltest.def: Allocate 128K stack for all executables (bug#23504) netware/pack_isam.def: Allocate 128K stack for all executables (bug#23504) netware/perror.def: Allocate 128K stack for all executables (bug#23504) netware/replace.def: Allocate 128K stack for all executables (bug#23504) netware/resolve_stack_dump.def: Allocate 128K stack for all executables (bug#23504) netware/resolveip.def: Allocate 128K stack for all executables (bug#23504) netware/mysql_upgrade.def: BitKeeper file /home/kent/bk/mysql-5.0-build/netware/mysql_upgrade.def netware/Makefile.am: Added "mysql_upgrade.def" --- netware/Makefile.am | 3 ++- netware/comp_err.def | 1 + netware/isamchk.def | 2 +- netware/isamlog.def | 1 + netware/libmysql.def | 2 +- netware/my_print_defaults.def | 2 +- netware/myisam_ftdump.def | 2 +- netware/myisamchk.def | 2 +- netware/myisamlog.def | 2 +- netware/myisampack.def | 2 +- netware/mysql.def | 2 +- netware/mysql_install_db.def | 2 +- netware/mysql_test_run.def | 2 +- netware/mysql_upgrade.def | 11 +++++++++++ netware/mysql_waitpid.def | 2 +- netware/mysqladmin.def | 2 +- netware/mysqlbinlog.def | 2 +- netware/mysqlcheck.def | 2 +- netware/mysqld.def | 2 +- netware/mysqld_safe.def | 2 +- netware/mysqldump.def | 2 +- netware/mysqlimport.def | 2 +- netware/mysqlshow.def | 1 + netware/mysqltest.def | 1 + netware/pack_isam.def | 1 + netware/perror.def | 2 +- netware/replace.def | 1 + netware/resolve_stack_dump.def | 2 +- netware/resolveip.def | 1 + 29 files changed, 40 insertions(+), 21 deletions(-) create mode 100644 netware/mysql_upgrade.def diff --git a/netware/Makefile.am b/netware/Makefile.am index 648ce79c484..a94b5f4dcaa 100644 --- a/netware/Makefile.am +++ b/netware/Makefile.am @@ -30,6 +30,7 @@ netware_build_files = client/mysql.def client/mysqladmin.def \ client/mysqlbinlog.def client/mysqlcheck.def \ client/mysqldump.def client/mysqlimport.def \ client/mysqlshow.def client/mysqltest.def \ + client/mysql_upgrade.def \ extra/my_print_defaults.def \ extra/perror.def extra/replace.def \ extra/resolveip.def extra/comp_err.def \ @@ -69,7 +70,7 @@ EXTRA_DIST= $(BUILT_SOURCES) comp_err.def init_db.sql install_test_db.ncf \ mysql_test_run.def mysql_waitpid.def mysqladmin.def \ mysqlbinlog.def mysqlcheck.def mysqld.def \ mysqld_safe.c mysqld_safe.def mysqldump.def mysqlimport.def \ - mysqlshow.def mysqltest.def perror.def \ + mysqlshow.def mysqltest.def mysql_upgrade.def perror.def \ replace.def resolve_stack_dump.def resolveip.def test_db.sql \ static_init_db.sql \ BUILD/apply-patch BUILD/compile-AUTOTOOLS \ diff --git a/netware/comp_err.def b/netware/comp_err.def index f27b40c7b78..f5b18bbdb9a 100644 --- a/netware/comp_err.def +++ b/netware/comp_err.def @@ -5,6 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Error File Compiler" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/isamchk.def b/netware/isamchk.def index 31cf3fc569a..8ae2c0ca96c 100644 --- a/netware/isamchk.def +++ b/netware/isamchk.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL ISAM Table Check Tool" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL ISAM Table Check Tool" VERSION 4, 0 -STACKSIZE 65536 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/isamlog.def b/netware/isamlog.def index 52f9de0d928..777d73a7835 100644 --- a/netware/isamlog.def +++ b/netware/isamlog.def @@ -5,6 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL ISAM Table Log Tool" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/libmysql.def b/netware/libmysql.def index 8a34754e092..d9d4c752612 100644 --- a/netware/libmysql.def +++ b/netware/libmysql.def @@ -7,6 +7,6 @@ COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Res DESCRIPTION "MySQL Client Library" VERSION 4, 0 AUTOUNLOAD -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/my_print_defaults.def b/netware/my_print_defaults.def index 778a5204ebd..acba6c81b49 100644 --- a/netware/my_print_defaults.def +++ b/netware/my_print_defaults.def @@ -5,7 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Print Defaults Tool" VERSION 5, 0, 17 -STACKSIZE 32767 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/myisam_ftdump.def b/netware/myisam_ftdump.def index 9639404b53b..78123537a54 100644 --- a/netware/myisam_ftdump.def +++ b/netware/myisam_ftdump.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL MyISAM Table Dump Tool" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL MyISAM Table Dump Tool" VERSION 4, 0 -STACKSIZE 65536 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/myisamchk.def b/netware/myisamchk.def index b7ec5ac9474..9805eb4ec1b 100644 --- a/netware/myisamchk.def +++ b/netware/myisamchk.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL MyISAM Table Check Tool[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL MyISAM Table Check Tool" VERSION 4, 0 -STACKSIZE 65536 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/myisamlog.def b/netware/myisamlog.def index 553a818a2ae..925650eac7b 100644 --- a/netware/myisamlog.def +++ b/netware/myisamlog.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL MyISAM Table Log Tool" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL MyISAM Table Log Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/myisampack.def b/netware/myisampack.def index d1f85fe03f8..877a143fd2e 100644 --- a/netware/myisampack.def +++ b/netware/myisampack.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL MyISAM Table Pack Tool" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL MyISAM Table Pack Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysql.def b/netware/mysql.def index 16acc7babe1..4e44f4882d1 100644 --- a/netware/mysql.def +++ b/netware/mysql.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Monitor[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Monitor" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 MULTIPLE XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysql_install_db.def b/netware/mysql_install_db.def index 372bbf15570..e3dc57fe44c 100644 --- a/netware/mysql_install_db.def +++ b/netware/mysql_install_db.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Install" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Initial Database Installer" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysql_test_run.def b/netware/mysql_test_run.def index d4d4baee168..c8afd305978 100644 --- a/netware/mysql_test_run.def +++ b/netware/mysql_test_run.def @@ -2,10 +2,10 @@ # MySQL Test Run #------------------------------------------------------------------------------ MODULE libc.nlm -STACKSIZE 65536 SCREENNAME "MySQL Test Run" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Test Run" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysql_upgrade.def b/netware/mysql_upgrade.def new file mode 100644 index 00000000000..7b5718ffb1b --- /dev/null +++ b/netware/mysql_upgrade.def @@ -0,0 +1,11 @@ +#------------------------------------------------------------------------------ +# MySQL Admin +#------------------------------------------------------------------------------ +MODULE libc.nlm +COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." +DESCRIPTION "MySQL Upgrade Tool" +VERSION 4, 0 +STACKSIZE 131072 +XDCDATA ../netware/mysql.xdc +#DEBUG + diff --git a/netware/mysql_waitpid.def b/netware/mysql_waitpid.def index da0884ccba3..6e9cc76f139 100644 --- a/netware/mysql_waitpid.def +++ b/netware/mysql_waitpid.def @@ -6,7 +6,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Tool - Wait for a Program to Terminate" VERSION 4, 0 -STACKSIZE 65536 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqladmin.def b/netware/mysqladmin.def index 6532cab84a0..03f15dfdd08 100644 --- a/netware/mysqladmin.def +++ b/netware/mysqladmin.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Admin[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Admin Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqlbinlog.def b/netware/mysqlbinlog.def index aced63429c5..88024acc318 100644 --- a/netware/mysqlbinlog.def +++ b/netware/mysqlbinlog.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Binary Log Dump Tool[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Binary Log Dump Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqlcheck.def b/netware/mysqlcheck.def index 1b90b2a1dbe..b9028c237d1 100644 --- a/netware/mysqlcheck.def +++ b/netware/mysqlcheck.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Check Tool[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Check Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqld.def b/netware/mysqld.def index 42c2d176a1b..bb7b8129983 100644 --- a/netware/mysqld.def +++ b/netware/mysqld.def @@ -6,7 +6,7 @@ COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Res DESCRIPTION "MySQL Database Server" VERSION 4, 0 MULTIPLE -STACKSIZE 65536 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqld_safe.def b/netware/mysqld_safe.def index ff3f1924906..5c436cc97ca 100644 --- a/netware/mysqld_safe.def +++ b/netware/mysqld_safe.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Database Server" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Database Server Monitor" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 MULTIPLE XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqldump.def b/netware/mysqldump.def index 5d7999c789f..2e745492cf3 100644 --- a/netware/mysqldump.def +++ b/netware/mysqldump.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Dump Tool[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Dump Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqlimport.def b/netware/mysqlimport.def index f98d8021a73..5db6b940ce7 100644 --- a/netware/mysqlimport.def +++ b/netware/mysqlimport.def @@ -6,7 +6,7 @@ SCREENNAME "MySQL Import[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Import Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqlshow.def b/netware/mysqlshow.def index b7b84a94067..386cb98c091 100644 --- a/netware/mysqlshow.def +++ b/netware/mysqlshow.def @@ -6,6 +6,7 @@ SCREENNAME "MySQL Show[scrollable]" COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Show Tool" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/mysqltest.def b/netware/mysqltest.def index e134acede07..f0ee5f7e6a4 100644 --- a/netware/mysqltest.def +++ b/netware/mysqltest.def @@ -5,6 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Test Case Tool" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/pack_isam.def b/netware/pack_isam.def index 9ea72a4f2e7..514b57b04bd 100644 --- a/netware/pack_isam.def +++ b/netware/pack_isam.def @@ -7,6 +7,7 @@ COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Res DESCRIPTION "MySQL ISAM Table Pack Tool" SCREENNAME "MySQL ISAM Table Pack Tool" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/perror.def b/netware/perror.def index d67bd6191b4..fc95de3476a 100644 --- a/netware/perror.def +++ b/netware/perror.def @@ -5,7 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Error Code Description Tool" VERSION 4, 0 -STACKSIZE 32768 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/replace.def b/netware/replace.def index 19348ee4245..7feccdbff41 100644 --- a/netware/replace.def +++ b/netware/replace.def @@ -5,6 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Text Replacement Tool" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/resolve_stack_dump.def b/netware/resolve_stack_dump.def index 01042699d61..20098c1b4e0 100644 --- a/netware/resolve_stack_dump.def +++ b/netware/resolve_stack_dump.def @@ -6,7 +6,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Stack Dump Resolve Tool" VERSION 4, 0 -STACKSIZE 65536 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG diff --git a/netware/resolveip.def b/netware/resolveip.def index 244f52bb969..1962d61be53 100644 --- a/netware/resolveip.def +++ b/netware/resolveip.def @@ -5,6 +5,7 @@ MODULE libc.nlm COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL IP/Hostname Resolve Tool" VERSION 4, 0 +STACKSIZE 131072 XDCDATA ../netware/mysql.xdc #DEBUG From ca35cae78be2a5152a6dd50a0b929a7ffb64b3c6 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 2 Dec 2006 06:06:31 +0100 Subject: [PATCH 36/39] Makefile.am: Added "mysql_client_test.def" mysql_client_test.def: BitKeeper file /home/kent/bk/mysql-5.0-build/netware/mysql_client_test.def netware/mysql_client_test.def: BitKeeper file /home/kent/bk/mysql-5.0-build/netware/mysql_client_test.def netware/Makefile.am: Added "mysql_client_test.def" --- netware/Makefile.am | 2 ++ netware/mysql_client_test.def | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 netware/mysql_client_test.def diff --git a/netware/Makefile.am b/netware/Makefile.am index a94b5f4dcaa..de39376f6a1 100644 --- a/netware/Makefile.am +++ b/netware/Makefile.am @@ -31,6 +31,7 @@ netware_build_files = client/mysql.def client/mysqladmin.def \ client/mysqldump.def client/mysqlimport.def \ client/mysqlshow.def client/mysqltest.def \ client/mysql_upgrade.def \ + tests/mysql_client_test.def \ extra/my_print_defaults.def \ extra/perror.def extra/replace.def \ extra/resolveip.def extra/comp_err.def \ @@ -71,6 +72,7 @@ EXTRA_DIST= $(BUILT_SOURCES) comp_err.def init_db.sql install_test_db.ncf \ mysqlbinlog.def mysqlcheck.def mysqld.def \ mysqld_safe.c mysqld_safe.def mysqldump.def mysqlimport.def \ mysqlshow.def mysqltest.def mysql_upgrade.def perror.def \ + mysql_client_test.def \ replace.def resolve_stack_dump.def resolveip.def test_db.sql \ static_init_db.sql \ BUILD/apply-patch BUILD/compile-AUTOTOOLS \ diff --git a/netware/mysql_client_test.def b/netware/mysql_client_test.def new file mode 100644 index 00000000000..9a6f63ec4d7 --- /dev/null +++ b/netware/mysql_client_test.def @@ -0,0 +1,10 @@ +#------------------------------------------------------------------------------ +# MySQL Test +#------------------------------------------------------------------------------ +MODULE libc.nlm +COPYRIGHT "(c) 2003-2005 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." +DESCRIPTION "MySQL Client Test" +VERSION 4, 0 +STACKSIZE 131072 +XDCDATA ../netware/mysql.xdc +#DEBUG From 1172c8ae5568374de74037644a9a082722df9fab Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 2 Dec 2006 23:16:47 +0100 Subject: [PATCH 37/39] mysql_install_db.sh: If --srcdir and --windows is given, check if error message file is in source or build tree (bug#24557) Makefile.am: Cleaned up "ali_check" target, to satisfy "distcleancheck" (bug#24557) mysql_install_db.sh: Added --srcdir=DIR option, used from top Makefile.am in dist-hook target, to find "fill_help_tables.sql" in VPATH build (bug#24557) Makefile.am: Work around problem with "distcleancheck", "sql_yacc.cc" might be in both the source and build tree. Call "mysql_install_db" with new option --srcdir, to enable the script to find all that is needed, if source and build directory is not the same (bug#24557) scripts/mysql_install_db.sh: If --srcdir and --windows is given, check if error message file is in source or build tree (bug#24557) Makefile.am: Work around problem with "distcleancheck", "sql_yacc.cc" might be in both the source and build tree. Call "mysql_install_db" with new option --srcdir, to enable the script to find all that is needed, if source and build directory is not the same (bug#24557) include/Makefile.am: Cleaned up "ali_check" target, to satisfy "distcleancheck" (bug#24557) --- Makefile.am | 24 +++++++++++++----------- include/Makefile.am | 23 +++++++++++------------ scripts/mysql_install_db.sh | 36 +++++++++++++++++++++++++----------- 3 files changed, 49 insertions(+), 34 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9752075fe78..6038825c928 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,6 +49,14 @@ BUILT_SOURCES = linked_client_sources linked_server_sources \ CLEANFILES = $(BUILT_SOURCES) bdb/build_unix/db.h DISTCLEANFILES = ac_available_languages_fragment +# Our current filtering of "sql_yacc.cc" in "sql/Makefile.am" creates +# a problem, if a VPATH build and "sql_yacc.cc" was part of the source +# distribution we end up with one "sql_yacc.cc" in the source tree, +# and one in the build tree. This breaks "distcleancheck", until this +# is sorted out we redefine the find that scans for files not removed + +distcleancheck_listfiles = find . -name sql_yacc.cc -o -type f -print + linked_include_sources: cd include; $(MAKE) link_sources echo timestamp > linked_include_sources @@ -93,17 +101,11 @@ bin-dist: all dist-hook: rm -rf `find $(distdir) -type d -name SCCS -print` rm -f `find $(distdir) -type l -print` - if echo "$(distdir)" | grep -q '^/' ; then \ - mkdir -p "$(distdir)/win" ; \ - scripts/mysql_install_db --no-defaults --windows \ - --basedir=$(top_srcdir) \ - --datadir="$(distdir)/win/data"; \ - else \ - mkdir -p "$$(pwd)/$(distdir)/win" ; \ - scripts/mysql_install_db --no-defaults --windows \ - --basedir=$(top_srcdir) \ - --datadir="$$(pwd)/$(distdir)/win/data"; \ - fi + mkdir -p $(distdir)/win + scripts/mysql_install_db --no-defaults --windows \ + --basedir=$(top_builddir) \ + --datadir=$(distdir)/win/data \ + --srcdir=$(top_srcdir) tags: support-files/build-tags diff --git a/include/Makefile.am b/include/Makefile.am index 3500503207c..8a4799149d0 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -15,14 +15,17 @@ # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # MA 02111-1307, USA -BUILT_SOURCES = mysql_version.h my_config.h -pkginclude_HEADERS = my_dbug.h m_string.h my_sys.h my_list.h my_xml.h \ - mysql.h mysql_com.h mysql_embed.h \ - my_semaphore.h my_pthread.h my_no_pthread.h raid.h \ - errmsg.h my_global.h my_net.h my_alloc.h \ - my_getopt.h sslopt-longopts.h my_dir.h typelib.h \ +BUILT_SOURCES = $(HEADERS_GEN) abi_check +HEADERS_GEN = mysql_version.h my_config.h +HEADERS_ABI = mysql.h mysql_com.h mysql_time.h \ + my_list.h my_alloc.h typelib.h +pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \ + my_xml.h mysql_embed.h \ + my_semaphore.h my_pthread.h my_no_pthread.h raid.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 \ - mysql_time.h m_ctype.h $(BUILT_SOURCES) + m_ctype.h $(HEADERS_GEN) noinst_HEADERS = config-win.h config-os2.h config-netware.h \ heap.h my_bitmap.h\ myisam.h myisampack.h myisammrg.h ft_global.h\ @@ -59,8 +62,7 @@ dist-hook: # # Create a icheck file and compare it to the reference -abi_check: mysql.h mysql_version.h mysql_com.h mysql_time.h my_list.h \ - my_alloc.h typelib.h mysql_h.ic +abi_check: $(HEADERS_ABI) mysql_version.h mysql_h.ic @set -ex; \ if [ @ICHECK@ != no ] ; then \ @ICHECK@ --canonify --skip-from-re /usr/ -o $@.ic mysql.h; \ @@ -68,8 +70,5 @@ abi_check: mysql.h mysql_version.h mysql_com.h mysql_time.h my_list.h \ fi; \ touch abi_check; -all: abi_check - - # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 5d7933e5277..e43b586054e 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -33,6 +33,7 @@ parse_arguments() { case "$arg" in --force) force=1 ;; --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --srcdir=*) srcdir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --user=*) # Note that the user will be passed to mysqld so that it runs @@ -78,6 +79,7 @@ ldata= execdir= bindir= basedir= +srcdir= force=0 verbose=0 fill_help_tables="" @@ -106,18 +108,24 @@ else fi # find fill_help_tables.sh -for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@ -do - if test -f $i/fill_help_tables.sql - then - pkgdatadir=$i - fi -done - -if test -f $pkgdatadir/fill_help_tables.sql +if test -n "$srcdir" then - fill_help_tables=$pkgdatadir/fill_help_tables.sql + fill_help_tables=$srcdir/scripts/fill_help_tables.sql else + for i in $basedir/support-files $basedir/share $basedir/share/mysql \ + $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@ + do + if test -f $i/fill_help_tables.sql + then + pkgdatadir=$i + fi + done + + fill_help_tables=$pkgdatadir/fill_help_tables.sql +fi + +if test ! -f $fill_help_tables +then echo "Could not find help file 'fill_help_tables.sql' in @pkgdatadir@ or inside $basedir". exit 1; fi @@ -130,7 +138,13 @@ scriptdir=$bindir if test "$windows" = 1 then mysqld="./sql/mysqld" - mysqld_opt="--language=./sql/share/english" + if test -n "$srcdir" -a -f $srcdir/sql/share/english/errmsg.sys + then + langdir=$srcdir/sql/share/english + else + langdir=./sql/share/english + fi + mysqld_opt="--language=$langdir" scriptdir="./scripts" fi From 63b2be3c8a16fd5add3699d310df3630d9c0ec75 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Dec 2006 14:26:05 +0200 Subject: [PATCH 38/39] item_func.cc: fixed a valgrind warning type_varchar.test: fixed a valgrind warning mysql-test/t/type_varchar.test: fixed a valgrind warning sql/item_func.cc: fixed a valgrind warning --- mysql-test/t/type_varchar.test | 1 + sql/item_func.cc | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mysql-test/t/type_varchar.test b/mysql-test/t/type_varchar.test index cfb6472a7b4..7b87a388c56 100644 --- a/mysql-test/t/type_varchar.test +++ b/mysql-test/t/type_varchar.test @@ -196,3 +196,4 @@ INSERT INTO t1 VALUES (10), (50), (30), ('1a'), (60), ('t'); SELECT a,(a + 0) FROM t1 ORDER BY a; SELECT a,(a DIV 2) FROM t1 ORDER BY a; SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a; +DROP TABLE t1; diff --git a/sql/item_func.cc b/sql/item_func.cc index 6bbb199a52b..ff1ef22d36d 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -900,7 +900,8 @@ void Item_func_signed::print(String *str) longlong Item_func_signed::val_int_from_str(int *error) { - char buff[MAX_FIELD_WIDTH], *end; + char buff[MAX_FIELD_WIDTH], *end, *start; + uint32 length; String tmp(buff,sizeof(buff), &my_charset_bin), *res; longlong value; @@ -916,13 +917,21 @@ longlong Item_func_signed::val_int_from_str(int *error) return 0; } null_value= 0; - end= (char*) res->ptr()+ res->length(); - value= my_strtoll10(res->ptr(), &end, error); - if (*error > 0 || end != res->ptr()+ res->length()) + start= (char *)res->ptr(); + length= res->length(); + + end= start + length; + value= my_strtoll10(start, &end, error); + if (*error > 0 || end != start+ length) + { + char err_buff[128]; + String err_tmp(err_buff,(uint32) sizeof(err_buff), system_charset_info); + err_tmp.copy(start, length, system_charset_info); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE, ER(ER_TRUNCATED_WRONG_VALUE), "INTEGER", - res->c_ptr()); + err_tmp.c_ptr()); + } return value; } From 818bec7fb89cdad25357f9d657bb72150fa5f06e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Dec 2006 14:29:51 +0200 Subject: [PATCH 39/39] type_varchar.result: fixed a valgrind problem mysql-test/r/type_varchar.result: fixed a valgrind problem --- mysql-test/r/type_varchar.result | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/r/type_varchar.result b/mysql-test/r/type_varchar.result index 4c1aee24642..f6c2f4d01a6 100644 --- a/mysql-test/r/type_varchar.result +++ b/mysql-test/r/type_varchar.result @@ -488,3 +488,4 @@ t 0 Warnings: Warning 1292 Truncated incorrect INTEGER value: '1a' Warning 1292 Truncated incorrect INTEGER value: 't' +DROP TABLE t1;