• Home
  • Raw
  • Download

Lines Matching refs:pIdx

17709 SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
60623 Index *pIdx = (Index *)sqliteHashData(p);
60624 if( pIdx->tnum==(int)iRoot ){
60631 iTab = pIdx->pTable->tnum;
61996 static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
62040 *pIdx = (int)(pSpace - data);
62069 *pIdx = top;
72341 Index *pIdx;
72363 Index *pIdx = p->pIdx; /* Index being probed */
72366 int nCol = pIdx->nColumn; /* Number of index columns including rowid */
72371 pRec->pKeyInfo = sqlite3KeyInfoOfIndex(p->pParse, pIdx);
72808 Index *pIdx, /* Index being probed */
72823 alloc.pIdx = pIdx;
72829 u8 aff = sqlite3IndexColumnAffinity(pParse->db, pIdx, iVal+i);
74033 SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){
74037 assert( pIdx!=0 );
74038 pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pIdx);
87514 Index *pIdx;
87532 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
87534 for(j=0; j<pIdx->nKeyCol; j++){
87536 if( pIdx->aiColumn[j]==iCol || pIdx->aiColumn[j]==XN_EXPR ){
95003 Index *pIdx; /* Iterator variable */
95035 for(pIdx=pTab->pIndex; pIdx && eType==0; pIdx=pIdx->pNext){
95038 if( pIdx->nColumn<nExpr ) continue;
95041 testcase( pIdx->nColumn==BMS-2 );
95042 testcase( pIdx->nColumn==BMS-1 );
95043 if( pIdx->nColumn>=BMS-1 ) continue;
95045 if( pIdx->nKeyCol>nExpr
95046 ||(pIdx->nColumn>nExpr && !IsUniqueIndex(pIdx))
95061 if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;
95062 assert( pIdx->azColl[j] );
95063 if( pReq!=0 && sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ){
95081 sqlite3MPrintf(db, "USING INDEX %s FOR IN-OPERATOR",pIdx->zName),
95084 sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);
95085 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
95086 VdbeComment((v, "%s", pIdx->zName));
95088 eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
95977 Index *pIdx, /* The index whose column is to be loaded */
95982 i16 iTabCol = pIdx->aiColumn[iIdxCol];
95984 assert( pIdx->aColExpr );
95985 assert( pIdx->aColExpr->nExpr>iIdxCol );
95987 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
95990 sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
97628 Index *pIdx; /* The index to be tested for coverage */
97640 && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0
97661 Index *pIdx /* The index that might be used for coverage */
97667 xcov.pIdx = pIdx;
99832 Index *pIdx; /* An index to being analyzed */
99902 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
99909 if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
99910 if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;
99911 if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){
99912 nCol = pIdx->nKeyCol;
99916 nCol = pIdx->nColumn;
99917 zIdxName = pIdx->zName;
99918 nColTest = pIdx->uniqNotNull ? pIdx->nKeyCol-1 : nCol-1;
99964 assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) );
99965 sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb);
99966 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
99967 VdbeComment((v, "%s", pIdx->zName));
99983 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2);
100019 if( nColTest==1 && pIdx->nKeyCol==1 && IsUniqueIndex(pIdx) ){
100027 char *pColl = (char*)sqlite3LocateCollSeq(pParse, pIdx->azColl[i]);
100067 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
100071 k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);
100072 assert( k>=0 && k<pIdx->nColumn );
100125 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, 0, regSample);
100128 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);
100244 Index *pIdx;
100272 if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){
100273 analyzeTable(pParse, pIdx->pTable, pIdx);
100435 SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){
100437 if( pIdx->aSample ){
100439 for(j=0; j<pIdx->nSample; j++){
100440 IndexSample *p = &pIdx->aSample[j];
100443 sqlite3DbFree(db, pIdx->aSample);
100446 pIdx->nSample = 0;
100447 pIdx->aSample = 0;
100451 UNUSED_PARAMETER(pIdx);
100460 static void initAvgEq(Index *pIdx){
100461 if( pIdx ){
100462 IndexSample *aSample = pIdx->aSample;
100463 IndexSample *pFinal = &aSample[pIdx->nSample-1];
100466 if( pIdx->nSampleCol>1 ){
100471 nCol = pIdx->nSampleCol-1;
100472 pIdx->aAvgEq[nCol] = 1;
100475 int nSample = pIdx->nSample;
100483 if( !pIdx->aiRowEst || iCol>=pIdx->nKeyCol || pIdx->aiRowEst[iCol+1]==0 ){
100488 nRow = pIdx->aiRowEst[0];
100489 nDist100 = ((i64)100 * pIdx->aiRowEst[0]) / pIdx->aiRowEst[iCol+1];
100491 pIdx->nRowEst0 = nRow;
100498 if( i==(pIdx->nSample-1)
100510 pIdx->aAvgEq[iCol] = avgEq;
100524 Index *pIdx = sqlite3FindIndex(db, zName, zDb);
100525 if( pIdx==0 ){
100527 if( pTab && !HasRowid(pTab) ) pIdx = sqlite3PrimaryKeyIndex(pTab);
100529 return pIdx;
100571 Index *pIdx; /* Pointer to the index object */
100580 pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
100581 assert( pIdx==0 || bStat3 || pIdx->nSample==0 );
100584 if( pIdx==0 || pIdx->nSample ) continue;
100586 assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );
100587 if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){
100588 nIdxCol = pIdx->nKeyCol;
100590 nIdxCol = pIdx->nColumn;
100593 pIdx->nSampleCol = nIdxCol;
100598 pIdx->aSample = sqlite3DbMallocZero(db, nByte);
100599 if( pIdx->aSample==0 ){
100603 pSpace = (tRowcnt*)&pIdx->aSample[nSample];
100604 pIdx->aAvgEq = pSpace; pSpace += nIdxCol;
100606 pIdx->aSample[i].anEq = pSpace; pSpace += nIdxCol;
100607 pIdx->aSample[i].anLt = pSpace; pSpace += nIdxCol;
100608 pIdx->aSample[i].anDLt = pSpace; pSpace += nIdxCol;
100610 assert( ((u8*)pSpace)-nByte==(u8*)(pIdx->aSample) );
100625 Index *pIdx; /* Pointer to the index object */
100630 pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
100631 if( pIdx==0 ) continue;
100634 nCol = pIdx->nSampleCol;
100636 if( pIdx!=pPrevIdx ){
100638 pPrevIdx = pIdx;
100640 pSample = &pIdx->aSample[pIdx->nSample];
100660 pIdx->nSample++;
100732 Index *pIdx = sqliteHashData(i);
100733 pIdx->hasStat1 = 0;
100735 sqlite3DeleteIndexSamples(db, pIdx);
100736 pIdx->aSample = 0;
100757 Index *pIdx = sqliteHashData(i);
100758 if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
100769 Index *pIdx = sqliteHashData(i);
100770 sqlite3_free(pIdx->aiRowEst);
100771 pIdx->aiRowEst = 0;
102455 SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){
102457 for(i=0; i<pIdx->nColumn; i++){
102458 if( iCol==pIdx->aiColumn[i] ) return i;
103041 Index *pIdx;
103049 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
103050 assert( pIdx->nKeyCol==1 );
103051 if( pIdx->aiColumn[0]==i ){
103052 pIdx->azColl[0] = p->aCol[i].zColl;
103151 static void identPut(char *z, int *pIdx, char *zSignedIdent){
103154 i = *pIdx;
103171 *pIdx = i;
103247 static int resizeIndexObject(sqlite3 *db, Index *pIdx, int N){
103250 if( pIdx->nColumn>=N ) return SQLITE_OK;
103251 assert( pIdx->isResized==0 );
103255 memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn);
103256 pIdx->azColl = (const char**)zExtra;
103258 memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn);
103259 pIdx->aiColumn = (i16*)zExtra;
103261 memcpy(zExtra, pIdx->aSortOrder, pIdx->nColumn);
103262 pIdx->aSortOrder = (u8*)zExtra;
103263 pIdx->nColumn = N;
103264 pIdx->isResized = 1;
103285 static void estimateIndexWidth(Index *pIdx){
103288 const Column *aCol = pIdx->pTable->aCol;
103289 for(i=0; i<pIdx->nColumn; i++){
103290 i16 x = pIdx->aiColumn[i];
103291 assert( x<pIdx->pTable->nCol );
103292 wIndex += x<0 ? 1 : aCol[pIdx->aiColumn[i]].szEst;
103294 pIdx->szIdxRow = sqlite3LogEst(wIndex*4);
103329 Index *pIdx;
103412 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
103414 if( IsPrimaryKeyIndex(pIdx) ) continue;
103416 if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ) n++;
103420 pIdx->nColumn = pIdx->nKeyCol;
103423 if( resizeIndexObject(db, pIdx, pIdx->nKeyCol+n) ) return;
103424 for(i=0, j=pIdx->nKeyCol; i<nPk; i++){
103425 if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ){
103426 pIdx->aiColumn[j] = pPk->aiColumn[i];
103427 pIdx->azColl[j] = pPk->azColl[i];
103431 assert( pIdx->nColumn>=pIdx->nKeyCol+n );
103432 assert( pIdx->nColumn>=j );
103484 Index *pIdx; /* An implied index of the table */
103536 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
103537 estimateIndexWidth(pIdx);
103961 Index *pIdx = sqliteHashData(pElem);
103962 if( pIdx->tnum==iFrom ){
103963 pIdx->tnum = iTo;
104025 Index *pIdx;
104031 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
104032 int iIdx = pIdx->tnum;
104033 assert( pIdx->pSchema==pTab->pSchema );
104907 Index *pIdx;
104908 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
104910 assert( IsUniqueIndex(pIdx) );
104911 assert( pIdx->idxType!=SQLITE_IDXTYPE_APPDEF );
104914 if( pIdx->nKeyCol!=pIndex->nKeyCol ) continue;
104915 for(k=0; k<pIdx->nKeyCol; k++){
104918 assert( pIdx->aiColumn[k]>=0 );
104919 if( pIdx->aiColumn[k]!=pIndex->aiColumn[k] ) break;
104920 z1 = pIdx->azColl[k];
104924 if( k==pIdx->nKeyCol ){
104925 if( pIdx->onError!=pIndex->onError ){
104933 if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){
104937 if( pIdx->onError==OE_Default ){
104938 pIdx->onError = pIndex->onError;
104941 if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;
105090 SQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){
105093 LogEst *a = pIdx->aiRowLogEst;
105094 int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
105098 assert( !pIdx->hasStat1 );
105103 a[0] = pIdx->pTable->nRowLogEst;
105104 if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10; assert( 10==sqlite3LogEst(2) );
105110 for(i=nCopy+1; i<=pIdx->nKeyCol; i++){
105115 if( IsUniqueIndex(pIdx) ) a[pIdx->nKeyCol] = 0;
105208 int *pIdx /* Write the index of a new slot here */
105216 *pIdx = -1;
105223 *pIdx = n;
105799 Index *pIdx /* The index that triggers the constraint */
105804 Table *pTab = pIdx->pTable;
105807 if( pIdx->aColExpr ){
105808 sqlite3XPrintf(&errMsg, "index '%q'", pIdx->zName);
105810 for(j=0; j<pIdx->nKeyCol; j++){
105812 assert( pIdx->aiColumn[j]>=0 );
105813 zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
105822 IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY
105985 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
105987 int nCol = pIdx->nColumn;
105988 int nKey = pIdx->nKeyCol;
105991 if( pIdx->uniqNotNull ){
105999 const char *zColl = pIdx->azColl[i];
106002 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
106006 if( pIdx->bNoQuery==0 ){
106014 pIdx->bNoQuery = 1;
106815 Index *pIdx; /* For looping over indices of the table */
106912 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){
106988 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
106989 assert( pIdx->pSchema==pTab->pSchema );
106990 sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
107405 Index *pIdx; /* Current index */
107412 for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
107413 assert( iIdxCur+i!=iDataCur || pPk==pIdx );
107415 if( pIdx==pPk ) continue;
107417 VdbeModuleComment((v, "GenRowIdxDel for %s", pIdx->zName));
107418 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 1,
107421 pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn);
107423 pPrior = pIdx;
107460 Index *pIdx, /* The index for which to generate a key */
107474 if( pIdx->pPartIdxWhere ){
107478 sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
107485 nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;
107490 && pPrior->aiColumn[j]==pIdx->aiColumn[j]
107496 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);
107507 if( pIdx->pTable->pSelect ){
107508 const char *zAff = sqlite3IndexAffinityStr(pParse->db, pIdx);
109619 Index *pIdx = 0; /* Value to return via *ppIdx */
109656 for(pIdx=pParent->pIndex; pIdx; pIdx=pIdx->pNext){
109657 if( pIdx->nKeyCol==nCol && IsUniqueIndex(pIdx) && pIdx->pPartIdxWhere==0 ){
109666 if( IsPrimaryKeyIndex(pIdx) ){
109680 i16 iCol = pIdx->aiColumn[i]; /* Index of column in parent tbl */
109691 if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;
109707 if( !pIdx ){
109717 *ppIdx = pIdx;
109751 Index *pIdx, /* Unique index on parent key columns in pTab */
109780 if( pIdx==0 ){
109815 sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);
109816 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
109835 int iParent = pIdx->aiColumn[i]+1+regData;
109836 assert( pIdx->aiColumn[i]>=0 );
109838 if( pIdx->aiColumn[i]==pTab->iPKey ){
109849 sqlite3IndexAffinityStr(pParse->db,pIdx), nCol);
109971 Index *pIdx, /* Index on parent covering the foreign key */
109985 assert( pIdx==0 || pIdx->pTable==pTab );
109986 assert( pIdx==0 || pIdx->nKeyCol==pFKey->nCol );
109987 assert( pIdx!=0 || pFKey->nCol==1 );
109988 assert( pIdx!=0 || HasRowid(pTab) );
110010 iCol = pIdx ? pIdx->aiColumn[i] : -1;
110042 assert( pIdx!=0 );
110044 i16 iCol = pIdx->aiColumn[i];
110311 Index *pIdx = 0; /* Index on key columns in pTo */
110334 if( !pTo || sqlite3FkLocateIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){
110355 assert( pFKey->nCol==1 || (aiFree && pIdx) );
110367 assert( pIdx==0 || pIdx->aiColumn[i]>=0 );
110374 char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zName;
110391 fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1, bIgnore);
110402 fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1, bIgnore);
110411 Index *pIdx = 0; /* Foreign key index for pFKey */
110428 if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){
110445 fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1);
110449 fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1);
110496 Index *pIdx = 0;
110497 sqlite3FkLocateIndex(pParse, pTab, p, &pIdx, 0);
110498 if( pIdx ){
110499 for(i=0; i<pIdx->nKeyCol; i++){
110500 assert( pIdx->aiColumn[i]>=0 );
110501 mask |= COLUMN_MASK(pIdx->aiColumn[i]);
110619 Index *pIdx = 0; /* Parent key index for this FK */
110628 if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0;
110641 assert( pIdx!=0 || (pTab->iPKey>=0 && pTab->iPKey<pTab->nCol) );
110642 assert( pIdx==0 || pIdx->aiColumn[i]>=0 );
110644 pTab->aCol[pIdx ? pIdx->aiColumn[i] : pTab->iPKey].zName);
110925 SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){
110926 if( !pIdx->zColAff ){
110936 Table *pTab = pIdx->pTable;
110937 pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+1);
110938 if( !pIdx->zColAff ){
110942 for(n=0; n<pIdx->nColumn; n++){
110943 i16 x = pIdx->aiColumn[n];
110945 pIdx->zColAff[n] = pTab->aCol[x].affinity;
110947 pIdx->zColAff[n] = SQLITE_AFF_INTEGER;
110951 assert( pIdx->aColExpr!=0 );
110952 aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);
110954 pIdx->zColAff[n] = aff;
110957 pIdx->zColAff[n] = 0;
110960 return pIdx->zColAff;
111342 Index *pIdx; /* For looping over indices of the table */
111645 for(i=0, pIdx=pTab->pIndex; i<nIdx; pIdx=pIdx->pNext, i++){
111646 assert( pIdx );
111648 pParse->nMem += pIdx->nColumn;
112091 Index *pIdx; /* Pointer to one of the indices */
112240 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
112241 if( pIdx->onError==OE_Ignore || pIdx->onError==OE_Fail ){
112335 for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){
112350 if( pIdx->pPartIdxWhere ){
112353 sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk,
112362 for(i=0; i<pIdx->nColumn; i++){
112363 int iField = pIdx->aiColumn[i];
112367 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
112369 VdbeComment((v, "%s column %d", pIdx->zName, i));
112380 sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
112381 VdbeComment((v, "for %s", pIdx->zName));
112383 if( pIdx->idxType==2 ) sqlite3SetMakeRecordP5(v, pIdx->pTable);
112390 if( isUpdate && pPk==pIdx && pkChng==0 ){
112396 onError = pIdx->onError;
112414 if( (ix==0 && pIdx->pNext==0) /* Condition 3 */
112415 && pPk==pIdx /* Condition 2 */
112429 regIdx, pIdx->nKeyCol); VdbeCoverage(v);
112432 regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);
112447 if( pIdx!=pPk ){
112450 x = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
112466 int regCmp = (IsPrimaryKeyIndex(pIdx) ? regIdx : regR);
112494 sqlite3UniqueConstraint(pParse, onError, pIdx);
112510 (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);
112571 Index *pIdx; /* An index being inserted or updated */
112586 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
112589 if( pIdx->pPartIdxWhere ){
112594 if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
112609 pIdx->uniqNotNull ? pIdx->nKeyCol: pIdx->nColumn);
112674 Index *pIdx;
112697 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
112699 assert( pIdx->pSchema==pTab->pSchema );
112700 if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
112705 sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb);
112706 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
112708 VdbeComment((v, "%s", pIdx->zName));
116432 Index *pIdx;
116444 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
116446 pIdx->zName,
116447 pIdx->szIdxRow,
116448 pIdx->aiRowLogEst[0],
116449 pIdx->hasStat1);
116458 Index *pIdx;
116460 pIdx = sqlite3FindIndex(db, zRight, zDb);
116461 if( pIdx ){
116466 mx = pIdx->nColumn;
116470 mx = pIdx->nKeyCol;
116473 pTab = pIdx->pTable;
116477 i16 cnum = pIdx->aiColumn[i];
116482 pIdx->aSortOrder[i],
116483 pIdx->azColl[i],
116484 i<pIdx->nKeyCol);
116493 Index *pIdx;
116500 for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){
116504 pIdx->zName,
116505 IsUniqueIndex(pIdx),
116506 azOrigin[pIdx->idxType],
116507 pIdx->pPartIdxWhere!=0);
116618 Index *pIdx; /* Index in the parent table */
116652 pIdx = 0;
116654 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);
116656 if( pIdx==0 ){
116659 sqlite3VdbeAddOp3(v, OP_OpenRead, i, pIdx->tnum, iDb);
116660 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
116673 pIdx = 0;
116676 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
116693 if( pIdx ){
116695 sqlite3IndexAffinityStr(db,pIdx), pFK->nCol);
116817 Index *pIdx; /* An index on pTab */
116820 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; }
116827 Index *pIdx;
116829 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
116830 aRoot[++cnt] = pIdx->tnum;
116854 Index *pIdx, *pPk;
116869 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
116922 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
116925 if( pPk==pIdx ) continue;
116926 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
116928 pPrior = pIdx;
116932 pIdx->nColumn); VdbeCoverage(v);
116937 jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);
116944 if( IsUniqueIndex(pIdx) ){
116948 for(kk=0; kk<pIdx->nKeyCol; kk++){
116949 int iCol = pIdx->aiColumn[kk];
116959 pIdx->nKeyCol); VdbeCoverage(v);
116973 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
116974 if( pPk==pIdx ) continue;
116978 sqlite3VdbeLoadString(v, 4, pIdx->zName);
117290 Index *pIdx; /* An index of the table */
117316 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
117317 if( !pIdx->hasStat1 ){
122690 Index *pIdx;
122691 for(pIdx=pTab->pIndex;
122692 pIdx && sqlite3StrICmp(pIdx->zName, zIndexedBy);
122693 pIdx=pIdx->pNext
122695 if( !pIdx ){
122700 pFrom->pIBIndex = pIdx;
123597 Index *pIdx /* Index used to optimize scan, or NULL */
123600 int bCover = (pIdx!=0 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pIdx)));
123604 bCover ? pIdx->zName : ""
124634 Index *pIdx; /* Iterator variable */
124652 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
124653 if( pIdx->bUnordered==0
124654 && pIdx->szIdxRow<pTab->szTabRow
124655 && pIdx->pPartIdxWhere==0
124656 && (!pBest || pIdx->szIdxRow<pBest->szIdxRow)
124658 pBest = pIdx;
126197 Index *pIdx; /* For looping over indices */
126300 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){
126301 if( IsPrimaryKeyIndex(pIdx) && pPk!=0 ){
126392 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
126394 if( chngKey || hasFK>1 || pIdx->pPartIdxWhere || pIdx==pPk ){
126396 pParse->nMem += pIdx->nColumn;
126399 for(i=0; i<pIdx->nKeyCol; i++){
126400 i16 iIdxCol = pIdx->aiColumn[i];
126403 pParse->nMem += pIdx->nColumn;
126405 || (onError==OE_Default && pIdx->onError==OE_Replace)
128147 Index *pIdx;
128163 pIdx = pNew->pIndex;
128164 if( pIdx ){
128165 assert( pIdx->pNext==0 );
128166 pTab->pIndex = pIdx;
128168 pIdx->pTable = pTab;
129104 Index *pIdx /* Must be compatible with this index, if not NULL */
129212 static const char *explainIndexColumnName(Index *pIdx, int i){
129213 i = pIdx->aiColumn[i];
129216 return pIdx->pTable->aCol[i].zName;
129229 Index *pIdx, /* Index to read column names from */
129243 sqlite3StrAccumAppendAll(pStr, explainIndexColumnName(pIdx, iTerm+i));
129350 Index *pIdx;
129353 pIdx = pLoop->u.btree.pIndex;
129355 if( !HasRowid(pItem->pTab) && IsPrimaryKeyIndex(pIdx) ){
129370 sqlite3XPrintf(&str, zFmt, pIdx->zName);
129850 Index *pIdx; /* The index being used for this loop */
129863 pIdx = pLoop->u.btree.pIndex;
129864 assert( pIdx!=0 );
129872 zAff = sqlite3DbStrDup(pParse->db,sqlite3IndexAffinityStr(pParse->db,pIdx));
129880 VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
129889 testcase( pIdx->aiColumn[j]==XN_EXPR );
129890 VdbeComment((v, "%s", explainIndexColumnName(pIdx, j)));
129989 Index *pIdx; /* The index used to access the table */
130000 assert( pHint->pIdx!=0 );
130003 && sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn)<0
130072 }else if( pHint->pIdx!=0 ){
130074 pExpr->iColumn = sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn);
130116 sHint.pIdx = pLoop->u.btree.pIndex;
130175 if( sHint.pIdx!=0 ){
130189 (sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0,
130217 Index *pIdx, /* Index scan is using */
130225 assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );
130232 Table *pTab = pIdx->pTable;
130236 for(i=0; i<pIdx->nColumn-1; i++){
130237 assert( pIdx->aiColumn[i]<pTab->nCol );
130238 if( pIdx->aiColumn[i]>=0 ) ai[pIdx->aiColumn[i]+1] = i+1;
130314 Index *pIdx, /* The Index */
130323 aColExpr = pIdx->aColExpr;
130331 if( pIdx->aiColumn[iIdxCol]!=XN_EXPR ) continue;
130368 Index *pIdx = 0; /* Index used by loop (if any) */
130703 pIdx = pLoop->u.btree.pIndex;
130720 && (pIdx->nKeyCol>nEq)
130752 testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC );
130755 pLevel->iLikeRepCntr |= bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC);
130759 j = pIdx->aiColumn[nEq];
130760 if( (j>=0 && pIdx->pTable->aCol[j].notNull==0) || j==XN_EXPR ){
130771 if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC))
130772 || (bRev && pIdx->nKeyCol==nEq)
130900 }else if( HasRowid(pIdx->pTable) ){
130911 codeDeferredSeek(pWInfo, pIdx, iCur, iIdxCur);
130914 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
130917 k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);
130928 whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
130946 if( omitTable ) pIdx = 0;
131276 iLoop = (pIdx ? 1 : 2);
131297 if( iLoop==1 && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){
132297 Index *pIdx;
132302 for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
132303 if( pIdx->aColExpr==0 ) continue;
132304 for(i=0; i<pIdx->nKeyCol; i++){
132305 if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
132306 if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
133239 Index *pIdx /* Must be compatible with this index */
133246 if( pIdx ){
133248 iColumn = pIdx->aiColumn[j];
133250 pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;
133251 pScan->zCollName = pIdx->azColl[j];
133252 }else if( iColumn==pIdx->pTable->iPKey ){
133255 pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;
133256 pScan->zCollName = pIdx->azColl[j];
133301 Index *pIdx /* Must be compatible with this index, if not NULL */
133307 p = whereScanInit(&scan, pWC, iCur, iColumn, op, pIdx);
133333 Index *pIdx, /* Index to match column of */
133337 const char *zColl = pIdx->azColl[iCol];
133342 && p->iColumn==pIdx->aiColumn[iCol]
133358 static int indexColumnNotNull(Index *pIdx, int iCol){
133360 assert( pIdx!=0 );
133361 assert( iCol>=0 && iCol<pIdx->nColumn );
133362 j = pIdx->aiColumn[iCol];
133364 return pIdx->pTable->aCol[j].notNull;
133388 Index *pIdx;
133421 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
133422 if( !IsUniqueIndex(pIdx) ) continue;
133423 for(i=0; i<pIdx->nKeyCol; i++){
133424 if( 0==sqlite3WhereFindTerm(pWC, iBase, i, ~(Bitmask)0, WO_EQ, pIdx) ){
133425 if( findIndexCol(pParse, pDistinct, iBase, pIdx, i)<0 ) break;
133426 if( indexColumnNotNull(pIdx, i)==0 ) break;
133429 if( i==pIdx->nKeyCol ){
133585 Index *pIdx; /* Object describing the transient index */
133676 pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed);
133677 if( pIdx==0 ) goto end_auto_index_create;
133678 pLoop->u.btree.pIndex = pIdx;
133679 pIdx->zName = "auto-index";
133680 pIdx->pTable = pTable;
133692 pIdx->aiColumn[n] = pTerm->u.leftColumn;
133694 pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
133705 pIdx->aiColumn[n] = i;
133706 pIdx->azColl[n] = sqlite3StrBINARY;
133712 pIdx->aiColumn[n] = i;
133713 pIdx->azColl[n] = sqlite3StrBINARY;
133718 pIdx->aiColumn[n] = XN_ROWID;
133719 pIdx->azColl[n] = sqlite3StrBINARY;
133725 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
133748 pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0
133983 Index *pIdx, /* Index to consider domain of */
133988 IndexSample *aSample = pIdx->aSample;
134002 assert( pIdx->nSample>0 );
134003 assert( pRec->nField>0 && pRec->nField<=pIdx->nSampleCol );
134051 iSample = pIdx->nSample * nField;
134092 assert( i<pIdx->nSample );
134102 assert( i<=pIdx->nSample && i>=0 );
134104 assert( i==pIdx->nSample
134136 if( i>=pIdx->nSample ){
134137 iUpper = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);
134153 aStat[1] = pIdx->aAvgEq[nField-1];
134190 SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){
134191 assert( iCol>=0 && iCol<pIdx->nColumn );
134192 if( !pIdx->zColAff ){
134193 if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB;
134195 return pIdx->zColAff[iCol];
135204 Index *pIdx, /* The index to be used for a inequality constraint */
135211 nCmp = MIN(nCmp, (pIdx->nColumn - nEq));
135232 || pLhs->iColumn!=pIdx->aiColumn[i+nEq]
135233 || pIdx->aSortOrder[i+nEq]!=pIdx->aSortOrder[nEq]
135240 idxaff = sqlite3TableColumnAffinity(pIdx->pTable, pLhs->iColumn);
135245 if( sqlite3StrICmp(pColl->zName, pIdx->azColl[i+nEq]) ) break;
135632 static Bitmask columnsInIndex(Index *pIdx){
135635 for(j=pIdx->nColumn-1; j>=0; j--){
135636 int x = pIdx->aiColumn[j];
137208 Index *pIdx;
137232 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
137235 if( !IsUniqueIndex(pIdx)
137236 || pIdx->pPartIdxWhere!=0
137237 || pIdx->nKeyCol>ArraySize(pLoop->aLTermSpace)
137239 opMask = pIdx->uniqNotNull ? (WO_EQ|WO_IS) : WO_EQ;
137240 for(j=0; j<pIdx->nKeyCol; j++){
137241 pTerm = sqlite3WhereFindTerm(pWC, iCur, j, 0, opMask, pIdx);
137246 if( j!=pIdx->nKeyCol ) continue;
137248 if( pIdx->isCovering || (pItem->colUsed & ~columnsInIndex(pIdx))==0 ){
137253 pLoop->u.btree.pIndex = pIdx;
137950 Index *pIdx;
137955 && (pIdx = pLoop->u.btree.pIndex)->hasStat1
137957 && pIdx->aiRowLogEst[n]>=36
138048 Index *pIdx = 0;
138077 pIdx = pLoop->u.btree.pIndex;
138079 pIdx = pLevel->u.pCovidx;
138081 if( pIdx
138082 && (pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable))
138096 assert( pIdx->pTable==pTab );
138102 x = sqlite3ColumnOfIndex(pIdx, x);
173613 sqlite3_stmt *pIdx = pIter->pIdxIter;
173614 rc = sqlite3_bind_text(pIdx, 1, pIter->zTbl, -1, SQLITE_STATIC);
187309 static int sqlite3Fts5ExprFirst(Fts5Expr*, Fts5Index *pIdx, i64 iMin, int bDesc);
192280 static int sqlite3Fts5ExprFirst(Fts5Expr *p, Fts5Index *pIdx, i64 iFirst, int bDesc){
192284 p->pIndex = pIdx;
198728 Fts5Index *pIdx;
203918 Fts5Index *pIdx = pCtx->pStorage->pIndex;
203924 return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken);