• Home
  • Raw
  • Download

Lines Matching refs:pIdx

17709 SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
60607 Index *pIdx = (Index *)sqliteHashData(p);
60608 if( pIdx->tnum==(int)iRoot ){
60615 iTab = pIdx->pTable->tnum;
61980 static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
62024 *pIdx = (int)(pSpace - data);
62053 *pIdx = top;
72325 Index *pIdx;
72347 Index *pIdx = p->pIdx; /* Index being probed */
72350 int nCol = pIdx->nColumn; /* Number of index columns including rowid */
72355 pRec->pKeyInfo = sqlite3KeyInfoOfIndex(p->pParse, pIdx);
72792 Index *pIdx, /* Index being probed */
72807 alloc.pIdx = pIdx;
72813 u8 aff = sqlite3IndexColumnAffinity(pParse->db, pIdx, iVal+i);
74017 SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){
74021 assert( pIdx!=0 );
74022 pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pIdx);
87498 Index *pIdx;
87516 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
87518 for(j=0; j<pIdx->nKeyCol; j++){
87520 if( pIdx->aiColumn[j]==iCol || pIdx->aiColumn[j]==XN_EXPR ){
94987 Index *pIdx; /* Iterator variable */
95019 for(pIdx=pTab->pIndex; pIdx && eType==0; pIdx=pIdx->pNext){
95022 if( pIdx->nColumn<nExpr ) continue;
95025 testcase( pIdx->nColumn==BMS-2 );
95026 testcase( pIdx->nColumn==BMS-1 );
95027 if( pIdx->nColumn>=BMS-1 ) continue;
95029 if( pIdx->nKeyCol>nExpr
95030 ||(pIdx->nColumn>nExpr && !IsUniqueIndex(pIdx))
95045 if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;
95046 assert( pIdx->azColl[j] );
95047 if( pReq!=0 && sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ){
95065 sqlite3MPrintf(db, "USING INDEX %s FOR IN-OPERATOR",pIdx->zName),
95068 sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);
95069 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
95070 VdbeComment((v, "%s", pIdx->zName));
95072 eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
95961 Index *pIdx, /* The index whose column is to be loaded */
95966 i16 iTabCol = pIdx->aiColumn[iIdxCol];
95968 assert( pIdx->aColExpr );
95969 assert( pIdx->aColExpr->nExpr>iIdxCol );
95971 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
95974 sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
97612 Index *pIdx; /* The index to be tested for coverage */
97624 && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0
97645 Index *pIdx /* The index that might be used for coverage */
97651 xcov.pIdx = pIdx;
99816 Index *pIdx; /* An index to being analyzed */
99886 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
99893 if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
99894 if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;
99895 if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){
99896 nCol = pIdx->nKeyCol;
99900 nCol = pIdx->nColumn;
99901 zIdxName = pIdx->zName;
99902 nColTest = pIdx->uniqNotNull ? pIdx->nKeyCol-1 : nCol-1;
99948 assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) );
99949 sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb);
99950 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
99951 VdbeComment((v, "%s", pIdx->zName));
99967 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2);
100003 if( nColTest==1 && pIdx->nKeyCol==1 && IsUniqueIndex(pIdx) ){
100011 char *pColl = (char*)sqlite3LocateCollSeq(pParse, pIdx->azColl[i]);
100051 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
100055 k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);
100056 assert( k>=0 && k<pIdx->nColumn );
100109 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, 0, regSample);
100112 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);
100228 Index *pIdx;
100256 if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){
100257 analyzeTable(pParse, pIdx->pTable, pIdx);
100419 SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){
100421 if( pIdx->aSample ){
100423 for(j=0; j<pIdx->nSample; j++){
100424 IndexSample *p = &pIdx->aSample[j];
100427 sqlite3DbFree(db, pIdx->aSample);
100430 pIdx->nSample = 0;
100431 pIdx->aSample = 0;
100435 UNUSED_PARAMETER(pIdx);
100444 static void initAvgEq(Index *pIdx){
100445 if( pIdx ){
100446 IndexSample *aSample = pIdx->aSample;
100447 IndexSample *pFinal = &aSample[pIdx->nSample-1];
100450 if( pIdx->nSampleCol>1 ){
100455 nCol = pIdx->nSampleCol-1;
100456 pIdx->aAvgEq[nCol] = 1;
100459 int nSample = pIdx->nSample;
100467 if( !pIdx->aiRowEst || iCol>=pIdx->nKeyCol || pIdx->aiRowEst[iCol+1]==0 ){
100472 nRow = pIdx->aiRowEst[0];
100473 nDist100 = ((i64)100 * pIdx->aiRowEst[0]) / pIdx->aiRowEst[iCol+1];
100475 pIdx->nRowEst0 = nRow;
100482 if( i==(pIdx->nSample-1)
100494 pIdx->aAvgEq[iCol] = avgEq;
100508 Index *pIdx = sqlite3FindIndex(db, zName, zDb);
100509 if( pIdx==0 ){
100511 if( pTab && !HasRowid(pTab) ) pIdx = sqlite3PrimaryKeyIndex(pTab);
100513 return pIdx;
100555 Index *pIdx; /* Pointer to the index object */
100564 pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
100565 assert( pIdx==0 || bStat3 || pIdx->nSample==0 );
100568 if( pIdx==0 || pIdx->nSample ) continue;
100570 assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );
100571 if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){
100572 nIdxCol = pIdx->nKeyCol;
100574 nIdxCol = pIdx->nColumn;
100577 pIdx->nSampleCol = nIdxCol;
100582 pIdx->aSample = sqlite3DbMallocZero(db, nByte);
100583 if( pIdx->aSample==0 ){
100587 pSpace = (tRowcnt*)&pIdx->aSample[nSample];
100588 pIdx->aAvgEq = pSpace; pSpace += nIdxCol;
100590 pIdx->aSample[i].anEq = pSpace; pSpace += nIdxCol;
100591 pIdx->aSample[i].anLt = pSpace; pSpace += nIdxCol;
100592 pIdx->aSample[i].anDLt = pSpace; pSpace += nIdxCol;
100594 assert( ((u8*)pSpace)-nByte==(u8*)(pIdx->aSample) );
100609 Index *pIdx; /* Pointer to the index object */
100614 pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
100615 if( pIdx==0 ) continue;
100618 nCol = pIdx->nSampleCol;
100620 if( pIdx!=pPrevIdx ){
100622 pPrevIdx = pIdx;
100624 pSample = &pIdx->aSample[pIdx->nSample];
100644 pIdx->nSample++;
100716 Index *pIdx = sqliteHashData(i);
100717 pIdx->hasStat1 = 0;
100719 sqlite3DeleteIndexSamples(db, pIdx);
100720 pIdx->aSample = 0;
100741 Index *pIdx = sqliteHashData(i);
100742 if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
100753 Index *pIdx = sqliteHashData(i);
100754 sqlite3_free(pIdx->aiRowEst);
100755 pIdx->aiRowEst = 0;
102439 SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){
102441 for(i=0; i<pIdx->nColumn; i++){
102442 if( iCol==pIdx->aiColumn[i] ) return i;
103025 Index *pIdx;
103033 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
103034 assert( pIdx->nKeyCol==1 );
103035 if( pIdx->aiColumn[0]==i ){
103036 pIdx->azColl[0] = p->aCol[i].zColl;
103135 static void identPut(char *z, int *pIdx, char *zSignedIdent){
103138 i = *pIdx;
103155 *pIdx = i;
103231 static int resizeIndexObject(sqlite3 *db, Index *pIdx, int N){
103234 if( pIdx->nColumn>=N ) return SQLITE_OK;
103235 assert( pIdx->isResized==0 );
103239 memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn);
103240 pIdx->azColl = (const char**)zExtra;
103242 memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn);
103243 pIdx->aiColumn = (i16*)zExtra;
103245 memcpy(zExtra, pIdx->aSortOrder, pIdx->nColumn);
103246 pIdx->aSortOrder = (u8*)zExtra;
103247 pIdx->nColumn = N;
103248 pIdx->isResized = 1;
103269 static void estimateIndexWidth(Index *pIdx){
103272 const Column *aCol = pIdx->pTable->aCol;
103273 for(i=0; i<pIdx->nColumn; i++){
103274 i16 x = pIdx->aiColumn[i];
103275 assert( x<pIdx->pTable->nCol );
103276 wIndex += x<0 ? 1 : aCol[pIdx->aiColumn[i]].szEst;
103278 pIdx->szIdxRow = sqlite3LogEst(wIndex*4);
103313 Index *pIdx;
103396 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
103398 if( IsPrimaryKeyIndex(pIdx) ) continue;
103400 if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ) n++;
103404 pIdx->nColumn = pIdx->nKeyCol;
103407 if( resizeIndexObject(db, pIdx, pIdx->nKeyCol+n) ) return;
103408 for(i=0, j=pIdx->nKeyCol; i<nPk; i++){
103409 if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ){
103410 pIdx->aiColumn[j] = pPk->aiColumn[i];
103411 pIdx->azColl[j] = pPk->azColl[i];
103415 assert( pIdx->nColumn>=pIdx->nKeyCol+n );
103416 assert( pIdx->nColumn>=j );
103468 Index *pIdx; /* An implied index of the table */
103520 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
103521 estimateIndexWidth(pIdx);
103945 Index *pIdx = sqliteHashData(pElem);
103946 if( pIdx->tnum==iFrom ){
103947 pIdx->tnum = iTo;
104009 Index *pIdx;
104015 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
104016 int iIdx = pIdx->tnum;
104017 assert( pIdx->pSchema==pTab->pSchema );
104891 Index *pIdx;
104892 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
104894 assert( IsUniqueIndex(pIdx) );
104895 assert( pIdx->idxType!=SQLITE_IDXTYPE_APPDEF );
104898 if( pIdx->nKeyCol!=pIndex->nKeyCol ) continue;
104899 for(k=0; k<pIdx->nKeyCol; k++){
104902 assert( pIdx->aiColumn[k]>=0 );
104903 if( pIdx->aiColumn[k]!=pIndex->aiColumn[k] ) break;
104904 z1 = pIdx->azColl[k];
104908 if( k==pIdx->nKeyCol ){
104909 if( pIdx->onError!=pIndex->onError ){
104917 if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){
104921 if( pIdx->onError==OE_Default ){
104922 pIdx->onError = pIndex->onError;
104925 if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;
105074 SQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){
105077 LogEst *a = pIdx->aiRowLogEst;
105078 int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
105082 assert( !pIdx->hasStat1 );
105087 a[0] = pIdx->pTable->nRowLogEst;
105088 if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10; assert( 10==sqlite3LogEst(2) );
105094 for(i=nCopy+1; i<=pIdx->nKeyCol; i++){
105099 if( IsUniqueIndex(pIdx) ) a[pIdx->nKeyCol] = 0;
105192 int *pIdx /* Write the index of a new slot here */
105200 *pIdx = -1;
105207 *pIdx = n;
105783 Index *pIdx /* The index that triggers the constraint */
105788 Table *pTab = pIdx->pTable;
105791 if( pIdx->aColExpr ){
105792 sqlite3XPrintf(&errMsg, "index '%q'", pIdx->zName);
105794 for(j=0; j<pIdx->nKeyCol; j++){
105796 assert( pIdx->aiColumn[j]>=0 );
105797 zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
105806 IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY
105969 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
105971 int nCol = pIdx->nColumn;
105972 int nKey = pIdx->nKeyCol;
105975 if( pIdx->uniqNotNull ){
105983 const char *zColl = pIdx->azColl[i];
105986 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
105990 if( pIdx->bNoQuery==0 ){
105998 pIdx->bNoQuery = 1;
106799 Index *pIdx; /* For looping over indices of the table */
106896 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){
106972 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
106973 assert( pIdx->pSchema==pTab->pSchema );
106974 sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
107389 Index *pIdx; /* Current index */
107396 for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
107397 assert( iIdxCur+i!=iDataCur || pPk==pIdx );
107399 if( pIdx==pPk ) continue;
107401 VdbeModuleComment((v, "GenRowIdxDel for %s", pIdx->zName));
107402 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 1,
107405 pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn);
107407 pPrior = pIdx;
107444 Index *pIdx, /* The index for which to generate a key */
107458 if( pIdx->pPartIdxWhere ){
107462 sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
107469 nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;
107474 && pPrior->aiColumn[j]==pIdx->aiColumn[j]
107480 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);
107491 if( pIdx->pTable->pSelect ){
107492 const char *zAff = sqlite3IndexAffinityStr(pParse->db, pIdx);
109603 Index *pIdx = 0; /* Value to return via *ppIdx */
109640 for(pIdx=pParent->pIndex; pIdx; pIdx=pIdx->pNext){
109641 if( pIdx->nKeyCol==nCol && IsUniqueIndex(pIdx) && pIdx->pPartIdxWhere==0 ){
109650 if( IsPrimaryKeyIndex(pIdx) ){
109664 i16 iCol = pIdx->aiColumn[i]; /* Index of column in parent tbl */
109675 if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;
109691 if( !pIdx ){
109701 *ppIdx = pIdx;
109735 Index *pIdx, /* Unique index on parent key columns in pTab */
109764 if( pIdx==0 ){
109799 sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);
109800 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
109819 int iParent = pIdx->aiColumn[i]+1+regData;
109820 assert( pIdx->aiColumn[i]>=0 );
109822 if( pIdx->aiColumn[i]==pTab->iPKey ){
109833 sqlite3IndexAffinityStr(pParse->db,pIdx), nCol);
109955 Index *pIdx, /* Index on parent covering the foreign key */
109969 assert( pIdx==0 || pIdx->pTable==pTab );
109970 assert( pIdx==0 || pIdx->nKeyCol==pFKey->nCol );
109971 assert( pIdx!=0 || pFKey->nCol==1 );
109972 assert( pIdx!=0 || HasRowid(pTab) );
109994 iCol = pIdx ? pIdx->aiColumn[i] : -1;
110026 assert( pIdx!=0 );
110028 i16 iCol = pIdx->aiColumn[i];
110295 Index *pIdx = 0; /* Index on key columns in pTo */
110318 if( !pTo || sqlite3FkLocateIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){
110339 assert( pFKey->nCol==1 || (aiFree && pIdx) );
110351 assert( pIdx==0 || pIdx->aiColumn[i]>=0 );
110358 char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zName;
110375 fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1, bIgnore);
110386 fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1, bIgnore);
110395 Index *pIdx = 0; /* Foreign key index for pFKey */
110412 if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){
110429 fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1);
110433 fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1);
110480 Index *pIdx = 0;
110481 sqlite3FkLocateIndex(pParse, pTab, p, &pIdx, 0);
110482 if( pIdx ){
110483 for(i=0; i<pIdx->nKeyCol; i++){
110484 assert( pIdx->aiColumn[i]>=0 );
110485 mask |= COLUMN_MASK(pIdx->aiColumn[i]);
110603 Index *pIdx = 0; /* Parent key index for this FK */
110612 if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0;
110625 assert( pIdx!=0 || (pTab->iPKey>=0 && pTab->iPKey<pTab->nCol) );
110626 assert( pIdx==0 || pIdx->aiColumn[i]>=0 );
110628 pTab->aCol[pIdx ? pIdx->aiColumn[i] : pTab->iPKey].zName);
110909 SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){
110910 if( !pIdx->zColAff ){
110920 Table *pTab = pIdx->pTable;
110921 pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+1);
110922 if( !pIdx->zColAff ){
110926 for(n=0; n<pIdx->nColumn; n++){
110927 i16 x = pIdx->aiColumn[n];
110929 pIdx->zColAff[n] = pTab->aCol[x].affinity;
110931 pIdx->zColAff[n] = SQLITE_AFF_INTEGER;
110935 assert( pIdx->aColExpr!=0 );
110936 aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);
110938 pIdx->zColAff[n] = aff;
110941 pIdx->zColAff[n] = 0;
110944 return pIdx->zColAff;
111326 Index *pIdx; /* For looping over indices of the table */
111629 for(i=0, pIdx=pTab->pIndex; i<nIdx; pIdx=pIdx->pNext, i++){
111630 assert( pIdx );
111632 pParse->nMem += pIdx->nColumn;
112075 Index *pIdx; /* Pointer to one of the indices */
112224 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
112225 if( pIdx->onError==OE_Ignore || pIdx->onError==OE_Fail ){
112319 for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){
112334 if( pIdx->pPartIdxWhere ){
112337 sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk,
112346 for(i=0; i<pIdx->nColumn; i++){
112347 int iField = pIdx->aiColumn[i];
112351 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
112353 VdbeComment((v, "%s column %d", pIdx->zName, i));
112364 sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
112365 VdbeComment((v, "for %s", pIdx->zName));
112367 if( pIdx->idxType==2 ) sqlite3SetMakeRecordP5(v, pIdx->pTable);
112374 if( isUpdate && pPk==pIdx && pkChng==0 ){
112380 onError = pIdx->onError;
112398 if( (ix==0 && pIdx->pNext==0) /* Condition 3 */
112399 && pPk==pIdx /* Condition 2 */
112413 regIdx, pIdx->nKeyCol); VdbeCoverage(v);
112416 regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);
112431 if( pIdx!=pPk ){
112434 x = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
112450 int regCmp = (IsPrimaryKeyIndex(pIdx) ? regIdx : regR);
112478 sqlite3UniqueConstraint(pParse, onError, pIdx);
112494 (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);
112555 Index *pIdx; /* An index being inserted or updated */
112570 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
112573 if( pIdx->pPartIdxWhere ){
112578 if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
112593 pIdx->uniqNotNull ? pIdx->nKeyCol: pIdx->nColumn);
112658 Index *pIdx;
112681 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
112683 assert( pIdx->pSchema==pTab->pSchema );
112684 if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
112689 sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb);
112690 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
112692 VdbeComment((v, "%s", pIdx->zName));
116416 Index *pIdx;
116428 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
116430 pIdx->zName,
116431 pIdx->szIdxRow,
116432 pIdx->aiRowLogEst[0],
116433 pIdx->hasStat1);
116442 Index *pIdx;
116444 pIdx = sqlite3FindIndex(db, zRight, zDb);
116445 if( pIdx ){
116450 mx = pIdx->nColumn;
116454 mx = pIdx->nKeyCol;
116457 pTab = pIdx->pTable;
116461 i16 cnum = pIdx->aiColumn[i];
116466 pIdx->aSortOrder[i],
116467 pIdx->azColl[i],
116468 i<pIdx->nKeyCol);
116477 Index *pIdx;
116484 for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){
116488 pIdx->zName,
116489 IsUniqueIndex(pIdx),
116490 azOrigin[pIdx->idxType],
116491 pIdx->pPartIdxWhere!=0);
116602 Index *pIdx; /* Index in the parent table */
116636 pIdx = 0;
116638 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);
116640 if( pIdx==0 ){
116643 sqlite3VdbeAddOp3(v, OP_OpenRead, i, pIdx->tnum, iDb);
116644 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
116657 pIdx = 0;
116660 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
116677 if( pIdx ){
116679 sqlite3IndexAffinityStr(db,pIdx), pFK->nCol);
116801 Index *pIdx; /* An index on pTab */
116804 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; }
116811 Index *pIdx;
116813 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
116814 aRoot[++cnt] = pIdx->tnum;
116838 Index *pIdx, *pPk;
116853 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
116906 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
116909 if( pPk==pIdx ) continue;
116910 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
116912 pPrior = pIdx;
116916 pIdx->nColumn); VdbeCoverage(v);
116921 jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);
116928 if( IsUniqueIndex(pIdx) ){
116932 for(kk=0; kk<pIdx->nKeyCol; kk++){
116933 int iCol = pIdx->aiColumn[kk];
116943 pIdx->nKeyCol); VdbeCoverage(v);
116957 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
116958 if( pPk==pIdx ) continue;
116962 sqlite3VdbeLoadString(v, 4, pIdx->zName);
117274 Index *pIdx; /* An index of the table */
117300 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
117301 if( !pIdx->hasStat1 ){
122674 Index *pIdx;
122675 for(pIdx=pTab->pIndex;
122676 pIdx && sqlite3StrICmp(pIdx->zName, zIndexedBy);
122677 pIdx=pIdx->pNext
122679 if( !pIdx ){
122684 pFrom->pIBIndex = pIdx;
123581 Index *pIdx /* Index used to optimize scan, or NULL */
123584 int bCover = (pIdx!=0 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pIdx)));
123588 bCover ? pIdx->zName : ""
124618 Index *pIdx; /* Iterator variable */
124636 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
124637 if( pIdx->bUnordered==0
124638 && pIdx->szIdxRow<pTab->szTabRow
124639 && pIdx->pPartIdxWhere==0
124640 && (!pBest || pIdx->szIdxRow<pBest->szIdxRow)
124642 pBest = pIdx;
126181 Index *pIdx; /* For looping over indices */
126284 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){
126285 if( IsPrimaryKeyIndex(pIdx) && pPk!=0 ){
126376 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
126378 if( chngKey || hasFK>1 || pIdx->pPartIdxWhere || pIdx==pPk ){
126380 pParse->nMem += pIdx->nColumn;
126383 for(i=0; i<pIdx->nKeyCol; i++){
126384 i16 iIdxCol = pIdx->aiColumn[i];
126387 pParse->nMem += pIdx->nColumn;
126389 || (onError==OE_Default && pIdx->onError==OE_Replace)
128131 Index *pIdx;
128147 pIdx = pNew->pIndex;
128148 if( pIdx ){
128149 assert( pIdx->pNext==0 );
128150 pTab->pIndex = pIdx;
128152 pIdx->pTable = pTab;
129088 Index *pIdx /* Must be compatible with this index, if not NULL */
129196 static const char *explainIndexColumnName(Index *pIdx, int i){
129197 i = pIdx->aiColumn[i];
129200 return pIdx->pTable->aCol[i].zName;
129213 Index *pIdx, /* Index to read column names from */
129227 sqlite3StrAccumAppendAll(pStr, explainIndexColumnName(pIdx, iTerm+i));
129334 Index *pIdx;
129337 pIdx = pLoop->u.btree.pIndex;
129339 if( !HasRowid(pItem->pTab) && IsPrimaryKeyIndex(pIdx) ){
129354 sqlite3XPrintf(&str, zFmt, pIdx->zName);
129834 Index *pIdx; /* The index being used for this loop */
129847 pIdx = pLoop->u.btree.pIndex;
129848 assert( pIdx!=0 );
129856 zAff = sqlite3DbStrDup(pParse->db,sqlite3IndexAffinityStr(pParse->db,pIdx));
129864 VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
129873 testcase( pIdx->aiColumn[j]==XN_EXPR );
129874 VdbeComment((v, "%s", explainIndexColumnName(pIdx, j)));
129973 Index *pIdx; /* The index used to access the table */
129984 assert( pHint->pIdx!=0 );
129987 && sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn)<0
130056 }else if( pHint->pIdx!=0 ){
130058 pExpr->iColumn = sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn);
130100 sHint.pIdx = pLoop->u.btree.pIndex;
130159 if( sHint.pIdx!=0 ){
130173 (sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0,
130201 Index *pIdx, /* Index scan is using */
130209 assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );
130216 Table *pTab = pIdx->pTable;
130220 for(i=0; i<pIdx->nColumn-1; i++){
130221 assert( pIdx->aiColumn[i]<pTab->nCol );
130222 if( pIdx->aiColumn[i]>=0 ) ai[pIdx->aiColumn[i]+1] = i+1;
130298 Index *pIdx, /* The Index */
130307 aColExpr = pIdx->aColExpr;
130315 if( pIdx->aiColumn[iIdxCol]!=XN_EXPR ) continue;
130352 Index *pIdx = 0; /* Index used by loop (if any) */
130687 pIdx = pLoop->u.btree.pIndex;
130704 && (pIdx->nKeyCol>nEq)
130736 testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC );
130739 pLevel->iLikeRepCntr |= bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC);
130743 j = pIdx->aiColumn[nEq];
130744 if( (j>=0 && pIdx->pTable->aCol[j].notNull==0) || j==XN_EXPR ){
130755 if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC))
130756 || (bRev && pIdx->nKeyCol==nEq)
130884 }else if( HasRowid(pIdx->pTable) ){
130895 codeDeferredSeek(pWInfo, pIdx, iCur, iIdxCur);
130898 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
130901 k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);
130912 whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
130930 if( omitTable ) pIdx = 0;
131260 iLoop = (pIdx ? 1 : 2);
131281 if( iLoop==1 && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){
132281 Index *pIdx;
132286 for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
132287 if( pIdx->aColExpr==0 ) continue;
132288 for(i=0; i<pIdx->nKeyCol; i++){
132289 if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
132290 if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
133223 Index *pIdx /* Must be compatible with this index */
133230 if( pIdx ){
133232 iColumn = pIdx->aiColumn[j];
133234 pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;
133235 pScan->zCollName = pIdx->azColl[j];
133236 }else if( iColumn==pIdx->pTable->iPKey ){
133239 pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;
133240 pScan->zCollName = pIdx->azColl[j];
133285 Index *pIdx /* Must be compatible with this index, if not NULL */
133291 p = whereScanInit(&scan, pWC, iCur, iColumn, op, pIdx);
133317 Index *pIdx, /* Index to match column of */
133321 const char *zColl = pIdx->azColl[iCol];
133326 && p->iColumn==pIdx->aiColumn[iCol]
133342 static int indexColumnNotNull(Index *pIdx, int iCol){
133344 assert( pIdx!=0 );
133345 assert( iCol>=0 && iCol<pIdx->nColumn );
133346 j = pIdx->aiColumn[iCol];
133348 return pIdx->pTable->aCol[j].notNull;
133372 Index *pIdx;
133405 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
133406 if( !IsUniqueIndex(pIdx) ) continue;
133407 for(i=0; i<pIdx->nKeyCol; i++){
133408 if( 0==sqlite3WhereFindTerm(pWC, iBase, i, ~(Bitmask)0, WO_EQ, pIdx) ){
133409 if( findIndexCol(pParse, pDistinct, iBase, pIdx, i)<0 ) break;
133410 if( indexColumnNotNull(pIdx, i)==0 ) break;
133413 if( i==pIdx->nKeyCol ){
133569 Index *pIdx; /* Object describing the transient index */
133660 pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed);
133661 if( pIdx==0 ) goto end_auto_index_create;
133662 pLoop->u.btree.pIndex = pIdx;
133663 pIdx->zName = "auto-index";
133664 pIdx->pTable = pTable;
133676 pIdx->aiColumn[n] = pTerm->u.leftColumn;
133678 pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
133689 pIdx->aiColumn[n] = i;
133690 pIdx->azColl[n] = sqlite3StrBINARY;
133696 pIdx->aiColumn[n] = i;
133697 pIdx->azColl[n] = sqlite3StrBINARY;
133702 pIdx->aiColumn[n] = XN_ROWID;
133703 pIdx->azColl[n] = sqlite3StrBINARY;
133709 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
133732 pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0
133967 Index *pIdx, /* Index to consider domain of */
133972 IndexSample *aSample = pIdx->aSample;
133986 assert( pIdx->nSample>0 );
133987 assert( pRec->nField>0 && pRec->nField<=pIdx->nSampleCol );
134035 iSample = pIdx->nSample * nField;
134076 assert( i<pIdx->nSample );
134086 assert( i<=pIdx->nSample && i>=0 );
134088 assert( i==pIdx->nSample
134120 if( i>=pIdx->nSample ){
134121 iUpper = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);
134137 aStat[1] = pIdx->aAvgEq[nField-1];
134174 SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){
134175 assert( iCol>=0 && iCol<pIdx->nColumn );
134176 if( !pIdx->zColAff ){
134177 if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB;
134179 return pIdx->zColAff[iCol];
135188 Index *pIdx, /* The index to be used for a inequality constraint */
135195 nCmp = MIN(nCmp, (pIdx->nColumn - nEq));
135216 || pLhs->iColumn!=pIdx->aiColumn[i+nEq]
135217 || pIdx->aSortOrder[i+nEq]!=pIdx->aSortOrder[nEq]
135224 idxaff = sqlite3TableColumnAffinity(pIdx->pTable, pLhs->iColumn);
135229 if( sqlite3StrICmp(pColl->zName, pIdx->azColl[i+nEq]) ) break;
135616 static Bitmask columnsInIndex(Index *pIdx){
135619 for(j=pIdx->nColumn-1; j>=0; j--){
135620 int x = pIdx->aiColumn[j];
137192 Index *pIdx;
137216 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
137219 if( !IsUniqueIndex(pIdx)
137220 || pIdx->pPartIdxWhere!=0
137221 || pIdx->nKeyCol>ArraySize(pLoop->aLTermSpace)
137223 opMask = pIdx->uniqNotNull ? (WO_EQ|WO_IS) : WO_EQ;
137224 for(j=0; j<pIdx->nKeyCol; j++){
137225 pTerm = sqlite3WhereFindTerm(pWC, iCur, j, 0, opMask, pIdx);
137230 if( j!=pIdx->nKeyCol ) continue;
137232 if( pIdx->isCovering || (pItem->colUsed & ~columnsInIndex(pIdx))==0 ){
137237 pLoop->u.btree.pIndex = pIdx;
137934 Index *pIdx;
137939 && (pIdx = pLoop->u.btree.pIndex)->hasStat1
137941 && pIdx->aiRowLogEst[n]>=36
138032 Index *pIdx = 0;
138061 pIdx = pLoop->u.btree.pIndex;
138063 pIdx = pLevel->u.pCovidx;
138065 if( pIdx
138066 && (pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable))
138080 assert( pIdx->pTable==pTab );
138086 x = sqlite3ColumnOfIndex(pIdx, x);
173585 sqlite3_stmt *pIdx = pIter->pIdxIter;
173586 rc = sqlite3_bind_text(pIdx, 1, pIter->zTbl, -1, SQLITE_STATIC);
187281 static int sqlite3Fts5ExprFirst(Fts5Expr*, Fts5Index *pIdx, i64 iMin, int bDesc);
192252 static int sqlite3Fts5ExprFirst(Fts5Expr *p, Fts5Index *pIdx, i64 iFirst, int bDesc){
192256 p->pIndex = pIdx;
198700 Fts5Index *pIdx;
203890 Fts5Index *pIdx = pCtx->pStorage->pIndex;
203896 return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken);