None of the queries named requires more than 1 parameter to xFilter. Why should 
they?

xBestIndex will be called once with no usable constraints and once with 
(value1, "=").

The difference is that xFilter will be called once for each constraint value, 
i.e. once for query 1 and twice for queries 2..4.

I guess you are setting argvIndex to 1 for a constraint that is not marked 
usable.

The exact calling sequence should be:

xBestIndex (1 constraint, not usable) => rows should be set to number of rows 
in vt
xBestIndex ( value1, "=" ) => rows should be set to 1 (if field value1 is a 
unique key for the table)
xFilter ( 7 ) => locate the row
xColumn ( ... ) => return the contents of the field
xNext  => set eof flag
xEof => return TRUE
xFilter ( 8 ) => locate the row
xColumn ( ... ) => return the contents of the field
xNext  => set eof flag
xEof => return TRUE


-----Urspr?ngliche Nachricht-----
Von: Emmanouil Karvounis [mailto:manosk at di.uoa.gr]
Gesendet: Donnerstag, 21. Mai 2015 17:21
An: sqlite-users at mailinglists.sqlite.org
Cc: Stamatios Christoforidis
Betreff: [sqlite] BestIndex problem

Greetings,

We are having an issue with BestIndex in our Virtual Table implementation.
Allow us to illustrate the problem with a simple example.

We create a virtual table named 'vt' that conceptually has 3 columns "value1, 
value2, value3" and then we want to execute the following queries:

1) select value1 from vt where value1 = 7;

In this case, BestIndex passes the equal constraint on the first column and by 
setting the output as pdxInfo->aConstraintUsage[0].argvIndex = 1, we indicate 
that we accept this specific constraint. So, at Filter we get the value 7 as 
argument0. Everything behaves normally so far.

However, in case we run any of the following equivalent queries (that should 
pass to Filter more than one value), we get an error message "xBestIndex 
returned an invalid plan":

2) select value1 from vt where value1 = 7 or value1 = 8;
3) select value1 from vt where value1 in (select * from tableA);    //
suppose tableA contains an integer 'id' column and records (7, 8)
4) select value1 from vt, tableA where value1 = tableA.id;

Again, in each case we set pdxInfo->aConstraintUsage[0].argvIndex = 1 but we 
get the above error message.

This behavior seems rather weird, so we'd like some expert help on what we 
might be doing wrong.


Thank you for your time,
Manos Karvounis
Stamatis Christoforidis
_______________________________________________
sqlite-users mailing list
sqlite-users at mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: hick at scigames.at

This communication (including any attachments) is intended for the use of the 
intended recipient(s) only and may contain information that is confidential, 
privileged or legally protected. Any unauthorized use or dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the sender by return e-mail message and 
delete all copies of the original communication. Thank you for your cooperation.


Reply via email to