LCOV - code coverage report
Current view: top level - src/backend/tsearch - dict.c (source / functions) Coverage Total Hit
Test: PostgreSQL 20devel Lines: 96.7 % 30 29
Test Date: 2026-07-25 22:15:46 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 91.7 % 12 11

             Branch data     Line data    Source code
       1                 :             : /*-------------------------------------------------------------------------
       2                 :             :  *
       3                 :             :  * dict.c
       4                 :             :  *      Standard interface to dictionary
       5                 :             :  *
       6                 :             :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
       7                 :             :  *
       8                 :             :  *
       9                 :             :  * IDENTIFICATION
      10                 :             :  *    src/backend/tsearch/dict.c
      11                 :             :  *
      12                 :             :  *-------------------------------------------------------------------------
      13                 :             :  */
      14                 :             : #include "postgres.h"
      15                 :             : 
      16                 :             : #include "catalog/pg_type.h"
      17                 :             : #include "tsearch/ts_cache.h"
      18                 :             : #include "tsearch/ts_public.h"
      19                 :             : #include "utils/array.h"
      20                 :             : #include "utils/builtins.h"
      21                 :             : 
      22                 :             : 
      23                 :             : /*
      24                 :             :  * Lexize one word by dictionary, mostly debug function
      25                 :             :  */
      26                 :             : Datum
      27                 :         668 : ts_lexize(PG_FUNCTION_ARGS)
      28                 :             : {
      29                 :         668 :     Oid         dictId = PG_GETARG_OID(0);
      30                 :         668 :     text       *in = PG_GETARG_TEXT_PP(1);
      31                 :             :     ArrayType  *a;
      32                 :             :     TSDictionaryCacheEntry *dict;
      33                 :             :     TSLexeme   *res,
      34                 :             :                *ptr;
      35                 :             :     Datum      *da;
      36                 :         668 :     DictSubState dstate = {false, false, NULL};
      37                 :             : 
      38                 :         668 :     dict = lookup_ts_dictionary_cache(dictId);
      39                 :             : 
      40                 :         668 :     res = (TSLexeme *) DatumGetPointer(FunctionCall4(&dict->lexize,
      41                 :             :                                                      PointerGetDatum(dict->dictData),
      42                 :             :                                                      PointerGetDatum(VARDATA_ANY(in)),
      43                 :             :                                                      Int32GetDatum(VARSIZE_ANY_EXHDR(in)),
      44                 :             :                                                      PointerGetDatum(&dstate)));
      45                 :             : 
      46         [ +  + ]:         668 :     if (dstate.getnext)
      47                 :             :     {
      48                 :           5 :         dstate.isend = true;
      49                 :           5 :         ptr = (TSLexeme *) DatumGetPointer(FunctionCall4(&dict->lexize,
      50                 :             :                                                          PointerGetDatum(dict->dictData),
      51                 :             :                                                          PointerGetDatum(VARDATA_ANY(in)),
      52                 :             :                                                          Int32GetDatum(VARSIZE_ANY_EXHDR(in)),
      53                 :             :                                                          PointerGetDatum(&dstate)));
      54         [ -  + ]:           5 :         if (ptr != NULL)
      55                 :           0 :             res = ptr;
      56                 :             :     }
      57                 :             : 
      58         [ +  + ]:         668 :     if (!res)
      59                 :          38 :         PG_RETURN_NULL();
      60                 :             : 
      61                 :         630 :     ptr = res;
      62         [ +  + ]:        1529 :     while (ptr->lexeme)
      63                 :         899 :         ptr++;
      64                 :         630 :     da = (Datum *) palloc_array(Datum, ptr - res);
      65                 :         630 :     ptr = res;
      66         [ +  + ]:        1529 :     while (ptr->lexeme)
      67                 :             :     {
      68                 :         899 :         da[ptr - res] = CStringGetTextDatum(ptr->lexeme);
      69                 :         899 :         ptr++;
      70                 :             :     }
      71                 :             : 
      72                 :         630 :     a = construct_array_builtin(da, ptr - res, TEXTOID);
      73                 :             : 
      74                 :         630 :     ptr = res;
      75         [ +  + ]:        1529 :     while (ptr->lexeme)
      76                 :             :     {
      77                 :         899 :         pfree(DatumGetPointer(da[ptr - res]));
      78                 :         899 :         pfree(ptr->lexeme);
      79                 :         899 :         ptr++;
      80                 :             :     }
      81                 :         630 :     pfree(res);
      82                 :         630 :     pfree(da);
      83                 :             : 
      84                 :         630 :     PG_RETURN_POINTER(a);
      85                 :             : }
        

Generated by: LCOV version 2.0-1