mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Change currtid functions to use an MVCC snapshot, not SnapshotNow.
This has a slight performance cost, but the only known consumers of these functions, known at the SQL level as currtid and currtid2, is pgsql-odbc; whose usage, we hope, is not sufficiently intensive to make this a problem. Per discussion.
This commit is contained in:
parent
80c79ab2a8
commit
ed93feb808
@ -30,6 +30,7 @@
|
|||||||
#include "utils/acl.h"
|
#include "utils/acl.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
#include "utils/rel.h"
|
#include "utils/rel.h"
|
||||||
|
#include "utils/snapmgr.h"
|
||||||
#include "utils/tqual.h"
|
#include "utils/tqual.h"
|
||||||
|
|
||||||
|
|
||||||
@ -332,6 +333,7 @@ currtid_byreloid(PG_FUNCTION_ARGS)
|
|||||||
ItemPointer result;
|
ItemPointer result;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
AclResult aclresult;
|
AclResult aclresult;
|
||||||
|
Snapshot snapshot;
|
||||||
|
|
||||||
result = (ItemPointer) palloc(sizeof(ItemPointerData));
|
result = (ItemPointer) palloc(sizeof(ItemPointerData));
|
||||||
if (!reloid)
|
if (!reloid)
|
||||||
@ -352,7 +354,10 @@ currtid_byreloid(PG_FUNCTION_ARGS)
|
|||||||
return currtid_for_view(rel, tid);
|
return currtid_for_view(rel, tid);
|
||||||
|
|
||||||
ItemPointerCopy(tid, result);
|
ItemPointerCopy(tid, result);
|
||||||
heap_get_latest_tid(rel, SnapshotNow, result);
|
|
||||||
|
snapshot = RegisterSnapshot(GetLatestSnapshot());
|
||||||
|
heap_get_latest_tid(rel, snapshot, result);
|
||||||
|
UnregisterSnapshot(snapshot);
|
||||||
|
|
||||||
heap_close(rel, AccessShareLock);
|
heap_close(rel, AccessShareLock);
|
||||||
|
|
||||||
@ -368,6 +373,7 @@ currtid_byrelname(PG_FUNCTION_ARGS)
|
|||||||
RangeVar *relrv;
|
RangeVar *relrv;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
AclResult aclresult;
|
AclResult aclresult;
|
||||||
|
Snapshot snapshot;
|
||||||
|
|
||||||
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
|
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
|
||||||
rel = heap_openrv(relrv, AccessShareLock);
|
rel = heap_openrv(relrv, AccessShareLock);
|
||||||
@ -384,7 +390,9 @@ currtid_byrelname(PG_FUNCTION_ARGS)
|
|||||||
result = (ItemPointer) palloc(sizeof(ItemPointerData));
|
result = (ItemPointer) palloc(sizeof(ItemPointerData));
|
||||||
ItemPointerCopy(tid, result);
|
ItemPointerCopy(tid, result);
|
||||||
|
|
||||||
heap_get_latest_tid(rel, SnapshotNow, result);
|
snapshot = RegisterSnapshot(GetLatestSnapshot());
|
||||||
|
heap_get_latest_tid(rel, snapshot, result);
|
||||||
|
UnregisterSnapshot(snapshot);
|
||||||
|
|
||||||
heap_close(rel, AccessShareLock);
|
heap_close(rel, AccessShareLock);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user