pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Fix COPY FROM ... WHERE for negated operators.
7+ messages / 1 participants
[nested] [flat]
* pgsql: Fix COPY FROM ... WHERE for negated operators.
@ 2026-10-06 14:05 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 7+ messages in thread
From: Nathan Bossart @ 2026-10-06 14:05 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix COPY FROM ... WHERE for negated operators.
COPY FROM runs its WHERE clause through eval_const_expressions(),
which among other things replaces NOT above an operator with the
operator's negator, if it has one (e.g., NOT (a > 0) becomes
a <= 0). The node it builds for the negator has no opfuncid, and
since COPY FROM never calls fix_opfuncids() on the clause, nothing
fills it in before the executor needs it. So
COPY tab FROM stdin WHERE NOT (a > 0)
fails with "cache lookup failed for function 0".
To fix, call fix_opfuncids() on the clause, as the relcache does
for index predicates.
Oversight in commit 31f3817402.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/asPZRTci4oBvxR9A%40nathan
Backpatch-through: 14
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/a14041d437ff9e74d3596aea31bd202662e28800
Modified Files
--------------
src/backend/commands/copy.c | 2 ++
src/test/regress/expected/copy2.out | 7 ++++++-
src/test/regress/sql/copy2.sql | 6 ++++++
3 files changed, 14 insertions(+), 1 deletion(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix COPY FROM ... WHERE for negated operators.
@ 2026-10-06 14:05 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 7+ messages in thread
From: Nathan Bossart @ 2026-10-06 14:05 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix COPY FROM ... WHERE for negated operators.
COPY FROM runs its WHERE clause through eval_const_expressions(),
which among other things replaces NOT above an operator with the
operator's negator, if it has one (e.g., NOT (a > 0) becomes
a <= 0). The node it builds for the negator has no opfuncid, and
since COPY FROM never calls fix_opfuncids() on the clause, nothing
fills it in before the executor needs it. So
COPY tab FROM stdin WHERE NOT (a > 0)
fails with "cache lookup failed for function 0".
To fix, call fix_opfuncids() on the clause, as the relcache does
for index predicates.
Oversight in commit 31f3817402.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/asPZRTci4oBvxR9A%40nathan
Backpatch-through: 14
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/63e33d40b2ea6c6c8d179e2b8593a18a445aa08c
Modified Files
--------------
src/backend/commands/copy.c | 2 ++
src/test/regress/expected/copy2.out | 7 ++++++-
src/test/regress/sql/copy2.sql | 6 ++++++
3 files changed, 14 insertions(+), 1 deletion(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix COPY FROM ... WHERE for negated operators.
@ 2026-10-06 14:05 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 7+ messages in thread
From: Nathan Bossart @ 2026-10-06 14:05 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix COPY FROM ... WHERE for negated operators.
COPY FROM runs its WHERE clause through eval_const_expressions(),
which among other things replaces NOT above an operator with the
operator's negator, if it has one (e.g., NOT (a > 0) becomes
a <= 0). The node it builds for the negator has no opfuncid, and
since COPY FROM never calls fix_opfuncids() on the clause, nothing
fills it in before the executor needs it. So
COPY tab FROM stdin WHERE NOT (a > 0)
fails with "cache lookup failed for function 0".
To fix, call fix_opfuncids() on the clause, as the relcache does
for index predicates.
Oversight in commit 31f3817402.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/asPZRTci4oBvxR9A%40nathan
Backpatch-through: 14
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/95d9604471a319b6ccfd0a7d884fd604d3da5b20
Modified Files
--------------
src/backend/commands/copy.c | 2 ++
src/test/regress/expected/copy2.out | 7 ++++++-
src/test/regress/sql/copy2.sql | 6 ++++++
3 files changed, 14 insertions(+), 1 deletion(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix COPY FROM ... WHERE for negated operators.
@ 2026-10-06 14:05 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 7+ messages in thread
From: Nathan Bossart @ 2026-10-06 14:05 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix COPY FROM ... WHERE for negated operators.
COPY FROM runs its WHERE clause through eval_const_expressions(),
which among other things replaces NOT above an operator with the
operator's negator, if it has one (e.g., NOT (a > 0) becomes
a <= 0). The node it builds for the negator has no opfuncid, and
since COPY FROM never calls fix_opfuncids() on the clause, nothing
fills it in before the executor needs it. So
COPY tab FROM stdin WHERE NOT (a > 0)
fails with "cache lookup failed for function 0".
To fix, call fix_opfuncids() on the clause, as the relcache does
for index predicates.
Oversight in commit 31f3817402.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/asPZRTci4oBvxR9A%40nathan
Backpatch-through: 14
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/6b428e47b050bddb9316a53402fb19ac452c05bd
Modified Files
--------------
src/backend/commands/copy.c | 2 ++
src/test/regress/expected/copy2.out | 7 ++++++-
src/test/regress/sql/copy2.sql | 6 ++++++
3 files changed, 14 insertions(+), 1 deletion(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix COPY FROM ... WHERE for negated operators.
@ 2026-10-06 14:05 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 7+ messages in thread
From: Nathan Bossart @ 2026-10-06 14:05 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix COPY FROM ... WHERE for negated operators.
COPY FROM runs its WHERE clause through eval_const_expressions(),
which among other things replaces NOT above an operator with the
operator's negator, if it has one (e.g., NOT (a > 0) becomes
a <= 0). The node it builds for the negator has no opfuncid, and
since COPY FROM never calls fix_opfuncids() on the clause, nothing
fills it in before the executor needs it. So
COPY tab FROM stdin WHERE NOT (a > 0)
fails with "cache lookup failed for function 0".
To fix, call fix_opfuncids() on the clause, as the relcache does
for index predicates.
Oversight in commit 31f3817402.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/asPZRTci4oBvxR9A%40nathan
Backpatch-through: 14
Branch
------
REL_16_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/1955fd0b48e2a1251d0a6adb73f0cfd3e4b2a8b5
Modified Files
--------------
src/backend/commands/copy.c | 2 ++
src/test/regress/expected/copy2.out | 7 ++++++-
src/test/regress/sql/copy2.sql | 6 ++++++
3 files changed, 14 insertions(+), 1 deletion(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix COPY FROM ... WHERE for negated operators.
@ 2026-10-06 14:05 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 7+ messages in thread
From: Nathan Bossart @ 2026-10-06 14:05 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix COPY FROM ... WHERE for negated operators.
COPY FROM runs its WHERE clause through eval_const_expressions(),
which among other things replaces NOT above an operator with the
operator's negator, if it has one (e.g., NOT (a > 0) becomes
a <= 0). The node it builds for the negator has no opfuncid, and
since COPY FROM never calls fix_opfuncids() on the clause, nothing
fills it in before the executor needs it. So
COPY tab FROM stdin WHERE NOT (a > 0)
fails with "cache lookup failed for function 0".
To fix, call fix_opfuncids() on the clause, as the relcache does
for index predicates.
Oversight in commit 31f3817402.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/asPZRTci4oBvxR9A%40nathan
Backpatch-through: 14
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/1adbe902ac86214782f295dac137997b523aa926
Modified Files
--------------
src/backend/commands/copy.c | 2 ++
src/test/regress/expected/copy2.out | 7 ++++++-
src/test/regress/sql/copy2.sql | 6 ++++++
3 files changed, 14 insertions(+), 1 deletion(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix COPY FROM ... WHERE for negated operators.
@ 2026-10-06 14:05 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 7+ messages in thread
From: Nathan Bossart @ 2026-10-06 14:05 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix COPY FROM ... WHERE for negated operators.
COPY FROM runs its WHERE clause through eval_const_expressions(),
which among other things replaces NOT above an operator with the
operator's negator, if it has one (e.g., NOT (a > 0) becomes
a <= 0). The node it builds for the negator has no opfuncid, and
since COPY FROM never calls fix_opfuncids() on the clause, nothing
fills it in before the executor needs it. So
COPY tab FROM stdin WHERE NOT (a > 0)
fails with "cache lookup failed for function 0".
To fix, call fix_opfuncids() on the clause, as the relcache does
for index predicates.
Oversight in commit 31f3817402.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/asPZRTci4oBvxR9A%40nathan
Backpatch-through: 14
Branch
------
REL_14_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/c596e189dfbef330dae624abdcaf1bcdd82adadf
Modified Files
--------------
src/backend/commands/copy.c | 2 ++
src/test/regress/expected/copy2.out | 7 ++++++-
src/test/regress/sql/copy2.sql | 6 ++++++
3 files changed, 14 insertions(+), 1 deletion(-)
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2026-10-06 14:05 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-06 14:05 pgsql: Fix COPY FROM ... WHERE for negated operators. Nathan Bossart <nathan@postgresql.org>
2026-10-06 14:05 pgsql: Fix COPY FROM ... WHERE for negated operators. Nathan Bossart <nathan@postgresql.org>
2026-10-06 14:05 pgsql: Fix COPY FROM ... WHERE for negated operators. Nathan Bossart <nathan@postgresql.org>
2026-10-06 14:05 pgsql: Fix COPY FROM ... WHERE for negated operators. Nathan Bossart <nathan@postgresql.org>
2026-10-06 14:05 pgsql: Fix COPY FROM ... WHERE for negated operators. Nathan Bossart <nathan@postgresql.org>
2026-10-06 14:05 pgsql: Fix COPY FROM ... WHERE for negated operators. Nathan Bossart <nathan@postgresql.org>
2026-10-06 14:05 pgsql: Fix COPY FROM ... WHERE for negated operators. Nathan Bossart <nathan@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox