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 1um3p9-009LPN-Cx for pgsql-general@arkaria.postgresql.org; Wed, 13 Aug 2025 05:14:55 +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 1um3p7-00CAwA-Nz for pgsql-general@arkaria.postgresql.org; Wed, 13 Aug 2025 05:14:53 +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 1um3p7-00CAw2-CP for pgsql-general@lists.postgresql.org; Wed, 13 Aug 2025 05:14:53 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1um3p5-000Izi-0N for pgsql-general@lists.postgresql.org; Wed, 13 Aug 2025 05:14:52 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-459e7ea3ebeso23634685e9.0 for ; Tue, 12 Aug 2025 22:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1755062089; x=1755666889; 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=W1Ele+CexQO0bqxhTtjCQsJ8RgvUsJ8S2t8QVJ5TZTs=; b=rFHOb9mz4rwb/mwafuy6pjkjYAO6sjGr4WcosEwGEtUAsusI4Li2t7frN6BmK6LQfi t1dNQ2eEtW5RN/CeV3m0zC9LSlvhikCZ6Yg++KQz1jc7+wphpkH/z9KITau/9IcwucD6 9KB25qQgQj+gB8Tk6Au1bd5QueD1h4j2P1PDhAghsh8k8C/qijQVjjW+VHplXVNcDiw+ MMfye5Zswdtk3aH77R+jYC8AsXZonWGfuZ9pCA3ClT+DPvitiwWXlU/PZzC8wweqMVD0 Atf5msMyjFKd5u68ZsKcPlnkJNbT5S5h0sb4L7TzJd6v1ptjDl9erkmoQZsLm7/TBeRL jlig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755062089; x=1755666889; 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=W1Ele+CexQO0bqxhTtjCQsJ8RgvUsJ8S2t8QVJ5TZTs=; b=hCM4WhPz/mqU8KRerAy2qf0nSXBIGksTcim6IcSoB/zaxo8tq7hDLJ9N7kCJf9hSSB iGQvufjbLnLF3XrG7GJMk0EJwZcV/OfhyLaJRRuyC8SZ27WHcOG/0Z9Nf4CRagNi6cn0 Ncnb0w/SzKTBBBmnmhDFlohPc5ZznaZavQyijLFdAbo281KV/tlYR270wW8hkTu+YL8K VDP73nYP9Xg8EeyMNPYbRXKLrxH0mXZkWzbgFHzo5a4LeONtJMihIOQLDLsfpPcpx+pc CAVa5AcGUXNY20I3LiNf5GWaXnciFzpfdf7/UhFkH99QjAk0KTR4AzD19oALEtiOucY1 kOZA== X-Forwarded-Encrypted: i=1; AJvYcCUacYWk0kSj38r9WehmmCNICxKVyB3JFeHXdu85mXpdpeKdt4B4qoOYzyc1mW62b7i5wEBtbHh1Ch2SFNEW@lists.postgresql.org X-Gm-Message-State: AOJu0Yz1zs0TIaeVhtj287Kj0+KFkdB17WKthrJLtzK7wnOQlnAIOWHc vkLfZ7HYjoRbTByHrW27DmoAHbZxqxKj0OsRzd8MdC1hFfmPaS5BFoxnu+Ad0eJBh0I= X-Gm-Gg: ASbGncs1HAXOPHXVgV2quT6euHbBFbVK8SIP9of+glgVwcGJ6V+uygPDUAcABnxXz/B +/CSUTEM6rdr7V5RYa81vS/BSHGtO5v9409eFopbTV4/1IWOsmxZmN3mbz/A48gDSOCe13ichi3 1u6gap9RMc04RS9VVSN6CirydkaBIvSL+QayFqdwj4HTKlfCOX/lta0grZPNroP53eUACxGoCmg 36/MFtTd1tpqW/JYqfW7JC40R0yWLHTa4LVZ53alHCwdg5JUTnePlxfZGGY2pyBCOCsDhUtqPZa kYzldNqOGV7oVqPdiPJg4bo3WsdeI2lHwyw4N4YlteJg5NYD2O2SSHJ082Yw3VYSRQhprWHhNlM 4Mh3CfOW83qqGjF/3AhDvKS82lywypD8Onpn9r64/qWEAbhf64GLg X-Google-Smtp-Source: AGHT+IGTYuOv1Dj/uQVYWn7VcpuJRzHgie5EU+kvfYIJuyu657lhP4ABOMoMmxyoyiS/u9f0+hZvlA== X-Received: by 2002:a05:600c:1c0c:b0:458:c002:6888 with SMTP id 5b1f17b1804b1-45a1660b159mr10710775e9.32.1755062089158; Tue, 12 Aug 2025 22:14:49 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:260:523e:5a1b:30ea:b8cc:a5c9]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45a16ddd23fsm13440255e9.11.2025.08.12.22.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Aug 2025 22:14:48 -0700 (PDT) Message-ID: <41cc55f13edfc22ab393fa27b54ca6b7fed32ee9.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 Cc: Adrian Klaver , pgsql-general@lists.postgresql.org Date: Wed, 13 Aug 2025 07:14:48 +0200 In-Reply-To: References: <1f99e5c1-a203-4441-aa5c-33a3baaf852c@aklaver.com> <93c76ed6cabcd32993203f03c7ce4fc88b20c087.camel@cybertec.at> 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 Mon, 2025-08-11 at 11:34 +0800, Charles Qi wrote: > The trigger function in example is doing nothing but return new, the > row is actually locked by the trigger itself (trigger.c > > ExecBRUpdateTriggers > GetTupleForTrigger) > > You mentioned a very important behavior: > > A multixact is only necessary > > if a subtransaction needs to take a stronger lock on the row than what > > was there before. > > We are doing two no key updates in example, and should not need a > stronger lock on the same row. Still, you could explicitly lock the row in the trigger function with a high enough lock level to avoid a multixact being created later on. Yours, Laurenz Albe