2
0

parse_coerce.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*-------------------------------------------------------------------------
  2. *
  3. * parse_coerce.h
  4. * Routines for type coercion.
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2022, 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, const Oid *input_typeids, const 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. CoercionContext ccontext, CoercionForm cformat, int location,
  45. bool hideInputCoercion);
  46. extern Node *coerce_to_boolean(ParseState *pstate, Node *node,
  47. const char *constructName);
  48. extern Node *coerce_to_specific_type(ParseState *pstate, Node *node,
  49. Oid targetTypeId,
  50. const char *constructName);
  51. extern Node *coerce_to_specific_type_typmod(ParseState *pstate, Node *node,
  52. Oid targetTypeId, int32 targetTypmod,
  53. const char *constructName);
  54. extern int parser_coercion_errposition(ParseState *pstate,
  55. int coerce_location,
  56. Node *input_expr);
  57. extern Oid select_common_type(ParseState *pstate, List *exprs,
  58. const char *context, Node **which_expr);
  59. extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
  60. Oid targetTypeId,
  61. const char *context);
  62. extern bool verify_common_type(Oid common_type, List *exprs);
  63. extern int32 select_common_typmod(ParseState *pstate, List *exprs, Oid common_type);
  64. extern bool check_generic_type_consistency(const Oid *actual_arg_types,
  65. const Oid *declared_arg_types,
  66. int nargs);
  67. extern Oid enforce_generic_type_consistency(const Oid *actual_arg_types,
  68. Oid *declared_arg_types,
  69. int nargs,
  70. Oid rettype,
  71. bool allow_poly);
  72. extern char *check_valid_polymorphic_signature(Oid ret_type,
  73. const Oid *declared_arg_types,
  74. int nargs);
  75. extern char *check_valid_internal_signature(Oid ret_type,
  76. const Oid *declared_arg_types,
  77. int nargs);
  78. extern CoercionPathType find_coercion_pathway(Oid targetTypeId,
  79. Oid sourceTypeId,
  80. CoercionContext ccontext,
  81. Oid *funcid);
  82. extern CoercionPathType find_typmod_coercion_function(Oid typeId,
  83. Oid *funcid);
  84. #endif /* PARSE_COERCE_H */