2
0

partcache.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*-------------------------------------------------------------------------
  2. *
  3. * partcache.h
  4. *
  5. * Copyright (c) 1996-2022, PostgreSQL Global Development Group
  6. *
  7. * src/include/utils/partcache.h
  8. *
  9. *-------------------------------------------------------------------------
  10. */
  11. #ifndef PARTCACHE_H
  12. #define PARTCACHE_H
  13. #include "access/attnum.h"
  14. #include "fmgr.h"
  15. #include "nodes/pg_list.h"
  16. #include "nodes/primnodes.h"
  17. #include "partitioning/partdefs.h"
  18. #include "utils/relcache.h"
  19. /*
  20. * Information about the partition key of a relation
  21. */
  22. typedef struct PartitionKeyData
  23. {
  24. char strategy; /* partitioning strategy */
  25. int16 partnatts; /* number of columns in the partition key */
  26. AttrNumber *partattrs; /* attribute numbers of columns in the
  27. * partition key or 0 if it's an expr */
  28. List *partexprs; /* list of expressions in the partitioning
  29. * key, one for each zero-valued partattrs */
  30. Oid *partopfamily; /* OIDs of operator families */
  31. Oid *partopcintype; /* OIDs of opclass declared input data types */
  32. FmgrInfo *partsupfunc; /* lookup info for support funcs */
  33. /* Partitioning collation per attribute */
  34. Oid *partcollation;
  35. /* Type information per attribute */
  36. Oid *parttypid;
  37. int32 *parttypmod;
  38. int16 *parttyplen;
  39. bool *parttypbyval;
  40. char *parttypalign;
  41. Oid *parttypcoll;
  42. } PartitionKeyData;
  43. extern PartitionKey RelationGetPartitionKey(Relation rel);
  44. extern List *RelationGetPartitionQual(Relation rel);
  45. extern Expr *get_partition_qual_relid(Oid relid);
  46. /*
  47. * PartitionKey inquiry functions
  48. */
  49. static inline int
  50. get_partition_strategy(PartitionKey key)
  51. {
  52. return key->strategy;
  53. }
  54. static inline int
  55. get_partition_natts(PartitionKey key)
  56. {
  57. return key->partnatts;
  58. }
  59. static inline List *
  60. get_partition_exprs(PartitionKey key)
  61. {
  62. return key->partexprs;
  63. }
  64. /*
  65. * PartitionKey inquiry functions - one column
  66. */
  67. static inline int16
  68. get_partition_col_attnum(PartitionKey key, int col)
  69. {
  70. return key->partattrs[col];
  71. }
  72. static inline Oid
  73. get_partition_col_typid(PartitionKey key, int col)
  74. {
  75. return key->parttypid[col];
  76. }
  77. static inline int32
  78. get_partition_col_typmod(PartitionKey key, int col)
  79. {
  80. return key->parttypmod[col];
  81. }
  82. static inline Oid
  83. get_partition_col_collation(PartitionKey key, int col)
  84. {
  85. return key->partcollation[col];
  86. }
  87. #endif /* PARTCACHE_H */