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 1wCstP-002Oel-06 for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Apr 2026 05:34:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wCstN-00Egqn-0G for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Apr 2026 05:34:25 +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.96) (envelope-from ) id 1wCstM-00EgqS-2a for pgsql-hackers@lists.postgresql.org; Wed, 15 Apr 2026 05:34:25 +0000 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wCstL-000000015bc-1W1A for pgsql-hackers@lists.postgresql.org; Wed, 15 Apr 2026 05:34:24 +0000 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-7dbec19732eso5729233a34.3 for ; Tue, 14 Apr 2026 22:34:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776231263; cv=none; d=google.com; s=arc-20240605; b=DuYgWzSohKlJfVJ9L6wORN7TMP3IhPh86ufu6WBIw9cAw/BTa7Qtv987NlI0s2QwIh 9EUTozzmVP/lW/fBuU58Xi6q+kcFyBHg0qXSI4ShYlg6QuuXcg4iayCswDoXILI+TQoh /s9nzTnOEL52AxbrSQ/MD0MKuLSyNdcg6aN6thtQCb1/GBKOcFa/kZQzOrs6zib8O6n4 7CB8RDiKcZrH2ybMgZfFa+mJWp2ZnKMXTVaCH4pHT5auydtRfS45o6TEMnGgTs4JFpL8 tMdhRkNFkPfKCrlSviGSJUrFGAmQSs63voIc2JsYVXQA0prGMgZD6vAJ+Iigzlk3UuW0 Fi+w== 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=JMLD3K0KyPQwcvS7i0q6ODCPwagO6Dap0VpEsaiXp80=; fh=1rlA/9/QyKD7uEug7YSWTZCS1a5XochpYm81G98TLF4=; b=HPksE+wPuAiW80V9sAVmxWYwGJ5rUs90Tx3hG9yxMH/fG15nW4BwyjI/CnzZyMIiJD hNMwfK8ze7AQv1RIcmSQKf4BA9wPIbeCMpbvORw718KNXlD75RLGv2P2tHDTOj+Gypkk ebx5Z41HDQ09wTslzr7CZjZP8wzAdWhdr5P5JZyXjIDRDY7HPN7yziQ7oQ2fPY2lZJzK YOOPqs/v/4o93LmezjtlhU+wRRYzHhhjHe9YL9jxQ8aqIl6N/RsKjRh0FwQJoi5lmYXO kpLkL9Bdd0uBVSUmoQxP5BgksoTMrqjWNjEZqaVfEencOeHC8vii+VgDixXuAI3bQ8Yn p8ww==; 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=1776231263; x=1776836063; 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=JMLD3K0KyPQwcvS7i0q6ODCPwagO6Dap0VpEsaiXp80=; b=ldl2lc8hIpaBnvn44fh/TAL+Kr4uJyCo3ASrtKLcE7V76XlSE1SFIttlZnCAp2ecXv gSD/tOpWoS+SNp3aoZhvAAI+cWXQw0ZwYPn3XIeG46BEfdXffkfiydXymcGoA8OE1mhV OYkV53LSaK/pkorxDHTOvB6m7LhuQK0MjgudcBQ20L5rI02x4zmBm7yYkGLyx7Nx7ihn DZFjkfTQjw42p8HSuBYzDjah1Yps6epjzNQp4WRCZM0Jtde+od58zRmLUYtKnnDRjVNI d8QJb33QYr0oobHz1ZKJ9lPde2NoEb7kHJ01RoR+MulrkaHDPlBRki0GWp5ho21wK8Md jFQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776231263; x=1776836063; 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=JMLD3K0KyPQwcvS7i0q6ODCPwagO6Dap0VpEsaiXp80=; b=kRI44SNJOtpbMRUY0OL6Rud8I1lgkuDUHi1KPvjDVKKXPCBQYudTB5+y/muBc01nQ3 CSAj5b/+ruxedUIsRfvtf6WwDJ2XFSbcRYjYdRtcVwfQ8amb2DOLLwd15MKARu40EX3b Bd9tHKe/BF5cKYGqEMECn0HfOMQK+GO+Uzc36AIMSrLT11mNyNgEvrEU7GusNptBhHox SOyfnEJRVLpnYHda7FnJFUUnKNUiRT7Ymfd8yIjNtu+C0kKU/cj+VkMqlHxfc42hICbm vtIiMMAI7hu7ObCIuTUw5vvMNHSre90PJMsmHdhW4HrLfrTtj16rw3ivjLgJC+mmCXQ9 rTww== X-Forwarded-Encrypted: i=1; AFNElJ9H4Sr27Iuji4HIIGJuNEZarH62RE0EMEYXIE4bkCn1w+f92L+AwyyWxuw1QpCw+Rj/9D0Ys9vMRlRS8uMO@lists.postgresql.org X-Gm-Message-State: AOJu0YyEdI/Mhf49PXUVR2liDDYGIe/0gi5YWx9xdJmw8RGqGno1Qtwu W8bTb9jqi+FvhipS8kCS6SjeLNpEll0+cUlNjmCIRZjCjU5/Jsh5qwopmaEXKKHpvqyEN/dyfrv f4aIp0uymJkC0mwIswvsZggkBp3gt9W5Wj5dMre7M0w== X-Gm-Gg: AeBDiesmN+/9VCgihTngqzbVBv+C+hlmastq6QjoNTOEzxi2wIqZBkn0gGAlFx8dcxz JRHS1sMDEW4ZUjDxW+oUy6EojmuX5QIhDFr3J1Tc4zuGaNgtcOV+tANqrUSoiJhVct5u5qPXBXM V6kgpLNutJZH9ogRtDm+cvDG6unRxQ7NQL1ot0kjzM9bugX+qkT33anuJr/s/1GWL20hZzamEy/ LWASii5SiiEmzRC4+tv4uCUjBBIicB84cPzR+TJeysqbOh9KoycAg1wiaKEUElFxL4j0uK/Szwz hJpvn0QZ0YDwsW/5YcSKt/yMrQ== X-Received: by 2002:a05:6820:2d4a:b0:68d:b678:713e with SMTP id 006d021491bc7-68db6787522mr7293739eaf.31.1776231263075; Tue, 14 Apr 2026 22:34:23 -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: Tue, 14 Apr 2026 22:34:11 -0700 X-Gm-Features: AQROBzCtGVomibur-t1xjxWz9T-dZSs7rm_Fg0VBUUxSPMLIRDilZ4c0ermqIIQ Message-ID: Subject: Re: SQL:2011 Application Time Update & Delete To: SATYANARAYANA NARLAPURAM Cc: 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 Tue, Apr 7, 2026 at 7:32=E2=80=AFAM SATYANARAYANA NARLAPURAM wrote: > > Hi Peter, Paul, > > Please see a few bug reports related to this at [1], [2], [3]. Thanks for collecting all these bugs together and for already working on patches for them! I've started going through them; I'll respond to each thread individually. For the bug here (widening the range in a BEFORE UPDATE trigger), see below= : > Additionally, it appears there is another issue here: > > A BEFORE UPDATE trigger that modifies the range column creates overlappi= ng rows. The trigger widening the range doesn't affect leftover computation= , which uses the original FPO bounds. Result: updated row overlaps both lef= tovers. > > SET datestyle TO ISO, YMD; > > CREATE TABLE fpo_trigger_overlap ( > id int, > valid_at daterange, > val text > ); > > -- BEFORE UPDATE trigger that resets the range to the full year > CREATE FUNCTION widen_range() RETURNS trigger AS $$ > BEGIN > NEW.valid_at :=3D daterange('2024-01-01', '2025-01-01'); > RETURN NEW; > END; > $$ LANGUAGE plpgsql; > > CREATE TRIGGER trg_widen BEFORE UPDATE ON fpo_trigger_overlap > FOR EACH ROW EXECUTE FUNCTION widen_range(); > > INSERT INTO fpo_trigger_overlap > VALUES (1, '[2024-01-01, 2025-01-01)', 'original'); > > UPDATE fpo_trigger_overlap > FOR PORTION OF valid_at FROM '2024-04-01' TO '2024-09-01' > SET val =3D 'modified'; > > > -- Detect overlaps (should be 0 rows for correct behavior): > SELECT a.valid_at AS range_a, a.val AS val_a, > b.valid_at AS range_b, b.val AS val_b > FROM fpo_trigger_overlap a, fpo_trigger_overlap b > WHERE a.ctid < b.ctid AND a.valid_at && b.valid_at; > > -- cleanup > DROP TABLE fpo_trigger_overlap; > DROP FUNCTION widen_range(); I'm working on a fix for this. It's not quite ready, but I can finish it in the morning. . . . Yours, -- Paul ~{:-) pj@illuminatedcomputing.com