Actually, I hadn't realized that the originally submitted patch had the test in postgres_fdw only, but we really want it to catch any FDW, so it needs to be somewhere more general. The best place I found to put this test is in make_modifytable ... I searched for some earlier place in the planner to do it, but couldn't find anything.
So what do people think about this?
Good point. I agree that the test should be in a more general place.
I wonder if we can make it earlier in grouping_planner() just before we add ModifyTablePath.