@ -858,10 +858,12 @@ ExecInsert(ModifyTableContext *context,
/*
/*
* If these are the first tuples stored in the buffers , add the
* If these are the first tuples stored in the buffers , add the
* target rel to the es_insert_pending_result_relations list ,
* target rel and the mtstate to the
* except in the case where flushing was done above , in which case
* es_insert_pending_result_relations and
* the target rel would already have been added to the list , so no
* es_insert_pending_modifytables lists respectively , execpt in
* need to do this .
* the case where flushing was done above , in which case they
* would already have been added to the lists , so no need to do
* this .
*/
*/
if ( resultRelInfo - > ri_NumSlots = = 0 & & ! flushed )
if ( resultRelInfo - > ri_NumSlots = = 0 & & ! flushed )
{
{
@ -870,6 +872,8 @@ ExecInsert(ModifyTableContext *context,
estate - > es_insert_pending_result_relations =
estate - > es_insert_pending_result_relations =
lappend ( estate - > es_insert_pending_result_relations ,
lappend ( estate - > es_insert_pending_result_relations ,
resultRelInfo ) ;
resultRelInfo ) ;
estate - > es_insert_pending_modifytables =
lappend ( estate - > es_insert_pending_modifytables , mtstate ) ;
}
}
Assert ( list_member_ptr ( estate - > es_insert_pending_result_relations ,
Assert ( list_member_ptr ( estate - > es_insert_pending_result_relations ,
resultRelInfo ) ) ;
resultRelInfo ) ) ;
@ -1219,12 +1223,14 @@ ExecBatchInsert(ModifyTableState *mtstate,
static void
static void
ExecPendingInserts ( EState * estate )
ExecPendingInserts ( EState * estate )
{
{
ListCell * lc ;
ListCell * l1 ,
* l2 ;
foreach ( lc , estate - > es_insert_pending_result_relations )
forboth ( l1 , estate - > es_insert_pending_result_relations ,
l2 , estate - > es_insert_pending_modifytables )
{
{
ResultRelInfo * resultRelInfo = ( ResultRelInfo * ) lfirst ( lc ) ;
ResultRelInfo * resultRelInfo = ( ResultRelInfo * ) lfirst ( l1 ) ;
ModifyTableState * mtstate = resultRelInfo - > ri_ModifyTableState ;
ModifyTableState * mtstate = ( ModifyTableState * ) lfirst ( l2 ) ;
Assert ( mtstate ) ;
Assert ( mtstate ) ;
ExecBatchInsert ( mtstate , resultRelInfo ,
ExecBatchInsert ( mtstate , resultRelInfo ,
@ -1236,7 +1242,9 @@ ExecPendingInserts(EState *estate)
}
}
list_free ( estate - > es_insert_pending_result_relations ) ;
list_free ( estate - > es_insert_pending_result_relations ) ;
list_free ( estate - > es_insert_pending_modifytables ) ;
estate - > es_insert_pending_result_relations = NIL ;
estate - > es_insert_pending_result_relations = NIL ;
estate - > es_insert_pending_modifytables = NIL ;
}
}
/*
/*
@ -4342,13 +4350,6 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
}
}
else
else
resultRelInfo - > ri_BatchSize = 1 ;
resultRelInfo - > ri_BatchSize = 1 ;
/*
* If doing batch insert , setup back - link so we can easily find the
* mtstate again .
*/
if ( resultRelInfo - > ri_BatchSize > 1 )
resultRelInfo - > ri_ModifyTableState = mtstate ;
}
}
/*
/*