@ -2012,8 +2012,8 @@ postgresExecForeignBatchInsert(EState *estate,
* Determine the maximum number of tuples that can be inserted in bulk
* Determine the maximum number of tuples that can be inserted in bulk
*
*
* Returns the batch size specified for server or table . When batching is not
* Returns the batch size specified for server or table . When batching is not
* allowed ( e . g . for tables with AFTER ROW triggers or with RETURNING clause ) ,
* allowed ( e . g . for tables with BEFORE / AFTER ROW triggers or with RETURNING
* returns 1.
* clause ) , returns 1.
*/
*/
static int
static int
postgresGetForeignModifyBatchSize ( ResultRelInfo * resultRelInfo )
postgresGetForeignModifyBatchSize ( ResultRelInfo * resultRelInfo )
@ -2042,10 +2042,19 @@ postgresGetForeignModifyBatchSize(ResultRelInfo *resultRelInfo)
else
else
batch_size = get_batch_size_option ( resultRelInfo - > ri_RelationDesc ) ;
batch_size = get_batch_size_option ( resultRelInfo - > ri_RelationDesc ) ;
/* Disable batching when we have to use RETURNING. */
/*
* Disable batching when we have to use RETURNING or there are any
* BEFORE / AFTER ROW INSERT triggers on the foreign table .
*
* When there are any BEFORE ROW INSERT triggers on the table , we can ' t
* support it , because such triggers might query the table we ' re inserting
* into and act differently if the tuples that have already been processed
* and prepared for insertion are not there .
*/
if ( resultRelInfo - > ri_projectReturning ! = NULL | |
if ( resultRelInfo - > ri_projectReturning ! = NULL | |
( resultRelInfo - > ri_TrigDesc & &
( resultRelInfo - > ri_TrigDesc & &
resultRelInfo - > ri_TrigDesc - > trig_insert_after_row ) )
( resultRelInfo - > ri_TrigDesc - > trig_insert_before_row | |
resultRelInfo - > ri_TrigDesc - > trig_insert_after_row ) ) )
return 1 ;
return 1 ;
/*
/*