Add some error cross-checks to gen_node_support.pl

Enterprise / PostgreSQL - Tom Lane [sss.pgh.pa.us] - 2 December 2022 20:09 UTC

Check that if we generate a call to copy, compare, write, or read a specific node type, that node type does have the appropriate support function. (This doesn't protect against trying to invoke nonexistent code when considering generic field types such as "Node *", but it seems like a useful check anyway.)

Check that array_size() refers to a field appearing earlier in the struct. Aside from catching obvious errors like a misspelled field name, this protects against a more subtle mistake: if the size field appears later in the struct than the array field, then compare and read functions would misbehave. There is actually exactly that situation in PlannerInfo, but it's okay since we do not need compare or read functionality for that (today anyway).

Discussion: https://postgr.es/m/263413.1669513145@sss.pgh.pa.us

b6bd5def3a Add some error cross-checks to gen_node_support.pl.
src/backend/nodes/gen_node_support.pl | 62 +++++++++++++++++++++++++++--------
1 file changed, 49 insertions(+), 13 deletions(-)

Upstream: git.postgresql.org


  • Share