summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorTor Didriksen <tor.didriksen@oracle.com>2012-09-12 08:36:12 +0200
committerTor Didriksen <tor.didriksen@oracle.com>2012-09-12 08:36:12 +0200
commit06e4a9696b2cc314ac4d2fb09f4151060a3ac434 (patch)
treec99083fa77c96f0d46c61113df65984aabad2c53 /sql/sql_select.cc
parent95f6e19187f85f9c4962301fb5d62cd74dea1431 (diff)
downloadmariadb-git-06e4a9696b2cc314ac4d2fb09f4151060a3ac434.tar.gz
Backport Bug#13724099
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 042e7563d42..bcf601e5142 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1676,6 +1676,8 @@ JOIN::optimize()
*/
void JOIN::restore_tmp()
{
+ DBUG_PRINT("info", ("restore_tmp this %p tmp_join %p", this, tmp_join));
+ DBUG_ASSERT(tmp_join != this);
memcpy(tmp_join, this, (size_t) sizeof(JOIN));
}
@@ -7090,13 +7092,18 @@ void JOIN::cleanup(bool full)
{
if (tmp_join)
tmp_table_param.copy_field= 0;
- group_fields.delete_elements();
+
/*
- Ensure that the above delete_elements() would not be called
+ Ensure that the following delete_elements() would not be called
twice for the same list.
*/
- if (tmp_join && tmp_join != this)
- tmp_join->group_fields= group_fields;
+ if (tmp_join && tmp_join != this &&
+ tmp_join->group_fields == this->group_fields)
+ tmp_join->group_fields.empty();
+
+ // Run Cached_item DTORs!
+ group_fields.delete_elements();
+
/*
We can't call delete_elements() on copy_funcs as this will cause
problems in free_elements() as some of the elements are then deleted.