To make it work, it is enough to properly pass the parent of the PlanState while initializing the projection in RETURNING clause.