pg_index.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*-------------------------------------------------------------------------
  2. *
  3. * pg_index.h
  4. * definition of the "index" system catalog (pg_index)
  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/catalog/pg_index.h
  11. *
  12. * NOTES
  13. * The Catalog.pm module reads this file and derives schema
  14. * information.
  15. *
  16. *-------------------------------------------------------------------------
  17. */
  18. #ifndef PG_INDEX_H
  19. #define PG_INDEX_H
  20. #include "catalog/genbki.h"
  21. #include "catalog/pg_index_d.h"
  22. /* ----------------
  23. * pg_index definition. cpp turns this into
  24. * typedef struct FormData_pg_index.
  25. * ----------------
  26. */
  27. CATALOG(pg_index,2610,IndexRelationId) BKI_SCHEMA_MACRO
  28. {
  29. Oid indexrelid BKI_LOOKUP(pg_class); /* OID of the index */
  30. Oid indrelid BKI_LOOKUP(pg_class); /* OID of the relation it
  31. * indexes */
  32. int16 indnatts; /* total number of columns in index */
  33. int16 indnkeyatts; /* number of key columns in index */
  34. bool indisunique; /* is this a unique index? */
  35. bool indnullsnotdistinct; /* null treatment in unique index */
  36. bool indisprimary; /* is this index for primary key? */
  37. bool indisexclusion; /* is this index for exclusion constraint? */
  38. bool indimmediate; /* is uniqueness enforced immediately? */
  39. bool indisclustered; /* is this the index last clustered by? */
  40. bool indisvalid; /* is this index valid for use by queries? */
  41. bool indcheckxmin; /* must we wait for xmin to be old? */
  42. bool indisready; /* is this index ready for inserts? */
  43. bool indislive; /* is this index alive at all? */
  44. bool indisreplident; /* is this index the identity for replication? */
  45. /* variable-length fields start here, but we allow direct access to indkey */
  46. int2vector indkey BKI_FORCE_NOT_NULL; /* column numbers of indexed cols,
  47. * or 0 */
  48. #ifdef CATALOG_VARLEN
  49. oidvector indcollation BKI_LOOKUP_OPT(pg_collation) BKI_FORCE_NOT_NULL; /* collation identifiers */
  50. oidvector indclass BKI_LOOKUP(pg_opclass) BKI_FORCE_NOT_NULL; /* opclass identifiers */
  51. int2vector indoption BKI_FORCE_NOT_NULL; /* per-column flags
  52. * (AM-specific meanings) */
  53. pg_node_tree indexprs; /* expression trees for index attributes that
  54. * are not simple column references; one for
  55. * each zero entry in indkey[] */
  56. pg_node_tree indpred; /* expression tree for predicate, if a partial
  57. * index; else NULL */
  58. #endif
  59. } FormData_pg_index;
  60. /* ----------------
  61. * Form_pg_index corresponds to a pointer to a tuple with
  62. * the format of pg_index relation.
  63. * ----------------
  64. */
  65. typedef FormData_pg_index *Form_pg_index;
  66. DECLARE_INDEX(pg_index_indrelid_index, 2678, IndexIndrelidIndexId, on pg_index using btree(indrelid oid_ops));
  67. DECLARE_UNIQUE_INDEX_PKEY(pg_index_indexrelid_index, 2679, IndexRelidIndexId, on pg_index using btree(indexrelid oid_ops));
  68. /* indkey can contain zero (InvalidAttrNumber) to represent expressions */
  69. DECLARE_ARRAY_FOREIGN_KEY_OPT((indrelid, indkey), pg_attribute, (attrelid, attnum));
  70. #ifdef EXPOSE_TO_CLIENT_CODE
  71. /*
  72. * Index AMs that support ordered scans must support these two indoption
  73. * bits. Otherwise, the content of the per-column indoption fields is
  74. * open for future definition.
  75. */
  76. #define INDOPTION_DESC 0x0001 /* values are in reverse order */
  77. #define INDOPTION_NULLS_FIRST 0x0002 /* NULLs are first instead of last */
  78. #endif /* EXPOSE_TO_CLIENT_CODE */
  79. #endif /* PG_INDEX_H */