pg_amop.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*-------------------------------------------------------------------------
  2. *
  3. * pg_amop.h
  4. * definition of the "access method operator" system catalog (pg_amop)
  5. *
  6. * The amop table identifies the operators associated with each index operator
  7. * family and operator class (classes are subsets of families). An associated
  8. * operator can be either a search operator or an ordering operator, as
  9. * identified by amoppurpose.
  10. *
  11. * The primary key for this table is <amopfamily, amoplefttype, amoprighttype,
  12. * amopstrategy>. amoplefttype and amoprighttype are just copies of the
  13. * operator's oprleft/oprright, ie its declared input data types. The
  14. * "default" operators for a particular opclass within the family are those
  15. * with amoplefttype = amoprighttype = opclass's opcintype. An opfamily may
  16. * also contain other operators, typically cross-data-type operators. All the
  17. * operators within a family are supposed to be compatible, in a way that is
  18. * defined by each individual index AM.
  19. *
  20. * We also keep a unique index on <amopopr, amoppurpose, amopfamily>, so that
  21. * we can use a syscache to quickly answer questions of the form "is this
  22. * operator in this opfamily, and if so what are its semantics with respect to
  23. * the family?" This implies that the same operator cannot be listed for
  24. * multiple strategy numbers within a single opfamily, with the exception that
  25. * it's possible to list it for both search and ordering purposes (with
  26. * different strategy numbers for the two purposes).
  27. *
  28. * amopmethod is a copy of the owning opfamily's opfmethod field. This is an
  29. * intentional denormalization of the catalogs to buy lookup speed.
  30. *
  31. *
  32. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  33. * Portions Copyright (c) 1994, Regents of the University of California
  34. *
  35. * src/include/catalog/pg_amop.h
  36. *
  37. * NOTES
  38. * The Catalog.pm module reads this file and derives schema
  39. * information.
  40. *
  41. *-------------------------------------------------------------------------
  42. */
  43. #ifndef PG_AMOP_H
  44. #define PG_AMOP_H
  45. #include "catalog/genbki.h"
  46. #include "catalog/pg_amop_d.h"
  47. /* ----------------
  48. * pg_amop definition. cpp turns this into
  49. * typedef struct FormData_pg_amop
  50. * ----------------
  51. */
  52. CATALOG(pg_amop,2602,AccessMethodOperatorRelationId)
  53. {
  54. Oid oid; /* oid */
  55. /* the index opfamily this entry is for */
  56. Oid amopfamily BKI_LOOKUP(pg_opfamily);
  57. /* operator's left input data type */
  58. Oid amoplefttype BKI_LOOKUP(pg_type);
  59. /* operator's right input data type */
  60. Oid amoprighttype BKI_LOOKUP(pg_type);
  61. /* operator strategy number */
  62. int16 amopstrategy;
  63. /* is operator for 's'earch or 'o'rdering? */
  64. char amoppurpose BKI_DEFAULT(s);
  65. /* the operator's pg_operator OID */
  66. Oid amopopr BKI_LOOKUP(pg_operator);
  67. /* the index access method this entry is for */
  68. Oid amopmethod BKI_LOOKUP(pg_am);
  69. /* ordering opfamily OID, or 0 if search op */
  70. Oid amopsortfamily BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_opfamily);
  71. } FormData_pg_amop;
  72. /* ----------------
  73. * Form_pg_amop corresponds to a pointer to a tuple with
  74. * the format of pg_amop relation.
  75. * ----------------
  76. */
  77. typedef FormData_pg_amop *Form_pg_amop;
  78. DECLARE_UNIQUE_INDEX(pg_amop_fam_strat_index, 2653, AccessMethodStrategyIndexId, on pg_amop using btree(amopfamily oid_ops, amoplefttype oid_ops, amoprighttype oid_ops, amopstrategy int2_ops));
  79. DECLARE_UNIQUE_INDEX(pg_amop_opr_fam_index, 2654, AccessMethodOperatorIndexId, on pg_amop using btree(amopopr oid_ops, amoppurpose char_ops, amopfamily oid_ops));
  80. DECLARE_UNIQUE_INDEX_PKEY(pg_amop_oid_index, 2756, AccessMethodOperatorOidIndexId, on pg_amop using btree(oid oid_ops));
  81. #ifdef EXPOSE_TO_CLIENT_CODE
  82. /* allowed values of amoppurpose: */
  83. #define AMOP_SEARCH 's' /* operator is for search */
  84. #define AMOP_ORDER 'o' /* operator is for ordering */
  85. #endif /* EXPOSE_TO_CLIENT_CODE */
  86. #endif /* PG_AMOP_H */