LCOV - code coverage report
Current view: top level - src/backend/parser - parse_node.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 151 158 95.6 %
Date: 2019-11-13 22:07:24 Functions: 10 10 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * parse_node.c
       4             :  *    various routines that make nodes for querytrees
       5             :  *
       6             :  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
       7             :  * Portions Copyright (c) 1994, Regents of the University of California
       8             :  *
       9             :  *
      10             :  * IDENTIFICATION
      11             :  *    src/backend/parser/parse_node.c
      12             :  *
      13             :  *-------------------------------------------------------------------------
      14             :  */
      15             : #include "postgres.h"
      16             : 
      17             : #include "access/htup_details.h"
      18             : #include "access/table.h"
      19             : #include "catalog/pg_type.h"
      20             : #include "mb/pg_wchar.h"
      21             : #include "nodes/makefuncs.h"
      22             : #include "nodes/nodeFuncs.h"
      23             : #include "parser/parse_coerce.h"
      24             : #include "parser/parse_expr.h"
      25             : #include "parser/parse_relation.h"
      26             : #include "parser/parsetree.h"
      27             : #include "utils/builtins.h"
      28             : #include "utils/int8.h"
      29             : #include "utils/lsyscache.h"
      30             : #include "utils/syscache.h"
      31             : #include "utils/varbit.h"
      32             : 
      33             : static void pcb_error_callback(void *arg);
      34             : 
      35             : 
      36             : /*
      37             :  * make_parsestate
      38             :  *      Allocate and initialize a new ParseState.
      39             :  *
      40             :  * Caller should eventually release the ParseState via free_parsestate().
      41             :  */
      42             : ParseState *
      43     1126476 : make_parsestate(ParseState *parentParseState)
      44             : {
      45             :     ParseState *pstate;
      46             : 
      47     1126476 :     pstate = palloc0(sizeof(ParseState));
      48             : 
      49     1126476 :     pstate->parentParseState = parentParseState;
      50             : 
      51             :     /* Fill in fields that don't start at null/false/zero */
      52     1126476 :     pstate->p_next_resno = 1;
      53     1126476 :     pstate->p_resolve_unknowns = true;
      54             : 
      55     1126476 :     if (parentParseState)
      56             :     {
      57      121876 :         pstate->p_sourcetext = parentParseState->p_sourcetext;
      58             :         /* all hooks are copied from parent */
      59      121876 :         pstate->p_pre_columnref_hook = parentParseState->p_pre_columnref_hook;
      60      121876 :         pstate->p_post_columnref_hook = parentParseState->p_post_columnref_hook;
      61      121876 :         pstate->p_paramref_hook = parentParseState->p_paramref_hook;
      62      121876 :         pstate->p_coerce_param_hook = parentParseState->p_coerce_param_hook;
      63      121876 :         pstate->p_ref_hook_state = parentParseState->p_ref_hook_state;
      64             :         /* query environment stays in context for the whole parse analysis */
      65      121876 :         pstate->p_queryEnv = parentParseState->p_queryEnv;
      66             :     }
      67             : 
      68     1126476 :     return pstate;
      69             : }
      70             : 
      71             : /*
      72             :  * free_parsestate
      73             :  *      Release a ParseState and any subsidiary resources.
      74             :  */
      75             : void
      76     1024598 : free_parsestate(ParseState *pstate)
      77             : {
      78             :     /*
      79             :      * Check that we did not produce too many resnos; at the very least we
      80             :      * cannot allow more than 2^16, since that would exceed the range of a
      81             :      * AttrNumber. It seems safest to use MaxTupleAttributeNumber.
      82             :      */
      83     1024598 :     if (pstate->p_next_resno - 1 > MaxTupleAttributeNumber)
      84           0 :         ereport(ERROR,
      85             :                 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
      86             :                  errmsg("target lists can have at most %d entries",
      87             :                         MaxTupleAttributeNumber)));
      88             : 
      89     1024598 :     if (pstate->p_target_relation != NULL)
      90       69272 :         table_close(pstate->p_target_relation, NoLock);
      91             : 
      92     1024598 :     pfree(pstate);
      93     1024598 : }
      94             : 
      95             : 
      96             : /*
      97             :  * parser_errposition
      98             :  *      Report a parse-analysis-time cursor position, if possible.
      99             :  *
     100             :  * This is expected to be used within an ereport() call.  The return value
     101             :  * is a dummy (always 0, in fact).
     102             :  *
     103             :  * The locations stored in raw parsetrees are byte offsets into the source
     104             :  * string.  We have to convert them to 1-based character indexes for reporting
     105             :  * to clients.  (We do things this way to avoid unnecessary overhead in the
     106             :  * normal non-error case: computing character indexes would be much more
     107             :  * expensive than storing token offsets.)
     108             :  */
     109             : int
     110        3722 : parser_errposition(ParseState *pstate, int location)
     111             : {
     112             :     int         pos;
     113             : 
     114             :     /* No-op if location was not provided */
     115        3722 :     if (location < 0)
     116          22 :         return 0;
     117             :     /* Can't do anything if source text is not available */
     118        3700 :     if (pstate == NULL || pstate->p_sourcetext == NULL)
     119         182 :         return 0;
     120             :     /* Convert offset to character number */
     121        3518 :     pos = pg_mbstrlen_with_len(pstate->p_sourcetext, location) + 1;
     122             :     /* And pass it to the ereport mechanism */
     123        3518 :     return errposition(pos);
     124             : }
     125             : 
     126             : 
     127             : /*
     128             :  * setup_parser_errposition_callback
     129             :  *      Arrange for non-parser errors to report an error position
     130             :  *
     131             :  * Sometimes the parser calls functions that aren't part of the parser
     132             :  * subsystem and can't reasonably be passed a ParseState; yet we would
     133             :  * like any errors thrown in those functions to be tagged with a parse
     134             :  * error location.  Use this function to set up an error context stack
     135             :  * entry that will accomplish that.  Usage pattern:
     136             :  *
     137             :  *      declare a local variable "ParseCallbackState pcbstate"
     138             :  *      ...
     139             :  *      setup_parser_errposition_callback(&pcbstate, pstate, location);
     140             :  *      call function that might throw error;
     141             :  *      cancel_parser_errposition_callback(&pcbstate);
     142             :  */
     143             : void
     144     1803604 : setup_parser_errposition_callback(ParseCallbackState *pcbstate,
     145             :                                   ParseState *pstate, int location)
     146             : {
     147             :     /* Setup error traceback support for ereport() */
     148     1803604 :     pcbstate->pstate = pstate;
     149     1803604 :     pcbstate->location = location;
     150     1803604 :     pcbstate->errcallback.callback = pcb_error_callback;
     151     1803604 :     pcbstate->errcallback.arg = (void *) pcbstate;
     152     1803604 :     pcbstate->errcallback.previous = error_context_stack;
     153     1803604 :     error_context_stack = &pcbstate->errcallback;
     154     1803604 : }
     155             : 
     156             : /*
     157             :  * Cancel a previously-set-up errposition callback.
     158             :  */
     159             : void
     160     1801632 : cancel_parser_errposition_callback(ParseCallbackState *pcbstate)
     161             : {
     162             :     /* Pop the error context stack */
     163     1801632 :     error_context_stack = pcbstate->errcallback.previous;
     164     1801632 : }
     165             : 
     166             : /*
     167             :  * Error context callback for inserting parser error location.
     168             :  *
     169             :  * Note that this will be called for *any* error occurring while the
     170             :  * callback is installed.  We avoid inserting an irrelevant error location
     171             :  * if the error is a query cancel --- are there any other important cases?
     172             :  */
     173             : static void
     174        1972 : pcb_error_callback(void *arg)
     175             : {
     176        1972 :     ParseCallbackState *pcbstate = (ParseCallbackState *) arg;
     177             : 
     178        1972 :     if (geterrcode() != ERRCODE_QUERY_CANCELED)
     179        1972 :         (void) parser_errposition(pcbstate->pstate, pcbstate->location);
     180        1972 : }
     181             : 
     182             : 
     183             : /*
     184             :  * make_var
     185             :  *      Build a Var node for an attribute identified by RTE and attrno
     186             :  */
     187             : Var *
     188     1678372 : make_var(ParseState *pstate, RangeTblEntry *rte, int attrno, int location)
     189             : {
     190             :     Var        *result;
     191             :     int         vnum,
     192             :                 sublevels_up;
     193             :     Oid         vartypeid;
     194             :     int32       type_mod;
     195             :     Oid         varcollid;
     196             : 
     197     1678372 :     vnum = RTERangeTablePosn(pstate, rte, &sublevels_up);
     198     1678372 :     get_rte_attribute_type(rte, attrno, &vartypeid, &type_mod, &varcollid);
     199     1678372 :     result = makeVar(vnum, attrno, vartypeid, type_mod, varcollid, sublevels_up);
     200     1678372 :     result->location = location;
     201     1678372 :     return result;
     202             : }
     203             : 
     204             : /*
     205             :  * transformContainerType()
     206             :  *      Identify the types involved in a subscripting operation for container
     207             :  *
     208             :  *
     209             :  * On entry, containerType/containerTypmod identify the type of the input value
     210             :  * to be subscripted (which could be a domain type).  These are modified if
     211             :  * necessary to identify the actual container type and typmod, and the
     212             :  * container's element type is returned.  An error is thrown if the input isn't
     213             :  * an array type.
     214             :  */
     215             : Oid
     216        7002 : transformContainerType(Oid *containerType, int32 *containerTypmod)
     217             : {
     218        7002 :     Oid         origContainerType = *containerType;
     219             :     Oid         elementType;
     220             :     HeapTuple   type_tuple_container;
     221             :     Form_pg_type type_struct_container;
     222             : 
     223             :     /*
     224             :      * If the input is a domain, smash to base type, and extract the actual
     225             :      * typmod to be applied to the base type. Subscripting a domain is an
     226             :      * operation that necessarily works on the base container type, not the
     227             :      * domain itself. (Note that we provide no method whereby the creator of a
     228             :      * domain over a container type could hide its ability to be subscripted.)
     229             :      */
     230        7002 :     *containerType = getBaseTypeAndTypmod(*containerType, containerTypmod);
     231             : 
     232             :     /*
     233             :      * Here is an array specific code. We treat int2vector and oidvector as
     234             :      * though they were domains over int2[] and oid[].  This is needed because
     235             :      * array slicing could create an array that doesn't satisfy the
     236             :      * dimensionality constraints of the xxxvector type; so we want the result
     237             :      * of a slice operation to be considered to be of the more general type.
     238             :      */
     239        7002 :     if (*containerType == INT2VECTOROID)
     240           4 :         *containerType = INT2ARRAYOID;
     241        6998 :     else if (*containerType == OIDVECTOROID)
     242         496 :         *containerType = OIDARRAYOID;
     243             : 
     244             :     /* Get the type tuple for the container */
     245        7002 :     type_tuple_container = SearchSysCache1(TYPEOID, ObjectIdGetDatum(*containerType));
     246        7002 :     if (!HeapTupleIsValid(type_tuple_container))
     247           0 :         elog(ERROR, "cache lookup failed for type %u", *containerType);
     248        7002 :     type_struct_container = (Form_pg_type) GETSTRUCT(type_tuple_container);
     249             : 
     250             :     /* needn't check typisdefined since this will fail anyway */
     251             : 
     252        7002 :     elementType = type_struct_container->typelem;
     253        7002 :     if (elementType == InvalidOid)
     254           0 :         ereport(ERROR,
     255             :                 (errcode(ERRCODE_DATATYPE_MISMATCH),
     256             :                  errmsg("cannot subscript type %s because it is not an array",
     257             :                         format_type_be(origContainerType))));
     258             : 
     259        7002 :     ReleaseSysCache(type_tuple_container);
     260             : 
     261        7002 :     return elementType;
     262             : }
     263             : 
     264             : /*
     265             :  * transformContainerSubscripts()
     266             :  *      Transform container (array, etc) subscripting.  This is used for both
     267             :  *      container fetch and container assignment.
     268             :  *
     269             :  * In a container fetch, we are given a source container value and we produce
     270             :  * an expression that represents the result of extracting a single container
     271             :  * element or a container slice.
     272             :  *
     273             :  * In a container assignment, we are given a destination container value plus a
     274             :  * source value that is to be assigned to a single element or a slice of that
     275             :  * container. We produce an expression that represents the new container value
     276             :  * with the source data inserted into the right part of the container.
     277             :  *
     278             :  * For both cases, if the source container is of a domain-over-array type,
     279             :  * the result is of the base array type or its element type; essentially,
     280             :  * we must fold a domain to its base type before applying subscripting.
     281             :  * (Note that int2vector and oidvector are treated as domains here.)
     282             :  *
     283             :  * pstate           Parse state
     284             :  * containerBase    Already-transformed expression for the container as a whole
     285             :  * containerType    OID of container's datatype (should match type of
     286             :  *                  containerBase, or be the base type of containerBase's
     287             :  *                  domain type)
     288             :  * elementType      OID of container's element type (fetch with
     289             :  *                  transformContainerType, or pass InvalidOid to do it here)
     290             :  * containerTypMod  typmod for the container (which is also typmod for the
     291             :  *                  elements)
     292             :  * indirection      Untransformed list of subscripts (must not be NIL)
     293             :  * assignFrom       NULL for container fetch, else transformed expression for
     294             :  *                  source.
     295             :  */
     296             : SubscriptingRef *
     297        7002 : transformContainerSubscripts(ParseState *pstate,
     298             :                              Node *containerBase,
     299             :                              Oid containerType,
     300             :                              Oid elementType,
     301             :                              int32 containerTypMod,
     302             :                              List *indirection,
     303             :                              Node *assignFrom)
     304             : {
     305        7002 :     bool        isSlice = false;
     306        7002 :     List       *upperIndexpr = NIL;
     307        7002 :     List       *lowerIndexpr = NIL;
     308             :     ListCell   *idx;
     309             :     SubscriptingRef *sbsref;
     310             : 
     311             :     /*
     312             :      * Caller may or may not have bothered to determine elementType.  Note
     313             :      * that if the caller did do so, containerType/containerTypMod must be as
     314             :      * modified by transformContainerType, ie, smash domain to base type.
     315             :      */
     316        7002 :     if (!OidIsValid(elementType))
     317        6348 :         elementType = transformContainerType(&containerType, &containerTypMod);
     318             : 
     319             :     /*
     320             :      * A list containing only simple subscripts refers to a single container
     321             :      * element.  If any of the items are slice specifiers (lower:upper), then
     322             :      * the subscript expression means a container slice operation.  In this
     323             :      * case, we convert any non-slice items to slices by treating the single
     324             :      * subscript as the upper bound and supplying an assumed lower bound of 1.
     325             :      * We have to prescan the list to see if there are any slice items.
     326             :      */
     327       13856 :     foreach(idx, indirection)
     328             :     {
     329        7094 :         A_Indices  *ai = (A_Indices *) lfirst(idx);
     330             : 
     331        7094 :         if (ai->is_slice)
     332             :         {
     333         240 :             isSlice = true;
     334         240 :             break;
     335             :         }
     336             :     }
     337             : 
     338             :     /*
     339             :      * Transform the subscript expressions.
     340             :      */
     341       14192 :     foreach(idx, indirection)
     342             :     {
     343        7190 :         A_Indices  *ai = lfirst_node(A_Indices, idx);
     344             :         Node       *subexpr;
     345             : 
     346        7190 :         if (isSlice)
     347             :         {
     348         344 :             if (ai->lidx)
     349             :             {
     350         256 :                 subexpr = transformExpr(pstate, ai->lidx, pstate->p_expr_kind);
     351             :                 /* If it's not int4 already, try to coerce */
     352         256 :                 subexpr = coerce_to_target_type(pstate,
     353             :                                                 subexpr, exprType(subexpr),
     354             :                                                 INT4OID, -1,
     355             :                                                 COERCION_ASSIGNMENT,
     356             :                                                 COERCE_IMPLICIT_CAST,
     357             :                                                 -1);
     358         256 :                 if (subexpr == NULL)
     359           0 :                     ereport(ERROR,
     360             :                             (errcode(ERRCODE_DATATYPE_MISMATCH),
     361             :                              errmsg("array subscript must have type integer"),
     362             :                              parser_errposition(pstate, exprLocation(ai->lidx))));
     363             :             }
     364          88 :             else if (!ai->is_slice)
     365             :             {
     366             :                 /* Make a constant 1 */
     367          36 :                 subexpr = (Node *) makeConst(INT4OID,
     368             :                                              -1,
     369             :                                              InvalidOid,
     370             :                                              sizeof(int32),
     371             :                                              Int32GetDatum(1),
     372             :                                              false,
     373             :                                              true); /* pass by value */
     374             :             }
     375             :             else
     376             :             {
     377             :                 /* Slice with omitted lower bound, put NULL into the list */
     378          52 :                 subexpr = NULL;
     379             :             }
     380         344 :             lowerIndexpr = lappend(lowerIndexpr, subexpr);
     381             :         }
     382             :         else
     383             :             Assert(ai->lidx == NULL && !ai->is_slice);
     384             : 
     385        7190 :         if (ai->uidx)
     386             :         {
     387        7138 :             subexpr = transformExpr(pstate, ai->uidx, pstate->p_expr_kind);
     388             :             /* If it's not int4 already, try to coerce */
     389        7138 :             subexpr = coerce_to_target_type(pstate,
     390             :                                             subexpr, exprType(subexpr),
     391             :                                             INT4OID, -1,
     392             :                                             COERCION_ASSIGNMENT,
     393             :                                             COERCE_IMPLICIT_CAST,
     394             :                                             -1);
     395        7138 :             if (subexpr == NULL)
     396           0 :                 ereport(ERROR,
     397             :                         (errcode(ERRCODE_DATATYPE_MISMATCH),
     398             :                          errmsg("array subscript must have type integer"),
     399             :                          parser_errposition(pstate, exprLocation(ai->uidx))));
     400             :         }
     401             :         else
     402             :         {
     403             :             /* Slice with omitted upper bound, put NULL into the list */
     404             :             Assert(isSlice && ai->is_slice);
     405          52 :             subexpr = NULL;
     406             :         }
     407        7190 :         upperIndexpr = lappend(upperIndexpr, subexpr);
     408             :     }
     409             : 
     410             :     /*
     411             :      * If doing an array store, coerce the source value to the right type.
     412             :      * (This should agree with the coercion done by transformAssignedExpr.)
     413             :      */
     414        7002 :     if (assignFrom != NULL)
     415             :     {
     416         654 :         Oid         typesource = exprType(assignFrom);
     417         654 :         Oid         typeneeded = isSlice ? containerType : elementType;
     418             :         Node       *newFrom;
     419             : 
     420         654 :         newFrom = coerce_to_target_type(pstate,
     421             :                                         assignFrom, typesource,
     422             :                                         typeneeded, containerTypMod,
     423             :                                         COERCION_ASSIGNMENT,
     424             :                                         COERCE_IMPLICIT_CAST,
     425             :                                         -1);
     426         654 :         if (newFrom == NULL)
     427           0 :             ereport(ERROR,
     428             :                     (errcode(ERRCODE_DATATYPE_MISMATCH),
     429             :                      errmsg("array assignment requires type %s"
     430             :                             " but expression is of type %s",
     431             :                             format_type_be(typeneeded),
     432             :                             format_type_be(typesource)),
     433             :                      errhint("You will need to rewrite or cast the expression."),
     434             :                      parser_errposition(pstate, exprLocation(assignFrom))));
     435         654 :         assignFrom = newFrom;
     436             :     }
     437             : 
     438             :     /*
     439             :      * Ready to build the SubscriptingRef node.
     440             :      */
     441        7002 :     sbsref = (SubscriptingRef *) makeNode(SubscriptingRef);
     442        7002 :     if (assignFrom != NULL)
     443         654 :         sbsref->refassgnexpr = (Expr *) assignFrom;
     444             : 
     445        7002 :     sbsref->refcontainertype = containerType;
     446        7002 :     sbsref->refelemtype = elementType;
     447        7002 :     sbsref->reftypmod = containerTypMod;
     448             :     /* refcollid will be set by parse_collate.c */
     449        7002 :     sbsref->refupperindexpr = upperIndexpr;
     450        7002 :     sbsref->reflowerindexpr = lowerIndexpr;
     451        7002 :     sbsref->refexpr = (Expr *) containerBase;
     452        7002 :     sbsref->refassgnexpr = (Expr *) assignFrom;
     453             : 
     454        7002 :     return sbsref;
     455             : }
     456             : 
     457             : /*
     458             :  * make_const
     459             :  *
     460             :  *  Convert a Value node (as returned by the grammar) to a Const node
     461             :  *  of the "natural" type for the constant.  Note that this routine is
     462             :  *  only used when there is no explicit cast for the constant, so we
     463             :  *  have to guess what type is wanted.
     464             :  *
     465             :  *  For string literals we produce a constant of type UNKNOWN ---- whose
     466             :  *  representation is the same as cstring, but it indicates to later type
     467             :  *  resolution that we're not sure yet what type it should be considered.
     468             :  *  Explicit "NULL" constants are also typed as UNKNOWN.
     469             :  *
     470             :  *  For integers and floats we produce int4, int8, or numeric depending
     471             :  *  on the value of the number.  XXX We should produce int2 as well,
     472             :  *  but additional cleanup is needed before we can do that; there are
     473             :  *  too many examples that fail if we try.
     474             :  */
     475             : Const *
     476      980084 : make_const(ParseState *pstate, Value *value, int location)
     477             : {
     478             :     Const      *con;
     479             :     Datum       val;
     480             :     int64       val64;
     481             :     Oid         typeid;
     482             :     int         typelen;
     483             :     bool        typebyval;
     484             :     ParseCallbackState pcbstate;
     485             : 
     486      980084 :     switch (nodeTag(value))
     487             :     {
     488             :         case T_Integer:
     489      275484 :             val = Int32GetDatum(intVal(value));
     490             : 
     491      275484 :             typeid = INT4OID;
     492      275484 :             typelen = sizeof(int32);
     493      275484 :             typebyval = true;
     494      275484 :             break;
     495             : 
     496             :         case T_Float:
     497             :             /* could be an oversize integer as well as a float ... */
     498        5668 :             if (scanint8(strVal(value), true, &val64))
     499             :             {
     500             :                 /*
     501             :                  * It might actually fit in int32. Probably only INT_MIN can
     502             :                  * occur, but we'll code the test generally just to be sure.
     503             :                  */
     504         308 :                 int32       val32 = (int32) val64;
     505             : 
     506         308 :                 if (val64 == (int64) val32)
     507             :                 {
     508          32 :                     val = Int32GetDatum(val32);
     509             : 
     510          32 :                     typeid = INT4OID;
     511          32 :                     typelen = sizeof(int32);
     512          32 :                     typebyval = true;
     513             :                 }
     514             :                 else
     515             :                 {
     516         276 :                     val = Int64GetDatum(val64);
     517             : 
     518         276 :                     typeid = INT8OID;
     519         276 :                     typelen = sizeof(int64);
     520         276 :                     typebyval = FLOAT8PASSBYVAL;    /* int8 and float8 alike */
     521             :                 }
     522             :             }
     523             :             else
     524             :             {
     525             :                 /* arrange to report location if numeric_in() fails */
     526        5360 :                 setup_parser_errposition_callback(&pcbstate, pstate, location);
     527        5360 :                 val = DirectFunctionCall3(numeric_in,
     528             :                                           CStringGetDatum(strVal(value)),
     529             :                                           ObjectIdGetDatum(InvalidOid),
     530             :                                           Int32GetDatum(-1));
     531        5360 :                 cancel_parser_errposition_callback(&pcbstate);
     532             : 
     533        5360 :                 typeid = NUMERICOID;
     534        5360 :                 typelen = -1;   /* variable len */
     535        5360 :                 typebyval = false;
     536             :             }
     537        5668 :             break;
     538             : 
     539             :         case T_String:
     540             : 
     541             :             /*
     542             :              * We assume here that UNKNOWN's internal representation is the
     543             :              * same as CSTRING
     544             :              */
     545      575352 :             val = CStringGetDatum(strVal(value));
     546             : 
     547      575352 :             typeid = UNKNOWNOID;    /* will be coerced later */
     548      575352 :             typelen = -2;       /* cstring-style varwidth type */
     549      575352 :             typebyval = false;
     550      575352 :             break;
     551             : 
     552             :         case T_BitString:
     553             :             /* arrange to report location if bit_in() fails */
     554        2660 :             setup_parser_errposition_callback(&pcbstate, pstate, location);
     555        2660 :             val = DirectFunctionCall3(bit_in,
     556             :                                       CStringGetDatum(strVal(value)),
     557             :                                       ObjectIdGetDatum(InvalidOid),
     558             :                                       Int32GetDatum(-1));
     559        2660 :             cancel_parser_errposition_callback(&pcbstate);
     560        2660 :             typeid = BITOID;
     561        2660 :             typelen = -1;
     562        2660 :             typebyval = false;
     563        2660 :             break;
     564             : 
     565             :         case T_Null:
     566             :             /* return a null const */
     567      120920 :             con = makeConst(UNKNOWNOID,
     568             :                             -1,
     569             :                             InvalidOid,
     570             :                             -2,
     571             :                             (Datum) 0,
     572             :                             true,
     573             :                             false);
     574      120920 :             con->location = location;
     575      120920 :             return con;
     576             : 
     577             :         default:
     578           0 :             elog(ERROR, "unrecognized node type: %d", (int) nodeTag(value));
     579             :             return NULL;        /* keep compiler quiet */
     580             :     }
     581             : 
     582      859164 :     con = makeConst(typeid,
     583             :                     -1,         /* typmod -1 is OK for all cases */
     584             :                     InvalidOid, /* all cases are uncollatable types */
     585             :                     typelen,
     586             :                     val,
     587             :                     false,
     588             :                     typebyval);
     589      859164 :     con->location = location;
     590             : 
     591      859164 :     return con;
     592             : }

Generated by: LCOV version 1.13