Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit87081b2

Browse files
committed
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 thePopActiveSnapshot() or equivalent just before PortalDefineQuery, which isan unsafe spot for it (in 8.3 and later) because we are carrying a plancacherefcount that hasn't yet been assigned to the portal. Any error thrown therewould result in leaking the refcount. It's not exactly likely thatPopActiveSnapshot would throw an elog, perhaps, but it could happen.Reorder the code and add another comment warning not to do that.
1 parentdf0ea5a commit87081b2

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

‎src/backend/tcop/postgres.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.562 2008/12/13 02:29:21 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.563 2009/01/01 17:12:16 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -1714,12 +1714,11 @@ exec_bind_message(StringInfo input_message)
17141714
cplan=NULL;
17151715
}
17161716

1717-
/* Done with the snapshot used for parameter I/O and parsing/planning */
1718-
if (snapshot_set)
1719-
PopActiveSnapshot();
1720-
17211717
/*
1722-
* Define portal and start execution.
1718+
* Now we can define the portal.
1719+
*
1720+
* DO NOT put any code that could possibly throw an error between the
1721+
* above "RevalidateCachedPlan(psrc, false)" call and here.
17231722
*/
17241723
PortalDefineQuery(portal,
17251724
saved_stmt_name,
@@ -1728,6 +1727,13 @@ exec_bind_message(StringInfo input_message)
17281727
plan_list,
17291728
cplan);
17301729

1730+
/* Done with the snapshot used for parameter I/O and parsing/planning */
1731+
if (snapshot_set)
1732+
PopActiveSnapshot();
1733+
1734+
/*
1735+
* And we're ready to start portal execution.
1736+
*/
17311737
PortalStart(portal,params,InvalidSnapshot);
17321738

17331739
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp