diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 770c75fe2c..d4c9f1ad11 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -2744,7 +2744,8 @@ CopyFrom(CopyState cstate)
 				if (resultRelInfo->ri_FdwRoutine == NULL &&
 					(resultRelInfo->ri_RelationDesc->rd_att->constr ||
 					 check_partition_constr))
-					ExecConstraints(resultRelInfo, slot, estate, true);
+					ExecConstraints(resultRelInfo, slot, estate,
+									check_partition_constr);
 
 				if (useHeapMultiInsert)
 				{
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index c4c841cdd7..2fec161076 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -412,7 +412,8 @@ ExecInsert(ModifyTableState *mtstate,
 
 		/* Check the constraints of the tuple */
 		if (resultRelationDesc->rd_att->constr || check_partition_constr)
-			ExecConstraints(resultRelInfo, slot, estate, true);
+			ExecConstraints(resultRelInfo, slot, estate,
+							check_partition_constr);
 
 		if (onconflict != ONCONFLICT_NONE && resultRelInfo->ri_NumIndices > 0)
 		{
