@@ -19266,7 +19266,8 @@ struct Index {
1926619266 u16 nKeyCol; /* Number of columns forming the key */
1926719267 u16 nColumn; /* Number of columns stored in the index */
1926819268 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 */
1927019271 unsigned bUnordered:1; /* Use this index for == or IN queries only */
1927119272 unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
1927219273 unsigned isResized:1; /* True if resizeIndexObject() has been called */
@@ -19298,7 +19299,6 @@ struct Index {
1929819299#define SQLITE_IDXTYPE_UNIQUE 1 /* Implements a UNIQUE constraint */
1929919300#define SQLITE_IDXTYPE_PRIMARYKEY 2 /* Is the PRIMARY KEY for the table */
1930019301#define SQLITE_IDXTYPE_IPK 3 /* INTEGER PRIMARY KEY index */
19301- #define SQLITE_IDXTYPE_VECTOR 4 /* libSQL vector index */
1930219302
1930319303/* Return true if index X is a PRIMARY KEY index */
1930419304#define IsPrimaryKeyIndex(X) ((X)->idxType==SQLITE_IDXTYPE_PRIMARYKEY)
@@ -19307,10 +19307,7 @@ struct Index {
1930719307#define IsUniqueIndex(X) ((X)->onError!=OE_None)
1930819308
1930919309/* 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)
1931419311
1931519312/* The Index.aiColumn[] values are normally positive integer. But
1931619313** there are some negative values that have special meaning:
@@ -123188,7 +123185,7 @@ static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){
123188123185 for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
123189123186 pNext = pIndex->pNext;
123190123187 assert( pIndex->pSchema==pTable->pSchema
123191- || (IsVirtual(pTable) && !IsAppDefIndex( pIndex) ) );
123188+ || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF ) );
123192123189 if( db->pnBytesFreed==0 && !IsVirtual(pTable) ){
123193123190 char *zName = pIndex->zName;
123194123191 TESTONLY ( Index *pOld = ) sqlite3HashInsert(
@@ -126700,13 +126697,12 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
126700126697 goto exit_create_index;
126701126698 }
126702126699 if( vectorIdxRc >= 1 ){
126703- idxType = SQLITE_IDXTYPE_VECTOR;
126704126700 /*
126705126701 * SQLite can use B-Tree indices in some optimizations (like SELECT COUNT(*) can use any full B-Tree index instead of PK index)
126706126702 * But, SQLite pretty conservative about usage of unordered indices - that's what we need here
126707126703 */
126708126704 pIndex->bUnordered = 1;
126709- pIndex->idxType = idxType ;
126705+ pIndex->idxIsVector = 1 ;
126710126706 }
126711126707 if( vectorIdxRc == 1 ){
126712126708 skipRefill = 1;
@@ -126754,7 +126750,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
126754126750 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
126755126751 int k;
126756126752 assert( IsUniqueIndex(pIdx) );
126757- assert( !IsAppDefIndex( pIdx) );
126753+ assert( pIdx->idxType!=SQLITE_IDXTYPE_APPDEF );
126758126754 assert( IsUniqueIndex(pIndex) );
126759126755
126760126756 if( pIdx->nKeyCol!=pIndex->nKeyCol ) continue;
@@ -127035,7 +127031,7 @@ SQLITE_PRIVATE void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists
127035127031 pParse->checkSchema = 1;
127036127032 goto exit_drop_index;
127037127033 }
127038- if( !IsAppDefIndex( pIndex) ){
127034+ if( pIndex->idxType!=SQLITE_IDXTYPE_APPDEF ){
127039127035 sqlite3ErrorMsg(pParse, "index associated with UNIQUE "
127040127036 "or PRIMARY KEY constraint cannot be dropped", 0);
127041127037 goto exit_drop_index;
@@ -177910,9 +177906,6 @@ static YYACTIONTYPE yy_reduce(
177910177906 case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm indextype ON nm LP sortlist RP where_opt */
177911177907{
177912177908 u8 idxType = SQLITE_IDXTYPE_APPDEF;
177913- if( yymsp[-6].minor.yy421.pUsing!=0 ){
177914- idxType = SQLITE_IDXTYPE_VECTOR;
177915- }
177916177909 sqlite3CreateIndex(pParse, &yymsp[-8].minor.yy0, &yymsp[-7].minor.yy0,
177917177910 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy402, yymsp[-11].minor.yy502,
177918177911 &yymsp[-12].minor.yy0, yymsp[0].minor.yy590, SQLITE_SO_ASC, yymsp[-9].minor.yy502, idxType, yymsp[-6].minor.yy421.pUsing);
0 commit comments