1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-05 13:16:09 +03:00

Fix over-optimization that could result in an unsigned double field being

set to a negative value. (Bug #7700)
This commit is contained in:
jimw@mysql.com
2005-01-17 16:13:56 -08:00
parent 46e444293a
commit a35c324358
3 changed files with 14 additions and 0 deletions

View File

@@ -120,3 +120,10 @@ drop table t1;
create table t1 (f float(54)); create table t1 (f float(54));
Incorrect column specifier for column 'f' Incorrect column specifier for column 'f'
drop table if exists t1; drop table if exists t1;
create table t1 (d1 double, d2 double unsigned);
insert into t1 set d1 = -1.0;
update t1 set d2 = d1;
select * from t1;
d1 d2
-1 0
drop table t1;

View File

@@ -67,3 +67,9 @@ drop table t1;
create table t1 (f float(54)); # Should give an error create table t1 (f float(54)); # Should give an error
drop table if exists t1; drop table if exists t1;
# Don't allow 'double unsigned' to be set to a negative value (Bug #7700)
create table t1 (d1 double, d2 double unsigned);
insert into t1 set d1 = -1.0;
update t1 set d2 = d1;
select * from t1;
drop table t1;

View File

@@ -537,6 +537,7 @@ void field_conv(Field *to,Field *from)
if (to->real_type() == from->real_type()) if (to->real_type() == from->real_type())
{ {
if (to->pack_length() == from->pack_length() && if (to->pack_length() == from->pack_length() &&
!(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) &&
to->real_type() != FIELD_TYPE_ENUM && to->real_type() != FIELD_TYPE_ENUM &&
to->real_type() != FIELD_TYPE_SET && to->real_type() != FIELD_TYPE_SET &&
to->table->db_low_byte_first == from->table->db_low_byte_first) to->table->db_low_byte_first == from->table->db_low_byte_first)