Gregory Stark <stark@enterprisedb.com> writes:
> Is it ok to scribble on and reuse objects from the parse tree when generating
> the transformed tree? Or should the transformed query object be built from
> freshly allocated nodes?
We do both already; take your pick. If you do the former, though,
I suggest designing the code so that it's a no-op on an
already-transformed node. It used to be the case that the grammar
could generate multiple references to the same subtree (e.g., by
transforming "x BETWEEN y AND z" to "x >= y AND x <= z") and I'm not
sure we have removed all such shortcuts.
There's some logical cleaniness to using different node types for raw
and transformed trees, but when there's a simple one-for-one
correspondence this is probably overkill.
regards, tom lane