Joshua Yanovski <pythonesque@gmail.com> writes:
> That sounds like it should work. I was also wondering whether it
> might be possible to do this more generally with some kind of "let"
> internal node:
> (let var = x in (var >= y and var <= z)
> I don't know enough about the planner or the SQL standard to know
> whether this would work, but it does seem a little nicer than
> special-casing BETWEEN to me.
Hmm ... interesting idea, but I don't think it answers any of the
fundamental issues about comparison semantics (ie, how much do we
care if "var" is promoted differently in the two clauses).
Also, as a grammar translation target for BETWEEN it would be a pretty
bad choice, because now views that had been defined in a perfectly
SQL-compliant manner would print out with very-PG-specific syntax.
The existing translation is nasty because of the double eval issue,
but at least what we print is standard SQL.
regards, tom lane