LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/preproc - ecpg_keywords.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 8 8 100.0 %
Date: 2019-09-19 02:07:14 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             : #include "preproc_extern.h"
      17             : #include "preproc.h"
      18             : 
      19             : /* ScanKeywordList lookup data for ECPG keywords */
      20             : #include "ecpg_kwlist_d.h"
      21             : 
      22             : /* Token codes for ECPG keywords */
      23             : #define PG_KEYWORD(kwname, value) value,
      24             : 
      25             : static const uint16 ECPGScanKeywordTokens[] = {
      26             : #include "ecpg_kwlist.h"
      27             : };
      28             : 
      29             : #undef PG_KEYWORD
      30             : 
      31             : 
      32             : /*
      33             :  * ScanECPGKeywordLookup - see if a given word is a keyword
      34             :  *
      35             :  * Returns the token value of the keyword, or -1 if no match.
      36             :  *
      37             :  * Keywords are matched using the same case-folding rules as in the backend.
      38             :  */
      39             : int
      40       10408 : ScanECPGKeywordLookup(const char *text)
      41             : {
      42             :     int         kwnum;
      43             : 
      44             :     /* First check SQL symbols defined by the backend. */
      45       10408 :     kwnum = ScanKeywordLookup(text, &ScanKeywords);
      46       10408 :     if (kwnum >= 0)
      47        5566 :         return SQLScanKeywordTokens[kwnum];
      48             : 
      49             :     /* Try ECPG-specific keywords. */
      50        4842 :     kwnum = ScanKeywordLookup(text, &ScanECPGKeywords);
      51        4842 :     if (kwnum >= 0)
      52        1762 :         return ECPGScanKeywordTokens[kwnum];
      53             : 
      54        3080 :     return -1;
      55             : }

Generated by: LCOV version 1.13