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

Commit07a601e

Browse files
committed
Avoid crashing in GetOldestSnapshot() if there are no known snapshots.
The sole caller expects NULL to be returned in such a case, so makeit so and document it.Per reports from Andreas Seltenreich and Regina Obe. This doesn'treally fix their problem, as now their RETURNING queries will say"ERROR: no known snapshots", but in any case this function shouldnot dump core in a reasonably-foreseeable situation.Report: <87vazemeda.fsf@credativ.de>Report: <20160807051854.1427.32414@wrigleys.postgresql.org>
1 parentbcbecbc commit07a601e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

‎src/backend/utils/time/snapmgr.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,14 @@ GetLatestSnapshot(void)
399399
/*
400400
* GetOldestSnapshot
401401
*
402-
*Get the oldest known snapshot, as judged by the LSN.
402+
*Get the transaction's oldest known snapshot, as judged by the LSN.
403+
*Will return NULL if there are no active or registered snapshots.
403404
*/
404405
Snapshot
405406
GetOldestSnapshot(void)
406407
{
407408
SnapshotOldestRegisteredSnapshot=NULL;
408409
XLogRecPtrRegisteredLSN=InvalidXLogRecPtr;
409-
XLogRecPtrActiveLSN=InvalidXLogRecPtr;
410410

411411
if (!pairingheap_is_empty(&RegisteredSnapshots))
412412
{
@@ -416,10 +416,12 @@ GetOldestSnapshot(void)
416416
}
417417

418418
if (OldestActiveSnapshot!=NULL)
419-
ActiveLSN=OldestActiveSnapshot->as_snap->lsn;
419+
{
420+
XLogRecPtrActiveLSN=OldestActiveSnapshot->as_snap->lsn;
420421

421-
if (XLogRecPtrIsInvalid(RegisteredLSN)||RegisteredLSN>ActiveLSN)
422-
returnOldestActiveSnapshot->as_snap;
422+
if (XLogRecPtrIsInvalid(RegisteredLSN)||RegisteredLSN>ActiveLSN)
423+
returnOldestActiveSnapshot->as_snap;
424+
}
423425

424426
returnOldestRegisteredSnapshot;
425427
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp