aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlogfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-12-04 18:37:54 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2017-12-04 18:37:54 -0500
commit066bc21c0e085e2642ff25cc665c4efad3669d6f (patch)
tree027c786114bb35dad2ad7bb4af9aea5736963824 /src/backend/access/transam/xlogfuncs.c
parent561885db05d3296082ce8750805b8ec322cf9aa1 (diff)
downloadpostgresql-066bc21c0e085e2642ff25cc665c4efad3669d6f.tar.gz
postgresql-066bc21c0e085e2642ff25cc665c4efad3669d6f.zip
Simplify do_pg_start_backup's API by opening pg_tblspc internally.
do_pg_start_backup() expects its callers to pass in an open DIR pointer for the pg_tblspc directory, but there's no apparent advantage in that. It complicates the callers without adding any flexibility, and there's no robustness advantage, since we surely have to be prepared for errors during the scan of pg_tblspc anyway. In fact, by holding an extra kernel resource during operations like the preliminary checkpoint, we might be making things a fraction more failure-prone not less. Hence, remove that argument and open the directory just for the duration of the actual scan. Discussion: https://postgr.es/m/28752.1512413887@sss.pgh.pa.us
Diffstat (limited to 'src/backend/access/transam/xlogfuncs.c')
-rw-r--r--src/backend/access/transam/xlogfuncs.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c
index 48d85c1ce5d..c41428ea2a3 100644
--- a/src/backend/access/transam/xlogfuncs.c
+++ b/src/backend/access/transam/xlogfuncs.c
@@ -75,7 +75,6 @@ pg_start_backup(PG_FUNCTION_ARGS)
bool exclusive = PG_GETARG_BOOL(2);
char *backupidstr;
XLogRecPtr startpoint;
- DIR *dir;
SessionBackupState status = get_backup_status();
backupidstr = text_to_cstring(backupid);
@@ -85,18 +84,10 @@ pg_start_backup(PG_FUNCTION_ARGS)
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("a backup is already in progress in this session")));
- /* Make sure we can open the directory with tablespaces in it */
- dir = AllocateDir("pg_tblspc");
- if (!dir)
- ereport(ERROR,
- (errcode_for_file_access(),
- errmsg("could not open directory \"%s\": %m",
- "pg_tblspc")));
-
if (exclusive)
{
startpoint = do_pg_start_backup(backupidstr, fast, NULL, NULL,
- dir, NULL, NULL, false, true);
+ NULL, NULL, false, true);
}
else
{
@@ -112,13 +103,11 @@ pg_start_backup(PG_FUNCTION_ARGS)
MemoryContextSwitchTo(oldcontext);
startpoint = do_pg_start_backup(backupidstr, fast, NULL, label_file,
- dir, NULL, tblspc_map_file, false, true);
+ NULL, tblspc_map_file, false, true);
before_shmem_exit(nonexclusive_base_backup_cleanup, (Datum) 0);
}
- FreeDir(dir);
-
PG_RETURN_LSN(startpoint);
}