Remove custom Constraint node read/write implementations
authorPeter Eisentraut <peter@eisentraut.org>
Thu, 22 Feb 2024 06:07:12 +0000 (07:07 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 22 Feb 2024 06:07:12 +0000 (07:07 +0100)
commitfbc93b8b5f59cfb23c22a26a46ca7bcc826be442
treeafd31cd4181910e432be584c5cea8b19a72430b9
parent801792e528d6cb5eeb3a70f5ceb10b15bf92f0c7
Remove custom Constraint node read/write implementations

This is part of an effort to reduce the number of special cases in the
automatically generated node support functions.

Allegedly, only certain fields of the Constraint node are valid based
on contype.  But this has historically not been kept up to date in the
read/write functions.  The Constraint node is only used for debugging
DDL statements, so there are no strong requirements for its output,
and there is no enforcement for its correctness.  (There was no read
support before a6bc3301925.)  Commits e7a552f303c and abf46ad9c7b are
examples of where omissions were fixed.

This patch just removes the custom read/write implementations for the
Constraint node type.  Now we just output all the fields, which is a
bit more than before, but at least we don't have to maintain these
functions anymore.  Also, we lose the string representation of the
contype field, but for this marginal use case that seems tolerable.
This patch also changes the documentation of the Constraint struct to
put less emphasis on grouping fields by constraint type but rather
document for each field how it's used.

Reviewed-by: Paul Jungwirth <pj@illuminatedcomputing.com>
Discussion: https://www.postgresql.org/message-id/flat/4b27fc50-8cd6-46f5-ab20-88dbaadca645@eisentraut.org
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/include/nodes/parsenodes.h