BUG #19966: FULL JOIN testing a NOT NULL column with IS NULL fails in 19, works in 18

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: aman(at)stack-auth(dot)com
Subject: BUG #19966: FULL JOIN testing a NOT NULL column with IS NULL fails in 19, works in 18
Date: 2026-12-01 23:50:43
Message-ID: 19966-c1d36223d8d7e4b7@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19966
Logged by: Aman Ganapathy
Email address: aman(at)stack-auth(dot)com
PostgreSQL version: 19.0
Operating system: Debian 13 (trixie), aarch64
Description:

A FULL JOIN that runs on 18.7 fails on 19.0 with "FULL JOIN is only
supported with merge-joinable or hash-joinable join conditions" when its
join condition uses IS NULL on a NOT NULL column. After dropping the NOT
NULL constraint, the same query runs on 19.0 too.

Setup: the official postgres:19.0 Docker image, started with

docker run -d --name pg19 -e POSTGRES_HOST_AUTH_METHOD=trust \
-e POSTGRES_INITDB_ARGS="--locale=C.UTF-8 --encoding=UTF8" -e TZ=UTC \
postgres:19.0 postgres -c log_error_verbosity=verbose

and postgres:18.7 the same way.

Test case, run with "psql -X" in a new, empty database:

\set VERBOSITY verbose
CREATE TABLE a (id int NOT NULL);
CREATE TABLE b (id int);
INSERT INTO a VALUES (1), (2);
INSERT INTO b VALUES (1), (NULL);
SELECT * FROM a FULL JOIN b ON (a.id IS NULL) = (b.id IS NULL);
ALTER TABLE a ALTER COLUMN id DROP NOT NULL;
SELECT * FROM a FULL JOIN b ON (a.id IS NULL) = (b.id IS NULL);

Output on 19.0 (psql -X -a -q, so each statement is shown above its result):

\set VERBOSITY verbose
CREATE TABLE a (id int NOT NULL);
CREATE TABLE b (id int);
INSERT INTO a VALUES (1), (2);
INSERT INTO b VALUES (1), (NULL);
SELECT * FROM a FULL JOIN b ON (a.id IS NULL) = (b.id IS NULL);
ERROR: 0A000: FULL JOIN is only supported with merge-joinable or
hash-joinable join conditions
LOCATION: populate_joinrel_with_paths, joinrels.c:1198
ALTER TABLE a ALTER COLUMN id DROP NOT NULL;
SELECT * FROM a FULL JOIN b ON (a.id IS NULL) = (b.id IS NULL);
id | id
----+----
1 | 1
2 | 1
|
(3 rows)

Output on 18.7:

\set VERBOSITY verbose
CREATE TABLE a (id int NOT NULL);
CREATE TABLE b (id int);
INSERT INTO a VALUES (1), (2);
INSERT INTO b VALUES (1), (NULL);
SELECT * FROM a FULL JOIN b ON (a.id IS NULL) = (b.id IS NULL);
id | id
----+----
1 | 1
2 | 1
|
(3 rows)

ALTER TABLE a ALTER COLUMN id DROP NOT NULL;
SELECT * FROM a FULL JOIN b ON (a.id IS NULL) = (b.id IS NULL);
id | id
----+----
1 | 1
2 | 1
|
(3 rows)

Expected: the first SELECT returns the 3 rows that 18.7 returns, as the
second SELECT does after DROP NOT NULL.

The same error on master at b4cc5e924b7 (2026-11-25), built with
--enable-debug --with-icu --enable-cassert.

Environment: PostgreSQL 19.0 (Debian 19.0-2.pgdg13+1) on
aarch64-unknown-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0,
64-bit; psql 19.0 (Debian 19.0-2.pgdg13+1). PostgreSQL 18.7 (Debian
18.7-1.pgdg13+5), same compiler. Debian 13 (trixie) in the images, Linux
7.0.14 aarch64, glibc 2.41, 14 CPUs, 16 GB RAM, running in an OrbStack
VM on macOS 15.7.9 (Apple Silicon).

Trying to work on a patch but don't have a fix as of yet.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message shihao zhong 2026-12-02 00:55:34 Re: Hot Standby: missing snapshot conflicts in CREATE INDEX, rewrite, hash
Previous Message PG Bug reporting form 2026-12-01 23:20:22 BUG #19965: btree_gist index on timetz returns too few rows for <, > and <>