summaryrefslogtreecommitdiff
path: root/src/include/partitioning
diff options
context:
space:
mode:
authorAlvaro Herrera2018-04-15 00:12:14 +0000
committerAlvaro Herrera2018-04-15 00:12:14 +0000
commitda6f3e45ddb68ab3161076e120e7c32cfd46d1db (patch)
treece5b30869c67d8be6a86fd6f8f0ba95b5ed61e73 /src/include/partitioning
parentb39fd897e0398a6bdc6552daa7cacdf9c0e46d7e (diff)
Reorganize partitioning code
There's been a massive addition of partitioning code in PostgreSQL 11, with little oversight on its placement, resulting in a catalog/partition.c with poorly defined boundaries and responsibilities. This commit tries to set a couple of distinct modules to separate things a little bit. There are no code changes here, only code movement. There are three new files: src/backend/utils/cache/partcache.c src/include/partitioning/partdefs.h src/include/utils/partcache.h The previous arrangement of #including catalog/partition.h almost everywhere is no more. Authors: Amit Langote and Álvaro Herrera Discussion: https://postgr.es/m/[email protected] https://postgr.es/m/[email protected] https://postgr.es/m/[email protected] https://postgr.es/m/[email protected]
Diffstat (limited to 'src/include/partitioning')
-rw-r--r--src/include/partitioning/partbounds.h41
-rw-r--r--src/include/partitioning/partdefs.h24
-rw-r--r--src/include/partitioning/partprune.h3
3 files changed, 59 insertions, 9 deletions
diff --git a/src/include/partitioning/partbounds.h b/src/include/partitioning/partbounds.h
index c76014d4a83..71c04aa446d 100644
--- a/src/include/partitioning/partbounds.h
+++ b/src/include/partitioning/partbounds.h
@@ -11,7 +11,11 @@
#ifndef PARTBOUNDS_H
#define PARTBOUNDS_H
-#include "catalog/partition.h"
+#include "fmgr.h"
+#include "nodes/parsenodes.h"
+#include "nodes/pg_list.h"
+#include "partitioning/partdefs.h"
+#include "utils/relcache.h"
/*
@@ -101,7 +105,34 @@ typedef struct PartitionRangeBound
} PartitionRangeBound;
extern int get_hash_partition_greatest_modulus(PartitionBoundInfo b);
-extern int partition_list_bsearch(FmgrInfo *partsupfunc, Oid *partcollation,
+extern uint64 compute_hash_value(int partnatts, FmgrInfo *partsupfunc,
+ Datum *values, bool *isnull);
+extern List *get_qual_from_partbound(Relation rel, Relation parent,
+ PartitionBoundSpec *spec);
+extern bool partition_bounds_equal(int partnatts, int16 *parttyplen,
+ bool *parttypbyval, PartitionBoundInfo b1,
+ PartitionBoundInfo b2);
+extern PartitionBoundInfo partition_bounds_copy(PartitionBoundInfo src,
+ PartitionKey key);
+extern void check_new_partition_bound(char *relname, Relation parent,
+ PartitionBoundSpec *spec);
+extern void check_default_allows_bound(Relation parent, Relation defaultRel,
+ PartitionBoundSpec *new_spec);
+
+extern PartitionRangeBound *make_one_range_bound(PartitionKey key, int index,
+ List *datums, bool lower);
+extern int32 partition_hbound_cmp(int modulus1, int remainder1, int modulus2,
+ int remainder2);
+extern int32 partition_rbound_cmp(int partnatts, FmgrInfo *partsupfunc,
+ Oid *partcollation, Datum *datums1,
+ PartitionRangeDatumKind *kind1, bool lower1,
+ PartitionRangeBound *b2);
+extern int32 partition_rbound_datum_cmp(FmgrInfo *partsupfunc,
+ Oid *partcollation,
+ Datum *rb_datums, PartitionRangeDatumKind *rb_kind,
+ Datum *tuple_datums, int n_tuple_datums);
+extern int partition_list_bsearch(FmgrInfo *partsupfunc,
+ Oid *partcollation,
PartitionBoundInfo boundinfo,
Datum value, bool *is_equal);
extern int partition_range_bsearch(int partnatts, FmgrInfo *partsupfunc,
@@ -114,11 +145,5 @@ extern int partition_range_datum_bsearch(FmgrInfo *partsupfunc,
int nvalues, Datum *values, bool *is_equal);
extern int partition_hash_bsearch(PartitionBoundInfo boundinfo,
int modulus, int remainder);
-extern uint64 compute_hash_value(int partnatts, FmgrInfo *partsupfunc,
- Datum *values, bool *isnull);
-extern int32 partition_rbound_datum_cmp(FmgrInfo *partsupfunc,
- Oid *partcollation,
- Datum *rb_datums, PartitionRangeDatumKind *rb_kind,
- Datum *tuple_datums, int n_tuple_datums);
#endif /* PARTBOUNDS_H */
diff --git a/src/include/partitioning/partdefs.h b/src/include/partitioning/partdefs.h
new file mode 100644
index 00000000000..1fe1b4868e9
--- /dev/null
+++ b/src/include/partitioning/partdefs.h
@@ -0,0 +1,24 @@
+/*-------------------------------------------------------------------------
+ *
+ * partdefs.h
+ * Base definitions for partitioned table handling
+ *
+ * Copyright (c) 2007-2018, PostgreSQL Global Development Group
+ *
+ * src/include/partitioning/partdefs.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PARTDEFS_H
+#define PARTDEFS_H
+
+
+typedef struct PartitionBoundInfoData *PartitionBoundInfo;
+
+typedef struct PartitionKeyData *PartitionKey;
+
+typedef struct PartitionBoundSpec PartitionBoundSpec;
+
+typedef struct PartitionDescData *PartitionDesc;
+
+#endif /* PARTDEFS_H */
diff --git a/src/include/partitioning/partprune.h b/src/include/partitioning/partprune.h
index 2ae2fd16ede..a5568abce65 100644
--- a/src/include/partitioning/partprune.h
+++ b/src/include/partitioning/partprune.h
@@ -14,9 +14,10 @@
#ifndef PARTPRUNE_H
#define PARTPRUNE_H
-#include "catalog/partition.h"
+#include "nodes/execnodes.h"
#include "nodes/relation.h"
+
/*
* PartitionPruneContext
*