LCOV - differential code coverage report
Current view: top level - src/backend/nodes - read.c (source / functions) Coverage Total Hit UNC UBC GBC GNC CBC DUB DCB
Current: 4b3c9325757dfd8f2312e9f1a8decf4431f344ae vs e87b024bfb8dd55e3049b1b6e6ab4e810cf1abc8 Lines: 69.2 % 169 117 1 51 2 20 95 2 29
Current Date: 2026-11-28 16:48:44 +0900 Functions: 85.7 % 7 6 1 3 3 2
Baseline: lcov-20261128-baseline Branches: 54.9 % 162 89 73 1 6 82
Baseline Date: 2026-11-28 16:48:48 +0900 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(1,7] days: 100.0 % 3 3 3
(30,360] days: 94.4 % 18 17 1 17
(360..) days: 65.5 % 148 97 51 2 95
Function coverage date bins:
(30,360] days: 100.0 % 2 2 2
(360..) days: 80.0 % 5 4 1 1 3
Branch coverage date bins:
(1,7] days: 100.0 % 6 6 6
(360..) days: 53.2 % 156 83 73 1 82

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * read.c
                                  4                 :                :  *    routines to convert a string (legal ascii representation of node) back
                                  5                 :                :  *    to nodes
                                  6                 :                :  *
                                  7                 :                :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
                                  8                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                  9                 :                :  *
                                 10                 :                :  *
                                 11                 :                :  * IDENTIFICATION
                                 12                 :                :  *    src/backend/nodes/read.c
                                 13                 :                :  *
                                 14                 :                :  * HISTORY
                                 15                 :                :  *    AUTHOR            DATE            MAJOR EVENT
                                 16                 :                :  *    Andrew Yu         Nov 2, 1994     file creation
                                 17                 :                :  *
                                 18                 :                :  *-------------------------------------------------------------------------
                                 19                 :                :  */
                                 20                 :                : #include "postgres.h"
                                 21                 :                : 
                                 22                 :                : #include <ctype.h>
                                 23                 :                : 
                                 24                 :                : #include "common/string.h"
                                 25                 :                : #include "nodes/bitmapset.h"
                                 26                 :                : #include "nodes/pg_list.h"
                                 27                 :                : #include "nodes/readfuncs.h"
                                 28                 :                : #include "nodes/value.h"
                                 29                 :                : 
                                 30                 :                : 
                                 31                 :                : /*
                                 32                 :                :  * stringToNode -
                                 33                 :                :  *    builds a Node tree from its string representation (assumed valid)
                                 34                 :                :  *
                                 35                 :                :  * restore_loc_fields instructs readfuncs.c whether to restore location
                                 36                 :                :  * fields rather than set them to -1.  This is currently only supported
                                 37                 :                :  * in builds with DEBUG_NODE_TESTS_ENABLED defined.
                                 38                 :                :  */
                                 39                 :                : static void *
 2993 tgl@sss.pgh.pa.us          40                 :CBC      271630 : stringToNodeInternal(const char *str, bool restore_loc_fields)
                                 41                 :                : {
                                 42                 :                :     ReadNodeContext ctx;
                                 43                 :                : 
                                 44                 :                :     /* initialize the context  */
   96 michael@paquier.xyz        45                 :GNC      271630 :     ctx.str = str;
                                 46                 :                : #ifdef DEBUG_NODE_TESTS_ENABLED
                                 47                 :         271630 :     ctx.restore_location_fields = restore_loc_fields;
                                 48                 :                : #endif
                                 49                 :                : 
                                 50                 :                :     /* do the reading, and return */
                                 51                 :         271630 :     return nodeRead(&ctx, NULL, 0);
                                 52                 :                : }
                                 53                 :                : 
                                 54                 :                : /*
                                 55                 :                :  * Externally visible entry points
                                 56                 :                :  */
                                 57                 :                : void *
 2993 tgl@sss.pgh.pa.us          58                 :CBC      271630 : stringToNode(const char *str)
                                 59                 :                : {
                                 60                 :         271630 :     return stringToNodeInternal(str, false);
                                 61                 :                : }
                                 62                 :                : 
                                 63                 :                : #ifdef DEBUG_NODE_TESTS_ENABLED
                                 64                 :                : 
                                 65                 :                : void *
 2993 tgl@sss.pgh.pa.us          66                 :UBC           0 : stringToNodeWithLocations(const char *str)
                                 67                 :                : {
                                 68                 :              0 :     return stringToNodeInternal(str, true);
                                 69                 :                : }
                                 70                 :                : 
                                 71                 :                : #endif
                                 72                 :                : 
                                 73                 :                : 
                                 74                 :                : /*****************************************************************************
                                 75                 :                :  *
                                 76                 :                :  * the lisp token parser
                                 77                 :                :  *
                                 78                 :                :  *****************************************************************************/
                                 79                 :                : 
                                 80                 :                : /* Character classes for pg_strtok() */
                                 81                 :                : #define TOKCLASS_SPACE      0x01    /* ' ', '\n', '\t' */
                                 82                 :                : #define TOKCLASS_SPECIAL    0x02    /* '(', ')', '{', '}' */
                                 83                 :                : #define TOKCLASS_NUL        0x04    /* '\0' */
                                 84                 :                : 
                                 85                 :                : /* Character class lookup table for pg_strtok() */
                                 86                 :                : static const uint8 pg_strtok_class[256] = {
                                 87                 :                :     ['\0'] = TOKCLASS_NUL,
                                 88                 :                :     [' '] = TOKCLASS_SPACE,
                                 89                 :                :     ['\n'] = TOKCLASS_SPACE,
                                 90                 :                :     ['\t'] = TOKCLASS_SPACE,
                                 91                 :                :     ['('] = TOKCLASS_SPECIAL,
                                 92                 :                :     [')'] = TOKCLASS_SPECIAL,
                                 93                 :                :     ['{'] = TOKCLASS_SPECIAL,
                                 94                 :                :     ['}'] = TOKCLASS_SPECIAL,
                                 95                 :                : };
                                 96                 :                : 
                                 97                 :                : /*
                                 98                 :                :  * pg_strtok --- retrieve next "token" from a string.
                                 99                 :                :  *
                                100                 :                :  * Works kinda like strtok, except it never modifies the source string.
                                101                 :                :  * (Instead of storing nulls into the string, the length of the token
                                102                 :                :  * is returned to the caller.)
                                103                 :                :  * Also, the rules about what is a token are hard-wired rather than being
                                104                 :                :  * configured by passing a set of terminating characters.
                                105                 :                :  *
                                106                 :                :  * The rules for tokens are:
                                107                 :                :  *  * Whitespace (space, tab, newline) always separates tokens.
                                108                 :                :  *  * The characters '(', ')', '{', '}' form individual tokens even
                                109                 :                :  *    without any whitespace around them.
                                110                 :                :  *  * Otherwise, a token is all the characters up to the next whitespace
                                111                 :                :  *    or occurrence of one of the four special characters.
                                112                 :                :  *  * A backslash '\' can be used to quote whitespace or one of the four
                                113                 :                :  *    special characters, so that it is treated as a plain token character.
                                114                 :                :  *    Backslashes themselves must also be backslashed for consistency.
                                115                 :                :  *    Any other character can be, but need not be, backslashed as well.
                                116                 :                :  *  * If the resulting token is '<>' (with no backslash), it is returned
                                117                 :                :  *    as a non-NULL pointer to the token but with length == 0.  Note that
                                118                 :                :  *    there is no other way to get a zero-length token.
                                119                 :                :  *
                                120                 :                :  * Returns a pointer to the start of the next token, and the length of the
                                121                 :                :  * token (including any embedded backslashes!) in *length.  If there are
                                122                 :                :  * no more tokens, NULL and 0 are returned.
                                123                 :                :  *
                                124                 :                :  * NOTE: this routine doesn't remove backslashes; the caller must do so
                                125                 :                :  * if necessary (see "debackslash").
                                126                 :                :  *
                                127                 :                :  * NOTE: prior to release 7.0, this routine also had a special case to treat
                                128                 :                :  * a token starting with '"' as extending to the next '"'.  This code was
                                129                 :                :  * broken, however, since it would fail to cope with a string containing an
                                130                 :                :  * embedded '"'.  I have therefore removed this special case, and instead
                                131                 :                :  * introduced rules for using backslashes to quote characters.  Higher-level
                                132                 :                :  * code should add backslashes to a string constant to ensure it is treated
                                133                 :                :  * as a single token.
                                134                 :                :  */
                                135                 :                : const char *
   96 michael@paquier.xyz       136                 :GNC    92590090 : pg_strtok(ReadNodeContext *ctx, int *length)
                                137                 :                : {
                                138                 :                :     const char *local_str;      /* working pointer to string */
                                139                 :                :     const char *ret_str;        /* start of token to return */
                                140                 :                : 
                                141                 :       92590090 :     local_str = ctx->str;
                                142                 :                : 
    2 drowley@postgresql.o      143         [ +  + ]:      171726073 :     while (pg_strtok_class[(unsigned char) *local_str] & TOKCLASS_SPACE)
 9815 tgl@sss.pgh.pa.us         144                 :CBC    79135983 :         local_str++;
                                145                 :                : 
                                146         [ +  + ]:       92590090 :     if (*local_str == '\0')
                                147                 :                :     {
 9815 tgl@sss.pgh.pa.us         148                 :GBC           2 :         *length = 0;
   96 michael@paquier.xyz       149                 :GNC           2 :         ctx->str = local_str;
 9815 tgl@sss.pgh.pa.us         150                 :GBC           2 :         return NULL;            /* no more tokens */
                                151                 :                :     }
                                152                 :                : 
                                153                 :                :     /*
                                154                 :                :      * Now pointing at start of next token.
                                155                 :                :      */
 9815 tgl@sss.pgh.pa.us         156                 :CBC    92590088 :     ret_str = local_str;
                                157                 :                : 
    2 drowley@postgresql.o      158         [ +  + ]:GNC    92590088 :     if (pg_strtok_class[(unsigned char) *local_str] & TOKCLASS_SPECIAL)
                                159                 :                :     {
                                160                 :                :         /* special 1-character token */
 9815 tgl@sss.pgh.pa.us         161                 :CBC    13185919 :         local_str++;
                                162                 :                :     }
                                163                 :                :     else
                                164                 :                :     {
                                165                 :                :         /* Normal token, possibly containing backslashes */
    2 drowley@postgresql.o      166         [ +  + ]:GNC   557137132 :         while (!(pg_strtok_class[(unsigned char) *local_str] &
                                167                 :                :                  (TOKCLASS_SPACE | TOKCLASS_SPECIAL | TOKCLASS_NUL)))
                                168                 :                :         {
 9815 tgl@sss.pgh.pa.us         169   [ +  +  +  - ]:CBC   477732963 :             if (*local_str == '\\' && local_str[1] != '\0')
                                170                 :            892 :                 local_str += 2;
                                171                 :                :             else
                                172                 :      477732071 :                 local_str++;
                                173                 :                :         }
                                174                 :                :     }
                                175                 :                : 
                                176                 :       92590088 :     *length = local_str - ret_str;
                                177                 :                : 
                                178                 :                :     /* Recognize special case for "empty" token */
                                179   [ +  +  +  +  :       92590088 :     if (*length == 2 && ret_str[0] == '<' && ret_str[1] == '>')
                                              +  - ]
                                180                 :        1936255 :         *length = 0;
                                181                 :                : 
   96 michael@paquier.xyz       182                 :GNC    92590088 :     ctx->str = local_str;
                                183                 :                : 
 9815 tgl@sss.pgh.pa.us         184                 :CBC    92590088 :     return ret_str;
                                185                 :                : }
                                186                 :                : 
                                187                 :                : /*
                                188                 :                :  * debackslash -
                                189                 :                :  *    create a palloc'd string holding the given token.
                                190                 :                :  *    any protective backslashes in the token are removed.
                                191                 :                :  */
                                192                 :                : char *
 2993                           193                 :        2646417 : debackslash(const char *token, int length)
                                194                 :                : {
 9726 bruce@momjian.us          195                 :        2646417 :     char       *result = palloc(length + 1);
                                196                 :        2646417 :     char       *ptr = result;
                                197                 :                : 
 9815 tgl@sss.pgh.pa.us         198         [ +  + ]:       26953736 :     while (length > 0)
                                199                 :                :     {
                                200   [ +  +  +  - ]:       24307319 :         if (*token == '\\' && length > 1)
                                201                 :            892 :             token++, length--;
                                202                 :       24307319 :         *ptr++ = *token++;
                                203                 :       24307319 :         length--;
                                204                 :                :     }
                                205                 :        2646417 :     *ptr = '\0';
                                206                 :        2646417 :     return result;
                                207                 :                : }
                                208                 :                : 
                                209                 :                : #define RIGHT_PAREN (1000000 + 1)
                                210                 :                : #define LEFT_PAREN  (1000000 + 2)
                                211                 :                : #define LEFT_BRACE  (1000000 + 3)
                                212                 :                : #define OTHER_TOKEN (1000000 + 4)
                                213                 :                : 
                                214                 :                : /*
                                215                 :                :  * nodeTokenType -
                                216                 :                :  *    returns the type of the node token contained in token.
                                217                 :                :  *    It returns one of the following valid NodeTags:
                                218                 :                :  *      T_Integer, T_Float, T_Boolean, T_String, T_BitString
                                219                 :                :  *    and some of its own:
                                220                 :                :  *      RIGHT_PAREN, LEFT_PAREN, LEFT_BRACE, OTHER_TOKEN
                                221                 :                :  *
                                222                 :                :  *    Assumption: the ascii representation is legal
                                223                 :                :  */
                                224                 :                : static NodeTag
 2993                           225                 :        8677551 : nodeTokenType(const char *token, int length)
                                226                 :                : {
                                227                 :                :     NodeTag     retval;
                                228                 :                :     const char *numptr;
                                229                 :                :     int         numlen;
                                230                 :                : 
                                231                 :                :     /*
                                232                 :                :      * Check if the token is a number
                                233                 :                :      */
 9777                           234                 :        8677551 :     numptr = token;
                                235                 :        8677551 :     numlen = length;
                                236   [ +  -  -  + ]:        8677551 :     if (*numptr == '+' || *numptr == '-')
 9777 tgl@sss.pgh.pa.us         237                 :UBC           0 :         numptr++, numlen--;
 9491 tgl@sss.pgh.pa.us         238   [ +  +  +  -  :CBC     8677551 :     if ((numlen > 0 && isdigit((unsigned char) *numptr)) ||
                                              +  + ]
 7714 bruce@momjian.us          239   [ -  +  -  - ]:        2148387 :         (numlen > 1 && *numptr == '.' && isdigit((unsigned char) numptr[1])))
                                240                 :                :     {
                                241                 :                :         /*
                                242                 :                :          * Yes.  Figure out whether it is integral or float; this requires
                                243                 :                :          * both a syntax check and a range check. strtoint() can do both for
                                244                 :                :          * us. We know the token will end at a character that strtoint will
                                245                 :                :          * stop at, so we do not need to modify the string.
                                246                 :                :          */
                                247                 :                :         char       *endptr;
                                248                 :                : 
 9777 tgl@sss.pgh.pa.us         249                 :UBC           0 :         errno = 0;
 1526 peter@eisentraut.org      250                 :              0 :         (void) strtoint(numptr, &endptr, 10);
 3182 peter_e@gmx.net           251   [ #  #  #  # ]:              0 :         if (endptr != token + length || errno == ERANGE)
 9777 tgl@sss.pgh.pa.us         252                 :              0 :             return T_Float;
                                253                 :              0 :         return T_Integer;
                                254                 :                :     }
                                255                 :                : 
                                256                 :                :     /*
                                257                 :                :      * these three cases do not need length checks, since pg_strtok() will
                                258                 :                :      * always treat them as single-byte tokens
                                259                 :                :      */
10674 bruce@momjian.us          260         [ +  + ]:CBC     8677551 :     else if (*token == '(')
                                261                 :        1019844 :         retval = LEFT_PAREN;
                                262         [ -  + ]:        7657707 :     else if (*token == ')')
10674 bruce@momjian.us          263                 :UBC           0 :         retval = RIGHT_PAREN;
10674 bruce@momjian.us          264         [ +  + ]:CBC     7657707 :     else if (*token == '{')
 8241 tgl@sss.pgh.pa.us         265                 :        3763023 :         retval = LEFT_BRACE;
 1776 peter@eisentraut.org      266   [ +  +  +  -  :        3894684 :     else if ((length == 4 && strncmp(token, "true", 4) == 0) ||
                                              +  + ]
                                267         [ -  + ]:         107486 :              (length == 5 && strncmp(token, "false", 5) == 0))
 1779 peter@eisentraut.org      268                 :UBC           0 :         retval = T_Boolean;
 3994 peter_e@gmx.net           269   [ +  +  +  -  :CBC     3894684 :     else if (*token == '"' && length > 1 && token[length - 1] == '"')
                                              +  - ]
 9815 tgl@sss.pgh.pa.us         270                 :        2148387 :         retval = T_String;
 1526 peter@eisentraut.org      271   [ +  -  -  + ]:        1746297 :     else if (*token == 'b' || *token == 'x')
 9524 peter_e@gmx.net           272                 :UBC           0 :         retval = T_BitString;
                                273                 :                :     else
 8241 tgl@sss.pgh.pa.us         274                 :CBC     1746297 :         retval = OTHER_TOKEN;
10315 bruce@momjian.us          275                 :        8677551 :     return retval;
                                276                 :                : }
                                277                 :                : 
                                278                 :                : /*
                                279                 :                :  * nodeRead -
                                280                 :                :  *    Slightly higher-level reader.
                                281                 :                :  *
                                282                 :                :  * This routine applies some semantic knowledge on top of the purely
                                283                 :                :  * lexical tokenizer pg_strtok().   It can read
                                284                 :                :  *  * Value token nodes (integers, floats, booleans, or strings);
                                285                 :                :  *  * General nodes (via parseNodeString() from readfuncs.c);
                                286                 :                :  *  * Lists of the above;
                                287                 :                :  *  * Lists of integers, OIDs, or TransactionIds.
                                288                 :                :  * The return value is declared void *, not Node *, to avoid having to
                                289                 :                :  * cast it explicitly in callers that assign to fields of different types.
                                290                 :                :  *
                                291                 :                :  * External callers should always pass NULL/0 for the arguments.  Internally
                                292                 :                :  * a non-NULL token may be passed when the upper recursion level has already
                                293                 :                :  * scanned the first token of a node's representation.
                                294                 :                :  *
                                295                 :                :  * We assume pg_strtok is already initialized with a string to read (hence
                                296                 :                :  * this should only be invoked from within a stringToNode operation).
                                297                 :                :  */
                                298                 :                : void *
   96 michael@paquier.xyz       299                 :GNC     8677551 : nodeRead(ReadNodeContext *ctx, const char *token, int tok_len)
                                300                 :                : {
                                301                 :                :     Node       *result;
                                302                 :                :     NodeTag     type;
                                303                 :                : 
 8241 tgl@sss.pgh.pa.us         304         [ +  + ]:CBC     8677551 :     if (token == NULL)          /* need to read a token? */
                                305                 :                :     {
   96 michael@paquier.xyz       306                 :GNC     3953201 :         token = pg_strtok(ctx, &tok_len);
                                307                 :                : 
 8241 tgl@sss.pgh.pa.us         308         [ -  + ]:CBC     3953201 :         if (token == NULL)      /* end of input */
 8241 tgl@sss.pgh.pa.us         309                 :UBC           0 :             return NULL;
                                310                 :                :     }
                                311                 :                : 
10674 bruce@momjian.us          312                 :CBC     8677551 :     type = nodeTokenType(token, tok_len);
                                313                 :                : 
 6158 peter_e@gmx.net           314   [ +  +  -  +  :        8677551 :     switch ((int) type)
                                     -  -  -  +  -  
                                                 - ]
                                315                 :                :     {
 8241 tgl@sss.pgh.pa.us         316                 :        3763023 :         case LEFT_BRACE:
   96 michael@paquier.xyz       317                 :GNC     3763023 :             result = parseNodeString(ctx);
                                318                 :        3763022 :             token = pg_strtok(ctx, &tok_len);
 9456 tgl@sss.pgh.pa.us         319   [ +  -  -  + ]:CBC     3763022 :             if (token == NULL || token[0] != '}')
 8530 tgl@sss.pgh.pa.us         320         [ #  # ]:UBC           0 :                 elog(ERROR, "did not find '}' at end of input node");
10673 bruce@momjian.us          321                 :CBC     3763022 :             break;
                                322                 :        1019844 :         case LEFT_PAREN:
                                323                 :                :             {
 8241 tgl@sss.pgh.pa.us         324                 :        1019844 :                 List       *l = NIL;
                                325                 :                : 
                                326                 :                :                 /*----------
                                327                 :                :                  * Could be an integer list:    (i int int ...)
                                328                 :                :                  * or an OID list:              (o int int ...)
                                329                 :                :                  * or an XID list:              (x int int ...)
                                330                 :                :                  * or a bitmapset:              (b int int ...)
                                331                 :                :                  * or a list of nodes/values:   (node node ...)
                                332                 :                :                  *----------
                                333                 :                :                  */
   96 michael@paquier.xyz       334                 :GNC     1019844 :                 token = pg_strtok(ctx, &tok_len);
 8239 tgl@sss.pgh.pa.us         335         [ -  + ]:CBC     1019844 :                 if (token == NULL)
 8239 tgl@sss.pgh.pa.us         336         [ #  # ]:UBC           0 :                     elog(ERROR, "unterminated List structure");
 8239 tgl@sss.pgh.pa.us         337   [ +  +  +  + ]:CBC     1019844 :                 if (tok_len == 1 && token[0] == 'i')
                                338                 :                :                 {
                                339                 :                :                     /* List of integers */
                                340                 :                :                     for (;;)
                                341                 :        1074678 :                     {
                                342                 :                :                         int         val;
                                343                 :                :                         char       *endptr;
                                344                 :                : 
   96 michael@paquier.xyz       345                 :GNC     1128030 :                         token = pg_strtok(ctx, &tok_len);
 8239 tgl@sss.pgh.pa.us         346         [ -  + ]:CBC     1128030 :                         if (token == NULL)
 8239 tgl@sss.pgh.pa.us         347         [ #  # ]:UBC           0 :                             elog(ERROR, "unterminated List structure");
 8239 tgl@sss.pgh.pa.us         348         [ +  + ]:CBC     1128030 :                         if (token[0] == ')')
                                349                 :          53352 :                             break;
                                350                 :        1074678 :                         val = (int) strtol(token, &endptr, 10);
                                351         [ -  + ]:        1074678 :                         if (endptr != token + tok_len)
 8239 tgl@sss.pgh.pa.us         352         [ #  # ]:UBC           0 :                             elog(ERROR, "unrecognized integer: \"%.*s\"",
                                353                 :                :                                  tok_len, token);
 8217 neilc@samurai.com         354                 :CBC     1074678 :                         l = lappend_int(l, val);
                                355                 :                :                     }
 1476 tgl@sss.pgh.pa.us         356                 :          53352 :                     result = (Node *) l;
                                357                 :                :                 }
 8239                           358   [ +  +  +  + ]:         966492 :                 else if (tok_len == 1 && token[0] == 'o')
                                359                 :                :                 {
                                360                 :                :                     /* List of OIDs */
                                361                 :                :                     for (;;)
                                362                 :         102365 :                     {
                                363                 :                :                         Oid         val;
                                364                 :                :                         char       *endptr;
                                365                 :                : 
   96 michael@paquier.xyz       366                 :GNC      125686 :                         token = pg_strtok(ctx, &tok_len);
 8239 tgl@sss.pgh.pa.us         367         [ -  + ]:CBC      125686 :                         if (token == NULL)
 8239 tgl@sss.pgh.pa.us         368         [ #  # ]:UBC           0 :                             elog(ERROR, "unterminated List structure");
 8239 tgl@sss.pgh.pa.us         369         [ +  + ]:CBC      125686 :                         if (token[0] == ')')
                                370                 :          23321 :                             break;
                                371                 :         102365 :                         val = (Oid) strtoul(token, &endptr, 10);
                                372         [ -  + ]:         102365 :                         if (endptr != token + tok_len)
 8239 tgl@sss.pgh.pa.us         373         [ #  # ]:UBC           0 :                             elog(ERROR, "unrecognized OID: \"%.*s\"",
                                374                 :                :                                  tok_len, token);
 8217 neilc@samurai.com         375                 :CBC      102365 :                         l = lappend_oid(l, val);
                                376                 :                :                     }
 1476 tgl@sss.pgh.pa.us         377                 :          23321 :                     result = (Node *) l;
                                378                 :                :                 }
 1599 alvherre@alvh.no-ip.      379   [ +  +  -  + ]:         943171 :                 else if (tok_len == 1 && token[0] == 'x')
                                380                 :                :                 {
                                381                 :                :                     /* List of TransactionIds */
                                382                 :                :                     for (;;)
 1599 alvherre@alvh.no-ip.      383                 :UBC           0 :                     {
                                384                 :                :                         TransactionId val;
                                385                 :                :                         char       *endptr;
                                386                 :                : 
   96 michael@paquier.xyz       387                 :UNC           0 :                         token = pg_strtok(ctx, &tok_len);
 1599 alvherre@alvh.no-ip.      388         [ #  # ]:UBC           0 :                         if (token == NULL)
                                389         [ #  # ]:              0 :                             elog(ERROR, "unterminated List structure");
                                390         [ #  # ]:              0 :                         if (token[0] == ')')
                                391                 :              0 :                             break;
                                392                 :              0 :                         val = (TransactionId) strtoul(token, &endptr, 10);
                                393         [ #  # ]:              0 :                         if (endptr != token + tok_len)
                                394         [ #  # ]:              0 :                             elog(ERROR, "unrecognized Xid: \"%.*s\"",
                                395                 :                :                                  tok_len, token);
                                396                 :              0 :                         l = lappend_xid(l, val);
                                397                 :                :                     }
 1476 tgl@sss.pgh.pa.us         398                 :              0 :                     result = (Node *) l;
                                399                 :                :                 }
 1476 tgl@sss.pgh.pa.us         400   [ +  +  +  + ]:CBC      943171 :                 else if (tok_len == 1 && token[0] == 'b')
                                401                 :            552 :                 {
                                402                 :                :                     /* Bitmapset -- see also _readBitmapset() */
                                403                 :            552 :                     Bitmapset  *bms = NULL;
                                404                 :                : 
                                405                 :                :                     for (;;)
                                406                 :           1324 :                     {
                                407                 :                :                         int         val;
                                408                 :                :                         char       *endptr;
                                409                 :                : 
   96 michael@paquier.xyz       410                 :GNC        1876 :                         token = pg_strtok(ctx, &tok_len);
 1476 tgl@sss.pgh.pa.us         411         [ -  + ]:CBC        1876 :                         if (token == NULL)
 1476 tgl@sss.pgh.pa.us         412         [ #  # ]:UBC           0 :                             elog(ERROR, "unterminated Bitmapset structure");
 1476 tgl@sss.pgh.pa.us         413   [ +  +  +  + ]:CBC        1876 :                         if (tok_len == 1 && token[0] == ')')
                                414                 :            552 :                             break;
                                415                 :           1324 :                         val = (int) strtol(token, &endptr, 10);
                                416         [ -  + ]:           1324 :                         if (endptr != token + tok_len)
 1476 tgl@sss.pgh.pa.us         417         [ #  # ]:UBC           0 :                             elog(ERROR, "unrecognized integer: \"%.*s\"",
                                418                 :                :                                  tok_len, token);
 1476 tgl@sss.pgh.pa.us         419                 :CBC        1324 :                         bms = bms_add_member(bms, val);
                                420                 :                :                     }
                                421                 :            552 :                     result = (Node *) bms;
                                422                 :                :                 }
                                423                 :                :                 else
                                424                 :                :                 {
                                425                 :                :                     /* List of other node types */
                                426                 :                :                     for (;;)
                                427                 :                :                     {
                                428                 :                :                         /* We have already scanned next token... */
 8239                           429         [ +  + ]:        5666969 :                         if (token[0] == ')')
                                430                 :         942619 :                             break;
   96 michael@paquier.xyz       431                 :GNC     4724350 :                         l = lappend(l, nodeRead(ctx, token, tok_len));
                                432                 :        4724350 :                         token = pg_strtok(ctx, &tok_len);
 8239 tgl@sss.pgh.pa.us         433         [ -  + ]:CBC     4724350 :                         if (token == NULL)
 8239 tgl@sss.pgh.pa.us         434         [ #  # ]:UBC           0 :                             elog(ERROR, "unterminated List structure");
                                435                 :                :                     }
 1476 tgl@sss.pgh.pa.us         436                 :CBC      942619 :                     result = (Node *) l;
                                437                 :                :                 }
 8241                           438                 :        1019844 :                 break;
                                439                 :                :             }
10673 bruce@momjian.us          440                 :UBC           0 :         case RIGHT_PAREN:
 8241 tgl@sss.pgh.pa.us         441         [ #  # ]:              0 :             elog(ERROR, "unexpected right parenthesis");
                                442                 :                :             result = NULL;      /* keep compiler happy */
                                443                 :                :             break;
 8241 tgl@sss.pgh.pa.us         444                 :CBC     1746297 :         case OTHER_TOKEN:
 9815                           445         [ +  - ]:        1746297 :             if (tok_len == 0)
                                446                 :                :             {
                                447                 :                :                 /* must be "<>" --- represents a null pointer */
 8241                           448                 :        1746297 :                 result = NULL;
                                449                 :                :             }
                                450                 :                :             else
                                451                 :                :             {
 8241 tgl@sss.pgh.pa.us         452         [ #  # ]:UBC           0 :                 elog(ERROR, "unrecognized token: \"%.*s\"", tok_len, token);
                                453                 :                :                 result = NULL;  /* keep compiler happy */
                                454                 :                :             }
10673 bruce@momjian.us          455                 :CBC     1746297 :             break;
10673 bruce@momjian.us          456                 :UBC           0 :         case T_Integer:
                                457                 :                : 
                                458                 :                :             /*
                                459                 :                :              * we know that the token terminates on a char atoi will stop at
                                460                 :                :              */
 3183 peter_e@gmx.net           461                 :              0 :             result = (Node *) makeInteger(atoi(token));
10673 bruce@momjian.us          462                 :              0 :             break;
 9777 tgl@sss.pgh.pa.us         463                 :              0 :         case T_Float:
                                464                 :                :             {
 9726 bruce@momjian.us          465                 :              0 :                 char       *fval = (char *) palloc(tok_len + 1);
                                466                 :                : 
 9777 tgl@sss.pgh.pa.us         467                 :              0 :                 memcpy(fval, token, tok_len);
                                468                 :              0 :                 fval[tok_len] = '\0';
 8241                           469                 :              0 :                 result = (Node *) makeFloat(fval);
                                470                 :                :             }
 9777                           471                 :              0 :             break;
 1779 peter@eisentraut.org      472                 :              0 :         case T_Boolean:
                                473                 :              0 :             result = (Node *) makeBoolean(token[0] == 't');
                                474                 :              0 :             break;
10673 bruce@momjian.us          475                 :CBC     2148387 :         case T_String:
                                476                 :                :             /* need to remove leading and trailing quotes, and backslashes */
 8241 tgl@sss.pgh.pa.us         477                 :        2148387 :             result = (Node *) makeString(debackslash(token + 1, tok_len - 2));
10673 bruce@momjian.us          478                 :        2148387 :             break;
 9524 peter_e@gmx.net           479                 :UBC           0 :         case T_BitString:
                                480                 :                :             /* need to remove backslashes, but there are no quotes */
 1019 tgl@sss.pgh.pa.us         481                 :              0 :             result = (Node *) makeBitString(debackslash(token, tok_len));
                                482                 :              0 :             break;
10673 bruce@momjian.us          483                 :              0 :         default:
 8530 tgl@sss.pgh.pa.us         484         [ #  # ]:              0 :             elog(ERROR, "unrecognized node type: %d", (int) type);
                                485                 :                :             result = NULL;      /* keep compiler happy */
                                486                 :                :             break;
                                487                 :                :     }
                                488                 :                : 
  730 peter@eisentraut.org      489                 :CBC     8677550 :     return result;
                                490                 :                : }
        

Generated by: LCOV version 2.0-1