LCOV - code coverage report
Current view: top level - src/bin/pg_waldump - smgrdesc.c (source / functions) Hit Total Coverage
Test: PostgreSQL 18devel Lines: 24 24 100.0 %
Date: 2024-11-21 10:14:43 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * smgrdesc.c
       4             :  *    rmgr descriptor routines for catalog/storage.c
       5             :  *
       6             :  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
       7             :  * Portions Copyright (c) 1994, Regents of the University of California
       8             :  *
       9             :  *
      10             :  * IDENTIFICATION
      11             :  *    src/backend/access/rmgrdesc/smgrdesc.c
      12             :  *
      13             :  *-------------------------------------------------------------------------
      14             :  */
      15             : #include "postgres.h"
      16             : 
      17             : #include "catalog/storage_xlog.h"
      18             : 
      19             : 
      20             : void
      21        3986 : smgr_desc(StringInfo buf, XLogReaderState *record)
      22             : {
      23        3986 :     char       *rec = XLogRecGetData(record);
      24        3986 :     uint8       info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
      25             : 
      26        3986 :     if (info == XLOG_SMGR_CREATE)
      27             :     {
      28        3974 :         xl_smgr_create *xlrec = (xl_smgr_create *) rec;
      29        3974 :         char       *path = relpathperm(xlrec->rlocator, xlrec->forkNum);
      30             : 
      31        3974 :         appendStringInfoString(buf, path);
      32        3974 :         pfree(path);
      33             :     }
      34          12 :     else if (info == XLOG_SMGR_TRUNCATE)
      35             :     {
      36          12 :         xl_smgr_truncate *xlrec = (xl_smgr_truncate *) rec;
      37          12 :         char       *path = relpathperm(xlrec->rlocator, MAIN_FORKNUM);
      38             : 
      39          12 :         appendStringInfo(buf, "%s to %u blocks flags %d", path,
      40             :                          xlrec->blkno, xlrec->flags);
      41          12 :         pfree(path);
      42             :     }
      43        3986 : }
      44             : 
      45             : const char *
      46        3990 : smgr_identify(uint8 info)
      47             : {
      48        3990 :     const char *id = NULL;
      49             : 
      50        3990 :     switch (info & ~XLR_INFO_MASK)
      51             :     {
      52        3976 :         case XLOG_SMGR_CREATE:
      53        3976 :             id = "CREATE";
      54        3976 :             break;
      55          14 :         case XLOG_SMGR_TRUNCATE:
      56          14 :             id = "TRUNCATE";
      57          14 :             break;
      58             :     }
      59             : 
      60        3990 :     return id;
      61             : }

Generated by: LCOV version 1.14