diff options
author | Georgi Kodinov <joro@sun.com> | 2010-02-02 18:30:23 +0200 |
---|---|---|
committer | Georgi Kodinov <joro@sun.com> | 2010-02-02 18:30:23 +0200 |
commit | a89d88dc0a5db71cb1c748e5fc7b6a570cc5c2ee (patch) | |
tree | 159635daf9a83916fb176f01af74509ae06e852e /sql/sql_select.h | |
parent | 8c65b726a5edd69eb9aee0ea903b2ce2c92ba961 (diff) | |
download | mariadb-git-a89d88dc0a5db71cb1c748e5fc7b6a570cc5c2ee.tar.gz |
Bug #45989 take 2 : memory leak after explain encounters an
error in the query.
Fixes a leak after materializing a GROUP BY subquery to a
temp table when the subquery has a blob column in the SELECT
list.
Fixed by correctly destructing temporary buffers for re-usable
queries
Diffstat (limited to 'sql/sql_select.h')
-rw-r--r-- | sql/sql_select.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h index dd99d358bac..bfff0a0ffa2 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -354,7 +354,25 @@ public: */ bool no_const_tables; - JOIN *tmp_join; ///< copy of this JOIN to be used with temporary tables + /** + Copy of this JOIN to be used with temporary tables. + + tmp_join is used when the JOIN needs to be "reusable" (e.g. in a subquery + that gets re-executed several times) and we know will use temporary tables + for materialization. The materialization to a temporary table overwrites the + JOIN structure to point to the temporary table after the materialization is + done. This is where tmp_join is used : it's a copy of the JOIN before the + materialization and is used in restoring before re-execution by overwriting + the current JOIN structure with the saved copy. + Because of this we should pay extra care of not freeing up helper structures + that are referenced by the original contents of the JOIN. We can check for + this by making sure the "current" join is not the temporary copy, e.g. + !tmp_join || tmp_join != join + + We should free these sub-structures at JOIN::destroy() if the "current" join + has a copy is not that copy. + */ + JOIN *tmp_join; ROLLUP rollup; ///< Used with rollup bool select_distinct; ///< Set if SELECT DISTINCT |