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.94.2) (envelope-from ) id 1uDvPg-0002YY-64 for pgsql-hackers@arkaria.postgresql.org; Sun, 11 May 2025 01:23:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uDvPd-006wAf-VI for pgsql-hackers@arkaria.postgresql.org; Sun, 11 May 2025 01:23:29 +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.94.2) (envelope-from ) id 1uDvPd-006wAX-9M for pgsql-hackers@lists.postgresql.org; Sun, 11 May 2025 01:23:29 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uDvPa-001C7W-0P for pgsql-hackers@lists.postgresql.org; Sun, 11 May 2025 01:23:27 +0000 Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 91A7025400CF; Sat, 10 May 2025 21:23:25 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Sat, 10 May 2025 21:23:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1746926605; x=1747013005; bh=t d3gAfKl/Nhn/X096CnC1iyLY+2rw/8Ycy9snbV1REo=; b=dN7v2QbRjq2GB77lI CtVom/7KZUUVqYNnh4Rp9RZ0stwQgvBCA+B8W2qkqkvd4jDKb6S3ElyKftOxp8mh ssiwieJ2otbnntxUAvGYsGwQ00un56Xs2IrXzS0SHXEyrBkP+jkYFjaIcD5NHaTR vqoJbPEff89Bcvsu+Yk3QYLFL8jc59StIJuPTkcoAjaROFa6pOwtnS1EvxiUSD3b cu8z27Avz4DaESAYq8yYKbgPE9Amo3zHZle0yE3u4Bn8nGevxwow03/b+nu3zUwj bs8F29u/mDRwJAbuk5iCTt96/whA80dLowlKD4DyfpEMO1GZFApKwPcVSZO61CQs W/WuQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvleejtdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepfffhvfevuffkgggtugfgjgesthekredttddt jeenucfhrhhomheplmhlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlh hvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepvdehueffhefgueekueef heehgffhuefgfedukeejveduffegffekgeffffevgeehnecuffhomhgrihhnpegvnhhtvg hrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhnsg gprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehshhhlohhk rdhkhigrlhdrohhsshesghhmrghilhdrtghomhdprhgtphhtthhopehvihhgnhgvshhhvd dusehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhi shhtshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepshdrthgrthgrrhhinh htshgvvhesphhoshhtghhrvghsphhrohdrrhhu X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 10 May 2025 21:23:24 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1746899967; bh=Se7VHZ+Uqh5smPnsoPRrpenPT1I3hzGhNpIKqRfhzCk=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=obZRhjdYojLBmLFf1+/n9vcibxNAAUfuc/feWldcJEikdwvk8zOP4vQfEahHD5+Ph cTgkM7Vj4czePpuNCihrrYeGbhPKy5bj4zZn24QZB4HyvtgBf+aZ5ZKuvInz2DHMev 0apZGYjjvLv7B4Tyq1/TqETbFrvB3yEQHtzqLgeBUFMikzff9GR+2p11HHhSFiFA4m YOtY7gy/yz2WzssbAjgVspXDkdlxuKvNPeaO3N4trPu//KwjOyypaj7+J8Z4NKHLr3 6MSYSINCQMfmgEidEUoUq+PCHsHhDNJsDJ2wnFdqJD0NLyIcg/g02GErrgq1xPES0m KNpK6TDjK6LCg== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id B89758F; Sat, 10 May 2025 19:59:27 +0200 (CEST) Date: Sat, 10 May 2025 13:59:27 -0400 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Shlok Kyal Cc: vignesh C , Sergey Tatarintsev , pgsql-hackers@lists.postgresql.org Subject: Re: Restrict publishing of partitioned table with a foreign table as partition Message-ID: <202505101759.6qlloepaeddl@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, I think reimplementing list_member_oid() under a different name (is_ancestor_member_relids) is pointless and should not be done. It also appears to me that we haven't nailed the error messages just yet. I tried to fix it upthread, but didn't really get it correct. For instance, consider this case taken from the new regression tests: /* test setup */ CREATE SCHEMA sch3; CREATE TABLE sch3.tmain(id int) PARTITION BY RANGE(id); CREATE TABLE sch3.part1 PARTITION OF sch3.tmain FOR VALUES FROM (0) TO (5); CREATE TABLE sch3.part2(id int) PARTITION BY RANGE(id); CREATE FOREIGN TABLE sch3.part2_1 PARTITION OF sch3.part2 FOR VALUES FROM (5) TO (10) SERVER fdw_server; ALTER TABLE sch3.tmain ATTACH PARTITION sch3.part2 FOR VALUES FROM (5) TO (10); The issue occurs in the next command: CREATE PUBLICATION pub1 FOR TABLE sch3.tmain WITH (publish_via_partition_root); ERROR: cannot add partitioned table "tmain" to publication "pub1", which has "publish_via_partition_root" set to "true" DETAIL: The table contains a partition that's a foreign table. The user is trying to create a publication, so an error saying that it's not possible to add a partition is a bit off-point. (If you squint hard enough it sort of makes sense, but it seems inconsistent enough.) We could replace the word "add" with the word "include" there and this particular problem would be fixed, perhaps. However, the next one is worse: CREATE PUBLICATION pub1 FOR ALL TABLES WITH (publish_via_partition_root); ERROR: cannot set parameter "publish_via_partition_root" to "true" for publication "pub1" DETAIL: Published partitioned table "tmain" contains a partition that is a foreign table. Here we again try to create a publication, but we get an error that we cannot set the parameter, which is even more detached from reality. Maybe what we need is to add another parameter to that function to indicate which operation is being executed (create publication, add schema, change the parameter), which is used to indicate the error message to throw. With that thought in mind, I think it would make things simpler for us to remove the duplicate copies of the same error messages by adding yet another function, after publication_check_foreign_parts(), which receives the operation being executed and whatever additional parameter it needs, and throws the error. If publication_check_foreign_parts() also receives the operation being executed, it can simply pass it through to that new function when an error needs to be thrown; other places that hardcode error situations would pass a constant for the operation. But the non-idiomatic locking of pg_partitioned_table appears to continue to be the pain point of this patch. My impression is that using a lock is the wrong approach to solve the concurrency problem. Maybe we can use a ConditionVariable instead somehow. (The real trick here is to figure out exactly _how_ to use the CV, I mean what exactly is the condition that the CV sleeps on?) -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "Industry suffers from the managerial dogma that for the sake of stability and continuity, the company should be independent of the competence of individual employees." (E. Dijkstra)