But isn't NULL and 0 a NULL? So wouldn't it need to evaluate X to determine if it was null, and thus discover it wasn't a valid column name and return an error?
David -------------------------------------------- On Thu, 12/19/13, Richard Hipp <[email protected]> wrote: Subject: Re: [sqlite] Does not detect invalid column name when subexpression optimized away To: "R Smith" <[email protected]>, "General Discussion of SQLite Database" <[email protected]> Cc: [email protected] Date: Thursday, December 19, 2013, 9:27 PM On Thu, Dec 19, 2013 at 6:36 PM, RSmith <[email protected]> wrote: > my guess is the optimiser pounces directly on the fact that (X and 0) > will always be 0 > Correct. The code is at http://www.sqlite.org/src/artifact/962c2988?ln=556-559 sqlite3ExprAnd() gets called to build the AND operator directly from the parser, long before any name resolution has occurred, and indeed before the expression has been fully parsed. As long as one side or the other of the AND operator does not have an egregious syntax error, if the other side evaluates to FALSE then the whole expression is coded as a FALSE literal. That code was added here: http://www.sqlite.org/src/info/f9a7e179cbbeeab5 -- D. Richard Hipp [email protected] _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

