LCOV - differential code coverage report
Current view: top level - src/backend/utils/adt - multixactfuncs.c (source / functions) Coverage Total Hit UNC GNC
Current: 806555e3000d0b0e0c536c1dc65548128d457d86 vs 1d325ad99cb2dec0e8b45ba36909ee0a497d2a57 Lines: 92.3 % 26 24 2 24
Current Date: 2025-12-17 08:58:58 +0900 Functions: 100.0 % 1 1 1
Baseline: lcov-20251217-005640-baseline Branches: 50.0 % 12 6 6 6
Baseline Date: 2025-12-16 12:57:12 -0800 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(1,7] days: 100.0 % 1 1 1
(30,360] days: 92.0 % 25 23 2 23
Function coverage date bins:
(30,360] days: 100.0 % 1 1 1
Branch coverage date bins:
(30,360] days: 50.0 % 12 6 6 6

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * multixactfuncs.c
                                  4                 :                :  *    Functions for accessing multixact-related data.
                                  5                 :                :  *
                                  6                 :                :  * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
                                  7                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                  8                 :                :  *
                                  9                 :                :  * IDENTIFICATION
                                 10                 :                :  *    src/backend/utils/adt/multixactfuncs.c
                                 11                 :                :  *
                                 12                 :                :  *-------------------------------------------------------------------------
                                 13                 :                :  */
                                 14                 :                : 
                                 15                 :                : #include "postgres.h"
                                 16                 :                : 
                                 17                 :                : #include "access/multixact.h"
                                 18                 :                : #include "funcapi.h"
                                 19                 :                : #include "utils/builtins.h"
                                 20                 :                : 
                                 21                 :                : /*
                                 22                 :                :  * pg_get_multixact_members
                                 23                 :                :  *
                                 24                 :                :  * Returns information about the MultiXactMembers of the specified
                                 25                 :                :  * MultiXactId.
                                 26                 :                :  */
                                 27                 :                : Datum
  121 michael@paquier.xyz        28                 :GNC      198078 : pg_get_multixact_members(PG_FUNCTION_ARGS)
                                 29                 :                : {
                                 30                 :                :     typedef struct
                                 31                 :                :     {
                                 32                 :                :         MultiXactMember *members;
                                 33                 :                :         int         nmembers;
                                 34                 :                :         int         iter;
                                 35                 :                :     } mxact;
                                 36                 :         198078 :     MultiXactId mxid = PG_GETARG_TRANSACTIONID(0);
                                 37                 :                :     mxact      *multi;
                                 38                 :                :     FuncCallContext *funccxt;
                                 39                 :                : 
                                 40         [ -  + ]:         198078 :     if (mxid < FirstMultiXactId)
  121 michael@paquier.xyz        41         [ #  # ]:UNC           0 :         ereport(ERROR,
                                 42                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                 43                 :                :                  errmsg("invalid MultiXactId: %u", mxid)));
                                 44                 :                : 
  121 michael@paquier.xyz        45         [ +  + ]:GNC      198078 :     if (SRF_IS_FIRSTCALL())
                                 46                 :                :     {
                                 47                 :                :         MemoryContext oldcxt;
                                 48                 :                :         TupleDesc   tupdesc;
                                 49                 :                : 
                                 50                 :           9990 :         funccxt = SRF_FIRSTCALL_INIT();
                                 51                 :           9990 :         oldcxt = MemoryContextSwitchTo(funccxt->multi_call_memory_ctx);
                                 52                 :                : 
    7                            53                 :           9990 :         multi = palloc_object(mxact);
                                 54                 :                :         /* no need to allow for old values here */
  121                            55                 :           9990 :         multi->nmembers = GetMultiXactIdMembers(mxid, &multi->members, false,
                                 56                 :                :                                                 false);
                                 57                 :           9990 :         multi->iter = 0;
                                 58                 :                : 
                                 59         [ -  + ]:           9990 :         if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
  121 michael@paquier.xyz        60         [ #  # ]:UNC           0 :             elog(ERROR, "return type must be a row type");
  121 michael@paquier.xyz        61                 :GNC        9990 :         funccxt->tuple_desc = tupdesc;
                                 62                 :           9990 :         funccxt->attinmeta = TupleDescGetAttInMetadata(tupdesc);
                                 63                 :           9990 :         funccxt->user_fctx = multi;
                                 64                 :                : 
                                 65                 :           9990 :         MemoryContextSwitchTo(oldcxt);
                                 66                 :                :     }
                                 67                 :                : 
                                 68                 :         198078 :     funccxt = SRF_PERCALL_SETUP();
                                 69                 :         198078 :     multi = (mxact *) funccxt->user_fctx;
                                 70                 :                : 
                                 71         [ +  + ]:         198078 :     while (multi->iter < multi->nmembers)
                                 72                 :                :     {
                                 73                 :                :         HeapTuple   tuple;
                                 74                 :                :         char       *values[2];
                                 75                 :                : 
                                 76                 :         188088 :         values[0] = psprintf("%u", multi->members[multi->iter].xid);
                                 77                 :         188088 :         values[1] = mxstatus_to_string(multi->members[multi->iter].status);
                                 78                 :                : 
                                 79                 :         188088 :         tuple = BuildTupleFromCStrings(funccxt->attinmeta, values);
                                 80                 :                : 
                                 81                 :         188088 :         multi->iter++;
                                 82                 :         188088 :         pfree(values[0]);
                                 83                 :         188088 :         SRF_RETURN_NEXT(funccxt, HeapTupleGetDatum(tuple));
                                 84                 :                :     }
                                 85                 :                : 
                                 86                 :           9990 :     SRF_RETURN_DONE(funccxt);
                                 87                 :                : }
        

Generated by: LCOV version 2.4-beta