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 1wFdaw-005NwE-13 for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2026 19:50:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wFdav-00F6Mn-1c for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2026 19:50:45 +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 1wFdav-00F6Me-0Z for pgsql-hackers@lists.postgresql.org; Wed, 22 Apr 2026 19:50:45 +0000 Received: from mail-dy1-x132b.google.com ([2607:f8b0:4864:20::132b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wFdas-00000002WfG-3uBc for pgsql-hackers@lists.postgresql.org; Wed, 22 Apr 2026 19:50:44 +0000 Received: by mail-dy1-x132b.google.com with SMTP id 5a478bee46e88-2dee127b3c5so7657410eec.1 for ; Wed, 22 Apr 2026 12:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776887440; cv=none; d=google.com; s=arc-20240605; b=eZwfXX+O7MgHHnuerSRwKnd9nVBi3V4NUu/YI9/X96KjqKmhYflSfD2gmabAlhgnXN xAbKT2wYdrEOkikGcprUAGQxTLatTQMDzvxZfhyfqj1PL0IOlIHviRU2JzbWPn1Bf/Yd qtj3M98x4DW6OI2+fIk1Obqihj3r05wC+XQf3Z0fu6SWsG8lASDOa+6MaPXA0Gst+SRM IR2vzcYjsE4sMFaVsnGXuMSB1TdoZ2+dxj7Xn9ybZ4fK5ZiGw7n7zvUhhw9CbhLLVqIq o8MkZ8GckiIdTc6VAqQ8AueWdM7pEkkS++h8WvvSsEYApNLEONy72qQapLXOV6pXsKQk 7XEQ== 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=ubHDatTs7WIp0Wp97mLpaymOTBUwChY8ZCznKLvKBsk=; fh=2SuSbAv1e0BLB53Ld6nytERnqBvesSmCmKgJl1z0bnw=; b=RcptnaiYnPnZ9oTmZLJk5mJHrMEI11EAR5z9H7vnXJlxkddzU4Sihyw9KBxCTw3piu 4zKAmbigFEBQnHEq8iiKI3DNMzvPM0VuY5YZwu78SKKpPww+G7qP/xJnrZwYNgCKEr/J fIY+aTb44/nezQbBQvNKA2ZfU2InCOHwIWttjX1HOQ1DcyR5hRMsOy0JtpxXbgS5FigX GmpsXLFbjgxVB2hpUQsSW9OnX2s1IMJuUh+EnGaBO627MASA7NUcccjmqJcl0GvurLxF elW3WhfJnyRBvSoK8A34xc2uuqIYCFU4j8+xFTzQjTwnYa5n6+NzgUbh40vZljdFAOvt ARkw==; 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=illuminatedcomputing-com.20251104.gappssmtp.com; s=20251104; t=1776887440; x=1777492240; 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=ubHDatTs7WIp0Wp97mLpaymOTBUwChY8ZCznKLvKBsk=; b=jxp0T+4Q5X+oZKdeR5tivL/bK5eAeqBLXQmmNjYJhzJi9Q/TJ1WR0YsrMM9I6U3IDd JiWwzYQg0zPre/HxzZ7Br9TpOyL6ZYPSFjlH+lbNntw5KRnqJbrVuLTueabMSTuLxhPN bFwFvMWnnA7elxEY4DoGQ0+2LkEyPQRGnoeD7s9n2EJM6wBKACpG3BUxMysQk1qPvKKh u7tDg4bZERkxLelwz53/msh1a21fVdo1uIZzas98FM+1ddrSpV/plvoLebgiR1IyUWPJ ZxPp8QhKuJo4gfrkkMJASbete0p5nVQkQVI4XdkOSeTEIwLoBjFAeP5WwhNTjXkJyfnh VSYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776887440; x=1777492240; 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=ubHDatTs7WIp0Wp97mLpaymOTBUwChY8ZCznKLvKBsk=; b=ePL25p2uHGJVULzVX3bb2Knq06J14amFLjUN+EntoL/4QUIqKK/fwk0UWzSkGmxNtY pTnscpismF7eLKQ1bilnQDDiuAjMGDXrSxtU7Eo3Ow/5Ie2YzHgHUc9SnzU2k4ja8Lhs 3yW/cFp7oHph2qgQSdA7iI/Bp3GQrUOeIsYd1Iqp7b1QWogo/WCtI6f+NeZqVK/zYE5Y 0wWah/3DQ5MXZivhMhpQnrqGLQxDafqoqem66myaQ6WE2XPrZijayFUsycdLr4tP3Xy1 fHWQ6gl2zUKkzGF1NGg8iLqT61M/0L5dfvzyDfMbkp/0cw/WsqJWYH32SNEsVvQFM9u6 iqvA== X-Forwarded-Encrypted: i=1; AFNElJ8ih0fXjp3yNOwkvXDBIQna/ZBTAI0GqbP5wE3y9F+dqFi06R5Gp/IjK1ikn7sNHo5CLciIsc1HE87+v+uY@lists.postgresql.org X-Gm-Message-State: AOJu0YyECa6w8gAH/jq31Oy6RcOPc5myvqD0Mn5jVaCBmkYG30Ebaw5A ubrPkYAAqF/gP9u7JFtHZzGg0tZMpkpCRhFRrwp9wjZsvVMesB21OGKjglrcoRaL5FckTzd/zUt 7BXvDbEdRFaieRk3btO2D2bqosuGJFjuQvPgcpe67QQ== X-Gm-Gg: AeBDiesTyn8ht0na0rEdqC5psLyUca9n0rKAWGmRj8ReJve6l8gki2MFOUqgAEUK51x 1Z9EKCguf+K3yjejys7T9PSmZPCH5hxB8Vco9UGoLMb7lS/qszuMgIK/zaUWIcRKIymMZTHzZDC VtsyLIr+zOjQE9a/E0W5EqTwffap5cIxuC6XeGwxqmhdbiRrI1vhB3UZHuwEdr6Hw4O2JEayvid +PCqosvGGllmOMAoWmCwIRb9dONmAxRjKNcM5B+eB/+Tz4ej+8xRkN/zaUU4OB/c1ZS8zzIOrsm 9haIYj0bhUWt6k8= X-Received: by 2002:a05:7301:4185:b0:2d9:fa9c:87a9 with SMTP id 5a478bee46e88-2e464ea79b5mr13689734eec.5.1776887440485; Wed, 22 Apr 2026 12:50:40 -0700 (PDT) MIME-Version: 1.0 References: <85ac7f0e-d95f-4377-ade0-8941fd328012@eisentraut.org> <7d63ddfa-c735-4dfe-8c7a-4f1e2a621058@eisentraut.org> <4606deaa-7d65-4f22-8a78-356c3180be9d@eisentraut.org> <53f1c094-3c29-4ef6-a9bd-dc2e7894ceb0@eisentraut.org> In-Reply-To: From: Paul A Jungwirth Date: Wed, 22 Apr 2026 12:50:27 -0700 X-Gm-Features: AQROBzCpsQSPGdM9Wr4JQBsdcFKtUUg8RAqjV_jgymqTj5DroJ-GaXNvEzKoJgI Message-ID: Subject: Re: SQL:2011 Application Time Update & Delete To: jian he Cc: SATYANARAYANA NARLAPURAM , Peter Eisentraut , Chao Li , 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, Apr 20, 2026 at 11:25=E2=80=AFPM jian he wrote: > > On Thu, Apr 16, 2026 at 7:26=E2=80=AFAM Paul A Jungwirth > wrote: > > > > I think using INSTEAD OF triggers to replace an UPDATE/DELETE FOR > > PORTION OF is a valid use-case, but it doesn't make sense to insert > > temporal leftovers. As you say, we can't access the underlying > > storage. But also we don't know what changes the trigger actually > > made. The trigger should be responsible for leftovers, and we > > shouldn't try to add more. So I think the fix is just to skip > > inserting leftovers. I've attached a patch to do that. > > > hi. > > CREATE TABLE fpo_instead_base (id int, valid_at daterange, val int); > INSERT INTO fpo_instead_base VALUES (1, '[2024-01-01,2024-12-31)', 100); > CREATE VIEW fpo_instead_view AS SELECT * FROM fpo_instead_base; > CREATE FUNCTION fpo_instead_trig_fn() RETURNS trigger LANGUAGE plpgsql AS= $$ > BEGIN > RETURN NEW; > END; > $$; > CREATE TRIGGER fpo_instead_trig INSTEAD OF UPDATE ON fpo_instead_view > FOR EACH ROW EXECUTE FUNCTION fpo_instead_trig_fn(); > > UPDATE fpo_instead_view FOR PORTION OF valid_at FROM '2024-04-01' TO > '2024-08-01' > SET val =3D 999 WHERE id =3D 1 > RETURNING *; > > id | valid_at | val > ----+-------------------------+----- > 1 | [2024-01-01,2024-12-31) | 999 > (1 row) > > Should I expect the column `valid_at` value as [2024-04-01,2024-08-01) ? Yes, because we ran an INSTEAD OF trigger and skipped the UPDATE (including setting the start/end dates). > We should also document this on doc/src/sgml/ref/update.sgml > Attached is a minor regession test enhancement for > "v2-0001-Fix-INSTEAD-OF-triggers-with-DELETE-UPDATE-FOR-PO.patch". Thanks! I squashed those patches and did some minor cleanup. I posted v4 to this dedicated thread: https://www.postgresql.org/message-id/CA%2BrenyVenLk%2Bu%3DyGvDAyeFEuvkmeQx= 448-KnnGczqQHB10_fbg%40mail.gmail.com I also made a commitfest entry pointing there. Let's continue on that thread so that future messages & patches get tracked correctly (and not as part of the original feature's CF entry). Hmm I forgot to add the documentation first. So I'll do that and post a v5 shortly. Yours, --=20 Paul ~{:-) pj@illuminatedcomputing.com