1 /*-------------------------------------------------------------------------
4 * Header file for structures and utility functions related to
7 * Copyright (c) 2007-2017, PostgreSQL Global Development Group
9 * src/include/catalog/partition.h
11 *-------------------------------------------------------------------------
17 #include "executor/tuptable.h"
18 #include "nodes/execnodes.h"
19 #include "parser/parse_node.h"
20 #include "utils/rel.h"
23 * PartitionBoundInfo encapsulates a set of partition bounds. It is usually
24 * associated with partitioned tables as part of its partition descriptor.
26 * The internal structure is opaque outside partition.c.
28 typedef struct PartitionBoundInfoData *PartitionBoundInfo;
31 * Information about partitions of a partitioned table.
33 typedef struct PartitionDescData
35 int nparts; /* Number of partitions */
36 Oid *oids; /* OIDs of partitions */
37 PartitionBoundInfo boundinfo; /* collection of partition bounds */
40 typedef struct PartitionDescData *PartitionDesc;
42 /*-----------------------
43 * PartitionDispatch - information about one partitioned table in a partition
44 * hiearchy required to route a tuple to one of its partitions
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
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 *-----------------------
60 typedef struct PartitionDispatchData
64 List *keystate; /* list of ExprState */
65 PartitionDesc partdesc;
66 TupleTableSlot *tupslot;
67 TupleConversionMap *tupmap;
69 } PartitionDispatchData;
71 typedef struct PartitionDispatchData *PartitionDispatch;
73 extern void RelationBuildPartitionDesc(Relation relation);
74 extern bool partition_bounds_equal(PartitionKey key,
75 PartitionBoundInfo p1, PartitionBoundInfo p2);
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, Relation partrel, Relation parent);
81 extern List *RelationGetPartitionQual(Relation rel);
83 /* For tuple routing */
84 extern PartitionDispatch *RelationGetPartitionDispatchInfo(Relation rel,
85 int lockmode, int *num_parted,
86 List **leaf_part_oids);
87 extern int get_partition_for_tuple(PartitionDispatch *pd,
91 #endif /* PARTITION_H */