Commit 28e5063d authored by sergefp@mysql.com's avatar sergefp@mysql.com

BUG#31450: Query causes error 1048

- Let Item::save_in_field() call set_field_to_null_with_conversions() 
  for decimal type, like this is done for the other item result types.
parent d0f53297
...@@ -805,3 +805,14 @@ SELECT 1 % .12345678912345678912345678912345678912345678912345678912345678912345 ...@@ -805,3 +805,14 @@ SELECT 1 % .12345678912345678912345678912345678912345678912345678912345678912345
SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()'; SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()';
MOD() MOD()
0.012345687012345687012345687012345687012345687012345687012345687012345687000000000 0.012345687012345687012345687012345687012345687012345687012345687012345687000000000
create table t1 (
ua_id decimal(22,0) not null,
ua_invited_by_id decimal(22,0) default NULL,
primary key(ua_id)
);
insert into t1 values (123, NULL), (456, NULL);
this must not produce error 1048:
select * from t1 where ua_invited_by_id not in (select ua_id from t1);
ua_id ua_invited_by_id
drop table t1;
End of 5.0 tests
...@@ -416,3 +416,22 @@ DROP TABLE t1; ...@@ -416,3 +416,22 @@ DROP TABLE t1;
SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%'; SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%';
SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()'; SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()';
#
# BUG#31450 "Query causes error 1048"
#
create table t1 (
ua_id decimal(22,0) not null,
ua_invited_by_id decimal(22,0) default NULL,
primary key(ua_id)
);
insert into t1 values (123, NULL), (456, NULL);
--echo this must not produce error 1048:
select * from t1 where ua_invited_by_id not in (select ua_id from t1);
drop table t1;
--echo End of 5.0 tests
...@@ -4548,7 +4548,7 @@ int Item::save_in_field(Field *field, bool no_conversions) ...@@ -4548,7 +4548,7 @@ int Item::save_in_field(Field *field, bool no_conversions)
my_decimal decimal_value; my_decimal decimal_value;
my_decimal *value= val_decimal(&decimal_value); my_decimal *value= val_decimal(&decimal_value);
if (null_value) if (null_value)
return set_field_to_null(field); return set_field_to_null_with_conversions(field, no_conversions);
field->set_notnull(); field->set_notnull();
error=field->store_decimal(value); error=field->store_decimal(value);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment