Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b2e046

Browse files
committed
PGPRO-2073: Write program-version only during backup
1 parent 4e68bac commit 0b2e046

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/backup.c

+2
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,8 @@ do_backup(time_t start_time)
911911
/* Start backup. Update backup status. */
912912
current.status = BACKUP_STATUS_RUNNING;
913913
current.start_time = start_time;
914+
StrNCpy(current.program_version, PROGRAM_VERSION,
915+
sizeof(current.program_version));
914916

915917
/* Create backup directory and BACKUP_CONTROL_FILE */
916918
if (pgBackupCreateDir(&current))

src/catalog.c

+13-8
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,19 @@ read_backup(time_t timestamp)
219219
/*
220220
* Save the backup status into BACKUP_CONTROL_FILE.
221221
*
222-
* We need to reread the backup using its ID and save it changing only its status.
222+
* We need to reread the backup using its ID and save it changing only its
223+
* status.
223224
*/
224225
void
225226
write_backup_status(pgBackup *backup)
226227
{
227228
pgBackup *tmp;
228229

229230
tmp = read_backup(backup->start_time);
230-
tmp->status = backup->status;
231231

232+
tmp->status = backup->status;
232233
write_backup(tmp);
234+
233235
pgBackupFree(tmp);
234236
}
235237

@@ -443,7 +445,8 @@ pgBackupWriteControl(FILE *out, pgBackup *backup)
443445
fprintf(out, "block-size = %u\n", backup->block_size);
444446
fprintf(out, "xlog-block-size = %u\n", backup->wal_block_size);
445447
fprintf(out, "checksum-version = %u\n", backup->checksum_version);
446-
fprintf(out, "program-version = %s\n", PROGRAM_VERSION);
448+
if (backup->program_version[0] != '\0')
449+
fprintf(out, "program-version = %s\n", backup->program_version);
447450
if (backup->server_version[0] != '\0')
448451
fprintf(out, "server-version = %s\n", backup->server_version);
449452

@@ -493,17 +496,19 @@ pgBackupWriteControl(FILE *out, pgBackup *backup)
493496
fprintf(out, "primary_conninfo = '%s'\n", backup->primary_conninfo);
494497
}
495498

496-
/* create BACKUP_CONTROL_FILE */
499+
/*
500+
* Save the backup content into BACKUP_CONTROL_FILE.
501+
*/
497502
void
498503
write_backup(pgBackup *backup)
499504
{
500505
FILE *fp = NULL;
501-
char ini_path[MAXPGPATH];
506+
char conf_path[MAXPGPATH];
502507

503-
pgBackupGetPath(backup, ini_path, lengthof(ini_path), BACKUP_CONTROL_FILE);
504-
fp = fopen(ini_path, "wt");
508+
pgBackupGetPath(backup, conf_path, lengthof(conf_path), BACKUP_CONTROL_FILE);
509+
fp = fopen(conf_path, "wt");
505510
if (fp == NULL)
506-
elog(ERROR, "cannot open configuration file \"%s\": %s", ini_path,
511+
elog(ERROR, "Cannot open configuration file \"%s\": %s", conf_path,
507512
strerror(errno));
508513

509514
pgBackupWriteControl(fp, backup);

src/utils/pgut.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ assign_option(pgut_option *opt, const char *optarg, pgut_optsrc src)
241241
*(char **) opt->var = pgut_strdup(optarg);
242242
if (strcmp(optarg,"") != 0)
243243
return;
244-
message = "a valid string. But provided: ";
244+
message = "a valid string";
245245
break;
246246
case 't':
247247
if (parse_time(optarg, opt->var,

0 commit comments

Comments
 (0)