diff options
Diffstat (limited to 'src/backend/backup')
| -rw-r--r-- | src/backend/backup/backup_manifest.c | 6 | ||||
| -rw-r--r-- | src/backend/backup/basebackup.c | 35 | ||||
| -rw-r--r-- | src/backend/backup/basebackup_copy.c | 2 |
3 files changed, 22 insertions, 21 deletions
diff --git a/src/backend/backup/backup_manifest.c b/src/backend/backup/backup_manifest.c index cee62165246..aeed362a9ad 100644 --- a/src/backend/backup/backup_manifest.c +++ b/src/backend/backup/backup_manifest.c @@ -97,7 +97,7 @@ FreeBackupManifest(backup_manifest_info *manifest) * Add an entry to the backup manifest for a file. */ void -AddFileToBackupManifest(backup_manifest_info *manifest, const char *spcoid, +AddFileToBackupManifest(backup_manifest_info *manifest, Oid spcoid, const char *pathname, size_t size, pg_time_t mtime, pg_checksum_context *checksum_ctx) { @@ -114,9 +114,9 @@ AddFileToBackupManifest(backup_manifest_info *manifest, const char *spcoid, * pathname relative to the data directory (ignoring the intermediate * symlink traversal). */ - if (spcoid != NULL) + if (OidIsValid(spcoid)) { - snprintf(pathbuf, sizeof(pathbuf), "pg_tblspc/%s/%s", spcoid, + snprintf(pathbuf, sizeof(pathbuf), "pg_tblspc/%u/%s", spcoid, pathname); pathname = pathbuf; } diff --git a/src/backend/backup/basebackup.c b/src/backend/backup/basebackup.c index b126d9c8907..b537f462197 100644 --- a/src/backend/backup/basebackup.c +++ b/src/backend/backup/basebackup.c @@ -75,14 +75,15 @@ typedef struct pg_checksum_type manifest_checksum_type; } basebackup_options; -static int64 sendTablespace(bbsink *sink, char *path, char *spcoid, bool sizeonly, +static int64 sendTablespace(bbsink *sink, char *path, Oid spcoid, bool sizeonly, struct backup_manifest_info *manifest); static int64 sendDir(bbsink *sink, const char *path, int basepathlen, bool sizeonly, List *tablespaces, bool sendtblspclinks, - backup_manifest_info *manifest, const char *spcoid); + backup_manifest_info *manifest, Oid spcoid); static bool sendFile(bbsink *sink, const char *readfilename, const char *tarfilename, - struct stat *statbuf, bool missing_ok, Oid dboid, - backup_manifest_info *manifest, const char *spcoid); + struct stat *statbuf, bool missing_ok, + Oid dboid, Oid spcoid, + backup_manifest_info *manifest); static off_t read_file_data_into_buffer(bbsink *sink, const char *readfilename, int fd, off_t offset, size_t length, @@ -305,7 +306,7 @@ perform_base_backup(basebackup_options *opt, bbsink *sink) if (tmp->path == NULL) tmp->size = sendDir(sink, ".", 1, true, state.tablespaces, - true, NULL, NULL); + true, NULL, InvalidOid); else tmp->size = sendTablespace(sink, tmp->path, tmp->oid, true, NULL); @@ -346,7 +347,7 @@ perform_base_backup(basebackup_options *opt, bbsink *sink) /* Then the bulk of the files... */ sendDir(sink, ".", 1, false, state.tablespaces, - sendtblspclinks, &manifest, NULL); + sendtblspclinks, &manifest, InvalidOid); /* ... and pg_control after everything else. */ if (lstat(XLOG_CONTROL_FILE, &statbuf) != 0) @@ -355,11 +356,11 @@ perform_base_backup(basebackup_options *opt, bbsink *sink) errmsg("could not stat file \"%s\": %m", XLOG_CONTROL_FILE))); sendFile(sink, XLOG_CONTROL_FILE, XLOG_CONTROL_FILE, &statbuf, - false, InvalidOid, &manifest, NULL); + false, InvalidOid, InvalidOid, &manifest); } else { - char *archive_name = psprintf("%s.tar", ti->oid); + char *archive_name = psprintf("%u.tar", ti->oid); bbsink_begin_archive(sink, archive_name); @@ -623,8 +624,8 @@ perform_base_backup(basebackup_options *opt, bbsink *sink) (errcode_for_file_access(), errmsg("could not stat file \"%s\": %m", pathbuf))); - sendFile(sink, pathbuf, pathbuf, &statbuf, false, InvalidOid, - &manifest, NULL); + sendFile(sink, pathbuf, pathbuf, &statbuf, false, + InvalidOid, InvalidOid, &manifest); /* unconditionally mark file as archived */ StatusFilePath(pathbuf, fname, ".done"); @@ -1087,7 +1088,7 @@ sendFileWithContent(bbsink *sink, const char *filename, const char *content, _tarWritePadding(sink, len); - AddFileToBackupManifest(manifest, NULL, filename, len, + AddFileToBackupManifest(manifest, InvalidOid, filename, len, (pg_time_t) statbuf.st_mtime, &checksum_ctx); } @@ -1099,7 +1100,7 @@ sendFileWithContent(bbsink *sink, const char *filename, const char *content, * Only used to send auxiliary tablespaces, not PGDATA. */ static int64 -sendTablespace(bbsink *sink, char *path, char *spcoid, bool sizeonly, +sendTablespace(bbsink *sink, char *path, Oid spcoid, bool sizeonly, backup_manifest_info *manifest) { int64 size; @@ -1154,7 +1155,7 @@ sendTablespace(bbsink *sink, char *path, char *spcoid, bool sizeonly, static int64 sendDir(bbsink *sink, const char *path, int basepathlen, bool sizeonly, List *tablespaces, bool sendtblspclinks, backup_manifest_info *manifest, - const char *spcoid) + Oid spcoid) { DIR *dir; struct dirent *de; @@ -1416,8 +1417,8 @@ sendDir(bbsink *sink, const char *path, int basepathlen, bool sizeonly, if (!sizeonly) sent = sendFile(sink, pathbuf, pathbuf + basepathlen + 1, &statbuf, - true, isDbDir ? atooid(lastDir + 1) : InvalidOid, - manifest, spcoid); + true, isDbDir ? atooid(lastDir + 1) : InvalidOid, spcoid, + manifest); if (sent || sizeonly) { @@ -1486,8 +1487,8 @@ is_checksummed_file(const char *fullpath, const char *filename) */ static bool sendFile(bbsink *sink, const char *readfilename, const char *tarfilename, - struct stat *statbuf, bool missing_ok, Oid dboid, - backup_manifest_info *manifest, const char *spcoid) + struct stat *statbuf, bool missing_ok, Oid dboid, Oid spcoid, + backup_manifest_info *manifest) { int fd; BlockNumber blkno = 0; diff --git a/src/backend/backup/basebackup_copy.c b/src/backend/backup/basebackup_copy.c index fee30c21e10..3bdbe1f9890 100644 --- a/src/backend/backup/basebackup_copy.c +++ b/src/backend/backup/basebackup_copy.c @@ -407,7 +407,7 @@ SendTablespaceList(List *tablespaces) } else { - values[0] = ObjectIdGetDatum(strtoul(ti->oid, NULL, 10)); + values[0] = ObjectIdGetDatum(ti->oid); values[1] = CStringGetTextDatum(ti->path); } if (ti->size >= 0) |
