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 1ulBoI-00ByhW-Rj for pgsql-general@arkaria.postgresql.org; Sun, 10 Aug 2025 19:34:26 +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 1ulBoG-008WoZ-Vf for pgsql-general@arkaria.postgresql.org; Sun, 10 Aug 2025 19:34:24 +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 1ulBoG-008WoR-JF for pgsql-general@lists.postgresql.org; Sun, 10 Aug 2025 19:34:24 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ulBoE-001pvy-0C for pgsql-general@lists.postgresql.org; Sun, 10 Aug 2025 19:34:24 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-615d1865b2dso5463825a12.0 for ; Sun, 10 Aug 2025 12:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1754854461; x=1755459261; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=CscPl/35t/ciEX+N0eQl4RpaaG3pgumfk7VV8MooMz0=; b=Y/cz0LKOJv7dIT2Tirsl4tce8ekIhkuNPUu+gYrZ/RlENaygUCz65ZDLzpcxRPNm6t 5E3VaKLJQJe6jbj52FknYSbgD3AztsveJxkvHCe5vwx2yRPkN07mCjxKLJ1BeJps/Z/T z2L8em19IpqpzXfR7uzWk2UrrP1EiKVMXgQnrZ2zvEA936fBKpsD5Wdp8romGYS3DEXv T+wGkZRNW4QYDTHlxR0gLVXcKn2vt5O2/VHF+KyDpU/zA56cenW1T056h5xjk7tE3JAo i6HZ+LSNlsHZdcZlJBllmk44oL44nO7zzUxMhb+WrReJyRc4e9Gc3c3Uw7L1GeHf6Xn9 8BEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754854461; x=1755459261; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=CscPl/35t/ciEX+N0eQl4RpaaG3pgumfk7VV8MooMz0=; b=wcq6W5oM5D7Ngk8ofKuUA1rPecpW4UvZFWimL8A7CpdA3D/t7fpfZc5QxuVKAUzb5w cTGGRtzLXAnYOyqxBnz2hCM9goOODKjtZmEMfL9q61EMx3vpMeISwED8Z7IdibWJY9oZ P+S0GaauQFw47nZvX6wDrzLd47BzW/AN84ahO8C7o89e2FqcC1ZPLlCOhLQl+FZlSWlL fYgzh0lJvPDumq51cI8HFHuJaUUjMMnve/6CEcsIZqe7wZC+p0mxPXi1Ott2qGwVoj6Y unIw7JTfKeCpWNGOUgPTNru/4NKVZnJcs+qmTS50LcfnSKRJSeBNtCL1yBMOUGGIvVFl uB7A== X-Gm-Message-State: AOJu0YyYy/MPZzVbHL6MLzNcQqczXI+aUwv+TOh102w5klKHbPhxO67v S3HO0FN86oUMdKR/LBzevoeIux253UL4CzN1gpxtWnzneVVAogHjv2TlKNbkm0YLenI= X-Gm-Gg: ASbGncsdMeuPzBDnAUzfqOxyxc45+DMrqSXCTM80MmbCoDR+Idoq3FUp3tbjIXUrDYM FkDvpJU0nsEu7if2V9Re6TQHuezuOg370tJvBRMGtwjq69/FoNKaVUf0BxWHp+BulfZurkYgbDF PuOc2nreDEYL+g74VamjHQTsbOpepvhT9+RK2FguHz+ixN5gsqXogWCGs11CKYk3uxK+WYeDDFB Fc4SCB3KqVraMY+deRTQcSpD504XvEpmjxWkQIJXWP+RNeZPup3KKU99IvJno+qB825yYEi1vha +Zs83AkLJlpVL47/oHFnTsAotf6lztFo5FypS7vGgeokIU1Y8WfyMKDQB3db+v45VlQYqFDdzIP OurdhBPfDBzEmnD/TCM/Zoj/Szch8qNndX0woBB2uxDtNYrqhxII= X-Google-Smtp-Source: AGHT+IGm/WucWMr63ymfETPjGJ6bMoqh9Qf7P0x6elHeEzApUxIJoywei3hcIMJfEgSm1MUsAhj60g== X-Received: by 2002:a17:907:3d88:b0:ae0:abec:dc13 with SMTP id a640c23a62f3a-af9c6501735mr1023194366b.53.1754854460703; Sun, 10 Aug 2025 12:34:20 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:260:68d6:ea3b:1a8c:cae9:ffb]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-af91a0a3cecsm1893531366b.53.2025.08.10.12.34.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 12:34:20 -0700 (PDT) Message-ID: <93c76ed6cabcd32993203f03c7ce4fc88b20c087.camel@cybertec.at> Subject: Re: When UPDATE a row in a table with BEFORE ROW UPDATE trigger, the XMAX of new tuple is set to current XID From: Laurenz Albe To: Charles Qi , Adrian Klaver Cc: pgsql-general@lists.postgresql.org Date: Sun, 10 Aug 2025 21:34:19 +0200 In-Reply-To: References: <1f99e5c1-a203-4441-aa5c-33a3baaf852c@aklaver.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-1.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2025-08-08 at 09:20 +0800, Charles Qi wrote: > Let me clarify the question, when the BEFORE ROW UPDATE trigger is presen= ted > Q. Why do we need to set the XMAX of the new tuple to the current xid? Because the row gets locked, I'd say (without looking at your example). > which risks piling up multixacts quickly in savepoint/exception block > scenarios. Why is that a problem for you? Perhaps the trigger could use SELECT ... FOR ... to lock the row in the strongest level your transaction needs. A multixact is only necessary if a subtransaction needs to take a stronger lock on the row than what was there before. Yours, Laurenz Albe