Re: Adding a stored generated column without long-lived locks
Alberto Piai <alberto.piai@gmail.com>
From: Alberto Piai <alberto.piai@gmail.com>
To: Alberto Piai <alberto.piai@gmail.com>, pgsql-hackers@postgresql.org
Date: 2026-05-14T22:46:32Z
Lists: pgsql-hackers
Attachments
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