LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/preproc - ecpg_keywords.c (source / functions) Coverage Total Hit
Test: PostgreSQL 20devel Lines: 100.0 % 8 8
Test Date: 2026-07-12 23:15:38 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 100.0 % 4 4

             Branch data     Line data    Source code
       1                 :             : /*-------------------------------------------------------------------------
       2                 :             :  *
       3                 :             :  * ecpg_keywords.c
       4                 :             :  *    lexical token lookup for reserved words in postgres embedded SQL
       5                 :             :  *
       6                 :             :  * IDENTIFICATION
       7                 :             :  *    src/interfaces/ecpg/preproc/ecpg_keywords.c
       8                 :             :  *
       9                 :             :  *-------------------------------------------------------------------------
      10                 :             :  */
      11                 :             : 
      12                 :             : #include "postgres_fe.h"
      13                 :             : 
      14                 :             : #include <ctype.h>
      15                 :             : 
      16                 :             : /* ScanKeywordList lookup data for ECPG keywords */
      17                 :             : #include "ecpg_kwlist_d.h"
      18                 :             : #include "preproc_extern.h"
      19                 :             : #include "preproc.h"
      20                 :             : 
      21                 :             : /* Token codes for ECPG keywords */
      22                 :             : #define PG_KEYWORD(kwname, value) value,
      23                 :             : 
      24                 :             : static const uint16 ECPGScanKeywordTokens[] = {
      25                 :             : #include "ecpg_kwlist.h"
      26                 :             : };
      27                 :             : 
      28                 :             : #undef PG_KEYWORD
      29                 :             : 
      30                 :             : 
      31                 :             : /*
      32                 :             :  * ScanECPGKeywordLookup - see if a given word is a keyword
      33                 :             :  *
      34                 :             :  * Returns the token value of the keyword, or -1 if no match.
      35                 :             :  *
      36                 :             :  * Keywords are matched using the same case-folding rules as in the backend.
      37                 :             :  */
      38                 :             : int
      39                 :        5942 : ScanECPGKeywordLookup(const char *text)
      40                 :             : {
      41                 :             :     int         kwnum;
      42                 :             : 
      43                 :             :     /* First check SQL symbols defined by the backend. */
      44                 :        5942 :     kwnum = ScanKeywordLookup(text, &ScanKeywords);
      45         [ +  + ]:        5942 :     if (kwnum >= 0)
      46                 :        3264 :         return SQLScanKeywordTokens[kwnum];
      47                 :             : 
      48                 :             :     /* Try ECPG-specific keywords. */
      49                 :        2678 :     kwnum = ScanKeywordLookup(text, &ScanECPGKeywords);
      50         [ +  + ]:        2678 :     if (kwnum >= 0)
      51                 :         958 :         return ECPGScanKeywordTokens[kwnum];
      52                 :             : 
      53                 :        1720 :     return -1;
      54                 :             : }
        

Generated by: LCOV version 2.0-1