diff options
Diffstat (limited to 'src/backend/utils/cache/plancache.c')
-rw-r--r-- | src/backend/utils/cache/plancache.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c index 26ef2fa6ff1..d85ea1bbd3a 100644 --- a/src/backend/utils/cache/plancache.c +++ b/src/backend/utils/cache/plancache.c @@ -141,7 +141,7 @@ InitPlanCache(void) * Once constructed, the cached plan can be made longer-lived, if needed, * by calling SaveCachedPlan. * - * raw_parse_tree: output of raw_parser() + * raw_parse_tree: output of raw_parser(), or NULL if empty query * query_string: original query text * commandTag: compile-time-constant tag for query, or NULL if empty query */ @@ -232,7 +232,7 @@ CreateCachedPlan(Node *raw_parse_tree, * invalidation, so plan use must be completed in the current transaction, * and DDL that might invalidate the querytree_list must be avoided as well. * - * raw_parse_tree: output of raw_parser() + * raw_parse_tree: output of raw_parser(), or NULL if empty query * query_string: original query text * commandTag: compile-time-constant tag for query, or NULL if empty query */ @@ -699,7 +699,9 @@ RevalidateCachedQuery(CachedPlanSource *plansource) * the cache. */ rawtree = copyObject(plansource->raw_parse_tree); - if (plansource->parserSetup != NULL) + if (rawtree == NULL) + tlist = NIL; + else if (plansource->parserSetup != NULL) tlist = pg_analyze_and_rewrite_params(rawtree, plansource->query_string, plansource->parserSetup, @@ -928,6 +930,7 @@ BuildCachedPlan(CachedPlanSource *plansource, List *qlist, */ snapshot_set = false; if (!ActiveSnapshotSet() && + plansource->raw_parse_tree && analyze_requires_snapshot(plansource->raw_parse_tree)) { PushActiveSnapshot(GetTransactionSnapshot()); |