Skip to content

Commit 13eef4b

Browse files
hlinnakahackorum
authored andcommitted
Move functions related to temporary file management to tempfile.c
Like in the few previous commits, the idea is that only functions related to the Virtual File Descriptor abstraction remain in fd.c. This commit moves functions related to creating and deleting temporary files and managing temporary dirs in tablespaces to a separate source file. This mostly a mechanical move. Note the split of the end-of-xact and process-exit functions, however. tempfile.c now registers the process-exit callback, but it relies on the CleanupTempFiles() function provided by fd.c to do the work. CleanupTempFiles() now only cleans up the temporary Files, it does not try to close AllocateDesc handles. They should've been closed by end-of-xact cleanup already, and if not, they will be closed at the impending process exit anyway. Resetting the temporary tablespace list is moved to a new AtEOXact_TempFiles() function, which is called from Commit/AbortTransaction(), but not from all the cleanup routines where AtEOXact_files() is called. Having a temporary tablespace list requires an open transaction, so it doesn't need to be called at non-transaction cleanup.
1 parent 005bee1 commit 13eef4b

15 files changed

Lines changed: 808 additions & 725 deletions

File tree

src/backend/access/transam/xact.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "storage/procarray.h"
6363
#include "storage/sinvaladt.h"
6464
#include "storage/smgr.h"
65+
#include "storage/tempfile.h"
6566
#include "utils/builtins.h"
6667
#include "utils/combocid.h"
6768
#include "utils/guc.h"
@@ -2512,6 +2513,7 @@ CommitTransaction(void)
25122513
AtEOXact_Namespace(true, is_parallel_worker);
25132514
AtEOXact_SMgr();
25142515
AtEOXact_Files(true);
2516+
AtEOXact_TempFiles();
25152517
AtEOXact_ComboCid();
25162518
AtEOXact_HashTables(true);
25172519
AtEOXact_RI(true);
@@ -2808,6 +2810,7 @@ PrepareTransaction(void)
28082810
AtEOXact_Namespace(true, false);
28092811
AtEOXact_SMgr();
28102812
AtEOXact_Files(true);
2813+
AtEOXact_TempFiles();
28112814
AtEOXact_ComboCid();
28122815
AtEOXact_HashTables(true);
28132816
AtEOXact_RI(true);
@@ -3039,6 +3042,7 @@ AbortTransaction(void)
30393042
AtEOXact_Namespace(false, is_parallel_worker);
30403043
AtEOXact_SMgr();
30413044
AtEOXact_Files(false);
3045+
AtEOXact_TempFiles();
30423046
AtEOXact_ComboCid();
30433047
AtEOXact_HashTables(false);
30443048
AtEOXact_RI(false);

src/backend/backup/basebackup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "storage/dsm_impl.h"
4444
#include "storage/ipc.h"
4545
#include "storage/reinit.h"
46+
#include "storage/tempfile.h"
4647
#include "utils/builtins.h"
4748
#include "utils/guc.h"
4849
#include "utils/ps_status.h"

src/backend/commands/tablespace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#include "storage/lwlock.h"
7575
#include "storage/procsignal.h"
7676
#include "storage/standby.h"
77+
#include "storage/tempfile.h"
7778
#include "utils/acl.h"
7879
#include "utils/builtins.h"
7980
#include "utils/fmgroids.h"

src/backend/postmaster/postmaster.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
#include "storage/pmsignal.h"
117117
#include "storage/proc.h"
118118
#include "storage/shmem_internal.h"
119+
#include "storage/tempfile.h"
119120
#include "tcop/backend_startup.h"
120121
#include "tcop/tcopprot.h"
121122
#include "utils/datetime.h"

src/backend/storage/file/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ OBJS = \
2020
fileset.o \
2121
file_utils.o \
2222
reinit.o \
23-
sharedfileset.o
23+
sharedfileset.o \
24+
tempfile.o
2425

2526
include $(top_srcdir)/src/backend/common.mk

src/backend/storage/file/buffile.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include "storage/buffile.h"
5353
#include "storage/bufmgr.h"
5454
#include "storage/fd.h"
55+
#include "storage/tempfile.h"
5556
#include "utils/resowner.h"
5657
#include "utils/wait_event.h"
5758

src/backend/storage/file/datadir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "storage/datadir.h"
2626
#include "storage/fd.h"
2727
#include "storage/file_utils.h"
28+
#include "storage/tempfile.h"
2829

2930
/* Define PG_FLUSH_DATA_WORKS if we have an implementation for pg_flush_data */
3031
#if defined(HAVE_SYNC_FILE_RANGE)

0 commit comments

Comments
 (0)