mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
Avoid returning MISUSE when sqlite is called recursively by an xBestIndex callback. (CVS 3274)
FossilOrigin-Name: 4339e1bf664c4287aabe0993a9c5a2b783019cb3
This commit is contained in:
10
src/where.c
10
src/where.c
@@ -16,7 +16,7 @@
|
||||
** so is applicable. Because this module is responsible for selecting
|
||||
** indices, you might also think of this module as the "query optimizer".
|
||||
**
|
||||
** $Id: where.c,v 1.219 2006/06/19 04:49:35 danielk1977 Exp $
|
||||
** $Id: where.c,v 1.220 2006/06/19 12:02:59 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -983,6 +983,7 @@ static double bestVirtualIndex(
|
||||
WhereTerm *pTerm;
|
||||
int i, j;
|
||||
int nOrderBy;
|
||||
int rc;
|
||||
|
||||
/* If the sqlite3_index_info structure has not been previously
|
||||
** allocated and initialized for this virtual table, then allocate
|
||||
@@ -1122,7 +1123,14 @@ static double bestVirtualIndex(
|
||||
if( pIdxInfo->nOrderBy && !orderByUsable ){
|
||||
*(int*)&pIdxInfo->nOrderBy = 0;
|
||||
}
|
||||
|
||||
sqlite3SafetyOff(pParse->db);
|
||||
pTab->pVtab->pModule->xBestIndex(pTab->pVtab, pIdxInfo);
|
||||
rc = sqlite3SafetyOn(pParse->db);
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqlite3ErrorMsg(pParse, "%s", sqlite3ErrStr(rc));
|
||||
}
|
||||
|
||||
*(int*)&pIdxInfo->nOrderBy = nOrderBy;
|
||||
return pIdxInfo->estimatedCost;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user