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

Commit2e44770

Browse files
committed
pgrowlocks: Use GetActiveSnapshot() rather than SnapshotNow.
Per discussion, it's desirable to eliminate all remaining uses ofSnapshotNow, because it has unpleasant semantics: race conditionscan result in seeing multiple versions of a concurrently updatedrow, or none at all. By using GetActiveSnapshot() here, callerswill see exactly those rows that would have been visible if theinvoking query had scanned the table using, for example, a SELECTstatement.This is slightly different from the old behavior, because commitsthat happen concurrently with the scan will not affect the results.In REPEATABLE READ or SERIALIZABLE modes, where transactionsnapshots are used, commits that have happened since the start ofthe transaction will also not affect the results. It is hopedthat this minor incompatibility will be thought an improvement,or at least no worse than what we did before.
1 parentf40a318 commit2e44770

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎contrib/pgrowlocks/pgrowlocks.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include"utils/acl.h"
3636
#include"utils/builtins.h"
3737
#include"utils/rel.h"
38+
#include"utils/snapmgr.h"
3839
#include"utils/tqual.h"
3940

4041

@@ -106,7 +107,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
106107
aclcheck_error(aclresult,ACL_KIND_CLASS,
107108
RelationGetRelationName(rel));
108109

109-
scan=heap_beginscan(rel,SnapshotNow,0,NULL);
110+
scan=heap_beginscan(rel,GetActiveSnapshot(),0,NULL);
110111
mydata=palloc(sizeof(*mydata));
111112
mydata->rel=rel;
112113
mydata->scan=scan;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp