Lines Matching defs:pIdx

20274 SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
68834 Index *pIdx = (Index *)sqliteHashData(p);
68835 if( pIdx->tnum==iRoot ){
68842 iTab = pIdx->pTable->tnum;
70308 ** as the first argument. Write into *pIdx the index into pPage->aData[]
70319 static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
70366 *pIdx = g2 = (int)(pSpace-data);
70400 *pIdx = top;
81926 Index *pIdx;
81948 Index *pIdx = p->pIdx; /* Index being probed */
81951 int nCol = pIdx->nColumn; /* Number of index columns including rowid */
81956 pRec->pKeyInfo = sqlite3KeyInfoOfIndex(p->pParse, pIdx);
82348 ** corresponding column within index pIdx is applied to it. Before
82363 Index *pIdx, /* Index being probed */
82378 alloc.pIdx = pIdx;
82384 u8 aff = sqlite3IndexColumnAffinity(pParse->db, pIdx, iVal+i);
84007 SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){
84011 assert( pIdx!=0 );
84012 pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pIdx);
99466 Index *pIdx;
99485 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
99487 for(j=0; j<pIdx->nKeyCol; j++){
99489 if( pIdx->aiColumn[j]==iCol || pIdx->aiColumn[j]==XN_EXPR ){
102768 Index *pIdx = (Index*)sqliteHashData(k);
102769 if( pIdx->tnum==iRoot ){
102770 pCur->zName = pIdx->zName;
108620 Index *pIdx; /* Iterator variable */
108652 for(pIdx=pTab->pIndex; pIdx && eType==0; pIdx=pIdx->pNext){
108655 if( pIdx->nColumn<nExpr ) continue;
108656 if( pIdx->pPartIdxWhere!=0 ) continue;
108659 testcase( pIdx->nColumn==BMS-2 );
108660 testcase( pIdx->nColumn==BMS-1 );
108661 if( pIdx->nColumn>=BMS-1 ) continue;
108663 if( pIdx->nKeyCol>nExpr
108664 ||(pIdx->nColumn>nExpr && !IsUniqueIndex(pIdx))
108679 if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;
108680 assert( pIdx->azColl[j] );
108681 if( pReq!=0 && sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ){
108695 /* If we reach this point, that means the index pIdx is usable */
108698 "USING INDEX %s FOR IN-OPERATOR",pIdx->zName));
108699 sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);
108700 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
108701 VdbeComment((v, "%s", pIdx->zName));
108703 eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];
109540 ** appropriate for the iIdxCol-th column of index pIdx.
109544 Index *pIdx, /* The index whose column is to be loaded */
109549 i16 iTabCol = pIdx->aiColumn[iIdxCol];
109551 assert( pIdx->aColExpr );
109552 assert( pIdx->aColExpr->nExpr>iIdxCol );
109554 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
109557 sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
111796 ** table entry. The IdxCover.pIdx field is the index. IdxCover.iCur
111800 Index *pIdx; /* The index to be tested for coverage */
111807 ** pWalker->u.pIdxCover->pIdx.
111812 && sqlite3TableColumnToIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0
111821 ** Determine if an index pIdx on table with cursor iCur contains will
111824 ** that are not found in the index pIdx.
111833 Index *pIdx /* The index that might be used for coverage */
111839 xcov.pIdx = pIdx;
113748 Index *pIdx;
113753 while( (pIdx = pParse->pNewIndex)!=0 ){
113754 pParse->pNewIndex = pIdx->pNext;
113755 sqlite3FreeIndex(db, pIdx);
113805 Index *pIdx;
113867 for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){
113868 sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
113870 for(pIdx=sParse.pNewIndex; pIdx; pIdx=pIdx->pNext){
113871 sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
115549 ** of the k-th column of the pIdx index.
115553 Index *pIdx, /* Index whose column is being loaded */
115557 assert( k>=0 && k<pIdx->nColumn );
115558 i = pIdx->aiColumn[k];
115560 VdbeComment((v,"%s.rowid",pIdx->zName));
115562 assert( pIdx->bHasExpr );
115563 VdbeComment((v,"%s.expr(%d)",pIdx->zName, k));
115565 VdbeComment((v,"%s.%s", pIdx->zName, pIdx->pTable->aCol[i].zCnName));
115585 Index *pIdx; /* An index to being analyzed */
115654 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
115655 int nCol; /* Number of columns in pIdx. "N" */
115661 if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
115662 if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;
115663 if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){
115664 nCol = pIdx->nKeyCol;
115668 nCol = pIdx->nColumn;
115669 zIdxName = pIdx->zName;
115670 nColTest = pIdx->uniqNotNull ? pIdx->nKeyCol-1 : nCol-1;
115716 assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) );
115717 sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb);
115718 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
115719 VdbeComment((v, "%s", pIdx->zName));
115730 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regRowid);
115777 if( nColTest==1 && pIdx->nKeyCol==1 && IsUniqueIndex(pIdx) ){
115785 char *pColl = (char*)sqlite3LocateCollSeq(pParse, pIdx->azColl[i]);
115788 analyzeVdbeCommentIndexWithColumnName(v,pIdx,i);
115809 analyzeVdbeCommentIndexWithColumnName(v,pIdx,i);
115828 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
115832 k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[j]);
115833 assert( k>=0 && k<pIdx->nColumn );
115835 analyzeVdbeCommentIndexWithColumnName(v,pIdx,k);
115897 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);
116012 Index *pIdx;
116040 if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){
116041 analyzeTable(pParse, pIdx->pTable, pIdx);
116205 SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){
116207 if( pIdx->aSample ){
116209 for(j=0; j<pIdx->nSample; j++){
116210 IndexSample *p = &pIdx->aSample[j];
116213 sqlite3DbFree(db, pIdx->aSample);
116216 pIdx->nSample = 0;
116217 pIdx->aSample = 0;
116221 UNUSED_PARAMETER(pIdx);
116227 ** Populate the pIdx->aAvgEq[] array based on the samples currently
116228 ** stored in pIdx->aSample[].
116230 static void initAvgEq(Index *pIdx){
116231 if( pIdx ){
116232 IndexSample *aSample = pIdx->aSample;
116233 IndexSample *pFinal = &aSample[pIdx->nSample-1];
116236 if( pIdx->nSampleCol>1 ){
116241 nCol = pIdx->nSampleCol-1;
116242 pIdx->aAvgEq[nCol] = 1;
116245 int nSample = pIdx->nSample;
116253 if( !pIdx->aiRowEst || iCol>=pIdx->nKeyCol || pIdx->aiRowEst[iCol+1]==0 ){
116258 nRow = pIdx->aiRowEst[0];
116259 nDist100 = ((i64)100 * pIdx->aiRowEst[0]) / pIdx->aiRowEst[iCol+1];
116261 pIdx->nRowEst0 = nRow;
116268 if( i==(pIdx->nSample-1)
116280 pIdx->aAvgEq[iCol] = avgEq;
116294 Index *pIdx = sqlite3FindIndex(db, zName, zDb);
116295 if( pIdx==0 ){
116297 if( pTab && !HasRowid(pTab) ) pIdx = sqlite3PrimaryKeyIndex(pTab);
116299 return pIdx;
116324 IndexSample *pSample; /* A slot in pIdx->aSample[] */
116339 Index *pIdx; /* Pointer to the index object */
116348 pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
116349 assert( pIdx==0 || pIdx->nSample==0 );
116350 if( pIdx==0 ) continue;
116351 assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );
116352 if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){
116353 nIdxCol = pIdx->nKeyCol;
116355 nIdxCol = pIdx->nColumn;
116357 pIdx->nSampleCol = nIdxCol;
116362 pIdx->aSample = sqlite3DbMallocZero(db, nByte);
116363 if( pIdx->aSample==0 ){
116367 pSpace = (tRowcnt*)&pIdx->aSample[nSample];
116368 pIdx->aAvgEq = pSpace; pSpace += nIdxCol;
116369 pIdx->pTable->tabFlags |= TF_HasStat4;
116371 pIdx->aSample[i].anEq = pSpace; pSpace += nIdxCol;
116372 pIdx->aSample[i].anLt = pSpace; pSpace += nIdxCol;
116373 pIdx->aSample[i].anDLt = pSpace; pSpace += nIdxCol;
116375 assert( ((u8*)pSpace)-nByte==(u8*)(pIdx->aSample) );
116390 Index *pIdx; /* Pointer to the index object */
116395 pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
116396 if( pIdx==0 ) continue;
116399 nCol = pIdx->nSampleCol;
116400 if( pIdx!=pPrevIdx ){
116402 pPrevIdx = pIdx;
116404 pSample = &pIdx->aSample[pIdx->nSample];
116424 pIdx->nSample++;
116491 Index *pIdx = sqliteHashData(i);
116492 pIdx->hasStat1 = 0;
116494 sqlite3DeleteIndexSamples(db, pIdx);
116495 pIdx->aSample = 0;
116518 Index *pIdx = sqliteHashData(i);
116519 if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
116530 Index *pIdx = sqliteHashData(i);
116531 sqlite3_free(pIdx->aiRowEst);
116532 pIdx->aiRowEst = 0;
118562 ** find the (first) offset of that column in index pIdx. Or return -1
118563 ** if column iCol is not used in index pIdx.
118565 SQLITE_PRIVATE i16 sqlite3TableColumnToIndex(Index *pIdx, i16 iCol){
118567 for(i=0; i<pIdx->nColumn; i++){
118568 if( iCol==pIdx->aiColumn[i] ) return i;
119092 Index *pIdx;
119093 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
119094 assert( pIdx->nKeyCol==1 && pIdx->onError!=OE_None );
119095 if( pIdx->aiColumn[0]==p->nCol-1 ){
119096 pIdx->uniqNotNull = 1;
119428 Index *pIdx;
119435 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
119436 assert( pIdx->nKeyCol==1 );
119437 if( pIdx->aiColumn[0]==i ){
119438 pIdx->azColl[0] = sqlite3ColumnColl(&p->aCol[i]);
119545 ** to the specified offset in the buffer and updates *pIdx to refer
119553 static void identPut(char *z, int *pIdx, char *zSignedIdent){
119556 i = *pIdx;
119573 *pIdx = i;
119649 static int resizeIndexObject(sqlite3 *db, Index *pIdx, int N){
119652 if( pIdx->nColumn>=N ) return SQLITE_OK;
119653 assert( pIdx->isResized==0 );
119657 memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn);
119658 pIdx->azColl = (const char**)zExtra;
119660 memcpy(zExtra, pIdx->aiRowLogEst, sizeof(LogEst)*(pIdx->nKeyCol+1));
119661 pIdx->aiRowLogEst = (LogEst*)zExtra;
119663 memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn);
119664 pIdx->aiColumn = (i16*)zExtra;
119666 memcpy(zExtra, pIdx->aSortOrder, pIdx->nColumn);
119667 pIdx->aSortOrder = (u8*)zExtra;
119668 pIdx->nColumn = N;
119669 pIdx->isResized = 1;
119690 static void estimateIndexWidth(Index *pIdx){
119693 const Column *aCol = pIdx->pTable->aCol;
119694 for(i=0; i<pIdx->nColumn; i++){
119695 i16 x = pIdx->aiColumn[i];
119696 assert( x<pIdx->pTable->nCol );
119697 wIndex += x<0 ? 1 : aCol[pIdx->aiColumn[i]].szEst;
119699 pIdx->szIdxRow = sqlite3LogEst(wIndex*4);
119716 ** Return true if any of the first nKey entries of index pIdx exactly
119718 ** PRIMARY KEY index. pIdx is an index on the same table. pIdx may
119721 ** The first nKey entries of pIdx are guaranteed to be ordinary columns,
119728 static int isDupColumn(Index *pIdx, int nKey, Index *pPk, int iCol){
119730 assert( nKey<=pIdx->nColumn );
119734 assert( pPk->pTable==pIdx->pTable );
119735 testcase( pPk==pIdx );
119739 assert( pIdx->aiColumn[i]>=0 || j>=0 );
119740 if( pIdx->aiColumn[i]==j
119741 && sqlite3StrICmp(pIdx->azColl[i], pPk->azColl[iCol])==0
119768 static void recomputeColumnsNotIndexed(Index *pIdx){
119771 Table *pTab = pIdx->pTable;
119772 for(j=pIdx->nColumn-1; j>=0; j--){
119773 int x = pIdx->aiColumn[j];
119780 pIdx->colNotIdxed = ~m;
119781 assert( (pIdx->colNotIdxed>>63)==1 ); /* See note-20221022-a */
119809 Index *pIdx;
119908 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
119910 if( IsPrimaryKeyIndex(pIdx) ) continue;
119912 if( !isDupColumn(pIdx, pIdx->nKeyCol, pPk, i) ){
119913 testcase( hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) );
119919 pIdx->nColumn = pIdx->nKeyCol;
119922 if( resizeIndexObject(db, pIdx, pIdx->nKeyCol+n) ) return;
119923 for(i=0, j=pIdx->nKeyCol; i<nPk; i++){
119924 if( !isDupColumn(pIdx, pIdx->nKeyCol, pPk, i) ){
119925 testcase( hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) );
119926 pIdx->aiColumn[j] = pPk->aiColumn[i];
119927 pIdx->azColl[j] = pPk->azColl[i];
119930 pIdx->bAscKeyBug = 1;
119935 assert( pIdx->nColumn>=pIdx->nKeyCol+n );
119936 assert( pIdx->nColumn>=j );
120098 Index *pIdx; /* An implied index of the table */
120236 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
120237 estimateIndexWidth(pIdx);
120707 Index *pIdx = sqliteHashData(pElem);
120708 if( pIdx->tnum==iFrom ){
120709 pIdx->tnum = iTo;
120772 Index *pIdx;
120778 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
120779 Pgno iIdx = pIdx->tnum;
120780 assert( pIdx->pSchema==pTab->pSchema );
121196 ** Generate code that will erase and refill index *pIdx. This is
121772 Index *pIdx;
121773 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
121775 assert( IsUniqueIndex(pIdx) );
121776 assert( pIdx->idxType!=SQLITE_IDXTYPE_APPDEF );
121779 if( pIdx->nKeyCol!=pIndex->nKeyCol ) continue;
121780 for(k=0; k<pIdx->nKeyCol; k++){
121783 assert( pIdx->aiColumn[k]>=0 );
121784 if( pIdx->aiColumn[k]!=pIndex->aiColumn[k] ) break;
121785 z1 = pIdx->azColl[k];
121789 if( k==pIdx->nKeyCol ){
121790 if( pIdx->onError!=pIndex->onError ){
121798 if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){
121802 if( pIdx->onError==OE_Default ){
121803 pIdx->onError = pIndex->onError;
121806 if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;
121986 SQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){
121989 LogEst *a = pIdx->aiRowLogEst;
121991 int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
121995 assert( !pIdx->hasStat1 );
122007 x = pIdx->pTable->nRowLogEst;
122010 pIdx->pTable->nRowLogEst = x = 99;
122012 if( pIdx->pPartIdxWhere!=0 ){ x -= 10; assert( 10==sqlite3LogEst(2) ); }
122018 for(i=nCopy+1; i<=pIdx->nKeyCol; i++){
122023 if( IsUniqueIndex(pIdx) ) a[pIdx->nKeyCol] = 0;
122107 ** returned. *pIdx is set to the index of the new array entry in this case.
122109 ** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains
122117 int *pIdx /* Write the index of a new slot here */
122120 sqlite3_int64 n = *pIdx = *pnEntry;
122125 *pIdx = -1;
122812 Index *pIdx /* The index that triggers the constraint */
122817 Table *pTab = pIdx->pTable;
122821 if( pIdx->aColExpr ){
122822 sqlite3_str_appendf(&errMsg, "index '%q'", pIdx->zName);
122824 for(j=0; j<pIdx->nKeyCol; j++){
122826 assert( pIdx->aiColumn[j]>=0 );
122827 zCol = pTab->aCol[pIdx->aiColumn[j]].zCnName;
122836 IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY
123001 SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
123003 int nCol = pIdx->nColumn;
123004 int nKey = pIdx->nKeyCol;
123007 if( pIdx->uniqNotNull ){
123015 const char *zColl = pIdx->azColl[i];
123018 pKey->aSortFlags[i] = pIdx->aSortOrder[i];
123023 if( pIdx->bNoQuery==0 ){
123031 pIdx->bNoQuery = 1;
123985 Index *pIdx; /* For looping over indices of the table */
124091 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){
124171 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
124172 assert( pIdx->pSchema==pTab->pSchema );
124173 if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
124174 sqlite3VdbeAddOp3(v, OP_Clear, pIdx->tnum, iDb, memCnt ? memCnt : -1);
124176 sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
124593 Index *pIdx; /* Current index */
124600 for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
124601 assert( iIdxCur+i!=iDataCur || pPk==pIdx );
124603 if( pIdx==pPk ) continue;
124605 VdbeModuleComment((v, "GenRowIdxDel for %s", pIdx->zName));
124606 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 1,
124609 pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn);
124612 pPrior = pIdx;
124618 ** regOut. The key with be for index pIdx which is an index on pTab.
124629 ** to that label if pIdx is a partial index that should be skipped.
124632 ** to false or null. If pIdx is not a partial index, *piPartIdxLabel
124639 ** computed into register regPrior. If the current pIdx index is generating
124640 ** its key into the same sequence of registers and if pPrior and pIdx share
124649 Index *pIdx, /* The index for which to generate a key */
124663 if( pIdx->pPartIdxWhere ){
124666 sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
124675 nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;
124680 && pPrior->aiColumn[j]==pIdx->aiColumn[j]
124686 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);
124687 if( pIdx->aiColumn[j]>=0 ){
127314 Index *pIdx = 0; /* Value to return via *ppIdx */
127353 for(pIdx=pParent->pIndex; pIdx; pIdx=pIdx->pNext){
127354 if( pIdx->nKeyCol==nCol && IsUniqueIndex(pIdx) && pIdx->pPartIdxWhere==0 ){
127355 /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number
127363 if( IsPrimaryKeyIndex(pIdx) ){
127377 i16 iCol = pIdx->aiColumn[i]; /* Index of column in parent tbl */
127388 if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;
127399 if( i==nCol ) break; /* pIdx is usable */
127404 if( !pIdx ){
127414 *ppIdx = pIdx;
127448 Index *pIdx, /* Unique index on parent key columns in pTab */
127483 if( pIdx==0 ){
127484 /* If pIdx is NULL, then the parent key is the INTEGER PRIMARY KEY
127518 sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);
127519 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
127542 iParent += sqlite3TableColumnToStorage(pIdx->pTable,
127543 pIdx->aiColumn[i]);
127544 assert( pIdx->aiColumn[i]>=0 );
127546 if( pIdx->aiColumn[i]==pTab->iPKey ){
127557 sqlite3IndexAffinityStr(pParse->db,pIdx), nCol);
127675 Index *pIdx, /* Index on parent covering the foreign key */
127677 int *aiCol, /* Map from pIdx cols to child table cols */
127689 assert( pIdx==0 || pIdx->pTable==pTab );
127690 assert( pIdx==0 || pIdx->nKeyCol==pFKey->nCol );
127691 assert( pIdx!=0 || pFKey->nCol==1 );
127692 assert( pIdx!=0 || HasRowid(pTab) );
127714 iCol = pIdx ? pIdx->aiColumn[i] : -1;
127748 assert( pIdx!=0 );
127749 for(i=0; i<pIdx->nKeyCol; i++){
127750 i16 iCol = pIdx->aiColumn[i];
128039 Index *pIdx = 0; /* Index on key columns in pTo */
128062 if( !pTo || sqlite3FkLocateIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){
128085 assert( pFKey->nCol==1 || (aiFree && pIdx) );
128097 assert( pIdx==0 || pIdx->aiColumn[i]>=0 );
128104 char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zCnName;
128121 fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1, bIgnore);
128132 fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1, bIgnore);
128141 Index *pIdx = 0; /* Foreign key index for pFKey */
128158 if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){
128175 fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1);
128179 fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1);
128226 Index *pIdx = 0;
128227 sqlite3FkLocateIndex(pParse, pTab, p, &pIdx, 0);
128228 if( pIdx ){
128229 for(i=0; i<pIdx->nKeyCol; i++){
128230 assert( pIdx->aiColumn[i]>=0 );
128231 mask |= COLUMN_MASK(pIdx->aiColumn[i]);
128352 Index *pIdx = 0; /* Parent key index for this FK */
128361 if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0;
128374 assert( pIdx!=0 || (pTab->iPKey>=0 && pTab->iPKey<pTab->nCol) );
128375 assert( pIdx==0 || pIdx->aiColumn[i]>=0 );
128377 pTab->aCol[pIdx ? pIdx->aiColumn[i] : pTab->iPKey].zCnName);
128657 ** pIdx. A column affinity string has one character for each column in
128675 SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){
128676 if( !pIdx->zColAff ){
128686 Table *pTab = pIdx->pTable;
128687 pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+1);
128688 if( !pIdx->zColAff ){
128692 for(n=0; n<pIdx->nColumn; n++){
128693 i16 x = pIdx->aiColumn[n];
128701 assert( pIdx->bHasExpr );
128702 assert( pIdx->aColExpr!=0 );
128703 aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);
128707 pIdx->zColAff[n] = aff;
128709 pIdx->zColAff[n] = 0;
128712 return pIdx->zColAff;
129297 Index *pIdx; /* For looping over indices of the table */
129657 for(i=0, pIdx=pTab->pIndex; i<nIdx; pIdx=pIdx->pNext, i++){
129658 assert( pIdx );
129660 pParse->nMem += pIdx->nColumn;
130131 Index *pIdx; /* The current Index */
130156 return pIter->u.lx.pIdx;
130172 pIter->u.lx.pIdx = pIter->u.lx.pIdx->pNext;
130173 return pIter->u.lx.pIdx;
130284 Index *pIdx; /* Pointer to one of the indices */
130293 Upsert *pUpsertClause = 0; /* The specific ON CONFLICT clause for pIdx */
130509 sIdxIter.u.lx.pIdx = pTab->pIndex;
130531 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){
130545 pIdx = pTab->pIndex;
130546 while( ALWAYS(pIdx!=0) && pIdx!=pTerm->pUpsertIdx ){
130547 pIdx = pIdx->pNext;
130552 sIdxIter.u.ax.aIdx[i].p = pIdx;
130556 for(jj=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, jj++){
130558 sIdxIter.u.ax.aIdx[i].p = pIdx;
130761 for(pIdx = indexIteratorFirst(&sIdxIter, &ix);
130762 pIdx;
130763 pIdx = indexIteratorNext(&sIdxIter, &ix)
130765 int regIdx; /* Range of registers hold conent for pIdx */
130773 pUpsertClause = sqlite3UpsertOfIndex(pUpsert, pIdx);
130783 VdbeNoopComment((v, "prep index %s", pIdx->zName));
130788 if( pIdx->pPartIdxWhere ){
130791 sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk,
130800 for(i=0; i<pIdx->nColumn; i++){
130801 int iField = pIdx->aiColumn[i];
130805 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
130807 VdbeComment((v, "%s column %d", pIdx->zName, i));
130819 sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
130820 VdbeComment((v, "for %s", pIdx->zName));
130822 if( pIdx->idxType==SQLITE_IDXTYPE_PRIMARYKEY ){
130823 sqlite3SetMakeRecordP5(v, pIdx->pTable);
130826 sqlite3VdbeReleaseRegisters(pParse, regIdx, pIdx->nColumn, 0, 0);
130832 if( isUpdate && pPk==pIdx && pkChng==0 ){
130838 onError = pIdx->onError;
130841 continue; /* pIdx is not a UNIQUE index */
130870 if( (ix==0 && pIdx->pNext==0) /* Condition 3 */
130871 && pPk==pIdx /* Condition 2 */
130887 regIdx, pIdx->nKeyCol); VdbeCoverage(v);
130890 regR = pIdx==pPk ? regIdx : sqlite3GetTempRange(pParse, nPkField);
130905 if( pIdx!=pPk ){
130908 x = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]);
130924 int regCmp = (IsPrimaryKeyIndex(pIdx) ? regIdx : regR);
130956 sqlite3UniqueConstraint(pParse, onError, pIdx);
130961 sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, pIdx, iIdxCur+ix);
130987 (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);
131003 if( pIdx->pPartIdxWhere ){
131035 sqlite3UniqueConstraint(pParse, OE_Abort, pIdx);
131166 Index *pIdx; /* An index being inserted or updated */
131178 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
131180 assert( pIdx->onError!=OE_Replace
131181 || pIdx->pNext==0
131182 || pIdx->pNext->onError==OE_Replace );
131184 if( pIdx->pPartIdxWhere ){
131189 if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
131198 pIdx->uniqNotNull ? pIdx->nKeyCol: pIdx->nColumn);
131255 Index *pIdx;
131279 for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
131281 assert( pIdx->pSchema==pTab->pSchema );
131282 if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
131287 sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb);
131288 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
131290 VdbeComment((v, "%s", pIdx->zName));
135551 Index *pIdx;
135563 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
135565 pIdx->zName,
135566 pIdx->szIdxRow,
135567 pIdx->aiRowLogEst[0],
135568 pIdx->hasStat1);
135577 Index *pIdx;
135579 pIdx = sqlite3FindIndex(db, zRight, zDb);
135580 if( pIdx==0 ){
135586 pIdx = sqlite3PrimaryKeyIndex(pTab);
135589 if( pIdx ){
135590 int iIdxDb = sqlite3SchemaToIndex(db, pIdx->pSchema);
135595 mx = pIdx->nColumn;
135599 mx = pIdx->nKeyCol;
135602 pTab = pIdx->pTable;
135606 i16 cnum = pIdx->aiColumn[i];
135611 pIdx->aSortOrder[i],
135612 pIdx->azColl[i],
135613 i<pIdx->nKeyCol);
135622 Index *pIdx;
135630 for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){
135634 pIdx->zName,
135635 IsUniqueIndex(pIdx),
135636 azOrigin[pIdx->idxType],
135637 pIdx->pPartIdxWhere!=0);
135752 Index *pIdx; /* Index in the parent table */
135787 pIdx = 0;
135789 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);
135791 if( pIdx==0 ){
135794 sqlite3VdbeAddOp3(v, OP_OpenRead, i, pIdx->tnum, iDb);
135795 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
135809 pIdx = 0;
135812 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
135830 if( pIdx ){
135832 sqlite3IndexAffinityStr(db,pIdx), pFK->nCol);
135960 Index *pIdx; /* An index on pTab */
135964 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; }
135975 Index *pIdx;
135978 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
135979 aRoot[++cnt] = pIdx->tnum;
136003 Index *pIdx, *pPk;
136028 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
136213 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
136216 if( pPk==pIdx ) continue;
136217 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
136219 pPrior = pIdx;
136223 pIdx->nColumn); VdbeCoverage(v);
136228 jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);
136235 if( IsUniqueIndex(pIdx) ){
136239 for(kk=0; kk<pIdx->nKeyCol; kk++){
136240 int iCol = pIdx->aiColumn[kk];
136250 pIdx->nKeyCol); VdbeCoverage(v);
136263 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
136264 if( pPk==pIdx ) continue;
136268 sqlite3VdbeLoadString(v, 4, pIdx->zName);
136586 Index *pIdx; /* An index of the table */
136612 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
136613 if( !pIdx->hasStat1 ){
143501 Index *pIdx;
143505 for(pIdx=pTab->pIndex;
143506 pIdx && sqlite3StrICmp(pIdx->zName, zIndexedBy);
143507 pIdx=pIdx->pNext
143509 if( !pIdx ){
143515 pFrom->u2.pIBIndex = pIdx;
144639 Index *pIdx /* Index used to optimize scan, or NULL */
144642 int bCover = (pIdx!=0 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pIdx)));
144646 bCover ? pIdx->zName : ""
145979 Index *pIdx; /* Iterator variable */
145998 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
145999 if( pIdx->bUnordered==0
146000 && pIdx->szIdxRow<pTab->szTabRow
146001 && pIdx->pPartIdxWhere==0
146002 && (!pBest || pIdx->szIdxRow<pBest->szIdxRow)
146004 pBest = pIdx;
147927 ** Check to see if column iCol of index pIdx references any of the
147938 Index *pIdx, /* The index to check */
147943 i16 iIdxCol = pIdx->aiColumn[iCol];
147949 assert( pIdx->aColExpr!=0 );
147950 assert( pIdx->aColExpr->a[iCol].pExpr!=0 );
147951 return sqlite3ExprReferencesUpdatedColumn(pIdx->aColExpr->a[iCol].pExpr,
147956 ** Check to see if index pIdx is a partial index whose conditional
147968 Index *pIdx, /* The index to check */
147972 if( pIdx->pPartIdxWhere==0 ) return 0;
147973 return sqlite3ExprReferencesUpdatedColumn(pIdx->pPartIdxWhere,
148139 Index *pIdx; /* For looping over indices */
148263 for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){
148264 if( pPk==pIdx ){
148412 for(nAllIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nAllIdx++){
148414 if( chngKey || hasFK>1 || pIdx==pPk
148415 || indexWhereClauseMightChange(pIdx,aXRef,chngRowid)
148418 pParse->nMem += pIdx->nColumn;
148421 for(i=0; i<pIdx->nKeyCol; i++){
148422 if( indexColumnIsBeingUpdated(pIdx, i, aXRef, chngRowid) ){
148424 pParse->nMem += pIdx->nColumn;
148425 if( onError==OE_Default && pIdx->onError==OE_Replace ){
149289 Index *pIdx; /* One of the indexes of pTab */
149342 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
149344 if( !IsUniqueIndex(pIdx) ) continue;
149345 if( pTarget->nExpr!=pIdx->nKeyCol ) continue;
149346 if( pIdx->pPartIdxWhere ){
149349 pIdx->pPartIdxWhere, iCursor)!=0 ){
149353 nn = pIdx->nKeyCol;
149356 sCol[0].u.zToken = (char*)pIdx->azColl[ii];
149357 if( pIdx->aiColumn[ii]==XN_EXPR ){
149358 assert( pIdx->aColExpr!=0 );
149359 assert( pIdx->aColExpr->nExpr>ii );
149360 assert( pIdx->bHasExpr );
149361 pExpr = pIdx->aColExpr->a[ii].pExpr;
149368 sCol[1].iColumn = pIdx->aiColumn[ii];
149386 pUpsert->pUpsertIdx = pIdx;
149421 ** a particular index pIdx, return a pointer to the particular ON CONFLICT
149425 SQLITE_PRIVATE Upsert *sqlite3UpsertOfIndex(Upsert *pUpsert, Index *pIdx){
149429 && pUpsert->pUpsertIdx!=pIdx
149439 ** If pIdx is NULL, then the UNIQUE constraint that failed was the IPK.
149441 ** currently points to the conflicting table row. Otherwise, if pIdx
149442 ** is not NULL, then pIdx is the constraint that failed and iCur is a
149449 Index *pIdx, /* The UNIQUE constraint that failed */
149450 int iCur /* Cursor for pIdx (or pTab if pIdx==NULL) */
149462 pUpsert = sqlite3UpsertOfIndex(pTop, pIdx);
149464 if( pIdx && iCur!=iDataCur ){
149479 k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]);
149481 VdbeComment((v, "%s.%s", pIdx->zName,
150783 Index *pIdx;
150800 pIdx = pNew->pIndex;
150801 if( pIdx ){
150802 assert( pIdx->pNext==0 );
150803 pTab->pIndex = pIdx;
150805 pIdx->pTable = pTab;
151382 int iIdxCur; /* The VDBE cursor used to access pIdx */
151819 Index *pIdx /* Must be compatible with this index, if not NULL */
151952 ** Return the name of the i-th column of the pIdx index.
151954 static const char *explainIndexColumnName(Index *pIdx, int i){
151955 i = pIdx->aiColumn[i];
151958 return pIdx->pTable->aCol[i].zCnName;
151971 Index *pIdx, /* Index to read column names from */
151985 sqlite3_str_appendall(pStr, explainIndexColumnName(pIdx, iTerm+i));
152081 Index *pIdx;
152084 pIdx = pLoop->u.btree.pIndex;
152086 if( !HasRowid(pItem->pTab) && IsPrimaryKeyIndex(pIdx) ){
152101 sqlite3_str_appendf(&str, zFmt, pIdx->zName);
152698 Index *pIdx; /* The index being used for this loop */
152711 pIdx = pLoop->u.btree.pIndex;
152712 assert( pIdx!=0 );
152720 zAff = sqlite3DbStrDup(pParse->db,sqlite3IndexAffinityStr(pParse->db,pIdx));
152729 VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
152739 testcase( pIdx->aiColumn[j]==XN_EXPR );
152740 VdbeComment((v, "%s", explainIndexColumnName(pIdx, j)));
152842 int iIdxCur; /* Cursor for the index, if pIdx!=0. Unused otherwise */
152843 Index *pIdx; /* The index used to access the table */
152854 assert( pHint->pIdx!=0 );
152857 && sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn)<0
152911 ** know because CCurHint.pIdx!=0) then transform the TK_COLUMN into
152923 }else if( pHint->pIdx!=0 ){
152925 pExpr->iColumn = sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn);
152967 sHint.pIdx = pLoop->u.btree.pIndex;
153026 if( sHint.pIdx!=0 ){
153040 (sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0,
153050 ** a rowid value just read from cursor iIdxCur, open on index pIdx. This
153076 Index *pIdx, /* Index scan is using */
153084 assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );
153092 Table *pTab = pIdx->pTable;
153096 for(i=0; i<pIdx->nColumn-1; i++){
153098 assert( pIdx->aiColumn[i]<pTab->nCol );
153099 x1 = pIdx->aiColumn[i];
153264 Index *pIdx = 0; /* Index used by loop (if any) */
153664 pIdx = pLoop->u.btree.pIndex;
153693 testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC );
153696 pLevel->iLikeRepCntr |= bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC);
153700 j = pIdx->aiColumn[nEq];
153701 if( (j>=0 && pIdx->pTable->aCol[j].notNull==0) || j==XN_EXPR ){
153734 if( (nEq<pIdx->nColumn && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC)) ){
153829 (pIdx->aiRowLogEst[0]+9)/10);
153958 /* pIdx is a covering index. No need to access the main table. */
153959 }else if( HasRowid(pIdx->pTable) ){
153960 codeDeferredSeek(pWInfo, pIdx, iCur, iIdxCur);
153962 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);
153965 k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[j]);
153980 if( pIdx->pPartIdxWhere ){
153981 whereApplyPartialIndexConstraints(pIdx->pPartIdxWhere, iCur, pWC);
153984 testcase( pIdx->pPartIdxWhere );
154006 if( omitTable ) pIdx = 0;
154376 ** iLoop==1: Code only expressions that are entirely covered by pIdx.
154383 iLoop = (pIdx ? 1 : 2);
154416 if( iLoop==1 && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){
155678 Index *pIdx;
155683 for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
155684 if( pIdx->aColExpr==0 ) continue;
155685 for(i=0; i<pIdx->nKeyCol; i++){
155686 if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
155687 assert( pIdx->bHasExpr );
155688 if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
156973 ** iCur. Or if pIdx!=0 then X is column iColumn of index pIdx. pIdx
156984 ** index pIdx.
156992 Index *pIdx /* Must be compatible with this index */
157004 if( pIdx ){
157006 iColumn = pIdx->aiColumn[j];
157007 if( iColumn==pIdx->pTable->iPKey ){
157010 pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;
157011 pScan->zCollName = pIdx->azColl[j];
157013 pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;
157014 pScan->zCollName = pIdx->azColl[j];
157027 ** where X is a reference to the iColumn of table iCur or of index pIdx
157028 ** if pIdx!=0 and <op> is one of the WO_xx operator codes specified by
157031 ** If pIdx!=0 then it must be one of the indexes of table iCur.
157032 ** Search for terms matching the iColumn-th column of pIdx
157056 Index *pIdx /* Must be compatible with this index, if not NULL */
157062 p = whereScanInit(&scan, pWC, iCur, iColumn, op, pIdx);
157079 ** of index pIdx.
157087 int iBase, /* Cursor for table associated with pIdx */
157088 Index *pIdx, /* Index to match column of */
157092 const char *zColl = pIdx->azColl[iCol];
157098 && p->iColumn==pIdx->aiColumn[iCol]
157112 ** Return TRUE if the iCol-th column of index pIdx is NOT NULL
157114 static int indexColumnNotNull(Index *pIdx, int iCol){
157116 assert( pIdx!=0 );
157117 assert( iCol>=0 && iCol<pIdx->nColumn );
157118 j = pIdx->aiColumn[iCol];
157120 return pIdx->pTable->aCol[j].notNull;
157144 Index *pIdx;
157179 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
157180 if( !IsUniqueIndex(pIdx) ) continue;
157181 if( pIdx->pPartIdxWhere ) continue;
157182 for(i=0; i<pIdx->nKeyCol; i++){
157183 if( 0==sqlite3WhereFindTerm(pWC, iBase, i, ~(Bitmask)0, WO_EQ, pIdx) ){
157184 if( findIndexCol(pParse, pDistinct, iBase, pIdx, i)<0 ) break;
157185 if( indexColumnNotNull(pIdx, i)==0 ) break;
157188 if( i==pIdx->nKeyCol ){
157380 Index *pIdx; /* Object describing the transient index */
157391 char *zNotUsed; /* Extra space on the end of pIdx */
157473 pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed);
157474 if( pIdx==0 ) goto end_auto_index_create;
157475 pLoop->u.btree.pIndex = pIdx;
157476 pIdx->zName = "auto-index";
157477 pIdx->pTable = pTable;
157492 pIdx->aiColumn[n] = pTerm->u.x.leftColumn;
157495 pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
157506 pIdx->aiColumn[n] = i;
157507 pIdx->azColl[n] = sqlite3StrBINARY;
157513 pIdx->aiColumn[n] = i;
157514 pIdx->azColl[n] = sqlite3StrBINARY;
157519 pIdx->aiColumn[n] = XN_ROWID;
157520 pIdx->azColl[n] = sqlite3StrBINARY;
157526 sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
157552 pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0
157670 Index *pIdx = pLoop->u.btree.pIndex;
157675 int iCol = pIdx->aiColumn[jj];
157676 assert( pIdx->pTable==pItem->pTab );
157677 sqlite3ExprCodeGetColumnOfTable(v, pIdx->pTable, iCur, iCol,r1+jj);
157985 Index *pIdx, /* Index to consider domain of */
157990 IndexSample *aSample = pIdx->aSample;
158004 assert( pIdx->nSample>0 );
158051 nField = MIN(pRec->nField, pIdx->nSample);
158053 iSample = pIdx->nSample * nField;
158094 assert( i<pIdx->nSample );
158101 /* Unless i==pIdx->nSample, indicating that pRec is larger than
158104 assert( i<=pIdx->nSample && i>=0 );
158106 assert( i==pIdx->nSample
158135 ** sample that is greater than pRec. Or, if i==pIdx->nSample then pRec
158138 if( i>=pIdx->nSample ){
158139 iUpper = pIdx->nRowEst0;
158155 aStat[1] = pIdx->aAvgEq[nField-1];
158192 SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){
158193 assert( iCol>=0 && iCol<pIdx->nColumn );
158194 if( !pIdx->zColAff ){
158195 if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB;
158197 assert( pIdx->zColAff[iCol]!=0 );
158198 return pIdx->zColAff[iCol];
159262 int iCur, /* Cursor open on pIdx */
159263 Index *pIdx, /* The index to be used for a inequality constraint */
159270 nCmp = MIN(nCmp, (pIdx->nColumn - nEq));
159294 || pLhs->iColumn!=pIdx->aiColumn[i+nEq]
159295 || pIdx->aSortOrder[i+nEq]!=pIdx->aSortOrder[nEq]
159302 idxaff = sqlite3TableColumnAffinity(pIdx->pTable, pLhs->iColumn);
159307 if( sqlite3StrICmp(pColl->zName, pIdx->azColl[i+nEq]) ) break;
159804 Index *pIdx; /* The index */
159812 ** make sure that column is covered by the index pCk->pIdx. We know that
159824 const Index *pIdx; /* The index of interest */
159830 pIdx = pWalk->u.pCovIdxCk->pIdx;
159831 aiColumn = pIdx->aiColumn;
159832 nColumn = pIdx->nColumn;
159842 ** pIdx is an index that covers all of the low-number columns used by
159845 ** of whether pIdx covers *all* columns in the query.
159847 ** Return 0 if pIdx is a covering index. Return non-zero if pIdx is
159848 ** not a covering index or if we are unable to determine if pIdx is a
159857 Index *pIdx, /* Index that is being tested */
159865 ** if pIdx is covering. Assume it is not. */
159868 for(i=0; i<pIdx->nColumn; i++){
159869 if( pIdx->aiColumn[i]>=BMS-1 ) break;
159871 if( i>=pIdx->nColumn ){
159872 /* pIdx does not index any columns greater than 62, but we know from
159877 ck.pIdx = pIdx;
161737 Index *pIdx;
161767 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
161770 if( !IsUniqueIndex(pIdx)
161771 || pIdx->pPartIdxWhere!=0
161772 || pIdx->nKeyCol>ArraySize(pLoop->aLTermSpace)
161774 opMask = pIdx->uniqNotNull ? (WO_EQ|WO_IS) : WO_EQ;
161775 for(j=0; j<pIdx->nKeyCol; j++){
161776 pTerm = whereScanInit(&scan, pWC, iCur, j, opMask, pIdx);
161782 if( j!=pIdx->nKeyCol ) continue;
161784 if( pIdx->isCovering || (pItem->colUsed & pIdx->colNotIdxed)==0 ){
161789 pLoop->u.btree.pIndex = pIdx;
162027 ** The index pIdx is used by a query and contains one or more expressions.
162028 ** In other words pIdx is an index on an expression. iIdxCur is the cursor
162039 Index *pIdx, /* The index-on-expression that contains the expressions */
162040 int iIdxCur, /* Cursor number for pIdx */
162046 assert( pIdx->bHasExpr );
162047 pTab = pIdx->pTable;
162048 for(i=0; i<pIdx->nColumn; i++){
162050 int j = pIdx->aiColumn[i];
162053 pExpr = pIdx->aColExpr->a[i].pExpr;
162074 p->zIdxName = pIdx->zName;
162837 Index *pIdx;
162842 && (pIdx = pLoop->u.btree.pIndex)->hasStat1
162844 && pIdx->aiRowLogEst[n]>=36
162976 Index *pIdx = 0;
163014 pIdx = pLoop->u.btree.pIndex;
163016 pIdx = pLevel->u.pCoveringIdx;
163018 if( pIdx
163021 if( pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable) ){
163026 if( pIdx->bHasExpr ){
163059 assert( pIdx->pTable==pTab );
163073 x = sqlite3TableColumnToIndex(pIdx, x);
209704 sqlite3_stmt *pIdx = pIter->pIdxIter;
209705 rc = sqlite3_bind_text(pIdx, 1, pIter->zTbl, -1, SQLITE_STATIC);
222648 ** for(rc = sqlite3Fts5ExprFirst(pExpr, pIdx, bDesc);
222656 static int sqlite3Fts5ExprFirst(Fts5Expr*, Fts5Index *pIdx, i64 iMin, int bDesc);
227845 ** Begin iterating through the set of documents in index pIdx matched by
227859 static int sqlite3Fts5ExprFirst(Fts5Expr *p, Fts5Index *pIdx, i64 iFirst, int bDesc){
227863 p->pIndex = pIdx;
234548 Fts5Index *pIdx;
240133 Fts5Index *pIdx = pCtx->pStorage->pIndex;
240139 return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken);