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 1wXH9E-003ARC-2Z for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2026 11:31:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wXH9D-00B2D1-2G for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2026 11:31:03 +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 1wXH9D-00B2Ct-10 for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2026 11:31:03 +0000 Received: from mail-dy1-x1336.google.com ([2607:f8b0:4864:20::1336]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wXH9A-00000002Jz3-3rRD for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2026 11:31:02 +0000 Received: by mail-dy1-x1336.google.com with SMTP id 5a478bee46e88-3042a388168so3428654eec.1 for ; Wed, 10 Jun 2026 04:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781091058; cv=none; d=google.com; s=arc-20240605; b=BBL16ArJu3n1o/ClcT3qB/0M9E2gp/O/Vburvm90EvSMfMFXpLdF7C65cqyJXV1wxr A9pgA/R9SAN+Zf7JzlJhrjeenecIBmK0N1vCfJql/FkPv69RIVErPEFc+swBfsQcMVUY 5VGVT4vFAmKoQoW5QFNOLoXLILK0iWRMrxrinQZ6RletLVjLUD/qTb/O0msjA0Bgsd3w NU8SoKr+Zm3yRlVXdNBxkUSE6oGaWMkHXTHoGAUNNEYYme1gOc9raEf/Zvk0YbB6F/O0 O5JtS28Cgz0mwV6524NVLrMzNF5Wyxl5LGrwvAWBX6QKhAXB5u2qFjy6vCHa+7U7BC1w PnSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=EmqQevSBTK6unTcJOorKwX8d4Pv9d6JYDEnY7CbEYUA=; fh=mWGT5H4ep7ZlzCtqirsfgcezVhoYx9fdTwYXnowVNaY=; b=PuSG/C+pYAoCi0CnpSPwM8QNRwgl50tREHHdT5WoxCb7qUUYCyzyAC2EXWwBC7PaIP cBGydPzjrinvkUhEK2Yr1VLJogxeoE2IJKjIIR5/eft0RK41tDa7jU5MCQJTPLEeoIc/ m8vd+CHlivcZ96FC/n/yBX5u4NLjuhvtcm+Y+EEZ8xA7Ro8+LVHUIvoh/uNmwu2Ts/ZX +qcTBSRoCZpBm5Kx1SG46pdkf/3V8T/MvlPPpvK1SayUaZHZ5GbFRbWapsIKdpgfT0Rl zLWTfjzhQ2XHGE/f0cdzdbxtx+ZXgLzGYaP1du75mPGn5bKwSLfw2iQ6855Gha8AtTnL UoZQ==; 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=1781091058; x=1781695858; 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=EmqQevSBTK6unTcJOorKwX8d4Pv9d6JYDEnY7CbEYUA=; b=Tt0vX8S3w5NkriyKn+1aOjLhSI3XoPfcwwCS77iYYmCTBaBPSB4kSyqmflxaMC6rAT 4/j3btdGC2K4PvW+upX6hXBT/o/nt8HU5OxBqUz3z+M4pmH0jWwiAulgbLGQPVSrCes3 Jx54axhNq3U66s4nQ/rN3D4YtKy/b7Vbvv+V1rJfwozz0+q3ymiYX0nGnl2sVaiYPH/k us5DsNZH82m/hSO5EODiv37HeZKlh61BBY9ZSO2LyvnUatSvB7nK6tS7NF4J+zdpT9V0 UPCfAFx6Gyq8Zdct0cgnO65KRTVkOW08yVx77tA4pWwbLO72SMsDFfM+PtJDm30LYi2V mKKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781091058; x=1781695858; 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=EmqQevSBTK6unTcJOorKwX8d4Pv9d6JYDEnY7CbEYUA=; b=mNud8SaN3nMSbeRNPYUY2y1++pcvJxsetvGEw0yYP1ItGTO2H5uRvfC/5lvBCTvHQi e4Nwd20fMus8m0jaMrLdd/XRLsNSU6u00it6W8rUyx48VJwkr5lV1ytXkiDGEPsQihiX ShT/uiIhEar6+MsM5GBsXEOsCS/jWxWC/MO3o5HCvHvoSEK5hjGubE+0ylCRMYy3x/37 nYz0495apVLgd4CiR1GN1xD4X/N7N9IotHT1HXZNe4HlxZdJuR3aq8lsOgdg8vsTc6Os FRXJiIOY9bJQL5GqHl9uwF+n8rTavZaDyXa8k7doJcd7t8QMQptBYxA+f8PPWbz0dbd4 m8iQ== X-Forwarded-Encrypted: i=1; AFNElJ/GisJAvMMCuULa64HaCeEBqTtq15C33C6HHMTIhcTREWWkbIOiIpGcANP8tsdsid0vP6MJorK5omnAtOGA@lists.postgresql.org X-Gm-Message-State: AOJu0YwtsMIYWYrPXyPhoCLJdqI4CQ/Dl86BmuY+MhafsGG1Cq11BDQ/ IkyIt08yoswLGRCDFcJ+BxG2Rt57xqY6md5vyTQ1sj1NzGXV9soBmA20AT+5+Q6PhAagHoY64mO 5cbGeC5CHTpeiftqGoXyTNwi00A0WRxA= X-Gm-Gg: Acq92OGbiS742gG3oDG55hYbMoazQl+8az/5yS3y+9wymsA0FABXo+GUKUxP9kJADnV /6E4XA4i8AxiV6F19Ml4eEkyC/QTkVsDuEqim+/AkcbwAc+5qkwxyle+PDrV3xYuEZ9A6qL1T9W jimSLblkZ0DBCKC/JfalGfET8wCWCnxJEtoAKb6wQ5WuGBO7430d0CTEBgAHLZCJQf/cEufOeSb fmwYBmNY4H+ey+az36jymI4Z6/fi2YU5FHtKdVUIlEa+iPbogHybbLEXQTd8o6EeH/3zUlKKdH3 OsLQ5BSkrIqccjhsM8pDp+zDwBp1Dr3Em+zmHHfJ+qTB2aQzMpkB5D+lm+hkNu5TS4gpQuZWW7y FEFuNLrerqtqALvkllybXsOwF5/jypLRIjVoek1sZ2flA3cn75hg= X-Received: by 2002:a05:693c:62c1:b0:304:ce0e:70d9 with SMTP id 5a478bee46e88-3077fe466d1mr6029380eec.8.1781091058000; Wed, 10 Jun 2026 04:30:58 -0700 (PDT) MIME-Version: 1.0 References: <20250718175314.4513c00a@karst> <20250729174852.14f23557@karst> In-Reply-To: From: Etsuro Fujita Date: Wed, 10 Jun 2026 20:30:46 +0900 X-Gm-Features: AVVi8CdzqcPTBJsKzCRo4dI2zodHWlTfxa5wd0mrAY_eKFBJEAXTx8oiucwHrOk Message-ID: Subject: Re: [(known) BUG] DELETE/UPDATE more than one row in partitioned foreign table To: Nikita Malakhov Cc: Jehan-Guillaume de Rorthais , pgsql-hackers@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 On Mon, Jun 1, 2026 at 7:44=E2=80=AFPM Etsuro Fujita wrote: > On Fri, May 15, 2026 at 2:23=E2=80=AFAM Nikita Malakhov wrote: > > CFbot was unhappy with previous patch set, so here's updated one > I took a quick look at the patch set. IIUC I think it's created based > on what I proposed in the original thread, which is invasive and thus > not back-patchable, so what you are proposing here isn't > back-patchable, either, I think. One thing I noticed about what I proposed in the original thread (but didn't when working on it) is that it would well handle cases where the remote table is a (simple) inherited/partitioned table, but wouldn't cases where it's e.g., a foreign table on the remote server pointing to such a table on another remote server. I haven't looked at your patch in very detail yet, but I tested it as shown below, and it causes unexpected results, so I suppose it inherits the limitation. create table pt (a int, b text) partition by list (a); create table pt_p1 partition of pt for values in (1); create table pt_p2 partition of pt for values in (2); create foreign table ft1 (a int, b text) server loopback options (table_name 'pt'); create foreign table ft2 (a int, b text) server loopback options (table_name 'ft1'); insert into pt values (1, 'foo'), (2, 'bar'); select ctid, * from ft2; ctid | a | b -------+---+----- (0,1) | 1 | foo (0,1) | 2 | bar (2 rows) explain verbose update ft2 set b =3D b || b where b =3D 'bar' and random() = < 1.0; QUERY PLAN ---------------------------------------------------------------------------= --------------------- Update on public.ft2 (cost=3D100.00..121.66 rows=3D0 width=3D0) Remote SQL: UPDATE public.ft1 SET b =3D $3 WHERE ctid =3D $1 AND tableoi= d =3D $2 -> Foreign Scan on public.ft2 (cost=3D100.00..121.66 rows=3D1 width=3D= 106) Output: (b || b), ctid, tableoid, $0, ft2.* Filter: (random() < '1'::double precision) Remote SQL: SELECT a, b, ctid, tableoid FROM public.ft1 WHERE ((b =3D 'bar')) FOR UPDATE (6 rows) update ft2 set b =3D b || b where b =3D 'bar' and random() < 1.0; UPDATE 1 select ctid, * from ft2; ctid | a | b -------+---+-------- (0,2) | 1 | barbar (0,1) | 2 | bar (2 rows) The first row belonging to pt_p1 is updated, which is wrong; the second one belonging to pt_p2 should be updated. To address this, I think it would be good if we could 1) extend the concept of inheritance to cover remote inheritances, like pt, and 2) extend inherited UPDATE/DELETE so that we update/delete leaf tables, like pt_p2, somehow directly, as done for local inheritances. I'm not sure about how to do that, though. Best regards, Etsuro Fujita