LCOV - differential code coverage report
Current view: top level - src/common - pg_parse_lsn.c (source / functions) Coverage Total Hit GNC
Current: ba12a202ce1b5581dc0ed149cf3f637d7897ad5d vs 2866d8c7dbfc9d882a7d80fef93fbbe763709932 Lines: 100.0 % 10 10 10
Current Date: 2026-08-27 14:31:44 +0300 Functions: 100.0 % 1 1 1
Baseline: lcov-20260827-baseline Branches: 100.0 % 12 12 12
Baseline Date: 2026-08-27 14:31:58 +0300 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(7,30] days: 100.0 % 10 10 10
Function coverage date bins:
(7,30] days: 100.0 % 1 1 1
Branch coverage date bins:
(7,30] days: 100.0 % 12 12 12

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * pg_parse_lsn.c
                                  4                 :                :  *    Parse a WAL location (LSN) in its text form.
                                  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/common/pg_parse_lsn.c
                                 11                 :                :  *
                                 12                 :                :  *-------------------------------------------------------------------------
                                 13                 :                :  */
                                 14                 :                : 
                                 15                 :                : #ifndef FRONTEND
                                 16                 :                : #include "postgres.h"
                                 17                 :                : #else
                                 18                 :                : #include "postgres_fe.h"
                                 19                 :                : #endif
                                 20                 :                : 
                                 21                 :                : #include "common/pg_parse_lsn.h"
                                 22                 :                : 
                                 23                 :                : #define MAXPG_LSNCOMPONENT  8
                                 24                 :                : 
                                 25                 :                : /*
                                 26                 :                :  * pg_parse_lsn
                                 27                 :                :  *
                                 28                 :                :  * Parse a WAL location in the "%X/%X" text form used for pg_lsn values,
                                 29                 :                :  * requiring one to eight hexadecimal digits in each component and nothing
                                 30                 :                :  * else.  Unlike sscanf(), this rejects components longer than eight
                                 31                 :                :  * hexadecimal digits, leading whitespace, signs, "0x" prefixes, and
                                 32                 :                :  * trailing characters.
                                 33                 :                :  *
                                 34                 :                :  * Returns true and sets *result on success; returns false on syntax
                                 35                 :                :  * error, leaving *result unchanged.
                                 36                 :                :  */
                                 37                 :                : bool
   15 fujii@postgresql.org       38                 :GNC        6022 : pg_parse_lsn(const char *str, XLogRecPtr *result)
                                 39                 :                : {
                                 40                 :                :     size_t      len1,
                                 41                 :                :                 len2;
                                 42                 :                : 
                                 43                 :           6022 :     len1 = strspn(str, "0123456789abcdefABCDEF");
                                 44   [ +  +  +  +  :           6022 :     if (len1 < 1 || len1 > MAXPG_LSNCOMPONENT || str[len1] != '/')
                                              +  + ]
                                 45                 :             32 :         return false;
                                 46                 :                : 
                                 47                 :           5990 :     len2 = strspn(str + len1 + 1, "0123456789abcdefABCDEF");
                                 48   [ +  +  +  +  :           5990 :     if (len2 < 1 || len2 > MAXPG_LSNCOMPONENT || str[len1 + 1 + len2] != '\0')
                                              +  + ]
                                 49                 :              9 :         return false;
                                 50                 :                : 
                                 51                 :           5981 :     *result = ((uint64) strtoul(str, NULL, 16)) << 32 |
                                 52                 :           5981 :         (uint32) strtoul(str + len1 + 1, NULL, 16);
                                 53                 :                : 
                                 54                 :           5981 :     return true;
                                 55                 :                : }
        

Generated by: LCOV version 2.0-1