LCOV - differential code coverage report
Current view: top level - contrib/pageinspect - fsmfuncs.c (source / functions) Coverage Total Hit UBC GNC CBC DCB
Current: 77aeca80249c9e640c811e80633a2e334a9320de vs 38afc3dcb25c45b744d4025029ce0a6c90b7059f Lines: 93.3 % 15 14 1 2 12 2
Current Date: 2026-07-25 19:08:27 +0900 Functions: 100.0 % 2 2 1 1
Baseline: lcov-20260725-baseline Branches: 70.0 % 10 7 3 2 5
Baseline Date: 2026-07-25 19:09:19 +0900 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(7,30] days: 100.0 % 2 2 2
(360..) days: 92.3 % 13 12 1 12
Function coverage date bins:
(360..) days: 100.0 % 2 2 1 1
Branch coverage date bins:
(7,30] days: 100.0 % 2 2 2
(360..) days: 62.5 % 8 5 3 5

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * fsmfuncs.c
                                  4                 :                :  *    Functions to investigate FSM pages
                                  5                 :                :  *
                                  6                 :                :  * These functions are restricted to superusers for the fear of introducing
                                  7                 :                :  * security holes if the input checking isn't as water-tight as it should.
                                  8                 :                :  * You'd need to be superuser to obtain a raw page image anyway, so
                                  9                 :                :  * there's hardly any use case for using these without superuser-rights
                                 10                 :                :  * anyway.
                                 11                 :                :  *
                                 12                 :                :  * Copyright (c) 2007-2026, PostgreSQL Global Development Group
                                 13                 :                :  *
                                 14                 :                :  * IDENTIFICATION
                                 15                 :                :  *    contrib/pageinspect/fsmfuncs.c
                                 16                 :                :  *
                                 17                 :                :  *-------------------------------------------------------------------------
                                 18                 :                :  */
                                 19                 :                : 
                                 20                 :                : #include "postgres.h"
                                 21                 :                : 
                                 22                 :                : #include "fmgr.h"
                                 23                 :                : #include "lib/stringinfo.h"
                                 24                 :                : #include "miscadmin.h"
                                 25                 :                : #include "pageinspect.h"
                                 26                 :                : #include "storage/fsm_internals.h"
                                 27                 :                : #include "utils/builtins.h"
                                 28                 :                : 
                                 29                 :                : /*
                                 30                 :                :  * Dumps the contents of a FSM page.
                                 31                 :                :  */
 6507 heikki.linnakangas@i       32                 :CBC           8 : PG_FUNCTION_INFO_V1(fsm_page_contents);
                                 33                 :                : 
                                 34                 :                : Datum
                                 35                 :              3 : fsm_page_contents(PG_FUNCTION_ARGS)
                                 36                 :                : {
                                 37                 :              3 :     bytea      *raw_page = PG_GETARG_BYTEA_P(0);
                                 38                 :                :     StringInfoData sinfo;
                                 39                 :                :     Page        page;
                                 40                 :                :     FSMPage     fsmpage;
                                 41                 :                : 
                                 42         [ -  + ]:              3 :     if (!superuser())
 6507 heikki.linnakangas@i       43         [ #  # ]:UBC           0 :         ereport(ERROR,
                                 44                 :                :                 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                                 45                 :                :                  errmsg("must be superuser to use raw page functions")));
                                 46                 :                : 
 1592 michael@paquier.xyz        47                 :CBC           3 :     page = get_page_from_raw(raw_page);
                                 48                 :                : 
 1563                            49         [ +  + ]:              2 :     if (PageIsNew(page))
                                 50                 :              1 :         PG_RETURN_NULL();
                                 51                 :                : 
 1592                            52                 :              1 :     fsmpage = (FSMPage) PageGetContents(page);
                                 53                 :                : 
 6507 heikki.linnakangas@i       54                 :              1 :     initStringInfo(&sinfo);
                                 55                 :                : 
   14 peter@eisentraut.org       56         [ +  + ]:GNC        8165 :     for (size_t i = 0; i < NodesPerPage; i++)
                                 57                 :                :     {
 6507 heikki.linnakangas@i       58         [ +  + ]:CBC        8164 :         if (fsmpage->fp_nodes[i] != 0)
   14 peter@eisentraut.org       59                 :GNC          13 :             appendStringInfo(&sinfo, "%zu: %d\n", i, fsmpage->fp_nodes[i]);
                                 60                 :                :     }
 6507 heikki.linnakangas@i       61                 :CBC           1 :     appendStringInfo(&sinfo, "fp_next_slot: %d\n", fsmpage->fp_next_slot);
                                 62                 :                : 
 4632 rhaas@postgresql.org       63                 :              1 :     PG_RETURN_TEXT_P(cstring_to_text_with_len(sinfo.data, sinfo.len));
                                 64                 :                : }
        

Generated by: LCOV version 2.0-1