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 1vEeHi-00EvUT-V5 for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Oct 2025 01:50:34 +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 1vEeHh-00BXA5-7X for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Oct 2025 01:50:32 +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 1vEeHg-00BX9x-V9 for pgsql-bugs@lists.postgresql.org; Fri, 31 Oct 2025 01:50:31 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vEeHe-004eqK-1H for pgsql-bugs@lists.postgresql.org; Fri, 31 Oct 2025 01:50:31 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-592fb80c2faso2191527e87.2 for ; Thu, 30 Oct 2025 18:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761875427; x=1762480227; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YvXLpgrUJQyXIYbQ4VyR+0jCrlG7bCO6EGLg2joPL4w=; b=kl7xT+j07xRP950m+ayO2ldqAPUXJz/os38tk0lGlhiM++1LlWBWAYOEnzCgmp6y+c KJY913eRWMLDbeG8AAi5WSGV4aS7tj29iWigCbtmQaTiwE2uNbTs0WIW9ha/GZ2OPbGe JN+8w0Ie46/sud+jplO9p3DOB7DE7Rd1JQQ/HqOet80c9myv/gegzlJLMvhDbe3lxY0h 5qcU3IcHODWMtttpRw87uz+e/vf/qc0fZmBzl0flUPzb0oyzd1+VMudZ0lb6qEkvtjcj u5gQAIqI781/ibltPaaF87oOoXhCf+zzb6eTWdxIcX0GnnCJ27qokxRd7jZZne8lJzdm niYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761875427; x=1762480227; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YvXLpgrUJQyXIYbQ4VyR+0jCrlG7bCO6EGLg2joPL4w=; b=FcTSIDKdRbZbom0OxlTmWdScHm/sQ4+uxNQM3pOBIHSjrClzekyBVVCaAga9xvA6+T pjMcF19cvgFPVy/gPbSNBN8+QWTfoB0OMv0cqVa9OlksoHbbv36py1+V+nGpCjvcUs/e 2wCuU7EAIsb4S4/Sp55/tzUEn3EL60k4dS1RPlEPsemWaDeTRiKlGxh4O0EuQ0jP+4zz fUXEwQfFgZ8KQD19kq0P9IkZxcj8OiUxO6W4X1IoO0qz1amCbmsW5Bevhdej54Tod8iM WJL3T0Bb24T3taA79uWg0u6bnnA9ijRPriykSLG17YGr+glcgKA+TxWwDpAQxJb7+OCq EVuA== X-Forwarded-Encrypted: i=1; AJvYcCU7SV02UzHQyXIEbVfcAxpH5TNJZpMP4lxNYuZxMA5xuYx4mGL0om4EzwodDZxddbyc7KU2bI9lG/1A@lists.postgresql.org X-Gm-Message-State: AOJu0YygX4Zn+rv/6Yk1h9vjSMK4GbqJOPIbq5uAc+plJFMZ6DefnM3W TvGIu8NhXX2XM8OVfY+q7rGTQ00Im9IP7NaCSxuKjL4oCTlhRUUv6IUPNhI2sD5xZSDZHuJYDCl WeynpoyqCSTjbyTpP2rySw1/1WUc25EU= X-Gm-Gg: ASbGncuN7jCeYUndZyVs8/4hqfpCW6YYjTtd1n9WO+5Zht6SBppNR3/C5LxWlD6fR/G er1UesnZnvwpylZIxEXkop+LxYsQ9WJ0anlRjMFIwdiSh/FcfrqpydksImw5E7PN1fi9Hfv0/y4 hSlyiX76BYSYnyXjNelegQxghhb+JH4zvG5ki2G1ouu511fNJVM3+k+DK56/wAzlCZMMr0WBkip 7F4i6iRbOksDA6XxYUSL8c3+lOfkvhAt5WF3xKMnP7Yk96otEVvo/jWPeaJOPt3GctE/ekFt0/k OBA2tMnmskkljYWEI+h1cgkUDK46vgXuYiDArbLbQhQqOLbx+ROtLwN1RVv5XQ== X-Google-Smtp-Source: AGHT+IFLvR7NjeeaZzW87341Z5GtAFv1cZ0s4HqbPV+bkEzkYRGcqHvLiWlkkGSkwkLkcE05DW6DLshFPsbOplVGQEY= X-Received: by 2002:a05:6512:3091:b0:58b:151:bc0a with SMTP id 2adb3069b0e04-5941d556fdemr871265e87.49.1761875427097; Thu, 30 Oct 2025 18:50:27 -0700 (PDT) MIME-Version: 1.0 References: <19099-e05dcfa022fe553d@postgresql.org> <2960545.1761800903@sss.pgh.pa.us> <3017911.1761832112@sss.pgh.pa.us> In-Reply-To: <3017911.1761832112@sss.pgh.pa.us> From: David Rowley Date: Fri, 31 Oct 2025 14:50:15 +1300 X-Gm-Features: AWmQ_bkQa9U0vhyrtXSuxlcJMeAQEXEVG1WlZ84X61f0BdYS8epys3vDefWRmPk Message-ID: Subject: Re: BUG #19099: Conditional DELETE from partitioned table with non-updatable partition raises internal error To: Tom Lane Cc: Kirill Reshke , Tender Wang , Amit Langote , jian he , exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 31 Oct 2025 at 02:48, Tom Lane wrote: > 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. It's a good point, but I doubt we could change this fact as I expect there are people relying on pruned partitions being excluded from this check. It seems reasonable that someone might want to do something like archive ancient time-based partitioned table partitions into file_fdw stored on a compressed filesystem so that they can still at least query old data should they need to. If we were to precheck that all partitions support an UPDATE/DELETE, then it could break workloads that do updates on recent data in heap-based partitions. Things would go bad for those people if they switched off partition pruning, but I doubt that would be the only reason as that would also add a huge amount of overhead to their SELECT statements. In any case, the planner is now very efficient at not loading any metadata for pruned partitions, so I don't see how we'd do this without adding possibly large overhead to the planner. I'd say we're well beyond the point of being able to change this now. David