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 1u6ucv-007acK-Kd for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Apr 2025 17:08:13 +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 1u6uct-0078ml-Nj for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Apr 2025 17:08:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u6uct-0078md-FB for pgsql-bugs@lists.postgresql.org; Mon, 21 Apr 2025 17:08:12 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u6ucq-001GED-2F for pgsql-bugs@postgresql.org; Mon, 21 Apr 2025 17:08:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 53LH85bx769271; Mon, 21 Apr 2025 13:08:05 -0400 From: Tom Lane To: Kirill Reshke cc: pgsql-bugs@postgresql.org, Alvaro Herrera Subject: Re: Command order bug in pg_dump In-reply-to: <592472.1745247403@sss.pgh.pa.us> References: <592472.1745247403@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 21 Apr 2025 10:56:43 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <769269.1745255285.1@sss.pgh.pa.us> Date: Mon, 21 Apr 2025 13:08:05 -0400 Message-ID: <769270.1745255285@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > I don't think this is pg_dump's fault: there is no such constraint > when the ALTER TABLE starts. Something inside the ALTER TABLE > recursion seems to be messing up if there is already another > similar FK constraint. Oh, I see what's happening. We create both the specified constraint and an inherited child constraint on the named partitioned table. If tt_a_fkey is added first, the name chosen for its child is "tt_i_fkey", breaking the later attempt by the user to use that name. Apparently there is some hack in psql to not show that child constraint entry, because you don't see it in \d output, which is what confused me before (and would confuse most people hitting this). We could fool around with the generation rule for the child constraint's name, but fundamentally we're infringing on user namespace here, so I think that's likely to just move the problem cases around. Why do we need this child pg_constraint entry at all? If we can't avoid having it, probably choosing a name like "tt_a_fkey1" would be marginally less likely to cause trouble ... but only marginally. In any case, it's pretty awful that we make these entries but \d does not show them. regards, tom lane