pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedbug in plancache.c
2+ messages / 2 participants
[nested] [flat]
* bug in plancache.c
@ 2011-09-26 10:15 YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
2011-09-26 16:45 ` Re: bug in plancache.c Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 2+ messages in thread
From: yamt@mwd.biglobe.ne.jp @ 2011-09-26 10:15 UTC (permalink / raw)
To: tgl@sss.pgh.pa.us; +Cc: 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 */
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.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 */
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: bug in plancache.c
2011-09-26 10:15 bug in plancache.c YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
@ 2011-09-26 16:45 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2011-09-26 16:45 UTC (permalink / raw)
To: yamt@mwd.biglobe.ne.jp; +Cc: pgsql-bugs
yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) writes:
> 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.
Good catch, thanks! (But a fix like this really requires a comment IMO.)
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2011-09-26 16:45 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-09-26 10:15 bug in plancache.c YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
2011-09-26 16:45 ` Tom Lane <tgl@sss.pgh.pa.us>
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