> 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).
My first thought was that it essentially would work as you describe
above--if the expression is volatile, evaluate the argument first and
then evaluate the expression, otherwise replace the parameter within
the subexpression. But then I realized that you didn't actually say
that is what the BETWEEN node would be doing :) I suppose any extra
logic would have to be present in some translation function to deal
with the let node, so effectively it would be special-cased anyway.
>
> 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
That's a good point, I suppose I'll just have to wait for this feature
to be added to the SQL standard :)
--
Josh