From: yamt@mwd.biglobe.ne.jp
To: tgl@sss.pgh.pa.us
Cc: pgsql-bugs@postgresql.org
Subject: bug in plancache.c
Date: Mon, 26 Sep 2011 10:15:48 +0000 (UTC)
Message-ID: <20110926101548.8FA8A14A143@mail.netbsd.org> (raw)
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.cindex 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 */
Attachments:a.diff (text/plain, 794B) download
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.cindex 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 */
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: yamt@mwd.biglobe.ne.jp, tgl@sss.pgh.pa.us
Subject: Re: bug in plancache.c
In-Reply-To: <20110926101548.8FA8A14A143@mail.netbsd.org>
References: <20110926101548.8FA8A14A143@mail.netbsd.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox