MDEV-736 LP:1004615 - Unexpected warnings "Encountered illegal value '' when converting to DECIMAL" on a query with aggregate functions and GROUP BY
fix: don't call field->val_decimal() if the field->is_null() because the buffer at field->ptr might not hold a valid decimal value sql/item_sum.cc: do not call field->val_decimal() if the field->is_null() storage/maria/ma_blockrec.c: cleanup storage/maria/ma_rrnd.c: cleanup strings/decimal.c: typo
This commit is contained in:
parent
ecf04668a2
commit
13ba0dd286
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user