PostgreSQL Source Code  git master
partcache.h
Go to the documentation of this file.
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 
14 #include "access/attnum.h"
15 #include "fmgr.h"
16 #include "nodes/parsenodes.h"
17 #include "nodes/pg_list.h"
18 #include "nodes/primnodes.h"
19 #include "partitioning/partdefs.h"
20 #include "utils/relcache.h"
21 
22 /*
23  * Information about the partition key of a relation
24  */
25 typedef struct PartitionKeyData
26 {
27  PartitionStrategy strategy; /* partitioning strategy */
28  int16 partnatts; /* number of columns in the partition key */
29  AttrNumber *partattrs; /* attribute numbers of columns in the
30  * partition key or 0 if it's an expr */
31  List *partexprs; /* list of expressions in the partitioning
32  * key, one for each zero-valued partattrs */
33 
34  Oid *partopfamily; /* OIDs of operator families */
35  Oid *partopcintype; /* OIDs of opclass declared input data types */
36  FmgrInfo *partsupfunc; /* lookup info for support funcs */
37 
38  /* Partitioning collation per attribute */
40 
41  /* Type information per attribute */
45  bool *parttypbyval;
46  char *parttypalign;
49 
50 
53 extern Expr *get_partition_qual_relid(Oid relid);
54 
55 /*
56  * PartitionKey inquiry functions
57  */
58 static inline int
60 {
61  return key->strategy;
62 }
63 
64 static inline int
66 {
67  return key->partnatts;
68 }
69 
70 static inline List *
72 {
73  return key->partexprs;
74 }
75 
76 /*
77  * PartitionKey inquiry functions - one column
78  */
79 static inline int16
81 {
82  return key->partattrs[col];
83 }
84 
85 static inline Oid
87 {
88  return key->parttypid[col];
89 }
90 
91 static inline int32
93 {
94  return key->parttypmod[col];
95 }
96 
97 static inline Oid
99 {
100  return key->partcollation[col];
101 }
102 
103 #endif /* PARTCACHE_H */
int16 AttrNumber
Definition: attnum.h:21
signed short int16
Definition: c.h:429
signed int int32
Definition: c.h:430
PartitionStrategy
Definition: parsenodes.h:834
static int get_partition_strategy(PartitionKey key)
Definition: partcache.h:59
static int32 get_partition_col_typmod(PartitionKey key, int col)
Definition: partcache.h:92
static int16 get_partition_col_attnum(PartitionKey key, int col)
Definition: partcache.h:80
Expr * get_partition_qual_relid(Oid relid)
Definition: partcache.c:304
struct PartitionKeyData PartitionKeyData
static int get_partition_natts(PartitionKey key)
Definition: partcache.h:65
List * RelationGetPartitionQual(Relation rel)
Definition: partcache.c:282
static Oid get_partition_col_typid(PartitionKey key, int col)
Definition: partcache.h:86
static Oid get_partition_col_collation(PartitionKey key, int col)
Definition: partcache.h:98
static List * get_partition_exprs(PartitionKey key)
Definition: partcache.h:71
PartitionKey RelationGetPartitionKey(Relation rel)
Definition: partcache.c:54
unsigned int Oid
Definition: postgres_ext.h:31
Definition: fmgr.h:57
Definition: pg_list.h:52
Oid * partcollation
Definition: partcache.h:39
Oid * parttypcoll
Definition: partcache.h:47
int32 * parttypmod
Definition: partcache.h:43
Oid * partopfamily
Definition: partcache.h:34
bool * parttypbyval
Definition: partcache.h:45
char * parttypalign
Definition: partcache.h:46
PartitionStrategy strategy
Definition: partcache.h:27
List * partexprs
Definition: partcache.h:31
int16 * parttyplen
Definition: partcache.h:44
FmgrInfo * partsupfunc
Definition: partcache.h:36
Oid * partopcintype
Definition: partcache.h:35
AttrNumber * partattrs
Definition: partcache.h:29