summaryrefslogtreecommitdiff
path: root/sql/item.h
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-03-29 11:33:20 +0100
committerSergei Golubchik <sergii@pisem.net>2014-03-29 11:33:20 +0100
commit73f48615754833e637ba05d2a0d92a0ea5c2d5cf (patch)
tree9642317ac9f2a0aa73175a2f6ccacd9ae82b7eea /sql/item.h
parentb37157e49e7cef7a5f70f4269678ad0c44863d69 (diff)
downloadmariadb-git-73f48615754833e637ba05d2a0d92a0ea5c2d5cf.tar.gz
MDEV-5969 Crash in prepared statement with NO_ZERO_IN_DATE and ROLLUP
MDEV-5971 Asymmetry between CAST(DATE'2001-00-00') to INT and TO CHAR in prepared statements Consistently set maybe_null flag, even not-NULL temporal literal may become NULL in the restrictive sql_mode.
Diffstat (limited to 'sql/item.h')
-rw-r--r--sql/item.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/sql/item.h b/sql/item.h
index ba7631daeb4..29e727b8d5f 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -971,6 +971,11 @@ public:
double val_real_from_decimal();
double val_real_from_date();
+ // Get TIME, DATE or DATETIME using proper sql_mode flags for the field type
+ bool get_temporal_with_sql_mode(MYSQL_TIME *ltime);
+ // Check NULL value for a TIME, DATE or DATETIME expression
+ bool is_null_from_temporal();
+
int save_time_in_field(Field *field);
int save_date_in_field(Field *field);
int save_str_value_in_field(Field *field, String *result);
@@ -2933,6 +2938,9 @@ public:
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
+ bool is_null()
+ { return is_null_from_temporal(); }
+ bool get_date_with_sql_mode(MYSQL_TIME *to);
String *val_str(String *str)
{ return val_string_from_date(str); }
longlong val_int()
@@ -2959,6 +2967,14 @@ public:
{
max_length= MAX_DATE_WIDTH;
fixed= 1;
+ /*
+ If date has zero month or day, it can return NULL in case of
+ NO_ZERO_DATE or NO_ZERO_IN_DATE.
+ We can't just check the current sql_mode here in constructor,
+ because sql_mode can change in case of prepared statements
+ between PREPARE and EXECUTE.
+ */
+ maybe_null= !ltime->month || !ltime->day;
}
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
void print(String *str, enum_query_type query_type);
@@ -2995,6 +3011,8 @@ public:
{
max_length= MAX_DATETIME_WIDTH + (decimals ? decimals + 1 : 0);
fixed= 1;
+ // See the comment on maybe_null in Item_date_literal
+ maybe_null= !ltime->month || !ltime->day;
}
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
void print(String *str, enum_query_type query_type);