LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/preproc - ecpg_keywords.c (source / functions) Hit Total Coverage
Test: PostgreSQL 17devel Lines: 8 8 100.0 %
Date: 2024-04-26 15:11:27 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          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       11084 : ScanECPGKeywordLookup(const char *text)
      40             : {
      41             :     int         kwnum;
      42             : 
      43             :     /* First check SQL symbols defined by the backend. */
      44       11084 :     kwnum = ScanKeywordLookup(text, &ScanKeywords);
      45       11084 :     if (kwnum >= 0)
      46        6078 :         return SQLScanKeywordTokens[kwnum];
      47             : 
      48             :     /* Try ECPG-specific keywords. */
      49        5006 :     kwnum = ScanKeywordLookup(text, &ScanECPGKeywords);
      50        5006 :     if (kwnum >= 0)
      51        1838 :         return ECPGScanKeywordTokens[kwnum];
      52             : 
      53        3168 :     return -1;
      54             : }

Generated by: LCOV version 1.14