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 572f413d6e4..26df7cb38fe 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -3348,7 +3348,6 @@ IncrBufferRefCount(Buffer buffer)
{
Assert(BufferIsPinned(buffer));
ResourceOwnerEnlargeBuffers(CurrentResourceOwner);
- ResourceOwnerRememberBuffer(CurrentResourceOwner, buffer);
if (BufferIsLocal(buffer))
LocalRefCount[-buffer - 1]++;
else
@@ -3359,6 +3358,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 3849bfb15d9..aa2fe2c6c04 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -1398,6 +1398,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.
@@ -1433,9 +1440,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;