Header And Logo

PostgreSQL
| The world's most advanced open source database.

parse_coerce.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * parse_coerce.h
00004  *  Routines for type coercion.
00005  *
00006  *
00007  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  * src/include/parser/parse_coerce.h
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef PARSE_COERCE_H
00015 #define PARSE_COERCE_H
00016 
00017 #include "parser/parse_node.h"
00018 
00019 
00020 /* Type categories (see TYPCATEGORY_xxx symbols in catalog/pg_type.h) */
00021 typedef char TYPCATEGORY;
00022 
00023 /* Result codes for find_coercion_pathway */
00024 typedef enum CoercionPathType
00025 {
00026     COERCION_PATH_NONE,         /* failed to find any coercion pathway */
00027     COERCION_PATH_FUNC,         /* apply the specified coercion function */
00028     COERCION_PATH_RELABELTYPE,  /* binary-compatible cast, no function */
00029     COERCION_PATH_ARRAYCOERCE,  /* need an ArrayCoerceExpr node */
00030     COERCION_PATH_COERCEVIAIO   /* need a CoerceViaIO node */
00031 } CoercionPathType;
00032 
00033 
00034 extern bool IsBinaryCoercible(Oid srctype, Oid targettype);
00035 extern bool IsPreferredType(TYPCATEGORY category, Oid type);
00036 extern TYPCATEGORY TypeCategory(Oid type);
00037 
00038 extern Node *coerce_to_target_type(ParseState *pstate,
00039                       Node *expr, Oid exprtype,
00040                       Oid targettype, int32 targettypmod,
00041                       CoercionContext ccontext,
00042                       CoercionForm cformat,
00043                       int location);
00044 extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
00045                 CoercionContext ccontext);
00046 extern Node *coerce_type(ParseState *pstate, Node *node,
00047             Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod,
00048             CoercionContext ccontext, CoercionForm cformat, int location);
00049 extern Node *coerce_to_domain(Node *arg, Oid baseTypeId, int32 baseTypeMod,
00050                  Oid typeId,
00051                  CoercionForm cformat, int location,
00052                  bool hideInputCoercion,
00053                  bool lengthCoercionDone);
00054 
00055 extern Node *coerce_to_boolean(ParseState *pstate, Node *node,
00056                   const char *constructName);
00057 extern Node *coerce_to_specific_type(ParseState *pstate, Node *node,
00058                         Oid targetTypeId,
00059                         const char *constructName);
00060 
00061 extern int parser_coercion_errposition(ParseState *pstate,
00062                             int coerce_location,
00063                             Node *input_expr);
00064 
00065 extern Oid select_common_type(ParseState *pstate, List *exprs,
00066                    const char *context, Node **which_expr);
00067 extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
00068                       Oid targetTypeId,
00069                       const char *context);
00070 
00071 extern bool check_generic_type_consistency(Oid *actual_arg_types,
00072                                Oid *declared_arg_types,
00073                                int nargs);
00074 extern Oid enforce_generic_type_consistency(Oid *actual_arg_types,
00075                                  Oid *declared_arg_types,
00076                                  int nargs,
00077                                  Oid rettype,
00078                                  bool allow_poly);
00079 extern Oid resolve_generic_type(Oid declared_type,
00080                      Oid context_actual_type,
00081                      Oid context_declared_type);
00082 
00083 extern CoercionPathType find_coercion_pathway(Oid targetTypeId,
00084                       Oid sourceTypeId,
00085                       CoercionContext ccontext,
00086                       Oid *funcid);
00087 extern CoercionPathType find_typmod_coercion_function(Oid typeId,
00088                               Oid *funcid);
00089 
00090 #endif   /* PARSE_COERCE_H */