summaryrefslogtreecommitdiff
path: root/sql/item_func.h
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-08-27 12:24:32 +0300
committerSergei Golubchik <serg@mariadb.org>2021-05-19 22:27:27 +0200
commitfa7d4abf164b37d0f98012ff7e906ebe7de8f1ed (patch)
treee351694a4b538ddf42f988d1d1df8f3ff1e3762d /sql/item_func.h
parentaee84453ab6befef296afdf8e66a8e295b624c72 (diff)
downloadmariadb-git-fa7d4abf164b37d0f98012ff7e906ebe7de8f1ed.tar.gz
Added typedef decimal_digits_t (uint16) for number of digits in most
aspects of decimals and integers For fields and Item's uint8 should be good enough. After discussions with Alexander Barkov we choose uint16 (for now) as some format functions may accept +256 digits. The reason for this patch was to make the usage and storage of decimal digits simlar. Before this patch decimals was stored/used as uint8, int and uint. The lengths for numbers where also using a lot of different types. Changed most decimal variables and functions to use the new typedef. squash! af7f09106b6c1dc20ae8c480bff6fd22d266b184 Use decimal_digits_t for all aspects of digits (total, precision and scale), both for decimals and integers.
Diffstat (limited to 'sql/item_func.h')
-rw-r--r--sql/item_func.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/sql/item_func.h b/sql/item_func.h
index e774d9c53bd..1e4788b1ff2 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1341,7 +1341,8 @@ public:
return args[0]->type_handler()->Item_func_signed_fix_length_and_dec(this);
}
virtual void print(String *str, enum_query_type query_type);
- uint decimal_precision() const { return args[0]->decimal_precision(); }
+ decimal_digits_t decimal_precision() const override
+ { return args[0]->decimal_precision(); }
bool need_parentheses_in_default() { return true; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_signed>(thd, this); }
@@ -1372,7 +1373,7 @@ public:
{
return args[0]->type_handler()->Item_func_unsigned_fix_length_and_dec(this);
}
- uint decimal_precision() const { return max_length; }
+ decimal_digits_t decimal_precision() const override { return max_length; }
virtual void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_unsigned>(thd, this); }
@@ -1383,10 +1384,10 @@ class Item_decimal_typecast :public Item_func
{
my_decimal decimal_value;
public:
- Item_decimal_typecast(THD *thd, Item *a, uint len, uint dec)
+ Item_decimal_typecast(THD *thd, Item *a, uint len, decimal_digits_t dec)
:Item_func(thd, a)
{
- decimals= (uint8) dec;
+ decimals= dec;
collation= DTCollation_numeric();
fix_char_length(my_decimal_precision_to_length_no_truncation(len, dec,
unsigned_flag));
@@ -1656,7 +1657,8 @@ public:
void fix_length_and_dec_double();
void fix_length_and_dec_decimal();
bool fix_length_and_dec();
- uint decimal_precision() const { return args[0]->decimal_precision(); }
+ decimal_digits_t decimal_precision() const override
+ { return args[0]->decimal_precision(); }
bool need_parentheses_in_default() { return true; }
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_neg>(thd, this); }
@@ -1990,7 +1992,7 @@ class Item_func_sign :public Item_long_func
public:
Item_func_sign(THD *thd, Item *a): Item_long_func(thd, a) {}
const char *func_name() const { return "sign"; }
- uint decimal_precision() const { return 1; }
+ decimal_digits_t decimal_precision() const override { return 1; }
bool fix_length_and_dec() { fix_char_length(2); return FALSE; }
longlong val_int();
Item *get_copy(THD *thd)