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 1wNepP-000yAe-2R for pgsql-hackers@arkaria.postgresql.org; Thu, 14 May 2026 22:46:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wNepO-00FQL5-0E for pgsql-hackers@arkaria.postgresql.org; Thu, 14 May 2026 22:46:50 +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 1wNepN-00FQKx-1s for pgsql-hackers@lists.postgresql.org; Thu, 14 May 2026 22:46:49 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wNepL-00000000eZE-0Z4t for pgsql-hackers@postgresql.org; Thu, 14 May 2026 22:46:49 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-83537a80ab6so5223239b3a.1 for ; Thu, 14 May 2026 15:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778798804; x=1779403604; darn=postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=w3q12ubELb9nr2msWZGIq3pk42Q0duSwssB0H2pl4Sg=; b=XkLESUqUvdlvER/28VTu4PMXoVQ7XjFo84zVrvfUcVx4edCPod+ytnNnn94gQqyLXf zAYEssQyoHZq6y5iPq/6RzzbIUhS2aqerIWl4c4l14XKkEsQy6zGiQMZHiUksgBwuT/c aNe+NMKdPsHRB3ahOZJJVmB2NrgGTSQH+sMB1+OFhWSV9G14sCu755oJr7J+af6HXtdk tj2ILoKZLbr+inllpTuFV3agDScML8ntL6dyRfOBOgfx22TT7Analu+BHqmznQ3WW7ba qNUwe0m9hc+RGR2kr8JbM2vo7osIF83TtVLEOYOZ9kw8M2AUeMlSTK7K4tJYUkJSKn5H CLeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778798804; x=1779403604; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w3q12ubELb9nr2msWZGIq3pk42Q0duSwssB0H2pl4Sg=; b=gNvQWaS596Pyi218JsJs4Ju1Gw5iri6VrXO7dDwmm8Vo42h1DEXz/ElWQQ1XcR2VB8 GUlnRO91KH/tWA2JYRm7VR3LX3xYnOfB/Rx8I9sX8iwnYClLV9gYWo8SuCa3D/XTWpRS Qa9Rpmc4Xe+MrUvKVAQcI9xMgjOz23Nhfn2bFpWtplDOycsILoX9+D6O6yBxUF/Yl0Yv 8dsboocTOcftoucsUltch68+J2QS4ZZqD65OUNHbSWwTbcnWqKKNUGs2/rHY4grjTqhd HGLMji42FYsUhU1obMtEvMRQQzobYV3w4hQ0ixNP07jL7srHWZAVWEh8oP1mI9bhR+Ao 73jA== X-Forwarded-Encrypted: i=1; AFNElJ+33D0livR5pPhwVN7snffAP0xxEEEFJkhJCmTdwN2lBuMkTxhCGvMPGm5ukKNeFlsiEXEdvpAQV1xuIY1n@postgresql.org X-Gm-Message-State: AOJu0YwJbXXDpYCFGTBiiCwVgn56AVs0YfI/ersrsHHUpimOQux+0Cs9 tkquTFu/amVUh1rln8AFIw2YYbnAW8I05qrSI12mIGu/y7W+CKPzOiX4 X-Gm-Gg: Acq92OHMDhMKG4UmJfuOokT+82GTYee8G/W/rhOXLR0LSH12mNm1C7LIw2ALWFSpKdW xsQGSFpxLGNYGpRqyWqAlW7iFHNhhENlaoEMRyUt150Fp1BpCAV6/ki2qKb9fWmj6QeU140PS7b GgaHYWopens/loWxMWQzJ3o4P0ENfLUwIv/kPWW2rnFVYQLKc9bjO8kGMbfn91NaMaaAEhgUtzr gA4yfnT74mNTeZ0G0r4+dJ9B4/QQBZJ0bfmidqlOjDYMSFOj9huCHb1IzdMPJPBcst97GJQEy/9 1fP5+XNeOlvolWwuMr0L1rkuJLmT0Tm/L2WedMTF24O5Q7ohWdSb7KuR36d4Yz1UC4QapDAf1+S k4P1P321SQxc03JSHSr8lrZMFiSpPlzyB04Mt4EC9soru4zaMnzoZoKUZ0YhQ5wKrvP9IgkBgdG Qpbh0xJAW7t1tMV3CN4LknRtOdv3c/mnGg8MMAz5lzX5uvFcNc+ws2BI2l2wb1u/iDWKO/CUzS4 8E= X-Received: by 2002:a05:6a00:1d82:b0:823:1c5f:1c43 with SMTP id d2e1a72fcca58-83f33de9fe3mr1413347b3a.36.1778798804489; Thu, 14 May 2026 15:46:44 -0700 (PDT) Received: from localhost (S0106749be81290d3.vn.shawcable.net. [24.85.172.38]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f19c5c3a9sm3800263b3a.38.2026.05.14.15.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2026 15:46:41 -0700 (PDT) Date: Thu, 14 May 2026 15:46:32 -0700 From: Alberto Piai To: Alberto Piai , pgsql-hackers@postgresql.org Subject: Re: Adding a stored generated column without long-lived locks Message-ID: X-Mailer: aerc 0.21.0 References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="zfrmj4necy5zy3mo" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --zfrmj4necy5zy3mo Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Fri Apr 24, 2026 at 2:10 AM PDT, Alberto Piai wrote: > On Tue Apr 7, 2026 at 5:02 PM +08, Alberto Piai wrote: >> On Tue Mar 17, 2026 at 5:31 PM +07, Alberto Piai wrote: >> >>> I recently needed to add a stored generated column to a table of >>> nontrivial size, and realized that currently there is no way to do >>> that without rewriting the table under an AccessExclusiveLock. The attached v4 is a rebase against current master, plus: - I moved the call to RememberAllDependentForRebuilding before the update to pg_attribute, since it provides checks for some invalid/unsupported invocations it seems more useful to do it before changing anything. - I hadn't noticed before that AddRelationNewConstraints returns the new (cooked) default definitions, so we can use those instead of building them again. - cleaned up some includes I had added by mistake, and moved some tests around between the two commits A while back I also posted a fix for the issue of DROP EXPRESSION not working with subpartitions [1], this patch isn't ajusted yet to match, I would do that if the bugfix would be committed first. I am still hoping to get a reviewer for the in-person commitfest at the upcoming pgconf.dev :) It's my first contribution, but the change is pretty self-contained and hopefully not terribly complex to review. I'm trying to address a real world use case, it would be fantastic to make some progress with this patch. Anyone's motivated? :) Regards, Alberto [1] https://www.postgresql.org/message-id/DHMT78XOD8BK.341V3H87KZ7NO%40gmail.com -- Alberto Piai Sensational AG Zürich, Switzerland --zfrmj4necy5zy3mo Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="v4-0001-Support-changing-a-column-into-a-stored-generated.patch"