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

Commitbb0aed5

Browse files
committed
Use SnapshotNow instead of SnapshotSelf for reading the catalogs
during flat-file writing. The only difference is that SnapshotSelfwould consider tuples of the 'current command' within the currenttransaction as valid, where SnapshotNow wouldn't. We can eliminatethe need for this with one extra CommandCounterIncrement call beforewe start reading the catalogs.
1 parent4aefe75 commitbb0aed5

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

‎src/backend/utils/init/flatfiles.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
2323
* Portions Copyright (c) 1994, Regents of the University of California
2424
*
25-
* $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.2 2005/02/2004:45:59 tgl Exp $
25+
* $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.3 2005/02/2022:02:19 tgl Exp $
2626
*
2727
*-------------------------------------------------------------------------
2828
*/
@@ -235,11 +235,9 @@ write_database_file(Relation drel)
235235
tempname)));
236236

237237
/*
238-
* Read pg_database and write the file. Note we use SnapshotSelf to
239-
* ensure we see all effects of current transaction. (Perhaps could
240-
* do a CommandCounterIncrement beforehand, instead?)
238+
* Read pg_database and write the file.
241239
*/
242-
scan=heap_beginscan(drel,SnapshotSelf,0,NULL);
240+
scan=heap_beginscan(drel,SnapshotNow,0,NULL);
243241
while ((tuple=heap_getnext(scan,ForwardScanDirection))!=NULL)
244242
{
245243
Form_pg_databasedbform= (Form_pg_database)GETSTRUCT(tuple);
@@ -349,11 +347,9 @@ write_group_file(Relation grel)
349347
tempname)));
350348

351349
/*
352-
* Read pg_group and write the file. Note we use SnapshotSelf to
353-
* ensure we see all effects of current transaction. (Perhaps could
354-
* do a CommandCounterIncrement beforehand, instead?)
350+
* Read pg_group and write the file.
355351
*/
356-
scan=heap_beginscan(grel,SnapshotSelf,0,NULL);
352+
scan=heap_beginscan(grel,SnapshotNow,0,NULL);
357353
while ((tuple=heap_getnext(scan,ForwardScanDirection))!=NULL)
358354
{
359355
Form_pg_groupgrpform= (Form_pg_group)GETSTRUCT(tuple);
@@ -491,11 +487,9 @@ write_user_file(Relation urel)
491487
tempname)));
492488

493489
/*
494-
* Read pg_shadow and write the file. Note we use SnapshotSelf to
495-
* ensure we see all effects of current transaction. (Perhaps could
496-
* do a CommandCounterIncrement beforehand, instead?)
490+
* Read pg_shadow and write the file.
497491
*/
498-
scan=heap_beginscan(urel,SnapshotSelf,0,NULL);
492+
scan=heap_beginscan(urel,SnapshotNow,0,NULL);
499493
while ((tuple=heap_getnext(scan,ForwardScanDirection))!=NULL)
500494
{
501495
Form_pg_shadowpwform= (Form_pg_shadow)GETSTRUCT(tuple);
@@ -713,6 +707,12 @@ AtEOXact_UpdateFlatFiles(bool isCommit)
713707
return;
714708
}
715709

710+
/*
711+
* Advance command counter to be certain we see all effects of the
712+
* current transaction.
713+
*/
714+
CommandCounterIncrement();
715+
716716
/*
717717
* We use ExclusiveLock to ensure that only one backend writes the
718718
* flat file(s) at a time.That's sufficient because it's okay to

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp