diff options
-rw-r--r-- | mysql-test/r/group_by.result | 13 | ||||
-rw-r--r-- | mysql-test/t/group_by.test | 16 | ||||
-rw-r--r-- | sql/item_sum.cc | 6 | ||||
-rw-r--r-- | storage/maria/ma_blockrec.c | 9 | ||||
-rw-r--r-- | storage/maria/ma_rrnd.c | 4 | ||||
-rw-r--r-- | strings/decimal.c | 2 |
6 files changed, 38 insertions, 12 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 68ddcd39e92..d6036d7e586 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -2097,7 +2097,7 @@ NULL drop table t1; # End of 5.2 tests # -# BUG#872702: Crash in add_ref_to_table_cond() when grouping by a PK +# lp:872702 Crash in add_ref_to_table_cond() when grouping by a PK # CREATE TABLE t1 (a int, PRIMARY KEY (a)) ; INSERT INTO t1 VALUES (14),(15),(16),(17),(18),(19),(20); @@ -2111,4 +2111,15 @@ FROM t2 GROUP BY 1; a DROP TABLE t1, t2; +FLUSH STATUS; +CREATE TABLE t1 (f1 INT, f2 decimal(20,1), f3 blob); +INSERT INTO t1 values(11,NULL,'blob'),(11,NULL,'blob'); +SELECT f3, MIN(f2) FROM t1 GROUP BY f1 LIMIT 1; +f3 MIN(f2) +blob NULL +DROP TABLE t1; +the value below *must* be 1 +show status like 'Created_tmp_disk_tables'; +Variable_name Value +Created_tmp_disk_tables 1 # End of 5.3 tests diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index d4214442709..b80c158aa92 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1456,7 +1456,7 @@ drop table t1; --echo # End of 5.2 tests --echo # ---echo # BUG#872702: Crash in add_ref_to_table_cond() when grouping by a PK +--echo # lp:872702 Crash in add_ref_to_table_cond() when grouping by a PK --echo # CREATE TABLE t1 (a int, PRIMARY KEY (a)) ; INSERT INTO t1 VALUES (14),(15),(16),(17),(18),(19),(20); @@ -1472,4 +1472,18 @@ WHERE a = ( GROUP BY 1; DROP TABLE t1, t2; +# +# MDEV-736 LP:1004615 - Unexpected warnings "Encountered illegal value '' when converting to DECIMAL" on a query with aggregate functions and GROUP BY +# + +FLUSH STATUS; # this test case *must* use Aria temp tables + +CREATE TABLE t1 (f1 INT, f2 decimal(20,1), f3 blob); +INSERT INTO t1 values(11,NULL,'blob'),(11,NULL,'blob'); +SELECT f3, MIN(f2) FROM t1 GROUP BY f1 LIMIT 1; +DROP TABLE t1; + +--echo the value below *must* be 1 +show status like 'Created_tmp_disk_tables'; + --echo # End of 5.3 tests diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 86aef19efc0..1c83f0e2422 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -2149,9 +2149,8 @@ Item_sum_hybrid::min_max_update_int_field() void Item_sum_hybrid::min_max_update_decimal_field() { - /* TODO: optimize: do not get result_field in case of args[0] is NULL */ my_decimal old_val, nr_val; - const my_decimal *old_nr= result_field->val_decimal(&old_val); + const my_decimal *old_nr; const my_decimal *nr= args[0]->val_decimal(&nr_val); if (!args[0]->null_value) { @@ -2159,16 +2158,17 @@ Item_sum_hybrid::min_max_update_decimal_field() old_nr=nr; else { + old_nr= result_field->val_decimal(&old_val); bool res= my_decimal_cmp(old_nr, nr) > 0; /* (cmp_sign > 0 && res) || (!(cmp_sign > 0) && !res) */ if ((cmp_sign > 0) ^ (!res)) old_nr=nr; } result_field->set_notnull(); + result_field->store_decimal(old_nr); } else if (result_field->is_null(0)) result_field->set_null(); - result_field->store_decimal(old_nr); } diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 4e55c519a9a..036059f1245 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -4676,7 +4676,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record, uchar *data, uchar *end_of_data) { MARIA_SHARE *share= info->s; - uchar *field_length_data, *blob_buffer, *start_of_data; + uchar *UNINIT_VAR(field_length_data), *UNINIT_VAR(blob_buffer), *start_of_data; uint flag, null_bytes, cur_null_bytes, row_extents, field_lengths; my_bool found_blob= 0; MARIA_EXTENT_CURSOR extent; @@ -4684,9 +4684,6 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record, MARIA_ROW *cur_row= &info->cur_row; DBUG_ENTER("_ma_read_block_record2"); - LINT_INIT(field_length_data); - LINT_INIT(blob_buffer); - start_of_data= data; flag= (uint) (uchar) data[0]; cur_null_bytes= share->base.original_null_bytes; @@ -5114,6 +5111,7 @@ int _ma_read_block_record(MARIA_HA *info, uchar *record, uchar *data, *end_of_data, *buff; uint offset; uint block_size= share->block_size; + int ret; DBUG_ENTER("_ma_read_block_record"); DBUG_PRINT("enter", ("rowid: %lu page: %lu rownr: %u", (ulong) record_pos, @@ -5135,7 +5133,8 @@ int _ma_read_block_record(MARIA_HA *info, uchar *record, my_errno= HA_ERR_RECORD_DELETED; /* File crashed */ DBUG_RETURN(HA_ERR_RECORD_DELETED); } - DBUG_RETURN(_ma_read_block_record2(info, record, data, end_of_data)); + ret= _ma_read_block_record2(info, record, data, end_of_data); + DBUG_RETURN(ret); } diff --git a/storage/maria/ma_rrnd.c b/storage/maria/ma_rrnd.c index 24c4bfdd467..8c35c71c95e 100644 --- a/storage/maria/ma_rrnd.c +++ b/storage/maria/ma_rrnd.c @@ -30,6 +30,7 @@ int maria_rrnd(MARIA_HA *info, uchar *buf, MARIA_RECORD_POS filepos) { + int ret; DBUG_ENTER("maria_rrnd"); DBUG_ASSERT(filepos != HA_OFFSET_ERROR); @@ -40,5 +41,6 @@ int maria_rrnd(MARIA_HA *info, uchar *buf, MARIA_RECORD_POS filepos) DBUG_RETURN(my_errno); info->cur_row.lastpos= filepos; /* Remember for update */ - DBUG_RETURN((*info->s->read_record)(info, buf, filepos)); + ret= (*info->s->read_record)(info, buf, filepos); + DBUG_RETURN(ret); } diff --git a/strings/decimal.c b/strings/decimal.c index 032cee938d3..e4925ff5f7c 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1190,7 +1190,7 @@ int decimal2longlong(const decimal_t *from, longlong *to) And for -1234567890.1234 it would be - 7E F2 04 37 2D FB 2D + 7E F2 04 C7 2D FB 2D */ int decimal2bin(const decimal_t *from, uchar *to, int precision, int frac) { |