@@ -291,7 +291,7 @@ router_run_modify_table(PlanState *state)
291291 /* PartitionRouter asked us to restart */
292292 if (mt_plans_new != mt_plans_old )
293293 {
294- int state_idx = mt_state -> mt_whichplan - 1 ;
294+ int state_idx = - mt_plans_new ;
295295
296296 /* HACK: partially restore ModifyTable's state */
297297 MTHackField (mt_state , mt_done ) = false;
@@ -312,7 +312,9 @@ router_set_slot(PartitionRouterState *state,
312312{
313313 ModifyTableState * mt_state = state -> mt_state ;
314314
315+ /* Check invariants */
315316 Assert (!TupIsNull (slot ));
317+ Assert (state -> junkfilter );
316318
317319 if (mt_state -> operation == operation )
318320 return slot ;
@@ -321,6 +323,11 @@ router_set_slot(PartitionRouterState *state,
321323 MTHackField (mt_state , mt_nplans ) = - mt_state -> mt_whichplan ;
322324 MTHackField (mt_state , operation ) = operation ;
323325
326+ /* HACK: conditionally disable junk filter in result relation */
327+ state -> current_rri -> ri_junkFilter = (operation == CMD_UPDATE ) ?
328+ state -> junkfilter :
329+ NULL ;
330+
324331 /* Set saved_slot and yield */
325332 state -> saved_slot = slot ;
326333 return NULL ;
@@ -355,21 +362,8 @@ router_get_slot(PartitionRouterState *state,
355362static void
356363router_lazy_init_junkfilter (PartitionRouterState * state , EState * estate )
357364{
358- Relation rel = state -> current_rri -> ri_RelationDesc ;
359-
360365 if (state -> junkfilter == NULL )
361- {
362- state -> junkfilter =
363- ExecInitJunkFilter (state -> subplan -> targetlist ,
364- RelationGetDescr (rel )-> tdhasoid ,
365- ExecInitExtraTupleSlotCompat (estate ));
366-
367- state -> junkfilter -> jf_junkAttNo =
368- ExecFindJunkAttribute (state -> junkfilter , "ctid" );
369-
370- if (!AttributeNumberIsValid (state -> junkfilter -> jf_junkAttNo ))
371- elog (ERROR , "could not find junk ctid column" );
372- }
366+ state -> junkfilter = state -> current_rri -> ri_junkFilter ;
373367}
374368
375369static void
0 commit comments