summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.h
diff options
context:
space:
mode:
authorSeppo Jaakola <seppo.jaakola@codership.com>2013-12-04 10:32:43 +0200
committerSeppo Jaakola <seppo.jaakola@codership.com>2013-12-04 10:32:43 +0200
commit496e22cf3bd2a481fd3502d86e5a4e8228bf9823 (patch)
tree80549f8005fcf3236bfa004a5aea35e4e67b36ca /sql/item_timefunc.h
parent45f484b8381a5923aec9c704e54c7f7bcfa02a40 (diff)
parent26f56089c734852dc31d98fd73e1d8f1750bd1a8 (diff)
downloadmariadb-git-496e22cf3bd2a481fd3502d86e5a4e8228bf9823.tar.gz
merge with MariaDB 5.6 bzr merge lp:maria --rtag:mariadb-10.0.6
and a number of fixes to make this buildable. Run also few short multi-master high conflict rate tests, with no issues
Diffstat (limited to 'sql/item_timefunc.h')
-rw-r--r--sql/item_timefunc.h88
1 files changed, 52 insertions, 36 deletions
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 029e3b17cf1..99c41961aba 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -30,19 +30,17 @@ enum date_time_format_types
TIME_ONLY= 0, TIME_MICROSECOND, DATE_ONLY, DATE_TIME, DATE_TIME_MICROSECOND
};
-static inline enum enum_mysql_timestamp_type
-mysql_type_to_time_type(enum enum_field_types mysql_type)
+
+static inline uint
+mysql_temporal_int_part_length(enum enum_field_types mysql_type)
{
- switch(mysql_type) {
- case MYSQL_TYPE_TIME: return MYSQL_TIMESTAMP_TIME;
- case MYSQL_TYPE_TIMESTAMP:
- case MYSQL_TYPE_DATETIME: return MYSQL_TIMESTAMP_DATETIME;
- case MYSQL_TYPE_NEWDATE:
- case MYSQL_TYPE_DATE: return MYSQL_TIMESTAMP_DATE;
- default: return MYSQL_TIMESTAMP_ERROR;
- }
+ static uint max_time_type_width[5]=
+ { MAX_DATETIME_WIDTH, MAX_DATETIME_WIDTH, MAX_DATE_WIDTH,
+ MAX_DATETIME_WIDTH, MIN_TIME_WIDTH };
+ return max_time_type_width[mysql_type_to_time_type(mysql_type)+2];
}
+
bool get_interval_value(Item *args,interval_type int_type, INTERVAL *interval);
class Item_func_period_add :public Item_int_func
@@ -82,7 +80,7 @@ public:
{
decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
- set_persist_maybe_null(1);
+ maybe_null=1;
}
enum_monotonicity_info get_monotonicity_info() const;
longlong val_int_endpoint(bool left_endp, bool *incl_endp);
@@ -105,7 +103,7 @@ public:
{
decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
- set_persist_maybe_null(1);
+ maybe_null= 1;
}
enum_monotonicity_info get_monotonicity_info() const;
longlong val_int_endpoint(bool left_endp, bool *incl_endp);
@@ -138,7 +136,7 @@ public:
{
decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
- set_persist_maybe_null(1);
+ maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@@ -170,7 +168,7 @@ public:
{
decimals= 0;
fix_char_length(2);
- set_persist_maybe_null(1);
+ maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@@ -208,7 +206,7 @@ public:
{
decimals= 0;
fix_char_length(3);
- set_persist_maybe_null(1);
+ maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@@ -229,7 +227,7 @@ public:
{
decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
- set_persist_maybe_null(1);
+ maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@@ -250,7 +248,7 @@ public:
{
decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
- set_persist_maybe_null(1);
+ maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@@ -271,7 +269,7 @@ public:
{
decimals=0;
max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
- set_persist_maybe_null(1);
+ maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@@ -292,7 +290,7 @@ public:
{
decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
- set_persist_maybe_null(1);
+ maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@@ -313,7 +311,7 @@ public:
{
decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
- set_persist_maybe_null(1);
+ maybe_null=1;
}
};
@@ -327,7 +325,7 @@ public:
{
decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
- set_persist_maybe_null(1);
+ maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@@ -350,7 +348,7 @@ public:
{
decimals=0;
max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
- set_persist_maybe_null(1);
+ maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@@ -384,7 +382,7 @@ public:
{
decimals= 0;
fix_char_length(1);
- set_persist_maybe_null(1);
+ maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@@ -410,26 +408,32 @@ class Item_func_dayname :public Item_func_weekday
class Item_func_seconds_hybrid: public Item_func_numhybrid
{
+protected:
+ virtual enum_field_types arg0_expected_type() const = 0;
public:
Item_func_seconds_hybrid() :Item_func_numhybrid() {}
Item_func_seconds_hybrid(Item *a) :Item_func_numhybrid(a) {}
void fix_num_length_and_dec()
{
if (arg_count)
- decimals= args[0]->decimals;
+ decimals= args[0]->temporal_precision(arg0_expected_type());
set_if_smaller(decimals, TIME_SECOND_PART_DIGITS);
max_length=17 + (decimals ? decimals + 1 : 0);
- set_persist_maybe_null(1);
+ maybe_null= true;
}
- void find_num_type() { hybrid_type= decimals ? DECIMAL_RESULT : INT_RESULT; }
+ void find_num_type()
+ { cached_result_type= decimals ? DECIMAL_RESULT : INT_RESULT; }
double real_op() { DBUG_ASSERT(0); return 0; }
String *str_op(String *str) { DBUG_ASSERT(0); return 0; }
+ bool date_op(MYSQL_TIME *ltime, uint fuzzydate) { DBUG_ASSERT(0); return true; }
};
class Item_func_unix_timestamp :public Item_func_seconds_hybrid
{
bool get_timestamp_value(my_time_t *seconds, ulong *second_part);
+protected:
+ enum_field_types arg0_expected_type() const { return MYSQL_TYPE_DATETIME; }
public:
Item_func_unix_timestamp() :Item_func_seconds_hybrid() {}
Item_func_unix_timestamp(Item *a) :Item_func_seconds_hybrid(a) {}
@@ -461,12 +465,14 @@ public:
class Item_func_time_to_sec :public Item_func_seconds_hybrid
{
+protected:
+ enum_field_types arg0_expected_type() const { return MYSQL_TYPE_TIME; }
public:
Item_func_time_to_sec(Item *item) :Item_func_seconds_hybrid(item) {}
const char *func_name() const { return "time_to_sec"; }
void fix_num_length_and_dec()
{
- set_persist_maybe_null(1);
+ maybe_null= true;
Item_func_seconds_hybrid::fix_num_length_and_dec();
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
@@ -576,7 +582,7 @@ public:
{
store_now_in_TIME(&ltime);
Item_timefunc::fix_length_and_dec();
- set_persist_maybe_null(0);
+ maybe_null= false;
}
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
/*
@@ -658,7 +664,7 @@ public:
{
store_now_in_TIME(&ltime);
Item_temporal_func::fix_length_and_dec();
- set_persist_maybe_null(0);
+ maybe_null= false;
}
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0;
@@ -703,7 +709,7 @@ public:
void update_used_tables()
{
Item_func_now::update_used_tables();
- set_persist_maybe_null(0);
+ maybe_null= 0;
used_tables_cache|= RAND_TABLE_BIT;
}
};
@@ -896,7 +902,7 @@ public:
void fix_length_and_dec()
{
if (decimals == NOT_FIXED_DEC)
- decimals= args[0]->decimals;
+ decimals= args[0]->temporal_precision(field_type());
Item_temporal_func::fix_length_and_dec();
}
};
@@ -968,7 +974,8 @@ public:
const char *func_name() const { return "timediff"; }
void fix_length_and_dec()
{
- decimals= MY_MAX(args[0]->decimals, args[1]->decimals);
+ decimals= MY_MAX(args[0]->temporal_precision(MYSQL_TYPE_TIME),
+ args[1]->temporal_precision(MYSQL_TYPE_TIME));
Item_timefunc::fix_length_and_dec();
}
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
@@ -980,6 +987,11 @@ public:
Item_func_maketime(Item *a, Item *b, Item *c)
:Item_timefunc(a, b, c)
{}
+ void fix_length_and_dec()
+ {
+ decimals= MY_MIN(args[2]->decimals, TIME_SECOND_PART_DIGITS);
+ Item_timefunc::fix_length_and_dec();
+ }
const char *func_name() const { return "maketime"; }
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
};
@@ -994,7 +1006,7 @@ public:
void fix_length_and_dec()
{
decimals=0;
- set_persist_maybe_null(1);
+ maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *int_arg) { return FALSE;}
@@ -1016,7 +1028,7 @@ public:
void fix_length_and_dec()
{
decimals=0;
- set_persist_maybe_null(1);
+ maybe_null=1;
}
virtual void print(String *str, enum_query_type query_type);
};
@@ -1038,7 +1050,7 @@ public:
const char *func_name() const { return "get_format"; }
void fix_length_and_dec()
{
- set_persist_maybe_null(1);
+ maybe_null= 1;
decimals=0;
fix_length_and_charset(17, default_charset());
}
@@ -1050,9 +1062,13 @@ class Item_func_str_to_date :public Item_temporal_hybrid_func
{
timestamp_type cached_timestamp_type;
bool const_item;
+ String subject_converter;
+ String format_converter;
+ CHARSET_INFO *internal_charset;
public:
Item_func_str_to_date(Item *a, Item *b)
- :Item_temporal_hybrid_func(a, b), const_item(false)
+ :Item_temporal_hybrid_func(a, b), const_item(false),
+ internal_charset(NULL)
{}
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
const char *func_name() const { return "str_to_date"; }