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);
75  PartitionBoundInfo p1, PartitionBoundInfo p2);
76 
77 extern void check_new_partition_bound(char *relname, Relation parent, Node *bound);
78 extern Oid get_partition_parent(Oid relid);
79 extern List *get_qual_from_partbound(Relation rel, Relation parent, Node *bound);
80 extern List *map_partition_varattnos(List *expr, int target_varno,
81  Relation partrel, Relation parent);
83 extern Expr *get_partition_qual_relid(Oid relid);
84 
85 /* For tuple routing */
86 extern PartitionDispatch *RelationGetPartitionDispatchInfo(Relation rel,
87  int lockmode, int *num_parted,
88  List **leaf_part_oids);
89 extern void FormPartitionKeyDatum(PartitionDispatch pd,
90  TupleTableSlot *slot,
91  EState *estate,
92  Datum *values,
93  bool *isnull);
94 extern int get_partition_for_tuple(PartitionDispatch *pd,
95  TupleTableSlot *slot,
96  EState *estate,
97  PartitionDispatchData **failed_at,
98  TupleTableSlot **failed_slot);
99 #endif /* PARTITION_H */
struct PartitionDispatchData * PartitionDispatch
Definition: partition.h:71
PartitionDesc partdesc
Definition: partition.h:65
void check_new_partition_bound(char *relname, Relation parent, Node *bound)
Definition: partition.c:668
TupleConversionMap * tupmap
Definition: partition.h:67
Definition: nodes.h:509
bool partition_bounds_equal(PartitionKey key, PartitionBoundInfo p1, PartitionBoundInfo p2)
Definition: partition.c:597
unsigned int Oid
Definition: postgres_ext.h:31
Oid get_partition_parent(Oid relid)
Definition: partition.c:851
PartitionBoundInfo boundinfo
Definition: partition.h:37
void FormPartitionKeyDatum(PartitionDispatch pd, TupleTableSlot *slot, EState *estate, Datum *values, bool *isnull)
Definition: partition.c:1857
int get_partition_for_tuple(PartitionDispatch *pd, TupleTableSlot *slot, EState *estate, PartitionDispatchData **failed_at, TupleTableSlot **failed_slot)
Definition: partition.c:1916
List * RelationGetPartitionQual(Relation rel)
Definition: partition.c:962
List * get_qual_from_partbound(Relation rel, Relation parent, Node *bound)
Definition: partition.c:892
struct PartitionDescData PartitionDescData
struct PartitionDescData * PartitionDesc
Definition: partition.h:40
Expr * get_partition_qual_relid(Oid relid)
Definition: partition.c:978
PartitionDispatch * RelationGetPartitionDispatchInfo(Relation rel, int lockmode, int *num_parted, List **leaf_part_oids)
Definition: partition.c:1024
uintptr_t Datum
Definition: postgres.h:372
TupleTableSlot * tupslot
Definition: partition.h:66
struct PartitionBoundInfoData * PartitionBoundInfo
Definition: partition.h:28
List * map_partition_varattnos(List *expr, int target_varno, Relation partrel, Relation parent)
Definition: partition.c:932
struct PartitionDispatchData PartitionDispatchData
static Datum values[MAXATTR]
Definition: bootstrap.c:163
Definition: pg_list.h:45
void RelationBuildPartitionDesc(Relation relation)
Definition: partition.c:159
PartitionKey key
Definition: partition.h:63