v27-0004-pass-and-reuse-in-get_merged_range_bounds.patch
application/octet-stream
Filename: v27-0004-pass-and-reuse-in-get_merged_range_bounds.patch
Type: application/octet-stream
Part: 2
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v27-0004
Subject: pass and reuse in get_merged_range_bounds
| File | + | − |
|---|---|---|
| src/backend/partitioning/partbounds.c | 13 | 23 |
From 6c7de3d0374397ce6a372cd3b0a9ec9e7c549230 Mon Sep 17 00:00:00 2001
From: Amul Sul <amul.sul@enterprisedb.com>
Date: Thu, 14 Nov 2019 23:12:08 -0500
Subject: [PATCH 4/5] pass and reuse in get_merged_range_bounds
---
src/backend/partitioning/partbounds.c | 36 ++++++++++-----------------
1 file changed, 13 insertions(+), 23 deletions(-)
diff --git a/src/backend/partitioning/partbounds.c b/src/backend/partitioning/partbounds.c
index 269b5c1f52f..9748dda8e2a 100644
--- a/src/backend/partitioning/partbounds.c
+++ b/src/backend/partitioning/partbounds.c
@@ -190,6 +190,7 @@ get_merged_range_bounds(int partnatts, FmgrInfo *partsupfuncs,
PartitionRangeBound *outer_ub,
PartitionRangeBound *inner_lb,
PartitionRangeBound *inner_ub,
+ int lb_cmpval, int ub_cmpval,
PartitionRangeBound *merged_lb,
PartitionRangeBound *merged_ub);
static void add_merged_range_bounds(int partnatts, FmgrInfo *partsupfuncs,
@@ -3303,9 +3304,15 @@ get_merged_range_bounds(int partnatts, FmgrInfo *partsupfuncs,
PartitionRangeBound *outer_ub,
PartitionRangeBound *inner_lb,
PartitionRangeBound *inner_ub,
+ int lb_cmpval, int ub_cmpval,
PartitionRangeBound *merged_lb,
PartitionRangeBound *merged_ub)
{
+ Assert(compare_range_bounds(partnatts, partsupfuncs, partcollations,
+ outer_lb, inner_lb) == lb_cmpval);
+ Assert(compare_range_bounds(partnatts, partsupfuncs, partcollations,
+ outer_ub, inner_ub) == ub_cmpval);
+
/*
* An outer join will have all the rows from the outer side, so merged
* bounds will be same as the outer bounds. An inner join will have rows
@@ -3323,31 +3330,13 @@ get_merged_range_bounds(int partnatts, FmgrInfo *partsupfuncs,
case JOIN_INNER:
case JOIN_SEMI:
- if (compare_range_bounds(partnatts, partsupfuncs, partcollations,
- outer_ub, inner_ub) < 0)
- *merged_ub = *outer_ub;
- else
- *merged_ub = *inner_ub;
-
- if (compare_range_bounds(partnatts, partsupfuncs, partcollations,
- outer_lb, inner_lb) > 0)
- *merged_lb = *outer_lb;
- else
- *merged_lb = *inner_lb;
+ *merged_lb = (lb_cmpval > 0)? *outer_lb : *inner_lb;
+ *merged_ub = (ub_cmpval < 0)? *outer_ub : *inner_ub;
break;
case JOIN_FULL:
- if (compare_range_bounds(partnatts, partsupfuncs, partcollations,
- outer_ub, inner_ub) > 0)
- *merged_ub = *outer_ub;
- else
- *merged_ub = *inner_ub;
-
- if (compare_range_bounds(partnatts, partsupfuncs, partcollations,
- outer_lb, inner_lb) < 0)
- *merged_lb = *outer_lb;
- else
- *merged_lb = *inner_lb;
+ *merged_lb = (lb_cmpval < 0)? *outer_lb : *inner_lb;
+ *merged_ub = (ub_cmpval > 0)? *outer_ub : *inner_ub;
break;
default:
@@ -3537,7 +3526,8 @@ partition_range_bounds_merge(int partnatts, FmgrInfo *partsupfuncs,
*/
get_merged_range_bounds(partnatts, partsupfuncs, partcollations,
jointype, &outer_lb, &outer_ub, &inner_lb,
- &inner_ub, &merged_lb, &merged_ub);
+ &inner_ub, lb_cmpval, ub_cmpval,
+ &merged_lb, &merged_ub);
/*
* Both partitions are not merged yet, so they should be merged
--
2.18.0