LCOV - differential code coverage report
Current view: top level - src/backend/access/rmgrdesc - standbydesc.c (source / functions) Coverage Total Hit UNC LBC UIC UBC GBC GIC GNC CBC EUB ECB DUB
Current: Differential Code Coverage HEAD vs 15 Lines: 72.6 % 62 45 4 4 5 4 4 19 1 21 8 20 1
Current Date: 2023-04-08 17:13:01 Functions: 100.0 % 4 4 3 1 3
Baseline: 15 Line coverage date bins:
Baseline Date: 2023-04-08 15:09:40 (120,180] days: 20.0 % 5 1 4 1
Legend: Lines: hit not hit (240..) days: 77.2 % 57 44 4 5 4 4 19 21 6 18
Function coverage date bins:
(240..) days: 57.1 % 7 4 3 1 3

 Age         Owner                  TLA  Line data    Source code
                                  1                 : /*-------------------------------------------------------------------------
                                  2                 :  *
                                  3                 :  * standbydesc.c
                                  4                 :  *    rmgr descriptor routines for storage/ipc/standby.c
                                  5                 :  *
                                  6                 :  * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
                                  7                 :  * Portions Copyright (c) 1994, Regents of the University of California
                                  8                 :  *
                                  9                 :  *
                                 10                 :  * IDENTIFICATION
                                 11                 :  *    src/backend/access/rmgrdesc/standbydesc.c
                                 12                 :  *
                                 13                 :  *-------------------------------------------------------------------------
                                 14                 :  */
                                 15                 : #include "postgres.h"
                                 16                 : 
                                 17                 : #include "storage/standbydefs.h"
                                 18                 : 
                                 19                 : static void
 3784 alvherre                   20 CBC           4 : standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
                                 21                 : {
                                 22                 :     int         i;
                                 23                 : 
 3124 andres                     24               4 :     appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
                                 25                 :                      xlrec->nextXid,
                                 26                 :                      xlrec->latestCompletedXid,
                                 27                 :                      xlrec->oldestRunningXid);
 3784 alvherre                   28               4 :     if (xlrec->xcnt > 0)
                                 29                 :     {
 3784 alvherre                   30 UBC           0 :         appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
                                 31               0 :         for (i = 0; i < xlrec->xcnt; i++)
                                 32               0 :             appendStringInfo(buf, " %u", xlrec->xids[i]);
                                 33                 :     }
                                 34                 : 
 3784 alvherre                   35 CBC           4 :     if (xlrec->subxid_overflow)
  158 akapila                    36 UNC           0 :         appendStringInfoString(buf, "; subxid overflowed");
                                 37                 : 
  158 akapila                    38 GNC           4 :     if (xlrec->subxcnt > 0)
                                 39                 :     {
  158 akapila                    40 UNC           0 :         appendStringInfo(buf, "; %d subxacts:", xlrec->subxcnt);
                                 41               0 :         for (i = 0; i < xlrec->subxcnt; i++)
                                 42               0 :             appendStringInfo(buf, " %u", xlrec->xids[xlrec->xcnt + i]);
                                 43                 :     }
 3784 alvherre                   44 GIC           4 : }
 3784 alvherre                   45 ECB             : 
                                 46                 : void
 3062 heikki.linnakangas         47 GBC           6 : standby_desc(StringInfo buf, XLogReaderState *record)
 3784 alvherre                   48 EUB             : {
 3221 heikki.linnakangas         49 GBC           6 :     char       *rec = XLogRecGetData(record);
 3062 heikki.linnakangas         50 GIC           6 :     uint8       info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
 3784 alvherre                   51 ECB             : 
 3784 alvherre                   52 GIC           6 :     if (info == XLOG_STANDBY_LOCK)
                                 53                 :     {
 3784 alvherre                   54 CBC           2 :         xl_standby_locks *xlrec = (xl_standby_locks *) rec;
                                 55                 :         int         i;
 3784 alvherre                   56 ECB             : 
 3784 alvherre                   57 CBC           4 :         for (i = 0; i < xlrec->nlocks; i++)
 3124 andres                     58 GIC           2 :             appendStringInfo(buf, "xid %u db %u rel %u ",
 3784 alvherre                   59 ECB             :                              xlrec->locks[i].xid, xlrec->locks[i].dbOid,
                                 60                 :                              xlrec->locks[i].relOid);
                                 61                 :     }
 3784 alvherre                   62 GIC           4 :     else if (info == XLOG_RUNNING_XACTS)
                                 63                 :     {
 3784 alvherre                   64 CBC           4 :         xl_running_xacts *xlrec = (xl_running_xacts *) rec;
 3784 alvherre                   65 ECB             : 
 3784 alvherre                   66 GIC           4 :         standby_desc_running_xacts(buf, xlrec);
                                 67                 :     }
 2542 andres                     68 UIC           0 :     else if (info == XLOG_INVALIDATIONS)
 2542 andres                     69 ECB             :     {
 2542 andres                     70 UIC           0 :         xl_invalidations *xlrec = (xl_invalidations *) rec;
 2542 andres                     71 ECB             : 
 2542 andres                     72 UIC           0 :         standby_desc_invalidations(buf, xlrec->nmsgs, xlrec->msgs,
 2542 andres                     73 ECB             :                                    xlrec->dbId, xlrec->tsId,
 2542 andres                     74 UIC           0 :                                    xlrec->relcacheInitFileInval);
 2542 andres                     75 EUB             :     }
 3124 andres                     76 GIC           6 : }
 3124 andres                     77 EUB             : 
                                 78                 : const char *
 3124 andres                     79 GBC           6 : standby_identify(uint8 info)
                                 80                 : {
                                 81               6 :     const char *id = NULL;
                                 82                 : 
 3121 andres                     83 CBC           6 :     switch (info & ~XLR_INFO_MASK)
                                 84                 :     {
 3124 andres                     85 GIC           2 :         case XLOG_STANDBY_LOCK:
 3124 andres                     86 CBC           2 :             id = "LOCK";
 3124 andres                     87 GIC           2 :             break;
 3124 andres                     88 CBC           4 :         case XLOG_RUNNING_XACTS:
 3124 andres                     89 GIC           4 :             id = "RUNNING_XACTS";
 3124 andres                     90 CBC           4 :             break;
 2542 andres                     91 UIC           0 :         case XLOG_INVALIDATIONS:
 2542 andres                     92 LBC           0 :             id = "INVALIDATIONS";
                                 93               0 :             break;
 3124 andres                     94 ECB             :     }
                                 95                 : 
 3124 andres                     96 CBC           6 :     return id;
 3784 alvherre                   97 ECB             : }
 2542 andres                     98 EUB             : 
                                 99                 : /*
                                100                 :  * This routine is used by both standby_desc and xact_desc, because
                                101                 :  * transaction commits and XLOG_INVALIDATIONS messages contain invalidations;
                                102                 :  * it seems pointless to duplicate the code.
 2542 andres                    103 ECB             :  */
                                104                 : void
 2542 andres                    105 GIC          28 : standby_desc_invalidations(StringInfo buf,
                                106                 :                            int nmsgs, SharedInvalidationMessage *msgs,
                                107                 :                            Oid dbId, Oid tsId,
                                108                 :                            bool relcacheInitFileInval)
                                109                 : {
                                110                 :     int         i;
                                111                 : 
 1243 fujii                     112 ECB             :     /* Do nothing if there are no invalidation messages */
 1243 fujii                     113 GIC          28 :     if (nmsgs <= 0)
                                114               7 :         return;
                                115                 : 
 2542 andres                    116              21 :     if (relcacheInitFileInval)
                                117               2 :         appendStringInfo(buf, "; relcache init file inval dbid %u tsid %u",
                                118                 :                          dbId, tsId);
                                119                 : 
 2542 andres                    120 CBC          21 :     appendStringInfoString(buf, "; inval msgs:");
                                121             573 :     for (i = 0; i < nmsgs; i++)
                                122                 :     {
                                123             552 :         SharedInvalidationMessage *msg = &msgs[i];
 2542 andres                    124 ECB             : 
 2542 andres                    125 GIC         552 :         if (msg->id >= 0)
                                126             464 :             appendStringInfo(buf, " catcache %d", msg->id);
 2542 andres                    127 CBC          88 :         else if (msg->id == SHAREDINVALCATALOG_ID)
                                128               1 :             appendStringInfo(buf, " catalog %u", msg->cat.catId);
 2542 andres                    129 GIC          87 :         else if (msg->id == SHAREDINVALRELCACHE_ID)
 2542 andres                    130 CBC          53 :             appendStringInfo(buf, " relcache %u", msg->rc.relId);
                                131                 :         /* not expected, but print something anyway */
                                132              34 :         else if (msg->id == SHAREDINVALSMGR_ID)
 2542 andres                    133 LBC           0 :             appendStringInfoString(buf, " smgr");
 2542 andres                    134 ECB             :         /* not expected, but print something anyway */
 2542 andres                    135 CBC          34 :         else if (msg->id == SHAREDINVALRELMAP_ID)
 2542 andres                    136 LBC           0 :             appendStringInfo(buf, " relmap db %u", msg->rm.dbId);
 2542 andres                    137 CBC          34 :         else if (msg->id == SHAREDINVALSNAPSHOT_ID)
 2542 andres                    138 GIC          34 :             appendStringInfo(buf, " snapshot %u", msg->sn.relId);
 2542 andres                    139 ECB             :         else
 2389 tgl                       140 UBC           0 :             appendStringInfo(buf, " unrecognized id %d", msg->id);
                                141                 :     }
 2542 andres                    142 ECB             : }
        

Generated by: LCOV version v1.16-55-g56c0a2a