Re: tablecmds.c/MergeAttributes() cleanup
Alvaro Herrera <alvherre@alvh.no-ip.org>
On 2023-Dec-06, Peter Eisentraut wrote: > One of your (Álvaro's) comments about this earlier was > > > Hmm, crazy. I'm not sure I like this, because it seems much too clever. > > The number of lines that are deleted is alluring, though. > > > > Maybe it'd be better to create a separate routine that takes a single > > ColumnDef and returns the Form_pg_attribute element for it; then use > > that in both BuildDescForRelation and ATExecAddColumn. > > which was also my thought at the beginning. However, this wouldn't quite > work that way, for several reasons. For instance, BuildDescForRelation() > also needs to keep track of the has_not_null property across all fields, and > so if you split that function up, you would have to somehow make that an > output argument and have the caller keep track of it. Also, the output of > BuildDescForRelation() in ATExecAddColumn() is passed into > InsertPgAttributeTuples(), which requires a tuple descriptor anyway, so > splitting this up into a per-attribute function would then require > ATExecAddColumn() to re-assemble a tuple descriptor anyway, so this wouldn't > save anything. Hmm. Well, if this state of affairs is useful to you, then I withdraw my objection, because with this patch we're not really adding any new weirdness, just moving around already-existing weirdness. So let's press ahead with 0001. (I didn't look at 0002 this time, since apparently you'd like to process the other patch first and then come back here.) If you look closely at InsertPgAttributeTuples and accompanying code, it all looks a bit archaic. They seem to be treating TupleDesc as a glorified array of Form_pg_attribute elements in a convenient packaging. It's probably cleaner to change these APIs so that they deal with a Form_pg_attribute array, and not TupleDesc anymore. But we can hack on that some other day. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "Pensar que el espectro que vemos es ilusorio no lo despoja de espanto, sólo le suma el nuevo terror de la locura" (Perelandra, C.S. Lewis)
Commits
-
Fix segmentation fault in MergeInheritedAttribute()
- 8f0a97dfffc5 17.0 landed
-
Improve compression and storage support with inheritance
- 0413a556990b 17.0 cited
-
Split some code out from MergeAttributes()
- f7cf9494bad3 17.0 landed
-
MergeAttributes code deduplication
- 64444ce071f6 17.0 landed
-
Add a const decoration
- 924d046dcf55 17.0 landed
-
MergeAttributes: convert pg_attribute back to ColumnDef before comparing
- 4d969b2f85e1 17.0 landed
-
Refactor ATExecAddColumn() to use BuildDescForRelation()
- a1604237a6ff 17.0 landed
-
Move BuildDescForRelation() from tupdesc.c to tablecmds.c
- 04e485273b56 17.0 landed
-
Push attcompression and attstorage handling into BuildDescForRelation()
- 180e3394a704 17.0 landed
-
Push attidentity and attgenerated handling into BuildDescForRelation()
- 6d341407a6e3 17.0 landed
-
Add TupleDescGetDefault()
- ebf76f2753a9 17.0 landed
-
MergeAttributes() and related variable renaming
- b0ae29512c21 17.0 landed
-
Clean up MergeCheckConstraint()
- 369202bf4be6 17.0 landed
-
Clean up MergeAttributesIntoExisting()
- eddad679d2ab 17.0 landed
-
Remove useless if condition
- 6844d3275ac6 17.0 landed
- 689c66a84bb7 17.0 landed
-
Make more use of makeColumnDef()
- 1fa9241bdd0e 17.0 landed
-
Add some const decorations
- 2b088c8e4a2c 17.0 landed
-
Remove ancient special case code for dropping oid columns
- 7ef2912519fd 17.0 landed
-
Remove ancient special case code for adding oid columns
- 5eaa0e92ee2f 17.0 landed
-
Remove obsolete comment about OID support
- adf333b4edb2 17.0 landed