@@ -19266,7 +19266,8 @@ struct Index {
19266
19266
u16 nKeyCol; /* Number of columns forming the key */
19267
19267
u16 nColumn; /* Number of columns stored in the index */
19268
19268
u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
19269
- unsigned idxType:3; /* 0:Normal 1:UNIQUE, 2:PRIMARY KEY, 3:IPK, 4:VECTOR INDEX */
19269
+ unsigned idxType:2; /* 0:Normal 1:UNIQUE, 2:PRIMARY KEY, 3:IPK */
19270
+ unsigned idxIsVector:1; /* 0:Normal 1:VECTOR INDEX */
19270
19271
unsigned bUnordered:1; /* Use this index for == or IN queries only */
19271
19272
unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
19272
19273
unsigned isResized:1; /* True if resizeIndexObject() has been called */
@@ -19298,7 +19299,6 @@ struct Index {
19298
19299
#define SQLITE_IDXTYPE_UNIQUE 1 /* Implements a UNIQUE constraint */
19299
19300
#define SQLITE_IDXTYPE_PRIMARYKEY 2 /* Is the PRIMARY KEY for the table */
19300
19301
#define SQLITE_IDXTYPE_IPK 3 /* INTEGER PRIMARY KEY index */
19301
- #define SQLITE_IDXTYPE_VECTOR 4 /* libSQL vector index */
19302
19302
19303
19303
/* Return true if index X is a PRIMARY KEY index */
19304
19304
#define IsPrimaryKeyIndex(X) ((X)->idxType==SQLITE_IDXTYPE_PRIMARYKEY)
@@ -19307,10 +19307,7 @@ struct Index {
19307
19307
#define IsUniqueIndex(X) ((X)->onError!=OE_None)
19308
19308
19309
19309
/* Return true if index X is a vector index */
19310
- #define IsVectorIndex(X) ((X)->idxType==SQLITE_IDXTYPE_VECTOR)
19311
-
19312
- /* Return true if index X is an user defined index (APPDEF or VECTOR) */
19313
- #define IsAppDefIndex(X) ((X)->idxType==SQLITE_IDXTYPE_APPDEF||(X)->idxType==SQLITE_IDXTYPE_VECTOR)
19310
+ #define IsVectorIndex(X) ((X)->idxIsVector==1)
19314
19311
19315
19312
/* The Index.aiColumn[] values are normally positive integer. But
19316
19313
** there are some negative values that have special meaning:
@@ -123188,7 +123185,7 @@ static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){
123188
123185
for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
123189
123186
pNext = pIndex->pNext;
123190
123187
assert( pIndex->pSchema==pTable->pSchema
123191
- || (IsVirtual(pTable) && !IsAppDefIndex( pIndex) ) );
123188
+ || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF ) );
123192
123189
if( db->pnBytesFreed==0 && !IsVirtual(pTable) ){
123193
123190
char *zName = pIndex->zName;
123194
123191
TESTONLY ( Index *pOld = ) sqlite3HashInsert(
@@ -126700,13 +126697,12 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
126700
126697
goto exit_create_index;
126701
126698
}
126702
126699
if( vectorIdxRc >= 1 ){
126703
- idxType = SQLITE_IDXTYPE_VECTOR;
126704
126700
/*
126705
126701
* SQLite can use B-Tree indices in some optimizations (like SELECT COUNT(*) can use any full B-Tree index instead of PK index)
126706
126702
* But, SQLite pretty conservative about usage of unordered indices - that's what we need here
126707
126703
*/
126708
126704
pIndex->bUnordered = 1;
126709
- pIndex->idxType = idxType ;
126705
+ pIndex->idxIsVector = 1 ;
126710
126706
}
126711
126707
if( vectorIdxRc == 1 ){
126712
126708
skipRefill = 1;
@@ -126754,7 +126750,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
126754
126750
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
126755
126751
int k;
126756
126752
assert( IsUniqueIndex(pIdx) );
126757
- assert( !IsAppDefIndex( pIdx) );
126753
+ assert( pIdx->idxType!=SQLITE_IDXTYPE_APPDEF );
126758
126754
assert( IsUniqueIndex(pIndex) );
126759
126755
126760
126756
if( pIdx->nKeyCol!=pIndex->nKeyCol ) continue;
@@ -127035,7 +127031,7 @@ SQLITE_PRIVATE void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists
127035
127031
pParse->checkSchema = 1;
127036
127032
goto exit_drop_index;
127037
127033
}
127038
- if( !IsAppDefIndex( pIndex) ){
127034
+ if( pIndex->idxType!=SQLITE_IDXTYPE_APPDEF ){
127039
127035
sqlite3ErrorMsg(pParse, "index associated with UNIQUE "
127040
127036
"or PRIMARY KEY constraint cannot be dropped", 0);
127041
127037
goto exit_drop_index;
@@ -177910,9 +177906,6 @@ static YYACTIONTYPE yy_reduce(
177910
177906
case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm indextype ON nm LP sortlist RP where_opt */
177911
177907
{
177912
177908
u8 idxType = SQLITE_IDXTYPE_APPDEF;
177913
- if( yymsp[-6].minor.yy421.pUsing!=0 ){
177914
- idxType = SQLITE_IDXTYPE_VECTOR;
177915
- }
177916
177909
sqlite3CreateIndex(pParse, &yymsp[-8].minor.yy0, &yymsp[-7].minor.yy0,
177917
177910
sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy402, yymsp[-11].minor.yy502,
177918
177911
&yymsp[-12].minor.yy0, yymsp[0].minor.yy590, SQLITE_SO_ASC, yymsp[-9].minor.yy502, idxType, yymsp[-6].minor.yy421.pUsing);
0 commit comments