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 1usAzI-0014vG-V4 for pgsql-bugs@arkaria.postgresql.org; Sat, 30 Aug 2025 02:06:42 +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 1usAzH-00Dhip-5B for pgsql-bugs@arkaria.postgresql.org; Sat, 30 Aug 2025 02:06:39 +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 1usAzG-00Dhig-Sb for pgsql-bugs@lists.postgresql.org; Sat, 30 Aug 2025 02:06:39 +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 1usAzF-002bNR-0L for pgsql-bugs@lists.postgresql.org; Sat, 30 Aug 2025 02:06:39 +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 57U26WU42504805; Fri, 29 Aug 2025 22:06:32 -0400 From: Tom Lane To: "David G. Johnston" cc: ZhangChi <798604270@qq.com>, pgsql-bugs Subject: Re: BUG #19036: Failed prepared INSERT statement make another SELECT query generate wrong result In-reply-to: References: <19036-ef3954ff85feefe2@postgresql.org> <2163312.1756480422@sss.pgh.pa.us> Comments: In-reply-to "David G. Johnston" message dated "Fri, 29 Aug 2025 18:57:05 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2504803.1756519592.1@sss.pgh.pa.us> Date: Fri, 29 Aug 2025 22:06:32 -0400 Message-ID: <2504804.1756519592@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Friday, August 29, 2025, ZhangChi <798604270@qq.com> wrote: >> I still have a problem with this. When an INSERT fails, why not undo all >> the effects of the INSERT? > Performance. Yeah. You can certainly argue that it was a design error to make nextval() nontransactional, but the performance advantages are compelling. Most critically, if we required that, then any transaction doing nextval() would block all other transactions from doing nextval() on the same sequence: they'd have to wait to see if the first one committed before they could know what value to use. (Deadlocks between nextval's on different sequences could be a problem as well.) So the odds that we'd change that are nil, even if there weren't a few decades worth of backwards compatibility to worry about. regards, tom lane