[Commits] aec4aa7a04b: MDEV-12059: Assertion `precision > 0' failed with a window function or window aggregate function
revision-id: aec4aa7a04bc84d361124f3c9feab4cdce572310 (mariadb-10.2.31-294-gaec4aa7a04b) parent(s): fbfb5b5f68a428ec819bc09d14b30cebf660b37b author: Varun Gupta committer: Varun Gupta timestamp: 2020-07-02 02:28:30 +0530 message: MDEV-12059: Assertion `precision > 0' failed with a window function or window aggregate function Pass the unsigned flag from the Item_sum to the window function --- mysql-test/r/win.result | 10 ++++++++++ mysql-test/t/win.test | 9 +++++++++ sql/item_windowfunc.cc | 1 + 3 files changed, 20 insertions(+) diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result index 9c85315b7c1..71953871295 100644 --- a/mysql-test/r/win.result +++ b/mysql-test/r/win.result @@ -3798,5 +3798,15 @@ SELECT FIRST_VALUE(MAX(a) OVER (PARTITION BY a)) OVER (ORDER BY a) AS x FROM t1 ERROR HY000: Window functions can not be used as arguments to group functions. DROP TABLE t1; # +# MDEV-12059: Assertion `precision > 0' failed with a window function or window aggregate function +# +CREATE TABLE t1 (d DECIMAL(1,0) UNSIGNED); +INSERT INTO t1 VALUES (1),(2); +SELECT MIN(d) OVER () FROM t1; +MIN(d) OVER () +1 +1 +DROP TABLE t1; +# # End of 10.2 tests # diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test index d19ff2c624d..a768b893432 100644 --- a/mysql-test/t/win.test +++ b/mysql-test/t/win.test @@ -2472,6 +2472,15 @@ SELECT NTILE(MAX(a) OVER (PARTITION BY a)) OVER (PARTITION BY a ORDER BY b) FROM SELECT FIRST_VALUE(MAX(a) OVER (PARTITION BY a)) OVER (ORDER BY a) AS x FROM t1 GROUP BY a; DROP TABLE t1; +--echo # +--echo # MDEV-12059: Assertion `precision > 0' failed with a window function or window aggregate function +--echo # + +CREATE TABLE t1 (d DECIMAL(1,0) UNSIGNED); +INSERT INTO t1 VALUES (1),(2); +SELECT MIN(d) OVER () FROM t1; +DROP TABLE t1; + --echo # --echo # End of 10.2 tests --echo # diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc index a3edacd880e..40116647b4d 100644 --- a/sql/item_windowfunc.cc +++ b/sql/item_windowfunc.cc @@ -111,6 +111,7 @@ Item_window_func::fix_fields(THD *thd, Item **ref) max_length= window_func()->max_length; maybe_null= window_func()->maybe_null; + unsigned_flag= window_func()->unsigned_flag; fixed= 1; set_phase_to_initial();
participants (1)
-
Varun