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 1tx1mF-001zmF-9u for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Mar 2025 10:44:59 +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 1tx1mE-002H6i-03 for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Mar 2025 10:44:58 +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 1tx1mD-002H6a-Io for pgsql-hackers@lists.postgresql.org; Tue, 25 Mar 2025 10:44:57 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tx1mB-0011eJ-2P for pgsql-hackers@lists.postgresql.org; Tue, 25 Mar 2025 10:44:56 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2239c066347so120014405ad.2 for ; Tue, 25 Mar 2025 03:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742899494; x=1743504294; darn=lists.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=SVVT2UOgIdy4Jzkltpx16KIPsF0XopF2erekzdXMu6s=; b=BCfRWbx0VZ9Zma9C+JFQY0diZ9nA3TIk+n8tF84aAR/dqEIZSwUTdM1rWuxML5w0FZ 4CB8W8gIJmQs6KgT/dOSveOb0hzZmrlOFzax+6x9EqYlelscH49scotH+zeAkY1n5bYW 3XuTTukpAsVP+1PIw4N2pw0LVmOjzIc0P39PkpZIxh/3JEkDUCag6mfa6YC3EijjAUHl PA+CQ0TBqbu66I2uur6lKS1/QQGyUMYEXGQpd9VkB3V23+u48Hu7kI1O9IfvO4VoPsYv 5oSxMw9HK5odjGjA5/RTTb6r5J3WbslLrgE81aIMv14UUa3N6G1sKbKApbCkNBhu271C D1Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742899494; x=1743504294; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SVVT2UOgIdy4Jzkltpx16KIPsF0XopF2erekzdXMu6s=; b=qaWNO7VPfk8CtbjH1Mld6OwPeec4RNBT4CpkoQwg7H245gfI9Dx4zT2wA/BAgECzYu YZpiZylmVUkCE7p+nOFMBM3plgOcPkT5yTsd/HC/m+/cj+C6THriVEnU/uh3RPCKu/4Q fnGZ2Z6l1DJ5Zn69sHmM8u+F2Ae7QCiW4nXF+IImM6CmLll8VJ86QxVhISnxARokFK0f O4pokROXftwQJdQOeMKkzTTHBlgKDHPzLw+wAYHHACI2b4h60c2yFJb8IJmGgO/4wtTb 7Jt39kJ86ZKooQjtQV8K3d8kQ2pByxXxfsb+PDaDBkZ12r2cImJOp54UR/y7s9g62Iup NDAg== X-Gm-Message-State: AOJu0YxkIhFK9ZpF9erO5seUCq/BeBn41A5Zc1tQZSuK2rtqIGYVKSQj +c3HPuOn1A9TK0778yv60w01vs/DF4kt2Tf0p2V1vcSLchU0QX90JopZlEE2TqchpoiwitfX4Nt McTNgesPGpgaOZKSHAYhiM87fmZ4= X-Gm-Gg: ASbGncvPukg+WPuNLnEYEynwEbCRtF/IS+k3AtoXx/Xfq7V1hjU1QwGXgJs377kMIdk b9f0+Eyf//jO/CzGFnIvLhAmN3TRr/NUV9D4MFVjCRLjSgO+RfERGsrGTiOgA8Z7u9ZkKaeTexu S+8wyxA/4jeVGFwkA6thveYPo449gy9/2G8gc6vCqdJmQD4tcF93g68u91+j49 X-Google-Smtp-Source: AGHT+IHvZEjIMCVd22+W1L6ZfvWU8vL5BM46SLwT9RyMAxD+cvYTUcRk59OzUO9FFbDjLNl1Jl1MlkvYxCTqUNkh4jM= X-Received: by 2002:a17:903:2ecb:b0:224:1221:1ab4 with SMTP id d9443c01a7336-22780db101dmr279390775ad.22.1742899494323; Tue, 25 Mar 2025 03:44:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Etsuro Fujita Date: Tue, 25 Mar 2025 11:44:43 +0100 X-Gm-Features: AQ5f1JpQDGkENB0_GkO7fnv76gVsotCdIQ7Atg9JogKsGYKpb1xAucA4twnh17M Message-ID: Subject: =?UTF-8?Q?Re=3A_Options_to_control_remote_transactions=E2=80=99_access?= =?UTF-8?Q?=2Fdeferrable_modes_in_postgres=5Ffdw?= To: Ashutosh Bapat Cc: PostgreSQL Hackers 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 On Mon, Mar 3, 2025 at 1:51=E2=80=AFPM Ashutosh Bapat wrote: > On Sun, Mar 2, 2025 at 5:14=E2=80=AFPM Etsuro Fujita wrote: > > postgres_fdw opens remote transactions in read/write mode in a local > > transaction even if the local transaction is read-only. I noticed > > that this leads to surprising behavior like this: > I am having a hard time deciding whether this is problematic behaviour > or not. Maybe the way example is setup - it's querying a view on a > remote database which doesn't return anything but modified data. If > there is no modification happening on the foreign server it won't > return any data. Thus we have no way to verify that the table changed > because of a READ ONLY transaction which is not expected to change any > data. Probably some other example which returns all the rows from test > while modifying some of it might be better. How about something like this? CREATE TABLE loct (f1 int, f2 text); CREATE FUNCTION locf() RETURNS SETOF loct LANGUAGE SQL AS 'UPDATE public.loct SET f2 =3D f2 || f2 RETURNING *'; CREATE VIEW locv AS SELECT t.* FROM locf() t; CREATE FOREIGN TABLE remt (f1 int, f2 text) SERVER loopback OPTIONS (table_name 'locv'); INSERT INTO loct VALUES (1, 'foo'), (2, 'bar'); SELECT * FROM loct; f1 | f2 ----+----- 1 | foo 2 | bar (2 rows) SELECT * FROM remt; -- should work f1 | f2 ----+-------- 1 | foofoo 2 | barbar (2 rows) SELECT * FROM loct; f1 | f2 ----+-------- 1 | foofoo 2 | barbar (2 rows) I added this test case to the updated patch [1]. Thanks for the comments! Best regards, Etsuro Fujita [1] https://www.postgresql.org/message-id/CAPmGK14Btk0odkH6vwBhBGjCexmmWcM_= D3DG0pJtObj8k_Unag%40mail.gmail.com