Lines Matching refs:pIdx

947   Index *pIdx,     /* Index whose column is being loaded */  in analyzeVdbeCommentIndexWithColumnName()  argument
951 assert( k>=0 && k<pIdx->nColumn ); in analyzeVdbeCommentIndexWithColumnName()
952 i = pIdx->aiColumn[k]; in analyzeVdbeCommentIndexWithColumnName()
954 VdbeComment((v,"%s.rowid",pIdx->zName)); in analyzeVdbeCommentIndexWithColumnName()
956 assert( pIdx->bHasExpr ); in analyzeVdbeCommentIndexWithColumnName()
957 VdbeComment((v,"%s.expr(%d)",pIdx->zName, k)); in analyzeVdbeCommentIndexWithColumnName()
959 VdbeComment((v,"%s.%s", pIdx->zName, pIdx->pTable->aCol[i].zCnName)); in analyzeVdbeCommentIndexWithColumnName()
979 Index *pIdx; /* An index to being analyzed */ in analyzeOneTable() local
1048 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ in analyzeOneTable()
1055 if( pOnlyIdx && pOnlyIdx!=pIdx ) continue; in analyzeOneTable()
1056 if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0; in analyzeOneTable()
1057 if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){ in analyzeOneTable()
1058 nCol = pIdx->nKeyCol; in analyzeOneTable()
1062 nCol = pIdx->nColumn; in analyzeOneTable()
1063 zIdxName = pIdx->zName; in analyzeOneTable()
1064 nColTest = pIdx->uniqNotNull ? pIdx->nKeyCol-1 : nCol-1; in analyzeOneTable()
1110 assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) ); in analyzeOneTable()
1111 sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb); in analyzeOneTable()
1112 sqlite3VdbeSetP4KeyInfo(pParse, pIdx); in analyzeOneTable()
1113 VdbeComment((v, "%s", pIdx->zName)); in analyzeOneTable()
1124 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regRowid); in analyzeOneTable()
1171 if( nColTest==1 && pIdx->nKeyCol==1 && IsUniqueIndex(pIdx) ){ in analyzeOneTable()
1179 char *pColl = (char*)sqlite3LocateCollSeq(pParse, pIdx->azColl[i]); in analyzeOneTable()
1182 analyzeVdbeCommentIndexWithColumnName(v,pIdx,i); in analyzeOneTable()
1203 analyzeVdbeCommentIndexWithColumnName(v,pIdx,i); in analyzeOneTable()
1222 Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable); in analyzeOneTable()
1226 k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[j]); in analyzeOneTable()
1227 assert( k>=0 && k<pIdx->nColumn ); in analyzeOneTable()
1229 analyzeVdbeCommentIndexWithColumnName(v,pIdx,k); in analyzeOneTable()
1291 sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i); in analyzeOneTable()
1406 Index *pIdx; in sqlite3Analyze() local
1434 if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){ in sqlite3Analyze()
1435 analyzeTable(pParse, pIdx->pTable, pIdx); in sqlite3Analyze()
1599 void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){ argument
1601 if( pIdx->aSample ){
1603 for(j=0; j<pIdx->nSample; j++){
1604 IndexSample *p = &pIdx->aSample[j];
1607 sqlite3DbFree(db, pIdx->aSample);
1610 pIdx->nSample = 0;
1611 pIdx->aSample = 0;
1615 UNUSED_PARAMETER(pIdx);
1624 static void initAvgEq(Index *pIdx){ argument
1625 if( pIdx ){
1626 IndexSample *aSample = pIdx->aSample;
1627 IndexSample *pFinal = &aSample[pIdx->nSample-1];
1630 if( pIdx->nSampleCol>1 ){
1635 nCol = pIdx->nSampleCol-1;
1636 pIdx->aAvgEq[nCol] = 1;
1639 int nSample = pIdx->nSample;
1647 if( !pIdx->aiRowEst || iCol>=pIdx->nKeyCol || pIdx->aiRowEst[iCol+1]==0 ){
1652 nRow = pIdx->aiRowEst[0];
1653 nDist100 = ((i64)100 * pIdx->aiRowEst[0]) / pIdx->aiRowEst[iCol+1];
1655 pIdx->nRowEst0 = nRow;
1662 if( i==(pIdx->nSample-1)
1674 pIdx->aAvgEq[iCol] = avgEq;
1688 Index *pIdx = sqlite3FindIndex(db, zName, zDb); local
1689 if( pIdx==0 ){
1691 if( pTab && !HasRowid(pTab) ) pIdx = sqlite3PrimaryKeyIndex(pTab);
1693 return pIdx;
1733 Index *pIdx; /* Pointer to the index object */ local
1742 pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
1743 assert( pIdx==0 || pIdx->nSample==0 );
1744 if( pIdx==0 ) continue;
1745 assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );
1746 if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){
1747 nIdxCol = pIdx->nKeyCol;
1749 nIdxCol = pIdx->nColumn;
1751 pIdx->nSampleCol = nIdxCol;
1756 pIdx->aSample = sqlite3DbMallocZero(db, nByte);
1757 if( pIdx->aSample==0 ){
1761 pSpace = (tRowcnt*)&pIdx->aSample[nSample];
1762 pIdx->aAvgEq = pSpace; pSpace += nIdxCol;
1763 pIdx->pTable->tabFlags |= TF_HasStat4;
1765 pIdx->aSample[i].anEq = pSpace; pSpace += nIdxCol;
1766 pIdx->aSample[i].anLt = pSpace; pSpace += nIdxCol;
1767 pIdx->aSample[i].anDLt = pSpace; pSpace += nIdxCol;
1769 assert( ((u8*)pSpace)-nByte==(u8*)(pIdx->aSample) );
1784 Index *pIdx; /* Pointer to the index object */ local
1789 pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);
1790 if( pIdx==0 ) continue;
1793 nCol = pIdx->nSampleCol;
1794 if( pIdx!=pPrevIdx ){
1796 pPrevIdx = pIdx;
1798 pSample = &pIdx->aSample[pIdx->nSample];
1818 pIdx->nSample++;
1885 Index *pIdx = sqliteHashData(i); local
1886 pIdx->hasStat1 = 0;
1888 sqlite3DeleteIndexSamples(db, pIdx);
1889 pIdx->aSample = 0;
1912 Index *pIdx = sqliteHashData(i); local
1913 if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
1924 Index *pIdx = sqliteHashData(i); local
1925 sqlite3_free(pIdx->aiRowEst);
1926 pIdx->aiRowEst = 0;