Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEWrI-0046vV-1U for pgsql-bugs@arkaria.postgresql.org; Sun, 19 Apr 2026 18:27:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEWrG-00Fs7U-0h for pgsql-bugs@arkaria.postgresql.org; Sun, 19 Apr 2026 18:27:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEWPH-00FlXH-1K for pgsql-bugs@lists.postgresql.org; Sun, 19 Apr 2026 17:58:07 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wEWPE-00000001nqm-2lwM for pgsql-bugs@lists.postgresql.org; Sun, 19 Apr 2026 17:58:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=JR1bPEJPqf6W9zgTW7vUzE4LJvfBlWfyZ/ABxr/zL1I=; b=AwE+oYE23skDnTPkIJbPxcWiF3 MJlDbPIxcXQKFBeqmnjAt2bguD8HaKlvh2bKKETbgRzYwCDJ4LNjEh1741M9WKNdFSTWBE/fSCKpB flwXDv6H9B5snOanOWPK6Ix9X56PhOEOgIXjo0rhwREGfW0cRNJ+aPd7rdBbl5dpnBIoXjBU+w8ou Sv81gvttPShteFfZxI7pxME3sYHXtAiIAkTVUgM+L+2B6mpk1+upUga4xSxAP5Qtj5tPMSZmCjqaH jsY6WaUobKWwvhkJuxml1WNPjjDFtU1cqFTC68hI6egkI060D+JYpUbO5z3ZbBHBTQB/4NXEWlwA7 M94OFfag==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEWPE-005LvY-0d for pgsql-bugs@lists.postgresql.org; Sun, 19 Apr 2026 17:58:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEWPC-00BvgJ-2s for pgsql-bugs@lists.postgresql.org; Sun, 19 Apr 2026 17:58:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19460: FULL JOIN rewriting issue on empty queries To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: francois.jehl@pigment.com Reply-To: francois.jehl@pigment.com, pgsql-bugs@lists.postgresql.org Date: Sun, 19 Apr 2026 17:57:59 +0000 Message-ID: <19460-5625143cef66012f@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19460 Logged by: Fran=C3=A7ois Jehl Email address: francois.jehl@pigment.com PostgreSQL version: 17.9 Operating system: Linux Description: =20 Good evening, After migrating from version 15 to 17.9, the following query fails with: ERROR: FULL JOIN is only supported with merge-joinable or hash-joinable join conditions This is weird because the FULL JOIN is a basic equi-join that succeeds on PG15 (we tested it; it also fails on 16). It requires a table t(id UUID PRIMARY KEY) but here is a repro on DbFiddle https://www.db-fiddle.com/f/hCq5S13Zs3EV8f86Mxxh3B/3. =20 SELECT COALESCE(lhs.id, rhs.id) AS id FROM (SELECT gen_random_uuid() AS id) AS lhs FULL OUTER JOIN ( SELECT sub.id FROM ( SELECT empty_source.id FROM (SELECT NULL::UUID AS id WHERE FALSE) AS empty_source LEFT OUTER JOIN ( SELECT t.id FROM t WHERE t.id =3D '26c5112c-0a8f-4315-9ff5-7dcb59b8359e'::UUID ) AS sub ON sub.id =3D empty_source.id ) AS sub ) AS rhs ON rhs.id =3D lhs.id; = = =20 Adding OFFSET 0 to the empty subquery on the RHS prevents the error, suggesting the query rewriter is doing something it should not! Another thing: removing the PK constraint on t.id, or removing/changing the WHERE filter to a non-PK column, makes the query succeed. The PK equality filter is required to trigger the failure (maybe because it generates some additional inlining, which then allows the empty subquery to collapse). We're happy to provide more context or test patches if helpful.