On 12/20/2013 11:11 AM, David Bicking wrote:
But isn't NULL and 0 a NULL?

I don't think it is. NULL really means unknown. The result of
"0 AND unknown" is not "unknown", it is 0. By contrast the
result of "0 OR unknown" really is unknown:

  sqlite> SELECT (0 OR NULL);
  null

"1 OR unknown" is not unknown, it is 1. And so on. To summarize:

  sqlite> SELECT (0 AND NULL), (1 AND NULL), (0 OR NULL), (1 OR NULL);
  0|null|null|1

Dan.





David

--------------------------------------------
On Thu, 12/19/13, Richard Hipp <d...@sqlite.org> wrote:

  Subject: Re: [sqlite] Does not detect invalid column name when subexpression 
optimized away
  To: "R Smith" <rsm...@rsweb.co.za>, "General Discussion of SQLite Database" 
<sqlite-users@sqlite.org>
  Cc: amb...@math.bme.hu
  Date: Thursday, December 19, 2013, 9:27 PM
On Thu, Dec 19, 2013 at
  6:36 PM, RSmith <rsm...@rsweb.co.za>
  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
  d...@sqlite.org
  _______________________________________________
  sqlite-users mailing list
  sqlite-users@sqlite.org
  http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to