Re: Questions about parser code - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Questions about parser code
Date
Msg-id 3172.1170176022@sss.pgh.pa.us
Whole thread Raw
In response to Questions about parser code  (Gregory Stark <stark@enterprisedb.com>)
Responses Re: Questions about parser code  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: "J. Andrew Rogers"
Date:
Subject: Re: pgsql: Fix for plpython functions; return true/false for boolean,
Next
From: Tom Lane
Date:
Subject: Re: standard_conforming_strings 'on' for 8.3?