Skip to content

Commit f39b265

Browse files
Move PG_TEMP_FILE* macros to file_utils.h.
Presently, frontend code that needs to use these macros must either include storage/fd.h, which declares several frontend-unsafe functions, or duplicate the macros. This commit moves these macros to common/file_utils.h, which is safe for both frontend and backend code. Consequently, we can also remove the duplicated macros in pg_checksums and stop including storage/fd.h in pg_rewind. Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/ZOP5qoUualu5xl2Z%40paquier.xyz
1 parent 119c23e commit f39b265

File tree

7 files changed

+8
-16
lines changed

7 files changed

+8
-16
lines changed

src/backend/backup/basebackup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "commands/defrem.h"
2626
#include "common/compression.h"
2727
#include "common/file_perm.h"
28+
#include "common/file_utils.h"
2829
#include "lib/stringinfo.h"
2930
#include "miscadmin.h"
3031
#include "nodes/pg_list.h"
@@ -37,7 +38,6 @@
3738
#include "storage/bufpage.h"
3839
#include "storage/checksum.h"
3940
#include "storage/dsm_impl.h"
40-
#include "storage/fd.h"
4141
#include "storage/ipc.h"
4242
#include "storage/reinit.h"
4343
#include "utils/builtins.h"

src/backend/postmaster/postmaster.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
#include "access/xlogrecovery.h"
9595
#include "catalog/pg_control.h"
9696
#include "common/file_perm.h"
97+
#include "common/file_utils.h"
9798
#include "common/ip.h"
9899
#include "common/pg_prng.h"
99100
#include "common/string.h"

src/backend/storage/file/fileset.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "catalog/pg_tablespace.h"
2727
#include "commands/tablespace.h"
28+
#include "common/file_utils.h"
2829
#include "common/hashfn.h"
2930
#include "miscadmin.h"
3031
#include "storage/ipc.h"

src/bin/pg_checksums/pg_checksums.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,6 @@ typedef enum
5252
PG_MODE_ENABLE
5353
} PgChecksumMode;
5454

55-
/*
56-
* Filename components.
57-
*
58-
* XXX: fd.h is not declared here as frontend side code is not able to
59-
* interact with the backend-side definitions for the various fsync
60-
* wrappers.
61-
*/
62-
#define PG_TEMP_FILES_DIR "pgsql_tmp"
63-
#define PG_TEMP_FILE_PREFIX "pgsql_tmp"
64-
6555
static PgChecksumMode mode = PG_MODE_CHECK;
6656

6757
static const char *progname;

src/bin/pg_rewind/filemap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
#include <unistd.h>
2828

2929
#include "catalog/pg_tablespace_d.h"
30+
#include "common/file_utils.h"
3031
#include "common/hashfn.h"
3132
#include "common/string.h"
3233
#include "datapagemap.h"
3334
#include "filemap.h"
3435
#include "pg_rewind.h"
35-
#include "storage/fd.h"
3636

3737
/*
3838
* Define a hash table which we can use to store information about the files

src/include/common/file_utils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@ extern ssize_t pg_pwritev_with_retry(int fd,
4646

4747
extern ssize_t pg_pwrite_zeros(int fd, size_t size, off_t offset);
4848

49+
/* Filename components */
50+
#define PG_TEMP_FILES_DIR "pgsql_tmp"
51+
#define PG_TEMP_FILE_PREFIX "pgsql_tmp"
52+
4953
#endif /* FILE_UTILS_H */

src/include/storage/fd.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,4 @@ extern int durable_unlink(const char *fname, int elevel);
195195
extern void SyncDataDirectory(void);
196196
extern int data_sync_elevel(int elevel);
197197

198-
/* Filename components */
199-
#define PG_TEMP_FILES_DIR "pgsql_tmp"
200-
#define PG_TEMP_FILE_PREFIX "pgsql_tmp"
201-
202198
#endif /* FD_H */

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