LCOV - differential code coverage report
Current view: top level - src/backend/access/rmgrdesc - xactdesc.c (source / functions) Coverage Total Hit UNC UBC GNC CBC DUB
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 80.6 % 248 200 3 45 200 3
Current Date: 2025-09-06 07:49:51 +0900 Functions: 83.3 % 12 10 1 1 2 8
Baseline: lcov-20250906-005545-baseline Branches: 73.8 % 84 62 22 62
Baseline Date: 2025-09-05 08:21:35 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(30,360] days: 70.0 % 10 7 3 7
(360..) days: 81.1 % 238 193 45 193
Function coverage date bins:
(360..) days: 83.3 % 12 10 1 1 2 8
Branch coverage date bins:
(360..) days: 73.8 % 84 62 22 62

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * xactdesc.c
                                  4                 :                :  *    rmgr descriptor routines for access/transam/xact.c
                                  5                 :                :  *
                                  6                 :                :  * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
                                  7                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                  8                 :                :  *
                                  9                 :                :  *
                                 10                 :                :  * IDENTIFICATION
                                 11                 :                :  *    src/backend/access/rmgrdesc/xactdesc.c
                                 12                 :                :  *
                                 13                 :                :  *-------------------------------------------------------------------------
                                 14                 :                :  */
                                 15                 :                : #include "postgres.h"
                                 16                 :                : 
                                 17                 :                : #include "access/transam.h"
                                 18                 :                : #include "access/xact.h"
                                 19                 :                : #include "replication/origin.h"
                                 20                 :                : #include "storage/sinval.h"
                                 21                 :                : #include "storage/standbydefs.h"
                                 22                 :                : #include "utils/timestamp.h"
                                 23                 :                : 
                                 24                 :                : /*
                                 25                 :                :  * Parse the WAL format of an xact commit and abort records into an easier to
                                 26                 :                :  * understand format.
                                 27                 :                :  *
                                 28                 :                :  * These routines are in xactdesc.c because they're accessed in backend (when
                                 29                 :                :  * replaying WAL) and frontend (pg_waldump) code. This file is the only xact
                                 30                 :                :  * specific one shared between both. They're complicated enough that
                                 31                 :                :  * duplication would be bothersome.
                                 32                 :                :  */
                                 33                 :                : 
                                 34                 :                : void
 3828 andres@anarazel.de         35                 :CBC       27203 : ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *parsed)
                                 36                 :                : {
                                 37                 :          27203 :     char       *data = ((char *) xlrec) + MinSizeOfXactCommit;
                                 38                 :                : 
                                 39                 :          27203 :     memset(parsed, 0, sizeof(*parsed));
                                 40                 :                : 
 3759 bruce@momjian.us           41                 :          27203 :     parsed->xinfo = 0;           /* default, if no XLOG_XACT_HAS_INFO is
                                 42                 :                :                                  * present */
                                 43                 :                : 
 3828 andres@anarazel.de         44                 :          27203 :     parsed->xact_time = xlrec->xact_time;
                                 45                 :                : 
                                 46         [ +  + ]:          27203 :     if (info & XLOG_XACT_HAS_INFO)
                                 47                 :                :     {
                                 48                 :          20136 :         xl_xact_xinfo *xl_xinfo = (xl_xact_xinfo *) data;
                                 49                 :                : 
                                 50                 :          20136 :         parsed->xinfo = xl_xinfo->xinfo;
                                 51                 :                : 
                                 52                 :          20136 :         data += sizeof(xl_xact_xinfo);
                                 53                 :                :     }
                                 54                 :                : 
                                 55         [ +  + ]:          27203 :     if (parsed->xinfo & XACT_XINFO_HAS_DBINFO)
                                 56                 :                :     {
                                 57                 :          19973 :         xl_xact_dbinfo *xl_dbinfo = (xl_xact_dbinfo *) data;
                                 58                 :                : 
                                 59                 :          19973 :         parsed->dbId = xl_dbinfo->dbId;
                                 60                 :          19973 :         parsed->tsId = xl_dbinfo->tsId;
                                 61                 :                : 
                                 62                 :          19973 :         data += sizeof(xl_xact_dbinfo);
                                 63                 :                :     }
                                 64                 :                : 
                                 65         [ +  + ]:          27203 :     if (parsed->xinfo & XACT_XINFO_HAS_SUBXACTS)
                                 66                 :                :     {
 3759 bruce@momjian.us           67                 :            229 :         xl_xact_subxacts *xl_subxacts = (xl_xact_subxacts *) data;
                                 68                 :                : 
 3828 andres@anarazel.de         69                 :            229 :         parsed->nsubxacts = xl_subxacts->nsubxacts;
                                 70                 :            229 :         parsed->subxacts = xl_subxacts->subxacts;
                                 71                 :                : 
                                 72                 :            229 :         data += MinSizeOfXactSubxacts;
                                 73                 :            229 :         data += parsed->nsubxacts * sizeof(TransactionId);
                                 74                 :                :     }
                                 75                 :                : 
 1158 rhaas@postgresql.org       76         [ +  + ]:          27203 :     if (parsed->xinfo & XACT_XINFO_HAS_RELFILELOCATORS)
                                 77                 :                :     {
                                 78                 :           2231 :         xl_xact_relfilelocators *xl_rellocators = (xl_xact_relfilelocators *) data;
                                 79                 :                : 
                                 80                 :           2231 :         parsed->nrels = xl_rellocators->nrels;
                                 81                 :           2231 :         parsed->xlocators = xl_rellocators->xlocators;
                                 82                 :                : 
                                 83                 :           2231 :         data += MinSizeOfXactRelfileLocators;
                                 84                 :           2231 :         data += xl_rellocators->nrels * sizeof(RelFileLocator);
                                 85                 :                :     }
                                 86                 :                : 
 1249 andres@anarazel.de         87         [ +  + ]:          27203 :     if (parsed->xinfo & XACT_XINFO_HAS_DROPPED_STATS)
                                 88                 :                :     {
                                 89                 :           2813 :         xl_xact_stats_items *xl_drops = (xl_xact_stats_items *) data;
                                 90                 :                : 
                                 91                 :           2813 :         parsed->nstats = xl_drops->nitems;
                                 92                 :           2813 :         parsed->stats = xl_drops->items;
                                 93                 :                : 
                                 94                 :           2813 :         data += MinSizeOfXactStatsItems;
                                 95                 :           2813 :         data += xl_drops->nitems * sizeof(xl_xact_stats_item);
                                 96                 :                :     }
                                 97                 :                : 
 3828                            98         [ +  + ]:          27203 :     if (parsed->xinfo & XACT_XINFO_HAS_INVALS)
                                 99                 :                :     {
                                100                 :          18042 :         xl_xact_invals *xl_invals = (xl_xact_invals *) data;
                                101                 :                : 
                                102                 :          18042 :         parsed->nmsgs = xl_invals->nmsgs;
                                103                 :          18042 :         parsed->msgs = xl_invals->msgs;
                                104                 :                : 
                                105                 :          18042 :         data += MinSizeOfXactInvals;
                                106                 :          18042 :         data += xl_invals->nmsgs * sizeof(SharedInvalidationMessage);
                                107                 :                :     }
                                108                 :                : 
                                109         [ +  + ]:          27203 :     if (parsed->xinfo & XACT_XINFO_HAS_TWOPHASE)
                                110                 :                :     {
                                111                 :            188 :         xl_xact_twophase *xl_twophase = (xl_xact_twophase *) data;
                                112                 :                : 
                                113                 :            188 :         parsed->twophase_xid = xl_twophase->xid;
                                114                 :                : 
                                115                 :            188 :         data += sizeof(xl_xact_twophase);
                                116                 :                : 
 2719 simon@2ndQuadrant.co      117         [ +  + ]:            188 :         if (parsed->xinfo & XACT_XINFO_HAS_GID)
                                118                 :                :         {
 2714 tgl@sss.pgh.pa.us         119                 :            104 :             strlcpy(parsed->twophase_gid, data, sizeof(parsed->twophase_gid));
 2699 heikki.linnakangas@i      120                 :            104 :             data += strlen(data) + 1;
                                121                 :                :         }
                                122                 :                :     }
                                123                 :                : 
                                124                 :                :     /* Note: no alignment is guaranteed after this point */
                                125                 :                : 
 3783 andres@anarazel.de        126         [ +  + ]:          27203 :     if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
                                127                 :                :     {
                                128                 :                :         xl_xact_origin xl_origin;
                                129                 :                : 
                                130                 :                :         /* no alignment is guaranteed, so copy onto stack */
 3781                           131                 :             96 :         memcpy(&xl_origin, data, sizeof(xl_origin));
                                132                 :                : 
                                133                 :             96 :         parsed->origin_lsn = xl_origin.origin_lsn;
                                134                 :             96 :         parsed->origin_timestamp = xl_origin.origin_timestamp;
                                135                 :                : 
 3783                           136                 :             96 :         data += sizeof(xl_xact_origin);
                                137                 :                :     }
 3828                           138                 :          27203 : }
                                139                 :                : 
                                140                 :                : void
                                141                 :           1978 : ParseAbortRecord(uint8 info, xl_xact_abort *xlrec, xl_xact_parsed_abort *parsed)
                                142                 :                : {
                                143                 :           1978 :     char       *data = ((char *) xlrec) + MinSizeOfXactAbort;
                                144                 :                : 
                                145                 :           1978 :     memset(parsed, 0, sizeof(*parsed));
                                146                 :                : 
 3759 bruce@momjian.us          147                 :           1978 :     parsed->xinfo = 0;           /* default, if no XLOG_XACT_HAS_INFO is
                                148                 :                :                                  * present */
                                149                 :                : 
 3828 andres@anarazel.de        150                 :           1978 :     parsed->xact_time = xlrec->xact_time;
                                151                 :                : 
                                152         [ +  + ]:           1978 :     if (info & XLOG_XACT_HAS_INFO)
                                153                 :                :     {
                                154                 :           1266 :         xl_xact_xinfo *xl_xinfo = (xl_xact_xinfo *) data;
                                155                 :                : 
                                156                 :           1266 :         parsed->xinfo = xl_xinfo->xinfo;
                                157                 :                : 
                                158                 :           1266 :         data += sizeof(xl_xact_xinfo);
                                159                 :                :     }
                                160                 :                : 
 2719 simon@2ndQuadrant.co      161         [ +  + ]:           1978 :     if (parsed->xinfo & XACT_XINFO_HAS_DBINFO)
                                162                 :                :     {
                                163                 :             40 :         xl_xact_dbinfo *xl_dbinfo = (xl_xact_dbinfo *) data;
                                164                 :                : 
                                165                 :             40 :         parsed->dbId = xl_dbinfo->dbId;
                                166                 :             40 :         parsed->tsId = xl_dbinfo->tsId;
                                167                 :                : 
                                168                 :             40 :         data += sizeof(xl_xact_dbinfo);
                                169                 :                :     }
                                170                 :                : 
 3828 andres@anarazel.de        171         [ +  + ]:           1978 :     if (parsed->xinfo & XACT_XINFO_HAS_SUBXACTS)
                                172                 :                :     {
 3759 bruce@momjian.us          173                 :             23 :         xl_xact_subxacts *xl_subxacts = (xl_xact_subxacts *) data;
                                174                 :                : 
 3828 andres@anarazel.de        175                 :             23 :         parsed->nsubxacts = xl_subxacts->nsubxacts;
                                176                 :             23 :         parsed->subxacts = xl_subxacts->subxacts;
                                177                 :                : 
                                178                 :             23 :         data += MinSizeOfXactSubxacts;
                                179                 :             23 :         data += parsed->nsubxacts * sizeof(TransactionId);
                                180                 :                :     }
                                181                 :                : 
 1158 rhaas@postgresql.org      182         [ +  + ]:           1978 :     if (parsed->xinfo & XACT_XINFO_HAS_RELFILELOCATORS)
                                183                 :                :     {
                                184                 :            337 :         xl_xact_relfilelocators *xl_rellocator = (xl_xact_relfilelocators *) data;
                                185                 :                : 
                                186                 :            337 :         parsed->nrels = xl_rellocator->nrels;
                                187                 :            337 :         parsed->xlocators = xl_rellocator->xlocators;
                                188                 :                : 
                                189                 :            337 :         data += MinSizeOfXactRelfileLocators;
                                190                 :            337 :         data += xl_rellocator->nrels * sizeof(RelFileLocator);
                                191                 :                :     }
                                192                 :                : 
 1249 andres@anarazel.de        193         [ +  + ]:           1978 :     if (parsed->xinfo & XACT_XINFO_HAS_DROPPED_STATS)
                                194                 :                :     {
                                195                 :            431 :         xl_xact_stats_items *xl_drops = (xl_xact_stats_items *) data;
                                196                 :                : 
                                197                 :            431 :         parsed->nstats = xl_drops->nitems;
                                198                 :            431 :         parsed->stats = xl_drops->items;
                                199                 :                : 
                                200                 :            431 :         data += MinSizeOfXactStatsItems;
                                201                 :            431 :         data += xl_drops->nitems * sizeof(xl_xact_stats_item);
                                202                 :                :     }
                                203                 :                : 
 3828                           204         [ +  + ]:           1978 :     if (parsed->xinfo & XACT_XINFO_HAS_TWOPHASE)
                                205                 :                :     {
                                206                 :             78 :         xl_xact_twophase *xl_twophase = (xl_xact_twophase *) data;
                                207                 :                : 
                                208                 :             78 :         parsed->twophase_xid = xl_twophase->xid;
                                209                 :                : 
                                210                 :             78 :         data += sizeof(xl_xact_twophase);
                                211                 :                : 
 2719 simon@2ndQuadrant.co      212         [ +  + ]:             78 :         if (parsed->xinfo & XACT_XINFO_HAS_GID)
                                213                 :                :         {
 2714 tgl@sss.pgh.pa.us         214                 :             40 :             strlcpy(parsed->twophase_gid, data, sizeof(parsed->twophase_gid));
 2699 heikki.linnakangas@i      215                 :             40 :             data += strlen(data) + 1;
                                216                 :                :         }
                                217                 :                :     }
                                218                 :                : 
                                219                 :                :     /* Note: no alignment is guaranteed after this point */
                                220                 :                : 
 2719 simon@2ndQuadrant.co      221         [ +  + ]:           1978 :     if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
                                222                 :                :     {
                                223                 :                :         xl_xact_origin xl_origin;
                                224                 :                : 
                                225                 :                :         /* no alignment is guaranteed, so copy onto stack */
                                226                 :              9 :         memcpy(&xl_origin, data, sizeof(xl_origin));
                                227                 :                : 
                                228                 :              9 :         parsed->origin_lsn = xl_origin.origin_lsn;
                                229                 :              9 :         parsed->origin_timestamp = xl_origin.origin_timestamp;
                                230                 :                : 
                                231                 :              9 :         data += sizeof(xl_xact_origin);
                                232                 :                :     }
 3828 andres@anarazel.de        233                 :           1978 : }
                                234                 :                : 
                                235                 :                : /*
                                236                 :                :  * ParsePrepareRecord
                                237                 :                :  */
                                238                 :                : void
 2124 fujii@postgresql.org      239                 :            152 : ParsePrepareRecord(uint8 info, xl_xact_prepare *xlrec, xl_xact_parsed_prepare *parsed)
                                240                 :                : {
                                241                 :                :     char       *bufptr;
                                242                 :                : 
                                243                 :            152 :     bufptr = ((char *) xlrec) + MAXALIGN(sizeof(xl_xact_prepare));
                                244                 :                : 
                                245                 :            152 :     memset(parsed, 0, sizeof(*parsed));
                                246                 :                : 
                                247                 :            152 :     parsed->xact_time = xlrec->prepared_at;
                                248                 :            152 :     parsed->origin_lsn = xlrec->origin_lsn;
                                249                 :            152 :     parsed->origin_timestamp = xlrec->origin_timestamp;
                                250                 :            152 :     parsed->twophase_xid = xlrec->xid;
                                251                 :            152 :     parsed->dbId = xlrec->database;
                                252                 :            152 :     parsed->nsubxacts = xlrec->nsubxacts;
                                253                 :            152 :     parsed->nrels = xlrec->ncommitrels;
                                254                 :            152 :     parsed->nabortrels = xlrec->nabortrels;
  108                           255                 :            152 :     parsed->nstats = xlrec->ncommitstats;
                                256                 :            152 :     parsed->nabortstats = xlrec->nabortstats;
 2124                           257                 :            152 :     parsed->nmsgs = xlrec->ninvalmsgs;
                                258                 :                : 
                                259                 :            152 :     strncpy(parsed->twophase_gid, bufptr, xlrec->gidlen);
                                260                 :            152 :     bufptr += MAXALIGN(xlrec->gidlen);
                                261                 :                : 
                                262                 :            152 :     parsed->subxacts = (TransactionId *) bufptr;
                                263                 :            152 :     bufptr += MAXALIGN(xlrec->nsubxacts * sizeof(TransactionId));
                                264                 :                : 
 1158 rhaas@postgresql.org      265                 :            152 :     parsed->xlocators = (RelFileLocator *) bufptr;
                                266                 :            152 :     bufptr += MAXALIGN(xlrec->ncommitrels * sizeof(RelFileLocator));
                                267                 :                : 
                                268                 :            152 :     parsed->abortlocators = (RelFileLocator *) bufptr;
                                269                 :            152 :     bufptr += MAXALIGN(xlrec->nabortrels * sizeof(RelFileLocator));
                                270                 :                : 
 1249 andres@anarazel.de        271                 :            152 :     parsed->stats = (xl_xact_stats_item *) bufptr;
                                272                 :            152 :     bufptr += MAXALIGN(xlrec->ncommitstats * sizeof(xl_xact_stats_item));
                                273                 :                : 
                                274                 :            152 :     parsed->abortstats = (xl_xact_stats_item *) bufptr;
                                275                 :            152 :     bufptr += MAXALIGN(xlrec->nabortstats * sizeof(xl_xact_stats_item));
                                276                 :                : 
 2124 fujii@postgresql.org      277                 :            152 :     parsed->msgs = (SharedInvalidationMessage *) bufptr;
                                278                 :            152 :     bufptr += MAXALIGN(xlrec->ninvalmsgs * sizeof(SharedInvalidationMessage));
                                279                 :            152 : }
                                280                 :                : 
                                281                 :                : static void
                                282                 :           1694 : xact_desc_relations(StringInfo buf, char *label, int nrels,
                                283                 :                :                     RelFileLocator *xlocators)
                                284                 :                : {
                                285                 :                :     int         i;
                                286                 :                : 
                                287         [ +  + ]:           1694 :     if (nrels > 0)
                                288                 :                :     {
                                289                 :             15 :         appendStringInfo(buf, "; %s:", label);
                                290         [ +  + ]:             71 :         for (i = 0; i < nrels; i++)
                                291                 :                :         {
  193 andres@anarazel.de        292                 :             56 :             appendStringInfo(buf, " %s",
                                293                 :             56 :                              relpathperm(xlocators[i], MAIN_FORKNUM).str);
                                294                 :                :         }
                                295                 :                :     }
 2124 fujii@postgresql.org      296                 :           1694 : }
                                297                 :                : 
                                298                 :                : static void
                                299                 :           1694 : xact_desc_subxacts(StringInfo buf, int nsubxacts, TransactionId *subxacts)
                                300                 :                : {
                                301                 :                :     int         i;
                                302                 :                : 
                                303         [ -  + ]:           1694 :     if (nsubxacts > 0)
                                304                 :                :     {
 4328 rhaas@postgresql.org      305                 :UBC           0 :         appendStringInfoString(buf, "; subxacts:");
 2124 fujii@postgresql.org      306         [ #  # ]:              0 :         for (i = 0; i < nsubxacts; i++)
                                307                 :              0 :             appendStringInfo(buf, " %u", subxacts[i]);
                                308                 :                :     }
 2124 fujii@postgresql.org      309                 :CBC        1694 : }
                                310                 :                : 
                                311                 :                : static void
 1249 andres@anarazel.de        312                 :           1694 : xact_desc_stats(StringInfo buf, const char *label,
                                313                 :                :                 int ndropped, xl_xact_stats_item *dropped_stats)
                                314                 :                : {
                                315                 :                :     int         i;
                                316                 :                : 
                                317         [ +  + ]:           1694 :     if (ndropped > 0)
                                318                 :                :     {
                                319                 :             18 :         appendStringInfo(buf, "; %sdropped stats:", label);
                                320         [ +  + ]:             39 :         for (i = 0; i < ndropped; i++)
                                321                 :                :         {
  353 michael@paquier.xyz       322                 :             21 :             uint64      objid =
                                323                 :             21 :                 ((uint64) dropped_stats[i].objid_hi) << 32 | dropped_stats[i].objid_lo;
                                324                 :                : 
  161 peter@eisentraut.org      325                 :             21 :             appendStringInfo(buf, " %d/%u/%" PRIu64,
 1249 andres@anarazel.de        326                 :             21 :                              dropped_stats[i].kind,
                                327                 :             21 :                              dropped_stats[i].dboid,
                                328                 :                :                              objid);
                                329                 :                :         }
                                330                 :                :     }
                                331                 :           1694 : }
                                332                 :                : 
                                333                 :                : static void
 2124 fujii@postgresql.org      334                 :           1688 : xact_desc_commit(StringInfo buf, uint8 info, xl_xact_commit *xlrec, RepOriginId origin_id)
                                335                 :                : {
                                336                 :                :     xl_xact_parsed_commit parsed;
                                337                 :                : 
                                338                 :           1688 :     ParseCommitRecord(info, xlrec, &parsed);
                                339                 :                : 
                                340                 :                :     /* If this is a prepared xact, show the xid of the original xact */
                                341         [ -  + ]:           1688 :     if (TransactionIdIsValid(parsed.twophase_xid))
 2124 fujii@postgresql.org      342                 :UBC           0 :         appendStringInfo(buf, "%u: ", parsed.twophase_xid);
                                343                 :                : 
 2124 fujii@postgresql.org      344                 :CBC        1688 :     appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
                                345                 :                : 
 1158 rhaas@postgresql.org      346                 :           1688 :     xact_desc_relations(buf, "rels", parsed.nrels, parsed.xlocators);
 2124 fujii@postgresql.org      347                 :           1688 :     xact_desc_subxacts(buf, parsed.nsubxacts, parsed.subxacts);
 1249 andres@anarazel.de        348                 :           1688 :     xact_desc_stats(buf, "", parsed.nstats, parsed.stats);
                                349                 :                : 
 2046 alvherre@alvh.no-ip.      350                 :           1688 :     standby_desc_invalidations(buf, parsed.nmsgs, parsed.msgs, parsed.dbId,
                                351                 :                :                                parsed.tsId,
                                352                 :           1688 :                                XactCompletionRelcacheInitFileInval(parsed.xinfo));
                                353                 :                : 
 1363 michael@paquier.xyz       354         [ -  + ]:           1688 :     if (XactCompletionApplyFeedback(parsed.xinfo))
 1363 michael@paquier.xyz       355                 :UBC           0 :         appendStringInfoString(buf, "; apply_feedback");
                                356                 :                : 
 3828 andres@anarazel.de        357         [ +  + ]:CBC        1688 :     if (XactCompletionForceSyncCommit(parsed.xinfo))
 3719 heikki.linnakangas@i      358                 :             39 :         appendStringInfoString(buf, "; sync");
                                359                 :                : 
 3783 andres@anarazel.de        360         [ -  + ]:           1688 :     if (parsed.xinfo & XACT_XINFO_HAS_ORIGIN)
                                361                 :                :     {
   61 alvherre@kurilemu.de      362                 :UNC           0 :         appendStringInfo(buf, "; origin: node %u, lsn %X/%08X, at %s",
                                363                 :                :                          origin_id,
 1656 peter@eisentraut.org      364                 :UBC           0 :                          LSN_FORMAT_ARGS(parsed.origin_lsn),
                                365                 :                :                          timestamptz_to_str(parsed.origin_timestamp));
                                366                 :                :     }
 4665 alvherre@alvh.no-ip.      367                 :CBC        1688 : }
                                368                 :                : 
                                369                 :                : static void
 1363 michael@paquier.xyz       370                 :              6 : xact_desc_abort(StringInfo buf, uint8 info, xl_xact_abort *xlrec, RepOriginId origin_id)
                                371                 :                : {
                                372                 :                :     xl_xact_parsed_abort parsed;
                                373                 :                : 
 3828 andres@anarazel.de        374                 :              6 :     ParseAbortRecord(info, xlrec, &parsed);
                                375                 :                : 
                                376                 :                :     /* If this is a prepared xact, show the xid of the original xact */
                                377         [ -  + ]:              6 :     if (TransactionIdIsValid(parsed.twophase_xid))
 3828 andres@anarazel.de        378                 :UBC           0 :         appendStringInfo(buf, "%u: ", parsed.twophase_xid);
                                379                 :                : 
 4665 alvherre@alvh.no-ip.      380                 :CBC           6 :     appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
                                381                 :                : 
 1158 rhaas@postgresql.org      382                 :              6 :     xact_desc_relations(buf, "rels", parsed.nrels, parsed.xlocators);
 2124 fujii@postgresql.org      383                 :              6 :     xact_desc_subxacts(buf, parsed.nsubxacts, parsed.subxacts);
                                384                 :                : 
 1363 michael@paquier.xyz       385         [ -  + ]:              6 :     if (parsed.xinfo & XACT_XINFO_HAS_ORIGIN)
                                386                 :                :     {
   61 alvherre@kurilemu.de      387                 :UNC           0 :         appendStringInfo(buf, "; origin: node %u, lsn %X/%08X, at %s",
                                388                 :                :                          origin_id,
 1363 michael@paquier.xyz       389                 :UBC           0 :                          LSN_FORMAT_ARGS(parsed.origin_lsn),
                                390                 :                :                          timestamptz_to_str(parsed.origin_timestamp));
                                391                 :                :     }
                                392                 :                : 
 1249 andres@anarazel.de        393                 :CBC           6 :     xact_desc_stats(buf, "", parsed.nstats, parsed.stats);
 2124 fujii@postgresql.org      394                 :              6 : }
                                395                 :                : 
                                396                 :                : static void
 1363 michael@paquier.xyz       397                 :UBC           0 : xact_desc_prepare(StringInfo buf, uint8 info, xl_xact_prepare *xlrec, RepOriginId origin_id)
                                398                 :                : {
                                399                 :                :     xl_xact_parsed_prepare parsed;
                                400                 :                : 
 2124 fujii@postgresql.org      401                 :              0 :     ParsePrepareRecord(info, xlrec, &parsed);
                                402                 :                : 
                                403                 :              0 :     appendStringInfo(buf, "gid %s: ", parsed.twophase_gid);
                                404                 :              0 :     appendStringInfoString(buf, timestamptz_to_str(parsed.xact_time));
                                405                 :                : 
 1158 rhaas@postgresql.org      406                 :              0 :     xact_desc_relations(buf, "rels(commit)", parsed.nrels, parsed.xlocators);
 2124 fujii@postgresql.org      407                 :              0 :     xact_desc_relations(buf, "rels(abort)", parsed.nabortrels,
                                408                 :                :                         parsed.abortlocators);
 1249 andres@anarazel.de        409                 :              0 :     xact_desc_stats(buf, "commit ", parsed.nstats, parsed.stats);
                                410                 :              0 :     xact_desc_stats(buf, "abort ", parsed.nabortstats, parsed.abortstats);
 2124 fujii@postgresql.org      411                 :              0 :     xact_desc_subxacts(buf, parsed.nsubxacts, parsed.subxacts);
                                412                 :                : 
 2046 alvherre@alvh.no-ip.      413                 :              0 :     standby_desc_invalidations(buf, parsed.nmsgs, parsed.msgs, parsed.dbId,
                                414                 :              0 :                                parsed.tsId, xlrec->initfileinval);
                                415                 :                : 
                                416                 :                :     /*
                                417                 :                :      * Check if the replication origin has been set in this record in the same
                                418                 :                :      * way as PrepareRedoAdd().
                                419                 :                :      */
 1363 michael@paquier.xyz       420         [ #  # ]:              0 :     if (origin_id != InvalidRepOriginId)
   61 alvherre@kurilemu.de      421                 :UNC           0 :         appendStringInfo(buf, "; origin: node %u, lsn %X/%08X, at %s",
                                422                 :                :                          origin_id,
 1363 michael@paquier.xyz       423                 :UBC           0 :                          LSN_FORMAT_ARGS(parsed.origin_lsn),
                                424                 :                :                          timestamptz_to_str(parsed.origin_timestamp));
 4665 alvherre@alvh.no-ip.      425                 :              0 : }
                                426                 :                : 
                                427                 :                : static void
                                428                 :              0 : xact_desc_assignment(StringInfo buf, xl_xact_assignment *xlrec)
                                429                 :                : {
                                430                 :                :     int         i;
                                431                 :                : 
 4328 rhaas@postgresql.org      432                 :              0 :     appendStringInfoString(buf, "subxacts:");
                                433                 :                : 
 4665 alvherre@alvh.no-ip.      434         [ #  # ]:              0 :     for (i = 0; i < xlrec->nsubxacts; i++)
                                435                 :              0 :         appendStringInfo(buf, " %u", xlrec->xsub[i]);
                                436                 :              0 : }
                                437                 :                : 
                                438                 :                : void
 3943 heikki.linnakangas@i      439                 :CBC        2774 : xact_desc(StringInfo buf, XLogReaderState *record)
                                440                 :                : {
 4102                           441                 :           2774 :     char       *rec = XLogRecGetData(record);
 3828 andres@anarazel.de        442                 :           2774 :     uint8       info = XLogRecGetInfo(record) & XLOG_XACT_OPMASK;
                                443                 :                : 
                                444   [ +  +  -  + ]:           2774 :     if (info == XLOG_XACT_COMMIT || info == XLOG_XACT_COMMIT_PREPARED)
 4665 alvherre@alvh.no-ip.      445                 :           1688 :     {
                                446                 :           1688 :         xl_xact_commit *xlrec = (xl_xact_commit *) rec;
                                447                 :                : 
 3783 andres@anarazel.de        448                 :           1688 :         xact_desc_commit(buf, XLogRecGetInfo(record), xlrec,
                                449                 :           1688 :                          XLogRecGetOrigin(record));
                                450                 :                :     }
 3828                           451   [ +  +  -  + ]:           1086 :     else if (info == XLOG_XACT_ABORT || info == XLOG_XACT_ABORT_PREPARED)
 4665 alvherre@alvh.no-ip.      452                 :              6 :     {
                                453                 :              6 :         xl_xact_abort *xlrec = (xl_xact_abort *) rec;
                                454                 :                : 
 1363 michael@paquier.xyz       455                 :              6 :         xact_desc_abort(buf, XLogRecGetInfo(record), xlrec,
                                456                 :              6 :                         XLogRecGetOrigin(record));
                                457                 :                :     }
 2124 fujii@postgresql.org      458         [ -  + ]:           1080 :     else if (info == XLOG_XACT_PREPARE)
                                459                 :                :     {
 2124 fujii@postgresql.org      460                 :UBC           0 :         xl_xact_prepare *xlrec = (xl_xact_prepare *) rec;
                                461                 :                : 
 1363 michael@paquier.xyz       462                 :              0 :         xact_desc_prepare(buf, XLogRecGetInfo(record), xlrec,
                                463                 :              0 :                           XLogRecGetOrigin(record));
                                464                 :                :     }
 4665 alvherre@alvh.no-ip.      465         [ -  + ]:CBC        1080 :     else if (info == XLOG_XACT_ASSIGNMENT)
                                466                 :                :     {
 4665 alvherre@alvh.no-ip.      467                 :UBC           0 :         xl_xact_assignment *xlrec = (xl_xact_assignment *) rec;
                                468                 :                : 
                                469                 :                :         /*
                                470                 :                :          * Note that we ignore the WAL record's xid, since we're more
                                471                 :                :          * interested in the top-level xid that issued the record and which
                                472                 :                :          * xids are being reported here.
                                473                 :                :          */
 4005 andres@anarazel.de        474                 :              0 :         appendStringInfo(buf, "xtop %u: ", xlrec->xtop);
 4665 alvherre@alvh.no-ip.      475                 :              0 :         xact_desc_assignment(buf, xlrec);
                                476                 :                :     }
 1871 akapila@postgresql.o      477         [ +  - ]:CBC        1080 :     else if (info == XLOG_XACT_INVALIDATIONS)
                                478                 :                :     {
                                479                 :           1080 :         xl_xact_invals *xlrec = (xl_xact_invals *) rec;
                                480                 :                : 
                                481                 :           1080 :         standby_desc_invalidations(buf, xlrec->nmsgs, xlrec->msgs, InvalidOid,
                                482                 :                :                                    InvalidOid, false);
                                483                 :                :     }
 4005 andres@anarazel.de        484                 :           2774 : }
                                485                 :                : 
                                486                 :                : const char *
                                487                 :           2777 : xact_identify(uint8 info)
                                488                 :                : {
                                489                 :           2777 :     const char *id = NULL;
                                490                 :                : 
 3828                           491   [ +  -  +  -  :           2777 :     switch (info & XLOG_XACT_OPMASK)
                                        -  -  +  - ]
                                492                 :                :     {
 4005                           493                 :           1689 :         case XLOG_XACT_COMMIT:
                                494                 :           1689 :             id = "COMMIT";
                                495                 :           1689 :             break;
 4005 andres@anarazel.de        496                 :UBC           0 :         case XLOG_XACT_PREPARE:
                                497                 :              0 :             id = "PREPARE";
                                498                 :              0 :             break;
 4005 andres@anarazel.de        499                 :CBC           7 :         case XLOG_XACT_ABORT:
                                500                 :              7 :             id = "ABORT";
                                501                 :              7 :             break;
 4005 andres@anarazel.de        502                 :UBC           0 :         case XLOG_XACT_COMMIT_PREPARED:
                                503                 :              0 :             id = "COMMIT_PREPARED";
                                504                 :              0 :             break;
                                505                 :              0 :         case XLOG_XACT_ABORT_PREPARED:
                                506                 :              0 :             id = "ABORT_PREPARED";
                                507                 :              0 :             break;
                                508                 :              0 :         case XLOG_XACT_ASSIGNMENT:
                                509                 :              0 :             id = "ASSIGNMENT";
                                510                 :              0 :             break;
 1871 akapila@postgresql.o      511                 :CBC        1081 :         case XLOG_XACT_INVALIDATIONS:
                                512                 :           1081 :             id = "INVALIDATION";
                                513                 :           1081 :             break;
                                514                 :                :     }
                                515                 :                : 
 4005 andres@anarazel.de        516                 :           2777 :     return id;
                                517                 :                : }
        

Generated by: LCOV version 2.4-beta