Skip to content

Commit fd8bde8

Browse files
author
Michael Paquier
committed
Merge "show timeline" and "show" as a single command
It is just troublesome to have to type a subcommands for something that could be merged into a single table. The output could be made in a smarter way though...
1 parent ef44c4f commit fd8bde8

File tree

3 files changed

+14
-53
lines changed

3 files changed

+14
-53
lines changed

pg_rman.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ main(int argc, char *argv[])
104104
const char *cmd = NULL;
105105
const char *range1 = NULL;
106106
const char *range2 = NULL;
107-
bool show_timeline = false;
108107
pgBackupRange range;
109108
int i;
110109

@@ -121,9 +120,6 @@ main(int argc, char *argv[])
121120
{
122121
if (cmd == NULL)
123122
cmd = argv[i];
124-
else if (pg_strcasecmp(argv[i], "timeline") == 0 &&
125-
pg_strcasecmp(cmd, "show") == 0)
126-
show_timeline = true;
127123
else if (range1 == NULL)
128124
range1 = argv[i];
129125
else if (range2 == NULL)
@@ -207,7 +203,7 @@ main(int argc, char *argv[])
207203
target_inclusive, target_tli, is_hard_copy);
208204
}
209205
else if (pg_strcasecmp(cmd, "show") == 0)
210-
return do_show(&range, show_timeline, show_all);
206+
return do_show(&range, show_all);
211207
else if (pg_strcasecmp(cmd, "validate") == 0)
212208
return do_validate(&range);
213209
else if (pg_strcasecmp(cmd, "delete") == 0)
@@ -227,7 +223,6 @@ pgut_help(bool details)
227223
printf(_(" %s OPTION backup\n"), PROGRAM_NAME);
228224
printf(_(" %s OPTION restore\n"), PROGRAM_NAME);
229225
printf(_(" %s OPTION show [DATE]\n"), PROGRAM_NAME);
230-
printf(_(" %s OPTION show timeline [DATE]\n"), PROGRAM_NAME);
231226
printf(_(" %s OPTION validate [DATE]\n"), PROGRAM_NAME);
232227
printf(_(" %s OPTION delete DATE\n"), PROGRAM_NAME);
233228

pg_rman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ extern int do_restore(const char *target_time,
247247
extern int do_init(void);
248248

249249
/* in show.c */
250-
extern int do_show(pgBackupRange *range, bool show_timeline, bool show_all);
250+
extern int do_show(pgBackupRange *range, bool show_all);
251251

252252
/* in delete.c */
253253
extern int do_delete(pgBackupRange *range, bool force);

show.c

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "pg_rman.h"
1111

1212
static void show_backup_list(FILE *out, parray *backup_list, bool show_all);
13-
static void show_timeline_backup_list(FILE *out, parray *backup_list, bool show_all);
1413
static void show_backup_detail(FILE *out, pgBackup *backup);
1514

1615
/*
@@ -19,7 +18,7 @@ static void show_backup_detail(FILE *out, pgBackup *backup);
1918
* backup indicated by id.
2019
*/
2120
int
22-
do_show(pgBackupRange *range, bool show_timeline, bool show_all)
21+
do_show(pgBackupRange *range, bool show_all)
2322
{
2423
if (pgBackupRangeIsSingle(range))
2524
{
@@ -49,10 +48,7 @@ do_show(pgBackupRange *range, bool show_timeline, bool show_all)
4948
elog(ERROR_SYSTEM, _("can't process any more."));
5049
}
5150

52-
if (!show_timeline)
53-
show_backup_list(stdout, backup_list, show_all);
54-
else
55-
show_timeline_backup_list(stdout, backup_list, show_all);
51+
show_backup_list(stdout, backup_list, show_all);
5652

5753
/* cleanup */
5854
parray_walk(backup_list, pgBackupFree);
@@ -165,13 +161,15 @@ show_backup_list(FILE *out, parray *backup_list, bool show_all)
165161
int i;
166162

167163
/* show header */
168-
fputs("============================================================================\n", out);
169-
fputs("Start Time Total Data WAL Log Backup Status \n", out);
170-
fputs("============================================================================\n", out);
164+
fputs("===========================================================================================================\n", out);
165+
fputs("Start Mode Current TLI Parent TLI Time Total Data WAL Log Backup Status \n", out);
166+
fputs("===========================================================================================================\n", out);
171167

172168
for (i = 0; i < parray_num(backup_list); i++)
173169
{
174170
pgBackup *backup;
171+
const char *modes[] = { "", "ARCH", "INCR", "FULL"};
172+
TimeLineID parent_tli;
175173
char timestamp[20];
176174
char duration[20] = "----";
177175
char total_data_bytes_str[10] = "----";
@@ -206,45 +204,13 @@ show_backup_list(FILE *out, parray *backup_list, bool show_all)
206204
pretty_size(backup->write_bytes, write_bytes_str,
207205
lengthof(write_bytes_str));
208206

209-
fprintf(out, "%-19s %5s %6s %6s %6s %6s %6s %s\n",
210-
timestamp, duration,
211-
total_data_bytes_str, read_data_bytes_str, read_arclog_bytes_str,
212-
read_srvlog_bytes_str, write_bytes_str, status2str(backup->status));
213-
}
214-
}
215-
216-
static void
217-
show_timeline_backup_list(FILE *out, parray *backup_list, bool show_all)
218-
{
219-
int i;
220-
221-
/* show header */
222-
fputs("============================================================\n", out);
223-
fputs("Start Mode Current TLI Parent TLI Status \n", out);
224-
fputs("============================================================\n", out);
225-
226-
for (i = 0; i < parray_num(backup_list); i++)
227-
{
228-
static const char *modes[] = { "", "ARCH", "INCR", "FULL"};
229-
230-
pgBackup *backup;
231-
char timestamp[20];
232-
TimeLineID parent_tli;
233-
234-
backup = parray_get(backup_list, i);
235-
236-
/* skip deleted backup and serverlog backup */
237-
if ((backup->status == BACKUP_STATUS_DELETED || !HAVE_ARCLOG(backup)) &&
238-
!show_all)
239-
continue;
240-
241-
time2iso(timestamp, lengthof(timestamp), backup->start_time);
242-
207+
/* Get parent timeline before printing */
243208
parent_tli = get_parent_tli(backup->tli);
244209

245-
fprintf(out, "%-19s %-4s %10d %10d %s\n",
246-
timestamp, modes[backup->backup_mode], backup->tli, parent_tli,
247-
status2str(backup->status));
210+
fprintf(out, "%-19s %-4s %10d %10d %5s %6s %6s %6s %6s %6s %s\n",
211+
timestamp, modes[backup->backup_mode], backup->tli, parent_tli, duration,
212+
total_data_bytes_str, read_data_bytes_str, read_arclog_bytes_str,
213+
read_srvlog_bytes_str, write_bytes_str, status2str(backup->status));
248214
}
249215
}
250216

0 commit comments

Comments
 (0)