Re: tablecmds.c/MergeAttributes() cleanup

Alvaro Herrera <alvherre@alvh.no-ip.org>

From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2023-08-29T12:09:31Z
Lists: pgsql-hackers
On 2023-Aug-29, Peter Eisentraut wrote:

> From 471fda80c41fae835ecbe63ae8505526a37487a9 Mon Sep 17 00:00:00 2001
> From: Peter Eisentraut <peter@eisentraut.org>
> Date: Wed, 12 Jul 2023 16:12:35 +0200
> Subject: [PATCH v2 04/10] Add TupleDescGetDefault()
> 
> This unifies some repetitive code.
> 
> Note: I didn't push the "not found" error message into the new
> function, even though all existing callers would be able to make use
> of it.  Using the existing error handling as-is would probably require
> exposing the Relation type via tupdesc.h, which doesn't seem
> desirable.

Note that all errors here are elog(ERROR), not user-facing, so ISTM
it would be OK to change them to report the relation OID rather than the
name.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"In fact, the basic problem with Perl 5's subroutines is that they're not
crufty enough, so the cruft leaks out into user-defined code instead, by
the Conservation of Cruft Principle."  (Larry Wall, Apocalypse 6)



Commits

  1. Fix segmentation fault in MergeInheritedAttribute()

  2. Improve compression and storage support with inheritance

  3. Split some code out from MergeAttributes()

  4. MergeAttributes code deduplication

  5. Add a const decoration

  6. MergeAttributes: convert pg_attribute back to ColumnDef before comparing

  7. Refactor ATExecAddColumn() to use BuildDescForRelation()

  8. Move BuildDescForRelation() from tupdesc.c to tablecmds.c

  9. Push attcompression and attstorage handling into BuildDescForRelation()

  10. Push attidentity and attgenerated handling into BuildDescForRelation()

  11. Add TupleDescGetDefault()

  12. MergeAttributes() and related variable renaming

  13. Clean up MergeCheckConstraint()

  14. Clean up MergeAttributesIntoExisting()

  15. Remove useless if condition

  16. Make more use of makeColumnDef()

  17. Add some const decorations

  18. Remove ancient special case code for dropping oid columns

  19. Remove ancient special case code for adding oid columns

  20. Remove obsolete comment about OID support