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-2018, 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 fromrel_varno,
58  Relation to_rel, Relation from_rel,
59  bool *found_whole_row);
61 extern Expr *get_partition_qual_relid(Oid relid);
62 extern bool has_partition_attrs(Relation rel, Bitmapset *attnums,
63  bool *used_in_expr);
64 
65 extern Oid get_default_oid_from_partdesc(PartitionDesc partdesc);
66 extern Oid get_default_partition_oid(Oid parentId);
67 extern void update_default_partition_oid(Oid parentId, Oid defaultPartId);
68 extern void check_default_allows_bound(Relation parent, Relation defaultRel,
69  PartitionBoundSpec *new_spec);
70 extern List *get_proposed_default_constraint(List *new_part_constaints);
71 
72 /* For tuple routing */
73 extern int get_partition_for_tuple(Relation relation, Datum *values,
74  bool *isnull);
75 
76 #endif /* PARTITION_H */
signed short int16
Definition: c.h:301
void check_new_partition_bound(char *relname, Relation parent, PartitionBoundSpec *spec)
Definition: partition.c:954
int get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
Definition: partition.c:2570
unsigned int Oid
Definition: postgres_ext.h:31
Oid get_partition_parent(Oid relid)
Definition: partition.c:1395
PartitionBoundInfo boundinfo
Definition: partition.h:40
Oid get_default_partition_oid(Oid parentId)
Definition: partition.c:3141
Oid get_default_oid_from_partdesc(PartitionDesc partdesc)
Definition: partition.c:3124
void update_default_partition_oid(Oid parentId, Oid defaultPartId)
Definition: partition.c:3166
bool partition_bounds_equal(int partnatts, int16 *parttyplen, bool *parttypbyval, PartitionBoundInfo b1, PartitionBoundInfo b2)
Definition: partition.c:751
void check_default_allows_bound(Relation parent, Relation defaultRel, PartitionBoundSpec *new_spec)
Definition: partition.c:1242
List * RelationGetPartitionQual(Relation rel)
Definition: partition.c:1521
struct PartitionDescData PartitionDescData
struct PartitionDescData * PartitionDesc
Definition: partition.h:43
Expr * get_partition_qual_relid(Oid relid)
Definition: partition.c:1538
uintptr_t Datum
Definition: postgres.h:365
bool has_partition_attrs(Relation rel, Bitmapset *attnums, bool *used_in_expr)
Definition: partition.c:2676
PartitionBoundInfo partition_bounds_copy(PartitionBoundInfo src, PartitionKey key)
Definition: partition.c:864
List * get_qual_from_partbound(Relation rel, Relation parent, PartitionBoundSpec *spec)
Definition: partition.c:1437
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:3196
Definition: pg_list.h:45
void RelationBuildPartitionDesc(Relation relation)
Definition: partition.c:204
List * map_partition_varattnos(List *expr, int fromrel_varno, Relation to_rel, Relation from_rel, bool *found_whole_row)
Definition: partition.c:1488