LCOV - code coverage report
Current view: top level - src/bin/pg_waldump - heapdesc.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 0 145 0.0 %
Date: 2019-09-19 16:06:56 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * heapdesc.c
       4             :  *    rmgr descriptor routines for access/heap/heapam.c
       5             :  *
       6             :  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
       7             :  * Portions Copyright (c) 1994, Regents of the University of California
       8             :  *
       9             :  *
      10             :  * IDENTIFICATION
      11             :  *    src/backend/access/rmgrdesc/heapdesc.c
      12             :  *
      13             :  *-------------------------------------------------------------------------
      14             :  */
      15             : #include "postgres.h"
      16             : 
      17             : #include "access/heapam_xlog.h"
      18             : 
      19             : static void
      20           0 : out_infobits(StringInfo buf, uint8 infobits)
      21             : {
      22           0 :     if (infobits & XLHL_XMAX_IS_MULTI)
      23           0 :         appendStringInfoString(buf, "IS_MULTI ");
      24           0 :     if (infobits & XLHL_XMAX_LOCK_ONLY)
      25           0 :         appendStringInfoString(buf, "LOCK_ONLY ");
      26           0 :     if (infobits & XLHL_XMAX_EXCL_LOCK)
      27           0 :         appendStringInfoString(buf, "EXCL_LOCK ");
      28           0 :     if (infobits & XLHL_XMAX_KEYSHR_LOCK)
      29           0 :         appendStringInfoString(buf, "KEYSHR_LOCK ");
      30           0 :     if (infobits & XLHL_KEYS_UPDATED)
      31           0 :         appendStringInfoString(buf, "KEYS_UPDATED ");
      32           0 : }
      33             : 
      34             : void
      35           0 : heap_desc(StringInfo buf, XLogReaderState *record)
      36             : {
      37           0 :     char       *rec = XLogRecGetData(record);
      38           0 :     uint8       info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
      39             : 
      40           0 :     info &= XLOG_HEAP_OPMASK;
      41           0 :     if (info == XLOG_HEAP_INSERT)
      42             :     {
      43           0 :         xl_heap_insert *xlrec = (xl_heap_insert *) rec;
      44             : 
      45           0 :         appendStringInfo(buf, "off %u flags 0x%02X", xlrec->offnum,
      46           0 :                          xlrec->flags);
      47             :     }
      48           0 :     else if (info == XLOG_HEAP_DELETE)
      49             :     {
      50           0 :         xl_heap_delete *xlrec = (xl_heap_delete *) rec;
      51             : 
      52           0 :         appendStringInfo(buf, "off %u flags 0x%02X ",
      53           0 :                          xlrec->offnum,
      54           0 :                          xlrec->flags);
      55           0 :         out_infobits(buf, xlrec->infobits_set);
      56             :     }
      57           0 :     else if (info == XLOG_HEAP_UPDATE)
      58             :     {
      59           0 :         xl_heap_update *xlrec = (xl_heap_update *) rec;
      60             : 
      61           0 :         appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
      62           0 :                          xlrec->old_offnum,
      63             :                          xlrec->old_xmax,
      64           0 :                          xlrec->flags);
      65           0 :         out_infobits(buf, xlrec->old_infobits_set);
      66           0 :         appendStringInfo(buf, "; new off %u xmax %u",
      67           0 :                          xlrec->new_offnum,
      68             :                          xlrec->new_xmax);
      69             :     }
      70           0 :     else if (info == XLOG_HEAP_HOT_UPDATE)
      71             :     {
      72           0 :         xl_heap_update *xlrec = (xl_heap_update *) rec;
      73             : 
      74           0 :         appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
      75           0 :                          xlrec->old_offnum,
      76             :                          xlrec->old_xmax,
      77           0 :                          xlrec->flags);
      78           0 :         out_infobits(buf, xlrec->old_infobits_set);
      79           0 :         appendStringInfo(buf, "; new off %u xmax %u",
      80           0 :                          xlrec->new_offnum,
      81             :                          xlrec->new_xmax);
      82             :     }
      83           0 :     else if (info == XLOG_HEAP_TRUNCATE)
      84             :     {
      85           0 :         xl_heap_truncate *xlrec = (xl_heap_truncate *) rec;
      86             :         int         i;
      87             : 
      88           0 :         if (xlrec->flags & XLH_TRUNCATE_CASCADE)
      89           0 :             appendStringInfoString(buf, "cascade ");
      90           0 :         if (xlrec->flags & XLH_TRUNCATE_RESTART_SEQS)
      91           0 :             appendStringInfoString(buf, "restart_seqs ");
      92           0 :         appendStringInfo(buf, "nrelids %u relids", xlrec->nrelids);
      93           0 :         for (i = 0; i < xlrec->nrelids; i++)
      94           0 :             appendStringInfo(buf, " %u", xlrec->relids[i]);
      95             :     }
      96           0 :     else if (info == XLOG_HEAP_CONFIRM)
      97             :     {
      98           0 :         xl_heap_confirm *xlrec = (xl_heap_confirm *) rec;
      99             : 
     100           0 :         appendStringInfo(buf, "off %u", xlrec->offnum);
     101             :     }
     102           0 :     else if (info == XLOG_HEAP_LOCK)
     103             :     {
     104           0 :         xl_heap_lock *xlrec = (xl_heap_lock *) rec;
     105             : 
     106           0 :         appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
     107           0 :                          xlrec->offnum, xlrec->locking_xid, xlrec->flags);
     108           0 :         out_infobits(buf, xlrec->infobits_set);
     109             :     }
     110           0 :     else if (info == XLOG_HEAP_INPLACE)
     111             :     {
     112           0 :         xl_heap_inplace *xlrec = (xl_heap_inplace *) rec;
     113             : 
     114           0 :         appendStringInfo(buf, "off %u", xlrec->offnum);
     115             :     }
     116           0 : }
     117             : void
     118           0 : heap2_desc(StringInfo buf, XLogReaderState *record)
     119             : {
     120           0 :     char       *rec = XLogRecGetData(record);
     121           0 :     uint8       info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
     122             : 
     123           0 :     info &= XLOG_HEAP_OPMASK;
     124           0 :     if (info == XLOG_HEAP2_CLEAN)
     125             :     {
     126           0 :         xl_heap_clean *xlrec = (xl_heap_clean *) rec;
     127             : 
     128           0 :         appendStringInfo(buf, "remxid %u", xlrec->latestRemovedXid);
     129             :     }
     130           0 :     else if (info == XLOG_HEAP2_FREEZE_PAGE)
     131             :     {
     132           0 :         xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
     133             : 
     134           0 :         appendStringInfo(buf, "cutoff xid %u ntuples %u",
     135           0 :                          xlrec->cutoff_xid, xlrec->ntuples);
     136             :     }
     137           0 :     else if (info == XLOG_HEAP2_CLEANUP_INFO)
     138             :     {
     139           0 :         xl_heap_cleanup_info *xlrec = (xl_heap_cleanup_info *) rec;
     140             : 
     141           0 :         appendStringInfo(buf, "remxid %u", xlrec->latestRemovedXid);
     142             :     }
     143           0 :     else if (info == XLOG_HEAP2_VISIBLE)
     144             :     {
     145           0 :         xl_heap_visible *xlrec = (xl_heap_visible *) rec;
     146             : 
     147           0 :         appendStringInfo(buf, "cutoff xid %u flags 0x%02X",
     148           0 :                          xlrec->cutoff_xid, xlrec->flags);
     149             :     }
     150           0 :     else if (info == XLOG_HEAP2_MULTI_INSERT)
     151             :     {
     152           0 :         xl_heap_multi_insert *xlrec = (xl_heap_multi_insert *) rec;
     153             : 
     154           0 :         appendStringInfo(buf, "%d tuples flags 0x%02X", xlrec->ntuples,
     155           0 :                          xlrec->flags);
     156             :     }
     157           0 :     else if (info == XLOG_HEAP2_LOCK_UPDATED)
     158             :     {
     159           0 :         xl_heap_lock_updated *xlrec = (xl_heap_lock_updated *) rec;
     160             : 
     161           0 :         appendStringInfo(buf, "off %u: xmax %u: flags 0x%02X ",
     162           0 :                          xlrec->offnum, xlrec->xmax, xlrec->flags);
     163           0 :         out_infobits(buf, xlrec->infobits_set);
     164             :     }
     165           0 :     else if (info == XLOG_HEAP2_NEW_CID)
     166             :     {
     167           0 :         xl_heap_new_cid *xlrec = (xl_heap_new_cid *) rec;
     168             : 
     169           0 :         appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
     170             :                          xlrec->target_node.spcNode,
     171             :                          xlrec->target_node.dbNode,
     172             :                          xlrec->target_node.relNode,
     173           0 :                          ItemPointerGetBlockNumber(&(xlrec->target_tid)),
     174           0 :                          ItemPointerGetOffsetNumber(&(xlrec->target_tid)));
     175           0 :         appendStringInfo(buf, "; cmin: %u, cmax: %u, combo: %u",
     176             :                          xlrec->cmin, xlrec->cmax, xlrec->combocid);
     177             :     }
     178           0 : }
     179             : 
     180             : const char *
     181           0 : heap_identify(uint8 info)
     182             : {
     183           0 :     const char *id = NULL;
     184             : 
     185           0 :     switch (info & ~XLR_INFO_MASK)
     186             :     {
     187             :         case XLOG_HEAP_INSERT:
     188           0 :             id = "INSERT";
     189           0 :             break;
     190             :         case XLOG_HEAP_INSERT | XLOG_HEAP_INIT_PAGE:
     191           0 :             id = "INSERT+INIT";
     192           0 :             break;
     193             :         case XLOG_HEAP_DELETE:
     194           0 :             id = "DELETE";
     195           0 :             break;
     196             :         case XLOG_HEAP_UPDATE:
     197           0 :             id = "UPDATE";
     198           0 :             break;
     199             :         case XLOG_HEAP_UPDATE | XLOG_HEAP_INIT_PAGE:
     200           0 :             id = "UPDATE+INIT";
     201           0 :             break;
     202             :         case XLOG_HEAP_HOT_UPDATE:
     203           0 :             id = "HOT_UPDATE";
     204           0 :             break;
     205             :         case XLOG_HEAP_HOT_UPDATE | XLOG_HEAP_INIT_PAGE:
     206           0 :             id = "HOT_UPDATE+INIT";
     207           0 :             break;
     208             :         case XLOG_HEAP_TRUNCATE:
     209           0 :             id = "TRUNCATE";
     210           0 :             break;
     211             :         case XLOG_HEAP_CONFIRM:
     212           0 :             id = "HEAP_CONFIRM";
     213           0 :             break;
     214             :         case XLOG_HEAP_LOCK:
     215           0 :             id = "LOCK";
     216           0 :             break;
     217             :         case XLOG_HEAP_INPLACE:
     218           0 :             id = "INPLACE";
     219           0 :             break;
     220             :     }
     221             : 
     222           0 :     return id;
     223             : }
     224             : 
     225             : const char *
     226           0 : heap2_identify(uint8 info)
     227             : {
     228           0 :     const char *id = NULL;
     229             : 
     230           0 :     switch (info & ~XLR_INFO_MASK)
     231             :     {
     232             :         case XLOG_HEAP2_CLEAN:
     233           0 :             id = "CLEAN";
     234           0 :             break;
     235             :         case XLOG_HEAP2_FREEZE_PAGE:
     236           0 :             id = "FREEZE_PAGE";
     237           0 :             break;
     238             :         case XLOG_HEAP2_CLEANUP_INFO:
     239           0 :             id = "CLEANUP_INFO";
     240           0 :             break;
     241             :         case XLOG_HEAP2_VISIBLE:
     242           0 :             id = "VISIBLE";
     243           0 :             break;
     244             :         case XLOG_HEAP2_MULTI_INSERT:
     245           0 :             id = "MULTI_INSERT";
     246           0 :             break;
     247             :         case XLOG_HEAP2_MULTI_INSERT | XLOG_HEAP_INIT_PAGE:
     248           0 :             id = "MULTI_INSERT+INIT";
     249           0 :             break;
     250             :         case XLOG_HEAP2_LOCK_UPDATED:
     251           0 :             id = "LOCK_UPDATED";
     252           0 :             break;
     253             :         case XLOG_HEAP2_NEW_CID:
     254           0 :             id = "NEW_CID";
     255           0 :             break;
     256             :         case XLOG_HEAP2_REWRITE:
     257           0 :             id = "REWRITE";
     258           0 :             break;
     259             :     }
     260             : 
     261           0 :     return id;
     262             : }

Generated by: LCOV version 1.13