Skip to content

Commit a7826d0

Browse files
committed
PGPRO-1059: Add PG version into show output
1 parent 22cb8c6 commit a7826d0

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/show.c

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,18 @@ show_backup_list(FILE *out, parray *backup_list)
226226

227227
/* if you add new fields here, fix the header */
228228
/* show header */
229-
fputs("==================================================================================================================================\n", out);
230-
fputs(" Instance ID Recovery time Mode WAL Current/Parent TLI Time Data Start LSN Stop LSN Status\n", out);
231-
fputs("==================================================================================================================================\n", out);
229+
fputs("============================================================================================================================================\n", out);
230+
fputs(" Instance Version ID Recovery time Mode WAL Current/Parent TLI Time Data Start LSN Stop LSN Status \n", out);
231+
fputs("============================================================================================================================================\n", out);
232232

233233
for (i = 0; i < parray_num(backup_list); i++)
234234
{
235235
pgBackup *backup = parray_get(backup_list, i);
236236
TimeLineID parent_tli;
237+
FILE *fp;
237238
char *backup_id;
239+
char pg_version_path[MAXPGPATH];
240+
char pg_version[100] = "---";
238241
char timestamp[100] = "----";
239242
char duration[20] = "----";
240243
char data_bytes_str[10] = "----";
@@ -257,8 +260,27 @@ show_backup_list(FILE *out, parray *backup_list)
257260
parent_tli = get_parent_tli(backup->tli);
258261
backup_id = base36enc(backup->start_time);
259262

260-
fprintf(out, " %-11s %-6s %-19s %-6s %-7s %3d / %-3d %5s %6s %2X/%-8X %2X/%-8X %-8s\n",
261-
instance_name, backup_id,
263+
/* Read PG_VERSION file to show backup version */
264+
pgBackupGetPath2(backup, pg_version_path, lengthof(pg_version_path),
265+
DATABASE_DIR, "PG_VERSION");
266+
fp = pgut_fopen(pg_version_path, "rt", true);
267+
if (fp)
268+
{
269+
if (fgets(pg_version, lengthof(pg_version), fp))
270+
{
271+
int len = strlen(pg_version);
272+
273+
/* Remove trailing new line */
274+
if (len > 0 && pg_version[len - 1] == '\n')
275+
pg_version[len - 1] = '\0';
276+
}
277+
fclose(fp);
278+
}
279+
280+
fprintf(out, " %-11s %-8s %-6s %-19s %-6s %-7s %3d / %-3d %5s %6s %2X/%-8X %2X/%-8X %-8s\n",
281+
instance_name,
282+
pg_version,
283+
backup_id,
262284
timestamp,
263285
pgBackupGetBackupMode(backup),
264286
backup->stream ? "STREAM": "ARCHIVE",

0 commit comments

Comments
 (0)