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 1wD8Gp-002de5-2N for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Apr 2026 21:59:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wD8Gm-002PDV-0k for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Apr 2026 21:59:36 +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 1wD8Gl-002PDM-2a for pgsql-hackers@lists.postgresql.org; Wed, 15 Apr 2026 21:59:35 +0000 Received: from mail-oo1-xc34.google.com ([2607:f8b0:4864:20::c34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wD8Gj-00000001DOQ-2i1J for pgsql-hackers@lists.postgresql.org; Wed, 15 Apr 2026 21:59:34 +0000 Received: by mail-oo1-xc34.google.com with SMTP id 006d021491bc7-67c250805ccso2532122eaf.1 for ; Wed, 15 Apr 2026 14:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776290373; cv=none; d=google.com; s=arc-20240605; b=VGI2WlHppmdQn8eDYA2FL6jKJm3H64wT3ffQ5Lp4iwzTFiQCBBTVlRx7qeYYZIdXWw QAUTwZt/dZGjjLznOsrtyCdCgSJIZ1X3IAri0o4/M1D/rH7pWFGa4ycQ2DL0TuRx5H6t JQX59DTL3hotXiombQcwg/6E2O3lI0YZDPyfLBtv/RcYItanoewR0ZrqIN1oLGwzEgOU C3D873EBj9WHzlqlCDa114XNq87GMQNvMFDTipiQpBEnxYtfW/FDEcmQD/CaMHYZIfXI y351phUEzlB1gG4C2hyH/zzzzV0O5XdwTm2c1C8qusEFfJCTLSmLE/0xQwmoY2HMDa0W mvFA== 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=AZ1WMsaNGZPs+9TzlinSIKRed1HFXxNJn91wI8pU0wg=; fh=bq8Bz8lfjvWmE7LwNp3RUbPsKIFzEvomdUFzDDTRwEo=; b=Yzj2GefLaU2C/f5+0CBs+F71SeRacOM1M2aGKe0nfZ2hjimWS3m6VKHwzYNRhLIyyn 5M6OLrTVzcjFlxcm9LTOOKSjTU0A3mP2WcHimiw+gv2yedAs8Yp5DdmyE9QcbSBHLkA9 iUbCmzlrhGc0IVQujoqKTYtNGC11zEoDc+j4AsGqgDh0sJ7X65oNG4Vzlwt0kUoLx4e9 tqtQF58gg8NSUmiBTz1oo+5Mo8pjdZ1iElsm94mNH3h61LKYdfQhsyQwcuvQsvbxy5bY 5/vUPNxnBQGax8vJ11GRDTYcVGh+2FXhTLAIVkwFQToSa3b85buZ4KBOPrgSwm5tqlqC 5qWQ==; 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=1776290373; x=1776895173; 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=AZ1WMsaNGZPs+9TzlinSIKRed1HFXxNJn91wI8pU0wg=; b=ZuPJg+FlyGHx3XwsvXm+sMQy26xEVU4C4I20Kkg2Pxr2PshuGdRh1P+a8QBU1r/Mfn RXrQedywyQn0lHLxBm6kDs7OzgMgthctfGH60QS01IUEBRyLXxaAX3eoDg4BFx3ihbOU eAHoFic8AJDr8VqkYk6pblabyvruHsY9SF8yIzsEjF/jBcWaRcYuTNqSW9Yq+9OYua1T vi4IyjnwyT/vqDbDS0/kfJXzFBKBCmKSvqkgvOTQxXOSsY4g/86dD7HRGO7MTzcHkQ0l 9n6B0R3x2Kqa5uL/KfOk8h6zbWWZi/QLMO8v6N32oSE/aDOB0NbH3qwPhBXOVppuBbKK 20Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776290373; x=1776895173; 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=AZ1WMsaNGZPs+9TzlinSIKRed1HFXxNJn91wI8pU0wg=; b=lFdbhsC9uGyg9Kp8xQICXmUqkx2RRdewzjJLZZuphb/NfVgVSTMEqpG1huIo8c2mx2 GA29WO4c8Bu8ySm9UX+xprEkY2y9mmiUwN3cETXxKQ43oQsZq4DuRw/DZrfo5H9UtFZW mV0CbDt8WekmfDGSrIYvjaZwRfYHRhSgdHLVNP4uGqpussOOoR9JOCQiJ2/F0BtnoG3+ aY2Xjsenzie2WR+XhFN5UTJhH72egnQI3cer/uA16XThTSIjraiLjIx2ZVnTclQTj0b2 /y8AvgvMijUUEIJsuiyYvv17ziQ0lf2MlJJgVwKtktDQXCBrCWxzbZXVKY/3TKJXWRXa 7yLg== X-Forwarded-Encrypted: i=1; AFNElJ8NTlgwUZuGyOnZfBTKgQDm6VCQJPkOaTnTdauu3jROCUK2gebB9xZthA5LHZqtnq3B4x0gj0RwGtUB0dCx@lists.postgresql.org X-Gm-Message-State: AOJu0YycMZ5ES/EB86LP6PycqvUEWDSn3IY7YJH+C7Wgn3SkemfBh8TU DPeSbIGO1nfBq1gPIkFCcKbXv75hj4IW2YwAHfhWl2e7GKr00FpFlXHTOmTyTK0OPronlagU+4+ wt7EDh8rp3m5qD0KQqRZequ7DBPRJILvUEW3kBjznmw== X-Gm-Gg: AeBDieupk5O/3+aj3XfdEh16GcDMLU/M3umS6QIFJkeoYJQlIr/YqTlVKozSA+/5vFu w/Uo0OtsbyVaJqJWFUHzKa/e/e+/Wn0MmStGseTrzbyew3LOSTnYp7EASWhTq87SZBY3E3buiku Qp6avN7RrdPrdcAE7DZJrxMVlAIibq+eK+kMFIt4ZJu8ldaEOKZDiTRD/mV3mgRLCCZYGzmKo6b dTj23H+5vPlwyI2X0bqP5h3O3u5wwKyvhzqovcsA8LPSIDz7wmRM3NR+6m8zSdaQI5zTknDyCCI eOges40sizE0dt0= X-Received: by 2002:a05:6820:4b01:b0:67e:160c:36c4 with SMTP id 006d021491bc7-68be7ceee88mr11824427eaf.29.1776290373310; Wed, 15 Apr 2026 14:59:33 -0700 (PDT) MIME-Version: 1.0 References: <53a13f97-340f-4d04-9dcc-77ca3ffb6a6a@eisentraut.org> <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, 15 Apr 2026 14:59:21 -0700 X-Gm-Features: AQROBzDl5qAG5O9T3Z9yYP22AZ442ZMDNYPwdGP3wmbP7yfArszvKF0wo18eFfg Message-ID: Subject: Re: SQL:2011 Application Time Update & Delete To: jian he 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 Mon, Apr 6, 2026 at 9:04=E2=80=AFPM jian he wrote: > > As you can see, ExecGetAllUpdatedCols does not account for the valid_at c= olumn, > even though it is actively being updated. ExecGetAllUpdatedCols is being = used > serval places, IMHO, we need to add some comments on > ExecGetAllUpdatedCols explaining > this behavior and maybe add some regression tests. > > I'm not sure if it's safe for ExecGetAllUpdatedCols to ignore the FOR > PORTION OF column. The other threads have found a couple problems with that now. I wonder if we should have ExecGetExtraUpdatedCols add the application-time attno to the returned bitmapset? Or even add it to updatedCols in analysis and then ignore it for permission checking. That seems more robust than finding all the places we need to add it, except updatedCols is in a struct called RTEPermissionInfo. Best of all I think would be to add a new bitmapset somewhere else and not use permissions infrastructure for GENERATED columns, UPDATE OF triggers, skipping CHECK constraints, etc. But is it too late in the cycle to make a change like that? In the short term, what about just doing this?: @@ -1449,6 +1449,7 @@ ExecGetAllUpdatedCols(ResultRelInfo *relinfo, EState *estate) oldcxt =3D MemoryContextSwitchTo(GetPerTupleMemoryContext(estate)); ret =3D bms_union(ExecGetUpdatedCols(relinfo, estate), + ExecGetForPortionOfCol(relinfo, estate), ExecGetExtraUpdatedCols(relinfo, estate)); MemoryContextSwitchTo(oldcxt); (Implementing that function is left as an exercise for the reader.) > transformForPortionOfClause > if (contain_volatile_functions_after_planning((Expr *) result->target= Range)) > ereport(ERROR, > (errmsg("FOR PORTION OF bounds cannot contain volatile > functions"))); > > Need > errcode(ERRCODE_FEATURE_NOT_SUPPORTED). Okay. > coerce_to_target_type function comment: > * This is the general-purpose entry point for arbitrary type coercion > * operations. Direct use of the component operations can_coerce_type, > * coerce_type, and coerce_type_typmod should be restricted to special > * cases (eg, when the conversion is expected to succeed). > > We should use coerce_to_target_type more, not can_coerce_type, > coerce_type individually. > coerce_to_target_type also handles `UNKNOWN` constant, which ensures > the deparsing casts to the correct data type. Including the casts when we deparse does seem like an improvement. The patch looks good to me. Yours, -- Paul ~{:-) pj@illuminatedcomputing.com