summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/main/fetch_first.result10
-rw-r--r--mysql-test/main/fetch_first.test10
-rw-r--r--sql/sql_select.cc1
3 files changed, 21 insertions, 0 deletions
diff --git a/mysql-test/main/fetch_first.result b/mysql-test/main/fetch_first.result
index 7bb89633081..69a0336d722 100644
--- a/mysql-test/main/fetch_first.result
+++ b/mysql-test/main/fetch_first.result
@@ -1368,3 +1368,13 @@ f
1
1
drop table t1;
+#
+# MDEV-25481: Memory leak upon query WITH TIES involving a blob
+#
+CREATE TABLE t (a TEXT);
+INSERT INTO t VALUES ('foo'),('bar');
+SELECT a FROM t ORDER BY a FETCH FIRST 2 ROWS WITH TIES;
+a
+bar
+foo
+DROP TABLE t;
diff --git a/mysql-test/main/fetch_first.test b/mysql-test/main/fetch_first.test
index 3fdd6c56968..8a5cb2c8e73 100644
--- a/mysql-test/main/fetch_first.test
+++ b/mysql-test/main/fetch_first.test
@@ -1046,3 +1046,13 @@ SELECT SQL_BUFFER_RESULT 1 AS f FROM t1 ORDER BY f FETCH NEXT 2 ROW WITH TIES;
SELECT 1 AS f FROM t1 ORDER BY f FETCH NEXT 2 ROW WITH TIES;
drop table t1;
+
+--echo #
+--echo # MDEV-25481: Memory leak upon query WITH TIES involving a blob
+--echo #
+CREATE TABLE t (a TEXT);
+INSERT INTO t VALUES ('foo'),('bar');
+SELECT a FROM t ORDER BY a FETCH FIRST 2 ROWS WITH TIES;
+
+# Cleanup
+DROP TABLE t;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7baa4b49890..50a42ff8410 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -14231,6 +14231,7 @@ void JOIN::cleanup(bool full)
// Run Cached_item DTORs!
group_fields.delete_elements();
+ order_fields.delete_elements();
/*
We can't call delete_elements() on copy_funcs as this will cause