Skip to content

Commit 1145931

Browse files
committed
bugfix: don't take parent's plan into account in PartitionFilter
1 parent d807338 commit 1145931

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/nodes_common.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ unpack_runtimeappend_private(RuntimeAppendState *scan_state, CustomScan *cscan)
240240

241241
/* Transform partition ranges into plain array of partition Oids */
242242
Oid *
243-
get_partition_oids(List *ranges, int *n, const PartRelationInfo *prel)
243+
get_partition_oids(List *ranges, int *n, const PartRelationInfo *prel,
244+
bool include_parent)
244245
{
245246
ListCell *range_cell;
246247
uint32 allocated = INITIAL_ALLOC_NUM;
@@ -250,7 +251,7 @@ get_partition_oids(List *ranges, int *n, const PartRelationInfo *prel)
250251

251252
/* If required, add parent to result */
252253
Assert(INITIAL_ALLOC_NUM >= 1);
253-
if (prel->enable_parent)
254+
if (include_parent)
254255
result[used++] = PrelParentRelid(prel);
255256

256257
/* Deal with selected partitions */
@@ -521,7 +522,7 @@ rescan_append_common(CustomScanState *node)
521522
}
522523

523524
/* Get Oids of the required partitions */
524-
parts = get_partition_oids(ranges, &nparts, prel);
525+
parts = get_partition_oids(ranges, &nparts, prel, prel->enable_parent);
525526

526527
/* Select new plans for this run using 'parts' */
527528
if (scan_state->cur_plans)

src/nodes_common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ clear_plan_states(CustomScanState *scan_state)
6060
}
6161
}
6262

63-
Oid * get_partition_oids(List *ranges, int *n, const PartRelationInfo *prel);
63+
Oid * get_partition_oids(List *ranges, int *n, const PartRelationInfo *prel,
64+
bool include_parent);
6465

6566
Path * create_append_path_common(PlannerInfo *root,
6667
AppendPath *inner_append,

src/partition_filter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ partition_filter_exec(CustomScanState *node)
199199
old_cxt = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
200200

201201
ranges = walk_expr_tree((Expr *) &state->temp_const, &wcxt)->rangeset;
202-
parts = get_partition_oids(ranges, &nparts, prel);
202+
parts = get_partition_oids(ranges, &nparts, prel, false);
203203

204204
if (nparts > 1)
205205
elog(ERROR, "PartitionFilter selected more than one partition");
@@ -222,7 +222,7 @@ partition_filter_exec(CustomScanState *node)
222222
elog(ERROR,
223223
"There is no suitable partition for key '%s'",
224224
datum_to_cstring(state->temp_const.constvalue,
225-
state->temp_const.consttype));
225+
state->temp_const.consttype));
226226
}
227227
else
228228
selected_partid = parts[0];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy