COPY FROM ... WHERE fails for negated operators

Поиск
Список
Период
Сортировка
Искать

COPY FROM ... WHERE fails for negated operators

От:
Nathan Bossart <nathandbossart@gmail.com>
Дата:
Вложения:
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

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

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Nathan Bossart  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


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

От:
Nathan Bossart <nathandbossart@gmail.com>
Дата:
On Mon, Oct 05, 2026 at 01:48:44PM -0400, Tom Lane wrote:
> 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.

Committed, thanks.

-- 
nathan


FAQ