summaryrefslogtreecommitdiff
path: root/sql/item_windowfunc.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-07-04 14:14:30 +0400
committerAlexander Barkov <bar@mariadb.org>2017-07-04 14:14:30 +0400
commit25ad623d64ebc34093544875e5b0ebd6101e975b (patch)
treeee4fb7047a003b0a8c292af0b91e3ef37b870477 /sql/item_windowfunc.h
parent760127ac6ff428d4538733b3f99b743f7a802581 (diff)
downloadmariadb-git-25ad623d64ebc34093544875e5b0ebd6101e975b.tar.gz
MDEV-13240 Wrong warning with MAX(datetime_field) OVER (...)
The problem resided in Item_window_func implementation, and it was revealed by bb-10.2-ext specific changes: Item_window_func::save_in_field() works differently in bb-10.2-ext vs 10.2: - 10.2 goes through val_str() - bb-10.2-ext goes through get_date(), due to Type_handler related changes. get_date() tries to convert empty string to DATETIME, hence the warning. During a discussion with Vicentiu, it was decided to fix Item_window_func::val_xxx() to return NULL (instead of an "empty" value, such as 0 for numbers and '' for strings) when force_return_blank is set.
Diffstat (limited to 'sql/item_windowfunc.h')
-rw-r--r--sql/item_windowfunc.h25
1 files changed, 17 insertions, 8 deletions
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h
index 77cbd556e60..9fe95ed6cee 100644
--- a/sql/item_windowfunc.h
+++ b/sql/item_windowfunc.h
@@ -839,13 +839,24 @@ public:
read_value_from_result_field= true;
}
+ bool is_null()
+ {
+ if (force_return_blank)
+ return true;
+
+ if (read_value_from_result_field)
+ return result_field->is_null();
+
+ return window_func()->is_null();
+ }
+
double val_real()
{
double res;
if (force_return_blank)
{
res= 0.0;
- null_value= false;
+ null_value= true;
}
else if (read_value_from_result_field)
{
@@ -866,7 +877,7 @@ public:
if (force_return_blank)
{
res= 0;
- null_value= false;
+ null_value= true;
}
else if (read_value_from_result_field)
{
@@ -886,9 +897,8 @@ public:
String *res;
if (force_return_blank)
{
- null_value= false;
- str->length(0);
- res= str;
+ null_value= true;
+ res= NULL;
}
else if (read_value_from_result_field)
{
@@ -910,9 +920,8 @@ public:
my_decimal *res;
if (force_return_blank)
{
- my_decimal_set_zero(dec);
- null_value= false;
- res= dec;
+ null_value= true;
+ res= NULL;
}
else if (read_value_from_result_field)
{