summaryrefslogtreecommitdiff
path: root/sql/field.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-08-08 13:47:50 +0400
committerAlexander Barkov <bar@mariadb.com>2019-08-08 13:47:50 +0400
commite555df648c5c81f51be2e574627f6327099516ba (patch)
tree7212f9634a7896ef9de240701490834638d5b2e4 /sql/field.h
parent7fc86a73d8fbfa6d527d9eb1160bedaf939eae7a (diff)
downloadmariadb-git-e555df648c5c81f51be2e574627f6327099516ba.tar.gz
MDEV-20285 Wrong result on INSERT..SELECT when converting from SIGNED to UNSIGNED
Diffstat (limited to 'sql/field.h')
-rw-r--r--sql/field.h23
1 files changed, 14 insertions, 9 deletions
diff --git a/sql/field.h b/sql/field.h
index 3e5b84f9249..330523f5864 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1708,13 +1708,6 @@ public:
{
return to->store(val_int(), MY_TEST(flags & UNSIGNED_FLAG));
}
- bool memcpy_field_possible(const Field *from) const
- {
- return real_type() == from->real_type() &&
- pack_length() == from->pack_length() &&
- !((flags & UNSIGNED_FLAG) && !(from->flags & UNSIGNED_FLAG)) &&
- decimals() == from->decimals();
- }
uint is_equal(Create_field *new_field);
uint row_pack_length() const { return pack_length(); }
uint32 pack_length_from_metadata(uint field_metadata) {
@@ -1892,7 +1885,10 @@ public:
e.g. a DOUBLE(53,10) into a DOUBLE(10,10).
But it should be OK the other way around.
*/
- return Field_num::memcpy_field_possible(from) &&
+ return real_type() == from->real_type() &&
+ pack_length() == from->pack_length() &&
+ is_unsigned() <= from->is_unsigned() &&
+ decimals() == from->decimals() &&
field_length >= from->field_length;
}
int store_decimal(const my_decimal *);
@@ -1983,7 +1979,10 @@ public:
}
bool memcpy_field_possible(const Field *from) const
{
- return Field_num::memcpy_field_possible(from) &&
+ return real_type() == from->real_type() &&
+ pack_length() == from->pack_length() &&
+ is_unsigned() <= from->is_unsigned() &&
+ decimals() == from->decimals() &&
field_length == from->field_length;
}
int reset(void);
@@ -2041,6 +2040,12 @@ public:
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, 0, zero_arg, unsigned_arg)
{}
+ bool memcpy_field_possible(const Field *from) const
+ {
+ return real_type() == from->real_type() &&
+ pack_length() == from->pack_length() &&
+ is_unsigned() == from->is_unsigned();
+ }
int store_decimal(const my_decimal *);
my_decimal *val_decimal(my_decimal *);
bool val_bool() { return val_int() != 0; }