LCOV - differential code coverage report
Current view: top level - src/backend/access/common - scankey.c (source / functions) Coverage Total Hit UBC CBC
Current: 77aeca80249c9e640c811e80633a2e334a9320de vs 38afc3dcb25c45b744d4025029ce0a6c90b7059f Lines: 100.0 % 30 30 30
Current Date: 2026-07-25 19:08:27 +0900 Functions: 100.0 % 3 3 3
Baseline: lcov-20260725-baseline Branches: 64.3 % 14 9 5 9
Baseline Date: 2026-07-25 19:09:19 +0900 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(360..) days: 100.0 % 30 30 30
Function coverage date bins:
(360..) days: 100.0 % 3 3 3
Branch coverage date bins:
(360..) days: 64.3 % 14 9 5 9

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * scankey.c
                                  4                 :                :  *    scan key support code
                                  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/access/common/scankey.c
                                 12                 :                :  *
                                 13                 :                :  *-------------------------------------------------------------------------
                                 14                 :                :  */
                                 15                 :                : #include "postgres.h"
                                 16                 :                : 
                                 17                 :                : #include "access/skey.h"
                                 18                 :                : #include "catalog/pg_collation.h"
                                 19                 :                : 
                                 20                 :                : 
                                 21                 :                : /*
                                 22                 :                :  * ScanKeyEntryInitialize
                                 23                 :                :  *      Initializes a scan key entry given all the field values.
                                 24                 :                :  *      The target procedure is specified by OID (but can be invalid
                                 25                 :                :  *      if SK_SEARCHNULL or SK_SEARCHNOTNULL is set).
                                 26                 :                :  *
                                 27                 :                :  * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
                                 28                 :                :  * itself, because that's what will be used for any subsidiary info attached
                                 29                 :                :  * to the ScanKey's FmgrInfo record.
                                 30                 :                :  */
                                 31                 :                : void
10973 scrappy@hub.org            32                 :CBC      266960 : ScanKeyEntryInitialize(ScanKey entry,
                                 33                 :                :                        int flags,
                                 34                 :                :                        AttrNumber attributeNumber,
                                 35                 :                :                        StrategyNumber strategy,
                                 36                 :                :                        Oid subtype,
                                 37                 :                :                        Oid collation,
                                 38                 :                :                        RegProcedure procedure,
                                 39                 :                :                        Datum argument)
                                 40                 :                : {
10548 bruce@momjian.us           41                 :         266960 :     entry->sk_flags = flags;
                                 42                 :         266960 :     entry->sk_attno = attributeNumber;
 8294 tgl@sss.pgh.pa.us          43                 :         266960 :     entry->sk_strategy = strategy;
 8291                            44                 :         266960 :     entry->sk_subtype = subtype;
 5583                            45                 :         266960 :     entry->sk_collation = collation;
 8291                            46                 :         266960 :     entry->sk_argument = argument;
 7050                            47         [ +  + ]:         266960 :     if (RegProcedureIsValid(procedure))
                                 48                 :                :     {
                                 49                 :         184264 :         fmgr_info(procedure, &entry->sk_func);
                                 50                 :                :     }
                                 51                 :                :     else
                                 52                 :                :     {
 6049                            53         [ -  + ]:          82696 :         Assert(flags & (SK_SEARCHNULL | SK_SEARCHNOTNULL));
 7050                            54   [ +  -  +  -  :         578872 :         MemSet(&entry->sk_func, 0, sizeof(entry->sk_func));
                                     +  -  +  -  +  
                                                 + ]
                                 55                 :                :     }
 8291                            56                 :         266960 : }
                                 57                 :                : 
                                 58                 :                : /*
                                 59                 :                :  * ScanKeyInit
                                 60                 :                :  *      Shorthand version of ScanKeyEntryInitialize: flags and subtype
                                 61                 :                :  *      are assumed to be zero (the usual value), and collation is defaulted.
                                 62                 :                :  *
                                 63                 :                :  * This is the recommended version for hardwired lookups in system catalogs.
                                 64                 :                :  * It cannot handle NULL arguments, unary operators, or nondefault operators,
                                 65                 :                :  * but we need none of those features for most hardwired lookups.
                                 66                 :                :  *
                                 67                 :                :  * We set collation to C_COLLATION_OID always.  This is the correct value
                                 68                 :                :  * for all collation-aware columns in system catalogs, and it will be ignored
                                 69                 :                :  * for other column types, so it's not worth trying to be more finicky.
                                 70                 :                :  *
                                 71                 :                :  * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
                                 72                 :                :  * itself, because that's what will be used for any subsidiary info attached
                                 73                 :                :  * to the ScanKey's FmgrInfo record.
                                 74                 :                :  */
                                 75                 :                : void
                                 76                 :        7669089 : ScanKeyInit(ScanKey entry,
                                 77                 :                :             AttrNumber attributeNumber,
                                 78                 :                :             StrategyNumber strategy,
                                 79                 :                :             RegProcedure procedure,
                                 80                 :                :             Datum argument)
                                 81                 :                : {
                                 82                 :        7669089 :     entry->sk_flags = 0;
                                 83                 :        7669089 :     entry->sk_attno = attributeNumber;
                                 84                 :        7669089 :     entry->sk_strategy = strategy;
                                 85                 :        7669089 :     entry->sk_subtype = InvalidOid;
 2776                            86                 :        7669089 :     entry->sk_collation = C_COLLATION_OID;
10548 bruce@momjian.us           87                 :        7669089 :     entry->sk_argument = argument;
10418 webmaster@postgresql       88                 :        7669089 :     fmgr_info(procedure, &entry->sk_func);
10973 scrappy@hub.org            89                 :        7669089 : }
                                 90                 :                : 
                                 91                 :                : /*
                                 92                 :                :  * ScanKeyEntryInitializeWithInfo
                                 93                 :                :  *      Initializes a scan key entry using an already-completed FmgrInfo
                                 94                 :                :  *      function lookup record.
                                 95                 :                :  *
                                 96                 :                :  * Note: CurrentMemoryContext at call should be as long-lived as the ScanKey
                                 97                 :                :  * itself, because that's what will be used for any subsidiary info attached
                                 98                 :                :  * to the ScanKey's FmgrInfo record.
                                 99                 :                :  */
                                100                 :                : void
 9058 tgl@sss.pgh.pa.us         101                 :       29268582 : ScanKeyEntryInitializeWithInfo(ScanKey entry,
                                102                 :                :                                int flags,
                                103                 :                :                                AttrNumber attributeNumber,
                                104                 :                :                                StrategyNumber strategy,
                                105                 :                :                                Oid subtype,
                                106                 :                :                                Oid collation,
                                107                 :                :                                FmgrInfo *finfo,
                                108                 :                :                                Datum argument)
                                109                 :                : {
                                110                 :       29268582 :     entry->sk_flags = flags;
                                111                 :       29268582 :     entry->sk_attno = attributeNumber;
 8294                           112                 :       29268582 :     entry->sk_strategy = strategy;
 8291                           113                 :       29268582 :     entry->sk_subtype = subtype;
 5583                           114                 :       29268582 :     entry->sk_collation = collation;
 9058                           115                 :       29268582 :     entry->sk_argument = argument;
 8294                           116                 :       29268582 :     fmgr_info_copy(&entry->sk_func, finfo, CurrentMemoryContext);
 5646 peter_e@gmx.net           117                 :       29268582 : }
        

Generated by: LCOV version 2.0-1