PostgreSQL Source Code git master
partdesc.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * partdesc.h
4 *
5 * Copyright (c) 1996-2025, PostgreSQL Global Development Group
6 *
7 * src/include/partitioning/partdesc.h
8 *
9 *-------------------------------------------------------------------------
10 */
11
12#ifndef PARTDESC_H
13#define PARTDESC_H
14
16#include "utils/relcache.h"
17
18/*
19 * Information about partitions of a partitioned table.
20 *
21 * For partitioned tables where detached partitions exist, we only cache
22 * descriptors that include all partitions, including detached; when we're
23 * requested a descriptor without the detached partitions, we create one
24 * afresh each time. (The reason for this is that the set of detached
25 * partitions that are visible to each caller depends on the snapshot it has,
26 * so it's pretty much impossible to evict a descriptor from cache at the
27 * right time.)
28 */
29typedef struct PartitionDescData
30{
31 int nparts; /* Number of partitions */
32 bool detached_exist; /* Are there any detached partitions? */
33 Oid *oids; /* Array of 'nparts' elements containing
34 * partition OIDs in order of their bounds */
35 bool *is_leaf; /* Array of 'nparts' elements storing whether
36 * the corresponding 'oids' element belongs to
37 * a leaf partition or not */
38 PartitionBoundInfo boundinfo; /* collection of partition bounds */
39
40 /* Caching fields to cache lookups in get_partition_for_tuple() */
41
42 /*
43 * Index into the PartitionBoundInfo's datum array for the last found
44 * partition or -1 if none.
45 */
47
48 /*
49 * Partition index of the last found partition or -1 if none has been
50 * found yet.
51 */
53
54 /*
55 * For LIST partitioning, this is the number of times in a row that the
56 * datum we're looking for a partition for matches the datum in the
57 * last_found_datum_index index of the boundinfo->datums array. For RANGE
58 * partitioning, this is the number of times in a row we've found that the
59 * datum we're looking for a partition for falls into the range of the
60 * partition corresponding to the last_found_datum_index index of the
61 * boundinfo->datums array.
62 */
65
66
67extern PartitionDesc RelationGetPartitionDesc(Relation rel, bool omit_detached);
68
69extern PartitionDirectory CreatePartitionDirectory(MemoryContext mcxt, bool omit_detached);
72
74
75#endif /* PARTCACHE_H */
PartitionDesc PartitionDirectoryLookup(PartitionDirectory, Relation)
Definition: partdesc.c:456
PartitionDirectory CreatePartitionDirectory(MemoryContext mcxt, bool omit_detached)
Definition: partdesc.c:423
void DestroyPartitionDirectory(PartitionDirectory pdir)
Definition: partdesc.c:484
PartitionDesc RelationGetPartitionDesc(Relation rel, bool omit_detached)
Definition: partdesc.c:71
struct PartitionDescData PartitionDescData
Oid get_default_oid_from_partdesc(PartitionDesc partdesc)
Definition: partdesc.c:501
unsigned int Oid
Definition: postgres_ext.h:32
int last_found_datum_index
Definition: partdesc.h:46
PartitionBoundInfo boundinfo
Definition: partdesc.h:38
int last_found_count
Definition: partdesc.h:63
bool detached_exist
Definition: partdesc.h:32
bool * is_leaf
Definition: partdesc.h:35
int last_found_part_index
Definition: partdesc.h:52