Re: COPY FROM ... WHERE fails for negated operators

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY FROM ... WHERE fails for negated operators
Date: 2026-10-05 17:48:44
Message-ID: 1087919.1791222524@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Nathan Bossart <nathandbossart(at)gmail(dot)com> writes:
> 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.

Ugh. We really ought to get rid of fix_opfuncids() in favor of
insisting that operator clauses be filled in fully from the start.
But that's not happening right now, so I concur with this fix
for the moment.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Lakhin 2026-10-05 18:00:00 Re: [PATCH v1] Fix races in Windows pthread emulation
Previous Message Nathan Bossart 2026-10-05 17:07:17 COPY FROM ... WHERE fails for negated operators