0002-partition_bounds_copy-code-refactoring-v1.patch
application/octet-stream
Filename: 0002-partition_bounds_copy-code-refactoring-v1.patch
Type: application/octet-stream
Part: 4
Message:
Re: [POC] hash partitioning
Patch
Format: format-patch
Series: patch v1-0002
Subject: partition_bounds_copy code refactoring v1
| File | + | − |
|---|---|---|
| src/backend/catalog/partition.c | 33 | 2 |
From cf0a3cc0d4cd941b82d742d471cb1e0e1ac1046f Mon Sep 17 00:00:00 2001
From: Amul Sul <sulamul@gmail.com>
Date: Tue, 10 Oct 2017 14:36:24 +0530
Subject: [PATCH 2/5] partition_bounds_copy code refactoring v1
---
src/backend/catalog/partition.c | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c
index 5daa8a1c19..e900899cc6 100644
--- a/src/backend/catalog/partition.c
+++ b/src/backend/catalog/partition.c
@@ -149,6 +149,7 @@ static int partition_bound_bsearch(PartitionKey key,
void *probe, bool probe_is_bound, bool *is_equal);
static void get_partition_dispatch_recurse(Relation rel, Relation parent,
List **pds, List **leaf_part_oids);
+static int get_partition_bound_num_indexes(PartitionBoundInfo b);
/*
* RelationBuildPartitionDesc
@@ -721,8 +722,7 @@ partition_bounds_copy(PartitionBoundInfo src,
ndatums = dest->ndatums = src->ndatums;
partnatts = key->partnatts;
- /* Range partitioned table has an extra index. */
- num_indexes = key->strategy == PARTITION_STRATEGY_RANGE ? ndatums + 1 : ndatums;
+ num_indexes = get_partition_bound_num_indexes(src);
/* List partitioned tables have only a single partition key. */
Assert(key->strategy != PARTITION_STRATEGY_LIST || partnatts == 1);
@@ -2894,3 +2894,34 @@ get_proposed_default_constraint(List *new_part_constraints)
return list_make1(defPartConstraint);
}
+
+/*
+ * get_partition_bound_num_indexes
+ *
+ * Returns the number of the entries in the partition bound indexes array.
+ */
+static int
+get_partition_bound_num_indexes(PartitionBoundInfo bound)
+{
+ int num_indexes;
+
+ Assert(bound);
+
+ switch (bound->strategy)
+ {
+ case PARTITION_STRATEGY_LIST:
+ num_indexes = bound->ndatums;
+ break;
+
+ case PARTITION_STRATEGY_RANGE:
+ /* Range partitioned table has an extra index. */
+ num_indexes = bound->ndatums + 1;
+ break;
+
+ default:
+ elog(ERROR, "unexpected partition strategy: %d",
+ (int) bound->strategy);
+ }
+
+ return num_indexes;
+}
--
2.14.1