That's not true. SQLite doesn't have to discard that information after performing the substitutions. It can use it later for optimizations.
I know that SQLite allows it. I'm not complaining about anything. Have a look at my original question, which is, restated: What is the rationale behind disallowing using aliases in the body of statements? I think it's an important question since it's obviously easier (trivial) to do common sub-expression elimination with aliases and it's clearly easier for humans to write correct code using them. I'm wondering what the evils of aliases in bodies are, because I can't think of any. Maybe its because SQL(ite) always wants to reevaluate expressions wherever they occur, and the implied semantics of body aliases run counter to this. If that's the case, my next question would be why that behavior is desirable. On Sat, Sep 5, 2015 at 11:55 AM, Simon Slavin <slavins at bigfraud.org> wrote: > > On 5 Sep 2015, at 7:07pm, Darko Volaric <lists at darko.org> wrote: > > > That's not a valid reason since it's trivial for SQLite to transform > > aliases by substituting their names with their definitions. It could be > > handled in the parser code. > > And by doing that you would not get optimization, since SQLite would have > to work out the value once for the WHERE clause and once for the selected > value. Which is what SQLite does now. Which is what you are complaining > about in this thread. > > Remember: SQLite /does/ do this, even though it's not required by the SQL > standard. > > Simon. > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >