PostgreSQL Source Code  git master
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 /* Seed for the extended hash function */
23 #define HASH_PARTITION_SEED UINT64CONST(0x7A5B22367996DCFD)
24 
25 /*
26  * PartitionBoundInfo encapsulates a set of partition bounds. It is usually
27  * associated with partitioned tables as part of its partition descriptor.
28  *
29  * The internal structure is opaque outside partition.c.
30  */
32 
33 /*
34  * Information about partitions of a partitioned table.
35  */
36 typedef struct PartitionDescData
37 {
38  int nparts; /* Number of partitions */
39  Oid *oids; /* OIDs of partitions */
40  PartitionBoundInfo boundinfo; /* collection of partition bounds */
42 
44 
45 extern void RelationBuildPartitionDesc(Relation relation);
46 extern bool partition_bounds_equal(int partnatts, int16 *parttyplen,
47  bool *parttypbyval, PartitionBoundInfo b1,
48  PartitionBoundInfo b2);
49 extern PartitionBoundInfo partition_bounds_copy(PartitionBoundInfo src,
50  PartitionKey key);
51 
52 extern void check_new_partition_bound(char *relname, Relation parent,
53  PartitionBoundSpec *spec);
54 extern Oid get_partition_parent(Oid relid);
55 extern List *get_qual_from_partbound(Relation rel, Relation parent,
56  PartitionBoundSpec *spec);
57 extern List *map_partition_varattnos(List *expr, int target_varno,
58  Relation partrel, Relation parent,
59  bool *found_whole_row);
61 extern Expr *get_partition_qual_relid(Oid relid);
62 
63 extern Oid get_default_oid_from_partdesc(PartitionDesc partdesc);
64 extern Oid get_default_partition_oid(Oid parentId);
65 extern void update_default_partition_oid(Oid parentId, Oid defaultPartId);
66 extern void check_default_allows_bound(Relation parent, Relation defaultRel,
67  PartitionBoundSpec *new_spec);
68 extern List *get_proposed_default_constraint(List *new_part_constaints);
69 
70 /* For tuple routing */
71 extern int get_partition_for_tuple(Relation relation, Datum *values,
72  bool *isnull);
73 
74 #endif /* PARTITION_H */
signed short int16
Definition: c.h:283
void check_new_partition_bound(char *relname, Relation parent, PartitionBoundSpec *spec)
Definition: partition.c:941
int get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
Definition: partition.c:2486
unsigned int Oid
Definition: postgres_ext.h:31
Oid get_partition_parent(Oid relid)
Definition: partition.c:1367
PartitionBoundInfo boundinfo
Definition: partition.h:40
Oid get_default_partition_oid(Oid parentId)
Definition: partition.c:2916
Oid get_default_oid_from_partdesc(PartitionDesc partdesc)
Definition: partition.c:2899
void update_default_partition_oid(Oid parentId, Oid defaultPartId)
Definition: partition.c:2941
bool partition_bounds_equal(int partnatts, int16 *parttyplen, bool *parttypbyval, PartitionBoundInfo b1, PartitionBoundInfo b2)
Definition: partition.c:735
void check_default_allows_bound(Relation parent, Relation defaultRel, PartitionBoundSpec *new_spec)
Definition: partition.c:1214
List * RelationGetPartitionQual(Relation rel)
Definition: partition.c:1490
struct PartitionDescData PartitionDescData
struct PartitionDescData * PartitionDesc
Definition: partition.h:43
Expr * get_partition_qual_relid(Oid relid)
Definition: partition.c:1507
uintptr_t Datum
Definition: postgres.h:372
PartitionBoundInfo partition_bounds_copy(PartitionBoundInfo src, PartitionKey key)
Definition: partition.c:851
List * get_qual_from_partbound(Relation rel, Relation parent, PartitionBoundSpec *spec)
Definition: partition.c:1409
struct PartitionBoundInfoData * PartitionBoundInfo
Definition: partition.h:31
static Datum values[MAXATTR]
Definition: bootstrap.c:164
List * get_proposed_default_constraint(List *new_part_constaints)
Definition: partition.c:2971
List * map_partition_varattnos(List *expr, int target_varno, Relation partrel, Relation parent, bool *found_whole_row)
Definition: partition.c:1457
Definition: pg_list.h:45
void RelationBuildPartitionDesc(Relation relation)
Definition: partition.c:189