Fix another place broken by new List implementation :-(. Per example
authorTom Lane <[email protected]>
Wed, 15 Dec 2004 21:13:34 +0000 (21:13 +0000)
committerTom Lane <[email protected]>
Wed, 15 Dec 2004 21:13:34 +0000 (21:13 +0000)
from [email protected].  I think this escaped notice because in
simple cases the list is NIL on entry.

src/backend/optimizer/geqo/geqo_eval.c

index 41244c994ca2c26a5f229594fbb50d8df371a463..c0aa9b5188cc29d4803c662933a4ed42fb49ac53 100644 (file)
@@ -80,12 +80,17 @@ geqo_eval(Gene *tour, int num_gene, GeqoEvalData *evaldata)
        oldcxt = MemoryContextSwitchTo(mycontext);
 
        /*
-        * preserve root->join_rel_list, which gimme_tree changes; without
-        * this, it'll be pointing at recycled storage after the
-        * MemoryContextDelete below.
+        * gimme_tree will add entries to root->join_rel_list, which may or may
+        * not already contain some entries.  The newly added entries will be
+        * recycled by the MemoryContextDelete below, so we must ensure that
+        * the list is restored to its former state before exiting.  With the
+        * new List implementation, the easiest way is to make a duplicate list
+        * that gimme_tree can modify.
         */
        savelist = evaldata->root->join_rel_list;
 
+       evaldata->root->join_rel_list = list_copy(savelist);
+
        /* construct the best path for the given combination of relations */
        joinrel = gimme_tree(tour, num_gene, evaldata);