Hi Chao,
Thanks for v3. I applied it on current master (eaa5961efc6). The code is
the same as v2, and with copy2.sql left alone copy2's output matches
master. file_fdw passes too.
One thing I noticed, since the check now runs before ProcessCopyOptions(),
option errors are reported after the relkind error:
copy s from stdin (format bogus);
-- master: ERROR: COPY format "bogus" not recognized
-- v3: ERROR: cannot copy to sequence "s"
That's the same order COPY TO already uses, so I think it's fine, but maybe
worth a word in the commit message. Column-list errors still come first,
since DoCopy resolves the column list for the permission check.
Also, I don't think any existing test covers the early failure itself.
Something like COPY seq FROM '/nonexistent/file' would, since master
reports "could not open file" there. Not a must, just an idea.
Either way v3 looks good to me.
Regards,
Surya Poondla