LCOV - differential code coverage report
Current view: top level - contrib/btree_gist - btree_bytea.c (source / functions) Coverage Total Hit UBC CBC
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 83.6 % 67 56 11 56
Current Date: 2025-09-06 07:49:51 +0900 Functions: 90.5 % 21 19 2 19
Baseline: lcov-20250906-005545-baseline Branches: 50.0 % 4 2 2 2
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: 100.0 % 16 16 16
(360..) days: 78.4 % 51 40 11 40
Function coverage date bins:
(30,360] days: 100.0 % 3 3 3
(360..) days: 88.9 % 18 16 2 16
Branch coverage date bins:
(30,360] days: 50.0 % 4 2 2 2

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*
                                  2                 :                :  * contrib/btree_gist/btree_bytea.c
                                  3                 :                :  */
                                  4                 :                : #include "postgres.h"
                                  5                 :                : 
                                  6                 :                : #include "btree_gist.h"
                                  7                 :                : #include "btree_utils_var.h"
                                  8                 :                : #include "utils/fmgrprotos.h"
                                  9                 :                : #include "utils/sortsupport.h"
                                 10                 :                : 
                                 11                 :                : /* GiST support functions */
 7771 teodor@sigaev.ru           12                 :CBC           4 : PG_FUNCTION_INFO_V1(gbt_bytea_compress);
                                 13                 :              4 : PG_FUNCTION_INFO_V1(gbt_bytea_union);
                                 14                 :              4 : PG_FUNCTION_INFO_V1(gbt_bytea_picksplit);
                                 15                 :              4 : PG_FUNCTION_INFO_V1(gbt_bytea_consistent);
                                 16                 :              4 : PG_FUNCTION_INFO_V1(gbt_bytea_penalty);
                                 17                 :              4 : PG_FUNCTION_INFO_V1(gbt_bytea_same);
  156 heikki.linnakangas@i       18                 :              4 : PG_FUNCTION_INFO_V1(gbt_bytea_sortsupport);
                                 19                 :                : 
                                 20                 :                : 
                                 21                 :                : /* define for comparison */
                                 22                 :                : 
                                 23                 :                : static bool
 3091 andrew@dunslane.net        24                 :            617 : gbt_byteagt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
                                 25                 :                : {
 5251 tgl@sss.pgh.pa.us          26                 :            617 :     return DatumGetBool(DirectFunctionCall2(byteagt,
                                 27                 :                :                                             PointerGetDatum(a),
                                 28                 :                :                                             PointerGetDatum(b)));
                                 29                 :                : }
                                 30                 :                : 
                                 31                 :                : static bool
 3091 andrew@dunslane.net        32                 :            617 : gbt_byteage(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
                                 33                 :                : {
 5251 tgl@sss.pgh.pa.us          34                 :            617 :     return DatumGetBool(DirectFunctionCall2(byteage,
                                 35                 :                :                                             PointerGetDatum(a),
                                 36                 :                :                                             PointerGetDatum(b)));
                                 37                 :                : }
                                 38                 :                : 
                                 39                 :                : static bool
 3091 andrew@dunslane.net        40                 :           1234 : gbt_byteaeq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
                                 41                 :                : {
 5251 tgl@sss.pgh.pa.us          42                 :           1234 :     return DatumGetBool(DirectFunctionCall2(byteaeq,
                                 43                 :                :                                             PointerGetDatum(a),
                                 44                 :                :                                             PointerGetDatum(b)));
                                 45                 :                : }
                                 46                 :                : 
                                 47                 :                : static bool
 3091 andrew@dunslane.net        48                 :            989 : gbt_byteale(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
                                 49                 :                : {
 5251 tgl@sss.pgh.pa.us          50                 :            989 :     return DatumGetBool(DirectFunctionCall2(byteale,
                                 51                 :                :                                             PointerGetDatum(a),
                                 52                 :                :                                             PointerGetDatum(b)));
                                 53                 :                : }
                                 54                 :                : 
                                 55                 :                : static bool
 3091 andrew@dunslane.net        56                 :           1607 : gbt_bytealt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
                                 57                 :                : {
 5251 tgl@sss.pgh.pa.us          58                 :           1607 :     return DatumGetBool(DirectFunctionCall2(bytealt,
                                 59                 :                :                                             PointerGetDatum(a),
                                 60                 :                :                                             PointerGetDatum(b)));
                                 61                 :                : }
                                 62                 :                : 
                                 63                 :                : static int32
 3091 andrew@dunslane.net        64                 :          10436 : gbt_byteacmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
                                 65                 :                : {
 5251 tgl@sss.pgh.pa.us          66                 :          10436 :     return DatumGetInt32(DirectFunctionCall2(byteacmp,
                                 67                 :                :                                              PointerGetDatum(a),
                                 68                 :                :                                              PointerGetDatum(b)));
                                 69                 :                : }
                                 70                 :                : 
                                 71                 :                : static const gbtree_vinfo tinfo =
                                 72                 :                : {
                                 73                 :                :     gbt_t_bytea,
                                 74                 :                :     0,
                                 75                 :                :     true,
                                 76                 :                :     gbt_byteagt,
                                 77                 :                :     gbt_byteage,
                                 78                 :                :     gbt_byteaeq,
                                 79                 :                :     gbt_byteale,
                                 80                 :                :     gbt_bytealt,
                                 81                 :                :     gbt_byteacmp,
                                 82                 :                :     NULL
                                 83                 :                : };
                                 84                 :                : 
                                 85                 :                : 
                                 86                 :                : /**************************************************
                                 87                 :                :  * GiST support functions
                                 88                 :                :  **************************************************/
                                 89                 :                : 
                                 90                 :                : Datum
 7678 bruce@momjian.us           91                 :            995 : gbt_bytea_compress(PG_FUNCTION_ARGS)
                                 92                 :                : {
                                 93                 :            995 :     GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
                                 94                 :                : 
                                 95                 :            995 :     PG_RETURN_POINTER(gbt_var_compress(entry, &tinfo));
                                 96                 :                : }
                                 97                 :                : 
                                 98                 :                : Datum
 7771 teodor@sigaev.ru           99                 :           5106 : gbt_bytea_consistent(PG_FUNCTION_ARGS)
                                100                 :                : {
 7678 bruce@momjian.us          101                 :           5106 :     GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
  282 peter@eisentraut.org      102                 :           5106 :     void       *query = DatumGetByteaP(PG_GETARG_DATUM(1));
 7678 bruce@momjian.us          103                 :           5106 :     StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
                                104                 :                : 
                                105                 :                :     /* Oid      subtype = PG_GETARG_OID(3); */
 6354 tgl@sss.pgh.pa.us         106                 :           5106 :     bool       *recheck = (bool *) PG_GETARG_POINTER(4);
                                107                 :                :     bool        retval;
                                108                 :           5106 :     GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
 7678 bruce@momjian.us          109                 :           5106 :     GBT_VARKEY_R r = gbt_var_key_readable(key);
                                110                 :                : 
                                111                 :                :     /* All cases served by this function are exact */
 6354 tgl@sss.pgh.pa.us         112                 :           5106 :     *recheck = false;
                                113                 :                : 
 5251                           114                 :          10212 :     retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
 3091 andrew@dunslane.net       115                 :           5106 :                                 GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
 7678 bruce@momjian.us          116                 :           5106 :     PG_RETURN_BOOL(retval);
                                117                 :                : }
                                118                 :                : 
                                119                 :                : Datum
 7771 teodor@sigaev.ru          120                 :              1 : gbt_bytea_union(PG_FUNCTION_ARGS)
                                121                 :                : {
 7678 bruce@momjian.us          122                 :              1 :     GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
                                123                 :              1 :     int32      *size = (int *) PG_GETARG_POINTER(1);
                                124                 :                : 
 5251 tgl@sss.pgh.pa.us         125                 :              1 :     PG_RETURN_POINTER(gbt_var_union(entryvec, size, PG_GET_COLLATION(),
                                126                 :                :                                     &tinfo, fcinfo->flinfo));
                                127                 :                : }
                                128                 :                : 
                                129                 :                : Datum
 7771 teodor@sigaev.ru          130                 :              5 : gbt_bytea_picksplit(PG_FUNCTION_ARGS)
                                131                 :                : {
 7678 bruce@momjian.us          132                 :              5 :     GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
                                133                 :              5 :     GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
                                134                 :                : 
 5251 tgl@sss.pgh.pa.us         135                 :              5 :     gbt_var_picksplit(entryvec, v, PG_GET_COLLATION(),
                                136                 :                :                       &tinfo, fcinfo->flinfo);
 7678 bruce@momjian.us          137                 :              5 :     PG_RETURN_POINTER(v);
                                138                 :                : }
                                139                 :                : 
                                140                 :                : Datum
 7771 teodor@sigaev.ru          141                 :UBC           0 : gbt_bytea_same(PG_FUNCTION_ARGS)
                                142                 :                : {
 7678 bruce@momjian.us          143                 :              0 :     Datum       d1 = PG_GETARG_DATUM(0);
                                144                 :              0 :     Datum       d2 = PG_GETARG_DATUM(1);
                                145                 :              0 :     bool       *result = (bool *) PG_GETARG_POINTER(2);
                                146                 :                : 
 3091 andrew@dunslane.net       147                 :              0 :     *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
 5251 tgl@sss.pgh.pa.us         148                 :              0 :     PG_RETURN_POINTER(result);
                                149                 :                : }
                                150                 :                : 
                                151                 :                : Datum
 7771 teodor@sigaev.ru          152                 :              0 : gbt_bytea_penalty(PG_FUNCTION_ARGS)
                                153                 :                : {
 7678 bruce@momjian.us          154                 :              0 :     GISTENTRY  *o = (GISTENTRY *) PG_GETARG_POINTER(0);
                                155                 :              0 :     GISTENTRY  *n = (GISTENTRY *) PG_GETARG_POINTER(1);
 7422 neilc@samurai.com         156                 :              0 :     float      *result = (float *) PG_GETARG_POINTER(2);
                                157                 :                : 
 5251 tgl@sss.pgh.pa.us         158                 :              0 :     PG_RETURN_POINTER(gbt_var_penalty(result, o, n, PG_GET_COLLATION(),
                                159                 :                :                                       &tinfo, fcinfo->flinfo));
                                160                 :                : }
                                161                 :                : 
                                162                 :                : static int
  156 heikki.linnakangas@i      163                 :CBC       10773 : gbt_bytea_ssup_cmp(Datum x, Datum y, SortSupport ssup)
                                164                 :                : {
                                165                 :          10773 :     GBT_VARKEY *key1 = PG_DETOAST_DATUM(x);
                                166                 :          10773 :     GBT_VARKEY *key2 = PG_DETOAST_DATUM(y);
                                167                 :                : 
                                168                 :          10773 :     GBT_VARKEY_R xkey = gbt_var_key_readable(key1);
                                169                 :          10773 :     GBT_VARKEY_R ykey = gbt_var_key_readable(key2);
                                170                 :                :     Datum       result;
                                171                 :                : 
                                172                 :                :     /* for leaf items we expect lower == upper, so only compare lower */
                                173                 :          10773 :     result = DirectFunctionCall2(byteacmp,
                                174                 :                :                                  PointerGetDatum(xkey.lower),
                                175                 :                :                                  PointerGetDatum(ykey.lower));
                                176                 :                : 
                                177         [ +  - ]:          10773 :     GBT_FREE_IF_COPY(key1, x);
                                178         [ +  - ]:          10773 :     GBT_FREE_IF_COPY(key2, y);
                                179                 :                : 
                                180                 :          10773 :     return DatumGetInt32(result);
                                181                 :                : }
                                182                 :                : 
                                183                 :                : Datum
                                184                 :              1 : gbt_bytea_sortsupport(PG_FUNCTION_ARGS)
                                185                 :                : {
                                186                 :              1 :     SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
                                187                 :                : 
                                188                 :              1 :     ssup->comparator = gbt_bytea_ssup_cmp;
                                189                 :              1 :     ssup->ssup_extra = NULL;
                                190                 :                : 
                                191                 :              1 :     PG_RETURN_VOID();
                                192                 :                : }
        

Generated by: LCOV version 2.4-beta