Re: Reject unsupported COPY FROM targets before analyzing WHERE clause

From: surya poondla <suryapoondla4(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Reject unsupported COPY FROM targets before analyzing WHERE clause
Date: 2026-11-04 00:40:47
Message-ID: CAOVWO5qyPacd-6Qjhisp03VWynRA_jhGssFSTLUSQx8euoUk0g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Ayoub Kazar 2026-11-04 00:21:36 Fix DEFAULT marker handling in COPY FROM ... HEADER MATCH