LCOV - differential code coverage report
Current view: top level - src/backend/access/transam - xlogbackup.c (source / functions) Coverage Total Hit UBC GNC CBC DCB
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 100.0 % 35 35 4 31 4
Current Date: 2025-09-06 07:49:51 +0900 Functions: 100.0 % 1 1 1
Baseline: lcov-20250906-005545-baseline Branches: 83.3 % 12 10 2 10
Baseline Date: 2025-09-05 08:21:35 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(30,360] days: 100.0 % 4 4 4
(360..) days: 100.0 % 31 31 31
Function coverage date bins:
(360..) days: 100.0 % 1 1 1
Branch coverage date bins:
(360..) days: 83.3 % 12 10 2 10

 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-2025, 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 *
 1076 michael@paquier.xyz        29                 :CBC         321 : build_backup_content(BackupState *state, bool ishistoryfile)
                                 30                 :                : {
                                 31                 :                :     char        startstrbuf[128];
                                 32                 :                :     char        startxlogfile[MAXFNAMELEN]; /* backup start WAL file */
                                 33                 :                :     XLogSegNo   startsegno;
                                 34                 :            321 :     StringInfo  result = makeStringInfo();
                                 35                 :                :     char       *data;
                                 36                 :                : 
                                 37         [ -  + ]:            321 :     Assert(state != NULL);
                                 38                 :                : 
                                 39                 :                :     /* Use the log timezone here, not the session timezone */
                                 40                 :            321 :     pg_strftime(startstrbuf, sizeof(startstrbuf), "%Y-%m-%d %H:%M:%S %Z",
                                 41                 :            321 :                 pg_localtime(&state->starttime, log_timezone));
                                 42                 :                : 
                                 43                 :            321 :     XLByteToSeg(state->startpoint, startsegno, wal_segment_size);
                                 44                 :            321 :     XLogFileName(startxlogfile, state->starttli, startsegno, wal_segment_size);
   61 alvherre@kurilemu.de       45                 :GNC         321 :     appendStringInfo(result, "START WAL LOCATION: %X/%08X (file %s)\n",
 1076 michael@paquier.xyz        46                 :CBC         321 :                      LSN_FORMAT_ARGS(state->startpoint), startxlogfile);
                                 47                 :                : 
                                 48         [ +  + ]:            321 :     if (ishistoryfile)
                                 49                 :                :     {
                                 50                 :                :         char        stopxlogfile[MAXFNAMELEN];  /* backup stop WAL file */
                                 51                 :                :         XLogSegNo   stopsegno;
                                 52                 :                : 
                                 53                 :            155 :         XLByteToSeg(state->stoppoint, stopsegno, wal_segment_size);
                                 54                 :            155 :         XLogFileName(stopxlogfile, state->stoptli, stopsegno, wal_segment_size);
   61 alvherre@kurilemu.de       55                 :GNC         155 :         appendStringInfo(result, "STOP WAL LOCATION: %X/%08X (file %s)\n",
 1076 michael@paquier.xyz        56                 :CBC         155 :                          LSN_FORMAT_ARGS(state->stoppoint), stopxlogfile);
                                 57                 :                :     }
                                 58                 :                : 
   61 alvherre@kurilemu.de       59                 :GNC         321 :     appendStringInfo(result, "CHECKPOINT LOCATION: %X/%08X\n",
 1076 michael@paquier.xyz        60                 :CBC         321 :                      LSN_FORMAT_ARGS(state->checkpointloc));
  704 drowley@postgresql.o       61                 :            321 :     appendStringInfoString(result, "BACKUP METHOD: streamed\n");
 1076 michael@paquier.xyz        62                 :            321 :     appendStringInfo(result, "BACKUP FROM: %s\n",
                                 63         [ +  + ]:            321 :                      state->started_in_recovery ? "standby" : "primary");
                                 64                 :            321 :     appendStringInfo(result, "START TIME: %s\n", startstrbuf);
                                 65                 :            321 :     appendStringInfo(result, "LABEL: %s\n", state->name);
                                 66                 :            321 :     appendStringInfo(result, "START TIMELINE: %u\n", state->starttli);
                                 67                 :                : 
                                 68         [ +  + ]:            321 :     if (ishistoryfile)
                                 69                 :                :     {
                                 70                 :                :         char        stopstrfbuf[128];
                                 71                 :                : 
                                 72                 :                :         /* Use the log timezone here, not the session timezone */
                                 73                 :            155 :         pg_strftime(stopstrfbuf, sizeof(stopstrfbuf), "%Y-%m-%d %H:%M:%S %Z",
                                 74                 :            155 :                     pg_localtime(&state->stoptime, log_timezone));
                                 75                 :                : 
                                 76                 :            155 :         appendStringInfo(result, "STOP TIME: %s\n", stopstrfbuf);
                                 77                 :            155 :         appendStringInfo(result, "STOP TIMELINE: %u\n", state->stoptli);
                                 78                 :                :     }
                                 79                 :                : 
                                 80                 :                :     /* either both istartpoint and istarttli should be set, or neither */
  626 rhaas@postgresql.org       81         [ -  + ]:            321 :     Assert(XLogRecPtrIsInvalid(state->istartpoint) == (state->istarttli == 0));
                                 82         [ +  + ]:            321 :     if (!XLogRecPtrIsInvalid(state->istartpoint))
                                 83                 :                :     {
   61 alvherre@kurilemu.de       84                 :GNC          20 :         appendStringInfo(result, "INCREMENTAL FROM LSN: %X/%08X\n",
  626 rhaas@postgresql.org       85                 :CBC          20 :                          LSN_FORMAT_ARGS(state->istartpoint));
                                 86                 :             20 :         appendStringInfo(result, "INCREMENTAL FROM TLI: %u\n",
                                 87                 :                :                          state->istarttli);
                                 88                 :                :     }
                                 89                 :                : 
 1075 michael@paquier.xyz        90                 :            321 :     data = result->data;
                                 91                 :            321 :     pfree(result);
                                 92                 :                : 
                                 93                 :            321 :     return data;
                                 94                 :                : }
        

Generated by: LCOV version 2.4-beta