LCOV - differential code coverage report
Current view: top level - src/backend/access/transam - xlogbackup.c (source / functions) Coverage Total Hit UNC UBC GNC CBC DUB DCB
Current: 0e5ff9b9b45a657aea12440478dc002e9b01f138 vs 0123ce131fca454009439dfa3b2266d1d40737d7 Lines: 100.0 % 33 33 16 17 18
Current Date: 2026-03-14 14:10:32 -0400 Functions: 100.0 % 1 1 1
Baseline: lcov-20260315-024220-baseline Branches: 83.3 % 12 10 1 1 3 7 1 3
Baseline Date: 2026-03-14 15:27:56 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(30,360] days: 100.0 % 16 16 16
(360..) days: 100.0 % 17 17 17
Function coverage date bins:
(360..) days: 100.0 % 1 1 1
Branch coverage date bins:
(30,360] days: 75.0 % 4 3 1 3
(360..) days: 87.5 % 8 7 1 7

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * xlogbackup.c
                                  4                 :                :  *      Internal routines for base backups.
                                  5                 :                :  *
                                  6                 :                :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
                                  7                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                  8                 :                :  *
                                  9                 :                :  * IDENTIFICATION
                                 10                 :                :  *      src/backend/access/transam/xlogbackup.c
                                 11                 :                :  *-------------------------------------------------------------------------
                                 12                 :                :  */
                                 13                 :                : 
                                 14                 :                : #include "postgres.h"
                                 15                 :                : 
                                 16                 :                : #include "access/xlog.h"
                                 17                 :                : #include "access/xlog_internal.h"
                                 18                 :                : #include "access/xlogbackup.h"
                                 19                 :                : 
                                 20                 :                : /*
                                 21                 :                :  * Build contents for backup_label or backup history file.
                                 22                 :                :  *
                                 23                 :                :  * When ishistoryfile is true, it creates the contents for a backup history
                                 24                 :                :  * file, otherwise it creates contents for a backup_label file.
                                 25                 :                :  *
                                 26                 :                :  * Returns the result generated as a palloc'd string.
                                 27                 :                :  */
                                 28                 :                : char *
 1266 michael@paquier.xyz        29                 :CBC         339 : build_backup_content(BackupState *state, bool ishistoryfile)
                                 30                 :                : {
                                 31                 :                :     char        startstrbuf[128];
                                 32                 :                :     char        startxlogfile[MAXFNAMELEN]; /* backup start WAL file */
                                 33                 :                :     XLogSegNo   startsegno;
                                 34                 :                :     StringInfoData result;
                                 35                 :                : 
                                 36         [ -  + ]:            339 :     Assert(state != NULL);
                                 37                 :                : 
  129 drowley@postgresql.o       38                 :GNC         339 :     initStringInfo(&result);
                                 39                 :                : 
                                 40                 :                :     /* Use the log timezone here, not the session timezone */
 1266 michael@paquier.xyz        41                 :CBC         339 :     pg_strftime(startstrbuf, sizeof(startstrbuf), "%Y-%m-%d %H:%M:%S %Z",
                                 42                 :            339 :                 pg_localtime(&state->starttime, log_timezone));
                                 43                 :                : 
                                 44                 :            339 :     XLByteToSeg(state->startpoint, startsegno, wal_segment_size);
                                 45                 :            339 :     XLogFileName(startxlogfile, state->starttli, startsegno, wal_segment_size);
  129 drowley@postgresql.o       46                 :GNC         339 :     appendStringInfo(&result, "START WAL LOCATION: %X/%08X (file %s)\n",
 1266 michael@paquier.xyz        47                 :CBC         339 :                      LSN_FORMAT_ARGS(state->startpoint), startxlogfile);
                                 48                 :                : 
                                 49         [ +  + ]:            339 :     if (ishistoryfile)
                                 50                 :                :     {
                                 51                 :                :         char        stopxlogfile[MAXFNAMELEN];  /* backup stop WAL file */
                                 52                 :                :         XLogSegNo   stopsegno;
                                 53                 :                : 
                                 54                 :            163 :         XLByteToSeg(state->stoppoint, stopsegno, wal_segment_size);
                                 55                 :            163 :         XLogFileName(stopxlogfile, state->stoptli, stopsegno, wal_segment_size);
  129 drowley@postgresql.o       56                 :GNC         163 :         appendStringInfo(&result, "STOP WAL LOCATION: %X/%08X (file %s)\n",
 1266 michael@paquier.xyz        57                 :CBC         163 :                          LSN_FORMAT_ARGS(state->stoppoint), stopxlogfile);
                                 58                 :                :     }
                                 59                 :                : 
  129 drowley@postgresql.o       60                 :GNC         339 :     appendStringInfo(&result, "CHECKPOINT LOCATION: %X/%08X\n",
 1266 michael@paquier.xyz        61                 :CBC         339 :                      LSN_FORMAT_ARGS(state->checkpointloc));
  129 drowley@postgresql.o       62                 :GNC         339 :     appendStringInfoString(&result, "BACKUP METHOD: streamed\n");
                                 63                 :            339 :     appendStringInfo(&result, "BACKUP FROM: %s\n",
 1266 michael@paquier.xyz        64         [ +  + ]:CBC         339 :                      state->started_in_recovery ? "standby" : "primary");
  129 drowley@postgresql.o       65                 :GNC         339 :     appendStringInfo(&result, "START TIME: %s\n", startstrbuf);
                                 66                 :            339 :     appendStringInfo(&result, "LABEL: %s\n", state->name);
                                 67                 :            339 :     appendStringInfo(&result, "START TIMELINE: %u\n", state->starttli);
                                 68                 :                : 
 1266 michael@paquier.xyz        69         [ +  + ]:CBC         339 :     if (ishistoryfile)
                                 70                 :                :     {
                                 71                 :                :         char        stopstrfbuf[128];
                                 72                 :                : 
                                 73                 :                :         /* Use the log timezone here, not the session timezone */
                                 74                 :            163 :         pg_strftime(stopstrfbuf, sizeof(stopstrfbuf), "%Y-%m-%d %H:%M:%S %Z",
                                 75                 :            163 :                     pg_localtime(&state->stoptime, log_timezone));
                                 76                 :                : 
  129 drowley@postgresql.o       77                 :GNC         163 :         appendStringInfo(&result, "STOP TIME: %s\n", stopstrfbuf);
                                 78                 :            163 :         appendStringInfo(&result, "STOP TIMELINE: %u\n", state->stoptli);
                                 79                 :                :     }
                                 80                 :                : 
                                 81                 :                :     /* either both istartpoint and istarttli should be set, or neither */
      alvherre@kurilemu.de       82         [ -  + ]:            339 :     Assert(XLogRecPtrIsValid(state->istartpoint) == (state->istarttli != 0));
                                 83         [ +  + ]:            339 :     if (XLogRecPtrIsValid(state->istartpoint))
                                 84                 :                :     {
      drowley@postgresql.o       85                 :             20 :         appendStringInfo(&result, "INCREMENTAL FROM LSN: %X/%08X\n",
  816 rhaas@postgresql.org       86                 :CBC          20 :                          LSN_FORMAT_ARGS(state->istartpoint));
  129 drowley@postgresql.o       87                 :GNC          20 :         appendStringInfo(&result, "INCREMENTAL FROM TLI: %u\n",
                                 88                 :                :                          state->istarttli);
                                 89                 :                :     }
                                 90                 :                : 
                                 91                 :            339 :     return result.data;
                                 92                 :                : }
        

Generated by: LCOV version 2.4-beta