bug: explain Rewind Le

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

bug: explain Rewind Le

Egor Shalashnikov
create table t(n number, v varchar2(10));
insert into t values (1, 'one')
explain select * from t where 0 < n;

addr  opcode         p1    p2    p3    p4             p5  comment
----  -------------  ----  ----  ----  -------------  --  -------------
0     Init           0     11    0                    00  Start at 11
1     OpenRead       0     2     0     2              00  root=2 iDb=0; t
2     Rewind         0     9     0                    00
3       Column         0     0     1                    00  r[1]=t.n
4       Le             2     8     1     (BINARY)       53  if r[2]<=r[1] goto 8
5       Copy           1     3     0                    00  r[3]=r[1]
6       Column         0     1     4                    00  r[4]=t.v
7       ResultRow      3     2     0                    00  output=r[3..4]
8     Next           0     3     0                    01
9     Close          0     0     0                    00
10    Halt           0     0     0                    00
11    Transaction    0     0     2     1              01  usesStmtJournal=0
12    TableLock      0     2     0     t              00  iDb=0 root=2 write=0
13    Integer        0     2     0                    00  r[2]=0
14    Goto           0     1     0                    00

The line 4 seems wrong for me, because t.n(r[1]) should be <= than
0(r[2]) to be ignored (goto 8). Here what we see: "if r[2]<=r[1] goto
8" - vise versa.

Egor.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: bug: explain Rewind Le

Clemens Ladisch
Egor Shalashnikov wrote:
> create table t(n number, v varchar2(10));
> insert into t values (1, 'one')
> explain select * from t where 0 < n;

If you omit the EXPLAIN, is the code executed correctly?

> addr  opcode         p1    p2    p3    p4             p5  comment
> ----  -------------  ----  ----  ----  -------------  --  -------------
> 13    Integer        0     2     0                    00  r[2]=0
> ...
> 2     Rewind         0     9     0                    00
> 3       Column         0     0     1                    00  r[1]=t.n
> 4       Le             2     8     1     (BINARY)       53  if r[2]<=r[1] goto 8
> 5       Copy           1     3     0                    00  r[3]=r[1]
> 6       Column         0     1     4                    00  r[4]=t.v
> 7       ResultRow      3     2     0                    00  output=r[3..4]
> 8     Next           0     3     0                    01
> ...
> The line 4 seems wrong for me, because t.n(r[1]) should be <= than
> 0(r[2]) to be ignored (goto 8).

The synopsis of OP_Le would be "if r[P3]<=r[P1] goto P2".

There is indeed something wrong in your EXPLAIN output.  But my 3.21.0
correctly shows "r[1]<=r[2]".


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: bug: explain Rewind Le

Egor Shalashnikov
Yes, absolutely correct
On Nov 1, 2017 10:55 AM, "Clemens Ladisch" <[hidden email]> wrote:

> Egor Shalashnikov wrote:
> > create table t(n number, v varchar2(10));
> > insert into t values (1, 'one')
> > explain select * from t where 0 < n;
>
> If you omit the EXPLAIN, is the code executed correctly?
>
> > addr  opcode         p1    p2    p3    p4             p5  comment
> > ----  -------------  ----  ----  ----  -------------  --  -------------
> > 13    Integer        0     2     0                    00  r[2]=0
> > ...
> > 2     Rewind         0     9     0                    00
> > 3       Column         0     0     1                    00  r[1]=t.n
> > 4       Le             2     8     1     (BINARY)       53  if
> r[2]<=r[1] goto 8
> > 5       Copy           1     3     0                    00  r[3]=r[1]
> > 6       Column         0     1     4                    00  r[4]=t.v
> > 7       ResultRow      3     2     0                    00
> output=r[3..4]
> > 8     Next           0     3     0                    01
> > ...
> > The line 4 seems wrong for me, because t.n(r[1]) should be <= than
> > 0(r[2]) to be ignored (goto 8).
>
> The synopsis of OP_Le would be "if r[P3]<=r[P1] goto P2".
>
> There is indeed something wrong in your EXPLAIN output.  But my 3.21.0
> correctly shows "r[1]<=r[2]".
>
>
> Regards,
> Clemens
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: bug: explain Rewind Le

Egor Shalashnikov
Thank you for checking the issue.
It seems I use an outdated version 3.11.0:

$ uname -a
Linux chrx 4.8.17-galliumos #1 SMP PREEMPT galliumos4 Thu Feb 23
02:27:28 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ sqlite3 --version
3.11.0 2016-02-15 17:29:24 3d862f207e3adc00f78066799ac5a8c282430a5f

Regards,
Egor.

On Wed, Nov 1, 2017 at 11:30 AM, Egor Shalashnikov
<[hidden email]> wrote:

> Yes, absolutely correct
>
> On Nov 1, 2017 10:55 AM, "Clemens Ladisch" <[hidden email]> wrote:
>>
>> Egor Shalashnikov wrote:
>> > create table t(n number, v varchar2(10));
>> > insert into t values (1, 'one')
>> > explain select * from t where 0 < n;
>>
>> If you omit the EXPLAIN, is the code executed correctly?
>>
>> > addr  opcode         p1    p2    p3    p4             p5  comment
>> > ----  -------------  ----  ----  ----  -------------  --  -------------
>> > 13    Integer        0     2     0                    00  r[2]=0
>> > ...
>> > 2     Rewind         0     9     0                    00
>> > 3       Column         0     0     1                    00  r[1]=t.n
>> > 4       Le             2     8     1     (BINARY)       53  if
>> > r[2]<=r[1] goto 8
>> > 5       Copy           1     3     0                    00  r[3]=r[1]
>> > 6       Column         0     1     4                    00  r[4]=t.v
>> > 7       ResultRow      3     2     0                    00
>> > output=r[3..4]
>> > 8     Next           0     3     0                    01
>> > ...
>> > The line 4 seems wrong for me, because t.n(r[1]) should be <= than
>> > 0(r[2]) to be ignored (goto 8).
>>
>> The synopsis of OP_Le would be "if r[P3]<=r[P1] goto P2".
>>
>> There is indeed something wrong in your EXPLAIN output.  But my 3.21.0
>> correctly shows "r[1]<=r[2]".
>>
>>
>> Regards,
>> Clemens
>> _______________________________________________
>> sqlite-users mailing list
>> [hidden email]
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users