aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/storage/buffer/bufmgr.c2
-rw-r--r--src/backend/storage/file/fd.c10
2 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index d00a60fab76..ddd92e75a01 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -2999,7 +2999,6 @@ IncrBufferRefCount(Buffer buffer)
{
Assert(BufferIsPinned(buffer));
ResourceOwnerEnlargeBuffers(CurrentResourceOwner);
- ResourceOwnerRememberBuffer(CurrentResourceOwner, buffer);
if (BufferIsLocal(buffer))
LocalRefCount[-buffer - 1]++;
else
@@ -3010,6 +3009,7 @@ IncrBufferRefCount(Buffer buffer)
Assert(ref != NULL);
ref->refcount++;
}
+ ResourceOwnerRememberBuffer(CurrentResourceOwner, buffer);
}
/*
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 33955270b42..bb81acbd1d0 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -1195,6 +1195,13 @@ OpenTemporaryFile(bool interXact)
File file = 0;
/*
+ * Make sure the current resource owner has space for this File before we
+ * open it, if we'll be registering it below.
+ */
+ if (!interXact)
+ ResourceOwnerEnlargeFiles(CurrentResourceOwner);
+
+ /*
* If some temp tablespace(s) have been given to us, try to use the next
* one. If a given tablespace can't be found, we silently fall back to
* the database's default tablespace.
@@ -1230,9 +1237,8 @@ OpenTemporaryFile(bool interXact)
{
VfdCache[file].fdstate |= FD_XACT_TEMPORARY;
- ResourceOwnerEnlargeFiles(CurrentResourceOwner);
- ResourceOwnerRememberFile(CurrentResourceOwner, file);
VfdCache[file].resowner = CurrentResourceOwner;
+ ResourceOwnerRememberFile(CurrentResourceOwner, file);
/* ensure cleanup happens at eoxact */
have_xact_temporary_files = true;