Re: ALTER TABLE ADD COLUMN fast default
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Petr Jelinek <petr.jelinek@2ndquadrant.com>,
Tomas Vondra <tomas.vondra@2ndquadrant.com>,
Andrew Dunstan <andrew.dunstan@2ndquadrant.com>,
Thomas Munro <thomas.munro@enterprisedb.com>,
David Rowley <david.rowley@2ndquadrant.com>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2018-02-20T18:50:54Z
Lists: pgsql-hackers
Andres Freund <andres@anarazel.de> writes: > On 2018-02-20 13:07:30 -0500, Tom Lane wrote: >> I can easily think of problems that will ensue if we try to support that >> case, because right now the toast mechanisms assume that OOL toasted >> values can only be referenced from the associated table. > What problem are you seeing with treating the toasted value to be from > pg_attribute? I'm only drinking my first coffee just now, so I might be > missing something... Locking/vacuuming is exactly what I'm worried about. Right now, a transaction cannot reference a toast value without holding at least AccessShare on the parent table. That would not be true of OOL fast defaults that are living in pg_attribute's toast table (if it had one). If you think this isn't potentially problematic, see the problems that forced us into hacks like 08e261cbc. I guess the fix equivalent to 08e261cbc would be to require any toasted fast-default value to be detoasted into line whenever it's copied into a tupledesc, rather than possibly being fetched later. > Now we certainly would need to make sure that the corresponding > pg_attribute row containing the default value doesn't go away too early, > but that shouldn't be much of a problem given that we never remove > them. I wondered for a second if there's problematic cases where the > default value is referenced by an index, and then the default-adding > transaction rolls back. But I can't construct anything realistically > problematic. Oooh ... but no, because we don't allow toasted values to be copied into indexes, for (I think) exactly this reason. See index_form_tuple. regards, tom lane
Commits
-
Clean up treatment of missing default and CHECK-constraint records.
- 091e22b2e673 14.0 landed
-
Fast ALTER TABLE ADD COLUMN with a non-NULL default
- 16828d5c0273 11.0 landed
-
Fix application of identity values in some cases
- 533c5d8bddf0 11.0 cited