Skip to content

Commit d6f00b9

Browse files
committed
Merge branch 'next' into next_epq_2
2 parents 8fa5d26 + 906dafb commit d6f00b9

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/include/compat/pg_compat.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -888,15 +888,15 @@ extern AttrNumber *convert_tuples_by_name_map(TupleDesc indesc,
888888

889889
/* See ExecEvalParamExtern() */
890890
static inline ParamExternData *
891-
CustomEvalParamExternCompat(Param *param, ParamListInfo params)
891+
CustomEvalParamExternCompat(Param *param,
892+
ParamListInfo params,
893+
ParamExternData *prmdata)
892894
{
893895
ParamExternData *prm;
894896

895897
#if PG_VERSION_NUM >= 110000
896-
ParamExternData prmdata;
897-
898898
if (params->paramFetch != NULL)
899-
prm = params->paramFetch(params, param->paramid, false, &prmdata);
899+
prm = params->paramFetch(params, param->paramid, false, prmdata);
900900
else
901901
prm = &params->params[param->paramid - 1];
902902
#else

src/nodes_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ build_parent_tlist(List *tlist, AppendRelInfo *appinfo)
159159
{
160160
tlist_var->varattno = attnum;
161161
found_column = true; /* successful mapping */
162+
break;
162163
}
163164
}
164165

src/planner_tree_modification.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,8 @@ modifytable_contains_fdw(List *rtable, ModifyTable *node)
885885

886886
/*
887887
* Find a single deepest subpartition using quals.
888-
* Return InvalidOid if it's not possible.
888+
* It's always better to narrow down the set of tables to be scanned.
889+
* Return InvalidOid if it's not possible (e.g. table is not partitioned).
889890
*/
890891
static Oid
891892
find_deepest_partition(Oid relid, Index rti, Expr *quals)
@@ -931,8 +932,13 @@ find_deepest_partition(Oid relid, Index rti, Expr *quals)
931932
Oid *children = PrelGetChildrenArray(prel),
932933
child = children[irange_lower(irange)];
933934

935+
/* Scan this partition */
936+
result = child;
937+
934938
/* Try to go deeper and see if there are subpartitions */
935-
result = find_deepest_partition(child, rti, quals);
939+
child = find_deepest_partition(child, rti, quals);
940+
if (OidIsValid(child))
941+
result = child;
936942
}
937943
break;
938944

@@ -943,8 +949,6 @@ find_deepest_partition(Oid relid, Index rti, Expr *quals)
943949
/* Don't forget to close 'prel'! */
944950
close_pathman_relation_info(prel);
945951
}
946-
/* Otherwise, return this table */
947-
else result = relid;
948952

949953
return result;
950954
}
@@ -967,7 +971,10 @@ eval_extern_params_mutator(Node *node, ParamListInfo params)
967971
param->paramid > 0 &&
968972
param->paramid <= params->numParams)
969973
{
970-
ParamExternData *prm = CustomEvalParamExternCompat(param, params);
974+
ParamExternData prmdata; /* storage for 'prm' (PG 11) */
975+
ParamExternData *prm = CustomEvalParamExternCompat(param,
976+
params,
977+
&prmdata);
971978

972979
if (OidIsValid(prm->ptype))
973980
{

0 commit comments

Comments
 (0)