Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 7C63CB5DBC7 for ; Mon, 26 Sep 2011 07:15:54 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 29716-07 for ; Mon, 26 Sep 2011 10:15:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11]) by mail.postgresql.org (Postfix) with ESMTP id 90AA3B5DBBD for ; Mon, 26 Sep 2011 07:15:48 -0300 (ADT) Received: by mail.netbsd.org (Postfix, from userid 1270) id 8FA8A14A143; Mon, 26 Sep 2011 10:15:48 +0000 (UTC) To: tgl@sss.pgh.pa.us Cc: pgsql-bugs@postgresql.org Subject: bug in plancache.c X-Mailer: Cue version 0.8 (100217-1432/takashi) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Disposition: attachment; filename="a.diff" Message-Id: <20110926101548.8FA8A14A143@mail.netbsd.org> Date: Mon, 26 Sep 2011 10:15:48 +0000 (UTC) From: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.001 tagged_above=-5 required=5 tests=BAYES_20=-0.001 X-Spam-Level: X-Archive-Number: 201109/177 X-Sequence-Number: 31194 hi, GetCachedPlan can pass the 'qlist' to the planner twice. if i understand the code correctly, it's unsafe because the planner is destructive wrt the input tree. for my application, it often causes a crash in executor. YAMAMOTO Takashi diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c index cfeb824..78c2c31 100644 --- a/src/backend/utils/cache/plancache.c +++ b/src/backend/utils/cache/plancache.c @@ -949,6 +949,7 @@ GetCachedPlan(CachedPlanSource *plansource, ParamListInfo boundParams, { /* Build a new generic plan */ plan = BuildCachedPlan(plansource, qlist, NULL); + qlist = NIL; /* Just make real sure plansource->gplan is clear */ ReleaseGenericPlan(plansource); /* Link the new generic plan into the plansource */