|
78 | 78 | ** src/vtab.c |
79 | 79 | ** src/wal.c |
80 | 80 | ** src/wal.h |
| 81 | +** src/where.c |
81 | 82 | ** src/wherecode.c |
82 | 83 | ** test/all.test |
83 | 84 | ** test/permutations.test |
@@ -126752,11 +126753,6 @@ SQLITE_PRIVATE void sqlite3CreateIndex( |
126752 | 126753 | goto exit_create_index; |
126753 | 126754 | } |
126754 | 126755 | if( vectorIdxRc >= 1 ){ |
126755 | | - /* |
126756 | | - * SQLite can use B-Tree indices in some optimizations (like SELECT COUNT(*) can use any full B-Tree index instead of PK index) |
126757 | | - * But, SQLite pretty conservative about usage of unordered indices - that's what we need here |
126758 | | - */ |
126759 | | - pIndex->bUnordered = 1; |
126760 | 126756 | pIndex->idxIsVector = 1; |
126761 | 126757 | } |
126762 | 126758 | if( vectorIdxRc == 1 ){ |
@@ -152451,6 +152447,7 @@ SQLITE_PRIVATE int sqlite3Select( |
152451 | 152447 | if( pIdx->bUnordered==0 |
152452 | 152448 | && pIdx->szIdxRow<pTab->szTabRow |
152453 | 152449 | && pIdx->pPartIdxWhere==0 |
| 152450 | + && pIdx->idxIsVector==0 |
152454 | 152451 | && (!pBest || pIdx->szIdxRow<pBest->szIdxRow) |
152455 | 152452 | ){ |
152456 | 152453 | pBest = pIdx; |
@@ -166075,9 +166072,10 @@ static int whereLoopAddBtreeIndex( |
166075 | 166072 | assert( pNew->u.btree.nBtm==0 ); |
166076 | 166073 | opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS; |
166077 | 166074 | } |
166078 | | - if( pProbe->bUnordered || pProbe->bLowQual ){ |
| 166075 | + if( pProbe->bUnordered || pProbe->bLowQual || pProbe->idxIsVector ){ |
166079 | 166076 | if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE); |
166080 | 166077 | if( pProbe->bLowQual ) opMask &= ~(WO_EQ|WO_IN|WO_IS); |
| 166078 | + if( pProbe->idxIsVector ) opMask = 0; |
166081 | 166079 | } |
166082 | 166080 |
|
166083 | 166081 | assert( pNew->u.btree.nEq<pProbe->nColumn ); |
@@ -166459,7 +166457,7 @@ static int indexMightHelpWithOrderBy( |
166459 | 166457 | ExprList *aColExpr; |
166460 | 166458 | int ii, jj; |
166461 | 166459 |
|
166462 | | - if( pIndex->bUnordered ) return 0; |
| 166460 | + if( pIndex->bUnordered || pIndex->idxIsVector ) return 0; |
166463 | 166461 | if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0; |
166464 | 166462 | for(ii=0; ii<pOB->nExpr; ii++){ |
166465 | 166463 | Expr *pExpr = sqlite3ExprSkipCollateAndLikely(pOB->a[ii].pExpr); |
@@ -166628,6 +166626,9 @@ static SQLITE_NOINLINE u32 whereIsCoveringIndex( |
166628 | 166626 | ** if pIdx is covering. Assume it is not. */ |
166629 | 166627 | return 0; |
166630 | 166628 | } |
| 166629 | + if( pIdx->idxIsVector==1 ){ |
| 166630 | + return 0; |
| 166631 | + } |
166631 | 166632 | if( pIdx->bHasExpr==0 ){ |
166632 | 166633 | for(i=0; i<pIdx->nColumn; i++){ |
166633 | 166634 | if( pIdx->aiColumn[i]>=BMS-1 ) break; |
@@ -166916,6 +166917,9 @@ static int whereLoopAddBtree( |
166916 | 166917 | testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */ |
166917 | 166918 | continue; /* Partial index inappropriate for this query */ |
166918 | 166919 | } |
| 166920 | + if( pProbe->idxIsVector!=0 ){ |
| 166921 | + continue; /* Vector index inappropriate for this query */ |
| 166922 | + } |
166919 | 166923 | if( pProbe->bNoQuery ) continue; |
166920 | 166924 | rSize = pProbe->aiRowLogEst[0]; |
166921 | 166925 | pNew->u.btree.nEq = 0; |
@@ -167919,7 +167923,7 @@ static i8 wherePathSatisfiesOrderBy( |
167919 | 167923 | pIndex = 0; |
167920 | 167924 | nKeyCol = 0; |
167921 | 167925 | nColumn = 1; |
167922 | | - }else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered ){ |
| 167926 | + }else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered || pIndex->idxIsVector ){ |
167923 | 167927 | return 0; |
167924 | 167928 | }else{ |
167925 | 167929 | nKeyCol = pIndex->nKeyCol; |
@@ -215466,7 +215470,6 @@ int vectorIndexSearch( |
215466 | 215470 | rc = SQLITE_ERROR; |
215467 | 215471 | goto out; |
215468 | 215472 | } |
215469 | | - assert( type == VECTOR_TYPE_FLOAT32 || type == VECTOR_TYPE_FLOAT64 || type == VECTOR_TYPE_FLOAT1BIT ); |
215470 | 215473 |
|
215471 | 215474 | pVector = vectorAlloc(type, dims); |
215472 | 215475 | if( pVector == NULL ){ |
|
0 commit comments