Skip to content

Commit 28626dc

Browse files
committed
Fix little bugs.
- scan segno in dir_read_file_list() - check backup_path in main() if 'backup_path == NULL'
1 parent c47af35 commit 28626dc

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

backup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ do_backup_database(parray *backup_list)
128128
{
129129
prev_backup = catalog_get_last_data_backup(backup_list, current.tli);
130130
if (prev_backup == NULL)
131-
elog(ERROR, "Valid backup on current timeline is not found."
131+
elog(ERROR, "Valid backup on current timeline is not found. "
132132
"Create new FULL backup before an incremental one.");
133133
}
134134

dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ dir_read_file_list(const char *root, const char *file_txt)
723723
sscanf(buf, "linked:%s", linked);
724724
ptr = strstr(buf,"segno");
725725
if (ptr)
726-
sscanf(buf, "linked:%s", linked);
726+
sscanf(buf, "segno:%d", &segno);
727727
#ifdef PGPRO_EE
728728
ptr = strstr(buf,"CFS_generation");
729729
sscanf(buf, "CFS_generation:%lu", &generation);

pg_probackup.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ static pgut_option options[] =
107107
int
108108
main(int argc, char *argv[])
109109
{
110-
int i;
110+
char path[MAXPGPATH];
111+
/* Check if backup_path is directory. */
112+
struct stat stat_buf;
113+
int rc = stat(backup_path, &stat_buf);
111114

112115
/* initialize configuration */
113116
pgBackup_init(&current);
@@ -147,7 +150,7 @@ main(int argc, char *argv[])
147150
}
148151

149152
/* Parse command line arguments */
150-
i = pgut_getopt(argc, argv, options);
153+
pgut_getopt(argc, argv, options);
151154

152155
if (backup_path == NULL)
153156
{
@@ -156,27 +159,20 @@ main(int argc, char *argv[])
156159
if (backup_path == NULL)
157160
elog(ERROR, "required parameter not specified: BACKUP_PATH (-B, --backup-path)");
158161
}
159-
else
160-
{
161-
char path[MAXPGPATH];
162-
/* Check if backup_path is directory. */
163-
struct stat stat_buf;
164-
int rc = stat(backup_path, &stat_buf);
165162

166-
/* If rc == -1, there is no file or directory. So it's OK. */
167-
if (rc != -1 && !S_ISDIR(stat_buf.st_mode))
168-
elog(ERROR, "-B, --backup-path must be a path to directory");
163+
/* If rc == -1, there is no file or directory. So it's OK. */
164+
if (rc != -1 && !S_ISDIR(stat_buf.st_mode))
165+
elog(ERROR, "-B, --backup-path must be a path to directory");
169166

170-
/* Do not read options from file or env if we're going to set them */
171-
if (backup_subcmd != CONFIGURE)
172-
{
173-
/* Read options from configuration file */
174-
join_path_components(path, backup_path, BACKUP_CATALOG_CONF_FILE);
175-
pgut_readopt(path, options, ERROR);
167+
/* Do not read options from file or env if we're going to set them */
168+
if (backup_subcmd != CONFIGURE)
169+
{
170+
/* Read options from configuration file */
171+
join_path_components(path, backup_path, BACKUP_CATALOG_CONF_FILE);
172+
pgut_readopt(path, options, ERROR);
176173

177-
/* Read environment variables */
178-
pgut_getopt_env(options);
179-
}
174+
/* Read environment variables */
175+
pgut_getopt_env(options);
180176
}
181177

182178
if (backup_id_string_param != NULL)
@@ -205,10 +201,15 @@ main(int argc, char *argv[])
205201
join_path_components(arclog_path, backup_path, "wal");
206202

207203
/* setup exclusion list for file search */
208-
for (i = 0; pgdata_exclude_dir[i]; i++); /* find first empty slot */
204+
if (!backup_logs)
205+
{
206+
int i;
207+
208+
for (i = 0; pgdata_exclude_dir[i]; i++); /* find first empty slot */
209209

210-
if(!backup_logs)
211-
pgdata_exclude_dir[i++] = "pg_log";
210+
/* Set 'pg_log' in first empty slot */
211+
pgdata_exclude_dir[i] = "pg_log";
212+
}
212213

213214
if (target_time != NULL && target_xid != NULL)
214215
elog(ERROR, "You can't specify recovery-target-time and recovery-target-xid at the same time");

0 commit comments

Comments
 (0)