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 1wLbKq-001tU0-2z for pgsql-hackers@arkaria.postgresql.org; Sat, 09 May 2026 06:38:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wLbKp-00CY0R-1v for pgsql-hackers@arkaria.postgresql.org; Sat, 09 May 2026 06:38:47 +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 1wLbKp-00CY0B-0b for pgsql-hackers@lists.postgresql.org; Sat, 09 May 2026 06:38:47 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wLbKm-00000000wh1-0rfD for pgsql-hackers@lists.postgresql.org; Sat, 09 May 2026 06:38:46 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-2b9e9a6802aso10707645ad.3 for ; Fri, 08 May 2026 23:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778308723; x=1778913523; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OXl0wXZPeueP96Mr7CzTxOgE6gsvpuMgy5LZGq/W8tA=; b=ZOF/R8/vehsd1La7pO/aOtAmbgcbtrFAX7rwCdK1HV4b6DSg2hZkaF5FVPOOeN8mk1 /7PhVGKg4zQQgp5lNPghm3pmb8Wh9l33O1vPD3pVZZhk37iaNRF7nGrNMJjSGPewYNIH aXDZqioZuSpCkHyWpe6dDsbaEkV+sw3lso5Menhb/kxBKZ/bpSSCIgb+6J9pZkMbBfMr BkEBahuNuFX2M51APe0yaMjTplWM7P01lfsSK3w2Qr/b95LDHUx5waZvmXo4ae8fX+qL Tnr8ymrJITJt4VVz4MDzSBNeJm26Yi4gpzEW307lqKk50hpaQVPKcEaTRnVPNg07vw0c xbOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778308723; x=1778913523; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=OXl0wXZPeueP96Mr7CzTxOgE6gsvpuMgy5LZGq/W8tA=; b=akq++18WVwkAnwjkZyKkat4MzJyijU1G3Hnzi/ZT9/A9seSX4+Z7C/2cHWHDgFcIH4 59wZEG+HrQHyYxK3Zy0g4XvrM1AsZWc+WW30oTUJzOsDfHkk54hBxeU/Vad1Jyg2dKjE MfVwTqaRNK9L1dbnsPlXTO8q0Wg6NpY4ey+v0T9XwC8bIDXvReRqkjG+u68y78+iT40v mqL5O7o5CZRXVvvxkxRtZGoFyhky3OrYRHiGGZiSTyD2AxCaVo8vvEJ7CyjkfgrjtF39 rJaExs1+dsZRhUPOVbGQz/1T0+HUUTXcq0kDnRZs3NkWMnWLkxexFrrgopOibSK/xR9C xfPQ== X-Forwarded-Encrypted: i=1; AFNElJ8tok+nOx4b2rngncGotEjd0NXBDYS21+DT1nn+j5VUoEJakPDb1zYtd95EwfXcBtCGDANFg3xkbIqnYW0a@lists.postgresql.org X-Gm-Message-State: AOJu0YzEj4H257xzUUoEh4yO2GqNJ6peSc9bM6s/nB9oCsGAjFAF7m8H bSDYHJC9If2qZ0yp04QkjVutnc31XyO0ve8k1I3tOFrns6HKurKZSakY X-Gm-Gg: Acq92OFrcskggr4k82+B1HfWMaiJbTKKoapjVOaVED03ePEERSq7l66WbySkdoljhsD Ya6hApmIc8Bh/t6YO7KoT3GHNM6eM1IXfx8hfRiWHzwc++30bwzGD9eOqnv0VR1By2IUxQJ6tgU Rnx4HkrlJ5TtHA8sygksZQQGRs9cqLRH4gdQKcG3PBZS8Uj7EHrIkv1pidGPy6E1t1kLFNmPs5T JJcNl9V8b2/JXqL8D5eqLD78rjTa0Jh17izH9aGgj0M2dK32gzOHAJRraiqyr2eqwtJx5L2ZHjY NzMXMYVWCe2Q430EKVeBCc8ovsXia9UVBIOymQ5OeIJYP5zzQRMEVSkjJ30J6UOFE1+m+o4nIeV LrH/MkBwN1QY5UpesIWiFwcSNkjLM/zTyUxA8MXJQerz6WDSPNzPrpkghBZXcMEZFPR/UZMFF+j jEvv7l8wgTh9rb82dutDq+mb5DgkAXAKo= X-Received: by 2002:a17:903:2d2:b0:2b9:4941:7f6e with SMTP id d9443c01a7336-2baf0cf399emr62088065ad.2.1778308723045; Fri, 08 May 2026 23:38:43 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e75fffsm40552755ad.59.2026.05.08.23.38.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 May 2026 23:38:42 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: FOR PORTION OF does not recompute GENERATED STORED columns that depend on the range column From: Chao Li In-Reply-To: Date: Sat, 9 May 2026 14:38:03 +0800 Cc: Peter Eisentraut , jian he , SATYANARAYANA NARLAPURAM , PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: References: <27BD5D23-19C9-4FD1-8935-9C788C3C9869@gmail.com> <66C1555B-CA54-4ED1-AB4F-0EE97D24A006@gmail.com> <91B35E0F-5DC1-4417-A1B9-FAF4A3DCD2BD@gmail.com> <74C1863C-2C2A-423A-BDE7-0228889F1D80@gmail.com> To: Paul A Jungwirth X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On May 8, 2026, at 23:25, Paul A Jungwirth = wrote: >=20 > On Fri, May 8, 2026 at 12:10=E2=80=AFAM Chao Li = wrote: >>> = >>=20 >> Thanks for updating the patch and making the separation. After = reading v11, I still have a few comments for 0001. >>=20 >> ``` >> + if (relinfo->ri_forPortionOf) >> + { >> + AttrNumber rangeAttno =3D = relinfo->ri_forPortionOf->fp_rangeAttno; >> + >> + if (!bms_is_member(rangeAttno - = FirstLowInvalidHeapAttributeNumber, >> + updatedCols)) >> + { >> + MemoryContext oldContext; >> + >> + oldContext =3D = MemoryContextSwitchTo(estate->es_query_cxt); >> + >> + updatedCols =3D bms_copy(updatedCols); >> + updatedCols =3D >> + bms_add_member(updatedCols, >> + rangeAttno = - FirstLowInvalidHeapAttributeNumber); >> + >> + MemoryContextSwitchTo(oldContext); >> + } >> } >> ``` >>=20 >> 1. I don=E2=80=99t think we should unconditionally do bms_copy, only = if (updatedCols =3D=3D perminfo->updatedCols), we need to make the copy. >=20 > You're saying we can skip the copy if execute_attr_map_cols already > made a new bms above. That's true. Since we're going to just use the > current memory context (see below), that seems safe. >=20 >> 2. I doubt if we need to switch to estate->es_query_cxt. Because = ExecGetUpdatedCols() is called by ExecGetAllUpdatedCols(), and its = header comment says the function runs in per-tuple memory context: >> ``` >> /* >> * Return columns being updated, including generated columns >> * >> * The bitmap is allocated in per-tuple memory context. It's up to the = caller to >> * copy it into a different context with the appropriate lifespan, if = needed. >> */ >> Bitmapset * >> ExecGetAllUpdatedCols(ResultRelInfo *relinfo, EState *estate) >> ``` >>=20 >> So I think bms_copy and bms_add_member should be just done in the = current memory context. >=20 > Okay. I think using the current memory context is more correct anyway. > There are other callers, and using the query memory context isn't > necessarily what they want. Also the bms (potentially) allocated by > execute_attr_map_cols is in the current memory context, so doing > something different feels surprising. And it's safer not to change the > behavior. Maybe there is a memory leak because of a long-lived > context, but then it exists already. I added a comment to > ExecGetUpdatedCols to call out that we use the current memory context. >=20 >> 3. "rangeAttno - FirstLowInvalidHeapAttributeNumber=E2=80=9D appears = twice, maybe add a local variable to avoid the duplication. >=20 > Okay. >=20 > v12 attached. >=20 > Yours, >=20 > --=20 > Paul ~{:-) > pj@illuminatedcomputing.com > = Thanks for updating the patch. I have no more comment. V12 LGTM. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/