As you noticed, you were asking to have the values of unusable constraints 
passed to your vt_filter function.

But how are you telling your vt_filter function which fields the passed values 
belong to? I don't see how the column number of the first constraint - usable 
or not- is going to be sufficient information. Neither is there a check for the 
type of operation requested taken into account.

Since your filter/next functions are probably going to return arbitrary 
records, the fact that you are not setting any "omit" flags allows SQLite to 
recheck the conditions and return something vaguely resembling the correct 
result set. Just with a lot of work filtering out superfluous records and 
missing any records that should have been returned by filter/next (but were 
not).

Also, you are writing the field aOrderBy, which is documented to be an input 
field.

-----Ursprüngliche Nachricht-----
Von: Micka [mailto:mickamus...@gmail.com]
Gesendet: Freitag, 04. Juli 2014 09:57
An: General Discussion of SQLite Database
Betreff: Re: [sqlite] Error xBestIndex returned an invalid plan

Ok I looked at the source sqlite3.c and saw that :



This is my correction :


int vt_best_index(sqlite3_vtab *p_svt, sqlite3_index_info *p_info){
sVTAB* p_vt         = (sVTAB*)p_svt;
int i;
int j=1;
printf("vt_best_index %d\n", p_info->nConstraint);

p_info->idxNum=0;

if(p_info->nConstraint!=0){
p_info->idxNum=p_info->aConstraint[0].iColumn;
p_info->idxStr=p_vt->acNameTab;
printf("best index constraint column %d\n", p_info->aConstraint[0].iColumn); 
for(i=0;i<p_info->nConstraint;i++){
 *if(p_info->aConstraint[i].usable){*
p_info->aConstraintUsage[i].argvIndex=j++;
}
}
}
if(p_info->nOrderBy==0){
p_info->aOrderBy=NULL;
}
return SQLITE_OK;
}

Thx every one ! And Keith Medcalf ... you should use your time better !


Micka,


On Fri, Jul 4, 2014 at 9:49 AM, Micka <mickamus...@gmail.com> wrote:

> I've no word for this ! .....
>
>
> On Fri, Jul 4, 2014 at 9:46 AM, Keith Medcalf <kmedc...@dessus.com> wrote:
>
>>
>> The spacing and indentation are atrocious?
>>
>> >-----Original Message-----
>> >From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
>> >boun...@sqlite.org] On Behalf Of Micka
>> >Sent: Friday, 4 July, 2014 01:29
>> >To: General Discussion of SQLite Database
>> >Subject: [sqlite] Error xBestIndex returned an invalid plan
>> >
>> >Hi, I wanted to know what could be wrong with :
>> >
>> >int vt_best_index(sqlite3_vtab *p_svt, sqlite3_index_info *p_info){
>> >sVTAB* p_vt         = (sVTAB*)p_svt;
>> >int i;
>> >printf("vt_best_index %d\n", p_info->nConstraint);
>> >
>> >p_info->idxNum=0;
>> >
>> >if(p_info->nConstraint!=0){
>> >p_info->idxNum=p_info->aConstraint[0].iColumn;
>> >p_info->idxStr=p_vt->acNameTab;
>> >printf("best index constraint column %d\n", p_info-
>> >>aConstraint[0].iColumn);
>> >for(i=0;i<p_info->nConstraint;i++){
>> >p_info->aConstraintUsage[i].argvIndex=(1+i);
>> >}
>> >}
>> >if(p_info->nOrderBy==0){
>> >p_info->aOrderBy=NULL;
>> >}
>> >return SQLITE_OK;
>> >}
>> >
>> >thx you very much ^^
>> >_______________________________________________
>> >sqlite-users mailing list
>> >sqlite-users@sqlite.org
>> >http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>>
>>
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


-----------------------------------------------------------------------
Gunter Hick
Software Engineer

Scientific Games International GmbH
Klitschgasse 2 – 4, A - 1130 Vienna,
Austria
FN 157284 a, HG Wien
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This e-mail is confidential and may well also be legally privileged. If you 
have received it in error, you are on notice as to its status and accordingly 
please notify us immediately by reply e-mail and then
delete this message from your system. Please do not copy it or use it for any 
purposes, or disclose its contents to any person as to do so could be a breach 
of confidence. Thank you for your cooperation.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to