The following two cases should fail the same way, but the second does not because we check directly the flag value extracted from the DefElem to see if the option is repeated or not: =# copy (select 1) to '/tmp/data.txt' (header on, header off); ERROR: 42601: conflicting or redundant options =# copy (select 1) to '/tmp/data.txt' (header off, header on); ERROR: 0A000: COPY HEADER available only in CSV mode
Looking quickly at the usages of defGetBoolean() across the code, it seems that we are rather consistent on a command-basis to handle such cases (EXPLAIN does not care, subscriptions do, etc.), while COPY is a mixed bag that clearly aims at checking for redundant options correctly. So, attached is a patch to do that, with tests for the various options while on it. This is not something worth a back-patch in my opinion.