LCOV - code coverage report
Current view: top level - src/backend/access/rmgrdesc - dbasedesc.c (source / functions) Hit Total Coverage
Test: PostgreSQL 17devel Lines: 23 28 82.1 %
Date: 2024-04-20 00:11:33 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * dbasedesc.c
       4             :  *    rmgr descriptor routines for commands/dbcommands.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/dbasedesc.c
      12             :  *
      13             :  *-------------------------------------------------------------------------
      14             :  */
      15             : #include "postgres.h"
      16             : 
      17             : #include "commands/dbcommands_xlog.h"
      18             : #include "lib/stringinfo.h"
      19             : 
      20             : 
      21             : void
      22          38 : dbase_desc(StringInfo buf, XLogReaderState *record)
      23             : {
      24          38 :     char       *rec = XLogRecGetData(record);
      25          38 :     uint8       info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
      26             : 
      27          38 :     if (info == XLOG_DBASE_CREATE_FILE_COPY)
      28             :     {
      29          12 :         xl_dbase_create_file_copy_rec *xlrec =
      30             :             (xl_dbase_create_file_copy_rec *) rec;
      31             : 
      32          12 :         appendStringInfo(buf, "copy dir %u/%u to %u/%u",
      33             :                          xlrec->src_tablespace_id, xlrec->src_db_id,
      34             :                          xlrec->tablespace_id, xlrec->db_id);
      35             :     }
      36          26 :     else if (info == XLOG_DBASE_CREATE_WAL_LOG)
      37             :     {
      38           0 :         xl_dbase_create_wal_log_rec *xlrec =
      39             :             (xl_dbase_create_wal_log_rec *) rec;
      40             : 
      41           0 :         appendStringInfo(buf, "create dir %u/%u",
      42             :                          xlrec->tablespace_id, xlrec->db_id);
      43             :     }
      44          26 :     else if (info == XLOG_DBASE_DROP)
      45             :     {
      46          26 :         xl_dbase_drop_rec *xlrec = (xl_dbase_drop_rec *) rec;
      47             :         int         i;
      48             : 
      49          26 :         appendStringInfoString(buf, "dir");
      50          52 :         for (i = 0; i < xlrec->ntablespaces; i++)
      51          26 :             appendStringInfo(buf, " %u/%u",
      52             :                              xlrec->tablespace_ids[i], xlrec->db_id);
      53             :     }
      54          38 : }
      55             : 
      56             : const char *
      57          38 : dbase_identify(uint8 info)
      58             : {
      59          38 :     const char *id = NULL;
      60             : 
      61          38 :     switch (info & ~XLR_INFO_MASK)
      62             :     {
      63          12 :         case XLOG_DBASE_CREATE_FILE_COPY:
      64          12 :             id = "CREATE_FILE_COPY";
      65          12 :             break;
      66           0 :         case XLOG_DBASE_CREATE_WAL_LOG:
      67           0 :             id = "CREATE_WAL_LOG";
      68           0 :             break;
      69          26 :         case XLOG_DBASE_DROP:
      70          26 :             id = "DROP";
      71          26 :             break;
      72             :     }
      73             : 
      74          38 :     return id;
      75             : }

Generated by: LCOV version 1.14