COPY FROM ... WHERE fails for negated operators

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: COPY FROM ... WHERE fails for negated operators
Date: 2026-10-05 17:07:17
Message-ID: asPZRTci4oBvxR9A@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The following steps produce a "cache lookup failed for function" error:

CREATE TABLE t (a int);
COPY t FROM stdin WHERE NOT (a > 0);
1
0
\.

I think what's happening is that negate_clause() is calling get_negator()
with a 0 argument because DoCopy() neglects to call fix_opfuncids() (like
RelationGetIndexPredicate() does). The attached patch fixes this.

--
nathan

Attachment Content-Type Size
v1-0001-Fix-COPY-FROM-.-WHERE-for-negated-operators.patch text/plain 4.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-10-05 17:48:44 Re: COPY FROM ... WHERE fails for negated operators
Previous Message Robert Haas 2026-10-05 17:01:07 Re: pg_*_advice: tsv load failure, etc.