diff options
| author | Abbas | 2012-05-01 05:13:20 +0000 |
|---|---|---|
| committer | Abbas | 2012-05-01 05:13:20 +0000 |
| commit | c0bc77818e7243179fb93d1c0770e52826d470d4 (patch) | |
| tree | 3a7665af03f94e4bbcdec5034928a3d7e33316a3 | |
| parent | 26e073f38d8a301c8f5de116613c6459903a50df (diff) | |
Fix for crash when a set parameter to value command is executed using PQprepare & PQexecPrepared
The crash was due to two reasons
1. The stmt_name member of CachedPlanSource was left uninitialized in FastCreateCachedPlan.
(Patch provided by Mason)
2. StoreCachedPlan was wrongly typecasting utility statements to PlannedStmt *.
| -rw-r--r-- | src/backend/utils/cache/plancache.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c index 7fbd62072f..aaa2151d44 100644 --- a/src/backend/utils/cache/plancache.c +++ b/src/backend/utils/cache/plancache.c @@ -267,7 +267,9 @@ FastCreateCachedPlan(Node *raw_parse_tree, plansource->plan = NULL; plansource->context = context; plansource->orig_plan = NULL; - +#ifdef PGXC + plansource->stmt_name = NULL; +#endif /* * Store the current output plans into the plancache entry. */ @@ -370,10 +372,19 @@ StoreCachedPlan(CachedPlanSource *plansource, n = 0; foreach(lc, stmt_list) { - PlannedStmt *ps = (PlannedStmt *) lfirst(lc); - n = SetRemoteStatementName(ps->planTree, plansource->stmt_name, - plansource->num_params, - plansource->param_types, n); + Node *st; + PlannedStmt *ps; + + st = (Node *) lfirst(lc); + + if (IsA(st, PlannedStmt)) + { + ps = (PlannedStmt *)st; + + n = SetRemoteStatementName(ps->planTree, plansource->stmt_name, + plansource->num_params, + plansource->param_types, n); + } } } #endif |
