LCOV - differential code coverage report
Current view: top level - src/backend/catalog - pg_range.c (source / functions) Coverage Total Hit UBC GNC CBC
Current: 0e5ff9b9b45a657aea12440478dc002e9b01f138 vs 0123ce131fca454009439dfa3b2266d1d40737d7 Lines: 96.0 % 50 48 2 5 43
Current Date: 2026-03-14 14:10:32 -0400 Functions: 100.0 % 2 2 1 1
Baseline: lcov-20260315-024220-baseline Branches: 87.5 % 8 7 1 7
Baseline Date: 2026-03-14 15:27:56 +0100 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(30,360] days: 100.0 % 5 5 5
(360..) days: 95.6 % 45 43 2 43
Function coverage date bins:
(360..) days: 100.0 % 2 2 1 1
Branch coverage date bins:
(360..) days: 87.5 % 8 7 1 7

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * pg_range.c
                                  4                 :                :  *    routines to support manipulation of the pg_range relation
                                  5                 :                :  *
                                  6                 :                :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
                                  7                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                  8                 :                :  *
                                  9                 :                :  *
                                 10                 :                :  * IDENTIFICATION
                                 11                 :                :  *    src/backend/catalog/pg_range.c
                                 12                 :                :  *
                                 13                 :                :  *-------------------------------------------------------------------------
                                 14                 :                :  */
                                 15                 :                : #include "postgres.h"
                                 16                 :                : 
                                 17                 :                : #include "access/genam.h"
                                 18                 :                : #include "access/htup_details.h"
                                 19                 :                : #include "access/table.h"
                                 20                 :                : #include "catalog/dependency.h"
                                 21                 :                : #include "catalog/indexing.h"
                                 22                 :                : #include "catalog/pg_collation.h"
                                 23                 :                : #include "catalog/pg_opclass.h"
                                 24                 :                : #include "catalog/pg_proc.h"
                                 25                 :                : #include "catalog/pg_range.h"
                                 26                 :                : #include "catalog/pg_type.h"
                                 27                 :                : #include "utils/fmgroids.h"
                                 28                 :                : #include "utils/rel.h"
                                 29                 :                : 
                                 30                 :                : 
                                 31                 :                : /*
                                 32                 :                :  * RangeCreate
                                 33                 :                :  *      Create an entry in pg_range.
                                 34                 :                :  */
                                 35                 :                : void
 5246 heikki.linnakangas@i       36                 :CBC          80 : RangeCreate(Oid rangeTypeOid, Oid rangeSubType, Oid rangeCollation,
                                 37                 :                :             Oid rangeSubOpclass, RegProcedure rangeCanonical,
                                 38                 :                :             RegProcedure rangeSubDiff, Oid multirangeTypeOid,
                                 39                 :                :             RegProcedure rangeConstruct2, RegProcedure rangeConstruct3,
                                 40                 :                :             RegProcedure mltrngConstruct0, RegProcedure mltrngConstruct1, RegProcedure mltrngConstruct2)
                                 41                 :                : {
                                 42                 :                :     Relation    pg_range;
                                 43                 :                :     Datum       values[Natts_pg_range];
                                 44                 :                :     bool        nulls[Natts_pg_range];
                                 45                 :                :     HeapTuple   tup;
                                 46                 :                :     ObjectAddress myself;
                                 47                 :                :     ObjectAddress referenced;
                                 48                 :                :     ObjectAddress referencing;
                                 49                 :                :     ObjectAddresses *addrs;
                                 50                 :                : 
 2610 andres@anarazel.de         51                 :             80 :     pg_range = table_open(RangeRelationId, RowExclusiveLock);
                                 52                 :                : 
 5235 tgl@sss.pgh.pa.us          53                 :             80 :     memset(nulls, 0, sizeof(nulls));
                                 54                 :                : 
      bruce@momjian.us           55                 :             80 :     values[Anum_pg_range_rngtypid - 1] = ObjectIdGetDatum(rangeTypeOid);
                                 56                 :             80 :     values[Anum_pg_range_rngsubtype - 1] = ObjectIdGetDatum(rangeSubType);
 5246 heikki.linnakangas@i       57                 :             80 :     values[Anum_pg_range_rngcollation - 1] = ObjectIdGetDatum(rangeCollation);
 5235 bruce@momjian.us           58                 :             80 :     values[Anum_pg_range_rngsubopc - 1] = ObjectIdGetDatum(rangeSubOpclass);
 5246 heikki.linnakangas@i       59                 :             80 :     values[Anum_pg_range_rngcanonical - 1] = ObjectIdGetDatum(rangeCanonical);
 5235 bruce@momjian.us           60                 :             80 :     values[Anum_pg_range_rngsubdiff - 1] = ObjectIdGetDatum(rangeSubDiff);
 1911 akorotkov@postgresql       61                 :             80 :     values[Anum_pg_range_rngmultitypid - 1] = ObjectIdGetDatum(multirangeTypeOid);
   52 peter@eisentraut.org       62                 :GNC          80 :     values[Anum_pg_range_rngconstruct2 - 1] = ObjectIdGetDatum(rangeConstruct2);
                                 63                 :             80 :     values[Anum_pg_range_rngconstruct3 - 1] = ObjectIdGetDatum(rangeConstruct3);
                                 64                 :             80 :     values[Anum_pg_range_rngmltconstruct0 - 1] = ObjectIdGetDatum(mltrngConstruct0);
                                 65                 :             80 :     values[Anum_pg_range_rngmltconstruct1 - 1] = ObjectIdGetDatum(mltrngConstruct1);
                                 66                 :             80 :     values[Anum_pg_range_rngmltconstruct2 - 1] = ObjectIdGetDatum(mltrngConstruct2);
                                 67                 :                : 
 5246 heikki.linnakangas@i       68                 :CBC          80 :     tup = heap_form_tuple(RelationGetDescr(pg_range), values, nulls);
                                 69                 :                : 
 3330 alvherre@alvh.no-ip.       70                 :             80 :     CatalogTupleInsert(pg_range, tup);
 5246 heikki.linnakangas@i       71                 :             80 :     heap_freetuple(tup);
                                 72                 :                : 
                                 73                 :                :     /* record type's dependencies on range-related items */
 2017 michael@paquier.xyz        74                 :             80 :     addrs = new_object_addresses();
                                 75                 :                : 
                                 76                 :             80 :     ObjectAddressSet(myself, TypeRelationId, rangeTypeOid);
                                 77                 :                : 
                                 78                 :             80 :     ObjectAddressSet(referenced, TypeRelationId, rangeSubType);
                                 79                 :             80 :     add_exact_object_address(&referenced, addrs);
                                 80                 :                : 
                                 81                 :             80 :     ObjectAddressSet(referenced, OperatorClassRelationId, rangeSubOpclass);
                                 82                 :             80 :     add_exact_object_address(&referenced, addrs);
                                 83                 :                : 
 5246 heikki.linnakangas@i       84         [ +  + ]:             80 :     if (OidIsValid(rangeCollation))
                                 85                 :                :     {
 2017 michael@paquier.xyz        86                 :             36 :         ObjectAddressSet(referenced, CollationRelationId, rangeCollation);
                                 87                 :             36 :         add_exact_object_address(&referenced, addrs);
                                 88                 :                :     }
                                 89                 :                : 
 5246 heikki.linnakangas@i       90         [ -  + ]:             80 :     if (OidIsValid(rangeCanonical))
                                 91                 :                :     {
 2017 michael@paquier.xyz        92                 :UBC           0 :         ObjectAddressSet(referenced, ProcedureRelationId, rangeCanonical);
                                 93                 :              0 :         add_exact_object_address(&referenced, addrs);
                                 94                 :                :     }
                                 95                 :                : 
 5246 heikki.linnakangas@i       96         [ +  + ]:CBC          80 :     if (OidIsValid(rangeSubDiff))
                                 97                 :                :     {
 2017 michael@paquier.xyz        98                 :              4 :         ObjectAddressSet(referenced, ProcedureRelationId, rangeSubDiff);
                                 99                 :              4 :         add_exact_object_address(&referenced, addrs);
                                100                 :                :     }
                                101                 :                : 
                                102                 :             80 :     record_object_address_dependencies(&myself, addrs, DEPENDENCY_NORMAL);
                                103                 :             80 :     free_object_addresses(addrs);
                                104                 :                : 
                                105                 :                :     /* record multirange type's dependency on the range type */
 1911 akorotkov@postgresql      106                 :             80 :     referencing.classId = TypeRelationId;
                                107                 :             80 :     referencing.objectId = multirangeTypeOid;
                                108                 :             80 :     referencing.objectSubId = 0;
                                109                 :             80 :     recordDependencyOn(&referencing, &myself, DEPENDENCY_INTERNAL);
                                110                 :                : 
 2610 andres@anarazel.de        111                 :             80 :     table_close(pg_range, RowExclusiveLock);
 5246 heikki.linnakangas@i      112                 :             80 : }
                                113                 :                : 
                                114                 :                : 
                                115                 :                : /*
                                116                 :                :  * RangeDelete
                                117                 :                :  *      Remove the pg_range entry for the specified type.
                                118                 :                :  */
                                119                 :                : void
                                120                 :             52 : RangeDelete(Oid rangeTypeOid)
                                121                 :                : {
                                122                 :                :     Relation    pg_range;
                                123                 :                :     ScanKeyData key[1];
                                124                 :                :     SysScanDesc scan;
                                125                 :                :     HeapTuple   tup;
                                126                 :                : 
 2610 andres@anarazel.de        127                 :             52 :     pg_range = table_open(RangeRelationId, RowExclusiveLock);
                                128                 :                : 
 5246 heikki.linnakangas@i      129                 :             52 :     ScanKeyInit(&key[0],
                                130                 :                :                 Anum_pg_range_rngtypid,
                                131                 :                :                 BTEqualStrategyNumber, F_OIDEQ,
                                132                 :                :                 ObjectIdGetDatum(rangeTypeOid));
                                133                 :                : 
                                134                 :             52 :     scan = systable_beginscan(pg_range, RangeTypidIndexId, true,
                                135                 :                :                               NULL, 1, key);
                                136                 :                : 
                                137         [ +  + ]:            104 :     while (HeapTupleIsValid(tup = systable_getnext(scan)))
                                138                 :                :     {
 3329 tgl@sss.pgh.pa.us         139                 :             52 :         CatalogTupleDelete(pg_range, &tup->t_self);
                                140                 :                :     }
                                141                 :                : 
 5246 heikki.linnakangas@i      142                 :             52 :     systable_endscan(scan);
                                143                 :                : 
 2610 andres@anarazel.de        144                 :             52 :     table_close(pg_range, RowExclusiveLock);
 5246 heikki.linnakangas@i      145                 :             52 : }
        

Generated by: LCOV version 2.4-beta