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 1w2Rky-000IYi-38 for pgsql-bugs@arkaria.postgresql.org; Tue, 17 Mar 2026 10:34:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2Rkx-000L9c-2t for pgsql-bugs@arkaria.postgresql.org; Tue, 17 Mar 2026 10:34:35 +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 1w2AEi-00Axrj-0t for pgsql-bugs@lists.postgresql.org; Mon, 16 Mar 2026 15:52:09 +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 1w2AEf-000000002Aq-25d6 for pgsql-bugs@lists.postgresql.org; Mon, 16 Mar 2026 15:52:08 +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=U4eiSKC2WGvUZZ0vLoVE+z4Jpd63m5E7Geu9wEAAd7U=; b=zidx44t9AHXOChZrTUf2pRDNA4 D4E6xz7RMgzrwXy304y/F2Go33PpKu2tB7z64TBTG/RdSHfMVGyzZ3uRP0oGah8SYhEvheNaGuUKl bFjHPUW/UXTaJ1ndTdklQtkTu+BJuQOWeevX6EaDr+hP/ghBe2I3BCi0SIMkJDWxsyPMByG8n74Za rPJhcW1egCE8OT4fSX/PfV+PtKFZyUlDXZr+y7Gmv4I4ustqBDtQH874BQfDqR0xmEEL26ta8YImA 5i1BX55IwCxFWX1miwnR3qiLLsec9JBvR9A7YiPFmAtx6SIflTD5KXr5IoP8y6jy/60XOVcKc/vxD 9LihGtkg==; 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 1w2AEe-0005xA-1z for pgsql-bugs@lists.postgresql.org; Mon, 16 Mar 2026 15:52:06 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2AEd-002Q5u-18 for pgsql-bugs@lists.postgresql.org; Mon, 16 Mar 2026 15:52:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19435: Error: "No relation entry for relid 2" Triggered by Complex Join with Self-Referencing Tables To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: ammmkilo@163.com Reply-To: ammmkilo@163.com, pgsql-bugs@lists.postgresql.org Date: Mon, 16 Mar 2026 15:51:30 +0000 Message-ID: <19435-3cc1a87f291129f1@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: 19435 Logged by: Hang ammmkilo Email address: ammmkilo@163.com PostgreSQL version: 18.3 Operating system: Ubuntu 22.04 Description: =20 A user encountered an error when attempting to execute a query involving multiple RIGHT JOIN operations and a NATURAL JOIN on the same table (pg_table_a). The error message returned was: [XX000]ERROR: no relation entry for relid 2 This error seems to be an internal one and should not be triggered by users. It might be a bug. ```sql DROP TABLE IF EXISTS pg_table_a; CREATE TABLE pg_table_a ( id INTEGER PRIMARY KEY, col_bool BOOLEAN ); INSERT INTO pg_table_a (id, col_bool) VALUES (5, TRUE); SELECT 1 AS c1 FROM ( pg_table_a AS tom0 RIGHT JOIN ( (pg_table_a AS tom1 NATURAL JOIN pg_table_a AS tom2) RIGHT JOIN pg_table_a AS tom3 ON tom1.col_bool IS NOT NULL ) ON tom1.col_bool ); ```