summaryrefslogtreecommitdiff
path: root/sql/field.h
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-03-08 19:41:58 +0100
committerSergei Golubchik <sergii@pisem.net>2011-03-08 19:41:58 +0100
commit8b7fd8f577fe3edc84eea54288c7d30775a1559b (patch)
tree6d245df86f99894d74eea055dc01800ccc2d7bb4 /sql/field.h
parent2c80662d231414eb98b5cd4cede069d1482ccc20 (diff)
downloadmariadb-git-8b7fd8f577fe3edc84eea54288c7d30775a1559b.tar.gz
lp:731124 Loss of precision on DISTINCT
many changes: * NOT_FIXED_DEC now create hires fields, not old ones. As a result, temp tables preserve microseconds (on DISTINCT, GROUP BY) * I_S tables force decimals=0 on temporal types (backward compatibility) * Item_func_coalesce calculates decimals for temporal types * no precision for TIME/DATETIME in CAST means 0, not NOT_FIXED_DEC * addtime/timediff calculate decimals from arguments (not NOT_FIXED_DEC) sql/field.h: NOT_FIXED_DEC now create hires fields, not old ones sql/item.h: force decimals=0 for I_S tables sql/item_cmpfunc.cc: Item_func_coalesce calculates decimals for temporal types sql/item_create.cc: no precision for TIME/DATETIME in CAST means 0, not NOT_FIXED_DEC sql/item_timefunc.cc: addtime calculates decimals from arguments (not NOT_FIXED_DEC) sql/item_timefunc.h: timediff calculates decimals from arguments (not NOT_FIXED_DEC)
Diffstat (limited to 'sql/field.h')
-rw-r--r--sql/field.h27
1 files changed, 15 insertions, 12 deletions
diff --git a/sql/field.h b/sql/field.h
index 9475e28bc0f..c955981531a 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1501,12 +1501,13 @@ new_Field_timestamp(uchar *ptr, uchar *null_ptr, uchar null_bit,
enum Field::utype unireg_check, const char *field_name,
TABLE_SHARE *share, uint dec, CHARSET_INFO *cs)
{
- if (dec==0 || dec == NOT_FIXED_DEC)
+ if (dec==0)
return new Field_timestamp(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit,
unireg_check, field_name, share, cs);
- else
- return new Field_timestamp_hires(ptr, null_ptr, null_bit, unireg_check,
- field_name, share, dec, cs);
+ if (dec == NOT_FIXED_DEC)
+ dec= MAX_DATETIME_PRECISION;
+ return new Field_timestamp_hires(ptr, null_ptr, null_bit, unireg_check,
+ field_name, share, dec, cs);
}
static inline Field_time *
@@ -1514,12 +1515,13 @@ new_Field_time(uchar *ptr, uchar *null_ptr, uchar null_bit,
enum Field::utype unireg_check, const char *field_name,
uint dec, CHARSET_INFO *cs)
{
- if (dec == 0 || dec == NOT_FIXED_DEC)
+ if (dec == 0)
return new Field_time(ptr, MIN_TIME_WIDTH, null_ptr, null_bit,
unireg_check, field_name, cs);
- else
- return new Field_time_hires(ptr, null_ptr, null_bit,
- unireg_check, field_name, dec, cs);
+ if (dec == NOT_FIXED_DEC)
+ dec= MAX_DATETIME_PRECISION;
+ return new Field_time_hires(ptr, null_ptr, null_bit,
+ unireg_check, field_name, dec, cs);
}
static inline Field_datetime *
@@ -1527,12 +1529,13 @@ new_Field_datetime(uchar *ptr, uchar *null_ptr, uchar null_bit,
enum Field::utype unireg_check,
const char *field_name, uint dec, CHARSET_INFO *cs)
{
- if (dec == 0 || dec == NOT_FIXED_DEC)
+ if (dec == 0)
return new Field_datetime(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit,
unireg_check, field_name, cs);
- else
- return new Field_datetime_hires(ptr, null_ptr, null_bit,
- unireg_check, field_name, dec, cs);
+ if (dec == NOT_FIXED_DEC)
+ dec= MAX_DATETIME_PRECISION;
+ return new Field_datetime_hires(ptr, null_ptr, null_bit,
+ unireg_check, field_name, dec, cs);
}
class Field_string :public Field_longstr {