[Commits] d23a7d5141c: MDEV-18015: Assertion `global_status_var.global_memory_used == 0' failed when using UDF , window functions and views
revision-id: d23a7d5141cdb3894c43c08bb9fcaf3c25d8365d (mariadb-10.2.19-73-gd23a7d5141c) parent(s): 5b0b73e9922f895cbae5c3ba48d1b65c45ed69bb author: Varun Gupta committer: Varun Gupta timestamp: 2018-12-19 03:42:16 +0530 message: MDEV-18015: Assertion `global_status_var.global_memory_used == 0' failed when using UDF , window functions and views Adding destructor for Group_bound_tracker to free Cached_item_str. The Cached_item for window functions are allocated on THD:mem_root but the Cached_item_str has value of type string which is allocated on the heap, so we need to call free() for it --- mysql-test/r/win.result | 27 +++++++++++++++++++++++++++ mysql-test/t/win.test | 16 ++++++++++++++++ sql/item_windowfunc.h | 12 ++++-------- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result index 2e80c2c961b..dc30e413ad4 100644 --- a/mysql-test/r/win.result +++ b/mysql-test/r/win.result @@ -3488,3 +3488,30 @@ ifnull(max(n1) over (partition by n1),'aaa') 4 drop table t1; drop view v1; +# +# MDEV-18015: Assertion `global_status_var.global_memory_used == 0' failed when using UDF, +# window functions and views +# +create table t1 (id int, n1 int); +insert into t1 values (1,1),(2,1),(3,2),(4,4); +explain +select max(n1) over (partition by 'abc') from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using temporary +select max(n1) over (partition by 'abc') from t1; +max(n1) over (partition by 'abc') +4 +4 +4 +4 +explain +select rank() over (partition by 'abc' order by 'xyz') from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using temporary +select rank() over (partition by 'abc' order by 'xyz') from t1; +rank() over (partition by 'abc' order by 'xyz') +1 +1 +1 +1 +drop table t1; diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test index 18bdfa31691..118ebb1e154 100644 --- a/mysql-test/t/win.test +++ b/mysql-test/t/win.test @@ -2240,3 +2240,19 @@ explain select * from v1; select * from v1; drop table t1; drop view v1; + +--echo # +--echo # MDEV-18015: Assertion `global_status_var.global_memory_used == 0' failed when using UDF, +--echo # window functions and views +--echo # + +create table t1 (id int, n1 int); +insert into t1 values (1,1),(2,1),(3,2),(4,4); +explain +select max(n1) over (partition by 'abc') from t1; +select max(n1) over (partition by 'abc') from t1; + +explain +select rank() over (partition by 'abc' order by 'xyz') from t1; +select rank() over (partition by 'abc' order by 'xyz') from t1; +drop table t1; diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h index 21270733051..b9df1b7482b 100644 --- a/sql/item_windowfunc.h +++ b/sql/item_windowfunc.h @@ -28,11 +28,6 @@ class Group_bound_tracker first_check= true; } - void cleanup() - { - group_fields.empty(); - } - /* Check if the current row is in a different group than the previous row this function was called for. @@ -70,6 +65,10 @@ class Group_bound_tracker } return 0; } + ~Group_bound_tracker() + { + group_fields.delete_elements(); + } private: List<Cached_item> group_fields; @@ -199,7 +198,6 @@ class Item_sum_rank: public Item_sum_int { if (peer_tracker) { - peer_tracker->cleanup(); delete peer_tracker; peer_tracker= NULL; } @@ -269,7 +267,6 @@ class Item_sum_dense_rank: public Item_sum_int { if (peer_tracker) { - peer_tracker->cleanup(); delete peer_tracker; peer_tracker= NULL; } @@ -537,7 +534,6 @@ class Item_sum_percent_rank: public Item_sum_window_with_row_count { if (peer_tracker) { - peer_tracker->cleanup(); delete peer_tracker; peer_tracker= NULL; }
participants (1)
-
Varun