revision-id: 0e4a9337719479bffb141b52ab9535dd88fbf607 (mariadb-10.2.31-317-g0e4a9337719) parent(s): a1e52e7f32cee7c204078db4c4beb88250d7e1f6 author: Varun Gupta committer: Varun Gupta timestamp: 2020-07-20 15:50:17 +0530 message: MDEV-18916: crash in Window_spec::print_partition() with decimals Removed an unnecessary ifndef which was printing the window name for a named window only in the case of debug build. The print() for the window function should behave in the same way on both release and debug builds. --- mysql-test/r/win.result | 7 +++++++ mysql-test/t/win.test | 9 +++++++++ sql/item_windowfunc.cc | 6 ++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result index 019cfd6115d..081aaedd323 100644 --- a/mysql-test/r/win.result +++ b/mysql-test/r/win.result @@ -3843,5 +3843,12 @@ ROW_NUMBER() OVER w2 5 DROP TABLE t1; # +# MDEV-18916: crash in Window_spec::print_partition() with decimals +# +SELECT cast((rank() over w1) as decimal (53,56)); +ERROR 42000: Too big scale 56 specified for 'rank() over w1'. Maximum is 38 +SELECT cast((rank() over w1) as decimal (53,30)); +ERROR HY000: Window specification with name 'w1' is not defined +# # End of 10.2 tests # diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test index deed7de2d23..b749b235082 100644 --- a/mysql-test/t/win.test +++ b/mysql-test/t/win.test @@ -2497,6 +2497,15 @@ SELECT a,b FROM t1 WINDOW w2 AS (PARTITION BY -1,1,0,2,3,4); SELECT ROW_NUMBER() OVER w2 FROM t1 WINDOW w2 AS (PARTITION BY -1,0,1,2,3,4,5,6); DROP TABLE t1; +--echo # +--echo # MDEV-18916: crash in Window_spec::print_partition() with decimals +--echo # + +--error ER_TOO_BIG_SCALE +SELECT cast((rank() over w1) as decimal (53,56)); +--error ER_WRONG_WINDOW_SPEC_NAME +SELECT cast((rank() over w1) as decimal (53,30)); + --echo # --echo # End of 10.2 tests --echo # diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc index a3edacd880e..87dddbfb439 100644 --- a/sql/item_windowfunc.cc +++ b/sql/item_windowfunc.cc @@ -443,10 +443,8 @@ void Item_window_func::print(String *str, enum_query_type query_type) { window_func()->print(str, query_type); str->append(" over "); -#ifndef DBUG_OFF - if (!window_spec) // one can call dbug_print_item() anytime in gdb + if (!window_spec) str->append(window_name); else -#endif - window_spec->print(str, query_type); + window_spec->print(str, query_type); }