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 1vO5a1-009WnI-2A for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Nov 2025 02:48:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vO5a0-00DLET-0x for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Nov 2025 02:48:28 +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.96) (envelope-from ) id 1vO5Zz-00DLEK-3D for pgsql-hackers@lists.postgresql.org; Wed, 26 Nov 2025 02:48:28 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vO5Zx-001WpH-23 for pgsql-hackers@postgresql.org; Wed, 26 Nov 2025 02:48:27 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-29586626fbeso76690125ad.0 for ; Tue, 25 Nov 2025 18:48:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764125303; x=1764730103; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lWel7lfAHxRTL06uDNKRVazQjelYS0k1UEETkWh0P1o=; b=H+0hAQ4q6WNh5IAXAqykdPPsTtOPHPlUHj5g1Gm0Wg06dUMMmj8ZpKMZw82uiRkS0N I2EkDDuap1G94elBJ6ijRFk8J5u5iGVZzIixhVrZwGxkbx8tk8o+6AKUzYiBEmaasUU5 w1tcd+oVMaLqKk3h3kTbOrnq4bNCmOCUhNRpKfKO9bnP5I4DlHM5Vs9TAS2il0ctDuXe qWsTgRgLBrmATzJsg5WlLxBVk7LfazAfgpjmDzHPzazuY9u7HuHWl44ffIUP3EoyCdi3 XphfRdZB73CN0qfLnk3yCSdez0ifEFrMwIVS0Dz49laEpP/GBUjJ2Emnv9a1cha6P6T0 rYcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764125303; x=1764730103; h=content-transfer-encoding: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; bh=lWel7lfAHxRTL06uDNKRVazQjelYS0k1UEETkWh0P1o=; b=DDHKyYIkNzgKUyTmGlrWjk9ZiWxUcpWpcNJBjX1YJREcd/U53WCO59OOxNDIPqWpqA nlt9HrN3/QkpnLWMCzSMnvKGuRQ6Y5CYqhJhlcYG9Rai37DGH6LZNELHuzkED+MZY3mV cSZB7/PYzFg3QoMrT0v0+24ob9JFq2E6u2bqIPcIUuUICn/C+2wNksNHmHefarUr32ag E8qTgrthNYnDzbm4vYYlYAH40jEWaVbgiE2IWG73/1836Y3xkxpdmKxAyrGOry+++eCb 7j1jRtnR/hYte2a4v3lMBFbVrME8ggR9y5rGgQSnaPJYpN/3nDFB0/Jj9ykaex9E0Z0q DODQ== X-Forwarded-Encrypted: i=1; AJvYcCVcarX57iT2UnzmXMQUe9CyWyv6Iyft4BeC0/Wvyi7Acz9DjH4d3Uw4WmmQN/EMVgPmnjrlhdqgQL2/oJN/@postgresql.org X-Gm-Message-State: AOJu0YzSHu30dPBS9jzYieyUXlXEBT9hSUesQFgAQRIPgbkG6bzGa1iT MutEx5u5NYvlRcvDO6hBJZH5RgvH7dIsgt8cuR9OaouJMgTKhnlRjeXBF5iO/DKgODSNIKhe9DI TCOGkDbnu4BwNtVGDMkJMkK7cahe4KF8= X-Gm-Gg: ASbGncs3Kk/WxMp7lhKCVRE8K+Rgp6w2MX4zTwHyjCwPXKarKcq7HTsjXUjnO0SjA5i 7OQuIJUYleVq/csNCu2c7MowWD9PceoCgkZvPb7DeddUYDluDN8i4Q9mJhKM146lw2DPG4ALm1M 1UxSlK3Bb8T/0OacbVWqLghebsnh76Vhi+J9VVP6YoOb5aGltqKuNBfF65udTh1PlfVC1qZKeIh pERA+d9UZuEvmLNHMpIg52Sf5QUZMSdNGheA3BqG5Fnt6uyyacEn6s567CT6OxymOqJiyAD X-Google-Smtp-Source: AGHT+IE4Aw0pWAuD+Oza2DcsocgUC4ms50m/xhTeRhGxXpkyaSqIKPufpxxUZzuKfva0WGSBakKMW925ORa7fQZ44JY= X-Received: by 2002:a17:902:ef0f:b0:250:1c22:e78 with SMTP id d9443c01a7336-29b6be8bd7emr195215015ad.1.1764125302810; Tue, 25 Nov 2025 18:48:22 -0800 (PST) MIME-Version: 1.0 References: <20250331212648.ad4ab804559001d7f0788741@sraoss.co.jp> In-Reply-To: From: Amit Langote Date: Wed, 26 Nov 2025 11:48:06 +0900 X-Gm-Features: AWmQ_bmsKwv0LnbQkGOMjkSRcyecb3hC2d_bwMnposYF01E4ca5IVofHPtLmDig Message-ID: Subject: Re: Add comments about fire_triggers argument in ri_triggers.c To: Kirill Reshke Cc: Yugo Nagata , pgsql-hackers@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 Mon, Nov 24, 2025 at 6:23=E2=80=AFPM Kirill Reshke wrote: > On Mon, 31 Mar 2025 at 17:27, Yugo Nagata wrote: > > > > Hi, > > > > SPI_execute_snapshot() has a argument called "fire_triggers". If this = is false, > > AFTER triggers are postponed to end of the query. This is true in norma= l case, > > but set to false in RI triggers. > > > > This is introduced by 9cb84097623e in 2007. It is aimed to fire check t= riggers > > after all RI updates on the same row are complete. > > > > However, I cannot find explanation of"why this is required" in the cod= ebase. > > Therefore, I've attached a patch add comments in ri_trigger.c for expla= ining why > > fire_triggers is specified to false. > > > > SPI_execute_snapshot() are used in a few places in ri_trigger.c, but I = added > > the comments only in ri_PerformCheck() because SPI_execute_snapshot() a= re used > > only for SELECT quereis in other places. Therefore, I wonder fire_trigg= ers is > > not needed to be false in these places, but I left them as is. > > I checked your patch and I agree that your comment makes things more clea= r. > > Your patch LGTM Hmm, isn=E2=80=99t that already explained in the comment for SPI_execute_sn= apshot()? /* * SPI_execute_snapshot -- identical to SPI_execute_plan, except that we al= low * the caller to specify exactly which snapshots to use, which will be * registered here. Also, the caller may specify that AFTER triggers shoul= d be * queued as part of the outer query rather than being fired immediately at= the * end of the command. That said, we could perhaps add a one-liner in ri_triggers.c as follows: /* * Finally we can run the query. * See SPI_execute_snapshot() for why fire_triggers =3D false. */ --=20 Thanks, Amit Langote