Virtual table OR constraint bug

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

Virtual table OR constraint bug

Lalit Maganti
Hi all,

I believe that I have found a bug in the virtual table bytecode generation
when OR constraints are present and argvIndex is set in xBestIndex but the
application does not actually filter fully.

The problem seems to be in not setting/unsetting the non-null flag
correctly (SQLITE_JUMPIFNULL) on the instruction which does the comparison;
this leads to NULLs slipping through the filter.

To fully repro the problem, please find attached a small C file which shows
the unexpected behaviour. By adding an EXPLAIN in-front of the SELECT
query, you should be able to see the incorrect bytecode on the NE opcode.

If the attachment doesn't come through for some reason, I've also put the
same file as a GitHub gist
<https://gist.github.com/tilal6991/57f8c51934379270abe58201c7b1dab1/>.

Thank you!

Regards,
Lalit
_______________________________________________
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: Virtual table OR constraint bug

Lalit Maganti
Hi folks,

Just wanted to check up on this to see if this issue is something which is
being tracked and if there was a potential fix in the works?

Thanks,
Lalit

On Thu, 2 Jan 2020 at 15:13, Lalit Maganti <[hidden email]> wrote:

> Hi all,
>
> I believe that I have found a bug in the virtual table bytecode generation
> when OR constraints are present and argvIndex is set in xBestIndex but the
> application does not actually filter fully.
>
> The problem seems to be in not setting/unsetting the non-null flag
> correctly (SQLITE_JUMPIFNULL) on the instruction which does the comparison;
> this leads to NULLs slipping through the filter.
>
> To fully repro the problem, please find attached a small C file which
> shows the unexpected behaviour. By adding an EXPLAIN in-front of the SELECT
> query, you should be able to see the incorrect bytecode on the NE opcode.
>
> If the attachment doesn't come through for some reason, I've also put the
> same file as a GitHub gist
> <https://gist.github.com/tilal6991/57f8c51934379270abe58201c7b1dab1/>.
>
> Thank you!
>
> Regards,
> Lalit
>
_______________________________________________
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: Virtual table OR constraint bug

Dan Kennedy-4

On 29/1/63 20:09, Lalit Maganti wrote:
> Hi folks,
>
> Just wanted to check up on this to see if this issue is something which is
> being tracked and if there was a potential fix in the works?

Thanks for the excellent bug report and minimal reproduction case. Now
fixed here:

   https://www.sqlite.org/src/info/dcb4838757ca49cf

None of us saw your post last month. We think it must have been filtered
as spam by gmail. Sorry about that.

Dan.





>
> Thanks,
> Lalit
>
> On Thu, 2 Jan 2020 at 15:13, Lalit Maganti <[hidden email]> wrote:
>
>> Hi all,
>>
>> I believe that I have found a bug in the virtual table bytecode generation
>> when OR constraints are present and argvIndex is set in xBestIndex but the
>> application does not actually filter fully.
>>
>> The problem seems to be in not setting/unsetting the non-null flag
>> correctly (SQLITE_JUMPIFNULL) on the instruction which does the comparison;
>> this leads to NULLs slipping through the filter.
>>
>> To fully repro the problem, please find attached a small C file which
>> shows the unexpected behaviour. By adding an EXPLAIN in-front of the SELECT
>> query, you should be able to see the incorrect bytecode on the NE opcode.
>>
>> If the attachment doesn't come through for some reason, I've also put the
>> same file as a GitHub gist
>> <https://gist.github.com/tilal6991/57f8c51934379270abe58201c7b1dab1/>.
>>
>> Thank you!
>>
>> Regards,
>> Lalit
>>
> _______________________________________________
> 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: Virtual table OR constraint bug

Lalit Maganti
Thank you for the fast fix!

Best,
Lalit

On Wed, 29 Jan 2020 at 15:07, Dan Kennedy <[hidden email]> wrote:

>
> On 29/1/63 20:09, Lalit Maganti wrote:
> > Hi folks,
> >
> > Just wanted to check up on this to see if this issue is something which
> is
> > being tracked and if there was a potential fix in the works?
>
> Thanks for the excellent bug report and minimal reproduction case. Now
> fixed here:
>
>    https://www.sqlite.org/src/info/dcb4838757ca49cf
>
> None of us saw your post last month. We think it must have been filtered
> as spam by gmail. Sorry about that.
>
> Dan.
>
>
>
>
>
> >
> > Thanks,
> > Lalit
> >
> > On Thu, 2 Jan 2020 at 15:13, Lalit Maganti <[hidden email]> wrote:
> >
> >> Hi all,
> >>
> >> I believe that I have found a bug in the virtual table bytecode
> generation
> >> when OR constraints are present and argvIndex is set in xBestIndex but
> the
> >> application does not actually filter fully.
> >>
> >> The problem seems to be in not setting/unsetting the non-null flag
> >> correctly (SQLITE_JUMPIFNULL) on the instruction which does the
> comparison;
> >> this leads to NULLs slipping through the filter.
> >>
> >> To fully repro the problem, please find attached a small C file which
> >> shows the unexpected behaviour. By adding an EXPLAIN in-front of the
> SELECT
> >> query, you should be able to see the incorrect bytecode on the NE
> opcode.
> >>
> >> If the attachment doesn't come through for some reason, I've also put
> the
> >> same file as a GitHub gist
> >> <https://gist.github.com/tilal6991/57f8c51934379270abe58201c7b1dab1/>.
> >>
> >> Thank you!
> >>
> >> Regards,
> >> Lalit
> >>
> > _______________________________________________
> > 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
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users