LCOV - differential code coverage report
Current view: top level - contrib/pg_freespacemap - pg_freespacemap.c (source / functions) Coverage Total Hit UBC CBC
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 92.3 % 13 12 1 12
Current Date: 2025-09-06 07:49:51 +0900 Functions: 100.0 % 3 3 3
Baseline: lcov-20250906-005545-baseline Branches: 44.4 % 18 8 10 8
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: 66.7 % 3 2 1 2
(360..) days: 100.0 % 10 10 10
Function coverage date bins:
(30,360] days: 100.0 % 1 1 1
(360..) days: 100.0 % 2 2 2
Branch coverage date bins:
(30,360] days: 25.0 % 12 3 9 3
(360..) days: 83.3 % 6 5 1 5

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * pg_freespacemap.c
                                  4                 :                :  *    display contents of a free space map
                                  5                 :                :  *
                                  6                 :                :  *    contrib/pg_freespacemap/pg_freespacemap.c
                                  7                 :                :  *-------------------------------------------------------------------------
                                  8                 :                :  */
                                  9                 :                : #include "postgres.h"
                                 10                 :                : 
                                 11                 :                : #include "access/relation.h"
                                 12                 :                : #include "fmgr.h"
                                 13                 :                : #include "storage/freespace.h"
                                 14                 :                : #include "utils/rel.h"
                                 15                 :                : 
  164 tgl@sss.pgh.pa.us          16                 :CBC           1 : PG_MODULE_MAGIC_EXT(
                                 17                 :                :                     .name = "pg_freespacemap",
                                 18                 :                :                     .version = PG_VERSION
                                 19                 :                : );
                                 20                 :                : 
                                 21                 :                : /*
                                 22                 :                :  * Returns the amount of free space on a given page, according to the
                                 23                 :                :  * free space map.
                                 24                 :                :  */
 6185 heikki.linnakangas@i       25                 :              2 : PG_FUNCTION_INFO_V1(pg_freespace);
                                 26                 :                : 
                                 27                 :                : Datum
                                 28                 :             47 : pg_freespace(PG_FUNCTION_ARGS)
                                 29                 :                : {
 5931 bruce@momjian.us           30                 :             47 :     Oid         relid = PG_GETARG_OID(0);
                                 31                 :             47 :     int64       blkno = PG_GETARG_INT64(1);
                                 32                 :                :     int16       freespace;
                                 33                 :                :     Relation    rel;
                                 34                 :                : 
 6185 heikki.linnakangas@i       35                 :             47 :     rel = relation_open(relid, AccessShareLock);
                                 36                 :                : 
  163 tgl@sss.pgh.pa.us          37   [ +  +  -  +  :             47 :     if (!RELKIND_HAS_STORAGE(rel->rd_rel->relkind))
                                     -  -  -  -  -  
                                                 - ]
  163 tgl@sss.pgh.pa.us          38         [ #  # ]:UBC           0 :         ereport(ERROR,
                                 39                 :                :                 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                 40                 :                :                  errmsg("relation \"%s\" does not have storage",
                                 41                 :                :                         RelationGetRelationName(rel)),
                                 42                 :                :                  errdetail_relkind_not_supported(rel->rd_rel->relkind)));
                                 43                 :                : 
 6183 heikki.linnakangas@i       44   [ +  +  +  + ]:CBC          47 :     if (blkno < 0 || blkno > MaxBlockNumber)
 6185                            45         [ +  - ]:              2 :         ereport(ERROR,
                                 46                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                 47                 :                :                  errmsg("invalid block number")));
                                 48                 :                : 
                                 49                 :             45 :     freespace = GetRecordedFreeSpace(rel, blkno);
                                 50                 :                : 
                                 51                 :             45 :     relation_close(rel, AccessShareLock);
                                 52                 :             45 :     PG_RETURN_INT16(freespace);
                                 53                 :                : }
        

Generated by: LCOV version 2.4-beta