Commit 9b7a1c0e authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-22243 type_test.type_test_double fails with 'NUMERIC_SCALE NULL'

1. fix useless correction of dec_arg *after it was used*
2. use DECIMAL_NOT_SPECIFIED instead of NOT_FIXED_DEC, because the latter
   is defined conditionally and has a wrong value in plugins
parent 8aa20764
......@@ -290,7 +290,7 @@ DATA_TYPE test_double
CHARACTER_MAXIMUM_LENGTH NULL
CHARACTER_OCTET_LENGTH NULL
NUMERIC_PRECISION 22
NUMERIC_SCALE 31
NUMERIC_SCALE NULL
DATETIME_PRECISION NULL
CHARACTER_SET_NAME NULL
COLLATION_NAME NULL
......
......@@ -2105,7 +2105,7 @@ class Field_str :public Field {
uchar null_bit_arg, utype unireg_check_arg,
const LEX_CSTRING *field_name_arg,
const DTCollation &collation);
uint decimals() const override { return is_created_from_null_item ? 0 : NOT_FIXED_DEC; }
uint decimals() const override { return is_created_from_null_item ? 0 : DECIMAL_NOT_SPECIFIED; }
int save_in_field(Field *to) override { return save_in_field_str(to); }
bool memcpy_field_possible(const Field *from) const override
{
......@@ -2267,7 +2267,7 @@ class Field_real :public Field_num {
Information_schema_numeric_attributes
information_schema_numeric_attributes() const override
{
return dec == NOT_FIXED_DEC ?
return dec == DECIMAL_NOT_SPECIFIED ?
Information_schema_numeric_attributes(field_length) :
Information_schema_numeric_attributes(field_length, dec);
}
......@@ -2836,6 +2836,8 @@ class Field_vers_trx_id :public Field_longlong {
integers. But in all other cases we treat it as TIME_RESULT! */
};
static inline uint8 fix_dec_arg(uint8 dec_arg)
{ return dec_arg >= FLOATING_POINT_DECIMALS ? DECIMAL_NOT_SPECIFIED : dec_arg; }
class Field_float final :public Field_real {
public:
......@@ -2845,19 +2847,13 @@ class Field_float final :public Field_real {
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
dec_arg, zero_arg, unsigned_arg)
{
if (dec_arg >= FLOATING_POINT_DECIMALS)
dec_arg= NOT_FIXED_DEC;
}
fix_dec_arg(dec_arg), zero_arg, unsigned_arg)
{ }
Field_float(uint32 len_arg, bool maybe_null_arg,
const LEX_CSTRING *field_name_arg, uint8 dec_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0,
NONE, field_name_arg, dec_arg, 0, 0)
{
if (dec_arg >= FLOATING_POINT_DECIMALS)
dec_arg= NOT_FIXED_DEC;
}
NONE, field_name_arg, fix_dec_arg(dec_arg), 0, 0)
{ }
const Type_handler *type_handler() const override
{ return &type_handler_float; }
enum ha_base_keytype key_type() const override { return HA_KEYTYPE_FLOAT; }
......@@ -2893,28 +2889,20 @@ class Field_double :public Field_real {
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
dec_arg, zero_arg, unsigned_arg)
{
if (dec_arg >= FLOATING_POINT_DECIMALS)
dec_arg= NOT_FIXED_DEC;
}
fix_dec_arg(dec_arg), zero_arg, unsigned_arg)
{ }
Field_double(uint32 len_arg, bool maybe_null_arg,
const LEX_CSTRING *field_name_arg, uint8 dec_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
NONE, field_name_arg, dec_arg, 0, 0)
{
if (dec_arg >= FLOATING_POINT_DECIMALS)
dec_arg= NOT_FIXED_DEC;
}
NONE, field_name_arg, fix_dec_arg(dec_arg), 0, 0)
{ }
Field_double(uint32 len_arg, bool maybe_null_arg,
const LEX_CSTRING *field_name_arg,
uint8 dec_arg, bool not_fixed_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
NONE, field_name_arg, dec_arg, 0, 0)
NONE, field_name_arg, fix_dec_arg(dec_arg), 0, 0)
{
not_fixed= not_fixed_arg;
if (dec_arg >= FLOATING_POINT_DECIMALS)
dec_arg= NOT_FIXED_DEC;
}
void init_for_tmp_table(Field *org_field, TABLE *new_table) override
{
......
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