LCOV - code coverage report
Current view: top level - src/backend/access/rmgrdesc - heapdesc.c (source / functions) Hit Total Coverage
Test: PostgreSQL 15devel Lines: 0 167 0.0 %
Date: 2021-12-04 22:09:09 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-2021, 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_PRUNE)
     125             :     {
     126           0 :         xl_heap_prune *xlrec = (xl_heap_prune *) rec;
     127             : 
     128           0 :         appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
     129             :                          xlrec->latestRemovedXid,
     130           0 :                          xlrec->nredirected,
     131           0 :                          xlrec->ndead);
     132             :     }
     133           0 :     else if (info == XLOG_HEAP2_VACUUM)
     134             :     {
     135           0 :         xl_heap_vacuum *xlrec = (xl_heap_vacuum *) rec;
     136             : 
     137           0 :         appendStringInfo(buf, "nunused %u", xlrec->nunused);
     138             :     }
     139           0 :     else if (info == XLOG_HEAP2_FREEZE_PAGE)
     140             :     {
     141           0 :         xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
     142             : 
     143           0 :         appendStringInfo(buf, "cutoff xid %u ntuples %u",
     144           0 :                          xlrec->cutoff_xid, xlrec->ntuples);
     145             :     }
     146           0 :     else if (info == XLOG_HEAP2_VISIBLE)
     147             :     {
     148           0 :         xl_heap_visible *xlrec = (xl_heap_visible *) rec;
     149             : 
     150           0 :         appendStringInfo(buf, "cutoff xid %u flags 0x%02X",
     151           0 :                          xlrec->cutoff_xid, xlrec->flags);
     152             :     }
     153           0 :     else if (info == XLOG_HEAP2_MULTI_INSERT)
     154             :     {
     155           0 :         xl_heap_multi_insert *xlrec = (xl_heap_multi_insert *) rec;
     156             : 
     157           0 :         appendStringInfo(buf, "%d tuples flags 0x%02X", xlrec->ntuples,
     158           0 :                          xlrec->flags);
     159             :     }
     160           0 :     else if (info == XLOG_HEAP2_LOCK_UPDATED)
     161             :     {
     162           0 :         xl_heap_lock_updated *xlrec = (xl_heap_lock_updated *) rec;
     163             : 
     164           0 :         appendStringInfo(buf, "off %u: xmax %u: flags 0x%02X ",
     165           0 :                          xlrec->offnum, xlrec->xmax, xlrec->flags);
     166           0 :         out_infobits(buf, xlrec->infobits_set);
     167             :     }
     168           0 :     else if (info == XLOG_HEAP2_NEW_CID)
     169             :     {
     170           0 :         xl_heap_new_cid *xlrec = (xl_heap_new_cid *) rec;
     171             : 
     172           0 :         appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
     173             :                          xlrec->target_node.spcNode,
     174             :                          xlrec->target_node.dbNode,
     175             :                          xlrec->target_node.relNode,
     176           0 :                          ItemPointerGetBlockNumber(&(xlrec->target_tid)),
     177           0 :                          ItemPointerGetOffsetNumber(&(xlrec->target_tid)));
     178           0 :         appendStringInfo(buf, "; cmin: %u, cmax: %u, combo: %u",
     179             :                          xlrec->cmin, xlrec->cmax, xlrec->combocid);
     180             :     }
     181           0 : }
     182             : 
     183             : const char *
     184           0 : heap_identify(uint8 info)
     185             : {
     186           0 :     const char *id = NULL;
     187             : 
     188           0 :     switch (info & ~XLR_INFO_MASK)
     189             :     {
     190           0 :         case XLOG_HEAP_INSERT:
     191           0 :             id = "INSERT";
     192           0 :             break;
     193           0 :         case XLOG_HEAP_INSERT | XLOG_HEAP_INIT_PAGE:
     194           0 :             id = "INSERT+INIT";
     195           0 :             break;
     196           0 :         case XLOG_HEAP_DELETE:
     197           0 :             id = "DELETE";
     198           0 :             break;
     199           0 :         case XLOG_HEAP_UPDATE:
     200           0 :             id = "UPDATE";
     201           0 :             break;
     202           0 :         case XLOG_HEAP_UPDATE | XLOG_HEAP_INIT_PAGE:
     203           0 :             id = "UPDATE+INIT";
     204           0 :             break;
     205           0 :         case XLOG_HEAP_HOT_UPDATE:
     206           0 :             id = "HOT_UPDATE";
     207           0 :             break;
     208           0 :         case XLOG_HEAP_HOT_UPDATE | XLOG_HEAP_INIT_PAGE:
     209           0 :             id = "HOT_UPDATE+INIT";
     210           0 :             break;
     211           0 :         case XLOG_HEAP_TRUNCATE:
     212           0 :             id = "TRUNCATE";
     213           0 :             break;
     214           0 :         case XLOG_HEAP_CONFIRM:
     215           0 :             id = "HEAP_CONFIRM";
     216           0 :             break;
     217           0 :         case XLOG_HEAP_LOCK:
     218           0 :             id = "LOCK";
     219           0 :             break;
     220           0 :         case XLOG_HEAP_INPLACE:
     221           0 :             id = "INPLACE";
     222           0 :             break;
     223             :     }
     224             : 
     225           0 :     return id;
     226             : }
     227             : 
     228             : const char *
     229           0 : heap2_identify(uint8 info)
     230             : {
     231           0 :     const char *id = NULL;
     232             : 
     233           0 :     switch (info & ~XLR_INFO_MASK)
     234             :     {
     235           0 :         case XLOG_HEAP2_PRUNE:
     236           0 :             id = "PRUNE";
     237           0 :             break;
     238           0 :         case XLOG_HEAP2_VACUUM:
     239           0 :             id = "VACUUM";
     240           0 :             break;
     241           0 :         case XLOG_HEAP2_FREEZE_PAGE:
     242           0 :             id = "FREEZE_PAGE";
     243           0 :             break;
     244           0 :         case XLOG_HEAP2_VISIBLE:
     245           0 :             id = "VISIBLE";
     246           0 :             break;
     247           0 :         case XLOG_HEAP2_MULTI_INSERT:
     248           0 :             id = "MULTI_INSERT";
     249           0 :             break;
     250           0 :         case XLOG_HEAP2_MULTI_INSERT | XLOG_HEAP_INIT_PAGE:
     251           0 :             id = "MULTI_INSERT+INIT";
     252           0 :             break;
     253           0 :         case XLOG_HEAP2_LOCK_UPDATED:
     254           0 :             id = "LOCK_UPDATED";
     255           0 :             break;
     256           0 :         case XLOG_HEAP2_NEW_CID:
     257           0 :             id = "NEW_CID";
     258           0 :             break;
     259           0 :         case XLOG_HEAP2_REWRITE:
     260           0 :             id = "REWRITE";
     261           0 :             break;
     262             :     }
     263             : 
     264           0 :     return id;
     265             : }

Generated by: LCOV version 1.14