LCOV - differential code coverage report
Current view: top level - contrib/btree_gist - btree_bytea.c (source / functions) Coverage Total Hit CBC
Current: Differential Code Coverage HEAD vs 15 Lines: 100.0 % 52 52 52
Current Date: 2023-04-08 15:15:32 Functions: 100.0 % 18 18 18
Baseline: 15
Baseline Date: 2023-04-08 15:09:40
Legend: Lines: hit not hit

           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/builtins.h"
       9                 : #include "utils/bytea.h"
      10                 : 
      11                 : 
      12                 : /*
      13                 : ** Bytea ops
      14                 : */
      15 CBC           2 : PG_FUNCTION_INFO_V1(gbt_bytea_compress);
      16               2 : PG_FUNCTION_INFO_V1(gbt_bytea_union);
      17               2 : PG_FUNCTION_INFO_V1(gbt_bytea_picksplit);
      18               2 : PG_FUNCTION_INFO_V1(gbt_bytea_consistent);
      19               2 : PG_FUNCTION_INFO_V1(gbt_bytea_penalty);
      20               2 : PG_FUNCTION_INFO_V1(gbt_bytea_same);
      21                 : 
      22                 : 
      23                 : /* define for comparison */
      24                 : 
      25                 : static bool
      26             595 : gbt_byteagt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
      27                 : {
      28             595 :     return DatumGetBool(DirectFunctionCall2(byteagt,
      29                 :                                             PointerGetDatum(a),
      30                 :                                             PointerGetDatum(b)));
      31                 : }
      32                 : 
      33                 : static bool
      34             595 : gbt_byteage(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
      35                 : {
      36             595 :     return DatumGetBool(DirectFunctionCall2(byteage,
      37                 :                                             PointerGetDatum(a),
      38                 :                                             PointerGetDatum(b)));
      39                 : }
      40                 : 
      41                 : static bool
      42            1190 : gbt_byteaeq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
      43                 : {
      44            1190 :     return DatumGetBool(DirectFunctionCall2(byteaeq,
      45                 :                                             PointerGetDatum(a),
      46                 :                                             PointerGetDatum(b)));
      47                 : }
      48                 : 
      49                 : static bool
      50             989 : gbt_byteale(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
      51                 : {
      52             989 :     return DatumGetBool(DirectFunctionCall2(byteale,
      53                 :                                             PointerGetDatum(a),
      54                 :                                             PointerGetDatum(b)));
      55                 : }
      56                 : 
      57                 : static bool
      58            1639 : gbt_bytealt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
      59                 : {
      60            1639 :     return DatumGetBool(DirectFunctionCall2(bytealt,
      61                 :                                             PointerGetDatum(a),
      62                 :                                             PointerGetDatum(b)));
      63                 : }
      64                 : 
      65                 : static int32
      66           19781 : gbt_byteacmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
      67                 : {
      68           19781 :     return DatumGetInt32(DirectFunctionCall2(byteacmp,
      69                 :                                              PointerGetDatum(a),
      70                 :                                              PointerGetDatum(b)));
      71                 : }
      72                 : 
      73                 : 
      74                 : static const gbtree_vinfo tinfo =
      75                 : {
      76                 :     gbt_t_bytea,
      77                 :     0,
      78                 :     true,
      79                 :     gbt_byteagt,
      80                 :     gbt_byteage,
      81                 :     gbt_byteaeq,
      82                 :     gbt_byteale,
      83                 :     gbt_bytealt,
      84                 :     gbt_byteacmp,
      85                 :     NULL
      86                 : };
      87                 : 
      88                 : 
      89                 : /**************************************************
      90                 :  * Text ops
      91                 :  **************************************************/
      92                 : 
      93                 : 
      94                 : Datum
      95            1000 : gbt_bytea_compress(PG_FUNCTION_ARGS)
      96                 : {
      97            1000 :     GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
      98                 : 
      99            1000 :     PG_RETURN_POINTER(gbt_var_compress(entry, &tinfo));
     100                 : }
     101                 : 
     102                 : 
     103                 : 
     104                 : Datum
     105            5050 : gbt_bytea_consistent(PG_FUNCTION_ARGS)
     106                 : {
     107            5050 :     GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
     108            5050 :     void       *query = (void *) DatumGetByteaP(PG_GETARG_DATUM(1));
     109            5050 :     StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
     110                 : 
     111                 :     /* Oid      subtype = PG_GETARG_OID(3); */
     112            5050 :     bool       *recheck = (bool *) PG_GETARG_POINTER(4);
     113                 :     bool        retval;
     114            5050 :     GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
     115            5050 :     GBT_VARKEY_R r = gbt_var_key_readable(key);
     116                 : 
     117                 :     /* All cases served by this function are exact */
     118            5050 :     *recheck = false;
     119                 : 
     120           10100 :     retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
     121            5050 :                                 GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
     122            5050 :     PG_RETURN_BOOL(retval);
     123                 : }
     124                 : 
     125                 : 
     126                 : 
     127                 : Datum
     128             857 : gbt_bytea_union(PG_FUNCTION_ARGS)
     129                 : {
     130             857 :     GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
     131             857 :     int32      *size = (int *) PG_GETARG_POINTER(1);
     132                 : 
     133             857 :     PG_RETURN_POINTER(gbt_var_union(entryvec, size, PG_GET_COLLATION(),
     134                 :                                     &tinfo, fcinfo->flinfo));
     135                 : }
     136                 : 
     137                 : 
     138                 : Datum
     139               5 : gbt_bytea_picksplit(PG_FUNCTION_ARGS)
     140                 : {
     141               5 :     GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
     142               5 :     GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
     143                 : 
     144               5 :     gbt_var_picksplit(entryvec, v, PG_GET_COLLATION(),
     145                 :                       &tinfo, fcinfo->flinfo);
     146               5 :     PG_RETURN_POINTER(v);
     147                 : }
     148                 : 
     149                 : Datum
     150             856 : gbt_bytea_same(PG_FUNCTION_ARGS)
     151                 : {
     152             856 :     Datum       d1 = PG_GETARG_DATUM(0);
     153             856 :     Datum       d2 = PG_GETARG_DATUM(1);
     154             856 :     bool       *result = (bool *) PG_GETARG_POINTER(2);
     155                 : 
     156             856 :     *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
     157             856 :     PG_RETURN_POINTER(result);
     158                 : }
     159                 : 
     160                 : 
     161                 : Datum
     162            3278 : gbt_bytea_penalty(PG_FUNCTION_ARGS)
     163                 : {
     164            3278 :     GISTENTRY  *o = (GISTENTRY *) PG_GETARG_POINTER(0);
     165            3278 :     GISTENTRY  *n = (GISTENTRY *) PG_GETARG_POINTER(1);
     166            3278 :     float      *result = (float *) PG_GETARG_POINTER(2);
     167                 : 
     168            3278 :     PG_RETURN_POINTER(gbt_var_penalty(result, o, n, PG_GET_COLLATION(),
     169                 :                                       &tinfo, fcinfo->flinfo));
     170                 : }
        

Generated by: LCOV version v1.16-55-g56c0a2a