PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
partition.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * partition.h
4  * Header file for structures and utility functions related to
5  * partitioning
6  *
7  * Copyright (c) 2007-2017, PostgreSQL Global Development Group
8  *
9  * src/include/catalog/partition.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef PARTITION_H
14 #define PARTITION_H
15 
16 #include "fmgr.h"
17 #include "executor/tuptable.h"
18 #include "nodes/execnodes.h"
19 #include "parser/parse_node.h"
20 #include "utils/rel.h"
21 
22 /*
23  * PartitionBoundInfo encapsulates a set of partition bounds. It is usually
24  * associated with partitioned tables as part of its partition descriptor.
25  *
26  * The internal structure is opaque outside partition.c.
27  */
29 
30 /*
31  * Information about partitions of a partitioned table.
32  */
33 typedef struct PartitionDescData
34 {
35  int nparts; /* Number of partitions */
36  Oid *oids; /* OIDs of partitions */
37  PartitionBoundInfo boundinfo; /* collection of partition bounds */
39 
41 
42 /*-----------------------
43  * PartitionDispatch - information about one partitioned table in a partition
44  * hierarchy required to route a tuple to one of its partitions
45  *
46  * reldesc Relation descriptor of the table
47  * key Partition key information of the table
48  * keystate Execution state required for expressions in the partition key
49  * partdesc Partition descriptor of the table
50  * tupslot A standalone TupleTableSlot initialized with this table's tuple
51  * descriptor
52  * tupmap TupleConversionMap to convert from the parent's rowtype to
53  * this table's rowtype (when extracting the partition key of a
54  * tuple just before routing it through this table)
55  * indexes Array with partdesc->nparts members (for details on what
56  * individual members represent, see how they are set in
57  * RelationGetPartitionDispatchInfo())
58  *-----------------------
59  */
60 typedef struct PartitionDispatchData
61 {
64  List *keystate; /* list of ExprState */
65  PartitionDesc partdesc;
68  int *indexes;
70 
72 
73 extern void RelationBuildPartitionDesc(Relation relation);
74 extern bool partition_bounds_equal(int partnatts, int16 *parttyplen,
75  bool *parttypbyval, PartitionBoundInfo b1,
76  PartitionBoundInfo b2);
77 
78 extern void check_new_partition_bound(char *relname, Relation parent,
79  PartitionBoundSpec *spec);
80 extern Oid get_partition_parent(Oid relid);
81 extern List *get_qual_from_partbound(Relation rel, Relation parent,
82  PartitionBoundSpec *spec);
83 extern List *map_partition_varattnos(List *expr, int target_varno,
84  Relation partrel, Relation parent,
85  bool *found_whole_row);
87 extern Expr *get_partition_qual_relid(Oid relid);
88 
89 /* For tuple routing */
90 extern PartitionDispatch *RelationGetPartitionDispatchInfo(Relation rel,
91  int *num_parted, List **leaf_part_oids);
92 extern void FormPartitionKeyDatum(PartitionDispatch pd,
93  TupleTableSlot *slot,
94  EState *estate,
95  Datum *values,
96  bool *isnull);
97 extern int get_partition_for_tuple(PartitionDispatch *pd,
98  TupleTableSlot *slot,
99  EState *estate,
100  PartitionDispatchData **failed_at,
101  TupleTableSlot **failed_slot);
102 extern Oid get_default_oid_from_partdesc(PartitionDesc partdesc);
103 extern Oid get_default_partition_oid(Oid parentId);
104 extern void update_default_partition_oid(Oid parentId, Oid defaultPartId);
105 extern void check_default_allows_bound(Relation parent, Relation defaultRel,
106  PartitionBoundSpec *new_spec);
107 extern List *get_proposed_default_constraint(List *new_part_constaints);
108 
109 #endif /* PARTITION_H */
signed short int16
Definition: c.h:245
struct PartitionDispatchData * PartitionDispatch
Definition: partition.h:71
PartitionDesc partdesc
Definition: partition.h:65
void check_new_partition_bound(char *relname, Relation parent, PartitionBoundSpec *spec)
Definition: partition.c:711
TupleConversionMap * tupmap
Definition: partition.h:67
unsigned int Oid
Definition: postgres_ext.h:31
Oid get_partition_parent(Oid relid)
Definition: partition.c:1036
PartitionBoundInfo boundinfo
Definition: partition.h:37
Oid get_default_partition_oid(Oid parentId)
Definition: partition.c:2735
Oid get_default_oid_from_partdesc(PartitionDesc partdesc)
Definition: partition.c:2718
PartitionDispatch * RelationGetPartitionDispatchInfo(Relation rel, int *num_parted, List **leaf_part_oids)
Definition: partition.c:1209
void FormPartitionKeyDatum(PartitionDispatch pd, TupleTableSlot *slot, EState *estate, Datum *values, bool *isnull)
Definition: partition.c:2214
void update_default_partition_oid(Oid parentId, Oid defaultPartId)
Definition: partition.c:2760
bool partition_bounds_equal(int partnatts, int16 *parttyplen, bool *parttypbyval, PartitionBoundInfo b1, PartitionBoundInfo b2)
Definition: partition.c:641
int get_partition_for_tuple(PartitionDispatch *pd, TupleTableSlot *slot, EState *estate, PartitionDispatchData **failed_at, TupleTableSlot **failed_slot)
Definition: partition.c:2273
void check_default_allows_bound(Relation parent, Relation defaultRel, PartitionBoundSpec *new_spec)
Definition: partition.c:901
List * RelationGetPartitionQual(Relation rel)
Definition: partition.c:1154
struct PartitionDescData PartitionDescData
struct PartitionDescData * PartitionDesc
Definition: partition.h:40
Expr * get_partition_qual_relid(Oid relid)
Definition: partition.c:1171
uintptr_t Datum
Definition: postgres.h:372
TupleTableSlot * tupslot
Definition: partition.h:66
List * get_qual_from_partbound(Relation rel, Relation parent, PartitionBoundSpec *spec)
Definition: partition.c:1078
struct PartitionBoundInfoData * PartitionBoundInfo
Definition: partition.h:28
struct PartitionDispatchData PartitionDispatchData
static Datum values[MAXATTR]
Definition: bootstrap.c:164
List * get_proposed_default_constraint(List *new_part_constaints)
Definition: partition.c:2790
List * map_partition_varattnos(List *expr, int target_varno, Relation partrel, Relation parent, bool *found_whole_row)
Definition: partition.c:1121
Definition: pg_list.h:45
void RelationBuildPartitionDesc(Relation relation)
Definition: partition.c:161
PartitionKey key
Definition: partition.h:63