Re: ALTER TABLE ADD COLUMN fast default
Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
From: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2017-12-12T19:13:20Z
Lists: pgsql-hackers
On 12/06/2017 11:26 AM, Andrew Dunstan wrote: >> In general, you need to be thinking about this in terms of making sure >> that it's impossible to accidentally not update code that needs to be >> updated. Another example is that I noticed that some places the patch >> has s/CreateTupleDescCopy/CreateTupleDescCopyConstr/, evidently because >> the former will fail to copy the missing-attribute support data. >> I think that's an astonishingly bad idea. There is basically no situation >> in which CreateTupleDescCopy defined in that way will ever be safe to use. >> The missing-attribute info is now a fundamental part of a tupdesc and it >> has to be copied always, just as much as e.g. atttypid. >> >> I would opine that it's a mistake to design TupleDesc as though the >> missing-attribute data had anything to do with default values. It may >> have originated from the same place but it's a distinct thing. Better >> to store it in a separate sub-structure. > > OK, will work on all that. Thanks again. > Looking closer at this. First, there is exactly one place where the patch does s/CreateTupleDescCopy/CreateTupleDescCopyConstr/. making this like atttypid suggests that it belongs right outside the TupleConstr structure. But then it seems to me that the change could well end up being a darn site more invasive. For example, should we be passing the number of missing values to CreateTemplateTupleDesc and CreateTupleDesc? I'm happy to do whatever work is required, but I want to have a firm understanding of the design before I spend lots of time cutting code. Once I understand how tupdesc.h should look I should be good. cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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