LCOV - code coverage report
Current view: top level - src/bin/pg_waldump - nbtdesc.c (source / functions) Hit Total Coverage
Test: PostgreSQL 14devel Lines: 0 98 0.0 %
Date: 2020-11-27 12:05:55 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * nbtdesc.c
       4             :  *    rmgr descriptor routines for access/nbtree/nbtxlog.c
       5             :  *
       6             :  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
       7             :  * Portions Copyright (c) 1994, Regents of the University of California
       8             :  *
       9             :  *
      10             :  * IDENTIFICATION
      11             :  *    src/backend/access/rmgrdesc/nbtdesc.c
      12             :  *
      13             :  *-------------------------------------------------------------------------
      14             :  */
      15             : #include "postgres.h"
      16             : 
      17             : #include "access/nbtxlog.h"
      18             : 
      19             : void
      20           0 : btree_desc(StringInfo buf, XLogReaderState *record)
      21             : {
      22           0 :     char       *rec = XLogRecGetData(record);
      23           0 :     uint8       info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
      24             : 
      25           0 :     switch (info)
      26             :     {
      27           0 :         case XLOG_BTREE_INSERT_LEAF:
      28             :         case XLOG_BTREE_INSERT_UPPER:
      29             :         case XLOG_BTREE_INSERT_META:
      30             :         case XLOG_BTREE_INSERT_POST:
      31             :             {
      32           0 :                 xl_btree_insert *xlrec = (xl_btree_insert *) rec;
      33             : 
      34           0 :                 appendStringInfo(buf, "off %u", xlrec->offnum);
      35           0 :                 break;
      36             :             }
      37           0 :         case XLOG_BTREE_SPLIT_L:
      38             :         case XLOG_BTREE_SPLIT_R:
      39             :             {
      40           0 :                 xl_btree_split *xlrec = (xl_btree_split *) rec;
      41             : 
      42           0 :                 appendStringInfo(buf, "level %u, firstrightoff %d, newitemoff %d, postingoff %d",
      43           0 :                                  xlrec->level, xlrec->firstrightoff,
      44           0 :                                  xlrec->newitemoff, xlrec->postingoff);
      45           0 :                 break;
      46             :             }
      47           0 :         case XLOG_BTREE_DEDUP:
      48             :             {
      49           0 :                 xl_btree_dedup *xlrec = (xl_btree_dedup *) rec;
      50             : 
      51           0 :                 appendStringInfo(buf, "nintervals %u", xlrec->nintervals);
      52           0 :                 break;
      53             :             }
      54           0 :         case XLOG_BTREE_VACUUM:
      55             :             {
      56           0 :                 xl_btree_vacuum *xlrec = (xl_btree_vacuum *) rec;
      57             : 
      58           0 :                 appendStringInfo(buf, "ndeleted %u; nupdated %u",
      59           0 :                                  xlrec->ndeleted, xlrec->nupdated);
      60           0 :                 break;
      61             :             }
      62           0 :         case XLOG_BTREE_DELETE:
      63             :             {
      64           0 :                 xl_btree_delete *xlrec = (xl_btree_delete *) rec;
      65             : 
      66           0 :                 appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u",
      67             :                                  xlrec->latestRemovedXid, xlrec->ndeleted);
      68           0 :                 break;
      69             :             }
      70           0 :         case XLOG_BTREE_MARK_PAGE_HALFDEAD:
      71             :             {
      72           0 :                 xl_btree_mark_page_halfdead *xlrec = (xl_btree_mark_page_halfdead *) rec;
      73             : 
      74           0 :                 appendStringInfo(buf, "topparent %u; leaf %u; left %u; right %u",
      75             :                                  xlrec->topparent, xlrec->leafblk, xlrec->leftblk, xlrec->rightblk);
      76           0 :                 break;
      77             :             }
      78           0 :         case XLOG_BTREE_UNLINK_PAGE_META:
      79             :         case XLOG_BTREE_UNLINK_PAGE:
      80             :             {
      81           0 :                 xl_btree_unlink_page *xlrec = (xl_btree_unlink_page *) rec;
      82             : 
      83           0 :                 appendStringInfo(buf, "left %u; right %u; btpo_xact %u; ",
      84             :                                  xlrec->leftsib, xlrec->rightsib,
      85             :                                  xlrec->btpo_xact);
      86           0 :                 appendStringInfo(buf, "leafleft %u; leafright %u; topparent %u",
      87             :                                  xlrec->leafleftsib, xlrec->leafrightsib,
      88             :                                  xlrec->topparent);
      89           0 :                 break;
      90             :             }
      91           0 :         case XLOG_BTREE_NEWROOT:
      92             :             {
      93           0 :                 xl_btree_newroot *xlrec = (xl_btree_newroot *) rec;
      94             : 
      95           0 :                 appendStringInfo(buf, "lev %u", xlrec->level);
      96           0 :                 break;
      97             :             }
      98           0 :         case XLOG_BTREE_REUSE_PAGE:
      99             :             {
     100           0 :                 xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
     101             : 
     102           0 :                 appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u",
     103             :                                  xlrec->node.spcNode, xlrec->node.dbNode,
     104             :                                  xlrec->node.relNode, xlrec->latestRemovedXid);
     105           0 :                 break;
     106             :             }
     107           0 :         case XLOG_BTREE_META_CLEANUP:
     108             :             {
     109             :                 xl_btree_metadata *xlrec;
     110             : 
     111           0 :                 xlrec = (xl_btree_metadata *) XLogRecGetBlockData(record, 0,
     112             :                                                                   NULL);
     113           0 :                 appendStringInfo(buf, "oldest_btpo_xact %u; last_cleanup_num_heap_tuples: %f",
     114             :                                  xlrec->oldest_btpo_xact,
     115             :                                  xlrec->last_cleanup_num_heap_tuples);
     116           0 :                 break;
     117             :             }
     118             :     }
     119           0 : }
     120             : 
     121             : const char *
     122           0 : btree_identify(uint8 info)
     123             : {
     124           0 :     const char *id = NULL;
     125             : 
     126           0 :     switch (info & ~XLR_INFO_MASK)
     127             :     {
     128           0 :         case XLOG_BTREE_INSERT_LEAF:
     129           0 :             id = "INSERT_LEAF";
     130           0 :             break;
     131           0 :         case XLOG_BTREE_INSERT_UPPER:
     132           0 :             id = "INSERT_UPPER";
     133           0 :             break;
     134           0 :         case XLOG_BTREE_INSERT_META:
     135           0 :             id = "INSERT_META";
     136           0 :             break;
     137           0 :         case XLOG_BTREE_SPLIT_L:
     138           0 :             id = "SPLIT_L";
     139           0 :             break;
     140           0 :         case XLOG_BTREE_SPLIT_R:
     141           0 :             id = "SPLIT_R";
     142           0 :             break;
     143           0 :         case XLOG_BTREE_INSERT_POST:
     144           0 :             id = "INSERT_POST";
     145           0 :             break;
     146           0 :         case XLOG_BTREE_DEDUP:
     147           0 :             id = "DEDUP";
     148           0 :             break;
     149           0 :         case XLOG_BTREE_VACUUM:
     150           0 :             id = "VACUUM";
     151           0 :             break;
     152           0 :         case XLOG_BTREE_DELETE:
     153           0 :             id = "DELETE";
     154           0 :             break;
     155           0 :         case XLOG_BTREE_MARK_PAGE_HALFDEAD:
     156           0 :             id = "MARK_PAGE_HALFDEAD";
     157           0 :             break;
     158           0 :         case XLOG_BTREE_UNLINK_PAGE:
     159           0 :             id = "UNLINK_PAGE";
     160           0 :             break;
     161           0 :         case XLOG_BTREE_UNLINK_PAGE_META:
     162           0 :             id = "UNLINK_PAGE_META";
     163           0 :             break;
     164           0 :         case XLOG_BTREE_NEWROOT:
     165           0 :             id = "NEWROOT";
     166           0 :             break;
     167           0 :         case XLOG_BTREE_REUSE_PAGE:
     168           0 :             id = "REUSE_PAGE";
     169           0 :             break;
     170           0 :         case XLOG_BTREE_META_CLEANUP:
     171           0 :             id = "META_CLEANUP";
     172           0 :             break;
     173             :     }
     174             : 
     175           0 :     return id;
     176             : }

Generated by: LCOV version 1.13