Skip to content
Snippets Groups Projects
Select Git revision
  • benchmark-tools
  • postgres-lambda
  • master default
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
23 results

parse_coerce.c

Blame
  • parse_coerce.c 71.70 KiB
    /*-------------------------------------------------------------------------
     *
     * parse_coerce.c
     *		handle type coercions/conversions for parser
     *
     * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
     * Portions Copyright (c) 1994, Regents of the University of California
     *
     *
     * IDENTIFICATION
     *	  src/backend/parser/parse_coerce.c
     *
     *-------------------------------------------------------------------------
     */
    #include "postgres.h"
    
    #include "access/htup_details.h"
    #include "catalog/pg_cast.h"
    #include "catalog/pg_class.h"
    #include "catalog/pg_inherits_fn.h"
    #include "catalog/pg_proc.h"
    #include "catalog/pg_type.h"
    #include "nodes/makefuncs.h"
    #include "nodes/nodeFuncs.h"
    #include "parser/parse_coerce.h"
    #include "parser/parse_relation.h"
    #include "parser/parse_type.h"
    #include "utils/builtins.h"
    #include "utils/lsyscache.h"
    #include "utils/syscache.h"
    #include "utils/typcache.h"
    
    
    static Node *coerce_type_typmod(Node *node,
    				   Oid targetTypeId, int32 targetTypMod,
    				   CoercionForm cformat, int location,
    				   bool isExplicit, bool hideInputCoercion);
    static void hide_coercion_node(Node *node);
    static Node *build_coercion_expression(Node *node,
    						  CoercionPathType pathtype,
    						  Oid funcId,
    						  Oid targetTypeId, int32 targetTypMod,
    						  CoercionForm cformat, int location,
    						  bool isExplicit);
    static Node *coerce_record_to_complex(ParseState *pstate, Node *node,
    						 Oid targetTypeId,
    						 CoercionContext ccontext,
    						 CoercionForm cformat,
    						 int location);
    static bool is_complex_array(Oid typid);
    static bool typeIsOfTypedTable(Oid reltypeId, Oid reloftypeId);
    
    
    /*
     * coerce_to_target_type()
     *		Convert an expression to a target type and typmod.
     *
     * This is the general-purpose entry point for arbitrary type coercion
     * operations.	Direct use of the component operations can_coerce_type,
     * coerce_type, and coerce_type_typmod should be restricted to special
     * cases (eg, when the conversion is expected to succeed).
     *
     * Returns the possibly-transformed expression tree, or NULL if the type
     * conversion is not possible.	(We do this, rather than ereport'ing directly,
     * so that callers can generate custom error messages indicating context.)
     *
     * pstate - parse state (can be NULL, see coerce_type)
     * expr - input expression tree (already transformed by transformExpr)
     * exprtype - result type of expr
     * targettype - desired result type