On Fri Jun 12, 2015 at 09:49:29AM +0000, Hick Gunter wrote:
> Seems the correct code is already generated...
Thanks Hick, that shows a bit more detail I didn't think to look for.
It seems that this only works for bind values, as the comparison and goto
statements aren't present when the term is defined at prepare time:
.width 4 10 4 4 4 10 2 10
EXPLAIN SELECT
x.id
FROM
x
WHERE
1=0
;
addr opcode p1 p2 p3 p4 p5 comment
---- ---------- ---- ---- ---- ---------- -- ----------
0 Init 0 9 0 00 NULL
1 Ne 2 7 1 51 NULL
2 OpenRead 0 2 0 0 00 NULL
3 Rewind 0 7 0 00 NULL
4 Rowid 0 3 0 00 NULL
5 ResultRow 3 1 0 00 NULL
6 Next 0 4 0 01 NULL
7 Close 0 0 0 00 NULL
8 Halt 0 0 0 00 NULL
9 Transactio 0 0 1 0 01 NULL
10 TableLock 0 2 0 x 00 NULL
11 Integer 1 1 0 00 NULL
12 Integer 0 2 0 00 NULL
13 Goto 0 1 0 00 NULL
That makes me think that for the 1=0 case the scan occurs anyway?
--
Mark Lawrence