aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/tid.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2013-07-25 16:32:02 -0400
committerRobert Haas <rhaas@postgresql.org>2013-07-25 16:32:02 -0400
commited93feb80891b131e9676e962256cc2b18aa5e78 (patch)
tree9e487863b1d62bf8436eafb85ada92c2f4219c3a /src/backend/utils/adt/tid.c
parent80c79ab2a8d63bc6c83269b29c1ba993c8077d3a (diff)
downloadpostgresql-ed93feb80891b131e9676e962256cc2b18aa5e78.tar.gz
postgresql-ed93feb80891b131e9676e962256cc2b18aa5e78.zip
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.
Diffstat (limited to 'src/backend/utils/adt/tid.c')
-rw-r--r--src/backend/utils/adt/tid.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index 5df9e399a97..1c2503f50f6 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -30,6 +30,7 @@
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/rel.h"
+#include "utils/snapmgr.h"
#include "utils/tqual.h"
@@ -332,6 +333,7 @@ currtid_byreloid(PG_FUNCTION_ARGS)
ItemPointer result;
Relation rel;
AclResult aclresult;
+ Snapshot snapshot;
result = (ItemPointer) palloc(sizeof(ItemPointerData));
if (!reloid)
@@ -352,7 +354,10 @@ currtid_byreloid(PG_FUNCTION_ARGS)
return currtid_for_view(rel, tid);
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);
@@ -368,6 +373,7 @@ currtid_byrelname(PG_FUNCTION_ARGS)
RangeVar *relrv;
Relation rel;
AclResult aclresult;
+ Snapshot snapshot;
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
rel = heap_openrv(relrv, AccessShareLock);
@@ -384,7 +390,9 @@ currtid_byrelname(PG_FUNCTION_ARGS)
result = (ItemPointer) palloc(sizeof(ItemPointerData));
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);