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 1wh0Nl-006bwh-37 for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Jul 2026 07:38:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wh0Nk-005HLl-2m for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Jul 2026 07:38:16 +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.96) (envelope-from ) id 1wh0Nk-005HLc-20 for pgsql-bugs@lists.postgresql.org; Tue, 07 Jul 2026 07:38:16 +0000 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wh0Ni-00000001zjM-3vGH for pgsql-bugs@lists.postgresql.org; Tue, 07 Jul 2026 07:38:15 +0000 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-492046a3313so2813310b6e.2 for ; Tue, 07 Jul 2026 00:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783409894; cv=none; d=google.com; s=arc-20260327; b=cPx6fQpJqWa9BpB4ODEQTb3z+txIDoCn2rbDGWJkrqfV6XYnGnc3k9YODa1gfavAKU JWjvyLMeSlxm6AmCLQdNdJKtVmjLOJ0UvLAUMbJqDzK3IMPDsAkgtfbUCM0gGnXPOFyu sNlaT3W89XhbKoEePQFOQe5THcNLj8XMf2YG+9pbc4oaQGnb4D2sx1Kh9CQb4kPPzUqm B60LrIPFaMT1dxb0doib7zUoalnV7w2nTkSYVO5N1ujJYutc80472e21BWaygeS4WVpG 5S3UMucsrZVyql5tQ8P8G2I7dYZn5UsPQA7cHUzCMdw5fNhroBs4VhMJ6fw57uxinQXu EnMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=V/OhC2bnxh/+dPWUfhi/xaSa8byVXo8Gy0QdTqHFNMU=; fh=j5mtWbd/UWdBLa8XAb+H1bb46Ii0fh2rMUe231ysluU=; b=cCC6FCRhEoYIHDjnDZtMYpT2lqN6ytKvlinuINaeAR6KrMLrCM8gnWJA+EIzfYkpqJ piRI0jMmYKkn5RaqHwh7pLskXCl+RmIPI80bryv92qhm61HflOTrDd7gfW3P385xL5Yy NwvO1iWm5XeBj1WOY6x3+R3OkU9G1tAsjETwHHMY0J7vR08y0G6DWaWB/ltuKNd5SFEA RjT8ehNrbCRJ64nUjw0/io+MQXJ2Htsc/PgoUmu68Jlw5c45g/iZ45fhuG2N2xfEEkCl af0T19BSsuQCxjSOU5/uqIA3uOH5J6lqcs0bsYZ17MFaM2ZcLHpWBmlo8xWszT+ASCdL l9Tw==; 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=20251104; t=1783409894; x=1784014694; darn=lists.postgresql.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=V/OhC2bnxh/+dPWUfhi/xaSa8byVXo8Gy0QdTqHFNMU=; b=E9wz29Zxsbd9gnJSkSwAsVeJC1d6VKGjFiDxlQg7Qk+gURnwOY1awMYJRDvRzuWY4K C6InKcc+KaGQtAOCcg8xLjL3BeWeEaokQXLFv1uAW5n7CFqU/yqC+OAu+BbAsu5GdxzH sZVoHV4AlYYKfiuee0XIYfZZpld+nJH/SWbEmXbL3s5xQ6RcGofzvm5EmzQ4xa3IrH3P dKU5JcH1p1hQBbYdeNHNwsEVrR+zmmK9xK6Vv5hlwH7mFcvp5UdTB/oM3ZP9q7lIjPx8 6BcMa9HGH6gjbZWptsHfeUklI2WJaSv2jIk4oIB5d9JmotqIeZFR22Qv/8Q+TdftaRLB r4hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783409894; x=1784014694; h=content-transfer-encoding:content-type: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 :content-type; bh=V/OhC2bnxh/+dPWUfhi/xaSa8byVXo8Gy0QdTqHFNMU=; b=X5UdNxaZbfrd9cbxFmi/O+VUJCvwc1Nsm6Koi6Boi01FWW38+VnLpjuwDh5yqvQoKc and6WwT55NlIWkFBjtdDV7b4ST4oD+bD5oozcl7OkYRaGOpY/SQG9YM8o91qJLWmHRBP 15aV8yhNLZIxdtPw2DIt84dJBcVMdEjiwjVmoCdpMx+ZGUSLpkoiXI22jbtxtf+Ei0bg mBy3na/KPshVn58DnLTLNIbeE3EgLPZ/aNPlkgoHnWtLew1neOBQDrfGkG3b0h2B8ZhS ZTAPLy/cmoSmYK+EaYM4RZBiXWWXnfWGikHl0OMPpfg62g+q32XvZeqXeY3SWy7A9ONe 04QA== X-Forwarded-Encrypted: i=1; AFNElJ9RMUP9uWiWD9jmOICCffovIiPpofYZtH4VJSm+7cGECQ9WVP9Nq2BjZFB8iWOL+sq4ZZHfGeIBtIm7@lists.postgresql.org X-Gm-Message-State: AOJu0Yzwy7slN6pqsvgSAbT3AhdoJXkIkrHw752l1t0cXz/zogo1xqyc yQCFSQwwg3oHEE+MO33aEx1KFm0T5XVYBRarKrLziBXN27a/LoK739KJiRurTCDS3zTUI3g093p hMquugBwFPTCiOB+KQT6V0Wza6zdM48g= X-Gm-Gg: AfdE7clLfhbMjk4H32aDVWUGOV9feMrsmCLSran9U/hL1A2viFcFAr8XXqML3xTyReN hGvOgkUVsIg4JvEHGkw1YcURNbXuSku+1g8FEg8ZTW5vaKNin4VCatkdhxmnkLb28gksQzXTgz7 St+YnR1fwolQEK41sBES63iNljpAhGqsjmHffdjoBh/9fQpT/JUt4bnDklmVgAsITJYg/TiPw7u /XmbU4BcRil4ea/KjrvMltgv6NaLxRWsyPBVCKDyvp3BxI83vTRmacOvvJkjGc0rDDM1XyvLp19 HbA3z1InPh/cbdlvba1ZBO3+vNpq1A== X-Received: by 2002:a05:6808:bce:b0:497:d3d6:6a40 with SMTP id 5614622812f47-49fdbe402b7mr3498501b6e.3.1783409894130; Tue, 07 Jul 2026 00:38:14 -0700 (PDT) MIME-Version: 1.0 References: <19536-73ce5847e6c0e7b1@postgresql.org> In-Reply-To: From: Bharath Rupireddy Date: Tue, 7 Jul 2026 00:38:02 -0700 X-Gm-Features: AVVi8CeInJ7cwBqmQPe5yaR0dQ1VUKqcd7-ThJl5J3_DenwyrmECNITqxuTUa0U Message-ID: Subject: Re: BUG #19536: UPDATE RETURNING OLD value is stale after concurrent update when table has a BEFORE UPDATE trigger To: Dean Rasheed Cc: bobergj@gmail.com, pgsql-bugs@lists.postgresql.org 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 Hi, On Tue, Jun 30, 2026 at 1:35=E2=80=AFAM Dean Rasheed wrote: > > I did think of that, but I was uneasy about copying the trigger's old > tuple after trigger invocation, in case the trigger scribbled on it > somehow. Fair argument. I'm convinced. > Actually, I think a neater long-term solution would be to move all the > EPQ rechecking and re-computing of the new tuple out of trigger.c, and > let the caller deal with it, as we do for the MERGE code Agreed. > Yes, that's right. The caller does not initialise context->tmfd at > all, and ExecUpdatePrologue() doesn't touch it if there are no > triggers. That works for me. > OK, I've added a bunch of tests for those cases. As expected, they > pass even without the code changes, but it's good to confirm that. Nice, thank you for adding those. > > Could we add some context to the error message, e.g., mentioning that > > this happens after processing the BEFORE UPDATE row triggers? That > > would make it easier to distinguish from the other similar ones. > > I'm pretty sure this is a can't-happen error condition, but OK. Thanks. Sorry for the late response. I took a look at the v2 patch, tested it locally, and it looks good to me. I think we should backpatch this fix down to PG18 (commit 80feb727c86). -- Bharath Rupireddy Amazon Web Services: https://aws.amazon.com