From a092ed1afe3c3c7889810f45d591cfb2633c87f9 Mon Sep 17 00:00:00 2001 From: Staale Smedseng <staale.smedseng@sun.com> Date: Tue, 9 Jun 2009 14:55:30 +0200 Subject: Bug #43414 Parenthesis (and other) warnings compiling MySQL with gcc 4.3.2 Compiling MySQL with gcc 4.3.2 and later produces a number of warnings, many of which are new with the recent compiler versions. This bug will be resolved in more than one patch to limit the size of changesets. This is the first patch, fixing a number of the warnings, predominantly "suggest using parentheses around && in ||", and empty for and while bodies. --- sql/item_sum.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sql/item_sum.cc') diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 57045f52825..a381361e8a2 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -652,8 +652,8 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) return TRUE; // 'item' can be changed during fix_fields - if (!item->fixed && - item->fix_fields(thd, args) || + if ((!item->fixed && + item->fix_fields(thd, args)) || (item= args[0])->check_cols(1)) return TRUE; decimals=item->decimals; @@ -969,8 +969,8 @@ void Item_sum_distinct::fix_length_and_dec() integers each <= 2^32. */ if (table_field_type == MYSQL_TYPE_INT24 || - table_field_type >= MYSQL_TYPE_TINY && - table_field_type <= MYSQL_TYPE_LONG) + (table_field_type >= MYSQL_TYPE_TINY && + table_field_type <= MYSQL_TYPE_LONG)) { val.traits= Hybrid_type_traits_fast_decimal::instance(); break; @@ -2608,8 +2608,8 @@ bool Item_sum_count_distinct::setup(THD *thd) enum enum_field_types f_type= f->type(); tree_key_length+= f->pack_length(); if ((f_type == MYSQL_TYPE_VARCHAR) || - !f->binary() && (f_type == MYSQL_TYPE_STRING || - f_type == MYSQL_TYPE_VAR_STRING)) + (!f->binary() && (f_type == MYSQL_TYPE_STRING || + f_type == MYSQL_TYPE_VAR_STRING))) { all_binary= FALSE; break; -- cgit v1.2.1 From a073ee45c290d81d365b48b03ef6924e778cd64f Mon Sep 17 00:00:00 2001 From: Staale Smedseng <staale.smedseng@sun.com> Date: Tue, 9 Jun 2009 18:11:21 +0200 Subject: Bug #43414 Parenthesis (and other) warnings compiling MySQL with gcc 4.3.2 Compiling MySQL with gcc 4.3.2 and later produces a number of warnings, many of which are new with the recent compiler versions. This bug will be resolved in more than one patch to limit the size of changesets. This is the first patch, fixing a number of the warnings, predominantly "suggest using parentheses around && in ||", and empty for and while bodies. --- sql/item_sum.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sql/item_sum.cc') diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 57045f52825..a381361e8a2 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -652,8 +652,8 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) return TRUE; // 'item' can be changed during fix_fields - if (!item->fixed && - item->fix_fields(thd, args) || + if ((!item->fixed && + item->fix_fields(thd, args)) || (item= args[0])->check_cols(1)) return TRUE; decimals=item->decimals; @@ -969,8 +969,8 @@ void Item_sum_distinct::fix_length_and_dec() integers each <= 2^32. */ if (table_field_type == MYSQL_TYPE_INT24 || - table_field_type >= MYSQL_TYPE_TINY && - table_field_type <= MYSQL_TYPE_LONG) + (table_field_type >= MYSQL_TYPE_TINY && + table_field_type <= MYSQL_TYPE_LONG)) { val.traits= Hybrid_type_traits_fast_decimal::instance(); break; @@ -2608,8 +2608,8 @@ bool Item_sum_count_distinct::setup(THD *thd) enum enum_field_types f_type= f->type(); tree_key_length+= f->pack_length(); if ((f_type == MYSQL_TYPE_VARCHAR) || - !f->binary() && (f_type == MYSQL_TYPE_STRING || - f_type == MYSQL_TYPE_VAR_STRING)) + (!f->binary() && (f_type == MYSQL_TYPE_STRING || + f_type == MYSQL_TYPE_VAR_STRING))) { all_binary= FALSE; break; -- cgit v1.2.1 From 096c12b2c42b83d879314276fe6471edf8c61fd0 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov <Alexey.Kopytov@Sun.com> Date: Fri, 3 Jul 2009 11:41:19 +0400 Subject: Bug #45262: Bad effects with CREATE TABLE and DECIMAL Using DECIMAL constants with more than 65 digits in CREATE TABLE ... SELECT led to bogus errors in release builds or assertion failures in debug builds. The problem was in inconsistency in how DECIMAL constants and fields are handled internally. We allow arbitrarily long DECIMAL constants, whereas DECIMAL(M,D) columns are limited to M<=65 and D<=30. my_decimal_precision_to_length() was used in both Item and Field code and truncated precision to DECIMAL_MAX_PRECISION when calculating value length without adjusting precision and decimals. As a result, a DECIMAL constant with more than 65 digits ended up having length less than precision or decimals which led to assertion failures. Fixed by modifying my_decimal_precision_to_length() so that precision is truncated to DECIMAL_MAX_PRECISION only for Field object which is indicated by the new 'truncate' parameter. Another inconsistency fixed by this patch is how DECIMAL constants and expressions are handled for CREATE ... SELECT. create_tmp_field_from_item() (which is used for constants) was changed as a part of the bugfix for bug #24907 to handle long DECIMAL constants gracefully. Item_func::tmp_table_field() (which is used for expressions) on the other hand was still using a simplistic approach when creating a Field_new_decimal from a DECIMAL expression. mysql-test/r/type_newdecimal.result: Added a test case for bug #45262. mysql-test/t/type_newdecimal.test: Added a test case for bug #45262. sql/item.cc: Use the new 'truncate' parameter in my_decimal_precision_to_length(). sql/item_cmpfunc.cc: Use the new 'truncate' parameter in my_decimal_precision_to_length(). sql/item_func.cc: 1. Use the new 'truncate' parameter in my_decimal_precision_to_length(). 2. Do not truncate decimal precision to DECIMAL_MAX_PRECISION for additive expressions involving long DECIMAL constants. 3. Fixed an incosistency in how DECIMAL constants and expressions are handled for CREATE ... SELECT. sql/item_func.h: Use the new 'truncate' parameter in my_decimal_precision_to_length(). sql/item_sum.cc: Use the new 'truncate' parameter in my_decimal_precision_to_length(). sql/my_decimal.h: Do not truncate precision to DECIMAL_MAX_PRECISION when calculating length in my_decimal_precision_to_length() if 'truncate' parameter is FALSE. sql/sql_select.cc: 1. Use the new 'truncate' parameter in my_decimal_precision_to_length(). 2. Use a more correct logic when adjusting value's length. --- sql/item_sum.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'sql/item_sum.cc') diff --git a/sql/item_sum.cc b/sql/item_sum.cc index a381361e8a2..79295904d65 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -786,8 +786,9 @@ void Item_sum_sum::fix_length_and_dec() { /* SUM result can't be longer than length(arg) + length(MAX_ROWS) */ int precision= args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS; - max_length= my_decimal_precision_to_length(precision, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, + decimals, + unsigned_flag); curr_dec_buff= 0; hybrid_type= DECIMAL_RESULT; my_decimal_set_zero(dec_buffs); @@ -1217,8 +1218,9 @@ void Item_sum_avg::fix_length_and_dec() { int precision= args[0]->decimal_precision() + prec_increment; decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE); - max_length= my_decimal_precision_to_length(precision, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, + decimals, + unsigned_flag); f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION); f_scale= args[0]->decimals; dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale); @@ -1418,8 +1420,9 @@ void Item_sum_variance::fix_length_and_dec() { int precision= args[0]->decimal_precision()*2 + prec_increment; decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE); - max_length= my_decimal_precision_to_length(precision, decimals, - unsigned_flag); + max_length= my_decimal_precision_to_length_no_truncation(precision, + decimals, + unsigned_flag); break; } -- cgit v1.2.1 From 5beae1f8dcf6417315aec0940fadd8b32c218afe Mon Sep 17 00:00:00 2001 From: Georgi Kodinov <joro@sun.com> Date: Fri, 10 Jul 2009 15:00:34 +0300 Subject: Bug #46080: group_concat(... order by) crashes server when sort_buffer_size cannot allocate The NULL return from tree_insert() (on low memory) was not checked for in Item_func_group_concat::add(). As a result on low memory conditions a crash happens. Fixed by properly checking the return code. --- sql/item_sum.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sql/item_sum.cc') diff --git a/sql/item_sum.cc b/sql/item_sum.cc index a381361e8a2..dde8fe29e5a 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3291,8 +3291,13 @@ bool Item_func_group_concat::add() TREE_ELEMENT *el= 0; // Only for safety if (row_eligible && tree) + { el= tree_insert(tree, table->record[0] + table->s->null_bytes, 0, tree->custom_arg); + /* check if there was enough memory to insert the row */ + if (!el) + return 1; + } /* If the row is not a duplicate (el->count == 1) we can dump the row here in case of GROUP_CONCAT(DISTINCT...) -- cgit v1.2.1