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.98.2) (envelope-from ) id 1xRYdt-000000014un-22iA for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Nov 2026 17:31:21 +0000 Received: from localhost ([127.0.0.1]:47716 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xRYds-0000000450q-0k0C for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Nov 2026 17:31:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]:48560) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR95Y-0000000BUtr-1EDR for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 14:14:12 +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 1xR95X-00000000NsR-0yxo for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 14:14:11 +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=BSvaC3Swijwj6egNqDzWnFSmHT+64mJ6yHqq13nV2eQ=; b=FzkaXvQ74CXorx+1BJYM7K1nnJ Qk5AK/PT16jWS4yoGhcabAsYRTmHISRQMSJqGxu3MpXHiK55dSvtdwu75JJgb15ZMcceInRQl5M9u kOYnHFJahOPnQr1Pcb2l11K1HCcm1Zx1jLnJx3H/T02ZvJtAyhdm+g04LDtFvk2A+YGa27ZZKhN1P gh02BDA62D0qX+YDVXhUOeSKg4DYJ/P+3BnjEo9DQ8lgpZod1lOngequUE5fQz9BjVKDRF3jT5CbP Jb6D6bO7w2DEK1Lk0bl7NHsFZbYlkCgrv47UpWNA05gxvjKVy3qBjbWMPTY10iX3TCapVEqH6aXoC UAedlvQw==; 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.98.2) (envelope-from ) id 1xR95Q-000000013eR-2Wbq for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 14:14:10 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xR95P-00000002kC9-3YnY for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 14:14:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19884: pg_publication_tables omits a detach-pending partition in root mode To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: 1548140642@qq.com Reply-To: 1548140642@qq.com, pgsql-bugs@lists.postgresql.org Date: Wed, 11 Nov 2026 14:13:50 +0000 Message-ID: <19884-3b4fbbdf292f33f1@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: 19884 Logged by: Milo Email address: 1548140642@qq.com PostgreSQL version: 18.6 Operating system: Linux/amd64 Description: =20 After phase one of ALTER TABLE ... DETACH PARTITION CONCURRENTLY, pg_publication_tables omits the detach-pending child from an ALL TABLES publication when publish_via_partition_root is enabled. At that point the child has no ancestors and is treated as a standalone relation for publication purposes, so it should appear in the view. The query instead returns zero rows. How to repeat: Save this as reproducer.sql and run it with psql -X -f reproducer.sql: DROP PUBLICATION IF EXISTS pub_root; DROP TABLE IF EXISTS parent_tbl CASCADE; DROP TABLE IF EXISTS child_tbl; CREATE EXTENSION dblink; CREATE TABLE parent_tbl (id integer) PARTITION BY RANGE (id); CREATE TABLE child_tbl PARTITION OF parent_tbl FOR VALUES FROM (0) TO (100); INSERT INTO parent_tbl VALUES (1); CREATE PUBLICATION pub_root FOR ALL TABLES WITH (publish_via_partition_root =3D true); SELECT dblink_connect('detacher', 'dbname=3D' || current_database()); SELECT dblink_connect('observer', 'dbname=3D' || current_database()); BEGIN ISOLATION LEVEL REPEATABLE READ; SELECT count(*) FROM parent_tbl; SELECT dblink_send_query( 'detacher', 'ALTER TABLE parent_tbl ' 'DETACH PARTITION child_tbl CONCURRENTLY'); DO $wait$ DECLARE pending boolean :=3D false; BEGIN FOR attempt IN 1..200 LOOP SELECT x.pending INTO pending FROM dblink( 'observer', $$SELECT inhdetachpending FROM pg_catalog.pg_inherits WHERE inhrelid =3D 'child_tbl'::regclass$$) AS x(pending boolean); EXIT WHEN pending; PERFORM pg_sleep(0.025); END LOOP; IF NOT pending THEN RAISE EXCEPTION 'concurrent detach did not reach pending state'; END IF; END $wait$; SELECT dblink_cancel_query('detacher'); SELECT * FROM dblink_get_result('detacher', false) AS x(status text); COMMIT; SELECT i.inhdetachpending FROM pg_catalog.pg_inherits AS i WHERE i.inhrelid =3D 'child_tbl'::regclass; SELECT count(*) AS visible_in_root_publication FROM pg_catalog.pg_publication_tables WHERE pubname =3D 'pub_root' AND tablename =3D 'child_tbl'; SELECT dblink_disconnect('detacher'); SELECT dblink_disconnect('observer'); ALTER TABLE parent_tbl DETACH PARTITION child_tbl FINALIZE; DROP PUBLICATION pub_root; DROP TABLE parent_tbl; DROP TABLE child_tbl; DROP EXTENSION dblink; The decisive output is: inhdetachpending ------------------ t (1 row) visible_in_root_publication ----------------------------- 0 (1 row) The second value should be 1 because the detach-pending child has no ancestors and therefore belongs in the root-mode publication as a standalone table. The result appears to come from publication membership relying on the partition catalog flag rather than the relation's effective ancestry while detach is pending. The issue was reproduced on PostgreSQL 18.6 on Linux/amd64. The run emitted the warning that wal_level was insufficient to publish logical changes; the publication and catalog-view query nevertheless completed. This occurs when an interrupted concurrent partition detach is inspected through publication membership with publish_via_partition_root enabled.