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 1vET17-00BzDZ-LX for pgsql-bugs@arkaria.postgresql.org; Thu, 30 Oct 2025 13:48:40 +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 1vET15-008a1e-O5 for pgsql-bugs@arkaria.postgresql.org; Thu, 30 Oct 2025 13:48:38 +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 1vET15-008a1V-BF for pgsql-bugs@lists.postgresql.org; Thu, 30 Oct 2025 13:48:38 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vET11-004ZV5-30 for pgsql-bugs@lists.postgresql.org; Thu, 30 Oct 2025 13:48:37 +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 59UDmW4M3017912; Thu, 30 Oct 2025 09:48:32 -0400 From: Tom Lane To: Kirill Reshke cc: Tender Wang , Amit Langote , jian he , exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19099: Conditional DELETE from partitioned table with non-updatable partition raises internal error In-reply-to: References: <19099-e05dcfa022fe553d@postgresql.org> <2960545.1761800903@sss.pgh.pa.us> Comments: In-reply-to Kirill Reshke message dated "Thu, 30 Oct 2025 18:31:09 +0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3017910.1761832112.1@sss.pgh.pa.us> Date: Thu, 30 Oct 2025 09:48:32 -0400 Message-ID: <3017911.1761832112@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Kirill Reshke writes: > Tom wrote: >> It's surely pretty accidental (and arguably not desirable) >> if "DELETE FROM pt WHERE false" doesn't fail the same way. > I cannot prove to myself why failing here is actually desirable. Can > you elaborate? If we throw that failure in some cases but not others, we're exposing implementation details. The definition could have been "throw 'cannot delete from foreign table' only if the query actually attempts to delete some specific row from some foreign table", but it is not implemented that way. Instead the error is thrown during query startup if the query has a foreign table as a potential delete target. Thus, as things stand today, you might or might not get the error depending on whether the planner can prove that that partition won't be deleted from. This is not a great user experience, because we don't (and won't) make any hard promises about how smart the planner is. An analogy perhaps is that whether you get a "permission denied" error about some target table is not conditional on whether the query actually attempts to delete any rows from it. We go out of our way to make sure that that happens when required by spec, even if the planner is able to prove that no delete will happen. None of this is meant to justify throwing an internal error here; that's clearly bad. I'm just saying that there would be little wrong with fixing it by throwing "cannot delete" instead. The user has no right to expect that that won't happen in a case like this. regards, tom lane