Skip to content

Commit ed93feb

Browse files
committed
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.
1 parent 80c79ab commit ed93feb

File tree

1 file changed

+10
-2
lines changed
  • src/backend/utils/adt

1 file changed

+10
-2
lines changed

src/backend/utils/adt/tid.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "utils/acl.h"
3131
#include "utils/builtins.h"
3232
#include "utils/rel.h"
33+
#include "utils/snapmgr.h"
3334
#include "utils/tqual.h"
3435

3536

@@ -332,6 +333,7 @@ currtid_byreloid(PG_FUNCTION_ARGS)
332333
ItemPointer result;
333334
Relation rel;
334335
AclResult aclresult;
336+
Snapshot snapshot;
335337

336338
result = (ItemPointer) palloc(sizeof(ItemPointerData));
337339
if (!reloid)
@@ -352,7 +354,10 @@ currtid_byreloid(PG_FUNCTION_ARGS)
352354
return currtid_for_view(rel, tid);
353355

354356
ItemPointerCopy(tid, result);
355-
heap_get_latest_tid(rel, SnapshotNow, result);
357+
358+
snapshot = RegisterSnapshot(GetLatestSnapshot());
359+
heap_get_latest_tid(rel, snapshot, result);
360+
UnregisterSnapshot(snapshot);
356361

357362
heap_close(rel, AccessShareLock);
358363

@@ -368,6 +373,7 @@ currtid_byrelname(PG_FUNCTION_ARGS)
368373
RangeVar *relrv;
369374
Relation rel;
370375
AclResult aclresult;
376+
Snapshot snapshot;
371377

372378
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
373379
rel = heap_openrv(relrv, AccessShareLock);
@@ -384,7 +390,9 @@ currtid_byrelname(PG_FUNCTION_ARGS)
384390
result = (ItemPointer) palloc(sizeof(ItemPointerData));
385391
ItemPointerCopy(tid, result);
386392

387-
heap_get_latest_tid(rel, SnapshotNow, result);
393+
snapshot = RegisterSnapshot(GetLatestSnapshot());
394+
heap_get_latest_tid(rel, snapshot, result);
395+
UnregisterSnapshot(snapshot);
388396

389397
heap_close(rel, AccessShareLock);
390398

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy