|
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 |
@@ -126770,11 +126771,6 @@ SQLITE_PRIVATE void sqlite3CreateIndex( |
126770 | 126771 | goto exit_create_index; |
126771 | 126772 | } |
126772 | 126773 | if( vectorIdxRc >= 1 ){ |
126773 | | - /* |
126774 | | - * SQLite can use B-Tree indices in some optimizations (like SELECT COUNT(*) can use any full B-Tree index instead of PK index) |
126775 | | - * But, SQLite pretty conservative about usage of unordered indices - that's what we need here |
126776 | | - */ |
126777 | | - pIndex->bUnordered = 1; |
126778 | 126774 | pIndex->idxIsVector = 1; |
126779 | 126775 | } |
126780 | 126776 | if( vectorIdxRc == 1 ){ |
@@ -152469,6 +152465,7 @@ SQLITE_PRIVATE int sqlite3Select( |
152469 | 152465 | if( pIdx->bUnordered==0 |
152470 | 152466 | && pIdx->szIdxRow<pTab->szTabRow |
152471 | 152467 | && pIdx->pPartIdxWhere==0 |
| 152468 | + && pIdx->idxIsVector==0 |
152472 | 152469 | && (!pBest || pIdx->szIdxRow<pBest->szIdxRow) |
152473 | 152470 | ){ |
152474 | 152471 | pBest = pIdx; |
@@ -166093,9 +166090,10 @@ static int whereLoopAddBtreeIndex( |
166093 | 166090 | assert( pNew->u.btree.nBtm==0 ); |
166094 | 166091 | opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS; |
166095 | 166092 | } |
166096 | | - if( pProbe->bUnordered || pProbe->bLowQual ){ |
| 166093 | + if( pProbe->bUnordered || pProbe->bLowQual || pProbe->idxIsVector ){ |
166097 | 166094 | if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE); |
166098 | 166095 | if( pProbe->bLowQual ) opMask &= ~(WO_EQ|WO_IN|WO_IS); |
| 166096 | + if( pProbe->idxIsVector ) opMask = 0; |
166099 | 166097 | } |
166100 | 166098 |
|
166101 | 166099 | assert( pNew->u.btree.nEq<pProbe->nColumn ); |
@@ -166477,7 +166475,7 @@ static int indexMightHelpWithOrderBy( |
166477 | 166475 | ExprList *aColExpr; |
166478 | 166476 | int ii, jj; |
166479 | 166477 |
|
166480 | | - if( pIndex->bUnordered ) return 0; |
| 166478 | + if( pIndex->bUnordered || pIndex->idxIsVector ) return 0; |
166481 | 166479 | if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0; |
166482 | 166480 | for(ii=0; ii<pOB->nExpr; ii++){ |
166483 | 166481 | Expr *pExpr = sqlite3ExprSkipCollateAndLikely(pOB->a[ii].pExpr); |
@@ -166646,6 +166644,9 @@ static SQLITE_NOINLINE u32 whereIsCoveringIndex( |
166646 | 166644 | ** if pIdx is covering. Assume it is not. */ |
166647 | 166645 | return 0; |
166648 | 166646 | } |
| 166647 | + if( pIdx->idxIsVector==1 ){ |
| 166648 | + return 0; |
| 166649 | + } |
166649 | 166650 | if( pIdx->bHasExpr==0 ){ |
166650 | 166651 | for(i=0; i<pIdx->nColumn; i++){ |
166651 | 166652 | if( pIdx->aiColumn[i]>=BMS-1 ) break; |
@@ -166934,6 +166935,9 @@ static int whereLoopAddBtree( |
166934 | 166935 | testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */ |
166935 | 166936 | continue; /* Partial index inappropriate for this query */ |
166936 | 166937 | } |
| 166938 | + if( pProbe->idxIsVector!=0 ){ |
| 166939 | + continue; /* Vector index inappropriate for this query */ |
| 166940 | + } |
166937 | 166941 | if( pProbe->bNoQuery ) continue; |
166938 | 166942 | rSize = pProbe->aiRowLogEst[0]; |
166939 | 166943 | pNew->u.btree.nEq = 0; |
@@ -167937,7 +167941,7 @@ static i8 wherePathSatisfiesOrderBy( |
167937 | 167941 | pIndex = 0; |
167938 | 167942 | nKeyCol = 0; |
167939 | 167943 | nColumn = 1; |
167940 | | - }else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered ){ |
| 167944 | + }else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered || pIndex->idxIsVector ){ |
167941 | 167945 | return 0; |
167942 | 167946 | }else{ |
167943 | 167947 | nKeyCol = pIndex->nKeyCol; |
@@ -216046,7 +216050,6 @@ int vectorIndexSearch( |
216046 | 216050 | rc = SQLITE_ERROR; |
216047 | 216051 | goto out; |
216048 | 216052 | } |
216049 | | - assert( type == VECTOR_TYPE_FLOAT32 || type == VECTOR_TYPE_FLOAT64 || type == VECTOR_TYPE_FLOAT1BIT ); |
216050 | 216053 |
|
216051 | 216054 | pVector = vectorAlloc(type, dims); |
216052 | 216055 | if( pVector == NULL ){ |
|
0 commit comments