Hello Peter,
Here are three patches to add more detailed error location support to some parts of CREATE TABLE (defaults, check constraints, partition specifications) as well as the COPY command. Examples can be seen in the regression test output. The first two are low-hanging fruit, since all the information was already collected and just needed to be passed through one last hop. The third one is a bit more invasive; it adds location information to the Value node, which is used in a variety of commands, so COPY is just a start here.
About patch 2: applies cleanly independently of the first one, compiles, "make check" is ok.
There is a "make_parsestate", but no corresponding free. The usual pattern, although there seems to be a few exception, is to "make" and "free".
Even if there is some under-the-hood garbage collection, I'd suggest to add a free after the call to ComputePartitionAttrs.
-- Fabien.