1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-18 02:02:55 +03:00

Add backup_type column to pg_stat_progress_basebackup.

This commit introduces a new column backup_type that indicates the
type of backup being performed: either 'full' or 'incremental'.

Bump catalog version.

Author: Shinya Kato <shinya11.kato@gmail.com>
Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>
Discussion: https://postgr.es/m/CAOzEurQuzbHwTj1ehk1a+eeQDidJPyrE5s6mYumkjwjZnurhkQ@mail.gmail.com
This commit is contained in:
Masahiko Sawada
2025-08-05 10:50:45 -07:00
parent 295a39770e
commit deb674454c
8 changed files with 36 additions and 7 deletions

View File

@@ -1048,7 +1048,7 @@ SendBaseBackup(BaseBackupCmd *cmd, IncrementalBackupInfo *ib)
sink = bbsink_zstd_new(sink, &opt.compression_specification);
/* Set up progress reporting. */
sink = bbsink_progress_new(sink, opt.progress);
sink = bbsink_progress_new(sink, opt.progress, opt.incremental);
/*
* Perform the base backup, but make sure we clean up the bbsink even if

View File

@@ -56,7 +56,7 @@ static const bbsink_ops bbsink_progress_ops = {
* forwards data to a successor sink.
*/
bbsink *
bbsink_progress_new(bbsink *next, bool estimate_backup_size)
bbsink_progress_new(bbsink *next, bool estimate_backup_size, bool incremental)
{
bbsink *sink;
@@ -69,10 +69,15 @@ bbsink_progress_new(bbsink *next, bool estimate_backup_size)
/*
* Report that a base backup is in progress, and set the total size of the
* backup to -1, which will get translated to NULL. If we're estimating
* the backup size, we'll insert the real estimate when we have it.
* the backup size, we'll insert the real estimate when we have it. Also,
* the backup type is set.
*/
pgstat_progress_start_command(PROGRESS_COMMAND_BASEBACKUP, InvalidOid);
pgstat_progress_update_param(PROGRESS_BASEBACKUP_BACKUP_TOTAL, -1);
pgstat_progress_update_param(PROGRESS_BASEBACKUP_BACKUP_TYPE,
incremental
? PROGRESS_BASEBACKUP_BACKUP_TYPE_INCREMENTAL
: PROGRESS_BASEBACKUP_BACKUP_TYPE_FULL);
return sink;
}

View File

@@ -1327,7 +1327,10 @@ CREATE VIEW pg_stat_progress_basebackup AS
CASE S.param2 WHEN -1 THEN NULL ELSE S.param2 END AS backup_total,
S.param3 AS backup_streamed,
S.param4 AS tablespaces_total,
S.param5 AS tablespaces_streamed
S.param5 AS tablespaces_streamed,
CASE S.param6 WHEN 1 THEN 'full'
WHEN 2 THEN 'incremental'
END AS backup_type
FROM pg_stat_get_progress_info('BASEBACKUP') AS S;