Re: Reject unsupported COPY FROM targets before analyzing WHERE clause

From: solai v <solai(dot)cdac(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, tgl <tgl(at)sss(dot)pgh(dot)pa(dot)us>, ZizhuanLiu X-MAN <44973863(at)qq(dot)com>
Subject: Re: Reject unsupported COPY FROM targets before analyzing WHERE clause
Date: 2026-08-11 05:10:01
Message-ID: CAF0whuf9MdPXJfrNvkyJb8b4G8SiWzkXU5H=6yRSeEzNfX0OJA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Chao,

I tested the v2 patch on PostgreSQL 20devel.
Before applying the patch, I reproduced the reported behavior with:

DROP SEQUENCE IF EXISTS s;
CREATE SEQUENCE s;

COPY s FROM stdin;

PostgreSQL waited for input with:

Enter data to be copied...

After providing input, it reported:

ERROR: cannot copy to sequence "s"

After applying the v2 patch and rebuilding PostgreSQL, I ran the same
test again:

COPY s FROM stdin;

This time PostgreSQL immediately reported:

ERROR: cannot copy to sequence "s"

and did not wait for input.

I also tested:

COPY s FROM stdin WHERE tableoid IS NULL;

and it continued to report:

ERROR: system columns are not supported in COPY FROM WHERE conditions
DETAIL: Column "tableoid" is a system column.

So the v2 patch successfully fixes the delayed error reporting by
rejecting the unsupported target before waiting for input. The
existing WHERE-clause validation behavior remains unchanged.

Regards,
Solai

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masashi Kamura (Fujitsu) 2026-08-11 05:16:21 Crash issue in PG18.5 regression
Previous Message Alexander Lakhin 2026-08-11 05:00:00 Re: [PATCH] Fix TOCTOU races in recovery/t/020_archive_status.pl archive checks