summaryrefslogtreecommitdiff
path: root/sql/item.h
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-08-07 18:06:56 +0200
committerSergei Golubchik <sergii@pisem.net>2014-08-07 18:06:56 +0200
commit6fb17a06016506498f4de75ff754f500f9f674f1 (patch)
treed03c86959f150edc0f6f27ca2c06ccbc0e6e5bf0 /sql/item.h
parent2023fac28130d7d3f7d6776332239c62c3890195 (diff)
parenta4ab2431a20f6e2198d980f8e84fa7118515ca3b (diff)
downloadmariadb-git-6fb17a06016506498f4de75ff754f500f9f674f1.tar.gz
5.5.39 merge
Diffstat (limited to 'sql/item.h')
-rw-r--r--sql/item.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/sql/item.h b/sql/item.h
index 29e727b8d5f..00c1468bb48 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1034,9 +1034,47 @@ public:
virtual cond_result eq_cmp_result() const { return COND_OK; }
inline uint float_length(uint decimals_par) const
{ return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;}
+ /* Returns total number of decimal digits */
virtual uint decimal_precision() const;
+ /* Returns the number of integer part digits only */
inline int decimal_int_part() const
{ return my_decimal_int_part(decimal_precision(), decimals); }
+ /*
+ Returns the number of fractional digits only.
+ NOT_FIXED_DEC is replaced to the maximum possible number
+ of fractional digits, taking into account the data type.
+ */
+ uint decimal_scale() const
+ {
+ return decimals < NOT_FIXED_DEC ? decimals :
+ is_temporal_type_with_time(field_type()) ?
+ TIME_SECOND_PART_DIGITS :
+ MY_MIN(max_length, DECIMAL_MAX_SCALE);
+ }
+ /*
+ Returns how many digits a divisor adds into a division result.
+ This is important when the integer part of the divisor can be 0.
+ In this example:
+ SELECT 1 / 0.000001; -> 1000000.0000
+ the divisor adds 5 digits into the result precision.
+
+ Currently this method only replaces NOT_FIXED_DEC to
+ TIME_SECOND_PART_DIGITS for temporal data types.
+ This method can be made virtual, to create more efficient (smaller)
+ data types for division results.
+ For example, in
+ SELECT 1/1.000001;
+ the divisor could provide no additional precision into the result,
+ so could any other items that are know to return a result
+ with non-zero integer part.
+ */
+ uint divisor_precision_increment() const
+ {
+ return decimals < NOT_FIXED_DEC ? decimals :
+ is_temporal_type_with_time(field_type()) ?
+ TIME_SECOND_PART_DIGITS :
+ decimals;
+ }
/**
TIME or DATETIME precision of the item: 0..6
*/