LCOV - code coverage report
Current view: top level - src/backend/parser - scan.l (source / functions) Coverage Total Hit
Test: PostgreSQL 20devel Lines: 86.7 % 465 403
Test Date: 2026-07-03 19:57:34 Functions: 82.4 % 17 14
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 66.7 % 174 116

             Branch data     Line data    Source code
       1                 :             : %top{
       2                 :             : /*-------------------------------------------------------------------------
       3                 :             :  *
       4                 :             :  * scan.l
       5                 :             :  *    lexical scanner for PostgreSQL
       6                 :             :  *
       7                 :             :  * NOTE NOTE NOTE:
       8                 :             :  *
       9                 :             :  * The rules in this file must be kept in sync with src/fe_utils/psqlscan.l
      10                 :             :  * and src/interfaces/ecpg/preproc/pgc.l!
      11                 :             :  *
      12                 :             :  * The rules are designed so that the scanner never has to backtrack,
      13                 :             :  * in the sense that there is always a rule that can match the input
      14                 :             :  * consumed so far (the rule action may internally throw back some input
      15                 :             :  * with yyless(), however).  As explained in the flex manual, this makes
      16                 :             :  * for a useful speed increase --- several percent faster when measuring
      17                 :             :  * raw parsing (Flex + Bison).  The extra complexity is mostly in the rules
      18                 :             :  * for handling float numbers and continued string literals.  If you change
      19                 :             :  * the lexical rules, verify that you haven't broken the no-backtrack
      20                 :             :  * property by running flex with the "-b" option and checking that the
      21                 :             :  * resulting "lex.backup" file says that no backing up is needed.  (As of
      22                 :             :  * Postgres 9.2, this check is made automatically by the Makefile.)
      23                 :             :  *
      24                 :             :  *
      25                 :             :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
      26                 :             :  * Portions Copyright (c) 1994, Regents of the University of California
      27                 :             :  *
      28                 :             :  * IDENTIFICATION
      29                 :             :  *    src/backend/parser/scan.l
      30                 :             :  *
      31                 :             :  *-------------------------------------------------------------------------
      32                 :             :  */
      33                 :             : #include "postgres.h"
      34                 :             : 
      35                 :             : #include <ctype.h>
      36                 :             : #include <unistd.h>
      37                 :             : 
      38                 :             : #include "common/string.h"
      39                 :             : #include "gramparse.h"
      40                 :             : #include "nodes/miscnodes.h"
      41                 :             : #include "parser/parser.h"        /* only needed for GUC variables */
      42                 :             : #include "parser/scansup.h"
      43                 :             : #include "port/pg_bitutils.h"
      44                 :             : #include "mb/pg_wchar.h"
      45                 :             : #include "utils/builtins.h"
      46                 :             : }
      47                 :             : 
      48                 :             : %{
      49                 :             : 
      50                 :             : /* LCOV_EXCL_START */
      51                 :             : 
      52                 :             : /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
      53                 :             : #undef fprintf
      54                 :             : #define fprintf(file, fmt, msg)  fprintf_to_ereport(fmt, msg)
      55                 :             : 
      56                 :             : static void
      57                 :           0 : fprintf_to_ereport(const char *fmt, const char *msg)
      58                 :             : {
      59         [ #  # ]:           0 :     ereport(ERROR, (errmsg_internal("%s", msg)));
      60                 :             : }
      61                 :             : 
      62                 :             : /*
      63                 :             :  * GUC variable.  This is a DIRECT violation of the warning given at the
      64                 :             :  * head of gram.y, ie flex/bison code must not depend on any GUC variables;
      65                 :             :  * as such, changing its value can induce very unintuitive behavior.
      66                 :             :  * In practice, backslash_quote is not too awful since it only controls
      67                 :             :  * whether to throw an error: it cannot change non-error results.
      68                 :             :  */
      69                 :             : int         backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING;
      70                 :             : 
      71                 :             : /*
      72                 :             :  * Constant data exported from this file.  This array maps from the
      73                 :             :  * zero-based keyword numbers returned by ScanKeywordLookup to the
      74                 :             :  * Bison token numbers needed by gram.y.  This is exported because
      75                 :             :  * callers need to pass it to scanner_init, if they are using the
      76                 :             :  * standard keyword list ScanKeywords.
      77                 :             :  */
      78                 :             : #define PG_KEYWORD(kwname, value, category, collabel) value,
      79                 :             : 
      80                 :             : const uint16 ScanKeywordTokens[] = {
      81                 :             : #include "parser/kwlist.h"
      82                 :             : };
      83                 :             : 
      84                 :             : #undef PG_KEYWORD
      85                 :             : 
      86                 :             : /*
      87                 :             :  * Set the type of YYSTYPE.
      88                 :             :  */
      89                 :             : #define YYSTYPE core_YYSTYPE
      90                 :             : 
      91                 :             : /*
      92                 :             :  * Each call to yylex must set yylloc to the location of the found token
      93                 :             :  * (expressed as a byte offset from the start of the input text).
      94                 :             :  * When we parse a token that requires multiple lexer rules to process,
      95                 :             :  * this should be done in the first such rule, else yylloc will point
      96                 :             :  * into the middle of the token.
      97                 :             :  */
      98                 :             : #define SET_YYLLOC()  (*(yylloc) = yytext - yyextra->scanbuf)
      99                 :             : 
     100                 :             : /*
     101                 :             :  * Advance yylloc by the given number of bytes.
     102                 :             :  */
     103                 :             : #define ADVANCE_YYLLOC(delta)  ( *(yylloc) += (delta) )
     104                 :             : 
     105                 :             : /*
     106                 :             :  * Sometimes, we do want yylloc to point into the middle of a token; this is
     107                 :             :  * useful for instance to throw an error about an escape sequence within a
     108                 :             :  * string literal.  But if we find no error there, we want to revert yylloc
     109                 :             :  * to the token start, so that that's the location reported to the parser.
     110                 :             :  * Use PUSH_YYLLOC/POP_YYLLOC to save/restore yylloc around such code.
     111                 :             :  * (Currently the implied "stack" is just one location, but someday we might
     112                 :             :  * need to nest these.)
     113                 :             :  */
     114                 :             : #define PUSH_YYLLOC()   (yyextra->save_yylloc = *(yylloc))
     115                 :             : #define POP_YYLLOC()    (*(yylloc) = yyextra->save_yylloc)
     116                 :             : 
     117                 :             : #define startlit()  ( yyextra->literallen = 0 )
     118                 :             : static void addlit(char *ytext, int yleng, core_yyscan_t yyscanner);
     119                 :             : static void addlitchar(unsigned char ychar, core_yyscan_t yyscanner);
     120                 :             : static char *litbufdup(core_yyscan_t yyscanner);
     121                 :             : static unsigned char unescape_single_char(unsigned char c, core_yyscan_t yyscanner);
     122                 :             : static int  process_integer_literal(const char *token, YYSTYPE *lval, int base);
     123                 :             : static void addunicode(char32_t c, yyscan_t yyscanner);
     124                 :             : 
     125                 :             : #define yyerror(msg)  scanner_yyerror(msg, yyscanner)
     126                 :             : 
     127                 :             : #define lexer_errposition()  scanner_errposition(*(yylloc), yyscanner)
     128                 :             : 
     129                 :             : %}
     130                 :             : 
     131                 :             : %option reentrant
     132                 :             : %option bison-bridge
     133                 :             : %option bison-locations
     134                 :             : %option 8bit
     135                 :             : %option never-interactive
     136                 :             : %option nodefault
     137                 :             : %option noinput
     138                 :             : %option nounput
     139                 :             : %option noyywrap
     140                 :             : %option noyyalloc
     141                 :             : %option noyyrealloc
     142                 :             : %option noyyfree
     143                 :             : %option warn
     144                 :             : %option prefix="core_yy"
     145                 :             : %option extra-type="core_yy_extra_type *"
     146                 :             : 
     147                 :             : /*
     148                 :             :  * OK, here is a short description of lex/flex rules behavior.
     149                 :             :  * The longest pattern which matches an input string is always chosen.
     150                 :             :  * For equal-length patterns, the first occurring in the rules list is chosen.
     151                 :             :  * INITIAL is the starting state, to which all non-conditional rules apply.
     152                 :             :  * Exclusive states change parsing rules while the state is active.  When in
     153                 :             :  * an exclusive state, only those rules defined for that state apply.
     154                 :             :  *
     155                 :             :  * We use exclusive states for quoted strings, extended comments,
     156                 :             :  * and to eliminate parsing troubles for numeric strings.
     157                 :             :  * Exclusive states:
     158                 :             :  *  <xb> bit string literal
     159                 :             :  *  <xc> extended C-style comments
     160                 :             :  *  <xd> delimited identifiers (double-quoted identifiers)
     161                 :             :  *  <xh> hexadecimal byte string
     162                 :             :  *  <xq> standard quoted strings
     163                 :             :  *  <xqs> quote stop (detect continued strings)
     164                 :             :  *  <xe> extended quoted strings (support backslash escape sequences)
     165                 :             :  *  <xdolq> $foo$ quoted strings
     166                 :             :  *  <xui> quoted identifier with Unicode escapes
     167                 :             :  *  <xus> quoted string with Unicode escapes
     168                 :             :  *  <xeu> Unicode surrogate pair in extended quoted string
     169                 :             :  *
     170                 :             :  * Remember to add an <<EOF>> case whenever you add a new exclusive state!
     171                 :             :  * The default one is probably not the right thing.
     172                 :             :  */
     173                 :             : 
     174                 :             : %x xb
     175                 :             : %x xc
     176                 :             : %x xd
     177                 :             : %x xh
     178                 :             : %x xq
     179                 :             : %x xqs
     180                 :             : %x xe
     181                 :             : %x xdolq
     182                 :             : %x xui
     183                 :             : %x xus
     184                 :             : %x xeu
     185                 :             : 
     186                 :             : /*
     187                 :             :  * In order to make the world safe for Windows and Mac clients as well as
     188                 :             :  * Unix ones, we accept either \n or \r as a newline.  A DOS-style \r\n
     189                 :             :  * sequence will be seen as two successive newlines, but that doesn't cause
     190                 :             :  * any problems.  Comments that start with -- and extend to the next
     191                 :             :  * newline are treated as equivalent to a single whitespace character.
     192                 :             :  *
     193                 :             :  * NOTE a fine point: if there is no newline following --, we will absorb
     194                 :             :  * everything to the end of the input as a comment.  This is correct.  Older
     195                 :             :  * versions of Postgres failed to recognize -- as a comment if the input
     196                 :             :  * did not end with a newline.
     197                 :             :  *
     198                 :             :  * non_newline_space tracks all the other space characters except newlines.
     199                 :             :  *
     200                 :             :  * XXX if you change the set of whitespace characters, fix scanner_isspace()
     201                 :             :  * to agree.
     202                 :             :  */
     203                 :             : 
     204                 :             : space               [ \t\n\r\f\v]
     205                 :             : non_newline_space   [ \t\f\v]
     206                 :             : newline             [\n\r]
     207                 :             : non_newline         [^\n\r]
     208                 :             : 
     209                 :             : comment         ("--"{non_newline}*)
     210                 :             : 
     211                 :             : whitespace      ({space}+|{comment})
     212                 :             : 
     213                 :             : /*
     214                 :             :  * SQL requires at least one newline in the whitespace separating
     215                 :             :  * string literals that are to be concatenated.  Silly, but who are we
     216                 :             :  * to argue?  Note that {whitespace_with_newline} should not have * after
     217                 :             :  * it, whereas {whitespace} should generally have a * after it...
     218                 :             :  */
     219                 :             : 
     220                 :             : special_whitespace      ({space}+|{comment}{newline})
     221                 :             : non_newline_whitespace  ({non_newline_space}|{comment})
     222                 :             : whitespace_with_newline ({non_newline_whitespace}*{newline}{special_whitespace}*)
     223                 :             : 
     224                 :             : quote           '
     225                 :             : /* If we see {quote} then {quotecontinue}, the quoted string continues */
     226                 :             : quotecontinue   {whitespace_with_newline}{quote}
     227                 :             : 
     228                 :             : /*
     229                 :             :  * {quotecontinuefail} is needed to avoid lexer backup when we fail to match
     230                 :             :  * {quotecontinue}.  It might seem that this could just be {whitespace}*,
     231                 :             :  * but if there's a dash after {whitespace_with_newline}, it must be consumed
     232                 :             :  * to see if there's another dash --- which would start a {comment} and thus
     233                 :             :  * allow continuation of the {quotecontinue} token.
     234                 :             :  */
     235                 :             : quotecontinuefail   {whitespace}*"-"?
     236                 :             : 
     237                 :             : /* Bit string
     238                 :             :  * It is tempting to scan the string for only those characters
     239                 :             :  * which are allowed. However, this leads to silently swallowed
     240                 :             :  * characters if illegal characters are included in the string.
     241                 :             :  * For example, if xbinside is [01] then B'ABCD' is interpreted
     242                 :             :  * as a zero-length string, and the ABCD' is lost!
     243                 :             :  * Better to pass the string forward and let the input routines
     244                 :             :  * validate the contents.
     245                 :             :  */
     246                 :             : xbstart         [bB]{quote}
     247                 :             : xbinside        [^']*
     248                 :             : 
     249                 :             : /* Hexadecimal byte string */
     250                 :             : xhstart         [xX]{quote}
     251                 :             : xhinside        [^']*
     252                 :             : 
     253                 :             : /* National character */
     254                 :             : xnstart         [nN]{quote}
     255                 :             : 
     256                 :             : /* Quoted string that allows backslash escapes */
     257                 :             : xestart         [eE]{quote}
     258                 :             : xeinside        [^\\']+
     259                 :             : xeescape        [\\][^0-7]
     260                 :             : xeoctesc        [\\][0-7]{1,3}
     261                 :             : xehexesc        [\\]x[0-9A-Fa-f]{1,2}
     262                 :             : xeunicode       [\\](u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})
     263                 :             : xeunicodefail   [\\](u[0-9A-Fa-f]{0,3}|U[0-9A-Fa-f]{0,7})
     264                 :             : 
     265                 :             : /* Extended quote
     266                 :             :  * xqdouble implements embedded quote, ''''
     267                 :             :  */
     268                 :             : xqstart         {quote}
     269                 :             : xqdouble        {quote}{quote}
     270                 :             : xqinside        [^']+
     271                 :             : 
     272                 :             : /* $foo$ style quotes ("dollar quoting")
     273                 :             :  * The quoted string starts with $foo$ where "foo" is an optional string
     274                 :             :  * in the form of an identifier, except that it may not contain "$",
     275                 :             :  * and extends to the first occurrence of an identical string.
     276                 :             :  * There is *no* processing of the quoted text.
     277                 :             :  *
     278                 :             :  * {dolqfailed} is an error rule to avoid scanner backup when {dolqdelim}
     279                 :             :  * fails to match its trailing "$".
     280                 :             :  */
     281                 :             : dolq_start      [A-Za-z\200-\377_]
     282                 :             : dolq_cont       [A-Za-z\200-\377_0-9]
     283                 :             : dolqdelim       \$({dolq_start}{dolq_cont}*)?\$
     284                 :             : dolqfailed      \${dolq_start}{dolq_cont}*
     285                 :             : dolqinside      [^$]+
     286                 :             : 
     287                 :             : /* Double quote
     288                 :             :  * Allows embedded spaces and other special characters into identifiers.
     289                 :             :  */
     290                 :             : dquote          \"
     291                 :             : xdstart         {dquote}
     292                 :             : xdstop          {dquote}
     293                 :             : xddouble        {dquote}{dquote}
     294                 :             : xdinside        [^"]+
     295                 :             : 
     296                 :             : /* Quoted identifier with Unicode escapes */
     297                 :             : xuistart        [uU]&{dquote}
     298                 :             : 
     299                 :             : /* Quoted string with Unicode escapes */
     300                 :             : xusstart        [uU]&{quote}
     301                 :             : 
     302                 :             : /* error rule to avoid backup */
     303                 :             : xufailed        [uU]&
     304                 :             : 
     305                 :             : 
     306                 :             : /* C-style comments
     307                 :             :  *
     308                 :             :  * The "extended comment" syntax closely resembles allowable operator syntax.
     309                 :             :  * The tricky part here is to get lex to recognize a string starting with
     310                 :             :  * slash-star as a comment, when interpreting it as an operator would produce
     311                 :             :  * a longer match --- remember lex will prefer a longer match!  Also, if we
     312                 :             :  * have something like plus-slash-star, lex will think this is a 3-character
     313                 :             :  * operator whereas we want to see it as a + operator and a comment start.
     314                 :             :  * The solution is two-fold:
     315                 :             :  * 1. append {op_chars}* to xcstart so that it matches as much text as
     316                 :             :  *    {operator} would. Then the tie-breaker (first matching rule of same
     317                 :             :  *    length) ensures xcstart wins.  We put back the extra stuff with yyless()
     318                 :             :  *    in case it contains a star-slash that should terminate the comment.
     319                 :             :  * 2. In the operator rule, check for slash-star within the operator, and
     320                 :             :  *    if found throw it back with yyless().  This handles the plus-slash-star
     321                 :             :  *    problem.
     322                 :             :  * Dash-dash comments have similar interactions with the operator rule.
     323                 :             :  */
     324                 :             : xcstart         \/\*{op_chars}*
     325                 :             : xcstop          \*+\/
     326                 :             : xcinside        [^*/]+
     327                 :             : 
     328                 :             : ident_start     [A-Za-z\200-\377_]
     329                 :             : ident_cont      [A-Za-z\200-\377_0-9\$]
     330                 :             : 
     331                 :             : identifier      {ident_start}{ident_cont}*
     332                 :             : 
     333                 :             : /* Assorted special-case operators and operator-like tokens */
     334                 :             : typecast        "::"
     335                 :             : dot_dot         \.\.
     336                 :             : colon_equals    ":="
     337                 :             : 
     338                 :             : /*
     339                 :             :  * These operator-like tokens (unlike the above ones) also match the {operator}
     340                 :             :  * rule, which means that they might be overridden by a longer match if they
     341                 :             :  * are followed by a comment start or a + or - character. Accordingly, if you
     342                 :             :  * add to this list, you must also add corresponding code to the {operator}
     343                 :             :  * block to return the correct token in such cases. (This is not needed in
     344                 :             :  * psqlscan.l since the token value is ignored there.)
     345                 :             :  */
     346                 :             : equals_greater  "=>"
     347                 :             : less_equals     "<="
     348                 :             : greater_equals  ">="
     349                 :             : less_greater    "<>"
     350                 :             : not_equals      "!="
     351                 :             : /* Note there is no need for left_arrow, since "<-" is not a single operator. */
     352                 :             : right_arrow     "->"
     353                 :             : 
     354                 :             : /*
     355                 :             :  * "self" is the set of chars that should be returned as single-character
     356                 :             :  * tokens.  "op_chars" is the set of chars that can make up "Op" tokens,
     357                 :             :  * which can be one or more characters long (but if a single-char token
     358                 :             :  * appears in the "self" set, it is not to be returned as an Op).  Note
     359                 :             :  * that the sets overlap, but each has some chars that are not in the other.
     360                 :             :  *
     361                 :             :  * If you change either set, adjust the character lists appearing in the
     362                 :             :  * rule for "operator"!
     363                 :             :  */
     364                 :             : self            [,()\[\].;\:\|\+\-\*\/\%\^\<\>\=]
     365                 :             : op_chars        [\~\!\@\#\^\&\|\`\?\+\-\*\/\%\<\>\=]
     366                 :             : operator        {op_chars}+
     367                 :             : 
     368                 :             : /*
     369                 :             :  * Numbers
     370                 :             :  *
     371                 :             :  * Unary minus is not part of a number here.  Instead we pass it separately to
     372                 :             :  * the parser, and there it gets coerced via doNegate().
     373                 :             :  *
     374                 :             :  * {numericfail} is used because we would like "1..10" to lex as 1, dot_dot, 10.
     375                 :             :  *
     376                 :             :  * {realfail} is added to prevent the need for scanner
     377                 :             :  * backup when the {real} rule fails to match completely.
     378                 :             :  */
     379                 :             : decdigit        [0-9]
     380                 :             : hexdigit        [0-9A-Fa-f]
     381                 :             : octdigit        [0-7]
     382                 :             : bindigit        [0-1]
     383                 :             : 
     384                 :             : decinteger      {decdigit}(_?{decdigit})*
     385                 :             : hexinteger      0[xX](_?{hexdigit})+
     386                 :             : octinteger      0[oO](_?{octdigit})+
     387                 :             : bininteger      0[bB](_?{bindigit})+
     388                 :             : 
     389                 :             : hexfail         0[xX]_?
     390                 :             : octfail         0[oO]_?
     391                 :             : binfail         0[bB]_?
     392                 :             : 
     393                 :             : numeric         (({decinteger}\.{decinteger}?)|(\.{decinteger}))
     394                 :             : numericfail     {decinteger}\.\.
     395                 :             : 
     396                 :             : real            ({decinteger}|{numeric})[Ee][-+]?{decinteger}
     397                 :             : realfail        ({decinteger}|{numeric})[Ee][-+]
     398                 :             : 
     399                 :             : /* Positional parameters don't accept underscores. */
     400                 :             : param           \${decdigit}+
     401                 :             : 
     402                 :             : /*
     403                 :             :  * An identifier immediately following an integer literal is disallowed because
     404                 :             :  * in some cases it's ambiguous what is meant: for example, 0x1234 could be
     405                 :             :  * either a hexinteger or a decinteger "0" and an identifier "x1234".  We can
     406                 :             :  * detect such problems by seeing if integer_junk matches a longer substring
     407                 :             :  * than any of the XXXinteger patterns (decinteger, hexinteger, octinteger,
     408                 :             :  * bininteger).  One "junk" pattern is sufficient because
     409                 :             :  * {decinteger}{identifier} will match all the same strings we'd match with
     410                 :             :  * {hexinteger}{identifier} etc.
     411                 :             :  *
     412                 :             :  * Note that the rule for integer_junk must appear after the ones for
     413                 :             :  * XXXinteger to make this work correctly: 0x1234 will match both hexinteger
     414                 :             :  * and integer_junk, and we need hexinteger to be chosen in that case.
     415                 :             :  *
     416                 :             :  * Also disallow strings matched by numeric_junk, real_junk and param_junk
     417                 :             :  * for consistency.
     418                 :             :  */
     419                 :             : integer_junk    {decinteger}{identifier}
     420                 :             : numeric_junk    {numeric}{identifier}
     421                 :             : real_junk       {real}{identifier}
     422                 :             : param_junk      \${decdigit}+{identifier}
     423                 :             : 
     424                 :             : other           .
     425                 :             : 
     426                 :             : /*
     427                 :             :  * Dollar quoted strings are totally opaque, and no escaping is done on them.
     428                 :             :  * Other quoted strings must allow some special characters such as single-quote
     429                 :             :  *  and newline.
     430                 :             :  * Embedded single-quotes are implemented both in the SQL standard
     431                 :             :  *  style of two adjacent single quotes "''" and in the Postgres/Java style
     432                 :             :  *  of escaped-quote "\'".
     433                 :             :  * Other embedded escaped characters are matched explicitly and the leading
     434                 :             :  *  backslash is dropped from the string.
     435                 :             :  * Note that xcstart must appear before operator, as explained above!
     436                 :             :  *  Also whitespace (comment) must appear before operator.
     437                 :             :  */
     438                 :             : 
     439                 :             : %%
     440                 :             : 
     441                 :             : {whitespace}    {
     442                 :             :                     /* ignore */
     443                 :             :                 }
     444                 :     6643324 : 
     445                 :       42639 : {xcstart}       {
     446                 :             :                     /* Set location in case of syntax error in comment */
     447                 :       42639 :                     SET_YYLLOC();
     448                 :       42639 :                     yyextra->xcdepth = 0;
     449                 :       42639 :                     BEGIN(xc);
     450                 :             :                     /* Put back any characters past slash-star; see above */
     451                 :       42639 :                     yyless(2);
     452                 :             :                 }
     453                 :       42639 : 
     454                 :             : <xc>{
     455                 :          12 : {xcstart}       {
     456                 :          12 :                     (yyextra->xcdepth)++;
     457                 :             :                     /* Put back any characters past slash-star; see above */
     458                 :          12 :                     yyless(2);
     459                 :             :                 }
     460                 :          12 : 
     461                 :       42651 : {xcstop}        {
     462         [ +  + ]:       42651 :                     if (yyextra->xcdepth <= 0)
     463                 :       42639 :                         BEGIN(INITIAL);
     464                 :             :                     else
     465                 :          12 :                         (yyextra->xcdepth)--;
     466                 :             :                 }
     467                 :       42651 : 
     468                 :       93932 : {xcinside}      {
     469                 :             :                     /* ignore */
     470                 :             :                 }
     471                 :       93932 : 
     472                 :       51314 : {op_chars}      {
     473                 :             :                     /* ignore */
     474                 :             :                 }
     475                 :       51314 : 
     476                 :           0 : \*+             {
     477                 :             :                     /* ignore */
     478                 :             :                 }
     479                 :           0 : 
     480                 :           0 : <<EOF>>         {
     481                 :           0 :                     yyerror("unterminated /* comment");
     482                 :             :                 }
     483                 :             : } /* <xc> */
     484                 :             : 
     485                 :         534 : {xbstart}       {
     486                 :             :                     /* Binary bit type.
     487                 :             :                      * At some point we should simply pass the string
     488                 :             :                      * forward to the parser and label it there.
     489                 :             :                      * In the meantime, place a leading "b" on the string
     490                 :             :                      * to mark it for the input routine as a binary string.
     491                 :             :                      */
     492                 :         534 :                     SET_YYLLOC();
     493                 :         534 :                     BEGIN(xb);
     494                 :         534 :                     startlit();
     495                 :         534 :                     addlitchar('b', yyscanner);
     496                 :             :                 }
     497                 :         534 : <xh>{xhinside}    |
     498                 :        3255 : <xb>{xbinside}    {
     499                 :        3255 :                     addlit(yytext, yyleng, yyscanner);
     500                 :             :                 }
     501                 :        3255 : <xb><<EOF>>       { yyerror("unterminated bit string literal"); }
     502                 :           0 : 
     503                 :        2742 : {xhstart}       {
     504                 :             :                     /* Hexadecimal bit type.
     505                 :             :                      * At some point we should simply pass the string
     506                 :             :                      * forward to the parser and label it there.
     507                 :             :                      * In the meantime, place a leading "x" on the string
     508                 :             :                      * to mark it for the input routine as a hex string.
     509                 :             :                      */
     510                 :        2742 :                     SET_YYLLOC();
     511                 :        2742 :                     BEGIN(xh);
     512                 :        2742 :                     startlit();
     513                 :        2742 :                     addlitchar('x', yyscanner);
     514                 :             :                 }
     515                 :        2742 : <xh><<EOF>>       { yyerror("unterminated hexadecimal string literal"); }
     516                 :           0 : 
     517                 :           2 : {xnstart}       {
     518                 :             :                     /* National character.
     519                 :             :                      * We will pass this along as a normal character string,
     520                 :             :                      * but preceded with an internally-generated "NCHAR".
     521                 :             :                      */
     522                 :             :                     int     kwnum;
     523                 :             : 
     524                 :           2 :                     SET_YYLLOC();
     525                 :           2 :                     yyless(1);  /* eat only 'n' this time */
     526                 :             : 
     527                 :           2 :                     kwnum = ScanKeywordLookup("nchar",
     528                 :           2 :                                               yyextra->keywordlist);
     529         [ +  - ]:           2 :                     if (kwnum >= 0)
     530                 :             :                     {
     531                 :           4 :                         yylval->keyword = GetScanKeyword(kwnum,
     532                 :           2 :                                                          yyextra->keywordlist);
     533                 :           2 :                         return yyextra->keyword_tokens[kwnum];
     534                 :             :                     }
     535                 :             :                     else
     536                 :             :                     {
     537                 :             :                         /* If NCHAR isn't a keyword, just return "n" */
     538                 :           0 :                         yylval->str = pstrdup("n");
     539                 :           0 :                         return IDENT;
     540                 :             :                     }
     541                 :             :                 }
     542                 :             : 
     543                 :      517082 : {xqstart}       {
     544                 :      517082 :                     yyextra->saw_non_ascii = false;
     545                 :      517082 :                     SET_YYLLOC();
     546                 :      517082 :                     BEGIN(xq);
     547                 :      517082 :                     startlit();
     548                 :             :                 }
     549                 :      517082 : {xestart}       {
     550                 :        2909 :                     yyextra->saw_non_ascii = false;
     551                 :        2909 :                     SET_YYLLOC();
     552                 :        2909 :                     BEGIN(xe);
     553                 :        2909 :                     startlit();
     554                 :             :                 }
     555                 :        2909 : {xusstart}      {
     556                 :         502 :                     SET_YYLLOC();
     557                 :         502 :                     BEGIN(xus);
     558                 :         502 :                     startlit();
     559                 :             :                 }
     560                 :         502 : 
     561                 :      523760 : <xb,xh,xq,xe,xus>{quote} {
     562                 :             :                     /*
     563                 :             :                      * When we are scanning a quoted string and see an end
     564                 :             :                      * quote, we must look ahead for a possible continuation.
     565                 :             :                      * If we don't see one, we know the end quote was in fact
     566                 :             :                      * the end of the string.  To reduce the lexer table size,
     567                 :             :                      * we use a single "xqs" state to do the lookahead for all
     568                 :             :                      * types of strings.
     569                 :             :                      */
     570                 :      523760 :                     yyextra->state_before_str_stop = YYSTATE;
     571                 :      523760 :                     BEGIN(xqs);
     572                 :             :                 }
     573                 :      523760 : <xqs>{quotecontinue} {
     574                 :          23 :                     /*
     575                 :             :                      * Found a quote continuation, so return to the in-quote
     576                 :             :                      * state and continue scanning the literal.  Nothing is
     577                 :             :                      * added to the literal's contents.
     578                 :             :                      */
     579                 :          23 :                     BEGIN(yyextra->state_before_str_stop);
     580                 :             :                 }
     581                 :          23 : <xqs>{quotecontinuefail} |
     582                 :      523737 : <xqs>{other} |
     583                 :             : <xqs><<EOF>>  {
     584                 :             :                     /*
     585                 :             :                      * Failed to see a quote continuation.  Throw back
     586                 :             :                      * everything after the end quote, and handle the string
     587                 :             :                      * according to the state we were in previously.
     588                 :             :                      */
     589                 :      523737 :                     yyless(0);
     590                 :      523737 :                     BEGIN(INITIAL);
     591                 :             : 
     592   [ +  +  +  +  :      523737 :                     switch (yyextra->state_before_str_stop)
                      - ]
     593                 :             :                     {
     594                 :         534 :                         case xb:
     595                 :         534 :                             yylval->str = litbufdup(yyscanner);
     596                 :         534 :                             return BCONST;
     597                 :        2742 :                         case xh:
     598                 :        2742 :                             yylval->str = litbufdup(yyscanner);
     599                 :        2742 :                             return XCONST;
     600                 :      519959 :                         case xq:
     601                 :             :                         case xe:
     602                 :             :                             /*
     603                 :             :                              * Check that the data remains valid, if it might
     604                 :             :                              * have been made invalid by unescaping any chars.
     605                 :             :                              */
     606         [ +  + ]:      519959 :                             if (yyextra->saw_non_ascii)
     607                 :           3 :                                 pg_verifymbstr(yyextra->literalbuf,
     608                 :           3 :                                                yyextra->literallen,
     609                 :             :                                                false);
     610                 :      519959 :                             yylval->str = litbufdup(yyscanner);
     611                 :      519959 :                             return SCONST;
     612                 :         502 :                         case xus:
     613                 :         502 :                             yylval->str = litbufdup(yyscanner);
     614                 :         502 :                             return USCONST;
     615                 :           0 :                         default:
     616                 :           0 :                             yyerror("unhandled previous state in xqs");
     617                 :             :                     }
     618                 :             :                 }
     619                 :             : 
     620                 :        4445 : <xq,xe,xus>{xqdouble} {
     621                 :        4445 :                     addlitchar('\'', yyscanner);
     622                 :             :                 }
     623                 :        4445 : <xq,xus>{xqinside}  {
     624                 :      508433 :                     addlit(yytext, yyleng, yyscanner);
     625                 :             :                 }
     626                 :      508433 : <xe>{xeinside}  {
     627                 :        3235 :                     addlit(yytext, yyleng, yyscanner);
     628                 :             :                 }
     629                 :        3235 : <xe>{xeunicode} {
     630                 :         124 :                     char32_t    c = strtoul(yytext + 2, NULL, 16);
     631                 :             : 
     632                 :             :                     /* Remember start of overall string token ... */
     633                 :         124 :                     PUSH_YYLLOC();
     634                 :             :                     /* ... and set the error cursor to point at this esc seq */
     635                 :         124 :                     SET_YYLLOC();
     636                 :             : 
     637         [ +  + ]:         124 :                     if (is_utf16_surrogate_first(c))
     638                 :             :                     {
     639                 :          20 :                         yyextra->utf16_first_part = c;
     640                 :          20 :                         BEGIN(xeu);
     641                 :             :                     }
     642         [ -  + ]:         104 :                     else if (is_utf16_surrogate_second(c))
     643                 :           0 :                         yyerror("invalid Unicode surrogate pair");
     644                 :             :                     else
     645                 :         104 :                         addunicode(c, yyscanner);
     646                 :             : 
     647                 :             :                     /* Restore yylloc to be start of string token */
     648                 :         120 :                     POP_YYLLOC();
     649                 :             :                 }
     650                 :         120 : <xeu>{xeunicode} {
     651                 :           8 :                     char32_t    c = strtoul(yytext + 2, NULL, 16);
     652                 :             : 
     653                 :             :                     /* Remember start of overall string token ... */
     654                 :           8 :                     PUSH_YYLLOC();
     655                 :             :                     /* ... and set the error cursor to point at this esc seq */
     656                 :           8 :                     SET_YYLLOC();
     657                 :             : 
     658         [ +  - ]:           8 :                     if (!is_utf16_surrogate_second(c))
     659                 :           8 :                         yyerror("invalid Unicode surrogate pair");
     660                 :             : 
     661                 :           0 :                     c = surrogate_pair_to_codepoint(yyextra->utf16_first_part, c);
     662                 :             : 
     663                 :           0 :                     addunicode(c, yyscanner);
     664                 :             : 
     665                 :             :                     /* Restore yylloc to be start of string token */
     666                 :           0 :                     POP_YYLLOC();
     667                 :             : 
     668                 :           0 :                     BEGIN(xe);
     669                 :             :                 }
     670                 :           0 : <xeu>. |
     671                 :          12 : <xeu>\n |
     672                 :             : <xeu><<EOF>>  {
     673                 :             :                     /* Set the error cursor to point at missing esc seq */
     674                 :          12 :                     SET_YYLLOC();
     675                 :          12 :                     yyerror("invalid Unicode surrogate pair");
     676                 :             :                 }
     677                 :             : <xe,xeu>{xeunicodefail}   {
     678                 :           8 :                     /* Set the error cursor to point at malformed esc seq */
     679                 :           8 :                     SET_YYLLOC();
     680         [ +  - ]:           8 :                     ereport(ERROR,
     681                 :             :                             (errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE),
     682                 :             :                              errmsg("invalid Unicode escape"),
     683                 :             :                              errhint("Unicode escapes must be \\uXXXX or \\UXXXXXXXX."),
     684                 :             :                              lexer_errposition()));
     685                 :             :                 }
     686                 :             : <xe>{xeescape}  {
     687         [ -  + ]:        1901 :                     if (yytext[1] == '\'')
     688                 :             :                     {
     689         [ #  # ]:           0 :                         if (yyextra->backslash_quote == BACKSLASH_QUOTE_OFF ||
     690   [ #  #  #  # ]:           0 :                             (yyextra->backslash_quote == BACKSLASH_QUOTE_SAFE_ENCODING &&
     691         [ #  # ]:           0 :                              PG_ENCODING_IS_CLIENT_ONLY(pg_get_client_encoding())))
     692         [ #  # ]:           0 :                             ereport(ERROR,
     693                 :             :                                     (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
     694                 :             :                                      errmsg("unsafe use of \\' in a string literal"),
     695                 :             :                                      errhint("Use '' to write quotes in strings. \\' is insecure in client-only encodings."),
     696                 :             :                                      lexer_errposition()));
     697                 :             :                     }
     698                 :        1901 :                     addlitchar(unescape_single_char(yytext[1], yyscanner),
     699                 :             :                                yyscanner);
     700                 :             :                 }
     701                 :        1901 : <xe>{xeoctesc}  {
     702                 :          30 :                     unsigned char c = strtoul(yytext + 1, NULL, 8);
     703                 :             : 
     704                 :          30 :                     addlitchar(c, yyscanner);
     705   [ +  -  -  + ]:          30 :                     if (c == '\0' || IS_HIGHBIT_SET(c))
     706                 :           0 :                         yyextra->saw_non_ascii = true;
     707                 :             :                 }
     708                 :          30 : <xe>{xehexesc}  {
     709                 :           6 :                     unsigned char c = strtoul(yytext + 2, NULL, 16);
     710                 :             : 
     711                 :           6 :                     addlitchar(c, yyscanner);
     712   [ +  -  +  + ]:           6 :                     if (c == '\0' || IS_HIGHBIT_SET(c))
     713                 :           5 :                         yyextra->saw_non_ascii = true;
     714                 :             :                 }
     715                 :           6 : <xe>.         {
     716                 :           0 :                     /* This is only needed for \ just before EOF */
     717                 :           0 :                     addlitchar(yytext[0], yyscanner);
     718                 :             :                 }
     719                 :           0 : <xq,xe,xus><<EOF>>        { yyerror("unterminated quoted string"); }
     720                 :           0 : 
     721                 :        5973 : {dolqdelim}     {
     722                 :        5973 :                     SET_YYLLOC();
     723                 :        5973 :                     yyextra->dolqstart = pstrdup(yytext);
     724                 :        5973 :                     BEGIN(xdolq);
     725                 :        5973 :                     startlit();
     726                 :             :                 }
     727                 :        5973 : {dolqfailed}    {
     728                 :           0 :                     SET_YYLLOC();
     729                 :             :                     /* throw back all but the initial "$" */
     730                 :           0 :                     yyless(1);
     731                 :             :                     /* and treat it as {other} */
     732                 :           0 :                     return yytext[0];
     733                 :             :                 }
     734                 :             : <xdolq>{dolqdelim} {
     735         [ +  + ]:        6253 :                     if (strcmp(yytext, yyextra->dolqstart) == 0)
     736                 :             :                     {
     737                 :        5973 :                         pfree(yyextra->dolqstart);
     738                 :        5973 :                         yyextra->dolqstart = NULL;
     739                 :        5973 :                         BEGIN(INITIAL);
     740                 :        5973 :                         yylval->str = litbufdup(yyscanner);
     741                 :        5973 :                         return SCONST;
     742                 :             :                     }
     743                 :             :                     else
     744                 :             :                     {
     745                 :             :                         /*
     746                 :             :                          * When we fail to match $...$ to dolqstart, transfer
     747                 :             :                          * the $... part to the output, but put back the final
     748                 :             :                          * $ for rescanning.  Consider $delim$...$junk$delim$
     749                 :             :                          */
     750                 :         280 :                         addlit(yytext, yyleng - 1, yyscanner);
     751                 :         280 :                         yyless(yyleng - 1);
     752                 :             :                     }
     753                 :             :                 }
     754                 :         280 : <xdolq>{dolqinside} {
     755                 :        8855 :                     addlit(yytext, yyleng, yyscanner);
     756                 :             :                 }
     757                 :        8855 : <xdolq>{dolqfailed} {
     758                 :         580 :                     addlit(yytext, yyleng, yyscanner);
     759                 :             :                 }
     760                 :         580 : <xdolq>.      {
     761                 :        2302 :                     /* This is only needed for $ inside the quoted text */
     762                 :        2302 :                     addlitchar(yytext[0], yyscanner);
     763                 :             :                 }
     764                 :        2302 : <xdolq><<EOF>>    { yyerror("unterminated dollar-quoted string"); }
     765                 :           0 : 
     766                 :       69209 : {xdstart}       {
     767                 :       69209 :                     SET_YYLLOC();
     768                 :       69209 :                     BEGIN(xd);
     769                 :       69209 :                     startlit();
     770                 :             :                 }
     771                 :       69209 : {xuistart}      {
     772                 :          18 :                     SET_YYLLOC();
     773                 :          18 :                     BEGIN(xui);
     774                 :          18 :                     startlit();
     775                 :             :                 }
     776                 :          18 : <xd>{xdstop}  {
     777                 :       69209 :                     char       *ident;
     778                 :             : 
     779                 :       69209 :                     BEGIN(INITIAL);
     780         [ +  + ]:       69209 :                     if (yyextra->literallen == 0)
     781                 :           4 :                         yyerror("zero-length delimited identifier");
     782                 :       69205 :                     ident = litbufdup(yyscanner);
     783         [ -  + ]:       69205 :                     if (yyextra->literallen >= NAMEDATALEN)
     784                 :           0 :                         truncate_identifier(ident, yyextra->literallen, true);
     785                 :       69205 :                     yylval->str = ident;
     786                 :       69205 :                     return IDENT;
     787                 :             :                 }
     788                 :             : <xui>{dquote} {
     789                 :          18 :                     BEGIN(INITIAL);
     790         [ -  + ]:          18 :                     if (yyextra->literallen == 0)
     791                 :           0 :                         yyerror("zero-length delimited identifier");
     792                 :             :                     /* can't truncate till after we de-escape the ident */
     793                 :          18 :                     yylval->str = litbufdup(yyscanner);
     794                 :          18 :                     return UIDENT;
     795                 :             :                 }
     796                 :             : <xd,xui>{xddouble}    {
     797                 :          92 :                     addlitchar('"', yyscanner);
     798                 :             :                 }
     799                 :          92 : <xd,xui>{xdinside}    {
     800                 :       69309 :                     addlit(yytext, yyleng, yyscanner);
     801                 :             :                 }
     802                 :       69309 : <xd,xui><<EOF>>       { yyerror("unterminated quoted identifier"); }
     803                 :           0 : 
     804                 :           0 : {xufailed}  {
     805                 :             :                     char       *ident;
     806                 :             : 
     807                 :           0 :                     SET_YYLLOC();
     808                 :             :                     /* throw back all but the initial u/U */
     809                 :           0 :                     yyless(1);
     810                 :             :                     /* and treat it as {identifier} */
     811                 :           0 :                     ident = downcase_truncate_identifier(yytext, yyleng, true);
     812                 :           0 :                     yylval->str = ident;
     813                 :           0 :                     return IDENT;
     814                 :             :                 }
     815                 :             : 
     816                 :      150791 : {typecast}      {
     817                 :      150791 :                     SET_YYLLOC();
     818                 :      150791 :                     return TYPECAST;
     819                 :             :                 }
     820                 :             : 
     821                 :         453 : {dot_dot}       {
     822                 :         453 :                     SET_YYLLOC();
     823                 :         453 :                     return DOT_DOT;
     824                 :             :                 }
     825                 :             : 
     826                 :       29892 : {colon_equals}  {
     827                 :       29892 :                     SET_YYLLOC();
     828                 :       29892 :                     return COLON_EQUALS;
     829                 :             :                 }
     830                 :             : 
     831                 :        1514 : {equals_greater} {
     832                 :        1514 :                     SET_YYLLOC();
     833                 :        1514 :                     return EQUALS_GREATER;
     834                 :             :                 }
     835                 :             : 
     836                 :        3540 : {less_equals}   {
     837                 :        3540 :                     SET_YYLLOC();
     838                 :        3540 :                     return LESS_EQUALS;
     839                 :             :                 }
     840                 :             : 
     841                 :        7981 : {greater_equals} {
     842                 :        7981 :                     SET_YYLLOC();
     843                 :        7981 :                     return GREATER_EQUALS;
     844                 :             :                 }
     845                 :             : 
     846                 :        7943 : {less_greater}  {
     847                 :             :                     /* We accept both "<>" and "!=" as meaning NOT_EQUALS */
     848                 :        7943 :                     SET_YYLLOC();
     849                 :        7943 :                     return NOT_EQUALS;
     850                 :             :                 }
     851                 :             : 
     852                 :       17672 : {not_equals}    {
     853                 :             :                     /* We accept both "<>" and "!=" as meaning NOT_EQUALS */
     854                 :       17672 :                     SET_YYLLOC();
     855                 :       17672 :                     return NOT_EQUALS;
     856                 :             :                 }
     857                 :             : 
     858                 :        1083 : {right_arrow}   {
     859                 :        1083 :                     SET_YYLLOC();
     860                 :        1083 :                     return RIGHT_ARROW;
     861                 :             :                 }
     862                 :             : 
     863                 :     4309519 : {self}          {
     864                 :     4309519 :                     SET_YYLLOC();
     865                 :     4309519 :                     return yytext[0];
     866                 :             :                 }
     867                 :             : 
     868                 :       39090 : {operator}      {
     869                 :             :                     /*
     870                 :             :                      * Check for embedded slash-star or dash-dash; those
     871                 :             :                      * are comment starts, so operator must stop there.
     872                 :             :                      * Note that slash-star or dash-dash at the first
     873                 :             :                      * character will match a prior rule, not this one.
     874                 :             :                      */
     875                 :       39090 :                     int         nchars = yyleng;
     876                 :       39090 :                     char       *slashstar = strstr(yytext, "/*");
     877                 :       39090 :                     char       *dashdash = strstr(yytext, "--");
     878                 :             : 
     879   [ +  +  -  + ]:       39090 :                     if (slashstar && dashdash)
     880                 :             :                     {
     881                 :             :                         /* if both appear, take the first one */
     882         [ #  # ]:           0 :                         if (slashstar > dashdash)
     883                 :           0 :                             slashstar = dashdash;
     884                 :             :                     }
     885         [ +  + ]:       39090 :                     else if (!slashstar)
     886                 :       39045 :                         slashstar = dashdash;
     887         [ +  + ]:       39090 :                     if (slashstar)
     888                 :          70 :                         nchars = slashstar - yytext;
     889                 :             : 
     890                 :             :                     /*
     891                 :             :                      * For SQL compatibility, '+' and '-' cannot be the
     892                 :             :                      * last char of a multi-char operator unless the operator
     893                 :             :                      * contains chars that are not in SQL operators.
     894                 :             :                      * The idea is to lex '=-' as two operators, but not
     895                 :             :                      * to forbid operator names like '?-' that could not be
     896                 :             :                      * sequences of SQL operators.
     897                 :             :                      */
     898         [ +  + ]:       39090 :                     if (nchars > 1 &&
     899         [ +  + ]:       31359 :                         (yytext[nchars - 1] == '+' ||
     900         [ +  + ]:       31354 :                          yytext[nchars - 1] == '-'))
     901                 :             :                     {
     902                 :             :                         int         ic;
     903                 :             : 
     904         [ +  + ]:        2391 :                         for (ic = nchars - 2; ic >= 0; ic--)
     905                 :             :                         {
     906                 :        1348 :                             char c = yytext[ic];
     907   [ +  -  +  +  :        1348 :                             if (c == '~' || c == '!' || c == '@' ||
             +  -  +  + ]
     908   [ +  -  +  -  :        1284 :                                 c == '#' || c == '^' || c == '&' ||
                   +  + ]
     909   [ +  -  +  +  :        1099 :                                 c == '|' || c == '`' || c == '?' ||
                   +  - ]
     910                 :             :                                 c == '%')
     911                 :             :                                 break;
     912                 :             :                         }
     913         [ +  + ]:        1305 :                         if (ic < 0)
     914                 :             :                         {
     915                 :             :                             /*
     916                 :             :                              * didn't find a qualifying character, so remove
     917                 :             :                              * all trailing [+-]
     918                 :             :                              */
     919                 :             :                             do {
     920                 :        1043 :                                 nchars--;
     921         [ +  + ]:        1043 :                             } while (nchars > 1 &&
     922         [ -  + ]:          28 :                                  (yytext[nchars - 1] == '+' ||
     923         [ -  + ]:          28 :                                   yytext[nchars - 1] == '-'));
     924                 :             :                         }
     925                 :             :                     }
     926                 :             : 
     927                 :       39090 :                     SET_YYLLOC();
     928                 :             : 
     929         [ +  + ]:       39090 :                     if (nchars < yyleng)
     930                 :             :                     {
     931                 :             :                         /* Strip the unwanted chars from the token */
     932                 :        1113 :                         yyless(nchars);
     933                 :             :                         /*
     934                 :             :                          * If what we have left is only one char, and it's
     935                 :             :                          * one of the characters matching "self", then
     936                 :             :                          * return it as a character token the same way
     937                 :             :                          * that the "self" rule would have.
     938                 :             :                          */
     939         [ +  + ]:        1113 :                         if (nchars == 1 &&
     940         [ +  - ]:        1015 :                             strchr(",()[].;:|+-*/%^<>=", yytext[0]))
     941                 :        1015 :                             return yytext[0];
     942                 :             :                         /*
     943                 :             :                          * Likewise, if what we have left is two chars, and
     944                 :             :                          * those match the tokens ">=", "<=", "=>", "<>" or
     945                 :             :                          * "!=", then we must return the appropriate token
     946                 :             :                          * rather than the generic Op.
     947                 :             :                          */
     948         [ +  - ]:          98 :                         if (nchars == 2)
     949                 :             :                         {
     950   [ +  +  +  - ]:          98 :                             if (yytext[0] == '=' && yytext[1] == '>')
     951                 :          30 :                                 return EQUALS_GREATER;
     952   [ +  +  +  - ]:          68 :                             if (yytext[0] == '>' && yytext[1] == '=')
     953                 :          14 :                                 return GREATER_EQUALS;
     954   [ +  +  +  + ]:          54 :                             if (yytext[0] == '<' && yytext[1] == '=')
     955                 :          14 :                                 return LESS_EQUALS;
     956   [ +  +  +  - ]:          40 :                             if (yytext[0] == '<' && yytext[1] == '>')
     957                 :          18 :                                 return NOT_EQUALS;
     958   [ +  +  +  - ]:          22 :                             if (yytext[0] == '!' && yytext[1] == '=')
     959                 :          19 :                                 return NOT_EQUALS;
     960   [ +  -  +  - ]:           3 :                             if (yytext[0] == '-' && yytext[1] == '>')
     961                 :           3 :                                 return RIGHT_ARROW;
     962                 :             :                         }
     963                 :             :                     }
     964                 :             : 
     965                 :             :                     /*
     966                 :             :                      * Complain if operator is too long.  Unlike the case
     967                 :             :                      * for identifiers, we make this an error not a notice-
     968                 :             :                      * and-truncate, because the odds are we are looking at
     969                 :             :                      * a syntactic mistake anyway.
     970                 :             :                      */
     971         [ -  + ]:       37977 :                     if (nchars >= NAMEDATALEN)
     972                 :           0 :                         yyerror("operator too long");
     973                 :             : 
     974                 :       37977 :                     yylval->str = pstrdup(yytext);
     975                 :       37977 :                     return Op;
     976                 :             :                 }
     977                 :             : 
     978                 :       27954 : {param}         {
     979                 :       27954 :                     ErrorSaveContext escontext = {T_ErrorSaveContext};
     980                 :             :                     int32       val;
     981                 :             : 
     982                 :       27954 :                     SET_YYLLOC();
     983                 :       27954 :                     val = pg_strtoint32_safe(yytext + 1, (Node *) &escontext);
     984         [ +  + ]:       27954 :                     if (escontext.error_occurred)
     985                 :           4 :                         yyerror("parameter number too large");
     986                 :       27950 :                     yylval->ival = val;
     987                 :       27950 :                     return PARAM;
     988                 :             :                 }
     989                 :             : {param_junk}    {
     990                 :           8 :                     SET_YYLLOC();
     991                 :           8 :                     yyerror("trailing junk after parameter");
     992                 :             :                 }
     993                 :             : 
     994                 :      295969 : {decinteger}    {
     995                 :      295969 :                     SET_YYLLOC();
     996                 :      295969 :                     return process_integer_literal(yytext, yylval, 10);
     997                 :             :                 }
     998                 :             : {hexinteger}    {
     999                 :         524 :                     SET_YYLLOC();
    1000                 :         524 :                     return process_integer_literal(yytext, yylval, 16);
    1001                 :             :                 }
    1002                 :             : {octinteger}    {
    1003                 :          40 :                     SET_YYLLOC();
    1004                 :          40 :                     return process_integer_literal(yytext, yylval, 8);
    1005                 :             :                 }
    1006                 :             : {bininteger}    {
    1007                 :          41 :                     SET_YYLLOC();
    1008                 :          41 :                     return process_integer_literal(yytext, yylval, 2);
    1009                 :             :                 }
    1010                 :             : {hexfail}       {
    1011                 :           4 :                     SET_YYLLOC();
    1012                 :           4 :                     yyerror("invalid hexadecimal integer");
    1013                 :             :                 }
    1014                 :             : {octfail}       {
    1015                 :           4 :                     SET_YYLLOC();
    1016                 :           4 :                     yyerror("invalid octal integer");
    1017                 :             :                 }
    1018                 :             : {binfail}       {
    1019                 :           4 :                     SET_YYLLOC();
    1020                 :           4 :                     yyerror("invalid binary integer");
    1021                 :             :                 }
    1022                 :             : {numeric}       {
    1023                 :        7497 :                     SET_YYLLOC();
    1024                 :        7497 :                     yylval->str = pstrdup(yytext);
    1025                 :        7497 :                     return FCONST;
    1026                 :             :                 }
    1027                 :             : {numericfail}   {
    1028                 :          70 :                     /* throw back the .., and treat as integer */
    1029                 :          70 :                     yyless(yyleng - 2);
    1030                 :          70 :                     SET_YYLLOC();
    1031                 :          70 :                     return process_integer_literal(yytext, yylval, 10);
    1032                 :             :                 }
    1033                 :             : {real}          {
    1034                 :         882 :                     SET_YYLLOC();
    1035                 :         882 :                     yylval->str = pstrdup(yytext);
    1036                 :         882 :                     return FCONST;
    1037                 :             :                 }
    1038                 :             : {realfail}      {
    1039                 :           4 :                     SET_YYLLOC();
    1040                 :           4 :                     yyerror("trailing junk after numeric literal");
    1041                 :             :                 }
    1042                 :             : {integer_junk}  {
    1043                 :          44 :                     SET_YYLLOC();
    1044                 :          44 :                     yyerror("trailing junk after numeric literal");
    1045                 :             :                 }
    1046                 :             : {numeric_junk}  {
    1047                 :          32 :                     SET_YYLLOC();
    1048                 :          32 :                     yyerror("trailing junk after numeric literal");
    1049                 :             :                 }
    1050                 :             : {real_junk}     {
    1051                 :           0 :                     SET_YYLLOC();
    1052                 :           0 :                     yyerror("trailing junk after numeric literal");
    1053                 :             :                 }
    1054                 :             : 
    1055                 :     7085933 : 
    1056                 :             : {identifier}    {
    1057                 :             :                     int         kwnum;
    1058                 :             :                     char       *ident;
    1059                 :             : 
    1060                 :     7085933 :                     SET_YYLLOC();
    1061                 :             : 
    1062                 :             :                     /* Is it a keyword? */
    1063                 :     7085933 :                     kwnum = ScanKeywordLookup(yytext,
    1064                 :     7085933 :                                               yyextra->keywordlist);
    1065         [ +  + ]:     7085933 :                     if (kwnum >= 0)
    1066                 :             :                     {
    1067                 :     6369508 :                         yylval->keyword = GetScanKeyword(kwnum,
    1068                 :     3184754 :                                                          yyextra->keywordlist);
    1069                 :     3184754 :                         return yyextra->keyword_tokens[kwnum];
    1070                 :             :                     }
    1071                 :             : 
    1072                 :             :                     /*
    1073                 :             :                      * No.  Convert the identifier to lower case, and truncate
    1074                 :             :                      * if necessary.
    1075                 :             :                      */
    1076                 :     3901179 :                     ident = downcase_truncate_identifier(yytext, yyleng, true);
    1077                 :     3901179 :                     yylval->str = ident;
    1078                 :     3901179 :                     return IDENT;
    1079                 :             :                 }
    1080                 :             : 
    1081                 :           8 : {other}         {
    1082                 :           8 :                     SET_YYLLOC();
    1083                 :           8 :                     return yytext[0];
    1084                 :             :                 }
    1085                 :             : 
    1086                 :      501509 : <<EOF>>         {
    1087                 :      501509 :                     SET_YYLLOC();
    1088                 :      501509 :                     yyterminate();
    1089                 :             :                 }
    1090                 :             : 
    1091                 :           0 : %%
    1092                 :             : 
    1093                 :             : /* LCOV_EXCL_STOP */
    1094                 :             : 
    1095                 :             : /*
    1096                 :             :  * Arrange access to yyextra for subroutines of the main yylex() function.
    1097                 :             :  * We expect each subroutine to have a yyscanner parameter.  Rather than
    1098                 :             :  * use the yyget_xxx functions, which might or might not get inlined by the
    1099                 :             :  * compiler, we cheat just a bit and cast yyscanner to the right type.
    1100                 :             :  */
    1101                 :             : #undef yyextra
    1102                 :             : #define yyextra  (((struct yyguts_t *) yyscanner)->yyextra_r)
    1103                 :             : 
    1104                 :             : /* Likewise for a couple of other things we need. */
    1105                 :             : #undef yylloc
    1106                 :             : #define yylloc  (((struct yyguts_t *) yyscanner)->yylloc_r)
    1107                 :             : #undef yyleng
    1108                 :             : #define yyleng  (((struct yyguts_t *) yyscanner)->yyleng_r)
    1109                 :             : 
    1110                 :             : 
    1111                 :             : /*
    1112                 :             :  * scanner_errposition
    1113                 :             :  *      Report a lexer or grammar error cursor position, if possible.
    1114                 :             :  *
    1115                 :             :  * This is expected to be used within an ereport() call, or via an error
    1116                 :             :  * callback such as setup_scanner_errposition_callback().  The return value
    1117                 :             :  * is a dummy (always 0, in fact).
    1118                 :             :  *
    1119                 :             :  * Note that this can only be used for messages emitted during raw parsing
    1120                 :             :  * (essentially, scan.l, parser.c, and gram.y), since it requires the
    1121                 :             :  * yyscanner struct to still be available.
    1122                 :             :  */
    1123                 :             : int
    1124                 :         827 : scanner_errposition(int location, core_yyscan_t yyscanner)
    1125                 :             : {
    1126                 :             :     int         pos;
    1127                 :             : 
    1128         [ -  + ]:         827 :     if (location < 0)
    1129                 :           0 :         return 0;               /* no-op if location is unknown */
    1130                 :             : 
    1131                 :             :     /* Convert byte offset to character number */
    1132                 :         827 :     pos = pg_mbstrlen_with_len(yyextra->scanbuf, location) + 1;
    1133                 :             :     /* And pass it to the ereport mechanism */
    1134                 :         827 :     return errposition(pos);
    1135                 :             : }
    1136                 :             : 
    1137                 :             : /*
    1138                 :             :  * Error context callback for inserting scanner error location.
    1139                 :             :  *
    1140                 :             :  * Note that this will be called for *any* error occurring while the
    1141                 :             :  * callback is installed.  We avoid inserting an irrelevant error location
    1142                 :             :  * if the error is a query cancel --- are there any other important cases?
    1143                 :             :  */
    1144                 :             : static void
    1145                 :          24 : scb_error_callback(void *arg)
    1146                 :             : {
    1147                 :          24 :     ScannerCallbackState *scbstate = (ScannerCallbackState *) arg;
    1148                 :             : 
    1149         [ +  - ]:          24 :     if (geterrcode() != ERRCODE_QUERY_CANCELED)
    1150                 :          24 :         (void) scanner_errposition(scbstate->location, scbstate->yyscanner);
    1151                 :          24 : }
    1152                 :             : 
    1153                 :             : /*
    1154                 :             :  * setup_scanner_errposition_callback
    1155                 :             :  *      Arrange for non-scanner errors to report an error position
    1156                 :             :  *
    1157                 :             :  * Sometimes the scanner calls functions that aren't part of the scanner
    1158                 :             :  * subsystem and can't reasonably be passed the yyscanner pointer; yet
    1159                 :             :  * we would like any errors thrown in those functions to be tagged with an
    1160                 :             :  * error location.  Use this function to set up an error context stack
    1161                 :             :  * entry that will accomplish that.  Usage pattern:
    1162                 :             :  *
    1163                 :             :  *      declare a local variable "ScannerCallbackState scbstate"
    1164                 :             :  *      ...
    1165                 :             :  *      setup_scanner_errposition_callback(&scbstate, yyscanner, location);
    1166                 :             :  *      call function that might throw error;
    1167                 :             :  *      cancel_scanner_errposition_callback(&scbstate);
    1168                 :             :  */
    1169                 :             : void
    1170                 :         802 : setup_scanner_errposition_callback(ScannerCallbackState *scbstate,
    1171                 :             :                                    core_yyscan_t yyscanner,
    1172                 :             :                                    int location)
    1173                 :             : {
    1174                 :             :     /* Setup error traceback support for ereport() */
    1175                 :         802 :     scbstate->yyscanner = yyscanner;
    1176                 :         802 :     scbstate->location = location;
    1177                 :         802 :     scbstate->errcallback.callback = scb_error_callback;
    1178                 :         802 :     scbstate->errcallback.arg = scbstate;
    1179                 :         802 :     scbstate->errcallback.previous = error_context_stack;
    1180                 :         802 :     error_context_stack = &scbstate->errcallback;
    1181                 :         802 : }
    1182                 :             : 
    1183                 :             : /*
    1184                 :             :  * Cancel a previously-set-up errposition callback.
    1185                 :             :  */
    1186                 :             : void
    1187                 :         778 : cancel_scanner_errposition_callback(ScannerCallbackState *scbstate)
    1188                 :             : {
    1189                 :             :     /* Pop the error context stack */
    1190                 :         778 :     error_context_stack = scbstate->errcallback.previous;
    1191                 :         778 : }
    1192                 :             : 
    1193                 :             : /*
    1194                 :             :  * scanner_yyerror
    1195                 :             :  *      Report a lexer or grammar error.
    1196                 :             :  *
    1197                 :             :  * The message's cursor position is whatever YYLLOC was last set to,
    1198                 :             :  * ie, the start of the current token if called within yylex(), or the
    1199                 :             :  * most recently lexed token if called from the grammar.
    1200                 :             :  * This is OK for syntax error messages from the Bison parser, because Bison
    1201                 :             :  * parsers report error as soon as the first unparsable token is reached.
    1202                 :             :  * Beware of using yyerror for other purposes, as the cursor position might
    1203                 :             :  * be misleading!
    1204                 :             :  */
    1205                 :             : void
    1206                 :         621 : scanner_yyerror(const char *message, core_yyscan_t yyscanner)
    1207                 :             : {
    1208                 :         621 :     const char *loc = yyextra->scanbuf + *yylloc;
    1209                 :             : 
    1210         [ +  + ]:         621 :     if (*loc == YY_END_OF_BUFFER_CHAR)
    1211                 :             :     {
    1212         [ +  - ]:          12 :         ereport(ERROR,
    1213                 :             :                 (errcode(ERRCODE_SYNTAX_ERROR),
    1214                 :             :         /* translator: %s is typically the translation of "syntax error" */
    1215                 :             :                  errmsg("%s at end of input", _(message)),
    1216                 :             :                  lexer_errposition()));
    1217                 :             :     }
    1218                 :             :     else
    1219                 :             :     {
    1220         [ +  - ]:         609 :         ereport(ERROR,
    1221                 :             :                 (errcode(ERRCODE_SYNTAX_ERROR),
    1222                 :             :         /* translator: first %s is typically the translation of "syntax error" */
    1223                 :             :                  errmsg("%s at or near \"%s\"", _(message), loc),
    1224                 :             :                  lexer_errposition()));
    1225                 :             :     }
    1226                 :             : }
    1227                 :             : 
    1228                 :             : 
    1229                 :             : /*
    1230                 :             :  * Called before any actual parsing is done
    1231                 :             :  */
    1232                 :             : core_yyscan_t
    1233                 :      513961 : scanner_init(const char *str,
    1234                 :             :              core_yy_extra_type *yyext,
    1235                 :             :              const ScanKeywordList *keywordlist,
    1236                 :             :              const uint16 *keyword_tokens)
    1237                 :             : {
    1238                 :      513961 :     Size        slen = strlen(str);
    1239                 :             :     yyscan_t    scanner;
    1240                 :             : 
    1241         [ -  + ]:      513961 :     if (yylex_init(&scanner) != 0)
    1242         [ #  # ]:           0 :         elog(ERROR, "yylex_init() failed: %m");
    1243                 :             : 
    1244                 :      513961 :     core_yyset_extra(yyext, scanner);
    1245                 :             : 
    1246                 :      513961 :     yyext->keywordlist = keywordlist;
    1247                 :      513961 :     yyext->keyword_tokens = keyword_tokens;
    1248                 :             : 
    1249                 :      513961 :     yyext->backslash_quote = backslash_quote;
    1250                 :             : 
    1251                 :             :     /*
    1252                 :             :      * Make a scan buffer with special termination needed by flex.
    1253                 :             :      */
    1254                 :      513961 :     yyext->scanbuf = (char *) palloc(slen + 2);
    1255                 :      513961 :     yyext->scanbuflen = slen;
    1256                 :      513961 :     memcpy(yyext->scanbuf, str, slen);
    1257                 :      513961 :     yyext->scanbuf[slen] = yyext->scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR;
    1258                 :      513961 :     yy_scan_buffer(yyext->scanbuf, slen + 2, scanner);
    1259                 :             : 
    1260                 :             :     /* initialize literal buffer to a reasonable but expansible size */
    1261                 :      513961 :     yyext->literalalloc = 1024;
    1262                 :      513961 :     yyext->literalbuf = (char *) palloc(yyext->literalalloc);
    1263                 :      513961 :     yyext->literallen = 0;
    1264                 :             : 
    1265                 :      513961 :     return scanner;
    1266                 :             : }
    1267                 :             : 
    1268                 :             : 
    1269                 :             : /*
    1270                 :             :  * Called after parsing is done to clean up after scanner_init()
    1271                 :             :  */
    1272                 :             : void
    1273                 :      513039 : scanner_finish(core_yyscan_t yyscanner)
    1274                 :             : {
    1275                 :             :     /*
    1276                 :             :      * We don't bother to call yylex_destroy(), because all it would do is
    1277                 :             :      * pfree a small amount of control storage.  It's cheaper to leak the
    1278                 :             :      * storage until the parsing context is destroyed.  The amount of space
    1279                 :             :      * involved is usually negligible compared to the output parse tree
    1280                 :             :      * anyway.
    1281                 :             :      *
    1282                 :             :      * We do bother to pfree the scanbuf and literal buffer, but only if they
    1283                 :             :      * represent a nontrivial amount of space.  The 8K cutoff is arbitrary.
    1284                 :             :      */
    1285         [ +  + ]:      513039 :     if (yyextra->scanbuflen >= 8192)
    1286                 :          62 :         pfree(yyextra->scanbuf);
    1287         [ +  + ]:      513039 :     if (yyextra->literalalloc >= 8192)
    1288                 :          44 :         pfree(yyextra->literalbuf);
    1289                 :      513039 : }
    1290                 :             : 
    1291                 :             : 
    1292                 :             : static void
    1293                 :      594047 : addlit(char *ytext, int yleng, core_yyscan_t yyscanner)
    1294                 :             : {
    1295                 :             :     /* enlarge buffer if needed */
    1296         [ +  + ]:      594047 :     if ((yyextra->literallen + yleng) >= yyextra->literalalloc)
    1297                 :             :     {
    1298                 :         179 :         yyextra->literalalloc = pg_nextpower2_32(yyextra->literallen + yleng + 1);
    1299                 :         179 :         yyextra->literalbuf = (char *) repalloc(yyextra->literalbuf,
    1300                 :         179 :                                                 yyextra->literalalloc);
    1301                 :             :     }
    1302                 :             :     /* append new data */
    1303                 :      594047 :     memcpy(yyextra->literalbuf + yyextra->literallen, ytext, yleng);
    1304                 :      594047 :     yyextra->literallen += yleng;
    1305                 :      594047 : }
    1306                 :             : 
    1307                 :             : 
    1308                 :             : static void
    1309                 :       12052 : addlitchar(unsigned char ychar, core_yyscan_t yyscanner)
    1310                 :             : {
    1311                 :             :     /* enlarge buffer if needed */
    1312         [ -  + ]:       12052 :     if ((yyextra->literallen + 1) >= yyextra->literalalloc)
    1313                 :             :     {
    1314                 :           0 :         yyextra->literalalloc *= 2;
    1315                 :           0 :         yyextra->literalbuf = (char *) repalloc(yyextra->literalbuf,
    1316                 :           0 :                                                 yyextra->literalalloc);
    1317                 :             :     }
    1318                 :             :     /* append new data */
    1319                 :       12052 :     yyextra->literalbuf[yyextra->literallen] = ychar;
    1320                 :       12052 :     yyextra->literallen += 1;
    1321                 :       12052 : }
    1322                 :             : 
    1323                 :             : 
    1324                 :             : /*
    1325                 :             :  * Create a palloc'd copy of literalbuf, adding a trailing null.
    1326                 :             :  */
    1327                 :             : static char *
    1328                 :      598933 : litbufdup(core_yyscan_t yyscanner)
    1329                 :             : {
    1330                 :      598933 :     int         llen = yyextra->literallen;
    1331                 :             :     char       *new;
    1332                 :             : 
    1333                 :      598933 :     new = palloc(llen + 1);
    1334                 :      598933 :     memcpy(new, yyextra->literalbuf, llen);
    1335                 :      598933 :     new[llen] = '\0';
    1336                 :      598933 :     return new;
    1337                 :             : }
    1338                 :             : 
    1339                 :             : /*
    1340                 :             :  * Process {decinteger}, {hexinteger}, etc.  Note this will also do the right
    1341                 :             :  * thing with {numeric}, ie digits and a decimal point.
    1342                 :             :  */
    1343                 :             : static int
    1344                 :      296644 : process_integer_literal(const char *token, YYSTYPE *lval, int base)
    1345                 :             : {
    1346                 :      296644 :     ErrorSaveContext escontext = {T_ErrorSaveContext};
    1347                 :             :     int32       val;
    1348                 :             : 
    1349                 :      296644 :     val = pg_strtoint32_safe(token, (Node *) &escontext);
    1350         [ +  + ]:      296644 :     if (escontext.error_occurred)
    1351                 :             :     {
    1352                 :             :         /* integer too large (or contains decimal pt), treat it as a float */
    1353                 :        1091 :         lval->str = pstrdup(token);
    1354                 :        1091 :         return FCONST;
    1355                 :             :     }
    1356                 :      295553 :     lval->ival = val;
    1357                 :      295553 :     return ICONST;
    1358                 :             : }
    1359                 :             : 
    1360                 :             : static void
    1361                 :         104 : addunicode(char32_t c, core_yyscan_t yyscanner)
    1362                 :             : {
    1363                 :             :     ScannerCallbackState scbstate;
    1364                 :             :     char        buf[MAX_UNICODE_EQUIVALENT_STRING + 1];
    1365                 :             : 
    1366         [ +  + ]:         104 :     if (!is_valid_unicode_codepoint(c))
    1367                 :           4 :         yyerror("invalid Unicode escape value");
    1368                 :             : 
    1369                 :             :     /*
    1370                 :             :      * We expect that pg_unicode_to_server() will complain about any
    1371                 :             :      * unconvertible code point, so we don't have to set saw_non_ascii.
    1372                 :             :      */
    1373                 :         100 :     setup_scanner_errposition_callback(&scbstate, yyscanner, *(yylloc));
    1374                 :         100 :     pg_unicode_to_server(c, (unsigned char *) buf);
    1375                 :         100 :     cancel_scanner_errposition_callback(&scbstate);
    1376                 :         100 :     addlit(buf, strlen(buf), yyscanner);
    1377                 :         100 : }
    1378                 :             : 
    1379                 :             : static unsigned char
    1380                 :        1901 : unescape_single_char(unsigned char c, core_yyscan_t yyscanner)
    1381                 :             : {
    1382   [ +  +  +  +  :        1901 :     switch (c)
                +  -  + ]
    1383                 :             :     {
    1384                 :          18 :         case 'b':
    1385                 :          18 :             return '\b';
    1386                 :           6 :         case 'f':
    1387                 :           6 :             return '\f';
    1388                 :         900 :         case 'n':
    1389                 :         900 :             return '\n';
    1390                 :          46 :         case 'r':
    1391                 :          46 :             return '\r';
    1392                 :          22 :         case 't':
    1393                 :          22 :             return '\t';
    1394                 :           0 :         case 'v':
    1395                 :           0 :             return '\v';
    1396                 :         909 :         default:
    1397                 :             :             /* check for backslash followed by non-7-bit-ASCII */
    1398   [ +  -  -  + ]:         909 :             if (c == '\0' || IS_HIGHBIT_SET(c))
    1399                 :           0 :                 yyextra->saw_non_ascii = true;
    1400                 :             : 
    1401                 :         909 :             return c;
    1402                 :             :     }
    1403                 :             : }
    1404                 :             : 
    1405                 :             : /*
    1406                 :             :  * Interface functions to make flex use palloc() instead of malloc().
    1407                 :             :  * It'd be better to make these static, but flex insists otherwise.
    1408                 :             :  */
    1409                 :             : 
    1410                 :             : void *
    1411                 :     1541883 : core_yyalloc(yy_size_t bytes, core_yyscan_t yyscanner)
    1412                 :             : {
    1413                 :     1541883 :     return palloc(bytes);
    1414                 :             : }
    1415                 :             : 
    1416                 :             : void *
    1417                 :           0 : core_yyrealloc(void *ptr, yy_size_t bytes, core_yyscan_t yyscanner)
    1418                 :             : {
    1419         [ #  # ]:           0 :     if (ptr)
    1420                 :           0 :         return repalloc(ptr, bytes);
    1421                 :             :     else
    1422                 :           0 :         return palloc(bytes);
    1423                 :             : }
    1424                 :             : 
    1425                 :             : void
    1426                 :           0 : core_yyfree(void *ptr, core_yyscan_t yyscanner)
    1427                 :             : {
    1428         [ #  # ]:           0 :     if (ptr)
    1429                 :           0 :         pfree(ptr);
    1430                 :           0 : }
        

Generated by: LCOV version 2.0-1