parse_coerce.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*-------------------------------------------------------------------------
  2. *
  3. * parse_coerce.h
  4. * Routines for type coercion.
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
  8. * Portions Copyright (c) 1994, Regents of the University of California
  9. *
  10. * src/include/parser/parse_coerce.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef PARSE_COERCE_H
  15. #define PARSE_COERCE_H
  16. #include "parser/parse_node.h"
  17. /* Type categories (see TYPCATEGORY_xxx symbols in catalog/pg_type.h) */
  18. typedef char TYPCATEGORY;
  19. /* Result codes for find_coercion_pathway */
  20. typedef enum CoercionPathType
  21. {
  22. COERCION_PATH_NONE, /* failed to find any coercion pathway */
  23. COERCION_PATH_FUNC, /* apply the specified coercion function */
  24. COERCION_PATH_RELABELTYPE, /* binary-compatible cast, no function */
  25. COERCION_PATH_ARRAYCOERCE, /* need an ArrayCoerceExpr node */
  26. COERCION_PATH_COERCEVIAIO /* need a CoerceViaIO node */
  27. } CoercionPathType;
  28. extern bool IsBinaryCoercible(Oid srctype, Oid targettype);
  29. extern bool IsPreferredType(TYPCATEGORY category, Oid type);
  30. extern TYPCATEGORY TypeCategory(Oid type);
  31. extern Node *coerce_to_target_type(ParseState *pstate,
  32. Node *expr, Oid exprtype,
  33. Oid targettype, int32 targettypmod,
  34. CoercionContext ccontext,
  35. CoercionForm cformat,
  36. int location);
  37. extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
  38. CoercionContext ccontext);
  39. extern Node *coerce_type(ParseState *pstate, Node *node,
  40. Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod,
  41. CoercionContext ccontext, CoercionForm cformat, int location);
  42. extern Node *coerce_to_domain(Node *arg, Oid baseTypeId, int32 baseTypeMod,
  43. Oid typeId,
  44. CoercionForm cformat, int location,
  45. bool hideInputCoercion,
  46. bool lengthCoercionDone);
  47. extern Node *coerce_to_boolean(ParseState *pstate, Node *node,
  48. const char *constructName);
  49. extern Node *coerce_to_specific_type(ParseState *pstate, Node *node,
  50. Oid targetTypeId,
  51. const char *constructName);
  52. extern int parser_coercion_errposition(ParseState *pstate,
  53. int coerce_location,
  54. Node *input_expr);
  55. extern Oid select_common_type(ParseState *pstate, List *exprs,
  56. const char *context, Node **which_expr);
  57. extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
  58. Oid targetTypeId,
  59. const char *context);
  60. extern bool check_generic_type_consistency(Oid *actual_arg_types,
  61. Oid *declared_arg_types,
  62. int nargs);
  63. extern Oid enforce_generic_type_consistency(Oid *actual_arg_types,
  64. Oid *declared_arg_types,
  65. int nargs,
  66. Oid rettype,
  67. bool allow_poly);
  68. extern Oid resolve_generic_type(Oid declared_type,
  69. Oid context_actual_type,
  70. Oid context_declared_type);
  71. extern CoercionPathType find_coercion_pathway(Oid targetTypeId,
  72. Oid sourceTypeId,
  73. CoercionContext ccontext,
  74. Oid *funcid);
  75. extern CoercionPathType find_typmod_coercion_function(Oid typeId,
  76. Oid *funcid);
  77. #endif /* PARSE_COERCE_H */