Re: [sqlite] Does not detect invalid column name when subexpression optimized away

2013-12-23 Thread Hick Gunter
> > >-Ursprüngliche Nachricht- >Von: RSmith [mailto:rsm...@rsweb.co.za] >Gesendet: Freitag, 20. Dezember 2013 14:20 >An: General Discussion of SQLite Database >Betreff: Re: [sqlite] Does not detect invalid column name when subexpression >optimized away > &g

Re: [sqlite] Does not detect invalid column name when subexpression optimized away

2013-12-20 Thread RSmith
On 2013/12/20 14:09, Simon Slavin wrote: On 20 Dec 2013, at 12:05pm, Dan Kennedy wrote: "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 Well if you're so smart, (A) Anything divided by i

Re: [sqlite] Does not detect invalid column name when subexpression optimized away

2013-12-20 Thread Simon Slavin
On 20 Dec 2013, at 12:05pm, Dan Kennedy wrote: > "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 Well if you're so smart, (A) Anything divided by itself is 1. (B) Anything divided by ze

Re: [sqlite] Does not detect invalid column name when subexpression optimized away

2013-12-20 Thread Dan Kennedy
; 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 wrote: S

Re: [sqlite] Does not detect invalid column name when subexpression optimized away

2013-12-20 Thread Simon Slavin
On 20 Dec 2013, at 4:11am, David Bicking wrote: > 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? In SQL, where anything can be NULL, binary operation tables must be written ou

Re: [sqlite] Does not detect invalid column name when subexpression optimized away

2013-12-20 Thread RSmith
On 2013/12/20 06:11, David Bicking wrote: 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 It's hard to make a case for it though. I could argue both sides from first princ

Re: [sqlite] Does not detect invalid column name when subexpression optimized away

2013-12-19 Thread David Bicking
Does not detect invalid column name when subexpression optimized away To: "R Smith" , "General Discussion of SQLite Database" Cc: amb...@math.bme.hu Date: Thursday, December 19, 2013, 9:27 PM On Thu, Dec 19, 2013 at 6:36 PM, RSmith wrote: >  my guess is the optim

Re: [sqlite] Does not detect invalid column name when subexpression optimized away

2013-12-19 Thread Richard Hipp
On Thu, Dec 19, 2013 at 6:36 PM, RSmith 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

Re: [sqlite] Does not detect invalid column name when subexpression optimized away

2013-12-19 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 19/12/13 15:36, RSmith wrote: > With this query you essentially ask the RDBMS to evaluate and supply > you with the result of (X and 0) - my guess is the optimiser pounces > directly on the fact that (X and 0) will always be 0 no matter what X > is

Re: [sqlite] Does not detect invalid column name when subexpression optimized away

2013-12-19 Thread RSmith
With this query you essentially ask the RDBMS to evaluate and supply you with the result of (X and 0) - my guess is the optimiser pounces directly on the fact that (X and 0) will always be 0 no matter what X is so that it does not bother trying to evaluate X which means it never has the need to r

[sqlite] Does not detect invalid column name when subexpression optimized away

2013-12-19 Thread Zsbán Ambrus
Why does the following select statement succeed, instead of giving a "no column error"? Is this a feature or a bug? sqlite> select nonsensename and 0; 0 sqlite> .version SQLite 3.8.1 2013-10-17 12:57:35 c78be6d786c19073b3a6730dfe3fb1be54f5657a The select statement is not a subquery and has no fr