Skip to content

Commit

Permalink
build bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
sivukhin committed Aug 19, 2024
1 parent 6e67b36 commit 18e09dd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
21 changes: 12 additions & 9 deletions libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
** src/vtab.c
** src/wal.c
** src/wal.h
** src/where.c
** src/wherecode.c
** test/all.test
** test/permutations.test
Expand Down Expand Up @@ -126752,11 +126753,6 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
goto exit_create_index;
}
if( vectorIdxRc >= 1 ){
/*
* SQLite can use B-Tree indices in some optimizations (like SELECT COUNT(*) can use any full B-Tree index instead of PK index)
* But, SQLite pretty conservative about usage of unordered indices - that's what we need here
*/
pIndex->bUnordered = 1;
pIndex->idxIsVector = 1;
}
if( vectorIdxRc == 1 ){
Expand Down Expand Up @@ -152451,6 +152447,7 @@ SQLITE_PRIVATE int sqlite3Select(
if( pIdx->bUnordered==0
&& pIdx->szIdxRow<pTab->szTabRow
&& pIdx->pPartIdxWhere==0
&& pIdx->idxIsVector==0
&& (!pBest || pIdx->szIdxRow<pBest->szIdxRow)
){
pBest = pIdx;
Expand Down Expand Up @@ -166075,9 +166072,10 @@ static int whereLoopAddBtreeIndex(
assert( pNew->u.btree.nBtm==0 );
opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
}
if( pProbe->bUnordered || pProbe->bLowQual ){
if( pProbe->bUnordered || pProbe->bLowQual || pProbe->idxIsVector ){
if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
if( pProbe->bLowQual ) opMask &= ~(WO_EQ|WO_IN|WO_IS);
if( pProbe->idxIsVector ) opMask = 0;
}

assert( pNew->u.btree.nEq<pProbe->nColumn );
Expand Down Expand Up @@ -166459,7 +166457,7 @@ static int indexMightHelpWithOrderBy(
ExprList *aColExpr;
int ii, jj;

if( pIndex->bUnordered ) return 0;
if( pIndex->bUnordered || pIndex->idxIsVector ) return 0;
if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0;
for(ii=0; ii<pOB->nExpr; ii++){
Expr *pExpr = sqlite3ExprSkipCollateAndLikely(pOB->a[ii].pExpr);
Expand Down Expand Up @@ -166628,6 +166626,9 @@ static SQLITE_NOINLINE u32 whereIsCoveringIndex(
** if pIdx is covering. Assume it is not. */
return 0;
}
if( pIdx->idxIsVector==1 ){
return 0;
}
if( pIdx->bHasExpr==0 ){
for(i=0; i<pIdx->nColumn; i++){
if( pIdx->aiColumn[i]>=BMS-1 ) break;
Expand Down Expand Up @@ -166916,6 +166917,9 @@ static int whereLoopAddBtree(
testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */
continue; /* Partial index inappropriate for this query */
}
if( pProbe->idxIsVector!=0 ){
continue; /* Vector index inappropriate for this query */
}
if( pProbe->bNoQuery ) continue;
rSize = pProbe->aiRowLogEst[0];
pNew->u.btree.nEq = 0;
Expand Down Expand Up @@ -167919,7 +167923,7 @@ static i8 wherePathSatisfiesOrderBy(
pIndex = 0;
nKeyCol = 0;
nColumn = 1;
}else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered ){
}else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered || pIndex->idxIsVector ){
return 0;
}else{
nKeyCol = pIndex->nKeyCol;
Expand Down Expand Up @@ -215466,7 +215470,6 @@ int vectorIndexSearch(
rc = SQLITE_ERROR;
goto out;
}
assert( type == VECTOR_TYPE_FLOAT32 || type == VECTOR_TYPE_FLOAT64 || type == VECTOR_TYPE_FLOAT1BIT );

pVector = vectorAlloc(type, dims);
if( pVector == NULL ){
Expand Down
21 changes: 12 additions & 9 deletions libsql-ffi/bundled/src/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
** src/vtab.c
** src/wal.c
** src/wal.h
** src/where.c
** src/wherecode.c
** test/all.test
** test/permutations.test
Expand Down Expand Up @@ -126752,11 +126753,6 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
goto exit_create_index;
}
if( vectorIdxRc >= 1 ){
/*
* SQLite can use B-Tree indices in some optimizations (like SELECT COUNT(*) can use any full B-Tree index instead of PK index)
* But, SQLite pretty conservative about usage of unordered indices - that's what we need here
*/
pIndex->bUnordered = 1;
pIndex->idxIsVector = 1;
}
if( vectorIdxRc == 1 ){
Expand Down Expand Up @@ -152451,6 +152447,7 @@ SQLITE_PRIVATE int sqlite3Select(
if( pIdx->bUnordered==0
&& pIdx->szIdxRow<pTab->szTabRow
&& pIdx->pPartIdxWhere==0
&& pIdx->idxIsVector==0
&& (!pBest || pIdx->szIdxRow<pBest->szIdxRow)
){
pBest = pIdx;
Expand Down Expand Up @@ -166075,9 +166072,10 @@ static int whereLoopAddBtreeIndex(
assert( pNew->u.btree.nBtm==0 );
opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
}
if( pProbe->bUnordered || pProbe->bLowQual ){
if( pProbe->bUnordered || pProbe->bLowQual || pProbe->idxIsVector ){
if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
if( pProbe->bLowQual ) opMask &= ~(WO_EQ|WO_IN|WO_IS);
if( pProbe->idxIsVector ) opMask = 0;
}

assert( pNew->u.btree.nEq<pProbe->nColumn );
Expand Down Expand Up @@ -166459,7 +166457,7 @@ static int indexMightHelpWithOrderBy(
ExprList *aColExpr;
int ii, jj;

if( pIndex->bUnordered ) return 0;
if( pIndex->bUnordered || pIndex->idxIsVector ) return 0;
if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0;
for(ii=0; ii<pOB->nExpr; ii++){
Expr *pExpr = sqlite3ExprSkipCollateAndLikely(pOB->a[ii].pExpr);
Expand Down Expand Up @@ -166628,6 +166626,9 @@ static SQLITE_NOINLINE u32 whereIsCoveringIndex(
** if pIdx is covering. Assume it is not. */
return 0;
}
if( pIdx->idxIsVector==1 ){
return 0;
}
if( pIdx->bHasExpr==0 ){
for(i=0; i<pIdx->nColumn; i++){
if( pIdx->aiColumn[i]>=BMS-1 ) break;
Expand Down Expand Up @@ -166916,6 +166917,9 @@ static int whereLoopAddBtree(
testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */
continue; /* Partial index inappropriate for this query */
}
if( pProbe->idxIsVector!=0 ){
continue; /* Vector index inappropriate for this query */
}
if( pProbe->bNoQuery ) continue;
rSize = pProbe->aiRowLogEst[0];
pNew->u.btree.nEq = 0;
Expand Down Expand Up @@ -167919,7 +167923,7 @@ static i8 wherePathSatisfiesOrderBy(
pIndex = 0;
nKeyCol = 0;
nColumn = 1;
}else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered ){
}else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered || pIndex->idxIsVector ){
return 0;
}else{
nKeyCol = pIndex->nKeyCol;
Expand Down Expand Up @@ -215466,7 +215470,6 @@ int vectorIndexSearch(
rc = SQLITE_ERROR;
goto out;
}
assert( type == VECTOR_TYPE_FLOAT32 || type == VECTOR_TYPE_FLOAT64 || type == VECTOR_TYPE_FLOAT1BIT );

pVector = vectorAlloc(type, dims);
if( pVector == NULL ){
Expand Down

0 comments on commit 18e09dd

Please sign in to comment.