diff options
author | Tom Lane | 2009-01-01 17:12:16 +0000 |
---|---|---|
committer | Tom Lane | 2009-01-01 17:12:16 +0000 |
commit | fcf61977ce94a19318bebe291000b73683abe21e (patch) | |
tree | 7ee391f0c972fe6241e9d5d237222a20760800dc /src/backend/tcop/postgres.c | |
parent | 431092f5a04e0756ed43339945e9786713791074 (diff) |
Fix an oversight in my patch of a couple weeks ago that ensured a snapshot
is available during datatype input in Bind message processing. I put the
PopActiveSnapshot() or equivalent just before PortalDefineQuery, which is
an unsafe spot for it (in 8.3 and later) because we are carrying a plancache
refcount that hasn't yet been assigned to the portal. Any error thrown there
would result in leaking the refcount. It's not exactly likely that
PopActiveSnapshot would throw an elog, perhaps, but it could happen.
Reorder the code and add another comment warning not to do that.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 911386edef..be208de1ab 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -1714,12 +1714,11 @@ exec_bind_message(StringInfo input_message) cplan = NULL; } - /* Done with the snapshot used for parameter I/O and parsing/planning */ - if (snapshot_set) - PopActiveSnapshot(); - /* - * Define portal and start execution. + * Now we can define the portal. + * + * DO NOT put any code that could possibly throw an error between the + * above "RevalidateCachedPlan(psrc, false)" call and here. */ PortalDefineQuery(portal, saved_stmt_name, @@ -1728,6 +1727,13 @@ exec_bind_message(StringInfo input_message) plan_list, cplan); + /* Done with the snapshot used for parameter I/O and parsing/planning */ + if (snapshot_set) + PopActiveSnapshot(); + + /* + * And we're ready to start portal execution. + */ PortalStart(portal, params, InvalidSnapshot); /* |