pg_cast.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*-------------------------------------------------------------------------
  2. *
  3. * pg_cast.h
  4. * definition of the "type casts" system catalog (pg_cast)
  5. *
  6. * As of Postgres 8.0, pg_cast describes not only type coercion functions
  7. * but also length coercion functions.
  8. *
  9. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  10. * Portions Copyright (c) 1994, Regents of the University of California
  11. *
  12. * src/include/catalog/pg_cast.h
  13. *
  14. * NOTES
  15. * The Catalog.pm module reads this file and derives schema
  16. * information.
  17. *
  18. *-------------------------------------------------------------------------
  19. */
  20. #ifndef PG_CAST_H
  21. #define PG_CAST_H
  22. #include "catalog/dependency.h"
  23. #include "catalog/genbki.h"
  24. #include "catalog/pg_cast_d.h"
  25. /* ----------------
  26. * pg_cast definition. cpp turns this into
  27. * typedef struct FormData_pg_cast
  28. * ----------------
  29. */
  30. CATALOG(pg_cast,2605,CastRelationId)
  31. {
  32. Oid oid; /* oid */
  33. /* source datatype for cast */
  34. Oid castsource BKI_LOOKUP(pg_type);
  35. /* destination datatype for cast */
  36. Oid casttarget BKI_LOOKUP(pg_type);
  37. /* cast function; 0 = binary coercible */
  38. Oid castfunc BKI_LOOKUP_OPT(pg_proc);
  39. /* contexts in which cast can be used */
  40. char castcontext;
  41. /* cast method */
  42. char castmethod;
  43. } FormData_pg_cast;
  44. /* ----------------
  45. * Form_pg_cast corresponds to a pointer to a tuple with
  46. * the format of pg_cast relation.
  47. * ----------------
  48. */
  49. typedef FormData_pg_cast *Form_pg_cast;
  50. DECLARE_UNIQUE_INDEX_PKEY(pg_cast_oid_index, 2660, CastOidIndexId, on pg_cast using btree(oid oid_ops));
  51. DECLARE_UNIQUE_INDEX(pg_cast_source_target_index, 2661, CastSourceTargetIndexId, on pg_cast using btree(castsource oid_ops, casttarget oid_ops));
  52. #ifdef EXPOSE_TO_CLIENT_CODE
  53. /*
  54. * The allowable values for pg_cast.castcontext are specified by this enum.
  55. * Since castcontext is stored as a "char", we use ASCII codes for human
  56. * convenience in reading the table. Note that internally to the backend,
  57. * these values are converted to the CoercionContext enum (see primnodes.h),
  58. * which is defined to sort in a convenient order; the ASCII codes don't
  59. * have to sort in any special order.
  60. */
  61. typedef enum CoercionCodes
  62. {
  63. COERCION_CODE_IMPLICIT = 'i', /* coercion in context of expression */
  64. COERCION_CODE_ASSIGNMENT = 'a', /* coercion in context of assignment */
  65. COERCION_CODE_EXPLICIT = 'e' /* explicit cast operation */
  66. } CoercionCodes;
  67. /*
  68. * The allowable values for pg_cast.castmethod are specified by this enum.
  69. * Since castmethod is stored as a "char", we use ASCII codes for human
  70. * convenience in reading the table.
  71. */
  72. typedef enum CoercionMethod
  73. {
  74. COERCION_METHOD_FUNCTION = 'f', /* use a function */
  75. COERCION_METHOD_BINARY = 'b', /* types are binary-compatible */
  76. COERCION_METHOD_INOUT = 'i' /* use input/output functions */
  77. } CoercionMethod;
  78. #endif /* EXPOSE_TO_CLIENT_CODE */
  79. extern ObjectAddress CastCreate(Oid sourcetypeid,
  80. Oid targettypeid,
  81. Oid funcid,
  82. char castcontext,
  83. char castmethod,
  84. DependencyType behavior);
  85. #endif /* PG_CAST_H */