@@ -812,12 +812,7 @@ make_partition_filter(Plan *subplan,
812812cscan -> scan .scanrelid = 0 ;
813813
814814/* Build an appropriate target list */
815- cscan -> scan .plan .targetlist = pfilter_build_tlist (subplan );
816-
817- /* Prepare 'custom_scan_tlist' for EXPLAIN (VERBOSE) */
818- cscan -> custom_scan_tlist = copyObject (cscan -> scan .plan .targetlist );
819- ChangeVarNodes ((Node * )cscan -> custom_scan_tlist ,INDEX_VAR ,parent_rti ,0 );
820- pfilter_tlist_fix_resjunk (cscan );
815+ cscan -> scan .plan .targetlist = pfilter_build_tlist (subplan ,parent_rti );
821816
822817/* Pack partitioned table's Oid and conflict_action */
823818cscan -> custom_private = list_make4 (makeInteger (parent_relid ),
@@ -1076,7 +1071,7 @@ partition_filter_explain(CustomScanState *node, List *ancestors, ExplainState *e
10761071 * Build partition filter's target list pointing to subplan tuple's elements.
10771072 */
10781073List *
1079- pfilter_build_tlist (Plan * subplan )
1074+ pfilter_build_tlist (Plan * subplan , Index varno )
10801075{
10811076List * result_tlist = NIL ;
10821077ListCell * lc ;
@@ -1096,7 +1091,7 @@ pfilter_build_tlist(Plan *subplan)
10961091}
10971092else
10981093{
1099- Var * var = makeVar (INDEX_VAR ,/* point to subplan's elements */
1094+ Var * var = makeVar (varno ,/* point to subplan's elements */
11001095tle -> resno ,
11011096exprType ((Node * )tle -> expr ),
11021097exprTypmod ((Node * )tle -> expr ),
@@ -1115,34 +1110,6 @@ pfilter_build_tlist(Plan *subplan)
11151110return result_tlist ;
11161111}
11171112
1118- /*
1119- * resjunk Vars had its varattnos being set on nonexisting relation columns.
1120- * For future processing service attributes should be indicated correctly.
1121- */
1122- void
1123- pfilter_tlist_fix_resjunk (CustomScan * css )
1124- {
1125- ListCell * lc ;
1126-
1127- foreach (lc ,css -> custom_scan_tlist )
1128- {
1129- TargetEntry * tle = (TargetEntry * )lfirst (lc );
1130-
1131- if (!IsA (tle -> expr ,Const ))
1132- {
1133- Var * var = (Var * )tle -> expr ;
1134-
1135- if (tle -> resjunk )
1136- {
1137- /* To make Var recognizable as service attribute. */
1138- var -> varattno = -1 ;
1139- }
1140- }
1141- }
1142-
1143- return ;
1144- }
1145-
11461113/*
11471114 * ----------------------------------------------
11481115 * Additional init steps for ResultPartsStorage