LCOV - differential code coverage report
Current view: top level - contrib/pg_freespacemap - pg_freespacemap.c (source / functions) Coverage Total Hit UBC CBC
Current: Differential Code Coverage 16@8cea358b128 vs 17@8cea358b128 Lines: 100.0 % 11 11 11
Current Date: 2024-04-14 14:21:10 Functions: 100.0 % 3 3 3
Baseline: 16@8cea358b128 Branches: 83.3 % 6 5 1 5
Baseline Date: 2024-04-14 14:21:09 Line coverage date bins:
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed (240..) days: 100.0 % 11 11 11
Function coverage date bins:
(240..) days: 100.0 % 3 3 3
Branch coverage date bins:
(240..) 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 "funcapi.h"
                                 13                 :                : #include "storage/freespace.h"
                                 14                 :                : 
 6529 tgl@sss.pgh.pa.us          15                 :CBC           1 : PG_MODULE_MAGIC;
                                 16                 :                : 
                                 17                 :                : /*
                                 18                 :                :  * Returns the amount of free space on a given page, according to the
                                 19                 :                :  * free space map.
                                 20                 :                :  */
 5675 heikki.linnakangas@i       21                 :              2 : PG_FUNCTION_INFO_V1(pg_freespace);
                                 22                 :                : 
                                 23                 :                : Datum
                                 24                 :             47 : pg_freespace(PG_FUNCTION_ARGS)
                                 25                 :                : {
 5421 bruce@momjian.us           26                 :             47 :     Oid         relid = PG_GETARG_OID(0);
                                 27                 :             47 :     int64       blkno = PG_GETARG_INT64(1);
                                 28                 :                :     int16       freespace;
                                 29                 :                :     Relation    rel;
                                 30                 :                : 
 5675 heikki.linnakangas@i       31                 :             47 :     rel = relation_open(relid, AccessShareLock);
                                 32                 :                : 
 5673                            33   [ +  +  +  + ]:             47 :     if (blkno < 0 || blkno > MaxBlockNumber)
 5675                            34         [ +  - ]:              2 :         ereport(ERROR,
                                 35                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                 36                 :                :                  errmsg("invalid block number")));
                                 37                 :                : 
                                 38                 :             45 :     freespace = GetRecordedFreeSpace(rel, blkno);
                                 39                 :                : 
                                 40                 :             45 :     relation_close(rel, AccessShareLock);
                                 41                 :             45 :     PG_RETURN_INT16(freespace);
                                 42                 :                : }
        

Generated by: LCOV version 2.1-beta2-3-g6141622