Re: automatically generating node support functions

Peter Eisentraut <peter.eisentraut@enterprisedb.com>

From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2021-06-08T17:45:58Z
Lists: pgsql-hackers
On 08.06.21 15:40, David Rowley wrote:
> It's almost 2 years ago now, but I'm wondering if you saw what Andres
> proposed in [1]?  The idea was basically to make a metadata array of
> the node structs so that, instead of having to output large amounts of
> .c code to do read/write/copy/equals, instead just have small
> functions that loop over the elements in the array for the given
> struct and perform the required operation based on the type.

That project was technologically impressive, but it seemed to have 
significant hurdles to overcome before it can be useful.  My proposal is 
usable and useful today.  And it doesn't prevent anyone from working on 
a more sophisticated solution.

> There were still quite a lot of unsolved problems, for example, how to
> determine the length of arrays so that we know how many bytes to
> compare in equal funcs.   I had a quick look at what you've got and
> see you've got a solution for that by looking at the last "int" field
> before the array and using that. (I wonder if you'd be better to use
> something more along the lines of your pg_node_attr() for that?)

I considered that, but since the convention seemed to work everywhere, I 
left it.  But it wouldn't be hard to change.



Commits

  1. Fix MSVC build script's check for obsolete node support functions.

  2. Improve performance of ORDER BY / DISTINCT aggregates

  3. doc: Fix typos in protocol.sgml

  4. Tighten up parsing logic in gen_node_support.pl.

  5. Add defenses against unexpected changes in the NodeTag enum list.

  6. Add copy/equal support for XID lists

  7. Rationalize order of input files for gen_node_support.pl.

  8. Make assorted quality-of-life improvements in gen_node_support.pl.

  9. Doc: rearrange high-level commentary about node support coverage.

  10. Automatically generate node support functions

  11. Adjust node serialization tag of A_Expr for consistency

  12. Remove T_Join and T_Plan

  13. Reformat some more node comments

  14. Reformat some node comments

  15. Remove JsonPathSpec typedef

  16. Add missing enum tag in enum used in nodes

  17. Add Cardinality typedef

  18. Make node output prefix match node structure name

  19. Add WRITE_INDEX_ARRAY

  20. Add COPY_ARRAY_FIELD and COMPARE_ARRAY_FIELD

  21. Remove T_Expr

  22. Change NestPath node to contain JoinPath node

  23. Change SeqScan node to contain Scan node

  24. Check the size in COPY_POINTER_FIELD

  25. Remove T_MemoryContext

  26. Add missing enum tags in enums used in nodes

  27. Rename some node support functions for consistency

  28. Rename argument of _outValue()

  29. Rename NodeTag of ExprState