maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #10784
Fwd: ecbad0a07a8: MDEV-13189: Window functions crash when using INTERVAL
Hi Sergey,
Can you please review this change that makes window functions work with
INTERVAL function?
Thanks,
Vicentiu
---------- Forwarded message ---------
From: vicentiu <vicentiu@xxxxxxxxxxx>
Date: Wed, 28 Jun 2017 at 21:08
Subject: ecbad0a07a8: MDEV-13189: Window functions crash when using INTERVAL
To: <commits@xxxxxxxxxxx>
revision-id: ecbad0a07a848c1f9f474c4c749c87b6bfe7986c
(mariadb-10.2.6-74-gecbad0a07a8)
parent(s): 31ba0fa48d27715e82258b1e74401093e0ee17a2
author: Vicențiu Ciorbaru
committer: Vicențiu Ciorbaru
timestamp: 2017-06-28 21:07:55 +0300
message:
MDEV-13189: Window functions crash when using INTERVAL
Interval function makes use of Item_row. Item_row did not correctly mark
with_window_func flag according to its arguments. Fix it by making
Item_row aware of this flag.
---
mysql-test/r/win.result | 14 ++++++++++++++
mysql-test/t/win.test | 9 +++++++++
sql/item_row.cc | 1 +
3 files changed, 24 insertions(+)
diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result
index 952bd82ac7f..7f8777ed491 100644
--- a/mysql-test/r/win.result
+++ b/mysql-test/r/win.result
@@ -3127,3 +3127,17 @@ NULL 1 0
1 0 1
2 0 1
drop table t1;
+#
+# MDEV-13189: Window functions crash when using INTERVAL function
+#
+create table t1(i int);
+insert into t1 values (1),(2),(10),(20),(30);
+select sum(i) over (order by i), interval(sum(i) over (order by i), 10, 20)
+from t1;
+sum(i) over (order by i) interval(sum(i) over (order by i), 10, 20)
+1 0
+3 0
+13 1
+33 2
+63 2
+drop table t1;
diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test
index 45653b18682..aff717e3151 100644
--- a/mysql-test/t/win.test
+++ b/mysql-test/t/win.test
@@ -1914,3 +1914,12 @@ select max(i) over (order by i),
max(i) over (order by i) is not null
from t1;
drop table t1;
+
+--echo #
+--echo # MDEV-13189: Window functions crash when using INTERVAL function
+--echo #
+create table t1(i int);
+insert into t1 values (1),(2),(10),(20),(30);
+select sum(i) over (order by i), interval(sum(i) over (order by i), 10, 20)
+from t1;
+drop table t1;
diff --git a/sql/item_row.cc b/sql/item_row.cc
index ddbb0736d54..fc484f560ee 100644
--- a/sql/item_row.cc
+++ b/sql/item_row.cc
@@ -63,6 +63,7 @@ bool Item_row::fix_fields(THD *thd, Item **ref)
}
maybe_null|= item->maybe_null;
with_sum_func= with_sum_func || item->with_sum_func;
+ with_window_func = with_window_func || item->with_window_func;
with_field= with_field || item->with_field;
with_subselect|= item->with_subselect;
}