diff options
author | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2021-01-12 13:31:57 +0530 |
---|---|---|
committer | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2021-01-13 19:24:05 +0530 |
commit | fb9a9599bc9faed7b2f4860cb5e2bc8c597aacef (patch) | |
tree | 3758fb941e482bc048af7405568860bb47365c75 /sql | |
parent | 59998d3480f2a472cfc79208be4ee32ff5eff1ed (diff) | |
download | mariadb-git-fb9a9599bc9faed7b2f4860cb5e2bc8c597aacef.tar.gz |
MDEV-24387: Wrong number of decimal digits in certain UNION/Subqery
constellation
Analysis: The decimals is set to NOT_FIXED_DEC for Field_str even if it is
NULL. Unsigned has decimals=0. So Type_std_attributes::decimals is set to 39
(maximum between 0 and 39). This results in incorrect number of decimals
when we have union of unsigned and NULL type.
Fix: Check if the field is created from NULL value. If yes, set decimals to 0
otherwise set it to NOT_FIXED_DEC.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sql/field.h b/sql/field.h index be3a648617b..1344774c189 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1762,7 +1762,7 @@ public: uchar null_bit_arg, utype unireg_check_arg, const LEX_CSTRING *field_name_arg, const DTCollation &collation); - uint decimals() const { return NOT_FIXED_DEC; } + uint decimals() const { return is_created_from_null_item ? 0 : NOT_FIXED_DEC; } int save_in_field(Field *to) { return save_in_field_str(to); } bool memcpy_field_possible(const Field *from) const { |