LCOV - differential code coverage report
Current view: top level - src/backend/access/transam - xlogbackup.c (source / functions) Coverage Total Hit UNC UBC GNC CBC DCB
Current: Differential Code Coverage 16@8cea358b128 vs 17@8cea358b128 Lines: 100.0 % 35 35 6 29 1
Current Date: 2024-04-14 14:21:10 Functions: 100.0 % 1 1 1
Baseline: 16@8cea358b128 Branches: 83.3 % 12 10 1 1 3 7
Baseline Date: 2024-04-14 14:21:09 Line coverage date bins:
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed (60,120] days: 100.0 % 5 5 5
(180,240] days: 100.0 % 1 1 1
(240..) days: 100.0 % 29 29 29
Function coverage date bins:
(240..) days: 100.0 % 1 1 1
Branch coverage date bins:
(60,120] days: 75.0 % 4 3 1 3
(240..) 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-2024, 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 *
  566 michael@paquier.xyz        29                 :CBC         289 : build_backup_content(BackupState *state, bool ishistoryfile)
                                 30                 :                : {
                                 31                 :                :     char        startstrbuf[128];
                                 32                 :                :     char        startxlogfile[MAXFNAMELEN]; /* backup start WAL file */
                                 33                 :                :     XLogSegNo   startsegno;
                                 34                 :            289 :     StringInfo  result = makeStringInfo();
                                 35                 :                :     char       *data;
                                 36                 :                : 
                                 37         [ -  + ]:            289 :     Assert(state != NULL);
                                 38                 :                : 
                                 39                 :                :     /* Use the log timezone here, not the session timezone */
                                 40                 :            289 :     pg_strftime(startstrbuf, sizeof(startstrbuf), "%Y-%m-%d %H:%M:%S %Z",
                                 41                 :            289 :                 pg_localtime(&state->starttime, log_timezone));
                                 42                 :                : 
                                 43                 :            289 :     XLByteToSeg(state->startpoint, startsegno, wal_segment_size);
                                 44                 :            289 :     XLogFileName(startxlogfile, state->starttli, startsegno, wal_segment_size);
                                 45                 :            289 :     appendStringInfo(result, "START WAL LOCATION: %X/%X (file %s)\n",
                                 46                 :            289 :                      LSN_FORMAT_ARGS(state->startpoint), startxlogfile);
                                 47                 :                : 
                                 48         [ +  + ]:            289 :     if (ishistoryfile)
                                 49                 :                :     {
                                 50                 :                :         char        stopxlogfile[MAXFNAMELEN];  /* backup stop WAL file */
                                 51                 :                :         XLogSegNo   stopsegno;
                                 52                 :                : 
                                 53                 :            138 :         XLByteToSeg(state->stoppoint, stopsegno, wal_segment_size);
                                 54                 :            138 :         XLogFileName(stopxlogfile, state->stoptli, stopsegno, wal_segment_size);
                                 55                 :            138 :         appendStringInfo(result, "STOP WAL LOCATION: %X/%X (file %s)\n",
                                 56                 :            138 :                          LSN_FORMAT_ARGS(state->stoppoint), stopxlogfile);
                                 57                 :                :     }
                                 58                 :                : 
                                 59                 :            289 :     appendStringInfo(result, "CHECKPOINT LOCATION: %X/%X\n",
                                 60                 :            289 :                      LSN_FORMAT_ARGS(state->checkpointloc));
  194 drowley@postgresql.o       61                 :GNC         289 :     appendStringInfoString(result, "BACKUP METHOD: streamed\n");
  566 michael@paquier.xyz        62                 :CBC         289 :     appendStringInfo(result, "BACKUP FROM: %s\n",
                                 63         [ +  + ]:            289 :                      state->started_in_recovery ? "standby" : "primary");
                                 64                 :            289 :     appendStringInfo(result, "START TIME: %s\n", startstrbuf);
                                 65                 :            289 :     appendStringInfo(result, "LABEL: %s\n", state->name);
                                 66                 :            289 :     appendStringInfo(result, "START TIMELINE: %u\n", state->starttli);
                                 67                 :                : 
                                 68         [ +  + ]:            289 :     if (ishistoryfile)
                                 69                 :                :     {
                                 70                 :                :         char        stopstrfbuf[128];
                                 71                 :                : 
                                 72                 :                :         /* Use the log timezone here, not the session timezone */
                                 73                 :            138 :         pg_strftime(stopstrfbuf, sizeof(stopstrfbuf), "%Y-%m-%d %H:%M:%S %Z",
                                 74                 :            138 :                     pg_localtime(&state->stoptime, log_timezone));
                                 75                 :                : 
                                 76                 :            138 :         appendStringInfo(result, "STOP TIME: %s\n", stopstrfbuf);
                                 77                 :            138 :         appendStringInfo(result, "STOP TIMELINE: %u\n", state->stoptli);
                                 78                 :                :     }
                                 79                 :                : 
                                 80                 :                :     /* either both istartpoint and istarttli should be set, or neither */
  116 rhaas@postgresql.org       81         [ -  + ]:GNC         289 :     Assert(XLogRecPtrIsInvalid(state->istartpoint) == (state->istarttli == 0));
                                 82         [ +  + ]:            289 :     if (!XLogRecPtrIsInvalid(state->istartpoint))
                                 83                 :                :     {
                                 84                 :             14 :         appendStringInfo(result, "INCREMENTAL FROM LSN: %X/%X\n",
                                 85                 :             14 :                          LSN_FORMAT_ARGS(state->istartpoint));
                                 86                 :             14 :         appendStringInfo(result, "INCREMENTAL FROM TLI: %u\n",
                                 87                 :                :                          state->istarttli);
                                 88                 :                :     }
                                 89                 :                : 
  565 michael@paquier.xyz        90                 :CBC         289 :     data = result->data;
                                 91                 :            289 :     pfree(result);
                                 92                 :                : 
                                 93                 :            289 :     return data;
                                 94                 :                : }
        

Generated by: LCOV version 2.1-beta2-3-g6141622