diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/commands/prepare.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index 80d6df8ac1e..e54cfc8ad88 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -234,6 +234,17 @@ ExecuteQuery(ParseState *pstate, plan_list = cplan->stmt_list; /* + * DO NOT add any logic that could possibly throw an error between + * GetCachedPlan and PortalDefineQuery, or you'll leak the plan refcount. + */ + PortalDefineQuery(portal, + NULL, + query_string, + entry->plansource->commandTag, + plan_list, + cplan); + + /* * For CREATE TABLE ... AS EXECUTE, we must verify that the prepared * statement is one that produces tuples. Currently we insist that it be * a plain old SELECT. In future we might consider supporting other @@ -276,13 +287,6 @@ ExecuteQuery(ParseState *pstate, count = FETCH_ALL; } - PortalDefineQuery(portal, - NULL, - query_string, - entry->plansource->commandTag, - plan_list, - cplan); - /* * Run the portal as appropriate. */ |