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 1sN9lI-0075z0-6l for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Jun 2024 11:27:28 +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 1sN9lG-003pzf-9D for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Jun 2024 11:27:26 +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 1sN9lF-003pzX-4r for pgsql-bugs@lists.postgresql.org; Fri, 28 Jun 2024 11:27:26 +0000 Received: from fhigh1-smtp.messagingengine.com ([103.168.172.152]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sN9lC-003XV3-EW for pgsql-bugs@lists.postgresql.org; Fri, 28 Jun 2024 11:27:24 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 5279411403C4; Fri, 28 Jun 2024 07:27:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 28 Jun 2024 07:27:20 -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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1719574040; x= 1719660440; bh=lLkjg0JkiXkTbC+Rgo3rvkUrkOFmHJyUgtEh+1jms7M=; b=T bQk+TKEr3ER9w9CR2XoEwAf13zF/eVmBg8o4fZcn913+v4ItekJd9nuHKVr6oGqG uMCF7utUNSjKYTStsOhILQjoia77aUQxU3j2R7JhOVYFSTsX+coO3EpuNvYQ34DU AvvpqE9dIySeBPo7U+qiVMbIDCTxpcC7KaB5be04OxYFGcXSH/imHcj+05Du54hl xNPN+ALxOD2Meq5/T8guA67lxYgaz0CXqHW7kjXtJtD2R1oCNkIR5A/LV0zJXbey 0pjUT5LuAuHBm01qAcf20hFiogZYSmhb0mVbnCLeWohi+ak9PUpp3xOB8B6g72WG 57Qo42bd5IVnW5gd/ib0Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrtdeigdeflecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehmkeerredttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpeduleekkefgtddttedtkefguddvieffleetgeejiefhteeh keevfeettdduvdfhueenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 28 Jun 2024 07:27:19 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1719574037; bh=XT81MzYrRe7uuNsL/Fn6PXfnZrg2hTRC8qP2da8QFT4=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=YkhUVhDZ29R/8JLSJORENzZjZXpAs1OWpPy68ZqQqdg4RgPRXNf2HmhSMgX7DLguU aTHQZm+tIIgOUZ00wqkhfi1APS/Whdg+7efNcO8N62PITm5aFl9d+aYDoy5UmRx0nU 4OXf5MT0+La4K57vcLPr05u+CsUGY5WyBnNX15GkrUpEO1VxdUcVhwVXyFxaB7nEhB GtP/ByYOEkBSj0ztYyR6cNiUcRXTfYZBKQvhh/A2tDTJfOE2rryKqkoNU7q/wcj+KL j/JqL73vXjQLk0gdButECMyLt3S5BK4OUL0eL6kpzdtsH2xcY1IwrCzL6nwnjoH/Sj Cshu8LEzL0smw== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 678DC52B; Fri, 28 Jun 2024 04:27:17 -0700 (PDT) Date: Fri, 28 Jun 2024 13:27:17 +0200 From: Alvaro Herrera To: Tender Wang Cc: Michael Paquier , exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18500: Detaching a partition with an index manually attached to the parent's index triggers Assert Message-ID: <202406281127.piekjwgnulgf@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="q72ne4r752oxakpn" 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 --q72ne4r752oxakpn Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2024-Jun-12, Tender Wang wrote: > I think what you said above. I feel that we need that "tp_pkey" is a > partition > of the partitioned index "t_a_idx". For example, below statement: > > test=# alter table tp drop constraint tp_pkey; > ERROR: cannot drop index tp_pkey because index t_a_idx requires it > HINT: You can drop index t_a_idx instead. > > If "tp_pkey" is not a partition of "t_a_idx", the primary key "tp_pkey" can > be dropped. I guess you could also fix this by adding a PK constraint to the parent table, so that the situation is consistent in the other direction. Here's a proposed patch for master only. It turns all three situations being reported into ereport(ERROR); in one case I have an XXX comment, because we have an alternative when attaching a partition that already has a PK to a partitioned table that has a non-PK index: just create a separate index in the partition. But that would cause slowness, which is probably undesirable. I'm inclined to just remove the XXX comment, but if anyone has other thoughts, they are welcome. I add an errhint() to one of these new errors, but I'm undecided about that idea --- should we add errhint() to all three messages, or none? We can't do this in back branches, of course (incl. 17 at this point), because that might break existing applications, which means we need to adjust behavior in some other way, probably similar to what Tender Wang suggested, namely just don't crash on detach, or something like that. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ --q72ne4r752oxakpn Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v2-0001-WIP-don-t-let-constraint-indexes-attach-to-raw-in.patch"