bug in plancache.c

From: yamt(at)mwd(dot)biglobe(dot)ne(dot)jp (YAMAMOTO Takashi)
To: tgl(at)sss(dot)pgh(dot)pa(dot)us
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: bug in plancache.c
Date: 2011-09-26 10:15:48
Message-ID: 20110926101548.8FA8A14A143@mail.netbsd.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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 */

Attachment Content-Type Size
a.diff text/plain 794 bytes

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2011-09-26 10:52:23 Re: [v9.2] make_greater_string() does not return a string in some cases
Previous Message YAMAMOTO Takashi 2011-09-26 10:06:53 Re: BUG #6218: TRAP: FailedAssertion( "!(owner->nsnapshots == 0)", File: "resowner.c", Line: 365)