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

Commit6252c4f

Browse files
committed
Run a portal's cleanup hook immediately when pushing it to DONE state.
This works around the problem noted by Yamamoto Takashi in bug #5906,that there were code paths whereby we could reach AtCleanup_Portalswith a portal's cleanup hook still unexecuted. The changes I madea few days ago were intended to prevent that from happening, andI think that on balance it's still a good thing to avoid, so I don'twant to remove the Assert in AtCleanup_Portals. Hence do this instead.
1 parent32fce70 commit6252c4f

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

‎src/backend/tcop/pquery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ PortalRun(Portal portal, long count, bool isTopLevel,
814814
dest,altdest,completionTag);
815815

816816
/* Prevent portal's commands from being re-executed */
817-
portal->status=PORTAL_DONE;
817+
MarkPortalDone(portal);
818818

819819
/* Always complete at end of RunMulti */
820820
result= true;

‎src/backend/utils/mmgr/portalmem.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,32 @@ UnpinPortal(Portal portal)
401401
portal->portalPinned= false;
402402
}
403403

404+
/*
405+
* MarkPortalDone
406+
*Transition a portal from ACTIVE to DONE state.
407+
*/
408+
void
409+
MarkPortalDone(Portalportal)
410+
{
411+
/* Perform the state transition */
412+
Assert(portal->status==PORTAL_ACTIVE);
413+
portal->status=PORTAL_DONE;
414+
415+
/*
416+
* Allow portalcmds.c to clean up the state it knows about. We might
417+
* as well do that now, since the portal can't be executed any more.
418+
*
419+
* In some cases involving execution of a ROLLBACK command in an already
420+
* aborted transaction, this prevents an assertion failure from reaching
421+
* AtCleanup_Portals with the cleanup hook still unexecuted.
422+
*/
423+
if (PointerIsValid(portal->cleanup))
424+
{
425+
(*portal->cleanup) (portal);
426+
portal->cleanup=NULL;
427+
}
428+
}
429+
404430
/*
405431
* PortalDrop
406432
*Destroy the portal.

‎src/include/utils/portal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ extern Portal CreatePortal(const char *name, bool allowDup, bool dupSilent);
206206
externPortalCreateNewPortal(void);
207207
externvoidPinPortal(Portalportal);
208208
externvoidUnpinPortal(Portalportal);
209+
externvoidMarkPortalDone(Portalportal);
209210
externvoidPortalDrop(Portalportal,boolisTopCommit);
210211
externPortalGetPortalByName(constchar*name);
211212
externvoidPortalDefineQuery(Portalportal,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp