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.96) (envelope-from ) id 1vj6Ab-006VPZ-09 for pgsql-bugs@arkaria.postgresql.org; Fri, 23 Jan 2026 01:41:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vj6AY-00Fa3Q-0p for pgsql-bugs@arkaria.postgresql.org; Fri, 23 Jan 2026 01:41:02 +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.96) (envelope-from ) id 1vj6AX-00Fa3H-34 for pgsql-bugs@lists.postgresql.org; Fri, 23 Jan 2026 01:41:02 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vj6AW-000000002XZ-0c86 for pgsql-bugs@lists.postgresql.org; Fri, 23 Jan 2026 01:41:02 +0000 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-34c3259da34so959675a91.2 for ; Thu, 22 Jan 2026 17:40:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769132458; cv=none; d=google.com; s=arc-20240605; b=VCJuBeUy622ea81IUiDCj3fDikCq0mXjbNcD93eZhsI/qNCOlxpauOpu10XHrxdyOr t2xVDxwstv22lPGRpDDnF/Wvw8bQSTd9BLH4GsJO3SSpAxGTmgcRq4vnCMuOdv1eXyW5 /JVJbMMrN+8ZBfL82HEzIE5rc89udun01MNKfqlZUc0KJCOjMrLfWIYyxI5TCb0DyDEK uo/LldEE734RSyTDEup6MeTFEngMq0uWHd46TadaHTE1XehLlvqbWwK7qfPfvL78AsVT bJH600CYBYc/DGb4dWUSxAtWVkBTgwQBbaRpYiR9s1fq2Ib1UPYA2fsDFfVJkJgtUPHQ WHkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=J4MDGS04ub8xkEXIy6s0tRo5veU+kBTUn0QBsjoK+bM=; fh=kskUTpzMpwLoF1rGhmEO50uhkuKsVpsAYC6hP5AaQgY=; b=PioL9Rgki5RETMjIfC+NZMZI6tMX5jq77N/szg9ySuA5faTgCvBd9vfDdFVLvuUL4y VTEzjiaI6DQ3/0/IpUy8xxKqnOTkOkEEsyGbZvfkBBzCs6xDuNyoX6QNRlI/0XB33kYx s/MyCQK32erevl3K1GDg148Mmf9ZSiHi7RrMQQtJ8z4IPJ5CA2IIKInzwB1Njsh6sVFQ hLrcfC6icrk5piz6C1L6ppzQvYJKNi+6ACgxzBbkHxmCuoE6DdrxcPCkQsRbOwPu4xlP NhLYc4cRQaubvANKCw1CYF2leZBm5jARdGR6PRg7Ku8W2yEMoyO0hQMn9SPLfwfUN1Kt gx5w==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769132458; x=1769737258; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=J4MDGS04ub8xkEXIy6s0tRo5veU+kBTUn0QBsjoK+bM=; b=GQ+G3ZwvkVq9LfUPlELcAA37gbVl3ueZca1Bvb3JaabE2Nmfqa240jSd1Vf/xs31Dq EWQ319X93RKDqtdVPkDovinY9YgrQMjY8NN4GP5MSzQk14LdtObbnHNviW36kJKZcfde nQWNd5OZQi1lveIzw8qNvGGFkn6VaqRzciKCeCiV4fNLbCbubE4Ao2Bme5nJs0Yn+WiV dHag6aA4OC0GdHi21FEQHV7QGBWlhbA4NTpJi61IMqJhgTckvlUc1XMbmS66++PKspXE XNwt4MYCOf4H4oJjD4I9KuseJdOLe4FJlmPvtQNqR+stf29tv8VYTK21bBUdOMDVq3JZ 4WOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769132458; x=1769737258; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=J4MDGS04ub8xkEXIy6s0tRo5veU+kBTUn0QBsjoK+bM=; b=micllkt26L2LpCG18Vjn7EBhUcaQn/cJJZvfnwHhD44KnV/DvwhMibfKacwSfBOPr2 gIaJIe93Qs1wjtITig9wn0q4XVSu5HjcAmJ/01UnCto7MH9ELcPWJQcjgKJQxFa75kER yLUyEUs0ddGuEQfaHgYI4wH8y7AORbfTFQ4JPWN3FkoOGdC0qWcQ1dUyqYZO5RWHUZ7n 6J8kW6dzY+7vM0owo1X10aqLMKDkAYaVGJEccnLlWhzVuDZpKz7b3gSdJvPYkKo67/xL 0XHhp+DJCLPaITcxGcPF5wL8aYQsjClcMJMH2zbzR3q3D3TNGQX1geQ/gHJ+k9yMdGKI SMQQ== X-Forwarded-Encrypted: i=1; AJvYcCUG/EeRDvdY0FDL4YZcYV9CLuZyPkCkJEGdZnqrd8d1bYhJArLSJNr11LXLSQFN3tU3HbbKXOEqa6J3@lists.postgresql.org X-Gm-Message-State: AOJu0Ywb2NDaIA5HEEkuB+KQgOJH3xsKXPCdTGVhBidOKpe90jn3DFqz 5Ru0u9mPBolZJoSwgrVuFIBEOZIoRPw2C5Ud9KWA0k2ElWU7t/TWc+CESV1sCKDoCkNzPjf6HJh l8PMaqJMnOP4S2rQW+8sbJzbwtvPWb6U= X-Gm-Gg: AZuq6aKjKSibWiLo8nd9jcY665ty/zqQ09viyOhMGwOhHvlYFWLsMGNq1RVROQ/OKgo BPnDKgYss72BbB09uwXkFWTtcAaviXy7WkEfygRGcLbCqYDpYM4nnkSvUFug+sv+7KkmzdqWVq2 YpaBkebGyBNJ2TmlyUnXdoqnTACrQqoG47+rmzhjuIcgWCF5Fcgdjw27A1paOU07+ArgtTmfZZi gGiwSo+SjdVfjWyXt+kd6Obopf6jcr3Tdk+n87B14+eIUEfjgVlwOovn1+V+b1Uo0J9+3qY X-Received: by 2002:a17:90b:3bc7:b0:352:cdda:7aa7 with SMTP id 98e67ed59e1d1-35368b40052mr1014808a91.24.1769132457824; Thu, 22 Jan 2026 17:40:57 -0800 (PST) MIME-Version: 1.0 References: <19099-e05dcfa022fe553d@postgresql.org> <2960545.1761800903@sss.pgh.pa.us> <3017911.1761832112@sss.pgh.pa.us> <1112704.1768847117@sss.pgh.pa.us> In-Reply-To: From: Amit Langote Date: Fri, 23 Jan 2026 10:40:41 +0900 X-Gm-Features: AZwV_Qg59z1A08uAsNj1DuCF0MkNbVAWseqAe6vJ9p7wlff8e__e0_n__E-kCC4 Message-ID: Subject: Re: BUG #19099: Conditional DELETE from partitioned table with non-updatable partition raises internal error To: Tom Lane Cc: Tender Wang , David Rowley , Kirill Reshke , jian he , Alexander Lakhin , PostgreSQL mailing lists Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jan 21, 2026 at 9:58=E2=80=AFPM Amit Langote wrote: > On Tue, Jan 20, 2026 at 12:07=E2=80=AFPM Amit Langote wrote: > > On Tue, Jan 20, 2026 at 3:25=E2=80=AFAM Tom Lane wr= ote: > > > Amit Langote writes: > > > >> To summarize, the two approaches we've thought about: > > > >> > > > >> 1. Executor-side fix > > > >> (v4-0001-Fix-bogus-ctid-requirement-for-dummy-root-partiti.patch > > > >> posted with my Nov 8 email): > > > >> > > > >> Make ExecInitModifyTable() not require ctid when the only result > > > >> relation is a dummy partitioned root. This is minimally invasive b= ut > > > >> leaves EXPLAIN VERBOSE output inconsistent depending on > > > >> enable_partition_pruning -- with pruning off, you see tableoid but= no > > > >> ctid, while with pruning on, you see ctid. That's confusing for us= ers > > > >> as mentioned upthread. > > > >> > > > >> 2. Planner-side fix > > > >> (v4-0001-Fix-row-identity-handling-for-dummy-partitioned-r.patch > > > >> posted with my last email): > > > >> > > > >> Don't add tableoid for child relations that don't contribute > > > >> row-identity columns. This keeps root->row_identity_vars empty whe= n > > > >> there exists only one such child relation, so > > > >> distribute_row_identity_vars() can add ctid for the dummy root. > > > >> EXPLAIN output is consistent regardless of pruning setting. (Some= may > > > >> notice in the patch that there's still a minor change, but that's = due > > > >> to how explain.c decides whether to print the table name before th= e > > > >> column name, which is unrelated to this.) > > > >> > > > >> I'm inclined to go with the second approach. The only back-patchin= g > > > >> concern is that EXPLAIN VERBOSE output order changes (ctid now app= ears > > > >> before tableoid). This is cosmetic -- junk columns are looked up b= y > > > >> name, not position -- but could affect tests or tools that parse > > > >> EXPLAIN output by position. > > > >> > > > >> If there are no objections, I'll commit patch #2 next week. > > > > > > > Tom, do you have any thoughts on the above? > > > > > > My apologies, I allowed this thread to fall off my radar. > > > > > > Of these two patches, I greatly prefer the executor-side fix. > > > I think the planner-side fix is much too invasive to consider > > > back-patching. Even if it doesn't bother any end users, > > > it will surely break some extensions' regression tests, > > > considering how many places it changes in our own tests. > > > > Ok, a fair point. > > > > > Also, I think the argument about preserving the same generated > > > tlist is fairly misguided, for two reasons: > > > > > > 1. We've never expected that the set of row-identity columns would > > > be independent of the set of child tables considered. For example, > > > different FDWs might produce different sorts of row-ID Vars. > > > > > > 2. EXPLAIN's output for a partitioned query is usually different > > > between pruning-on and pruning-off. Why's it important that > > > this tlist detail not be different? > > > > Right, the targetlist will look different if a foreign child is pruned > > vs not anyway. I was maybe too focused on this degenerate case where > > all children are excluded -- with pruning off you get tableoid but no > > ctid (because the foreign child was processed before constraint > > exclusion, leaving root->row_identity_vars non-empty triggering the > > block in distribute_row_identity_vars() to add ctid), with pruning on > > you get ctid but no tableoid (because the child was never processed, > > leaving root->row_identity_vars empty). > > > > Because, the degenerate case is a no-op at runtime, maybe we're ok. > > > > > So on the whole, I'd do #1 and call it good. I don't even see an > > > argument for applying #2 in HEAD only. > > > > Ok, I'll post an updated patch for #1 shortly. > > Updated patch attached. While reworking it, I realized that > partitioned tables should only appear in the result relations list > when all leaf partitions have been pruned. So instead of checking > nrels > 1, I now Assert(nrels =3D=3D 1) when we see a partitioned table > and skip the ctid requirement. Also added a corresponding adjustment > in ExecModifyTable() to allow invalid ri_RowIdAttNo for partitioned > tables. Pushed this now. Thanks to all. --=20 Thanks, Amit Langote